@squeed/flow-sdk 2.0.6 → 2.0.7

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/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var Zb=Object.create;var Jn=Object.defineProperty;var Yb=Object.getOwnPropertyDescriptor;var Xb=Object.getOwnPropertyNames;var Qb=Object.getPrototypeOf,ev=Object.prototype.hasOwnProperty;var rv=(e,t,r)=>t in e?Jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var tv=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xb(t))!ev.call(e,o)&&o!==r&&Jn(e,o,{get:()=>t[o],enumerable:!(n=Yb(t,o))||n.enumerable});return e};var Ne=(e,t,r)=>(r=e!=null?Zb(Qb(e)):{},tv(t||!e||!e.__esModule?Jn(r,"default",{value:e,enumerable:!0}):r,e));var Tr=(e,t,r)=>rv(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),B=require("@chakra-ui/react"),S=require("react"),Z=require("react-icons/pi"),py=require("@emotion/react"),nv=require("@emotion/styled"),ov=require("react-icons/tb"),Dt=require("react-dom"),iv=require("markdown-to-jsx/react"),gy=e=>e&&e.__esModule?e:{default:e},mn=gy(nv),av=gy(iv);function yy({edge:e,enabled:t,bounds:r,inside:n=[],threshold:o=80}){const[i,s]=S.useState(!1),[a,u]=S.useState(!1),c=S.useRef(n);return c.current=n,S.useEffect(()=>{if(!t)return;const l=()=>{const f=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');u(Array.from(f).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},d=new MutationObserver(l);return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",l,!0),l(),()=>{d.disconnect(),document.removeEventListener("toggle",l,!0)}},[t]),S.useEffect(()=>{const l=f=>{var m;const p=(m=r.current)==null?void 0:m.getBoundingClientRect();if(!p)return;const y=f.target instanceof Node?f.target:null,g=!!y&&c.current.some(w=>{var v;return(v=w.current)==null?void 0:v.contains(y)}),b=e==="bottom"?p.bottom-f.clientY:f.clientY-p.top,x=f.clientX>=p.left&&f.clientX<=p.right&&b>=0&&b<=o;s(g||x)},d=()=>s(!1);return document.addEventListener("pointermove",l,!0),document.addEventListener("pointerdown",l,!0),document.documentElement.addEventListener("pointerleave",d),()=>{document.removeEventListener("pointermove",l,!0),document.removeEventListener("pointerdown",l,!0),document.documentElement.removeEventListener("pointerleave",d)}},[e,r,o]),t&&(i||a)}const sv=py.keyframes`
1
+ "use strict";var Zb=Object.create;var Zn=Object.defineProperty;var Yb=Object.getOwnPropertyDescriptor;var Xb=Object.getOwnPropertyNames;var Qb=Object.getPrototypeOf,ev=Object.prototype.hasOwnProperty;var rv=(e,t,r)=>t in e?Zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var tv=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xb(t))!ev.call(e,o)&&o!==r&&Zn(e,o,{get:()=>t[o],enumerable:!(n=Yb(t,o))||n.enumerable});return e};var Ne=(e,t,r)=>(r=e!=null?Zb(Qb(e)):{},tv(t||!e||!e.__esModule?Zn(r,"default",{value:e,enumerable:!0}):r,e));var Tr=(e,t,r)=>rv(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),B=require("@chakra-ui/react"),S=require("react"),Z=require("react-icons/pi"),py=require("@emotion/react"),nv=require("@emotion/styled"),ov=require("react-icons/tb"),Dt=require("react-dom"),iv=require("markdown-to-jsx/react"),gy=e=>e&&e.__esModule?e:{default:e},bn=gy(nv),av=gy(iv);function yy({edge:e,enabled:t,bounds:r,inside:n=[],threshold:o=80}){const[i,s]=S.useState(!1),[a,u]=S.useState(!1),c=S.useRef(n);return c.current=n,S.useEffect(()=>{if(!t)return;const l=()=>{const f=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');u(Array.from(f).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},d=new MutationObserver(l);return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",l,!0),l(),()=>{d.disconnect(),document.removeEventListener("toggle",l,!0)}},[t]),S.useEffect(()=>{const l=f=>{var m;const p=(m=r.current)==null?void 0:m.getBoundingClientRect();if(!p)return;const y=f.target instanceof Node?f.target:null,g=!!y&&c.current.some(w=>{var v;return(v=w.current)==null?void 0:v.contains(y)}),b=e==="bottom"?p.bottom-f.clientY:f.clientY-p.top,x=f.clientX>=p.left&&f.clientX<=p.right&&b>=0&&b<=o;s(g||x)},d=()=>s(!1);return document.addEventListener("pointermove",l,!0),document.addEventListener("pointerdown",l,!0),document.documentElement.addEventListener("pointerleave",d),()=>{document.removeEventListener("pointermove",l,!0),document.removeEventListener("pointerdown",l,!0),document.documentElement.removeEventListener("pointerleave",d)}},[e,r,o]),t&&(i||a)}const sv=py.keyframes`
2
2
  0%, 100% { box-shadow: var(--flow-rest-shadow); }
3
3
  25%, 50% { box-shadow: var(--flow-hover-shadow); }
4
4
  `,cv=py.keyframes`
5
5
  from { box-shadow: var(--flow-start-shadow); }
6
6
  to { box-shadow: var(--flow-rest-shadow); }
7
- `;function my(e,t=!0,r="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${t?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)":{[r]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${sv} 1200ms steps(10, end) 600ms`:"none"}}}}}}function zr(e,t){const{boxShadow:r,css:n}=my(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...o,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${cv} 600ms steps(5, end)`}}}}}const by=S.createContext(null),vy=S.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Ur(){return S.useContext(vy)}function Ie(){const e=S.useContext(by);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function xy({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=S.useMemo(()=>{var Be,rr,De;const oe=new Map;for(const Q of r)(Be=Q.data)!=null&&Be.id&&oe.set(Q.data.id,Q);const We=new Map;for(const Q of n)(rr=Q.data)!=null&&rr.id&&We.set(Q.data.id,Q);const Qe=new Set;for(const Q of r)(De=Q.data)!=null&&De.parent&&Qe.add(Q.data.parent);return{nodeById:oe,edgeById:We,parentIds:Qe}},[r,n]),s=S.useRef(null),[a,u]=S.useState([]),[c,l]=S.useState(null),[d,f]=S.useState(!0),[p,y]=S.useState(!1),[g,b]=S.useState(!0),[x,m]=S.useState(!1),[w,v]=S.useState(!1),[C,_]=S.useState(!0),[R,T]=S.useState(!1),[A,k]=S.useState("auto"),[E,j]=S.useState(!1),M=e.compactPropertyLayout??E,[I,q]=S.useState({}),O=e.nodeViewModes??I,V=[...i.nodeById.values()].filter(oe=>{var We;return i.parentIds.has(oe.data.id)||((We=oe.data.config)==null?void 0:We.parentContainer)||oe.data.type==="objectView"||oe.data.type==="arrayView"}),W=!!V.length&&V.every(oe=>{var We,Qe,Be;return i.parentIds.has(oe.data.id)||(We=oe.data.config)!=null&&We.parentContainer?!!((Qe=oe.data.config)!=null&&Qe.collapsed):O[oe.data.id]==="icon-label"||((Be=oe.data.config)==null?void 0:Be.labelBelow)&&O[oe.data.id]!=="properties"}),[re,Y]=S.useState("normal"),[he,me]=S.useState(),J=e.edgeRadius??he,N=J!==void 0&&Number.isFinite(J)?Math.min(500,Math.max(0,J)):void 0,[L,G]=S.useState(),D=e.spacing??re,ne=typeof D=="number"?Number.isFinite(D)?Math.min(2,Math.max(.5,D)):1:D==="compact"?.5:D==="spacious"?2:1,ue=e.backgroundVariant??L??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[X,U]=S.useState(),K=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:X,[te,ce]=S.useState("blue.500"),[de,Ae]=S.useState(!1),ge=S.useRef(t);ge.current=t;const Ke=S.useMemo(()=>{const oe=We=>(...Qe)=>{var Be,rr;return(rr=(Be=ge.current)==null?void 0:Be[We])==null?void 0:rr.call(Be,...Qe)};return{onNodeSelect:oe("onNodeSelect"),onBackgroundClick:oe("onBackgroundClick"),onNodeDeselect:oe("onNodeDeselect"),onNodeDoubleClick:oe("onNodeDoubleClick"),onNodeViewToggle:oe("onNodeViewToggle"),onNodeTypeViewChange:oe("onNodeTypeViewChange"),onNodeCreate:oe("onNodeCreate"),onNodeCreateRequest:oe("onNodeCreateRequest"),onNodeDelete:oe("onNodeDelete"),onNodeLabelChange:oe("onNodeLabelChange"),onNodeContentChange:oe("onNodeContentChange"),onNodeCollapse:oe("onNodeCollapse"),onNodeColorChange:oe("onNodeColorChange"),onNodeBorderColorChange:oe("onNodeBorderColorChange"),onNodeBorderStyleChange:oe("onNodeBorderStyleChange"),onNodeBorderWidthChange:oe("onNodeBorderWidthChange"),onNodeBorderRadiusChange:oe("onNodeBorderRadiusChange"),onNodeIconChange:oe("onNodeIconChange"),onNodeOutlineChange:oe("onNodeOutlineChange"),onNodeAnimationChange:oe("onNodeAnimationChange"),onNodeAnimationVariantChange:oe("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:oe("onEdgeAnimationVariantChange"),onNodeHoverAction:oe("onNodeHoverAction"),onEdgeCreate:oe("onEdgeCreate"),onEdgeSelect:oe("onEdgeSelect"),onEdgeDeselect:oe("onEdgeDeselect"),onEdgeRemove:oe("onEdgeRemove"),onEdgeDelete:oe("onEdgeDelete"),onEdgeColorChange:oe("onEdgeColorChange"),onEdgeTypeChange:oe("onEdgeTypeChange"),onEdgeIconChange:oe("onEdgeIconChange"),onEdgeLabelChange:oe("onEdgeLabelChange"),onEdgeStyleChange:oe("onEdgeStyleChange"),onViewportChange:oe("onViewportChange"),onDirectionChange:oe("onDirectionChange"),onThemeColorChange:oe("onThemeColorChange"),onSpacingChange:oe("onSpacingChange"),onEdgeRadiusChange:oe("onEdgeRadiusChange"),onBackgroundVariantChange:oe("onBackgroundVariantChange"),onEdgeModeChange:oe("onEdgeModeChange"),onCompactPropertyLayoutChange:oe("onCompactPropertyLayoutChange"),onWorkflowContractChange:oe("onWorkflowContractChange"),onArrayModeChange:oe("onArrayModeChange"),onInit:oe("onInit"),onLayoutComplete:oe("onLayoutComplete"),onJsonChange:oe("onJsonChange")}},[]),Oe=e.themeColor||te,Le=e.edgeColor||"",er=e.colorMode||"light",Ve=e.direction||"LR",$e=e.nodeAlignment??"center",xe=e.edgeMode==="workflow"?"nodes":e.edgeMode??A,Me=e.readOnly??!1,Fe=JSON.stringify(e.parentNodeStyle??null),nr=S.useMemo(()=>e.parentNodeStyle,[Fe]),Ze=e.isZoomMode!==void 0?e.isZoomMode:d,Ye=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,fr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:x,wr=e.isDragMode!==void 0?e.isDragMode:g,we=S.useRef(e);we.current=e;const ar=S.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 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 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 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}}),[]),sr=S.useCallback((oe,We)=>{var Qe;if(We!=="default"&&We!=="properties"&&We!=="icon-label")throw new Error("Unknown node view mode.");q(Be=>Be[oe]===We?Be:{...Be,[oe]:We}),(Qe=t.onNodeViewModeChange)==null||Qe.call(t,oe,We)},[t.onNodeViewModeChange]),Ct=S.useMemo(()=>({allNodesIconLabel:W,setAllNodesIconLabel:oe=>{var We,Qe,Be,rr;if(!oe)for(const[De,Q]of Object.entries(O))Q==="icon-label"&&!i.nodeById.has(De)&&sr(De,"default");for(const De of V)i.parentIds.has(De.data.id)||(We=De.data.config)!=null&&We.parentContainer?!Me&&!!((Qe=De.data.config)!=null&&Qe.collapsed)!==oe&&((Be=t.onNodeCollapse)==null||Be.call(t,De.data.id,oe)):sr(De.data.id,oe?"icon-label":"default");(rr=t.onAllNodesIconLabelChange)==null||rr.call(t,oe)},nodeViewModes:O,setNodeViewMode:sr,spacing:ne,setSpacing:Y,edgeRadius:N,setEdgeRadius:me,backgroundVariant:ue,setBackgroundVariant:G,themeColor:Oe,setThemeColor:ce,backgroundSelected:de,setBackgroundSelected:Ae,edgeColor:Le,colorMode:er,direction:Ve,nodeAlignment:$e,edgeMode:xe,setEdgeMode:k,compactPropertyLayout:M,setCompactPropertyLayout:j,workflowContract:K,setWorkflowContract:U,parentNodeStyle:nr,selectedNodeIds:a,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Ze,setIsZoomMode:f,isMultiSelectMode:Ye,setIsMultiSelectMode:y,isDragMode:wr,setIsDragMode:b,isEdgeHandlesEnabled:fr,setIsEdgeHandlesEnabled:m,isArrayNodeMode:w,setIsArrayNodeMode:v,isPinned:C,setIsPinned:_,isPerformanceMode:R,setIsPerformanceMode:T,engineRef:s,callbacks:Ke,config:ar,readOnly:Me}),[W,i,sr,t.onNodeCollapse,t.onAllNodesIconLabelChange,O,t.onNodeViewModeChange,Oe,ne,ue,N,e.backgroundColor,de,Le,er,Ve,$e,xe,K,nr,a,c,Ze,Ye,wr,fr,w,C,R,Me,e.edgeHandles,e.edgeType,e.edgeReveal,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,M,Ke,ar]);return h.jsx(by.Provider,{value:Ct,children:h.jsx(vy.Provider,{value:i,children:o})})}function dn(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,s=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),s=Math.max(0,Math.floor(s*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+s).toString(16).slice(1).toUpperCase()}function dl(e,t,r){const n=a=>{const u=/^#?([0-9a-f]{6})$/i.exec((a==null?void 0:a.trim())??"");return u?parseInt(u[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const s=a=>Math.round((o>>a&255)*(1-r)+(i>>a&255)*r);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const jr=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:dn(e,.1),border:dn(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"},wy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:dn(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},fl={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"}},fe=(e,t)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const a=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(a&&a!=="")return a}catch{}const[n,o]=e.split(".");return n&&o&&((i=fl[n])!=null&&i[Number(o)])?fl[n][Number(o)]:`var(--chakra-colors-${r})`};function or(e,t,r){return e?r:t}function Xt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=wy(e),n=jr(t).background,o=jr(t).highlight,i=jr(t).border,s=jr(t).property,a=jr(t).property;let u=jr(t).background,c=jr(t).highlight;return u=e==="transparent"?e:fe(u)+50,c=e==="transparent"?e:fe(c)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:s,propertyColor:a,secondary:r,bgColorFaint:u,highlightColorFaint:c}}function He(e=null){const{colorMode:t}=Ie(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=or(n,"white","gray.900"),i=or(n,"gray.100","gray.800"),s=or(n,"gray.200","blackAlpha.400"),a=or(n,"gray.200","blackAlpha.600"),u=or(n,"gray.500","gray.700"),c=or(n,"gray.700","gray.700"),l=or(n,"gray.900","gray.900"),d=or(n,"gray.400","gray.500"),f=or(n,"gray.400","gray.500"),p=or(n,"gray.900","gray.200"),y=or(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),g=or(n,"gray.900","gray.200"),b=or(n,e&&"#000000",e||"#ffffff"),x=or(n,e||"#ffffff",e?"#000000":"#ffffff"),m=c,w=or(n,"gray.300","gray.800"),v=or(n,"white","blackAlpha.400"),C=or(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:s,darkBackgroundSecondary:a,border:u,darkColor:l,backgroundWhiteColor:v,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:g,moreIconColor:m,colorText:p,themedColorText:y,logoColor:b,logoColorSecondary:x,darkColorActive:w,greenColor:C}}var jt=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(jt||{});const zt=["","icon-label","object","text"];var uv=typeof global=="object"&&global&&global.Object===Object&&global,lv=typeof self=="object"&&self&&self.Object===Object&&self,dv=uv||lv||Function("return this")(),ht=dv.Symbol,Cy=Object.prototype,fv=Cy.hasOwnProperty,hv=Cy.toString,St=ht?ht.toStringTag:void 0;function pv(e){var t=fv.call(e,St),r=e[St];try{e[St]=void 0;var n=!0}catch{}var o=hv.call(e);return n&&(t?e[St]=r:delete e[St]),o}var gv=Object.prototype,yv=gv.toString;function mv(e){return yv.call(e)}var bv="[object Null]",vv="[object Undefined]",hl=ht?ht.toStringTag:void 0;function xv(e){return e==null?e===void 0?vv:bv:hl&&hl in Object(e)?pv(e):mv(e)}function wv(e){return e!=null&&typeof e=="object"}var Cv="[object Symbol]";function _v(e){return typeof e=="symbol"||wv(e)&&xv(e)==Cv}function Sv(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Pe=Array.isArray,pl=ht?ht.prototype:void 0,gl=pl?pl.toString:void 0;function _y(e){if(typeof e=="string")return e;if(Pe(e))return Sv(e,_y)+"";if(_v(e))return gl?gl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ju(e){return e==null?"":_y(e)}function Ev(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}function jv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:Ev(e,t,r)}var kv="\\ud800-\\udfff",Rv="\\u0300-\\u036f",Pv="\\ufe20-\\ufe2f",Av="\\u20d0-\\u20ff",Tv=Rv+Pv+Av,Ov="\\ufe0e\\ufe0f",Iv="\\u200d",Mv=RegExp("["+Iv+kv+Tv+Ov+"]");function Sy(e){return Mv.test(e)}function qv(e){return e.split("")}var Ey="\\ud800-\\udfff",Nv="\\u0300-\\u036f",$v="\\ufe20-\\ufe2f",Lv="\\u20d0-\\u20ff",Fv=Nv+$v+Lv,Bv="\\ufe0e\\ufe0f",Dv="["+Ey+"]",bu="["+Fv+"]",vu="\\ud83c[\\udffb-\\udfff]",zv="(?:"+bu+"|"+vu+")",jy="[^"+Ey+"]",ky="(?:\\ud83c[\\udde6-\\uddff]){2}",Ry="[\\ud800-\\udbff][\\udc00-\\udfff]",Vv="\\u200d",Py=zv+"?",Ay="["+Bv+"]?",Wv="(?:"+Vv+"(?:"+[jy,ky,Ry].join("|")+")"+Ay+Py+")*",Gv=Ay+Py+Wv,Uv="(?:"+[jy+bu+"?",bu,ky,Ry,Dv].join("|")+")",Hv=RegExp(vu+"(?="+vu+")|"+Uv+Gv,"g");function Kv(e){return e.match(Hv)||[]}function Jv(e){return Sy(e)?Kv(e):qv(e)}function Zv(e){return function(t){t=ju(t);var r=Sy(t)?Jv(t):void 0,n=r?r[0]:t.charAt(0),o=r?jv(r,1).join(""):t.slice(1);return n[e]()+o}}var Yv=Zv("toUpperCase");function Xv(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;)r=t(r,e[o],o,e);return r}function Qv(e){return function(t){return e==null?void 0:e[t]}}var ex={À:"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"},rx=Qv(ex),tx=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,nx="\\u0300-\\u036f",ox="\\ufe20-\\ufe2f",ix="\\u20d0-\\u20ff",ax=nx+ox+ix,sx="["+ax+"]",cx=RegExp(sx,"g");function ux(e){return e=ju(e),e&&e.replace(tx,rx).replace(cx,"")}var lx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function dx(e){return e.match(lx)||[]}var fx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function hx(e){return fx.test(e)}var Ty="\\ud800-\\udfff",px="\\u0300-\\u036f",gx="\\ufe20-\\ufe2f",yx="\\u20d0-\\u20ff",mx=px+gx+yx,Oy="\\u2700-\\u27bf",Iy="a-z\\xdf-\\xf6\\xf8-\\xff",bx="\\xac\\xb1\\xd7\\xf7",vx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",xx="\\u2000-\\u206f",wx=" \\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",My="A-Z\\xc0-\\xd6\\xd8-\\xde",Cx="\\ufe0e\\ufe0f",qy=bx+vx+xx+wx,Ny="['’]",yl="["+qy+"]",_x="["+mx+"]",$y="\\d+",Sx="["+Oy+"]",Ly="["+Iy+"]",Fy="[^"+Ty+qy+$y+Oy+Iy+My+"]",Ex="\\ud83c[\\udffb-\\udfff]",jx="(?:"+_x+"|"+Ex+")",kx="[^"+Ty+"]",By="(?:\\ud83c[\\udde6-\\uddff]){2}",Dy="[\\ud800-\\udbff][\\udc00-\\udfff]",st="["+My+"]",Rx="\\u200d",ml="(?:"+Ly+"|"+Fy+")",Px="(?:"+st+"|"+Fy+")",bl="(?:"+Ny+"(?:d|ll|m|re|s|t|ve))?",vl="(?:"+Ny+"(?:D|LL|M|RE|S|T|VE))?",zy=jx+"?",Vy="["+Cx+"]?",Ax="(?:"+Rx+"(?:"+[kx,By,Dy].join("|")+")"+Vy+zy+")*",Tx="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ox="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ix=Vy+zy+Ax,Mx="(?:"+[Sx,By,Dy].join("|")+")"+Ix,qx=RegExp([st+"?"+Ly+"+"+bl+"(?="+[yl,st,"$"].join("|")+")",Px+"+"+vl+"(?="+[yl,st+ml,"$"].join("|")+")",st+"?"+ml+"+"+bl,st+"+"+vl,Ox,Tx,$y,Mx].join("|"),"g");function Nx(e){return e.match(qx)||[]}function $x(e,t,r){return e=ju(e),t=t,t===void 0?hx(e)?Nx(e):dx(e):e.match(t)||[]}var Lx="['’]",Fx=RegExp(Lx,"g");function Bx(e){return function(t){return Xv($x(ux(t).replace(Fx,"")),e,"")}}var Cr=Bx(function(e,t,r){return e+(r?" ":"")+Yv(t)});function Ee({label:e,children:t}){const r=S.cloneElement(t,{title:t.props.title??e});if(!B.Tooltip.Root){const n=B.Tooltip;return h.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return h.jsxs(B.Tooltip.Root,{positioning:{placement:"top"},children:[h.jsx(B.Tooltip.Trigger,{asChild:!0,children:r}),h.jsx(B.Portal,{children:h.jsx(B.Tooltip.Positioner,{children:h.jsx(B.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Mt(){const{border:e}=He();return h.jsx(B.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:e})}function Ir({children:e,value:t,onValueChange:r,disabled:n,style:o,title:i,icon:s,popupContent:a,labelCase:u="title","aria-label":c}){var E;const{colorMode:l}=Ie(),{background:d,border:f,colorText:p,colorActive:y,colorInactive:g}=He(),b=l==="dark",x=S.useId(),m=S.useRef(null),w=S.useRef(null),[v,C]=S.useState(!1);S.useEffect(()=>{const j=w.current;j.setAttribute("popover","auto");const M=I=>C(I.newState==="open");return j.addEventListener("toggle",M),()=>j.removeEventListener("toggle",M)},[]);const _=S.Children.toArray(e).filter(S.isValidElement).map(j=>{const M=j.props;return{value:String(M.value),label:typeof M.children=="string"&&u==="title"?Cr(M.children):M.children,disabled:M.disabled}}),R=()=>{var j;return(j=w.current)==null?void 0:j.hidePopover()},T=()=>{var V,W,re,Y;const j=(V=m.current)==null?void 0:V.getBoundingClientRect(),M=w.current;if(!j||!M)return;const q=((Y=(re=(W=m.current)==null?void 0:W.closest("[data-flow-toolbar-scroll]"))==null?void 0:re.parentElement)==null?void 0:Y.getBoundingClientRect())??j;M.style.maxHeight=`${Math.max(60,Math.max(q.top-40,window.innerHeight-q.bottom-40))}px`;const O=M.getBoundingClientRect();M.style.left=`${Math.max(12,Math.min(j.right-O.width,window.innerWidth-O.width-12))}px`,M.style.top=`${Math.max(12,q.top>=O.height+36?q.top-O.height-24:Math.min(q.bottom+24,window.innerHeight-O.height-12))}px`},A=()=>{var I,q,O,V,W,re;if(n)return;if((I=w.current)==null||I.showPopover(),T(),a){(O=(q=w.current)==null?void 0:q.querySelector("input"))==null||O.focus({preventScroll:!0});return}const j=(V=w.current)==null?void 0:V.querySelectorAll('[role="option"]:not(:disabled)');(re=((W=w.current)==null?void 0:W.querySelector('[aria-selected="true"]:not(:disabled)'))??(j==null?void 0:j[0]))==null||re.focus()};S.useEffect(()=>{if(v){if(n){R();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[v,n]);const k=`var(--chakra-colors-${d.replace(".","-")})`;return h.jsxs(h.Fragment,{children:[h.jsx(Ee,{label:i??c,children:h.jsx(B.chakra.button,{ref:m,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":c,title:i??c,"aria-haspopup":a?"dialog":"listbox","aria-expanded":v,"aria-controls":x,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?g:p,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:o,onClick:()=>v?R():A(),onKeyDown:j=>{["ArrowDown","ArrowUp"].includes(j.key)&&(j.preventDefault(),A())},children:s??h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((E=_.find(j=>j.value===t))==null?void 0:E.label)??t}),h.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),h.jsx(B.chakra.div,{ref:w,id:x,role:a?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:d,color:p,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},...zr(k,`var(--chakra-colors-${(b?f:"gray.300").replace(".","-")})`)},onKeyDown:j=>{var q,O,V;if(a&&!["Escape","Tab"].includes(j.key))return;const M=[...j.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')],I=M.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(j.key)){j.preventDefault();const W=j.key==="Home"?0:j.key==="End"?M.length-1:(I+(j.key==="ArrowDown"?1:-1)+M.length)%M.length;(q=M[W])==null||q.focus()}else j.key==="Escape"||j.key==="Tab"?(j.key==="Escape"&&(j.preventDefault(),j.stopPropagation()),R(),(O=m.current)==null||O.focus()):j.key.length===1&&j.key!==" "&&((V=M.find((W,re)=>{var Y;return re>I&&((Y=W.textContent)==null?void 0:Y.toLowerCase().startsWith(j.key.toLowerCase()))}))==null||V.focus())},children:a??_.map(j=>h.jsxs(B.chakra.button,{type:"button",role:"option","aria-selected":j.value===t,disabled:j.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",borderRadius:"30px",fontSize:"sm",textAlign:"left",bg:"transparent",color:p,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var M;R(),(M=m.current)==null||M.focus(),r(j.value)},children:[h.jsx("span",{style:{flex:1},children:j.label}),h.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${y.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:j.value===t?"visible":"hidden"}})]},j.value))})]})}const be=S.forwardRef(function({icon:t,...r},n){const{colorMode:o}=Ie();return h.jsx(B.IconButton,{ref:n,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:r.title??r["aria-label"],...r,children:t})}),gt=S.forwardRef(function(t,r){const{themeColor:n}=Ie();return h.jsx(Ee,{label:"Close",children:h.jsx(be,{ref:r,size:"sm",variant:"ghost",color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:h.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})});function ku({label:e,icon:t,checked:r,onChange:n,disabled:o}){const{themeColor:i,readOnly:s}=Ie(),{colorInactive:a}=He();return h.jsx(Ee,{label:e,children:h.jsx(be,{"aria-label":e,"aria-pressed":r,icon:h.jsxs(h.Fragment,{children:[t,h.jsx(B.Text,{as:"span",fontSize:"xs",fontWeight:"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?i:a,disabled:o||s,onClick:()=>n(!r)})})}function Wy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Ie();return h.jsx(ku,{label:e,checked:t,icon:h.jsx(B.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:o=>{var i;r(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const Dx=mn.default.input`
7
+ `;function my(e,t=!0,r="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${t?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)":{[r]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${sv} 1200ms steps(10, end) 600ms`:"none"}}}}}}function zr(e,t){const{boxShadow:r,css:n}=my(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...o,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${cv} 600ms steps(5, end)`}}}}}const by=S.createContext(null),vy=S.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Ur(){return S.useContext(vy)}function Ie(){const e=S.useContext(by);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function xy({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=S.useMemo(()=>{var Be,rr,De;const oe=new Map;for(const Q of r)(Be=Q.data)!=null&&Be.id&&oe.set(Q.data.id,Q);const We=new Map;for(const Q of n)(rr=Q.data)!=null&&rr.id&&We.set(Q.data.id,Q);const Qe=new Set;for(const Q of r)(De=Q.data)!=null&&De.parent&&Qe.add(Q.data.parent);return{nodeById:oe,edgeById:We,parentIds:Qe}},[r,n]),s=S.useRef(null),[a,u]=S.useState([]),[c,l]=S.useState(null),[d,f]=S.useState(!0),[p,y]=S.useState(!1),[g,b]=S.useState(!0),[x,m]=S.useState(!1),[w,v]=S.useState(!1),[C,_]=S.useState(!0),[R,T]=S.useState(!1),[A,k]=S.useState("auto"),[E,j]=S.useState(!1),M=e.compactPropertyLayout??E,[I,q]=S.useState({}),O=e.nodeViewModes??I,V=[...i.nodeById.values()].filter(oe=>{var We;return i.parentIds.has(oe.data.id)||((We=oe.data.config)==null?void 0:We.parentContainer)||oe.data.type==="objectView"||oe.data.type==="arrayView"}),W=!!V.length&&V.every(oe=>{var We,Qe,Be;return i.parentIds.has(oe.data.id)||(We=oe.data.config)!=null&&We.parentContainer?!!((Qe=oe.data.config)!=null&&Qe.collapsed):O[oe.data.id]==="icon-label"||((Be=oe.data.config)==null?void 0:Be.labelBelow)&&O[oe.data.id]!=="properties"}),[re,Y]=S.useState("normal"),[he,me]=S.useState(),J=e.edgeRadius??he,N=J!==void 0&&Number.isFinite(J)?Math.min(500,Math.max(0,J)):void 0,[L,G]=S.useState(),D=e.spacing??re,ne=typeof D=="number"?Number.isFinite(D)?Math.min(2,Math.max(.5,D)):1:D==="compact"?.5:D==="spacious"?2:1,ue=e.backgroundVariant??L??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[X,U]=S.useState(),K=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:X,[te,ce]=S.useState("blue.500"),[de,Ae]=S.useState(!1),ge=S.useRef(t);ge.current=t;const Ke=S.useMemo(()=>{const oe=We=>(...Qe)=>{var Be,rr;return(rr=(Be=ge.current)==null?void 0:Be[We])==null?void 0:rr.call(Be,...Qe)};return{onNodeSelect:oe("onNodeSelect"),onBackgroundClick:oe("onBackgroundClick"),onNodeDeselect:oe("onNodeDeselect"),onNodeDoubleClick:oe("onNodeDoubleClick"),onNodeViewToggle:oe("onNodeViewToggle"),onNodeTypeViewChange:oe("onNodeTypeViewChange"),onNodeCreate:oe("onNodeCreate"),onNodeCreateRequest:oe("onNodeCreateRequest"),onNodeDelete:oe("onNodeDelete"),onNodeLabelChange:oe("onNodeLabelChange"),onNodeContentChange:oe("onNodeContentChange"),onNodeCollapse:oe("onNodeCollapse"),onNodeColorChange:oe("onNodeColorChange"),onNodeBorderColorChange:oe("onNodeBorderColorChange"),onNodeBorderStyleChange:oe("onNodeBorderStyleChange"),onNodeBorderWidthChange:oe("onNodeBorderWidthChange"),onNodeBorderRadiusChange:oe("onNodeBorderRadiusChange"),onNodeIconChange:oe("onNodeIconChange"),onNodeOutlineChange:oe("onNodeOutlineChange"),onNodeAnimationChange:oe("onNodeAnimationChange"),onNodeAnimationVariantChange:oe("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:oe("onEdgeAnimationVariantChange"),onNodeHoverAction:oe("onNodeHoverAction"),onEdgeCreate:oe("onEdgeCreate"),onEdgeSelect:oe("onEdgeSelect"),onEdgeDeselect:oe("onEdgeDeselect"),onEdgeRemove:oe("onEdgeRemove"),onEdgeDelete:oe("onEdgeDelete"),onEdgeColorChange:oe("onEdgeColorChange"),onEdgeTypeChange:oe("onEdgeTypeChange"),onEdgeIconChange:oe("onEdgeIconChange"),onEdgeLabelChange:oe("onEdgeLabelChange"),onEdgeStyleChange:oe("onEdgeStyleChange"),onViewportChange:oe("onViewportChange"),onDirectionChange:oe("onDirectionChange"),onThemeColorChange:oe("onThemeColorChange"),onSpacingChange:oe("onSpacingChange"),onEdgeRadiusChange:oe("onEdgeRadiusChange"),onBackgroundVariantChange:oe("onBackgroundVariantChange"),onEdgeModeChange:oe("onEdgeModeChange"),onCompactPropertyLayoutChange:oe("onCompactPropertyLayoutChange"),onWorkflowContractChange:oe("onWorkflowContractChange"),onArrayModeChange:oe("onArrayModeChange"),onInit:oe("onInit"),onLayoutComplete:oe("onLayoutComplete"),onJsonChange:oe("onJsonChange")}},[]),Oe=e.themeColor||te,Le=e.edgeColor||"",er=e.colorMode||"light",Ve=e.direction||"LR",$e=e.nodeAlignment??"center",xe=e.edgeMode==="workflow"?"nodes":e.edgeMode??A,Me=e.readOnly??!1,Fe=JSON.stringify(e.parentNodeStyle??null),nr=S.useMemo(()=>e.parentNodeStyle,[Fe]),Ze=e.isZoomMode!==void 0?e.isZoomMode:d,Ye=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,fr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:x,wr=e.isDragMode!==void 0?e.isDragMode:g,we=S.useRef(e);we.current=e;const ar=S.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 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 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 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}}),[]),sr=S.useCallback((oe,We)=>{var Qe;if(We!=="default"&&We!=="properties"&&We!=="icon-label")throw new Error("Unknown node view mode.");q(Be=>Be[oe]===We?Be:{...Be,[oe]:We}),(Qe=t.onNodeViewModeChange)==null||Qe.call(t,oe,We)},[t.onNodeViewModeChange]),Ct=S.useMemo(()=>({allNodesIconLabel:W,setAllNodesIconLabel:oe=>{var We,Qe,Be,rr;if(!oe)for(const[De,Q]of Object.entries(O))Q==="icon-label"&&!i.nodeById.has(De)&&sr(De,"default");for(const De of V)i.parentIds.has(De.data.id)||(We=De.data.config)!=null&&We.parentContainer?!Me&&!!((Qe=De.data.config)!=null&&Qe.collapsed)!==oe&&((Be=t.onNodeCollapse)==null||Be.call(t,De.data.id,oe)):sr(De.data.id,oe?"icon-label":"default");(rr=t.onAllNodesIconLabelChange)==null||rr.call(t,oe)},nodeViewModes:O,setNodeViewMode:sr,spacing:ne,setSpacing:Y,edgeRadius:N,setEdgeRadius:me,backgroundVariant:ue,setBackgroundVariant:G,themeColor:Oe,setThemeColor:ce,backgroundSelected:de,setBackgroundSelected:Ae,edgeColor:Le,colorMode:er,direction:Ve,nodeAlignment:$e,edgeMode:xe,setEdgeMode:k,compactPropertyLayout:M,setCompactPropertyLayout:j,workflowContract:K,setWorkflowContract:U,parentNodeStyle:nr,selectedNodeIds:a,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Ze,setIsZoomMode:f,isMultiSelectMode:Ye,setIsMultiSelectMode:y,isDragMode:wr,setIsDragMode:b,isEdgeHandlesEnabled:fr,setIsEdgeHandlesEnabled:m,isArrayNodeMode:w,setIsArrayNodeMode:v,isPinned:C,setIsPinned:_,isPerformanceMode:R,setIsPerformanceMode:T,engineRef:s,callbacks:Ke,config:ar,readOnly:Me}),[W,i,sr,t.onNodeCollapse,t.onAllNodesIconLabelChange,O,t.onNodeViewModeChange,Oe,ne,ue,N,e.backgroundColor,de,Le,er,Ve,$e,xe,K,nr,a,c,Ze,Ye,wr,fr,w,C,R,Me,e.edgeHandles,e.edgeType,e.edgeReveal,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,M,Ke,ar]);return h.jsx(by.Provider,{value:Ct,children:h.jsx(vy.Provider,{value:i,children:o})})}function fn(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,s=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),s=Math.max(0,Math.floor(s*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+s).toString(16).slice(1).toUpperCase()}function dl(e,t,r){const n=a=>{const u=/^#?([0-9a-f]{6})$/i.exec((a==null?void 0:a.trim())??"");return u?parseInt(u[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const s=a=>Math.round((o>>a&255)*(1-r)+(i>>a&255)*r);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const jr=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:fn(e,.1),border:fn(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"},wy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:fn(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},fl={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"}},fe=(e,t)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const a=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(a&&a!=="")return a}catch{}const[n,o]=e.split(".");return n&&o&&((i=fl[n])!=null&&i[Number(o)])?fl[n][Number(o)]:`var(--chakra-colors-${r})`};function or(e,t,r){return e?r:t}function Xt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=wy(e),n=jr(t).background,o=jr(t).highlight,i=jr(t).border,s=jr(t).property,a=jr(t).property;let u=jr(t).background,c=jr(t).highlight;return u=e==="transparent"?e:fe(u)+50,c=e==="transparent"?e:fe(c)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:s,propertyColor:a,secondary:r,bgColorFaint:u,highlightColorFaint:c}}function He(e=null){const{colorMode:t}=Ie(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=or(n,"white","gray.900"),i=or(n,"gray.100","gray.800"),s=or(n,"gray.200","blackAlpha.400"),a=or(n,"gray.200","blackAlpha.600"),u=or(n,"gray.500","gray.700"),c=or(n,"gray.700","gray.700"),l=or(n,"gray.900","gray.900"),d=or(n,"gray.400","gray.500"),f=or(n,"gray.400","gray.500"),p=or(n,"gray.900","gray.200"),y=or(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),g=or(n,"gray.900","gray.200"),b=or(n,e&&"#000000",e||"#ffffff"),x=or(n,e||"#ffffff",e?"#000000":"#ffffff"),m=c,w=or(n,"gray.300","gray.800"),v=or(n,"white","blackAlpha.400"),C=or(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:s,darkBackgroundSecondary:a,border:u,darkColor:l,backgroundWhiteColor:v,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:g,moreIconColor:m,colorText:p,themedColorText:y,logoColor:b,logoColorSecondary:x,darkColorActive:w,greenColor:C}}var jt=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(jt||{});const zt=["","icon-label","object","text"];var uv=typeof global=="object"&&global&&global.Object===Object&&global,lv=typeof self=="object"&&self&&self.Object===Object&&self,dv=uv||lv||Function("return this")(),ht=dv.Symbol,Cy=Object.prototype,fv=Cy.hasOwnProperty,hv=Cy.toString,St=ht?ht.toStringTag:void 0;function pv(e){var t=fv.call(e,St),r=e[St];try{e[St]=void 0;var n=!0}catch{}var o=hv.call(e);return n&&(t?e[St]=r:delete e[St]),o}var gv=Object.prototype,yv=gv.toString;function mv(e){return yv.call(e)}var bv="[object Null]",vv="[object Undefined]",hl=ht?ht.toStringTag:void 0;function xv(e){return e==null?e===void 0?vv:bv:hl&&hl in Object(e)?pv(e):mv(e)}function wv(e){return e!=null&&typeof e=="object"}var Cv="[object Symbol]";function _v(e){return typeof e=="symbol"||wv(e)&&xv(e)==Cv}function Sv(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Pe=Array.isArray,pl=ht?ht.prototype:void 0,gl=pl?pl.toString:void 0;function _y(e){if(typeof e=="string")return e;if(Pe(e))return Sv(e,_y)+"";if(_v(e))return gl?gl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ku(e){return e==null?"":_y(e)}function Ev(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}function jv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:Ev(e,t,r)}var kv="\\ud800-\\udfff",Rv="\\u0300-\\u036f",Pv="\\ufe20-\\ufe2f",Av="\\u20d0-\\u20ff",Tv=Rv+Pv+Av,Ov="\\ufe0e\\ufe0f",Iv="\\u200d",Mv=RegExp("["+Iv+kv+Tv+Ov+"]");function Sy(e){return Mv.test(e)}function qv(e){return e.split("")}var Ey="\\ud800-\\udfff",Nv="\\u0300-\\u036f",$v="\\ufe20-\\ufe2f",Lv="\\u20d0-\\u20ff",Fv=Nv+$v+Lv,Bv="\\ufe0e\\ufe0f",Dv="["+Ey+"]",vu="["+Fv+"]",xu="\\ud83c[\\udffb-\\udfff]",zv="(?:"+vu+"|"+xu+")",jy="[^"+Ey+"]",ky="(?:\\ud83c[\\udde6-\\uddff]){2}",Ry="[\\ud800-\\udbff][\\udc00-\\udfff]",Vv="\\u200d",Py=zv+"?",Ay="["+Bv+"]?",Wv="(?:"+Vv+"(?:"+[jy,ky,Ry].join("|")+")"+Ay+Py+")*",Gv=Ay+Py+Wv,Uv="(?:"+[jy+vu+"?",vu,ky,Ry,Dv].join("|")+")",Hv=RegExp(xu+"(?="+xu+")|"+Uv+Gv,"g");function Kv(e){return e.match(Hv)||[]}function Jv(e){return Sy(e)?Kv(e):qv(e)}function Zv(e){return function(t){t=ku(t);var r=Sy(t)?Jv(t):void 0,n=r?r[0]:t.charAt(0),o=r?jv(r,1).join(""):t.slice(1);return n[e]()+o}}var Yv=Zv("toUpperCase");function Xv(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;)r=t(r,e[o],o,e);return r}function Qv(e){return function(t){return e==null?void 0:e[t]}}var ex={À:"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"},rx=Qv(ex),tx=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,nx="\\u0300-\\u036f",ox="\\ufe20-\\ufe2f",ix="\\u20d0-\\u20ff",ax=nx+ox+ix,sx="["+ax+"]",cx=RegExp(sx,"g");function ux(e){return e=ku(e),e&&e.replace(tx,rx).replace(cx,"")}var lx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function dx(e){return e.match(lx)||[]}var fx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function hx(e){return fx.test(e)}var Ty="\\ud800-\\udfff",px="\\u0300-\\u036f",gx="\\ufe20-\\ufe2f",yx="\\u20d0-\\u20ff",mx=px+gx+yx,Oy="\\u2700-\\u27bf",Iy="a-z\\xdf-\\xf6\\xf8-\\xff",bx="\\xac\\xb1\\xd7\\xf7",vx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",xx="\\u2000-\\u206f",wx=" \\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",My="A-Z\\xc0-\\xd6\\xd8-\\xde",Cx="\\ufe0e\\ufe0f",qy=bx+vx+xx+wx,Ny="['’]",yl="["+qy+"]",_x="["+mx+"]",$y="\\d+",Sx="["+Oy+"]",Ly="["+Iy+"]",Fy="[^"+Ty+qy+$y+Oy+Iy+My+"]",Ex="\\ud83c[\\udffb-\\udfff]",jx="(?:"+_x+"|"+Ex+")",kx="[^"+Ty+"]",By="(?:\\ud83c[\\udde6-\\uddff]){2}",Dy="[\\ud800-\\udbff][\\udc00-\\udfff]",st="["+My+"]",Rx="\\u200d",ml="(?:"+Ly+"|"+Fy+")",Px="(?:"+st+"|"+Fy+")",bl="(?:"+Ny+"(?:d|ll|m|re|s|t|ve))?",vl="(?:"+Ny+"(?:D|LL|M|RE|S|T|VE))?",zy=jx+"?",Vy="["+Cx+"]?",Ax="(?:"+Rx+"(?:"+[kx,By,Dy].join("|")+")"+Vy+zy+")*",Tx="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ox="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ix=Vy+zy+Ax,Mx="(?:"+[Sx,By,Dy].join("|")+")"+Ix,qx=RegExp([st+"?"+Ly+"+"+bl+"(?="+[yl,st,"$"].join("|")+")",Px+"+"+vl+"(?="+[yl,st+ml,"$"].join("|")+")",st+"?"+ml+"+"+bl,st+"+"+vl,Ox,Tx,$y,Mx].join("|"),"g");function Nx(e){return e.match(qx)||[]}function $x(e,t,r){return e=ku(e),t=t,t===void 0?hx(e)?Nx(e):dx(e):e.match(t)||[]}var Lx="['’]",Fx=RegExp(Lx,"g");function Bx(e){return function(t){return Xv($x(ux(t).replace(Fx,"")),e,"")}}var Cr=Bx(function(e,t,r){return e+(r?" ":"")+Yv(t)});function Ee({label:e,children:t}){const r=S.cloneElement(t,{title:t.props.title??e});if(!B.Tooltip.Root){const n=B.Tooltip;return h.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return h.jsxs(B.Tooltip.Root,{positioning:{placement:"top"},children:[h.jsx(B.Tooltip.Trigger,{asChild:!0,children:r}),h.jsx(B.Portal,{children:h.jsx(B.Tooltip.Positioner,{children:h.jsx(B.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Mt(){const{border:e}=He();return h.jsx(B.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:e})}function Ir({children:e,value:t,onValueChange:r,disabled:n,style:o,title:i,icon:s,popupContent:a,labelCase:u="title","aria-label":c}){var E;const{colorMode:l}=Ie(),{background:d,border:f,colorText:p,colorActive:y,colorInactive:g}=He(),b=l==="dark",x=S.useId(),m=S.useRef(null),w=S.useRef(null),[v,C]=S.useState(!1);S.useEffect(()=>{const j=w.current;j.setAttribute("popover","auto");const M=I=>C(I.newState==="open");return j.addEventListener("toggle",M),()=>j.removeEventListener("toggle",M)},[]);const _=S.Children.toArray(e).filter(S.isValidElement).map(j=>{const M=j.props;return{value:String(M.value),label:typeof M.children=="string"&&u==="title"?Cr(M.children):M.children,disabled:M.disabled}}),R=()=>{var j;return(j=w.current)==null?void 0:j.hidePopover()},T=()=>{var V,W,re,Y;const j=(V=m.current)==null?void 0:V.getBoundingClientRect(),M=w.current;if(!j||!M)return;const q=((Y=(re=(W=m.current)==null?void 0:W.closest("[data-flow-toolbar-scroll]"))==null?void 0:re.parentElement)==null?void 0:Y.getBoundingClientRect())??j;M.style.maxHeight=`${Math.max(60,Math.max(q.top-40,window.innerHeight-q.bottom-40))}px`;const O=M.getBoundingClientRect();M.style.left=`${Math.max(12,Math.min(j.right-O.width,window.innerWidth-O.width-12))}px`,M.style.top=`${Math.max(12,q.top>=O.height+36?q.top-O.height-24:Math.min(q.bottom+24,window.innerHeight-O.height-12))}px`},A=()=>{var I,q,O,V,W,re;if(n)return;if((I=w.current)==null||I.showPopover(),T(),a){(O=(q=w.current)==null?void 0:q.querySelector("input"))==null||O.focus({preventScroll:!0});return}const j=(V=w.current)==null?void 0:V.querySelectorAll('[role="option"]:not(:disabled)');(re=((W=w.current)==null?void 0:W.querySelector('[aria-selected="true"]:not(:disabled)'))??(j==null?void 0:j[0]))==null||re.focus()};S.useEffect(()=>{if(v){if(n){R();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[v,n]);const k=`var(--chakra-colors-${d.replace(".","-")})`;return h.jsxs(h.Fragment,{children:[h.jsx(Ee,{label:i??c,children:h.jsx(B.chakra.button,{ref:m,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":c,title:i??c,"aria-haspopup":a?"dialog":"listbox","aria-expanded":v,"aria-controls":x,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?g:p,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:o,onClick:()=>v?R():A(),onKeyDown:j=>{["ArrowDown","ArrowUp"].includes(j.key)&&(j.preventDefault(),A())},children:s??h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((E=_.find(j=>j.value===t))==null?void 0:E.label)??t}),h.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),h.jsx(B.chakra.div,{ref:w,id:x,role:a?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:d,color:p,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},...zr(k,`var(--chakra-colors-${(b?f:"gray.300").replace(".","-")})`)},onKeyDown:j=>{var q,O,V;if(a&&!["Escape","Tab"].includes(j.key))return;const M=[...j.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')],I=M.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(j.key)){j.preventDefault();const W=j.key==="Home"?0:j.key==="End"?M.length-1:(I+(j.key==="ArrowDown"?1:-1)+M.length)%M.length;(q=M[W])==null||q.focus()}else j.key==="Escape"||j.key==="Tab"?(j.key==="Escape"&&(j.preventDefault(),j.stopPropagation()),R(),(O=m.current)==null||O.focus()):j.key.length===1&&j.key!==" "&&((V=M.find((W,re)=>{var Y;return re>I&&((Y=W.textContent)==null?void 0:Y.toLowerCase().startsWith(j.key.toLowerCase()))}))==null||V.focus())},children:a??_.map(j=>h.jsxs(B.chakra.button,{type:"button",role:"option","aria-selected":j.value===t,disabled:j.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",borderRadius:"30px",fontSize:"sm",textAlign:"left",bg:"transparent",color:p,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var M;R(),(M=m.current)==null||M.focus(),r(j.value)},children:[h.jsx("span",{style:{flex:1},children:j.label}),h.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${y.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:j.value===t?"visible":"hidden"}})]},j.value))})]})}const be=S.forwardRef(function({icon:t,...r},n){const{colorMode:o}=Ie();return h.jsx(B.IconButton,{ref:n,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:r.title??r["aria-label"],...r,children:t})}),gt=S.forwardRef(function(t,r){const{themeColor:n}=Ie();return h.jsx(Ee,{label:"Close",children:h.jsx(be,{ref:r,size:"sm",variant:"ghost",color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:h.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})});function Ru({label:e,icon:t,checked:r,onChange:n,disabled:o}){const{themeColor:i,readOnly:s}=Ie(),{colorInactive:a}=He();return h.jsx(Ee,{label:e,children:h.jsx(be,{"aria-label":e,"aria-pressed":r,icon:h.jsxs(h.Fragment,{children:[t,h.jsx(B.Text,{as:"span",fontSize:"xs",fontWeight:"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?i:a,disabled:o||s,onClick:()=>n(!r)})})}function Wy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Ie();return h.jsx(Ru,{label:e,checked:t,icon:h.jsx(B.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:o=>{var i;r(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const Dx=bn.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
- `,Gy=S.forwardRef(function({style:t,...r},n){return h.jsx(Dx,{...r,ref:n,style:{...t,backgroundImage:"none","--flow-range-track":(t==null?void 0:t.backgroundImage)??"none"}})});function xl({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:s}){const a=S.useId(),{readOnly:u,themeColor:c}=Ie(),{colorInactive:l}=He(),d=(r-o)/(i-o)*100,f=c.includes(".")?`var(--chakra-colors-${c.replace(".","-")})`:c;return h.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[h.jsxs("label",{htmlFor:a,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",h.jsx("span",{children:n})]}),h.jsx(Gy,{id:a,"aria-label":t,type:"range",min:o,max:i,step:5,value:r,disabled:u,style:{color:f,accentColor:f,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>s(Number(p.target.value))})]})}const wl={dot:{label:"Dots",icon:Z.PiDotsNine},grid:{label:"Grid",icon:Z.PiGridFour},steel:{label:"Steel",icon:Z.PiLineSegments},none:{label:"Solid",icon:Z.PiSquareFill},transparent:{label:"Transparent",icon:Z.PiSelection}};function Uy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:s,readOnly:a}=Ie(),u=wl[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:h.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:h.jsx(xl,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:c=>{var l;t(c/100),(l=s.onSpacingChange)==null||l.call(s,c/100)}}),children:h.jsx("option",{value:"spacing",children:"Spacing"})}),h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:h.jsx(xl,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:c=>{var l;n(c),(l=s.onEdgeRadiusChange)==null||l.call(s,c)}}),children:h.jsx("option",{value:"radius",children:"Edge radius"})}),h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Background variant",title:`Background: ${wl[o].label}`,icon:h.jsx(u,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:a,onValueChange:c=>{var l;i(c),(l=s.onBackgroundVariantChange)==null||l.call(s,c)},children:[h.jsx("option",{value:"dot",children:"Dots"}),h.jsx("option",{value:"grid",children:"Grid"}),h.jsx("option",{value:"steel",children:"Steel"}),h.jsx("option",{value:"none",children:"Solid"}),h.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const ir=[];for(let e=0;e<256;++e)ir.push((e+256).toString(16).slice(1));function zx(e,t=0){return(ir[e[t+0]]+ir[e[t+1]]+ir[e[t+2]]+ir[e[t+3]]+"-"+ir[e[t+4]]+ir[e[t+5]]+"-"+ir[e[t+6]]+ir[e[t+7]]+"-"+ir[e[t+8]]+ir[e[t+9]]+"-"+ir[e[t+10]]+ir[e[t+11]]+ir[e[t+12]]+ir[e[t+13]]+ir[e[t+14]]+ir[e[t+15]]).toLowerCase()}let Zn;const Vx=new Uint8Array(16);function Wx(){if(!Zn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Zn=crypto.getRandomValues.bind(crypto)}return Zn(Vx)}const Gx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cl={randomUUID:Gx};function Ru(e,t,r){var o;if(Cl.randomUUID&&!e)return Cl.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??Wx();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,zx(n)}const bn={label:"Untitled",description:"",isTask:!1,isLocked:!1},Pu={id:null,type:"text",data:{...bn,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"}}},_l={id:null,type:"objectView",data:{...bn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Ux={id:null,type:"arrayView",data:{...bn,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"}}},Sl={id:null,type:"workflowStep",data:{...bn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},yr=e=>typeof e=="object",Hy=e=>Array.isArray(e),Hx=["order","position","selected","locked","grabbed","grabbable","scratch"],Vr=e=>Object.entries(e).reduce((t,[r,n])=>(!yr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),Au=(e,t)=>typeof e=="string"&&e.startsWith("$")?Yn(e,t):yr(e)&&!Hy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Yn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Yn(o,t):r[n]=o,r),{}):e,Wr=e=>Object.entries(e).reduce((t,[r,n])=>(yr(n)&&r&&n&&!r.startsWith("$")&&(Hx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Yr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(yr(i)||Hy(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),Dr=(e,t,r=null,n=null,o=null,i=!1,s=null)=>({data:{id:Ru(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:s}}),Gr=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,s]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=s:i!=="$"?n[i]=s:i==="$"&&(o=s);return{newConfig:r,updatedObject:n,arrayObject:o}},lt=(e,t)=>{let r=_l;const{view:n,borderColor:o,borderRadius:i,bgColor:s,textColor:a,fontSize:u,stepType:c}=t;e=n||e,c?r={...Sl}:e==="object"?r=_l:e==="text"?r=Pu:e==="array"?r=Ux:e==="workflowStep"&&(r={...Sl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:i||(c?15:53),bgColor:s,borderColor:o,textColor:a,fontSize:u},r.data.config=t,{config:r}},Vt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Yn=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!o)return e;const i=Kx(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},Kx=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:u}=Gr(s);return s=u.length?u:s,s[a]},i))(t)};function ft(e,t="root",r=[]){try{const{arrayObject:n}=Gr(e);n.length&&(e=n);const o=Vr(e),i=Wr(e);return yr(e)?(Pe(e)||Pe(e)&&t==="root"||!Pe(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Pe(e)?qt({chldPth:null,itrblObjct:i,nodes:r,path:t}):Pe(e)&&e.forEach((s,a)=>{const u=Vr(s),c=Wr(s),{newConfig:l,arrayObject:d}=Gr(s);let f=`${t}.${a}`;yr(s)?Object.keys(u).length?(ft(u,f,r),Object.keys(c).length&&!Pe(s)&&qt({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Pe(s)?qt({chldPth:f,itrblObjct:c,nodes:r,path:t}):Pe(s)&&Ky({chldPth:f,item:s,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const qt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],s)=>{const a=Vr(i),u=Wr(i),{newConfig:c,arrayObject:l}=Gr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(yr(i)&&!Pe(i)){const f=Object.keys(a).length===0;if(f&&(lt("array",c),r.push(d)),Object.keys(a).length){const p=Pe(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let y=d;f&&(y=`${d}.${p}`),ft(i,y,r)}else Object.keys(u).length&&!Pe(i)?qt({chldPth:d,itrblObjct:u,path:d,nodes:r}):ft(i,d,r)}else Pe(i)&&ft(i,d,r)}),Ky=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let s=`${e}.${i}`;const a=Wr(o),u=Vr(o);yr(o)?!Pe(o)&&Object.keys(u).length?ft(o,s,r):Object.keys(a).length&&!Pe(o)?qt({chldPth:s,itrblObjct:a,path:n,nodes:r}):Pe(o)&&Ky({chldPth:s,item:o,nodes:r,path:n}):r.push(s)}),fn=[];let Nt;function Qr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const a=e;if(!Nt){const{nodes:l}=ft(e);Nt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=Vt(t,r);const{newConfig:l,arrayObject:d}=Gr(e),f=Object.keys(s).length>0?s:l;d.length&&(e=d);const p=Vr(e),y=Wr(e),{label:g,collapsed:b,parent:x}=f;if(!yr(e))r.push(Yr(Pu,t,{label:g||t,parent:x},e,a));else if(Pe(e)||Pe(e)&&t==="root"){const{config:m}=lt("array",f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t==="root"?o:`${o} ${w}`;r.push(Yr(m,t,{label:g||v,parent:x},e,Pe(a)?{[o]:a}:a))}else if(!Pe(e)&&Object.keys(p).length||t==="root"){const{config:m}=lt(null,f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t.split("."),C=v[v.length-1];let _=isNaN(Number(C))?null:Number(C)+1;const R=isNaN(Number(C))?C:v[v.length-2]+" "+_,T=t==="root"?o:R;let A=!1;Number.isNaN(Number(o))||(A=!0);const k=e;if(g){const{config:E}=lt("object",f);r.push(Yr(E,t,{label:g||`${g} ${w}`,parent:x},p,k))}else m.data.headerTitle=T,r.push(Yr(m,t,{label:g,parent:x},p,k))}return b||(Object.keys(y).length&&!Pe(e)?$t({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:y,nodes:r,path:t,newConfig:f}):Pe(e)&&e.forEach((m,w)=>{m=Au(m,Nt);const v=m,C=Vr(m),_=Wr(m),{newConfig:R,arrayObject:T}=Gr(m);T.length&&(m=T);const{config:A}=lt(typeof m=="string"?"text":"array",R),{hideConfig:k,sourceLabel:E,label:j,isEdgeAnimated:M,parent:I}=R;u=u||k;const q=t==="root"&&i.isCntr,O=t.split(".").slice(0,2).join("."),V=fn.includes(O),W=i.isCntr&&V||w%2===0&&q;let re=`${t}.${w}`;re=Vt(re,r),W&&fn.push(re),yr(m)?Object.keys(C).length&&!Pe(m)?(n.push(Dr(t,re,null,E,W,M)),Qr(m,re,r,n,j||w,i,R)):Object.keys(_).length&&!Pe(m)?$t({flowConfig:i,chldPth:re,isInverted:W,edges:n,itrblObjct:_,nodes:r,path:t,newConfig:R,forceIsInverted:!0}):Pe(m)?Jy({flowConfig:i,chldPth:re,edges:n,isInverted:W,item:m,nodes:r,path:t}):yr(m)&&$t({flowConfig:i,chldPth:re,isInverted:W,edges:n,itrblObjct:[m],nodes:r,path:t,newConfig:R}):(n.push(Dr(t,re,null,E,W,M)),r.push(Yr(A,re,{label:j||String(m),parent:I},m,v)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const $t=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:s,newConfig:a,forceIsInverted:u=!1})=>{let{hideDefaultObject:c,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,f],p)=>{f=Au(f,Nt);const y=f,g=Vr(f),b=Wr(f),{newConfig:x,arrayObject:m}=Gr(f);m.length&&(f=m);const{hideConfig:w,sourceLabel:v,label:C,content:_,target:R,targetLabel:T,collapsed:A,isEdgeAnimated:k,parent:E}=x;c=c||w;const j=s==="root"&&t.isCntr,M=s.split(".").slice(0,2).join("."),I=fn.includes(M);u||(i=t.isCntr&&I||p%2===0&&j);let q=e?`${e}.${d}`:`${s}.${d}`;if(q=Vt(q,o),i&&fn.push(q),R&&r.push(Dr(q,R,null,T,i,k)),yr(f)&&!Pe(f)){r.push(Dr(s,q,null,v,i,k));const O=l||Object.keys(g).length===0;if(O){const V=_?"object":"array",{config:W}=lt(V,x);W.data.headerTitle=_?C:null,o.push(Yr(W,q,{label:C||d,parent:E},f,y))}if(Object.keys(g).length&&!c){const V=Pe(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let W=q;O&&(W=`${q}.${V}`,W=Vt(W,o),r.push(Dr(q,W,null,v,i,k))),Qr(f,W,o,r,C||d,t,x)}else Object.keys(b).length&&!Pe(f)?$t({chldPth:q,flowConfig:t,itrblObjct:b,path:q,edges:r,nodes:o,newConfig:x,isInverted:i}):Qr(f,q,o,r,d,t,x)}else Pe(f)&&(r.push(Dr(s,q,null,v,i,k)),Qr(f,q,o,r,d,t,x))})},Jy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:s})=>o.forEach((a,u)=>{let c=`${t}.${u}`;c=Vt(c,i);const l=a;a=Au(a,Nt);const d=Wr(a),f=Vr(a),{newConfig:p}=Gr(a),{collapsed:y,label:g,parent:b,sourceLabel:x,isEdgeAnimated:m,content:w}=p;yr(a)?!Pe(a)&&Object.keys(f).length?(r.push(Dr(s,c,null,x,n,m)),Qr(a,c,i,r,u,e,p)):Object.keys(d).length&&!Pe(a)&&!y?$t({chldPth:c,flowConfig:e,itrblObjct:d,path:s,edges:r,nodes:i,isInverted:n,newConfig:p}):Pe(a)&&Jy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:a,nodes:i,path:s}):(r.push(Dr(s,c,null,x,n,m)),i.push(Yr(Pu,c,{label:g||String(a),parent:b},a,l)))});function Jx(e,t){const r=new Set,n=c=>{if(!(!c||typeof c!="object")){typeof c.$parent=="string"&&r.add(c.$parent);for(const[l,d]of Object.entries(c))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const o=new Map(t.nodes.map(c=>[c.data.id,c])),i=c=>{var p,y;let l=c.data.id;const d=new Set([c.data.id]);let f=c.data.parent;for(;f&&!d.has(f);)r.has(f)&&o.has(f)&&((p=ve(e,f))!=null&&p.$collapsed)&&(l=f),d.add(f),f=(y=o.get(f))==null?void 0:y.data.parent;return l},s=new Map(t.nodes.map(c=>[c.data.id,i(c)])),a=t.nodes.filter(c=>s.get(c.data.id)===c.data.id).map(c=>{if(!r.has(c.data.id))return c;const l=ve(e,c.data.id),d=!!(l!=null&&l.$collapsed);return{...c,data:{...c.data,...d?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),u=new Set(a.map(c=>c.data.id));return{nodes:a,edges:t.edges.flatMap(c=>{const l=s.get(c.data.source),d=s.get(c.data.target);return!l||!d||!u.has(l)||!u.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 vn(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;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=t.get(i)??0;return t.set(i,s+1),[{value:o,key:`${i}#${s}`,index:n}]})}function Zy(e,t,r){const n=vn(e).find(u=>u.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((u,c)=>c===n.index?o?[o]:[]:[u]);if(i.length)return{...e,$connections:i};const{$connections:s,...a}=e;return a}function Zx(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,s)=>r(i,`${o}.${s}`));for(const i of vn(n)){const s=i.value;t.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==="$"?r(s,o):i.startsWith("$")?s:r(s,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const Wt="root",El=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Mr(e){const t=e.split(".");for(t[0]===Wt&&t.shift();t.length&&El(t[t.length-1]);)t.pop();return t.filter(r=>!El(r))}function xn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function ve(e,t){return Mr(t).reduce((r,n)=>{var o;if(r!=null)return(o=xn(r))==null?void 0:o[n]},e)}function Yx(e){return Array.isArray(e)?[...e]:{...e}}function mr(e,t,r){const n=Mr(t),o=(i,s)=>{if(s===n.length)return r(i);const a=n[s],u=xn(i);if(u==null||typeof u!="object")return i;const c=o(u[a],s+1);if(Object.is(c,u[a]))return i;const l=Yx(u);return l[a]=c,u!==i?{...i,$:l}:l};return o(e,0)}function Or(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function ur(e,t,r,n){return mr(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Or(o,r,n))}const Yy=(e,t,r)=>ur(e,t,"$collapsed",r);function Gt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.collapsedEndpoints??e,r=e.isInverted?t.target:t.source,n=e.isInverted?t.source:t.target,o=Mr(r).join("."),i=Mr(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Br(e,t,r,n){if(t.connection){const a=t.connection;return mr(e,a.address,u=>Zy(u,a.key,c=>{if(r==="$edgeIcon")return Or(c,"icon",n);if(r==="$edgeType")return Or(c,"type",n);if(r==="$edgeAnimationVariant")return Or(c,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Or(c,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:l}:c.style===l?Or(c,"style",void 0):c}))}const{address:o,kind:i}=Gt(t),s=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return mr(e,o,a=>Or(a,s,n))}const Xy=(e,t,r)=>Br(Br(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Tu(e,t,r,n){let o=n||"";const i=mr(e,t,a=>{const u=xn(a);if(Array.isArray(u)){o=String(u.length);const l=[...u,r];return u===a?l:{...a,$:l}}const c=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!o){let l=1;for(;`node_${l}`in c;)l++;o=`node_${l}`}return c[o]=r,c}),s=Mr(t);return{json:i,address:[Wt,...s,o].join(".")}}function Qy(e,t){const r=Mr(t);if(!r.length)return e;const n=r[r.length-1],o=[Wt,...r.slice(0,-1)].join(".");return mr(e,o,i=>{const s=xn(i);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return i;if(Array.isArray(s)){const c=s.filter((l,d)=>String(d)!==n);return s===i?c:{...i,$:c}}const{[n]:a,...u}=i;return u})}const em=(e,t,r,n)=>ur(n?mr(e,t,o=>Or(o,"$targetLabel",n)):e,t,"$target",r);function Ou(e,t,r){const n=ve(e,t);return vn(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:mr(e,t,i=>Or(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||Ru()}]))}function rm(e,t){if(t.connection){const i=t.connection;return vn(ve(e,i.address)).some(s=>s.key===i.key)?{json:mr(e,i.address,s=>Zy(s,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=Gt(t);return n==="hierarchy"?ve(e,r)===void 0?{json:e,removed:!1}:{json:mr(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:mr(e,r,i=>{const{$target:s,$targetLabel:a,...u}=i||{};return u}),removed:!0}}function xu(e,t={}){var x;const r=Zx(e),{nodes:n,edges:o}=Qr(r.json,Wt,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(m=>m.data.id)),s=new Map;for(const m of n){const w=m.data.id;if(!w.endsWith(".0")||ve(e,w)!==void 0)continue;const v=w.slice(0,-2),C=ve(e,v);!i.has(v)&&C&&typeof C=="object"&&!Array.isArray(C)&&typeof C.$label=="string"&&Object.keys(C).every(_=>_.startsWith("$")&&_!=="$")&&s.set(w,v)}const a=m=>s.get(m)??m,u=new Set(n.flatMap(m=>m.data.parent?[a(m.data.parent)]:[])),c=n.map(m=>{var T;const w=a(m.data.id),v=ve(e,w),C={...m.data,id:w},_=v&&typeof v=="object"&&!Array.isArray(v)&&"$"in v?v.$:v;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(A=>!A.startsWith("$")))&&(C.config={...C.config,collapsed:!!v.$collapsed}),u.has(w)||(C.viewProps={...C.viewProps},delete C.viewProps.borderWidth),!v||typeof v!="object"||Array.isArray(v))return{data:C};if(v.$form&&typeof v.$form=="object"&&(C.config={...C.config,form:v.$form},C.type="objectView"),Array.isArray(v.$ports)){const A=v.$ports.filter(k=>k&&typeof k.id=="string"&&["source","target"].includes(k.role)&&["top","right","bottom","left"].includes(k.side));C.config={...C.config,ports:A}}return C.parent&&(C.parent=a(C.parent)),typeof v.$label=="string"&&(C.label=v.$label,C.headerTitle=v.$label),typeof v.$subtitle=="string"&&(C.config={...C.config,subtitle:v.$subtitle}),typeof v.$outline=="boolean"&&(C.viewProps={...C.viewProps,outline:v.$outline}),["solid","dashed","dotted","double"].includes(v.$borderStyle)&&(C.viewProps={...C.viewProps,borderStyle:v.$borderStyle}),Number.isFinite(v.$borderWidth)&&v.$borderWidth>=0&&(C.viewProps={...C.viewProps,borderWidth:v.$borderWidth}),Number.isFinite(v.$borderRadius)&&v.$borderRadius>=0&&(C.viewProps={...C.viewProps,borderRadius:v.$borderRadius}),typeof v.$isNodeAnimated=="boolean"&&(C.isNodeAnimated=v.$isNodeAnimated),["traveling","pulse"].includes(v.$nodeAnimationVariant)&&(C.nodeAnimationVariant=v.$nodeAnimationVariant),typeof v.$content=="string"&&(C.config={...C.config,content:v.$content},v.$view||(C.type="objectView")),(((T=C.config)==null?void 0:T.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(C.config={...C.config||{}},(v.$collapsed!==void 0||C.config.collapsed!==void 0)&&(C.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(C.config.icon=v.$icon)),{data:C}}),l=new Map,d=o.map(m=>{const w=a(m.data.source),v=a(m.data.target),C=`${w}->${v}`,_=l.get(C)??0;l.set(C,_+1);const R={...m.data,id:_?`${C}#${_}`:C,source:w,target:v},T=Gt(R),A=ve(e,T.address);if(A&&typeof A=="object"){const k=A[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof k=="string"&&(R.type=k);const E=A[T.kind==="target"?"$targetIcon":"$edgeIcon"];typeof E=="string"&&(R.icon=E),A.$isEdgeAnimated!==void 0&&(R.isEdgeAnimated=!!A.$isEdgeAnimated);const j=A[T.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(j)&&(R.edgeAnimationVariant=j),A.$isEdgeDashed!==void 0&&(R.isEdgeDashed=!!A.$isEdgeDashed),A.$edgeColor&&(R.color=A.$edgeColor)}return{data:R}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const m=c.findIndex(w=>w.data.id===Wt);m!==-1&&c.splice(m,1)}const f=new Set(c.map(m=>m.data.id));for(let m=d.length-1;m>=0;m--){const w=d[m].data,v=Gt(w);(!f.has(w.source)||!f.has(w.target)||v.kind==="hierarchy"&&((x=ve(e,v.address))==null?void 0:x.$hideParentEdge)===!0)&&d.splice(m,1)}d.push(...r.edges.filter(m=>f.has(m.data.source)&&f.has(m.data.target)));const p=Jx(e,{nodes:c,edges:d}),y=p.nodes.filter(m=>{var w;return(w=m.data.config)==null?void 0:w.collapsed}).map(m=>Mr(m.data.id));if(!y.length)return p;const g=p.nodes.filter(m=>{const w=Mr(m.data.id);return!y.some(v=>v.length<w.length&&v.every((C,_)=>C===w[_]))}),b=new Set(g.map(m=>m.data.id));return{nodes:g,edges:p.edges.filter(m=>b.has(m.data.source)&&b.has(m.data.target))}}function Xx(e,t){const r=new Set(e.filter(u=>{var c,l;return(l=(c=u.data)==null?void 0:c.config)==null?void 0:l.collapsed}).map(u=>u.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(u=>[u.data.id,u])),o=new Set(e.map(u=>u.data.parent).filter(Boolean)),i=new Map(e.map(u=>{var f;let c=u.data.id,l=u.data.parent;const d=new Set([c]);for(;l&&!d.has(l);)r.has(l)&&(c=l),d.add(l),l=(f=n.get(l))==null?void 0:f.data.parent;return[u.data.id,c]})),s=new Map;for(const u of t){const c=u.data.isInverted?u.data.target:u.data.source,l=u.data.isInverted?u.data.source:u.data.target;(s.get(c)??s.set(c,[]).get(c)).push(l)}const a=new Set(e.filter(u=>i.get(u.data.id)!==u.data.id).map(u=>u.data.id));for(const u of r){if(o.has(u))continue;const c=[...s.get(u)||[]];for(;c.length;){const l=c.pop();r.has(l)||a.has(l)||(a.add(l),c.push(...s.get(l)||[]))}}return{nodes:e.filter(u=>!a.has(u.data.id)).map(u=>{var c;return r.has(u.data.id)&&o.has(u.data.id)?{...u,data:{...u.data,type:"arrayView",label:u.data.label??u.data.headerTitle,config:{...u.data.config,parentContainer:!0,labelBelow:!0,icon:((c=u.data.config)==null?void 0:c.icon)||"PiStack"}}}:u}),edges:t.flatMap(u=>{const c=i.get(u.data.source)??u.data.source,l=i.get(u.data.target)??u.data.target;return a.has(c)||a.has(l)?[]:c===u.data.source&&l===u.data.target?[u]:c===l?[]:[{...u,data:{...u.data,source:c,target:l,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Iu(e,t){const r=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 u=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const l of Object.keys(s))if(!u.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(d=>!["$ref","title","description"].includes(d)))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 l=r;for(const d of s.$ref.slice(2).split("/")){const f=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,f))throw new Error(`Unresolved reference: ${s.$ref}`);l=l[f]}return o(l,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(l=>l!=="anyOf"&&!c.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(l=>o(l,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(f=>![...c,"const","enum","type"].includes(f))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(f=>{if(f!==null&&!["string","number","boolean"].includes(typeof f))throw new Error("Only primitive literals are supported.");const p=f===null?"null":typeof f;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(y=>y===p||y==="integer"&&Number.isInteger(f)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:f}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(l=>l!=="type"&&!c.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(l=>o({type:l},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(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(s.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([d,f])=>[d,{type:o(f,a),optional:!(s.required??[]).includes(d)}]))}}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(r);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:t,nodes:i.properties}}async function Mu(e,t,r,n={}){var y;let o=512;const i=await import("typescript"),s=i.createSourceFile(t,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const u=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((y=g.typeParameters)!=null&&y.length||u.has(g.name.text))throw new Error("Generics and duplicate declarations are not supported.");u.set(g.name.text,g)}const c=(g,b)=>{var C;const x={},m=g.find(_=>i.isIndexSignatureDeclaration(_));let w;if(m&&n.allowJson&&i.isIndexSignatureDeclaration(m)){if(g.filter(_=>i.isIndexSignatureDeclaration(_)).length!==1||m.parameters.length!==1||((C=m.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!m.type)throw new Error("Only one string-keyed index signature is supported for forms.");w=d(m.type,b)}return{kind:"object",properties:Object.fromEntries(g.filter(_=>_!==m||!w).map(_=>{if(!i.isPropertySignature(_)||!_.type||!_.name||!i.isIdentifier(_.name)&&!i.isStringLiteral(_.name))throw new Error("Only explicitly typed named properties are supported.");const R=d(_.type,b),T=n.allowJson?i.getJSDocTags(_).filter(A=>A.tagName.text==="port"):[];if(T.length>1)throw new Error(`Duplicate port declaration: ${_.name.text}`);if(T.length){const[A,k,E]=String(T[0].comment??"").trim().split(/\s+/);if(A!=="config"||!k||E||!u.has(k))throw new Error(`Config port ${_.name.text} requires @port config ResourceType`);const j=R.kind==="array";if((R.kind==="array"?R.items.kind:R.kind)!=="string")throw new Error(`Config port ${_.name.text} must be a string or string array reference`);x[_.name.text]={kind:"config",resourceType:k,multiple:j}}return[_.name.text,{type:R,optional:!!_.questionToken}]})),...w?{additionalProperties:w}:{},...Object.keys(x).length?{ports:x}:{}}},l=(g,b)=>{var C;if(b.includes(g))throw new Error("Recursive types are not supported.");const x=u.get(g);if(!x)throw new Error(`Unknown type: ${g}`);let m;if(i.isInterfaceDeclaration(x)){if((C=x.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");m=c(x.members,[...b,g])}else m=d(x.type,[...b,g]);const w=n.allowJson?i.getJSDocTags(x).filter(_=>_.tagName.text==="port"):[];if(!w.length)return m;if(m.kind!=="object")throw new Error("Node ports require an object interface");const v={...m.ports};for(const _ of w){const[R,T,...A]=String(_.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(R)||!/^[A-Za-z][\w-]*$/.test(T??""))throw new Error("Node ports require @port input|output|error Name");const k=A.length?JSON.parse(A.join(" ")):void 0;if(k!==void 0&&typeof k!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(v,T))throw new Error(`Duplicate port declaration: ${T}`);v[T]={kind:R,...typeof k=="string"?{label:k}:{}}}return{...m,ports:v}},d=(g,b)=>{var x,m,w;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 d(g.type,b);if(i.isUnionTypeNode(g))return{kind:"union",types:g.types.map(v=>d(v,b))};if(i.isArrayTypeNode(g))return{kind:"array",items:d(g.elementType,b)};if(i.isTypeLiteralNode(g))return c(g.members,b);if(i.isLiteralTypeNode(g)){const v=g.literal;if(i.isStringLiteral(v))return{kind:"literal",value:v.text};if(i.isNumericLiteral(v))return{kind:"literal",value:Number(v.text)};if(v.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(v.kind===i.SyntaxKind.TrueKeyword||v.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:v.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(g)&&i.isIdentifier(g.typeName)){if(n.allowJson&&g.typeName.text==="Record"&&!u.has("Record")&&((x=g.typeArguments)==null?void 0:x.length)===2&&g.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(g.typeArguments[1],b)};if(g.typeName.text==="Array"&&((m=g.typeArguments)==null?void 0:m.length)===1)return{kind:"array",items:d(g.typeArguments[0],b)};if(!((w=g.typeArguments)!=null&&w.length))return l(g.typeName.text,b)}throw new Error(`Unsupported TypeScript type: ${g.getText(s)}`)},f=r??(u.has("Graph")?"Graph":u.size===1?[...u.keys()][0]:void 0);if(!f)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(f,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function tm(e,t){const r=await Mu(e,t);if(Object.values(r.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:r.properties}}function kt(e,t){if(e.kind==="json"||t.kind==="json"||e.kind==="object"&&e.additionalProperties||t.kind==="object"&&t.additionalProperties)return!1;if(e.kind==="union")return e.types.every(r=>kt(r,t));if(t.kind==="union")return t.types.some(r=>kt(e,r));if(e.kind==="literal"){if(t.kind==="literal")return e.value===t.value;const r=e.value===null?"null":typeof e.value;return t.kind===r||t.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&t.kind==="number"?!0:e.kind==="array"&&t.kind==="array"?kt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return o?(n.optional||!o.optional)&&kt(o.type,n.type):n.optional}):e.kind===t.kind}function qu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(s,a)=>{var l;const u=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,u)?(l=e.nodes[u])==null?void 0:l.type:void 0;return a&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,a)?c.properties[a]:void 0},n=r(t.source,t.sourceProperty),o=r(t.target,t.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(!kt(n.type,o.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function nm(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const t=await e.text();if(/\.json$/i.test(e.name))return Iu(t,e.name);if(/\.ts$/i.test(e.name))return tm(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const jl=new WeakMap;function Ut(e){if(!e||typeof e!="object")return e;const t=jl.get(e);if(t)return t;const r=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Ut(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:Ut(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return jl.set(e,n),n}function yt(e,t,r){var o;const n=t.split(".");for(let i=n.length;i>0;i--){const s=n.slice(0,i).join("."),a=(o=ve(e,s))==null?void 0:o.$form;if(!(a!=null&&a.$type))continue;let u=Object.prototype.hasOwnProperty.call(r,a.$type)?r[a.$type]:void 0;for(const d of n.slice(i))(u==null?void 0:u.kind)==="array"&&/^\d+$/.test(d)?u=u.items:(u==null?void 0:u.kind)==="object"?u=Object.prototype.hasOwnProperty.call(u.properties,d)?u.properties[d].type:void 0:u=void 0;if((u==null?void 0:u.kind)!=="object")return;const c=n.slice(i).join("."),l=Object.fromEntries(Object.entries(a.$fields??{}).filter(([d])=>!c||d.startsWith(`${c}.`)).map(([d,f])=>[c?d.slice(c.length+1):d,f]));return{type:u,fields:l,binding:a}}}async function Nu(e,t){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const r=await e.text();if(e.name.endsWith(".ts")){if(!t.length||t.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(t);for(const s of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Mu(r,e.name,s,{allowJson:!0});o.push([s,a]);for(const u of Object.values(a.ports??{}))u.resourceType&&i.add(u.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Iu(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function wn(e,t){return!e||("$in"in e?e.$in.includes(ve(t,e.$address)):ve(t,e.$address)===e.$equals)}function Lt(e){const t=e.kind==="array"?e.items:e,r=t.kind==="union"?t.types:[t];if(r.every(n=>n.kind==="literal"))return r.map(n=>({label:String(n.value),value:n.value}))}function kr(e,t,r){if(t===void 0||t==="")return r?"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(t)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!kr(n,t,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return t===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(t)&&t.every(n=>!kr(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!t||typeof t!="object"||Array.isArray(t)?"Expected an object":e.additionalProperties&&Object.entries(t).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&kr(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>kr(o.type,t[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return t===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(t)?void 0:"Expected a whole number";if(typeof t!==e.kind||typeof t=="number"&&!Number.isFinite(t))return`Expected ${e.kind}`}function kl(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=r.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(a=>a.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...r].join("."),s=ve(e,i);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return ur(e,i,n,t.op==="remove"?void 0:t.value)}return mr(e,i,a=>{const u=Array.isArray(a.$)?a.$:a;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(u,n)||t.op==="set"&&Object.is(u[n],t.value))return a;const c=Array.isArray(u)?[...u]:{...u};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),u===a?c:{...a,$:c}})}function Cn(e,t,r){let n=kl(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const o=r==null?void 0:r({...t,previousValue:Ut(ve(e,t.address)),data:Ut(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=kl(n,i)}return n}function Qx(e,t){let r=e;for(const n of t){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;Ht(i),r=Cn(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Ht(r),r}function Qt(e,t,r){const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;if(!(!n||!r||!Object.prototype.hasOwnProperty.call(r,n.type)))return{address:n.address,type:r[n.type],fields:n.fields??{}}}function Ht(e){if(!(!e||typeof e!="object"))for(const[t,r]of Object.entries(e)){if(t.startsWith("$")||["__proto__","prototype","constructor"].includes(t))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${t}`);Ht(r)}}function e0(e,t,r){Ht(t.value);const n=Cn(e,t,r);return Ht(n),n}function om(e,t){const r=(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=ve(t,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 u=r(a,s);u!==a&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,s,{value:u,enumerable:!0,writable:!0,configurable:!0}))}return i};return r(e)}const Xr=(e="reference")=>({kind:e,text:"",paths:[""]}),im=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function r0(e,t){const r=new Set(t.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!im(a)||!r.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 t0(e){const t=await import("typescript"),r=s=>{const a=t.createSourceFile("binding.ts",`(${s})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const u=a.statements[0];if(!u||!t.isExpressionStatement(u))throw new Error("Unsupported reference expression.");const c=Xr();c.paths=[];const l=d=>{if(t.isParenthesizedExpression(d))return l(d.expression);if(t.isBinaryExpression(d)&&d.operatorToken.kind===t.SyntaxKind.BarBarToken){l(d.left),l(d.right);return}if(t.isStringLiteral(d)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=d.text;return}const f=d.getText(a);if(!im(f)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(f)};if(l(u.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=s=>{const a=[];let u=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const l of s.matchAll(c)){const d=l.index;if(d<u)continue;d>u&&a.push({...Xr("text"),text:s.slice(u,d)});const f=l[1].trim();if(f.startsWith("#if ")){const p=s.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...r(f.slice(4)),kind:"conditional",text:s.slice(d+l[0].length,p)}),u=p+7}else a.push(r(f)),u=d+l[0].length}return u<s.length&&a.push({...Xr("text"),text:s.slice(u)}),a},o={mode:"reference",parts:[Xr()],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,u])=>({key:a,parts:n(u)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const s=t.createSourceFile("condition.ts",`value ${i[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&t.isExpressionStatement(a)&&t.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.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 Rl({parts:e,references:t,onChange:r,disabled:n}){const o=(i,s)=>r(e.map((a,u)=>u===i?{...a,...s}:a));return h.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,s)=>h.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[h.jsxs("legend",{children:["Part ",s+1]}),h.jsxs("div",{style:{display:"flex",gap:8},children:[h.jsxs("span",{"data-form-select":"",style:{flex:1},children:[h.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:a=>o(s,{kind:a.target.value}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"text",children:"Text"}),h.jsx("option",{value:"conditional",children:"Conditional text"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),h.jsx(be,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((a,u)=>u!==s))})]}),i.kind!=="text"&&h.jsxs(h.Fragment,{children:[i.paths.map((a,u)=>h.jsxs("label",{children:["Reference ",u+1,h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":`Reference ${u+1}`,disabled:n,value:a,onChange:c=>o(s,{paths:i.paths.map((l,d)=>d===u?c.target.value:l)}),children:[h.jsx("option",{value:"",children:"Select reference"}),t.map(c=>h.jsx("option",{value:c.path,children:c.label},c.path))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},u)),i.kind==="reference"&&h.jsxs(h.Fragment,{children:[h.jsx(be,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(s,{paths:[...i.paths,""]})}),h.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.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&&h.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:a=>o(s,{fallback:a.target.value})})]})]}),i.kind!=="reference"&&h.jsxs("label",{children:["Text",h.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:a=>o(s,{text:a.target.value})})]})]},s)),h.jsx(be,{"aria-label":"Add part",title:"Add part",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,Xr()])})]})}function n0({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,s]=S.useState(),[a,u]=S.useState(""),[c,l]=S.useState(!1),d=async()=>{l(!0),u("");try{s(await t0(typeof t=="string"?t:""))}catch(f){u(f instanceof Error?f.message:"Unable to read binding.")}finally{l(!1)}};return h.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[h.jsx(be,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:h.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:d}),typeof t=="string"&&t.includes("{{")&&h.jsx("span",{children:"Bound value"}),i&&h.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Binding mode",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:f=>s({...i,mode:f.target.value,parts:[Xr()]}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"condition",children:"Equals"}),h.jsx("option",{value:"template",children:"Text template"}),h.jsx("option",{value:"json",children:"JSON output"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?h.jsxs(h.Fragment,{children:[i.fields.map((f,p)=>h.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Output field name",h.jsx("input",{"aria-label":"Output field name",value:f.key,onChange:y=>s({...i,fields:i.fields.map((g,b)=>b===p?{...g,key:y.target.value}:g)})})]}),h.jsx(Rl,{parts:f.parts,references:r,disabled:n,onChange:y=>s({...i,fields:i.fields.map((g,b)=>b===p?{...g,parts:y}:g)})}),h.jsx(be,{"aria-label":"Remove output field",title:"Remove output field",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:i.fields.filter((y,g)=>g!==p)})})]},p)),h.jsx(be,{"aria-label":"Add output field",title:"Add output field",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:[...i.fields,{key:"",parts:[Xr()]}]})})]}):h.jsx(Rl,{parts:i.parts,references:r,disabled:n,onChange:f=>s({...i,parts:f})}),i.mode==="condition"&&h.jsxs("label",{children:["Equals",h.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:f=>s({...i,comparison:f.target.value})})]}),h.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[h.jsx(be,{"aria-label":"Apply binding",title:"Apply binding",icon:h.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(r0(i,r)),s(void 0),u("")}catch(f){u(f instanceof Error?f.message:"Unable to apply binding.")}}}),h.jsx(be,{"aria-label":"Cancel binding",title:"Cancel binding",icon:h.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),u("")}})]})]}),a&&h.jsx("p",{role:"alert",children:a})]})}const o0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),i0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Rt=(e,t)=>JSON.stringify([e,t]);function Kt(e,t){if(e.kind==="union"){const r=e.types.find(n=>n.kind===(Array.isArray(t)?"array":t===null?"null":typeof t)||n.kind==="literal"&&Object.is(n.value,t));return Kt(r??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},t)}return e.kind!=="json"?e:Array.isArray(t)?{kind:"array",items:{kind:"json"}}:t!==null&&typeof t=="object"||t===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:t===null?"null":typeof t}}function Pt(e){const t=Kt(e,void 0);return t.kind==="object"?{}:t.kind==="array"?[]:t.kind==="literal"?t.value:t.kind==="number"||t.kind==="integer"?0:t.kind==="boolean"?!1:t.kind==="null"?null:""}function Pl(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"&&!Lt(e)?e.types:[e]}function a0(e,t,r){if(t.address===r.address)return;const n=ve(e,t.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,u])=>u.optional&&s[a]===void 0||o(u.type,s[a]))&&Object.entries(s).every(([a,u])=>Object.prototype.hasOwnProperty.call(i.properties,a)||!i.additionalProperties||o(i.additionalProperties,u)):s===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!kr(i,s,!0);if(o(r.type,n))return structuredClone(n)}function s0(e,t,r,n){var u,c;const o={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},i=new Set(n.map(l=>l.data.id)),s=new Map(n.flatMap(l=>{const d=t[l.data.id];return d&&r[d.type]?[[d.address,l.data.id]]:[]})),a=(l,d,f,p,y,g=!1)=>{var R,T,A,k;if(y>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const b=ve(e,d),x=Kt(f,b),m=x.kind!=="object"&&x.kind!=="array";o.containers.set(l,{address:d,type:x,declared:f,scalar:m});const w=`__form:${l}`,v={...(R=o.bindings[l])==null?void 0:R.fields},C={kind:"object",properties:{},ports:{...x.kind==="object"?x.ports:{},...g?{resource:{label:"output",...x.kind==="object"?(T=x.ports)==null?void 0:T.resource:{},kind:"output"}}:{}}},_=x.kind==="object"?{...x.properties,...Object.fromEntries(Object.keys(b??{}).filter(E=>!Object.prototype.hasOwnProperty.call(x.properties,E)&&x.additionalProperties).map(E=>[E,{type:x.additionalProperties,optional:!0}]))}:x.kind==="array"?Object.fromEntries((Array.isArray(b)?b:[]).map((E,j)=>[String(j),{type:x.items,optional:!0}])):{value:{type:Lt(f)?f:x,optional:!1}};for(const[E,j]of Object.entries(_)){if(!o0(E))throw new Error(`Unsupported structured property key: ${E}`);const M=m?d:`${d}.${E}`,I=ve(e,M),q=Kt(j.type,I),O=q.kind==="object"||q.kind==="array",V=(A=C.ports)==null?void 0:A[E],W=(V==null?void 0:V.kind)==="config"&&(((k=v[E])==null?void 0:k.$options)||Lt(j.type)),re=j.type.kind==="json"||j.type.kind==="union"&&!Lt(j.type);if(!O&&x.kind!=="array"&&(!re||m)||W){C.properties[E]={...j,type:j.type.kind==="json"?q:j.type};continue}const Y=s.get(M)??i0(M),he=x.kind==="array"?`Item ${Number(E)+1}`:E,me={address:M,owner:l,field:E,type:j.type,label:he,nodeId:Y,present:I!==void 0};if(o.slots.set(Rt(l,E),me),C.ports[E]={kind:"config",resourceType:`__form:${Y}`},I===void 0||(o.edges.push({data:{id:`__form-edge:${l}:${E}`,source:Y,target:l,sourceProperty:"output:resource",targetProperty:`config:${E}`,isEdgeDashed:!0}}),o.containers.has(Y)||s.has(M)))continue;if(i.has(Y))throw new Error(`Structured node identity conflict: ${Y}`);i.add(Y);const J={data:{id:Y,type:"objectView",label:he,headerTitle:he,description:{},config:{form:!0,icon:q.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(J),a(Y,M,j.type,p,y+1,!0);const N=o.schema[`__form:${Y}`];J.data.description=Object.fromEntries(Object.keys(N.properties).map(L=>[L,ve(e,q.kind==="array"||q.kind==="object"?`${M}.${L}`:M)]).filter(([,L])=>L!==void 0))}o.schema[w]=C,o.bindings[l]={...o.bindings[l],address:d,type:w,fields:v}};for(const l of n){const d=t[l.data.id];if(d!=null&&d.portResources)continue;const f=d&&r[d.type];!d||!f||ve(e,d.address)===void 0||a(l.data.id,d.address,f,(u=l.data.viewProps)==null?void 0:u.bgColor,0,o.edges.some(p=>p.data.source===l.data.id))}for(const l of o.edges){const d=o.bindings[l.data.source],f=o.schema[d.type].ports;f.resource={...f.resource,kind:"output",label:((c=f.resource)==null?void 0:c.label)??"output"}}return o}function c0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=S.useContext(Rr),i=Ie(),[s,a]=S.useState(""),[u,c]=S.useState("0"),[l,d]=S.useState(""),f=t==null?void 0:t.containers.get(e);if(!f||!r||!t)return null;const p=i.readOnly||i.config.editable===!1||!o,y=ve(r,f.address),g=Pl(f.declared),b=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,x=b?Pl(b):[],m=k=>k.kind==="literal"?String(k.value):k.kind==="string"?"Text":Cr(k.kind),w=[...t.slots.values()].filter(k=>k.owner===e),v=(k,E)=>{var j;return(j=n.onFormChange)==null?void 0:j.call(n,{data:r,nodeAddress:f.address,address:k,previousValue:ve(r,k),value:E})},C=k=>{var E;i.setSelectedNodeIds([k]),(E=i.engineRef.current)==null||E.focusNode(k,90,!1)},_=(k,E)=>{if(!Array.isArray(y))return;const j=[...y];[j[k],j[k+E]]=[j[k+E],j[k]],v(f.address,j)},R=()=>{const k=x[Number(u)]??x[0];if(k)if(f.type.kind==="array")v(f.address,[...Array.isArray(y)?y:[],Pt(k)]);else{if(!s||s.includes(".")||s.startsWith("$")||["__proto__","constructor","prototype"].includes(s)){d("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(y,s)){d("Property already exists.");return}v(`${f.address}.${s}`,Pt(k)),a(""),d("")}},T=f.type.kind==="object"&&!!f.type.additionalProperties,A=f.type.kind==="array";return h.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[g.length>1&&h.jsxs("label",{children:["Value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"Value type",disabled:p,value:g.findIndex(k=>Kt(k,y).kind===f.type.kind),onChange:k=>v(f.address,Pt(g[Number(k.target.value)])),children:g.map((k,E)=>h.jsx("option",{value:E,children:m(k)},E))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),w.map((k,E)=>h.jsxs("div",{"data-structured-slot":k.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[k.type.kind==="array"?h.jsx(Z.PiListNumbers,{size:20}):h.jsx(Z.PiBracketsCurly,{size:20}),h.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(k.label)}),h.jsx(be,{"aria-label":`${k.present?"Focus":"Create"} ${Cr(k.label)}`,title:`${k.present?"Focus":"Create"} ${Cr(k.label)}`,icon:k.present?h.jsx(Z.PiMagnifyingGlass,{size:18}):h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!k.present,onClick:j=>{var M;k.present?((M=j.currentTarget.closest("dialog"))==null||M.close(),C(k.nodeId)):v(k.address,Pt(k.type))}}),A&&h.jsxs(h.Fragment,{children:[h.jsx(be,{"aria-label":`Move item ${E+1} up`,icon:h.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:p||E===0,onClick:()=>_(E,-1)}),h.jsx(be,{"aria-label":`Move item ${E+1} down`,icon:h.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:p||E===w.length-1,onClick:()=>_(E,1)})]}),k.present&&h.jsx(be,{"aria-label":`Remove ${Cr(k.label)}`,icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>A?v(f.address,y.filter((j,M)=>M!==E)):v(k.address,void 0)})]},k.address)),(A||T)&&h.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&h.jsxs("label",{style:{flex:"1 1 120px",minWidth:0},children:["Property name",h.jsx("input",{"aria-label":"Property name",value:s,disabled:p,onChange:k=>a(k.target.value)})]}),x.length>1&&h.jsxs("label",{style:{flex:"1 1 100px"},children:["New value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"New value type",value:u,disabled:p,onChange:k=>c(k.target.value),children:x.map((k,E)=>h.jsx("option",{value:E,children:m(k)},E))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:h.jsx(be,{"aria-label":A?"Add item":"Add property",icon:h.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:p,onClick:R})})]}),l&&h.jsx("p",{role:"alert",children:l})]})}const Rr=S.createContext({callbacks:{}}),an=mn.default.div`
58
+ `,Gy=S.forwardRef(function({style:t,...r},n){return h.jsx(Dx,{...r,ref:n,style:{...t,backgroundImage:"none","--flow-range-track":(t==null?void 0:t.backgroundImage)??"none"}})});function xl({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:s}){const a=S.useId(),{readOnly:u,themeColor:c}=Ie(),{colorInactive:l}=He(),d=(r-o)/(i-o)*100,f=c.includes(".")?`var(--chakra-colors-${c.replace(".","-")})`:c;return h.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[h.jsxs("label",{htmlFor:a,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",h.jsx("span",{children:n})]}),h.jsx(Gy,{id:a,"aria-label":t,type:"range",min:o,max:i,step:5,value:r,disabled:u,style:{color:f,accentColor:f,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>s(Number(p.target.value))})]})}const wl={dot:{label:"Dots",icon:Z.PiDotsNine},grid:{label:"Grid",icon:Z.PiGridFour},steel:{label:"Steel",icon:Z.PiLineSegments},none:{label:"Solid",icon:Z.PiSquareFill},transparent:{label:"Transparent",icon:Z.PiSelection}};function Uy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:s,readOnly:a}=Ie(),u=wl[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:h.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:h.jsx(xl,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:c=>{var l;t(c/100),(l=s.onSpacingChange)==null||l.call(s,c/100)}}),children:h.jsx("option",{value:"spacing",children:"Spacing"})}),h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:h.jsx(xl,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:c=>{var l;n(c),(l=s.onEdgeRadiusChange)==null||l.call(s,c)}}),children:h.jsx("option",{value:"radius",children:"Edge radius"})}),h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Background variant",title:`Background: ${wl[o].label}`,icon:h.jsx(u,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:a,onValueChange:c=>{var l;i(c),(l=s.onBackgroundVariantChange)==null||l.call(s,c)},children:[h.jsx("option",{value:"dot",children:"Dots"}),h.jsx("option",{value:"grid",children:"Grid"}),h.jsx("option",{value:"steel",children:"Steel"}),h.jsx("option",{value:"none",children:"Solid"}),h.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const ir=[];for(let e=0;e<256;++e)ir.push((e+256).toString(16).slice(1));function zx(e,t=0){return(ir[e[t+0]]+ir[e[t+1]]+ir[e[t+2]]+ir[e[t+3]]+"-"+ir[e[t+4]]+ir[e[t+5]]+"-"+ir[e[t+6]]+ir[e[t+7]]+"-"+ir[e[t+8]]+ir[e[t+9]]+"-"+ir[e[t+10]]+ir[e[t+11]]+ir[e[t+12]]+ir[e[t+13]]+ir[e[t+14]]+ir[e[t+15]]).toLowerCase()}let Yn;const Vx=new Uint8Array(16);function Wx(){if(!Yn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yn=crypto.getRandomValues.bind(crypto)}return Yn(Vx)}const Gx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cl={randomUUID:Gx};function Pu(e,t,r){var o;if(Cl.randomUUID&&!e)return Cl.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??Wx();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,zx(n)}const vn={label:"Untitled",description:"",isTask:!1,isLocked:!1},Au={id:null,type:"text",data:{...vn,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"}}},_l={id:null,type:"objectView",data:{...vn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Ux={id:null,type:"arrayView",data:{...vn,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"}}},Sl={id:null,type:"workflowStep",data:{...vn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},yr=e=>typeof e=="object",Hy=e=>Array.isArray(e),Hx=["order","position","selected","locked","grabbed","grabbable","scratch"],Vr=e=>Object.entries(e).reduce((t,[r,n])=>(!yr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),Tu=(e,t)=>typeof e=="string"&&e.startsWith("$")?Xn(e,t):yr(e)&&!Hy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Xn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Xn(o,t):r[n]=o,r),{}):e,Wr=e=>Object.entries(e).reduce((t,[r,n])=>(yr(n)&&r&&n&&!r.startsWith("$")&&(Hx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Yr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(yr(i)||Hy(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),Dr=(e,t,r=null,n=null,o=null,i=!1,s=null)=>({data:{id:Pu(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:s}}),Gr=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,s]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=s:i!=="$"?n[i]=s:i==="$"&&(o=s);return{newConfig:r,updatedObject:n,arrayObject:o}},lt=(e,t)=>{let r=_l;const{view:n,borderColor:o,borderRadius:i,bgColor:s,textColor:a,fontSize:u,stepType:c}=t;e=n||e,c?r={...Sl}:e==="object"?r=_l:e==="text"?r=Au:e==="array"?r=Ux:e==="workflowStep"&&(r={...Sl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:i||(c?15:53),bgColor:s,borderColor:o,textColor:a,fontSize:u},r.data.config=t,{config:r}},Vt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Xn=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!o)return e;const i=Kx(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},Kx=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:u}=Gr(s);return s=u.length?u:s,s[a]},i))(t)};function ft(e,t="root",r=[]){try{const{arrayObject:n}=Gr(e);n.length&&(e=n);const o=Vr(e),i=Wr(e);return yr(e)?(Pe(e)||Pe(e)&&t==="root"||!Pe(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Pe(e)?qt({chldPth:null,itrblObjct:i,nodes:r,path:t}):Pe(e)&&e.forEach((s,a)=>{const u=Vr(s),c=Wr(s),{newConfig:l,arrayObject:d}=Gr(s);let f=`${t}.${a}`;yr(s)?Object.keys(u).length?(ft(u,f,r),Object.keys(c).length&&!Pe(s)&&qt({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Pe(s)?qt({chldPth:f,itrblObjct:c,nodes:r,path:t}):Pe(s)&&Ky({chldPth:f,item:s,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const qt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],s)=>{const a=Vr(i),u=Wr(i),{newConfig:c,arrayObject:l}=Gr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(yr(i)&&!Pe(i)){const f=Object.keys(a).length===0;if(f&&(lt("array",c),r.push(d)),Object.keys(a).length){const p=Pe(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let y=d;f&&(y=`${d}.${p}`),ft(i,y,r)}else Object.keys(u).length&&!Pe(i)?qt({chldPth:d,itrblObjct:u,path:d,nodes:r}):ft(i,d,r)}else Pe(i)&&ft(i,d,r)}),Ky=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let s=`${e}.${i}`;const a=Wr(o),u=Vr(o);yr(o)?!Pe(o)&&Object.keys(u).length?ft(o,s,r):Object.keys(a).length&&!Pe(o)?qt({chldPth:s,itrblObjct:a,path:n,nodes:r}):Pe(o)&&Ky({chldPth:s,item:o,nodes:r,path:n}):r.push(s)}),hn=[];let Nt;function Qr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const a=e;if(!Nt){const{nodes:l}=ft(e);Nt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=Vt(t,r);const{newConfig:l,arrayObject:d}=Gr(e),f=Object.keys(s).length>0?s:l;d.length&&(e=d);const p=Vr(e),y=Wr(e),{label:g,collapsed:b,parent:x}=f;if(!yr(e))r.push(Yr(Au,t,{label:g||t,parent:x},e,a));else if(Pe(e)||Pe(e)&&t==="root"){const{config:m}=lt("array",f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t==="root"?o:`${o} ${w}`;r.push(Yr(m,t,{label:g||v,parent:x},e,Pe(a)?{[o]:a}:a))}else if(!Pe(e)&&Object.keys(p).length||t==="root"){const{config:m}=lt(null,f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t.split("."),C=v[v.length-1];let _=isNaN(Number(C))?null:Number(C)+1;const R=isNaN(Number(C))?C:v[v.length-2]+" "+_,T=t==="root"?o:R;let A=!1;Number.isNaN(Number(o))||(A=!0);const k=e;if(g){const{config:E}=lt("object",f);r.push(Yr(E,t,{label:g||`${g} ${w}`,parent:x},p,k))}else m.data.headerTitle=T,r.push(Yr(m,t,{label:g,parent:x},p,k))}return b||(Object.keys(y).length&&!Pe(e)?$t({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:y,nodes:r,path:t,newConfig:f}):Pe(e)&&e.forEach((m,w)=>{m=Tu(m,Nt);const v=m,C=Vr(m),_=Wr(m),{newConfig:R,arrayObject:T}=Gr(m);T.length&&(m=T);const{config:A}=lt(typeof m=="string"?"text":"array",R),{hideConfig:k,sourceLabel:E,label:j,isEdgeAnimated:M,parent:I}=R;u=u||k;const q=t==="root"&&i.isCntr,O=t.split(".").slice(0,2).join("."),V=hn.includes(O),W=i.isCntr&&V||w%2===0&&q;let re=`${t}.${w}`;re=Vt(re,r),W&&hn.push(re),yr(m)?Object.keys(C).length&&!Pe(m)?(n.push(Dr(t,re,null,E,W,M)),Qr(m,re,r,n,j||w,i,R)):Object.keys(_).length&&!Pe(m)?$t({flowConfig:i,chldPth:re,isInverted:W,edges:n,itrblObjct:_,nodes:r,path:t,newConfig:R,forceIsInverted:!0}):Pe(m)?Jy({flowConfig:i,chldPth:re,edges:n,isInverted:W,item:m,nodes:r,path:t}):yr(m)&&$t({flowConfig:i,chldPth:re,isInverted:W,edges:n,itrblObjct:[m],nodes:r,path:t,newConfig:R}):(n.push(Dr(t,re,null,E,W,M)),r.push(Yr(A,re,{label:j||String(m),parent:I},m,v)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const $t=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:s,newConfig:a,forceIsInverted:u=!1})=>{let{hideDefaultObject:c,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,f],p)=>{f=Tu(f,Nt);const y=f,g=Vr(f),b=Wr(f),{newConfig:x,arrayObject:m}=Gr(f);m.length&&(f=m);const{hideConfig:w,sourceLabel:v,label:C,content:_,target:R,targetLabel:T,collapsed:A,isEdgeAnimated:k,parent:E}=x;c=c||w;const j=s==="root"&&t.isCntr,M=s.split(".").slice(0,2).join("."),I=hn.includes(M);u||(i=t.isCntr&&I||p%2===0&&j);let q=e?`${e}.${d}`:`${s}.${d}`;if(q=Vt(q,o),i&&hn.push(q),R&&r.push(Dr(q,R,null,T,i,k)),yr(f)&&!Pe(f)){r.push(Dr(s,q,null,v,i,k));const O=l||Object.keys(g).length===0;if(O){const V=_?"object":"array",{config:W}=lt(V,x);W.data.headerTitle=_?C:null,o.push(Yr(W,q,{label:C||d,parent:E},f,y))}if(Object.keys(g).length&&!c){const V=Pe(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let W=q;O&&(W=`${q}.${V}`,W=Vt(W,o),r.push(Dr(q,W,null,v,i,k))),Qr(f,W,o,r,C||d,t,x)}else Object.keys(b).length&&!Pe(f)?$t({chldPth:q,flowConfig:t,itrblObjct:b,path:q,edges:r,nodes:o,newConfig:x,isInverted:i}):Qr(f,q,o,r,d,t,x)}else Pe(f)&&(r.push(Dr(s,q,null,v,i,k)),Qr(f,q,o,r,d,t,x))})},Jy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:s})=>o.forEach((a,u)=>{let c=`${t}.${u}`;c=Vt(c,i);const l=a;a=Tu(a,Nt);const d=Wr(a),f=Vr(a),{newConfig:p}=Gr(a),{collapsed:y,label:g,parent:b,sourceLabel:x,isEdgeAnimated:m,content:w}=p;yr(a)?!Pe(a)&&Object.keys(f).length?(r.push(Dr(s,c,null,x,n,m)),Qr(a,c,i,r,u,e,p)):Object.keys(d).length&&!Pe(a)&&!y?$t({chldPth:c,flowConfig:e,itrblObjct:d,path:s,edges:r,nodes:i,isInverted:n,newConfig:p}):Pe(a)&&Jy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:a,nodes:i,path:s}):(r.push(Dr(s,c,null,x,n,m)),i.push(Yr(Au,c,{label:g||String(a),parent:b},a,l)))});function Jx(e,t){const r=new Set,n=c=>{if(!(!c||typeof c!="object")){typeof c.$parent=="string"&&r.add(c.$parent);for(const[l,d]of Object.entries(c))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const o=new Map(t.nodes.map(c=>[c.data.id,c])),i=c=>{var p,y;let l=c.data.id;const d=new Set([c.data.id]);let f=c.data.parent;for(;f&&!d.has(f);)r.has(f)&&o.has(f)&&((p=ve(e,f))!=null&&p.$collapsed)&&(l=f),d.add(f),f=(y=o.get(f))==null?void 0:y.data.parent;return l},s=new Map(t.nodes.map(c=>[c.data.id,i(c)])),a=t.nodes.filter(c=>s.get(c.data.id)===c.data.id).map(c=>{if(!r.has(c.data.id))return c;const l=ve(e,c.data.id),d=!!(l!=null&&l.$collapsed);return{...c,data:{...c.data,...d?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),u=new Set(a.map(c=>c.data.id));return{nodes:a,edges:t.edges.flatMap(c=>{const l=s.get(c.data.source),d=s.get(c.data.target);return!l||!d||!u.has(l)||!u.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 xn(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;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=t.get(i)??0;return t.set(i,s+1),[{value:o,key:`${i}#${s}`,index:n}]})}function Zy(e,t,r){const n=xn(e).find(u=>u.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((u,c)=>c===n.index?o?[o]:[]:[u]);if(i.length)return{...e,$connections:i};const{$connections:s,...a}=e;return a}function Zx(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,s)=>r(i,`${o}.${s}`));for(const i of xn(n)){const s=i.value;t.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==="$"?r(s,o):i.startsWith("$")?s:r(s,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const Wt="root",El=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Mr(e){const t=e.split(".");for(t[0]===Wt&&t.shift();t.length&&El(t[t.length-1]);)t.pop();return t.filter(r=>!El(r))}function wn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function ve(e,t){return Mr(t).reduce((r,n)=>{var o;if(r!=null)return(o=wn(r))==null?void 0:o[n]},e)}function Yx(e){return Array.isArray(e)?[...e]:{...e}}function mr(e,t,r){const n=Mr(t),o=(i,s)=>{if(s===n.length)return r(i);const a=n[s],u=wn(i);if(u==null||typeof u!="object")return i;const c=o(u[a],s+1);if(Object.is(c,u[a]))return i;const l=Yx(u);return l[a]=c,u!==i?{...i,$:l}:l};return o(e,0)}function Or(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function lr(e,t,r,n){return mr(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Or(o,r,n))}const Yy=(e,t,r)=>lr(e,t,"$collapsed",r);function Gt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.collapsedEndpoints??e,r=e.isInverted?t.target:t.source,n=e.isInverted?t.source:t.target,o=Mr(r).join("."),i=Mr(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Br(e,t,r,n){if(t.connection){const a=t.connection;return mr(e,a.address,u=>Zy(u,a.key,c=>{if(r==="$edgeIcon")return Or(c,"icon",n);if(r==="$edgeType")return Or(c,"type",n);if(r==="$edgeAnimationVariant")return Or(c,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Or(c,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:l}:c.style===l?Or(c,"style",void 0):c}))}const{address:o,kind:i}=Gt(t),s=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return mr(e,o,a=>Or(a,s,n))}const Xy=(e,t,r)=>Br(Br(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Ou(e,t,r,n){let o=n||"";const i=mr(e,t,a=>{const u=wn(a);if(Array.isArray(u)){o=String(u.length);const l=[...u,r];return u===a?l:{...a,$:l}}const c=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!o){let l=1;for(;`node_${l}`in c;)l++;o=`node_${l}`}return c[o]=r,c}),s=Mr(t);return{json:i,address:[Wt,...s,o].join(".")}}function Qy(e,t){const r=Mr(t);if(!r.length)return e;const n=r[r.length-1],o=[Wt,...r.slice(0,-1)].join(".");return mr(e,o,i=>{const s=wn(i);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return i;if(Array.isArray(s)){const c=s.filter((l,d)=>String(d)!==n);return s===i?c:{...i,$:c}}const{[n]:a,...u}=i;return u})}const em=(e,t,r,n)=>lr(n?mr(e,t,o=>Or(o,"$targetLabel",n)):e,t,"$target",r);function Iu(e,t,r){const n=ve(e,t);return xn(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:mr(e,t,i=>Or(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||Pu()}]))}function rm(e,t){if(t.connection){const i=t.connection;return xn(ve(e,i.address)).some(s=>s.key===i.key)?{json:mr(e,i.address,s=>Zy(s,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=Gt(t);return n==="hierarchy"?ve(e,r)===void 0?{json:e,removed:!1}:{json:mr(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:mr(e,r,i=>{const{$target:s,$targetLabel:a,...u}=i||{};return u}),removed:!0}}function wu(e,t={}){var x;const r=Zx(e),{nodes:n,edges:o}=Qr(r.json,Wt,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(m=>m.data.id)),s=new Map;for(const m of n){const w=m.data.id;if(!w.endsWith(".0")||ve(e,w)!==void 0)continue;const v=w.slice(0,-2),C=ve(e,v);!i.has(v)&&C&&typeof C=="object"&&!Array.isArray(C)&&typeof C.$label=="string"&&Object.keys(C).every(_=>_.startsWith("$")&&_!=="$")&&s.set(w,v)}const a=m=>s.get(m)??m,u=new Set(n.flatMap(m=>m.data.parent?[a(m.data.parent)]:[])),c=n.map(m=>{var T;const w=a(m.data.id),v=ve(e,w),C={...m.data,id:w},_=v&&typeof v=="object"&&!Array.isArray(v)&&"$"in v?v.$:v;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(A=>!A.startsWith("$")))&&(C.config={...C.config,collapsed:!!v.$collapsed}),u.has(w)||(C.viewProps={...C.viewProps},delete C.viewProps.borderWidth),!v||typeof v!="object"||Array.isArray(v))return{data:C};if(v.$form&&typeof v.$form=="object"&&(C.config={...C.config,form:v.$form},C.type="objectView"),Array.isArray(v.$ports)){const A=v.$ports.filter(k=>k&&typeof k.id=="string"&&["source","target"].includes(k.role)&&["top","right","bottom","left"].includes(k.side));C.config={...C.config,ports:A}}return C.parent&&(C.parent=a(C.parent)),typeof v.$label=="string"&&(C.label=v.$label,C.headerTitle=v.$label),typeof v.$subtitle=="string"&&(C.config={...C.config,subtitle:v.$subtitle}),typeof v.$outline=="boolean"&&(C.viewProps={...C.viewProps,outline:v.$outline}),["solid","dashed","dotted","double"].includes(v.$borderStyle)&&(C.viewProps={...C.viewProps,borderStyle:v.$borderStyle}),Number.isFinite(v.$borderWidth)&&v.$borderWidth>=0&&(C.viewProps={...C.viewProps,borderWidth:v.$borderWidth}),Number.isFinite(v.$borderRadius)&&v.$borderRadius>=0&&(C.viewProps={...C.viewProps,borderRadius:v.$borderRadius}),typeof v.$isNodeAnimated=="boolean"&&(C.isNodeAnimated=v.$isNodeAnimated),["traveling","pulse"].includes(v.$nodeAnimationVariant)&&(C.nodeAnimationVariant=v.$nodeAnimationVariant),typeof v.$content=="string"&&(C.config={...C.config,content:v.$content},v.$view||(C.type="objectView")),(((T=C.config)==null?void 0:T.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(C.config={...C.config||{}},(v.$collapsed!==void 0||C.config.collapsed!==void 0)&&(C.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(C.config.icon=v.$icon)),{data:C}}),l=new Map,d=o.map(m=>{const w=a(m.data.source),v=a(m.data.target),C=`${w}->${v}`,_=l.get(C)??0;l.set(C,_+1);const R={...m.data,id:_?`${C}#${_}`:C,source:w,target:v},T=Gt(R),A=ve(e,T.address);if(A&&typeof A=="object"){const k=A[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof k=="string"&&(R.type=k);const E=A[T.kind==="target"?"$targetIcon":"$edgeIcon"];typeof E=="string"&&(R.icon=E),A.$isEdgeAnimated!==void 0&&(R.isEdgeAnimated=!!A.$isEdgeAnimated);const j=A[T.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(j)&&(R.edgeAnimationVariant=j),A.$isEdgeDashed!==void 0&&(R.isEdgeDashed=!!A.$isEdgeDashed),A.$edgeColor&&(R.color=A.$edgeColor)}return{data:R}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const m=c.findIndex(w=>w.data.id===Wt);m!==-1&&c.splice(m,1)}const f=new Set(c.map(m=>m.data.id));for(let m=d.length-1;m>=0;m--){const w=d[m].data,v=Gt(w);(!f.has(w.source)||!f.has(w.target)||v.kind==="hierarchy"&&((x=ve(e,v.address))==null?void 0:x.$hideParentEdge)===!0)&&d.splice(m,1)}d.push(...r.edges.filter(m=>f.has(m.data.source)&&f.has(m.data.target)));const p=Jx(e,{nodes:c,edges:d}),y=p.nodes.filter(m=>{var w;return(w=m.data.config)==null?void 0:w.collapsed}).map(m=>Mr(m.data.id));if(!y.length)return p;const g=p.nodes.filter(m=>{const w=Mr(m.data.id);return!y.some(v=>v.length<w.length&&v.every((C,_)=>C===w[_]))}),b=new Set(g.map(m=>m.data.id));return{nodes:g,edges:p.edges.filter(m=>b.has(m.data.source)&&b.has(m.data.target))}}function Xx(e,t){const r=new Set(e.filter(u=>{var c,l;return(l=(c=u.data)==null?void 0:c.config)==null?void 0:l.collapsed}).map(u=>u.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(u=>[u.data.id,u])),o=new Set(e.map(u=>u.data.parent).filter(Boolean)),i=new Map(e.map(u=>{var f;let c=u.data.id,l=u.data.parent;const d=new Set([c]);for(;l&&!d.has(l);)r.has(l)&&(c=l),d.add(l),l=(f=n.get(l))==null?void 0:f.data.parent;return[u.data.id,c]})),s=new Map;for(const u of t){const c=u.data.isInverted?u.data.target:u.data.source,l=u.data.isInverted?u.data.source:u.data.target;(s.get(c)??s.set(c,[]).get(c)).push(l)}const a=new Set(e.filter(u=>i.get(u.data.id)!==u.data.id).map(u=>u.data.id));for(const u of r){if(o.has(u))continue;const c=[...s.get(u)||[]];for(;c.length;){const l=c.pop();r.has(l)||a.has(l)||(a.add(l),c.push(...s.get(l)||[]))}}return{nodes:e.filter(u=>!a.has(u.data.id)).map(u=>{var c;return r.has(u.data.id)&&o.has(u.data.id)?{...u,data:{...u.data,type:"arrayView",label:u.data.label??u.data.headerTitle,config:{...u.data.config,parentContainer:!0,labelBelow:!0,icon:((c=u.data.config)==null?void 0:c.icon)||"PiStack"}}}:u}),edges:t.flatMap(u=>{const c=i.get(u.data.source)??u.data.source,l=i.get(u.data.target)??u.data.target;return a.has(c)||a.has(l)?[]:c===u.data.source&&l===u.data.target?[u]:c===l?[]:[{...u,data:{...u.data,source:c,target:l,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Mu(e,t){const r=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 u=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const l of Object.keys(s))if(!u.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(d=>!["$ref","title","description"].includes(d)))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 l=r;for(const d of s.$ref.slice(2).split("/")){const f=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,f))throw new Error(`Unresolved reference: ${s.$ref}`);l=l[f]}return o(l,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(l=>l!=="anyOf"&&!c.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(l=>o(l,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(f=>![...c,"const","enum","type"].includes(f))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(f=>{if(f!==null&&!["string","number","boolean"].includes(typeof f))throw new Error("Only primitive literals are supported.");const p=f===null?"null":typeof f;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(y=>y===p||y==="integer"&&Number.isInteger(f)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:f}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(l=>l!=="type"&&!c.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(l=>o({type:l},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(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(s.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([d,f])=>[d,{type:o(f,a),optional:!(s.required??[]).includes(d)}]))}}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(r);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:t,nodes:i.properties}}async function qu(e,t,r,n={}){var y;let o=512;const i=await import("typescript"),s=i.createSourceFile(t,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const u=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((y=g.typeParameters)!=null&&y.length||u.has(g.name.text))throw new Error("Generics and duplicate declarations are not supported.");u.set(g.name.text,g)}const c=(g,b)=>{var C;const x={},m=g.find(_=>i.isIndexSignatureDeclaration(_));let w;if(m&&n.allowJson&&i.isIndexSignatureDeclaration(m)){if(g.filter(_=>i.isIndexSignatureDeclaration(_)).length!==1||m.parameters.length!==1||((C=m.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!m.type)throw new Error("Only one string-keyed index signature is supported for forms.");w=d(m.type,b)}return{kind:"object",properties:Object.fromEntries(g.filter(_=>_!==m||!w).map(_=>{if(!i.isPropertySignature(_)||!_.type||!_.name||!i.isIdentifier(_.name)&&!i.isStringLiteral(_.name))throw new Error("Only explicitly typed named properties are supported.");const R=d(_.type,b),T=n.allowJson?i.getJSDocTags(_).filter(A=>A.tagName.text==="port"):[];if(T.length>1)throw new Error(`Duplicate port declaration: ${_.name.text}`);if(T.length){const[A,k,E]=String(T[0].comment??"").trim().split(/\s+/);if(A!=="config"||!k||E||!u.has(k))throw new Error(`Config port ${_.name.text} requires @port config ResourceType`);const j=R.kind==="array";if((R.kind==="array"?R.items.kind:R.kind)!=="string")throw new Error(`Config port ${_.name.text} must be a string or string array reference`);x[_.name.text]={kind:"config",resourceType:k,multiple:j}}return[_.name.text,{type:R,optional:!!_.questionToken}]})),...w?{additionalProperties:w}:{},...Object.keys(x).length?{ports:x}:{}}},l=(g,b)=>{var C;if(b.includes(g))throw new Error("Recursive types are not supported.");const x=u.get(g);if(!x)throw new Error(`Unknown type: ${g}`);let m;if(i.isInterfaceDeclaration(x)){if((C=x.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");m=c(x.members,[...b,g])}else m=d(x.type,[...b,g]);const w=n.allowJson?i.getJSDocTags(x).filter(_=>_.tagName.text==="port"):[];if(!w.length)return m;if(m.kind!=="object")throw new Error("Node ports require an object interface");const v={...m.ports};for(const _ of w){const[R,T,...A]=String(_.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(R)||!/^[A-Za-z][\w-]*$/.test(T??""))throw new Error("Node ports require @port input|output|error Name");const k=A.length?JSON.parse(A.join(" ")):void 0;if(k!==void 0&&typeof k!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(v,T))throw new Error(`Duplicate port declaration: ${T}`);v[T]={kind:R,...typeof k=="string"?{label:k}:{}}}return{...m,ports:v}},d=(g,b)=>{var x,m,w;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 d(g.type,b);if(i.isUnionTypeNode(g))return{kind:"union",types:g.types.map(v=>d(v,b))};if(i.isArrayTypeNode(g))return{kind:"array",items:d(g.elementType,b)};if(i.isTypeLiteralNode(g))return c(g.members,b);if(i.isLiteralTypeNode(g)){const v=g.literal;if(i.isStringLiteral(v))return{kind:"literal",value:v.text};if(i.isNumericLiteral(v))return{kind:"literal",value:Number(v.text)};if(v.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(v.kind===i.SyntaxKind.TrueKeyword||v.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:v.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(g)&&i.isIdentifier(g.typeName)){if(n.allowJson&&g.typeName.text==="Record"&&!u.has("Record")&&((x=g.typeArguments)==null?void 0:x.length)===2&&g.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(g.typeArguments[1],b)};if(g.typeName.text==="Array"&&((m=g.typeArguments)==null?void 0:m.length)===1)return{kind:"array",items:d(g.typeArguments[0],b)};if(!((w=g.typeArguments)!=null&&w.length))return l(g.typeName.text,b)}throw new Error(`Unsupported TypeScript type: ${g.getText(s)}`)},f=r??(u.has("Graph")?"Graph":u.size===1?[...u.keys()][0]:void 0);if(!f)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(f,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function tm(e,t){const r=await qu(e,t);if(Object.values(r.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:r.properties}}function kt(e,t){if(e.kind==="json"||t.kind==="json"||e.kind==="object"&&e.additionalProperties||t.kind==="object"&&t.additionalProperties)return!1;if(e.kind==="union")return e.types.every(r=>kt(r,t));if(t.kind==="union")return t.types.some(r=>kt(e,r));if(e.kind==="literal"){if(t.kind==="literal")return e.value===t.value;const r=e.value===null?"null":typeof e.value;return t.kind===r||t.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&t.kind==="number"?!0:e.kind==="array"&&t.kind==="array"?kt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return o?(n.optional||!o.optional)&&kt(o.type,n.type):n.optional}):e.kind===t.kind}function Nu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(s,a)=>{var l;const u=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,u)?(l=e.nodes[u])==null?void 0:l.type:void 0;return a&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,a)?c.properties[a]:void 0},n=r(t.source,t.sourceProperty),o=r(t.target,t.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(!kt(n.type,o.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function nm(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const t=await e.text();if(/\.json$/i.test(e.name))return Mu(t,e.name);if(/\.ts$/i.test(e.name))return tm(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const jl=new WeakMap;function Ut(e){if(!e||typeof e!="object")return e;const t=jl.get(e);if(t)return t;const r=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Ut(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:Ut(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return jl.set(e,n),n}function yt(e,t,r){var o;const n=t.split(".");for(let i=n.length;i>0;i--){const s=n.slice(0,i).join("."),a=(o=ve(e,s))==null?void 0:o.$form;if(!(a!=null&&a.$type))continue;let u=Object.prototype.hasOwnProperty.call(r,a.$type)?r[a.$type]:void 0;for(const d of n.slice(i))(u==null?void 0:u.kind)==="array"&&/^\d+$/.test(d)?u=u.items:(u==null?void 0:u.kind)==="object"?u=Object.prototype.hasOwnProperty.call(u.properties,d)?u.properties[d].type:void 0:u=void 0;if((u==null?void 0:u.kind)!=="object")return;const c=n.slice(i).join("."),l=Object.fromEntries(Object.entries(a.$fields??{}).filter(([d])=>!c||d.startsWith(`${c}.`)).map(([d,f])=>[c?d.slice(c.length+1):d,f]));return{type:u,fields:l,binding:a}}}async function $u(e,t){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const r=await e.text();if(e.name.endsWith(".ts")){if(!t.length||t.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(t);for(const s of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await qu(r,e.name,s,{allowJson:!0});o.push([s,a]);for(const u of Object.values(a.ports??{}))u.resourceType&&i.add(u.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Mu(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function Cn(e,t){return!e||("$in"in e?e.$in.includes(ve(t,e.$address)):ve(t,e.$address)===e.$equals)}function Lt(e){const t=e.kind==="array"?e.items:e,r=t.kind==="union"?t.types:[t];if(r.every(n=>n.kind==="literal"))return r.map(n=>({label:String(n.value),value:n.value}))}function kr(e,t,r){if(t===void 0||t==="")return r?"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(t)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!kr(n,t,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return t===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(t)&&t.every(n=>!kr(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!t||typeof t!="object"||Array.isArray(t)?"Expected an object":e.additionalProperties&&Object.entries(t).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&kr(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>kr(o.type,t[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return t===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(t)?void 0:"Expected a whole number";if(typeof t!==e.kind||typeof t=="number"&&!Number.isFinite(t))return`Expected ${e.kind}`}function kl(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=r.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(a=>a.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...r].join("."),s=ve(e,i);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return lr(e,i,n,t.op==="remove"?void 0:t.value)}return mr(e,i,a=>{const u=Array.isArray(a.$)?a.$:a;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(u,n)||t.op==="set"&&Object.is(u[n],t.value))return a;const c=Array.isArray(u)?[...u]:{...u};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),u===a?c:{...a,$:c}})}function _n(e,t,r){let n=kl(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const o=r==null?void 0:r({...t,previousValue:Ut(ve(e,t.address)),data:Ut(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=kl(n,i)}return n}function Qx(e,t){let r=e;for(const n of t){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;Ht(i),r=_n(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Ht(r),r}function Qt(e,t,r){const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;if(!(!n||!r||!Object.prototype.hasOwnProperty.call(r,n.type)))return{address:n.address,type:r[n.type],fields:n.fields??{}}}function Ht(e){if(!(!e||typeof e!="object"))for(const[t,r]of Object.entries(e)){if(t.startsWith("$")||["__proto__","prototype","constructor"].includes(t))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${t}`);Ht(r)}}function e0(e,t,r){Ht(t.value);const n=_n(e,t,r);return Ht(n),n}function om(e,t){const r=(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=ve(t,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 u=r(a,s);u!==a&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,s,{value:u,enumerable:!0,writable:!0,configurable:!0}))}return i};return r(e)}const Xr=(e="reference")=>({kind:e,text:"",paths:[""]}),im=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function r0(e,t){const r=new Set(t.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!im(a)||!r.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 t0(e){const t=await import("typescript"),r=s=>{const a=t.createSourceFile("binding.ts",`(${s})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const u=a.statements[0];if(!u||!t.isExpressionStatement(u))throw new Error("Unsupported reference expression.");const c=Xr();c.paths=[];const l=d=>{if(t.isParenthesizedExpression(d))return l(d.expression);if(t.isBinaryExpression(d)&&d.operatorToken.kind===t.SyntaxKind.BarBarToken){l(d.left),l(d.right);return}if(t.isStringLiteral(d)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=d.text;return}const f=d.getText(a);if(!im(f)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(f)};if(l(u.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=s=>{const a=[];let u=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const l of s.matchAll(c)){const d=l.index;if(d<u)continue;d>u&&a.push({...Xr("text"),text:s.slice(u,d)});const f=l[1].trim();if(f.startsWith("#if ")){const p=s.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...r(f.slice(4)),kind:"conditional",text:s.slice(d+l[0].length,p)}),u=p+7}else a.push(r(f)),u=d+l[0].length}return u<s.length&&a.push({...Xr("text"),text:s.slice(u)}),a},o={mode:"reference",parts:[Xr()],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,u])=>({key:a,parts:n(u)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const s=t.createSourceFile("condition.ts",`value ${i[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&t.isExpressionStatement(a)&&t.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.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 Rl({parts:e,references:t,onChange:r,disabled:n}){const o=(i,s)=>r(e.map((a,u)=>u===i?{...a,...s}:a));return h.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,s)=>h.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[h.jsxs("legend",{children:["Part ",s+1]}),h.jsxs("div",{style:{display:"flex",gap:8},children:[h.jsxs("span",{"data-form-select":"",style:{flex:1},children:[h.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:a=>o(s,{kind:a.target.value}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"text",children:"Text"}),h.jsx("option",{value:"conditional",children:"Conditional text"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),h.jsx(be,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((a,u)=>u!==s))})]}),i.kind!=="text"&&h.jsxs(h.Fragment,{children:[i.paths.map((a,u)=>h.jsxs("label",{children:["Reference ",u+1,h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":`Reference ${u+1}`,disabled:n,value:a,onChange:c=>o(s,{paths:i.paths.map((l,d)=>d===u?c.target.value:l)}),children:[h.jsx("option",{value:"",children:"Select reference"}),t.map(c=>h.jsx("option",{value:c.path,children:c.label},c.path))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},u)),i.kind==="reference"&&h.jsxs(h.Fragment,{children:[h.jsx(be,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(s,{paths:[...i.paths,""]})}),h.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.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&&h.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:a=>o(s,{fallback:a.target.value})})]})]}),i.kind!=="reference"&&h.jsxs("label",{children:["Text",h.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:a=>o(s,{text:a.target.value})})]})]},s)),h.jsx(be,{"aria-label":"Add part",title:"Add part",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,Xr()])})]})}function n0({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,s]=S.useState(),[a,u]=S.useState(""),[c,l]=S.useState(!1),d=async()=>{l(!0),u("");try{s(await t0(typeof t=="string"?t:""))}catch(f){u(f instanceof Error?f.message:"Unable to read binding.")}finally{l(!1)}};return h.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[h.jsx(be,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:h.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:d}),typeof t=="string"&&t.includes("{{")&&h.jsx("span",{children:"Bound value"}),i&&h.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Binding mode",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:f=>s({...i,mode:f.target.value,parts:[Xr()]}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"condition",children:"Equals"}),h.jsx("option",{value:"template",children:"Text template"}),h.jsx("option",{value:"json",children:"JSON output"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?h.jsxs(h.Fragment,{children:[i.fields.map((f,p)=>h.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Output field name",h.jsx("input",{"aria-label":"Output field name",value:f.key,onChange:y=>s({...i,fields:i.fields.map((g,b)=>b===p?{...g,key:y.target.value}:g)})})]}),h.jsx(Rl,{parts:f.parts,references:r,disabled:n,onChange:y=>s({...i,fields:i.fields.map((g,b)=>b===p?{...g,parts:y}:g)})}),h.jsx(be,{"aria-label":"Remove output field",title:"Remove output field",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:i.fields.filter((y,g)=>g!==p)})})]},p)),h.jsx(be,{"aria-label":"Add output field",title:"Add output field",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:[...i.fields,{key:"",parts:[Xr()]}]})})]}):h.jsx(Rl,{parts:i.parts,references:r,disabled:n,onChange:f=>s({...i,parts:f})}),i.mode==="condition"&&h.jsxs("label",{children:["Equals",h.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:f=>s({...i,comparison:f.target.value})})]}),h.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[h.jsx(be,{"aria-label":"Apply binding",title:"Apply binding",icon:h.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(r0(i,r)),s(void 0),u("")}catch(f){u(f instanceof Error?f.message:"Unable to apply binding.")}}}),h.jsx(be,{"aria-label":"Cancel binding",title:"Cancel binding",icon:h.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),u("")}})]})]}),a&&h.jsx("p",{role:"alert",children:a})]})}const o0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),i0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Rt=(e,t)=>JSON.stringify([e,t]);function Kt(e,t){if(e.kind==="union"){const r=e.types.find(n=>n.kind===(Array.isArray(t)?"array":t===null?"null":typeof t)||n.kind==="literal"&&Object.is(n.value,t));return Kt(r??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},t)}return e.kind!=="json"?e:Array.isArray(t)?{kind:"array",items:{kind:"json"}}:t!==null&&typeof t=="object"||t===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:t===null?"null":typeof t}}function Pt(e){const t=Kt(e,void 0);return t.kind==="object"?{}:t.kind==="array"?[]:t.kind==="literal"?t.value:t.kind==="number"||t.kind==="integer"?0:t.kind==="boolean"?!1:t.kind==="null"?null:""}function Pl(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"&&!Lt(e)?e.types:[e]}function a0(e,t,r){if(t.address===r.address)return;const n=ve(e,t.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,u])=>u.optional&&s[a]===void 0||o(u.type,s[a]))&&Object.entries(s).every(([a,u])=>Object.prototype.hasOwnProperty.call(i.properties,a)||!i.additionalProperties||o(i.additionalProperties,u)):s===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!kr(i,s,!0);if(o(r.type,n))return structuredClone(n)}function s0(e,t,r,n){var u,c;const o={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},i=new Set(n.map(l=>l.data.id)),s=new Map(n.flatMap(l=>{const d=t[l.data.id];return d&&r[d.type]?[[d.address,l.data.id]]:[]})),a=(l,d,f,p,y,g=!1)=>{var R,T,A,k;if(y>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const b=ve(e,d),x=Kt(f,b),m=x.kind!=="object"&&x.kind!=="array";o.containers.set(l,{address:d,type:x,declared:f,scalar:m});const w=`__form:${l}`,v={...(R=o.bindings[l])==null?void 0:R.fields},C={kind:"object",properties:{},ports:{...x.kind==="object"?x.ports:{},...g?{resource:{label:"output",...x.kind==="object"?(T=x.ports)==null?void 0:T.resource:{},kind:"output"}}:{}}},_=x.kind==="object"?{...x.properties,...Object.fromEntries(Object.keys(b??{}).filter(E=>!Object.prototype.hasOwnProperty.call(x.properties,E)&&x.additionalProperties).map(E=>[E,{type:x.additionalProperties,optional:!0}]))}:x.kind==="array"?Object.fromEntries((Array.isArray(b)?b:[]).map((E,j)=>[String(j),{type:x.items,optional:!0}])):{value:{type:Lt(f)?f:x,optional:!1}};for(const[E,j]of Object.entries(_)){if(!o0(E))throw new Error(`Unsupported structured property key: ${E}`);const M=m?d:`${d}.${E}`,I=ve(e,M),q=Kt(j.type,I),O=q.kind==="object"||q.kind==="array",V=(A=C.ports)==null?void 0:A[E],W=(V==null?void 0:V.kind)==="config"&&(((k=v[E])==null?void 0:k.$options)||Lt(j.type)),re=j.type.kind==="json"||j.type.kind==="union"&&!Lt(j.type);if(!O&&x.kind!=="array"&&(!re||m)||W){C.properties[E]={...j,type:j.type.kind==="json"?q:j.type};continue}const Y=s.get(M)??i0(M),he=x.kind==="array"?`Item ${Number(E)+1}`:E,me={address:M,owner:l,field:E,type:j.type,label:he,nodeId:Y,present:I!==void 0};if(o.slots.set(Rt(l,E),me),C.ports[E]={kind:"config",resourceType:`__form:${Y}`},I===void 0||(o.edges.push({data:{id:`__form-edge:${l}:${E}`,source:Y,target:l,sourceProperty:"output:resource",targetProperty:`config:${E}`,isEdgeDashed:!0}}),o.containers.has(Y)||s.has(M)))continue;if(i.has(Y))throw new Error(`Structured node identity conflict: ${Y}`);i.add(Y);const J={data:{id:Y,type:"objectView",label:he,headerTitle:he,description:{},config:{form:!0,icon:q.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(J),a(Y,M,j.type,p,y+1,!0);const N=o.schema[`__form:${Y}`];J.data.description=Object.fromEntries(Object.keys(N.properties).map(L=>[L,ve(e,q.kind==="array"||q.kind==="object"?`${M}.${L}`:M)]).filter(([,L])=>L!==void 0))}o.schema[w]=C,o.bindings[l]={...o.bindings[l],address:d,type:w,fields:v}};for(const l of n){const d=t[l.data.id];if(d!=null&&d.portResources)continue;const f=d&&r[d.type];!d||!f||ve(e,d.address)===void 0||a(l.data.id,d.address,f,(u=l.data.viewProps)==null?void 0:u.bgColor,0,o.edges.some(p=>p.data.source===l.data.id))}for(const l of o.edges){const d=o.bindings[l.data.source],f=o.schema[d.type].ports;f.resource={...f.resource,kind:"output",label:((c=f.resource)==null?void 0:c.label)??"output"}}return o}function c0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=S.useContext(Rr),i=Ie(),[s,a]=S.useState(""),[u,c]=S.useState("0"),[l,d]=S.useState(""),f=t==null?void 0:t.containers.get(e);if(!f||!r||!t)return null;const p=i.readOnly||i.config.editable===!1||!o,y=ve(r,f.address),g=Pl(f.declared),b=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,x=b?Pl(b):[],m=k=>k.kind==="literal"?String(k.value):k.kind==="string"?"Text":Cr(k.kind),w=[...t.slots.values()].filter(k=>k.owner===e),v=(k,E)=>{var j;return(j=n.onFormChange)==null?void 0:j.call(n,{data:r,nodeAddress:f.address,address:k,previousValue:ve(r,k),value:E})},C=k=>{var E;i.setSelectedNodeIds([k]),(E=i.engineRef.current)==null||E.focusNode(k,90,!1)},_=(k,E)=>{if(!Array.isArray(y))return;const j=[...y];[j[k],j[k+E]]=[j[k+E],j[k]],v(f.address,j)},R=()=>{const k=x[Number(u)]??x[0];if(k)if(f.type.kind==="array")v(f.address,[...Array.isArray(y)?y:[],Pt(k)]);else{if(!s||s.includes(".")||s.startsWith("$")||["__proto__","constructor","prototype"].includes(s)){d("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(y,s)){d("Property already exists.");return}v(`${f.address}.${s}`,Pt(k)),a(""),d("")}},T=f.type.kind==="object"&&!!f.type.additionalProperties,A=f.type.kind==="array";return h.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[g.length>1&&h.jsxs("label",{children:["Value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"Value type",disabled:p,value:g.findIndex(k=>Kt(k,y).kind===f.type.kind),onChange:k=>v(f.address,Pt(g[Number(k.target.value)])),children:g.map((k,E)=>h.jsx("option",{value:E,children:m(k)},E))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),w.map((k,E)=>h.jsxs("div",{"data-structured-slot":k.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[k.type.kind==="array"?h.jsx(Z.PiListNumbers,{size:20}):h.jsx(Z.PiBracketsCurly,{size:20}),h.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(k.label)}),h.jsx(be,{"aria-label":`${k.present?"Focus":"Create"} ${Cr(k.label)}`,title:`${k.present?"Focus":"Create"} ${Cr(k.label)}`,icon:k.present?h.jsx(Z.PiMagnifyingGlass,{size:18}):h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!k.present,onClick:j=>{var M;k.present?((M=j.currentTarget.closest("dialog"))==null||M.close(),C(k.nodeId)):v(k.address,Pt(k.type))}}),A&&h.jsxs(h.Fragment,{children:[h.jsx(be,{"aria-label":`Move item ${E+1} up`,icon:h.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:p||E===0,onClick:()=>_(E,-1)}),h.jsx(be,{"aria-label":`Move item ${E+1} down`,icon:h.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:p||E===w.length-1,onClick:()=>_(E,1)})]}),k.present&&h.jsx(be,{"aria-label":`Remove ${Cr(k.label)}`,icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>A?v(f.address,y.filter((j,M)=>M!==E)):v(k.address,void 0)})]},k.address)),(A||T)&&h.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&h.jsxs("label",{style:{flex:"1 1 120px",minWidth:0},children:["Property name",h.jsx("input",{"aria-label":"Property name",value:s,disabled:p,onChange:k=>a(k.target.value)})]}),x.length>1&&h.jsxs("label",{style:{flex:"1 1 100px"},children:["New value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"New value type",value:u,disabled:p,onChange:k=>c(k.target.value),children:x.map((k,E)=>h.jsx("option",{value:E,children:m(k)},E))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:h.jsx(be,{"aria-label":A?"Add item":"Add property",icon:h.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:p,onClick:R})})]}),l&&h.jsx("p",{role:"alert",children:l})]})}const Rr=S.createContext({callbacks:{}}),sn=bn.default.div`
59
59
  padding: 0;
60
60
  font-size: 16px;
61
61
  line-height: 1.4;
@@ -153,8 +153,8 @@
153
153
  font-size: 14px;
154
154
  margin-top: 8px;
155
155
  }
156
- `;function Al({request:e,property:t,config:r,value:n,disabled:o}){var L,G;const{callbacks:i,structured:s,references:a}=S.useContext(Rr),{themeColor:u}=Ie(),{background:c}=He(),l=S.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",f=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,y]=S.useState(f),[g,b]=S.useState(""),[x,m]=S.useState(0),[w,v]=S.useState(),C=((L=r.$options)==null?void 0:L.$source)==="callback",_=i.resolveFormOptions,{data:R,address:T,nodeAddress:A,nodeId:k}=e,E=S.useRef(R);E.current=R;const j=JSON.stringify([T,k,(G=r.$options)!=null&&G.$dependsOn?r.$options.$dependsOn.map(D=>ve(R,D)):ve(R,A)]);S.useEffect(()=>{y(f),b("")},[f,T,k]),S.useEffect(()=>{if(!C)return;const D=new AbortController;return Promise.resolve().then(()=>{if(!_)throw new Error("No options resolver configured");return _({address:T,nodeAddress:A,nodeId:k,data:Ut(E.current),signal:D.signal})}).then(ne=>{if(!Array.isArray(ne)||ne.some(ue=>!ue||typeof ue.label!="string"||!["string","number","boolean"].includes(typeof ue.value)&&ue.value!==null))throw new Error("Invalid options response");D.signal.aborted||v({key:j,options:ne})}).catch(ne=>{D.signal.aborted||v({key:j,options:[],error:ne instanceof Error?ne.message:"Options unavailable"})}),()=>D.abort()},[C,_,j,T,A,k,x]);const M=C&&(w==null?void 0:w.key)!==j,I=C?(w==null?void 0:w.key)===j?w.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Lt(t.type),q=t.type.kind==="array",O=(s&&d||r.$control==="checkbox"?"pills":r.$control)??(I?q||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),V=!t.optional||!!r.$requiredWhen&&wn(r.$requiredWhen,R),W=!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),re=g||C&&(w==null?void 0:w.key)===j&&w.error||!W&&kr(t.type,n,V),Y=Cr(r.$label??T.split(".").pop()),he=D=>{var ne;if(!(o||Object.is(D,n)))try{(ne=i.onFormChange)==null||ne.call(i,{...e,previousValue:n,value:D}),b("")}catch(ue){b(ue instanceof Error?ue.message:"Unable to update field")}},me=()=>{if(d){try{const X=p===""&&t.optional?void 0:JSON.parse(p),U=kr(t.type,X,V);if(U){b(U);return}he(X)}catch{b("Enter valid JSON")}return}const D=t.type.kind==="number"||t.type.kind==="integer",ne=p===""&&t.optional?void 0:D&&p!==""?Number(p):p,ue=kr(t.type,ne,V);if(D&&ue&&p!==""){b(ue);return}he(ne)},J={id:l,disabled:o,"aria-label":Y,"aria-required":V,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},N=fe(u);return h.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(A.length+1),children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsxs("label",{htmlFor:l,children:[Y,V?" *":""]}),t.optional&&n!==void 0&&h.jsx("button",{type:"button","aria-label":`Reset ${Y}`,title:`Reset ${Y}`,disabled:o,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>he(void 0),children:h.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!d&&h.jsx(n0,{label:Y,value:n,references:a,disabled:o,onChange:he}),W?null:O==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...J,disabled:o||M||!!(w!=null&&w.error),value:(I==null?void 0:I.findIndex(D=>Object.is(D.value,n)))??-1,onChange:D=>{const ne=I==null?void 0:I[Number(D.target.value)];ne&&he(ne.value)},children:[h.jsx("option",{value:-1,disabled:!0,children:n!==void 0?String(n):""}),I==null?void 0:I.map((D,ne)=>h.jsx("option",{value:ne,style:{background:fe(c)},children:Cr(D.label)||D.label},ne))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}):O==="pills"?h.jsxs("div",{id:l,role:"group","aria-label":Y,"aria-describedby":J["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[I==null?void 0:I.map((D,ne)=>{const ue=q?Array.isArray(n)&&n.includes(D.value):Object.is(n,D.value);return h.jsx("button",{type:"button",disabled:o||M,"aria-pressed":ue,style:{padding:"8px 16px",borderRadius:24,border:0,color:ue?N:"inherit",background:ue?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>he(q?ue?n.filter(X=>X!==D.value):[...Array.isArray(n)?n:[],D.value]:D.value),children:Cr(D.label)||D.label},ne)}),M&&h.jsx("span",{role:"status",children:"Loading..."})]}):O==="textarea"?h.jsx("textarea",{...J,value:p,onChange:D=>y(D.target.value),onBlur:me}):h.jsx("input",{...J,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:D=>y(D.target.value),onBlur:me,onKeyDown:D=>{D.key==="Enter"&&me(),D.key==="Escape"&&y(n===void 0?"":String(n))}}),re&&h.jsx("div",{role:"alert",id:`${l}-error`,children:re}),C&&(w==null?void 0:w.error)&&h.jsx("button",{type:"button",disabled:o,onClick:()=>{v(void 0),m(x+1)},children:"Retry"})]})}function am({nodeAddress:e}){var v,C;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:s,structured:a}=S.useContext(Rr),{readOnly:u,config:c}=Ie(),l=s==null?void 0:s(e);if(l!==void 0)return h.jsx("fieldset",{"data-flow-form":e,disabled:u||c.editable===!1||!i,style:{border:0,margin:0,padding:0,minWidth:0},children:l});if(!t)return h.jsx(an,{role:"alert",children:"Forms require a JSON document."});const d=o?Qt(o,e,r):void 0,f=o?d:r&&yt(t,e,r);if(!f)return h.jsx(an,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,y=ve(t,p),g=(v=a==null?void 0:a.containers.get(e))==null?void 0:v.scalar;if(y===void 0||typeof y!="object"&&!g)return h.jsx(an,{role:"alert",children:"Bound form state is unavailable."});const b=Object.entries(f.type.properties).filter(([_])=>{var R;return wn((R=f.fields[_])==null?void 0:R.$visibleWhen,t)}),x=b.length>8||b.some(([_])=>{var R;return(R=f.fields[_])==null?void 0:R.$section}),m=new Map;for(const _ of b){const[R,T]=_,A=x?Cr(((C=f.fields[R])==null?void 0:C.$section)??(T.type.kind==="object"||T.type.kind==="array"?R:T.optional?"Options":"General")):"";m.has(A)||m.set(A,[]),m.get(A).push(_)}const w=([_,R])=>h.jsx(Al,{request:{data:t,address:g?p:`${p}.${_}`,nodeAddress:p,nodeId:typeof(y==null?void 0:y.id)=="string"?y.id:void 0},property:R,config:f.fields[_]??{},value:g?y:y==null?void 0:y[_],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(y==null?void 0:y.id)??e}:${_}`);return h.jsxs(an,{"data-flow-form":e,onClick:_=>_.stopPropagation(),onDoubleClick:_=>_.stopPropagation(),children:[a&&h.jsx(c0,{nodeAddress:e}),d&&f.type.additionalProperties&&b.length===0&&h.jsx(Al,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:y,disabled:u||c.editable===!1||!i}),[...m].map(([_,R])=>x&&R.length>1?h.jsxs("details",{open:!0,children:[h.jsxs("summary",{children:[h.jsx("span",{children:_}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),R.map(w)]},_):R.map(w))]})}function sm(e){const{viewData:t}=S.useContext(Rr),{nodeById:r,edgeById:n,parentIds:o}=Ur();if(t){const i=ve(t,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,u])=>!a.startsWith("$")&&u!==null&&typeof u=="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&&r.has(a)})}function Jt(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function hn(e,t,r,n){return{borderColor:t,borderWidth:Jt(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...my(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function cm({label:e,value:t,options:r,onChange:n,disabled:o}){var i;return h.jsxs(Ir,{"aria-label":e,title:`Animation: ${((i=r.find(s=>s.value===t))==null?void 0:i.label)??"Mixed"}`,value:t,style:{width:104},disabled:o,onValueChange:s=>{const a=r.find(u=>u.value===s);a&&n(a.value)},children:[t===""&&h.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(s=>h.jsx("option",{value:s.value,children:s.label},s.value))]})}const pn="data:image/svg+xml;base64,";function At(e){if(e.startsWith(pn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function u0(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const t=await e.text(),r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.doctype||r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(r.querySelector("script, foreignObject")||[...r.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(t);let o="";for(const i of n)o+=String.fromCharCode(i);return pn+btoa(o)}const qr=({name:e,svg:t=!1,...r})=>{const[n,o]=S.useState(null),[i,s]=S.useState(!0),[a,u]=S.useState(!1),c=typeof e=="string"&&At(e);if(S.useEffect(()=>{if(c||!e||e.length<2){o(null),s(!1);return}s(!0),u(!1),(async()=>{try{let d;if(e.startsWith("Md"))d="md";else if(e.startsWith("Fa"))d="fa6";else if(e.startsWith("Io5"))d="io5";else if(e.startsWith("Io"))d="io";else if(e.startsWith("Ti"))d="ti";else if(e.startsWith("Go"))d="go";else if(e.startsWith("Fi"))d="fi";else if(e.startsWith("Di"))d="di";else if(e.startsWith("Ai"))d="ai";else if(e.startsWith("Bs"))d="bs";else if(e.startsWith("Ri"))d="ri";else if(e.startsWith("Fc"))d="fc";else if(e.startsWith("Gi"))d="gi";else if(e.startsWith("Hi2"))d="hi2";else if(e.startsWith("Hi"))d="hi";else if(e.startsWith("Si"))d="si";else if(e.startsWith("Sl"))d="sl";else if(e.startsWith("Im"))d="im";else if(e.startsWith("Bi"))d="bi";else if(e.startsWith("Pi"))d="pi";else if(e.startsWith("Vsc"))d="vsc";else if(e.startsWith("Tb"))d="tb";else if(e.startsWith("Tfi"))d="tfi";else if(e.startsWith("Cg"))d="cg";else if(e.startsWith("Lia"))d="lia";else if(e.startsWith("Lu"))d="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let f;switch(d){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=f[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);o(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),u(!0),o(null)}finally{s(!1)}})()},[e,c]),c){const{size:l=80,style:d,...f}=r;return t?h.jsx("image",{...f,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):h.jsx("img",{...f,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return i||!n?null:h.jsx(n,{...r})};function $u({nodeId:e,edgeId:t,value:r}){const{callbacks:n,readOnly:o,themeColor:i}=Ie(),{background:s,backgroundSecondary:a,border:u,colorText:c}=He(),l=S.useRef(null),d=S.useId(),f=S.useRef(null),p=S.useRef(0),[y,g]=S.useState(!1),[b,x]=S.useState("icons"),[m,w]=S.useState([]),[v,C]=S.useState("loading"),[_,R]=S.useState(""),[T,A]=S.useState(0),[k,E]=S.useState(""),[j,M]=S.useState(""),[I,q]=S.useState(!1);S.useEffect(()=>()=>{p.current++},[]),S.useEffect(()=>{if(!y)return;let J=!0;return import("react-icons/pi").then(N=>{J&&(w(Object.keys(N).filter(L=>L.startsWith("Pi")).sort()),C("ready"))}).catch(()=>{J&&C("unavailable")}),()=>{J=!1}},[y]),S.useEffect(()=>{var J;o&&((J=l.current)==null||J.close())},[o]);const O=J=>{var N,L,G;o||(t?(N=n.onEdgeIconChange)==null||N.call(n,t,J):e&&((L=n.onNodeIconChange)==null||L.call(n,e,J)),(G=l.current)==null||G.close())},V=m.filter(J=>J.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(_.trim().toLowerCase())),W=36,re=Math.max(1,Math.ceil(V.length/W)),Y=Math.min(T,re-1),he=V.slice(Y*W,(Y+1)*W),me={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${fe(u)}`,borderRadius:30};return h.jsxs(h.Fragment,{children:[h.jsx(Ee,{label:t?"Choose edge icon":"Choose node icon",children:h.jsx(be,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:h.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:fe(i),disabled:o,onClick:()=>{var J;M(""),x(r&&At(r)?"custom":"icons"),E(r&&!r.startsWith(pn)&&At(r)?r:""),g(!0),(J=l.current)==null||J.showModal()}})}),h.jsx(B.chakra.dialog,{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",css:zr(fe(s),fe(u)),onClose:()=>{g(!1),p.current++,q(!1)},onClick:J=>{J.stopPropagation(),J.target===J.currentTarget&&J.currentTarget.close()},onKeyDown:J=>J.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:fe(s),color:fe(c)},children:y&&h.jsxs("div",{style:{display:"grid",gap:8},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsx("strong",{children:t?"Edge icon":"Node icon"}),h.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&h.jsx(Ee,{label:"Remove icon",children:h.jsx(be,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:o||I,onClick:()=>O("")})}),h.jsx(gt,{"aria-label":"Close icon picker",onClick:()=>{var J;return(J=l.current)==null?void 0:J.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${fe(u)}`},children:["icons","custom"].map(J=>h.jsx("button",{id:`${d}-${J}`,type:"button",role:"tab","aria-selected":b===J,"aria-controls":`${d}-panel`,tabIndex:b===J?0:-1,onClick:()=>{x(J),M("")},onKeyDown:N=>{var G;if(!["ArrowLeft","ArrowRight","Home","End"].includes(N.key))return;N.preventDefault();const L=N.key==="Home"?"icons":N.key==="End"||J==="icons"?"custom":"icons";x(L),M(""),(G=document.getElementById(`${d}-${L}`))==null||G.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${b===J?fe(i):"transparent"}`,color:b===J?fe(i):"inherit",cursor:"pointer",fontSize:13},children:J==="icons"?"React icons":"Custom SVG"},J))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:I||o,onChange:async J=>{var G;const N=(G=J.target.files)==null?void 0:G[0];if(J.target.value="",!N)return;const L=++p.current;q(!0),M("");try{const D=await u0(N);L===p.current&&O(D)}catch(D){L===p.current&&M(D instanceof Error?D.message:"Unable to read SVG.")}finally{L===p.current&&q(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${b}`,style:{display:"grid",gap:8},children:b==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:_,onChange:J=>{R(J.target.value),A(0)},style:me}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[he.map(J=>h.jsx("button",{type:"button","aria-label":`Choose ${J}`,"aria-pressed":r===J,title:J,onClick:()=>O(J),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===J?2:1}px solid ${fe(r===J?i:u)}`,background:fe(r===J?s:a),color:"inherit",cursor:"pointer"},children:h.jsx(qr,{name:J,size:24})},J)),he.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:v==="loading"?"Loading icons...":v==="unavailable"?"React icons unavailable":"No icons found"})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsxs("span",{role:"status",style:{fontSize:12},children:[V.length," icons · ",Y+1," / ",re]}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx(Ee,{label:"Previous icons",children:h.jsx(be,{"aria-label":"Previous icons",icon:h.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:Y===0,onClick:()=>A(Y-1)})}),h.jsx(Ee,{label:"Next icons",children:h.jsx(be,{"aria-label":"Next icons",icon:h.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:Y+1>=re,onClick:()=>A(Y+1)})})]})]})]}):h.jsxs(h.Fragment,{children:[r&&At(r)&&h.jsx(qr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:I||o,onClick:()=>{var J;return(J=f.current)==null?void 0:J.click()},style:{...me,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[h.jsx(Z.PiUploadSimple,{}),I?"Uploading...":"Upload SVG"]}),h.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:J=>{J.preventDefault(),!(I||o)&&(!At(k.trim())||k.trim().startsWith(pn)?M("Enter an HTTP or HTTPS image URL."):O(k.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:k,disabled:I||o,onChange:J=>E(J.target.value),style:{...me,flex:1,minWidth:0}}),h.jsx(Ee,{label:"Apply URL",children:h.jsx(be,{type:"submit","aria-label":"Apply URL",icon:h.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:I||o||!k.trim(),style:{flexShrink:0}})})]})]})}),j&&h.jsx("div",{role:"alert",style:{fontSize:13},children:j})]})})]})}const Lu=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],um=["gray.900","gray.600","gray.200","white"];function lm(){const{config:e}=Ie(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Lu,show:n=>!r.has(n)}}function dr(){const{border:e}=He();return h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function et({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:s}){const{colorText:a}=He(),[u,c]=S.useState(e),l=S.useRef(!1);S.useEffect(()=>c(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const f=u.trim();if(o==="number"&&f!==""&&(!Number.isFinite(Number(f))||Number(f)<(i??0))){c(e);return}f!==e&&s(f)};return h.jsx(B.Input,{"aria-label":r,type:o,min:i,size:"xs",w:n,value:u,placeholder:t,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&(d(),f.target.blur()),f.key==="Escape"&&(l.current=!0,c(e),f.target.blur())}})}function Zt({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=He(),[u,c]=S.useState(!1),l=S.useId(),d=S.useRef(null),f=t??e[0]??"transparent";return h.jsxs(B.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var y;p.key==="Escape"&&(c(!1),(y=d.current)==null||y.focus())},children:[h.jsx(Ee,{label:`${r}: ${f}`,children:h.jsx(B.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":u,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${fe(a)}`,outlineOffset:"1px",onClick:()=>c(p=>!p)})}),u&&h.jsxs(B.HStack,{id:l,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(p=>{const y=t===p;return h.jsx(Ee,{label:`${r}: ${p}`,children:h.jsx(B.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":y,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:y?`2px solid ${fe(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(p),onDoubleClick:g=>{var b;g.stopPropagation(),c(!1),(b=d.current)==null||b.focus()}})},p)}),o&&h.jsx(Ee,{label:`Reset ${r.toLowerCase()}`,children:h.jsx(be,{"aria-label":`Reset ${r}`,icon:h.jsx(B.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var p;o(),c(!1),(p=d.current)==null||p.focus()}})})]})]})}function dm({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Ie(),{colorInactive:i}=He(),{edgeById:s}=Ur(),{palette:a,show:u}=lm(),c=(p=s.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],d=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(et,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:y=>{var g;return(g=r.onEdgeLabelChange)==null?void 0:g.call(r,e,y)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f.map(y=>h.jsx(Ee,{label:y.label,children:h.jsx(be,{"aria-label":`Edge style ${y.key}`,"aria-pressed":d===y.key,icon:h.jsx(B.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===y.key?n:i,onClick:()=>{var g;return(g=r.onEdgeStyleChange)==null?void 0:g.call(r,e,y.key)}})},y.key)),d==="animated"&&h.jsx(cm,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:y=>{var g;return(g=r.onEdgeAnimationVariantChange)==null?void 0:g.call(r,e,y)}}),h.jsxs(Ir,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:o.readOnly,onValueChange:y=>{var g;return(g=r.onEdgeTypeChange)==null?void 0:g.call(r,e,y||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(y=>h.jsx("option",{value:y,children:y},y))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx($u,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(et,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:y=>{var g;return(g=r.onEdgeIconChange)==null?void 0:g.call(r,e,y)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Zt,{label:"Edge color",colors:a,value:c==null?void 0:c.color,onPick:y=>{var g;return(g=r.onEdgeColorChange)==null?void 0:g.call(r,e,y)},onReset:()=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:"Delete edge",children:h.jsx(be,{"aria-label":"Delete edge",icon:h.jsx(B.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=r.onEdgeDelete)==null||y.call(r,e,c),t()}})})]})]})}function fm({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Ie(),{colorInactive:o}=He(),{nodeById:i}=Ur(),[s,a]=S.useState(!1),u=e.map(y=>{var g,b;return(b=(g=i.get(y))==null?void 0:g.data.viewProps)==null?void 0:b.borderRadius}),c=!u.every(y=>y===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=s||!c&&l!==""&&!d.includes(l),p=y=>e.forEach(g=>{var b;return(b=r.onNodeBorderRadiusChange)==null?void 0:b.call(r,g,y)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(dr,{}),h.jsx(B.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Ir,{icon:h.jsx(B.Icon,{as:ov.TbBorderRadius,boxSize:5,color:o,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${c?"Mixed":u[0]===void 0?"Default":`${u[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:f?"custom":l,disabled:n.readOnly,onValueChange:y=>{a(y==="custom"),y!=="custom"&&p(y===""?void 0:Number(y))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(y=>h.jsxs("option",{value:y,children:[y,"px radius"]},y)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(et,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:y=>p(y===""?void 0:Number(y))})]})}function hm({ids:e,onClose:t}){var J,N,L,G,D,ne,ue,X;const{callbacks:r,colorMode:n,themeColor:o,config:i,setNodeViewMode:s}=Ie(),{colorText:a,colorInactive:u}=He(),{nodeById:c,parentIds:l}=Ur(),{palette:d,show:f}=lm(),p=e.length===1,y=p?(J=c.get(e[0]))==null?void 0:J.data:void 0,g=e.map(U=>{var K,te;return((te=(K=c.get(U))==null?void 0:K.data.config)==null?void 0:te.typeView)??""}),b=g.some(U=>U!==g[0]),x=b?"mixed":g[0]??"",m=e.some(U=>{var te,ce;const K=(te=c.get(U))==null?void 0:te.data;return K&&(l.has(U)||((ce=K.config)==null?void 0:ce.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},K.type))}),w=(N=y==null?void 0:y.config)==null?void 0:N.collapsed,v=sm(e[0]),C=U=>{var K,te,ce;return(((te=(K=c.get(U))==null?void 0:K.data.viewProps)==null?void 0:te.outline)??(l.has(U)?(ce=i.parentNodeStyle)==null?void 0:ce.outline:!1))===!0},_=e.every(C),R=!_&&e.some(C),T=U=>{var K;return((K=c.get(U))==null?void 0:K.data.isNodeAnimated)===!0},A=e.every(T),k=!A&&e.some(T),E=e.map(U=>{var K;return((K=c.get(U))==null?void 0:K.data.nodeAnimationVariant)??"traveling"}),j=E.every(U=>U===E[0])?E[0]:"",M=U=>e.forEach(U),[I,q]=S.useState(!1),O=I&&f("color")&&f("borderColor"),V=U=>{var K,te,ce;return(((te=(K=c.get(U))==null?void 0:K.data.viewProps)==null?void 0:te.borderStyle)??(l.has(U)?(ce=i.parentNodeStyle)==null?void 0:ce.borderStyle:"solid"))==="dashed"},W=e.every(V),re=!W&&e.some(V),Y=e.map(U=>{var ce,de,Ae;const K=(ce=c.get(U))==null?void 0:ce.data,te=l.has(U)?Jt((de=i.parentNodeStyle)==null?void 0:de.borderWidth,6):(K==null?void 0:K.type)==="objectView"?3:2;return Jt((Ae=K==null?void 0:K.viewProps)==null?void 0:Ae.borderWidth,te)}),he=Y.every(U=>U===Y[0])?String(Y[0]??""):"",me=U=>M(K=>{var te,ce;O?(te=r.onNodeBorderColorChange)==null||te.call(r,K,U):(ce=r.onNodeColorChange)==null||ce.call(r,K,"bg",U)});return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),h.jsx(dr,{}),p&&f("label")?h.jsx(et,{ariaLabel:"Node label",placeholder:"Node label",value:(y==null?void 0:y.label)??(y==null?void 0:y.headerTitle)??"",onCommit:U=>{var K;return(K=r.onNodeLabelChange)==null?void 0:K.call(r,e[0],U)}}):h.jsxs(B.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),f("typeView")&&h.jsxs(Ir,{"aria-label":"Type view",title:m?"Type view is managed by the custom renderer or container":`Type view: ${x||"None (default)"}`,icon:h.jsx(Z.PiImage,{size:20}),style:{width:36},value:x,disabled:i.readOnly||i.editable===!1||m,onValueChange:U=>{zt.includes(U)&&M(K=>{var te,ce;(te=r.onNodeTypeViewChange)==null||te.call(r,K,U||void 0),s(K,"default"),(ce=r.onNodeViewToggle)==null||ce.call(r,K)})},children:[b&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),zt.map(U=>h.jsx("option",{value:U,children:U||"None"},U))]}),f("style")&&h.jsx(fm,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:_?"Restore node fill":"Remove node fill",children:h.jsx(be,{"aria-label":"Toggle node outline","aria-pressed":R?"mixed":_,icon:h.jsx(B.Icon,{as:_?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:_?o:u,onClick:()=>M(U=>{var K;return(K=r.onNodeOutlineChange)==null?void 0:K.call(r,U,!_)})})})]}),f("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f("borderColor")&&h.jsx(Ee,{label:O?"Edit node colors":"Edit node border",children:h.jsx(be,{"aria-label":"Edit node border","aria-pressed":O,icon:h.jsx(B.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:O?o:u,bg:O?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>q(U=>!U)})}),h.jsx(Zt,{label:O?"Border color":"Background",colors:d,value:O?((L=y==null?void 0:y.viewProps)==null?void 0:L.borderColor)??(p&&l.has(e[0])?(G=i.parentNodeStyle)==null?void 0:G.borderColor:void 0):(D=y==null?void 0:y.viewProps)==null?void 0:D.bgColor,onPick:me,onReset:()=>me("")}),O&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:W?"Solid border":"Dashed border",children:h.jsx(be,{"aria-label":"Toggle dashed border","aria-pressed":re?"mixed":W,icon:h.jsx(B.Icon,{as:W?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:W?o:u,onClick:()=>M(U=>{var K;return(K=r.onNodeBorderStyleChange)==null?void 0:K.call(r,U,W?"solid":"dashed")})})}),h.jsx(et,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:he,onCommit:U=>M(K=>{var te;return(te=r.onNodeBorderWidthChange)==null?void 0:te.call(r,K,U===""?void 0:Number(U))})})]})]}),f("animation")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:A?"Stop border animation":"Animate node border",children:h.jsx(be,{"aria-label":"Toggle node animation","aria-pressed":k?"mixed":A,icon:h.jsx(B.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:A?o:u,onClick:()=>M(U=>{var K;return(K=r.onNodeAnimationChange)==null?void 0:K.call(r,U,!A)})})}),(A||k)&&h.jsx(cm,{label:"Node animation",value:j,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:i.readOnly,onChange:U=>M(K=>{var te;return(te=r.onNodeAnimationVariantChange)==null?void 0:te.call(r,K,U)})})]}),!O&&f("textColor")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Zt,{label:"Text color",colors:um,value:(ne=y==null?void 0:y.viewProps)==null?void 0:ne.textColor,onPick:U=>M(K=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,K,"text",U)}),onReset:()=>M(U=>{var K;return(K=r.onNodeColorChange)==null?void 0:K.call(r,U,"text","")})})]}),p&&f("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx($u,{nodeId:e[0],value:(ue=y==null?void 0:y.config)==null?void 0:ue.icon},e[0]),h.jsx(et,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((X=y==null?void 0:y.config)==null?void 0:X.icon)||"",onCommit:U=>{var K;return(K=r.onNodeIconChange)==null?void 0:K.call(r,e[0],U)}})]}),p&&v&&f("collapse")&&w!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:w?"Expand":"Collapse",children:h.jsx(be,{"aria-label":w?"Expand node":"Collapse node",icon:h.jsx(B.Icon,{as:w?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:u,onClick:()=>{var U;return(U=r.onNodeCollapse)==null?void 0:U.call(r,e[0],!w)}})})]}),f("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:p?"Delete node":`Delete ${e.length} nodes`,children:h.jsx(be,{"aria-label":"Delete selected nodes",icon:h.jsx(B.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{M(U=>{var K,te;return(te=r.onNodeDelete)==null?void 0:te.call(r,U,((K=c.get(U))==null?void 0:K.data)||{id:U})}),t()}})})]})]})}async function pm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:o=>!(o instanceof Element)||!o.matches("button, [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(r.slice(r.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()),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function gm(e,t="squeed.svg"){const r=document.createElement("a");r.href=await pm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function ym(){const{themeColor:e}=Ie(),[t,r]=S.useState(!1),[n,o]=S.useState("");return h.jsxs(h.Fragment,{children:[h.jsx(Ee,{label:"Download SVG (current view)",children:h.jsx(be,{"aria-label":"Download SVG",icon:h.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:t,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}r(!0),o("");try{await gm(s)}catch(u){o(u instanceof Error?u.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&h.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function mm({children:e,background:t,border:r}){const n=S.useRef(null),[o,i]=S.useState({left:!1,right:!1});S.useLayoutEffect(()=>{const a=n.current,u=()=>{const l=a.scrollLeft>1,d=a.scrollWidth-a.clientWidth-a.scrollLeft>1;i(f=>f.left===l&&f.right===d?f:{left:l,right:d})},c=new ResizeObserver(u);return c.observe(a),a.firstElementChild&&c.observe(a.firstElementChild),a.addEventListener("scroll",u,{passive:!0}),u(),()=>{c.disconnect(),a.removeEventListener("scroll",u)}},[]);const s=`var(--chakra-colors-${t.replace(".","-")})`;return h.jsxs(B.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:zr(s,`var(--chakra-colors-${r.replace(".","-")})`),children:[h.jsx(B.Box,{ref:n,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(a=>h.jsx(B.Box,{"data-flow-toolbar-fade":a,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:a==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[a]:0,opacity:o[a]?1:0,background:`linear-gradient(to ${a==="left"?"right":"left"}, ${s}, transparent)`}},a))]})}async function l0(e,t){const r=new Set,n=[],o=(a,u)=>{var l,d,f;if(!a||typeof a!="object")return;const c=a;n.push(u),typeof((l=c.$form)==null?void 0:l.$type)=="string"&&r.add(c.$form.$type),typeof((f=(d=c.$form)==null?void 0:d.$create)==null?void 0:f.$type)=="string"&&r.add(c.$form.$create.$type);for(const[p,y]of Object.entries(c))p==="$"?o(y,u):p.startsWith("$")||o(y,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await nm(e)};const i=await Nu(e,[...r]);for(const a of r)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const u=yt(t,a,i);u&&(s[a]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function bm({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=He();return!e||typeof document>"u"?null:Dt.createPortal(h.jsxs(B.chakra.div,{role:"alert","aria-atomic":"true",css:zr(fe(r),fe(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:fe(r),color:fe(n),fontSize:14,lineHeight:1.5},children:[h.jsx(Z.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),h.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[h.jsx("strong",{children:"Interface upload failed"}),h.jsx("div",{children:e})]}),h.jsx(gt,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function vm({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:u}=Ie(),{edgeById:c}=Ur(),{data:l,schema:d,setSchema:f,bindings:p,structured:y}=S.useContext(Rr),g=(y==null?void 0:y.sourceBindings)??p,b=(y==null?void 0:y.sourceSchema)??d,{colorText:x}=He(),m=S.useRef(null),w=S.useRef(0),[v,C]=S.useState(!1),[_,R]=S.useState("");S.useEffect(()=>()=>{w.current++},[]),S.useEffect(()=>{w.current++,C(!1)},[a,l,g]);const T=o?[...c.values()].filter(k=>qu(o,k.data)).length:0,A=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(bm,{message:_,onDismiss:()=>R("")}),e&&h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?h.jsx(Z.PiGraph,{size:20}):r==="properties"?h.jsx(Z.PiTable,{size:20}):h.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:a,onValueChange:k=>{var j;const E=k==="auto"?"auto":k==="properties"?"properties":"nodes";n(E),(j=s.onEdgeModeChange)==null||j.call(s,E)},children:[h.jsx("option",{value:"auto",children:"Auto"}),h.jsx("option",{value:"nodes",children:"Nodes"}),h.jsx("option",{value:"properties",children:"Properties"})]}),h.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[h.jsx(Ee,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:h.jsx(be,{"aria-label":"Upload workflow interface",icon:h.jsx(Z.PiUploadSimple,{size:20}),color:fe(u),size:"sm",variant:"ghost",disabled:v||a,onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()}})}),h.jsx("input",{ref:m,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||v,onChange:async k=>{var M,I;const E=(M=k.target.files)==null?void 0:M[0];if(k.target.value="",!E)return;const j=++w.current;C(!0),R("");try{const q=g?await Nu(E,[...new Set(Object.values(g).map(W=>W.schemaType??W.type))]):void 0;if(g&&q){for(const W of Object.values(g))if(!Object.prototype.hasOwnProperty.call(q,W.schemaType??W.type))throw new Error(`Missing form type: ${W.schemaType??W.type}`)}const{contract:O,schema:V}=g&&q?{schema:q,contract:{name:E.name,nodes:Object.fromEntries(Object.entries(g).map(([W,re])=>[W,{type:q[re.schemaType??re.type],optional:!1}]))}}:await l0(E,l);if(j!==w.current)return;f==null||f(V),i(O),(I=s.onWorkflowContractChange)==null||I.call(s,O)}catch(q){j===w.current&&R(`${E.name}: ${q instanceof Error?q.message:"Unable to load interface."}`)}finally{j===w.current&&C(!1)}}}),!t&&(A||v)&&h.jsx("span",{role:"status",title:A,style:{color:fe(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v?"Loading interface...":A}),!t&&o&&h.jsx(Ee,{label:"Remove workflow interface",children:h.jsx(be,{"aria-label":"Remove workflow interface",icon:h.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||v,onClick:()=>{var k;f==null||f(void 0),i(void 0),(k=s.onWorkflowContractChange)==null||k.call(s,void 0),R("")}})})]})]})}const d0=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:jt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:jt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:jt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:jt.RIGHT_LEFT}],xm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,backgroundSelected:n,setBackgroundSelected:o,direction:i,edgeMode:s,allNodesIconLabel:a,setAllNodesIconLabel:u,selectedNodeIds:c,setSelectedNodeIds:l,selectedEdgeId:d,setSelectedEdgeId:f,isZoomMode:p,setIsZoomMode:y,isMultiSelectMode:g,setIsMultiSelectMode:b,isDragMode:x,setIsDragMode:m,isEdgeHandlesEnabled:w,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,isPinned:R,setIsPinned:T,callbacks:A,config:k,readOnly:E}=Ie(),{nodeById:j,edgeById:M,parentIds:I}=Ur(),q=k.colorMode==="dark",{background:O,border:V,colorInactive:W,colorText:re,colorActive:Y}=He(),he=`var(--chakra-colors-${O.replace(".","-")})`,me=`var(--chakra-colors-${(q?V:"gray.300").replace(".","-")})`,[J,N]=S.useState(!1),[L,G]=S.useState(!0),D=S.useRef(null),ne=yy({edge:"bottom",enabled:!R,bounds:D,inside:[D]}),ue=S.useCallback(xe=>{const Me=e.current;if(!Me)return;const Fe=k.minZoom??.01,nr=k.maxZoom??1.5,Ze=.02;let Ye=Me.zoom();switch(xe){case"increase":Ye=Math.min(nr,Ye+Ze),Me.zoom(Ye),Me.center();break;case"decrease":Ye=Math.max(Fe,Ye-Ze),Me.zoom(Ye),Me.center();break;case"reset":Me.fit(50);break}},[e,k.minZoom,k.maxZoom]),X=k.renderSelectedNodeToolbar,U=c.length>0&&!!X,K=S.useMemo(()=>U?c.map(xe=>{var Fe;return{...((Fe=j.get(xe))==null?void 0:Fe.data)??{id:xe},isParent:I.has(xe)}}):[],[U,c,j,I]),te=S.useCallback(()=>{var xe;l([]),(xe=A.onNodeDeselect)==null||xe.call(A)},[l,A]),ce=k.renderSelectedEdgeToolbar,de=!!d&&!!ce,Ae=S.useMemo(()=>{var xe;return!de||!d?null:((xe=M.get(d))==null?void 0:xe.data)??{id:d}},[de,d,M]),ge=S.useCallback(()=>{var xe;f(null),(xe=A.onEdgeDeselect)==null||xe.call(A)},[f,A]),Ke=k.selectionToolbar!==!1&&!E,Oe=Ke&&!!d&&!ce,Le=Ke&&!Oe&&c.length>0&&!X,er=Oe||Le,Ve=R||ne||J||er;S.useEffect(()=>{c.length||d?o(!1):n&&!E&&(T(!0),G(!1))},[n,c.length,d,E,o,T]);const $e=k.renderBottomBar;return $e?h.jsxs(h.Fragment,{children:[U&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:K,onDeselect:te})}),de&&Ae&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ce({edgeId:d,edgeData:Ae,onDeselect:ge})}),h.jsx(B.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:$e({zoomIn:()=>ue("increase"),zoomOut:()=>ue("decrease"),resetZoom:()=>ue("reset"),direction:i,isZoomMode:p,setIsZoomMode:y,isMultiSelectMode:g,setIsMultiSelectMode:b,isDragMode:x,setIsDragMode:m,isEdgeHandlesEnabled:w,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,selectedNodeIds:c,selectedNodeData:K,selectedEdgeId:d,selectedEdgeData:Ae,onNodeDeselect:te,onEdgeDeselect:ge,callbacks:A})})]}):h.jsxs(h.Fragment,{children:[U&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:K,onDeselect:te})}),de&&Ae&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ce({edgeId:d,edgeData:Ae,onDeselect:ge})}),h.jsx(B.Box,{ref:D,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:Ve?"translateY(0)":"translateY(100%)",pointerEvents:Ve?"auto":"none",visibility:Ve?"visible":"hidden",opacity:Ve?1:0,children:h.jsxs(B.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",children:[h.jsx(mm,{background:O,border:q?V:"gray.300",children:h.jsxs(B.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Oe?h.jsx(dm,{edgeId:d,onClose:ge}):Le?h.jsx(hm,{ids:c,onClose:te}):null,h.jsxs("div",{style:{display:Oe||Le?"none":"contents"},children:[h.jsx(Ee,{label:R?"Unpin":"Pin",children:h.jsx(be,{"aria-label":"Pin",icon:h.jsx(B.Icon,{as:R?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:R?t:W,onClick:()=>{T(!R),N(!1)}})}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:"Zoom Out",children:h.jsx(be,{"aria-label":"Zoom out",icon:h.jsx(B.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ue("decrease")})}),h.jsx(Ee,{label:"Zoom In",children:h.jsx(be,{"aria-label":"Zoom in",icon:h.jsx(B.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ue("increase")})}),h.jsx(Ee,{label:"Reset Zoom",children:h.jsx(be,{"aria-label":"Reset zoom",icon:h.jsx(B.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ue("reset")})}),!L&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:p?"Zoom Mode (z)":"Pan Mode (z)",children:h.jsx(be,{"aria-label":"Toggle zoom mode",icon:h.jsx(B.Icon,{as:p?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:p?t:W,onClick:()=>y(!p)})}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:g?"Multi-Select On (m)":"Multi-Select Off (m)",children:h.jsx(be,{"aria-label":"Toggle multi-select",icon:h.jsx(B.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:g?t:W,onClick:()=>b(!g)})}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:x?"Drag Mode On (d)":"Drag Mode Off (d)",children:h.jsx(be,{"aria-label":"Toggle drag mode",icon:h.jsx(B.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:x?t:W,onClick:()=>m(!x)})}),k.edgeHandles!==!1&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:w?"Draw Mode On":"Draw Mode Off",children:h.jsx(be,{"aria-label":"Toggle draw mode",icon:h.jsx(B.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:w?t:W,onClick:()=>v(!w)})})]}),k.bottomBarExtra&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V,role:"separator","aria-orientation":"vertical"}),k.bottomBarExtra]}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V,role:"separator","aria-orientation":"vertical"}),h.jsx(Wy,{}),h.jsx(ku,{label:"Collapse all",checked:a,icon:h.jsx(B.Icon,{as:Z.PiArrowsInLineVertical,boxSize:5}),onChange:u}),s!=="properties"&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:C?"Array Mode [ ]":"Set Mode { }",children:h.jsx(be,{"aria-label":"Toggle array mode",icon:h.jsx(B.Icon,{as:C?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:C?t:W,onClick:()=>{var Me;const xe=!C;_(xe),(Me=A.onArrayModeChange)==null||Me.call(A,xe)}})})]}),n&&!E&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Zt,{label:"Graph theme",colors:Lu,value:t,includeTransparent:!1,onPick:xe=>{var Me;r(xe),(Me=A.onThemeColorChange)==null||Me.call(A,xe)}})]}),h.jsx(vm,{}),h.jsx(Uy,{})]}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:L?"Expand toolbar":"Collapse toolbar",children:h.jsx(be,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(B.Icon,{as:L?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:W,onClick:()=>G(!L)})}),!L&&h.jsx(ym,{})]})]})}),!er&&h.jsxs(B.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(B.Box,{"data-flow-direction-control":"",bg:O,borderRadius:"30px",h:50,css:zr(he,me),px:3,cursor:"pointer",onClick:()=>N(!J),children:h.jsxs(B.Flex,{align:"center",h:"100%",children:[h.jsx(Ee,{label:"Flow Direction",children:h.jsx(be,{"aria-label":"Direction",icon:h.jsx(B.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:W})}),h.jsx(B.Text,{fontSize:"xs",color:q?"whiteAlpha.600":"blackAlpha.500",ml:1,children:i})]})}),J&&h.jsx(B.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(B.Box,{bg:O,borderRadius:"30px",p:2,minW:"180px",css:zr(he,me),children:[d0.map(xe=>h.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"30px",cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Me;(Me=A.onDirectionChange)==null||Me.call(A,xe.value),N(!1)},children:[h.jsx(B.Icon,{as:xe.icon,boxSize:5,color:re}),h.jsx(B.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:xe.label}),i===xe.value&&h.jsx(B.Icon,{as:Z.PiCheck,boxSize:4,color:Y})]},xe.value)),h.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var xe;(xe=A.onDirectionChange)==null||xe.call(A,"C"),N(!1)},children:[h.jsx(B.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:re}),h.jsx(B.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(B.Icon,{as:Z.PiCheck,boxSize:4,color:Y})]})]})})]})]})})]})};xm.displayName="BottomBar";const wm=S.memo(xm);function f0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(ku,{label:n,checked:e,onChange:t,disabled:r,icon:h.jsx(B.Icon,{as:Z.PiGraph,boxSize:5})})}const Tl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Cm(e,t){const r=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(u=>Object.prototype.hasOwnProperty.call(s,u)&&n(i[u],s[u]))},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 u=new Set([...Object.keys(i),...Object.keys(s)]);for(const c of u)if(!n(i[c],s[c])){if(Object.prototype.hasOwnProperty.call(Tl,c)){if(typeof s[c]!="string"||!s[c])return!1;r.set(a,{...r.get(a),[Tl[c]]:s[c]})}else if(c.startsWith("$")&&c!=="$"||!o(i[c],s[c],c==="$"?a:`${a}.${c}`))return!1}return!0};if(o(e,t,"root"))return r}function h0(e,t){return Cm(e,t)!==void 0}function p0(e,t,r){if(e===t)return r;const n=Cm(e,t);if(!n)return;const o=new Set(r.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!ve(t,i))return;return{edges:r.edges,nodes:r.nodes.map(i=>{const s=n.get(i.data.id),a=ve(e,i.data.id),u=ve(t,i.data.id);return!s&&a===u?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(u,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function wu(e){return e.kind==="literal"?e.value:e.kind==="union"?wu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,wu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function _m(e,t,r){var b,x,m;const n=(b=ve(e,t))==null?void 0:b.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(w=>!/^[A-Za-z0-9_-]+$/.test(w)||["__proto__","constructor","prototype"].includes(w)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),u=yt(e,a,r),c=(x=u==null?void 0:u.type.properties[s])==null?void 0:x.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[o.$type],d=o.$defaults??{};for(const[w,v]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,w)||kr(l.properties[w].type,v,!l.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const f={...wu(l),...structuredClone(d)};((m=l.properties.id)==null?void 0:m.type.kind)==="string"&&(f.id=Ru());let p=e;const y=ve(e,o.$address);if(y===void 0)p=mr(e,a,w=>({...w,[s]:[]}));else if(!Array.isArray(y)&&!Array.isArray(y==null?void 0:y.$))throw new Error("Form creation destination is not an array.");const g=Tu(p,o.$address,{...f,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:Ou(g.json,t,{target:g.address,label:o.$edgeLabel})}}function g0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Sm(e,t,r,n,o){const i=(a,u)=>{a!==e&&(e=a,n==null||n(a,u))},s=a=>{var c;const u=(c=t.find(l=>l.data.id===a))==null?void 0:c.data;return u&&{source:u.source,target:u.target,isInverted:u.isInverted,sourceProperty:u.sourceProperty,targetProperty:u.targetProperty,connection:u.connection}};return{...r,onFormChange:a=>{const u=ve(e,a.nodeAddress);if(!u||a.nodeId!==void 0&&u.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(Cn(e,a,r.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,u)=>{var c;(c=r.onNodeLabelChange)==null||c.call(r,a,u),i(ur(e,a,"$label",u),{type:"nodeLabel",address:a,key:"$label",value:u})},onNodeContentChange:(a,u)=>{var c;(c=r.onNodeContentChange)==null||c.call(r,a,u),i(ur(e,a,"$content",u),{type:"nodeContent",address:a,key:"$content",value:u})},onNodeTypeViewChange:(a,u)=>{var c;u!==void 0&&!zt.includes(u)||((c=r.onNodeTypeViewChange)==null||c.call(r,a,u),i(ur(e,a,"$view",u),{type:"nodeStyle",address:a,key:"$view",value:u}))},onNodeColorChange:(a,u,c)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,a,u,c);const l=u==="bg"?"$bgColor":"$textColor";i(ur(e,a,l,c),{type:"nodeColor",address:a,key:l,value:c})},onNodeBorderColorChange:(a,u)=>{var c;(c=r.onNodeBorderColorChange)==null||c.call(r,a,u),i(ur(e,a,"$borderColor",u),{type:"nodeColor",address:a,key:"$borderColor",value:u})},onNodeBorderStyleChange:(a,u)=>{var c;(c=r.onNodeBorderStyleChange)==null||c.call(r,a,u),i(ur(e,a,"$borderStyle",u),{type:"nodeStyle",address:a,key:"$borderStyle",value:u})},onNodeBorderWidthChange:(a,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderWidthChange)==null||c.call(r,a,u),i(ur(e,a,"$borderWidth",u),{type:"nodeStyle",address:a,key:"$borderWidth",value:u}))},onNodeBorderRadiusChange:(a,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderRadiusChange)==null||c.call(r,a,u),i(ur(e,a,"$borderRadius",u),{type:"nodeStyle",address:a,key:"$borderRadius",value:u}))},onNodeIconChange:(a,u)=>{var c;(c=r.onNodeIconChange)==null||c.call(r,a,u),i(ur(e,a,"$icon",u),{type:"nodeIcon",address:a,key:"$icon",value:u})},onNodeOutlineChange:(a,u)=>{var c;(c=r.onNodeOutlineChange)==null||c.call(r,a,u),i(ur(e,a,"$outline",u),{type:"nodeOutline",address:a,key:"$outline",value:u})},onNodeAnimationChange:(a,u)=>{var c;(c=r.onNodeAnimationChange)==null||c.call(r,a,u),i(ur(e,a,"$isNodeAnimated",u),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:u})},onNodeAnimationVariantChange:(a,u)=>{var c;u!=="traveling"&&u!=="pulse"||((c=r.onNodeAnimationVariantChange)==null||c.call(r,a,u),i(ur(e,a,"$nodeAnimationVariant",u),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:u}))},onNodeCollapse:(a,u)=>{var c;(c=r.onNodeCollapse)==null||c.call(r,a,u),i(Yy(e,a,u),{type:"nodeCollapse",address:a,key:"$collapsed",value:u})},onNodeCreate:a=>{var p,y;const u=a.sourceNodeId&&_m(e,a.sourceNodeId,o);if(u){(p=r.onNodeCreate)==null||p.call(r,a),i(u.json,{type:"nodeCreate",address:u.address,value:"form"});return}(y=r.onNodeCreate)==null||y.call(r,a);const c=a.sourceNodeId||"root",l=ve(e,c),d=g0(l,a.isArrayMode?"list":"node"),f=Tu(e,c,a.isArrayMode?[]:{},d);i(f.json,{type:"nodeCreate",address:f.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,u)=>{var c;(c=r.onNodeDelete)==null||c.call(r,a,u),i(Qy(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,u,c)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,a,u,c);const l=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:u}:void 0;i(l?Ou(e,a,l):em(e,a,u),{type:"edgeCreate",address:a,key:l?"$connections":"$target",value:l??u})},onEdgeLabelChange:(a,u)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$sourceLabel",u),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:u})},onEdgeStyleChange:(a,u)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,a,u);const c=s(a);c&&i(Xy(e,c,u),{type:"edgeStyle",edge:c,value:u})},onEdgeAnimationVariantChange:(a,u)=>{var l;if(u!=="dashed"&&u!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeAnimationVariant",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:u})},onEdgeTypeChange:(a,u)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeType",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:u})},onEdgeIconChange:(a,u)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeIcon",u||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:u})},onEdgeColorChange:(a,u)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeColor",u),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:u})},onEdgeDelete:(a,u)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,a,u);const c=s(a);if(!c)return;const l=rm(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const y0=".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 m0({path:e,color:t,width:r,reversed:n}){return h.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:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const b0=".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 v0({path:e,width:t,reversed:r,children:n,onComplete:o}){const i=`flow-edge-reveal-${S.useId().replace(/:/g,"")}`,s=S.useRef(null),[a,u]=S.useState({x:0,y:0,width:1,height:1});return S.useEffect(()=>{const c=matchMedia("(prefers-reduced-motion: reduce)"),l=()=>{c.matches&&(o==null||o())};return l(),c.addEventListener("change",l),()=>c.removeEventListener("change",l)},[o]),S.useLayoutEffect(()=>{var l;const c=(l=s.current)==null?void 0:l.getBBox();c&&u({x:c.x-t,y:c.y-t,width:c.width+t*2,height:c.height+t*2})},[e,t]),h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:h.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:c=>{c.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":r?"reverse":"forward",style:{"--flow-edge-reveal-from":r?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:t,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),h.jsx("g",{mask:`url(#${i})`,children:n})]})}const x0=".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 Em({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:u="traveling"}){const c=S.useId(),l=`flow-sdk-node-border-animation${u==="pulse"?" flow-sdk-node-border-pulse":""}`;if(u==="pulse"){const d=a?"path":"rect",f=a?{d:a}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2))},p=s+36,y={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return h.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[h.jsx("defs",{children:h.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[h.jsx("rect",{...y,fill:"white"}),h.jsx(d,{...f,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),h.jsx(d,{...f,className:l,"data-animation-variant":u,fill:"none",stroke:`color-mix(in srgb, ${i} 60%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?h.jsx("path",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):h.jsx("rect",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const w0=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 Ol(e,t,r){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of t)(s.parent===i||s.id.startsWith(`${i}.`)||r.some(u=>(u.inverted?u.target:u.source)===i&&(u.inverted?u.source:u.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function C0(e,t,r){const n=r==="downward"||r==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=t(s.source),u=t(s.target);if(!a||!u)continue;const c=n?u.y-a.y:u.x-a.x,l=Math.abs(c)-(n?a.h+u.h:a.w+u.w)/2;if(l<=320)continue;const d=JSON.stringify([s.source,Math.sign(c)]),f=o.get(d)??[];f.push({edge:s,gap:l,cross:n?u.x-a.x:u.y-a.y}),o.set(d,f)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:u})=>u.target)).size<2)continue;const a=new Map;for(const{edge:u}of s)a.set(u.target,(a.get(u.target)??0)+1);for(const u of[-1,0,1]){const c=s.filter(({cross:d})=>Math.sign(d)===u);c.sort((d,f)=>Math.abs(f.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(f.edge.id));const l=Math.min(...c.map(({gap:d})=>d));c.forEach(({edge:d,gap:f,cross:p},y)=>{const g=c.length===1?l/2:120+(l-280)*y/(c.length-1),b=c.find(x=>Math.abs(x.cross)<Math.abs(p));i.set(d.id,{turn:g/f,labelAtTarget:a.get(d.target)===1,labelFraction:p?(p+((b==null?void 0:b.cross)??0))/(2*p):.5})})}}return i}const ct=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}),_0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Xn(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const S0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Il=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,hr=e=>(Math.round(e*10)/10).toString(),Je=e=>`${hr(e.x)} ${hr(e.y)}`,E0=e=>e>0?1:e<0?-1:0,Ml=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function j0(e,t,r,n,o=10){const i=t.x-e.x,s=t.y-e.y,a=Ml(i,(e.w+t.w)/2),u=Ml(s,(e.h+t.h)/2),c=r==="downward"||r==="upward",l=c?u:a,d=c?s:i,f=E0(d),p=n*l,y=m=>Math.abs(m)<o||Math.abs(m)>=Math.abs(l),g=y(p)||y(Math.abs(l)-Math.abs(p));let b;if(g)if(c)if(Math.abs(d)<=e.h/2){const m=(e.x+t.x)/2;b=[m,e.y,m,t.y]}else if(Math.abs(i)<=t.w/2){const m=(e.y+t.y)/2;b=[e.x,m,t.x,m]}else b=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const m=(e.y+t.y)/2;b=[e.x,m,t.x,m]}else if(Math.abs(s)<=t.h/2){const m=(e.x+t.x)/2;b=[m,e.y,m,t.y]}else b=[t.x,e.y];else if(c){const m=e.y+p+e.h/2*f;b=[e.x,m,t.x,m]}else{const m=e.x+p+e.w/2*f;b=[m,e.y,m,t.y]}const x=[{x:e.x,y:e.y}];for(let m=0;m<b.length;m+=2)x.push({x:b[m],y:b[m+1]});return x.push({x:t.x,y:t.y}),x}function k0(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,s=o>0?(r.y2-e.y)/o:o<0?(r.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 pt(e,t,r){var s;if(!((s=r.outline)!=null&&s.length))return k0(e,t,ct(r));const n=t.x-e.x,o=t.y-e.y;let i=1/0;return r.outline.forEach((a,u,c)=>{const l=c[(u+1)%c.length],d=l.x-a.x,f=l.y-a.y,p=n*f-o*d;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,g=a.y-e.y,b=(y*f-g*d)/p,x=(y*o-g*n)/p;b>=0&&b<1&&x>=-1e-9&&x<=1+1e-9&&(i=Math.min(i,b))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function jm(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,o=t==="top"||t==="bottom",i=t==="top"||t==="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{...pt(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:t}}function dt(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function R0(e,t,r,n){const o=dt(e,r.srcDist),i=dt(t,r.tgtDist);if(n==="straight")return Rm(o,i,r);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&t.side==="top"?i.y-o.y:e.side==="top"&&t.side==="bottom"?o.y-i.y:e.side==="right"&&t.side==="left"?i.x-o.x:e.side==="left"&&t.side==="right"?o.x-i.x:void 0,u=a!==void 0&&a>0?Math.min(s,a/2):s,c=dt({...o,side:e.side},u),l=dt({...i,side:t.side},u),d=r.arrowAt==="source"?tr(o,c,r.arrowGap):o,f=r.arrowAt==="target"?tr(i,l,r.arrowGap):i,p=r.arrowAt==="source"?br(o,c,r.arrowSize,r.headShape):r.arrowAt==="target"?br(i,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Je(d)} C${Je(c)} ${Je(l)} ${Je(f)}`,arrow:p,label:{x:(d.x+3*c.x+3*l.x+f.x)/8,y:(d.y+3*c.y+3*l.y+f.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",g=t.side==="left"||t.side==="right";let b;if(y!==g){const m=y?{x:l.x,y:c.y}:{x:c.x,y:l.y},w=(m.x-c.x)*(c.x-o.x)+(m.y-c.y)*(c.y-o.y)>=0,v=(m.x-l.x)*(l.x-i.x)+(m.y-l.y)*(l.y-i.y)>=0;b=[w&&v?m:y?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(a!==void 0&&a<=0)if(y){const m=(c.y+l.y)/2;b=[{x:c.x,y:m},{x:l.x,y:m}]}else{const m=(c.x+l.x)/2;b=[{x:m,y:c.y},{x:m,y:l.y}]}else if(y){const m=e.side===t.side?e.side==="right"?Math.max(c.x,l.x):Math.min(c.x,l.x):(c.x+l.x)/2;b=[{x:m,y:c.y},{x:m,y:l.y}]}else{const m=e.side===t.side?e.side==="bottom"?Math.max(c.y,l.y):Math.min(c.y,l.y):(c.y+l.y)/2;b=[{x:c.x,y:m},{x:l.x,y:m}]}const x=[c,...b,l].filter((m,w,v)=>w===0||m.x!==v[w-1].x||m.y!==v[w-1].y);return _n(d,x,f,p,n==="orthogonal"?0:r.radius)}function tr(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-r)/i;return s<0&&(s=1e-5),{x:t.x+s*n,y:t.y+s*o}}function br(e,t,r,n="triangle"){const o=e.x-t.x,i=e.y-t.y,s=Math.hypot(o,i)||1,a=o/s,u=i/s,c=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-a*c,f=e.y-u*c;return n==="square"?`M${Je(e)} L${hr(e.x-u*l)} ${hr(e.y+a*l)} L${hr(d-u*l)} ${hr(f+a*l)} L${hr(d+u*l)} ${hr(f-a*l)} L${hr(e.x+u*l)} ${hr(e.y-a*l)} Z`:`M${Je(e)} L${hr(d-u*l)} ${hr(f+a*l)} L${hr(d+u*l)} ${hr(f-a*l)} Z`}function Fr(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function P0(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),u=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(u)<1e-6)return{p1:t,b:t,p2:t,r:0};const c=Math.min(n,s/2,a/2);return{p1:{x:t.x-o.x/s*c,y:t.y-o.y/s*c},b:t,p2:{x:t.x+i.x/a*c,y:t.y+i.y/a*c},r:c}}function km(e,t,r,n){let o=-1,i=null;for(let y=0;y<e.length-1;y++){const g=pt(e[y],e[y+1],t);if(g){o=y,i=g;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const g=pt(e[y],e[y-1],r);if(g){s=y,a=g;break}}if(!i||!a||o>=s)return null;const u=e.slice(o+1,s),c=u[0]??a,l=u[u.length-1]??i;let d,f,p;if(n.arrowAt==="source"){const y=tr(i,c,n.srcDist);d=tr(i,c,n.srcDist+n.arrowGap),p=br(y,c,n.arrowSize,n.headShape)}else d=tr(i,c,n.srcDist);if(n.arrowAt==="target"){const y=tr(a,l,n.tgtDist);f=tr(a,l,n.tgtDist+n.arrowGap),p=br(y,l,n.arrowSize,n.headShape)}else f=tr(a,l,n.tgtDist);return _n(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function _n(e,t,r,n,o,i,s){var f;const a=[e,...t,r],u=[];let c=`M${Je(e)}`;for(let p=1;p<a.length-1;p++){const y=P0(a[p-1],a[p],a[p+1],o);u.push(y),y.r===0?c+=` L${Je(y.b)}`:c+=` L${Je(y.p1)} Q${Je(y.b)} ${Je(y.p2)}`}c+=` L${Je(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Fr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],y=t[d/2];l={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:Fr(y.x-p.x,y.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const y=a[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Fr(y.x-p.b.x,y.y-p.b.y)}}else l={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:Fr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&u.length===2){const b=u[0].p2,x=u[1].p1,m=Math.hypot(x.x-b.x,x.y-b.y),w=Math.min(.5,i/(2*m)),v=Math.max(w,Math.min(1-w,s));l={x:b.x+(x.x-b.x)*v,y:b.y+(x.y-b.y)*v,angle:Fr(x.x-b.x,x.y-b.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,y=r.x-p.x,g=r.y-p.y;Math.hypot(y,g)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Fr(y,g)})}return{d:c,arrow:n,label:l}}function ql(e,t,r,n,o,i,s){const a=r==="leftward"?-1:1,u={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},c={x:t.x-a*(t.w/2+s.tgtDist),y:o??t.y},l=Math.max(80,s.arrowGap+s.arrowSize*.3),d=u.x+a*l,f=c.x-a*l;let p;if(a*(f-d)>=0){const x=u.x+(c.x-u.x)*i,m=Math.max(Math.min(d,f),Math.min(Math.max(d,f),x));p=[{x:m,y:u.y},{x:m,y:c.y}]}else{const x=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:x},{x:f,y:x},{x:f,y:c.y}]}const y=s.arrowAt==="source"?tr(u,p[0],s.arrowGap):u,g=s.arrowAt==="target"?tr(c,p[p.length-1],s.arrowGap):c,b=s.arrowAt==="source"?br(u,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?br(c,p[p.length-1],s.arrowSize,s.headShape):void 0;return _n(y,p,g,b,s.radius)}function Nl(e,t,r,n,o){return km(j0(e,t,r,n),e,t,o)}function $l(e,t,r,n,o,i){const s=n===void 0&&o===void 0&&(r==="downward"||r==="upward"),a=r==="leftward"||s&&r==="upward"?-1:1,u=(c,l,d)=>{const f={x:c.x,y:l??c.y},p=Math.max(c.w,c.h)*2+1,y=pt(f,{x:f.x+(s?0:d*p),y:f.y+(s?d*p:0)},c);return y?{x:y.x+(s?0:d*i),y:y.y+(s?d*i:0)}:s?{x:c.x,y:c.y+d*(c.h/2+i)}:{x:c.x+d*(c.w/2+i),y:l??c.y}};return{sourcePoint:u(e,n,a),targetPoint:u(t,o,-a)}}function A0(e,t,r,n){const o=r==="downward"||r==="upward",i=r==="leftward"||r==="upward"?-1:1,s=Math.max(100,Math.abs(o?t.y-e.y:t.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},u={x:t.x-(o?0:i*s),y:t.y-(o?i*s:0)},c=n.arrowAt==="source"?tr(e,a,n.arrowGap):e,l=n.arrowAt==="target"?tr(t,u,n.arrowGap):t;return{d:`M${Je(c)} C${Je(a)} ${Je(u)} ${Je(l)}`,arrow:n.arrowAt==="source"?br(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?br(t,u,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*a.x+3*u.x+l.x)/8,y:(c.y+3*a.y+3*u.y+l.y)/8,angle:Fr(l.x+u.x-a.x-c.x,l.y+u.y-a.y-c.y)}}}function Rm(e,t,r){const n=r.arrowAt==="source"?tr(e,t,r.arrowGap):e,o=r.arrowAt==="target"?tr(t,e,r.arrowGap):t,i=r.arrowAt==="source"?br(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?br(t,e,r.arrowSize,r.headShape):void 0;return _n(n,[],o,i,0)}function T0(e,t,r,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,u=s-Math.PI/2,c=u-a/2,l=u+a/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},y={x:e.x,y:e.y},g=pt(y,f,e),b=pt(y,p,e);if(!g||!b)return null;const x={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let m=tr(g,f,r.srcDist),w=tr(b,p,r.tgtDist),v;if(r.arrowAt==="target"){const _=w;w=tr(b,p,r.tgtDist+r.arrowGap),v=br(_,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const _=m;m=tr(g,f,r.srcDist+r.arrowGap),v=br(_,f,r.arrowSize,r.headShape)}return{d:`M${Je(m)} Q${Je(f)} ${Je(x)} Q${Je(p)} ${Je(w)}`,arrow:v,label:{x:x.x,y:x.y,angle:Fr(p.x-f.x,p.y-f.y)}}}const at=e=>Math.round(e*1e3)/1e3;function Pm(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=t.getBoundingClientRect();if(!o.width||!o.height)return;const i=t,s=typeof i.getScreenCTM=="function"?i.getScreenCTM():null,a=typeof i.getTotalLength=="function"?i.getTotalLength():0,u=i.points,c=(u==null?void 0:u.numberOfItems)||128,l=s&&a>0?Array.from({length:c},(d,f)=>{const p=u!=null&&u.numberOfItems?u.getItem(f):i.getPointAtLength(a*f/c);return{x:at((s.a*p.x+s.c*p.y+s.e-r.left)/n),y:at((s.b*p.x+s.d*p.y+s.f-r.top)/n)}}):void 0;return{left:at((o.left-r.left)/n),top:at((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:at(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:at(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function Ft(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(o=>({x:r+o.x,y:n+o.y}))}:{}}}function O0(e,t,r,n,o){var l;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",u=new Map;for(const d of n)for(const[f,p,y]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const g=t.get(y);if(p===void 0||!g||y===f)continue;const b=r.get(y),x=JSON.stringify([f,p]),m=u.get(x)??[];m.push(b?Ft(g,b):g),u.set(x,m)}const c=new Map(e);for(const[d,f]of e){const p=t.get(d);if(!p||!f.some(w=>w.placement==="config"))continue;const y=r.get(d),g=y?Ft(p,y):p,b={x:p.w/2,y:p.h/2,w:p.w,h:p.h},x=y?Ft(b,y):b,m=new Map;for(const w of f){if(w.placement!=="config")continue;const C=(u.get(JSON.stringify([d,w.property]))??[]).reduce((R,T)=>R+(i?T.y-g.y:T.x-g.x),0),_=((l=w.anchor)==null?void 0:l.side)===a?a:s;m.set(w,C<-.001?s:C>.001?a:_)}c.set(d,f.map(w=>{const v=m.get(w);if(!v)return w;const C=f.filter(T=>m.get(T)===v),_=(C.indexOf(w)+1)/(C.length+1),R=jm(x,v,_);return{...w,anchor:R,top:R.y,height:0}}))}return c}function Ll(e,t,r){const n=new Set(t.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 t)!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 r)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 rt='"Helvetica Neue", Helvetica, sans-serif';let Et;const sn=new Map;function Sn(e,t){const r=`${t}|${e}`,n=sn.get(r);if(n!==void 0)return n;Et===void 0&&(Et=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return Et?(Et.font=t,o=Et.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,sn.size>5e3&&sn.clear(),sn.set(r,o),o}function I0(e,t,r){const n=[];for(const o of String(e).split(`
157
- `)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const u=s?`${s} ${a}`:a;!s||Sn(u,t)<=r?s=u:(n.push(s),s=a)}n.push(s)}return n}const M0=e=>e.stopPropagation();function q0({id:e,rect:t,label:r,labelLayer:n,style:o,onSelect:i,onCollapse:s,selected:a=!1}){const u=t.x2-t.x1,c=t.y2-t.y1,l=o.borderWidth,d=o.borderStyle==="dashed"?`${l*4} ${l*2}`:o.borderStyle==="dotted"?`${l} ${l}`:void 0,f=t.x1+u/2,p=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+c/2,y=r?Sn(r,`bold ${o.fontSize}px ${rt}`):0,g=o.fontSize/5,b=r||a&&s?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[a&&s&&h.jsx("foreignObject",{x:f+y/2+g+8,y:p-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:h.jsx(Ee,{label:"Show icon",children:h.jsx(be,{"aria-label":"Show icon",icon:h.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:x=>{x.stopPropagation(),s(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-y/2-g,y:p-o.fontSize/2-g,width:y+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),h.jsx("text",{x:f,y:p,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:M0,onClick:x=>{x.stopPropagation(),i==null||i(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.altKey})},children:[h.jsx("rect",{x:t.x1,y:t.y1,width:u,height:c,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?l/3:l,strokeDasharray:d}),o.borderStyle==="double"&&h.jsx("rect",{x:t.x1+l*2/3,y:t.y1+l*2/3,width:Math.max(0,u-l*4/3),height:Math.max(0,c-l*4/3),rx:Math.max(0,o.borderRadius-l*2/3),ry:Math.max(0,o.borderRadius-l*2/3),fill:"none",stroke:o.borderColor,strokeWidth:l/3}),o.animated&&l>0&&h.jsx(Em,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:c,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,l*1.6)}),n&&b?Dt.createPortal(b,n):b]})}const N0=S.memo(q0),gn=45,Am=70,Zr=15,Tm=50;function Om(e,t,r=gn){const n=`${r}px ${rt}`,o=e?I0(e,n,200*r/gn):[],i=t?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(c=>Sn(c,n))),a=Math.max(o.length*r,t?48:0),u=o.length||t?2*Zr:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+u,height:a+u}}const Bt=6,Im=3,Fu=Math.max(Math.pow(Bt*13.37,.9),29)*Im,Mm=Bt*Im*2,un=80,$0=2*un+Fu*.3+100,L0=36+2*Math.max(80,Mm+Fu*.3);function Cu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function _u(e,t){return t==="auto"||(t==="properties"?Cu(e):!Cu(e))}function ut(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&Cu(n))}function F0(e,t,r,n=!1,o){if(!n)return{nodes:e,edges:t};const i=e.filter(a=>ut(a.id,t,r)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:t.filter(a=>_u(a,r)&&s.has(a.source)&&s.has(a.target))}}const B0=500,D0="32 18",z0=e=>e.stopPropagation();function V0({id:e,reveal:t,onRevealComplete:r,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:u,target:c,sourceProperty:l,targetProperty:d,sourceY:f,targetY:p,sourcePort:y,targetPort:g,propertyMode:b=!1,dir:x,turn:m,labelAtTarget:w,labelFraction:v,color:C,labelBg:_,labelLayer:R,label:T,dashed:A,animated:k,inverted:E,loopIndex:j=0,onSelect:M}){const I=n==null?void 0:n.icon,q=b?gn:Am,{lines:O,iconWidth:V,contentWidth:W,contentHeight:re}=S.useMemo(()=>Om(T,I,q),[T,I,q]),Y=S.useMemo(()=>{const K={srcDist:un,tgtDist:un,arrowGap:Mm,arrowSize:Fu,headShape:b&&(E?f!==void 0||y:p!==void 0||g)?"square":"triangle",radius:s??(w?40:B0),arrowAt:E?"source":"target",labelTargetLength:w?W+2*Zr:void 0,labelFraction:w?v:void 0},te=f!==void 0||p!==void 0||!!y||!!g,ce=$l(u,c,x,f,p,0),de=f===void 0&&p===void 0&&(x==="downward"||x==="upward"),Ae=y??{...ce.sourcePoint,side:de?x==="upward"?"top":"bottom":x==="leftward"?"left":"right"},ge=g??{...ce.targetPoint,side:de?x==="upward"?"bottom":"top":x==="leftward"?"right":"left"},Ke=u.x===c.x&&u.y===c.y,Oe=y||g?R0(Ae,ge,{...K,srcDist:18,tgtDist:18},i):te?ql(u,c,x,f,p,m,{...K,srcDist:18,tgtDist:18,radius:s??Math.min(K.radius,40)}):Ke?T0(u,j,{...K,srcDist:0,tgtDist:0}):Nl(u,c,x,m,K);if(!Oe)return null;const Le=$l(u,c,x,f,p,te?18:un);y&&(Le.sourcePoint=dt(y,18)),g&&(Le.targetPoint=dt(g,18));const er=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(er){const Ve={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return er({edge:n??{id:e,source:"",target:""},source:{...u},target:{...c},...Le,direction:Ve[x],sourceY:f,targetY:p,inverted:!!E,defaultGeometry:Oe})??Oe}return Ke||y||g?Oe:i==="straight"?te?Rm(Le.sourcePoint,Le.targetPoint,K):km([u,c],u,c,K):i==="bezier"?A0(Le.sourcePoint,Le.targetPoint,te?x==="leftward"?"leftward":"rightward":x,K):i==="orthogonal"?te?ql(u,c,x,f,p,m,{...K,srcDist:18,tgtDist:18,radius:0}):Nl(u,c,x,m,{...K,radius:0}):Oe},[u,e,n,i,s,a,c,b,f,p,y,g,x,m,E,j,w,v,W]);if(!Y)return null;const he=(x==="rightward"||x==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(b&&(f!==void 0||p!==void 0||y||g)),me=he?`translate(${Y.label.x} ${Y.label.y-re/2-2*Zr})`:`translate(${Y.label.x} ${Y.label.y}) rotate(${Y.label.angle}) translate(${w||Object.prototype.hasOwnProperty.call(a??{},i)?0:Tm} 0)`,J=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",N=o?J:C,L=o?h.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${Y.label.x} ${Y.label.y-O.length*q/2-55})`,children:[h.jsx("title",{children:o}),h.jsx(qr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:J})]}):null,G=k&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",D=!G&&(A||k)?D0:void 0,ne=k&&!G?`flow-sdk-edge-anim${E?" flow-sdk-edge-anim-rev":""}`:void 0;let ue=null;const X=t?{"--flow-edge-reveal-duration":`${t.durationMs??600}ms`,"--flow-edge-reveal-state":t.paused?"paused":"running"}:void 0;if(O.length||I){const K=W,te=re;ue=h.jsxs("g",{className:`flow-sdk-edge-label${t?" flow-sdk-edge-reveal-end":""}`,style:X,"data-label-transform":me,"data-label-horizontal":he||void 0,"data-edge-id":e,"data-source-property":l,"data-target-property":d,transform:me,children:[h.jsx("rect",{x:-K/2-Zr,y:-te/2-Zr,width:K+2*Zr,height:te+2*Zr,fill:C==="transparent"?"transparent":_}),h.jsx("text",{fill:C,fontSize:q,style:{fontSize:q,fontFamily:rt},fontFamily:rt,textAnchor:"middle",dominantBaseline:"central",children:O.map((ce,de)=>h.jsx("tspan",{x:V/2,y:(de-(O.length-1)/2)*q,children:ce},de))}),I&&h.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[h.jsx("title",{children:T?`Edge icon: ${T}`:"Edge icon"}),h.jsx("rect",{x:-K/2,y:-24,width:48,height:48,fill:"transparent"}),h.jsx(qr,{name:I,svg:!0,size:48,x:-K/2,y:-24,color:C})]})]})}const U=h.jsxs(h.Fragment,{children:[h.jsx("path",{d:Y.d,fill:"none",stroke:N,strokeWidth:Bt,strokeOpacity:G?.35:void 0,strokeDasharray:D,className:ne}),G&&h.jsx(m0,{path:Y.d,color:N,width:Bt*1.6,reversed:E})]});return h.jsxs("g",{className:"flow-sdk-edge",style:X,"data-edge-id":e,"data-source-property":l,"data-target-property":d,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:z0,onClick:K=>{K.stopPropagation(),M==null||M(e)},children:[t?h.jsx(v0,{path:Y.d,width:Bt*4,reversed:E,onComplete:()=>r==null?void 0:r(e),children:U}):U,Y.arrow&&h.jsx("path",{className:t?"flow-sdk-edge-reveal-end":void 0,d:Y.arrow,fill:N}),R&&ue?Dt.createPortal(ue,R):ue,R&&L?Dt.createPortal(L,R):L,h.jsx("path",{className:"flow-sdk-edge-hit",d:Y.d,fill:"none",stroke:"transparent"})]})}const Fl=S.memo(V0);function W0(e,t,r){const[n,o]=S.useState(()=>({nodes:new Set,edges:new Set})),i=S.useMemo(()=>{const a=new Set(e.map(p=>p.id)),u=t.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})),c=new Set(u.map(p=>p.id)),l=new Set([...n.nodes].filter(p=>a.has(p))),d=new Set([...n.edges].filter(p=>c.has(p)));if(!r)return{nodes:a,edges:c,ready:c};for(const p of e)u.filter(g=>g.target===p.id&&g.source!==g.target).every(g=>d.has(g.id))&&l.add(p.id);let f=new Set(u.filter(p=>l.has(p.source)).map(p=>p.id));if(l.size<a.size&&!u.some(p=>f.has(p.id)&&!d.has(p.id))){const p=e.find(y=>!l.has(y.id));p&&l.add(p.id),f=new Set(u.filter(y=>l.has(y.source)).map(y=>y.id))}return{nodes:l,edges:d,ready:f}},[e,t,r,n]);S.useLayoutEffect(()=>{o(a=>{const u=r?i:{nodes:new Set,edges:new Set},c=(l,d)=>l.size===d.size&&[...l].every(f=>d.has(f));return c(a.nodes,u.nodes)&&c(a.edges,u.edges)?a:{nodes:u.nodes,edges:u.edges}})},[i,r]);const s=S.useCallback(a=>{o(u=>u.edges.has(a)?u:{...u,edges:new Set([...u.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}const Bl=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function G0(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),o=(c,l=0)=>{const d=c.getBoundingClientRect(),f=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:f.x-l,right:p.x+l,top:f.y-l,bottom:p.y+l}},i=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const l=c.getBoundingClientRect(),d=getComputedStyle(c);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(c=>o(c,24));for(const c of t.querySelectorAll(".flow-sdk-container-label"))i.push(o(c,12));const s=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const c of s)c.setAttribute("transform",c.dataset.labelTransform??"");const a=new Map(s.map(c=>[c,o(c,8)])),u=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of s){const l=c.dataset.labelHorizontal==="true",d=a.get(c);a.delete(c);const f=R=>i.some(T=>Bl(R,T))||[...a.values()].some(T=>Bl(R,T));if(!l&&!f(d)){a.set(c,d);continue}const p=u.get(c.dataset.edgeId),y=c.querySelector("rect");if(!p||!y)continue;const g=y.getBBox(),b=p.getTotalLength();if(!Number.isFinite(b)||b<=0)continue;const x=(d.left+d.right)/2,m=(d.top+d.bottom)/2,w=Math.min(256,Math.max(16,Math.ceil(b/24))),v=Array.from({length:w+1},(R,T)=>p.getPointAtLength(b*T/w)),_=Array.from({length:w+1},(R,T)=>{const A=b*T/w,k=v[T],E=l?{x:k.x,y:k.y-g.height/2-15}:k,j=p.getPointAtLength(Math.max(0,A-2)),M=p.getPointAtLength(Math.min(b,A+2));let I=Math.atan2(M.y-j.y,M.x-j.x)*180/Math.PI;I>90&&(I-=180),I<-90&&(I+=180);const q=Math.abs(I)<1;l&&(I=0);const O=I*Math.PI/180,V=Math.abs(Math.cos(O))*g.width+Math.abs(Math.sin(O))*g.height,W=Math.abs(Math.sin(O))*g.width+Math.abs(Math.cos(O))*g.height;return{point:E,angle:I,straight:q,score:Math.hypot(E.x-x,E.y-m),bounds:{left:E.x-V/2-8,right:E.x+V/2+8,top:E.y-W/2-8,bottom:E.y+W/2+8}}}).sort((R,T)=>R.score-T.score).find(R=>!f(R.bounds)&&(!l||R.straight&&!v.some(T=>T.x>R.bounds.left&&T.x<R.bounds.right&&T.y>R.bounds.top&&T.y<R.bounds.bottom)));_?(c.setAttribute("transform",`translate(${_.point.x} ${_.point.y}) rotate(${_.angle})`),a.set(c,_.bounds)):a.set(c,d)}}var cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function U0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Bu(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 Qn,Dl;function H0(){if(Dl)return Qn;Dl=1;function e(){this.__data__=[],this.size=0}return Qn=e,Qn}var eo,zl;function mt(){if(zl)return eo;zl=1;function e(t,r){return t===r||t!==t&&r!==r}return eo=e,eo}var ro,Vl;function En(){if(Vl)return ro;Vl=1;var e=mt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return ro=t,ro}var to,Wl;function K0(){if(Wl)return to;Wl=1;var e=En(),t=Array.prototype,r=t.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():r.call(i,s,1),--this.size,!0}return to=n,to}var no,Gl;function J0(){if(Gl)return no;Gl=1;var e=En();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return no=t,no}var oo,Ul;function Z0(){if(Ul)return oo;Ul=1;var e=En();function t(r){return e(this.__data__,r)>-1}return oo=t,oo}var io,Hl;function Y0(){if(Hl)return io;Hl=1;var e=En();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return io=t,io}var ao,Kl;function jn(){if(Kl)return ao;Kl=1;var e=H0(),t=K0(),r=J0(),n=Z0(),o=Y0();function i(s){var a=-1,u=s==null?0:s.length;for(this.clear();++a<u;){var c=s[a];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,ao=i,ao}var so,Jl;function X0(){if(Jl)return so;Jl=1;var e=jn();function t(){this.__data__=new e,this.size=0}return so=t,so}var co,Zl;function Q0(){if(Zl)return co;Zl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return co=e,co}var uo,Yl;function ew(){if(Yl)return uo;Yl=1;function e(t){return this.__data__.get(t)}return uo=e,uo}var lo,Xl;function rw(){if(Xl)return lo;Xl=1;function e(t){return this.__data__.has(t)}return lo=e,lo}var fo,Ql;function qm(){if(Ql)return fo;Ql=1;var e=typeof cn=="object"&&cn&&cn.Object===Object&&cn;return fo=e,fo}var ho,ed;function Sr(){if(ed)return ho;ed=1;var e=qm(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return ho=r,ho}var po,rd;function bt(){if(rd)return po;rd=1;var e=Sr(),t=e.Symbol;return po=t,po}var go,td;function tw(){if(td)return go;td=1;var e=bt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(s){var a=r.call(s,o),u=s[o];try{s[o]=void 0;var c=!0}catch{}var l=n.call(s);return c&&(a?s[o]=u:delete s[o]),l}return go=i,go}var yo,nd;function nw(){if(nd)return yo;nd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return yo=r,yo}var mo,od;function tt(){if(od)return mo;od=1;var e=bt(),t=tw(),r=nw(),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)?t(a):r(a)}return mo=s,mo}var bo,id;function vr(){if(id)return bo;id=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return bo=e,bo}var vo,ad;function en(){if(ad)return vo;ad=1;var e=tt(),t=vr(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!t(a))return!1;var u=e(a);return u==n||u==o||u==r||u==i}return vo=s,vo}var xo,sd;function ow(){if(sd)return xo;sd=1;var e=Sr(),t=e["__core-js_shared__"];return xo=t,xo}var wo,cd;function iw(){if(cd)return wo;cd=1;var e=ow(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return wo=r,wo}var Co,ud;function Nm(){if(ud)return Co;ud=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Co=r,Co}var _o,ld;function aw(){if(ld)return _o;ld=1;var e=en(),t=iw(),r=vr(),n=Nm(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,u=s.toString,c=a.hasOwnProperty,l=RegExp("^"+u.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?l:i;return p.test(n(f))}return _o=d,_o}var So,dd;function sw(){if(dd)return So;dd=1;function e(t,r){return t==null?void 0:t[r]}return So=e,So}var Eo,fd;function nt(){if(fd)return Eo;fd=1;var e=aw(),t=sw();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return Eo=r,Eo}var jo,hd;function Du(){if(hd)return jo;hd=1;var e=nt(),t=Sr(),r=e(t,"Map");return jo=r,jo}var ko,pd;function kn(){if(pd)return ko;pd=1;var e=nt(),t=e(Object,"create");return ko=t,ko}var Ro,gd;function cw(){if(gd)return Ro;gd=1;var e=kn();function t(){this.__data__=e?e(null):{},this.size=0}return Ro=t,Ro}var Po,yd;function uw(){if(yd)return Po;yd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Po=e,Po}var Ao,md;function lw(){if(md)return Ao;md=1;var e=kn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===t?void 0:a}return n.call(s,i)?s[i]:void 0}return Ao=o,Ao}var To,bd;function dw(){if(bd)return To;bd=1;var e=kn(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return To=n,To}var Oo,vd;function fw(){if(vd)return Oo;vd=1;var e=kn(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return Oo=r,Oo}var Io,xd;function hw(){if(xd)return Io;xd=1;var e=cw(),t=uw(),r=lw(),n=dw(),o=fw();function i(s){var a=-1,u=s==null?0:s.length;for(this.clear();++a<u;){var c=s[a];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Io=i,Io}var Mo,wd;function pw(){if(wd)return Mo;wd=1;var e=hw(),t=jn(),r=Du();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Mo=n,Mo}var qo,Cd;function gw(){if(Cd)return qo;Cd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return qo=e,qo}var No,_d;function Rn(){if(_d)return No;_d=1;var e=gw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return No=t,No}var $o,Sd;function yw(){if(Sd)return $o;Sd=1;var e=Rn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return $o=t,$o}var Lo,Ed;function mw(){if(Ed)return Lo;Ed=1;var e=Rn();function t(r){return e(this,r).get(r)}return Lo=t,Lo}var Fo,jd;function bw(){if(jd)return Fo;jd=1;var e=Rn();function t(r){return e(this,r).has(r)}return Fo=t,Fo}var Bo,kd;function vw(){if(kd)return Bo;kd=1;var e=Rn();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return Bo=t,Bo}var Do,Rd;function zu(){if(Rd)return Do;Rd=1;var e=pw(),t=yw(),r=mw(),n=bw(),o=vw();function i(s){var a=-1,u=s==null?0:s.length;for(this.clear();++a<u;){var c=s[a];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Do=i,Do}var zo,Pd;function xw(){if(Pd)return zo;Pd=1;var e=jn(),t=Du(),r=zu(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var u=a.__data__;if(!t||u.length<n-1)return u.push([i,s]),this.size=++a.size,this;a=this.__data__=new r(u)}return a.set(i,s),this.size=a.size,this}return zo=o,zo}var Vo,Ad;function Pn(){if(Ad)return Vo;Ad=1;var e=jn(),t=X0(),r=Q0(),n=ew(),o=rw(),i=xw();function s(a){var u=this.__data__=new e(a);this.size=u.size}return s.prototype.clear=t,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Vo=s,Vo}var Wo,Td;function Vu(){if(Td)return Wo;Td=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return Wo=e,Wo}var Go,Od;function $m(){if(Od)return Go;Od=1;var e=nt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Go=t,Go}var Uo,Id;function An(){if(Id)return Uo;Id=1;var e=$m();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Uo=t,Uo}var Ho,Md;function Tn(){if(Md)return Ho;Md=1;var e=An(),t=mt(),r=Object.prototype,n=r.hasOwnProperty;function o(i,s,a){var u=i[s];(!(n.call(i,s)&&t(u,a))||a===void 0&&!(s in i))&&e(i,s,a)}return Ho=o,Ho}var Ko,qd;function rn(){if(qd)return Ko;qd=1;var e=Tn(),t=An();function r(n,o,i,s){var a=!i;i||(i={});for(var u=-1,c=o.length;++u<c;){var l=o[u],d=s?s(i[l],n[l],l,i,n):void 0;d===void 0&&(d=n[l]),a?t(i,l,d):e(i,l,d)}return i}return Ko=r,Ko}var Jo,Nd;function ww(){if(Nd)return Jo;Nd=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Jo=e,Jo}var Zo,$d;function Pr(){if($d)return Zo;$d=1;function e(t){return t!=null&&typeof t=="object"}return Zo=e,Zo}var Yo,Ld;function Cw(){if(Ld)return Yo;Ld=1;var e=tt(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Yo=n,Yo}var Xo,Fd;function tn(){if(Fd)return Xo;Fd=1;var e=Cw(),t=Pr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return t(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Xo=i,Xo}var Qo,Bd;function Xe(){if(Bd)return Qo;Bd=1;var e=Array.isArray;return Qo=e,Qo}var Tt={exports:{}},ei,Dd;function _w(){if(Dd)return ei;Dd=1;function e(){return!1}return ei=e,ei}Tt.exports;var zd;function vt(){return zd||(zd=1,(function(e,t){var r=Sr(),n=_w(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?r.Buffer:void 0,u=a?a.isBuffer:void 0,c=u||n;e.exports=c})(Tt,Tt.exports)),Tt.exports}var ri,Vd;function On(){if(Vd)return ri;Vd=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return ri=r,ri}var ti,Wd;function Wu(){if(Wd)return ti;Wd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ti=t,ti}var ni,Gd;function Sw(){if(Gd)return ni;Gd=1;var e=tt(),t=Wu(),r=Pr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",u="[object Function]",c="[object Map]",l="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",y="[object String]",g="[object WeakMap]",b="[object ArrayBuffer]",x="[object DataView]",m="[object Float32Array]",w="[object Float64Array]",v="[object Int8Array]",C="[object Int16Array]",_="[object Int32Array]",R="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",k="[object Uint32Array]",E={};E[m]=E[w]=E[v]=E[C]=E[_]=E[R]=E[T]=E[A]=E[k]=!0,E[n]=E[o]=E[b]=E[i]=E[x]=E[s]=E[a]=E[u]=E[c]=E[l]=E[d]=E[f]=E[p]=E[y]=E[g]=!1;function j(M){return r(M)&&t(M.length)&&!!E[e(M)]}return ni=j,ni}var oi,Ud;function In(){if(Ud)return oi;Ud=1;function e(t){return function(r){return t(r)}}return oi=e,oi}var Ot={exports:{}};Ot.exports;var Hd;function Gu(){return Hd||(Hd=1,(function(e,t){var r=qm(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&r.process,a=(function(){try{var u=o&&o.require&&o.require("util").types;return u||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(Ot,Ot.exports)),Ot.exports}var ii,Kd;function nn(){if(Kd)return ii;Kd=1;var e=Sw(),t=In(),r=Gu(),n=r&&r.isTypedArray,o=n?t(n):e;return ii=o,ii}var ai,Jd;function Lm(){if(Jd)return ai;Jd=1;var e=ww(),t=tn(),r=Xe(),n=vt(),o=On(),i=nn(),s=Object.prototype,a=s.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),y=!d&&!f&&!p&&i(c),g=d||f||p||y,b=g?e(c.length,String):[],x=b.length;for(var m in c)(l||a.call(c,m))&&!(g&&(m=="length"||p&&(m=="offset"||m=="parent")||y&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||o(m,x)))&&b.push(m);return b}return ai=u,ai}var si,Zd;function Mn(){if(Zd)return si;Zd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return si=t,si}var ci,Yd;function Fm(){if(Yd)return ci;Yd=1;function e(t,r){return function(n){return t(r(n))}}return ci=e,ci}var ui,Xd;function Ew(){if(Xd)return ui;Xd=1;var e=Fm(),t=e(Object.keys,Object);return ui=t,ui}var li,Qd;function Uu(){if(Qd)return li;Qd=1;var e=Mn(),t=Ew(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return li=o,li}var di,ef;function Nr(){if(ef)return di;ef=1;var e=en(),t=Wu();function r(n){return n!=null&&t(n.length)&&!e(n)}return di=r,di}var fi,rf;function Hr(){if(rf)return fi;rf=1;var e=Lm(),t=Uu(),r=Nr();function n(o){return r(o)?e(o):t(o)}return fi=n,fi}var hi,tf;function jw(){if(tf)return hi;tf=1;var e=rn(),t=Hr();function r(n,o){return n&&e(o,t(o),n)}return hi=r,hi}var pi,nf;function kw(){if(nf)return pi;nf=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return pi=e,pi}var gi,of;function Rw(){if(of)return gi;of=1;var e=vr(),t=Mn(),r=kw(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return r(s);var a=t(s),u=[];for(var c in s)c=="constructor"&&(a||!o.call(s,c))||u.push(c);return u}return gi=i,gi}var yi,af;function ot(){if(af)return yi;af=1;var e=Lm(),t=Rw(),r=Nr();function n(o){return r(o)?e(o,!0):t(o)}return yi=n,yi}var mi,sf;function Pw(){if(sf)return mi;sf=1;var e=rn(),t=ot();function r(n,o){return n&&e(o,t(o),n)}return mi=r,mi}var It={exports:{}};It.exports;var cf;function Bm(){return cf||(cf=1,(function(e,t){var r=Sr(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var d=c.length,f=a?a(d):new c.constructor(d);return c.copy(f),f}e.exports=u})(It,It.exports)),It.exports}var bi,uf;function Dm(){if(uf)return bi;uf=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return bi=e,bi}var vi,lf;function zm(){if(lf)return vi;lf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,s=[];++n<o;){var a=t[n];r(a,n,t)&&(s[i++]=a)}return s}return vi=e,vi}var xi,df;function Vm(){if(df)return xi;df=1;function e(){return[]}return xi=e,xi}var wi,ff;function Hu(){if(ff)return wi;ff=1;var e=zm(),t=Vm(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:t;return wi=i,wi}var Ci,hf;function Aw(){if(hf)return Ci;hf=1;var e=rn(),t=Hu();function r(n,o){return e(n,t(n),o)}return Ci=r,Ci}var _i,pf;function Ku(){if(pf)return _i;pf=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return _i=e,_i}var Si,gf;function qn(){if(gf)return Si;gf=1;var e=Fm(),t=e(Object.getPrototypeOf,Object);return Si=t,Si}var Ei,yf;function Wm(){if(yf)return Ei;yf=1;var e=Ku(),t=qn(),r=Hu(),n=Vm(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,r(s)),s=t(s);return a}:n;return Ei=i,Ei}var ji,mf;function Tw(){if(mf)return ji;mf=1;var e=rn(),t=Wm();function r(n,o){return e(n,t(n),o)}return ji=r,ji}var ki,bf;function Gm(){if(bf)return ki;bf=1;var e=Ku(),t=Xe();function r(n,o,i){var s=o(n);return t(n)?s:e(s,i(n))}return ki=r,ki}var Ri,vf;function Um(){if(vf)return Ri;vf=1;var e=Gm(),t=Hu(),r=Hr();function n(o){return e(o,r,t)}return Ri=n,Ri}var Pi,xf;function Ow(){if(xf)return Pi;xf=1;var e=Gm(),t=Wm(),r=ot();function n(o){return e(o,r,t)}return Pi=n,Pi}var Ai,wf;function Iw(){if(wf)return Ai;wf=1;var e=nt(),t=Sr(),r=e(t,"DataView");return Ai=r,Ai}var Ti,Cf;function Mw(){if(Cf)return Ti;Cf=1;var e=nt(),t=Sr(),r=e(t,"Promise");return Ti=r,Ti}var Oi,_f;function Hm(){if(_f)return Oi;_f=1;var e=nt(),t=Sr(),r=e(t,"Set");return Oi=r,Oi}var Ii,Sf;function qw(){if(Sf)return Ii;Sf=1;var e=nt(),t=Sr(),r=e(t,"WeakMap");return Ii=r,Ii}var Mi,Ef;function xt(){if(Ef)return Mi;Ef=1;var e=Iw(),t=Du(),r=Mw(),n=Hm(),o=qw(),i=tt(),s=Nm(),a="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=s(e),y=s(t),g=s(r),b=s(n),x=s(o),m=i;return(e&&m(new e(new ArrayBuffer(1)))!=f||t&&m(new t)!=a||r&&m(r.resolve())!=c||n&&m(new n)!=l||o&&m(new o)!=d)&&(m=function(w){var v=i(w),C=v==u?w.constructor:void 0,_=C?s(C):"";if(_)switch(_){case p:return f;case y:return a;case g:return c;case b:return l;case x:return d}return v}),Mi=m,Mi}var qi,jf;function Nw(){if(jf)return qi;jf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return qi=r,qi}var Ni,kf;function Km(){if(kf)return Ni;kf=1;var e=Sr(),t=e.Uint8Array;return Ni=t,Ni}var $i,Rf;function Ju(){if(Rf)return $i;Rf=1;var e=Km();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return $i=t,$i}var Li,Pf;function $w(){if(Pf)return Li;Pf=1;var e=Ju();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Li=t,Li}var Fi,Af;function Lw(){if(Af)return Fi;Af=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Fi=t,Fi}var Bi,Tf;function Fw(){if(Tf)return Bi;Tf=1;var e=bt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Bi=n,Bi}var Di,Of;function Jm(){if(Of)return Di;Of=1;var e=Ju();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Di=t,Di}var zi,If;function Bw(){if(If)return zi;If=1;var e=Ju(),t=$w(),r=Lw(),n=Fw(),o=Jm(),i="[object Boolean]",s="[object Date]",a="[object Map]",u="[object Number]",c="[object RegExp]",l="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",g="[object Float32Array]",b="[object Float64Array]",x="[object Int8Array]",m="[object Int16Array]",w="[object Int32Array]",v="[object Uint8Array]",C="[object Uint8ClampedArray]",_="[object Uint16Array]",R="[object Uint32Array]";function T(A,k,E){var j=A.constructor;switch(k){case p:return e(A);case i:case s:return new j(+A);case y:return t(A,E);case g:case b:case x:case m:case w:case v:case C:case _:case R:return o(A,E);case a:return new j;case u:case d:return new j(A);case c:return r(A);case l:return new j;case f:return n(A)}}return zi=T,zi}var Vi,Mf;function Zm(){if(Mf)return Vi;Mf=1;var e=vr(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Vi=r,Vi}var Wi,qf;function Ym(){if(qf)return Wi;qf=1;var e=Zm(),t=qn(),r=Mn();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Wi=n,Wi}var Gi,Nf;function Dw(){if(Nf)return Gi;Nf=1;var e=xt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Gi=n,Gi}var Ui,$f;function zw(){if($f)return Ui;$f=1;var e=Dw(),t=In(),r=Gu(),n=r&&r.isMap,o=n?t(n):e;return Ui=o,Ui}var Hi,Lf;function Vw(){if(Lf)return Hi;Lf=1;var e=xt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Hi=n,Hi}var Ki,Ff;function Ww(){if(Ff)return Ki;Ff=1;var e=Vw(),t=In(),r=Gu(),n=r&&r.isSet,o=n?t(n):e;return Ki=o,Ki}var Ji,Bf;function Xm(){if(Bf)return Ji;Bf=1;var e=Pn(),t=Vu(),r=Tn(),n=jw(),o=Pw(),i=Bm(),s=Dm(),a=Aw(),u=Tw(),c=Um(),l=Ow(),d=xt(),f=Nw(),p=Bw(),y=Ym(),g=Xe(),b=vt(),x=zw(),m=vr(),w=Ww(),v=Hr(),C=ot(),_=1,R=2,T=4,A="[object Arguments]",k="[object Array]",E="[object Boolean]",j="[object Date]",M="[object Error]",I="[object Function]",q="[object GeneratorFunction]",O="[object Map]",V="[object Number]",W="[object Object]",re="[object RegExp]",Y="[object Set]",he="[object String]",me="[object Symbol]",J="[object WeakMap]",N="[object ArrayBuffer]",L="[object DataView]",G="[object Float32Array]",D="[object Float64Array]",ne="[object Int8Array]",ue="[object Int16Array]",X="[object Int32Array]",U="[object Uint8Array]",K="[object Uint8ClampedArray]",te="[object Uint16Array]",ce="[object Uint32Array]",de={};de[A]=de[k]=de[N]=de[L]=de[E]=de[j]=de[G]=de[D]=de[ne]=de[ue]=de[X]=de[O]=de[V]=de[W]=de[re]=de[Y]=de[he]=de[me]=de[U]=de[K]=de[te]=de[ce]=!0,de[M]=de[I]=de[J]=!1;function Ae(ge,Ke,Oe,Le,er,Ve){var $e,xe=Ke&_,Me=Ke&R,Fe=Ke&T;if(Oe&&($e=er?Oe(ge,Le,er,Ve):Oe(ge)),$e!==void 0)return $e;if(!m(ge))return ge;var nr=g(ge);if(nr){if($e=f(ge),!xe)return s(ge,$e)}else{var Ze=d(ge),Ye=Ze==I||Ze==q;if(b(ge))return i(ge,xe);if(Ze==W||Ze==A||Ye&&!er){if($e=Me||Ye?{}:y(ge),!xe)return Me?u(ge,o($e,ge)):a(ge,n($e,ge))}else{if(!de[Ze])return er?ge:{};$e=p(ge,Ze,xe)}}Ve||(Ve=new e);var fr=Ve.get(ge);if(fr)return fr;Ve.set(ge,$e),w(ge)?ge.forEach(function(ar){$e.add(Ae(ar,Ke,Oe,ar,ge,Ve))}):x(ge)&&ge.forEach(function(ar,sr){$e.set(sr,Ae(ar,Ke,Oe,sr,ge,Ve))});var wr=Fe?Me?l:c:Me?C:v,we=nr?void 0:wr(ge);return t(we||ge,function(ar,sr){we&&(sr=ar,ar=ge[sr]),r($e,sr,Ae(ar,Ke,Oe,sr,ge,Ve))}),$e}return Ji=Ae,Ji}var Zi,Df;function Gw(){if(Df)return Zi;Df=1;var e=Xm(),t=4;function r(n){return e(n,t)}return Zi=r,Zi}var Yi,zf;function Zu(){if(zf)return Yi;zf=1;function e(t){return function(){return t}}return Yi=e,Yi}var Xi,Vf;function Uw(){if(Vf)return Xi;Vf=1;function e(t){return function(r,n,o){for(var i=-1,s=Object(r),a=o(r),u=a.length;u--;){var c=a[t?u:++i];if(n(s[c],c,s)===!1)break}return r}}return Xi=e,Xi}var Qi,Wf;function Yu(){if(Wf)return Qi;Wf=1;var e=Uw(),t=e();return Qi=t,Qi}var ea,Gf;function Xu(){if(Gf)return ea;Gf=1;var e=Yu(),t=Hr();function r(n,o){return n&&e(n,o,t)}return ea=r,ea}var ra,Uf;function Hw(){if(Uf)return ra;Uf=1;var e=Nr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var s=o.length,a=n?s:-1,u=Object(o);(n?a--:++a<s)&&i(u[a],a,u)!==!1;);return o}}return ra=t,ra}var ta,Hf;function Nn(){if(Hf)return ta;Hf=1;var e=Xu(),t=Hw(),r=t(e);return ta=r,ta}var na,Kf;function it(){if(Kf)return na;Kf=1;function e(t){return t}return na=e,na}var oa,Jf;function Qm(){if(Jf)return oa;Jf=1;var e=it();function t(r){return typeof r=="function"?r:e}return oa=t,oa}var ia,Zf;function eb(){if(Zf)return ia;Zf=1;var e=Vu(),t=Nn(),r=Qm(),n=Xe();function o(i,s){var a=n(i)?e:t;return a(i,r(s))}return ia=o,ia}var aa,Yf;function rb(){return Yf||(Yf=1,aa=eb()),aa}var sa,Xf;function Kw(){if(Xf)return sa;Xf=1;var e=Nn();function t(r,n){var o=[];return e(r,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return sa=t,sa}var ca,Qf;function Jw(){if(Qf)return ca;Qf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return ca=t,ca}var ua,eh;function Zw(){if(eh)return ua;eh=1;function e(t){return this.__data__.has(t)}return ua=e,ua}var la,rh;function tb(){if(rh)return la;rh=1;var e=zu(),t=Jw(),r=Zw();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=t,n.prototype.has=r,la=n,la}var da,th;function Yw(){if(th)return da;th=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return da=e,da}var fa,nh;function nb(){if(nh)return fa;nh=1;function e(t,r){return t.has(r)}return fa=e,fa}var ha,oh;function ob(){if(oh)return ha;oh=1;var e=tb(),t=Yw(),r=nb(),n=1,o=2;function i(s,a,u,c,l,d){var f=u&n,p=s.length,y=a.length;if(p!=y&&!(f&&y>p))return!1;var g=d.get(s),b=d.get(a);if(g&&b)return g==a&&b==s;var x=-1,m=!0,w=u&o?new e:void 0;for(d.set(s,a),d.set(a,s);++x<p;){var v=s[x],C=a[x];if(c)var _=f?c(C,v,x,a,s,d):c(v,C,x,s,a,d);if(_!==void 0){if(_)continue;m=!1;break}if(w){if(!t(a,function(R,T){if(!r(w,T)&&(v===R||l(v,R,u,c,d)))return w.push(T)})){m=!1;break}}else if(!(v===C||l(v,C,u,c,d))){m=!1;break}}return d.delete(s),d.delete(a),m}return ha=i,ha}var pa,ih;function Xw(){if(ih)return pa;ih=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return pa=e,pa}var ga,ah;function Qu(){if(ah)return ga;ah=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return ga=e,ga}var ya,sh;function Qw(){if(sh)return ya;sh=1;var e=bt(),t=Km(),r=mt(),n=ob(),o=Xw(),i=Qu(),s=1,a=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",y="[object Set]",g="[object String]",b="[object Symbol]",x="[object ArrayBuffer]",m="[object DataView]",w=e?e.prototype:void 0,v=w?w.valueOf:void 0;function C(_,R,T,A,k,E,j){switch(T){case m:if(_.byteLength!=R.byteLength||_.byteOffset!=R.byteOffset)return!1;_=_.buffer,R=R.buffer;case x:return!(_.byteLength!=R.byteLength||!E(new t(_),new t(R)));case u:case c:case f:return r(+_,+R);case l:return _.name==R.name&&_.message==R.message;case p:case g:return _==R+"";case d:var M=o;case y:var I=A&s;if(M||(M=i),_.size!=R.size&&!I)return!1;var q=j.get(_);if(q)return q==R;A|=a,j.set(_,R);var O=n(M(_),M(R),A,k,E,j);return j.delete(_),O;case b:if(v)return v.call(_)==v.call(R)}return!1}return ya=C,ya}var ma,ch;function e1(){if(ch)return ma;ch=1;var e=Um(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,s,a,u,c,l){var d=a&t,f=e(i),p=f.length,y=e(s),g=y.length;if(p!=g&&!d)return!1;for(var b=p;b--;){var x=f[b];if(!(d?x in s:n.call(s,x)))return!1}var m=l.get(i),w=l.get(s);if(m&&w)return m==s&&w==i;var v=!0;l.set(i,s),l.set(s,i);for(var C=d;++b<p;){x=f[b];var _=i[x],R=s[x];if(u)var T=d?u(R,_,x,s,i,l):u(_,R,x,i,s,l);if(!(T===void 0?_===R||c(_,R,a,u,l):T)){v=!1;break}C||(C=x=="constructor")}if(v&&!C){var A=i.constructor,k=s.constructor;A!=k&&"constructor"in i&&"constructor"in s&&!(typeof A=="function"&&A instanceof A&&typeof k=="function"&&k instanceof k)&&(v=!1)}return l.delete(i),l.delete(s),v}return ma=o,ma}var ba,uh;function r1(){if(uh)return ba;uh=1;var e=Pn(),t=ob(),r=Qw(),n=e1(),o=xt(),i=Xe(),s=vt(),a=nn(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function y(g,b,x,m,w,v){var C=i(g),_=i(b),R=C?l:o(g),T=_?l:o(b);R=R==c?d:R,T=T==c?d:T;var A=R==d,k=T==d,E=R==T;if(E&&s(g)){if(!s(b))return!1;C=!0,A=!1}if(E&&!A)return v||(v=new e),C||a(g)?t(g,b,x,m,w,v):r(g,b,R,x,m,w,v);if(!(x&u)){var j=A&&p.call(g,"__wrapped__"),M=k&&p.call(b,"__wrapped__");if(j||M){var I=j?g.value():g,q=M?b.value():b;return v||(v=new e),w(I,q,x,m,v)}}return E?(v||(v=new e),n(g,b,x,m,w,v)):!1}return ba=y,ba}var va,lh;function ib(){if(lh)return va;lh=1;var e=r1(),t=Pr();function r(n,o,i,s,a){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,s,r,a)}return va=r,va}var xa,dh;function t1(){if(dh)return xa;dh=1;var e=Pn(),t=ib(),r=1,n=2;function o(i,s,a,u){var c=a.length,l=c,d=!u;if(i==null)return!l;for(i=Object(i);c--;){var f=a[c];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++c<l;){f=a[c];var p=f[0],y=i[p],g=f[1];if(d&&f[2]){if(y===void 0&&!(p in i))return!1}else{var b=new e;if(u)var x=u(y,g,p,i,s,b);if(!(x===void 0?t(g,y,r|n,u,b):x))return!1}}return!0}return xa=o,xa}var wa,fh;function ab(){if(fh)return wa;fh=1;var e=vr();function t(r){return r===r&&!e(r)}return wa=t,wa}var Ca,hh;function n1(){if(hh)return Ca;hh=1;var e=ab(),t=Hr();function r(n){for(var o=t(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return Ca=r,Ca}var _a,ph;function sb(){if(ph)return _a;ph=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return _a=e,_a}var Sa,gh;function o1(){if(gh)return Sa;gh=1;var e=t1(),t=n1(),r=sb();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return Sa=n,Sa}var Ea,yh;function wt(){if(yh)return Ea;yh=1;var e=tt(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return Ea=n,Ea}var ja,mh;function el(){if(mh)return ja;mh=1;var e=Xe(),t=wt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\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||t(i)?!0:n.test(i)||!r.test(i)||s!=null&&i in Object(s)}return ja=o,ja}var ka,bh;function i1(){if(bh)return ka;bh=1;var e=zu(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],u=i.cache;if(u.has(a))return u.get(a);var c=n.apply(this,s);return i.cache=u.set(a,c)||u,c};return i.cache=new(r.Cache||e),i}return r.Cache=e,ka=r,ka}var Ra,vh;function a1(){if(vh)return Ra;vh=1;var e=i1(),t=500;function r(n){var o=e(n,function(s){return i.size===t&&i.clear(),s}),i=o.cache;return o}return Ra=r,Ra}var Pa,xh;function s1(){if(xh)return Pa;xh=1;var e=a1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(s,a,u,c){i.push(u?c.replace(r,"$1"):a||s)}),i});return Pa=n,Pa}var Aa,wh;function $n(){if(wh)return Aa;wh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return Aa=e,Aa}var Ta,Ch;function c1(){if(Ch)return Ta;Ch=1;var e=bt(),t=$n(),r=Xe(),n=wt(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(r(a))return t(a,s)+"";if(n(a))return i?i.call(a):"";var u=a+"";return u=="0"&&1/a==-1/0?"-0":u}return Ta=s,Ta}var Oa,_h;function cb(){if(_h)return Oa;_h=1;var e=c1();function t(r){return r==null?"":e(r)}return Oa=t,Oa}var Ia,Sh;function Ln(){if(Sh)return Ia;Sh=1;var e=Xe(),t=el(),r=s1(),n=cb();function o(i,s){return e(i)?i:t(i,s)?[i]:r(n(i))}return Ia=o,Ia}var Ma,Eh;function on(){if(Eh)return Ma;Eh=1;var e=wt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ma=t,Ma}var qa,jh;function Fn(){if(jh)return qa;jh=1;var e=Ln(),t=on();function r(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[t(o[i++])];return i&&i==s?n:void 0}return qa=r,qa}var Na,kh;function u1(){if(kh)return Na;kh=1;var e=Fn();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return Na=t,Na}var $a,Rh;function l1(){if(Rh)return $a;Rh=1;function e(t,r){return t!=null&&r in Object(t)}return $a=e,$a}var La,Ph;function ub(){if(Ph)return La;Ph=1;var e=Ln(),t=tn(),r=Xe(),n=On(),o=Wu(),i=on();function s(a,u,c){u=e(u,a);for(var l=-1,d=u.length,f=!1;++l<d;){var p=i(u[l]);if(!(f=a!=null&&c(a,p)))break;a=a[p]}return f||++l!=d?f:(d=a==null?0:a.length,!!d&&o(d)&&n(p,d)&&(r(a)||t(a)))}return La=s,La}var Fa,Ah;function lb(){if(Ah)return Fa;Ah=1;var e=l1(),t=ub();function r(n,o){return n!=null&&t(n,o,e)}return Fa=r,Fa}var Ba,Th;function d1(){if(Th)return Ba;Th=1;var e=ib(),t=u1(),r=lb(),n=el(),o=ab(),i=sb(),s=on(),a=1,u=2;function c(l,d){return n(l)&&o(d)?i(s(l),d):function(f){var p=t(f,l);return p===void 0&&p===d?r(f,l):e(d,p,a|u)}}return Ba=c,Ba}var Da,Oh;function db(){if(Oh)return Da;Oh=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Da=e,Da}var za,Ih;function f1(){if(Ih)return za;Ih=1;var e=Fn();function t(r){return function(n){return e(n,r)}}return za=t,za}var Va,Mh;function h1(){if(Mh)return Va;Mh=1;var e=db(),t=f1(),r=el(),n=on();function o(i){return r(i)?e(n(i)):t(i)}return Va=o,Va}var Wa,qh;function $r(){if(qh)return Wa;qh=1;var e=o1(),t=d1(),r=it(),n=Xe(),o=h1();function i(s){return typeof s=="function"?s:s==null?r:typeof s=="object"?n(s)?t(s[0],s[1]):e(s):o(s)}return Wa=i,Wa}var Ga,Nh;function fb(){if(Nh)return Ga;Nh=1;var e=zm(),t=Kw(),r=$r(),n=Xe();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Ga=o,Ga}var Ua,$h;function p1(){if($h)return Ua;$h=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Ua=r,Ua}var Ha,Lh;function hb(){if(Lh)return Ha;Lh=1;var e=p1(),t=ub();function r(n,o){return n!=null&&t(n,o,e)}return Ha=r,Ha}var Ka,Fh;function g1(){if(Fh)return Ka;Fh=1;var e=Uu(),t=xt(),r=tn(),n=Xe(),o=Nr(),i=vt(),s=Mn(),a=nn(),u="[object Map]",c="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||r(p)))return!p.length;var y=t(p);if(y==u||y==c)return!p.size;if(s(p))return!e(p).length;for(var g in p)if(d.call(p,g))return!1;return!0}return Ka=f,Ka}var Ja,Bh;function pb(){if(Bh)return Ja;Bh=1;function e(t){return t===void 0}return Ja=e,Ja}var Za,Dh;function gb(){if(Dh)return Za;Dh=1;var e=Nn(),t=Nr();function r(n,o){var i=-1,s=t(n)?Array(n.length):[];return e(n,function(a,u,c){s[++i]=o(a,u,c)}),s}return Za=r,Za}var Ya,zh;function yb(){if(zh)return Ya;zh=1;var e=$n(),t=$r(),r=gb(),n=Xe();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Ya=o,Ya}var Xa,Vh;function y1(){if(Vh)return Xa;Vh=1;function e(t,r,n,o){var i=-1,s=t==null?0:t.length;for(o&&s&&(n=t[++i]);++i<s;)n=r(n,t[i],i,t);return n}return Xa=e,Xa}var Qa,Wh;function m1(){if(Wh)return Qa;Wh=1;function e(t,r,n,o,i){return i(t,function(s,a,u){n=o?(o=!1,s):r(n,s,a,u)}),n}return Qa=e,Qa}var es,Gh;function mb(){if(Gh)return es;Gh=1;var e=y1(),t=Nn(),r=$r(),n=m1(),o=Xe();function i(s,a,u){var c=o(s)?e:n,l=arguments.length<3;return c(s,r(a,4),u,l,t)}return es=i,es}var rs,Uh;function b1(){if(Uh)return rs;Uh=1;var e=tt(),t=Xe(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return rs=o,rs}var ts,Hh;function v1(){if(Hh)return ts;Hh=1;var e=db(),t=e("length");return ts=t,ts}var ns,Kh;function x1(){if(Kh)return ns;Kh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function u(c){return a.test(c)}return ns=u,ns}var os,Jh;function w1(){if(Jh)return os;Jh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+a+"|"+u+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=c+"?",g="["+i+"]?",b="(?:"+p+"(?:"+[l,d,f].join("|")+")"+g+y+")*",x=g+y+b,m="(?:"+[l+a+"?",a,d,f,s].join("|")+")",w=RegExp(u+"(?="+u+")|"+m+x,"g");function v(C){for(var _=w.lastIndex=0;w.test(C);)++_;return _}return os=v,os}var is,Zh;function C1(){if(Zh)return is;Zh=1;var e=v1(),t=x1(),r=w1();function n(o){return t(o)?r(o):e(o)}return is=n,is}var as,Yh;function _1(){if(Yh)return as;Yh=1;var e=Uu(),t=xt(),r=Nr(),n=b1(),o=C1(),i="[object Map]",s="[object Set]";function a(u){if(u==null)return 0;if(r(u))return n(u)?o(u):u.length;var c=t(u);return c==i||c==s?u.size:e(u).length}return as=a,as}var ss,Xh;function S1(){if(Xh)return ss;Xh=1;var e=Vu(),t=Zm(),r=Xu(),n=$r(),o=qn(),i=Xe(),s=vt(),a=en(),u=vr(),c=nn();function l(d,f,p){var y=i(d),g=y||s(d)||c(d);if(f=n(f,4),p==null){var b=d&&d.constructor;g?p=y?new b:[]:u(d)?p=a(b)?t(o(d)):{}:p={}}return(g?e:r)(d,function(x,m,w){return f(p,x,m,w)}),p}return ss=l,ss}var cs,Qh;function E1(){if(Qh)return cs;Qh=1;var e=bt(),t=tn(),r=Xe(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return cs=o,cs}var us,ep;function rl(){if(ep)return us;ep=1;var e=Ku(),t=E1();function r(n,o,i,s,a){var u=-1,c=n.length;for(i||(i=t),a||(a=[]);++u<c;){var l=n[u];o>0&&i(l)?o>1?r(l,o-1,i,s,a):e(a,l):s||(a[a.length]=l)}return a}return us=r,us}var ls,rp;function j1(){if(rp)return ls;rp=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return ls=e,ls}var ds,tp;function bb(){if(tp)return ds;tp=1;var e=j1(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,u=t(s.length-o,0),c=Array(u);++a<u;)c[a]=s[o+a];a=-1;for(var l=Array(o+1);++a<o;)l[a]=s[a];return l[o]=i(c),e(n,this,l)}}return ds=r,ds}var fs,np;function k1(){if(np)return fs;np=1;var e=Zu(),t=$m(),r=it(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return fs=n,fs}var hs,op;function R1(){if(op)return hs;op=1;var e=800,t=16,r=Date.now;function n(o){var i=0,s=0;return function(){var a=r(),u=t-(a-s);if(s=a,u>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return hs=n,hs}var ps,ip;function vb(){if(ip)return ps;ip=1;var e=k1(),t=R1(),r=t(e);return ps=r,ps}var gs,ap;function Bn(){if(ap)return gs;ap=1;var e=it(),t=bb(),r=vb();function n(o,i){return r(t(o,i,e),o+"")}return gs=n,gs}var ys,sp;function xb(){if(sp)return ys;sp=1;function e(t,r,n,o){for(var i=t.length,s=n+(o?1:-1);o?s--:++s<i;)if(r(t[s],s,t))return s;return-1}return ys=e,ys}var ms,cp;function P1(){if(cp)return ms;cp=1;function e(t){return t!==t}return ms=e,ms}var bs,up;function A1(){if(up)return bs;up=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return bs=e,bs}var vs,lp;function T1(){if(lp)return vs;lp=1;var e=xb(),t=P1(),r=A1();function n(o,i,s){return i===i?r(o,i,s):e(o,t,s)}return vs=n,vs}var xs,dp;function O1(){if(dp)return xs;dp=1;var e=T1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return xs=t,xs}var ws,fp;function I1(){if(fp)return ws;fp=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return ws=e,ws}var Cs,hp;function M1(){if(hp)return Cs;hp=1;function e(){}return Cs=e,Cs}var _s,pp;function q1(){if(pp)return _s;pp=1;var e=Hm(),t=M1(),r=Qu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return _s=o,_s}var Ss,gp;function N1(){if(gp)return Ss;gp=1;var e=tb(),t=O1(),r=I1(),n=nb(),o=q1(),i=Qu(),s=200;function a(u,c,l){var d=-1,f=t,p=u.length,y=!0,g=[],b=g;if(l)y=!1,f=r;else if(p>=s){var x=c?null:o(u);if(x)return i(x);y=!1,f=n,b=new e}else b=c?[]:g;e:for(;++d<p;){var m=u[d],w=c?c(m):m;if(m=l||m!==0?m:0,y&&w===w){for(var v=b.length;v--;)if(b[v]===w)continue e;c&&b.push(w),g.push(m)}else f(b,w,l)||(b!==g&&b.push(w),g.push(m))}return g}return Ss=a,Ss}var Es,yp;function wb(){if(yp)return Es;yp=1;var e=Nr(),t=Pr();function r(n){return t(n)&&e(n)}return Es=r,Es}var js,mp;function $1(){if(mp)return js;mp=1;var e=rl(),t=Bn(),r=N1(),n=wb(),o=t(function(i){return r(e(i,1,n,!0))});return js=o,js}var ks,bp;function L1(){if(bp)return ks;bp=1;var e=$n();function t(r,n){return e(n,function(o){return r[o]})}return ks=t,ks}var Rs,vp;function Cb(){if(vp)return Rs;vp=1;var e=L1(),t=Hr();function r(n){return n==null?[]:e(n,t(n))}return Rs=r,Rs}var Ps,xp;function xr(){if(xp)return Ps;xp=1;var e;if(typeof Bu=="function")try{e={clone:Gw(),constant:Zu(),each:rb(),filter:fb(),has:hb(),isArray:Xe(),isEmpty:g1(),isFunction:en(),isUndefined:pb(),keys:Hr(),map:yb(),reduce:mb(),size:_1(),transform:S1(),union:$1(),values:Cb()}}catch{}return e||(e=window._),Ps=e,Ps}var As,wp;function tl(){if(wp)return As;wp=1;var e=xr();As=o;var t="\0",r="\0",n="";function o(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.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[r]={}),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(l){return this._label=l,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},o.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},o.prototype.setNodes=function(l,d){var f=arguments,p=this;return e.each(l,function(y){f.length>1?p.setNode(y,d):p.setNode(y)}),this},o.prototype.setNode=function(l,d){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=d),this):(this._nodes[l]=arguments.length>1?d:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},o.prototype.node=function(l){return this._nodes[l]},o.prototype.hasNode=function(l){return e.has(this._nodes,l)},o.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var f=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(p){d.setParent(p)}),delete this._children[l]),e.each(e.keys(this._in[l]),f),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),f),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},o.prototype.setParent=function(l,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=r;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===l)throw new Error("Setting "+d+" as parent of "+l+" would create a cycle");this.setNode(d)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=d,this._children[d][l]=!0,this},o.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},o.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},o.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var d=this._children[l];if(d)return e.keys(d)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},o.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},o.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},o.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},o.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},o.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(g,b){l(b)&&d.setNode(b,g)}),e.each(this._edgeObjs,function(g){d.hasNode(g.v)&&d.hasNode(g.w)&&d.setEdge(g,f.edge(g))});var p={};function y(g){var b=f.parent(g);return b===void 0||d.hasNode(b)?(p[g]=b,b):b in p?p[b]:y(b)}return this._isCompound&&e.each(d.nodes(),function(g){d.setParent(g,y(g))}),d},o.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(l,d){var f=this,p=arguments;return e.reduce(l,function(y,g){return p.length>1?f.setEdge(y,g,d):f.setEdge(y,g),g}),this},o.prototype.setEdge=function(){var l,d,f,p,y=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(l=g.v,d=g.w,f=g.name,arguments.length===2&&(p=arguments[1],y=!0)):(l=g,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var b=a(this._isDirected,l,d,f);if(e.has(this._edgeLabels,b))return y&&(this._edgeLabels[b]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[b]=y?p:this._defaultEdgeLabelFn(l,d,f);var x=u(this._isDirected,l,d,f);return l=x.v,d=x.w,Object.freeze(x),this._edgeObjs[b]=x,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][b]=x,this._out[l][b]=x,this._edgeCount++,this},o.prototype.edge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,l,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,l,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,l,d,f),y=this._edgeObjs[p];return y&&(l=y.v,d=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[d],l),s(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},o.prototype.inEdges=function(l,d){var f=this._in[l];if(f){var p=e.values(f);return d?e.filter(p,function(y){return y.v===d}):p}},o.prototype.outEdges=function(l,d){var f=this._out[l];if(f){var p=e.values(f);return d?e.filter(p,function(y){return y.w===d}):p}},o.prototype.nodeEdges=function(l,d){var f=this.inEdges(l,d);if(f)return f.concat(this.outEdges(l,d))};function i(l,d){l[d]?l[d]++:l[d]=1}function s(l,d){--l[d]||delete l[d]}function a(l,d,f,p){var y=""+d,g=""+f;if(!l&&y>g){var b=y;y=g,g=b}return y+n+g+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var y=""+d,g=""+f;if(!l&&y>g){var b=y;y=g,g=b}var x={v:y,w:g};return p&&(x.name=p),x}function c(l,d){return a(l,d.v,d.w,d.name)}return As}var Ts,Cp;function F1(){return Cp||(Cp=1,Ts="2.1.8"),Ts}var Os,_p;function B1(){return _p||(_p=1,Os={Graph:tl(),version:F1()}),Os}var Is,Sp;function D1(){if(Sp)return Is;Sp=1;var e=xr(),t=tl();Is={write:r,read:i};function r(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 u=s.node(a),c=s.parent(a),l={v:a};return e.isUndefined(u)||(l.value=u),e.isUndefined(c)||(l.parent=c),l})}function o(s){return e.map(s.edges(),function(a){var u=s.edge(a),c={v:a.v,w:a.w};return e.isUndefined(a.name)||(c.name=a.name),e.isUndefined(u)||(c.value=u),c})}function i(s){var a=new t(s.options).setGraph(s.value);return e.each(s.nodes,function(u){a.setNode(u.v,u.value),u.parent&&a.setParent(u.v,u.parent)}),e.each(s.edges,function(u){a.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),a}return Is}var Ms,Ep;function z1(){if(Ep)return Ms;Ep=1;var e=xr();Ms=t;function t(r){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(r.successors(a),s),e.each(r.predecessors(a),s))}return e.each(r.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return Ms}var qs,jp;function _b(){if(jp)return qs;jp=1;var e=xr();qs=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,s=i.length;return o[r]=s,i.push({key:r,priority:n}),this._decrease(s),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,s=r;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!==r&&(this._swap(r,s),this._heapify(s)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,s=o[r],a=o[n];o[r]=a,o[n]=s,i[a.key]=r,i[s.key]=n},qs}var Ns,kp;function Sb(){if(kp)return Ns;kp=1;var e=xr(),t=_b();Ns=n;var r=e.constant(1);function n(i,s,a,u){return o(i,String(s),a||r,u||function(c){return i.outEdges(c)})}function o(i,s,a,u){var c={},l=new t,d,f,p=function(y){var g=y.v!==d?y.v:y.w,b=c[g],x=a(y),m=f.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+x);m<b.distance&&(b.distance=m,b.predecessor=d,l.decrease(g,m))};for(i.nodes().forEach(function(y){var g=y===s?0:Number.POSITIVE_INFINITY;c[y]={distance:g},l.add(y,g)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return Ns}var $s,Rp;function V1(){if(Rp)return $s;Rp=1;var e=Sb(),t=xr();$s=r;function r(n,o,i){return t.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return $s}var Ls,Pp;function Eb(){if(Pp)return Ls;Pp=1;var e=xr();Ls=t;function t(r){var n=0,o=[],i={},s=[];function a(u){var c=i[u]={onStack:!0,lowlink:n,index:n++};if(o.push(u),r.successors(u).forEach(function(f){e.has(i,f)?i[f].onStack&&(c.lowlink=Math.min(c.lowlink,i[f].index)):(a(f),c.lowlink=Math.min(c.lowlink,i[f].lowlink))}),c.lowlink===c.index){var l=[],d;do d=o.pop(),i[d].onStack=!1,l.push(d);while(u!==d);s.push(l)}}return r.nodes().forEach(function(u){e.has(i,u)||a(u)}),s}return Ls}var Fs,Ap;function W1(){if(Ap)return Fs;Ap=1;var e=xr(),t=Eb();Fs=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Fs}var Bs,Tp;function G1(){if(Tp)return Bs;Tp=1;var e=xr();Bs=r;var t=e.constant(1);function r(o,i,s){return n(o,i||t,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},u=o.nodes();return u.forEach(function(c){a[c]={},a[c][c]={distance:0},u.forEach(function(l){c!==l&&(a[c][l]={distance:Number.POSITIVE_INFINITY})}),s(c).forEach(function(l){var d=l.v===c?l.w:l.v,f=i(l);a[c][d]={distance:f,predecessor:c}})}),u.forEach(function(c){var l=a[c];u.forEach(function(d){var f=a[d];u.forEach(function(p){var y=f[c],g=l[p],b=f[p],x=y.distance+g.distance;x<b.distance&&(b.distance=x,b.predecessor=g.predecessor)})})}),a}return Bs}var Ds,Op;function jb(){if(Op)return Ds;Op=1;var e=xr();Ds=t,t.CycleException=r;function t(n){var o={},i={},s=[];function a(u){if(e.has(i,u))throw new r;e.has(o,u)||(i[u]=!0,o[u]=!0,e.each(n.predecessors(u),a),delete i[u],s.push(u))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new r;return s}function r(){}return r.prototype=new Error,Ds}var zs,Ip;function U1(){if(Ip)return zs;Ip=1;var e=jb();zs=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return zs}var Vs,Mp;function kb(){if(Mp)return Vs;Mp=1;var e=xr();Vs=t;function t(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],u={};return e.each(o,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);r(n,c,i==="post",u,s,a)}),a}function r(n,o,i,s,a,u){e.has(s,o)||(s[o]=!0,i||u.push(o),e.each(a(o),function(c){r(n,c,i,s,a,u)}),i&&u.push(o))}return Vs}var Ws,qp;function H1(){if(qp)return Ws;qp=1;var e=kb();Ws=t;function t(r,n){return e(r,n,"post")}return Ws}var Gs,Np;function K1(){if(Np)return Gs;Np=1;var e=kb();Gs=t;function t(r,n){return e(r,n,"pre")}return Gs}var Us,$p;function J1(){if($p)return Us;$p=1;var e=xr(),t=tl(),r=_b();Us=n;function n(o,i){var s=new t,a={},u=new r,c;function l(f){var p=f.v===c?f.w:f.v,y=u.priority(p);if(y!==void 0){var g=i(f);g<y&&(a[p]=c,u.decrease(p,g))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(f){u.add(f,Number.POSITIVE_INFINITY),s.setNode(f)}),u.decrease(o.nodes()[0],0);for(var d=!1;u.size()>0;){if(c=u.removeMin(),e.has(a,c))s.setEdge(c,a[c]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(c).forEach(l)}return s}return Us}var Hs,Lp;function Z1(){return Lp||(Lp=1,Hs={components:z1(),dijkstra:Sb(),dijkstraAll:V1(),findCycles:W1(),floydWarshall:G1(),isAcyclic:U1(),postorder:H1(),preorder:K1(),prim:J1(),tarjan:Eb(),topsort:jb()}),Hs}var Ks,Fp;function Y1(){if(Fp)return Ks;Fp=1;var e=B1();return Ks={Graph:e.Graph,json:D1(),alg:Z1(),version:e.version},Ks}var Js,Bp;function _r(){if(Bp)return Js;Bp=1;var e;if(typeof Bu=="function")try{e=Y1()}catch{}return e||(e=window.graphlib),Js=e,Js}var Zs,Dp;function X1(){if(Dp)return Zs;Dp=1;var e=Xm(),t=1,r=4;function n(o){return e(o,t|r)}return Zs=n,Zs}var Ys,zp;function Dn(){if(zp)return Ys;zp=1;var e=mt(),t=Nr(),r=On(),n=vr();function o(i,s,a){if(!n(a))return!1;var u=typeof s;return(u=="number"?t(a)&&r(s,a.length):u=="string"&&s in a)?e(a[s],i):!1}return Ys=o,Ys}var Xs,Vp;function Q1(){if(Vp)return Xs;Vp=1;var e=Bn(),t=mt(),r=Dn(),n=ot(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,u){a=Object(a);var c=-1,l=u.length,d=l>2?u[2]:void 0;for(d&&r(u[0],u[1],d)&&(l=1);++c<l;)for(var f=u[c],p=n(f),y=-1,g=p.length;++y<g;){var b=p[y],x=a[b];(x===void 0||t(x,o[b])&&!i.call(a,b))&&(a[b]=f[b])}return a});return Xs=s,Xs}var Qs,Wp;function eC(){if(Wp)return Qs;Wp=1;var e=$r(),t=Nr(),r=Hr();function n(o){return function(i,s,a){var u=Object(i);if(!t(i)){var c=e(s,3);i=r(i),s=function(d){return c(u[d],d,u)}}var l=o(i,s,a);return l>-1?u[c?i[l]:l]:void 0}}return Qs=n,Qs}var ec,Gp;function rC(){if(Gp)return ec;Gp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return ec=t,ec}var rc,Up;function tC(){if(Up)return rc;Up=1;var e=rC(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return rc=r,rc}var tc,Hp;function nC(){if(Hp)return tc;Hp=1;var e=tC(),t=vr(),r=wt(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=t(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=e(c);var d=i.test(c);return d||s.test(c)?a(c.slice(2),d?2:8):o.test(c)?n:+c}return tc=u,tc}var nc,Kp;function Rb(){if(Kp)return nc;Kp=1;var e=nC(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return nc=n,nc}var oc,Jp;function oC(){if(Jp)return oc;Jp=1;var e=Rb();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return oc=t,oc}var ic,Zp;function iC(){if(Zp)return ic;Zp=1;var e=xb(),t=$r(),r=oC(),n=Math.max;function o(i,s,a){var u=i==null?0:i.length;if(!u)return-1;var c=a==null?0:r(a);return c<0&&(c=n(u+c,0)),e(i,t(s,3),c)}return ic=o,ic}var ac,Yp;function aC(){if(Yp)return ac;Yp=1;var e=eC(),t=iC(),r=e(t);return ac=r,ac}var sc,Xp;function Pb(){if(Xp)return sc;Xp=1;var e=rl();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return sc=t,sc}var cc,Qp;function sC(){if(Qp)return cc;Qp=1;var e=Yu(),t=Qm(),r=ot();function n(o,i){return o==null?o:e(o,t(i),r)}return cc=n,cc}var uc,eg;function cC(){if(eg)return uc;eg=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return uc=e,uc}var lc,rg;function uC(){if(rg)return lc;rg=1;var e=An(),t=Xu(),r=$r();function n(o,i){var s={};return i=r(i,3),t(o,function(a,u,c){e(s,u,i(a,u,c))}),s}return lc=n,lc}var dc,tg;function nl(){if(tg)return dc;tg=1;var e=wt();function t(r,n,o){for(var i=-1,s=r.length;++i<s;){var a=r[i],u=n(a);if(u!=null&&(c===void 0?u===u&&!e(u):o(u,c)))var c=u,l=a}return l}return dc=t,dc}var fc,ng;function lC(){if(ng)return fc;ng=1;function e(t,r){return t>r}return fc=e,fc}var hc,og;function dC(){if(og)return hc;og=1;var e=nl(),t=lC(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return hc=n,hc}var pc,ig;function Ab(){if(ig)return pc;ig=1;var e=An(),t=mt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return pc=r,pc}var gc,ag;function fC(){if(ag)return gc;ag=1;var e=tt(),t=qn(),r=Pr(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,u=s.call(Object);function c(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var f=a.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&s.call(f)==u}return gc=c,gc}var yc,sg;function Tb(){if(sg)return yc;sg=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return yc=e,yc}var mc,cg;function hC(){if(cg)return mc;cg=1;var e=rn(),t=ot();function r(n){return e(n,t(n))}return mc=r,mc}var bc,ug;function pC(){if(ug)return bc;ug=1;var e=Ab(),t=Bm(),r=Jm(),n=Dm(),o=Ym(),i=tn(),s=Xe(),a=wb(),u=vt(),c=en(),l=vr(),d=fC(),f=nn(),p=Tb(),y=hC();function g(b,x,m,w,v,C,_){var R=p(b,m),T=p(x,m),A=_.get(T);if(A){e(b,m,A);return}var k=C?C(R,T,m+"",b,x,_):void 0,E=k===void 0;if(E){var j=s(T),M=!j&&u(T),I=!j&&!M&&f(T);k=T,j||M||I?s(R)?k=R:a(R)?k=n(R):M?(E=!1,k=t(T,!0)):I?(E=!1,k=r(T,!0)):k=[]:d(T)||i(T)?(k=R,i(R)?k=y(R):(!l(R)||c(R))&&(k=o(T))):E=!1}E&&(_.set(T,k),v(k,T,w,C,_),_.delete(T)),e(b,m,k)}return bc=g,bc}var vc,lg;function gC(){if(lg)return vc;lg=1;var e=Pn(),t=Ab(),r=Yu(),n=pC(),o=vr(),i=ot(),s=Tb();function a(u,c,l,d,f){u!==c&&r(c,function(p,y){if(f||(f=new e),o(p))n(u,c,y,l,a,d,f);else{var g=d?d(s(u,y),p,y+"",u,c,f):void 0;g===void 0&&(g=p),t(u,y,g)}},i)}return vc=a,vc}var xc,dg;function yC(){if(dg)return xc;dg=1;var e=Bn(),t=Dn();function r(n){return e(function(o,i){var s=-1,a=i.length,u=a>1?i[a-1]:void 0,c=a>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(a--,u):void 0,c&&t(i[0],i[1],c)&&(u=a<3?void 0:u,a=1),o=Object(o);++s<a;){var l=i[s];l&&n(o,l,s,u)}return o})}return xc=r,xc}var wc,fg;function mC(){if(fg)return wc;fg=1;var e=gC(),t=yC(),r=t(function(n,o,i){e(n,o,i)});return wc=r,wc}var Cc,hg;function Ob(){if(hg)return Cc;hg=1;function e(t,r){return t<r}return Cc=e,Cc}var _c,pg;function bC(){if(pg)return _c;pg=1;var e=nl(),t=Ob(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return _c=n,_c}var Sc,gg;function vC(){if(gg)return Sc;gg=1;var e=nl(),t=$r(),r=Ob();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return Sc=n,Sc}var Ec,yg;function xC(){if(yg)return Ec;yg=1;var e=Sr(),t=function(){return e.Date.now()};return Ec=t,Ec}var jc,mg;function wC(){if(mg)return jc;mg=1;var e=Tn(),t=Ln(),r=On(),n=vr(),o=on();function i(s,a,u,c){if(!n(s))return s;a=t(a,s);for(var l=-1,d=a.length,f=d-1,p=s;p!=null&&++l<d;){var y=o(a[l]),g=u;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(l!=f){var b=p[y];g=c?c(b,y,p):void 0,g===void 0&&(g=n(b)?b:r(a[l+1])?[]:{})}e(p,y,g),p=p[y]}return s}return jc=i,jc}var kc,bg;function CC(){if(bg)return kc;bg=1;var e=Fn(),t=wC(),r=Ln();function n(o,i,s){for(var a=-1,u=i.length,c={};++a<u;){var l=i[a],d=e(o,l);s(d,l)&&t(c,r(l,o),d)}return c}return kc=n,kc}var Rc,vg;function _C(){if(vg)return Rc;vg=1;var e=CC(),t=lb();function r(n,o){return e(n,o,function(i,s){return t(n,s)})}return Rc=r,Rc}var Pc,xg;function SC(){if(xg)return Pc;xg=1;var e=Pb(),t=bb(),r=vb();function n(o){return r(t(o,void 0,e),o+"")}return Pc=n,Pc}var Ac,wg;function EC(){if(wg)return Ac;wg=1;var e=_C(),t=SC(),r=t(function(n,o){return n==null?{}:e(n,o)});return Ac=r,Ac}var Tc,Cg;function jC(){if(Cg)return Tc;Cg=1;var e=Math.ceil,t=Math.max;function r(n,o,i,s){for(var a=-1,u=t(e((o-n)/(i||1)),0),c=Array(u);u--;)c[s?u:++a]=n,n+=i;return c}return Tc=r,Tc}var Oc,_g;function kC(){if(_g)return Oc;_g=1;var e=jC(),t=Dn(),r=Rb();function n(o){return function(i,s,a){return a&&typeof a!="number"&&t(i,s,a)&&(s=a=void 0),i=r(i),s===void 0?(s=i,i=0):s=r(s),a=a===void 0?i<s?1:-1:r(a),e(i,s,a,o)}}return Oc=n,Oc}var Ic,Sg;function RC(){if(Sg)return Ic;Sg=1;var e=kC(),t=e();return Ic=t,Ic}var Mc,Eg;function PC(){if(Eg)return Mc;Eg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Mc=e,Mc}var qc,jg;function AC(){if(jg)return qc;jg=1;var e=wt();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,s=r===r,a=e(r),u=n!==void 0,c=n===null,l=n===n,d=e(n);if(!c&&!d&&!a&&r>n||a&&u&&l&&!c&&!d||i&&u&&l||!o&&l||!s)return 1;if(!i&&!a&&!d&&r<n||d&&o&&s&&!i&&!a||c&&o&&s||!u&&s||!l)return-1}return 0}return qc=t,qc}var Nc,kg;function TC(){if(kg)return Nc;kg=1;var e=AC();function t(r,n,o){for(var i=-1,s=r.criteria,a=n.criteria,u=s.length,c=o.length;++i<u;){var l=e(s[i],a[i]);if(l){if(i>=c)return l;var d=o[i];return l*(d=="desc"?-1:1)}}return r.index-n.index}return Nc=t,Nc}var $c,Rg;function OC(){if(Rg)return $c;Rg=1;var e=$n(),t=Fn(),r=$r(),n=gb(),o=PC(),i=In(),s=TC(),a=it(),u=Xe();function c(l,d,f){d.length?d=e(d,function(g){return u(g)?function(b){return t(b,g.length===1?g[0]:g)}:g}):d=[a];var p=-1;d=e(d,i(r));var y=n(l,function(g,b,x){var m=e(d,function(w){return w(g)});return{criteria:m,index:++p,value:g}});return o(y,function(g,b){return s(g,b,f)})}return $c=c,$c}var Lc,Pg;function IC(){if(Pg)return Lc;Pg=1;var e=rl(),t=OC(),r=Bn(),n=Dn(),o=r(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]]),t(i,e(s,1),[])});return Lc=o,Lc}var Fc,Ag;function MC(){if(Ag)return Fc;Ag=1;var e=cb(),t=0;function r(n){var o=++t;return e(n)+o}return Fc=r,Fc}var Bc,Tg;function qC(){if(Tg)return Bc;Tg=1;function e(t,r,n){for(var o=-1,i=t.length,s=r.length,a={};++o<i;){var u=o<s?r[o]:void 0;n(a,t[o],u)}return a}return Bc=e,Bc}var Dc,Og;function NC(){if(Og)return Dc;Og=1;var e=Tn(),t=qC();function r(n,o){return t(n||[],o||[],e)}return Dc=r,Dc}var zc,Ig;function Ue(){if(Ig)return zc;Ig=1;var e;if(typeof Bu=="function")try{e={cloneDeep:X1(),constant:Zu(),defaults:Q1(),each:rb(),filter:fb(),find:aC(),flatten:Pb(),forEach:eb(),forIn:sC(),has:hb(),isUndefined:pb(),last:cC(),map:yb(),mapValues:uC(),max:dC(),merge:mC(),min:bC(),minBy:vC(),now:xC(),pick:EC(),range:RC(),reduce:mb(),sortBy:IC(),uniqueId:MC(),values:Cb(),zipObject:NC()}}catch{}return e||(e=window._),zc=e,zc}var Vc,Mg;function $C(){if(Mg)return Vc;Mg=1,Vc=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 t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(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,r)),i=i._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,o){if(n!=="_next"&&n!=="_prev")return o}return Vc}var Wc,qg;function LC(){if(qg)return Wc;qg=1;var e=Ue(),t=_r().Graph,r=$C();Wc=o;var n=e.constant(1);function o(c,l){if(c.nodeCount()<=1)return[];var d=a(c,l||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return c.outEdges(p.v,p.w)}),!0)}function i(c,l,d){for(var f=[],p=l[l.length-1],y=l[0],g;c.nodeCount();){for(;g=y.dequeue();)s(c,l,d,g);for(;g=p.dequeue();)s(c,l,d,g);if(c.nodeCount()){for(var b=l.length-2;b>0;--b)if(g=l[b].dequeue(),g){f=f.concat(s(c,l,d,g,!0));break}}}return f}function s(c,l,d,f,p){var y=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(g){var b=c.edge(g),x=c.node(g.v);p&&y.push({v:g.v,w:g.w}),x.out-=b,u(l,d,x)}),e.forEach(c.outEdges(f.v),function(g){var b=c.edge(g),x=g.w,m=c.node(x);m.in-=b,u(l,d,m)}),c.removeNode(f.v),y}function a(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(b){d.setNode(b,{v:b,in:0,out:0})}),e.forEach(c.edges(),function(b){var x=d.edge(b.v,b.w)||0,m=l(b),w=x+m;d.setEdge(b.v,b.w,w),p=Math.max(p,d.node(b.v).out+=m),f=Math.max(f,d.node(b.w).in+=m)});var y=e.range(p+f+3).map(function(){return new r}),g=f+1;return e.forEach(d.nodes(),function(b){u(y,g,d.node(b))}),{graph:d,buckets:y,zeroIdx:g}}function u(c,l,d){d.out?d.in?c[d.out-d.in+l].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}return Wc}var Gc,Ng;function FC(){if(Ng)return Gc;Ng=1;var e=Ue(),t=LC();Gc={run:r,undo:o};function r(i){var s=i.graph().acyclicer==="greedy"?t(i,a(i)):n(i);e.forEach(s,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function a(u){return function(c){return u.edge(c).weight}}}function n(i){var s=[],a={},u={};function c(l){e.has(u,l)||(u[l]=!0,a[l]=!0,e.forEach(i.outEdges(l),function(d){e.has(a,d.w)?s.push(d):c(d.w)}),delete a[l])}return e.forEach(i.nodes(),c),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var u=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,u)}})}return Gc}var Uc,$g;function pr(){if($g)return Uc;$g=1;var e=Ue(),t=_r().Graph;Uc={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:l,addBorderNode:d,maxRank:f,partition:p,time:y,notime:g};function r(b,x,m,w){var v;do v=e.uniqueId(w);while(b.hasNode(v));return m.dummy=x,b.setNode(v,m),v}function n(b){var x=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(m){x.setNode(m,b.node(m))}),e.forEach(b.edges(),function(m){var w=x.edge(m.v,m.w)||{weight:0,minlen:1},v=b.edge(m);x.setEdge(m.v,m.w,{weight:w.weight+v.weight,minlen:Math.max(w.minlen,v.minlen)})}),x}function o(b){var x=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(m){b.children(m).length||x.setNode(m,b.node(m))}),e.forEach(b.edges(),function(m){x.setEdge(m,b.edge(m))}),x}function i(b){var x=e.map(b.nodes(),function(m){var w={};return e.forEach(b.outEdges(m),function(v){w[v.w]=(w[v.w]||0)+b.edge(v).weight}),w});return e.zipObject(b.nodes(),x)}function s(b){var x=e.map(b.nodes(),function(m){var w={};return e.forEach(b.inEdges(m),function(v){w[v.v]=(w[v.v]||0)+b.edge(v).weight}),w});return e.zipObject(b.nodes(),x)}function a(b,x){var m=b.x,w=b.y,v=x.x-m,C=x.y-w,_=b.width/2,R=b.height/2;if(!v&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var T,A;return Math.abs(C)*_>Math.abs(v)*R?(C<0&&(R=-R),T=R*v/C,A=R):(v<0&&(_=-_),T=_,A=_*C/v),{x:m+T,y:w+A}}function u(b){var x=e.map(e.range(f(b)+1),function(){return[]});return e.forEach(b.nodes(),function(m){var w=b.node(m),v=w.rank;e.isUndefined(v)||(x[v][w.order]=m)}),x}function c(b){var x=e.min(e.map(b.nodes(),function(m){return b.node(m).rank}));e.forEach(b.nodes(),function(m){var w=b.node(m);e.has(w,"rank")&&(w.rank-=x)})}function l(b){var x=e.min(e.map(b.nodes(),function(C){return b.node(C).rank})),m=[];e.forEach(b.nodes(),function(C){var _=b.node(C).rank-x;m[_]||(m[_]=[]),m[_].push(C)});var w=0,v=b.graph().nodeRankFactor;e.forEach(m,function(C,_){e.isUndefined(C)&&_%v!==0?--w:w&&e.forEach(C,function(R){b.node(R).rank+=w})})}function d(b,x,m,w){var v={width:0,height:0};return arguments.length>=4&&(v.rank=m,v.order=w),r(b,"border",v,x)}function f(b){return e.max(e.map(b.nodes(),function(x){var m=b.node(x).rank;if(!e.isUndefined(m))return m}))}function p(b,x){var m={lhs:[],rhs:[]};return e.forEach(b,function(w){x(w)?m.lhs.push(w):m.rhs.push(w)}),m}function y(b,x){var m=e.now();try{return x()}finally{console.log(b+" time: "+(e.now()-m)+"ms")}}function g(b,x){return x()}return Uc}var Hc,Lg;function BC(){if(Lg)return Hc;Lg=1;var e=Ue(),t=pr();Hc={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,u=i.node(a).rank,c=s.w,l=i.node(c).rank,d=s.name,f=i.edge(s),p=f.labelRank;if(l!==u+1){i.removeEdge(s);var y,g,b;for(b=0,++u;u<l;++b,++u)f.points=[],g={width:0,height:0,edgeLabel:f,edgeObj:s,rank:u},y=t.addDummyNode(i,"edge",g,"_d"),u===p&&(g.width=f.width,g.height=f.height,g.dummy="edge-label",g.labelpos=f.labelpos),i.setEdge(a,y,{weight:f.weight},d),b===0&&i.graph().dummyChains.push(y),a=y;i.setEdge(a,c,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),u=a.edgeLabel,c;for(i.setEdge(a.edgeObj,u);a.dummy;)c=i.successors(s)[0],i.removeNode(s),u.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(u.x=a.x,u.y=a.y,u.width=a.width,u.height=a.height),s=c,a=i.node(s)})}return Hc}var Kc,Fg;function yn(){if(Fg)return Kc;Fg=1;var e=Ue();Kc={longestPath:t,slack:r};function t(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var u=e.min(e.map(n.outEdges(s),function(c){return i(c.w)-n.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),a.rank=u}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Kc}var Jc,Bg;function Ib(){if(Bg)return Jc;Bg=1;var e=Ue(),t=_r().Graph,r=yn().slack;Jc=n;function n(a){var u=new t({directed:!1}),c=a.nodes()[0],l=a.nodeCount();u.setNode(c,{});for(var d,f;o(u,a)<l;)d=i(u,a),f=u.hasNode(d.v)?r(a,d):-r(a,d),s(u,a,f);return u}function o(a,u){function c(l){e.forEach(u.nodeEdges(l),function(d){var f=d.v,p=l===f?d.w:f;!a.hasNode(p)&&!r(u,d)&&(a.setNode(p,{}),a.setEdge(l,p,{}),c(p))})}return e.forEach(a.nodes(),c),a.nodeCount()}function i(a,u){return e.minBy(u.edges(),function(c){if(a.hasNode(c.v)!==a.hasNode(c.w))return r(u,c)})}function s(a,u,c){e.forEach(a.nodes(),function(l){u.node(l).rank+=c})}return Jc}var Zc,Dg;function DC(){if(Dg)return Zc;Dg=1;var e=Ue(),t=Ib(),r=yn().slack,n=yn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,s=pr().simplify;Zc=a,a.initLowLimValues=d,a.initCutValues=u,a.calcCutValue=l,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=g;function a(w){w=s(w),n(w);var v=t(w);d(v),u(v,w);for(var C,_;C=p(v);)_=y(v,w,C),g(v,w,C,_)}function u(w,v){var C=i(w,w.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(_){c(w,v,_)})}function c(w,v,C){var _=w.node(C),R=_.parent;w.edge(C,R).cutvalue=l(w,v,C)}function l(w,v,C){var _=w.node(C),R=_.parent,T=!0,A=v.edge(C,R),k=0;return A||(T=!1,A=v.edge(R,C)),k=A.weight,e.forEach(v.nodeEdges(C),function(E){var j=E.v===C,M=j?E.w:E.v;if(M!==R){var I=j===T,q=v.edge(E).weight;if(k+=I?q:-q,x(w,C,M)){var O=w.edge(C,M).cutvalue;k+=I?-O:O}}}),k}function d(w,v){arguments.length<2&&(v=w.nodes()[0]),f(w,{},1,v)}function f(w,v,C,_,R){var T=C,A=w.node(_);return v[_]=!0,e.forEach(w.neighbors(_),function(k){e.has(v,k)||(C=f(w,v,C,k,_))}),A.low=T,A.lim=C++,R?A.parent=R:delete A.parent,C}function p(w){return e.find(w.edges(),function(v){return w.edge(v).cutvalue<0})}function y(w,v,C){var _=C.v,R=C.w;v.hasEdge(_,R)||(_=C.w,R=C.v);var T=w.node(_),A=w.node(R),k=T,E=!1;T.lim>A.lim&&(k=A,E=!0);var j=e.filter(v.edges(),function(M){return E===m(w,w.node(M.v),k)&&E!==m(w,w.node(M.w),k)});return e.minBy(j,function(M){return r(v,M)})}function g(w,v,C,_){var R=C.v,T=C.w;w.removeEdge(R,T),w.setEdge(_.v,_.w,{}),d(w),u(w,v),b(w,v)}function b(w,v){var C=e.find(w.nodes(),function(R){return!v.node(R).parent}),_=o(w,C);_=_.slice(1),e.forEach(_,function(R){var T=w.node(R).parent,A=v.edge(R,T),k=!1;A||(A=v.edge(T,R),k=!0),v.node(R).rank=v.node(T).rank+(k?A.minlen:-A.minlen)})}function x(w,v,C){return w.hasEdge(v,C)}function m(w,v,C){return C.low<=v.lim&&v.lim<=C.lim}return Zc}var Yc,zg;function zC(){if(zg)return Yc;zg=1;var e=yn(),t=e.longestPath,r=Ib(),n=DC();Yc=o;function o(u){switch(u.graph().ranker){case"network-simplex":a(u);break;case"tight-tree":s(u);break;case"longest-path":i(u);break;default:a(u)}}var i=t;function s(u){t(u),r(u)}function a(u){n(u)}return Yc}var Xc,Vg;function VC(){if(Vg)return Xc;Vg=1;var e=Ue();Xc=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),u=a.edgeObj,c=r(o,i,u.v,u.w),l=c.path,d=c.lca,f=0,p=l[f],y=!0;s!==u.w;){if(a=o.node(s),y){for(;(p=l[f])!==d&&o.node(p).maxRank<a.rank;)f++;p===d&&(y=!1)}if(!y){for(;f<l.length-1&&o.node(p=l[f+1]).minRank<=a.rank;)f++;p=l[f]}o.setParent(s,p),s=o.successors(s)[0]}})}function r(o,i,s,a){var u=[],c=[],l=Math.min(i[s].low,i[a].low),d=Math.max(i[s].lim,i[a].lim),f,p;f=s;do f=o.parent(f),u.push(f);while(f&&(i[f].low>l||d>i[f].lim));for(p=f,f=a;(f=o.parent(f))!==p;)c.push(f);return{path:u.concat(c.reverse()),lca:p}}function n(o){var i={},s=0;function a(u){var c=s;e.forEach(o.children(u),a),i[u]={low:c,lim:s++}}return e.forEach(o.children(),a),i}return Xc}var Qc,Wg;function WC(){if(Wg)return Qc;Wg=1;var e=Ue(),t=pr();Qc={run:r,cleanup:s};function r(a){var u=t.addDummyNode(a,"root",{},"_root"),c=o(a),l=e.max(e.values(c))-1,d=2*l+1;a.graph().nestingRoot=u,e.forEach(a.edges(),function(p){a.edge(p).minlen*=d});var f=i(a)+1;e.forEach(a.children(),function(p){n(a,u,d,f,l,c,p)}),a.graph().nodeRankFactor=d}function n(a,u,c,l,d,f,p){var y=a.children(p);if(!y.length){p!==u&&a.setEdge(u,p,{weight:0,minlen:c});return}var g=t.addBorderNode(a,"_bt"),b=t.addBorderNode(a,"_bb"),x=a.node(p);a.setParent(g,p),x.borderTop=g,a.setParent(b,p),x.borderBottom=b,e.forEach(y,function(m){n(a,u,c,l,d,f,m);var w=a.node(m),v=w.borderTop?w.borderTop:m,C=w.borderBottom?w.borderBottom:m,_=w.borderTop?l:2*l,R=v!==C?1:d-f[p]+1;a.setEdge(g,v,{weight:_,minlen:R,nestingEdge:!0}),a.setEdge(C,b,{weight:_,minlen:R,nestingEdge:!0})}),a.parent(p)||a.setEdge(u,g,{weight:0,minlen:d+f[p]})}function o(a){var u={};function c(l,d){var f=a.children(l);f&&f.length&&e.forEach(f,function(p){c(p,d+1)}),u[l]=d}return e.forEach(a.children(),function(l){c(l,1)}),u}function i(a){return e.reduce(a.edges(),function(u,c){return u+a.edge(c).weight},0)}function s(a){var u=a.graph();a.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(a.edges(),function(c){var l=a.edge(c);l.nestingEdge&&a.removeEdge(c)})}return Qc}var eu,Gg;function GC(){if(Gg)return eu;Gg=1;var e=Ue(),t=pr();eu=r;function r(o){function i(s){var a=o.children(s),u=o.node(s);if(a.length&&e.forEach(a,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,l=u.maxRank+1;c<l;++c)n(o,"borderLeft","_bl",s,u,c),n(o,"borderRight","_br",s,u,c)}}e.forEach(o.children(),i)}function n(o,i,s,a,u,c){var l={width:0,height:0,rank:c,borderType:i},d=u[i][c-1],f=t.addDummyNode(o,"border",l,s);u[i][c]=f,o.setParent(f,a),d&&o.setEdge(d,f,{weight:1})}return eu}var ru,Ug;function UC(){if(Ug)return ru;Ug=1;var e=Ue();ru={adjust:t,undo:r};function t(c){var l=c.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(c)}function r(c){var l=c.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&i(c),(l==="lr"||l==="rl")&&(a(c),n(c))}function n(c){e.forEach(c.nodes(),function(l){o(c.node(l))}),e.forEach(c.edges(),function(l){o(c.edge(l))})}function o(c){var l=c.width;c.width=c.height,c.height=l}function i(c){e.forEach(c.nodes(),function(l){s(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,s),e.has(d,"y")&&s(d)})}function s(c){c.y=-c.y}function a(c){e.forEach(c.nodes(),function(l){u(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,u),e.has(d,"x")&&u(d)})}function u(c){var l=c.x;c.x=c.y,c.y=l}return ru}var tu,Hg;function HC(){if(Hg)return tu;Hg=1;var e=Ue();tu=t;function t(r){var n={},o=e.filter(r.nodes(),function(c){return!r.children(c).length}),i=e.max(e.map(o,function(c){return r.node(c).rank})),s=e.map(e.range(i+1),function(){return[]});function a(c){if(!e.has(n,c)){n[c]=!0;var l=r.node(c);s[l.rank].push(c),e.forEach(r.successors(c),a)}}var u=e.sortBy(o,function(c){return r.node(c).rank});return e.forEach(u,a),s}return tu}var nu,Kg;function KC(){if(Kg)return nu;Kg=1;var e=Ue();nu=t;function t(n,o){for(var i=0,s=1;s<o.length;++s)i+=r(n,o[s-1],o[s]);return i}function r(n,o,i){for(var s=e.zipObject(i,e.map(i,function(f,p){return p})),a=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var c=2*u-1;u-=1;var l=e.map(new Array(c),function(){return 0}),d=0;return e.forEach(a.forEach(function(f){var p=f.pos+u;l[p]+=f.weight;for(var y=0;p>0;)p%2&&(y+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*y})),d}return nu}var ou,Jg;function JC(){if(Jg)return ou;Jg=1;var e=Ue();ou=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var s=e.reduce(i,function(a,u){var c=r.edge(u),l=r.node(u.v);return{sum:a.sum+c.weight*l.order,weight:a.weight+c.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return ou}var iu,Zg;function ZC(){if(Zg)return iu;Zg=1;var e=Ue();iu=t;function t(o,i){var s={};e.forEach(o,function(u,c){var l=s[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(l.barycenter=u.barycenter,l.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=s[u.v],l=s[u.w];!e.isUndefined(c)&&!e.isUndefined(l)&&(l.indegree++,c.out.push(s[u.w]))});var a=e.filter(s,function(u){return!u.indegree});return r(a)}function r(o){var i=[];function s(c){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(c.barycenter)||l.barycenter>=c.barycenter)&&n(c,l)}}function a(c){return function(l){l.in.push(c),--l.indegree===0&&o.push(l)}}for(;o.length;){var u=o.pop();i.push(u),e.forEach(u.in.reverse(),s(u)),e.forEach(u.out,a(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["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 iu}var au,Yg;function YC(){if(Yg)return au;Yg=1;var e=Ue(),t=pr();au=r;function r(i,s){var a=t.partition(i,function(g){return e.has(g,"barycenter")}),u=a.lhs,c=e.sortBy(a.rhs,function(g){return-g.i}),l=[],d=0,f=0,p=0;u.sort(o(!!s)),p=n(l,c,p),e.forEach(u,function(g){p+=g.vs.length,l.push(g.vs),d+=g.barycenter*g.weight,f+=g.weight,p=n(l,c,p)});var y={vs:e.flatten(l,!0)};return f&&(y.barycenter=d/f,y.weight=f),y}function n(i,s,a){for(var u;s.length&&(u=e.last(s)).i<=a;)s.pop(),i.push(u.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 au}var su,Xg;function XC(){if(Xg)return su;Xg=1;var e=Ue(),t=JC(),r=ZC(),n=YC();su=o;function o(a,u,c,l){var d=a.children(u),f=a.node(u),p=f?f.borderLeft:void 0,y=f?f.borderRight:void 0,g={};p&&(d=e.filter(d,function(C){return C!==p&&C!==y}));var b=t(a,d);e.forEach(b,function(C){if(a.children(C.v).length){var _=o(a,C.v,c,l);g[C.v]=_,e.has(_,"barycenter")&&s(C,_)}});var x=r(b,c);i(x,g);var m=n(x,l);if(p&&(m.vs=e.flatten([p,m.vs,y],!0),a.predecessors(p).length)){var w=a.node(a.predecessors(p)[0]),v=a.node(a.predecessors(y)[0]);e.has(m,"barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+w.order+v.order)/(m.weight+2),m.weight+=2}return m}function i(a,u){e.forEach(a,function(c){c.vs=e.flatten(c.vs.map(function(l){return u[l]?u[l].vs:l}),!0)})}function s(a,u){e.isUndefined(a.barycenter)?(a.barycenter=u.barycenter,a.weight=u.weight):(a.barycenter=(a.barycenter*a.weight+u.barycenter*u.weight)/(a.weight+u.weight),a.weight+=u.weight)}return su}var cu,Qg;function QC(){if(Qg)return cu;Qg=1;var e=Ue(),t=_r().Graph;cu=r;function r(o,i,s){var a=n(o),u=new t({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(c){return o.node(c)});return e.forEach(o.nodes(),function(c){var l=o.node(c),d=o.parent(c);(l.rank===i||l.minRank<=i&&i<=l.maxRank)&&(u.setNode(c),u.setParent(c,d||a),e.forEach(o[s](c),function(f){var p=f.v===c?f.w:f.v,y=u.edge(p,c),g=e.isUndefined(y)?0:y.weight;u.setEdge(p,c,{weight:o.edge(f).weight+g})}),e.has(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[i],borderRight:l.borderRight[i]}))}),u}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return cu}var uu,ey;function e_(){if(ey)return uu;ey=1;var e=Ue();uu=t;function t(r,n,o){var i={},s;e.forEach(o,function(a){for(var u=r.parent(a),c,l;u;){if(c=r.parent(u),c?(l=i[c],i[c]=u):(l=s,s=u),l&&l!==u){n.setEdge(l,u);return}u=c}})}return uu}var lu,ry;function r_(){if(ry)return lu;ry=1;var e=Ue(),t=HC(),r=KC(),n=XC(),o=QC(),i=e_(),s=_r().Graph,a=pr();lu=u;function u(f){var p=a.maxRank(f),y=c(f,e.range(1,p+1),"inEdges"),g=c(f,e.range(p-1,-1,-1),"outEdges"),b=t(f);d(f,b);for(var x=Number.POSITIVE_INFINITY,m,w=0,v=0;v<4;++w,++v){l(w%2?y:g,w%4>=2),b=a.buildLayerMatrix(f);var C=r(f,b);C<x&&(v=0,m=e.cloneDeep(b),x=C)}d(f,m)}function c(f,p,y){return e.map(p,function(g){return o(f,g,y)})}function l(f,p){var y=new s;e.forEach(f,function(g){var b=g.graph().root,x=n(g,b,y,p);e.forEach(x.vs,function(m,w){g.node(m).order=w}),i(g,y,x.vs)})}function d(f,p){e.forEach(p,function(y){e.forEach(y,function(g,b){f.node(g).order=b})})}return lu}var du,ty;function t_(){if(ty)return du;ty=1;var e=Ue(),t=_r().Graph,r=pr();du={positionX:y,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(x,m){var w={};function v(C,_){var R=0,T=0,A=C.length,k=e.last(_);return e.forEach(_,function(E,j){var M=i(x,E),I=M?x.node(M).order:A;(M||E===k)&&(e.forEach(_.slice(T,j+1),function(q){e.forEach(x.predecessors(q),function(O){var V=x.node(O),W=V.order;(W<R||I<W)&&!(V.dummy&&x.node(q).dummy)&&s(w,O,q)})}),T=j+1,R=I)}),_}return e.reduce(m,v),w}function o(x,m){var w={};function v(_,R,T,A,k){var E;e.forEach(e.range(R,T),function(j){E=_[j],x.node(E).dummy&&e.forEach(x.predecessors(E),function(M){var I=x.node(M);I.dummy&&(I.order<A||I.order>k)&&s(w,M,E)})})}function C(_,R){var T=-1,A,k=0;return e.forEach(R,function(E,j){if(x.node(E).dummy==="border"){var M=x.predecessors(E);M.length&&(A=x.node(M[0]).order,v(R,k,j,T,A),k=j,T=A)}v(R,k,R.length,A,_.length)}),R}return e.reduce(m,C),w}function i(x,m){if(x.node(m).dummy)return e.find(x.predecessors(m),function(w){return x.node(w).dummy})}function s(x,m,w){if(m>w){var v=m;m=w,w=v}var C=x[m];C||(x[m]=C={}),C[w]=!0}function a(x,m,w){if(m>w){var v=m;m=w,w=v}return e.has(x[m],w)}function u(x,m,w,v){var C={},_={},R={};return e.forEach(m,function(T){e.forEach(T,function(A,k){C[A]=A,_[A]=A,R[A]=k})}),e.forEach(m,function(T){var A=-1;e.forEach(T,function(k){var E=v(k);if(E.length){E=e.sortBy(E,function(O){return R[O]});for(var j=(E.length-1)/2,M=Math.floor(j),I=Math.ceil(j);M<=I;++M){var q=E[M];_[k]===k&&A<R[q]&&!a(w,k,q)&&(_[q]=k,_[k]=C[k]=C[q],A=R[q])}}})}),{root:C,align:_}}function c(x,m,w,v,C){var _={},R=l(x,m,w,C),T=C?"borderLeft":"borderRight";function A(j,M){for(var I=R.nodes(),q=I.pop(),O={};q;)O[q]?j(q):(O[q]=!0,I.push(q),I=I.concat(M(q))),q=I.pop()}function k(j){_[j]=R.inEdges(j).reduce(function(M,I){return Math.max(M,_[I.v]+R.edge(I))},0)}function E(j){var M=R.outEdges(j).reduce(function(q,O){return Math.min(q,_[O.w]-R.edge(O))},Number.POSITIVE_INFINITY),I=x.node(j);M!==Number.POSITIVE_INFINITY&&I.borderType!==T&&(_[j]=Math.max(_[j],M))}return A(k,R.predecessors.bind(R)),A(E,R.successors.bind(R)),e.forEach(v,function(j){_[j]=_[w[j]]}),_}function l(x,m,w,v){var C=new t,_=x.graph(),R=g(_.nodesep,_.edgesep,v);return e.forEach(m,function(T){var A;e.forEach(T,function(k){var E=w[k];if(C.setNode(E),A){var j=w[A],M=C.edge(j,E);C.setEdge(j,E,Math.max(R(x,k,A),M||0))}A=k})}),C}function d(x,m){return e.minBy(e.values(m),function(w){var v=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(w,function(_,R){var T=b(x,R)/2;v=Math.max(_+T,v),C=Math.min(_-T,C)}),v-C})}function f(x,m){var w=e.values(m),v=e.min(w),C=e.max(w);e.forEach(["u","d"],function(_){e.forEach(["l","r"],function(R){var T=_+R,A=x[T],k;if(A!==m){var E=e.values(A);k=R==="l"?v-e.min(E):C-e.max(E),k&&(x[T]=e.mapValues(A,function(j){return j+k}))}})})}function p(x,m){return e.mapValues(x.ul,function(w,v){if(m)return x[m.toLowerCase()][v];var C=e.sortBy(e.map(x,v));return(C[1]+C[2])/2})}function y(x){var m=r.buildLayerMatrix(x),w=e.merge(n(x,m),o(x,m)),v={},C;e.forEach(["u","d"],function(R){C=R==="u"?m:e.values(m).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(C=e.map(C,function(j){return e.values(j).reverse()}));var A=(R==="u"?x.predecessors:x.successors).bind(x),k=u(x,C,w,A),E=c(x,C,k.root,k.align,T==="r");T==="r"&&(E=e.mapValues(E,function(j){return-j})),v[R+T]=E})});var _=d(x,v);return f(v,_),p(v,x.graph().align)}function g(x,m,w){return function(v,C,_){var R=v.node(C),T=v.node(_),A=0,k;if(A+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":k=-R.width/2;break;case"r":k=R.width/2;break}if(k&&(A+=w?k:-k),k=0,A+=(R.dummy?m:x)/2,A+=(T.dummy?m:x)/2,A+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":k=T.width/2;break;case"r":k=-T.width/2;break}return k&&(A+=w?k:-k),k=0,A}}function b(x,m){return x.node(m).width}return du}var fu,ny;function n_(){if(ny)return fu;ny=1;var e=Ue(),t=pr(),r=t_().positionX;fu=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(s,a){i.node(a).x=s})}function o(i){var s=t.buildLayerMatrix(i),a=i.graph().ranksep,u=0;e.forEach(s,function(c){var l=e.max(e.map(c,function(d){return i.node(d).height}));e.forEach(c,function(d){i.node(d).y=u+l/2}),u+=l+a})}return fu}var hu,oy;function o_(){if(oy)return hu;oy=1;var e=Ue(),t=FC(),r=BC(),n=zC(),o=pr().normalizeRanks,i=VC(),s=pr().removeEmptyRanks,a=WC(),u=GC(),c=UC(),l=r_(),d=n_(),f=pr(),p=_r().Graph;hu=y;function y(N,L){var G=L&&L.debugTiming?f.time:f.notime;G("layout",function(){var D=G(" buildLayoutGraph",function(){return A(N)});G(" runLayout",function(){g(D,G)}),G(" updateInputGraph",function(){b(N,D)})})}function g(N,L){L(" makeSpaceForEdgeLabels",function(){k(N)}),L(" removeSelfEdges",function(){re(N)}),L(" acyclic",function(){t.run(N)}),L(" nestingGraph.run",function(){a.run(N)}),L(" rank",function(){n(f.asNonCompoundGraph(N))}),L(" injectEdgeLabelProxies",function(){E(N)}),L(" removeEmptyRanks",function(){s(N)}),L(" nestingGraph.cleanup",function(){a.cleanup(N)}),L(" normalizeRanks",function(){o(N)}),L(" assignRankMinMax",function(){j(N)}),L(" removeEdgeLabelProxies",function(){M(N)}),L(" normalize.run",function(){r.run(N)}),L(" parentDummyChains",function(){i(N)}),L(" addBorderSegments",function(){u(N)}),L(" order",function(){l(N)}),L(" insertSelfEdges",function(){Y(N)}),L(" adjustCoordinateSystem",function(){c.adjust(N)}),L(" position",function(){d(N)}),L(" positionSelfEdges",function(){he(N)}),L(" removeBorderNodes",function(){W(N)}),L(" normalize.undo",function(){r.undo(N)}),L(" fixupEdgeLabelCoords",function(){O(N)}),L(" undoCoordinateSystem",function(){c.undo(N)}),L(" translateGraph",function(){I(N)}),L(" assignNodeIntersects",function(){q(N)}),L(" reversePoints",function(){V(N)}),L(" acyclic.undo",function(){t.undo(N)})}function b(N,L){e.forEach(N.nodes(),function(G){var D=N.node(G),ne=L.node(G);D&&(D.x=ne.x,D.y=ne.y,L.children(G).length&&(D.width=ne.width,D.height=ne.height))}),e.forEach(N.edges(),function(G){var D=N.edge(G),ne=L.edge(G);D.points=ne.points,e.has(ne,"x")&&(D.x=ne.x,D.y=ne.y)}),N.graph().width=L.graph().width,N.graph().height=L.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],m={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],v=["width","height"],C={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function A(N){var L=new p({multigraph:!0,compound:!0}),G=J(N.graph());return L.setGraph(e.merge({},m,me(G,x),e.pick(G,w))),e.forEach(N.nodes(),function(D){var ne=J(N.node(D));L.setNode(D,e.defaults(me(ne,v),C)),L.setParent(D,N.parent(D))}),e.forEach(N.edges(),function(D){var ne=J(N.edge(D));L.setEdge(D,e.merge({},R,me(ne,_),e.pick(ne,T)))}),L}function k(N){var L=N.graph();L.ranksep/=2,e.forEach(N.edges(),function(G){var D=N.edge(G);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function E(N){e.forEach(N.edges(),function(L){var G=N.edge(L);if(G.width&&G.height){var D=N.node(L.v),ne=N.node(L.w),ue={rank:(ne.rank-D.rank)/2+D.rank,e:L};f.addDummyNode(N,"edge-proxy",ue,"_ep")}})}function j(N){var L=0;e.forEach(N.nodes(),function(G){var D=N.node(G);D.borderTop&&(D.minRank=N.node(D.borderTop).rank,D.maxRank=N.node(D.borderBottom).rank,L=e.max(L,D.maxRank))}),N.graph().maxRank=L}function M(N){e.forEach(N.nodes(),function(L){var G=N.node(L);G.dummy==="edge-proxy"&&(N.edge(G.e).labelRank=G.rank,N.removeNode(L))})}function I(N){var L=Number.POSITIVE_INFINITY,G=0,D=Number.POSITIVE_INFINITY,ne=0,ue=N.graph(),X=ue.marginx||0,U=ue.marginy||0;function K(te){var ce=te.x,de=te.y,Ae=te.width,ge=te.height;L=Math.min(L,ce-Ae/2),G=Math.max(G,ce+Ae/2),D=Math.min(D,de-ge/2),ne=Math.max(ne,de+ge/2)}e.forEach(N.nodes(),function(te){K(N.node(te))}),e.forEach(N.edges(),function(te){var ce=N.edge(te);e.has(ce,"x")&&K(ce)}),L-=X,D-=U,e.forEach(N.nodes(),function(te){var ce=N.node(te);ce.x-=L,ce.y-=D}),e.forEach(N.edges(),function(te){var ce=N.edge(te);e.forEach(ce.points,function(de){de.x-=L,de.y-=D}),e.has(ce,"x")&&(ce.x-=L),e.has(ce,"y")&&(ce.y-=D)}),ue.width=G-L+X,ue.height=ne-D+U}function q(N){e.forEach(N.edges(),function(L){var G=N.edge(L),D=N.node(L.v),ne=N.node(L.w),ue,X;G.points?(ue=G.points[0],X=G.points[G.points.length-1]):(G.points=[],ue=ne,X=D),G.points.unshift(f.intersectRect(D,ue)),G.points.push(f.intersectRect(ne,X))})}function O(N){e.forEach(N.edges(),function(L){var G=N.edge(L);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 V(N){e.forEach(N.edges(),function(L){var G=N.edge(L);G.reversed&&G.points.reverse()})}function W(N){e.forEach(N.nodes(),function(L){if(N.children(L).length){var G=N.node(L),D=N.node(G.borderTop),ne=N.node(G.borderBottom),ue=N.node(e.last(G.borderLeft)),X=N.node(e.last(G.borderRight));G.width=Math.abs(X.x-ue.x),G.height=Math.abs(ne.y-D.y),G.x=ue.x+G.width/2,G.y=D.y+G.height/2}}),e.forEach(N.nodes(),function(L){N.node(L).dummy==="border"&&N.removeNode(L)})}function re(N){e.forEach(N.edges(),function(L){if(L.v===L.w){var G=N.node(L.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:L,label:N.edge(L)}),N.removeEdge(L)}})}function Y(N){var L=f.buildLayerMatrix(N);e.forEach(L,function(G){var D=0;e.forEach(G,function(ne,ue){var X=N.node(ne);X.order=ue+D,e.forEach(X.selfEdges,function(U){f.addDummyNode(N,"selfedge",{width:U.label.width,height:U.label.height,rank:X.rank,order:ue+ ++D,e:U.e,label:U.label},"_se")}),delete X.selfEdges})})}function he(N){e.forEach(N.nodes(),function(L){var G=N.node(L);if(G.dummy==="selfedge"){var D=N.node(G.e.v),ne=D.x+D.width/2,ue=D.y,X=G.x-ne,U=D.height/2;N.setEdge(G.e,G.label),N.removeNode(L),G.label.points=[{x:ne+2*X/3,y:ue-U},{x:ne+5*X/6,y:ue-U},{x:ne+X,y:ue},{x:ne+5*X/6,y:ue+U},{x:ne+2*X/3,y:ue+U}],G.label.x=G.x,G.label.y=G.y}})}function me(N,L){return e.mapValues(e.pick(N,L),Number)}function J(N){var L={};return e.forEach(N,function(G,D){L[D.toLowerCase()]=G}),L}return hu}var pu,iy;function i_(){if(iy)return pu;iy=1;var e=Ue(),t=pr(),r=_r().Graph;pu={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),s=new r({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,u){var c="layer"+u;s.setNode(c,{rank:"same"}),e.reduce(a,function(l,d){return s.setEdge(l,d,{style:"invis"}),d})}),s}return pu}var gu,ay;function a_(){return ay||(ay=1,gu="0.8.5"),gu}var yu,sy;function s_(){return sy||(sy=1,yu={graphlib:_r(),layout:o_(),debug:i_(),util:{time:pr().time,notime:pr().notime},version:a_()}),yu}var c_=s_();const cy=U0(c_);function u_(e,t,r){var l;const n=new Set(e.map(d=>d.id)),o=new Set;for(const d of e)d.parent&&n.has(d.parent)&&o.add(d.parent);const i=new cy.graphlib.Graph({multigraph:!0,compound:!0}),s=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);i.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*s):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*s):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*s):r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const d of e)i.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&i.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||o.has(d.source)||o.has(d.target))continue;const f=Om(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",y=(f.width?f.width+2*Tm:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,f.height),height:p?Math.max(1,f.height):y,labelpos:"c"}:{}},d.id)}cy.layout(i);const a=new Map;for(const d of e){if(o.has(d.id))continue;const f=i.node(d.id);f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&a.set(d.id,{x:f.x,y:f.y})}const u=r.compact?1:r.spacingFactor;if(u&&u!==1&&a.size){let d=1/0,f=1/0,p=-1/0,y=-1/0;a.forEach(x=>{d=Math.min(d,x.x),f=Math.min(f,x.y),p=Math.max(p,x.x),y=Math.max(y,x.y)});const g=(d+p)/2,b=(f+y)/2;a.forEach((x,m)=>a.set(m,{x:g+(x.x-g)*u,y:b+(x.y-b)*u}))}const c=r.nodeAlignment??"center";if(c!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",f=d?"x":"y",p=d?"width":"height",y=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,g=c==="leading"?-y:y,b=new Map;for(const x of e){const m=a.get(x.id);if(!m)continue;const w=m[f];b.set(w,Math.max(b.get(w)??0,x[p]))}for(const x of e){const m=a.get(x.id);if(!m)continue;const w=m[f],v=(b.get(w)-x[p])/2;a.set(x.id,{...m,[f]:w+g*v})}}return a}function l_(e,t,r,n,o){const i=new Map,s=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!s.has(l.parent))continue;const d=i.get(l.parent);d?d.push(l.id):i.set(l.parent,[l.id])}const a=(l,d=new Set)=>{var p;const f=(p=s.get(l))==null?void 0:p.parent;return!f||!s.has(f)||d.has(l)?0:(d.add(l),1+a(f,d))},u=[...i.keys()].sort((l,d)=>a(d)-a(l)),c=new Map;for(const l of u){let d=null;for(const y of i.get(l)||[]){let g=c.get(y);if(!g){const b=t.get(y);if(!b)continue;const x=r.get(y)||{w:60,h:60};g={x1:b.x-x.w/2,y1:b.y-x.h/2,x2:b.x+x.w/2,y2:b.y+x.h/2}}d=d?{x1:Math.min(d.x1,g.x1),y1:Math.min(d.y1,g.y1),x2:Math.max(d.x2,g.x2),y2:Math.max(d.y2,g.y2)}:{...g}}if(!d)continue;const f=n(l);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(l);if(p){const y=d.x2-d.x1,g=d.y2-d.y1;if(p.w>y){const b=(p.w-y)/2;d.x1-=b,d.x2+=b}if(p.h>g){const b=(p.h-g)/2;d.y1-=b,d.y2+=b}}c.set(l,d)}return c}function d_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Pm(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 u=a.dataset.flowPortSide;if(u&&["top","right","bottom","left"].includes(u)){const l=jm(n?Ft(o,n):o,u,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const c=a.getBoundingClientRect();return!c.width||!c.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((c.top-t.top)/r*1e3)/1e3,height:Math.round(c.height/r*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function f_({id:e,x:t,y:r,placed:n,hidden:o,onMount:i,drawHandles:s,drawMode:a,connectedPorts:u,resolvedRows:c,hasCollapseControl:l,handleColor:d,animated:f,animationColor:p,animationWidth:y=8,animationVariant:g,width:b=0,height:x=0,propertyMode:m,reversePorts:w,direction:v="LR",onPropertyRows:C,onSurface:_,children:R}){const T=S.useRef(null),[A,k]=S.useState([]),E=c??A,[j,M]=S.useState();return S.useLayoutEffect(()=>{const I=T.current;if(!I)return;const q=()=>{const W=Pm(I);M(re=>JSON.stringify(re)===JSON.stringify(W)?re:W),_==null||_(e,W)};q();const O=new ResizeObserver(q);O.observe(I);const V=I.querySelector("[data-flow-node-surface]");return V&&O.observe(V),()=>O.disconnect()},[e,R,_]),S.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),_==null||_(e,void 0)}),[e,i,_]),S.useLayoutEffect(()=>{const I=T.current;if(!I)return;let q="";const O=()=>{const Y=d_(I),he=m?Y:Y.filter(J=>J.anchor),me=JSON.stringify(he);me!==q&&(q=me,k(he),C==null||C(e,he))};if(O(),!m&&!I.querySelector("[data-flow-port-side]"))return;const V=new ResizeObserver(O),W=()=>{V.disconnect(),V.observe(I),I.querySelectorAll("[data-flow-property]").forEach(Y=>V.observe(Y)),O()};W();const re=new MutationObserver(W);return re.observe(I,{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"]}),I.addEventListener("scroll",O,!0),()=>{V.disconnect(),re.disconnect(),I.removeEventListener("scroll",O,!0)}},[e,m,C,R]),h.jsxs("div",{ref:T,className:"flow-sdk-node","data-node-id":e,style:{transform:`translate(-50%, -50%) translate3d(${t.toFixed(2)}px, ${r.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden"},children:[R,f&&y>0&&b>0&&x>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(Em,{variant:g,x:((j==null?void 0:j.left)??0)+y/2,y:((j==null?void 0:j.top)??0)+y/2,width:((j==null?void 0:j.width)??b)-y,height:((j==null?void 0:j.height)??x)-y,radius:((j==null?void 0:j.radius)??0)-y/2,path:j!=null&&j.outline?`M${j.outline.map(I=>`${I.x} ${I.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:y})}),s&&m&&E.map(I=>["source","target"].filter(q=>!I.role||I.role===q).filter(q=>a||(u==null?void 0:u.has(`${q}:${I.property}`))).map(q=>{var O;return h.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":I.property,"data-port-role":q,"data-port-side":(O=I.anchor)==null?void 0:O.side,"aria-label":`${q==="source"?"Connect":"Input"} ${I.property}`,title:`${q==="source"?"Connect":"Input"} ${I.property}`,style:{color:d,...I.anchor?{top:I.anchor.y,left:I.anchor.x-16}:{top:I.top+I.height/2,[q==="source"!=!!w?"right":"left"]:-16}},onClick:V=>V.stopPropagation()},`${I.property}:${q}`)})),s&&!l&&(!m||!E.length)&&(!m||!E.some(I=>I.anchor))&&h.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((j==null?void 0:j.left)??0)+(v==="RL"?-36:v==="LR"?(j==null?void 0:j.width)??b:((j==null?void 0:j.width)??b)/2),top:((j==null?void 0:j.top)??0)+(v==="BT"?-36:v==="TB"?(j==null?void 0:j.height)??x:((j==null?void 0:j.height)??x)/2),transform:v==="BT"||v==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:I=>I.stopPropagation(),children:h.jsx(Z.PiPlusBold,{size:24})})]})}const h_=S.memo(f_);class p_{constructor(t,r,n){Tr(this,"_pan");Tr(this,"_zoom");Tr(this,"minZoom");Tr(this,"maxZoom");Tr(this,"size",{w:0,h:0});Tr(this,"listeners",new Set);Tr(this,"animationFrame");Tr(this,"animationTimer");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}cancelAnimation(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),clearTimeout(this.animationTimer),this.animationFrame=void 0,this.animationTimer=void 0}transition(t,r=!1){if(this.cancelAnimation(),!r||typeof requestAnimationFrame>"u"||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches){this.set(t.pan,t.zoom);return}const n=this.state,o={pan:{...t.pan},zoom:this.clamp(t.zoom)},i=performance.now(),s=()=>{this.cancelAnimation(),this.set(o.pan,o.zoom)},a=u=>{const c=Math.min(1,(u-i)/300);if(c>=1){s();return}const l=c*c*(3-2*c);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.animationFrame=requestAnimationFrame(a)};this.animationFrame=requestAnimationFrame(a),this.animationTimer=setTimeout(s,400)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(t){return Number.isFinite(t)?Math.max(this.minZoom,Math.min(this.maxZoom,t)):this.minZoom}set(t,r){this.cancelAnimation(),this.apply(t,r)}apply(t,r){let n=!1;if(t&&(t.x!==this._pan.x||t.y!==this._pan.y)&&(this._pan={x:t.x,y:t.y},n=!0),r!==void 0){const o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0,n=!1){const o=t.x2-t.x1,i=t.y2-t.y1;if(!(o>0)||!(i>0)||!this.size.w||!this.size.h)return;const s=this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/i));this.transition({pan:{x:(this.size.w-s*(t.x1+t.x2))/2,y:(this.size.h-s*(t.y1+t.y2))/2},zoom:s},n)}center(t,r=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(t.x1+t.x2))/2,y:(this.size.h-n*(t.y1+t.y2))/2},zoom:n},r)}renderedToModel(t){return{x:(t.x-this._pan.x)/this._zoom,y:(t.y-this._pan.y)/this._zoom}}modelToRendered(t){return{x:t.x*this._zoom+this._pan.x,y:t.y*this._zoom+this._pan.y}}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(){const t=this.state;this.listeners.forEach(r=>r(t))}}const g_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},mu={w:60,h:60},uy=4,y_=30,ly=300,m_=500,b_=45,v_=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function dy(e){const[t,r]=[...e.values()];return!t||!r?null:{center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2},distance:Math.max(1,Math.hypot(r.x-t.x,r.y-t.y))}}function x_(e){var ul;const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:u,spacingFactor:c=1.3,compactSpacingScale:l,minZoom:d,maxZoom:f,initialViewport:p,containerStyle:y,lineColor:g,drawMode:b,dragMode:x,multiSelect:m,isPerformanceMode:w}=e,[v,C]=S.useState(null),_=S.useMemo(()=>v?(v.mode==="connections"?Ll:Ol)(v.id,t,r):null,[v,t,r]),R=i==="auto"||i==="properties",T=S.useMemo(()=>r.filter(P=>_u(P,i)&&(!_||_.has(P.source)&&_.has(P.target))),[r,i,_]),A=S.useMemo(()=>F0(t,r,i,s,_),[t,r,i,s,_]),k=S.useRef(A);k.current=A;const E=S.useRef(e);E.current=e;const j=S.useRef(null),M=S.useRef(null),I=S.useRef(null),q=S.useRef(null),O=S.useMemo(()=>new p_(p,d,f),[]);S.useEffect(()=>{O.minZoom=d,O.maxZoom=f},[O,d,f]);const V=S.useRef(new Map),W=S.useRef(new Map),re=S.useRef(new Map),Y=S.useRef(null),[he,me]=S.useState(new Map),J=S.useCallback((P,$)=>{me(F=>{if(JSON.stringify(F.get(P))===JSON.stringify($))return F;const H=new Map(F);return $?H.set(P,$):H.delete(P),H})},[]),[N,L]=S.useState(new Map),G=S.useRef(N),D=S.useCallback((P,$)=>{L(F=>{if(JSON.stringify(F.get(P)??[])===JSON.stringify($))return F;const H=new Map(F);return $.length?H.set(P,$):H.delete(P),H})},[]),[ne,ue]=S.useState(()=>new Map),X=S.useRef(ne);X.current=ne;const U=S.useRef(new Map),K=S.useRef(!1),[te,ce]=S.useState(0),de=S.useRef(),Ae=S.useRef(),ge=S.useRef(null),Ke=S.useRef(),Oe=S.useRef(!1),Le=S.useRef(null),er=S.useRef(c),Ve=s,$e=S.useRef(Ve),[xe,Me]=S.useState(!0),Fe=S.useRef(null);Fe.current=_;const nr=S.useRef(1);nr.current=(v==null?void 0:v.mode)==="connections"?1.25:1;const Ze=S.useRef(null),Ye=S.useRef(t),fr=S.useRef([]),wr=S.useRef(!1),we=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(Ke.current)},ar=()=>{fr.current.length&&(wr.current=!0),!K.current&&E.current.fitOnInit!==!1&&(Oe.current=!0),clearTimeout(Ae.current),Ae.current=setTimeout(()=>{K.current=!0,ce(P=>P+1)},m_)},sr=P=>{we();const $=new Map(X.current),F=performance.now(),H=()=>{we(),ue(P),ar()},ie=pe=>{const je=Math.min(1,(pe-F)/ly);if(je>=1)return H();const Te=v_(je),ae=new Map;P.forEach((se,le)=>{const ye=$.get(le);ae.set(le,ye?{x:ye.x+(se.x-ye.x)*Te,y:ye.y+(se.y-ye.y)*Te}:se)}),ue(ae),ge.current=requestAnimationFrame(ie)};ge.current=requestAnimationFrame(ie),Ke.current=setTimeout(H,ly+100)},Ct=()=>{const P=E.current,$=nr.current,F=k.current,H=F.nodes.map(pe=>{const je=V.current.get(pe.id)||mu;return{id:pe.id,parent:pe.parent,width:je.w,height:je.h}});let ie;try{const pe=P.compactPropertyLayout,je=P.edgeMode!=="nodes"&&P.edgeMode!=="workflow",Te=F.edges.map(ae=>({...ae,connectorClearance:pe?je&&(ae.sourceProperty!==void 0||ae.targetProperty!==void 0)?L0:$0:0}));ie=u_(H,Te,{edgeLabelFontSize:P.edgeMode==="nodes"||P.edgeMode==="workflow"?Am:gn,rankDir:P.direction,compact:pe,nodeAlignment:P.nodeAlignment,rankSep:P.rankSep*$,edgeSep:P.edgeSep*$,nodeSep:5*$,spacingFactor:P.spacingFactor??1.3,compactSpacingScale:(P.compactSpacingScale??(P.spacingFactor??1.3)/1.3)*$})}catch(pe){console.warn("[flow-sdk] layout failed",pe);return}for(const[pe,je]of U.current)ie.has(pe)?ie.set(pe,je):P.nodes.some(Te=>Te.id===pe)||U.current.delete(pe);K.current&&!P.isPerformanceMode?sr(ie):(we(),ue(ie),ar())},oe=S.useCallback(()=>{clearTimeout(Ae.current),clearTimeout(de.current),de.current=setTimeout(Ct,E.current.layoutDebounce)},[]);S.useEffect(()=>{const P=new Map(Ye.current.map($=>[$.id,$]));t.some($=>{var F;return((F=P.get($.id))==null?void 0:F.collapsed)===!0&&!$.collapsed})&&(fr.current=t.filter($=>!P.has($.id)).map($=>$.id)),Ye.current=t,er.current!==c&&X.current.size>0&&(K.current=!0,Oe.current=!1,clearTimeout(Ae.current)),er.current=c,$e.current!==Ve&&(Oe.current=!Le.current),$e.current=Ve,oe()},[t,r,A.nodes,A.edges,Ve,n,o,a,u,oe,c,l]),S.useEffect(()=>()=>{clearTimeout(de.current),clearTimeout(Ae.current),we()},[]);const We=S.useCallback((P,$)=>{var F,H;if(!Y.current&&typeof ResizeObserver<"u"&&(Y.current=new ResizeObserver(ie=>{let pe=!1;for(const je of ie){const Te=re.current.get(je.target);if(!Te)continue;const ae=je.target,se=ae.offsetWidth,le=ae.offsetHeight;if(!se&&!le)continue;const ye=V.current.get(Te);ye&&ye.w===se&&ye.h===le||(V.current.set(Te,{w:se,h:le}),pe=!0)}pe&&oe()})),$){W.current.set(P,$),re.current.set($,P),(F=Y.current)==null||F.observe($);const ie=$.offsetWidth,pe=$.offsetHeight;(ie||pe)&&V.current.set(P,{w:ie,h:pe})}else{const ie=W.current.get(P);ie&&((H=Y.current)==null||H.unobserve(ie),re.current.delete(ie)),W.current.delete(P),V.current.delete(P),G.current.has(P)&&D(P,[])}oe()},[oe,D]);S.useEffect(()=>()=>{var P;return(P=Y.current)==null?void 0:P.disconnect()},[]);const Qe=S.useMemo(()=>{const P=new Map;for(const $ of t)$.label&&P.set($.id,$.label);return P},[t]),Be=S.useMemo(()=>l_(A.nodes,ne,V.current,P=>y(P).padding,P=>{const $=Qe.get(P);if(!$)return;const F=y(P);return{w:Sn($,`bold ${F.fontSize}px ${rt}`)+2*b_,h:0}}),[A.nodes,ne,y,Qe]),rr=S.useRef(Be);rr.current=Be;const De=S.useCallback(P=>{const $=rr.current.get(P);if($)return _0($);const F=X.current.get(P);if(!F)return;const H=V.current.get(P)||mu;return{x:F.x,y:F.y,w:H.w,h:H.h}},[]),Q=S.useMemo(()=>{const P=new Map;for(const $ of t){const F=De($.id);F&&P.set($.id,F)}return O0(N,P,he,r,n)},[N,t,ne,Be,he,r,n,De]);G.current=Q;const z=(P,$)=>{var ie;if(!R||$===void 0)return;const F=(ie=Q.get(P))==null?void 0:ie.find(pe=>pe.property===$),H=De(P);return F&&!F.anchor&&H?H.y-H.h/2+F.top+F.height/2:void 0},ee=(P,$)=>{var ie,pe;if($===void 0)return;const F=(pe=(ie=Q.get(P))==null?void 0:ie.find(je=>je.property===$))==null?void 0:pe.anchor,H=De(P);return F&&H?{x:H.x-H.w/2+F.x,y:H.y-H.h/2+F.y,side:F.side}:void 0},Ce=(P,$)=>{const F=De(P),H=he.get(P);return F&&H&&!Be.has(P)&&z(P,$)===void 0?Ft(F,H):F},_e=()=>{const P=[];X.current.forEach(($,F)=>{if(rr.current.has(F))return;const H=V.current.get(F)||mu;P.push(ct({x:$.x,y:$.y,w:H.w,h:H.h}))}),rr.current.forEach($=>P.push($));try{for(const $ of[M.current,I.current]){const F=$==null?void 0:$.getBBox();F&&F.width>0&&F.height>0&&P.push({x1:F.x,y1:F.y,x2:F.x+F.width,y2:F.y+F.height})}}catch{}return Xn(P)},Se=()=>{var F,H;const{pan:P,zoom:$}=O;q.current&&(q.current.style.transform=`translate3d(${P.x}px, ${P.y}px, 0) scale(${$})`),(F=M.current)==null||F.setAttribute("transform",`translate(${P.x} ${P.y}) scale(${$})`),(H=I.current)==null||H.setAttribute("transform",`translate(${P.x} ${P.y}) scale(${$})`)};S.useEffect(()=>{Se();let P=null,$;const F=O.onChange(()=>{Se();const H=j.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout($),$=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),P===null&&(P=requestAnimationFrame(()=>{var ie,pe;P=null,(pe=(ie=E.current).onViewportChange)==null||pe.call(ie,O.state)}))});return()=>{F(),clearTimeout($),P!==null&&cancelAnimationFrame(P)}},[]),S.useLayoutEffect(()=>{const P=j.current;if(!P)return;const $=()=>{let H=P.clientWidth,ie=P.clientHeight;ie||(ie=Math.max(0,window.innerHeight-P.getBoundingClientRect().top-100),ie&&(P.style.height=`${ie}px`)),H||(H=window.innerWidth,H&&(P.style.width=`${H}px`)),O.size={w:H,h:ie}};if($(),typeof ResizeObserver>"u")return;const F=new ResizeObserver($);return F.observe(P),()=>F.disconnect()},[O]),S.useEffect(()=>{if(wr.current){wr.current=!1;const $=fr.current.flatMap(H=>{const ie=De(H);return ie?[ct(ie)]:[]});fr.current=[];const F=Xn($);if(F){Oe.current=!1,O.center(F,E.current.animateViewport);return}}if(!Oe.current)return;Oe.current=!1;const P=_e();P&&O.fit(P,50,E.current.animateViewport)},[ne]);const Ge=S.useMemo(()=>{const P=ae=>Ol(ae,E.current.nodes,E.current.edges),$=(ae,se=50,le=E.current.animateViewport)=>{const ye=Xn([...ae].flatMap(lr=>{const _t=De(lr);return _t?[ct(_t)]:[]}));ye&&(Oe.current=!1,O.fit(ye,Number.isFinite(se)?Math.max(0,se):50,le))},F=(ae,se,le,ye)=>{if(!De(ae))return;const lr=se==="connections"?ie(ae):P(ae);Ze.current||(Ze.current={pan:{...O.pan},zoom:O.zoom}),Fe.current=lr,E.current.compactPropertyLayout&&(Oe.current=!1,Le.current=()=>$(Fe.current??lr,le,ye)),C({id:ae,mode:se}),E.current.compactPropertyLayout||$(lr,le,ye)},H=ae=>{Le.current?Le.current=ae:ae()},ie=ae=>Ll(ae,E.current.nodes,E.current.edges),pe=(ae=>{if(ae===void 0)return O.zoom;O.set(void 0,ae)}),je=(ae=>{if(ae===void 0)return O.pan;O.set(ae)}),Te=(ae,se)=>{var ye;const le=(ye=j.current)==null?void 0:ye.getBoundingClientRect();return{x:ae-((le==null?void 0:le.left)??0),y:se-((le==null?void 0:le.top)??0)}};return{zoom:pe,pan:je,setEdgesVisible:Me,focusNode:(ae,se,le)=>H(()=>$(new Set([ae]),se,le)),focusBranch:(ae,se,le)=>H(()=>$(P(ae),se,le)),focusConnections:(ae,se,le)=>H(()=>$(ie(ae),se,le)),isolateConnections:(ae,se,le)=>F(ae,"connections",se,le),isolateBranch:(ae,se,le)=>F(ae,"branch",se,le),restoreView:(ae=E.current.animateViewport)=>{const se=E.current.compactPropertyLayout&&!!Fe.current;Fe.current=null,C(null);const le=Ze.current;Ze.current=null,se?Le.current=()=>{le&&O.transition(le,ae)}:le&&H(()=>O.transition(le,ae))},zoomAt:(ae,se)=>O.zoomAt(ae,se),fit:(ae=0,se=E.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ae,se)})},centerAndFit:(ae=0,se=E.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ae,se)})},center:(ae=E.current.animateViewport)=>{const se=_e();se&&O.center(se,ae)},clientToModel:(ae,se)=>O.renderedToModel(Te(ae,se)),modelToClient:ae=>{var ye;const se=(ye=j.current)==null?void 0:ye.getBoundingClientRect(),le=O.modelToRendered(ae);return{x:le.x+((se==null?void 0:se.left)??0),y:le.y+((se==null?void 0:se.top)??0)}},getNodeBox:ae=>De(ae),setNodePosition:(ae,se,le)=>{if(!X.current.has(ae)||se&&(!Number.isFinite(se.x)||!Number.isFinite(se.y)))return!1;if(we(),!se)return U.current.delete(ae),oe(),!0;const ye=new Map(X.current);return ye.set(ae,{...se}),(le==null?void 0:le.persist)===!1?U.current.delete(ae):U.current.set(ae,{...se}),X.current=ye,ue(ye),(le==null?void 0:le.persist)===!1&&oe(),!0},onViewportChange:ae=>O.onChange(ae)}},[]);S.useEffect(()=>{var P,$;return($=(P=E.current).onInit)==null||$.call(P,Ge),()=>O.cancelAnimation()},[Ge]),S.useEffect(()=>{var P,$;if(te>0){const F=Le.current;Le.current=null,F==null||F(),($=(P=E.current).onLayoutComplete)==null||$.call(P,Ge)}},[Ge,te]);const ke=S.useRef(null),qe=S.useRef(new Map),ze=S.useRef(!1),[gr,cr]=S.useState(null),[Re,Er]=S.useState(null),Ar=P=>{const $=j.current.getBoundingClientRect();return{x:P.clientX-$.left,y:P.clientY-$.top}},Lr=(P,$)=>{const F=E.current.nodes;for(let H=F.length-1;H>=0;H--){const ie=F[H].id;if(!ut(ie,E.current.edges,E.current.edgeMode)||Fe.current&&!Fe.current.has(ie)||ie===$||rr.current.has(ie))continue;const pe=De(ie);if(pe&&Il(P,ct(pe)))return ie}for(const[H,ie]of rr.current)if(ut(H,E.current.edges,E.current.edgeMode)&&!(Fe.current&&!Fe.current.has(H))&&H!==$&&Il(P,ie))return H;return null},Wn=(P,$)=>{if(E.current.edgeMode==="nodes"||E.current.edgeMode==="workflow")return null;const F=E.current.direction==="RL",H=Math.max(16,6/O.zoom);let ie=null;for(const pe of[...E.current.nodes].reverse()){if(!ut(pe.id,E.current.edges,E.current.edgeMode)||Fe.current&&!Fe.current.has(pe.id))continue;const je=De(pe.id),Te=G.current.get(pe.id);if(!je||!Te||rr.current.has(pe.id))continue;const ae=je.x+($==="source"!==F?1:-1)*je.w/2;for(const se of Te){if(se.role&&se.role!==$)continue;const le=je.y-je.h/2+se.top,ye=Math.hypot(P.x-(se.anchor?je.x-je.w/2+se.anchor.x:ae),P.y-le-se.height/2);if(!se.anchor&&P.x>=je.x-je.w/2&&P.x<=je.x+je.w/2&&P.y>=le&&P.y<=le+se.height)return{nodeId:pe.id,property:se.property};ye<=H&&(!ie||ye<ie.distance)&&(ie={nodeId:pe.id,property:se.property,distance:ye})}}return ie},Vb=P=>{var je;if(!P.currentTarget.contains(P.target)||P.button!==0||E.current.readOnly)return;ke.current||(ze.current=!1);const $=P.target;if($.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const F=E.current,H=Ar(P);if(P.pointerType==="touch"){qe.current.set(P.pointerId,H);const Te=dy(qe.current);if(Te){ke.current={kind:"pinch",distance:Te.distance,zoom:O.zoom,anchor:O.renderedToModel(Te.center)},Er(null),cr(null),ze.current=!0;for(const ae of qe.current.keys())P.currentTarget.setPointerCapture(ae);return}}if(ke.current)return;const ie=F.drawHandles&&$.closest(".flow-sdk-handle"),pe=F.drawHandles&&$.closest(".flow-sdk-property-port");if(F.drawMode||ie||pe){const Te=O.renderedToModel(H),ae=F.drawMode?Wn(Te,"source"):null,se=pe||ie,le=se?(je=se.closest("[data-node-id]"))==null?void 0:je.dataset.nodeId:(ae==null?void 0:ae.nodeId)??Lr(Te),ye=pe?pe.dataset.property:ae==null?void 0:ae.property;if(le){ke.current={kind:"draw",pointerId:P.pointerId,source:le,sourceProperty:ye,reverse:(pe==null?void 0:pe.dataset.portRole)==="target",startClient:{x:P.clientX,y:P.clientY}},ze.current=!0,Er({source:le,sourceProperty:ye,point:Te,target:null}),P.currentTarget.setPointerCapture(P.pointerId);return}}$.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(F.multiSelect?ke.current={kind:"box",pointerId:P.pointerId,start:H,current:H}:F.dragMode?ke.current={kind:"pan",pointerId:P.pointerId,start:H,pan0:O.pan,moved:!1}:ke.current={kind:"tap",pointerId:P.pointerId,start:H,moved:!1},P.currentTarget.setPointerCapture(P.pointerId))},Wb=P=>{const $=ke.current;if(!$||E.current.readOnly)return;const F=Ar(P);if(qe.current.has(P.pointerId)&&qe.current.set(P.pointerId,F),$.kind==="pinch"){const H=dy(qe.current);if(!H)return;const ie=Math.max(O.minZoom,Math.min(O.maxZoom,$.zoom*H.distance/$.distance));O.set({x:H.center.x-$.anchor.x*ie,y:H.center.y-$.anchor.y*ie},ie);return}if($.pointerId===P.pointerId)switch($.kind){case"pan":{const H=F.x-$.start.x,ie=F.y-$.start.y;if(!$.moved&&Math.hypot(H,ie)<=uy)return;$.moved=!0,ze.current=!0,O.set({x:$.pan0.x+H,y:$.pan0.y+ie});break}case"tap":{Math.hypot(F.x-$.start.x,F.y-$.start.y)>uy&&($.moved=!0);break}case"box":{ze.current=!0,$.current=F,cr({x1:Math.min($.start.x,F.x),y1:Math.min($.start.y,F.y),x2:Math.max($.start.x,F.x),y2:Math.max($.start.y,F.y)});break}case"draw":{const H=O.renderedToModel(F),ie=Wn(H,$.reverse?"source":"target");Er($.reverse&&ie?{source:ie.nodeId,sourceProperty:ie.property,point:H,target:$.source,targetProperty:$.sourceProperty}:{source:$.source,sourceProperty:$.sourceProperty,point:H,target:(ie==null?void 0:ie.nodeId)??Lr(H,$.source),targetProperty:ie==null?void 0:ie.property});break}}},al=(P,$)=>{var ie,pe,je,Te,ae;qe.current.delete(P.pointerId);const F=ke.current;if(!F)return;if(F.kind==="pinch"){const se=[...qe.current][0];ke.current=se&&E.current.dragMode&&!$?{kind:"pan",pointerId:se[0],start:se[1],pan0:O.pan,moved:!0}:null;return}if(F.pointerId!==P.pointerId)return;ke.current=null;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}const H=E.current;switch($=$||!!H.readOnly,F.kind){case"pan":case"tap":!$&&!F.moved&&((ie=H.onBackgroundTap)==null||ie.call(H));break;case"box":{if(cr(null),$)break;const se=O.renderedToModel(F.start),le=O.renderedToModel(F.current),ye={x1:Math.min(se.x,le.x),y1:Math.min(se.y,le.y),x2:Math.max(se.x,le.x),y2:Math.max(se.y,le.y)};if(ye.x2-ye.x1<1&&ye.y2-ye.y1<1){(pe=H.onBackgroundTap)==null||pe.call(H);break}const lr=[];for(const _t of H.nodes){const ll=De(_t.id);ll&&S0(ct(ll),ye)&&lr.push(_t.id)}lr.length&&((je=H.onBoxSelect)==null||je.call(H,lr));break}case"draw":{if(Er(null),$)break;const se=Ar(P),le=O.renderedToModel(se),ye=Wn(le,F.reverse?"source":"target"),lr=(ye==null?void 0:ye.nodeId)??Lr(le);if(lr===F.source&&(F.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===F.sourceProperty))break;lr?(Te=H.onEdgeDraw)==null||Te.call(H,F.reverse?lr:F.source,F.reverse?F.source:lr,F.sourceProperty!==void 0||(ye==null?void 0:ye.property)!==void 0?{sourceProperty:F.reverse?ye==null?void 0:ye.property:F.sourceProperty,targetProperty:F.reverse?F.sourceProperty:ye==null?void 0:ye.property}:void 0):Math.max(Math.abs(P.clientX-F.startClient.x),Math.abs(P.clientY-F.startClient.y))>y_&&((ae=H.onDrawIntoSpace)==null||ae.call(H,F.source,le,F.sourceProperty,F.reverse));break}}},Kr=S.useCallback(()=>{var F;const P=ke.current,$=[...qe.current.keys()];P&&P.kind!=="pinch"&&$.push(P.pointerId),ke.current=null,qe.current.clear(),Er(null),cr(null);for(const H of $)(F=j.current)!=null&&F.hasPointerCapture(H)&&j.current.releasePointerCapture(H)},[]);S.useEffect(()=>{const P=$=>{$.key==="Escape"&&Kr()};return window.addEventListener("keydown",P),window.addEventListener("blur",Kr),()=>{window.removeEventListener("keydown",P),window.removeEventListener("blur",Kr),ke.current=null,qe.current.clear()}},[Kr]),S.useEffect(()=>{Kr()},[b,x,m,i,n,e.drawHandles,e.readOnly,Kr]);const Gb=S.useMemo(()=>{const P=new Map,$=new Map;for(const F of T){if(F.source!==F.target)continue;const H=P.get(F.source)??0;P.set(F.source,H+1),$.set(F.id,H)}return $},[T]),Gn=g_[n],[Un,Ub]=S.useState(null),Hn=W0(t,T,!!((ul=e.edgeReveal)!=null&&ul.revealNodes));S.useLayoutEffect(()=>{j.current&&Un&&G0(j.current)});const Kn=C0(T,Ce,Gn),Hb=e.onEdgeSelect,Kb=e.onContainerSelect,sl=Re?Re.target&&Ce(Re.target,Re.targetProperty)||{x:Re.point.x,y:Re.point.y,w:1,h:1}:null,cl=Re?Ce(Re.source,Re.sourceProperty):null,Jb=["flow-sdk-canvas",b?"flow-sdk-draw":"",w?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:j,className:Jb,"data-edge-mode":i,onPointerDownCapture:Vb,onPointerMove:Wb,onPointerUp:P=>al(P,!1),onPointerCancel:P=>al(P,!0),onLostPointerCapture:P=>{const $=ke.current;$&&($.kind==="pinch"||$.pointerId===P.pointerId)&&Kr()},onClickCapture:P=>{P.currentTarget.contains(P.target)&&(ze.current||e.readOnly)&&(P.preventDefault(),P.stopPropagation())},children:[h.jsx("svg",{className:"flow-sdk-svg",children:h.jsxs("g",{ref:M,children:[h.jsx("g",{className:"flow-sdk-containers",children:[...Be].filter(([P])=>ut(P,r,i)).filter(([P])=>!_||_.has(P)).map(([P,$])=>{var F;return h.jsx(N0,{id:P,rect:$,label:Qe.get(P),labelLayer:Un,style:y(P),onSelect:Kb,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(F=e.selectedNodeIds)==null?void 0:F.includes(P)},P)})}),h.jsx("g",{className:"flow-sdk-edges",children:xe&&T.map(P=>{var H,ie,pe;if(!Hn.ready.has(P.id)||_&&(!_.has(P.source)||!_.has(P.target)))return null;const $=Ce(P.source,P.sourceProperty),F=Ce(P.target,P.targetProperty);return!$||!F?null:h.jsx(Fl,{id:P.id,edgeData:P.data,validationIssue:P.validationIssue,edgeType:P.type,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Hn.complete,source:$,target:F,sourceProperty:P.sourceProperty,targetProperty:P.targetProperty,sourceY:z(P.source,P.sourceProperty),targetY:z(P.target,P.targetProperty),sourcePort:ee(P.source,P.sourceProperty),targetPort:ee(P.target,P.targetProperty),dir:Gn,turn:((H=Kn.get(P.id))==null?void 0:H.turn)??P.turn,labelAtTarget:(ie=Kn.get(P.id))==null?void 0:ie.labelAtTarget,labelFraction:(pe=Kn.get(P.id))==null?void 0:pe.labelFraction,color:P.color,labelBg:P.labelBg,label:P.label,labelLayer:Un,dashed:P.dashed,animated:P.animated&&!w,inverted:P.inverted,loopIndex:Gb.get(P.id)??0,onSelect:Hb},P.id)})}),xe&&Re&&_u(Re,i)&&cl&&sl&&h.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:h.jsx(Fl,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Re.source,target:Re.target??"",sourceProperty:Re.sourceProperty,targetProperty:Re.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,source:cl,target:sl,sourceProperty:Re.sourceProperty,targetProperty:Re.targetProperty,sourceY:z(Re.source,Re.sourceProperty),sourcePort:ee(Re.source,Re.sourceProperty),targetPort:Re.target?ee(Re.target,Re.targetProperty):void 0,targetY:Re.target?z(Re.target,Re.targetProperty):void 0,dir:Gn,turn:.5,color:g,labelBg:g})})]})}),h.jsx("div",{ref:q,className:"flow-sdk-nodes",children:t.map(P=>{var pe,je;const $=ne.get(P.id),F=Be.get(P.id),H=($==null?void 0:$.x)??(F?(F.x1+F.x2)/2:0),ie=($==null?void 0:$.y)??(F?(F.y1+F.y2)/2:0);return h.jsx(h_,{id:P.id,x:H,y:ie,placed:!!$||!!F,hidden:!Hn.shown.has(P.id)||!ut(P.id,r,i)||!!_&&!_.has(P.id),onMount:We,drawHandles:e.drawHandles&&!e.readOnly,drawMode:b,connectedPorts:new Set(T.flatMap(Te=>[...Te.source===P.id&&Te.sourceProperty!==void 0?[`source:${Te.sourceProperty}`]:[],...Te.target===P.id&&Te.targetProperty!==void 0?[`target:${Te.targetProperty}`]:[]])),hasCollapseControl:P.hasCollapseControl,handleColor:g,animated:P.animated&&!F&&!w,animationColor:P.animationColor,animationWidth:P.animationWidth,animationVariant:P.animationVariant,width:(pe=V.current.get(P.id))==null?void 0:pe.w,height:(je=V.current.get(P.id))==null?void 0:je.h,propertyMode:R,resolvedRows:Q.get(P.id),reversePorts:n==="RL",direction:n,onPropertyRows:D,onSurface:J,children:P.element},P.id)})}),gr&&h.jsx("div",{className:"flow-sdk-box",style:{left:gr.x1,top:gr.y1,width:gr.x2-gr.x1,height:gr.y2-gr.y1}}),h.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:h.jsx("g",{ref:I,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:h.jsx("g",{ref:Ub,className:"flow-sdk-labels",style:{pointerEvents:b?"none":"visiblePainted",outline:"none"}})})})]})}const w_=S.memo(x_);function Mb({id:e,label:t,role:r,side:n,position:o=.5,placement:i,children:s,style:a}){return h.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"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:r==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??t??e})}const C_=mn.default.dialog`
156
+ `;function Al({request:e,property:t,config:r,value:n,disabled:o}){var L,G;const{callbacks:i,structured:s,references:a}=S.useContext(Rr),{themeColor:u}=Ie(),{background:c}=He(),l=S.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",f=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,y]=S.useState(f),[g,b]=S.useState(""),[x,m]=S.useState(0),[w,v]=S.useState(),C=((L=r.$options)==null?void 0:L.$source)==="callback",_=i.resolveFormOptions,{data:R,address:T,nodeAddress:A,nodeId:k}=e,E=S.useRef(R);E.current=R;const j=JSON.stringify([T,k,(G=r.$options)!=null&&G.$dependsOn?r.$options.$dependsOn.map(D=>ve(R,D)):ve(R,A)]);S.useEffect(()=>{y(f),b("")},[f,T,k]),S.useEffect(()=>{if(!C)return;const D=new AbortController;return Promise.resolve().then(()=>{if(!_)throw new Error("No options resolver configured");return _({address:T,nodeAddress:A,nodeId:k,data:Ut(E.current),signal:D.signal})}).then(ne=>{if(!Array.isArray(ne)||ne.some(ue=>!ue||typeof ue.label!="string"||!["string","number","boolean"].includes(typeof ue.value)&&ue.value!==null))throw new Error("Invalid options response");D.signal.aborted||v({key:j,options:ne})}).catch(ne=>{D.signal.aborted||v({key:j,options:[],error:ne instanceof Error?ne.message:"Options unavailable"})}),()=>D.abort()},[C,_,j,T,A,k,x]);const M=C&&(w==null?void 0:w.key)!==j,I=C?(w==null?void 0:w.key)===j?w.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Lt(t.type),q=t.type.kind==="array",O=(s&&d||r.$control==="checkbox"?"pills":r.$control)??(I?q||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),V=!t.optional||!!r.$requiredWhen&&Cn(r.$requiredWhen,R),W=!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),re=g||C&&(w==null?void 0:w.key)===j&&w.error||!W&&kr(t.type,n,V),Y=Cr(r.$label??T.split(".").pop()),he=D=>{var ne;if(!(o||Object.is(D,n)))try{(ne=i.onFormChange)==null||ne.call(i,{...e,previousValue:n,value:D}),b("")}catch(ue){b(ue instanceof Error?ue.message:"Unable to update field")}},me=()=>{if(d){try{const X=p===""&&t.optional?void 0:JSON.parse(p),U=kr(t.type,X,V);if(U){b(U);return}he(X)}catch{b("Enter valid JSON")}return}const D=t.type.kind==="number"||t.type.kind==="integer",ne=p===""&&t.optional?void 0:D&&p!==""?Number(p):p,ue=kr(t.type,ne,V);if(D&&ue&&p!==""){b(ue);return}he(ne)},J={id:l,disabled:o,"aria-label":Y,"aria-required":V,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},N=fe(u);return h.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(A.length+1),children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsxs("label",{htmlFor:l,children:[Y,V?" *":""]}),t.optional&&n!==void 0&&h.jsx("button",{type:"button","aria-label":`Reset ${Y}`,title:`Reset ${Y}`,disabled:o,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>he(void 0),children:h.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!d&&h.jsx(n0,{label:Y,value:n,references:a,disabled:o,onChange:he}),W?null:O==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...J,disabled:o||M||!!(w!=null&&w.error),value:(I==null?void 0:I.findIndex(D=>Object.is(D.value,n)))??-1,onChange:D=>{const ne=I==null?void 0:I[Number(D.target.value)];ne&&he(ne.value)},children:[h.jsx("option",{value:-1,disabled:!0,children:n!==void 0?String(n):""}),I==null?void 0:I.map((D,ne)=>h.jsx("option",{value:ne,style:{background:fe(c)},children:Cr(D.label)||D.label},ne))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}):O==="pills"?h.jsxs("div",{id:l,role:"group","aria-label":Y,"aria-describedby":J["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[I==null?void 0:I.map((D,ne)=>{const ue=q?Array.isArray(n)&&n.includes(D.value):Object.is(n,D.value);return h.jsx("button",{type:"button",disabled:o||M,"aria-pressed":ue,style:{padding:"8px 16px",borderRadius:24,border:0,color:ue?N:"inherit",background:ue?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>he(q?ue?n.filter(X=>X!==D.value):[...Array.isArray(n)?n:[],D.value]:D.value),children:Cr(D.label)||D.label},ne)}),M&&h.jsx("span",{role:"status",children:"Loading..."})]}):O==="textarea"?h.jsx("textarea",{...J,value:p,onChange:D=>y(D.target.value),onBlur:me}):h.jsx("input",{...J,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:D=>y(D.target.value),onBlur:me,onKeyDown:D=>{D.key==="Enter"&&me(),D.key==="Escape"&&y(n===void 0?"":String(n))}}),re&&h.jsx("div",{role:"alert",id:`${l}-error`,children:re}),C&&(w==null?void 0:w.error)&&h.jsx("button",{type:"button",disabled:o,onClick:()=>{v(void 0),m(x+1)},children:"Retry"})]})}function am({nodeAddress:e}){var v,C;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:s,structured:a}=S.useContext(Rr),{readOnly:u,config:c}=Ie(),l=s==null?void 0:s(e);if(l!==void 0)return h.jsx("fieldset",{"data-flow-form":e,disabled:u||c.editable===!1||!i,style:{border:0,margin:0,padding:0,minWidth:0},children:l});if(!t)return h.jsx(sn,{role:"alert",children:"Forms require a JSON document."});const d=o?Qt(o,e,r):void 0,f=o?d:r&&yt(t,e,r);if(!f)return h.jsx(sn,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,y=ve(t,p),g=(v=a==null?void 0:a.containers.get(e))==null?void 0:v.scalar;if(y===void 0||typeof y!="object"&&!g)return h.jsx(sn,{role:"alert",children:"Bound form state is unavailable."});const b=Object.entries(f.type.properties).filter(([_])=>{var R;return Cn((R=f.fields[_])==null?void 0:R.$visibleWhen,t)}),x=b.length>8||b.some(([_])=>{var R;return(R=f.fields[_])==null?void 0:R.$section}),m=new Map;for(const _ of b){const[R,T]=_,A=x?Cr(((C=f.fields[R])==null?void 0:C.$section)??(T.type.kind==="object"||T.type.kind==="array"?R:T.optional?"Options":"General")):"";m.has(A)||m.set(A,[]),m.get(A).push(_)}const w=([_,R])=>h.jsx(Al,{request:{data:t,address:g?p:`${p}.${_}`,nodeAddress:p,nodeId:typeof(y==null?void 0:y.id)=="string"?y.id:void 0},property:R,config:f.fields[_]??{},value:g?y:y==null?void 0:y[_],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(y==null?void 0:y.id)??e}:${_}`);return h.jsxs(sn,{"data-flow-form":e,onClick:_=>_.stopPropagation(),onDoubleClick:_=>_.stopPropagation(),children:[a&&h.jsx(c0,{nodeAddress:e}),d&&f.type.additionalProperties&&b.length===0&&h.jsx(Al,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:y,disabled:u||c.editable===!1||!i}),[...m].map(([_,R])=>x&&R.length>1?h.jsxs("details",{open:!0,children:[h.jsxs("summary",{children:[h.jsx("span",{children:_}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),R.map(w)]},_):R.map(w))]})}function sm(e){const{viewData:t}=S.useContext(Rr),{nodeById:r,edgeById:n,parentIds:o}=Ur();if(t){const i=ve(t,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,u])=>!a.startsWith("$")&&u!==null&&typeof u=="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&&r.has(a)})}function Jt(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function pn(e,t,r,n){return{borderColor:t,borderWidth:Jt(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...my(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function cm({label:e,value:t,options:r,onChange:n,disabled:o}){var i;return h.jsxs(Ir,{"aria-label":e,title:`Animation: ${((i=r.find(s=>s.value===t))==null?void 0:i.label)??"Mixed"}`,value:t,style:{width:104},disabled:o,onValueChange:s=>{const a=r.find(u=>u.value===s);a&&n(a.value)},children:[t===""&&h.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(s=>h.jsx("option",{value:s.value,children:s.label},s.value))]})}const gn="data:image/svg+xml;base64,";function At(e){if(e.startsWith(gn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function u0(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const t=await e.text(),r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.doctype||r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(r.querySelector("script, foreignObject")||[...r.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(t);let o="";for(const i of n)o+=String.fromCharCode(i);return gn+btoa(o)}const qr=({name:e,svg:t=!1,...r})=>{const[n,o]=S.useState(null),[i,s]=S.useState(!0),[a,u]=S.useState(!1),c=typeof e=="string"&&At(e);if(S.useEffect(()=>{if(c||!e||e.length<2){o(null),s(!1);return}s(!0),u(!1),(async()=>{try{let d;if(e.startsWith("Md"))d="md";else if(e.startsWith("Fa"))d="fa6";else if(e.startsWith("Io5"))d="io5";else if(e.startsWith("Io"))d="io";else if(e.startsWith("Ti"))d="ti";else if(e.startsWith("Go"))d="go";else if(e.startsWith("Fi"))d="fi";else if(e.startsWith("Di"))d="di";else if(e.startsWith("Ai"))d="ai";else if(e.startsWith("Bs"))d="bs";else if(e.startsWith("Ri"))d="ri";else if(e.startsWith("Fc"))d="fc";else if(e.startsWith("Gi"))d="gi";else if(e.startsWith("Hi2"))d="hi2";else if(e.startsWith("Hi"))d="hi";else if(e.startsWith("Si"))d="si";else if(e.startsWith("Sl"))d="sl";else if(e.startsWith("Im"))d="im";else if(e.startsWith("Bi"))d="bi";else if(e.startsWith("Pi"))d="pi";else if(e.startsWith("Vsc"))d="vsc";else if(e.startsWith("Tb"))d="tb";else if(e.startsWith("Tfi"))d="tfi";else if(e.startsWith("Cg"))d="cg";else if(e.startsWith("Lia"))d="lia";else if(e.startsWith("Lu"))d="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let f;switch(d){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=f[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);o(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),u(!0),o(null)}finally{s(!1)}})()},[e,c]),c){const{size:l=80,style:d,...f}=r;return t?h.jsx("image",{...f,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):h.jsx("img",{...f,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return i||!n?null:h.jsx(n,{...r})};function Lu({nodeId:e,edgeId:t,value:r}){const{callbacks:n,readOnly:o,themeColor:i}=Ie(),{background:s,backgroundSecondary:a,border:u,colorText:c}=He(),l=S.useRef(null),d=S.useId(),f=S.useRef(null),p=S.useRef(0),[y,g]=S.useState(!1),[b,x]=S.useState("icons"),[m,w]=S.useState([]),[v,C]=S.useState("loading"),[_,R]=S.useState(""),[T,A]=S.useState(0),[k,E]=S.useState(""),[j,M]=S.useState(""),[I,q]=S.useState(!1);S.useEffect(()=>()=>{p.current++},[]),S.useEffect(()=>{if(!y)return;let J=!0;return import("react-icons/pi").then(N=>{J&&(w(Object.keys(N).filter(L=>L.startsWith("Pi")).sort()),C("ready"))}).catch(()=>{J&&C("unavailable")}),()=>{J=!1}},[y]),S.useEffect(()=>{var J;o&&((J=l.current)==null||J.close())},[o]);const O=J=>{var N,L,G;o||(t?(N=n.onEdgeIconChange)==null||N.call(n,t,J):e&&((L=n.onNodeIconChange)==null||L.call(n,e,J)),(G=l.current)==null||G.close())},V=m.filter(J=>J.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(_.trim().toLowerCase())),W=36,re=Math.max(1,Math.ceil(V.length/W)),Y=Math.min(T,re-1),he=V.slice(Y*W,(Y+1)*W),me={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${fe(u)}`,borderRadius:30};return h.jsxs(h.Fragment,{children:[h.jsx(Ee,{label:t?"Choose edge icon":"Choose node icon",children:h.jsx(be,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:h.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:fe(i),disabled:o,onClick:()=>{var J;M(""),x(r&&At(r)?"custom":"icons"),E(r&&!r.startsWith(gn)&&At(r)?r:""),g(!0),(J=l.current)==null||J.showModal()}})}),h.jsx(B.chakra.dialog,{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",css:zr(fe(s),fe(u)),onClose:()=>{g(!1),p.current++,q(!1)},onClick:J=>{J.stopPropagation(),J.target===J.currentTarget&&J.currentTarget.close()},onKeyDown:J=>J.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:fe(s),color:fe(c)},children:y&&h.jsxs("div",{style:{display:"grid",gap:8},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsx("strong",{children:t?"Edge icon":"Node icon"}),h.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&h.jsx(Ee,{label:"Remove icon",children:h.jsx(be,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:o||I,onClick:()=>O("")})}),h.jsx(gt,{"aria-label":"Close icon picker",onClick:()=>{var J;return(J=l.current)==null?void 0:J.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${fe(u)}`},children:["icons","custom"].map(J=>h.jsx("button",{id:`${d}-${J}`,type:"button",role:"tab","aria-selected":b===J,"aria-controls":`${d}-panel`,tabIndex:b===J?0:-1,onClick:()=>{x(J),M("")},onKeyDown:N=>{var G;if(!["ArrowLeft","ArrowRight","Home","End"].includes(N.key))return;N.preventDefault();const L=N.key==="Home"?"icons":N.key==="End"||J==="icons"?"custom":"icons";x(L),M(""),(G=document.getElementById(`${d}-${L}`))==null||G.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${b===J?fe(i):"transparent"}`,color:b===J?fe(i):"inherit",cursor:"pointer",fontSize:13},children:J==="icons"?"React icons":"Custom SVG"},J))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:I||o,onChange:async J=>{var G;const N=(G=J.target.files)==null?void 0:G[0];if(J.target.value="",!N)return;const L=++p.current;q(!0),M("");try{const D=await u0(N);L===p.current&&O(D)}catch(D){L===p.current&&M(D instanceof Error?D.message:"Unable to read SVG.")}finally{L===p.current&&q(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${b}`,style:{display:"grid",gap:8},children:b==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:_,onChange:J=>{R(J.target.value),A(0)},style:me}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[he.map(J=>h.jsx("button",{type:"button","aria-label":`Choose ${J}`,"aria-pressed":r===J,title:J,onClick:()=>O(J),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===J?2:1}px solid ${fe(r===J?i:u)}`,background:fe(r===J?s:a),color:"inherit",cursor:"pointer"},children:h.jsx(qr,{name:J,size:24})},J)),he.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:v==="loading"?"Loading icons...":v==="unavailable"?"React icons unavailable":"No icons found"})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsxs("span",{role:"status",style:{fontSize:12},children:[V.length," icons · ",Y+1," / ",re]}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx(Ee,{label:"Previous icons",children:h.jsx(be,{"aria-label":"Previous icons",icon:h.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:Y===0,onClick:()=>A(Y-1)})}),h.jsx(Ee,{label:"Next icons",children:h.jsx(be,{"aria-label":"Next icons",icon:h.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:Y+1>=re,onClick:()=>A(Y+1)})})]})]})]}):h.jsxs(h.Fragment,{children:[r&&At(r)&&h.jsx(qr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:I||o,onClick:()=>{var J;return(J=f.current)==null?void 0:J.click()},style:{...me,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[h.jsx(Z.PiUploadSimple,{}),I?"Uploading...":"Upload SVG"]}),h.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:J=>{J.preventDefault(),!(I||o)&&(!At(k.trim())||k.trim().startsWith(gn)?M("Enter an HTTP or HTTPS image URL."):O(k.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:k,disabled:I||o,onChange:J=>E(J.target.value),style:{...me,flex:1,minWidth:0}}),h.jsx(Ee,{label:"Apply URL",children:h.jsx(be,{type:"submit","aria-label":"Apply URL",icon:h.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:I||o||!k.trim(),style:{flexShrink:0}})})]})]})}),j&&h.jsx("div",{role:"alert",style:{fontSize:13},children:j})]})})]})}const Fu=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],um=["gray.900","gray.600","gray.200","white"];function lm(){const{config:e}=Ie(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Fu,show:n=>!r.has(n)}}function dr(){const{border:e}=He();return h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function et({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:s}){const{colorText:a}=He(),[u,c]=S.useState(e),l=S.useRef(!1);S.useEffect(()=>c(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const f=u.trim();if(o==="number"&&f!==""&&(!Number.isFinite(Number(f))||Number(f)<(i??0))){c(e);return}f!==e&&s(f)};return h.jsx(B.Input,{"aria-label":r,type:o,min:i,size:"xs",w:n,value:u,placeholder:t,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&(d(),f.target.blur()),f.key==="Escape"&&(l.current=!0,c(e),f.target.blur())}})}function Zt({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=He(),[u,c]=S.useState(!1),l=S.useId(),d=S.useRef(null),f=t??e[0]??"transparent";return h.jsxs(B.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var y;p.key==="Escape"&&(c(!1),(y=d.current)==null||y.focus())},children:[h.jsx(Ee,{label:`${r}: ${f}`,children:h.jsx(B.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":u,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${fe(a)}`,outlineOffset:"1px",onClick:()=>c(p=>!p)})}),u&&h.jsxs(B.HStack,{id:l,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(p=>{const y=t===p;return h.jsx(Ee,{label:`${r}: ${p}`,children:h.jsx(B.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":y,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:y?`2px solid ${fe(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(p),onDoubleClick:g=>{var b;g.stopPropagation(),c(!1),(b=d.current)==null||b.focus()}})},p)}),o&&h.jsx(Ee,{label:`Reset ${r.toLowerCase()}`,children:h.jsx(be,{"aria-label":`Reset ${r}`,icon:h.jsx(B.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var p;o(),c(!1),(p=d.current)==null||p.focus()}})})]})]})}function dm({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Ie(),{colorInactive:i}=He(),{edgeById:s}=Ur(),{palette:a,show:u}=lm(),c=(p=s.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],d=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(et,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:y=>{var g;return(g=r.onEdgeLabelChange)==null?void 0:g.call(r,e,y)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f.map(y=>h.jsx(Ee,{label:y.label,children:h.jsx(be,{"aria-label":`Edge style ${y.key}`,"aria-pressed":d===y.key,icon:h.jsx(B.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===y.key?n:i,onClick:()=>{var g;return(g=r.onEdgeStyleChange)==null?void 0:g.call(r,e,y.key)}})},y.key)),d==="animated"&&h.jsx(cm,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:y=>{var g;return(g=r.onEdgeAnimationVariantChange)==null?void 0:g.call(r,e,y)}}),h.jsxs(Ir,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:o.readOnly,onValueChange:y=>{var g;return(g=r.onEdgeTypeChange)==null?void 0:g.call(r,e,y||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(y=>h.jsx("option",{value:y,children:y},y))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Lu,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(et,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:y=>{var g;return(g=r.onEdgeIconChange)==null?void 0:g.call(r,e,y)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Zt,{label:"Edge color",colors:a,value:c==null?void 0:c.color,onPick:y=>{var g;return(g=r.onEdgeColorChange)==null?void 0:g.call(r,e,y)},onReset:()=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:"Delete edge",children:h.jsx(be,{"aria-label":"Delete edge",icon:h.jsx(B.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=r.onEdgeDelete)==null||y.call(r,e,c),t()}})})]})]})}function fm({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Ie(),{colorInactive:o}=He(),{nodeById:i}=Ur(),[s,a]=S.useState(!1),u=e.map(y=>{var g,b;return(b=(g=i.get(y))==null?void 0:g.data.viewProps)==null?void 0:b.borderRadius}),c=!u.every(y=>y===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=s||!c&&l!==""&&!d.includes(l),p=y=>e.forEach(g=>{var b;return(b=r.onNodeBorderRadiusChange)==null?void 0:b.call(r,g,y)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(dr,{}),h.jsx(B.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Ir,{icon:h.jsx(B.Icon,{as:ov.TbBorderRadius,boxSize:5,color:o,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${c?"Mixed":u[0]===void 0?"Default":`${u[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:f?"custom":l,disabled:n.readOnly,onValueChange:y=>{a(y==="custom"),y!=="custom"&&p(y===""?void 0:Number(y))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(y=>h.jsxs("option",{value:y,children:[y,"px radius"]},y)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(et,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:y=>p(y===""?void 0:Number(y))})]})}function hm({ids:e,onClose:t}){var J,N,L,G,D,ne,ue,X;const{callbacks:r,colorMode:n,themeColor:o,config:i,setNodeViewMode:s}=Ie(),{colorText:a,colorInactive:u}=He(),{nodeById:c,parentIds:l}=Ur(),{palette:d,show:f}=lm(),p=e.length===1,y=p?(J=c.get(e[0]))==null?void 0:J.data:void 0,g=e.map(U=>{var K,te;return((te=(K=c.get(U))==null?void 0:K.data.config)==null?void 0:te.typeView)??""}),b=g.some(U=>U!==g[0]),x=b?"mixed":g[0]??"",m=e.some(U=>{var te,ce;const K=(te=c.get(U))==null?void 0:te.data;return K&&(l.has(U)||((ce=K.config)==null?void 0:ce.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},K.type))}),w=(N=y==null?void 0:y.config)==null?void 0:N.collapsed,v=sm(e[0]),C=U=>{var K,te,ce;return(((te=(K=c.get(U))==null?void 0:K.data.viewProps)==null?void 0:te.outline)??(l.has(U)?(ce=i.parentNodeStyle)==null?void 0:ce.outline:!1))===!0},_=e.every(C),R=!_&&e.some(C),T=U=>{var K;return((K=c.get(U))==null?void 0:K.data.isNodeAnimated)===!0},A=e.every(T),k=!A&&e.some(T),E=e.map(U=>{var K;return((K=c.get(U))==null?void 0:K.data.nodeAnimationVariant)??"traveling"}),j=E.every(U=>U===E[0])?E[0]:"",M=U=>e.forEach(U),[I,q]=S.useState(!1),O=I&&f("color")&&f("borderColor"),V=U=>{var K,te,ce;return(((te=(K=c.get(U))==null?void 0:K.data.viewProps)==null?void 0:te.borderStyle)??(l.has(U)?(ce=i.parentNodeStyle)==null?void 0:ce.borderStyle:"solid"))==="dashed"},W=e.every(V),re=!W&&e.some(V),Y=e.map(U=>{var ce,de,Ae;const K=(ce=c.get(U))==null?void 0:ce.data,te=l.has(U)?Jt((de=i.parentNodeStyle)==null?void 0:de.borderWidth,6):(K==null?void 0:K.type)==="objectView"?3:2;return Jt((Ae=K==null?void 0:K.viewProps)==null?void 0:Ae.borderWidth,te)}),he=Y.every(U=>U===Y[0])?String(Y[0]??""):"",me=U=>M(K=>{var te,ce;O?(te=r.onNodeBorderColorChange)==null||te.call(r,K,U):(ce=r.onNodeColorChange)==null||ce.call(r,K,"bg",U)});return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),h.jsx(dr,{}),p&&f("label")?h.jsx(et,{ariaLabel:"Node label",placeholder:"Node label",value:(y==null?void 0:y.label)??(y==null?void 0:y.headerTitle)??"",onCommit:U=>{var K;return(K=r.onNodeLabelChange)==null?void 0:K.call(r,e[0],U)}}):h.jsxs(B.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),f("typeView")&&h.jsxs(Ir,{"aria-label":"Type view",title:m?"Type view is managed by the custom renderer or container":`Type view: ${x||"None (default)"}`,icon:h.jsx(Z.PiImage,{size:20}),style:{width:36},value:x,disabled:i.readOnly||i.editable===!1||m,onValueChange:U=>{zt.includes(U)&&M(K=>{var te,ce;(te=r.onNodeTypeViewChange)==null||te.call(r,K,U||void 0),s(K,"default"),(ce=r.onNodeViewToggle)==null||ce.call(r,K)})},children:[b&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),zt.map(U=>h.jsx("option",{value:U,children:U||"None"},U))]}),f("style")&&h.jsx(fm,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:_?"Restore node fill":"Remove node fill",children:h.jsx(be,{"aria-label":"Toggle node outline","aria-pressed":R?"mixed":_,icon:h.jsx(B.Icon,{as:_?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:_?o:u,onClick:()=>M(U=>{var K;return(K=r.onNodeOutlineChange)==null?void 0:K.call(r,U,!_)})})})]}),f("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f("borderColor")&&h.jsx(Ee,{label:O?"Edit node colors":"Edit node border",children:h.jsx(be,{"aria-label":"Edit node border","aria-pressed":O,icon:h.jsx(B.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:O?o:u,bg:O?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>q(U=>!U)})}),h.jsx(Zt,{label:O?"Border color":"Background",colors:d,value:O?((L=y==null?void 0:y.viewProps)==null?void 0:L.borderColor)??(p&&l.has(e[0])?(G=i.parentNodeStyle)==null?void 0:G.borderColor:void 0):(D=y==null?void 0:y.viewProps)==null?void 0:D.bgColor,onPick:me,onReset:()=>me("")}),O&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:W?"Solid border":"Dashed border",children:h.jsx(be,{"aria-label":"Toggle dashed border","aria-pressed":re?"mixed":W,icon:h.jsx(B.Icon,{as:W?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:W?o:u,onClick:()=>M(U=>{var K;return(K=r.onNodeBorderStyleChange)==null?void 0:K.call(r,U,W?"solid":"dashed")})})}),h.jsx(et,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:he,onCommit:U=>M(K=>{var te;return(te=r.onNodeBorderWidthChange)==null?void 0:te.call(r,K,U===""?void 0:Number(U))})})]})]}),f("animation")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:A?"Stop border animation":"Animate node border",children:h.jsx(be,{"aria-label":"Toggle node animation","aria-pressed":k?"mixed":A,icon:h.jsx(B.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:A?o:u,onClick:()=>M(U=>{var K;return(K=r.onNodeAnimationChange)==null?void 0:K.call(r,U,!A)})})}),(A||k)&&h.jsx(cm,{label:"Node animation",value:j,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:i.readOnly,onChange:U=>M(K=>{var te;return(te=r.onNodeAnimationVariantChange)==null?void 0:te.call(r,K,U)})})]}),!O&&f("textColor")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Zt,{label:"Text color",colors:um,value:(ne=y==null?void 0:y.viewProps)==null?void 0:ne.textColor,onPick:U=>M(K=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,K,"text",U)}),onReset:()=>M(U=>{var K;return(K=r.onNodeColorChange)==null?void 0:K.call(r,U,"text","")})})]}),p&&f("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Lu,{nodeId:e[0],value:(ue=y==null?void 0:y.config)==null?void 0:ue.icon},e[0]),h.jsx(et,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((X=y==null?void 0:y.config)==null?void 0:X.icon)||"",onCommit:U=>{var K;return(K=r.onNodeIconChange)==null?void 0:K.call(r,e[0],U)}})]}),p&&v&&f("collapse")&&w!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:w?"Expand":"Collapse",children:h.jsx(be,{"aria-label":w?"Expand node":"Collapse node",icon:h.jsx(B.Icon,{as:w?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:u,onClick:()=>{var U;return(U=r.onNodeCollapse)==null?void 0:U.call(r,e[0],!w)}})})]}),f("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Ee,{label:p?"Delete node":`Delete ${e.length} nodes`,children:h.jsx(be,{"aria-label":"Delete selected nodes",icon:h.jsx(B.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{M(U=>{var K,te;return(te=r.onNodeDelete)==null?void 0:te.call(r,U,((K=c.get(U))==null?void 0:K.data)||{id:U})}),t()}})})]})]})}async function pm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:o=>!(o instanceof Element)||!o.matches("button, [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(r.slice(r.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()),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function gm(e,t="squeed.svg"){const r=document.createElement("a");r.href=await pm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function ym(){const{themeColor:e}=Ie(),[t,r]=S.useState(!1),[n,o]=S.useState("");return h.jsxs(h.Fragment,{children:[h.jsx(Ee,{label:"Download SVG (current view)",children:h.jsx(be,{"aria-label":"Download SVG",icon:h.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:t,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}r(!0),o("");try{await gm(s)}catch(u){o(u instanceof Error?u.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&h.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function mm({children:e,background:t,border:r}){const n=S.useRef(null),[o,i]=S.useState({left:!1,right:!1});S.useLayoutEffect(()=>{const a=n.current,u=()=>{const l=a.scrollLeft>1,d=a.scrollWidth-a.clientWidth-a.scrollLeft>1;i(f=>f.left===l&&f.right===d?f:{left:l,right:d})},c=new ResizeObserver(u);return c.observe(a),a.firstElementChild&&c.observe(a.firstElementChild),a.addEventListener("scroll",u,{passive:!0}),u(),()=>{c.disconnect(),a.removeEventListener("scroll",u)}},[]);const s=`var(--chakra-colors-${t.replace(".","-")})`;return h.jsxs(B.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:zr(s,`var(--chakra-colors-${r.replace(".","-")})`),children:[h.jsx(B.Box,{ref:n,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(a=>h.jsx(B.Box,{"data-flow-toolbar-fade":a,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:a==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[a]:0,opacity:o[a]?1:0,background:`linear-gradient(to ${a==="left"?"right":"left"}, ${s}, transparent)`}},a))]})}async function l0(e,t){const r=new Set,n=[],o=(a,u)=>{var l,d,f;if(!a||typeof a!="object")return;const c=a;n.push(u),typeof((l=c.$form)==null?void 0:l.$type)=="string"&&r.add(c.$form.$type),typeof((f=(d=c.$form)==null?void 0:d.$create)==null?void 0:f.$type)=="string"&&r.add(c.$form.$create.$type);for(const[p,y]of Object.entries(c))p==="$"?o(y,u):p.startsWith("$")||o(y,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await nm(e)};const i=await $u(e,[...r]);for(const a of r)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const u=yt(t,a,i);u&&(s[a]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function bm({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=He();return!e||typeof document>"u"?null:Dt.createPortal(h.jsxs(B.chakra.div,{role:"alert","aria-atomic":"true",css:zr(fe(r),fe(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:fe(r),color:fe(n),fontSize:14,lineHeight:1.5},children:[h.jsx(Z.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),h.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[h.jsx("strong",{children:"Interface upload failed"}),h.jsx("div",{children:e})]}),h.jsx(gt,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function vm({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:u}=Ie(),{edgeById:c}=Ur(),{data:l,schema:d,setSchema:f,bindings:p,structured:y}=S.useContext(Rr),g=(y==null?void 0:y.sourceBindings)??p,b=(y==null?void 0:y.sourceSchema)??d,{colorText:x}=He(),m=S.useRef(null),w=S.useRef(0),[v,C]=S.useState(!1),[_,R]=S.useState("");S.useEffect(()=>()=>{w.current++},[]),S.useEffect(()=>{w.current++,C(!1)},[a,l,g]);const T=o?[...c.values()].filter(k=>Nu(o,k.data)).length:0,A=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(bm,{message:_,onDismiss:()=>R("")}),e&&h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?h.jsx(Z.PiGraph,{size:20}):r==="properties"?h.jsx(Z.PiTable,{size:20}):h.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:a,onValueChange:k=>{var j;const E=k==="auto"?"auto":k==="properties"?"properties":"nodes";n(E),(j=s.onEdgeModeChange)==null||j.call(s,E)},children:[h.jsx("option",{value:"auto",children:"Auto"}),h.jsx("option",{value:"nodes",children:"Nodes"}),h.jsx("option",{value:"properties",children:"Properties"})]}),h.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[h.jsx(Ee,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:h.jsx(be,{"aria-label":"Upload workflow interface",icon:h.jsx(Z.PiUploadSimple,{size:20}),color:fe(u),size:"sm",variant:"ghost",disabled:v||a,onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()}})}),h.jsx("input",{ref:m,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||v,onChange:async k=>{var M,I;const E=(M=k.target.files)==null?void 0:M[0];if(k.target.value="",!E)return;const j=++w.current;C(!0),R("");try{const q=g?await $u(E,[...new Set(Object.values(g).map(W=>W.schemaType??W.type))]):void 0;if(g&&q){for(const W of Object.values(g))if(!Object.prototype.hasOwnProperty.call(q,W.schemaType??W.type))throw new Error(`Missing form type: ${W.schemaType??W.type}`)}const{contract:O,schema:V}=g&&q?{schema:q,contract:{name:E.name,nodes:Object.fromEntries(Object.entries(g).map(([W,re])=>[W,{type:q[re.schemaType??re.type],optional:!1}]))}}:await l0(E,l);if(j!==w.current)return;f==null||f(V),i(O),(I=s.onWorkflowContractChange)==null||I.call(s,O)}catch(q){j===w.current&&R(`${E.name}: ${q instanceof Error?q.message:"Unable to load interface."}`)}finally{j===w.current&&C(!1)}}}),!t&&(A||v)&&h.jsx("span",{role:"status",title:A,style:{color:fe(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v?"Loading interface...":A}),!t&&o&&h.jsx(Ee,{label:"Remove workflow interface",children:h.jsx(be,{"aria-label":"Remove workflow interface",icon:h.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||v,onClick:()=>{var k;f==null||f(void 0),i(void 0),(k=s.onWorkflowContractChange)==null||k.call(s,void 0),R("")}})})]})]})}const d0=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:jt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:jt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:jt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:jt.RIGHT_LEFT}],xm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,backgroundSelected:n,setBackgroundSelected:o,direction:i,edgeMode:s,allNodesIconLabel:a,setAllNodesIconLabel:u,selectedNodeIds:c,setSelectedNodeIds:l,selectedEdgeId:d,setSelectedEdgeId:f,isZoomMode:p,setIsZoomMode:y,isMultiSelectMode:g,setIsMultiSelectMode:b,isDragMode:x,setIsDragMode:m,isEdgeHandlesEnabled:w,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,isPinned:R,setIsPinned:T,callbacks:A,config:k,readOnly:E}=Ie(),{nodeById:j,edgeById:M,parentIds:I}=Ur(),q=k.colorMode==="dark",{background:O,border:V,colorInactive:W,colorText:re,colorActive:Y}=He(),he=`var(--chakra-colors-${O.replace(".","-")})`,me=`var(--chakra-colors-${(q?V:"gray.300").replace(".","-")})`,[J,N]=S.useState(!1),[L,G]=S.useState(!0),D=S.useRef(null),ne=yy({edge:"bottom",enabled:!R,bounds:D,inside:[D]}),ue=S.useCallback(xe=>{const Me=e.current;if(!Me)return;const Fe=k.minZoom??.01,nr=k.maxZoom??1.5,Ze=.02;let Ye=Me.zoom();switch(xe){case"increase":Ye=Math.min(nr,Ye+Ze),Me.zoom(Ye),Me.center();break;case"decrease":Ye=Math.max(Fe,Ye-Ze),Me.zoom(Ye),Me.center();break;case"reset":Me.fit(50);break}},[e,k.minZoom,k.maxZoom]),X=k.renderSelectedNodeToolbar,U=c.length>0&&!!X,K=S.useMemo(()=>U?c.map(xe=>{var Fe;return{...((Fe=j.get(xe))==null?void 0:Fe.data)??{id:xe},isParent:I.has(xe)}}):[],[U,c,j,I]),te=S.useCallback(()=>{var xe;l([]),(xe=A.onNodeDeselect)==null||xe.call(A)},[l,A]),ce=k.renderSelectedEdgeToolbar,de=!!d&&!!ce,Ae=S.useMemo(()=>{var xe;return!de||!d?null:((xe=M.get(d))==null?void 0:xe.data)??{id:d}},[de,d,M]),ge=S.useCallback(()=>{var xe;f(null),(xe=A.onEdgeDeselect)==null||xe.call(A)},[f,A]),Ke=k.selectionToolbar!==!1&&!E,Oe=Ke&&!!d&&!ce,Le=Ke&&!Oe&&c.length>0&&!X,er=Oe||Le,Ve=R||ne||J||er;S.useEffect(()=>{c.length||d?o(!1):n&&!E&&(T(!0),G(!1))},[n,c.length,d,E,o,T]);const $e=k.renderBottomBar;return $e?h.jsxs(h.Fragment,{children:[U&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:K,onDeselect:te})}),de&&Ae&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ce({edgeId:d,edgeData:Ae,onDeselect:ge})}),h.jsx(B.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:$e({zoomIn:()=>ue("increase"),zoomOut:()=>ue("decrease"),resetZoom:()=>ue("reset"),direction:i,isZoomMode:p,setIsZoomMode:y,isMultiSelectMode:g,setIsMultiSelectMode:b,isDragMode:x,setIsDragMode:m,isEdgeHandlesEnabled:w,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,selectedNodeIds:c,selectedNodeData:K,selectedEdgeId:d,selectedEdgeData:Ae,onNodeDeselect:te,onEdgeDeselect:ge,callbacks:A})})]}):h.jsxs(h.Fragment,{children:[U&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:K,onDeselect:te})}),de&&Ae&&h.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ce({edgeId:d,edgeData:Ae,onDeselect:ge})}),h.jsx(B.Box,{ref:D,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:Ve?"translateY(0)":"translateY(100%)",pointerEvents:Ve?"auto":"none",visibility:Ve?"visible":"hidden",opacity:Ve?1:0,css:{"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:h.jsxs(B.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",children:[h.jsx(mm,{background:O,border:q?V:"gray.300",children:h.jsxs(B.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Oe?h.jsx(dm,{edgeId:d,onClose:ge}):Le?h.jsx(hm,{ids:c,onClose:te}):null,h.jsxs("div",{style:{display:Oe||Le?"none":"contents"},children:[h.jsx(Ee,{label:R?"Unpin":"Pin",children:h.jsx(be,{"aria-label":"Pin",icon:h.jsx(B.Icon,{as:R?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:R?t:W,onClick:()=>{T(!R),N(!1)}})}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:"Zoom Out",children:h.jsx(be,{"aria-label":"Zoom out",icon:h.jsx(B.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ue("decrease")})}),h.jsx(Ee,{label:"Zoom In",children:h.jsx(be,{"aria-label":"Zoom in",icon:h.jsx(B.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ue("increase")})}),h.jsx(Ee,{label:"Reset Zoom",children:h.jsx(be,{"aria-label":"Reset zoom",icon:h.jsx(B.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ue("reset")})}),!L&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:p?"Zoom Mode (z)":"Pan Mode (z)",children:h.jsx(be,{"aria-label":"Toggle zoom mode",icon:h.jsx(B.Icon,{as:p?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:p?t:W,onClick:()=>y(!p)})}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:g?"Multi-Select On (m)":"Multi-Select Off (m)",children:h.jsx(be,{"aria-label":"Toggle multi-select",icon:h.jsx(B.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:g?t:W,onClick:()=>b(!g)})}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:x?"Drag Mode On (d)":"Drag Mode Off (d)",children:h.jsx(be,{"aria-label":"Toggle drag mode",icon:h.jsx(B.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:x?t:W,onClick:()=>m(!x)})}),k.edgeHandles!==!1&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:w?"Draw Mode On":"Draw Mode Off",children:h.jsx(be,{"aria-label":"Toggle draw mode",icon:h.jsx(B.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:w?t:W,onClick:()=>v(!w)})})]}),k.bottomBarExtra&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V,role:"separator","aria-orientation":"vertical"}),k.bottomBarExtra]}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V,role:"separator","aria-orientation":"vertical"}),h.jsx(Wy,{}),h.jsx(Ru,{label:"Collapse all",checked:a,icon:h.jsx(B.Icon,{as:Z.PiArrowsInLineVertical,boxSize:5}),onChange:u}),s!=="properties"&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:C?"Array Mode [ ]":"Set Mode { }",children:h.jsx(be,{"aria-label":"Toggle array mode",icon:h.jsx(B.Icon,{as:C?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:C?t:W,onClick:()=>{var Me;const xe=!C;_(xe),(Me=A.onArrayModeChange)==null||Me.call(A,xe)}})})]}),n&&!E&&h.jsxs(h.Fragment,{children:[h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Zt,{label:"Graph theme",colors:Fu,value:t,includeTransparent:!1,onPick:xe=>{var Me;r(xe),(Me=A.onThemeColorChange)==null||Me.call(A,xe)}})]}),h.jsx(vm,{}),h.jsx(Uy,{})]}),h.jsx(B.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:V}),h.jsx(Ee,{label:L?"Expand toolbar":"Collapse toolbar",children:h.jsx(be,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(B.Icon,{as:L?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:W,onClick:()=>G(!L)})}),!L&&h.jsx(ym,{})]})]})}),!er&&h.jsxs(B.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(B.Box,{"data-flow-direction-control":"",bg:O,borderRadius:"30px",h:50,css:zr(he,me),px:3,cursor:"pointer",onClick:()=>N(!J),children:h.jsxs(B.Flex,{align:"center",h:"100%",children:[h.jsx(Ee,{label:"Flow Direction",children:h.jsx(be,{"aria-label":"Direction",icon:h.jsx(B.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:W})}),h.jsx(B.Text,{fontSize:"xs",color:q?"whiteAlpha.600":"blackAlpha.500",ml:1,children:i})]})}),J&&h.jsx(B.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(B.Box,{bg:O,borderRadius:"30px",p:2,minW:"180px",css:zr(he,me),children:[d0.map(xe=>h.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"30px",cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Me;(Me=A.onDirectionChange)==null||Me.call(A,xe.value),N(!1)},children:[h.jsx(B.Icon,{as:xe.icon,boxSize:5,color:re}),h.jsx(B.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:xe.label}),i===xe.value&&h.jsx(B.Icon,{as:Z.PiCheck,boxSize:4,color:Y})]},xe.value)),h.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var xe;(xe=A.onDirectionChange)==null||xe.call(A,"C"),N(!1)},children:[h.jsx(B.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:re}),h.jsx(B.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(B.Icon,{as:Z.PiCheck,boxSize:4,color:Y})]})]})})]})]})})]})};xm.displayName="BottomBar";const wm=S.memo(xm);function f0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(Ru,{label:n,checked:e,onChange:t,disabled:r,icon:h.jsx(B.Icon,{as:Z.PiGraph,boxSize:5})})}const Tl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Cm(e,t){const r=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(u=>Object.prototype.hasOwnProperty.call(s,u)&&n(i[u],s[u]))},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 u=new Set([...Object.keys(i),...Object.keys(s)]);for(const c of u)if(!n(i[c],s[c])){if(Object.prototype.hasOwnProperty.call(Tl,c)){if(typeof s[c]!="string"||!s[c])return!1;r.set(a,{...r.get(a),[Tl[c]]:s[c]})}else if(c.startsWith("$")&&c!=="$"||!o(i[c],s[c],c==="$"?a:`${a}.${c}`))return!1}return!0};if(o(e,t,"root"))return r}function h0(e,t){return Cm(e,t)!==void 0}function p0(e,t,r){if(e===t)return r;const n=Cm(e,t);if(!n)return;const o=new Set(r.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!ve(t,i))return;return{edges:r.edges,nodes:r.nodes.map(i=>{const s=n.get(i.data.id),a=ve(e,i.data.id),u=ve(t,i.data.id);return!s&&a===u?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(u,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function Cu(e){return e.kind==="literal"?e.value:e.kind==="union"?Cu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,Cu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function _m(e,t,r){var b,x,m;const n=(b=ve(e,t))==null?void 0:b.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(w=>!/^[A-Za-z0-9_-]+$/.test(w)||["__proto__","constructor","prototype"].includes(w)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),u=yt(e,a,r),c=(x=u==null?void 0:u.type.properties[s])==null?void 0:x.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[o.$type],d=o.$defaults??{};for(const[w,v]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,w)||kr(l.properties[w].type,v,!l.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const f={...Cu(l),...structuredClone(d)};((m=l.properties.id)==null?void 0:m.type.kind)==="string"&&(f.id=Pu());let p=e;const y=ve(e,o.$address);if(y===void 0)p=mr(e,a,w=>({...w,[s]:[]}));else if(!Array.isArray(y)&&!Array.isArray(y==null?void 0:y.$))throw new Error("Form creation destination is not an array.");const g=Ou(p,o.$address,{...f,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:Iu(g.json,t,{target:g.address,label:o.$edgeLabel})}}function g0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Sm(e,t,r,n,o){const i=(a,u)=>{a!==e&&(e=a,n==null||n(a,u))},s=a=>{var c;const u=(c=t.find(l=>l.data.id===a))==null?void 0:c.data;return u&&{source:u.source,target:u.target,isInverted:u.isInverted,sourceProperty:u.sourceProperty,targetProperty:u.targetProperty,connection:u.connection}};return{...r,onFormChange:a=>{const u=ve(e,a.nodeAddress);if(!u||a.nodeId!==void 0&&u.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(_n(e,a,r.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,u)=>{var c;(c=r.onNodeLabelChange)==null||c.call(r,a,u),i(lr(e,a,"$label",u),{type:"nodeLabel",address:a,key:"$label",value:u})},onNodeContentChange:(a,u)=>{var c;(c=r.onNodeContentChange)==null||c.call(r,a,u),i(lr(e,a,"$content",u),{type:"nodeContent",address:a,key:"$content",value:u})},onNodeTypeViewChange:(a,u)=>{var c;u!==void 0&&!zt.includes(u)||((c=r.onNodeTypeViewChange)==null||c.call(r,a,u),i(lr(e,a,"$view",u),{type:"nodeStyle",address:a,key:"$view",value:u}))},onNodeColorChange:(a,u,c)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,a,u,c);const l=u==="bg"?"$bgColor":"$textColor";i(lr(e,a,l,c),{type:"nodeColor",address:a,key:l,value:c})},onNodeBorderColorChange:(a,u)=>{var c;(c=r.onNodeBorderColorChange)==null||c.call(r,a,u),i(lr(e,a,"$borderColor",u),{type:"nodeColor",address:a,key:"$borderColor",value:u})},onNodeBorderStyleChange:(a,u)=>{var c;(c=r.onNodeBorderStyleChange)==null||c.call(r,a,u),i(lr(e,a,"$borderStyle",u),{type:"nodeStyle",address:a,key:"$borderStyle",value:u})},onNodeBorderWidthChange:(a,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderWidthChange)==null||c.call(r,a,u),i(lr(e,a,"$borderWidth",u),{type:"nodeStyle",address:a,key:"$borderWidth",value:u}))},onNodeBorderRadiusChange:(a,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderRadiusChange)==null||c.call(r,a,u),i(lr(e,a,"$borderRadius",u),{type:"nodeStyle",address:a,key:"$borderRadius",value:u}))},onNodeIconChange:(a,u)=>{var c;(c=r.onNodeIconChange)==null||c.call(r,a,u),i(lr(e,a,"$icon",u),{type:"nodeIcon",address:a,key:"$icon",value:u})},onNodeOutlineChange:(a,u)=>{var c;(c=r.onNodeOutlineChange)==null||c.call(r,a,u),i(lr(e,a,"$outline",u),{type:"nodeOutline",address:a,key:"$outline",value:u})},onNodeAnimationChange:(a,u)=>{var c;(c=r.onNodeAnimationChange)==null||c.call(r,a,u),i(lr(e,a,"$isNodeAnimated",u),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:u})},onNodeAnimationVariantChange:(a,u)=>{var c;u!=="traveling"&&u!=="pulse"||((c=r.onNodeAnimationVariantChange)==null||c.call(r,a,u),i(lr(e,a,"$nodeAnimationVariant",u),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:u}))},onNodeCollapse:(a,u)=>{var c;(c=r.onNodeCollapse)==null||c.call(r,a,u),i(Yy(e,a,u),{type:"nodeCollapse",address:a,key:"$collapsed",value:u})},onNodeCreate:a=>{var p,y;const u=a.sourceNodeId&&_m(e,a.sourceNodeId,o);if(u){(p=r.onNodeCreate)==null||p.call(r,a),i(u.json,{type:"nodeCreate",address:u.address,value:"form"});return}(y=r.onNodeCreate)==null||y.call(r,a);const c=a.sourceNodeId||"root",l=ve(e,c),d=g0(l,a.isArrayMode?"list":"node"),f=Ou(e,c,a.isArrayMode?[]:{},d);i(f.json,{type:"nodeCreate",address:f.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,u)=>{var c;(c=r.onNodeDelete)==null||c.call(r,a,u),i(Qy(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,u,c)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,a,u,c);const l=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:u}:void 0;i(l?Iu(e,a,l):em(e,a,u),{type:"edgeCreate",address:a,key:l?"$connections":"$target",value:l??u})},onEdgeLabelChange:(a,u)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$sourceLabel",u),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:u})},onEdgeStyleChange:(a,u)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,a,u);const c=s(a);c&&i(Xy(e,c,u),{type:"edgeStyle",edge:c,value:u})},onEdgeAnimationVariantChange:(a,u)=>{var l;if(u!=="dashed"&&u!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeAnimationVariant",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:u})},onEdgeTypeChange:(a,u)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeType",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:u})},onEdgeIconChange:(a,u)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeIcon",u||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:u})},onEdgeColorChange:(a,u)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,a,u);const c=s(a);c&&i(Br(e,c,"$edgeColor",u),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:u})},onEdgeDelete:(a,u)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,a,u);const c=s(a);if(!c)return;const l=rm(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const y0=".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 m0({path:e,color:t,width:r,reversed:n}){return h.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:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const b0=".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 v0({path:e,width:t,reversed:r,children:n,onComplete:o}){const i=`flow-edge-reveal-${S.useId().replace(/:/g,"")}`,s=S.useRef(null),[a,u]=S.useState({x:0,y:0,width:1,height:1});return S.useEffect(()=>{const c=matchMedia("(prefers-reduced-motion: reduce)"),l=()=>{c.matches&&(o==null||o())};return l(),c.addEventListener("change",l),()=>c.removeEventListener("change",l)},[o]),S.useLayoutEffect(()=>{var l;const c=(l=s.current)==null?void 0:l.getBBox();c&&u({x:c.x-t,y:c.y-t,width:c.width+t*2,height:c.height+t*2})},[e,t]),h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:h.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:c=>{c.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":r?"reverse":"forward",style:{"--flow-edge-reveal-from":r?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:t,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),h.jsx("g",{mask:`url(#${i})`,children:n})]})}const x0=".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 Em({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:u="traveling"}){const c=S.useId(),l=`flow-sdk-node-border-animation${u==="pulse"?" flow-sdk-node-border-pulse":""}`;if(u==="pulse"){const d=a?"path":"rect",f=a?{d:a}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2))},p=s+36,y={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return h.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[h.jsx("defs",{children:h.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[h.jsx("rect",{...y,fill:"white"}),h.jsx(d,{...f,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),h.jsx(d,{...f,className:l,"data-animation-variant":u,fill:"none",stroke:`color-mix(in srgb, ${i} 60%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?h.jsx("path",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):h.jsx("rect",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const w0=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 Ol(e,t,r){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of t)(s.parent===i||s.id.startsWith(`${i}.`)||r.some(u=>(u.inverted?u.target:u.source)===i&&(u.inverted?u.source:u.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function C0(e,t,r){const n=r==="downward"||r==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=t(s.source),u=t(s.target);if(!a||!u)continue;const c=n?u.y-a.y:u.x-a.x,l=Math.abs(c)-(n?a.h+u.h:a.w+u.w)/2;if(l<=320)continue;const d=JSON.stringify([s.source,Math.sign(c)]),f=o.get(d)??[];f.push({edge:s,gap:l,cross:n?u.x-a.x:u.y-a.y}),o.set(d,f)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:u})=>u.target)).size<2)continue;const a=new Map;for(const{edge:u}of s)a.set(u.target,(a.get(u.target)??0)+1);for(const u of[-1,0,1]){const c=s.filter(({cross:d})=>Math.sign(d)===u);c.sort((d,f)=>Math.abs(f.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(f.edge.id));const l=Math.min(...c.map(({gap:d})=>d));c.forEach(({edge:d,gap:f,cross:p},y)=>{const g=c.length===1?l/2:120+(l-280)*y/(c.length-1),b=c.find(x=>Math.abs(x.cross)<Math.abs(p));i.set(d.id,{turn:g/f,labelAtTarget:a.get(d.target)===1,labelFraction:p?(p+((b==null?void 0:b.cross)??0))/(2*p):.5})})}}return i}const ct=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}),_0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Qn(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const S0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Il=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,hr=e=>(Math.round(e*10)/10).toString(),Je=e=>`${hr(e.x)} ${hr(e.y)}`,E0=e=>e>0?1:e<0?-1:0,Ml=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function j0(e,t,r,n,o=10){const i=t.x-e.x,s=t.y-e.y,a=Ml(i,(e.w+t.w)/2),u=Ml(s,(e.h+t.h)/2),c=r==="downward"||r==="upward",l=c?u:a,d=c?s:i,f=E0(d),p=n*l,y=m=>Math.abs(m)<o||Math.abs(m)>=Math.abs(l),g=y(p)||y(Math.abs(l)-Math.abs(p));let b;if(g)if(c)if(Math.abs(d)<=e.h/2){const m=(e.x+t.x)/2;b=[m,e.y,m,t.y]}else if(Math.abs(i)<=t.w/2){const m=(e.y+t.y)/2;b=[e.x,m,t.x,m]}else b=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const m=(e.y+t.y)/2;b=[e.x,m,t.x,m]}else if(Math.abs(s)<=t.h/2){const m=(e.x+t.x)/2;b=[m,e.y,m,t.y]}else b=[t.x,e.y];else if(c){const m=e.y+p+e.h/2*f;b=[e.x,m,t.x,m]}else{const m=e.x+p+e.w/2*f;b=[m,e.y,m,t.y]}const x=[{x:e.x,y:e.y}];for(let m=0;m<b.length;m+=2)x.push({x:b[m],y:b[m+1]});return x.push({x:t.x,y:t.y}),x}function k0(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,s=o>0?(r.y2-e.y)/o:o<0?(r.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 pt(e,t,r){var s;if(!((s=r.outline)!=null&&s.length))return k0(e,t,ct(r));const n=t.x-e.x,o=t.y-e.y;let i=1/0;return r.outline.forEach((a,u,c)=>{const l=c[(u+1)%c.length],d=l.x-a.x,f=l.y-a.y,p=n*f-o*d;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,g=a.y-e.y,b=(y*f-g*d)/p,x=(y*o-g*n)/p;b>=0&&b<1&&x>=-1e-9&&x<=1+1e-9&&(i=Math.min(i,b))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function jm(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,o=t==="top"||t==="bottom",i=t==="top"||t==="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{...pt(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:t}}function dt(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function R0(e,t,r,n){const o=dt(e,r.srcDist),i=dt(t,r.tgtDist);if(n==="straight")return Rm(o,i,r);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&t.side==="top"?i.y-o.y:e.side==="top"&&t.side==="bottom"?o.y-i.y:e.side==="right"&&t.side==="left"?i.x-o.x:e.side==="left"&&t.side==="right"?o.x-i.x:void 0,u=a!==void 0&&a>0?Math.min(s,a/2):s,c=dt({...o,side:e.side},u),l=dt({...i,side:t.side},u),d=r.arrowAt==="source"?tr(o,c,r.arrowGap):o,f=r.arrowAt==="target"?tr(i,l,r.arrowGap):i,p=r.arrowAt==="source"?br(o,c,r.arrowSize,r.headShape):r.arrowAt==="target"?br(i,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Je(d)} C${Je(c)} ${Je(l)} ${Je(f)}`,arrow:p,label:{x:(d.x+3*c.x+3*l.x+f.x)/8,y:(d.y+3*c.y+3*l.y+f.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",g=t.side==="left"||t.side==="right";let b;if(y!==g){const m=y?{x:l.x,y:c.y}:{x:c.x,y:l.y},w=(m.x-c.x)*(c.x-o.x)+(m.y-c.y)*(c.y-o.y)>=0,v=(m.x-l.x)*(l.x-i.x)+(m.y-l.y)*(l.y-i.y)>=0;b=[w&&v?m:y?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(a!==void 0&&a<=0)if(y){const m=(c.y+l.y)/2;b=[{x:c.x,y:m},{x:l.x,y:m}]}else{const m=(c.x+l.x)/2;b=[{x:m,y:c.y},{x:m,y:l.y}]}else if(y){const m=e.side===t.side?e.side==="right"?Math.max(c.x,l.x):Math.min(c.x,l.x):(c.x+l.x)/2;b=[{x:m,y:c.y},{x:m,y:l.y}]}else{const m=e.side===t.side?e.side==="bottom"?Math.max(c.y,l.y):Math.min(c.y,l.y):(c.y+l.y)/2;b=[{x:c.x,y:m},{x:l.x,y:m}]}const x=[c,...b,l].filter((m,w,v)=>w===0||m.x!==v[w-1].x||m.y!==v[w-1].y);return Sn(d,x,f,p,n==="orthogonal"?0:r.radius)}function tr(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-r)/i;return s<0&&(s=1e-5),{x:t.x+s*n,y:t.y+s*o}}function br(e,t,r,n="triangle"){const o=e.x-t.x,i=e.y-t.y,s=Math.hypot(o,i)||1,a=o/s,u=i/s,c=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-a*c,f=e.y-u*c;return n==="square"?`M${Je(e)} L${hr(e.x-u*l)} ${hr(e.y+a*l)} L${hr(d-u*l)} ${hr(f+a*l)} L${hr(d+u*l)} ${hr(f-a*l)} L${hr(e.x+u*l)} ${hr(e.y-a*l)} Z`:`M${Je(e)} L${hr(d-u*l)} ${hr(f+a*l)} L${hr(d+u*l)} ${hr(f-a*l)} Z`}function Fr(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function P0(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),u=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(u)<1e-6)return{p1:t,b:t,p2:t,r:0};const c=Math.min(n,s/2,a/2);return{p1:{x:t.x-o.x/s*c,y:t.y-o.y/s*c},b:t,p2:{x:t.x+i.x/a*c,y:t.y+i.y/a*c},r:c}}function km(e,t,r,n){let o=-1,i=null;for(let y=0;y<e.length-1;y++){const g=pt(e[y],e[y+1],t);if(g){o=y,i=g;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const g=pt(e[y],e[y-1],r);if(g){s=y,a=g;break}}if(!i||!a||o>=s)return null;const u=e.slice(o+1,s),c=u[0]??a,l=u[u.length-1]??i;let d,f,p;if(n.arrowAt==="source"){const y=tr(i,c,n.srcDist);d=tr(i,c,n.srcDist+n.arrowGap),p=br(y,c,n.arrowSize,n.headShape)}else d=tr(i,c,n.srcDist);if(n.arrowAt==="target"){const y=tr(a,l,n.tgtDist);f=tr(a,l,n.tgtDist+n.arrowGap),p=br(y,l,n.arrowSize,n.headShape)}else f=tr(a,l,n.tgtDist);return Sn(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function Sn(e,t,r,n,o,i,s){var f;const a=[e,...t,r],u=[];let c=`M${Je(e)}`;for(let p=1;p<a.length-1;p++){const y=P0(a[p-1],a[p],a[p+1],o);u.push(y),y.r===0?c+=` L${Je(y.b)}`:c+=` L${Je(y.p1)} Q${Je(y.b)} ${Je(y.p2)}`}c+=` L${Je(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Fr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],y=t[d/2];l={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:Fr(y.x-p.x,y.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const y=a[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Fr(y.x-p.b.x,y.y-p.b.y)}}else l={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:Fr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&u.length===2){const b=u[0].p2,x=u[1].p1,m=Math.hypot(x.x-b.x,x.y-b.y),w=Math.min(.5,i/(2*m)),v=Math.max(w,Math.min(1-w,s));l={x:b.x+(x.x-b.x)*v,y:b.y+(x.y-b.y)*v,angle:Fr(x.x-b.x,x.y-b.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,y=r.x-p.x,g=r.y-p.y;Math.hypot(y,g)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Fr(y,g)})}return{d:c,arrow:n,label:l}}function ql(e,t,r,n,o,i,s){const a=r==="leftward"?-1:1,u={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},c={x:t.x-a*(t.w/2+s.tgtDist),y:o??t.y},l=Math.max(80,s.arrowGap+s.arrowSize*.3),d=u.x+a*l,f=c.x-a*l;let p;if(a*(f-d)>=0){const x=u.x+(c.x-u.x)*i,m=Math.max(Math.min(d,f),Math.min(Math.max(d,f),x));p=[{x:m,y:u.y},{x:m,y:c.y}]}else{const x=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:x},{x:f,y:x},{x:f,y:c.y}]}const y=s.arrowAt==="source"?tr(u,p[0],s.arrowGap):u,g=s.arrowAt==="target"?tr(c,p[p.length-1],s.arrowGap):c,b=s.arrowAt==="source"?br(u,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?br(c,p[p.length-1],s.arrowSize,s.headShape):void 0;return Sn(y,p,g,b,s.radius)}function Nl(e,t,r,n,o){return km(j0(e,t,r,n),e,t,o)}function $l(e,t,r,n,o,i){const s=n===void 0&&o===void 0&&(r==="downward"||r==="upward"),a=r==="leftward"||s&&r==="upward"?-1:1,u=(c,l,d)=>{const f={x:c.x,y:l??c.y},p=Math.max(c.w,c.h)*2+1,y=pt(f,{x:f.x+(s?0:d*p),y:f.y+(s?d*p:0)},c);return y?{x:y.x+(s?0:d*i),y:y.y+(s?d*i:0)}:s?{x:c.x,y:c.y+d*(c.h/2+i)}:{x:c.x+d*(c.w/2+i),y:l??c.y}};return{sourcePoint:u(e,n,a),targetPoint:u(t,o,-a)}}function A0(e,t,r,n){const o=r==="downward"||r==="upward",i=r==="leftward"||r==="upward"?-1:1,s=Math.max(100,Math.abs(o?t.y-e.y:t.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},u={x:t.x-(o?0:i*s),y:t.y-(o?i*s:0)},c=n.arrowAt==="source"?tr(e,a,n.arrowGap):e,l=n.arrowAt==="target"?tr(t,u,n.arrowGap):t;return{d:`M${Je(c)} C${Je(a)} ${Je(u)} ${Je(l)}`,arrow:n.arrowAt==="source"?br(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?br(t,u,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*a.x+3*u.x+l.x)/8,y:(c.y+3*a.y+3*u.y+l.y)/8,angle:Fr(l.x+u.x-a.x-c.x,l.y+u.y-a.y-c.y)}}}function Rm(e,t,r){const n=r.arrowAt==="source"?tr(e,t,r.arrowGap):e,o=r.arrowAt==="target"?tr(t,e,r.arrowGap):t,i=r.arrowAt==="source"?br(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?br(t,e,r.arrowSize,r.headShape):void 0;return Sn(n,[],o,i,0)}function T0(e,t,r,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,u=s-Math.PI/2,c=u-a/2,l=u+a/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},y={x:e.x,y:e.y},g=pt(y,f,e),b=pt(y,p,e);if(!g||!b)return null;const x={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let m=tr(g,f,r.srcDist),w=tr(b,p,r.tgtDist),v;if(r.arrowAt==="target"){const _=w;w=tr(b,p,r.tgtDist+r.arrowGap),v=br(_,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const _=m;m=tr(g,f,r.srcDist+r.arrowGap),v=br(_,f,r.arrowSize,r.headShape)}return{d:`M${Je(m)} Q${Je(f)} ${Je(x)} Q${Je(p)} ${Je(w)}`,arrow:v,label:{x:x.x,y:x.y,angle:Fr(p.x-f.x,p.y-f.y)}}}const at=e=>Math.round(e*1e3)/1e3;function Pm(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=t.getBoundingClientRect();if(!o.width||!o.height)return;const i=t,s=typeof i.getScreenCTM=="function"?i.getScreenCTM():null,a=typeof i.getTotalLength=="function"?i.getTotalLength():0,u=i.points,c=(u==null?void 0:u.numberOfItems)||128,l=s&&a>0?Array.from({length:c},(d,f)=>{const p=u!=null&&u.numberOfItems?u.getItem(f):i.getPointAtLength(a*f/c);return{x:at((s.a*p.x+s.c*p.y+s.e-r.left)/n),y:at((s.b*p.x+s.d*p.y+s.f-r.top)/n)}}):void 0;return{left:at((o.left-r.left)/n),top:at((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:at(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:at(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function Ft(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(o=>({x:r+o.x,y:n+o.y}))}:{}}}function O0(e,t,r,n,o){var l;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",u=new Map;for(const d of n)for(const[f,p,y]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const g=t.get(y);if(p===void 0||!g||y===f)continue;const b=r.get(y),x=JSON.stringify([f,p]),m=u.get(x)??[];m.push(b?Ft(g,b):g),u.set(x,m)}const c=new Map(e);for(const[d,f]of e){const p=t.get(d);if(!p||!f.some(w=>w.placement==="config"))continue;const y=r.get(d),g=y?Ft(p,y):p,b={x:p.w/2,y:p.h/2,w:p.w,h:p.h},x=y?Ft(b,y):b,m=new Map;for(const w of f){if(w.placement!=="config")continue;const C=(u.get(JSON.stringify([d,w.property]))??[]).reduce((R,T)=>R+(i?T.y-g.y:T.x-g.x),0),_=((l=w.anchor)==null?void 0:l.side)===a?a:s;m.set(w,C<-.001?s:C>.001?a:_)}c.set(d,f.map(w=>{const v=m.get(w);if(!v)return w;const C=f.filter(T=>m.get(T)===v),_=(C.indexOf(w)+1)/(C.length+1),R=jm(x,v,_);return{...w,anchor:R,top:R.y,height:0}}))}return c}function Ll(e,t,r){const n=new Set(t.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 t)!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 r)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 rt='"Helvetica Neue", Helvetica, sans-serif';let Et;const cn=new Map;function En(e,t){const r=`${t}|${e}`,n=cn.get(r);if(n!==void 0)return n;Et===void 0&&(Et=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return Et?(Et.font=t,o=Et.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,cn.size>5e3&&cn.clear(),cn.set(r,o),o}function I0(e,t,r){const n=[];for(const o of String(e).split(`
157
+ `)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const u=s?`${s} ${a}`:a;!s||En(u,t)<=r?s=u:(n.push(s),s=a)}n.push(s)}return n}const M0=e=>e.stopPropagation();function q0({id:e,rect:t,label:r,labelLayer:n,style:o,onSelect:i,onCollapse:s,selected:a=!1}){const u=t.x2-t.x1,c=t.y2-t.y1,l=o.borderWidth,d=o.borderStyle==="dashed"?`${l*4} ${l*2}`:o.borderStyle==="dotted"?`${l} ${l}`:void 0,f=t.x1+u/2,p=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+c/2,y=r?En(r,`bold ${o.fontSize}px ${rt}`):0,g=o.fontSize/5,b=r||a&&s?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[a&&s&&h.jsx("foreignObject",{x:f+y/2+g+8,y:p-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:h.jsx(Ee,{label:"Show icon",children:h.jsx(be,{"aria-label":"Show icon",icon:h.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:x=>{x.stopPropagation(),s(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-y/2-g,y:p-o.fontSize/2-g,width:y+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),h.jsx("text",{x:f,y:p,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:M0,onClick:x=>{x.stopPropagation(),i==null||i(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.altKey})},children:[h.jsx("rect",{x:t.x1,y:t.y1,width:u,height:c,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?l/3:l,strokeDasharray:d}),o.borderStyle==="double"&&h.jsx("rect",{x:t.x1+l*2/3,y:t.y1+l*2/3,width:Math.max(0,u-l*4/3),height:Math.max(0,c-l*4/3),rx:Math.max(0,o.borderRadius-l*2/3),ry:Math.max(0,o.borderRadius-l*2/3),fill:"none",stroke:o.borderColor,strokeWidth:l/3}),o.animated&&l>0&&h.jsx(Em,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:c,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,l*1.6)}),n&&b?Dt.createPortal(b,n):b]})}const N0=S.memo(q0),yn=45,Am=70,Zr=15,Tm=50;function Om(e,t,r=yn){const n=`${r}px ${rt}`,o=e?I0(e,n,200*r/yn):[],i=t?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(c=>En(c,n))),a=Math.max(o.length*r,t?48:0),u=o.length||t?2*Zr:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+u,height:a+u}}const Bt=6,Im=3,Bu=Math.max(Math.pow(Bt*13.37,.9),29)*Im,Mm=Bt*Im*2,ln=80,$0=2*ln+Bu*.3+100,L0=36+2*Math.max(80,Mm+Bu*.3);function _u(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Su(e,t){return t==="auto"||(t==="properties"?_u(e):!_u(e))}function ut(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&_u(n))}function F0(e,t,r,n=!1,o){if(!n)return{nodes:e,edges:t};const i=e.filter(a=>ut(a.id,t,r)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:t.filter(a=>Su(a,r)&&s.has(a.source)&&s.has(a.target))}}const B0=500,D0="32 18",z0=e=>e.stopPropagation();function V0({id:e,reveal:t,onRevealComplete:r,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:u,target:c,sourceProperty:l,targetProperty:d,sourceY:f,targetY:p,sourcePort:y,targetPort:g,propertyMode:b=!1,dir:x,turn:m,labelAtTarget:w,labelFraction:v,color:C,labelBg:_,labelLayer:R,label:T,dashed:A,animated:k,inverted:E,loopIndex:j=0,onSelect:M}){const I=n==null?void 0:n.icon,q=b?yn:Am,{lines:O,iconWidth:V,contentWidth:W,contentHeight:re}=S.useMemo(()=>Om(T,I,q),[T,I,q]),Y=S.useMemo(()=>{const K={srcDist:ln,tgtDist:ln,arrowGap:Mm,arrowSize:Bu,headShape:b&&(E?f!==void 0||y:p!==void 0||g)?"square":"triangle",radius:s??(w?40:B0),arrowAt:E?"source":"target",labelTargetLength:w?W+2*Zr:void 0,labelFraction:w?v:void 0},te=f!==void 0||p!==void 0||!!y||!!g,ce=$l(u,c,x,f,p,0),de=f===void 0&&p===void 0&&(x==="downward"||x==="upward"),Ae=y??{...ce.sourcePoint,side:de?x==="upward"?"top":"bottom":x==="leftward"?"left":"right"},ge=g??{...ce.targetPoint,side:de?x==="upward"?"bottom":"top":x==="leftward"?"right":"left"},Ke=u.x===c.x&&u.y===c.y,Oe=y||g?R0(Ae,ge,{...K,srcDist:18,tgtDist:18},i):te?ql(u,c,x,f,p,m,{...K,srcDist:18,tgtDist:18,radius:s??Math.min(K.radius,40)}):Ke?T0(u,j,{...K,srcDist:0,tgtDist:0}):Nl(u,c,x,m,K);if(!Oe)return null;const Le=$l(u,c,x,f,p,te?18:ln);y&&(Le.sourcePoint=dt(y,18)),g&&(Le.targetPoint=dt(g,18));const er=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(er){const Ve={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return er({edge:n??{id:e,source:"",target:""},source:{...u},target:{...c},...Le,direction:Ve[x],sourceY:f,targetY:p,inverted:!!E,defaultGeometry:Oe})??Oe}return Ke||y||g?Oe:i==="straight"?te?Rm(Le.sourcePoint,Le.targetPoint,K):km([u,c],u,c,K):i==="bezier"?A0(Le.sourcePoint,Le.targetPoint,te?x==="leftward"?"leftward":"rightward":x,K):i==="orthogonal"?te?ql(u,c,x,f,p,m,{...K,srcDist:18,tgtDist:18,radius:0}):Nl(u,c,x,m,{...K,radius:0}):Oe},[u,e,n,i,s,a,c,b,f,p,y,g,x,m,E,j,w,v,W]);if(!Y)return null;const he=(x==="rightward"||x==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(b&&(f!==void 0||p!==void 0||y||g)),me=he?`translate(${Y.label.x} ${Y.label.y-re/2-2*Zr})`:`translate(${Y.label.x} ${Y.label.y}) rotate(${Y.label.angle}) translate(${w||Object.prototype.hasOwnProperty.call(a??{},i)?0:Tm} 0)`,J=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",N=o?J:C,L=o?h.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${Y.label.x} ${Y.label.y-O.length*q/2-55})`,children:[h.jsx("title",{children:o}),h.jsx(qr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:J})]}):null,G=k&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",D=!G&&(A||k)?D0:void 0,ne=k&&!G?`flow-sdk-edge-anim${E?" flow-sdk-edge-anim-rev":""}`:void 0;let ue=null;const X=t?{"--flow-edge-reveal-duration":`${t.durationMs??600}ms`,"--flow-edge-reveal-state":t.paused?"paused":"running"}:void 0;if(O.length||I){const K=W,te=re;ue=h.jsxs("g",{className:`flow-sdk-edge-label${t?" flow-sdk-edge-reveal-end":""}`,style:X,"data-label-transform":me,"data-label-horizontal":he||void 0,"data-edge-id":e,"data-source-property":l,"data-target-property":d,transform:me,children:[h.jsx("rect",{x:-K/2-Zr,y:-te/2-Zr,width:K+2*Zr,height:te+2*Zr,fill:C==="transparent"?"transparent":_}),h.jsx("text",{fill:C,fontSize:q,style:{fontSize:q,fontFamily:rt},fontFamily:rt,textAnchor:"middle",dominantBaseline:"central",children:O.map((ce,de)=>h.jsx("tspan",{x:V/2,y:(de-(O.length-1)/2)*q,children:ce},de))}),I&&h.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[h.jsx("title",{children:T?`Edge icon: ${T}`:"Edge icon"}),h.jsx("rect",{x:-K/2,y:-24,width:48,height:48,fill:"transparent"}),h.jsx(qr,{name:I,svg:!0,size:48,x:-K/2,y:-24,color:C})]})]})}const U=h.jsxs(h.Fragment,{children:[h.jsx("path",{d:Y.d,fill:"none",stroke:N,strokeWidth:Bt,strokeOpacity:G?.35:void 0,strokeDasharray:D,className:ne}),G&&h.jsx(m0,{path:Y.d,color:N,width:Bt*1.6,reversed:E})]});return h.jsxs("g",{className:"flow-sdk-edge",style:X,"data-edge-id":e,"data-source-property":l,"data-target-property":d,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:z0,onClick:K=>{K.stopPropagation(),M==null||M(e)},children:[t?h.jsx(v0,{path:Y.d,width:Bt*4,reversed:E,onComplete:()=>r==null?void 0:r(e),children:U}):U,Y.arrow&&h.jsx("path",{className:t?"flow-sdk-edge-reveal-end":void 0,d:Y.arrow,fill:N}),R&&ue?Dt.createPortal(ue,R):ue,R&&L?Dt.createPortal(L,R):L,h.jsx("path",{className:"flow-sdk-edge-hit",d:Y.d,fill:"none",stroke:"transparent"})]})}const Fl=S.memo(V0);function W0(e,t,r){const[n,o]=S.useState(()=>({nodes:new Set,edges:new Set})),i=S.useMemo(()=>{const a=new Set(e.map(p=>p.id)),u=t.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})),c=new Set(u.map(p=>p.id)),l=new Set([...n.nodes].filter(p=>a.has(p))),d=new Set([...n.edges].filter(p=>c.has(p)));if(!r)return{nodes:a,edges:c,ready:c};for(const p of e)u.filter(g=>g.target===p.id&&g.source!==g.target).every(g=>d.has(g.id))&&l.add(p.id);let f=new Set(u.filter(p=>l.has(p.source)).map(p=>p.id));if(l.size<a.size&&!u.some(p=>f.has(p.id)&&!d.has(p.id))){const p=e.find(y=>!l.has(y.id));p&&l.add(p.id),f=new Set(u.filter(y=>l.has(y.source)).map(y=>y.id))}return{nodes:l,edges:d,ready:f}},[e,t,r,n]);S.useLayoutEffect(()=>{o(a=>{const u=r?i:{nodes:new Set,edges:new Set},c=(l,d)=>l.size===d.size&&[...l].every(f=>d.has(f));return c(a.nodes,u.nodes)&&c(a.edges,u.edges)?a:{nodes:u.nodes,edges:u.edges}})},[i,r]);const s=S.useCallback(a=>{o(u=>u.edges.has(a)?u:{...u,edges:new Set([...u.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}const Bl=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function G0(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),o=(c,l=0)=>{const d=c.getBoundingClientRect(),f=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:f.x-l,right:p.x+l,top:f.y-l,bottom:p.y+l}},i=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const l=c.getBoundingClientRect(),d=getComputedStyle(c);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(c=>o(c,24));for(const c of t.querySelectorAll(".flow-sdk-container-label"))i.push(o(c,12));const s=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const c of s)c.setAttribute("transform",c.dataset.labelTransform??"");const a=new Map(s.map(c=>[c,o(c,8)])),u=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of s){const l=c.dataset.labelHorizontal==="true",d=a.get(c);a.delete(c);const f=R=>i.some(T=>Bl(R,T))||[...a.values()].some(T=>Bl(R,T));if(!l&&!f(d)){a.set(c,d);continue}const p=u.get(c.dataset.edgeId),y=c.querySelector("rect");if(!p||!y)continue;const g=y.getBBox(),b=p.getTotalLength();if(!Number.isFinite(b)||b<=0)continue;const x=(d.left+d.right)/2,m=(d.top+d.bottom)/2,w=Math.min(256,Math.max(16,Math.ceil(b/24))),v=Array.from({length:w+1},(R,T)=>p.getPointAtLength(b*T/w)),_=Array.from({length:w+1},(R,T)=>{const A=b*T/w,k=v[T],E=l?{x:k.x,y:k.y-g.height/2-15}:k,j=p.getPointAtLength(Math.max(0,A-2)),M=p.getPointAtLength(Math.min(b,A+2));let I=Math.atan2(M.y-j.y,M.x-j.x)*180/Math.PI;I>90&&(I-=180),I<-90&&(I+=180);const q=Math.abs(I)<1;l&&(I=0);const O=I*Math.PI/180,V=Math.abs(Math.cos(O))*g.width+Math.abs(Math.sin(O))*g.height,W=Math.abs(Math.sin(O))*g.width+Math.abs(Math.cos(O))*g.height;return{point:E,angle:I,straight:q,score:Math.hypot(E.x-x,E.y-m),bounds:{left:E.x-V/2-8,right:E.x+V/2+8,top:E.y-W/2-8,bottom:E.y+W/2+8}}}).sort((R,T)=>R.score-T.score).find(R=>!f(R.bounds)&&(!l||R.straight&&!v.some(T=>T.x>R.bounds.left&&T.x<R.bounds.right&&T.y>R.bounds.top&&T.y<R.bounds.bottom)));_?(c.setAttribute("transform",`translate(${_.point.x} ${_.point.y}) rotate(${_.angle})`),a.set(c,_.bounds)):a.set(c,d)}}var un=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function U0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Du(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 eo,Dl;function H0(){if(Dl)return eo;Dl=1;function e(){this.__data__=[],this.size=0}return eo=e,eo}var ro,zl;function mt(){if(zl)return ro;zl=1;function e(t,r){return t===r||t!==t&&r!==r}return ro=e,ro}var to,Vl;function jn(){if(Vl)return to;Vl=1;var e=mt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return to=t,to}var no,Wl;function K0(){if(Wl)return no;Wl=1;var e=jn(),t=Array.prototype,r=t.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():r.call(i,s,1),--this.size,!0}return no=n,no}var oo,Gl;function J0(){if(Gl)return oo;Gl=1;var e=jn();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return oo=t,oo}var io,Ul;function Z0(){if(Ul)return io;Ul=1;var e=jn();function t(r){return e(this.__data__,r)>-1}return io=t,io}var ao,Hl;function Y0(){if(Hl)return ao;Hl=1;var e=jn();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return ao=t,ao}var so,Kl;function kn(){if(Kl)return so;Kl=1;var e=H0(),t=K0(),r=J0(),n=Z0(),o=Y0();function i(s){var a=-1,u=s==null?0:s.length;for(this.clear();++a<u;){var c=s[a];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,so=i,so}var co,Jl;function X0(){if(Jl)return co;Jl=1;var e=kn();function t(){this.__data__=new e,this.size=0}return co=t,co}var uo,Zl;function Q0(){if(Zl)return uo;Zl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return uo=e,uo}var lo,Yl;function ew(){if(Yl)return lo;Yl=1;function e(t){return this.__data__.get(t)}return lo=e,lo}var fo,Xl;function rw(){if(Xl)return fo;Xl=1;function e(t){return this.__data__.has(t)}return fo=e,fo}var ho,Ql;function qm(){if(Ql)return ho;Ql=1;var e=typeof un=="object"&&un&&un.Object===Object&&un;return ho=e,ho}var po,ed;function Sr(){if(ed)return po;ed=1;var e=qm(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return po=r,po}var go,rd;function bt(){if(rd)return go;rd=1;var e=Sr(),t=e.Symbol;return go=t,go}var yo,td;function tw(){if(td)return yo;td=1;var e=bt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(s){var a=r.call(s,o),u=s[o];try{s[o]=void 0;var c=!0}catch{}var l=n.call(s);return c&&(a?s[o]=u:delete s[o]),l}return yo=i,yo}var mo,nd;function nw(){if(nd)return mo;nd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return mo=r,mo}var bo,od;function tt(){if(od)return bo;od=1;var e=bt(),t=tw(),r=nw(),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)?t(a):r(a)}return bo=s,bo}var vo,id;function vr(){if(id)return vo;id=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return vo=e,vo}var xo,ad;function en(){if(ad)return xo;ad=1;var e=tt(),t=vr(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!t(a))return!1;var u=e(a);return u==n||u==o||u==r||u==i}return xo=s,xo}var wo,sd;function ow(){if(sd)return wo;sd=1;var e=Sr(),t=e["__core-js_shared__"];return wo=t,wo}var Co,cd;function iw(){if(cd)return Co;cd=1;var e=ow(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Co=r,Co}var _o,ud;function Nm(){if(ud)return _o;ud=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return _o=r,_o}var So,ld;function aw(){if(ld)return So;ld=1;var e=en(),t=iw(),r=vr(),n=Nm(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,u=s.toString,c=a.hasOwnProperty,l=RegExp("^"+u.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?l:i;return p.test(n(f))}return So=d,So}var Eo,dd;function sw(){if(dd)return Eo;dd=1;function e(t,r){return t==null?void 0:t[r]}return Eo=e,Eo}var jo,fd;function nt(){if(fd)return jo;fd=1;var e=aw(),t=sw();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return jo=r,jo}var ko,hd;function zu(){if(hd)return ko;hd=1;var e=nt(),t=Sr(),r=e(t,"Map");return ko=r,ko}var Ro,pd;function Rn(){if(pd)return Ro;pd=1;var e=nt(),t=e(Object,"create");return Ro=t,Ro}var Po,gd;function cw(){if(gd)return Po;gd=1;var e=Rn();function t(){this.__data__=e?e(null):{},this.size=0}return Po=t,Po}var Ao,yd;function uw(){if(yd)return Ao;yd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Ao=e,Ao}var To,md;function lw(){if(md)return To;md=1;var e=Rn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===t?void 0:a}return n.call(s,i)?s[i]:void 0}return To=o,To}var Oo,bd;function dw(){if(bd)return Oo;bd=1;var e=Rn(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return Oo=n,Oo}var Io,vd;function fw(){if(vd)return Io;vd=1;var e=Rn(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return Io=r,Io}var Mo,xd;function hw(){if(xd)return Mo;xd=1;var e=cw(),t=uw(),r=lw(),n=dw(),o=fw();function i(s){var a=-1,u=s==null?0:s.length;for(this.clear();++a<u;){var c=s[a];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Mo=i,Mo}var qo,wd;function pw(){if(wd)return qo;wd=1;var e=hw(),t=kn(),r=zu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return qo=n,qo}var No,Cd;function gw(){if(Cd)return No;Cd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return No=e,No}var $o,_d;function Pn(){if(_d)return $o;_d=1;var e=gw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return $o=t,$o}var Lo,Sd;function yw(){if(Sd)return Lo;Sd=1;var e=Pn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return Lo=t,Lo}var Fo,Ed;function mw(){if(Ed)return Fo;Ed=1;var e=Pn();function t(r){return e(this,r).get(r)}return Fo=t,Fo}var Bo,jd;function bw(){if(jd)return Bo;jd=1;var e=Pn();function t(r){return e(this,r).has(r)}return Bo=t,Bo}var Do,kd;function vw(){if(kd)return Do;kd=1;var e=Pn();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return Do=t,Do}var zo,Rd;function Vu(){if(Rd)return zo;Rd=1;var e=pw(),t=yw(),r=mw(),n=bw(),o=vw();function i(s){var a=-1,u=s==null?0:s.length;for(this.clear();++a<u;){var c=s[a];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,zo=i,zo}var Vo,Pd;function xw(){if(Pd)return Vo;Pd=1;var e=kn(),t=zu(),r=Vu(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var u=a.__data__;if(!t||u.length<n-1)return u.push([i,s]),this.size=++a.size,this;a=this.__data__=new r(u)}return a.set(i,s),this.size=a.size,this}return Vo=o,Vo}var Wo,Ad;function An(){if(Ad)return Wo;Ad=1;var e=kn(),t=X0(),r=Q0(),n=ew(),o=rw(),i=xw();function s(a){var u=this.__data__=new e(a);this.size=u.size}return s.prototype.clear=t,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Wo=s,Wo}var Go,Td;function Wu(){if(Td)return Go;Td=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return Go=e,Go}var Uo,Od;function $m(){if(Od)return Uo;Od=1;var e=nt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Uo=t,Uo}var Ho,Id;function Tn(){if(Id)return Ho;Id=1;var e=$m();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Ho=t,Ho}var Ko,Md;function On(){if(Md)return Ko;Md=1;var e=Tn(),t=mt(),r=Object.prototype,n=r.hasOwnProperty;function o(i,s,a){var u=i[s];(!(n.call(i,s)&&t(u,a))||a===void 0&&!(s in i))&&e(i,s,a)}return Ko=o,Ko}var Jo,qd;function rn(){if(qd)return Jo;qd=1;var e=On(),t=Tn();function r(n,o,i,s){var a=!i;i||(i={});for(var u=-1,c=o.length;++u<c;){var l=o[u],d=s?s(i[l],n[l],l,i,n):void 0;d===void 0&&(d=n[l]),a?t(i,l,d):e(i,l,d)}return i}return Jo=r,Jo}var Zo,Nd;function ww(){if(Nd)return Zo;Nd=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Zo=e,Zo}var Yo,$d;function Pr(){if($d)return Yo;$d=1;function e(t){return t!=null&&typeof t=="object"}return Yo=e,Yo}var Xo,Ld;function Cw(){if(Ld)return Xo;Ld=1;var e=tt(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Xo=n,Xo}var Qo,Fd;function tn(){if(Fd)return Qo;Fd=1;var e=Cw(),t=Pr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return t(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Qo=i,Qo}var ei,Bd;function Xe(){if(Bd)return ei;Bd=1;var e=Array.isArray;return ei=e,ei}var Tt={exports:{}},ri,Dd;function _w(){if(Dd)return ri;Dd=1;function e(){return!1}return ri=e,ri}Tt.exports;var zd;function vt(){return zd||(zd=1,(function(e,t){var r=Sr(),n=_w(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?r.Buffer:void 0,u=a?a.isBuffer:void 0,c=u||n;e.exports=c})(Tt,Tt.exports)),Tt.exports}var ti,Vd;function In(){if(Vd)return ti;Vd=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return ti=r,ti}var ni,Wd;function Gu(){if(Wd)return ni;Wd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ni=t,ni}var oi,Gd;function Sw(){if(Gd)return oi;Gd=1;var e=tt(),t=Gu(),r=Pr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",u="[object Function]",c="[object Map]",l="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",y="[object String]",g="[object WeakMap]",b="[object ArrayBuffer]",x="[object DataView]",m="[object Float32Array]",w="[object Float64Array]",v="[object Int8Array]",C="[object Int16Array]",_="[object Int32Array]",R="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",k="[object Uint32Array]",E={};E[m]=E[w]=E[v]=E[C]=E[_]=E[R]=E[T]=E[A]=E[k]=!0,E[n]=E[o]=E[b]=E[i]=E[x]=E[s]=E[a]=E[u]=E[c]=E[l]=E[d]=E[f]=E[p]=E[y]=E[g]=!1;function j(M){return r(M)&&t(M.length)&&!!E[e(M)]}return oi=j,oi}var ii,Ud;function Mn(){if(Ud)return ii;Ud=1;function e(t){return function(r){return t(r)}}return ii=e,ii}var Ot={exports:{}};Ot.exports;var Hd;function Uu(){return Hd||(Hd=1,(function(e,t){var r=qm(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&r.process,a=(function(){try{var u=o&&o.require&&o.require("util").types;return u||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(Ot,Ot.exports)),Ot.exports}var ai,Kd;function nn(){if(Kd)return ai;Kd=1;var e=Sw(),t=Mn(),r=Uu(),n=r&&r.isTypedArray,o=n?t(n):e;return ai=o,ai}var si,Jd;function Lm(){if(Jd)return si;Jd=1;var e=ww(),t=tn(),r=Xe(),n=vt(),o=In(),i=nn(),s=Object.prototype,a=s.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),y=!d&&!f&&!p&&i(c),g=d||f||p||y,b=g?e(c.length,String):[],x=b.length;for(var m in c)(l||a.call(c,m))&&!(g&&(m=="length"||p&&(m=="offset"||m=="parent")||y&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||o(m,x)))&&b.push(m);return b}return si=u,si}var ci,Zd;function qn(){if(Zd)return ci;Zd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return ci=t,ci}var ui,Yd;function Fm(){if(Yd)return ui;Yd=1;function e(t,r){return function(n){return t(r(n))}}return ui=e,ui}var li,Xd;function Ew(){if(Xd)return li;Xd=1;var e=Fm(),t=e(Object.keys,Object);return li=t,li}var di,Qd;function Hu(){if(Qd)return di;Qd=1;var e=qn(),t=Ew(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return di=o,di}var fi,ef;function Nr(){if(ef)return fi;ef=1;var e=en(),t=Gu();function r(n){return n!=null&&t(n.length)&&!e(n)}return fi=r,fi}var hi,rf;function Hr(){if(rf)return hi;rf=1;var e=Lm(),t=Hu(),r=Nr();function n(o){return r(o)?e(o):t(o)}return hi=n,hi}var pi,tf;function jw(){if(tf)return pi;tf=1;var e=rn(),t=Hr();function r(n,o){return n&&e(o,t(o),n)}return pi=r,pi}var gi,nf;function kw(){if(nf)return gi;nf=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return gi=e,gi}var yi,of;function Rw(){if(of)return yi;of=1;var e=vr(),t=qn(),r=kw(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return r(s);var a=t(s),u=[];for(var c in s)c=="constructor"&&(a||!o.call(s,c))||u.push(c);return u}return yi=i,yi}var mi,af;function ot(){if(af)return mi;af=1;var e=Lm(),t=Rw(),r=Nr();function n(o){return r(o)?e(o,!0):t(o)}return mi=n,mi}var bi,sf;function Pw(){if(sf)return bi;sf=1;var e=rn(),t=ot();function r(n,o){return n&&e(o,t(o),n)}return bi=r,bi}var It={exports:{}};It.exports;var cf;function Bm(){return cf||(cf=1,(function(e,t){var r=Sr(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var d=c.length,f=a?a(d):new c.constructor(d);return c.copy(f),f}e.exports=u})(It,It.exports)),It.exports}var vi,uf;function Dm(){if(uf)return vi;uf=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return vi=e,vi}var xi,lf;function zm(){if(lf)return xi;lf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,s=[];++n<o;){var a=t[n];r(a,n,t)&&(s[i++]=a)}return s}return xi=e,xi}var wi,df;function Vm(){if(df)return wi;df=1;function e(){return[]}return wi=e,wi}var Ci,ff;function Ku(){if(ff)return Ci;ff=1;var e=zm(),t=Vm(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:t;return Ci=i,Ci}var _i,hf;function Aw(){if(hf)return _i;hf=1;var e=rn(),t=Ku();function r(n,o){return e(n,t(n),o)}return _i=r,_i}var Si,pf;function Ju(){if(pf)return Si;pf=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return Si=e,Si}var Ei,gf;function Nn(){if(gf)return Ei;gf=1;var e=Fm(),t=e(Object.getPrototypeOf,Object);return Ei=t,Ei}var ji,yf;function Wm(){if(yf)return ji;yf=1;var e=Ju(),t=Nn(),r=Ku(),n=Vm(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,r(s)),s=t(s);return a}:n;return ji=i,ji}var ki,mf;function Tw(){if(mf)return ki;mf=1;var e=rn(),t=Wm();function r(n,o){return e(n,t(n),o)}return ki=r,ki}var Ri,bf;function Gm(){if(bf)return Ri;bf=1;var e=Ju(),t=Xe();function r(n,o,i){var s=o(n);return t(n)?s:e(s,i(n))}return Ri=r,Ri}var Pi,vf;function Um(){if(vf)return Pi;vf=1;var e=Gm(),t=Ku(),r=Hr();function n(o){return e(o,r,t)}return Pi=n,Pi}var Ai,xf;function Ow(){if(xf)return Ai;xf=1;var e=Gm(),t=Wm(),r=ot();function n(o){return e(o,r,t)}return Ai=n,Ai}var Ti,wf;function Iw(){if(wf)return Ti;wf=1;var e=nt(),t=Sr(),r=e(t,"DataView");return Ti=r,Ti}var Oi,Cf;function Mw(){if(Cf)return Oi;Cf=1;var e=nt(),t=Sr(),r=e(t,"Promise");return Oi=r,Oi}var Ii,_f;function Hm(){if(_f)return Ii;_f=1;var e=nt(),t=Sr(),r=e(t,"Set");return Ii=r,Ii}var Mi,Sf;function qw(){if(Sf)return Mi;Sf=1;var e=nt(),t=Sr(),r=e(t,"WeakMap");return Mi=r,Mi}var qi,Ef;function xt(){if(Ef)return qi;Ef=1;var e=Iw(),t=zu(),r=Mw(),n=Hm(),o=qw(),i=tt(),s=Nm(),a="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=s(e),y=s(t),g=s(r),b=s(n),x=s(o),m=i;return(e&&m(new e(new ArrayBuffer(1)))!=f||t&&m(new t)!=a||r&&m(r.resolve())!=c||n&&m(new n)!=l||o&&m(new o)!=d)&&(m=function(w){var v=i(w),C=v==u?w.constructor:void 0,_=C?s(C):"";if(_)switch(_){case p:return f;case y:return a;case g:return c;case b:return l;case x:return d}return v}),qi=m,qi}var Ni,jf;function Nw(){if(jf)return Ni;jf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Ni=r,Ni}var $i,kf;function Km(){if(kf)return $i;kf=1;var e=Sr(),t=e.Uint8Array;return $i=t,$i}var Li,Rf;function Zu(){if(Rf)return Li;Rf=1;var e=Km();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return Li=t,Li}var Fi,Pf;function $w(){if(Pf)return Fi;Pf=1;var e=Zu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Fi=t,Fi}var Bi,Af;function Lw(){if(Af)return Bi;Af=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Bi=t,Bi}var Di,Tf;function Fw(){if(Tf)return Di;Tf=1;var e=bt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Di=n,Di}var zi,Of;function Jm(){if(Of)return zi;Of=1;var e=Zu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return zi=t,zi}var Vi,If;function Bw(){if(If)return Vi;If=1;var e=Zu(),t=$w(),r=Lw(),n=Fw(),o=Jm(),i="[object Boolean]",s="[object Date]",a="[object Map]",u="[object Number]",c="[object RegExp]",l="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",g="[object Float32Array]",b="[object Float64Array]",x="[object Int8Array]",m="[object Int16Array]",w="[object Int32Array]",v="[object Uint8Array]",C="[object Uint8ClampedArray]",_="[object Uint16Array]",R="[object Uint32Array]";function T(A,k,E){var j=A.constructor;switch(k){case p:return e(A);case i:case s:return new j(+A);case y:return t(A,E);case g:case b:case x:case m:case w:case v:case C:case _:case R:return o(A,E);case a:return new j;case u:case d:return new j(A);case c:return r(A);case l:return new j;case f:return n(A)}}return Vi=T,Vi}var Wi,Mf;function Zm(){if(Mf)return Wi;Mf=1;var e=vr(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Wi=r,Wi}var Gi,qf;function Ym(){if(qf)return Gi;qf=1;var e=Zm(),t=Nn(),r=qn();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Gi=n,Gi}var Ui,Nf;function Dw(){if(Nf)return Ui;Nf=1;var e=xt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Ui=n,Ui}var Hi,$f;function zw(){if($f)return Hi;$f=1;var e=Dw(),t=Mn(),r=Uu(),n=r&&r.isMap,o=n?t(n):e;return Hi=o,Hi}var Ki,Lf;function Vw(){if(Lf)return Ki;Lf=1;var e=xt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Ki=n,Ki}var Ji,Ff;function Ww(){if(Ff)return Ji;Ff=1;var e=Vw(),t=Mn(),r=Uu(),n=r&&r.isSet,o=n?t(n):e;return Ji=o,Ji}var Zi,Bf;function Xm(){if(Bf)return Zi;Bf=1;var e=An(),t=Wu(),r=On(),n=jw(),o=Pw(),i=Bm(),s=Dm(),a=Aw(),u=Tw(),c=Um(),l=Ow(),d=xt(),f=Nw(),p=Bw(),y=Ym(),g=Xe(),b=vt(),x=zw(),m=vr(),w=Ww(),v=Hr(),C=ot(),_=1,R=2,T=4,A="[object Arguments]",k="[object Array]",E="[object Boolean]",j="[object Date]",M="[object Error]",I="[object Function]",q="[object GeneratorFunction]",O="[object Map]",V="[object Number]",W="[object Object]",re="[object RegExp]",Y="[object Set]",he="[object String]",me="[object Symbol]",J="[object WeakMap]",N="[object ArrayBuffer]",L="[object DataView]",G="[object Float32Array]",D="[object Float64Array]",ne="[object Int8Array]",ue="[object Int16Array]",X="[object Int32Array]",U="[object Uint8Array]",K="[object Uint8ClampedArray]",te="[object Uint16Array]",ce="[object Uint32Array]",de={};de[A]=de[k]=de[N]=de[L]=de[E]=de[j]=de[G]=de[D]=de[ne]=de[ue]=de[X]=de[O]=de[V]=de[W]=de[re]=de[Y]=de[he]=de[me]=de[U]=de[K]=de[te]=de[ce]=!0,de[M]=de[I]=de[J]=!1;function Ae(ge,Ke,Oe,Le,er,Ve){var $e,xe=Ke&_,Me=Ke&R,Fe=Ke&T;if(Oe&&($e=er?Oe(ge,Le,er,Ve):Oe(ge)),$e!==void 0)return $e;if(!m(ge))return ge;var nr=g(ge);if(nr){if($e=f(ge),!xe)return s(ge,$e)}else{var Ze=d(ge),Ye=Ze==I||Ze==q;if(b(ge))return i(ge,xe);if(Ze==W||Ze==A||Ye&&!er){if($e=Me||Ye?{}:y(ge),!xe)return Me?u(ge,o($e,ge)):a(ge,n($e,ge))}else{if(!de[Ze])return er?ge:{};$e=p(ge,Ze,xe)}}Ve||(Ve=new e);var fr=Ve.get(ge);if(fr)return fr;Ve.set(ge,$e),w(ge)?ge.forEach(function(ar){$e.add(Ae(ar,Ke,Oe,ar,ge,Ve))}):x(ge)&&ge.forEach(function(ar,sr){$e.set(sr,Ae(ar,Ke,Oe,sr,ge,Ve))});var wr=Fe?Me?l:c:Me?C:v,we=nr?void 0:wr(ge);return t(we||ge,function(ar,sr){we&&(sr=ar,ar=ge[sr]),r($e,sr,Ae(ar,Ke,Oe,sr,ge,Ve))}),$e}return Zi=Ae,Zi}var Yi,Df;function Gw(){if(Df)return Yi;Df=1;var e=Xm(),t=4;function r(n){return e(n,t)}return Yi=r,Yi}var Xi,zf;function Yu(){if(zf)return Xi;zf=1;function e(t){return function(){return t}}return Xi=e,Xi}var Qi,Vf;function Uw(){if(Vf)return Qi;Vf=1;function e(t){return function(r,n,o){for(var i=-1,s=Object(r),a=o(r),u=a.length;u--;){var c=a[t?u:++i];if(n(s[c],c,s)===!1)break}return r}}return Qi=e,Qi}var ea,Wf;function Xu(){if(Wf)return ea;Wf=1;var e=Uw(),t=e();return ea=t,ea}var ra,Gf;function Qu(){if(Gf)return ra;Gf=1;var e=Xu(),t=Hr();function r(n,o){return n&&e(n,o,t)}return ra=r,ra}var ta,Uf;function Hw(){if(Uf)return ta;Uf=1;var e=Nr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var s=o.length,a=n?s:-1,u=Object(o);(n?a--:++a<s)&&i(u[a],a,u)!==!1;);return o}}return ta=t,ta}var na,Hf;function $n(){if(Hf)return na;Hf=1;var e=Qu(),t=Hw(),r=t(e);return na=r,na}var oa,Kf;function it(){if(Kf)return oa;Kf=1;function e(t){return t}return oa=e,oa}var ia,Jf;function Qm(){if(Jf)return ia;Jf=1;var e=it();function t(r){return typeof r=="function"?r:e}return ia=t,ia}var aa,Zf;function eb(){if(Zf)return aa;Zf=1;var e=Wu(),t=$n(),r=Qm(),n=Xe();function o(i,s){var a=n(i)?e:t;return a(i,r(s))}return aa=o,aa}var sa,Yf;function rb(){return Yf||(Yf=1,sa=eb()),sa}var ca,Xf;function Kw(){if(Xf)return ca;Xf=1;var e=$n();function t(r,n){var o=[];return e(r,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return ca=t,ca}var ua,Qf;function Jw(){if(Qf)return ua;Qf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return ua=t,ua}var la,eh;function Zw(){if(eh)return la;eh=1;function e(t){return this.__data__.has(t)}return la=e,la}var da,rh;function tb(){if(rh)return da;rh=1;var e=Vu(),t=Jw(),r=Zw();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=t,n.prototype.has=r,da=n,da}var fa,th;function Yw(){if(th)return fa;th=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return fa=e,fa}var ha,nh;function nb(){if(nh)return ha;nh=1;function e(t,r){return t.has(r)}return ha=e,ha}var pa,oh;function ob(){if(oh)return pa;oh=1;var e=tb(),t=Yw(),r=nb(),n=1,o=2;function i(s,a,u,c,l,d){var f=u&n,p=s.length,y=a.length;if(p!=y&&!(f&&y>p))return!1;var g=d.get(s),b=d.get(a);if(g&&b)return g==a&&b==s;var x=-1,m=!0,w=u&o?new e:void 0;for(d.set(s,a),d.set(a,s);++x<p;){var v=s[x],C=a[x];if(c)var _=f?c(C,v,x,a,s,d):c(v,C,x,s,a,d);if(_!==void 0){if(_)continue;m=!1;break}if(w){if(!t(a,function(R,T){if(!r(w,T)&&(v===R||l(v,R,u,c,d)))return w.push(T)})){m=!1;break}}else if(!(v===C||l(v,C,u,c,d))){m=!1;break}}return d.delete(s),d.delete(a),m}return pa=i,pa}var ga,ih;function Xw(){if(ih)return ga;ih=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return ga=e,ga}var ya,ah;function el(){if(ah)return ya;ah=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return ya=e,ya}var ma,sh;function Qw(){if(sh)return ma;sh=1;var e=bt(),t=Km(),r=mt(),n=ob(),o=Xw(),i=el(),s=1,a=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",y="[object Set]",g="[object String]",b="[object Symbol]",x="[object ArrayBuffer]",m="[object DataView]",w=e?e.prototype:void 0,v=w?w.valueOf:void 0;function C(_,R,T,A,k,E,j){switch(T){case m:if(_.byteLength!=R.byteLength||_.byteOffset!=R.byteOffset)return!1;_=_.buffer,R=R.buffer;case x:return!(_.byteLength!=R.byteLength||!E(new t(_),new t(R)));case u:case c:case f:return r(+_,+R);case l:return _.name==R.name&&_.message==R.message;case p:case g:return _==R+"";case d:var M=o;case y:var I=A&s;if(M||(M=i),_.size!=R.size&&!I)return!1;var q=j.get(_);if(q)return q==R;A|=a,j.set(_,R);var O=n(M(_),M(R),A,k,E,j);return j.delete(_),O;case b:if(v)return v.call(_)==v.call(R)}return!1}return ma=C,ma}var ba,ch;function e1(){if(ch)return ba;ch=1;var e=Um(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,s,a,u,c,l){var d=a&t,f=e(i),p=f.length,y=e(s),g=y.length;if(p!=g&&!d)return!1;for(var b=p;b--;){var x=f[b];if(!(d?x in s:n.call(s,x)))return!1}var m=l.get(i),w=l.get(s);if(m&&w)return m==s&&w==i;var v=!0;l.set(i,s),l.set(s,i);for(var C=d;++b<p;){x=f[b];var _=i[x],R=s[x];if(u)var T=d?u(R,_,x,s,i,l):u(_,R,x,i,s,l);if(!(T===void 0?_===R||c(_,R,a,u,l):T)){v=!1;break}C||(C=x=="constructor")}if(v&&!C){var A=i.constructor,k=s.constructor;A!=k&&"constructor"in i&&"constructor"in s&&!(typeof A=="function"&&A instanceof A&&typeof k=="function"&&k instanceof k)&&(v=!1)}return l.delete(i),l.delete(s),v}return ba=o,ba}var va,uh;function r1(){if(uh)return va;uh=1;var e=An(),t=ob(),r=Qw(),n=e1(),o=xt(),i=Xe(),s=vt(),a=nn(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function y(g,b,x,m,w,v){var C=i(g),_=i(b),R=C?l:o(g),T=_?l:o(b);R=R==c?d:R,T=T==c?d:T;var A=R==d,k=T==d,E=R==T;if(E&&s(g)){if(!s(b))return!1;C=!0,A=!1}if(E&&!A)return v||(v=new e),C||a(g)?t(g,b,x,m,w,v):r(g,b,R,x,m,w,v);if(!(x&u)){var j=A&&p.call(g,"__wrapped__"),M=k&&p.call(b,"__wrapped__");if(j||M){var I=j?g.value():g,q=M?b.value():b;return v||(v=new e),w(I,q,x,m,v)}}return E?(v||(v=new e),n(g,b,x,m,w,v)):!1}return va=y,va}var xa,lh;function ib(){if(lh)return xa;lh=1;var e=r1(),t=Pr();function r(n,o,i,s,a){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,s,r,a)}return xa=r,xa}var wa,dh;function t1(){if(dh)return wa;dh=1;var e=An(),t=ib(),r=1,n=2;function o(i,s,a,u){var c=a.length,l=c,d=!u;if(i==null)return!l;for(i=Object(i);c--;){var f=a[c];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++c<l;){f=a[c];var p=f[0],y=i[p],g=f[1];if(d&&f[2]){if(y===void 0&&!(p in i))return!1}else{var b=new e;if(u)var x=u(y,g,p,i,s,b);if(!(x===void 0?t(g,y,r|n,u,b):x))return!1}}return!0}return wa=o,wa}var Ca,fh;function ab(){if(fh)return Ca;fh=1;var e=vr();function t(r){return r===r&&!e(r)}return Ca=t,Ca}var _a,hh;function n1(){if(hh)return _a;hh=1;var e=ab(),t=Hr();function r(n){for(var o=t(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return _a=r,_a}var Sa,ph;function sb(){if(ph)return Sa;ph=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Sa=e,Sa}var Ea,gh;function o1(){if(gh)return Ea;gh=1;var e=t1(),t=n1(),r=sb();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return Ea=n,Ea}var ja,yh;function wt(){if(yh)return ja;yh=1;var e=tt(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return ja=n,ja}var ka,mh;function rl(){if(mh)return ka;mh=1;var e=Xe(),t=wt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\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||t(i)?!0:n.test(i)||!r.test(i)||s!=null&&i in Object(s)}return ka=o,ka}var Ra,bh;function i1(){if(bh)return Ra;bh=1;var e=Vu(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],u=i.cache;if(u.has(a))return u.get(a);var c=n.apply(this,s);return i.cache=u.set(a,c)||u,c};return i.cache=new(r.Cache||e),i}return r.Cache=e,Ra=r,Ra}var Pa,vh;function a1(){if(vh)return Pa;vh=1;var e=i1(),t=500;function r(n){var o=e(n,function(s){return i.size===t&&i.clear(),s}),i=o.cache;return o}return Pa=r,Pa}var Aa,xh;function s1(){if(xh)return Aa;xh=1;var e=a1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(s,a,u,c){i.push(u?c.replace(r,"$1"):a||s)}),i});return Aa=n,Aa}var Ta,wh;function Ln(){if(wh)return Ta;wh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return Ta=e,Ta}var Oa,Ch;function c1(){if(Ch)return Oa;Ch=1;var e=bt(),t=Ln(),r=Xe(),n=wt(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(r(a))return t(a,s)+"";if(n(a))return i?i.call(a):"";var u=a+"";return u=="0"&&1/a==-1/0?"-0":u}return Oa=s,Oa}var Ia,_h;function cb(){if(_h)return Ia;_h=1;var e=c1();function t(r){return r==null?"":e(r)}return Ia=t,Ia}var Ma,Sh;function Fn(){if(Sh)return Ma;Sh=1;var e=Xe(),t=rl(),r=s1(),n=cb();function o(i,s){return e(i)?i:t(i,s)?[i]:r(n(i))}return Ma=o,Ma}var qa,Eh;function on(){if(Eh)return qa;Eh=1;var e=wt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return qa=t,qa}var Na,jh;function Bn(){if(jh)return Na;jh=1;var e=Fn(),t=on();function r(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[t(o[i++])];return i&&i==s?n:void 0}return Na=r,Na}var $a,kh;function u1(){if(kh)return $a;kh=1;var e=Bn();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return $a=t,$a}var La,Rh;function l1(){if(Rh)return La;Rh=1;function e(t,r){return t!=null&&r in Object(t)}return La=e,La}var Fa,Ph;function ub(){if(Ph)return Fa;Ph=1;var e=Fn(),t=tn(),r=Xe(),n=In(),o=Gu(),i=on();function s(a,u,c){u=e(u,a);for(var l=-1,d=u.length,f=!1;++l<d;){var p=i(u[l]);if(!(f=a!=null&&c(a,p)))break;a=a[p]}return f||++l!=d?f:(d=a==null?0:a.length,!!d&&o(d)&&n(p,d)&&(r(a)||t(a)))}return Fa=s,Fa}var Ba,Ah;function lb(){if(Ah)return Ba;Ah=1;var e=l1(),t=ub();function r(n,o){return n!=null&&t(n,o,e)}return Ba=r,Ba}var Da,Th;function d1(){if(Th)return Da;Th=1;var e=ib(),t=u1(),r=lb(),n=rl(),o=ab(),i=sb(),s=on(),a=1,u=2;function c(l,d){return n(l)&&o(d)?i(s(l),d):function(f){var p=t(f,l);return p===void 0&&p===d?r(f,l):e(d,p,a|u)}}return Da=c,Da}var za,Oh;function db(){if(Oh)return za;Oh=1;function e(t){return function(r){return r==null?void 0:r[t]}}return za=e,za}var Va,Ih;function f1(){if(Ih)return Va;Ih=1;var e=Bn();function t(r){return function(n){return e(n,r)}}return Va=t,Va}var Wa,Mh;function h1(){if(Mh)return Wa;Mh=1;var e=db(),t=f1(),r=rl(),n=on();function o(i){return r(i)?e(n(i)):t(i)}return Wa=o,Wa}var Ga,qh;function $r(){if(qh)return Ga;qh=1;var e=o1(),t=d1(),r=it(),n=Xe(),o=h1();function i(s){return typeof s=="function"?s:s==null?r:typeof s=="object"?n(s)?t(s[0],s[1]):e(s):o(s)}return Ga=i,Ga}var Ua,Nh;function fb(){if(Nh)return Ua;Nh=1;var e=zm(),t=Kw(),r=$r(),n=Xe();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Ua=o,Ua}var Ha,$h;function p1(){if($h)return Ha;$h=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Ha=r,Ha}var Ka,Lh;function hb(){if(Lh)return Ka;Lh=1;var e=p1(),t=ub();function r(n,o){return n!=null&&t(n,o,e)}return Ka=r,Ka}var Ja,Fh;function g1(){if(Fh)return Ja;Fh=1;var e=Hu(),t=xt(),r=tn(),n=Xe(),o=Nr(),i=vt(),s=qn(),a=nn(),u="[object Map]",c="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||r(p)))return!p.length;var y=t(p);if(y==u||y==c)return!p.size;if(s(p))return!e(p).length;for(var g in p)if(d.call(p,g))return!1;return!0}return Ja=f,Ja}var Za,Bh;function pb(){if(Bh)return Za;Bh=1;function e(t){return t===void 0}return Za=e,Za}var Ya,Dh;function gb(){if(Dh)return Ya;Dh=1;var e=$n(),t=Nr();function r(n,o){var i=-1,s=t(n)?Array(n.length):[];return e(n,function(a,u,c){s[++i]=o(a,u,c)}),s}return Ya=r,Ya}var Xa,zh;function yb(){if(zh)return Xa;zh=1;var e=Ln(),t=$r(),r=gb(),n=Xe();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Xa=o,Xa}var Qa,Vh;function y1(){if(Vh)return Qa;Vh=1;function e(t,r,n,o){var i=-1,s=t==null?0:t.length;for(o&&s&&(n=t[++i]);++i<s;)n=r(n,t[i],i,t);return n}return Qa=e,Qa}var es,Wh;function m1(){if(Wh)return es;Wh=1;function e(t,r,n,o,i){return i(t,function(s,a,u){n=o?(o=!1,s):r(n,s,a,u)}),n}return es=e,es}var rs,Gh;function mb(){if(Gh)return rs;Gh=1;var e=y1(),t=$n(),r=$r(),n=m1(),o=Xe();function i(s,a,u){var c=o(s)?e:n,l=arguments.length<3;return c(s,r(a,4),u,l,t)}return rs=i,rs}var ts,Uh;function b1(){if(Uh)return ts;Uh=1;var e=tt(),t=Xe(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return ts=o,ts}var ns,Hh;function v1(){if(Hh)return ns;Hh=1;var e=db(),t=e("length");return ns=t,ns}var os,Kh;function x1(){if(Kh)return os;Kh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function u(c){return a.test(c)}return os=u,os}var is,Jh;function w1(){if(Jh)return is;Jh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+a+"|"+u+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=c+"?",g="["+i+"]?",b="(?:"+p+"(?:"+[l,d,f].join("|")+")"+g+y+")*",x=g+y+b,m="(?:"+[l+a+"?",a,d,f,s].join("|")+")",w=RegExp(u+"(?="+u+")|"+m+x,"g");function v(C){for(var _=w.lastIndex=0;w.test(C);)++_;return _}return is=v,is}var as,Zh;function C1(){if(Zh)return as;Zh=1;var e=v1(),t=x1(),r=w1();function n(o){return t(o)?r(o):e(o)}return as=n,as}var ss,Yh;function _1(){if(Yh)return ss;Yh=1;var e=Hu(),t=xt(),r=Nr(),n=b1(),o=C1(),i="[object Map]",s="[object Set]";function a(u){if(u==null)return 0;if(r(u))return n(u)?o(u):u.length;var c=t(u);return c==i||c==s?u.size:e(u).length}return ss=a,ss}var cs,Xh;function S1(){if(Xh)return cs;Xh=1;var e=Wu(),t=Zm(),r=Qu(),n=$r(),o=Nn(),i=Xe(),s=vt(),a=en(),u=vr(),c=nn();function l(d,f,p){var y=i(d),g=y||s(d)||c(d);if(f=n(f,4),p==null){var b=d&&d.constructor;g?p=y?new b:[]:u(d)?p=a(b)?t(o(d)):{}:p={}}return(g?e:r)(d,function(x,m,w){return f(p,x,m,w)}),p}return cs=l,cs}var us,Qh;function E1(){if(Qh)return us;Qh=1;var e=bt(),t=tn(),r=Xe(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return us=o,us}var ls,ep;function tl(){if(ep)return ls;ep=1;var e=Ju(),t=E1();function r(n,o,i,s,a){var u=-1,c=n.length;for(i||(i=t),a||(a=[]);++u<c;){var l=n[u];o>0&&i(l)?o>1?r(l,o-1,i,s,a):e(a,l):s||(a[a.length]=l)}return a}return ls=r,ls}var ds,rp;function j1(){if(rp)return ds;rp=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return ds=e,ds}var fs,tp;function bb(){if(tp)return fs;tp=1;var e=j1(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,u=t(s.length-o,0),c=Array(u);++a<u;)c[a]=s[o+a];a=-1;for(var l=Array(o+1);++a<o;)l[a]=s[a];return l[o]=i(c),e(n,this,l)}}return fs=r,fs}var hs,np;function k1(){if(np)return hs;np=1;var e=Yu(),t=$m(),r=it(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return hs=n,hs}var ps,op;function R1(){if(op)return ps;op=1;var e=800,t=16,r=Date.now;function n(o){var i=0,s=0;return function(){var a=r(),u=t-(a-s);if(s=a,u>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return ps=n,ps}var gs,ip;function vb(){if(ip)return gs;ip=1;var e=k1(),t=R1(),r=t(e);return gs=r,gs}var ys,ap;function Dn(){if(ap)return ys;ap=1;var e=it(),t=bb(),r=vb();function n(o,i){return r(t(o,i,e),o+"")}return ys=n,ys}var ms,sp;function xb(){if(sp)return ms;sp=1;function e(t,r,n,o){for(var i=t.length,s=n+(o?1:-1);o?s--:++s<i;)if(r(t[s],s,t))return s;return-1}return ms=e,ms}var bs,cp;function P1(){if(cp)return bs;cp=1;function e(t){return t!==t}return bs=e,bs}var vs,up;function A1(){if(up)return vs;up=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return vs=e,vs}var xs,lp;function T1(){if(lp)return xs;lp=1;var e=xb(),t=P1(),r=A1();function n(o,i,s){return i===i?r(o,i,s):e(o,t,s)}return xs=n,xs}var ws,dp;function O1(){if(dp)return ws;dp=1;var e=T1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return ws=t,ws}var Cs,fp;function I1(){if(fp)return Cs;fp=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return Cs=e,Cs}var _s,hp;function M1(){if(hp)return _s;hp=1;function e(){}return _s=e,_s}var Ss,pp;function q1(){if(pp)return Ss;pp=1;var e=Hm(),t=M1(),r=el(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return Ss=o,Ss}var Es,gp;function N1(){if(gp)return Es;gp=1;var e=tb(),t=O1(),r=I1(),n=nb(),o=q1(),i=el(),s=200;function a(u,c,l){var d=-1,f=t,p=u.length,y=!0,g=[],b=g;if(l)y=!1,f=r;else if(p>=s){var x=c?null:o(u);if(x)return i(x);y=!1,f=n,b=new e}else b=c?[]:g;e:for(;++d<p;){var m=u[d],w=c?c(m):m;if(m=l||m!==0?m:0,y&&w===w){for(var v=b.length;v--;)if(b[v]===w)continue e;c&&b.push(w),g.push(m)}else f(b,w,l)||(b!==g&&b.push(w),g.push(m))}return g}return Es=a,Es}var js,yp;function wb(){if(yp)return js;yp=1;var e=Nr(),t=Pr();function r(n){return t(n)&&e(n)}return js=r,js}var ks,mp;function $1(){if(mp)return ks;mp=1;var e=tl(),t=Dn(),r=N1(),n=wb(),o=t(function(i){return r(e(i,1,n,!0))});return ks=o,ks}var Rs,bp;function L1(){if(bp)return Rs;bp=1;var e=Ln();function t(r,n){return e(n,function(o){return r[o]})}return Rs=t,Rs}var Ps,vp;function Cb(){if(vp)return Ps;vp=1;var e=L1(),t=Hr();function r(n){return n==null?[]:e(n,t(n))}return Ps=r,Ps}var As,xp;function xr(){if(xp)return As;xp=1;var e;if(typeof Du=="function")try{e={clone:Gw(),constant:Yu(),each:rb(),filter:fb(),has:hb(),isArray:Xe(),isEmpty:g1(),isFunction:en(),isUndefined:pb(),keys:Hr(),map:yb(),reduce:mb(),size:_1(),transform:S1(),union:$1(),values:Cb()}}catch{}return e||(e=window._),As=e,As}var Ts,wp;function nl(){if(wp)return Ts;wp=1;var e=xr();Ts=o;var t="\0",r="\0",n="";function o(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.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[r]={}),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(l){return this._label=l,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},o.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},o.prototype.setNodes=function(l,d){var f=arguments,p=this;return e.each(l,function(y){f.length>1?p.setNode(y,d):p.setNode(y)}),this},o.prototype.setNode=function(l,d){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=d),this):(this._nodes[l]=arguments.length>1?d:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},o.prototype.node=function(l){return this._nodes[l]},o.prototype.hasNode=function(l){return e.has(this._nodes,l)},o.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var f=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(p){d.setParent(p)}),delete this._children[l]),e.each(e.keys(this._in[l]),f),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),f),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},o.prototype.setParent=function(l,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=r;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===l)throw new Error("Setting "+d+" as parent of "+l+" would create a cycle");this.setNode(d)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=d,this._children[d][l]=!0,this},o.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},o.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},o.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var d=this._children[l];if(d)return e.keys(d)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},o.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},o.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},o.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},o.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},o.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(g,b){l(b)&&d.setNode(b,g)}),e.each(this._edgeObjs,function(g){d.hasNode(g.v)&&d.hasNode(g.w)&&d.setEdge(g,f.edge(g))});var p={};function y(g){var b=f.parent(g);return b===void 0||d.hasNode(b)?(p[g]=b,b):b in p?p[b]:y(b)}return this._isCompound&&e.each(d.nodes(),function(g){d.setParent(g,y(g))}),d},o.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(l,d){var f=this,p=arguments;return e.reduce(l,function(y,g){return p.length>1?f.setEdge(y,g,d):f.setEdge(y,g),g}),this},o.prototype.setEdge=function(){var l,d,f,p,y=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(l=g.v,d=g.w,f=g.name,arguments.length===2&&(p=arguments[1],y=!0)):(l=g,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var b=a(this._isDirected,l,d,f);if(e.has(this._edgeLabels,b))return y&&(this._edgeLabels[b]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[b]=y?p:this._defaultEdgeLabelFn(l,d,f);var x=u(this._isDirected,l,d,f);return l=x.v,d=x.w,Object.freeze(x),this._edgeObjs[b]=x,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][b]=x,this._out[l][b]=x,this._edgeCount++,this},o.prototype.edge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,l,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,l,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,l,d,f),y=this._edgeObjs[p];return y&&(l=y.v,d=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[d],l),s(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},o.prototype.inEdges=function(l,d){var f=this._in[l];if(f){var p=e.values(f);return d?e.filter(p,function(y){return y.v===d}):p}},o.prototype.outEdges=function(l,d){var f=this._out[l];if(f){var p=e.values(f);return d?e.filter(p,function(y){return y.w===d}):p}},o.prototype.nodeEdges=function(l,d){var f=this.inEdges(l,d);if(f)return f.concat(this.outEdges(l,d))};function i(l,d){l[d]?l[d]++:l[d]=1}function s(l,d){--l[d]||delete l[d]}function a(l,d,f,p){var y=""+d,g=""+f;if(!l&&y>g){var b=y;y=g,g=b}return y+n+g+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var y=""+d,g=""+f;if(!l&&y>g){var b=y;y=g,g=b}var x={v:y,w:g};return p&&(x.name=p),x}function c(l,d){return a(l,d.v,d.w,d.name)}return Ts}var Os,Cp;function F1(){return Cp||(Cp=1,Os="2.1.8"),Os}var Is,_p;function B1(){return _p||(_p=1,Is={Graph:nl(),version:F1()}),Is}var Ms,Sp;function D1(){if(Sp)return Ms;Sp=1;var e=xr(),t=nl();Ms={write:r,read:i};function r(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 u=s.node(a),c=s.parent(a),l={v:a};return e.isUndefined(u)||(l.value=u),e.isUndefined(c)||(l.parent=c),l})}function o(s){return e.map(s.edges(),function(a){var u=s.edge(a),c={v:a.v,w:a.w};return e.isUndefined(a.name)||(c.name=a.name),e.isUndefined(u)||(c.value=u),c})}function i(s){var a=new t(s.options).setGraph(s.value);return e.each(s.nodes,function(u){a.setNode(u.v,u.value),u.parent&&a.setParent(u.v,u.parent)}),e.each(s.edges,function(u){a.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),a}return Ms}var qs,Ep;function z1(){if(Ep)return qs;Ep=1;var e=xr();qs=t;function t(r){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(r.successors(a),s),e.each(r.predecessors(a),s))}return e.each(r.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return qs}var Ns,jp;function _b(){if(jp)return Ns;jp=1;var e=xr();Ns=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,s=i.length;return o[r]=s,i.push({key:r,priority:n}),this._decrease(s),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,s=r;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!==r&&(this._swap(r,s),this._heapify(s)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,s=o[r],a=o[n];o[r]=a,o[n]=s,i[a.key]=r,i[s.key]=n},Ns}var $s,kp;function Sb(){if(kp)return $s;kp=1;var e=xr(),t=_b();$s=n;var r=e.constant(1);function n(i,s,a,u){return o(i,String(s),a||r,u||function(c){return i.outEdges(c)})}function o(i,s,a,u){var c={},l=new t,d,f,p=function(y){var g=y.v!==d?y.v:y.w,b=c[g],x=a(y),m=f.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+x);m<b.distance&&(b.distance=m,b.predecessor=d,l.decrease(g,m))};for(i.nodes().forEach(function(y){var g=y===s?0:Number.POSITIVE_INFINITY;c[y]={distance:g},l.add(y,g)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return $s}var Ls,Rp;function V1(){if(Rp)return Ls;Rp=1;var e=Sb(),t=xr();Ls=r;function r(n,o,i){return t.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return Ls}var Fs,Pp;function Eb(){if(Pp)return Fs;Pp=1;var e=xr();Fs=t;function t(r){var n=0,o=[],i={},s=[];function a(u){var c=i[u]={onStack:!0,lowlink:n,index:n++};if(o.push(u),r.successors(u).forEach(function(f){e.has(i,f)?i[f].onStack&&(c.lowlink=Math.min(c.lowlink,i[f].index)):(a(f),c.lowlink=Math.min(c.lowlink,i[f].lowlink))}),c.lowlink===c.index){var l=[],d;do d=o.pop(),i[d].onStack=!1,l.push(d);while(u!==d);s.push(l)}}return r.nodes().forEach(function(u){e.has(i,u)||a(u)}),s}return Fs}var Bs,Ap;function W1(){if(Ap)return Bs;Ap=1;var e=xr(),t=Eb();Bs=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Bs}var Ds,Tp;function G1(){if(Tp)return Ds;Tp=1;var e=xr();Ds=r;var t=e.constant(1);function r(o,i,s){return n(o,i||t,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},u=o.nodes();return u.forEach(function(c){a[c]={},a[c][c]={distance:0},u.forEach(function(l){c!==l&&(a[c][l]={distance:Number.POSITIVE_INFINITY})}),s(c).forEach(function(l){var d=l.v===c?l.w:l.v,f=i(l);a[c][d]={distance:f,predecessor:c}})}),u.forEach(function(c){var l=a[c];u.forEach(function(d){var f=a[d];u.forEach(function(p){var y=f[c],g=l[p],b=f[p],x=y.distance+g.distance;x<b.distance&&(b.distance=x,b.predecessor=g.predecessor)})})}),a}return Ds}var zs,Op;function jb(){if(Op)return zs;Op=1;var e=xr();zs=t,t.CycleException=r;function t(n){var o={},i={},s=[];function a(u){if(e.has(i,u))throw new r;e.has(o,u)||(i[u]=!0,o[u]=!0,e.each(n.predecessors(u),a),delete i[u],s.push(u))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new r;return s}function r(){}return r.prototype=new Error,zs}var Vs,Ip;function U1(){if(Ip)return Vs;Ip=1;var e=jb();Vs=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Vs}var Ws,Mp;function kb(){if(Mp)return Ws;Mp=1;var e=xr();Ws=t;function t(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],u={};return e.each(o,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);r(n,c,i==="post",u,s,a)}),a}function r(n,o,i,s,a,u){e.has(s,o)||(s[o]=!0,i||u.push(o),e.each(a(o),function(c){r(n,c,i,s,a,u)}),i&&u.push(o))}return Ws}var Gs,qp;function H1(){if(qp)return Gs;qp=1;var e=kb();Gs=t;function t(r,n){return e(r,n,"post")}return Gs}var Us,Np;function K1(){if(Np)return Us;Np=1;var e=kb();Us=t;function t(r,n){return e(r,n,"pre")}return Us}var Hs,$p;function J1(){if($p)return Hs;$p=1;var e=xr(),t=nl(),r=_b();Hs=n;function n(o,i){var s=new t,a={},u=new r,c;function l(f){var p=f.v===c?f.w:f.v,y=u.priority(p);if(y!==void 0){var g=i(f);g<y&&(a[p]=c,u.decrease(p,g))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(f){u.add(f,Number.POSITIVE_INFINITY),s.setNode(f)}),u.decrease(o.nodes()[0],0);for(var d=!1;u.size()>0;){if(c=u.removeMin(),e.has(a,c))s.setEdge(c,a[c]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(c).forEach(l)}return s}return Hs}var Ks,Lp;function Z1(){return Lp||(Lp=1,Ks={components:z1(),dijkstra:Sb(),dijkstraAll:V1(),findCycles:W1(),floydWarshall:G1(),isAcyclic:U1(),postorder:H1(),preorder:K1(),prim:J1(),tarjan:Eb(),topsort:jb()}),Ks}var Js,Fp;function Y1(){if(Fp)return Js;Fp=1;var e=B1();return Js={Graph:e.Graph,json:D1(),alg:Z1(),version:e.version},Js}var Zs,Bp;function _r(){if(Bp)return Zs;Bp=1;var e;if(typeof Du=="function")try{e=Y1()}catch{}return e||(e=window.graphlib),Zs=e,Zs}var Ys,Dp;function X1(){if(Dp)return Ys;Dp=1;var e=Xm(),t=1,r=4;function n(o){return e(o,t|r)}return Ys=n,Ys}var Xs,zp;function zn(){if(zp)return Xs;zp=1;var e=mt(),t=Nr(),r=In(),n=vr();function o(i,s,a){if(!n(a))return!1;var u=typeof s;return(u=="number"?t(a)&&r(s,a.length):u=="string"&&s in a)?e(a[s],i):!1}return Xs=o,Xs}var Qs,Vp;function Q1(){if(Vp)return Qs;Vp=1;var e=Dn(),t=mt(),r=zn(),n=ot(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,u){a=Object(a);var c=-1,l=u.length,d=l>2?u[2]:void 0;for(d&&r(u[0],u[1],d)&&(l=1);++c<l;)for(var f=u[c],p=n(f),y=-1,g=p.length;++y<g;){var b=p[y],x=a[b];(x===void 0||t(x,o[b])&&!i.call(a,b))&&(a[b]=f[b])}return a});return Qs=s,Qs}var ec,Wp;function eC(){if(Wp)return ec;Wp=1;var e=$r(),t=Nr(),r=Hr();function n(o){return function(i,s,a){var u=Object(i);if(!t(i)){var c=e(s,3);i=r(i),s=function(d){return c(u[d],d,u)}}var l=o(i,s,a);return l>-1?u[c?i[l]:l]:void 0}}return ec=n,ec}var rc,Gp;function rC(){if(Gp)return rc;Gp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return rc=t,rc}var tc,Up;function tC(){if(Up)return tc;Up=1;var e=rC(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return tc=r,tc}var nc,Hp;function nC(){if(Hp)return nc;Hp=1;var e=tC(),t=vr(),r=wt(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=t(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=e(c);var d=i.test(c);return d||s.test(c)?a(c.slice(2),d?2:8):o.test(c)?n:+c}return nc=u,nc}var oc,Kp;function Rb(){if(Kp)return oc;Kp=1;var e=nC(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return oc=n,oc}var ic,Jp;function oC(){if(Jp)return ic;Jp=1;var e=Rb();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return ic=t,ic}var ac,Zp;function iC(){if(Zp)return ac;Zp=1;var e=xb(),t=$r(),r=oC(),n=Math.max;function o(i,s,a){var u=i==null?0:i.length;if(!u)return-1;var c=a==null?0:r(a);return c<0&&(c=n(u+c,0)),e(i,t(s,3),c)}return ac=o,ac}var sc,Yp;function aC(){if(Yp)return sc;Yp=1;var e=eC(),t=iC(),r=e(t);return sc=r,sc}var cc,Xp;function Pb(){if(Xp)return cc;Xp=1;var e=tl();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return cc=t,cc}var uc,Qp;function sC(){if(Qp)return uc;Qp=1;var e=Xu(),t=Qm(),r=ot();function n(o,i){return o==null?o:e(o,t(i),r)}return uc=n,uc}var lc,eg;function cC(){if(eg)return lc;eg=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return lc=e,lc}var dc,rg;function uC(){if(rg)return dc;rg=1;var e=Tn(),t=Qu(),r=$r();function n(o,i){var s={};return i=r(i,3),t(o,function(a,u,c){e(s,u,i(a,u,c))}),s}return dc=n,dc}var fc,tg;function ol(){if(tg)return fc;tg=1;var e=wt();function t(r,n,o){for(var i=-1,s=r.length;++i<s;){var a=r[i],u=n(a);if(u!=null&&(c===void 0?u===u&&!e(u):o(u,c)))var c=u,l=a}return l}return fc=t,fc}var hc,ng;function lC(){if(ng)return hc;ng=1;function e(t,r){return t>r}return hc=e,hc}var pc,og;function dC(){if(og)return pc;og=1;var e=ol(),t=lC(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return pc=n,pc}var gc,ig;function Ab(){if(ig)return gc;ig=1;var e=Tn(),t=mt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return gc=r,gc}var yc,ag;function fC(){if(ag)return yc;ag=1;var e=tt(),t=Nn(),r=Pr(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,u=s.call(Object);function c(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var f=a.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&s.call(f)==u}return yc=c,yc}var mc,sg;function Tb(){if(sg)return mc;sg=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return mc=e,mc}var bc,cg;function hC(){if(cg)return bc;cg=1;var e=rn(),t=ot();function r(n){return e(n,t(n))}return bc=r,bc}var vc,ug;function pC(){if(ug)return vc;ug=1;var e=Ab(),t=Bm(),r=Jm(),n=Dm(),o=Ym(),i=tn(),s=Xe(),a=wb(),u=vt(),c=en(),l=vr(),d=fC(),f=nn(),p=Tb(),y=hC();function g(b,x,m,w,v,C,_){var R=p(b,m),T=p(x,m),A=_.get(T);if(A){e(b,m,A);return}var k=C?C(R,T,m+"",b,x,_):void 0,E=k===void 0;if(E){var j=s(T),M=!j&&u(T),I=!j&&!M&&f(T);k=T,j||M||I?s(R)?k=R:a(R)?k=n(R):M?(E=!1,k=t(T,!0)):I?(E=!1,k=r(T,!0)):k=[]:d(T)||i(T)?(k=R,i(R)?k=y(R):(!l(R)||c(R))&&(k=o(T))):E=!1}E&&(_.set(T,k),v(k,T,w,C,_),_.delete(T)),e(b,m,k)}return vc=g,vc}var xc,lg;function gC(){if(lg)return xc;lg=1;var e=An(),t=Ab(),r=Xu(),n=pC(),o=vr(),i=ot(),s=Tb();function a(u,c,l,d,f){u!==c&&r(c,function(p,y){if(f||(f=new e),o(p))n(u,c,y,l,a,d,f);else{var g=d?d(s(u,y),p,y+"",u,c,f):void 0;g===void 0&&(g=p),t(u,y,g)}},i)}return xc=a,xc}var wc,dg;function yC(){if(dg)return wc;dg=1;var e=Dn(),t=zn();function r(n){return e(function(o,i){var s=-1,a=i.length,u=a>1?i[a-1]:void 0,c=a>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(a--,u):void 0,c&&t(i[0],i[1],c)&&(u=a<3?void 0:u,a=1),o=Object(o);++s<a;){var l=i[s];l&&n(o,l,s,u)}return o})}return wc=r,wc}var Cc,fg;function mC(){if(fg)return Cc;fg=1;var e=gC(),t=yC(),r=t(function(n,o,i){e(n,o,i)});return Cc=r,Cc}var _c,hg;function Ob(){if(hg)return _c;hg=1;function e(t,r){return t<r}return _c=e,_c}var Sc,pg;function bC(){if(pg)return Sc;pg=1;var e=ol(),t=Ob(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return Sc=n,Sc}var Ec,gg;function vC(){if(gg)return Ec;gg=1;var e=ol(),t=$r(),r=Ob();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return Ec=n,Ec}var jc,yg;function xC(){if(yg)return jc;yg=1;var e=Sr(),t=function(){return e.Date.now()};return jc=t,jc}var kc,mg;function wC(){if(mg)return kc;mg=1;var e=On(),t=Fn(),r=In(),n=vr(),o=on();function i(s,a,u,c){if(!n(s))return s;a=t(a,s);for(var l=-1,d=a.length,f=d-1,p=s;p!=null&&++l<d;){var y=o(a[l]),g=u;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(l!=f){var b=p[y];g=c?c(b,y,p):void 0,g===void 0&&(g=n(b)?b:r(a[l+1])?[]:{})}e(p,y,g),p=p[y]}return s}return kc=i,kc}var Rc,bg;function CC(){if(bg)return Rc;bg=1;var e=Bn(),t=wC(),r=Fn();function n(o,i,s){for(var a=-1,u=i.length,c={};++a<u;){var l=i[a],d=e(o,l);s(d,l)&&t(c,r(l,o),d)}return c}return Rc=n,Rc}var Pc,vg;function _C(){if(vg)return Pc;vg=1;var e=CC(),t=lb();function r(n,o){return e(n,o,function(i,s){return t(n,s)})}return Pc=r,Pc}var Ac,xg;function SC(){if(xg)return Ac;xg=1;var e=Pb(),t=bb(),r=vb();function n(o){return r(t(o,void 0,e),o+"")}return Ac=n,Ac}var Tc,wg;function EC(){if(wg)return Tc;wg=1;var e=_C(),t=SC(),r=t(function(n,o){return n==null?{}:e(n,o)});return Tc=r,Tc}var Oc,Cg;function jC(){if(Cg)return Oc;Cg=1;var e=Math.ceil,t=Math.max;function r(n,o,i,s){for(var a=-1,u=t(e((o-n)/(i||1)),0),c=Array(u);u--;)c[s?u:++a]=n,n+=i;return c}return Oc=r,Oc}var Ic,_g;function kC(){if(_g)return Ic;_g=1;var e=jC(),t=zn(),r=Rb();function n(o){return function(i,s,a){return a&&typeof a!="number"&&t(i,s,a)&&(s=a=void 0),i=r(i),s===void 0?(s=i,i=0):s=r(s),a=a===void 0?i<s?1:-1:r(a),e(i,s,a,o)}}return Ic=n,Ic}var Mc,Sg;function RC(){if(Sg)return Mc;Sg=1;var e=kC(),t=e();return Mc=t,Mc}var qc,Eg;function PC(){if(Eg)return qc;Eg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return qc=e,qc}var Nc,jg;function AC(){if(jg)return Nc;jg=1;var e=wt();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,s=r===r,a=e(r),u=n!==void 0,c=n===null,l=n===n,d=e(n);if(!c&&!d&&!a&&r>n||a&&u&&l&&!c&&!d||i&&u&&l||!o&&l||!s)return 1;if(!i&&!a&&!d&&r<n||d&&o&&s&&!i&&!a||c&&o&&s||!u&&s||!l)return-1}return 0}return Nc=t,Nc}var $c,kg;function TC(){if(kg)return $c;kg=1;var e=AC();function t(r,n,o){for(var i=-1,s=r.criteria,a=n.criteria,u=s.length,c=o.length;++i<u;){var l=e(s[i],a[i]);if(l){if(i>=c)return l;var d=o[i];return l*(d=="desc"?-1:1)}}return r.index-n.index}return $c=t,$c}var Lc,Rg;function OC(){if(Rg)return Lc;Rg=1;var e=Ln(),t=Bn(),r=$r(),n=gb(),o=PC(),i=Mn(),s=TC(),a=it(),u=Xe();function c(l,d,f){d.length?d=e(d,function(g){return u(g)?function(b){return t(b,g.length===1?g[0]:g)}:g}):d=[a];var p=-1;d=e(d,i(r));var y=n(l,function(g,b,x){var m=e(d,function(w){return w(g)});return{criteria:m,index:++p,value:g}});return o(y,function(g,b){return s(g,b,f)})}return Lc=c,Lc}var Fc,Pg;function IC(){if(Pg)return Fc;Pg=1;var e=tl(),t=OC(),r=Dn(),n=zn(),o=r(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]]),t(i,e(s,1),[])});return Fc=o,Fc}var Bc,Ag;function MC(){if(Ag)return Bc;Ag=1;var e=cb(),t=0;function r(n){var o=++t;return e(n)+o}return Bc=r,Bc}var Dc,Tg;function qC(){if(Tg)return Dc;Tg=1;function e(t,r,n){for(var o=-1,i=t.length,s=r.length,a={};++o<i;){var u=o<s?r[o]:void 0;n(a,t[o],u)}return a}return Dc=e,Dc}var zc,Og;function NC(){if(Og)return zc;Og=1;var e=On(),t=qC();function r(n,o){return t(n||[],o||[],e)}return zc=r,zc}var Vc,Ig;function Ue(){if(Ig)return Vc;Ig=1;var e;if(typeof Du=="function")try{e={cloneDeep:X1(),constant:Yu(),defaults:Q1(),each:rb(),filter:fb(),find:aC(),flatten:Pb(),forEach:eb(),forIn:sC(),has:hb(),isUndefined:pb(),last:cC(),map:yb(),mapValues:uC(),max:dC(),merge:mC(),min:bC(),minBy:vC(),now:xC(),pick:EC(),range:RC(),reduce:mb(),sortBy:IC(),uniqueId:MC(),values:Cb(),zipObject:NC()}}catch{}return e||(e=window._),Vc=e,Vc}var Wc,Mg;function $C(){if(Mg)return Wc;Mg=1,Wc=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 t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(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,r)),i=i._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,o){if(n!=="_next"&&n!=="_prev")return o}return Wc}var Gc,qg;function LC(){if(qg)return Gc;qg=1;var e=Ue(),t=_r().Graph,r=$C();Gc=o;var n=e.constant(1);function o(c,l){if(c.nodeCount()<=1)return[];var d=a(c,l||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return c.outEdges(p.v,p.w)}),!0)}function i(c,l,d){for(var f=[],p=l[l.length-1],y=l[0],g;c.nodeCount();){for(;g=y.dequeue();)s(c,l,d,g);for(;g=p.dequeue();)s(c,l,d,g);if(c.nodeCount()){for(var b=l.length-2;b>0;--b)if(g=l[b].dequeue(),g){f=f.concat(s(c,l,d,g,!0));break}}}return f}function s(c,l,d,f,p){var y=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(g){var b=c.edge(g),x=c.node(g.v);p&&y.push({v:g.v,w:g.w}),x.out-=b,u(l,d,x)}),e.forEach(c.outEdges(f.v),function(g){var b=c.edge(g),x=g.w,m=c.node(x);m.in-=b,u(l,d,m)}),c.removeNode(f.v),y}function a(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(b){d.setNode(b,{v:b,in:0,out:0})}),e.forEach(c.edges(),function(b){var x=d.edge(b.v,b.w)||0,m=l(b),w=x+m;d.setEdge(b.v,b.w,w),p=Math.max(p,d.node(b.v).out+=m),f=Math.max(f,d.node(b.w).in+=m)});var y=e.range(p+f+3).map(function(){return new r}),g=f+1;return e.forEach(d.nodes(),function(b){u(y,g,d.node(b))}),{graph:d,buckets:y,zeroIdx:g}}function u(c,l,d){d.out?d.in?c[d.out-d.in+l].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}return Gc}var Uc,Ng;function FC(){if(Ng)return Uc;Ng=1;var e=Ue(),t=LC();Uc={run:r,undo:o};function r(i){var s=i.graph().acyclicer==="greedy"?t(i,a(i)):n(i);e.forEach(s,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function a(u){return function(c){return u.edge(c).weight}}}function n(i){var s=[],a={},u={};function c(l){e.has(u,l)||(u[l]=!0,a[l]=!0,e.forEach(i.outEdges(l),function(d){e.has(a,d.w)?s.push(d):c(d.w)}),delete a[l])}return e.forEach(i.nodes(),c),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var u=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,u)}})}return Uc}var Hc,$g;function pr(){if($g)return Hc;$g=1;var e=Ue(),t=_r().Graph;Hc={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:l,addBorderNode:d,maxRank:f,partition:p,time:y,notime:g};function r(b,x,m,w){var v;do v=e.uniqueId(w);while(b.hasNode(v));return m.dummy=x,b.setNode(v,m),v}function n(b){var x=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(m){x.setNode(m,b.node(m))}),e.forEach(b.edges(),function(m){var w=x.edge(m.v,m.w)||{weight:0,minlen:1},v=b.edge(m);x.setEdge(m.v,m.w,{weight:w.weight+v.weight,minlen:Math.max(w.minlen,v.minlen)})}),x}function o(b){var x=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(m){b.children(m).length||x.setNode(m,b.node(m))}),e.forEach(b.edges(),function(m){x.setEdge(m,b.edge(m))}),x}function i(b){var x=e.map(b.nodes(),function(m){var w={};return e.forEach(b.outEdges(m),function(v){w[v.w]=(w[v.w]||0)+b.edge(v).weight}),w});return e.zipObject(b.nodes(),x)}function s(b){var x=e.map(b.nodes(),function(m){var w={};return e.forEach(b.inEdges(m),function(v){w[v.v]=(w[v.v]||0)+b.edge(v).weight}),w});return e.zipObject(b.nodes(),x)}function a(b,x){var m=b.x,w=b.y,v=x.x-m,C=x.y-w,_=b.width/2,R=b.height/2;if(!v&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var T,A;return Math.abs(C)*_>Math.abs(v)*R?(C<0&&(R=-R),T=R*v/C,A=R):(v<0&&(_=-_),T=_,A=_*C/v),{x:m+T,y:w+A}}function u(b){var x=e.map(e.range(f(b)+1),function(){return[]});return e.forEach(b.nodes(),function(m){var w=b.node(m),v=w.rank;e.isUndefined(v)||(x[v][w.order]=m)}),x}function c(b){var x=e.min(e.map(b.nodes(),function(m){return b.node(m).rank}));e.forEach(b.nodes(),function(m){var w=b.node(m);e.has(w,"rank")&&(w.rank-=x)})}function l(b){var x=e.min(e.map(b.nodes(),function(C){return b.node(C).rank})),m=[];e.forEach(b.nodes(),function(C){var _=b.node(C).rank-x;m[_]||(m[_]=[]),m[_].push(C)});var w=0,v=b.graph().nodeRankFactor;e.forEach(m,function(C,_){e.isUndefined(C)&&_%v!==0?--w:w&&e.forEach(C,function(R){b.node(R).rank+=w})})}function d(b,x,m,w){var v={width:0,height:0};return arguments.length>=4&&(v.rank=m,v.order=w),r(b,"border",v,x)}function f(b){return e.max(e.map(b.nodes(),function(x){var m=b.node(x).rank;if(!e.isUndefined(m))return m}))}function p(b,x){var m={lhs:[],rhs:[]};return e.forEach(b,function(w){x(w)?m.lhs.push(w):m.rhs.push(w)}),m}function y(b,x){var m=e.now();try{return x()}finally{console.log(b+" time: "+(e.now()-m)+"ms")}}function g(b,x){return x()}return Hc}var Kc,Lg;function BC(){if(Lg)return Kc;Lg=1;var e=Ue(),t=pr();Kc={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,u=i.node(a).rank,c=s.w,l=i.node(c).rank,d=s.name,f=i.edge(s),p=f.labelRank;if(l!==u+1){i.removeEdge(s);var y,g,b;for(b=0,++u;u<l;++b,++u)f.points=[],g={width:0,height:0,edgeLabel:f,edgeObj:s,rank:u},y=t.addDummyNode(i,"edge",g,"_d"),u===p&&(g.width=f.width,g.height=f.height,g.dummy="edge-label",g.labelpos=f.labelpos),i.setEdge(a,y,{weight:f.weight},d),b===0&&i.graph().dummyChains.push(y),a=y;i.setEdge(a,c,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),u=a.edgeLabel,c;for(i.setEdge(a.edgeObj,u);a.dummy;)c=i.successors(s)[0],i.removeNode(s),u.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(u.x=a.x,u.y=a.y,u.width=a.width,u.height=a.height),s=c,a=i.node(s)})}return Kc}var Jc,Fg;function mn(){if(Fg)return Jc;Fg=1;var e=Ue();Jc={longestPath:t,slack:r};function t(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var u=e.min(e.map(n.outEdges(s),function(c){return i(c.w)-n.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),a.rank=u}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Jc}var Zc,Bg;function Ib(){if(Bg)return Zc;Bg=1;var e=Ue(),t=_r().Graph,r=mn().slack;Zc=n;function n(a){var u=new t({directed:!1}),c=a.nodes()[0],l=a.nodeCount();u.setNode(c,{});for(var d,f;o(u,a)<l;)d=i(u,a),f=u.hasNode(d.v)?r(a,d):-r(a,d),s(u,a,f);return u}function o(a,u){function c(l){e.forEach(u.nodeEdges(l),function(d){var f=d.v,p=l===f?d.w:f;!a.hasNode(p)&&!r(u,d)&&(a.setNode(p,{}),a.setEdge(l,p,{}),c(p))})}return e.forEach(a.nodes(),c),a.nodeCount()}function i(a,u){return e.minBy(u.edges(),function(c){if(a.hasNode(c.v)!==a.hasNode(c.w))return r(u,c)})}function s(a,u,c){e.forEach(a.nodes(),function(l){u.node(l).rank+=c})}return Zc}var Yc,Dg;function DC(){if(Dg)return Yc;Dg=1;var e=Ue(),t=Ib(),r=mn().slack,n=mn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,s=pr().simplify;Yc=a,a.initLowLimValues=d,a.initCutValues=u,a.calcCutValue=l,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=g;function a(w){w=s(w),n(w);var v=t(w);d(v),u(v,w);for(var C,_;C=p(v);)_=y(v,w,C),g(v,w,C,_)}function u(w,v){var C=i(w,w.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(_){c(w,v,_)})}function c(w,v,C){var _=w.node(C),R=_.parent;w.edge(C,R).cutvalue=l(w,v,C)}function l(w,v,C){var _=w.node(C),R=_.parent,T=!0,A=v.edge(C,R),k=0;return A||(T=!1,A=v.edge(R,C)),k=A.weight,e.forEach(v.nodeEdges(C),function(E){var j=E.v===C,M=j?E.w:E.v;if(M!==R){var I=j===T,q=v.edge(E).weight;if(k+=I?q:-q,x(w,C,M)){var O=w.edge(C,M).cutvalue;k+=I?-O:O}}}),k}function d(w,v){arguments.length<2&&(v=w.nodes()[0]),f(w,{},1,v)}function f(w,v,C,_,R){var T=C,A=w.node(_);return v[_]=!0,e.forEach(w.neighbors(_),function(k){e.has(v,k)||(C=f(w,v,C,k,_))}),A.low=T,A.lim=C++,R?A.parent=R:delete A.parent,C}function p(w){return e.find(w.edges(),function(v){return w.edge(v).cutvalue<0})}function y(w,v,C){var _=C.v,R=C.w;v.hasEdge(_,R)||(_=C.w,R=C.v);var T=w.node(_),A=w.node(R),k=T,E=!1;T.lim>A.lim&&(k=A,E=!0);var j=e.filter(v.edges(),function(M){return E===m(w,w.node(M.v),k)&&E!==m(w,w.node(M.w),k)});return e.minBy(j,function(M){return r(v,M)})}function g(w,v,C,_){var R=C.v,T=C.w;w.removeEdge(R,T),w.setEdge(_.v,_.w,{}),d(w),u(w,v),b(w,v)}function b(w,v){var C=e.find(w.nodes(),function(R){return!v.node(R).parent}),_=o(w,C);_=_.slice(1),e.forEach(_,function(R){var T=w.node(R).parent,A=v.edge(R,T),k=!1;A||(A=v.edge(T,R),k=!0),v.node(R).rank=v.node(T).rank+(k?A.minlen:-A.minlen)})}function x(w,v,C){return w.hasEdge(v,C)}function m(w,v,C){return C.low<=v.lim&&v.lim<=C.lim}return Yc}var Xc,zg;function zC(){if(zg)return Xc;zg=1;var e=mn(),t=e.longestPath,r=Ib(),n=DC();Xc=o;function o(u){switch(u.graph().ranker){case"network-simplex":a(u);break;case"tight-tree":s(u);break;case"longest-path":i(u);break;default:a(u)}}var i=t;function s(u){t(u),r(u)}function a(u){n(u)}return Xc}var Qc,Vg;function VC(){if(Vg)return Qc;Vg=1;var e=Ue();Qc=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),u=a.edgeObj,c=r(o,i,u.v,u.w),l=c.path,d=c.lca,f=0,p=l[f],y=!0;s!==u.w;){if(a=o.node(s),y){for(;(p=l[f])!==d&&o.node(p).maxRank<a.rank;)f++;p===d&&(y=!1)}if(!y){for(;f<l.length-1&&o.node(p=l[f+1]).minRank<=a.rank;)f++;p=l[f]}o.setParent(s,p),s=o.successors(s)[0]}})}function r(o,i,s,a){var u=[],c=[],l=Math.min(i[s].low,i[a].low),d=Math.max(i[s].lim,i[a].lim),f,p;f=s;do f=o.parent(f),u.push(f);while(f&&(i[f].low>l||d>i[f].lim));for(p=f,f=a;(f=o.parent(f))!==p;)c.push(f);return{path:u.concat(c.reverse()),lca:p}}function n(o){var i={},s=0;function a(u){var c=s;e.forEach(o.children(u),a),i[u]={low:c,lim:s++}}return e.forEach(o.children(),a),i}return Qc}var eu,Wg;function WC(){if(Wg)return eu;Wg=1;var e=Ue(),t=pr();eu={run:r,cleanup:s};function r(a){var u=t.addDummyNode(a,"root",{},"_root"),c=o(a),l=e.max(e.values(c))-1,d=2*l+1;a.graph().nestingRoot=u,e.forEach(a.edges(),function(p){a.edge(p).minlen*=d});var f=i(a)+1;e.forEach(a.children(),function(p){n(a,u,d,f,l,c,p)}),a.graph().nodeRankFactor=d}function n(a,u,c,l,d,f,p){var y=a.children(p);if(!y.length){p!==u&&a.setEdge(u,p,{weight:0,minlen:c});return}var g=t.addBorderNode(a,"_bt"),b=t.addBorderNode(a,"_bb"),x=a.node(p);a.setParent(g,p),x.borderTop=g,a.setParent(b,p),x.borderBottom=b,e.forEach(y,function(m){n(a,u,c,l,d,f,m);var w=a.node(m),v=w.borderTop?w.borderTop:m,C=w.borderBottom?w.borderBottom:m,_=w.borderTop?l:2*l,R=v!==C?1:d-f[p]+1;a.setEdge(g,v,{weight:_,minlen:R,nestingEdge:!0}),a.setEdge(C,b,{weight:_,minlen:R,nestingEdge:!0})}),a.parent(p)||a.setEdge(u,g,{weight:0,minlen:d+f[p]})}function o(a){var u={};function c(l,d){var f=a.children(l);f&&f.length&&e.forEach(f,function(p){c(p,d+1)}),u[l]=d}return e.forEach(a.children(),function(l){c(l,1)}),u}function i(a){return e.reduce(a.edges(),function(u,c){return u+a.edge(c).weight},0)}function s(a){var u=a.graph();a.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(a.edges(),function(c){var l=a.edge(c);l.nestingEdge&&a.removeEdge(c)})}return eu}var ru,Gg;function GC(){if(Gg)return ru;Gg=1;var e=Ue(),t=pr();ru=r;function r(o){function i(s){var a=o.children(s),u=o.node(s);if(a.length&&e.forEach(a,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,l=u.maxRank+1;c<l;++c)n(o,"borderLeft","_bl",s,u,c),n(o,"borderRight","_br",s,u,c)}}e.forEach(o.children(),i)}function n(o,i,s,a,u,c){var l={width:0,height:0,rank:c,borderType:i},d=u[i][c-1],f=t.addDummyNode(o,"border",l,s);u[i][c]=f,o.setParent(f,a),d&&o.setEdge(d,f,{weight:1})}return ru}var tu,Ug;function UC(){if(Ug)return tu;Ug=1;var e=Ue();tu={adjust:t,undo:r};function t(c){var l=c.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(c)}function r(c){var l=c.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&i(c),(l==="lr"||l==="rl")&&(a(c),n(c))}function n(c){e.forEach(c.nodes(),function(l){o(c.node(l))}),e.forEach(c.edges(),function(l){o(c.edge(l))})}function o(c){var l=c.width;c.width=c.height,c.height=l}function i(c){e.forEach(c.nodes(),function(l){s(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,s),e.has(d,"y")&&s(d)})}function s(c){c.y=-c.y}function a(c){e.forEach(c.nodes(),function(l){u(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,u),e.has(d,"x")&&u(d)})}function u(c){var l=c.x;c.x=c.y,c.y=l}return tu}var nu,Hg;function HC(){if(Hg)return nu;Hg=1;var e=Ue();nu=t;function t(r){var n={},o=e.filter(r.nodes(),function(c){return!r.children(c).length}),i=e.max(e.map(o,function(c){return r.node(c).rank})),s=e.map(e.range(i+1),function(){return[]});function a(c){if(!e.has(n,c)){n[c]=!0;var l=r.node(c);s[l.rank].push(c),e.forEach(r.successors(c),a)}}var u=e.sortBy(o,function(c){return r.node(c).rank});return e.forEach(u,a),s}return nu}var ou,Kg;function KC(){if(Kg)return ou;Kg=1;var e=Ue();ou=t;function t(n,o){for(var i=0,s=1;s<o.length;++s)i+=r(n,o[s-1],o[s]);return i}function r(n,o,i){for(var s=e.zipObject(i,e.map(i,function(f,p){return p})),a=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var c=2*u-1;u-=1;var l=e.map(new Array(c),function(){return 0}),d=0;return e.forEach(a.forEach(function(f){var p=f.pos+u;l[p]+=f.weight;for(var y=0;p>0;)p%2&&(y+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*y})),d}return ou}var iu,Jg;function JC(){if(Jg)return iu;Jg=1;var e=Ue();iu=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var s=e.reduce(i,function(a,u){var c=r.edge(u),l=r.node(u.v);return{sum:a.sum+c.weight*l.order,weight:a.weight+c.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return iu}var au,Zg;function ZC(){if(Zg)return au;Zg=1;var e=Ue();au=t;function t(o,i){var s={};e.forEach(o,function(u,c){var l=s[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(l.barycenter=u.barycenter,l.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=s[u.v],l=s[u.w];!e.isUndefined(c)&&!e.isUndefined(l)&&(l.indegree++,c.out.push(s[u.w]))});var a=e.filter(s,function(u){return!u.indegree});return r(a)}function r(o){var i=[];function s(c){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(c.barycenter)||l.barycenter>=c.barycenter)&&n(c,l)}}function a(c){return function(l){l.in.push(c),--l.indegree===0&&o.push(l)}}for(;o.length;){var u=o.pop();i.push(u),e.forEach(u.in.reverse(),s(u)),e.forEach(u.out,a(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["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 au}var su,Yg;function YC(){if(Yg)return su;Yg=1;var e=Ue(),t=pr();su=r;function r(i,s){var a=t.partition(i,function(g){return e.has(g,"barycenter")}),u=a.lhs,c=e.sortBy(a.rhs,function(g){return-g.i}),l=[],d=0,f=0,p=0;u.sort(o(!!s)),p=n(l,c,p),e.forEach(u,function(g){p+=g.vs.length,l.push(g.vs),d+=g.barycenter*g.weight,f+=g.weight,p=n(l,c,p)});var y={vs:e.flatten(l,!0)};return f&&(y.barycenter=d/f,y.weight=f),y}function n(i,s,a){for(var u;s.length&&(u=e.last(s)).i<=a;)s.pop(),i.push(u.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 su}var cu,Xg;function XC(){if(Xg)return cu;Xg=1;var e=Ue(),t=JC(),r=ZC(),n=YC();cu=o;function o(a,u,c,l){var d=a.children(u),f=a.node(u),p=f?f.borderLeft:void 0,y=f?f.borderRight:void 0,g={};p&&(d=e.filter(d,function(C){return C!==p&&C!==y}));var b=t(a,d);e.forEach(b,function(C){if(a.children(C.v).length){var _=o(a,C.v,c,l);g[C.v]=_,e.has(_,"barycenter")&&s(C,_)}});var x=r(b,c);i(x,g);var m=n(x,l);if(p&&(m.vs=e.flatten([p,m.vs,y],!0),a.predecessors(p).length)){var w=a.node(a.predecessors(p)[0]),v=a.node(a.predecessors(y)[0]);e.has(m,"barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+w.order+v.order)/(m.weight+2),m.weight+=2}return m}function i(a,u){e.forEach(a,function(c){c.vs=e.flatten(c.vs.map(function(l){return u[l]?u[l].vs:l}),!0)})}function s(a,u){e.isUndefined(a.barycenter)?(a.barycenter=u.barycenter,a.weight=u.weight):(a.barycenter=(a.barycenter*a.weight+u.barycenter*u.weight)/(a.weight+u.weight),a.weight+=u.weight)}return cu}var uu,Qg;function QC(){if(Qg)return uu;Qg=1;var e=Ue(),t=_r().Graph;uu=r;function r(o,i,s){var a=n(o),u=new t({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(c){return o.node(c)});return e.forEach(o.nodes(),function(c){var l=o.node(c),d=o.parent(c);(l.rank===i||l.minRank<=i&&i<=l.maxRank)&&(u.setNode(c),u.setParent(c,d||a),e.forEach(o[s](c),function(f){var p=f.v===c?f.w:f.v,y=u.edge(p,c),g=e.isUndefined(y)?0:y.weight;u.setEdge(p,c,{weight:o.edge(f).weight+g})}),e.has(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[i],borderRight:l.borderRight[i]}))}),u}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return uu}var lu,ey;function e_(){if(ey)return lu;ey=1;var e=Ue();lu=t;function t(r,n,o){var i={},s;e.forEach(o,function(a){for(var u=r.parent(a),c,l;u;){if(c=r.parent(u),c?(l=i[c],i[c]=u):(l=s,s=u),l&&l!==u){n.setEdge(l,u);return}u=c}})}return lu}var du,ry;function r_(){if(ry)return du;ry=1;var e=Ue(),t=HC(),r=KC(),n=XC(),o=QC(),i=e_(),s=_r().Graph,a=pr();du=u;function u(f){var p=a.maxRank(f),y=c(f,e.range(1,p+1),"inEdges"),g=c(f,e.range(p-1,-1,-1),"outEdges"),b=t(f);d(f,b);for(var x=Number.POSITIVE_INFINITY,m,w=0,v=0;v<4;++w,++v){l(w%2?y:g,w%4>=2),b=a.buildLayerMatrix(f);var C=r(f,b);C<x&&(v=0,m=e.cloneDeep(b),x=C)}d(f,m)}function c(f,p,y){return e.map(p,function(g){return o(f,g,y)})}function l(f,p){var y=new s;e.forEach(f,function(g){var b=g.graph().root,x=n(g,b,y,p);e.forEach(x.vs,function(m,w){g.node(m).order=w}),i(g,y,x.vs)})}function d(f,p){e.forEach(p,function(y){e.forEach(y,function(g,b){f.node(g).order=b})})}return du}var fu,ty;function t_(){if(ty)return fu;ty=1;var e=Ue(),t=_r().Graph,r=pr();fu={positionX:y,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(x,m){var w={};function v(C,_){var R=0,T=0,A=C.length,k=e.last(_);return e.forEach(_,function(E,j){var M=i(x,E),I=M?x.node(M).order:A;(M||E===k)&&(e.forEach(_.slice(T,j+1),function(q){e.forEach(x.predecessors(q),function(O){var V=x.node(O),W=V.order;(W<R||I<W)&&!(V.dummy&&x.node(q).dummy)&&s(w,O,q)})}),T=j+1,R=I)}),_}return e.reduce(m,v),w}function o(x,m){var w={};function v(_,R,T,A,k){var E;e.forEach(e.range(R,T),function(j){E=_[j],x.node(E).dummy&&e.forEach(x.predecessors(E),function(M){var I=x.node(M);I.dummy&&(I.order<A||I.order>k)&&s(w,M,E)})})}function C(_,R){var T=-1,A,k=0;return e.forEach(R,function(E,j){if(x.node(E).dummy==="border"){var M=x.predecessors(E);M.length&&(A=x.node(M[0]).order,v(R,k,j,T,A),k=j,T=A)}v(R,k,R.length,A,_.length)}),R}return e.reduce(m,C),w}function i(x,m){if(x.node(m).dummy)return e.find(x.predecessors(m),function(w){return x.node(w).dummy})}function s(x,m,w){if(m>w){var v=m;m=w,w=v}var C=x[m];C||(x[m]=C={}),C[w]=!0}function a(x,m,w){if(m>w){var v=m;m=w,w=v}return e.has(x[m],w)}function u(x,m,w,v){var C={},_={},R={};return e.forEach(m,function(T){e.forEach(T,function(A,k){C[A]=A,_[A]=A,R[A]=k})}),e.forEach(m,function(T){var A=-1;e.forEach(T,function(k){var E=v(k);if(E.length){E=e.sortBy(E,function(O){return R[O]});for(var j=(E.length-1)/2,M=Math.floor(j),I=Math.ceil(j);M<=I;++M){var q=E[M];_[k]===k&&A<R[q]&&!a(w,k,q)&&(_[q]=k,_[k]=C[k]=C[q],A=R[q])}}})}),{root:C,align:_}}function c(x,m,w,v,C){var _={},R=l(x,m,w,C),T=C?"borderLeft":"borderRight";function A(j,M){for(var I=R.nodes(),q=I.pop(),O={};q;)O[q]?j(q):(O[q]=!0,I.push(q),I=I.concat(M(q))),q=I.pop()}function k(j){_[j]=R.inEdges(j).reduce(function(M,I){return Math.max(M,_[I.v]+R.edge(I))},0)}function E(j){var M=R.outEdges(j).reduce(function(q,O){return Math.min(q,_[O.w]-R.edge(O))},Number.POSITIVE_INFINITY),I=x.node(j);M!==Number.POSITIVE_INFINITY&&I.borderType!==T&&(_[j]=Math.max(_[j],M))}return A(k,R.predecessors.bind(R)),A(E,R.successors.bind(R)),e.forEach(v,function(j){_[j]=_[w[j]]}),_}function l(x,m,w,v){var C=new t,_=x.graph(),R=g(_.nodesep,_.edgesep,v);return e.forEach(m,function(T){var A;e.forEach(T,function(k){var E=w[k];if(C.setNode(E),A){var j=w[A],M=C.edge(j,E);C.setEdge(j,E,Math.max(R(x,k,A),M||0))}A=k})}),C}function d(x,m){return e.minBy(e.values(m),function(w){var v=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(w,function(_,R){var T=b(x,R)/2;v=Math.max(_+T,v),C=Math.min(_-T,C)}),v-C})}function f(x,m){var w=e.values(m),v=e.min(w),C=e.max(w);e.forEach(["u","d"],function(_){e.forEach(["l","r"],function(R){var T=_+R,A=x[T],k;if(A!==m){var E=e.values(A);k=R==="l"?v-e.min(E):C-e.max(E),k&&(x[T]=e.mapValues(A,function(j){return j+k}))}})})}function p(x,m){return e.mapValues(x.ul,function(w,v){if(m)return x[m.toLowerCase()][v];var C=e.sortBy(e.map(x,v));return(C[1]+C[2])/2})}function y(x){var m=r.buildLayerMatrix(x),w=e.merge(n(x,m),o(x,m)),v={},C;e.forEach(["u","d"],function(R){C=R==="u"?m:e.values(m).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(C=e.map(C,function(j){return e.values(j).reverse()}));var A=(R==="u"?x.predecessors:x.successors).bind(x),k=u(x,C,w,A),E=c(x,C,k.root,k.align,T==="r");T==="r"&&(E=e.mapValues(E,function(j){return-j})),v[R+T]=E})});var _=d(x,v);return f(v,_),p(v,x.graph().align)}function g(x,m,w){return function(v,C,_){var R=v.node(C),T=v.node(_),A=0,k;if(A+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":k=-R.width/2;break;case"r":k=R.width/2;break}if(k&&(A+=w?k:-k),k=0,A+=(R.dummy?m:x)/2,A+=(T.dummy?m:x)/2,A+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":k=T.width/2;break;case"r":k=-T.width/2;break}return k&&(A+=w?k:-k),k=0,A}}function b(x,m){return x.node(m).width}return fu}var hu,ny;function n_(){if(ny)return hu;ny=1;var e=Ue(),t=pr(),r=t_().positionX;hu=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(s,a){i.node(a).x=s})}function o(i){var s=t.buildLayerMatrix(i),a=i.graph().ranksep,u=0;e.forEach(s,function(c){var l=e.max(e.map(c,function(d){return i.node(d).height}));e.forEach(c,function(d){i.node(d).y=u+l/2}),u+=l+a})}return hu}var pu,oy;function o_(){if(oy)return pu;oy=1;var e=Ue(),t=FC(),r=BC(),n=zC(),o=pr().normalizeRanks,i=VC(),s=pr().removeEmptyRanks,a=WC(),u=GC(),c=UC(),l=r_(),d=n_(),f=pr(),p=_r().Graph;pu=y;function y(N,L){var G=L&&L.debugTiming?f.time:f.notime;G("layout",function(){var D=G(" buildLayoutGraph",function(){return A(N)});G(" runLayout",function(){g(D,G)}),G(" updateInputGraph",function(){b(N,D)})})}function g(N,L){L(" makeSpaceForEdgeLabels",function(){k(N)}),L(" removeSelfEdges",function(){re(N)}),L(" acyclic",function(){t.run(N)}),L(" nestingGraph.run",function(){a.run(N)}),L(" rank",function(){n(f.asNonCompoundGraph(N))}),L(" injectEdgeLabelProxies",function(){E(N)}),L(" removeEmptyRanks",function(){s(N)}),L(" nestingGraph.cleanup",function(){a.cleanup(N)}),L(" normalizeRanks",function(){o(N)}),L(" assignRankMinMax",function(){j(N)}),L(" removeEdgeLabelProxies",function(){M(N)}),L(" normalize.run",function(){r.run(N)}),L(" parentDummyChains",function(){i(N)}),L(" addBorderSegments",function(){u(N)}),L(" order",function(){l(N)}),L(" insertSelfEdges",function(){Y(N)}),L(" adjustCoordinateSystem",function(){c.adjust(N)}),L(" position",function(){d(N)}),L(" positionSelfEdges",function(){he(N)}),L(" removeBorderNodes",function(){W(N)}),L(" normalize.undo",function(){r.undo(N)}),L(" fixupEdgeLabelCoords",function(){O(N)}),L(" undoCoordinateSystem",function(){c.undo(N)}),L(" translateGraph",function(){I(N)}),L(" assignNodeIntersects",function(){q(N)}),L(" reversePoints",function(){V(N)}),L(" acyclic.undo",function(){t.undo(N)})}function b(N,L){e.forEach(N.nodes(),function(G){var D=N.node(G),ne=L.node(G);D&&(D.x=ne.x,D.y=ne.y,L.children(G).length&&(D.width=ne.width,D.height=ne.height))}),e.forEach(N.edges(),function(G){var D=N.edge(G),ne=L.edge(G);D.points=ne.points,e.has(ne,"x")&&(D.x=ne.x,D.y=ne.y)}),N.graph().width=L.graph().width,N.graph().height=L.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],m={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],v=["width","height"],C={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function A(N){var L=new p({multigraph:!0,compound:!0}),G=J(N.graph());return L.setGraph(e.merge({},m,me(G,x),e.pick(G,w))),e.forEach(N.nodes(),function(D){var ne=J(N.node(D));L.setNode(D,e.defaults(me(ne,v),C)),L.setParent(D,N.parent(D))}),e.forEach(N.edges(),function(D){var ne=J(N.edge(D));L.setEdge(D,e.merge({},R,me(ne,_),e.pick(ne,T)))}),L}function k(N){var L=N.graph();L.ranksep/=2,e.forEach(N.edges(),function(G){var D=N.edge(G);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function E(N){e.forEach(N.edges(),function(L){var G=N.edge(L);if(G.width&&G.height){var D=N.node(L.v),ne=N.node(L.w),ue={rank:(ne.rank-D.rank)/2+D.rank,e:L};f.addDummyNode(N,"edge-proxy",ue,"_ep")}})}function j(N){var L=0;e.forEach(N.nodes(),function(G){var D=N.node(G);D.borderTop&&(D.minRank=N.node(D.borderTop).rank,D.maxRank=N.node(D.borderBottom).rank,L=e.max(L,D.maxRank))}),N.graph().maxRank=L}function M(N){e.forEach(N.nodes(),function(L){var G=N.node(L);G.dummy==="edge-proxy"&&(N.edge(G.e).labelRank=G.rank,N.removeNode(L))})}function I(N){var L=Number.POSITIVE_INFINITY,G=0,D=Number.POSITIVE_INFINITY,ne=0,ue=N.graph(),X=ue.marginx||0,U=ue.marginy||0;function K(te){var ce=te.x,de=te.y,Ae=te.width,ge=te.height;L=Math.min(L,ce-Ae/2),G=Math.max(G,ce+Ae/2),D=Math.min(D,de-ge/2),ne=Math.max(ne,de+ge/2)}e.forEach(N.nodes(),function(te){K(N.node(te))}),e.forEach(N.edges(),function(te){var ce=N.edge(te);e.has(ce,"x")&&K(ce)}),L-=X,D-=U,e.forEach(N.nodes(),function(te){var ce=N.node(te);ce.x-=L,ce.y-=D}),e.forEach(N.edges(),function(te){var ce=N.edge(te);e.forEach(ce.points,function(de){de.x-=L,de.y-=D}),e.has(ce,"x")&&(ce.x-=L),e.has(ce,"y")&&(ce.y-=D)}),ue.width=G-L+X,ue.height=ne-D+U}function q(N){e.forEach(N.edges(),function(L){var G=N.edge(L),D=N.node(L.v),ne=N.node(L.w),ue,X;G.points?(ue=G.points[0],X=G.points[G.points.length-1]):(G.points=[],ue=ne,X=D),G.points.unshift(f.intersectRect(D,ue)),G.points.push(f.intersectRect(ne,X))})}function O(N){e.forEach(N.edges(),function(L){var G=N.edge(L);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 V(N){e.forEach(N.edges(),function(L){var G=N.edge(L);G.reversed&&G.points.reverse()})}function W(N){e.forEach(N.nodes(),function(L){if(N.children(L).length){var G=N.node(L),D=N.node(G.borderTop),ne=N.node(G.borderBottom),ue=N.node(e.last(G.borderLeft)),X=N.node(e.last(G.borderRight));G.width=Math.abs(X.x-ue.x),G.height=Math.abs(ne.y-D.y),G.x=ue.x+G.width/2,G.y=D.y+G.height/2}}),e.forEach(N.nodes(),function(L){N.node(L).dummy==="border"&&N.removeNode(L)})}function re(N){e.forEach(N.edges(),function(L){if(L.v===L.w){var G=N.node(L.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:L,label:N.edge(L)}),N.removeEdge(L)}})}function Y(N){var L=f.buildLayerMatrix(N);e.forEach(L,function(G){var D=0;e.forEach(G,function(ne,ue){var X=N.node(ne);X.order=ue+D,e.forEach(X.selfEdges,function(U){f.addDummyNode(N,"selfedge",{width:U.label.width,height:U.label.height,rank:X.rank,order:ue+ ++D,e:U.e,label:U.label},"_se")}),delete X.selfEdges})})}function he(N){e.forEach(N.nodes(),function(L){var G=N.node(L);if(G.dummy==="selfedge"){var D=N.node(G.e.v),ne=D.x+D.width/2,ue=D.y,X=G.x-ne,U=D.height/2;N.setEdge(G.e,G.label),N.removeNode(L),G.label.points=[{x:ne+2*X/3,y:ue-U},{x:ne+5*X/6,y:ue-U},{x:ne+X,y:ue},{x:ne+5*X/6,y:ue+U},{x:ne+2*X/3,y:ue+U}],G.label.x=G.x,G.label.y=G.y}})}function me(N,L){return e.mapValues(e.pick(N,L),Number)}function J(N){var L={};return e.forEach(N,function(G,D){L[D.toLowerCase()]=G}),L}return pu}var gu,iy;function i_(){if(iy)return gu;iy=1;var e=Ue(),t=pr(),r=_r().Graph;gu={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),s=new r({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,u){var c="layer"+u;s.setNode(c,{rank:"same"}),e.reduce(a,function(l,d){return s.setEdge(l,d,{style:"invis"}),d})}),s}return gu}var yu,ay;function a_(){return ay||(ay=1,yu="0.8.5"),yu}var mu,sy;function s_(){return sy||(sy=1,mu={graphlib:_r(),layout:o_(),debug:i_(),util:{time:pr().time,notime:pr().notime},version:a_()}),mu}var c_=s_();const cy=U0(c_);function u_(e,t,r){var l;const n=new Set(e.map(d=>d.id)),o=new Set;for(const d of e)d.parent&&n.has(d.parent)&&o.add(d.parent);const i=new cy.graphlib.Graph({multigraph:!0,compound:!0}),s=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);i.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*s):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*s):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*s):r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const d of e)i.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&i.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||o.has(d.source)||o.has(d.target))continue;const f=Om(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",y=(f.width?f.width+2*Tm:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,f.height),height:p?Math.max(1,f.height):y,labelpos:"c"}:{}},d.id)}cy.layout(i);const a=new Map;for(const d of e){if(o.has(d.id))continue;const f=i.node(d.id);f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&a.set(d.id,{x:f.x,y:f.y})}const u=r.compact?1:r.spacingFactor;if(u&&u!==1&&a.size){let d=1/0,f=1/0,p=-1/0,y=-1/0;a.forEach(x=>{d=Math.min(d,x.x),f=Math.min(f,x.y),p=Math.max(p,x.x),y=Math.max(y,x.y)});const g=(d+p)/2,b=(f+y)/2;a.forEach((x,m)=>a.set(m,{x:g+(x.x-g)*u,y:b+(x.y-b)*u}))}const c=r.nodeAlignment??"center";if(c!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",f=d?"x":"y",p=d?"width":"height",y=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,g=c==="leading"?-y:y,b=new Map;for(const x of e){const m=a.get(x.id);if(!m)continue;const w=m[f];b.set(w,Math.max(b.get(w)??0,x[p]))}for(const x of e){const m=a.get(x.id);if(!m)continue;const w=m[f],v=(b.get(w)-x[p])/2;a.set(x.id,{...m,[f]:w+g*v})}}return a}function l_(e,t,r,n,o){const i=new Map,s=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!s.has(l.parent))continue;const d=i.get(l.parent);d?d.push(l.id):i.set(l.parent,[l.id])}const a=(l,d=new Set)=>{var p;const f=(p=s.get(l))==null?void 0:p.parent;return!f||!s.has(f)||d.has(l)?0:(d.add(l),1+a(f,d))},u=[...i.keys()].sort((l,d)=>a(d)-a(l)),c=new Map;for(const l of u){let d=null;for(const y of i.get(l)||[]){let g=c.get(y);if(!g){const b=t.get(y);if(!b)continue;const x=r.get(y)||{w:60,h:60};g={x1:b.x-x.w/2,y1:b.y-x.h/2,x2:b.x+x.w/2,y2:b.y+x.h/2}}d=d?{x1:Math.min(d.x1,g.x1),y1:Math.min(d.y1,g.y1),x2:Math.max(d.x2,g.x2),y2:Math.max(d.y2,g.y2)}:{...g}}if(!d)continue;const f=n(l);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(l);if(p){const y=d.x2-d.x1,g=d.y2-d.y1;if(p.w>y){const b=(p.w-y)/2;d.x1-=b,d.x2+=b}if(p.h>g){const b=(p.h-g)/2;d.y1-=b,d.y2+=b}}c.set(l,d)}return c}function d_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Pm(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 u=a.dataset.flowPortSide;if(u&&["top","right","bottom","left"].includes(u)){const l=jm(n?Ft(o,n):o,u,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const c=a.getBoundingClientRect();return!c.width||!c.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((c.top-t.top)/r*1e3)/1e3,height:Math.round(c.height/r*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function f_({id:e,x:t,y:r,placed:n,hidden:o,onMount:i,drawHandles:s,drawMode:a,connectedPorts:u,resolvedRows:c,hasCollapseControl:l,handleColor:d,animated:f,animationColor:p,animationWidth:y=8,animationVariant:g,width:b=0,height:x=0,propertyMode:m,reversePorts:w,direction:v="LR",onPropertyRows:C,onSurface:_,children:R}){const T=S.useRef(null),[A,k]=S.useState([]),E=c??A,[j,M]=S.useState();return S.useLayoutEffect(()=>{const I=T.current;if(!I)return;const q=()=>{const W=Pm(I);M(re=>JSON.stringify(re)===JSON.stringify(W)?re:W),_==null||_(e,W)};q();const O=new ResizeObserver(q);O.observe(I);const V=I.querySelector("[data-flow-node-surface]");return V&&O.observe(V),()=>O.disconnect()},[e,R,_]),S.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),_==null||_(e,void 0)}),[e,i,_]),S.useLayoutEffect(()=>{const I=T.current;if(!I)return;let q="";const O=()=>{const Y=d_(I),he=m?Y:Y.filter(J=>J.anchor),me=JSON.stringify(he);me!==q&&(q=me,k(he),C==null||C(e,he))};if(O(),!m&&!I.querySelector("[data-flow-port-side]"))return;const V=new ResizeObserver(O),W=()=>{V.disconnect(),V.observe(I),I.querySelectorAll("[data-flow-property]").forEach(Y=>V.observe(Y)),O()};W();const re=new MutationObserver(W);return re.observe(I,{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"]}),I.addEventListener("scroll",O,!0),()=>{V.disconnect(),re.disconnect(),I.removeEventListener("scroll",O,!0)}},[e,m,C,R]),h.jsxs("div",{ref:T,className:"flow-sdk-node","data-node-id":e,style:{transform:`translate(-50%, -50%) translate3d(${t.toFixed(2)}px, ${r.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden"},children:[R,f&&y>0&&b>0&&x>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(Em,{variant:g,x:((j==null?void 0:j.left)??0)+y/2,y:((j==null?void 0:j.top)??0)+y/2,width:((j==null?void 0:j.width)??b)-y,height:((j==null?void 0:j.height)??x)-y,radius:((j==null?void 0:j.radius)??0)-y/2,path:j!=null&&j.outline?`M${j.outline.map(I=>`${I.x} ${I.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:y})}),s&&m&&E.map(I=>["source","target"].filter(q=>!I.role||I.role===q).filter(q=>a||(u==null?void 0:u.has(`${q}:${I.property}`))).map(q=>{var O;return h.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":I.property,"data-port-role":q,"data-port-side":(O=I.anchor)==null?void 0:O.side,"aria-label":`${q==="source"?"Connect":"Input"} ${I.property}`,title:`${q==="source"?"Connect":"Input"} ${I.property}`,style:{color:d,...I.anchor?{top:I.anchor.y,left:I.anchor.x-16}:{top:I.top+I.height/2,[q==="source"!=!!w?"right":"left"]:-16}},onClick:V=>V.stopPropagation()},`${I.property}:${q}`)})),s&&!l&&(!m||!E.length)&&(!m||!E.some(I=>I.anchor))&&h.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((j==null?void 0:j.left)??0)+(v==="RL"?-36:v==="LR"?(j==null?void 0:j.width)??b:((j==null?void 0:j.width)??b)/2),top:((j==null?void 0:j.top)??0)+(v==="BT"?-36:v==="TB"?(j==null?void 0:j.height)??x:((j==null?void 0:j.height)??x)/2),transform:v==="BT"||v==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:I=>I.stopPropagation(),children:h.jsx(Z.PiPlusBold,{size:24})})]})}const h_=S.memo(f_);class p_{constructor(t,r,n){Tr(this,"_pan");Tr(this,"_zoom");Tr(this,"minZoom");Tr(this,"maxZoom");Tr(this,"size",{w:0,h:0});Tr(this,"listeners",new Set);Tr(this,"animationFrame");Tr(this,"animationTimer");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}cancelAnimation(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),clearTimeout(this.animationTimer),this.animationFrame=void 0,this.animationTimer=void 0}transition(t,r=!1){if(this.cancelAnimation(),!r||typeof requestAnimationFrame>"u"||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches){this.set(t.pan,t.zoom);return}const n=this.state,o={pan:{...t.pan},zoom:this.clamp(t.zoom)},i=performance.now(),s=()=>{this.cancelAnimation(),this.set(o.pan,o.zoom)},a=u=>{const c=Math.min(1,(u-i)/300);if(c>=1){s();return}const l=c*c*(3-2*c);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.animationFrame=requestAnimationFrame(a)};this.animationFrame=requestAnimationFrame(a),this.animationTimer=setTimeout(s,400)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(t){return Number.isFinite(t)?Math.max(this.minZoom,Math.min(this.maxZoom,t)):this.minZoom}set(t,r){this.cancelAnimation(),this.apply(t,r)}apply(t,r){let n=!1;if(t&&(t.x!==this._pan.x||t.y!==this._pan.y)&&(this._pan={x:t.x,y:t.y},n=!0),r!==void 0){const o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0,n=!1,o=1){const i=t.x2-t.x1,s=t.y2-t.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*r)/i,(this.size.h-2*r)/s))*o);this.transition({pan:{x:(this.size.w-a*(t.x1+t.x2))/2,y:(this.size.h-a*(t.y1+t.y2))/2},zoom:a},n)}center(t,r=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(t.x1+t.x2))/2,y:(this.size.h-n*(t.y1+t.y2))/2},zoom:n},r)}renderedToModel(t){return{x:(t.x-this._pan.x)/this._zoom,y:(t.y-this._pan.y)/this._zoom}}modelToRendered(t){return{x:t.x*this._zoom+this._pan.x,y:t.y*this._zoom+this._pan.y}}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(){const t=this.state;this.listeners.forEach(r=>r(t))}}const g_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},bu={w:60,h:60},uy=4,y_=30,ly=300,m_=500,b_=45,v_=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function dy(e){const[t,r]=[...e.values()];return!t||!r?null:{center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2},distance:Math.max(1,Math.hypot(r.x-t.x,r.y-t.y))}}function x_(e){var ll;const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:u,spacingFactor:c=1.3,compactSpacingScale:l,minZoom:d,maxZoom:f,initialViewport:p,containerStyle:y,lineColor:g,drawMode:b,dragMode:x,multiSelect:m,isPerformanceMode:w}=e,[v,C]=S.useState(null),_=S.useMemo(()=>v?(v.mode==="connections"?Ll:Ol)(v.id,t,r):null,[v,t,r]),R=i==="auto"||i==="properties",T=S.useMemo(()=>r.filter(P=>Su(P,i)&&(!_||_.has(P.source)&&_.has(P.target))),[r,i,_]),A=S.useMemo(()=>F0(t,r,i,s,_),[t,r,i,s,_]),k=S.useRef(A);k.current=A;const E=S.useRef(e);E.current=e;const j=S.useRef(null),M=S.useRef(null),I=S.useRef(null),q=S.useRef(null),O=S.useMemo(()=>new p_(p,d,f),[]);S.useEffect(()=>{O.minZoom=d,O.maxZoom=f},[O,d,f]);const V=S.useRef(new Map),W=S.useRef(new Map),re=S.useRef(new Map),Y=S.useRef(null),[he,me]=S.useState(new Map),J=S.useCallback((P,$)=>{me(F=>{if(JSON.stringify(F.get(P))===JSON.stringify($))return F;const H=new Map(F);return $?H.set(P,$):H.delete(P),H})},[]),[N,L]=S.useState(new Map),G=S.useRef(N),D=S.useCallback((P,$)=>{L(F=>{if(JSON.stringify(F.get(P)??[])===JSON.stringify($))return F;const H=new Map(F);return $.length?H.set(P,$):H.delete(P),H})},[]),[ne,ue]=S.useState(()=>new Map),X=S.useRef(ne);X.current=ne;const U=S.useRef(new Map),K=S.useRef(!1),[te,ce]=S.useState(0),de=S.useRef(),Ae=S.useRef(),ge=S.useRef(null),Ke=S.useRef(),Oe=S.useRef(!1),Le=S.useRef(null),er=S.useRef(c),Ve=s,$e=S.useRef(Ve),[xe,Me]=S.useState(!0),Fe=S.useRef(null);Fe.current=_;const nr=S.useRef(1);nr.current=(v==null?void 0:v.mode)==="connections"?1.25:1;const Ze=S.useRef(null),Ye=S.useRef(t),fr=S.useRef([]),wr=S.useRef(!1),we=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(Ke.current)},ar=()=>{fr.current.length&&(wr.current=!0),!K.current&&E.current.fitOnInit!==!1&&(Oe.current=!0),clearTimeout(Ae.current),Ae.current=setTimeout(()=>{K.current=!0,ce(P=>P+1)},m_)},sr=P=>{we();const $=new Map(X.current),F=performance.now(),H=()=>{we(),ue(P),ar()},ie=pe=>{const je=Math.min(1,(pe-F)/ly);if(je>=1)return H();const Te=v_(je),ae=new Map;P.forEach((se,le)=>{const ye=$.get(le);ae.set(le,ye?{x:ye.x+(se.x-ye.x)*Te,y:ye.y+(se.y-ye.y)*Te}:se)}),ue(ae),ge.current=requestAnimationFrame(ie)};ge.current=requestAnimationFrame(ie),Ke.current=setTimeout(H,ly+100)},Ct=()=>{const P=E.current,$=nr.current,F=k.current,H=F.nodes.map(pe=>{const je=V.current.get(pe.id)||bu;return{id:pe.id,parent:pe.parent,width:je.w,height:je.h}});let ie;try{const pe=P.compactPropertyLayout,je=P.edgeMode!=="nodes"&&P.edgeMode!=="workflow",Te=F.edges.map(ae=>({...ae,connectorClearance:pe?je&&(ae.sourceProperty!==void 0||ae.targetProperty!==void 0)?L0:$0:0}));ie=u_(H,Te,{edgeLabelFontSize:P.edgeMode==="nodes"||P.edgeMode==="workflow"?Am:yn,rankDir:P.direction,compact:pe,nodeAlignment:P.nodeAlignment,rankSep:P.rankSep*$,edgeSep:P.edgeSep*$,nodeSep:5*$,spacingFactor:P.spacingFactor??1.3,compactSpacingScale:(P.compactSpacingScale??(P.spacingFactor??1.3)/1.3)*$})}catch(pe){console.warn("[flow-sdk] layout failed",pe);return}for(const[pe,je]of U.current)ie.has(pe)?ie.set(pe,je):P.nodes.some(Te=>Te.id===pe)||U.current.delete(pe);K.current&&!P.isPerformanceMode?sr(ie):(we(),ue(ie),ar())},oe=S.useCallback(()=>{clearTimeout(Ae.current),clearTimeout(de.current),de.current=setTimeout(Ct,E.current.layoutDebounce)},[]);S.useEffect(()=>{const P=new Map(Ye.current.map($=>[$.id,$]));t.some($=>{var F;return((F=P.get($.id))==null?void 0:F.collapsed)===!0&&!$.collapsed})&&(fr.current=t.filter($=>!P.has($.id)).map($=>$.id)),Ye.current=t,er.current!==c&&X.current.size>0&&(K.current=!0,Oe.current=!1,clearTimeout(Ae.current)),er.current=c,$e.current!==Ve&&(Oe.current=!Le.current),$e.current=Ve,oe()},[t,r,A.nodes,A.edges,Ve,n,o,a,u,oe,c,l]),S.useEffect(()=>()=>{clearTimeout(de.current),clearTimeout(Ae.current),we()},[]);const We=S.useCallback((P,$)=>{var F,H;if(!Y.current&&typeof ResizeObserver<"u"&&(Y.current=new ResizeObserver(ie=>{let pe=!1;for(const je of ie){const Te=re.current.get(je.target);if(!Te)continue;const ae=je.target,se=ae.offsetWidth,le=ae.offsetHeight;if(!se&&!le)continue;const ye=V.current.get(Te);ye&&ye.w===se&&ye.h===le||(V.current.set(Te,{w:se,h:le}),pe=!0)}pe&&oe()})),$){W.current.set(P,$),re.current.set($,P),(F=Y.current)==null||F.observe($);const ie=$.offsetWidth,pe=$.offsetHeight;(ie||pe)&&V.current.set(P,{w:ie,h:pe})}else{const ie=W.current.get(P);ie&&((H=Y.current)==null||H.unobserve(ie),re.current.delete(ie)),W.current.delete(P),V.current.delete(P),G.current.has(P)&&D(P,[])}oe()},[oe,D]);S.useEffect(()=>()=>{var P;return(P=Y.current)==null?void 0:P.disconnect()},[]);const Qe=S.useMemo(()=>{const P=new Map;for(const $ of t)$.label&&P.set($.id,$.label);return P},[t]),Be=S.useMemo(()=>l_(A.nodes,ne,V.current,P=>y(P).padding,P=>{const $=Qe.get(P);if(!$)return;const F=y(P);return{w:En($,`bold ${F.fontSize}px ${rt}`)+2*b_,h:0}}),[A.nodes,ne,y,Qe]),rr=S.useRef(Be);rr.current=Be;const De=S.useCallback(P=>{const $=rr.current.get(P);if($)return _0($);const F=X.current.get(P);if(!F)return;const H=V.current.get(P)||bu;return{x:F.x,y:F.y,w:H.w,h:H.h}},[]),Q=S.useMemo(()=>{const P=new Map;for(const $ of t){const F=De($.id);F&&P.set($.id,F)}return O0(N,P,he,r,n)},[N,t,ne,Be,he,r,n,De]);G.current=Q;const z=(P,$)=>{var ie;if(!R||$===void 0)return;const F=(ie=Q.get(P))==null?void 0:ie.find(pe=>pe.property===$),H=De(P);return F&&!F.anchor&&H?H.y-H.h/2+F.top+F.height/2:void 0},ee=(P,$)=>{var ie,pe;if($===void 0)return;const F=(pe=(ie=Q.get(P))==null?void 0:ie.find(je=>je.property===$))==null?void 0:pe.anchor,H=De(P);return F&&H?{x:H.x-H.w/2+F.x,y:H.y-H.h/2+F.y,side:F.side}:void 0},Ce=(P,$)=>{const F=De(P),H=he.get(P);return F&&H&&!Be.has(P)&&z(P,$)===void 0?Ft(F,H):F},_e=()=>{const P=[];X.current.forEach(($,F)=>{if(rr.current.has(F))return;const H=V.current.get(F)||bu;P.push(ct({x:$.x,y:$.y,w:H.w,h:H.h}))}),rr.current.forEach($=>P.push($));try{for(const $ of[M.current,I.current]){const F=$==null?void 0:$.getBBox();F&&F.width>0&&F.height>0&&P.push({x1:F.x,y1:F.y,x2:F.x+F.width,y2:F.y+F.height})}}catch{}return Qn(P)},Se=()=>{var F,H;const{pan:P,zoom:$}=O;q.current&&(q.current.style.transform=`translate3d(${P.x}px, ${P.y}px, 0) scale(${$})`),(F=M.current)==null||F.setAttribute("transform",`translate(${P.x} ${P.y}) scale(${$})`),(H=I.current)==null||H.setAttribute("transform",`translate(${P.x} ${P.y}) scale(${$})`)};S.useEffect(()=>{Se();let P=null,$;const F=O.onChange(()=>{Se();const H=j.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout($),$=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),P===null&&(P=requestAnimationFrame(()=>{var ie,pe;P=null,(pe=(ie=E.current).onViewportChange)==null||pe.call(ie,O.state)}))});return()=>{F(),clearTimeout($),P!==null&&cancelAnimationFrame(P)}},[]),S.useLayoutEffect(()=>{const P=j.current;if(!P)return;const $=()=>{let H=P.clientWidth,ie=P.clientHeight;ie||(ie=Math.max(0,window.innerHeight-P.getBoundingClientRect().top-100),ie&&(P.style.height=`${ie}px`)),H||(H=window.innerWidth,H&&(P.style.width=`${H}px`)),O.size={w:H,h:ie}};if($(),typeof ResizeObserver>"u")return;const F=new ResizeObserver($);return F.observe(P),()=>F.disconnect()},[O]),S.useEffect(()=>{if(wr.current){wr.current=!1;const $=fr.current.flatMap(H=>{const ie=De(H);return ie?[ct(ie)]:[]});fr.current=[];const F=Qn($);if(F){Oe.current=!1,O.center(F,E.current.animateViewport);return}}if(!Oe.current)return;Oe.current=!1;const P=_e();P&&O.fit(P,50,E.current.animateViewport)},[ne]);const Ge=S.useMemo(()=>{const P=ae=>Ol(ae,E.current.nodes,E.current.edges),$=(ae,se=50,le=E.current.animateViewport,ye=1)=>{const ur=Qn([...ae].flatMap(an=>{const _t=De(an);return _t?[ct(_t)]:[]}));ur&&(Oe.current=!1,O.fit(ur,Number.isFinite(se)?Math.max(0,se):50,le,ye))},F=(ae,se,le,ye)=>{if(!De(ae))return;const ur=se==="connections"?ie(ae):P(ae);Ze.current||(Ze.current={pan:{...O.pan},zoom:O.zoom}),Fe.current=ur,E.current.compactPropertyLayout&&(Oe.current=!1,Le.current=()=>$(Fe.current??ur,le,ye)),C({id:ae,mode:se}),E.current.compactPropertyLayout||$(ur,le,ye)},H=ae=>{Le.current?Le.current=ae:ae()},ie=ae=>Ll(ae,E.current.nodes,E.current.edges),pe=(ae=>{if(ae===void 0)return O.zoom;O.set(void 0,ae)}),je=(ae=>{if(ae===void 0)return O.pan;O.set(ae)}),Te=(ae,se)=>{var ye;const le=(ye=j.current)==null?void 0:ye.getBoundingClientRect();return{x:ae-((le==null?void 0:le.left)??0),y:se-((le==null?void 0:le.top)??0)}};return{zoom:pe,pan:je,setEdgesVisible:Me,focusNode:(ae,se,le)=>H(()=>$(new Set([ae]),se,le,.6)),focusBranch:(ae,se,le)=>H(()=>$(P(ae),se,le)),focusConnections:(ae,se,le)=>H(()=>$(ie(ae),se,le)),isolateConnections:(ae,se,le)=>F(ae,"connections",se,le),isolateBranch:(ae,se,le)=>F(ae,"branch",se,le),restoreView:(ae=E.current.animateViewport)=>{const se=E.current.compactPropertyLayout&&!!Fe.current;Fe.current=null,C(null);const le=Ze.current;Ze.current=null,se?Le.current=()=>{le&&O.transition(le,ae)}:le&&H(()=>O.transition(le,ae))},zoomAt:(ae,se)=>O.zoomAt(ae,se),fit:(ae=0,se=E.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ae,se)})},centerAndFit:(ae=0,se=E.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ae,se)})},center:(ae=E.current.animateViewport)=>{const se=_e();se&&O.center(se,ae)},clientToModel:(ae,se)=>O.renderedToModel(Te(ae,se)),modelToClient:ae=>{var ye;const se=(ye=j.current)==null?void 0:ye.getBoundingClientRect(),le=O.modelToRendered(ae);return{x:le.x+((se==null?void 0:se.left)??0),y:le.y+((se==null?void 0:se.top)??0)}},getNodeBox:ae=>De(ae),setNodePosition:(ae,se,le)=>{if(!X.current.has(ae)||se&&(!Number.isFinite(se.x)||!Number.isFinite(se.y)))return!1;if(we(),!se)return U.current.delete(ae),oe(),!0;const ye=new Map(X.current);return ye.set(ae,{...se}),(le==null?void 0:le.persist)===!1?U.current.delete(ae):U.current.set(ae,{...se}),X.current=ye,ue(ye),(le==null?void 0:le.persist)===!1&&oe(),!0},onViewportChange:ae=>O.onChange(ae)}},[]);S.useEffect(()=>{var P,$;return($=(P=E.current).onInit)==null||$.call(P,Ge),()=>O.cancelAnimation()},[Ge]),S.useEffect(()=>{var P,$;if(te>0){const F=Le.current;Le.current=null,F==null||F(),($=(P=E.current).onLayoutComplete)==null||$.call(P,Ge)}},[Ge,te]);const ke=S.useRef(null),qe=S.useRef(new Map),ze=S.useRef(!1),[gr,cr]=S.useState(null),[Re,Er]=S.useState(null),Ar=P=>{const $=j.current.getBoundingClientRect();return{x:P.clientX-$.left,y:P.clientY-$.top}},Lr=(P,$)=>{const F=E.current.nodes;for(let H=F.length-1;H>=0;H--){const ie=F[H].id;if(!ut(ie,E.current.edges,E.current.edgeMode)||Fe.current&&!Fe.current.has(ie)||ie===$||rr.current.has(ie))continue;const pe=De(ie);if(pe&&Il(P,ct(pe)))return ie}for(const[H,ie]of rr.current)if(ut(H,E.current.edges,E.current.edgeMode)&&!(Fe.current&&!Fe.current.has(H))&&H!==$&&Il(P,ie))return H;return null},Gn=(P,$)=>{if(E.current.edgeMode==="nodes"||E.current.edgeMode==="workflow")return null;const F=E.current.direction==="RL",H=Math.max(16,6/O.zoom);let ie=null;for(const pe of[...E.current.nodes].reverse()){if(!ut(pe.id,E.current.edges,E.current.edgeMode)||Fe.current&&!Fe.current.has(pe.id))continue;const je=De(pe.id),Te=G.current.get(pe.id);if(!je||!Te||rr.current.has(pe.id))continue;const ae=je.x+($==="source"!==F?1:-1)*je.w/2;for(const se of Te){if(se.role&&se.role!==$)continue;const le=je.y-je.h/2+se.top,ye=Math.hypot(P.x-(se.anchor?je.x-je.w/2+se.anchor.x:ae),P.y-le-se.height/2);if(!se.anchor&&P.x>=je.x-je.w/2&&P.x<=je.x+je.w/2&&P.y>=le&&P.y<=le+se.height)return{nodeId:pe.id,property:se.property};ye<=H&&(!ie||ye<ie.distance)&&(ie={nodeId:pe.id,property:se.property,distance:ye})}}return ie},Vb=P=>{var je;if(!P.currentTarget.contains(P.target)||P.button!==0||E.current.readOnly)return;ke.current||(ze.current=!1);const $=P.target;if($.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const F=E.current,H=Ar(P);if(P.pointerType==="touch"){qe.current.set(P.pointerId,H);const Te=dy(qe.current);if(Te){ke.current={kind:"pinch",distance:Te.distance,zoom:O.zoom,anchor:O.renderedToModel(Te.center)},Er(null),cr(null),ze.current=!0;for(const ae of qe.current.keys())P.currentTarget.setPointerCapture(ae);return}}if(ke.current)return;const ie=F.drawHandles&&$.closest(".flow-sdk-handle"),pe=F.drawHandles&&$.closest(".flow-sdk-property-port");if(F.drawMode||ie||pe){const Te=O.renderedToModel(H),ae=F.drawMode?Gn(Te,"source"):null,se=pe||ie,le=se?(je=se.closest("[data-node-id]"))==null?void 0:je.dataset.nodeId:(ae==null?void 0:ae.nodeId)??Lr(Te),ye=pe?pe.dataset.property:ae==null?void 0:ae.property;if(le){ke.current={kind:"draw",pointerId:P.pointerId,source:le,sourceProperty:ye,reverse:(pe==null?void 0:pe.dataset.portRole)==="target",startClient:{x:P.clientX,y:P.clientY}},ze.current=!0,Er({source:le,sourceProperty:ye,point:Te,target:null}),P.currentTarget.setPointerCapture(P.pointerId);return}}$.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(F.multiSelect?ke.current={kind:"box",pointerId:P.pointerId,start:H,current:H}:F.dragMode?ke.current={kind:"pan",pointerId:P.pointerId,start:H,pan0:O.pan,moved:!1}:ke.current={kind:"tap",pointerId:P.pointerId,start:H,moved:!1},P.currentTarget.setPointerCapture(P.pointerId))},Wb=P=>{const $=ke.current;if(!$||E.current.readOnly)return;const F=Ar(P);if(qe.current.has(P.pointerId)&&qe.current.set(P.pointerId,F),$.kind==="pinch"){const H=dy(qe.current);if(!H)return;const ie=Math.max(O.minZoom,Math.min(O.maxZoom,$.zoom*H.distance/$.distance));O.set({x:H.center.x-$.anchor.x*ie,y:H.center.y-$.anchor.y*ie},ie);return}if($.pointerId===P.pointerId)switch($.kind){case"pan":{const H=F.x-$.start.x,ie=F.y-$.start.y;if(!$.moved&&Math.hypot(H,ie)<=uy)return;$.moved=!0,ze.current=!0,O.set({x:$.pan0.x+H,y:$.pan0.y+ie});break}case"tap":{Math.hypot(F.x-$.start.x,F.y-$.start.y)>uy&&($.moved=!0);break}case"box":{ze.current=!0,$.current=F,cr({x1:Math.min($.start.x,F.x),y1:Math.min($.start.y,F.y),x2:Math.max($.start.x,F.x),y2:Math.max($.start.y,F.y)});break}case"draw":{const H=O.renderedToModel(F),ie=Gn(H,$.reverse?"source":"target");Er($.reverse&&ie?{source:ie.nodeId,sourceProperty:ie.property,point:H,target:$.source,targetProperty:$.sourceProperty}:{source:$.source,sourceProperty:$.sourceProperty,point:H,target:(ie==null?void 0:ie.nodeId)??Lr(H,$.source),targetProperty:ie==null?void 0:ie.property});break}}},sl=(P,$)=>{var ie,pe,je,Te,ae;qe.current.delete(P.pointerId);const F=ke.current;if(!F)return;if(F.kind==="pinch"){const se=[...qe.current][0];ke.current=se&&E.current.dragMode&&!$?{kind:"pan",pointerId:se[0],start:se[1],pan0:O.pan,moved:!0}:null;return}if(F.pointerId!==P.pointerId)return;ke.current=null;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}const H=E.current;switch($=$||!!H.readOnly,F.kind){case"pan":case"tap":!$&&!F.moved&&((ie=H.onBackgroundTap)==null||ie.call(H));break;case"box":{if(cr(null),$)break;const se=O.renderedToModel(F.start),le=O.renderedToModel(F.current),ye={x1:Math.min(se.x,le.x),y1:Math.min(se.y,le.y),x2:Math.max(se.x,le.x),y2:Math.max(se.y,le.y)};if(ye.x2-ye.x1<1&&ye.y2-ye.y1<1){(pe=H.onBackgroundTap)==null||pe.call(H);break}const ur=[];for(const an of H.nodes){const _t=De(an.id);_t&&S0(ct(_t),ye)&&ur.push(an.id)}ur.length&&((je=H.onBoxSelect)==null||je.call(H,ur));break}case"draw":{if(Er(null),$)break;const se=Ar(P),le=O.renderedToModel(se),ye=Gn(le,F.reverse?"source":"target"),ur=(ye==null?void 0:ye.nodeId)??Lr(le);if(ur===F.source&&(F.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===F.sourceProperty))break;ur?(Te=H.onEdgeDraw)==null||Te.call(H,F.reverse?ur:F.source,F.reverse?F.source:ur,F.sourceProperty!==void 0||(ye==null?void 0:ye.property)!==void 0?{sourceProperty:F.reverse?ye==null?void 0:ye.property:F.sourceProperty,targetProperty:F.reverse?F.sourceProperty:ye==null?void 0:ye.property}:void 0):Math.max(Math.abs(P.clientX-F.startClient.x),Math.abs(P.clientY-F.startClient.y))>y_&&((ae=H.onDrawIntoSpace)==null||ae.call(H,F.source,le,F.sourceProperty,F.reverse));break}}},Kr=S.useCallback(()=>{var F;const P=ke.current,$=[...qe.current.keys()];P&&P.kind!=="pinch"&&$.push(P.pointerId),ke.current=null,qe.current.clear(),Er(null),cr(null);for(const H of $)(F=j.current)!=null&&F.hasPointerCapture(H)&&j.current.releasePointerCapture(H)},[]);S.useEffect(()=>{const P=$=>{$.key==="Escape"&&Kr()};return window.addEventListener("keydown",P),window.addEventListener("blur",Kr),()=>{window.removeEventListener("keydown",P),window.removeEventListener("blur",Kr),ke.current=null,qe.current.clear()}},[Kr]),S.useEffect(()=>{Kr()},[b,x,m,i,n,e.drawHandles,e.readOnly,Kr]);const Gb=S.useMemo(()=>{const P=new Map,$=new Map;for(const F of T){if(F.source!==F.target)continue;const H=P.get(F.source)??0;P.set(F.source,H+1),$.set(F.id,H)}return $},[T]),Un=g_[n],[Hn,Ub]=S.useState(null),Kn=W0(t,T,!!((ll=e.edgeReveal)!=null&&ll.revealNodes));S.useLayoutEffect(()=>{j.current&&Hn&&G0(j.current)});const Jn=C0(T,Ce,Un),Hb=e.onEdgeSelect,Kb=e.onContainerSelect,cl=Re?Re.target&&Ce(Re.target,Re.targetProperty)||{x:Re.point.x,y:Re.point.y,w:1,h:1}:null,ul=Re?Ce(Re.source,Re.sourceProperty):null,Jb=["flow-sdk-canvas",b?"flow-sdk-draw":"",w?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:j,className:Jb,"data-edge-mode":i,onPointerDownCapture:Vb,onPointerMove:Wb,onPointerUp:P=>sl(P,!1),onPointerCancel:P=>sl(P,!0),onLostPointerCapture:P=>{const $=ke.current;$&&($.kind==="pinch"||$.pointerId===P.pointerId)&&Kr()},onClickCapture:P=>{P.currentTarget.contains(P.target)&&(ze.current||e.readOnly)&&(P.preventDefault(),P.stopPropagation())},children:[h.jsx("svg",{className:"flow-sdk-svg",children:h.jsxs("g",{ref:M,children:[h.jsx("g",{className:"flow-sdk-containers",children:[...Be].filter(([P])=>ut(P,r,i)).filter(([P])=>!_||_.has(P)).map(([P,$])=>{var F;return h.jsx(N0,{id:P,rect:$,label:Qe.get(P),labelLayer:Hn,style:y(P),onSelect:Kb,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(F=e.selectedNodeIds)==null?void 0:F.includes(P)},P)})}),h.jsx("g",{className:"flow-sdk-edges",children:xe&&T.map(P=>{var H,ie,pe;if(!Kn.ready.has(P.id)||_&&(!_.has(P.source)||!_.has(P.target)))return null;const $=Ce(P.source,P.sourceProperty),F=Ce(P.target,P.targetProperty);return!$||!F?null:h.jsx(Fl,{id:P.id,edgeData:P.data,validationIssue:P.validationIssue,edgeType:P.type,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Kn.complete,source:$,target:F,sourceProperty:P.sourceProperty,targetProperty:P.targetProperty,sourceY:z(P.source,P.sourceProperty),targetY:z(P.target,P.targetProperty),sourcePort:ee(P.source,P.sourceProperty),targetPort:ee(P.target,P.targetProperty),dir:Un,turn:((H=Jn.get(P.id))==null?void 0:H.turn)??P.turn,labelAtTarget:(ie=Jn.get(P.id))==null?void 0:ie.labelAtTarget,labelFraction:(pe=Jn.get(P.id))==null?void 0:pe.labelFraction,color:P.color,labelBg:P.labelBg,label:P.label,labelLayer:Hn,dashed:P.dashed,animated:P.animated&&!w,inverted:P.inverted,loopIndex:Gb.get(P.id)??0,onSelect:Hb},P.id)})}),xe&&Re&&Su(Re,i)&&ul&&cl&&h.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:h.jsx(Fl,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Re.source,target:Re.target??"",sourceProperty:Re.sourceProperty,targetProperty:Re.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,source:ul,target:cl,sourceProperty:Re.sourceProperty,targetProperty:Re.targetProperty,sourceY:z(Re.source,Re.sourceProperty),sourcePort:ee(Re.source,Re.sourceProperty),targetPort:Re.target?ee(Re.target,Re.targetProperty):void 0,targetY:Re.target?z(Re.target,Re.targetProperty):void 0,dir:Un,turn:.5,color:g,labelBg:g})})]})}),h.jsx("div",{ref:q,className:"flow-sdk-nodes",children:t.map(P=>{var pe,je;const $=ne.get(P.id),F=Be.get(P.id),H=($==null?void 0:$.x)??(F?(F.x1+F.x2)/2:0),ie=($==null?void 0:$.y)??(F?(F.y1+F.y2)/2:0);return h.jsx(h_,{id:P.id,x:H,y:ie,placed:!!$||!!F,hidden:!Kn.shown.has(P.id)||!ut(P.id,r,i)||!!_&&!_.has(P.id),onMount:We,drawHandles:e.drawHandles&&!e.readOnly,drawMode:b,connectedPorts:new Set(T.flatMap(Te=>[...Te.source===P.id&&Te.sourceProperty!==void 0?[`source:${Te.sourceProperty}`]:[],...Te.target===P.id&&Te.targetProperty!==void 0?[`target:${Te.targetProperty}`]:[]])),hasCollapseControl:P.hasCollapseControl,handleColor:g,animated:P.animated&&!F&&!w,animationColor:P.animationColor,animationWidth:P.animationWidth,animationVariant:P.animationVariant,width:(pe=V.current.get(P.id))==null?void 0:pe.w,height:(je=V.current.get(P.id))==null?void 0:je.h,propertyMode:R,resolvedRows:Q.get(P.id),reversePorts:n==="RL",direction:n,onPropertyRows:D,onSurface:J,children:P.element},P.id)})}),gr&&h.jsx("div",{className:"flow-sdk-box",style:{left:gr.x1,top:gr.y1,width:gr.x2-gr.x1,height:gr.y2-gr.y1}}),h.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:h.jsx("g",{ref:I,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:h.jsx("g",{ref:Ub,className:"flow-sdk-labels",style:{pointerEvents:b?"none":"visiblePainted",outline:"none"}})})})]})}const w_=S.memo(x_);function Mb({id:e,label:t,role:r,side:n,position:o=.5,placement:i,children:s,style:a}){return h.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"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:r==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??t??e})}const C_=bn.default.dialog`
158
158
  ${e=>zr(e.$surface,e.$border)}
159
159
  &[open] {
160
160
  display: flex;
@@ -168,7 +168,7 @@
168
168
  & *::-webkit-scrollbar {
169
169
  display: none;
170
170
  }
171
- `,__=mn.default.div`
171
+ `,__=bn.default.div`
172
172
  min-height: 0;
173
173
  overflow: auto;
174
174
  padding: 32px 0;
@@ -186,5 +186,5 @@
186
186
  black calc(100% - 32px),
187
187
  transparent
188
188
  );
189
- `;function qb({nodeAddress:e,active:t,label:r,open:n=!1,onClose:o,children:i,filter:s,height:a}){const{background:u,border:c,colorText:l}=He(),d=S.useRef(null),f=S.useId(),{data:p,schema:y,bindings:g}=S.useContext(Rr),b=i!==void 0||!!(p&&y&&(g?Qt(g,e,y):yt(p,e,y)));S.useEffect(()=>{var m,w,v,C,_;!t||!b||!n?(m=d.current)==null||m.close():(w=d.current)!=null&&w.open||((v=d.current)==null||v.showModal(),(_=(C=d.current)==null?void 0:C.querySelector("[data-form-filter] input"))==null||_.focus())},[t,b,n]);const x=fe(u);return b?h.jsx(h.Fragment,{children:typeof document<"u"&&Dt.createPortal(h.jsx(C_,{ref:d,id:f,$surface:x,$border:fe(c),"aria-label":`Configure ${r}`,onClose:o,onPointerDown:m=>m.stopPropagation(),onWheel:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),onClick:m=>{var w;m.stopPropagation(),m.target===m.currentTarget&&((w=d.current)==null||w.close())},style:{margin:"auto",padding:20,width:380,boxSizing:"border-box",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:fe(l),fontSize:16,textTransform:"none"},children:n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[h.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),h.jsx("form",{method:"dialog",style:{margin:0},onSubmit:m=>m.stopPropagation(),children:h.jsx(gt,{type:"submit","aria-label":"Close node configuration"})})]}),s&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),h.jsx(__,{"data-form-scroll":"",style:a?{flex:1}:void 0,children:i??h.jsx(am,{nodeAddress:e})})]})}),document.body)}):null}const Su=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:s,border:a,colorText:u}=He();return h.jsx(Ee,{label:t,children:h.jsx(B.Flex,{children:h.jsx(B.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})})},S_=({data:e,children:t,isInverted:r,isParent:n})=>{var N,L,G,D,ne,ue;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:s,setSelectedEdgeId:a,isMultiSelectMode:u,isPerformanceMode:c,engineRef:l,callbacks:d,config:f,themeColor:p,direction:y}=Ie(),{background:g,border:b,colorText:x}=He(),m=S.useRef(null),w=S.useRef(null),[v,C]=S.useState(!1),[_,R]=S.useState(!1),[T,A]=S.useState(!1),k=e==null?void 0:e.id,E=sm(k),j=o.includes(k),M=f.nodeOverlayActions,I=f.renderNodeOverlay,q=(()=>{var X;try{const U=(X=l.current)==null?void 0:X.zoom();return U!==void 0&&U<.08}catch{return!1}})(),O=S.useCallback(X=>{var K,te,ce,de;if(_||f.readOnly)return;const U={shiftKey:X.shiftKey,ctrlKey:X.ctrlKey,metaKey:X.metaKey,altKey:X.altKey};if(s&&(a(null),(K=d.onEdgeDeselect)==null||K.call(d)),u){const Ae=o.includes(k),ge=Ae?o.filter(Ke=>Ke!==k):[...o,k];i(ge),Ae?(te=d.onNodeDeselect)==null||te.call(d):(ce=d.onNodeSelect)==null||ce.call(d,k,e,U)}else i([k]),(de=d.onNodeSelect)==null||de.call(d,k,e,U)},[k,e,o,s,u,_,i,a,d,f]),V=S.useCallback(()=>{var X;_||f.readOnly||(X=d.onNodeDoubleClick)==null||X.call(d,k,e)},[k,e,_,d,f]),W=S.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>C(!0),100)},[]),re=S.useCallback(()=>{w.current&&clearTimeout(w.current),C(!1)},[]),Y=!!((N=e==null?void 0:e.config)!=null&&N.form),he={tabIndex:Y?0:void 0,"aria-haspopup":Y?"dialog":void 0,"aria-expanded":Y?T:void 0,onDoubleClickCapture:X=>{var U;!Y||f.readOnly||_||!X.currentTarget.contains(X.target)||X.target instanceof Element&&X.target.closest("button, input, textarea, select, a, [contenteditable=true]")||(X.preventDefault(),X.stopPropagation(),i([k]),A(!0),(U=d.onNodeDoubleClick)==null||U.call(d,k,e))},onKeyDown:X=>{!Y||f.readOnly||X.target!==X.currentTarget||X.key!=="Enter"||(X.preventDefault(),X.stopPropagation(),i([k]),A(!0))}},me=Y&&h.jsx(qb,{nodeAddress:k,active:j,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var X;A(!1),j&&((X=m.current)==null||X.focus({preventScroll:!0}))}}),J=Array.isArray((L=e==null?void 0:e.config)==null?void 0:L.ports)?e.config.ports.map(X=>h.jsx(Mb,{...X},`${X.id}:${X.role}`)):null;return n?h.jsxs(B.Box,{ref:m,...he,onClick:O,onDoubleClick:V,onMouseEnter:W,onMouseLeave:re,cursor:"pointer",position:"relative",children:[me,!c&&(I||M&&M.length>0)&&v&&!q&&h.jsxs(h.Fragment,{children:[h.jsx(B.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:k,nodeData:e,isRoot:k==="root",isParent:!0,isHovered:v,setIsHovered:C})}):h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(B.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(B.Box,{display:"contents",children:[U>0&&h.jsx(B.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(Su,{icon:X.icon,label:X.label,color:x,bgColor:g,borderColor:b,textColor:x,boxSize:5,onClick:K=>{var te;K.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,X.id,k,e)}})]},X.id))})})]}),t({id:k,data:e,isActive:j,isLowZoom:q,isEditing:_,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)}),E&&!((G=e==null?void 0:e.config)!=null&&G.parentContainer)&&((D=e==null?void 0:e.config)==null?void 0:D.collapsed)!==void 0&&(()=>{var K;const X=y==="TB"||y==="BT",U=r||y==="RL";return h.jsx(B.IconButton,{position:"absolute",...X?{[y==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:"-75px",left:U?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:te=>{var ce;te.stopPropagation(),(ce=d.onNodeCollapse)==null||ce.call(d,k,!e.config.collapsed)},bgColor:fe(((K=e==null?void 0:e.viewProps)==null?void 0:K.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:fe("gray.800")})})})()]}):h.jsxs(B.Box,{ref:m,...he,onClick:O,onDoubleClick:V,onMouseEnter:W,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[me,J,!c&&(I||M&&M.length>0)&&v&&!q&&h.jsxs(h.Fragment,{children:[h.jsx(B.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:k,nodeData:e,isRoot:k==="root",isParent:!!n,isHovered:v,setIsHovered:C})}):h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(B.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(B.Box,{display:"contents",children:[U>0&&h.jsx(B.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(Su,{icon:X.icon,label:X.label,color:x,bgColor:g,borderColor:b,textColor:x,boxSize:5,onClick:K=>{var te;K.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,X.id,k,e)}})]},X.id))})})]}),h.jsxs(B.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[E&&!((ne=e==null?void 0:e.config)!=null&&ne.parentContainer)&&((ue=e==null?void 0:e.config)==null?void 0:ue.collapsed)!==void 0&&!n&&(()=>{var te,ce,de;const X=y==="TB"||y==="BT",U=r||y==="RL",K=(te=e==null?void 0:e.config)!=null&&te.labelBelow?((((ce=e==null?void 0:e.viewProps)==null?void 0:ce.fontSize)||1)*100+100)/2:void 0;return h.jsx(B.IconButton,{position:"absolute",...X?{[y==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:K===void 0?"-75px":`calc(50% - ${K+75}px)`,left:U?K===void 0?"-75px":`calc(50% - ${K+75}px)`:void 0,alignSelf:K===void 0?"center":void 0,top:K===void 0?void 0:`${K}px`,transform:K===void 0?void 0:"translateY(-50%)",zIndex:K===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:Ae=>{var ge;Ae.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,k,!e.config.collapsed)},bgColor:fe(((de=e==null?void 0:e.viewProps)==null?void 0:de.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:fe("gray.800")})})})(),t({id:k,data:e,isActive:j,isLowZoom:q,isEditing:_,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)})]})]})},zn=S.memo(S_);function ol(e=!0){const t=S.useRef(null);return S.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Yt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:u})=>{const{callbacks:c,config:l,readOnly:d}=Ie(),f=l.editable&&!d,[p,y]=S.useState(t),[g,b]=S.useState(),x=S.useRef(null),m=S.useRef(!1),w=ol(s);S.useEffect(()=>{s&&(m.current=!1,x.current&&(x.current.focus(),x.current.select()))},[s]);const v=()=>{var _;if(m.current)return;m.current=!0;const C=p.trim();C&&C!==t&&((_=c.onNodeLabelChange)==null||_.call(c,e,C)),u()};return!f||!s?h.jsx(B.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:f?C=>{C.stopPropagation(),b({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(t),a()}:void 0,cursor:f?"text":void 0,children:t}):h.jsxs("div",{ref:w,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[h.jsx(B.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),h.jsx(B.Input,{ref:x,value:p,onChange:C=>y(C.target.value),onBlur:v,onKeyDown:C=>{C.key==="Enter"&&v(),C.key==="Escape"&&(m.current=!0,u())},color:r,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"})]})},E_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var g,b,x,m,w,v,C,_;const{themeColor:s}=Ie(),{colorText:a}=He(),u=((g=t==null?void 0:t.viewProps)==null?void 0:g.bgColor)==="transparent",c=((b=t==null?void 0:t.viewProps)==null?void 0:b.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Xt(((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||s),p=fe(((m=t==null?void 0:t.viewProps)==null?void 0:m.textColor)||(u||c?a:f)),y=((w=t==null?void 0:t.viewProps)==null?void 0:w.borderColor)||(c?!u&&((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)||s:d);return h.jsx(B.Box,{"data-flow-node-surface":"",borderRadius:(C=t==null?void 0:t.viewProps)==null?void 0:C.borderRadius,bgColor:c?"transparent":l,...hn(t==null?void 0:t.viewProps,y,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:h.jsxs(B.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((_=t==null?void 0:t.config)==null?void 0:_.icon)&&h.jsx(B.Box,{flexShrink:0,children:h.jsx(qr,{name:t.config.icon,size:80,color:p})}),h.jsx(Yt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Vn(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Ie();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>t(o,"properties"),restoreNodeView:o=>t(o,"default"),toggleNodeView:o=>t(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:t}}const j_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var w,v,C,_,R,T,A,k,E,j,M,I,q,O,V;const{themeColor:s}=Ie(),{colorText:a}=He(),u=((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)==="transparent",c=((v=r==null?void 0:r.viewProps)==null?void 0:v.outline)===!0,l=!u&&((C=r==null?void 0:r.viewProps)==null?void 0:C.bgColor)||s,{borderColor:d,highlightColor:f,textColor:p}=Xt(l),y=fe(((_=r==null?void 0:r.viewProps)==null?void 0:_.textColor)||(u||c?a:p)),g=u&&!c&&!((R=r==null?void 0:r.viewProps)!=null&&R.borderColor)?"transparent":fe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),b=u||c?"transparent":l!=null&&l.startsWith("#")?l:fe(f),x=(A=r==null?void 0:r.config)==null?void 0:A.icon,m=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((k=r==null?void 0:r.config)!=null&&k.labelBelow){const W=(((E=r==null?void 0:r.viewProps)==null?void 0:E.fontSize)||1)*100;return h.jsxs(B.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(W+200,360)}px`,position:"relative",children:[h.jsx(B.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${W+100}px`,height:`${W+100}px`,flexShrink:0,borderRadius:(j=r==null?void 0:r.viewProps)==null?void 0:j.borderRadius,backgroundColor:b,...hn(r==null?void 0:r.viewProps,g,t,2),children:!!x&&h.jsx(qr,{name:x,size:W,color:y})}),h.jsxs(B.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[h.jsx(Yt,{nodeId:e,label:m,color:fe(((M=r==null?void 0:r.viewProps)==null?void 0:M.textColor)||a),isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((I=r.config)==null?void 0:I.subtitle)=="string"&&r.config.subtitle!==""&&h.jsx(B.Text,{"data-flow-node-subtitle":"",color:fe(((q=r==null?void 0:r.viewProps)==null?void 0:q.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:r.config.subtitle,children:r.config.subtitle})]})]})}return h.jsxs(B.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(O=r==null?void 0:r.viewProps)==null?void 0:O.borderRadius,bgColor:b,style:{backgroundColor:b},textTransform:"capitalize",...hn(r==null?void 0:r.viewProps,g,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!x&&h.jsx(B.Flex,{align:"center",py:14,mr:m?8:0,flexShrink:0,children:h.jsx(qr,{name:x,size:(((V=r==null?void 0:r.viewProps)==null?void 0:V.fontSize)||1)*100,color:y},y)}),(m||!x)&&h.jsx(B.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Yt,{nodeId:e,label:m,color:y,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Nb({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=j_,...o}){const{colorMode:i,callbacks:s}=Ie();return h.jsx(zn,{...o,children:a=>h.jsxs(B.Box,{position:"relative",children:[h.jsx(n,{...a}),e&&a.isActive&&h.jsx(B.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:h.jsx(Ee,{label:t,children:h.jsx(be,{"aria-label":t,icon:h.jsx(B.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:r,onClick:u=>{var c;u.stopPropagation(),e(),(c=s.onNodeViewToggle)==null||c.call(s,o.data.id)}})})})]})})}const fy=1.55;function k_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Ie(),s=!!o.editable&&!i,[a,u]=S.useState(!1),[c,l]=S.useState(t),[d,f]=S.useState(),p=S.useRef(null),y=S.useRef(!1),g=ol(a);S.useLayoutEffect(()=>{const m=p.current;!a||!m||(m.style.height="auto",m.style.height=`${Math.max((d==null?void 0:d.height)??0,m.scrollHeight)}px`)},[c,a,d]),S.useEffect(()=>{var m;s?a&&(y.current=!1,(m=p.current)==null||m.focus()):u(!1)},[a,s]);const b=m=>{s&&(f({width:m.offsetWidth,height:m.offsetHeight}),l(t),u(!0))},x=()=>{var m;y.current||!s||(y.current=!0,c!==t&&((m=n.onNodeContentChange)==null||m.call(n,e,c)),u(!1))};return!a||!s?h.jsx(B.Box,{"data-flow-content":"",color:r,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:fy,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:s?"text":void 0,tabIndex:s?0:void 0,onDoubleClick:m=>{m.stopPropagation(),b(m.currentTarget)},onKeyDown:m=>{s&&m.key==="Enter"&&m.target===m.currentTarget&&(m.preventDefault(),m.stopPropagation(),b(m.currentTarget))},children:h.jsx(av.default,{options:{forceBlock:!0,wrapper:S.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t})}):h.jsx("div",{ref:g,style:{width:d==null?void 0:d.width,minHeight:d==null?void 0:d.height,maxWidth:"100%"},children:h.jsx(B.Textarea,{ref:p,"aria-label":"Node content",value:c,onChange:m=>l(m.target.value),onBlur:x,onKeyDown:m=>{m.stopPropagation(),!m.nativeEvent.isComposing&&(m.key==="Enter"&&(m.ctrlKey||m.metaKey)&&(m.preventDefault(),x()),m.key==="Escape"&&(y.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:fy,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const R_=(e,t,r)=>{var f,p,y,g;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Xt(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,u=r==="dark"?"gray.200":"gray.900",c=a?"transparent":n!=null&&n.startsWith("#")?fe(n):fe(i.bgColor),l=fe(((y=e==null?void 0:e.viewProps)==null?void 0:y.textColor)||(a?u:i.textColor)),d=fe(((g=e==null?void 0:e.viewProps)==null?void 0:g.borderColor)||(s?n==="transparent"?t:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?u:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:c,hextextColor:l,hexborderColor:d}},P_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,A_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,$b=600,T_=3,O_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function I_({headerTitle:e,hasContent:t,data:r,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isEditing:u,onEditStart:c,onEditEnd:l,props:d,objVisible:f,setObjVisible:p,onShowNativeIcon:y}){var m,w;const{callbacks:g}=Ie(),b=d.onShowIcon??y,x=b?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((m=r.config)==null?void 0:m.form)||a&&y)&&h.jsxs(B.Flex,{justify:"flex-start",direction:"row",p:Object.entries(r.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&&!t?"transparent":o.hexborderColor,children:[!!n&&h.jsx(B.Flex,{mr:6,alignItems:"center",flexShrink:0,children:h.jsx(qr,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),h.jsx(Yt,{nodeId:s,label:A_(e),color:((w=r==null?void 0:r.viewProps)==null?void 0:w.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),a&&(t||b)&&h.jsx(B.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(Ee,{label:x,children:h.jsx(be,{"aria-label":x,icon:h.jsx(B.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:v=>{var C;v.stopPropagation(),b?b():p(!f),(C=g.onNodeViewToggle)==null||C.call(g,s)}})})})]})})}function M_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:u}){const{edgeById:c}=Ur(),l=new Set;for(const{data:d}of c.values())d.source===e.id&&d.sourceProperty!==void 0&&l.add(`source:${d.sourceProperty}`),d.target===e.id&&d.targetProperty!==void 0&&l.add(`target:${d.targetProperty}`);return h.jsx(B.Box,{children:Object.entries(e.description||{}).map(([d,f],p)=>{var M,I,q;const y=t&&Object.keys(t).find(O=>O.slice(O.indexOf(":")+1)===d),g=r&&((M=n==null?void 0:n.type.ports)==null?void 0:M[d]),b=y??(g?`${g.kind}:${d}`:d),x=o.find(O=>O.id===b),m=y?"source":x==null?void 0:x.role,w=l.has(`source:${b}`),v=l.has(`target:${b}`),C=i.some(O=>O.id===d),_=f===""&&(C||(m?l.has(`${m}:${b}`):w||v)),R=m??(w!==v?w?"source":"target":void 0),T=(x==null?void 0:x.side)??(R?R==="source"!=(a==="RL")?"right":"left":void 0),A=_&&T==="right"?"right":"left",k=(x==null?void 0:x.label)??(g==null?void 0:g.label)??(C?d.replace(/^(template|input|output|config|error):/,""):d),E=jr(s.wordBeforeDot)[typeof f],j=jr(s.wordBeforeDot).property;return h.jsxs(B.Box,{"data-flow-property":y&&(a==="TB"||a==="BT")?void 0:b,"data-flow-port-role":m,"data-flow-inspection-row":r?"":void 0,children:[h.jsxs(B.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[h.jsx(B.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:_?"100%":`${u}px`,minWidth:`${u}px`,borderRightColor:s.hexborderColor,borderRightWidth:_?0:1,children:h.jsx(B.Text,{py:5,px:10,w:"100%",textAlign:A,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((I=e==null?void 0:e.viewProps)==null?void 0:I.textColor)||(s.isTransparent?s.hextextColor:j),children:k})}),!_&&h.jsx(B.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:$b,maxH:200,children:h.jsx(B.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((q=e==null?void 0:e.viewProps)==null?void 0:q.textColor)||(s.isTransparent?s.hextextColor:E),fontWeight:400,children:P_(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(B.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},d)})})}function q_(e){var w,v,C;const{themeColor:t,colorMode:r,direction:n}=Ie(),o=Vn(),i=o.getNodeViewMode(e.data.id)==="properties",s=_=>o.setNodeViewMode(e.data.id,_?"properties":"default"),a=!!e.onShowIcon||i||typeof((w=e.data.config)==null?void 0:w.content)!="string",{bindings:u,data:c,schema:l}=S.useContext(Rr),d=(v=u==null?void 0:u[e.data.id])==null?void 0:v.portResources,f=u?Qt(u,e.data.id,l):c&&l?yt(c,e.data.id,l):void 0,p=f&&ve(c,"address"in f?f.address:e.data.id),y=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(_=>{var R;return Object.prototype.hasOwnProperty.call(p,_)&&wn((R=f.fields[_])==null?void 0:R.$visibleWhen,c)}).map(_=>[_,p[_]!==null&&typeof p[_]=="object"?JSON.stringify(p[_],null,2):p[_]===null?"null":p[_]])):{},g=d?Object.fromEntries(Object.entries(d).map(([_,R])=>{var T;return[_.slice(_.indexOf(":")+1),((T=ve(c,R))==null?void 0:T.name)??R.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:y,b=a&&!d?((C=e.data.config)==null?void 0:C.ports)??[]:[],x=b.filter(_=>!Object.prototype.hasOwnProperty.call(g,_.id)&&!Object.entries((f==null?void 0:f.type.ports)??{}).some(([R,T])=>`${T.kind}:${R}`===_.id&&Object.prototype.hasOwnProperty.call(g,R))),m={...g,...Object.fromEntries(x.map(_=>[_.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:d,form:f,description:m,inspectionPorts:b,extraPorts:x}}const il=e=>{var b,x,m;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:u,description:c,inspectionPorts:l,extraPorts:d}=q_(e),f=Vn(),p=f.getNodeViewMode(e.data.id)==="icon-label",g=!e.onShowIcon&&!((b=e.data.config)!=null&&b.parentContainer)&&typeof((x=e.data.config)==null?void 0:x.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Nb,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((m=e.data.config)==null?void 0:m.icon)||"PiBracketsCurly"}},onExpand:()=>f.restoreNodeView(e.data.id)}):h.jsx(zn,{...e,data:{...e.data,description:c},children:({id:w,data:v,isActive:C,isEditing:_,onEditStart:R,onEditEnd:T})=>{var W,re,Y,he,me,J;const A=R_(v,t,r),k=v.label??v.headerTitle,E=Object.entries(v.description||{}).length>0,j=O_(v.description),M=(re=(W=e.data)==null?void 0:W.config)==null?void 0:re.icon,I=(he=(Y=e.data)==null?void 0:Y.config)==null?void 0:he.content,q=typeof I=="string"&&!e.onShowIcon,O=((me=v==null?void 0:v.viewProps)==null?void 0:me.borderRadius)??"53px",V=hn(v==null?void 0:v.viewProps,A.hexborderColor,C,T_);return h.jsx(B.Flex,{justifyContent:"space-between",...v==null?void 0:v.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:O,overflow:"hidden",alignItems:"center",style:{backgroundColor:A.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:q||e.onShowIcon?j+$b+V.borderWidth*2:void 0,...V,children:h.jsxs(B.Flex,{width:"100%",direction:"column",borderRadius:O,borderColor:A.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(I_,{headerTitle:k,hasContent:q,data:v,icon:M,colors:A,hasConfig:E,id:w,isActive:C,isEditing:_,onEditStart:R,onEditEnd:T,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:g}),q&&!o?h.jsx(B.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:A.highlightColor,p:12,fontSize:"5xl",lineHeight:"normal",children:h.jsx(k_,{nodeId:w,content:I,color:((J=v==null?void 0:v.viewProps)==null?void 0:J.textColor)||A.hextextColor})}):h.jsx(M_,{data:v,resourcePorts:a,inspecting:s,form:u,inspectionPorts:l,extraPorts:d,colors:A,direction:n,uniformKeyWidth:j})]})})}})};il.displayName="NodeJsonObjectView";const Lb=e=>{var c,l,d,f,p,y,g;const t=Vn(),r=t.getNodeViewMode(e.data.id)==="properties",n=b=>t.setNodeViewMode(e.data.id,b?"properties":"default"),{callbacks:o,readOnly:i}=Ie(),s=(l=(c=e.data)==null?void 0:c.config)==null?void 0:l.parentContainer,a=s?"Show parent":"Show properties",u=s||((f=(d=e.data)==null?void 0:d.config)==null?void 0:f.form)||((g=(y=(p=e.data)==null?void 0:p.config)==null?void 0:y.ports)==null?void 0:g.length);return!s&&u&&r?h.jsx(il,{...e,onShowIcon:()=>n(!1)}):h.jsx(Nb,{...e,toggleLabel:a,toggleDisabled:s&&i,onExpand:u?()=>{var b;s?(b=o.onNodeCollapse)==null||b.call(o,e.data.id,!1):n(!0)}:void 0})},Fb=e=>h.jsx(Lb,{...e,renderCompact:E_}),Bb=e=>h.jsx(Lb,{...e}),Db=e=>h.jsx(zn,{...e,children:()=>null});Fb.displayName="text";Bb.displayName="arrayView";Db.displayName="ParentContainerView";const N_={objectView:il,arrayView:Bb,text:Fb,parentContainer:Db},$_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Ie(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?h.jsx(B.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):h.jsxs(B.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[h.jsx(B.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="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}}),h.jsx(B.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},L_=.4,Jr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},F_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:o,backgroundVariant:i,setBackgroundSelected:s,edgeColor:a,direction:u,nodeAlignment:c,edgeMode:l,compactPropertyLayout:d,workflowContract:f,parentNodeStyle:p,engineRef:y,callbacks:g,config:b,selectedNodeIds:x,setSelectedNodeIds:m,selectedEdgeId:w,setSelectedEdgeId:v,setIsPerformanceMode:C,isZoomMode:_,setIsZoomMode:R,isMultiSelectMode:T,setIsMultiSelectMode:A,isDragMode:k,setIsDragMode:E,isEdgeHandlesEnabled:j,setIsEdgeHandlesEnabled:M,isArrayNodeMode:I}=Ie(),q=S.useRef(null),[O,V]=S.useState(null),W=e.length>200;S.useEffect(()=>{C(W)},[W,C]);const{edgeSep:re,rankSep:Y,spacingFactor:he}=S.useMemo(()=>{const Q=w0(e.length),z=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Q.edgeSep*z,rankSep:Q.rankSep*z,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:me}=Xt(r),{canvas:J,borderSecondary:N,colorText:L}=He(),G=i==="transparent"?"transparent":b.backgroundColor||J,D=S.useCallback(Q=>{if(Q!=null&&Q.includes("gray"))return"whitesmoke";if(!Q)return fe(r);switch(Q){case"dark":return fe(G);case"light":return fe(N);default:return fe(Q)}},[r,G,N]),ne=b.colorMode==="dark",ue=S.useMemo(()=>D(ne?me:"light"),[ne,me,D]),X=a?D(a):ue,U=S.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),K=u==="C"?"LR":u,te=S.useCallback(Q=>{const z={...p,...Q};return{...z,bgColor:z.bgColor||r,bgOpacity:z.outline?0:z.bgOpacity??L_}},[p,r]),ce=S.useMemo(()=>{var z;const Q=new Map;for(const ee of e)(z=ee.data)!=null&&z.id&&Q.set(ee.data.id,ee);return Q},[e]),de=S.useMemo(()=>{var z;const Q=new Map;for(const ee of t)(z=ee.data)!=null&&z.id&&Q.set(ee.data.id,ee);return Q},[t]),Ae=S.useCallback(Q=>{var _e;const z=(_e=ce.get(Q))==null?void 0:_e.data,ee=te(z==null?void 0:z.viewProps),Ce=fe(ee.bgColor);return{animated:!!(z!=null&&z.isNodeAnimated)&&!W,animationVariant:z==null?void 0:z.nodeAnimationVariant,animationColor:fe(ee.borderColor||r),bgColor:ee.outline?"transparent":Ce,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?fe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?fe(r):Ce,borderWidth:Jt(ee.borderWidth,Jr.borderWidth),borderStyle:ee.borderStyle??Jr.borderStyle,borderRadius:ee.borderRadius??Jr.borderRadius,textColor:ee.textColor?fe(ee.textColor):ee.outline||ee.bgColor==="transparent"?fe(L):Ce,fontSize:ee.fontSize??Jr.fontSize,labelPosition:ee.labelPosition??Jr.labelPosition,labelMargin:Jr.labelMargin,labelBg:dl(D("dark"),Ce,ee.bgOpacity)??D("dark"),padding:ee.padding??Jr.padding}},[te,ce,L,r,W,D]),ge=S.useMemo(()=>{var ee,Ce;const Q=new Map;for(const _e of t){const Se=(ee=_e.data)==null?void 0:ee.source,Ge=(Ce=_e.data)==null?void 0:Ce.target;if(!Se||!Ge||Se===Ge)continue;const ke=Se<Ge?`${Se}|${Ge}`:`${Ge}|${Se}`,qe=Q.get(ke);qe?qe.push({id:_e.data.id,source:Se}):Q.set(ke,[{id:_e.data.id,source:Se}])}const z=new Map;for(const[_e,Se]of Q){if(Se.length<2)continue;const Ge=_e.split("|")[0],ke=Math.min(20,70/Se.length);Se.forEach(({id:qe,source:ze},gr)=>{const cr=50+(gr-(Se.length-1)/2)*ke;z.set(qe,(ze===Ge?cr:100-cr)/100)})}return z},[t]),Ke=S.useMemo(()=>{const Q=D("dark");return t.filter(z=>{var ee;return((ee=z.data)==null?void 0:ee.id)&&z.data.source&&z.data.target}).map(({data:z})=>{var Se,Ge,ke,qe,ze,gr;let ee=Q;const Ce=(Ge=(Se=ce.get(z.source))==null?void 0:Se.data)==null?void 0:Ge.parent,_e=(qe=(ke=ce.get(z.target))==null?void 0:ke.data)==null?void 0:qe.parent;if(Ce&&Ce===_e){const cr=te((gr=(ze=ce.get(Ce))==null?void 0:ze.data)==null?void 0:gr.viewProps),Re=dl(Q,fe(cr.bgColor),cr.bgOpacity);Re&&(ee=Re)}return{id:z.id,data:z,type:z.type??b.edgeType??"rounded-orthogonal",source:z.source,target:z.target,sourceProperty:z.sourceProperty,targetProperty:z.targetProperty,label:z.label,validationIssue:(l==="auto"||l==="properties")&&(z.sourceProperty!==void 0||z.targetProperty!==void 0)&&f?qu(f,z):void 0,color:z.color?fe(z.color):X,labelBg:ee,dashed:!!z.isEdgeDashed,animated:!!z.isEdgeAnimated,inverted:!!z.isInverted,turn:ge.get(z.id)??.5}})},[t,X,ge,b.edgeType,l,f,ce,te,D]),Oe=S.useMemo(()=>{var z;const Q=new Set;for(const ee of e)(z=ee.data)!=null&&z.parent&&Q.add(ee.data.parent);return Q},[e]),Le=S.useMemo(()=>{var z;const Q=new Map;for(const ee of t)(z=ee.data)!=null&&z.source&&!Q.has(ee.data.source)&&Q.set(ee.data.source,ee.data);return Q},[t]),er=S.useMemo(()=>{const Q={...N_,...b.customViews};return e.filter(z=>{var ee;return(ee=z.data)==null?void 0:ee.id}).map(z=>{var Ge,ke,qe,ze;const ee=Oe.has(z.data.id)&&!z.data.parent,Ce=ee?z.data.label??z.data.headerTitle??"Container":void 0,_e=ee?Q.parentContainer:Q[z.data.type]||Q.text,Se=Le.get(z.data.id);return{id:z.data.id,collapsed:(Ge=z.data.config)==null?void 0:Ge.collapsed,parent:z.data.parent,label:Ce,animated:!!z.data.isNodeAnimated,animationVariant:z.data.nodeAnimationVariant,hasCollapseControl:((ke=z.data.config)==null?void 0:ke.collapsed)!==void 0,animationColor:fe(((qe=z.data.viewProps)==null?void 0:qe.borderColor)||r),animationWidth:Jt((ze=z.data.viewProps)==null?void 0:ze.borderWidth,8),element:S.createElement(_e,{...z,isInverted:Se==null?void 0:Se.isInverted,isParent:ee,key:`${z.data.id}-${r}`})}})},[e,Oe,Le,r,b.customViews]),Ve=S.useMemo(()=>W?300:e.length>50?150:e.length>20?100:50,[e.length,W]),$e=S.useRef(b);$e.current=b;const xe=S.useRef(_);xe.current=_;const Me=S.useRef(I);Me.current=I;const Fe=S.useRef(x);Fe.current=x;const nr=S.useRef(w);nr.current=w;const Ze=S.useRef(T);Ze.current=T;const Ye=S.useRef(ce);Ye.current=ce;const fr=S.useRef(de);fr.current=de;const wr=S.useRef(new Map);S.useEffect(()=>{var ee,Ce;const Q=new Map([...de].filter(([,_e])=>ce.has(_e.data.source)&&ce.has(_e.data.target))),z=wr.current;wr.current=Q;for(const[_e,Se]of z)Q.has(_e)||(nr.current===_e&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g)),(Ce=g.onEdgeRemove)==null||Ce.call(g,_e,Se.data))},[de,ce,g,v]),S.useEffect(()=>{const Q=q.current;if(!O||!Q)return;let z=null,ee=null,Ce=0,_e=0,Se=0,Ge=0,ke=0;const qe=ze=>{if($e.current.readOnly)return;ze.preventDefault(),ze.stopPropagation(),xe.current||ze.metaKey||ze.ctrlKey?(Se+=ze.deltaY,Ge=ze.clientX,ke=ze.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const cr=$e.current,Re=O.zoom(),Er=Se;Se=0;let Ar=Re-Er*.05/100;Ar=Math.max(cr.minZoom??.01,Math.min(cr.maxZoom??1.5,Ar));const Lr=Q.getBoundingClientRect();O.zoomAt(Ar,{x:Ge-Lr.left,y:ke-Lr.top})}))):(Ce+=ze.deltaX,_e+=ze.deltaY,z===null&&(z=requestAnimationFrame(()=>{z=null;const cr=O.pan(),Re=O.zoom(),Er=.35,Ar=Ce,Lr=_e;Ce=0,_e=0,O.pan({x:cr.x+-Ar*Er/Re,y:cr.y+-Lr*Er/Re})})))};return Q.addEventListener("wheel",qe,{passive:!1}),()=>{Q.removeEventListener("wheel",qe),z!==null&&cancelAnimationFrame(z),ee!==null&&cancelAnimationFrame(ee)}},[O]),S.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Q=z=>{var Ce,_e,Se,Ge;if($e.current.readOnly)return;const ee=z.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((z.key==="z"||z.key==="Z")&&R(!xe.current),(z.key==="m"||z.key==="M")&&A(!T),(z.key==="d"||z.key==="D")&&E(!k),(z.key==="v"||z.key==="V")&&!z.repeat&&!z.metaKey&&!z.ctrlKey&&!z.altKey&&ee.tagName!=="SELECT"&&M(!j),(z.key==="Delete"||z.key==="Backspace")&&nr.current){z.preventDefault();const ke=nr.current;(_e=g.onEdgeDelete)==null||_e.call(g,ke,((Ce=fr.current.get(ke))==null?void 0:Ce.data)??{id:ke}),v(null);return}if((z.key==="Delete"||z.key==="Backspace")&&Fe.current.length>0){z.preventDefault();const ke=Fe.current.filter(qe=>qe!=="root");if(ke.length===0)return;for(const qe of ke){const ze=(Se=Ye.current.get(qe))==null?void 0:Se.data;(Ge=g.onNodeDelete)==null||Ge.call(g,qe,ze||{})}m([])}}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[T,k,j,M,R,A,E,b.disableKeyboardShortcuts,g,m,v]);const we=S.useCallback(Q=>{var z;y.current=Q,V(Q),(z=g.onInit)==null||z.call(g,Q)},[y,g]),ar=S.useCallback(Q=>{var z;return(z=g.onViewportChange)==null?void 0:z.call(g,Q)},[g]),sr=S.useCallback(Q=>{var ee,Ce,_e;const z=((ee=fr.current.get(Q))==null?void 0:ee.data)??{id:Q};if(nr.current===Q&&Ze.current){v(null),(Ce=g.onEdgeDeselect)==null||Ce.call(g);return}Fe.current.length&&m([]),v(Q),(_e=g.onEdgeSelect)==null||_e.call(g,Q,z)},[g,v,m]),Ct=S.useCallback(()=>{var Q,z,ee;s(!0),(Q=g.onBackgroundClick)==null||Q.call(g),Fe.current.length&&(m([]),(z=g.onNodeDeselect)==null||z.call(g)),nr.current&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g))},[g,m,v,s]),oe=S.useCallback(Q=>{var Ce,_e;const z=Fe.current,ee=Q.filter(Se=>!z.includes(Se));if(ee.length){m([...z,...ee]);for(const Se of ee)(_e=g.onNodeSelect)==null||_e.call(g,Se,((Ce=Ye.current.get(Se))==null?void 0:Ce.data)??{id:Se})}},[g,m]),We=S.useCallback((Q,z)=>{var ee,Ce;m([Q]),(Ce=g.onNodeSelect)==null||Ce.call(g,Q,((ee=Ye.current.get(Q))==null?void 0:ee.data)??{id:Q},z)},[g,m]),Qe=S.useCallback((Q,z,ee)=>{var Ce;return(Ce=g.onEdgeCreate)==null?void 0:Ce.call(g,Q,z,ee)},[g]),Be=S.useCallback((Q,z,ee,Ce=!1)=>{var _e,Se;l==="properties"&&((_e=g.onNodeCreateRequest)==null?void 0:_e.call(g,{sourceNodeId:Q,position:z,sourceProperty:ee,reverse:Ce}))===!0||ee!==void 0||Ce||(Se=g.onNodeCreate)==null||Se.call(g,{type:"text",sourceNodeId:Q,position:z,isArrayMode:Me.current})},[g,l]),rr=!b.readOnly&&j&&b.edgeHandles!==!1,De=i==="transparent"?"none":i;return h.jsx($_,{pattern:De,backgroundColor:G,children:h.jsx(B.Box,{ref:q,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(w_,{nodes:er,edges:Ke,direction:K,nodeAlignment:c,onContainerCollapse:Q=>{var z,ee;(z=g.onNodeCollapse)==null||z.call(g,Q,!0),(ee=g.onNodeViewToggle)==null||ee.call(g,Q)},selectedNodeIds:x,edgeMode:l,compactPropertyLayout:d,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.edgeReveal,rankSep:Y,edgeSep:re,spacingFactor:he,compactSpacingScale:n,layoutDebounce:Ve,isPerformanceMode:W,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:U,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:Ae,lineColor:X,drawMode:rr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:k,multiSelect:!!T,onInit:we,onLayoutComplete:g.onLayoutComplete,animateViewport:b.animateViewport,onViewportChange:ar,onBackgroundTap:Ct,onBoxSelect:oe,onEdgeSelect:sr,onContainerSelect:We,onEdgeDraw:Qe,onDrawIntoSpace:Be})})})},zb=S.memo(F_),B_=".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 hy=!1;function D_(){if(hy||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=B_+x0+y0+b0+".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}',hy=!0}function z_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=S.useState(null),i=S.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&h0(n.json,r.json),[n==null?void 0:n.json,r.json]),s=n===null||n.json!==r.json&&!i,a=e||s;return S.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),S.useEffect(()=>{if(e||!s)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>o(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,s,r.json]),h.jsxs(B.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[h.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{a?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&h.jsx(V_,{...s?n:r,className:void 0,style:void 0})}),a&&t!==null&&h.jsx(B.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((u=r.config)==null?void 0:u.colorMode)==="dark"?"gray.800":"gray.100",color:((c=r.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?h.jsx("span",{children:"Loading diagram..."}):t})]})}function V_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:u,showBottomBar:c=!0,children:l}){D_();const[d,f]=S.useState(),[p,y]=S.useState(!1),g=i.formSchema??d,b=S.useMemo(()=>t&&r?om(t,r.state):t,[t,r==null?void 0:r.state]),x=i.direction==="C",m=S.useMemo(()=>{let E,j;return M=>(j=E&&j?p0(E,M,j)??xu(M,{title:e,isCenter:x}):xu(M,{title:e,isCenter:x}),E=M,j)},[e,x]),w=S.useMemo(()=>b?m(b):null,[b,m]),v=S.useMemo(()=>r!=null&&r.structured&&!p&&g?s0(r.state,r.bindings,g,(w==null?void 0:w.nodes)??n??[]):void 0,[r==null?void 0:r.structured,p,r==null?void 0:r.state,r==null?void 0:r.bindings,g,w,n]),C=(v==null?void 0:v.schema)??g,_=(v==null?void 0:v.bindings)??(r==null?void 0:r.bindings),R=S.useMemo(()=>[...(w==null?void 0:w.nodes)??n??[],...(v==null?void 0:v.nodes)??[]].map(j=>{var re,Y,he,me;const M=t?(re=ve(t,j.data.id))==null?void 0:re.$view:(Y=j.data.config)==null?void 0:Y.typeView,I=M&&zt.includes(M)?M:void 0,q=I?I==="icon-label":(he=j.data.config)==null?void 0:he.labelBelow,O=I==="object"?"objectView":I==="text"?"text":q?"arrayView":j.data.type,V=C&&(r?Qt(_,j.data.id,C):t&&yt(t,j.data.id,C)),W=(((me=j.data.config)==null?void 0:me.ports)??[]).map(J=>({...J}));if(v&&V){const J=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[N,L]of Object.entries(V.type.ports??{})){const G=`${L.kind}:${N}`,D=W.find(ne=>ne.id===G);D?D.label===void 0&&L.label!==void 0&&(D.label=L.label):W.push({id:G,...L.label!==void 0?{label:L.label}:{},role:L.kind==="input"||L.kind==="config"?"target":"source",side:J[L.kind],...L.kind==="config"?{placement:"config"}:{}})}for(const N of W){const L=W.filter(G=>G.side===N.side);N.position=(L.indexOf(N)+1)/(L.length+1)}}return V||q||I?{...j,data:{...j.data,type:O,...r?{description:Object.fromEntries(Object.entries(j.data.description??{}).filter(([J])=>!J.startsWith("$")&&!(v!=null&&v.slots.has(Rt(j.data.id,J)))))}:{},config:{...j.data.config,...v&&V?{ports:W}:{},...V?{form:!0}:{},...I?{typeView:I,labelBelow:!!q}:q?{labelBelow:!0}:{}}}}:j}),[w,n,t,C,_,v,i.direction]),T=[...(w==null?void 0:w.edges)??o??[],...(v==null?void 0:v.edges)??[]],A=S.useMemo(()=>{const E=t&&w?Sm(t,w.edges,s,s.onJsonChange,g):{...s};if(v){const j=new Set([...v.nodes.map(M=>M.data.id),...v.edges.map(M=>M.data.id)]);for(const M of Object.keys(E)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const I=E[M];E[M]=(q,...O)=>{if(!j.has(q))return I==null?void 0:I(q,...O)}}}return{...E,onAllNodesIconLabelChange:j=>{var M;y(j),(M=E.onAllNodesIconLabelChange)==null||M.call(E,j)}}},[t,w,s,g,v]),k=S.useMemo(()=>{if(!r)return A;let E=r.state;const j=I=>{if(i.readOnly||i.editable===!1)return;const q=r.onStateChange??r.onChange;if(!q)return;const O=e0(E,I,s.onFormChange);O!==E&&(E=O,q(O,{...I,data:O}))},M=(I,q,O)=>{var W;const V=t&&((W=ve(t,I))==null?void 0:W[q]);return!V||typeof V.$state!="string"?!1:(j({address:V.$state,nodeAddress:I,previousValue:ve(E,V.$state),value:O,data:E}),!0)};return{...A,onFormChange:j,onNodeCreateRequest:I=>{var V,W;const q=(V=I.sourceProperty)!=null&&V.startsWith("config:")?I.sourceProperty.slice(7):void 0,O=q!==void 0&&(v==null?void 0:v.slots.get(Rt(I.sourceNodeId,q)));return O?(O.present||j({data:E,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Pt(O.type),previousValue:void 0}),!0):((W=A.onNodeCreateRequest)==null?void 0:W.call(A,I))??!1},onNodeDelete:(I,q)=>{var he,me;if(!(v!=null&&v.nodes.some(J=>J.data.id===I)))return(he=A.onNodeDelete)==null?void 0:he.call(A,I,q);const O=v&&[...v.slots.values()].find(J=>J.nodeId===I);if(!O)return(me=A.onNodeDelete)==null?void 0:me.call(A,I,q);const V=O.address.split("."),W=V.pop(),re=V.join("."),Y=ve(E,re);j(Array.isArray(Y)?{data:E,nodeAddress:re,address:re,previousValue:Y,value:Y.filter((J,N)=>String(N)!==W)}:{data:E,nodeAddress:re,address:O.address,previousValue:ve(E,O.address),value:void 0})},onEdgeCreate:(I,q,O)=>{var re,Y;const V=((re=O==null?void 0:O.targetProperty)==null?void 0:re.startsWith("config:"))&&(v==null?void 0:v.slots.get(Rt(q,O.targetProperty.slice(7)))),W=v==null?void 0:v.containers.get(I);if(V&&W&&(O==null?void 0:O.sourceProperty)==="output:resource"){const he=a0(E,W,V);he!==void 0&&j({data:E,nodeAddress:V.address.split(".").slice(0,-1).join("."),address:V.address,previousValue:ve(E,V.address),value:he});return}V||v!=null&&v.nodes.some(he=>he.data.id===I||he.data.id===q)||(Y=A.onEdgeCreate)==null||Y.call(A,I,q,O)},onEdgeDelete:(I,q)=>{var me;const O=v==null?void 0:v.edges.find(J=>J.data.id===I);if(!O)return(me=A.onEdgeDelete)==null?void 0:me.call(A,I,q);const V=v.slots.get(Rt(O.data.target,O.data.targetProperty.slice(7))),W=V.address.split("."),re=W.pop(),Y=W.join("."),he=ve(E,Y);j(Array.isArray(he)?{data:E,nodeAddress:Y,address:Y,previousValue:he,value:he.filter((J,N)=>String(N)!==re)}:{data:E,nodeAddress:Y,address:V.address,previousValue:ve(E,V.address),value:void 0})},onNodeContentChange:(I,q)=>{var O,V;M(I,"$content",q)?(O=s.onNodeContentChange)==null||O.call(s,I,q):(V=A.onNodeContentChange)==null||V.call(A,I,q)},onNodeLabelChange:(I,q)=>{var O,V;M(I,"$label",q)?(O=s.onNodeLabelChange)==null||O.call(s,I,q):(V=A.onNodeLabelChange)==null||V.call(A,I,q)}}},[A,r,t,s,v,i.readOnly,i.editable]);return h.jsx(Rr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:_,references:r==null?void 0:r.references,structured:v,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!s.onJsonChange,schema:C,setSchema:E=>{var j;f(E),(j=s.onFormSchemaChange)==null||j.call(s,E)},callbacks:k},children:h.jsx(xy,{config:v?{...i,formSchema:C}:i,callbacks:k,nodes:R,edges:T,children:h.jsxs(B.Box,{className:a,"data-flow-diagram":"",style:u,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[h.jsx(zb,{nodes:R,edges:T}),c&&h.jsx(wm,{}),l]})})})}function W_(e){return Eu(JSON.parse(e))}function Eu(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const t=new Set,r=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||t.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");t.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);r(i)}t.delete(n)}};return r(e),structuredClone(e)}function G_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=Eu(t);return e.onJsonChange(r,{type:"documentReplace",address:"root"}),r},replaceState(t){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const r=Eu(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function U_(e,t){const r=(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)=>r(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.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=r(s,o[i]);return a===void 0?[]:[[i,a]]}))};return r(e,t)??{}}function ln(e){let t="",r=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(r||!t.trim()))try{const u=e.parse(e.repair(t)),c=JSON.stringify(u);if(c===n)return;e.preview(u),n=c}catch{}},a=u=>{if(!r){if(new TextEncoder().encode(u).byteLength>(e.maxBytes??1024*1024))throw r=!0,i(),new Error("JSON stream exceeds the size limit.");t=u,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(u){a(t+u)},flush:s,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,i();const u=e.parse(t);return e.commit(u),u},cancel(){r=!0,i(),t=""}}}function H_(e){const{source:t}=e,r=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(r)||r<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(t).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(t);let o=ln(e),i=0,s=!1,a=!1,u;const c=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:i,total:t.length,playing:s}),d=()=>{clearTimeout(u),u=void 0},f=(g=!1)=>{o.snapshot(t.slice(0,i)),i===t.length?(s=!1,d(),o.finish()):g&&o.flush()},p=g=>{s=!1,d(),o.cancel(),l(),e.onError(g)},y=()=>{if(u=void 0,!(!s||a)){i=Math.min(t.length,i+c);try{f()}catch(g){p(g);return}l(),s&&(u=setTimeout(y,r))}};return{play(){a||s||(i===t.length&&(o.cancel(),o=ln(e),i=0),s=!0,l(),u=setTimeout(y,r))},pause(){a||(s=!1,d(),o.flush(),l())},seek(g){if(!a){if(!Number.isFinite(g))throw new Error("Playback position must be finite.");d(),i=Math.max(0,Math.min(t.length,Math.round(g))),o.cancel(),o=ln(e);try{f(!0)}catch(b){p(b);return}l(),s&&(u=setTimeout(y,r))}},dispose(){a=!0,s=!1,d(),o.cancel()}}}function K_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=S.useContext(Rr),{colorText:i,background:s}=He();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const a=o&&Qt(o,e,n);if(!r||!a)return null;const u=ve(r,a.address);return!u||typeof u!="object"?null:h.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:fe(i),background:fe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(l=>{const d=a.fields[l]??{};if(!wn(d.$visibleWhen,r))return null;const f=u[l],p=f==null?"":typeof f=="object"?JSON.stringify(f):String(f);return h.jsxs("div",{"data-flow-property":l,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:[h.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),h.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=wm;exports.CompactPropertyLayoutToggle=Wy;exports.ConnectionsOnlyToggle=f0;exports.DEFAULT_PALETTE=Lu;exports.DiagramAppearanceControls=Uy;exports.DynamicIcon=qr;exports.EdgeTools=dm;exports.EditableLabel=Yt;exports.ErrorToast=bm;exports.FlowDiagram=z_;exports.FlowDiagramProvider=xy;exports.FlowPort=Mb;exports.FlowView=zb;exports.FormDocumentContext=Rr;exports.NODE_TYPE_VIEWS=zt;exports.NodeBorderRadiusControl=fm;exports.NodeConfigSummary=K_;exports.NodeForm=am;exports.NodeFormPopover=qb;exports.NodeIconPicker=$u;exports.NodeTools=hm;exports.NodeView=zn;exports.SvgExportButton=ym;exports.Swatches=Zt;exports.TEXT_PALETTE=um;exports.ToolbarCloseButton=gt;exports.ToolbarCommitInput=et;exports.ToolbarDivider=Mt;exports.ToolbarIconButton=be;exports.ToolbarRangeInput=Gy;exports.ToolbarScrollContainer=mm;exports.ToolbarSelect=Ir;exports.ToolbarTooltip=Ee;exports.TooltipIconButton=Su;exports.WorkflowControls=vm;exports.addChild=Tu;exports.addConnection=Ou;exports.addTargetEdge=em;exports.addressToPath=Mr;exports.applyCollapsed=Xx;exports.applyFormChange=Cn;exports.applyStateEdits=Qx;exports.bindSqueedCallbacks=Sm;exports.compileSqueed=xu;exports.connectionIssue=qu;exports.contentObjTheme=jr;exports.createFlowDiagram=Qr;exports.createFlowDocumentActions=G_;exports.createFormNode=_m;exports.createJsonPlayback=H_;exports.createJsonStream=ln;exports.downloadSvg=gm;exports.exportSvg=pm;exports.formValueError=kr;exports.getChakraColorHex=fe;exports.getColorVariant=wy;exports.getDarkerHexColor=dn;exports.getInteractionSurface=zr;exports.getNode=ve;exports.parseFlowDocument=W_;exports.parseJsonContract=Iu;exports.parseTypeScriptContract=tm;exports.parseTypeScriptForm=Mu;exports.projectJsonPlaybackPreview=U_;exports.readFormSchema=Nu;exports.readWorkflowContract=nm;exports.removeEdge=rm;exports.removeNode=Qy;exports.resolveEdgeOwner=Gt;exports.resolveStateView=om;exports.setCollapsed=Yy;exports.setEdgeProp=Br;exports.setEdgeStyle=Xy;exports.setNodeProp=ur;exports.updateNode=mr;exports.useCustomColors=He;exports.useEdgeProximity=yy;exports.useFlowData=Ur;exports.useFlowDiagramContext=Ie;exports.useNodeViewActions=Vn;exports.useStopPropagation=ol;exports.useThemeContentColors=Xt;
189
+ `;function qb({nodeAddress:e,active:t,label:r,open:n=!1,onClose:o,children:i,filter:s,height:a}){const{background:u,border:c,colorText:l}=He(),d=S.useRef(null),f=S.useId(),{data:p,schema:y,bindings:g}=S.useContext(Rr),b=i!==void 0||!!(p&&y&&(g?Qt(g,e,y):yt(p,e,y)));S.useEffect(()=>{var m,w,v,C,_;!t||!b||!n?(m=d.current)==null||m.close():(w=d.current)!=null&&w.open||((v=d.current)==null||v.showModal(),(_=(C=d.current)==null?void 0:C.querySelector("[data-form-filter] input"))==null||_.focus())},[t,b,n]);const x=fe(u);return b?h.jsx(h.Fragment,{children:typeof document<"u"&&Dt.createPortal(h.jsx(C_,{ref:d,id:f,$surface:x,$border:fe(c),"aria-label":`Configure ${r}`,onClose:o,onPointerDown:m=>m.stopPropagation(),onWheel:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),onClick:m=>{var w;m.stopPropagation(),m.target===m.currentTarget&&((w=d.current)==null||w.close())},style:{margin:"auto",padding:20,width:380,boxSizing:"border-box",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:fe(l),fontSize:16,textTransform:"none"},children:n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[h.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),h.jsx("form",{method:"dialog",style:{margin:0},onSubmit:m=>m.stopPropagation(),children:h.jsx(gt,{type:"submit","aria-label":"Close node configuration"})})]}),s&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),h.jsx(__,{"data-form-scroll":"",style:a?{flex:1}:void 0,children:i??h.jsx(am,{nodeAddress:e})})]})}),document.body)}):null}const Eu=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:s,border:a,colorText:u}=He();return h.jsx(Ee,{label:t,children:h.jsx(B.Flex,{children:h.jsx(B.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})})},S_=({data:e,children:t,isInverted:r,isParent:n})=>{var N,L,G,D,ne,ue;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:s,setSelectedEdgeId:a,isMultiSelectMode:u,isPerformanceMode:c,engineRef:l,callbacks:d,config:f,themeColor:p,direction:y}=Ie(),{background:g,border:b,colorText:x}=He(),m=S.useRef(null),w=S.useRef(null),[v,C]=S.useState(!1),[_,R]=S.useState(!1),[T,A]=S.useState(!1),k=e==null?void 0:e.id,E=sm(k),j=o.includes(k),M=f.nodeOverlayActions,I=f.renderNodeOverlay,q=(()=>{var X;try{const U=(X=l.current)==null?void 0:X.zoom();return U!==void 0&&U<.08}catch{return!1}})(),O=S.useCallback(X=>{var K,te,ce,de;if(_||f.readOnly)return;const U={shiftKey:X.shiftKey,ctrlKey:X.ctrlKey,metaKey:X.metaKey,altKey:X.altKey};if(s&&(a(null),(K=d.onEdgeDeselect)==null||K.call(d)),u){const Ae=o.includes(k),ge=Ae?o.filter(Ke=>Ke!==k):[...o,k];i(ge),Ae?(te=d.onNodeDeselect)==null||te.call(d):(ce=d.onNodeSelect)==null||ce.call(d,k,e,U)}else i([k]),(de=d.onNodeSelect)==null||de.call(d,k,e,U)},[k,e,o,s,u,_,i,a,d,f]),V=S.useCallback(()=>{var X;_||f.readOnly||(X=d.onNodeDoubleClick)==null||X.call(d,k,e)},[k,e,_,d,f]),W=S.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>C(!0),100)},[]),re=S.useCallback(()=>{w.current&&clearTimeout(w.current),C(!1)},[]),Y=!!((N=e==null?void 0:e.config)!=null&&N.form),he={tabIndex:Y?0:void 0,"aria-haspopup":Y?"dialog":void 0,"aria-expanded":Y?T:void 0,onDoubleClickCapture:X=>{var U;!Y||f.readOnly||_||!X.currentTarget.contains(X.target)||X.target instanceof Element&&X.target.closest("button, input, textarea, select, a, [contenteditable=true]")||(X.preventDefault(),X.stopPropagation(),i([k]),A(!0),(U=d.onNodeDoubleClick)==null||U.call(d,k,e))},onKeyDown:X=>{!Y||f.readOnly||X.target!==X.currentTarget||X.key!=="Enter"||(X.preventDefault(),X.stopPropagation(),i([k]),A(!0))}},me=Y&&h.jsx(qb,{nodeAddress:k,active:j,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var X;A(!1),j&&((X=m.current)==null||X.focus({preventScroll:!0}))}}),J=Array.isArray((L=e==null?void 0:e.config)==null?void 0:L.ports)?e.config.ports.map(X=>h.jsx(Mb,{...X},`${X.id}:${X.role}`)):null;return n?h.jsxs(B.Box,{ref:m,...he,onClick:O,onDoubleClick:V,onMouseEnter:W,onMouseLeave:re,cursor:"pointer",position:"relative",children:[me,!c&&(I||M&&M.length>0)&&v&&!q&&h.jsxs(h.Fragment,{children:[h.jsx(B.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:k,nodeData:e,isRoot:k==="root",isParent:!0,isHovered:v,setIsHovered:C})}):h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(B.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(B.Box,{display:"contents",children:[U>0&&h.jsx(B.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(Eu,{icon:X.icon,label:X.label,color:x,bgColor:g,borderColor:b,textColor:x,boxSize:5,onClick:K=>{var te;K.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,X.id,k,e)}})]},X.id))})})]}),t({id:k,data:e,isActive:j,isLowZoom:q,isEditing:_,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)}),E&&!((G=e==null?void 0:e.config)!=null&&G.parentContainer)&&((D=e==null?void 0:e.config)==null?void 0:D.collapsed)!==void 0&&(()=>{var K;const X=y==="TB"||y==="BT",U=r||y==="RL";return h.jsx(B.IconButton,{position:"absolute",...X?{[y==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:"-75px",left:U?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:te=>{var ce;te.stopPropagation(),(ce=d.onNodeCollapse)==null||ce.call(d,k,!e.config.collapsed)},bgColor:fe(((K=e==null?void 0:e.viewProps)==null?void 0:K.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:fe("gray.800")})})})()]}):h.jsxs(B.Box,{ref:m,...he,onClick:O,onDoubleClick:V,onMouseEnter:W,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[me,J,!c&&(I||M&&M.length>0)&&v&&!q&&h.jsxs(h.Fragment,{children:[h.jsx(B.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:k,nodeData:e,isRoot:k==="root",isParent:!!n,isHovered:v,setIsHovered:C})}):h.jsx(B.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(B.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(B.Box,{display:"contents",children:[U>0&&h.jsx(B.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(Eu,{icon:X.icon,label:X.label,color:x,bgColor:g,borderColor:b,textColor:x,boxSize:5,onClick:K=>{var te;K.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,X.id,k,e)}})]},X.id))})})]}),h.jsxs(B.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[E&&!((ne=e==null?void 0:e.config)!=null&&ne.parentContainer)&&((ue=e==null?void 0:e.config)==null?void 0:ue.collapsed)!==void 0&&!n&&(()=>{var te,ce,de;const X=y==="TB"||y==="BT",U=r||y==="RL",K=(te=e==null?void 0:e.config)!=null&&te.labelBelow?((((ce=e==null?void 0:e.viewProps)==null?void 0:ce.fontSize)||1)*100+100)/2:void 0;return h.jsx(B.IconButton,{position:"absolute",...X?{[y==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:K===void 0?"-75px":`calc(50% - ${K+75}px)`,left:U?K===void 0?"-75px":`calc(50% - ${K+75}px)`:void 0,alignSelf:K===void 0?"center":void 0,top:K===void 0?void 0:`${K}px`,transform:K===void 0?void 0:"translateY(-50%)",zIndex:K===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:Ae=>{var ge;Ae.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,k,!e.config.collapsed)},bgColor:fe(((de=e==null?void 0:e.viewProps)==null?void 0:de.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:fe("gray.800")})})})(),t({id:k,data:e,isActive:j,isLowZoom:q,isEditing:_,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)})]})]})},Vn=S.memo(S_);function il(e=!0){const t=S.useRef(null);return S.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Yt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:u})=>{const{callbacks:c,config:l,readOnly:d}=Ie(),f=l.editable&&!d,[p,y]=S.useState(t),[g,b]=S.useState(),x=S.useRef(null),m=S.useRef(!1),w=il(s);S.useEffect(()=>{s&&(m.current=!1,x.current&&(x.current.focus(),x.current.select()))},[s]);const v=()=>{var _;if(m.current)return;m.current=!0;const C=p.trim();C&&C!==t&&((_=c.onNodeLabelChange)==null||_.call(c,e,C)),u()};return!f||!s?h.jsx(B.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:f?C=>{C.stopPropagation(),b({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(t),a()}:void 0,cursor:f?"text":void 0,children:t}):h.jsxs("div",{ref:w,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[h.jsx(B.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),h.jsx(B.Input,{ref:x,value:p,onChange:C=>y(C.target.value),onBlur:v,onKeyDown:C=>{C.key==="Enter"&&v(),C.key==="Escape"&&(m.current=!0,u())},color:r,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"})]})},E_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var g,b,x,m,w,v,C,_;const{themeColor:s}=Ie(),{colorText:a}=He(),u=((g=t==null?void 0:t.viewProps)==null?void 0:g.bgColor)==="transparent",c=((b=t==null?void 0:t.viewProps)==null?void 0:b.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Xt(((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||s),p=fe(((m=t==null?void 0:t.viewProps)==null?void 0:m.textColor)||(u||c?a:f)),y=((w=t==null?void 0:t.viewProps)==null?void 0:w.borderColor)||(c?!u&&((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)||s:d);return h.jsx(B.Box,{"data-flow-node-surface":"",borderRadius:(C=t==null?void 0:t.viewProps)==null?void 0:C.borderRadius,bgColor:c?"transparent":l,...pn(t==null?void 0:t.viewProps,y,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:h.jsxs(B.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((_=t==null?void 0:t.config)==null?void 0:_.icon)&&h.jsx(B.Box,{flexShrink:0,children:h.jsx(qr,{name:t.config.icon,size:80,color:p})}),h.jsx(Yt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Wn(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Ie();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>t(o,"properties"),restoreNodeView:o=>t(o,"default"),toggleNodeView:o=>t(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:t}}const j_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var w,v,C,_,R,T,A,k,E,j,M,I,q,O,V;const{themeColor:s}=Ie(),{colorText:a}=He(),u=((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)==="transparent",c=((v=r==null?void 0:r.viewProps)==null?void 0:v.outline)===!0,l=!u&&((C=r==null?void 0:r.viewProps)==null?void 0:C.bgColor)||s,{borderColor:d,highlightColor:f,textColor:p}=Xt(l),y=fe(((_=r==null?void 0:r.viewProps)==null?void 0:_.textColor)||(u||c?a:p)),g=u&&!c&&!((R=r==null?void 0:r.viewProps)!=null&&R.borderColor)?"transparent":fe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),b=u||c?"transparent":l!=null&&l.startsWith("#")?l:fe(f),x=(A=r==null?void 0:r.config)==null?void 0:A.icon,m=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((k=r==null?void 0:r.config)!=null&&k.labelBelow){const W=(((E=r==null?void 0:r.viewProps)==null?void 0:E.fontSize)||1)*100;return h.jsxs(B.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(W+200,360)}px`,position:"relative",children:[h.jsx(B.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${W+100}px`,height:`${W+100}px`,flexShrink:0,borderRadius:(j=r==null?void 0:r.viewProps)==null?void 0:j.borderRadius,backgroundColor:b,...pn(r==null?void 0:r.viewProps,g,t,2),children:!!x&&h.jsx(qr,{name:x,size:W,color:y})}),h.jsxs(B.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[h.jsx(Yt,{nodeId:e,label:m,color:fe(((M=r==null?void 0:r.viewProps)==null?void 0:M.textColor)||a),isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((I=r.config)==null?void 0:I.subtitle)=="string"&&r.config.subtitle!==""&&h.jsx(B.Text,{"data-flow-node-subtitle":"",color:fe(((q=r==null?void 0:r.viewProps)==null?void 0:q.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:r.config.subtitle,children:r.config.subtitle})]})]})}return h.jsxs(B.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(O=r==null?void 0:r.viewProps)==null?void 0:O.borderRadius,bgColor:b,style:{backgroundColor:b},textTransform:"capitalize",...pn(r==null?void 0:r.viewProps,g,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!x&&h.jsx(B.Flex,{align:"center",py:14,mr:m?8:0,flexShrink:0,children:h.jsx(qr,{name:x,size:(((V=r==null?void 0:r.viewProps)==null?void 0:V.fontSize)||1)*100,color:y},y)}),(m||!x)&&h.jsx(B.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Yt,{nodeId:e,label:m,color:y,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Nb({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=j_,...o}){const{colorMode:i,callbacks:s}=Ie();return h.jsx(Vn,{...o,children:a=>h.jsxs(B.Box,{position:"relative",children:[h.jsx(n,{...a}),e&&a.isActive&&h.jsx(B.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:h.jsx(Ee,{label:t,children:h.jsx(be,{"aria-label":t,icon:h.jsx(B.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:r,onClick:u=>{var c;u.stopPropagation(),e(),(c=s.onNodeViewToggle)==null||c.call(s,o.data.id)}})})})]})})}const fy=1.55;function k_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Ie(),s=!!o.editable&&!i,[a,u]=S.useState(!1),[c,l]=S.useState(t),[d,f]=S.useState(),p=S.useRef(null),y=S.useRef(!1),g=il(a);S.useLayoutEffect(()=>{const m=p.current;!a||!m||(m.style.height="auto",m.style.height=`${Math.max((d==null?void 0:d.height)??0,m.scrollHeight)}px`)},[c,a,d]),S.useEffect(()=>{var m;s?a&&(y.current=!1,(m=p.current)==null||m.focus()):u(!1)},[a,s]);const b=m=>{s&&(f({width:m.offsetWidth,height:m.offsetHeight}),l(t),u(!0))},x=()=>{var m;y.current||!s||(y.current=!0,c!==t&&((m=n.onNodeContentChange)==null||m.call(n,e,c)),u(!1))};return!a||!s?h.jsx(B.Box,{"data-flow-content":"",color:r,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:fy,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:s?"text":void 0,tabIndex:s?0:void 0,onDoubleClick:m=>{m.stopPropagation(),b(m.currentTarget)},onKeyDown:m=>{s&&m.key==="Enter"&&m.target===m.currentTarget&&(m.preventDefault(),m.stopPropagation(),b(m.currentTarget))},children:h.jsx(av.default,{options:{forceBlock:!0,wrapper:S.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t})}):h.jsx("div",{ref:g,style:{width:d==null?void 0:d.width,minHeight:d==null?void 0:d.height,maxWidth:"100%"},children:h.jsx(B.Textarea,{ref:p,"aria-label":"Node content",value:c,onChange:m=>l(m.target.value),onBlur:x,onKeyDown:m=>{m.stopPropagation(),!m.nativeEvent.isComposing&&(m.key==="Enter"&&(m.ctrlKey||m.metaKey)&&(m.preventDefault(),x()),m.key==="Escape"&&(y.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:fy,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const R_=(e,t,r)=>{var f,p,y,g;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Xt(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,u=r==="dark"?"gray.200":"gray.900",c=a?"transparent":n!=null&&n.startsWith("#")?fe(n):fe(i.bgColor),l=fe(((y=e==null?void 0:e.viewProps)==null?void 0:y.textColor)||(a?u:i.textColor)),d=fe(((g=e==null?void 0:e.viewProps)==null?void 0:g.borderColor)||(s?n==="transparent"?t:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?u:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:c,hextextColor:l,hexborderColor:d}},P_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,A_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,$b=600,T_=3,O_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function I_({headerTitle:e,hasContent:t,data:r,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isEditing:u,onEditStart:c,onEditEnd:l,props:d,objVisible:f,setObjVisible:p,onShowNativeIcon:y}){var m,w;const{callbacks:g}=Ie(),b=d.onShowIcon??y,x=b?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((m=r.config)==null?void 0:m.form)||a&&y)&&h.jsxs(B.Flex,{justify:"flex-start",direction:"row",p:Object.entries(r.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&&!t?"transparent":o.hexborderColor,children:[!!n&&h.jsx(B.Flex,{mr:6,alignItems:"center",flexShrink:0,children:h.jsx(qr,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),h.jsx(Yt,{nodeId:s,label:A_(e),color:((w=r==null?void 0:r.viewProps)==null?void 0:w.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),a&&(t||b)&&h.jsx(B.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(Ee,{label:x,children:h.jsx(be,{"aria-label":x,icon:h.jsx(B.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:v=>{var C;v.stopPropagation(),b?b():p(!f),(C=g.onNodeViewToggle)==null||C.call(g,s)}})})})]})})}function M_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:u}){const{edgeById:c}=Ur(),l=new Set;for(const{data:d}of c.values())d.source===e.id&&d.sourceProperty!==void 0&&l.add(`source:${d.sourceProperty}`),d.target===e.id&&d.targetProperty!==void 0&&l.add(`target:${d.targetProperty}`);return h.jsx(B.Box,{children:Object.entries(e.description||{}).map(([d,f],p)=>{var M,I,q;const y=t&&Object.keys(t).find(O=>O.slice(O.indexOf(":")+1)===d),g=r&&((M=n==null?void 0:n.type.ports)==null?void 0:M[d]),b=y??(g?`${g.kind}:${d}`:d),x=o.find(O=>O.id===b),m=y?"source":x==null?void 0:x.role,w=l.has(`source:${b}`),v=l.has(`target:${b}`),C=i.some(O=>O.id===d),_=f===""&&(C||(m?l.has(`${m}:${b}`):w||v)),R=m??(w!==v?w?"source":"target":void 0),T=(x==null?void 0:x.side)??(R?R==="source"!=(a==="RL")?"right":"left":void 0),A=_&&T==="right"?"right":"left",k=(x==null?void 0:x.label)??(g==null?void 0:g.label)??(C?d.replace(/^(template|input|output|config|error):/,""):d),E=jr(s.wordBeforeDot)[typeof f],j=jr(s.wordBeforeDot).property;return h.jsxs(B.Box,{"data-flow-property":y&&(a==="TB"||a==="BT")?void 0:b,"data-flow-port-role":m,"data-flow-inspection-row":r?"":void 0,children:[h.jsxs(B.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[h.jsx(B.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:_?"100%":`${u}px`,minWidth:`${u}px`,borderRightColor:s.hexborderColor,borderRightWidth:_?0:1,children:h.jsx(B.Text,{py:5,px:10,w:"100%",textAlign:A,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((I=e==null?void 0:e.viewProps)==null?void 0:I.textColor)||(s.isTransparent?s.hextextColor:j),children:k})}),!_&&h.jsx(B.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:$b,maxH:200,children:h.jsx(B.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((q=e==null?void 0:e.viewProps)==null?void 0:q.textColor)||(s.isTransparent?s.hextextColor:E),fontWeight:400,children:P_(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(B.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},d)})})}function q_(e){var w,v,C;const{themeColor:t,colorMode:r,direction:n}=Ie(),o=Wn(),i=o.getNodeViewMode(e.data.id)==="properties",s=_=>o.setNodeViewMode(e.data.id,_?"properties":"default"),a=!!e.onShowIcon||i||typeof((w=e.data.config)==null?void 0:w.content)!="string",{bindings:u,data:c,schema:l}=S.useContext(Rr),d=(v=u==null?void 0:u[e.data.id])==null?void 0:v.portResources,f=u?Qt(u,e.data.id,l):c&&l?yt(c,e.data.id,l):void 0,p=f&&ve(c,"address"in f?f.address:e.data.id),y=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(_=>{var R;return Object.prototype.hasOwnProperty.call(p,_)&&Cn((R=f.fields[_])==null?void 0:R.$visibleWhen,c)}).map(_=>[_,p[_]!==null&&typeof p[_]=="object"?JSON.stringify(p[_],null,2):p[_]===null?"null":p[_]])):{},g=d?Object.fromEntries(Object.entries(d).map(([_,R])=>{var T;return[_.slice(_.indexOf(":")+1),((T=ve(c,R))==null?void 0:T.name)??R.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:y,b=a&&!d?((C=e.data.config)==null?void 0:C.ports)??[]:[],x=b.filter(_=>!Object.prototype.hasOwnProperty.call(g,_.id)&&!Object.entries((f==null?void 0:f.type.ports)??{}).some(([R,T])=>`${T.kind}:${R}`===_.id&&Object.prototype.hasOwnProperty.call(g,R))),m={...g,...Object.fromEntries(x.map(_=>[_.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:d,form:f,description:m,inspectionPorts:b,extraPorts:x}}const al=e=>{var b,x,m;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:u,description:c,inspectionPorts:l,extraPorts:d}=q_(e),f=Wn(),p=f.getNodeViewMode(e.data.id)==="icon-label",g=!e.onShowIcon&&!((b=e.data.config)!=null&&b.parentContainer)&&typeof((x=e.data.config)==null?void 0:x.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Nb,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((m=e.data.config)==null?void 0:m.icon)||"PiBracketsCurly"}},onExpand:()=>f.restoreNodeView(e.data.id)}):h.jsx(Vn,{...e,data:{...e.data,description:c},children:({id:w,data:v,isActive:C,isEditing:_,onEditStart:R,onEditEnd:T})=>{var W,re,Y,he,me,J;const A=R_(v,t,r),k=v.label??v.headerTitle,E=Object.entries(v.description||{}).length>0,j=O_(v.description),M=(re=(W=e.data)==null?void 0:W.config)==null?void 0:re.icon,I=(he=(Y=e.data)==null?void 0:Y.config)==null?void 0:he.content,q=typeof I=="string"&&!e.onShowIcon,O=((me=v==null?void 0:v.viewProps)==null?void 0:me.borderRadius)??"53px",V=pn(v==null?void 0:v.viewProps,A.hexborderColor,C,T_);return h.jsx(B.Flex,{justifyContent:"space-between",...v==null?void 0:v.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:O,overflow:"hidden",alignItems:"center",style:{backgroundColor:A.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:q||e.onShowIcon?j+$b+V.borderWidth*2:void 0,...V,children:h.jsxs(B.Flex,{width:"100%",direction:"column",borderRadius:O,borderColor:A.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(I_,{headerTitle:k,hasContent:q,data:v,icon:M,colors:A,hasConfig:E,id:w,isActive:C,isEditing:_,onEditStart:R,onEditEnd:T,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:g}),q&&!o?h.jsx(B.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:A.highlightColor,p:12,fontSize:"5xl",lineHeight:"normal",children:h.jsx(k_,{nodeId:w,content:I,color:((J=v==null?void 0:v.viewProps)==null?void 0:J.textColor)||A.hextextColor})}):h.jsx(M_,{data:v,resourcePorts:a,inspecting:s,form:u,inspectionPorts:l,extraPorts:d,colors:A,direction:n,uniformKeyWidth:j})]})})}})};al.displayName="NodeJsonObjectView";const Lb=e=>{var c,l,d,f,p,y,g;const t=Wn(),r=t.getNodeViewMode(e.data.id)==="properties",n=b=>t.setNodeViewMode(e.data.id,b?"properties":"default"),{callbacks:o,readOnly:i}=Ie(),s=(l=(c=e.data)==null?void 0:c.config)==null?void 0:l.parentContainer,a=s?"Show parent":"Show properties",u=s||((f=(d=e.data)==null?void 0:d.config)==null?void 0:f.form)||((g=(y=(p=e.data)==null?void 0:p.config)==null?void 0:y.ports)==null?void 0:g.length);return!s&&u&&r?h.jsx(al,{...e,onShowIcon:()=>n(!1)}):h.jsx(Nb,{...e,toggleLabel:a,toggleDisabled:s&&i,onExpand:u?()=>{var b;s?(b=o.onNodeCollapse)==null||b.call(o,e.data.id,!1):n(!0)}:void 0})},Fb=e=>h.jsx(Lb,{...e,renderCompact:E_}),Bb=e=>h.jsx(Lb,{...e}),Db=e=>h.jsx(Vn,{...e,children:()=>null});Fb.displayName="text";Bb.displayName="arrayView";Db.displayName="ParentContainerView";const N_={objectView:al,arrayView:Bb,text:Fb,parentContainer:Db},$_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Ie(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?h.jsx(B.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):h.jsxs(B.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[h.jsx(B.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="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}}),h.jsx(B.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},L_=.4,Jr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},F_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:o,backgroundVariant:i,setBackgroundSelected:s,edgeColor:a,direction:u,nodeAlignment:c,edgeMode:l,compactPropertyLayout:d,workflowContract:f,parentNodeStyle:p,engineRef:y,callbacks:g,config:b,selectedNodeIds:x,setSelectedNodeIds:m,selectedEdgeId:w,setSelectedEdgeId:v,setIsPerformanceMode:C,isZoomMode:_,setIsZoomMode:R,isMultiSelectMode:T,setIsMultiSelectMode:A,isDragMode:k,setIsDragMode:E,isEdgeHandlesEnabled:j,setIsEdgeHandlesEnabled:M,isArrayNodeMode:I}=Ie(),q=S.useRef(null),[O,V]=S.useState(null),W=e.length>200;S.useEffect(()=>{C(W)},[W,C]);const{edgeSep:re,rankSep:Y,spacingFactor:he}=S.useMemo(()=>{const Q=w0(e.length),z=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Q.edgeSep*z,rankSep:Q.rankSep*z,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:me}=Xt(r),{canvas:J,borderSecondary:N,colorText:L}=He(),G=i==="transparent"?"transparent":b.backgroundColor||J,D=S.useCallback(Q=>{if(Q!=null&&Q.includes("gray"))return"whitesmoke";if(!Q)return fe(r);switch(Q){case"dark":return fe(G);case"light":return fe(N);default:return fe(Q)}},[r,G,N]),ne=b.colorMode==="dark",ue=S.useMemo(()=>D(ne?me:"light"),[ne,me,D]),X=a?D(a):ue,U=S.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),K=u==="C"?"LR":u,te=S.useCallback(Q=>{const z={...p,...Q};return{...z,bgColor:z.bgColor||r,bgOpacity:z.outline?0:z.bgOpacity??L_}},[p,r]),ce=S.useMemo(()=>{var z;const Q=new Map;for(const ee of e)(z=ee.data)!=null&&z.id&&Q.set(ee.data.id,ee);return Q},[e]),de=S.useMemo(()=>{var z;const Q=new Map;for(const ee of t)(z=ee.data)!=null&&z.id&&Q.set(ee.data.id,ee);return Q},[t]),Ae=S.useCallback(Q=>{var _e;const z=(_e=ce.get(Q))==null?void 0:_e.data,ee=te(z==null?void 0:z.viewProps),Ce=fe(ee.bgColor);return{animated:!!(z!=null&&z.isNodeAnimated)&&!W,animationVariant:z==null?void 0:z.nodeAnimationVariant,animationColor:fe(ee.borderColor||r),bgColor:ee.outline?"transparent":Ce,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?fe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?fe(r):Ce,borderWidth:Jt(ee.borderWidth,Jr.borderWidth),borderStyle:ee.borderStyle??Jr.borderStyle,borderRadius:ee.borderRadius??Jr.borderRadius,textColor:ee.textColor?fe(ee.textColor):ee.outline||ee.bgColor==="transparent"?fe(L):Ce,fontSize:ee.fontSize??Jr.fontSize,labelPosition:ee.labelPosition??Jr.labelPosition,labelMargin:Jr.labelMargin,labelBg:dl(D("dark"),Ce,ee.bgOpacity)??D("dark"),padding:ee.padding??Jr.padding}},[te,ce,L,r,W,D]),ge=S.useMemo(()=>{var ee,Ce;const Q=new Map;for(const _e of t){const Se=(ee=_e.data)==null?void 0:ee.source,Ge=(Ce=_e.data)==null?void 0:Ce.target;if(!Se||!Ge||Se===Ge)continue;const ke=Se<Ge?`${Se}|${Ge}`:`${Ge}|${Se}`,qe=Q.get(ke);qe?qe.push({id:_e.data.id,source:Se}):Q.set(ke,[{id:_e.data.id,source:Se}])}const z=new Map;for(const[_e,Se]of Q){if(Se.length<2)continue;const Ge=_e.split("|")[0],ke=Math.min(20,70/Se.length);Se.forEach(({id:qe,source:ze},gr)=>{const cr=50+(gr-(Se.length-1)/2)*ke;z.set(qe,(ze===Ge?cr:100-cr)/100)})}return z},[t]),Ke=S.useMemo(()=>{const Q=D("dark");return t.filter(z=>{var ee;return((ee=z.data)==null?void 0:ee.id)&&z.data.source&&z.data.target}).map(({data:z})=>{var Se,Ge,ke,qe,ze,gr;let ee=Q;const Ce=(Ge=(Se=ce.get(z.source))==null?void 0:Se.data)==null?void 0:Ge.parent,_e=(qe=(ke=ce.get(z.target))==null?void 0:ke.data)==null?void 0:qe.parent;if(Ce&&Ce===_e){const cr=te((gr=(ze=ce.get(Ce))==null?void 0:ze.data)==null?void 0:gr.viewProps),Re=dl(Q,fe(cr.bgColor),cr.bgOpacity);Re&&(ee=Re)}return{id:z.id,data:z,type:z.type??b.edgeType??"rounded-orthogonal",source:z.source,target:z.target,sourceProperty:z.sourceProperty,targetProperty:z.targetProperty,label:z.label,validationIssue:(l==="auto"||l==="properties")&&(z.sourceProperty!==void 0||z.targetProperty!==void 0)&&f?Nu(f,z):void 0,color:z.color?fe(z.color):X,labelBg:ee,dashed:!!z.isEdgeDashed,animated:!!z.isEdgeAnimated,inverted:!!z.isInverted,turn:ge.get(z.id)??.5}})},[t,X,ge,b.edgeType,l,f,ce,te,D]),Oe=S.useMemo(()=>{var z;const Q=new Set;for(const ee of e)(z=ee.data)!=null&&z.parent&&Q.add(ee.data.parent);return Q},[e]),Le=S.useMemo(()=>{var z;const Q=new Map;for(const ee of t)(z=ee.data)!=null&&z.source&&!Q.has(ee.data.source)&&Q.set(ee.data.source,ee.data);return Q},[t]),er=S.useMemo(()=>{const Q={...N_,...b.customViews};return e.filter(z=>{var ee;return(ee=z.data)==null?void 0:ee.id}).map(z=>{var Ge,ke,qe,ze;const ee=Oe.has(z.data.id)&&!z.data.parent,Ce=ee?z.data.label??z.data.headerTitle??"Container":void 0,_e=ee?Q.parentContainer:Q[z.data.type]||Q.text,Se=Le.get(z.data.id);return{id:z.data.id,collapsed:(Ge=z.data.config)==null?void 0:Ge.collapsed,parent:z.data.parent,label:Ce,animated:!!z.data.isNodeAnimated,animationVariant:z.data.nodeAnimationVariant,hasCollapseControl:((ke=z.data.config)==null?void 0:ke.collapsed)!==void 0,animationColor:fe(((qe=z.data.viewProps)==null?void 0:qe.borderColor)||r),animationWidth:Jt((ze=z.data.viewProps)==null?void 0:ze.borderWidth,8),element:S.createElement(_e,{...z,isInverted:Se==null?void 0:Se.isInverted,isParent:ee,key:`${z.data.id}-${r}`})}})},[e,Oe,Le,r,b.customViews]),Ve=S.useMemo(()=>W?300:e.length>50?150:e.length>20?100:50,[e.length,W]),$e=S.useRef(b);$e.current=b;const xe=S.useRef(_);xe.current=_;const Me=S.useRef(I);Me.current=I;const Fe=S.useRef(x);Fe.current=x;const nr=S.useRef(w);nr.current=w;const Ze=S.useRef(T);Ze.current=T;const Ye=S.useRef(ce);Ye.current=ce;const fr=S.useRef(de);fr.current=de;const wr=S.useRef(new Map);S.useEffect(()=>{var ee,Ce;const Q=new Map([...de].filter(([,_e])=>ce.has(_e.data.source)&&ce.has(_e.data.target))),z=wr.current;wr.current=Q;for(const[_e,Se]of z)Q.has(_e)||(nr.current===_e&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g)),(Ce=g.onEdgeRemove)==null||Ce.call(g,_e,Se.data))},[de,ce,g,v]),S.useEffect(()=>{const Q=q.current;if(!O||!Q)return;let z=null,ee=null,Ce=0,_e=0,Se=0,Ge=0,ke=0;const qe=ze=>{if($e.current.readOnly)return;ze.preventDefault(),ze.stopPropagation(),xe.current||ze.metaKey||ze.ctrlKey?(Se+=ze.deltaY,Ge=ze.clientX,ke=ze.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const cr=$e.current,Re=O.zoom(),Er=Se;Se=0;let Ar=Re-Er*.05/100;Ar=Math.max(cr.minZoom??.01,Math.min(cr.maxZoom??1.5,Ar));const Lr=Q.getBoundingClientRect();O.zoomAt(Ar,{x:Ge-Lr.left,y:ke-Lr.top})}))):(Ce+=ze.deltaX,_e+=ze.deltaY,z===null&&(z=requestAnimationFrame(()=>{z=null;const cr=O.pan(),Re=O.zoom(),Er=.35,Ar=Ce,Lr=_e;Ce=0,_e=0,O.pan({x:cr.x+-Ar*Er/Re,y:cr.y+-Lr*Er/Re})})))};return Q.addEventListener("wheel",qe,{passive:!1}),()=>{Q.removeEventListener("wheel",qe),z!==null&&cancelAnimationFrame(z),ee!==null&&cancelAnimationFrame(ee)}},[O]),S.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Q=z=>{var Ce,_e,Se,Ge;if($e.current.readOnly)return;const ee=z.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((z.key==="z"||z.key==="Z")&&R(!xe.current),(z.key==="m"||z.key==="M")&&A(!T),(z.key==="d"||z.key==="D")&&E(!k),(z.key==="v"||z.key==="V")&&!z.repeat&&!z.metaKey&&!z.ctrlKey&&!z.altKey&&ee.tagName!=="SELECT"&&M(!j),(z.key==="Delete"||z.key==="Backspace")&&nr.current){z.preventDefault();const ke=nr.current;(_e=g.onEdgeDelete)==null||_e.call(g,ke,((Ce=fr.current.get(ke))==null?void 0:Ce.data)??{id:ke}),v(null);return}if((z.key==="Delete"||z.key==="Backspace")&&Fe.current.length>0){z.preventDefault();const ke=Fe.current.filter(qe=>qe!=="root");if(ke.length===0)return;for(const qe of ke){const ze=(Se=Ye.current.get(qe))==null?void 0:Se.data;(Ge=g.onNodeDelete)==null||Ge.call(g,qe,ze||{})}m([])}}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[T,k,j,M,R,A,E,b.disableKeyboardShortcuts,g,m,v]);const we=S.useCallback(Q=>{var z;y.current=Q,V(Q),(z=g.onInit)==null||z.call(g,Q)},[y,g]),ar=S.useCallback(Q=>{var z;return(z=g.onViewportChange)==null?void 0:z.call(g,Q)},[g]),sr=S.useCallback(Q=>{var ee,Ce,_e;const z=((ee=fr.current.get(Q))==null?void 0:ee.data)??{id:Q};if(nr.current===Q&&Ze.current){v(null),(Ce=g.onEdgeDeselect)==null||Ce.call(g);return}Fe.current.length&&m([]),v(Q),(_e=g.onEdgeSelect)==null||_e.call(g,Q,z)},[g,v,m]),Ct=S.useCallback(()=>{var Q,z,ee;s(!0),(Q=g.onBackgroundClick)==null||Q.call(g),Fe.current.length&&(m([]),(z=g.onNodeDeselect)==null||z.call(g)),nr.current&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g))},[g,m,v,s]),oe=S.useCallback(Q=>{var Ce,_e;const z=Fe.current,ee=Q.filter(Se=>!z.includes(Se));if(ee.length){m([...z,...ee]);for(const Se of ee)(_e=g.onNodeSelect)==null||_e.call(g,Se,((Ce=Ye.current.get(Se))==null?void 0:Ce.data)??{id:Se})}},[g,m]),We=S.useCallback((Q,z)=>{var ee,Ce;m([Q]),(Ce=g.onNodeSelect)==null||Ce.call(g,Q,((ee=Ye.current.get(Q))==null?void 0:ee.data)??{id:Q},z)},[g,m]),Qe=S.useCallback((Q,z,ee)=>{var Ce;return(Ce=g.onEdgeCreate)==null?void 0:Ce.call(g,Q,z,ee)},[g]),Be=S.useCallback((Q,z,ee,Ce=!1)=>{var _e,Se;l==="properties"&&((_e=g.onNodeCreateRequest)==null?void 0:_e.call(g,{sourceNodeId:Q,position:z,sourceProperty:ee,reverse:Ce}))===!0||ee!==void 0||Ce||(Se=g.onNodeCreate)==null||Se.call(g,{type:"text",sourceNodeId:Q,position:z,isArrayMode:Me.current})},[g,l]),rr=!b.readOnly&&j&&b.edgeHandles!==!1,De=i==="transparent"?"none":i;return h.jsx($_,{pattern:De,backgroundColor:G,children:h.jsx(B.Box,{ref:q,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(w_,{nodes:er,edges:Ke,direction:K,nodeAlignment:c,onContainerCollapse:Q=>{var z,ee;(z=g.onNodeCollapse)==null||z.call(g,Q,!0),(ee=g.onNodeViewToggle)==null||ee.call(g,Q)},selectedNodeIds:x,edgeMode:l,compactPropertyLayout:d,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.edgeReveal,rankSep:Y,edgeSep:re,spacingFactor:he,compactSpacingScale:n,layoutDebounce:Ve,isPerformanceMode:W,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:U,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:Ae,lineColor:X,drawMode:rr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:k,multiSelect:!!T,onInit:we,onLayoutComplete:g.onLayoutComplete,animateViewport:b.animateViewport,onViewportChange:ar,onBackgroundTap:Ct,onBoxSelect:oe,onEdgeSelect:sr,onContainerSelect:We,onEdgeDraw:Qe,onDrawIntoSpace:Be})})})},zb=S.memo(F_),B_=".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 hy=!1;function D_(){if(hy||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=B_+x0+y0+b0+".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}',hy=!0}function z_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=S.useState(null),i=S.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&h0(n.json,r.json),[n==null?void 0:n.json,r.json]),s=n===null||n.json!==r.json&&!i,a=e||s;return S.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),S.useEffect(()=>{if(e||!s)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>o(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,s,r.json]),h.jsxs(B.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[h.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{a?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&h.jsx(V_,{...s?n:r,className:void 0,style:void 0})}),a&&t!==null&&h.jsx(B.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((u=r.config)==null?void 0:u.colorMode)==="dark"?"gray.800":"gray.100",color:((c=r.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?h.jsx("span",{children:"Loading diagram..."}):t})]})}function V_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:u,showBottomBar:c=!0,children:l}){D_();const[d,f]=S.useState(),[p,y]=S.useState(!1),g=i.formSchema??d,b=S.useMemo(()=>t&&r?om(t,r.state):t,[t,r==null?void 0:r.state]),x=i.direction==="C",m=S.useMemo(()=>{let E,j;return M=>(j=E&&j?p0(E,M,j)??wu(M,{title:e,isCenter:x}):wu(M,{title:e,isCenter:x}),E=M,j)},[e,x]),w=S.useMemo(()=>b?m(b):null,[b,m]),v=S.useMemo(()=>r!=null&&r.structured&&!p&&g?s0(r.state,r.bindings,g,(w==null?void 0:w.nodes)??n??[]):void 0,[r==null?void 0:r.structured,p,r==null?void 0:r.state,r==null?void 0:r.bindings,g,w,n]),C=(v==null?void 0:v.schema)??g,_=(v==null?void 0:v.bindings)??(r==null?void 0:r.bindings),R=S.useMemo(()=>[...(w==null?void 0:w.nodes)??n??[],...(v==null?void 0:v.nodes)??[]].map(j=>{var re,Y,he,me;const M=t?(re=ve(t,j.data.id))==null?void 0:re.$view:(Y=j.data.config)==null?void 0:Y.typeView,I=M&&zt.includes(M)?M:void 0,q=I?I==="icon-label":(he=j.data.config)==null?void 0:he.labelBelow,O=I==="object"?"objectView":I==="text"?"text":q?"arrayView":j.data.type,V=C&&(r?Qt(_,j.data.id,C):t&&yt(t,j.data.id,C)),W=(((me=j.data.config)==null?void 0:me.ports)??[]).map(J=>({...J}));if(v&&V){const J=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[N,L]of Object.entries(V.type.ports??{})){const G=`${L.kind}:${N}`,D=W.find(ne=>ne.id===G);D?D.label===void 0&&L.label!==void 0&&(D.label=L.label):W.push({id:G,...L.label!==void 0?{label:L.label}:{},role:L.kind==="input"||L.kind==="config"?"target":"source",side:J[L.kind],...L.kind==="config"?{placement:"config"}:{}})}for(const N of W){const L=W.filter(G=>G.side===N.side);N.position=(L.indexOf(N)+1)/(L.length+1)}}return V||q||I?{...j,data:{...j.data,type:O,...r?{description:Object.fromEntries(Object.entries(j.data.description??{}).filter(([J])=>!J.startsWith("$")&&!(v!=null&&v.slots.has(Rt(j.data.id,J)))))}:{},config:{...j.data.config,...v&&V?{ports:W}:{},...V?{form:!0}:{},...I?{typeView:I,labelBelow:!!q}:q?{labelBelow:!0}:{}}}}:j}),[w,n,t,C,_,v,i.direction]),T=[...(w==null?void 0:w.edges)??o??[],...(v==null?void 0:v.edges)??[]],A=S.useMemo(()=>{const E=t&&w?Sm(t,w.edges,s,s.onJsonChange,g):{...s};if(v){const j=new Set([...v.nodes.map(M=>M.data.id),...v.edges.map(M=>M.data.id)]);for(const M of Object.keys(E)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const I=E[M];E[M]=(q,...O)=>{if(!j.has(q))return I==null?void 0:I(q,...O)}}}return{...E,onAllNodesIconLabelChange:j=>{var M;y(j),(M=E.onAllNodesIconLabelChange)==null||M.call(E,j)}}},[t,w,s,g,v]),k=S.useMemo(()=>{if(!r)return A;let E=r.state;const j=I=>{if(i.readOnly||i.editable===!1)return;const q=r.onStateChange??r.onChange;if(!q)return;const O=e0(E,I,s.onFormChange);O!==E&&(E=O,q(O,{...I,data:O}))},M=(I,q,O)=>{var W;const V=t&&((W=ve(t,I))==null?void 0:W[q]);return!V||typeof V.$state!="string"?!1:(j({address:V.$state,nodeAddress:I,previousValue:ve(E,V.$state),value:O,data:E}),!0)};return{...A,onFormChange:j,onNodeCreateRequest:I=>{var V,W;const q=(V=I.sourceProperty)!=null&&V.startsWith("config:")?I.sourceProperty.slice(7):void 0,O=q!==void 0&&(v==null?void 0:v.slots.get(Rt(I.sourceNodeId,q)));return O?(O.present||j({data:E,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Pt(O.type),previousValue:void 0}),!0):((W=A.onNodeCreateRequest)==null?void 0:W.call(A,I))??!1},onNodeDelete:(I,q)=>{var he,me;if(!(v!=null&&v.nodes.some(J=>J.data.id===I)))return(he=A.onNodeDelete)==null?void 0:he.call(A,I,q);const O=v&&[...v.slots.values()].find(J=>J.nodeId===I);if(!O)return(me=A.onNodeDelete)==null?void 0:me.call(A,I,q);const V=O.address.split("."),W=V.pop(),re=V.join("."),Y=ve(E,re);j(Array.isArray(Y)?{data:E,nodeAddress:re,address:re,previousValue:Y,value:Y.filter((J,N)=>String(N)!==W)}:{data:E,nodeAddress:re,address:O.address,previousValue:ve(E,O.address),value:void 0})},onEdgeCreate:(I,q,O)=>{var re,Y;const V=((re=O==null?void 0:O.targetProperty)==null?void 0:re.startsWith("config:"))&&(v==null?void 0:v.slots.get(Rt(q,O.targetProperty.slice(7)))),W=v==null?void 0:v.containers.get(I);if(V&&W&&(O==null?void 0:O.sourceProperty)==="output:resource"){const he=a0(E,W,V);he!==void 0&&j({data:E,nodeAddress:V.address.split(".").slice(0,-1).join("."),address:V.address,previousValue:ve(E,V.address),value:he});return}V||v!=null&&v.nodes.some(he=>he.data.id===I||he.data.id===q)||(Y=A.onEdgeCreate)==null||Y.call(A,I,q,O)},onEdgeDelete:(I,q)=>{var me;const O=v==null?void 0:v.edges.find(J=>J.data.id===I);if(!O)return(me=A.onEdgeDelete)==null?void 0:me.call(A,I,q);const V=v.slots.get(Rt(O.data.target,O.data.targetProperty.slice(7))),W=V.address.split("."),re=W.pop(),Y=W.join("."),he=ve(E,Y);j(Array.isArray(he)?{data:E,nodeAddress:Y,address:Y,previousValue:he,value:he.filter((J,N)=>String(N)!==re)}:{data:E,nodeAddress:Y,address:V.address,previousValue:ve(E,V.address),value:void 0})},onNodeContentChange:(I,q)=>{var O,V;M(I,"$content",q)?(O=s.onNodeContentChange)==null||O.call(s,I,q):(V=A.onNodeContentChange)==null||V.call(A,I,q)},onNodeLabelChange:(I,q)=>{var O,V;M(I,"$label",q)?(O=s.onNodeLabelChange)==null||O.call(s,I,q):(V=A.onNodeLabelChange)==null||V.call(A,I,q)}}},[A,r,t,s,v,i.readOnly,i.editable]);return h.jsx(Rr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:_,references:r==null?void 0:r.references,structured:v,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!s.onJsonChange,schema:C,setSchema:E=>{var j;f(E),(j=s.onFormSchemaChange)==null||j.call(s,E)},callbacks:k},children:h.jsx(xy,{config:v?{...i,formSchema:C}:i,callbacks:k,nodes:R,edges:T,children:h.jsxs(B.Box,{className:a,"data-flow-diagram":"",style:u,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[h.jsx(zb,{nodes:R,edges:T}),c&&h.jsx(wm,{}),l]})})})}function W_(e){return ju(JSON.parse(e))}function ju(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const t=new Set,r=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||t.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");t.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);r(i)}t.delete(n)}};return r(e),structuredClone(e)}function G_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=ju(t);return e.onJsonChange(r,{type:"documentReplace",address:"root"}),r},replaceState(t){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const r=ju(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function U_(e,t){const r=(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)=>r(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.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=r(s,o[i]);return a===void 0?[]:[[i,a]]}))};return r(e,t)??{}}function dn(e){let t="",r=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(r||!t.trim()))try{const u=e.parse(e.repair(t)),c=JSON.stringify(u);if(c===n)return;e.preview(u),n=c}catch{}},a=u=>{if(!r){if(new TextEncoder().encode(u).byteLength>(e.maxBytes??1024*1024))throw r=!0,i(),new Error("JSON stream exceeds the size limit.");t=u,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(u){a(t+u)},flush:s,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,i();const u=e.parse(t);return e.commit(u),u},cancel(){r=!0,i(),t=""}}}function H_(e){const{source:t}=e,r=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(r)||r<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(t).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(t);let o=dn(e),i=0,s=!1,a=!1,u;const c=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:i,total:t.length,playing:s}),d=()=>{clearTimeout(u),u=void 0},f=(g=!1)=>{o.snapshot(t.slice(0,i)),i===t.length?(s=!1,d(),o.finish()):g&&o.flush()},p=g=>{s=!1,d(),o.cancel(),l(),e.onError(g)},y=()=>{if(u=void 0,!(!s||a)){i=Math.min(t.length,i+c);try{f()}catch(g){p(g);return}l(),s&&(u=setTimeout(y,r))}};return{play(){a||s||(i===t.length&&(o.cancel(),o=dn(e),i=0),s=!0,l(),u=setTimeout(y,r))},pause(){a||(s=!1,d(),o.flush(),l())},seek(g){if(!a){if(!Number.isFinite(g))throw new Error("Playback position must be finite.");d(),i=Math.max(0,Math.min(t.length,Math.round(g))),o.cancel(),o=dn(e);try{f(!0)}catch(b){p(b);return}l(),s&&(u=setTimeout(y,r))}},dispose(){a=!0,s=!1,d(),o.cancel()}}}function K_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=S.useContext(Rr),{colorText:i,background:s}=He();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const a=o&&Qt(o,e,n);if(!r||!a)return null;const u=ve(r,a.address);return!u||typeof u!="object"?null:h.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:fe(i),background:fe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(l=>{const d=a.fields[l]??{};if(!Cn(d.$visibleWhen,r))return null;const f=u[l],p=f==null?"":typeof f=="object"?JSON.stringify(f):String(f);return h.jsxs("div",{"data-flow-property":l,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:[h.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),h.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=wm;exports.CompactPropertyLayoutToggle=Wy;exports.ConnectionsOnlyToggle=f0;exports.DEFAULT_PALETTE=Fu;exports.DiagramAppearanceControls=Uy;exports.DynamicIcon=qr;exports.EdgeTools=dm;exports.EditableLabel=Yt;exports.ErrorToast=bm;exports.FlowDiagram=z_;exports.FlowDiagramProvider=xy;exports.FlowPort=Mb;exports.FlowView=zb;exports.FormDocumentContext=Rr;exports.NODE_TYPE_VIEWS=zt;exports.NodeBorderRadiusControl=fm;exports.NodeConfigSummary=K_;exports.NodeForm=am;exports.NodeFormPopover=qb;exports.NodeIconPicker=Lu;exports.NodeTools=hm;exports.NodeView=Vn;exports.SvgExportButton=ym;exports.Swatches=Zt;exports.TEXT_PALETTE=um;exports.ToolbarCloseButton=gt;exports.ToolbarCommitInput=et;exports.ToolbarDivider=Mt;exports.ToolbarIconButton=be;exports.ToolbarRangeInput=Gy;exports.ToolbarScrollContainer=mm;exports.ToolbarSelect=Ir;exports.ToolbarTooltip=Ee;exports.TooltipIconButton=Eu;exports.WorkflowControls=vm;exports.addChild=Ou;exports.addConnection=Iu;exports.addTargetEdge=em;exports.addressToPath=Mr;exports.applyCollapsed=Xx;exports.applyFormChange=_n;exports.applyStateEdits=Qx;exports.bindSqueedCallbacks=Sm;exports.compileSqueed=wu;exports.connectionIssue=Nu;exports.contentObjTheme=jr;exports.createFlowDiagram=Qr;exports.createFlowDocumentActions=G_;exports.createFormNode=_m;exports.createJsonPlayback=H_;exports.createJsonStream=dn;exports.downloadSvg=gm;exports.exportSvg=pm;exports.formValueError=kr;exports.getChakraColorHex=fe;exports.getColorVariant=wy;exports.getDarkerHexColor=fn;exports.getInteractionSurface=zr;exports.getNode=ve;exports.parseFlowDocument=W_;exports.parseJsonContract=Mu;exports.parseTypeScriptContract=tm;exports.parseTypeScriptForm=qu;exports.projectJsonPlaybackPreview=U_;exports.readFormSchema=$u;exports.readWorkflowContract=nm;exports.removeEdge=rm;exports.removeNode=Qy;exports.resolveEdgeOwner=Gt;exports.resolveStateView=om;exports.setCollapsed=Yy;exports.setEdgeProp=Br;exports.setEdgeStyle=Xy;exports.setNodeProp=lr;exports.updateNode=mr;exports.useCustomColors=He;exports.useEdgeProximity=yy;exports.useFlowData=Ur;exports.useFlowDiagramContext=Ie;exports.useNodeViewActions=Wn;exports.useStopPropagation=il;exports.useThemeContentColors=Xt;
190
190
  //# sourceMappingURL=index.cjs.map