@squeed/flow-sdk 2.0.33 → 2.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var fx=Object.create;var Fo=Object.defineProperty;var hx=Object.getOwnPropertyDescriptor;var px=Object.getOwnPropertyNames;var gx=Object.getPrototypeOf,yx=Object.prototype.hasOwnProperty;var mx=(e,r,t)=>r in e?Fo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var bx=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of px(r))!yx.call(e,o)&&o!==t&&Fo(e,o,{get:()=>r[o],enumerable:!(n=hx(r,o))||n.enumerable});return e};var ot=(e,r,t)=>(t=e!=null?fx(gx(e)):{},bx(r||!e||!e.__esModule?Fo(t,"default",{value:e,enumerable:!0}):t,e));var Ot=(e,r,t)=>mx(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),V=require("@chakra-ui/react"),j=require("react"),Vr=require("react-dom"),Z=require("react-icons/pi"),jm=require("@emotion/react"),vx=require("@emotion/styled"),xx=require("react-icons/tb"),wx=require("markdown-to-jsx/react"),_m=e=>e&&e.__esModule?e:{default:e},so=_m(vx),Cx=_m(wx);function Sx(e,r){let t,n,o,i;const s=(l=t)=>!!l&&["completed","failed","cancelled"].includes(l.status),a=()=>{const l=i;i=void 0,l==null||l()},c=l=>{if(!n||n.signal.aborted||!t||l.executionId!==t.executionId||s())return;const{step:d,...u}=l;t={...t,...u,steps:d?{...t.steps,[d.id]:{...t.steps[d.id],...d}}:t.steps},n.state=t,s()&&a(),r(t)};return{getState:()=>t,async run(l,d=crypto.randomUUID()){if(n&&!n.signal.aborted&&!s())throw new Error("An execution is already active.");o==null||o.abort(),a(),o=new AbortController;const u={executionId:d,input:l,signal:o.signal,state:{executionId:d,status:"subscribing",steps:{}}};n=u,t=u.state,r(t);try{const h=await e.subscribe(u,m=>{n===u&&c(m)});if(n!==u||u.signal.aborted||s())return h(),u.state;if(i=h,c({executionId:d,status:"running"}),n!==u||u.signal.aborted||s(u.state))return u.state;const p=await e.execute(u);n===u&&p&&c(p)}catch(h){if(s(u.state))return u.state;throw n===u&&!u.signal.aborted&&c({executionId:d,status:"failed",error:h instanceof Error?h.message:String(h)}),h}return u.state},async cancel(){const l=n;if(!(!l||l.signal.aborted||s())){if(!e.cancel)throw new Error("This adapter does not support cancellation.");await e.cancel(l),n===l&&c({executionId:l.executionId,status:"cancelled"})}},dispose(){o==null||o.abort(),n=void 0,a()}}}function Em({edge:e,enabled:r,bounds:t,inside:n=[],threshold:o=80}){const[i,s]=j.useState(!1),[a,c]=j.useState(!1),l=j.useRef(n);return l.current=n,j.useEffect(()=>{if(!r)return;const d=()=>{const h=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');c(Array.from(h).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},u=new MutationObserver(d);return u.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",d,!0),d(),()=>{u.disconnect(),document.removeEventListener("toggle",d,!0)}},[r]),j.useEffect(()=>{const d=h=>{var v;const p=(v=t.current)==null?void 0:v.getBoundingClientRect();if(!p)return;const m=h.target instanceof Node?h.target:null,y=!!m&&l.current.some(x=>{var w;return(w=x.current)==null?void 0:w.contains(m)}),g=e==="bottom"?p.bottom-h.clientY:h.clientY-p.top,b=h.clientX>=p.left&&h.clientX<=p.right&&g>=0&&g<=o;s(y||b)},u=()=>s(!1);return document.addEventListener("pointermove",d,!0),document.addEventListener("pointerdown",d,!0),document.documentElement.addEventListener("pointerleave",u),()=>{document.removeEventListener("pointermove",d,!0),document.removeEventListener("pointerdown",d,!0),document.documentElement.removeEventListener("pointerleave",u)}},[e,t,o]),r&&(i||a)}const Zr="#c6c6c6";function to(e,r=.2){const t=e.replace(/^#/,""),n=parseInt(t,16);let o=n>>16&255,i=n>>8&255,s=n&255;return o=Math.max(0,Math.floor(o*(1-r))),i=Math.max(0,Math.floor(i*(1-r))),s=Math.max(0,Math.floor(s*(1-r))),"#"+((1<<24)+(o<<16)+(i<<8)+s).toString(16).slice(1).toUpperCase()}function wu(e,r,t){const n=a=>{const c=/^#?([0-9a-f]{6})$/i.exec((a==null?void 0:a.trim())??"");return c?parseInt(c[1],16):null},o=n(e),i=n(r);if(o===null||i===null)return null;const s=a=>Math.round((o>>a&255)*(1-t)+(i>>a&255)*t);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const
|
|
1
|
+
"use strict";var fx=Object.create;var Fo=Object.defineProperty;var hx=Object.getOwnPropertyDescriptor;var px=Object.getOwnPropertyNames;var gx=Object.getPrototypeOf,yx=Object.prototype.hasOwnProperty;var mx=(e,r,t)=>r in e?Fo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var bx=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of px(r))!yx.call(e,o)&&o!==t&&Fo(e,o,{get:()=>r[o],enumerable:!(n=hx(r,o))||n.enumerable});return e};var ot=(e,r,t)=>(t=e!=null?fx(gx(e)):{},bx(r||!e||!e.__esModule?Fo(t,"default",{value:e,enumerable:!0}):t,e));var Ot=(e,r,t)=>mx(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),V=require("@chakra-ui/react"),j=require("react"),Vr=require("react-dom"),Z=require("react-icons/pi"),jm=require("@emotion/react"),vx=require("@emotion/styled"),xx=require("react-icons/tb"),wx=require("markdown-to-jsx/react"),_m=e=>e&&e.__esModule?e:{default:e},so=_m(vx),Cx=_m(wx);function Sx(e,r){let t,n,o,i;const s=(l=t)=>!!l&&["completed","failed","cancelled"].includes(l.status),a=()=>{const l=i;i=void 0,l==null||l()},c=l=>{if(!n||n.signal.aborted||!t||l.executionId!==t.executionId||s())return;const{step:d,...u}=l;t={...t,...u,steps:d?{...t.steps,[d.id]:{...t.steps[d.id],...d}}:t.steps},n.state=t,s()&&a(),r(t)};return{getState:()=>t,async run(l,d=crypto.randomUUID()){if(n&&!n.signal.aborted&&!s())throw new Error("An execution is already active.");o==null||o.abort(),a(),o=new AbortController;const u={executionId:d,input:l,signal:o.signal,state:{executionId:d,status:"subscribing",steps:{}}};n=u,t=u.state,r(t);try{const h=await e.subscribe(u,m=>{n===u&&c(m)});if(n!==u||u.signal.aborted||s())return h(),u.state;if(i=h,c({executionId:d,status:"running"}),n!==u||u.signal.aborted||s(u.state))return u.state;const p=await e.execute(u);n===u&&p&&c(p)}catch(h){if(s(u.state))return u.state;throw n===u&&!u.signal.aborted&&c({executionId:d,status:"failed",error:h instanceof Error?h.message:String(h)}),h}return u.state},async cancel(){const l=n;if(!(!l||l.signal.aborted||s())){if(!e.cancel)throw new Error("This adapter does not support cancellation.");await e.cancel(l),n===l&&c({executionId:l.executionId,status:"cancelled"})}},dispose(){o==null||o.abort(),n=void 0,a()}}}function Em({edge:e,enabled:r,bounds:t,inside:n=[],threshold:o=80}){const[i,s]=j.useState(!1),[a,c]=j.useState(!1),l=j.useRef(n);return l.current=n,j.useEffect(()=>{if(!r)return;const d=()=>{const h=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');c(Array.from(h).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},u=new MutationObserver(d);return u.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",d,!0),d(),()=>{u.disconnect(),document.removeEventListener("toggle",d,!0)}},[r]),j.useEffect(()=>{const d=h=>{var v;const p=(v=t.current)==null?void 0:v.getBoundingClientRect();if(!p)return;const m=h.target instanceof Node?h.target:null,y=!!m&&l.current.some(x=>{var w;return(w=x.current)==null?void 0:w.contains(m)}),g=e==="bottom"?p.bottom-h.clientY:h.clientY-p.top,b=h.clientX>=p.left&&h.clientX<=p.right&&g>=0&&g<=o;s(y||b)},u=()=>s(!1);return document.addEventListener("pointermove",d,!0),document.addEventListener("pointerdown",d,!0),document.documentElement.addEventListener("pointerleave",u),()=>{document.removeEventListener("pointermove",d,!0),document.removeEventListener("pointerdown",d,!0),document.documentElement.removeEventListener("pointerleave",u)}},[e,t,o]),r&&(i||a)}const Zr="#c6c6c6";function to(e,r=.2){const t=e.replace(/^#/,""),n=parseInt(t,16);let o=n>>16&255,i=n>>8&255,s=n&255;return o=Math.max(0,Math.floor(o*(1-r))),i=Math.max(0,Math.floor(i*(1-r))),s=Math.max(0,Math.floor(s*(1-r))),"#"+((1<<24)+(o<<16)+(i<<8)+s).toString(16).slice(1).toUpperCase()}function wu(e,r,t){const n=a=>{const c=/^#?([0-9a-f]{6})$/i.exec((a==null?void 0:a.trim())??"");return c?parseInt(c[1],16):null},o=n(e),i=n(r);if(o===null||i===null)return null;const s=a=>Math.round((o>>a&255)*(1-t)+(i>>a&255)*t);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const Xt=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:to(e,.1),border:to(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"},km=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let r=e;if(r!=null&&r.startsWith("#"))return{secondary:to(e)};let t=String(Number(e.slice(-3))+200);t=e.slice(0,-3).concat(t);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:r,secondary:t,light:n}},Cu={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"}},Pe=(e,r)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#")||e!=null&&e.startsWith("var(--"))return e;if(!e)return"whitesmoke";const t=e.replace(/\./g,"-");try{const a=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${t}`).trim();if(a&&a!=="")return a}catch{}const[n,o]=e.split(".");return n&&o&&((i=Cu[n])!=null&&i[Number(o)])?Cu[n][Number(o)]:`var(--chakra-colors-${t})`},jx=jm.keyframes`
|
|
2
2
|
0%, 100% { box-shadow: var(--flow-rest-shadow); }
|
|
3
3
|
25%, 50% { box-shadow: var(--flow-hover-shadow); }
|
|
4
4
|
`,_x=jm.keyframes`
|
|
5
5
|
from { box-shadow: var(--flow-start-shadow); }
|
|
6
6
|
to { box-shadow: var(--flow-rest-shadow); }
|
|
7
|
-
`;function Rm(e,r=!0,t="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${r?8:0}px ${o}`,a=`0 0 0 8px ${o}`;return{boxShadow:s,css:{"--flow-rest-shadow":a,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[t]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${jx} 1200ms steps(10, end) 600ms`:"none"}}}}}}function gr(e,r){const{boxShadow:t,css:n}=Rm(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:t,...n,"--flow-start-shadow":t,"@media (hover: hover)":{"&:hover":{...o,borderColor:r,"@media (prefers-reduced-motion: no-preference)":{animation:`${_x} 600ms steps(5, end)`}}}}}const Am=j.createContext(null),Pm=j.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function vr(){return j.useContext(Pm)}function He(){const e=j.useContext(Am);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Mm({config:e,callbacks:r,nodes:t=[],edges:n=[],children:o}){var $e;const i=j.useMemo(()=>{var xe,Ze,Qe;const U=new Map;for(const Ke of t)(xe=Ke.data)!=null&&xe.id&&U.set(Ke.data.id,Ke);const ge=new Map;for(const Ke of n)(Ze=Ke.data)!=null&&Ze.id&&ge.set(Ke.data.id,Ke);const Ie=new Set;for(const Ke of t)(Qe=Ke.data)!=null&&Qe.parent&&Ie.add(Ke.data.parent);return{nodeById:U,edgeById:ge,parentIds:Ie}},[t,n]),s=j.useRef(null),[a,c]=j.useState([]),[l,d]=j.useState(null),[u,h]=j.useState(!0),[p,m]=j.useState(!1),[y,g]=j.useState(!0),[b,v]=j.useState(!1),[x,w]=j.useState(!1),[C,S]=j.useState(!0),[_,k]=j.useState(!1),[E,O]=j.useState(()=>{var U;return(U=e.nodeGrid)!=null&&U.enabled?{...e.nodeGrid.options,...e.nodeGrid.order?{order:e.nodeGrid.order}:{}}:null}),P=j.useRef(E),[A,M]=j.useState(E??(($e=e.nodeGrid)==null?void 0:$e.options)??{gaps:15,fill:!1,padding:0}),[T,N]=j.useState(()=>new Set),$=j.useCallback(U=>{var ge;!!(U!=null&&U.fill)!=!!((ge=P.current)!=null&&ge.fill)&&N(new Set),P.current=U,U&&M(U),O(U)},[]),[I,W]=j.useState("auto"),[ie,ae]=j.useState(!1),re=e.compactPropertyLayout??ie,[ye,be]=j.useState({}),L=e.nodeViewModes??ye,[z,G]=j.useState(e.allNodesIconLabel);j.useEffect(()=>G(e.allNodesIconLabel),[e.allNodesIconLabel]);const[D,se]=j.useState({}),X=j.useCallback((U,ge)=>{se(Ie=>{const xe={...Ie};for(const Ze of U)ge===void 0?delete xe[Ze]:xe[Ze]=ge;return xe})},[]),le=[...i.nodeById.values()].filter(U=>{var ge;return i.parentIds.has(U.data.id)||((ge=U.data.config)==null?void 0:ge.parentContainer)||U.data.type==="objectView"||U.data.type==="arrayView"||U.data.type==="grid"}),ue=le.every(U=>{var ge,Ie,xe;return i.parentIds.has(U.data.id)||(ge=U.data.config)!=null&&ge.parentContainer?!!((Ie=U.data.config)!=null&&Ie.collapsed):L[U.data.id]==="icon-label"||U.data.type==="grid"&&L[U.data.id]===void 0||((xe=U.data.config)==null?void 0:xe.labelBelow)&&L[U.data.id]!=="properties"}),Ce=z??e.allNodesIconLabel??ue,[je,pe]=j.useState("normal"),[fe,Y]=j.useState(),H=e.edgeRadius??fe,we=H!==void 0&&Number.isFinite(H)?Math.min(500,Math.max(0,H)):void 0,[J,ve]=j.useState(),Q=e.spacing??je,Ee=typeof Q=="number"?Number.isFinite(Q)?Math.min(2,Math.max(e.nodeGridSpacing==="layout"?0:.5,Q)):1:Q==="compact"?.5:Q==="spacious"?2:1,Ae=e.backgroundVariant??J??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[qe,Je]=j.useState(),Fe=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:qe,[ct,De]=j.useState("blue.500"),[rt,ft]=j.useState(!1),Oe=j.useRef(r);Oe.current=r;const Xe=j.useMemo(()=>{const U=ge=>(...Ie)=>{var xe,Ze;return(Ze=(xe=Oe.current)==null?void 0:xe[ge])==null?void 0:Ze.call(xe,...Ie)};return{onNodeSelect:U("onNodeSelect"),onNodesCopy:U("onNodesCopy"),onNodesDuplicate:U("onNodesDuplicate"),onBackgroundClick:U("onBackgroundClick"),onBottomBarCollapsedChange:U("onBottomBarCollapsedChange"),onNodeGridZoomOut:U("onNodeGridZoomOut"),onNodeGridFillRequest:U("onNodeGridFillRequest"),onNodeGridModeRequest:U("onNodeGridModeRequest"),onNodeGridDrop:U("onNodeGridDrop"),onNodeParentChange:U("onNodeParentChange"),onNodeDeselect:U("onNodeDeselect"),onNodeDoubleClick:U("onNodeDoubleClick"),onNodeViewToggle:U("onNodeViewToggle"),onNodeTypeViewChange:U("onNodeTypeViewChange"),onNodeCreate:U("onNodeCreate"),onNodeCreateRequest:U("onNodeCreateRequest"),onNodeDelete:U("onNodeDelete"),onNodeLabelChange:U("onNodeLabelChange"),onNodeSubtitleChange:U("onNodeSubtitleChange"),onNodeContentChange:U("onNodeContentChange"),onNodeCollapse:U("onNodeCollapse"),onNodeColorChange:U("onNodeColorChange"),onNodeBorderColorChange:U("onNodeBorderColorChange"),onNodeBorderStyleChange:U("onNodeBorderStyleChange"),onNodeBorderWidthChange:U("onNodeBorderWidthChange"),onNodeBorderRadiusChange:(ge,Ie)=>{var xe,Ze,Qe;(xe=P.current)!=null&&xe.fill&&N(Ke=>new Set([...Ke,ge])),(Qe=(Ze=Oe.current).onNodeBorderRadiusChange)==null||Qe.call(Ze,ge,Ie)},onNodeIconChange:U("onNodeIconChange"),onNodeOutlineChange:U("onNodeOutlineChange"),onNodeAnimationChange:U("onNodeAnimationChange"),onNodeAnimationVariantChange:U("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:U("onEdgeAnimationVariantChange"),onNodeHoverAction:U("onNodeHoverAction"),onEdgeCreate:U("onEdgeCreate"),onEdgeSelect:U("onEdgeSelect"),onEdgeDeselect:U("onEdgeDeselect"),onEdgeRemove:U("onEdgeRemove"),onEdgeDelete:U("onEdgeDelete"),onEdgeColorChange:U("onEdgeColorChange"),onEdgeTypeChange:U("onEdgeTypeChange"),onEdgeIconChange:U("onEdgeIconChange"),onEdgeLabelChange:U("onEdgeLabelChange"),onEdgeStyleChange:U("onEdgeStyleChange"),onViewportChange:U("onViewportChange"),onDirectionChange:U("onDirectionChange"),onThemeColorChange:U("onThemeColorChange"),onSpacingChange:U("onSpacingChange"),onEdgeRadiusChange:U("onEdgeRadiusChange"),onBackgroundVariantChange:U("onBackgroundVariantChange"),onEdgeModeChange:U("onEdgeModeChange"),onCompactPropertyLayoutChange:U("onCompactPropertyLayoutChange"),onWorkflowContractChange:U("onWorkflowContractChange"),onWorkflowConfigurationOpen:r.onWorkflowConfigurationOpen?U("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:U("onArrayModeChange"),onInit:U("onInit"),onLayoutComplete:U("onLayoutComplete"),onJsonChange:U("onJsonChange")}},[]),nt=e.themeColor||ct,[lt,zt]=j.useState(""),kt=e.edgeColor??lt,et=e.colorMode||"light",We=e.direction||"LR",Ht=e.nodeAlignment??"center",dt=e.edgeMode==="workflow"?"nodes":e.edgeMode??I,er=e.readOnly??!1,ar=JSON.stringify(e.parentNodeStyle??null),Bt=j.useMemo(()=>e.parentNodeStyle,[ar]),Dt=e.isZoomMode!==void 0?e.isZoomMode:u,Kt=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,tr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,$r=e.isDragMode!==void 0?e.isDragMode:y,ze=j.useRef(e);ze.current=e;const ce=j.useMemo(()=>({get direction(){return ze.current.direction},get nodeAlignment(){return ze.current.nodeAlignment},get edgeMode(){return ze.current.edgeMode},get compactPropertyLayout(){return ze.current.compactPropertyLayout},get bottomBarCollapsed(){return ze.current.bottomBarCollapsed},get bottomBarNavigation(){return ze.current.bottomBarNavigation},get bottomBarFill(){return ze.current.bottomBarFill},get bottomBarCollision(){return ze.current.bottomBarCollision},get nodeGridConnections(){return ze.current.nodeGridConnections},get nodeGrid(){return ze.current.nodeGrid},get edgeType(){return ze.current.edgeType},get edgeReveal(){return ze.current.edgeReveal},get customEdgeTypes(){return ze.current.customEdgeTypes},get themeColor(){return ze.current.themeColor},get colorMode(){return ze.current.colorMode},get readOnly(){return ze.current.readOnly},get editable(){return ze.current.editable},get minZoom(){return ze.current.minZoom},get nodeGridSpacing(){return ze.current.nodeGridSpacing},get maxZoom(){return ze.current.maxZoom},get backgroundPattern(){return ze.current.backgroundPattern},get edgeColor(){return ze.current.edgeColor},get parentNodeStyle(){return ze.current.parentNodeStyle},get backgroundColor(){return ze.current.backgroundColor},get edgeHandles(){return ze.current.edgeHandles},get initialViewport(){return ze.current.initialViewport},get animateViewport(){return ze.current.animateViewport},get disableAnimations(){return ze.current.disableAnimations},get nodeOverlayActions(){return ze.current.nodeOverlayActions},get renderNodeOverlay(){return ze.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return ze.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return ze.current.renderSelectedEdgeToolbar},get renderBottomBar(){return ze.current.renderBottomBar},get bottomBarExtra(){return ze.current.bottomBarExtra},get selectionToolbar(){return ze.current.selectionToolbar},get customViews(){return ze.current.customViews},get disableKeyboardShortcuts(){return ze.current.disableKeyboardShortcuts},get isZoomMode(){return ze.current.isZoomMode},get isMultiSelectMode(){return ze.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return ze.current.isEdgeHandlesEnabled},get isDragMode(){return ze.current.isDragMode}}),[]),B=j.useCallback((U,ge)=>{var Ie;if(ge!=="default"&&ge!=="properties"&&ge!=="icon-label")throw new Error("Unknown node view mode.");G(xe=>xe??Ce),be(xe=>xe[U]===ge?xe:{...xe,[U]:ge}),(Ie=r.onNodeViewModeChange)==null||Ie.call(r,U,ge)},[r.onNodeViewModeChange,Ce]),oe=j.useMemo(()=>({allNodesIconLabel:Ce,setAllNodesIconLabel:U=>{var ge,Ie,xe,Ze,Qe;if(G(U),!U)for(const[Ke,vt]of Object.entries(L))vt==="icon-label"&&!i.nodeById.has(Ke)&&B(Ke,"default");for(const Ke of le)i.parentIds.has(Ke.data.id)||(ge=Ke.data.config)!=null&&ge.parentContainer?!er&&!!((Ie=Ke.data.config)!=null&&Ie.collapsed)!==U&&((xe=r.onNodeCollapse)==null||xe.call(r,Ke.data.id,U)):B(Ke.data.id,U?"icon-label":(Ze=Ke.data.config)!=null&&Ze.labelBelow?"properties":"default");(Qe=r.onAllNodesIconLabelChange)==null||Qe.call(r,U)},nodeViewModes:L,setNodeViewMode:B,nodeRadiusPreviews:D,setNodeRadiusPreview:X,spacing:Ee,setSpacing:pe,edgeRadius:we,setEdgeRadius:Y,backgroundVariant:Ae,setBackgroundVariant:ve,themeColor:nt,setThemeColor:De,backgroundSelected:rt,setBackgroundSelected:ft,edgeColor:kt,setEdgeColor:U=>{var ge;zt(U),(ge=r.onGraphEdgeColorChange)==null||ge.call(r,U)},colorMode:et,direction:We,nodeAlignment:Ht,edgeMode:dt,setEdgeMode:W,compactPropertyLayout:re,setCompactPropertyLayout:ae,workflowContract:Fe,setWorkflowContract:Je,parentNodeStyle:Bt,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isZoomMode:Dt,setIsZoomMode:h,isMultiSelectMode:Kt,setIsMultiSelectMode:m,isDragMode:$r,setIsDragMode:g,isEdgeHandlesEnabled:tr,setIsEdgeHandlesEnabled:v,isArrayNodeMode:x,setIsArrayNodeMode:w,isPinned:C,setIsPinned:S,isPerformanceMode:_,setIsPerformanceMode:k,nodeGridOptions:E,setNodeGridOptions:$,lastNodeGridOptions:A,fillRadiusEditedIds:T,setFillRadiusEditedIds:N,engineRef:s,callbacks:Xe,config:ce,readOnly:er}),[Ce,i,B,r.onNodeCollapse,r.onAllNodesIconLabelChange,r.onGraphEdgeColorChange,L,r.onNodeViewModeChange,D,X,nt,Ee,Ae,we,e.backgroundColor,rt,kt,et,We,Ht,dt,Fe,Bt,a,l,Dt,Kt,$r,tr,x,C,_,E,A,T,er,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.disableAnimations,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.bottomBarNavigation,e.bottomBarFill,e.bottomBarCollision,e.nodeGridSpacing,e.nodeGridConnections,e.compactPropertyLayout,re,Xe,ce]);return f.jsx(Am.Provider,{value:oe,children:f.jsx(Pm.Provider,{value:i,children:o})})}function wt(e,r,t){return e?t:r}function Nn(e){const[r]=(e==null?void 0:e.split("."))||[],{secondary:t}=km(e),n=Yt(r).background,o=Yt(r).highlight,i=Yt(r).border,s=Yt(r).property,a=Yt(r).property;let c=Yt(r).background,l=Yt(r).highlight;return c=e==="transparent"?e:Pe(c)+50,l=e==="transparent"?e:Pe(l)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:s,propertyColor:a,secondary:t,bgColorFaint:c,highlightColorFaint:l}}function st(e=null){const{colorMode:r}=He(),t=e==null?void 0:e.includes("gray"),n=r==="dark",o=wt(n,"white","gray.900"),i=wt(n,"gray.100","gray.800"),s=wt(n,"gray.200","blackAlpha.400"),a=wt(n,"gray.200","blackAlpha.600"),c=wt(n,"gray.500","gray.700"),l=wt(n,"gray.700","gray.700"),d=wt(n,"gray.900","gray.900"),u=wt(n,"gray.400","gray.500"),h=wt(n,"gray.400","gray.500"),p=wt(n,"gray.900","gray.200"),m=wt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),y=wt(n,"gray.900","gray.200"),g=wt(n,e&&"#000000",e||"#ffffff"),b=wt(n,e||"#ffffff",e?"#000000":"#ffffff"),v=l,x=wt(n,"gray.300","gray.800"),w=wt(n,"white","blackAlpha.400"),C=wt(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:d,backgroundWhiteColor:w,borderSecondary:l,colorActive:u,colorInactive:h,iconColor:y,moreIconColor:v,colorText:p,themedColorText:m,logoColor:g,logoColorSecondary:b,darkColorActive:x,greenColor:C}}var hn=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(hn||{});const wd=["","icon-label","object","text","grid","parent"];var Ex=typeof global=="object"&&global&&global.Object===Object&&global,kx=typeof self=="object"&&self&&self.Object===Object&&self,Rx=Ex||kx||Function("return this")(),Wr=Rx.Symbol,Im=Object.prototype,Ax=Im.hasOwnProperty,Px=Im.toString,un=Wr?Wr.toStringTag:void 0;function Mx(e){var r=Ax.call(e,un),t=e[un];try{e[un]=void 0;var n=!0}catch{}var o=Px.call(e);return n&&(r?e[un]=t:delete e[un]),o}var Ix=Object.prototype,Tx=Ix.toString;function Ox(e){return Tx.call(e)}var Nx="[object Null]",$x="[object Undefined]",Su=Wr?Wr.toStringTag:void 0;function qx(e){return e==null?e===void 0?$x:Nx:Su&&Su in Object(e)?Mx(e):Ox(e)}function Lx(e){return e!=null&&typeof e=="object"}var Fx="[object Symbol]";function zx(e){return typeof e=="symbol"||Lx(e)&&qx(e)==Fx}function Bx(e,r){for(var t=-1,n=e==null?0:e.length,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o}var tt=Array.isArray,ju=Wr?Wr.prototype:void 0,_u=ju?ju.toString:void 0;function Tm(e){if(typeof e=="string")return e;if(tt(e))return Bx(e,Tm)+"";if(zx(e))return _u?_u.call(e):"";var r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function Cd(e){return e==null?"":Tm(e)}function Dx(e,r,t){var n=-1,o=e.length;r<0&&(r=-r>o?0:o+r),t=t>o?o:t,t<0&&(t+=o),o=r>t?0:t-r>>>0,r>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+r];return i}function Vx(e,r,t){var n=e.length;return t=t===void 0?n:t,!r&&t>=n?e:Dx(e,r,t)}var Wx="\\ud800-\\udfff",Gx="\\u0300-\\u036f",Ux="\\ufe20-\\ufe2f",Hx="\\u20d0-\\u20ff",Kx=Gx+Ux+Hx,Jx="\\ufe0e\\ufe0f",Zx="\\u200d",Yx=RegExp("["+Zx+Wx+Kx+Jx+"]");function Om(e){return Yx.test(e)}function Xx(e){return e.split("")}var Nm="\\ud800-\\udfff",Qx="\\u0300-\\u036f",e0="\\ufe20-\\ufe2f",t0="\\u20d0-\\u20ff",r0=Qx+e0+t0,n0="\\ufe0e\\ufe0f",o0="["+Nm+"]",dd="["+r0+"]",ud="\\ud83c[\\udffb-\\udfff]",i0="(?:"+dd+"|"+ud+")",$m="[^"+Nm+"]",qm="(?:\\ud83c[\\udde6-\\uddff]){2}",Lm="[\\ud800-\\udbff][\\udc00-\\udfff]",a0="\\u200d",Fm=i0+"?",zm="["+n0+"]?",s0="(?:"+a0+"(?:"+[$m,qm,Lm].join("|")+")"+zm+Fm+")*",c0=zm+Fm+s0,l0="(?:"+[$m+dd+"?",dd,qm,Lm,o0].join("|")+")",d0=RegExp(ud+"(?="+ud+")|"+l0+c0,"g");function u0(e){return e.match(d0)||[]}function f0(e){return Om(e)?u0(e):Xx(e)}function h0(e){return function(r){r=Cd(r);var t=Om(r)?f0(r):void 0,n=t?t[0]:r.charAt(0),o=t?Vx(t,1).join(""):r.slice(1);return n[e]()+o}}var p0=h0("toUpperCase");function g0(e,r,t,n){for(var o=-1,i=e==null?0:e.length;++o<i;)t=r(t,e[o],o,e);return t}function y0(e){return function(r){return e==null?void 0:e[r]}}var m0={À:"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"},b0=y0(m0),v0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,x0="\\u0300-\\u036f",w0="\\ufe20-\\ufe2f",C0="\\u20d0-\\u20ff",S0=x0+w0+C0,j0="["+S0+"]",_0=RegExp(j0,"g");function E0(e){return e=Cd(e),e&&e.replace(v0,b0).replace(_0,"")}var k0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function R0(e){return e.match(k0)||[]}var A0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function P0(e){return A0.test(e)}var Bm="\\ud800-\\udfff",M0="\\u0300-\\u036f",I0="\\ufe20-\\ufe2f",T0="\\u20d0-\\u20ff",O0=M0+I0+T0,Dm="\\u2700-\\u27bf",Vm="a-z\\xdf-\\xf6\\xf8-\\xff",N0="\\xac\\xb1\\xd7\\xf7",$0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",q0="\\u2000-\\u206f",L0=" \\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",Wm="A-Z\\xc0-\\xd6\\xd8-\\xde",F0="\\ufe0e\\ufe0f",Gm=N0+$0+q0+L0,Um="['’]",Eu="["+Gm+"]",z0="["+O0+"]",Hm="\\d+",B0="["+Dm+"]",Km="["+Vm+"]",Jm="[^"+Bm+Gm+Hm+Dm+Vm+Wm+"]",D0="\\ud83c[\\udffb-\\udfff]",V0="(?:"+z0+"|"+D0+")",W0="[^"+Bm+"]",Zm="(?:\\ud83c[\\udde6-\\uddff]){2}",Ym="[\\ud800-\\udbff][\\udc00-\\udfff]",qr="["+Wm+"]",G0="\\u200d",ku="(?:"+Km+"|"+Jm+")",U0="(?:"+qr+"|"+Jm+")",Ru="(?:"+Um+"(?:d|ll|m|re|s|t|ve))?",Au="(?:"+Um+"(?:D|LL|M|RE|S|T|VE))?",Xm=V0+"?",Qm="["+F0+"]?",H0="(?:"+G0+"(?:"+[W0,Zm,Ym].join("|")+")"+Qm+Xm+")*",K0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",J0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Z0=Qm+Xm+H0,Y0="(?:"+[B0,Zm,Ym].join("|")+")"+Z0,X0=RegExp([qr+"?"+Km+"+"+Ru+"(?="+[Eu,qr,"$"].join("|")+")",U0+"+"+Au+"(?="+[Eu,qr+ku,"$"].join("|")+")",qr+"?"+ku+"+"+Ru,qr+"+"+Au,J0,K0,Hm,Y0].join("|"),"g");function Q0(e){return e.match(X0)||[]}function ew(e,r,t){return e=Cd(e),r=r,r===void 0?P0(e)?Q0(e):R0(e):e.match(r)||[]}var tw="['’]",rw=RegExp(tw,"g");function nw(e){return function(r){return g0(ew(E0(r).replace(rw,"")),e,"")}}var $t=nw(function(e,r,t){return e+(t?" ":"")+p0(r)});function ow(){let e,r=null;const t=new Set,n=o=>{r=o,t.forEach(i=>i())};return{subscribe:o=>(t.add(o),()=>{t.delete(o)}),getSnapshot:()=>r,select(o,i){e=o,n(i)},update(o,i){e===o&&n(i)},remove(o){e===o&&(e=void 0,n(null))}}}const Gr=j.createContext(null),iw=()=>j.useState(ow)[0];function co(e,r=!0){const t=j.useContext(Gr),n=j.useId();return j.useEffect(()=>{r?t==null||t.update(n,e):t==null||t.remove(n)}),j.useEffect(()=>()=>t==null?void 0:t.remove(n),[t,n]),()=>{r&&(t==null||t.select(n,e))}}function aw({divider:e,visibleActions:r=[]}){const t=j.useContext(Gr),n=j.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null),o=n&&r.includes(n.props["aria-label"]??"");return f.jsx(Gr.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:n&&!o?"contents":"none"},children:[n&&!o&&e,!o&&n]})})}function Ue({label:e,children:r}){const t=j.cloneElement(r,{title:r.props.title??e});if(!V.Tooltip.Root){const n=V.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:t})}return f.jsxs(V.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(V.Tooltip.Trigger,{asChild:!0,children:t}),f.jsx(V.Portal,{children:f.jsx(V.Tooltip.Positioner,{children:f.jsx(V.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function xn(){const{border:e}=st(),{colorMode:r}=He();return f.jsx(V.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:r==="dark"?e:"gray.300"})}function At({children:e,value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,labelCase:l="title","aria-label":d,...u}){var M;const{colorMode:h}=He(),{background:p,border:m,colorText:y,colorInactive:g}=st(),b=h==="dark",v=j.useId(),x=j.useRef(null),w=j.useRef(null),[C,S]=j.useState(!1),_=co(f.jsx(At,{value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,labelCase:l,"aria-label":d,children:e}),!!s);j.useEffect(()=>{const T=w.current;T.setAttribute("popover","auto");const N=$=>S($.newState==="open");return T.addEventListener("toggle",N),()=>T.removeEventListener("toggle",N)},[]);const k=j.Children.toArray(e).filter(j.isValidElement).map(T=>{const N=T.props;return{value:String(N.value),label:typeof N.children=="string"&&l==="title"?$t(N.children):N.children,disabled:N.disabled}}),E=()=>{var T;return(T=w.current)==null?void 0:T.hidePopover()},O=()=>{var ie,ae,re,ye,be;const T=(ie=x.current)==null?void 0:ie.getBoundingClientRect(),N=w.current;if(!T||!N)return;if((ae=x.current)!=null&&ae.closest("[popover]")){const L=window.innerHeight-T.bottom-16,z=T.top-16;N.style.maxHeight=`${Math.max(60,L,z)}px`;const G=N.getBoundingClientRect();N.style.left=`${Math.max(12,Math.min(T.right-G.width,window.innerWidth-G.width-12))}px`,N.style.top=`${Math.max(12,G.height<=L?T.bottom+4:T.top-G.height-4)}px`;return}const $=(be=(ye=(re=x.current)==null?void 0:re.closest("[data-flow-toolbar-scroll]"))==null?void 0:ye.parentElement)==null?void 0:be.getBoundingClientRect(),I=$??T;N.style.maxHeight=`${Math.max(60,Math.max(I.top-40,window.innerHeight-I.bottom-40))}px`;const W=N.getBoundingClientRect();N.style.left=`${Math.max(12,Math.min(Math.max(($==null?void 0:$.left)??12,T.right-W.width),(($==null?void 0:$.right)??window.innerWidth-12)-W.width,window.innerWidth-W.width-12))}px`,N.style.top=`${Math.max(12,I.top>=W.height+36?I.top-W.height-24:Math.min(I.bottom+24,window.innerHeight-W.height-12))}px`},P=()=>{var $,I,W,ie,ae,re;if(n)return;if(($=w.current)==null||$.showPopover(),O(),a){(W=(I=w.current)==null?void 0:I.querySelector("input"))==null||W.focus({preventScroll:!0});return}const T=(ie=w.current)==null?void 0:ie.querySelectorAll('[role="option"]:not(:disabled)');(re=((ae=w.current)==null?void 0:ae.querySelector('[aria-selected="true"]:not(:disabled)'))??(T==null?void 0:T[0]))==null||re.focus()};j.useEffect(()=>{if(C){if(n){E();return}return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}}},[C,n]);const A=`var(--chakra-colors-${p.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(Ue,{label:i??d,children:f.jsx(V.chakra.button,{...u,ref:x,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":d,title:i??d,"aria-haspopup":a?"dialog":"listbox","aria-expanded":C,"aria-controls":v,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?g:y,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:o,onClick:()=>{_(),C?E():P()},onKeyDown:T=>{["ArrowDown","ArrowUp"].includes(T.key)&&(T.preventDefault(),P())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((M=k.find(T=>T.value===r))==null?void 0:M.label)??r}),f.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(V.chakra.div,{ref:w,id:v,role:a?"dialog":"listbox","aria-label":d,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:p,color:y,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},'& [role="option"]':ro,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...gr(A,`var(--chakra-colors-${(b?m:"gray.300").replace(".","-")})`)},onKeyDown:T=>{var I,W,ie;if(a&&!["Escape","Tab"].includes(T.key))return;const N=[...T.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],$=N.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(T.key)){T.preventDefault();const ae=T.key==="Home"?0:T.key==="End"?N.length-1:($+(T.key==="ArrowDown"?1:-1)+N.length)%N.length;(I=N[ae])==null||I.focus()}else T.key==="Escape"||T.key==="Tab"?(T.key==="Escape"&&(T.preventDefault(),T.stopPropagation()),E(),(W=x.current)==null||W.focus()):T.key.length===1&&T.key!==" "&&((ie=N.find((ae,re)=>{var ye;return re>$&&((ye=ae.textContent)==null?void 0:ye.toLowerCase().startsWith(T.key.toLowerCase()))}))==null||ie.focus())},children:[a??k.map(T=>f.jsxs(V.chakra.button,{type:"button",role:"option","aria-selected":T.value===r,disabled:T.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",fontSize:"sm",textAlign:"left",bg:"transparent",color:y,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var N;E(),(N=x.current)==null||N.focus(),t(T.value)},children:[f.jsx("span",{style:{flex:1},children:T.label}),f.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${y.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:T.value===r?"visible":"hidden"}})]},T.value)),c]})]})}const ro={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Ne=j.forwardRef(function({icon:r,rememberAction:t=!0,...n},o){const{colorMode:i}=He(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=co(f.jsx(Ue,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Ne,{...s,icon:r})}),t&&!!n.onClick);return f.jsx(V.IconButton,{ref:o,_hover:{bg:i==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var l;a(),(l=n.onClick)==null||l.call(n,c)},children:r})}),Yr=j.forwardRef(function(r,t){const{themeColor:n}=He();return f.jsx(Ue,{label:"Close",children:f.jsx(Ne,{ref:t,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...r,"aria-label":r["aria-label"]??"Close selection tools",icon:f.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})});function eb({onBeforeExpand:e}={}){const{allNodesIconLabel:r,setAllNodesIconLabel:t}=He();return f.jsx(Ur,{label:"Collapse all",hideLabel:!0,checked:r,icon:f.jsx(Z.PiArrowsInLineVertical,{size:20}),onChange:n=>{n||e==null||e(),t(n)}})}function Ur({label:e,icon:r,checked:t,onChange:n,disabled:o,hideLabel:i=!1,helper:s=e}){const{themeColor:a,readOnly:c}=He(),{colorInactive:l}=st();return f.jsx(Ue,{label:s,children:f.jsx(Ne,{"aria-label":e,"aria-pressed":t,icon:f.jsxs(f.Fragment,{children:[r,!i&&f.jsx(V.Text,{as:"span",fontSize:"16px",fontWeight:t?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:t?a:l,disabled:o||c,onClick:()=>n(!t)})})}function tb({label:e="Compact layout"}={}){const{compactPropertyLayout:r,setCompactPropertyLayout:t,callbacks:n}=He();return f.jsx(Ur,{hideLabel:!0,label:e,checked:r,icon:f.jsx(V.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:o=>{var i;t(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const sw=so.default.input`
|
|
7
|
+
`;function Rm(e,r=!0,t="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${r?8:0}px ${o}`,a=`0 0 0 8px ${o}`;return{boxShadow:s,css:{"--flow-rest-shadow":a,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[t]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${jx} 1200ms steps(10, end) 600ms`:"none"}}}}}}function gr(e,r){const{boxShadow:t,css:n}=Rm(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:t,...n,"--flow-start-shadow":t,"@media (hover: hover)":{"&:hover":{...o,borderColor:r,"@media (prefers-reduced-motion: no-preference)":{animation:`${_x} 600ms steps(5, end)`}}}}}const Am=j.createContext(null),Pm=j.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function vr(){return j.useContext(Pm)}function He(){const e=j.useContext(Am);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Mm({config:e,callbacks:r,nodes:t=[],edges:n=[],children:o}){var $e;const i=j.useMemo(()=>{var xe,Ze,Qe;const U=new Map;for(const Ke of t)(xe=Ke.data)!=null&&xe.id&&U.set(Ke.data.id,Ke);const ge=new Map;for(const Ke of n)(Ze=Ke.data)!=null&&Ze.id&&ge.set(Ke.data.id,Ke);const Ie=new Set;for(const Ke of t)(Qe=Ke.data)!=null&&Qe.parent&&Ie.add(Ke.data.parent);return{nodeById:U,edgeById:ge,parentIds:Ie}},[t,n]),s=j.useRef(null),[a,c]=j.useState([]),[l,d]=j.useState(null),[u,h]=j.useState(!0),[p,m]=j.useState(!1),[y,g]=j.useState(!0),[b,v]=j.useState(!1),[x,w]=j.useState(!1),[C,S]=j.useState(!0),[_,k]=j.useState(!1),[E,O]=j.useState(()=>{var U;return(U=e.nodeGrid)!=null&&U.enabled?{...e.nodeGrid.options,...e.nodeGrid.order?{order:e.nodeGrid.order}:{}}:null}),P=j.useRef(E),[A,M]=j.useState(E??(($e=e.nodeGrid)==null?void 0:$e.options)??{gaps:15,fill:!1,padding:0}),[T,N]=j.useState(()=>new Set),$=j.useCallback(U=>{var ge;!!(U!=null&&U.fill)!=!!((ge=P.current)!=null&&ge.fill)&&N(new Set),P.current=U,U&&M(U),O(U)},[]),[I,W]=j.useState("auto"),[ie,ae]=j.useState(!1),re=e.compactPropertyLayout??ie,[ye,be]=j.useState({}),L=e.nodeViewModes??ye,[z,G]=j.useState(e.allNodesIconLabel);j.useEffect(()=>G(e.allNodesIconLabel),[e.allNodesIconLabel]);const[D,se]=j.useState({}),X=j.useCallback((U,ge)=>{se(Ie=>{const xe={...Ie};for(const Ze of U)ge===void 0?delete xe[Ze]:xe[Ze]=ge;return xe})},[]),le=[...i.nodeById.values()].filter(U=>{var ge;return i.parentIds.has(U.data.id)||((ge=U.data.config)==null?void 0:ge.parentContainer)||U.data.type==="objectView"||U.data.type==="arrayView"||U.data.type==="grid"}),ue=le.every(U=>{var ge,Ie,xe;return i.parentIds.has(U.data.id)||(ge=U.data.config)!=null&&ge.parentContainer?!!((Ie=U.data.config)!=null&&Ie.collapsed):L[U.data.id]==="icon-label"||U.data.type==="grid"&&L[U.data.id]===void 0||((xe=U.data.config)==null?void 0:xe.labelBelow)&&L[U.data.id]!=="properties"}),Ce=z??e.allNodesIconLabel??ue,[je,pe]=j.useState("normal"),[fe,Y]=j.useState(),H=e.edgeRadius??fe,we=H!==void 0&&Number.isFinite(H)?Math.min(500,Math.max(0,H)):void 0,[J,ve]=j.useState(),Q=e.spacing??je,Ee=typeof Q=="number"?Number.isFinite(Q)?Math.min(2,Math.max(e.nodeGridSpacing==="layout"?0:.5,Q)):1:Q==="compact"?.5:Q==="spacious"?2:1,Ae=e.backgroundVariant??J??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[qe,Je]=j.useState(),Fe=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:qe,[ct,De]=j.useState("blue.500"),[rt,ft]=j.useState(!1),Oe=j.useRef(r);Oe.current=r;const Xe=j.useMemo(()=>{const U=ge=>(...Ie)=>{var xe,Ze;return(Ze=(xe=Oe.current)==null?void 0:xe[ge])==null?void 0:Ze.call(xe,...Ie)};return{onNodeSelect:U("onNodeSelect"),onNodesCopy:U("onNodesCopy"),onNodesDuplicate:U("onNodesDuplicate"),onBackgroundClick:U("onBackgroundClick"),onBottomBarCollapsedChange:U("onBottomBarCollapsedChange"),onNodeGridZoomOut:U("onNodeGridZoomOut"),onNodeGridFillRequest:U("onNodeGridFillRequest"),onNodeGridModeRequest:U("onNodeGridModeRequest"),onNodeGridDrop:U("onNodeGridDrop"),onNodeParentChange:U("onNodeParentChange"),onNodeDeselect:U("onNodeDeselect"),onNodeDoubleClick:U("onNodeDoubleClick"),onNodeViewToggle:U("onNodeViewToggle"),onNodeTypeViewChange:U("onNodeTypeViewChange"),onNodeCreate:U("onNodeCreate"),onNodeCreateRequest:U("onNodeCreateRequest"),onNodeDelete:U("onNodeDelete"),onNodeLabelChange:U("onNodeLabelChange"),onNodeSubtitleChange:U("onNodeSubtitleChange"),onNodeContentChange:U("onNodeContentChange"),onNodeCollapse:U("onNodeCollapse"),onNodeColorChange:U("onNodeColorChange"),onNodeBorderColorChange:U("onNodeBorderColorChange"),onNodeBorderStyleChange:U("onNodeBorderStyleChange"),onNodeBorderWidthChange:U("onNodeBorderWidthChange"),onNodeBorderRadiusChange:(ge,Ie)=>{var xe,Ze,Qe;(xe=P.current)!=null&&xe.fill&&N(Ke=>new Set([...Ke,ge])),(Qe=(Ze=Oe.current).onNodeBorderRadiusChange)==null||Qe.call(Ze,ge,Ie)},onNodeIconChange:U("onNodeIconChange"),onNodeOutlineChange:U("onNodeOutlineChange"),onNodeAnimationChange:U("onNodeAnimationChange"),onNodeAnimationVariantChange:U("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:U("onEdgeAnimationVariantChange"),onNodeHoverAction:U("onNodeHoverAction"),onEdgeCreate:U("onEdgeCreate"),onEdgeSelect:U("onEdgeSelect"),onEdgeDeselect:U("onEdgeDeselect"),onEdgeRemove:U("onEdgeRemove"),onEdgeDelete:U("onEdgeDelete"),onEdgeColorChange:U("onEdgeColorChange"),onEdgeTypeChange:U("onEdgeTypeChange"),onEdgeIconChange:U("onEdgeIconChange"),onEdgeLabelChange:U("onEdgeLabelChange"),onEdgeStyleChange:U("onEdgeStyleChange"),onViewportChange:U("onViewportChange"),onDirectionChange:U("onDirectionChange"),onThemeColorChange:U("onThemeColorChange"),onSpacingChange:U("onSpacingChange"),onEdgeRadiusChange:U("onEdgeRadiusChange"),onBackgroundVariantChange:U("onBackgroundVariantChange"),onEdgeModeChange:U("onEdgeModeChange"),onCompactPropertyLayoutChange:U("onCompactPropertyLayoutChange"),onWorkflowContractChange:U("onWorkflowContractChange"),onWorkflowConfigurationOpen:r.onWorkflowConfigurationOpen?U("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:U("onArrayModeChange"),onInit:U("onInit"),onLayoutComplete:U("onLayoutComplete"),onJsonChange:U("onJsonChange")}},[]),nt=e.themeColor||ct,[lt,zt]=j.useState(""),kt=e.edgeColor??lt,et=e.colorMode||"light",We=e.direction||"LR",Ht=e.nodeAlignment??"center",dt=e.edgeMode==="workflow"?"nodes":e.edgeMode??I,tr=e.readOnly??!1,ar=JSON.stringify(e.parentNodeStyle??null),Bt=j.useMemo(()=>e.parentNodeStyle,[ar]),Dt=e.isZoomMode!==void 0?e.isZoomMode:u,Kt=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,rr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,$r=e.isDragMode!==void 0?e.isDragMode:y,ze=j.useRef(e);ze.current=e;const ce=j.useMemo(()=>({get direction(){return ze.current.direction},get nodeAlignment(){return ze.current.nodeAlignment},get edgeMode(){return ze.current.edgeMode},get compactPropertyLayout(){return ze.current.compactPropertyLayout},get bottomBarCollapsed(){return ze.current.bottomBarCollapsed},get bottomBarNavigation(){return ze.current.bottomBarNavigation},get bottomBarFill(){return ze.current.bottomBarFill},get bottomBarCollision(){return ze.current.bottomBarCollision},get nodeGridConnections(){return ze.current.nodeGridConnections},get nodeGrid(){return ze.current.nodeGrid},get edgeType(){return ze.current.edgeType},get edgeReveal(){return ze.current.edgeReveal},get customEdgeTypes(){return ze.current.customEdgeTypes},get themeColor(){return ze.current.themeColor},get colorMode(){return ze.current.colorMode},get readOnly(){return ze.current.readOnly},get editable(){return ze.current.editable},get minZoom(){return ze.current.minZoom},get nodeGridSpacing(){return ze.current.nodeGridSpacing},get maxZoom(){return ze.current.maxZoom},get backgroundPattern(){return ze.current.backgroundPattern},get edgeColor(){return ze.current.edgeColor},get parentNodeStyle(){return ze.current.parentNodeStyle},get backgroundColor(){return ze.current.backgroundColor},get edgeHandles(){return ze.current.edgeHandles},get initialViewport(){return ze.current.initialViewport},get animateViewport(){return ze.current.animateViewport},get disableAnimations(){return ze.current.disableAnimations},get nodeOverlayActions(){return ze.current.nodeOverlayActions},get renderNodeOverlay(){return ze.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return ze.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return ze.current.renderSelectedEdgeToolbar},get renderBottomBar(){return ze.current.renderBottomBar},get bottomBarExtra(){return ze.current.bottomBarExtra},get selectionToolbar(){return ze.current.selectionToolbar},get customViews(){return ze.current.customViews},get disableKeyboardShortcuts(){return ze.current.disableKeyboardShortcuts},get isZoomMode(){return ze.current.isZoomMode},get isMultiSelectMode(){return ze.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return ze.current.isEdgeHandlesEnabled},get isDragMode(){return ze.current.isDragMode}}),[]),B=j.useCallback((U,ge)=>{var Ie;if(ge!=="default"&&ge!=="properties"&&ge!=="icon-label")throw new Error("Unknown node view mode.");G(xe=>xe??Ce),be(xe=>xe[U]===ge?xe:{...xe,[U]:ge}),(Ie=r.onNodeViewModeChange)==null||Ie.call(r,U,ge)},[r.onNodeViewModeChange,Ce]),oe=j.useMemo(()=>({allNodesIconLabel:Ce,setAllNodesIconLabel:U=>{var ge,Ie,xe,Ze,Qe;if(G(U),!U)for(const[Ke,vt]of Object.entries(L))vt==="icon-label"&&!i.nodeById.has(Ke)&&B(Ke,"default");for(const Ke of le)i.parentIds.has(Ke.data.id)||(ge=Ke.data.config)!=null&&ge.parentContainer?!tr&&!!((Ie=Ke.data.config)!=null&&Ie.collapsed)!==U&&((xe=r.onNodeCollapse)==null||xe.call(r,Ke.data.id,U)):B(Ke.data.id,U?"icon-label":(Ze=Ke.data.config)!=null&&Ze.labelBelow?"properties":"default");(Qe=r.onAllNodesIconLabelChange)==null||Qe.call(r,U)},nodeViewModes:L,setNodeViewMode:B,nodeRadiusPreviews:D,setNodeRadiusPreview:X,spacing:Ee,setSpacing:pe,edgeRadius:we,setEdgeRadius:Y,backgroundVariant:Ae,setBackgroundVariant:ve,themeColor:nt,setThemeColor:De,backgroundSelected:rt,setBackgroundSelected:ft,edgeColor:kt,setEdgeColor:U=>{var ge;zt(U),(ge=r.onGraphEdgeColorChange)==null||ge.call(r,U)},colorMode:et,direction:We,nodeAlignment:Ht,edgeMode:dt,setEdgeMode:W,compactPropertyLayout:re,setCompactPropertyLayout:ae,workflowContract:Fe,setWorkflowContract:Je,parentNodeStyle:Bt,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isZoomMode:Dt,setIsZoomMode:h,isMultiSelectMode:Kt,setIsMultiSelectMode:m,isDragMode:$r,setIsDragMode:g,isEdgeHandlesEnabled:rr,setIsEdgeHandlesEnabled:v,isArrayNodeMode:x,setIsArrayNodeMode:w,isPinned:C,setIsPinned:S,isPerformanceMode:_,setIsPerformanceMode:k,nodeGridOptions:E,setNodeGridOptions:$,lastNodeGridOptions:A,fillRadiusEditedIds:T,setFillRadiusEditedIds:N,engineRef:s,callbacks:Xe,config:ce,readOnly:tr}),[Ce,i,B,r.onNodeCollapse,r.onAllNodesIconLabelChange,r.onGraphEdgeColorChange,L,r.onNodeViewModeChange,D,X,nt,Ee,Ae,we,e.backgroundColor,rt,kt,et,We,Ht,dt,Fe,Bt,a,l,Dt,Kt,$r,rr,x,C,_,E,A,T,tr,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.disableAnimations,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.bottomBarNavigation,e.bottomBarFill,e.bottomBarCollision,e.nodeGridSpacing,e.nodeGridConnections,e.compactPropertyLayout,re,Xe,ce]);return f.jsx(Am.Provider,{value:oe,children:f.jsx(Pm.Provider,{value:i,children:o})})}function wt(e,r,t){return e?t:r}function Nn(e){const[r]=(e==null?void 0:e.split("."))||[],{secondary:t}=km(e),n=Xt(r).background,o=Xt(r).highlight,i=Xt(r).border,s=Xt(r).property,a=Xt(r).property;let c=Xt(r).background,l=Xt(r).highlight;return c=e==="transparent"?e:Pe(c)+50,l=e==="transparent"?e:Pe(l)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:s,propertyColor:a,secondary:t,bgColorFaint:c,highlightColorFaint:l}}function st(e=null){const{colorMode:r}=He(),t=e==null?void 0:e.includes("gray"),n=r==="dark",o=wt(n,"white","gray.900"),i=wt(n,"gray.100","gray.800"),s=wt(n,"gray.200","blackAlpha.400"),a=wt(n,"gray.200","blackAlpha.600"),c=wt(n,"gray.500","gray.700"),l=wt(n,"gray.700","gray.700"),d=wt(n,"gray.900","gray.900"),u=wt(n,"gray.400","gray.500"),h=wt(n,"gray.400","gray.500"),p=wt(n,"gray.900","gray.200"),m=wt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),y=wt(n,"gray.900","gray.200"),g=wt(n,e&&"#000000",e||"#ffffff"),b=wt(n,e||"#ffffff",e?"#000000":"#ffffff"),v=l,x=wt(n,"gray.300","gray.800"),w=wt(n,"white","blackAlpha.400"),C=wt(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:d,backgroundWhiteColor:w,borderSecondary:l,colorActive:u,colorInactive:h,iconColor:y,moreIconColor:v,colorText:p,themedColorText:m,logoColor:g,logoColorSecondary:b,darkColorActive:x,greenColor:C}}var hn=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(hn||{});const wd=["","icon-label","object","text","grid","parent"];var Ex=typeof global=="object"&&global&&global.Object===Object&&global,kx=typeof self=="object"&&self&&self.Object===Object&&self,Rx=Ex||kx||Function("return this")(),Wr=Rx.Symbol,Im=Object.prototype,Ax=Im.hasOwnProperty,Px=Im.toString,un=Wr?Wr.toStringTag:void 0;function Mx(e){var r=Ax.call(e,un),t=e[un];try{e[un]=void 0;var n=!0}catch{}var o=Px.call(e);return n&&(r?e[un]=t:delete e[un]),o}var Ix=Object.prototype,Tx=Ix.toString;function Ox(e){return Tx.call(e)}var Nx="[object Null]",$x="[object Undefined]",Su=Wr?Wr.toStringTag:void 0;function qx(e){return e==null?e===void 0?$x:Nx:Su&&Su in Object(e)?Mx(e):Ox(e)}function Lx(e){return e!=null&&typeof e=="object"}var Fx="[object Symbol]";function zx(e){return typeof e=="symbol"||Lx(e)&&qx(e)==Fx}function Bx(e,r){for(var t=-1,n=e==null?0:e.length,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o}var tt=Array.isArray,ju=Wr?Wr.prototype:void 0,_u=ju?ju.toString:void 0;function Tm(e){if(typeof e=="string")return e;if(tt(e))return Bx(e,Tm)+"";if(zx(e))return _u?_u.call(e):"";var r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function Cd(e){return e==null?"":Tm(e)}function Dx(e,r,t){var n=-1,o=e.length;r<0&&(r=-r>o?0:o+r),t=t>o?o:t,t<0&&(t+=o),o=r>t?0:t-r>>>0,r>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+r];return i}function Vx(e,r,t){var n=e.length;return t=t===void 0?n:t,!r&&t>=n?e:Dx(e,r,t)}var Wx="\\ud800-\\udfff",Gx="\\u0300-\\u036f",Ux="\\ufe20-\\ufe2f",Hx="\\u20d0-\\u20ff",Kx=Gx+Ux+Hx,Jx="\\ufe0e\\ufe0f",Zx="\\u200d",Yx=RegExp("["+Zx+Wx+Kx+Jx+"]");function Om(e){return Yx.test(e)}function Xx(e){return e.split("")}var Nm="\\ud800-\\udfff",Qx="\\u0300-\\u036f",e0="\\ufe20-\\ufe2f",t0="\\u20d0-\\u20ff",r0=Qx+e0+t0,n0="\\ufe0e\\ufe0f",o0="["+Nm+"]",dd="["+r0+"]",ud="\\ud83c[\\udffb-\\udfff]",i0="(?:"+dd+"|"+ud+")",$m="[^"+Nm+"]",qm="(?:\\ud83c[\\udde6-\\uddff]){2}",Lm="[\\ud800-\\udbff][\\udc00-\\udfff]",a0="\\u200d",Fm=i0+"?",zm="["+n0+"]?",s0="(?:"+a0+"(?:"+[$m,qm,Lm].join("|")+")"+zm+Fm+")*",c0=zm+Fm+s0,l0="(?:"+[$m+dd+"?",dd,qm,Lm,o0].join("|")+")",d0=RegExp(ud+"(?="+ud+")|"+l0+c0,"g");function u0(e){return e.match(d0)||[]}function f0(e){return Om(e)?u0(e):Xx(e)}function h0(e){return function(r){r=Cd(r);var t=Om(r)?f0(r):void 0,n=t?t[0]:r.charAt(0),o=t?Vx(t,1).join(""):r.slice(1);return n[e]()+o}}var p0=h0("toUpperCase");function g0(e,r,t,n){for(var o=-1,i=e==null?0:e.length;++o<i;)t=r(t,e[o],o,e);return t}function y0(e){return function(r){return e==null?void 0:e[r]}}var m0={À:"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"},b0=y0(m0),v0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,x0="\\u0300-\\u036f",w0="\\ufe20-\\ufe2f",C0="\\u20d0-\\u20ff",S0=x0+w0+C0,j0="["+S0+"]",_0=RegExp(j0,"g");function E0(e){return e=Cd(e),e&&e.replace(v0,b0).replace(_0,"")}var k0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function R0(e){return e.match(k0)||[]}var A0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function P0(e){return A0.test(e)}var Bm="\\ud800-\\udfff",M0="\\u0300-\\u036f",I0="\\ufe20-\\ufe2f",T0="\\u20d0-\\u20ff",O0=M0+I0+T0,Dm="\\u2700-\\u27bf",Vm="a-z\\xdf-\\xf6\\xf8-\\xff",N0="\\xac\\xb1\\xd7\\xf7",$0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",q0="\\u2000-\\u206f",L0=" \\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",Wm="A-Z\\xc0-\\xd6\\xd8-\\xde",F0="\\ufe0e\\ufe0f",Gm=N0+$0+q0+L0,Um="['’]",Eu="["+Gm+"]",z0="["+O0+"]",Hm="\\d+",B0="["+Dm+"]",Km="["+Vm+"]",Jm="[^"+Bm+Gm+Hm+Dm+Vm+Wm+"]",D0="\\ud83c[\\udffb-\\udfff]",V0="(?:"+z0+"|"+D0+")",W0="[^"+Bm+"]",Zm="(?:\\ud83c[\\udde6-\\uddff]){2}",Ym="[\\ud800-\\udbff][\\udc00-\\udfff]",qr="["+Wm+"]",G0="\\u200d",ku="(?:"+Km+"|"+Jm+")",U0="(?:"+qr+"|"+Jm+")",Ru="(?:"+Um+"(?:d|ll|m|re|s|t|ve))?",Au="(?:"+Um+"(?:D|LL|M|RE|S|T|VE))?",Xm=V0+"?",Qm="["+F0+"]?",H0="(?:"+G0+"(?:"+[W0,Zm,Ym].join("|")+")"+Qm+Xm+")*",K0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",J0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Z0=Qm+Xm+H0,Y0="(?:"+[B0,Zm,Ym].join("|")+")"+Z0,X0=RegExp([qr+"?"+Km+"+"+Ru+"(?="+[Eu,qr,"$"].join("|")+")",U0+"+"+Au+"(?="+[Eu,qr+ku,"$"].join("|")+")",qr+"?"+ku+"+"+Ru,qr+"+"+Au,J0,K0,Hm,Y0].join("|"),"g");function Q0(e){return e.match(X0)||[]}function ew(e,r,t){return e=Cd(e),r=r,r===void 0?P0(e)?Q0(e):R0(e):e.match(r)||[]}var tw="['’]",rw=RegExp(tw,"g");function nw(e){return function(r){return g0(ew(E0(r).replace(rw,"")),e,"")}}var $t=nw(function(e,r,t){return e+(t?" ":"")+p0(r)});function ow(){let e,r=null;const t=new Set,n=o=>{r=o,t.forEach(i=>i())};return{subscribe:o=>(t.add(o),()=>{t.delete(o)}),getSnapshot:()=>r,select(o,i){e=o,n(i)},update(o,i){e===o&&n(i)},remove(o){e===o&&(e=void 0,n(null))}}}const Gr=j.createContext(null),iw=()=>j.useState(ow)[0];function co(e,r=!0){const t=j.useContext(Gr),n=j.useId();return j.useEffect(()=>{r?t==null||t.update(n,e):t==null||t.remove(n)}),j.useEffect(()=>()=>t==null?void 0:t.remove(n),[t,n]),()=>{r&&(t==null||t.select(n,e))}}function aw({divider:e,visibleActions:r=[]}){const t=j.useContext(Gr),n=j.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null),o=n&&r.includes(n.props["aria-label"]??"");return f.jsx(Gr.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:n&&!o?"contents":"none"},children:[n&&!o&&e,!o&&n]})})}function Ue({label:e,children:r}){const t=j.cloneElement(r,{title:r.props.title??e});if(!V.Tooltip.Root){const n=V.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:t})}return f.jsxs(V.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(V.Tooltip.Trigger,{asChild:!0,children:t}),f.jsx(V.Portal,{children:f.jsx(V.Tooltip.Positioner,{children:f.jsx(V.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function xn(){const{border:e}=st(),{colorMode:r}=He();return f.jsx(V.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:r==="dark"?e:"gray.300"})}function At({children:e,value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,labelCase:l="title","aria-label":d,...u}){var M;const{colorMode:h}=He(),{background:p,border:m,colorText:y,colorInactive:g}=st(),b=h==="dark",v=j.useId(),x=j.useRef(null),w=j.useRef(null),[C,S]=j.useState(!1),_=co(f.jsx(At,{value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,labelCase:l,"aria-label":d,children:e}),!!s);j.useEffect(()=>{const T=w.current;T.setAttribute("popover","auto");const N=$=>S($.newState==="open");return T.addEventListener("toggle",N),()=>T.removeEventListener("toggle",N)},[]);const k=j.Children.toArray(e).filter(j.isValidElement).map(T=>{const N=T.props;return{value:String(N.value),label:typeof N.children=="string"&&l==="title"?$t(N.children):N.children,disabled:N.disabled}}),E=()=>{var T;return(T=w.current)==null?void 0:T.hidePopover()},O=()=>{var ie,ae,re,ye,be;const T=(ie=x.current)==null?void 0:ie.getBoundingClientRect(),N=w.current;if(!T||!N)return;if((ae=x.current)!=null&&ae.closest("[popover]")){const L=window.innerHeight-T.bottom-16,z=T.top-16;N.style.maxHeight=`${Math.max(60,L,z)}px`;const G=N.getBoundingClientRect();N.style.left=`${Math.max(12,Math.min(T.right-G.width,window.innerWidth-G.width-12))}px`,N.style.top=`${Math.max(12,G.height<=L?T.bottom+4:T.top-G.height-4)}px`;return}const $=(be=(ye=(re=x.current)==null?void 0:re.closest("[data-flow-toolbar-scroll]"))==null?void 0:ye.parentElement)==null?void 0:be.getBoundingClientRect(),I=$??T;N.style.maxHeight=`${Math.max(60,Math.max(I.top-40,window.innerHeight-I.bottom-40))}px`;const W=N.getBoundingClientRect();N.style.left=`${Math.max(12,Math.min(Math.max(($==null?void 0:$.left)??12,T.right-W.width),(($==null?void 0:$.right)??window.innerWidth-12)-W.width,window.innerWidth-W.width-12))}px`,N.style.top=`${Math.max(12,I.top>=W.height+36?I.top-W.height-24:Math.min(I.bottom+24,window.innerHeight-W.height-12))}px`},P=()=>{var $,I,W,ie,ae,re;if(n)return;if(($=w.current)==null||$.showPopover(),O(),a){(W=(I=w.current)==null?void 0:I.querySelector("input"))==null||W.focus({preventScroll:!0});return}const T=(ie=w.current)==null?void 0:ie.querySelectorAll('[role="option"]:not(:disabled)');(re=((ae=w.current)==null?void 0:ae.querySelector('[aria-selected="true"]:not(:disabled)'))??(T==null?void 0:T[0]))==null||re.focus()};j.useEffect(()=>{if(C){if(n){E();return}return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}}},[C,n]);const A=`var(--chakra-colors-${p.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(Ue,{label:i??d,children:f.jsx(V.chakra.button,{...u,ref:x,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":d,title:i??d,"aria-haspopup":a?"dialog":"listbox","aria-expanded":C,"aria-controls":v,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?g:y,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:o,onClick:()=>{_(),C?E():P()},onKeyDown:T=>{["ArrowDown","ArrowUp"].includes(T.key)&&(T.preventDefault(),P())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((M=k.find(T=>T.value===r))==null?void 0:M.label)??r}),f.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(V.chakra.div,{ref:w,id:v,role:a?"dialog":"listbox","aria-label":d,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:p,color:y,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},'& [role="option"]':ro,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...gr(A,`var(--chakra-colors-${(b?m:"gray.300").replace(".","-")})`)},onKeyDown:T=>{var I,W,ie;if(a&&!["Escape","Tab"].includes(T.key))return;const N=[...T.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],$=N.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(T.key)){T.preventDefault();const ae=T.key==="Home"?0:T.key==="End"?N.length-1:($+(T.key==="ArrowDown"?1:-1)+N.length)%N.length;(I=N[ae])==null||I.focus()}else T.key==="Escape"||T.key==="Tab"?(T.key==="Escape"&&(T.preventDefault(),T.stopPropagation()),E(),(W=x.current)==null||W.focus()):T.key.length===1&&T.key!==" "&&((ie=N.find((ae,re)=>{var ye;return re>$&&((ye=ae.textContent)==null?void 0:ye.toLowerCase().startsWith(T.key.toLowerCase()))}))==null||ie.focus())},children:[a??k.map(T=>f.jsxs(V.chakra.button,{type:"button",role:"option","aria-selected":T.value===r,disabled:T.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",fontSize:"sm",textAlign:"left",bg:"transparent",color:y,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var N;E(),(N=x.current)==null||N.focus(),t(T.value)},children:[f.jsx("span",{style:{flex:1},children:T.label}),f.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${y.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:T.value===r?"visible":"hidden"}})]},T.value)),c]})]})}const ro={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Ne=j.forwardRef(function({icon:r,rememberAction:t=!0,...n},o){const{colorMode:i}=He(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=co(f.jsx(Ue,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Ne,{...s,icon:r})}),t&&!!n.onClick);return f.jsx(V.IconButton,{ref:o,_hover:{bg:i==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var l;a(),(l=n.onClick)==null||l.call(n,c)},children:r})}),Yr=j.forwardRef(function(r,t){const{themeColor:n}=He();return f.jsx(Ue,{label:"Close",children:f.jsx(Ne,{ref:t,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...r,"aria-label":r["aria-label"]??"Close selection tools",icon:f.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})});function eb({onBeforeExpand:e}={}){const{allNodesIconLabel:r,setAllNodesIconLabel:t}=He();return f.jsx(Ur,{label:"Collapse all",hideLabel:!0,checked:r,icon:f.jsx(Z.PiArrowsInLineVertical,{size:20}),onChange:n=>{n||e==null||e(),t(n)}})}function Ur({label:e,icon:r,checked:t,onChange:n,disabled:o,hideLabel:i=!1,helper:s=e}){const{themeColor:a,readOnly:c}=He(),{colorInactive:l}=st();return f.jsx(Ue,{label:s,children:f.jsx(Ne,{"aria-label":e,"aria-pressed":t,icon:f.jsxs(f.Fragment,{children:[r,!i&&f.jsx(V.Text,{as:"span",fontSize:"16px",fontWeight:t?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:t?a:l,disabled:o||c,onClick:()=>n(!t)})})}function tb({label:e="Compact layout"}={}){const{compactPropertyLayout:r,setCompactPropertyLayout:t,callbacks:n}=He();return f.jsx(Ur,{hideLabel:!0,label:e,checked:r,icon:f.jsx(V.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:o=>{var i;t(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const sw=so.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
|
-
`,Sd=j.forwardRef(function({style:r,...t},n){return f.jsx(sw,{...t,ref:n,style:{...r,backgroundImage:"none","--flow-range-track":(r==null?void 0:r.backgroundImage)??"none"}})});function fd({label:e,inputLabel:r,value:t,displayValue:n,min:o,max:i,step:s=5,onChange:a,onChangeEnd:c}){const l=j.useId(),{readOnly:d,themeColor:u}=He(),{colorInactive:h}=st(),p=(t-o)/(i-o)*100,m=u.includes(".")?`var(--chakra-colors-${u.replace(".","-")})`:u;return f.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[f.jsxs("label",{htmlFor:l,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(Sd,{id:l,"aria-label":r,type:"range",min:o,max:i,step:s,value:t,disabled:d,style:{color:m,accentColor:m,backgroundImage:`linear-gradient(to right, currentColor ${p}%, var(--chakra-colors-${h.replace(".","-")}) ${p}%)`},onChange:y=>a(Number(y.target.value)),onPointerUp:c,onKeyUp:c,onBlur:c})]})}const Pu={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 rb(){const{spacing:e,setSpacing:r,edgeRadius:t,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:s,readOnly:a,config:c}=He(),l=Pu[o].icon;return f.jsxs(f.Fragment,{children:[f.jsx(xn,{}),f.jsx(At,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(fd,{label:"Spacing",inputLabel:"Node spacing percentage",min:c.nodeGridSpacing==="layout"?0:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:d=>{var u;r(d/100),(u=s.onSpacingChange)==null||u.call(s,d/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(xn,{}),f.jsx(At,{"aria-label":"Edge radius",title:`Edge radius: ${t??"Default"}`,icon:f.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(fd,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:t??500,displayValue:t??"Default",onChange:d=>{var u;n(d),(u=s.onEdgeRadiusChange)==null||u.call(s,d)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(xn,{}),f.jsxs(At,{"aria-label":"Background variant",title:`Background: ${Pu[o].label}`,icon:f.jsx(l,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:a,onValueChange:d=>{var u;i(d),(u=s.onBackgroundVariantChange)==null||u.call(s,d)},children:[f.jsx("option",{value:"dot",children:"Dots"}),f.jsx("option",{value:"grid",children:"Grid"}),f.jsx("option",{value:"steel",children:"Steel"}),f.jsx("option",{value:"none",children:"Solid"}),f.jsx("option",{value:"transparent",children:"Transparent"})]})]})}function nb(){var o;const{engineRef:e,nodeGridOptions:r,readOnly:t}=He(),n=!!(r!=null&&r.fill);return f.jsx(Ur,{label:"Grid adjustment",hideLabel:!0,helper:n?"Grid adjustment":"Enable Collision and Fill to adjust the Grid",icon:f.jsx(Z.PiArrowsHorizontal,{size:20}),checked:n&&!!((o=r==null?void 0:r.adjustment)!=null&&o.enabled),disabled:!n,onChange:i=>{var s;t||!(r!=null&&r.fill)||(s=e.current)==null||s.setNodeGridMode(!0,{...r,adjustment:{...r.adjustment,enabled:i}})}})}function zo(){const{engineRef:e,nodeGridOptions:r,lastNodeGridOptions:t,readOnly:n,themeColor:o,callbacks:i,config:s}=He(),{colorText:a,colorInactive:c}=st(),l=r??t,d=typeof l.gaps=="object"?l.gaps.x:l.gaps??l.margin??15,u=Math.max(200,d),h=p=>{var m;return(m=e.current)==null?void 0:m.setNodeGridMode(!0,{...l,...p})};return f.jsxs(f.Fragment,{children:[s.bottomBarCollision!==!1&&f.jsx(Ur,{label:"Collision mode",hideLabel:!0,icon:f.jsx(Z.PiGridFour,{size:20}),checked:r!==null,onChange:p=>{var m,y;((m=i.onNodeGridModeRequest)==null?void 0:m.call(i,p,l))!==!0&&((y=e.current)==null||y.setNodeGridMode(p,l))}}),(r||s.bottomBarFill===!0)&&f.jsxs(V.HStack,{role:"group","aria-label":"Collision settings",gap:2,flexShrink:0,children:[r&&s.nodeGridSpacing!=="layout"&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{width:"96px",flexShrink:0,display:"flex",alignItems:"center",children:f.jsx(Sd,{type:"range","aria-label":"Collision gap",title:`Gap: ${d}`,min:0,max:u,step:5,value:d,disabled:n,style:{color:Pe(o),backgroundImage:`linear-gradient(to right, currentColor ${d/u*100}%, ${Pe(c)} ${d/u*100}%)`},onChange:p=>h({gaps:Number(p.target.value)})})}),f.jsx(V.Text,{fontSize:"xs",color:a,width:"28px",textAlign:"right",fontVariantNumeric:"tabular-nums",children:d})]}),s.bottomBarFill!==!1&&f.jsx(Ur,{label:"Fill",hideLabel:!0,helper:r?"Fill available canvas space":"Enable Collision mode to use Fill",icon:f.jsx(Z.PiArrowsOut,{size:18}),checked:!!r&&!!l.fill,disabled:!r,onChange:p=>{var m,y;!r&&((m=i.onNodeGridModeRequest)==null?void 0:m.call(i,!0,{...l,fill:p}))===!0||p&&((y=i.onNodeGridFillRequest)==null?void 0:y.call(i,{...l,fill:p}))===!0||h({fill:p})}}),r&&l.fill&&f.jsx(nb,{})]})]})}const Ct=[];for(let e=0;e<256;++e)Ct.push((e+256).toString(16).slice(1));function cw(e,r=0){return(Ct[e[r+0]]+Ct[e[r+1]]+Ct[e[r+2]]+Ct[e[r+3]]+"-"+Ct[e[r+4]]+Ct[e[r+5]]+"-"+Ct[e[r+6]]+Ct[e[r+7]]+"-"+Ct[e[r+8]]+Ct[e[r+9]]+"-"+Ct[e[r+10]]+Ct[e[r+11]]+Ct[e[r+12]]+Ct[e[r+13]]+Ct[e[r+14]]+Ct[e[r+15]]).toLowerCase()}let Bo;const lw=new Uint8Array(16);function dw(){if(!Bo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Bo=crypto.getRandomValues.bind(crypto)}return Bo(lw)}const uw=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Mu={randomUUID:uw};function jd(e,r,t){var o;if(Mu.randomUUID&&!e)return Mu.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??dw();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,cw(n)}const lo={label:"Untitled",description:"",isTask:!1,isLocked:!1},_d={id:null,type:"text",data:{...lo,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"}}},Iu={id:null,type:"objectView",data:{...lo,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},fw={id:null,type:"arrayView",data:{...lo,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"}}},Tu={id:null,type:"workflowStep",data:{...lo,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},Pt=e=>typeof e=="object",ob=e=>Array.isArray(e),hw=["order","position","selected","locked","grabbed","grabbable","scratch"],yr=e=>Object.entries(e).reduce((r,[t,n])=>(!Pt(n)&&!t.startsWith("$")&&(r[t]=n),r),{}),Ed=(e,r)=>typeof e=="string"&&e.startsWith("$")?Do(e,r):Pt(e)&&!ob(e)?Object.entries(e).reduce((t,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...Do(o,r),...e}):typeof o=="string"&&o.startsWith("$")?t[n]=Do(o,r):t[n]=o,t),{}):e,mr=e=>Object.entries(e).reduce((r,[t,n])=>(Pt(n)&&t&&n&&!t.startsWith("$")&&(hw.includes(t)&&(t=t+"#"),r[t]=n),r),{}),kr=(e,r,{label:t,parent:n=void 0},o,i=null)=>(i!==null&&(Pt(i)||ob(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:r,text:t||"",label:t,code:i||null,type:e.type,description:o}}),fr=(e,r,t=null,n=null,o=null,i=!1,s=null)=>({data:{id:jd(),source:o?r:e,target:o?e:r,label:n||"",isInverted:o,isEdgeAnimated:i,parent:s}}),br=(e,r=[])=>{const t={},n={};let o=[];if(e)for(const[i,s]of Object.entries(e))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=s:i!=="$"?n[i]=s:i==="$"&&(o=s);return{newConfig:t,updatedObject:n,arrayObject:o}},Lr=(e,r)=>{let t=Iu;const{view:n,borderColor:o,borderRadius:i,bgColor:s,textColor:a,fontSize:c,stepType:l}=r;e=n||e,l?t={...Tu}:e==="object"?t=Iu:e==="text"?t=_d:e==="array"?t=fw:e==="workflowStep"&&(t={...Tu});const d=t.data.viewProps;return t.data.viewProps={...d,borderRadius:i||(l?15:53),bgColor:s,borderColor:o,textColor:a,fontSize:c},t.data.config=r,{config:t}},An=(e,r)=>(e=r.find(n=>n.data.id===e)?`${e}.#`:e,e),Do=(e,{ids:r,jsnObjct:t})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=r.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!o)return e;const i=pw(o,t);return JSON.stringify(i).includes(e)?e:i||e}return e},pw=(e,r)=>{let t=e.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=br(s);return s=c.length?c:s,s[a]},i))(r)};function zr(e,r="root",t=[]){try{const{arrayObject:n}=br(e);n.length&&(e=n);const o=yr(e),i=mr(e);return Pt(e)?(tt(e)||tt(e)&&r==="root"||!tt(e)&&Object.keys(o).length||r==="root")&&t.push(r):t.push(r),Object.keys(i).length&&!tt(e)?wn({chldPth:null,itrblObjct:i,nodes:t,path:r}):tt(e)&&e.forEach((s,a)=>{const c=yr(s),l=mr(s),{newConfig:d,arrayObject:u}=br(s);let h=`${r}.${a}`;Pt(s)?Object.keys(c).length?(zr(c,h,t),Object.keys(l).length&&!tt(s)&&wn({chldPth:h,itrblObjct:l,nodes:t,path:r})):Object.keys(l).length&&!tt(s)?wn({chldPth:h,itrblObjct:l,nodes:t,path:r}):tt(s)&&ib({chldPth:h,item:s,nodes:t,path:r}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const wn=({chldPth:e,itrblObjct:r,nodes:t,path:n})=>Object.entries(r).forEach(([o,i],s)=>{const a=yr(i),c=mr(i),{newConfig:l,arrayObject:d}=br(i);d.length&&(i=d),n.split(".").slice(0,2).join(".");let u=e?`${e}.${o}`:`${n}.${o}`;if(Pt(i)&&!tt(i)){const h=Object.keys(a).length===0;if(h&&(Lr("array",l),t.push(u)),Object.keys(a).length){const p=tt(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let m=u;h&&(m=`${u}.${p}`),zr(i,m,t)}else Object.keys(c).length&&!tt(i)?wn({chldPth:u,itrblObjct:c,path:u,nodes:t}):zr(i,u,t)}else tt(i)&&zr(i,u,t)}),ib=({chldPth:e,item:r,nodes:t,path:n})=>r.forEach((o,i)=>{let s=`${e}.${i}`;const a=mr(o),c=yr(o);Pt(o)?!tt(o)&&Object.keys(c).length?zr(o,s,t):Object.keys(a).length&&!tt(o)?wn({chldPth:s,itrblObjct:a,path:n,nodes:t}):tt(o)&&ib({chldPth:s,item:o,nodes:t,path:n}):t.push(s)}),Cn=[];let Sn;function Pr(e,r="root",t=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:t,edges:n};const a=e;if(r==="root"&&(Cn.length=0),!Sn){const{nodes:d}=zr(e);Sn={ids:d,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:l}=i;try{r=An(r,t);const{newConfig:d,arrayObject:u}=br(e),h=Object.keys(s).length>0?s:d;u.length&&(e=u);const p=yr(e),m=mr(e),{label:y,collapsed:g,parent:b}=h;if(!Pt(e))t.push(kr(_d,r,{label:y||r,parent:b},e,a));else if(tt(e)||tt(e)&&r==="root"){const{config:v}=Lr("array",h),x=tt(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r==="root"?o:`${o} ${x}`;t.push(kr(v,r,{label:y||w,parent:b},e,tt(a)?{[o]:a}:a))}else if(!tt(e)&&Object.keys(p).length||r==="root"){const{config:v}=Lr(null,h),x=tt(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r.split("."),C=w[w.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const _=isNaN(Number(C))?C:w[w.length-2]+" "+S,k=r==="root"?o:_;let E=!1;Number.isNaN(Number(o))||(E=!0);const O=e;if(y){const{config:P}=Lr("object",h);t.push(kr(P,r,{label:y||`${y} ${x}`,parent:b},p,O))}else v.data.headerTitle=k,t.push(kr(v,r,{label:y,parent:b},p,O))}return g||(Object.keys(m).length&&!tt(e)?jn({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:m,nodes:t,path:r,newConfig:h}):tt(e)&&e.forEach((v,x)=>{v=Ed(v,Sn);const w=v,C=yr(v),S=mr(v),{newConfig:_,arrayObject:k}=br(v);k.length&&(v=k);const{config:E}=Lr(typeof v=="string"?"text":"array",_),{hideConfig:O,sourceLabel:P,label:A,isEdgeAnimated:M,parent:T}=_;c=c||O;const N=r==="root"&&i.isCntr,$=r.split(".").slice(0,2).join("."),I=Cn.includes($),W=i.isCntr&&I||x%2===0&&N;let ie=`${r}.${x}`;ie=An(ie,t),W&&Cn.push(ie),Pt(v)?Object.keys(C).length&&!tt(v)?(n.push(fr(r,ie,null,P,W,M)),Pr(v,ie,t,n,A||x,i,_)):Object.keys(S).length&&!tt(v)?jn({flowConfig:i,chldPth:ie,isInverted:W,edges:n,itrblObjct:S,nodes:t,path:r,newConfig:_,forceIsInverted:!0}):tt(v)?ab({flowConfig:i,chldPth:ie,edges:n,isInverted:W,item:v,nodes:t,path:r}):Pt(v)&&jn({flowConfig:i,chldPth:ie,isInverted:W,edges:n,itrblObjct:[v],nodes:t,path:r,newConfig:_}):(n.push(fr(r,ie,null,P,W,M)),t.push(kr(E,ie,{label:A||String(v),parent:T},v,w)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const jn=({chldPth:e,flowConfig:r,edges:t,itrblObjct:n,nodes:o,isInverted:i,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:l,sprtObjctKy:d}=r;return Object.entries(n).forEach(([u,h],p)=>{h=Ed(h,Sn);const m=h,y=yr(h),g=mr(h),{newConfig:b,arrayObject:v}=br(h);v.length&&(h=v);const{hideConfig:x,sourceLabel:w,label:C,content:S,target:_,targetLabel:k,collapsed:E,isEdgeAnimated:O,parent:P}=b;l=l||x;const A=s==="root"&&r.isCntr,M=s.split(".").slice(0,2).join("."),T=Cn.includes(M);c||(i=r.isCntr&&T||p%2===0&&A);let N=e?`${e}.${u}`:`${s}.${u}`;if(N=An(N,o),i&&Cn.push(N),_&&t.push(fr(N,_,null,k,i,O)),Pt(h)&&!tt(h)){t.push(fr(s,N,null,w,i,O));const $=d||Object.keys(y).length===0;if($){const I=S?"object":"array",{config:W}=Lr(I,b);W.data.headerTitle=S?C:null,o.push(kr(W,N,{label:C||u,parent:P},h,m))}if(Object.keys(y).length&&!l){const I=tt(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let W=N;$&&(W=`${N}.${I}`,W=An(W,o),t.push(fr(N,W,null,w,i,O))),Pr(h,W,o,t,C||u,r,b)}else Object.keys(g).length&&!tt(h)?jn({chldPth:N,flowConfig:r,itrblObjct:g,path:N,edges:t,nodes:o,newConfig:b,isInverted:i}):Pr(h,N,o,t,u,r,b)}else tt(h)&&(t.push(fr(s,N,null,w,i,O)),Pr(h,N,o,t,u,r,b))})},ab=({flowConfig:e,chldPth:r,edges:t,isInverted:n,item:o,nodes:i,path:s})=>o.forEach((a,c)=>{let l=`${r}.${c}`;l=An(l,i);const d=a;a=Ed(a,Sn);const u=mr(a),h=yr(a),{newConfig:p}=br(a),{collapsed:m,label:y,parent:g,sourceLabel:b,isEdgeAnimated:v,content:x}=p;Pt(a)?!tt(a)&&Object.keys(h).length?(t.push(fr(s,l,null,b,n,v)),Pr(a,l,i,t,c,e,p)):Object.keys(u).length&&!tt(a)&&!m?jn({chldPth:l,flowConfig:e,itrblObjct:u,path:s,edges:t,nodes:i,isInverted:n,newConfig:p}):tt(a)&&ab({flowConfig:e,chldPth:l,edges:t,isInverted:n,item:a,nodes:i,path:s}):(t.push(fr(s,l,null,b,n,v)),i.push(kr(_d,l,{label:y||String(a),parent:g},a,d)))});function gw(e,r){const t=new Set,n=(l,d="root")=>{if(!(!l||typeof l!="object")){l.$view==="parent"&&t.add(d),typeof l.$parent=="string"&&t.add(l.$parent);for(const[u,h]of Object.entries(l))(!u.startsWith("$")||u==="$")&&n(h,u==="$"?d:`${d}.${u}`)}};if(n(e),!t.size)return r;const o=new Map(r.nodes.map(l=>[l.data.id,l])),i=l=>{var p,m;let d=l.data.id;const u=new Set([l.data.id]);let h=l.data.parent;for(;h&&!u.has(h);)t.has(h)&&o.has(h)&&((p=Le(e,h))!=null&&p.$collapsed)&&(d=h),u.add(h),h=(m=o.get(h))==null?void 0:m.data.parent;return d},s=new Map(r.nodes.map(l=>[l.data.id,i(l)])),a=r.nodes.filter(l=>s.get(l.data.id)===l.data.id).map(l=>{if(!t.has(l.data.id))return l;const d=Le(e,l.data.id),u=!!(d!=null&&d.$collapsed);return{...l,data:{...l.data,...u?{type:"arrayView"}:{},config:{...l.data.config,parentContainer:!0,collapsed:u,...u?{labelBelow:!0,icon:(d==null?void 0:d.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(l=>l.data.id));return{nodes:a,edges:r.edges.flatMap(l=>{const d=s.get(l.data.source),u=s.get(l.data.target);return!d||!u||!c.has(d)||!c.has(u)?[]:d===l.data.source&&u===l.data.target?[l]:d===u?[]:[{...l,data:{...l.data,source:d,target:u,collapsedEndpoints:l.data.collapsedEndpoints??{source:l.data.source,target:l.data.target}}}]})}}function uo(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const r=new Map;return e.$connections.flatMap((t,n)=>{if(!t||typeof t!="object")return[];const o=t;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),s=r.get(i)??0;return r.set(i,s+1),[{value:o,key:`${i}#${s}`,index:n}]})}function sb(e,r,t){const n=uo(e).find(c=>c.key===r);if(!n)return e;const o=t(n.value),i=e.$connections.flatMap((c,l)=>l===n.index?o?[o]:[]:[c]);if(i.length)return{...e,$connections:i};const{$connections:s,...a}=e;return a}function yw(e){const r=[],t=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,s)=>t(i,`${o}.${s}`));for(const i of uo(n)){const s=i.value;r.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:s.target,type:typeof s.type=="string"?s.type:void 0,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,icon:typeof s.icon=="string"?s.icon:void 0,label:typeof s.label=="string"?s.label:void 0,color:typeof s.color=="string"?s.color:void 0,isEdgeDashed:s.style==="dashed",isEdgeAnimated:s.style==="animated",...["dashed","traveling"].includes(s.animationVariant)?{edgeAnimationVariant:s.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,s])=>[i,i==="$"?t(s,o):i.startsWith("$")?s:t(s,`${o}.${i}`)]))};return{json:t(e,"root"),edges:r}}const Br="root",Ou=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Vt(e){const r=e.split(".");for(r[0]===Br&&r.shift();r.length&&Ou(r[r.length-1]);)r.pop();return r.filter(t=>!Ou(t))}function fo(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Le(e,r){return Vt(r).reduce((t,n)=>{var o;if(t!=null)return(o=fo(t))==null?void 0:o[n]},e)}function mw(e){return Array.isArray(e)?[...e]:{...e}}function _t(e,r,t){const n=Vt(r),o=(i,s)=>{if(s===n.length)return t(i);const a=n[s],c=fo(i);if(c==null||typeof c!="object")return i;const l=o(c[a],s+1);if(Object.is(l,c[a]))return i;const d=mw(c);return d[a]=l,c!==i?{...i,$:d}:d};return o(e,0)}function nr(e,r,t){const n=t===""&&r!=="$content"||t===void 0||t===null;if(Array.isArray(e))return n?e:{[r]:t,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[r]:o[r]=t,o}function St(e,r,t,n){return _t(e,r,o=>t==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:nr(o,t,n))}const kd=(e,r,t)=>St(e,r,"$collapsed",t);function Rr(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const r=e.collapsedEndpoints??e,t=e.isInverted?r.target:r.source,n=e.isInverted?r.source:r.target,o=Vt(t).join("."),i=Vt(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function ur(e,r,t,n){if(r.connection){const a=r.connection;return _t(e,a.address,c=>sb(c,a.key,l=>{if(t==="$edgeIcon")return nr(l,"icon",n);if(t==="$edgeType")return nr(l,"type",n);if(t==="$edgeAnimationVariant")return nr(l,"animationVariant",n);if(t==="$sourceLabel"||t==="$edgeColor")return nr(l,t==="$sourceLabel"?"label":"color",n);const d=t==="$isEdgeAnimated"?"animated":"dashed";return n?{...l,style:d}:l.style===d?nr(l,"style",void 0):l}))}const{address:o,kind:i}=Rr(r),s=i==="target"&&t==="$sourceLabel"?"$targetLabel":i==="target"&&t==="$edgeType"?"$targetEdgeType":i==="target"&&t==="$edgeIcon"?"$targetIcon":i==="target"&&t==="$edgeAnimationVariant"?"$targetAnimationVariant":t;return _t(e,o,a=>nr(a,s,n))}const cb=(e,r,t)=>ur(ur(e,r,"$isEdgeAnimated",t==="animated"||void 0),r,"$isEdgeDashed",t==="dashed"||void 0);function Rd(e,r,t,n){let o=n||"";const i=_t(e,r,a=>{const c=fo(a);if(Array.isArray(c)){o=String(c.length);const d=[...c,t];return c===a?d:{...a,$:d}}const l=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!o){let d=1;for(;`node_${d}`in l;)d++;o=`node_${d}`}return l[o]=t,l}),s=Vt(r);return{json:i,address:[Br,...s,o].join(".")}}function lb(e,r){const t=Vt(r);if(!t.length)return e;const n=t[t.length-1],o=[Br,...t.slice(0,-1)].join(".");return _t(e,o,i=>{const s=fo(i);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return i;if(Array.isArray(s)){const l=s.filter((d,u)=>String(u)!==n);return s===i?l:{...i,$:l}}const{[n]:a,...c}=i;return c})}const db=(e,r,t,n)=>St(n?_t(e,r,o=>nr(o,"$targetLabel",n)):e,r,"$target",t);function Ad(e,r,t){const n=Le(e,r);return uo(n).some(({value:i})=>i.target===t.target&&i.sourceProperty===t.sourceProperty&&i.targetProperty===t.targetProperty)?e:_t(e,r,i=>nr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...t,id:t.id||jd()}]))}function ub(e,r){if(r.connection){const i=r.connection;return uo(Le(e,i.address)).some(s=>s.key===i.key)?{json:_t(e,i.address,s=>sb(s,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:t,kind:n}=Rr(r);return n==="hierarchy"?Le(e,t)===void 0?{json:e,removed:!1}:{json:_t(e,t,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:_t(e,t,i=>{const{$target:s,$targetLabel:a,...c}=i||{};return c}),removed:!0}}function hd(e,r={}){var v;const t=yw(e),{nodes:n,edges:o}=Pr(t.json,Br,[],[],r.title||"untitled",{hideDefaultObject:!!r.hideDefaultObject,sprtObjctKy:!!r.separateObjectKeys,isCntr:!!r.isCenter}),i=new Set(n.map(x=>x.data.id)),s=new Map;for(const x of n){const w=x.data.id;if(!w.endsWith(".0")||Le(e,w)!==void 0)continue;const C=w.slice(0,-2),S=Le(e,C);!i.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(_=>_.startsWith("$")&&_!=="$")&&s.set(w,C)}const a=x=>s.get(x)??x,c=new Set(n.flatMap(x=>x.data.parent?[a(x.data.parent)]:[])),l=new Map;if(r.isCenter){const x=new Map;for(const{data:w}of o){const C=Rr(w);if(C.kind==="hierarchy")l.set(a(C.address),!!w.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(w.isInverted?w.source:w.target);if(Vt(S).length!==1)continue;const _=!!w.isInverted;x.set(S,x.has(S)&&x.get(S)!==_?null:_)}}for(const[w]of l){const C=`${Br}.${Vt(w)[0]}`,S=x.get(C);typeof S=="boolean"&&l.set(w,S)}}const d=n.map(x=>{var E;const w=a(x.data.id),C=Le(e,w),S={...x.data,id:w};l.has(w)&&(S.config={...S.config,isInverted:l.get(w)});const _=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(O=>!O.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),c.has(w)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$view==="parent"&&(S.type="objectView",S.config={...S.config,typeView:"parent",parentContainer:!0,collapsed:!!C.$collapsed}),C.$view==="grid"){S.type="grid";const O=C.$gridSize;if(O!==void 0&&(!O||![O.width,O.height].every(P=>Number.isFinite(P)&&P>0&&P<=16384)))throw new Error("Invalid grid frame size.");S.config={...S.config,typeView:"grid",documentId:C.$document,gridSize:O},S.viewProps={...S.viewProps,bgColor:C.$bgColor??"transparent",borderRadius:C.$borderRadius??0,borderWidth:C.$borderWidth??0}}if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const O=C.$ports.filter(P=>P&&typeof P.id=="string"&&["source","target"].includes(P.role)&&["top","right","bottom","left"].includes(P.side));S.config={...S.config,ports:O}}if(S.parent&&(S.parent=a(S.parent)),typeof C.$label=="string"&&(S.label=C.$label,S.headerTitle=C.$label),typeof C.$subtitle=="string"&&(S.config={...S.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(S.viewProps={...S.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(S.viewProps={...S.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(S.viewProps={...S.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(S.viewProps={...S.viewProps,borderRadius:C.$borderRadius}),typeof C.$isNodeAnimated=="boolean"&&(S.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(S.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"||C.$contentFormat==="jsx"&&Array.isArray(C.$content)){S.config={...S.config,content:C.$content};const O=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(O))throw new Error("Invalid content format: expected markdown, html, or jsx.");S.config.contentFormat=O,C.$view||(S.type="objectView")}return(((E=S.config)==null?void 0:E.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(S.config={...S.config||{}},(C.$collapsed!==void 0||S.config.collapsed!==void 0)&&(S.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(S.config.icon=C.$icon)),{data:S}}),u=new Map,h=o.map(x=>{let w=a(x.data.source),C=a(x.data.target),S=x.data.isInverted;const _=Rr(x.data),k=l.get(a(_.address));_.kind==="hierarchy"&&k!==void 0&&k!==!!S&&([w,C]=[C,w],S=k);const E=`${w}->${C}`,O=u.get(E)??0;u.set(E,O+1);const P={...x.data,id:O?`${E}#${O}`:E,source:w,target:C,isInverted:S},A=Rr(P),M=Le(e,A.address);if(M&&typeof M=="object"){const T=M[A.kind==="target"?"$targetEdgeType":"$edgeType"];typeof T=="string"&&(P.type=T);const N=M[A.kind==="target"?"$targetIcon":"$edgeIcon"];typeof N=="string"&&(P.icon=N),M.$isEdgeAnimated!==void 0&&(P.isEdgeAnimated=!!M.$isEdgeAnimated);const $=M[A.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes($)&&(P.edgeAnimationVariant=$),M.$isEdgeDashed!==void 0&&(P.isEdgeDashed=!!M.$isEdgeDashed),M.$edgeColor&&(P.color=M.$edgeColor)}return{data:P}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const x=d.findIndex(w=>w.data.id===Br);x!==-1&&d.splice(x,1)}const p=new Set(d.map(x=>x.data.id));for(let x=h.length-1;x>=0;x--){const w=h[x].data,C=Rr(w);(!p.has(w.source)||!p.has(w.target)||C.kind==="hierarchy"&&((v=Le(e,C.address))==null?void 0:v.$hideParentEdge)===!0)&&h.splice(x,1)}h.push(...t.edges.filter(x=>p.has(x.data.source)&&p.has(x.data.target)));const m=gw(e,{nodes:d,edges:h}),y=m.nodes.filter(x=>{var w;return(w=x.data.config)==null?void 0:w.collapsed}).map(x=>Vt(x.data.id));if(!y.length)return m;const g=m.nodes.filter(x=>{const w=Vt(x.data.id);return!y.some(C=>C.length<w.length&&C.every((S,_)=>S===w[_]))}),b=new Set(g.map(x=>x.data.id));return{nodes:g,edges:m.edges.filter(x=>b.has(x.data.source)&&b.has(x.data.target))}}function bw(e,r){const t=new Set(e.filter(c=>{var l,d;return(d=(l=c.data)==null?void 0:l.config)==null?void 0:d.collapsed}).map(c=>c.data.id));if(!t.size)return{nodes:e,edges:r};const n=new Map(e.map(c=>[c.data.id,c])),o=new Set(e.map(c=>c.data.parent).filter(Boolean)),i=new Map(e.map(c=>{var h;let l=c.data.id,d=c.data.parent;const u=new Set([l]);for(;d&&!u.has(d);)t.has(d)&&(l=d),u.add(d),d=(h=n.get(d))==null?void 0:h.data.parent;return[c.data.id,l]})),s=new Map;for(const c of r){const l=c.data.isInverted?c.data.target:c.data.source,d=c.data.isInverted?c.data.source:c.data.target;(s.get(l)??s.set(l,[]).get(l)).push(d)}const a=new Set(e.filter(c=>i.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of t){if(o.has(c))continue;const l=[...s.get(c)||[]];for(;l.length;){const d=l.pop();t.has(d)||a.has(d)||(a.add(d),l.push(...s.get(d)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var l;return t.has(c.data.id)&&o.has(c.data.id)?{...c,data:{...c.data,type:"arrayView",label:c.data.label??c.data.headerTitle,config:{...c.data.config,parentContainer:!0,labelBelow:!0,icon:((l=c.data.config)==null?void 0:l.icon)||"PiStack"}}}:c}),edges:r.flatMap(c=>{const l=i.get(c.data.source)??c.data.source,d=i.get(c.data.target)??c.data.target;return a.has(l)||a.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Pd(e,r){const t=JSON.parse(e);let n=512;const o=(s,a=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Expected a JSON Schema object.");const c=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const d of Object.keys(s))if(!c.has(d))throw new Error(`Unsupported JSON Schema keyword: ${d}`);const l=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(u=>!["$ref","title","description"].includes(u)))throw new Error("Use $ref without sibling constraints.");if(typeof s.$ref!="string"||!s.$ref.startsWith("#/")||a.includes(s.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let d=t;for(const u of s.$ref.slice(2).split("/")){const h=u.replace(/~1/g,"/").replace(/~0/g,"~");if(!d||!Object.prototype.hasOwnProperty.call(d,h))throw new Error(`Unresolved reference: ${s.$ref}`);d=d[h]}return o(d,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(d=>d!=="anyOf"&&!l.includes(d)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(d=>o(d,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...l,"const","enum","type"].includes(h))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const d=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(d)||!d.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:d.map(h=>{if(h!==null&&!["string","number","boolean"].includes(typeof h))throw new Error("Only primitive literals are supported.");const p=h===null?"null":typeof h;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(m=>m===p||m==="integer"&&Number.isInteger(h)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:h}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(d=>typeof d!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(d=>d!=="type"&&!l.includes(d)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(d=>o({type:d},a))}}if((s.properties||s.required||s.additionalProperties!==void 0)&&s.type!=="object"&&s.type!==void 0)throw new Error("Object constraints require an object type.");if(s.items&&s.type!=="array")throw new Error("items requires an array type.");if(s.type==="object"||s.properties){if(s.additionalProperties!==void 0&&s.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!s.properties||typeof s.properties!="object"||Array.isArray(s.properties))throw new Error("Object schemas must declare properties.");if(s.required!==void 0&&(!Array.isArray(s.required)||s.required.some(u=>typeof u!="string"||!Object.prototype.hasOwnProperty.call(s.properties,u))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([u,h])=>[u,{type:o(h,a),optional:!(s.required??[]).includes(u)}]))}}if(s.type==="array")return{kind:"array",items:o(s.items,a)};if(["string","number","integer","boolean","null"].includes(s.type))return{kind:s.type};throw new Error("Every property must declare a supported type.")},i=o(t);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(s=>s.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:i.properties}}async function Md(e,r,t,n={}){var m;let o=512;const i=await import("typescript"),s=i.createSourceFile(r,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const c=new Map;for(const y of s.statements){if(!i.isInterfaceDeclaration(y)&&!i.isTypeAliasDeclaration(y))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((m=y.typeParameters)!=null&&m.length||c.has(y.name.text))throw new Error("Generics and duplicate declarations are not supported.");c.set(y.name.text,y)}const l=(y,g)=>{var C;const b={},v=y.find(S=>i.isIndexSignatureDeclaration(S));let x;if(v&&n.allowJson&&i.isIndexSignatureDeclaration(v)){if(y.filter(S=>i.isIndexSignatureDeclaration(S)).length!==1||v.parameters.length!==1||((C=v.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!v.type)throw new Error("Only one string-keyed index signature is supported for forms.");x=u(v.type,g)}return{kind:"object",properties:Object.fromEntries(y.filter(S=>S!==v||!x).map(S=>{if(!i.isPropertySignature(S)||!S.type||!S.name||!i.isIdentifier(S.name)&&!i.isStringLiteral(S.name))throw new Error("Only explicitly typed named properties are supported.");const _=u(S.type,g),k=n.allowJson?i.getJSDocTags(S).filter(E=>E.tagName.text==="port"):[];if(k.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(k.length){const[E,O,P]=String(k[0].comment??"").trim().split(/\s+/);if(E!=="config"||!O||P||!c.has(O))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const A=_.kind==="array";if((_.kind==="array"?_.items.kind:_.kind)!=="string")throw new Error(`Config port ${S.name.text} must be a string or string array reference`);b[S.name.text]={kind:"config",resourceType:O,multiple:A}}return[S.name.text,{type:_,optional:!!S.questionToken}]})),...x?{additionalProperties:x}:{},...Object.keys(b).length?{ports:b}:{}}},d=(y,g)=>{var C;if(g.includes(y))throw new Error("Recursive types are not supported.");const b=c.get(y);if(!b)throw new Error(`Unknown type: ${y}`);let v;if(i.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");v=l(b.members,[...g,y])}else v=u(b.type,[...g,y]);const x=n.allowJson?i.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!x.length)return v;if(v.kind!=="object")throw new Error("Node ports require an object interface");const w={...v.ports};for(const S of x){const[_,k,...E]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(_)||!/^[A-Za-z][\w-]*$/.test(k??""))throw new Error("Node ports require @port input|output|error Name");const O=E.length?JSON.parse(E.join(" ")):void 0;if(O!==void 0&&typeof O!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(w,k))throw new Error(`Duplicate port declaration: ${k}`);w[k]={kind:_,...typeof O=="string"?{label:O}:{}}}return{...v,ports:w}},u=(y,g)=>{var b,v,x;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(y.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(y.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(y.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(y.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(y))return u(y.type,g);if(i.isUnionTypeNode(y))return{kind:"union",types:y.types.map(w=>u(w,g))};if(i.isArrayTypeNode(y))return{kind:"array",items:u(y.elementType,g)};if(i.isTypeLiteralNode(y))return l(y.members,g);if(i.isLiteralTypeNode(y)){const w=y.literal;if(i.isStringLiteral(w))return{kind:"literal",value:w.text};if(i.isNumericLiteral(w))return{kind:"literal",value:Number(w.text)};if(w.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(w.kind===i.SyntaxKind.TrueKeyword||w.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:w.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(y)&&i.isIdentifier(y.typeName)){if(n.allowJson&&y.typeName.text==="Record"&&!c.has("Record")&&((b=y.typeArguments)==null?void 0:b.length)===2&&y.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:u(y.typeArguments[1],g)};if(y.typeName.text==="Array"&&((v=y.typeArguments)==null?void 0:v.length)===1)return{kind:"array",items:u(y.typeArguments[0],g)};if(!((x=y.typeArguments)!=null&&x.length))return d(y.typeName.text,g)}throw new Error(`Unsupported TypeScript type: ${y.getText(s)}`)},h=t??(c.has("Graph")?"Graph":c.size===1?[...c.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=d(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function fb(e,r){const t=await Md(e,r);if(Object.values(t.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:t.properties}}function pn(e,r){if(e.kind==="json"||r.kind==="json"||e.kind==="object"&&e.additionalProperties||r.kind==="object"&&r.additionalProperties)return!1;if(e.kind==="union")return e.types.every(t=>pn(t,r));if(r.kind==="union")return r.types.some(t=>pn(e,t));if(e.kind==="literal"){if(r.kind==="literal")return e.value===r.value;const t=e.value===null?"null":typeof e.value;return r.kind===t||r.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&r.kind==="number"?!0:e.kind==="array"&&r.kind==="array"?pn(e.items,r.items):e.kind==="object"&&r.kind==="object"?Object.entries(r.properties).every(([t,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,t)?e.properties[t]:void 0;return o?(n.optional||!o.optional)&&pn(o.type,n.type):n.optional}):e.kind===r.kind}function Id(e,r){if(!r.sourceProperty&&!r.targetProperty)return;const t=(s,a)=>{var d;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),l=Object.prototype.hasOwnProperty.call(e.nodes,c)?(d=e.nodes[c])==null?void 0:d.type:void 0;return a&&(l==null?void 0:l.kind)==="object"&&Object.prototype.hasOwnProperty.call(l.properties,a)?l.properties[a]:void 0},n=t(r.source,r.sourceProperty),o=t(r.target,r.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=s=>s.kind==="json"||s.kind==="object"&&(!!s.additionalProperties||Object.values(s.properties).some(a=>i(a.type)))||s.kind==="array"&&i(s.items)||s.kind==="union"&&s.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!pn(n.type,o.type))return`Incompatible property types: ${r.sourceProperty} -> ${r.targetProperty}.`}async function hb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const r=await e.text();if(/\.json$/i.test(e.name))return Pd(r,e.name);if(/\.ts$/i.test(e.name))return fb(r,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Nu=new WeakMap;function Hr(e){if(!e||typeof e!="object")return e;const r=Nu.get(e);if(r)return r;const t=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Hr(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:Hr(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:t,deleteProperty:t,defineProperty:t,setPrototypeOf:t,preventExtensions:t});return Nu.set(e,n),n}function Xr(e,r,t){var o;const n=r.split(".");for(let i=n.length;i>0;i--){const s=n.slice(0,i).join("."),a=(o=Le(e,s))==null?void 0:o.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(t,a.$type)?t[a.$type]:void 0;for(const u of n.slice(i))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(u)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,u)?c.properties[u].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const l=n.slice(i).join("."),d=Object.fromEntries(Object.entries(a.$fields??{}).filter(([u])=>!l||u.startsWith(`${l}.`)).map(([u,h])=>[l?u.slice(l.length+1):u,h]));return{type:c,fields:d,binding:a}}}async function Td(e,r){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const t=await e.text();if(e.name.endsWith(".ts")){if(!r.length||r.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(r);for(const s of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Md(t,e.name,s,{allowJson:!0});o.push([s,a]);for(const c of Object.values(a.ports??{}))c.resourceType&&i.add(c.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Pd(t,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function ho(e,r){return!e||("$in"in e?e.$in.includes(Le(r,e.$address)):Le(r,e.$address)===e.$equals)}function _n(e){const r=e.kind==="array"?e.items:e,t=r.kind==="union"?r.types:[r];if(t.every(n=>n.kind==="literal"))return t.map(n=>({label:String(n.value),value:n.value}))}function Wt(e,r,t){if(r===void 0||r==="")return t?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const s=Object.values(i).every(o);return n.delete(i),s};return o(r)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Wt(n,r,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return r===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(r)&&r.every(n=>!Wt(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!r||typeof r!="object"||Array.isArray(r)?"Expected an object":e.additionalProperties&&Object.entries(r).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Wt(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Wt(o.type,r[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return r===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(r)?void 0:"Expected a whole number";if(typeof r!==e.kind||typeof r=="number"&&!Number.isFinite(r))return`Expected ${e.kind}`}function $u(e,r){const t=r.address.split(".");if(t.shift()!=="root"||!t.length||t.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=t.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(t.some(a=>a.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...t].join("."),s=Le(e,i);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(r.op==="set"&&typeof r.value!="string")throw new Error("Node colors must be strings.");return St(e,i,n,r.op==="remove"?void 0:r.value)}return _t(e,i,a=>{const c=Array.isArray(a.$)?a.$:a;if(r.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||r.op==="set"&&Object.is(c[n],r.value))return a;const l=Array.isArray(c)?[...c]:{...c};if(Array.isArray(l)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=l.length))throw new Error("Invalid array address.");return r.op==="remove"?Array.isArray(l)?l.splice(Number(n),1):delete l[n]:Object.defineProperty(l,n,{value:structuredClone(r.value),enumerable:!0,writable:!0,configurable:!0}),c===a?l:{...a,$:l}})}function po(e,r,t){let n=$u(e,r.value===void 0?{op:"remove",address:r.address}:{op:"set",address:r.address,value:r.value});const o=t==null?void 0:t({...r,previousValue:Hr(Le(e,r.address)),data:Hr(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=$u(n,i)}return n}const En="data:image/svg+xml;base64,";function lr(e){if(e.startsWith(En))return!0;try{const r=new URL(e);return(r.protocol==="https:"||r.protocol==="http:")&&!r.username&&!r.password}catch{return!1}}async function vw(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const r=await e.text(),t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.doctype||t.querySelector("parsererror")||t.documentElement.localName!=="svg"||t.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(t.querySelector("script, foreignObject")||[...t.querySelectorAll("*")].some(i=>[...i.attributes].some(s=>/^on/i.test(s.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(r);let o="";for(const i of n)o+=String.fromCharCode(i);return En+btoa(o)}const Xt=({name:e,svg:r=!1,...t})=>{const[n,o]=j.useState(null),[i,s]=j.useState(!0),[a,c]=j.useState(!1),l=typeof e=="string"&&lr(e);if(j.useEffect(()=>{if(l||!e||e.length<2){o(null),s(!1);return}s(!0),c(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let h;switch(u){case"md":h=await import("react-icons/md");break;case"fa6":h=await import("react-icons/fa6");break;case"io5":h=await import("react-icons/io5");break;case"io":h=await import("react-icons/io");break;case"ti":h=await import("react-icons/ti");break;case"go":h=await import("react-icons/go");break;case"fi":h=await import("react-icons/fi");break;case"di":h=await import("react-icons/di");break;case"ai":h=await import("react-icons/ai");break;case"bs":h=await import("react-icons/bs");break;case"ri":h=await import("react-icons/ri");break;case"fc":h=await import("react-icons/fc");break;case"gi":h=await import("react-icons/gi");break;case"hi2":h=await import("react-icons/hi2");break;case"hi":h=await import("react-icons/hi");break;case"si":h=await import("react-icons/si");break;case"sl":h=await import("react-icons/sl");break;case"im":h=await import("react-icons/im");break;case"bi":h=await import("react-icons/bi");break;case"pi":h=await import("react-icons/pi");break;case"vsc":h=await import("react-icons/vsc");break;case"tb":h=await import("react-icons/tb");break;case"tfi":h=await import("react-icons/tfi");break;case"cg":h=await import("react-icons/cg");break;case"lia":h=await import("react-icons/lia");break;case"lu":h=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${u}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${u}`);o(()=>p)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),c(!0),o(null)}finally{s(!1)}})()},[e,l]),l){const{size:d=80,style:u,...h}=t;return r?f.jsx("image",{...h,href:e,width:d,height:d,preserveAspectRatio:"xMidYMid meet",style:u}):f.jsx("img",{...h,src:e,alt:"",width:d,height:d,referrerPolicy:"no-referrer",style:{objectFit:"contain",...u}})}return i||!n?null:f.jsx(n,{...t})};function xw(e,r){let t=e;for(const n of r){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(s=>s.startsWith("$")||["__proto__","prototype","constructor"].includes(s)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Pn(i),t=po(t,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Pn(t),t}function $n(e,r,t){const n=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(!(!n||!t||!Object.prototype.hasOwnProperty.call(t,n.type)))return{address:n.address,type:t[n.type],fields:n.fields??{}}}function Pn(e){if(!(!e||typeof e!="object"))for(const[r,t]of Object.entries(e)){if(r.startsWith("$")||["__proto__","prototype","constructor"].includes(r))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${r}`);Pn(t)}}function ww(e,r,t){Pn(r.value);const n=po(e,r,t);return Pn(n),n}function pb(e,r){const t=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const s=Le(r,n.$state);return s==null?"":typeof s=="object"?JSON.stringify(s,null,2):String(s)}let i=n;for(const[s,a]of Object.entries(n)){const c=t(a,s);c!==a&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,s,{value:c,enumerable:!0,writable:!0,configurable:!0}))}return i};return t(e)}const Cw=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),Sw=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,gn=(e,r)=>JSON.stringify([e,r]);function Mn(e,r){if(e.kind==="union"){const t=e.types.find(n=>n.kind===(Array.isArray(r)?"array":r===null?"null":typeof r)||n.kind==="literal"&&Object.is(n.value,r));return Mn(t??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},r)}return e.kind!=="json"?e:Array.isArray(r)?{kind:"array",items:{kind:"json"}}:r!==null&&typeof r=="object"||r===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:r===null?"null":typeof r}}function yn(e){const r=Mn(e,void 0);return r.kind==="object"?{}:r.kind==="array"?[]:r.kind==="literal"?r.value:r.kind==="number"||r.kind==="integer"?0:r.kind==="boolean"?!1:r.kind==="null"?null:""}function qu(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"&&!_n(e)?e.types:[e]}function jw(e,r,t){if(r.address===t.address)return;const n=Le(e,r.address),o=(i,s)=>s===void 0?!1:i.kind==="union"?i.types.some(a=>o(a,s)):i.kind==="array"?Array.isArray(s)&&s.every(a=>o(i.items,a)):i.kind==="object"?!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(i.properties).every(([a,c])=>c.optional&&s[a]===void 0||o(c.type,s[a]))&&Object.entries(s).every(([a,c])=>Object.prototype.hasOwnProperty.call(i.properties,a)||!i.additionalProperties||o(i.additionalProperties,c)):s===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Wt(i,s,!0);if(o(t.type,n))return structuredClone(n)}function gb(e,r,t,n){var c,l;const o={sourceSchema:t,sourceBindings:r,nodes:[],edges:[],schema:{...t},bindings:{...r},slots:new Map,containers:new Map},i=new Set(n.map(d=>d.data.id)),s=new Map(n.flatMap(d=>{const u=r[d.data.id];return u&&t[u.type]?[[u.address,d.data.id]]:[]})),a=(d,u,h,p,m,y=!1)=>{var _,k,E,O,P;if(m>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const g=Le(e,u),b=Mn(h,g),v=b.kind!=="object"&&b.kind!=="array";o.containers.set(d,{address:u,type:b,declared:h,scalar:v});const x=`__form:${d}`,w={...(_=o.bindings[d])==null?void 0:_.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...y?{resource:{label:"output",...b.kind==="object"?(k=b.ports)==null?void 0:k.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(g??{}).filter(A=>!Object.prototype.hasOwnProperty.call(b.properties,A)&&b.additionalProperties).map(A=>[A,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(g)?g:[]).map((A,M)=>[String(M),{type:b.items,optional:!0}])):{value:{type:_n(h)?h:b,optional:!1}};for(const[A,M]of Object.entries(S)){if(!Cw(A))throw new Error(`Unsupported structured property key: ${A}`);const T=v?u:`${u}.${A}`,N=Le(e,T),$=Mn(M.type,N),I=$.kind==="object"||$.kind==="array",W=(E=C.ports)==null?void 0:E[A],ie=(W==null?void 0:W.kind)==="config"&&(((O=w[A])==null?void 0:O.$options)||_n(M.type)),ae=M.type.kind==="json"||M.type.kind==="union"&&!_n(M.type);if(((P=w[A])==null?void 0:P.$control)==="upload"||!I&&b.kind!=="array"&&(!ae||v)||ie){C.properties[A]={...M,type:M.type.kind==="json"?$:M.type};continue}const re=s.get(T)??Sw(T),ye=b.kind==="array"?`Item ${Number(A)+1}`:A,be={address:T,owner:d,field:A,type:M.type,label:ye,nodeId:re,present:N!==void 0};if(o.slots.set(gn(d,A),be),C.ports[A]={kind:"config",resourceType:`__form:${re}`},N===void 0||(o.edges.push({data:{id:`__form-edge:${d}:${A}`,source:re,target:d,sourceProperty:"output:resource",targetProperty:`config:${A}`,isEdgeDashed:!0}}),o.containers.has(re)||s.has(T)))continue;if(i.has(re))throw new Error(`Structured node identity conflict: ${re}`);i.add(re);const L={data:{id:re,type:"objectView",label:ye,headerTitle:ye,description:{},config:{form:!0,icon:$.kind==="array"?"PiListNumbers":I?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(L),a(re,T,M.type,p,m+1,!0);const z=o.schema[`__form:${re}`];L.data.description=Object.fromEntries(Object.keys(z.properties).map(G=>[G,Le(e,$.kind==="array"||$.kind==="object"?`${T}.${G}`:T)]).filter(([,G])=>G!==void 0))}o.schema[x]=C,o.bindings[d]={...o.bindings[d],address:u,type:x,fields:w}};for(const d of n){const u=r[d.data.id];if(u!=null&&u.portResources)continue;const h=u&&t[u.type];!u||!h||Le(e,u.address)===void 0||a(d.data.id,u.address,h,(c=d.data.viewProps)==null?void 0:c.bgColor,0,o.edges.some(p=>p.data.source===d.data.id))}for(const d of o.edges){const u=o.bindings[d.data.source],h=o.schema[u.type].ports;h.resource={...h.resource,kind:"output",label:((l=h.resource)==null?void 0:l.label)??"output"}}return o}const Ar=(e="reference")=>({kind:e,text:"",paths:[""]}),yb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(r=>["__proto__","constructor","prototype"].includes(r));function _w(e,r){const t=new Set(r.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!yb(a)||!t.has(a)))throw new Error("Choose an available reference.");return[...s.paths,...s.fallback===void 0?[]:[JSON.stringify(s.fallback)]].join(" || ")},o=s=>{if(s.includes("{{")||s.includes("}}"))throw new Error("Use a reference part for dynamic values.");return s},i=s=>s.map(a=>{if(a.kind==="text")return o(a.text);if(a.kind==="conditional"){if(a.paths.length!==1||a.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(a)}}}${o(a.text)}{{/if}}`}return`{{${n(a)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const s=i(e.parts);return e.mode==="condition"?`${s} == ${JSON.stringify(e.comparison)}`:s}if(e.mode==="json"){const s=e.fields.map(a=>a.key);if(!s.length||new Set(s).size!==s.length||s.some(a=>!a||["__proto__","constructor","prototype"].includes(a)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(a=>[a.key,i(a.parts)])))}return i(e.parts)}async function Ew(e){const r=await import("typescript"),t=s=>{const a=r.createSourceFile("binding.ts",`(${s})`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!r.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const l=Ar();l.paths=[];const d=u=>{if(r.isParenthesizedExpression(u))return d(u.expression);if(r.isBinaryExpression(u)&&u.operatorToken.kind===r.SyntaxKind.BarBarToken){d(u.left),d(u.right);return}if(r.isStringLiteral(u)){if(l.fallback!==void 0)throw new Error("Multiple fallback values.");l.fallback=u.text;return}const h=u.getText(a);if(!yb(h)||l.fallback!==void 0)throw new Error("Unsupported reference expression.");l.paths.push(h)};if(d(c.expression),!l.paths.length)throw new Error("A binding needs a reference.");return l},n=s=>{const a=[];let c=0;const l=/\{\{([\s\S]*?)\}\}/g;for(const d of s.matchAll(l)){const u=d.index;if(u<c)continue;u>c&&a.push({...Ar("text"),text:s.slice(c,u)});const h=d[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",u+d[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...t(h.slice(4)),kind:"conditional",text:s.slice(u+d[0].length,p)}),c=p+7}else a.push(t(h)),c=u+d[0].length}return c<s.length&&a.push({...Ar("text"),text:s.slice(c)}),a},o={mode:"reference",parts:[Ar()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const s=JSON.parse(e);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(a=>typeof a=="string"))return{...o,mode:"json",fields:Object.entries(s).map(([a,c])=>({key:a,parts:n(c)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const s=r.createSourceFile("condition.ts",`value ${i[1].text}`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&r.isExpressionStatement(a)&&r.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===r.SyntaxKind.EqualsEqualsToken&&r.isStringLiteral(a.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:a.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function Lu({parts:e,references:r,onChange:t,disabled:n}){const o=(i,s)=>t(e.map((a,c)=>c===i?{...a,...s}:a));return f.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,s)=>f.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[f.jsxs("legend",{children:["Part ",s+1]}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsxs("span",{"data-form-select":"",style:{flex:1},children:[f.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:a=>o(s,{kind:a.target.value}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"text",children:"Text"}),f.jsx("option",{value:"conditional",children:"Conditional text"})]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Ne,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t(e.filter((a,c)=>c!==s))})]}),i.kind!=="text"&&f.jsxs(f.Fragment,{children:[i.paths.map((a,c)=>f.jsxs("label",{children:["Reference ",c+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${c+1}`,disabled:n,value:a,onChange:l=>o(s,{paths:i.paths.map((d,u)=>u===c?l.target.value:d)}),children:[f.jsx("option",{value:"",children:"Select reference"}),r.map(l=>f.jsx("option",{value:l.path,children:l.label},l.path))]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),i.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Ne,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(s,{paths:[...i.paths,""]})}),f.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:a=>o(s,{fallback:a.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&f.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:a=>o(s,{fallback:a.target.value})})]})]}),i.kind!=="reference"&&f.jsxs("label",{children:["Text",f.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:a=>o(s,{text:a.target.value})})]})]},s)),f.jsx(Ne,{"aria-label":"Add part",title:"Add part",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t([...e,Ar()])})]})}function kw({label:e,value:r,references:t,disabled:n,onChange:o}){const[i,s]=j.useState(),[a,c]=j.useState(""),[l,d]=j.useState(!1),u=async()=>{d(!0),c("");try{s(await Ew(typeof r=="string"?r:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{d(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Ne,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||l,onClick:u}),typeof r=="string"&&r.includes("{{")&&f.jsx("span",{children:"Bound value"}),i&&f.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Binding mode",f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:h=>s({...i,mode:h.target.value,parts:[Ar()]}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"condition",children:"Equals"}),f.jsx("option",{value:"template",children:"Text template"}),f.jsx("option",{value:"json",children:"JSON output"})]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?f.jsxs(f.Fragment,{children:[i.fields.map((h,p)=>f.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Output field name",f.jsx("input",{"aria-label":"Output field name",value:h.key,onChange:m=>s({...i,fields:i.fields.map((y,g)=>g===p?{...y,key:m.target.value}:y)})})]}),f.jsx(Lu,{parts:h.parts,references:t,disabled:n,onChange:m=>s({...i,fields:i.fields.map((y,g)=>g===p?{...y,parts:m}:y)})}),f.jsx(Ne,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:i.fields.filter((m,y)=>y!==p)})})]},p)),f.jsx(Ne,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:[...i.fields,{key:"",parts:[Ar()]}]})})]}):f.jsx(Lu,{parts:i.parts,references:t,disabled:n,onChange:h=>s({...i,parts:h})}),i.mode==="condition"&&f.jsxs("label",{children:["Equals",f.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:h=>s({...i,comparison:h.target.value})})]}),f.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[f.jsx(Ne,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(_w(i,t)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Ne,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function Rw({nodeAddress:e,onOpen:r}){const{structured:t,data:n,callbacks:o,editable:i,onFieldCreate:s}=j.useContext(Mt),a=He(),[c,l]=j.useState(""),[d,u]=j.useState("0"),[h,p]=j.useState(""),m=t==null?void 0:t.containers.get(e);if(!m||!n||!t)return null;const y=a.readOnly||a.config.editable===!1||!i,g=Le(n,m.address),b=qu(m.declared),v=m.type.kind==="array"?m.type.items:m.type.kind==="object"?m.type.additionalProperties:void 0,x=v?qu(v):[],w=!!s&&m.type.kind==="object"&&(v==null?void 0:v.kind)==="json",C=M=>M.kind==="literal"?String(M.value):M.kind==="string"?"Text":$t(M.kind),S=[...t.slots.values()].filter(M=>M.owner===e),_=(M,T)=>{var N;return(N=o.onFormChange)==null?void 0:N.call(o,{data:n,nodeAddress:m.address,address:M,previousValue:Le(n,M),value:T})},k=M=>{var T;a.setSelectedNodeIds([M]),(T=a.engineRef.current)==null||T.focusNode(M,90,!1)},E=(M,T)=>{if(!Array.isArray(g))return;const N=[...g];[N[M],N[M+T]]=[N[M+T],N[M]],_(m.address,N)},O=()=>{const M=x[Number(d)]??x[0];if(M)if(m.type.kind==="array")_(m.address,[...Array.isArray(g)?g:[],yn(M)]);else{if(!c||c.includes(".")||c.startsWith("$")||["__proto__","constructor","prototype"].includes(c)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(g,c)){p("Property already exists.");return}w&&(d==="file"||d==="files")?s==null||s({data:n,nodeAddress:m.address,address:`${m.address}.${c}`,previousValue:void 0,value:d==="files"?[]:""},{$control:"upload"}):_(`${m.address}.${c}`,yn(M)),l(""),p("")}},P=m.type.kind==="object"&&!!m.type.additionalProperties,A=m.type.kind==="array";return f.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[b.length>1&&f.jsxs("label",{children:["Value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsx(At,{"aria-label":"Value type",disabled:y,value:String(b.findIndex(M=>Mn(M,g).kind===m.type.kind)),onValueChange:M=>_(m.address,yn(b[Number(M)])),children:b.map((M,T)=>f.jsx("option",{value:T,children:C(M)},T))})})]}),S.map((M,T)=>f.jsxs("div",{"data-structured-slot":M.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[M.type.kind==="array"?f.jsx(Z.PiListNumbers,{size:20}):f.jsx(Z.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:$t(M.label)}),f.jsx(Ne,{"aria-label":`${M.present?r?"Edit":"Focus":"Create"} ${$t(M.label)}`,title:`${M.present?r?"Edit":"Focus":"Create"} ${$t(M.label)}`,icon:M.present?f.jsx(Z.PiMagnifyingGlass,{size:18}):f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:y&&!M.present,onClick:N=>{var $;M.present?r?r(M.nodeId):(($=N.currentTarget.closest("dialog"))==null||$.close(),k(M.nodeId)):_(M.address,yn(M.type))}}),A&&f.jsxs(f.Fragment,{children:[f.jsx(Ne,{"aria-label":`Move item ${T+1} up`,icon:f.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:y||T===0,onClick:()=>E(T,-1)}),f.jsx(Ne,{"aria-label":`Move item ${T+1} down`,icon:f.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:y||T===S.length-1,onClick:()=>E(T,1)})]}),M.present&&f.jsx(Ne,{"aria-label":`Remove ${$t(M.label)}`,icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:y,onClick:()=>A?_(m.address,g.filter((N,$)=>$!==T)):_(M.address,void 0)})]},M.address)),(A||P)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[P&&f.jsxs("label",{style:{flex:"1 1 120px",minWidth:0,display:"grid",gap:8},children:["Property name",f.jsx("input",{"aria-label":"Property name",placeholder:"Required",value:c,disabled:y,onChange:M=>l(M.target.value)})]}),x.length>1&&f.jsxs("label",{style:{flex:"1 1 100px",minWidth:0,display:"grid",gap:8},children:["New value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsxs(At,{"aria-label":"New value type",value:d,disabled:y,onValueChange:u,children:[x.map((M,T)=>f.jsx("option",{value:T,children:C(M)},T)),w&&f.jsx("option",{value:"file",children:"File"}),w&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...P||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Ne,{"aria-label":A?"Add item":"Add property",icon:f.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:y,onClick:O})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Mt=j.createContext({callbacks:{}}),Jn=so.default.div`
|
|
58
|
+
`,Sd=j.forwardRef(function({style:r,...t},n){return f.jsx(sw,{...t,ref:n,style:{...r,backgroundImage:"none","--flow-range-track":(r==null?void 0:r.backgroundImage)??"none"}})});function fd({label:e,inputLabel:r,value:t,displayValue:n,min:o,max:i,step:s=5,onChange:a,onChangeEnd:c}){const l=j.useId(),{readOnly:d,themeColor:u}=He(),{colorInactive:h}=st(),p=(t-o)/(i-o)*100,m=u.includes(".")?`var(--chakra-colors-${u.replace(".","-")})`:u;return f.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[f.jsxs("label",{htmlFor:l,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(Sd,{id:l,"aria-label":r,type:"range",min:o,max:i,step:s,value:t,disabled:d,style:{color:m,accentColor:m,backgroundImage:`linear-gradient(to right, currentColor ${p}%, var(--chakra-colors-${h.replace(".","-")}) ${p}%)`},onChange:y=>a(Number(y.target.value)),onPointerUp:c,onKeyUp:c,onBlur:c})]})}const Pu={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 rb(){const{spacing:e,setSpacing:r,edgeRadius:t,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:s,readOnly:a,config:c}=He(),l=Pu[o].icon;return f.jsxs(f.Fragment,{children:[f.jsx(xn,{}),f.jsx(At,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(fd,{label:"Spacing",inputLabel:"Node spacing percentage",min:c.nodeGridSpacing==="layout"?0:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:d=>{var u;r(d/100),(u=s.onSpacingChange)==null||u.call(s,d/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(xn,{}),f.jsx(At,{"aria-label":"Edge radius",title:`Edge radius: ${t??"Default"}`,icon:f.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(fd,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:t??500,displayValue:t??"Default",onChange:d=>{var u;n(d),(u=s.onEdgeRadiusChange)==null||u.call(s,d)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(xn,{}),f.jsxs(At,{"aria-label":"Background variant",title:`Background: ${Pu[o].label}`,icon:f.jsx(l,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:a,onValueChange:d=>{var u;i(d),(u=s.onBackgroundVariantChange)==null||u.call(s,d)},children:[f.jsx("option",{value:"dot",children:"Dots"}),f.jsx("option",{value:"grid",children:"Grid"}),f.jsx("option",{value:"steel",children:"Steel"}),f.jsx("option",{value:"none",children:"Solid"}),f.jsx("option",{value:"transparent",children:"Transparent"})]})]})}function nb(){var o;const{engineRef:e,nodeGridOptions:r,readOnly:t}=He(),n=!!(r!=null&&r.fill);return f.jsx(Ur,{label:"Grid adjustment",hideLabel:!0,helper:n?"Grid adjustment":"Enable Collision and Fill to adjust the Grid",icon:f.jsx(Z.PiArrowsHorizontal,{size:20}),checked:n&&!!((o=r==null?void 0:r.adjustment)!=null&&o.enabled),disabled:!n,onChange:i=>{var s;t||!(r!=null&&r.fill)||(s=e.current)==null||s.setNodeGridMode(!0,{...r,adjustment:{...r.adjustment,enabled:i}})}})}function zo(){const{engineRef:e,nodeGridOptions:r,lastNodeGridOptions:t,readOnly:n,themeColor:o,callbacks:i,config:s}=He(),{colorText:a,colorInactive:c}=st(),l=r??t,d=typeof l.gaps=="object"?l.gaps.x:l.gaps??l.margin??15,u=Math.max(200,d),h=p=>{var m;return(m=e.current)==null?void 0:m.setNodeGridMode(!0,{...l,...p})};return f.jsxs(f.Fragment,{children:[s.bottomBarCollision!==!1&&f.jsx(Ur,{label:"Collision mode",hideLabel:!0,icon:f.jsx(Z.PiGridFour,{size:20}),checked:r!==null,onChange:p=>{var m,y;((m=i.onNodeGridModeRequest)==null?void 0:m.call(i,p,l))!==!0&&((y=e.current)==null||y.setNodeGridMode(p,l))}}),(r||s.bottomBarFill===!0)&&f.jsxs(V.HStack,{role:"group","aria-label":"Collision settings",gap:2,flexShrink:0,children:[r&&s.nodeGridSpacing!=="layout"&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{width:"96px",flexShrink:0,display:"flex",alignItems:"center",children:f.jsx(Sd,{type:"range","aria-label":"Collision gap",title:`Gap: ${d}`,min:0,max:u,step:5,value:d,disabled:n,style:{color:Pe(o),backgroundImage:`linear-gradient(to right, currentColor ${d/u*100}%, ${Pe(c)} ${d/u*100}%)`},onChange:p=>h({gaps:Number(p.target.value)})})}),f.jsx(V.Text,{fontSize:"xs",color:a,width:"28px",textAlign:"right",fontVariantNumeric:"tabular-nums",children:d})]}),s.bottomBarFill!==!1&&f.jsx(Ur,{label:"Fill",hideLabel:!0,helper:r?"Fill available canvas space":"Enable Collision mode to use Fill",icon:f.jsx(Z.PiArrowsOut,{size:18}),checked:!!r&&!!l.fill,disabled:!r,onChange:p=>{var m,y;!r&&((m=i.onNodeGridModeRequest)==null?void 0:m.call(i,!0,{...l,fill:p}))===!0||p&&((y=i.onNodeGridFillRequest)==null?void 0:y.call(i,{...l,fill:p}))===!0||h({fill:p})}}),r&&l.fill&&f.jsx(nb,{})]})]})}const Ct=[];for(let e=0;e<256;++e)Ct.push((e+256).toString(16).slice(1));function cw(e,r=0){return(Ct[e[r+0]]+Ct[e[r+1]]+Ct[e[r+2]]+Ct[e[r+3]]+"-"+Ct[e[r+4]]+Ct[e[r+5]]+"-"+Ct[e[r+6]]+Ct[e[r+7]]+"-"+Ct[e[r+8]]+Ct[e[r+9]]+"-"+Ct[e[r+10]]+Ct[e[r+11]]+Ct[e[r+12]]+Ct[e[r+13]]+Ct[e[r+14]]+Ct[e[r+15]]).toLowerCase()}let Bo;const lw=new Uint8Array(16);function dw(){if(!Bo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Bo=crypto.getRandomValues.bind(crypto)}return Bo(lw)}const uw=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Mu={randomUUID:uw};function jd(e,r,t){var o;if(Mu.randomUUID&&!e)return Mu.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??dw();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,cw(n)}const lo={label:"Untitled",description:"",isTask:!1,isLocked:!1},_d={id:null,type:"text",data:{...lo,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"}}},Iu={id:null,type:"objectView",data:{...lo,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},fw={id:null,type:"arrayView",data:{...lo,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"}}},Tu={id:null,type:"workflowStep",data:{...lo,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},Pt=e=>typeof e=="object",ob=e=>Array.isArray(e),hw=["order","position","selected","locked","grabbed","grabbable","scratch"],yr=e=>Object.entries(e).reduce((r,[t,n])=>(!Pt(n)&&!t.startsWith("$")&&(r[t]=n),r),{}),Ed=(e,r)=>typeof e=="string"&&e.startsWith("$")?Do(e,r):Pt(e)&&!ob(e)?Object.entries(e).reduce((t,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...Do(o,r),...e}):typeof o=="string"&&o.startsWith("$")?t[n]=Do(o,r):t[n]=o,t),{}):e,mr=e=>Object.entries(e).reduce((r,[t,n])=>(Pt(n)&&t&&n&&!t.startsWith("$")&&(hw.includes(t)&&(t=t+"#"),r[t]=n),r),{}),kr=(e,r,{label:t,parent:n=void 0},o,i=null)=>(i!==null&&(Pt(i)||ob(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:r,text:t||"",label:t,code:i||null,type:e.type,description:o}}),fr=(e,r,t=null,n=null,o=null,i=!1,s=null)=>({data:{id:jd(),source:o?r:e,target:o?e:r,label:n||"",isInverted:o,isEdgeAnimated:i,parent:s}}),br=(e,r=[])=>{const t={},n={};let o=[];if(e)for(const[i,s]of Object.entries(e))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=s:i!=="$"?n[i]=s:i==="$"&&(o=s);return{newConfig:t,updatedObject:n,arrayObject:o}},Lr=(e,r)=>{let t=Iu;const{view:n,borderColor:o,borderRadius:i,bgColor:s,textColor:a,fontSize:c,stepType:l}=r;e=n||e,l?t={...Tu}:e==="object"?t=Iu:e==="text"?t=_d:e==="array"?t=fw:e==="workflowStep"&&(t={...Tu});const d=t.data.viewProps;return t.data.viewProps={...d,borderRadius:i||(l?15:53),bgColor:s,borderColor:o,textColor:a,fontSize:c},t.data.config=r,{config:t}},An=(e,r)=>(e=r.find(n=>n.data.id===e)?`${e}.#`:e,e),Do=(e,{ids:r,jsnObjct:t})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=r.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!o)return e;const i=pw(o,t);return JSON.stringify(i).includes(e)?e:i||e}return e},pw=(e,r)=>{let t=e.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=br(s);return s=c.length?c:s,s[a]},i))(r)};function zr(e,r="root",t=[]){try{const{arrayObject:n}=br(e);n.length&&(e=n);const o=yr(e),i=mr(e);return Pt(e)?(tt(e)||tt(e)&&r==="root"||!tt(e)&&Object.keys(o).length||r==="root")&&t.push(r):t.push(r),Object.keys(i).length&&!tt(e)?wn({chldPth:null,itrblObjct:i,nodes:t,path:r}):tt(e)&&e.forEach((s,a)=>{const c=yr(s),l=mr(s),{newConfig:d,arrayObject:u}=br(s);let h=`${r}.${a}`;Pt(s)?Object.keys(c).length?(zr(c,h,t),Object.keys(l).length&&!tt(s)&&wn({chldPth:h,itrblObjct:l,nodes:t,path:r})):Object.keys(l).length&&!tt(s)?wn({chldPth:h,itrblObjct:l,nodes:t,path:r}):tt(s)&&ib({chldPth:h,item:s,nodes:t,path:r}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const wn=({chldPth:e,itrblObjct:r,nodes:t,path:n})=>Object.entries(r).forEach(([o,i],s)=>{const a=yr(i),c=mr(i),{newConfig:l,arrayObject:d}=br(i);d.length&&(i=d),n.split(".").slice(0,2).join(".");let u=e?`${e}.${o}`:`${n}.${o}`;if(Pt(i)&&!tt(i)){const h=Object.keys(a).length===0;if(h&&(Lr("array",l),t.push(u)),Object.keys(a).length){const p=tt(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let m=u;h&&(m=`${u}.${p}`),zr(i,m,t)}else Object.keys(c).length&&!tt(i)?wn({chldPth:u,itrblObjct:c,path:u,nodes:t}):zr(i,u,t)}else tt(i)&&zr(i,u,t)}),ib=({chldPth:e,item:r,nodes:t,path:n})=>r.forEach((o,i)=>{let s=`${e}.${i}`;const a=mr(o),c=yr(o);Pt(o)?!tt(o)&&Object.keys(c).length?zr(o,s,t):Object.keys(a).length&&!tt(o)?wn({chldPth:s,itrblObjct:a,path:n,nodes:t}):tt(o)&&ib({chldPth:s,item:o,nodes:t,path:n}):t.push(s)}),Cn=[];let Sn;function Pr(e,r="root",t=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:t,edges:n};const a=e;if(r==="root"&&(Cn.length=0),!Sn){const{nodes:d}=zr(e);Sn={ids:d,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:l}=i;try{r=An(r,t);const{newConfig:d,arrayObject:u}=br(e),h=Object.keys(s).length>0?s:d;u.length&&(e=u);const p=yr(e),m=mr(e),{label:y,collapsed:g,parent:b}=h;if(!Pt(e))t.push(kr(_d,r,{label:y||r,parent:b},e,a));else if(tt(e)||tt(e)&&r==="root"){const{config:v}=Lr("array",h),x=tt(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r==="root"?o:`${o} ${x}`;t.push(kr(v,r,{label:y||w,parent:b},e,tt(a)?{[o]:a}:a))}else if(!tt(e)&&Object.keys(p).length||r==="root"){const{config:v}=Lr(null,h),x=tt(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r.split("."),C=w[w.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const _=isNaN(Number(C))?C:w[w.length-2]+" "+S,k=r==="root"?o:_;let E=!1;Number.isNaN(Number(o))||(E=!0);const O=e;if(y){const{config:P}=Lr("object",h);t.push(kr(P,r,{label:y||`${y} ${x}`,parent:b},p,O))}else v.data.headerTitle=k,t.push(kr(v,r,{label:y,parent:b},p,O))}return g||(Object.keys(m).length&&!tt(e)?jn({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:m,nodes:t,path:r,newConfig:h}):tt(e)&&e.forEach((v,x)=>{v=Ed(v,Sn);const w=v,C=yr(v),S=mr(v),{newConfig:_,arrayObject:k}=br(v);k.length&&(v=k);const{config:E}=Lr(typeof v=="string"?"text":"array",_),{hideConfig:O,sourceLabel:P,label:A,isEdgeAnimated:M,parent:T}=_;c=c||O;const N=r==="root"&&i.isCntr,$=r.split(".").slice(0,2).join("."),I=Cn.includes($),W=i.isCntr&&I||x%2===0&&N;let ie=`${r}.${x}`;ie=An(ie,t),W&&Cn.push(ie),Pt(v)?Object.keys(C).length&&!tt(v)?(n.push(fr(r,ie,null,P,W,M)),Pr(v,ie,t,n,A||x,i,_)):Object.keys(S).length&&!tt(v)?jn({flowConfig:i,chldPth:ie,isInverted:W,edges:n,itrblObjct:S,nodes:t,path:r,newConfig:_,forceIsInverted:!0}):tt(v)?ab({flowConfig:i,chldPth:ie,edges:n,isInverted:W,item:v,nodes:t,path:r}):Pt(v)&&jn({flowConfig:i,chldPth:ie,isInverted:W,edges:n,itrblObjct:[v],nodes:t,path:r,newConfig:_}):(n.push(fr(r,ie,null,P,W,M)),t.push(kr(E,ie,{label:A||String(v),parent:T},v,w)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const jn=({chldPth:e,flowConfig:r,edges:t,itrblObjct:n,nodes:o,isInverted:i,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:l,sprtObjctKy:d}=r;return Object.entries(n).forEach(([u,h],p)=>{h=Ed(h,Sn);const m=h,y=yr(h),g=mr(h),{newConfig:b,arrayObject:v}=br(h);v.length&&(h=v);const{hideConfig:x,sourceLabel:w,label:C,content:S,target:_,targetLabel:k,collapsed:E,isEdgeAnimated:O,parent:P}=b;l=l||x;const A=s==="root"&&r.isCntr,M=s.split(".").slice(0,2).join("."),T=Cn.includes(M);c||(i=r.isCntr&&T||p%2===0&&A);let N=e?`${e}.${u}`:`${s}.${u}`;if(N=An(N,o),i&&Cn.push(N),_&&t.push(fr(N,_,null,k,i,O)),Pt(h)&&!tt(h)){t.push(fr(s,N,null,w,i,O));const $=d||Object.keys(y).length===0;if($){const I=S?"object":"array",{config:W}=Lr(I,b);W.data.headerTitle=S?C:null,o.push(kr(W,N,{label:C||u,parent:P},h,m))}if(Object.keys(y).length&&!l){const I=tt(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let W=N;$&&(W=`${N}.${I}`,W=An(W,o),t.push(fr(N,W,null,w,i,O))),Pr(h,W,o,t,C||u,r,b)}else Object.keys(g).length&&!tt(h)?jn({chldPth:N,flowConfig:r,itrblObjct:g,path:N,edges:t,nodes:o,newConfig:b,isInverted:i}):Pr(h,N,o,t,u,r,b)}else tt(h)&&(t.push(fr(s,N,null,w,i,O)),Pr(h,N,o,t,u,r,b))})},ab=({flowConfig:e,chldPth:r,edges:t,isInverted:n,item:o,nodes:i,path:s})=>o.forEach((a,c)=>{let l=`${r}.${c}`;l=An(l,i);const d=a;a=Ed(a,Sn);const u=mr(a),h=yr(a),{newConfig:p}=br(a),{collapsed:m,label:y,parent:g,sourceLabel:b,isEdgeAnimated:v,content:x}=p;Pt(a)?!tt(a)&&Object.keys(h).length?(t.push(fr(s,l,null,b,n,v)),Pr(a,l,i,t,c,e,p)):Object.keys(u).length&&!tt(a)&&!m?jn({chldPth:l,flowConfig:e,itrblObjct:u,path:s,edges:t,nodes:i,isInverted:n,newConfig:p}):tt(a)&&ab({flowConfig:e,chldPth:l,edges:t,isInverted:n,item:a,nodes:i,path:s}):(t.push(fr(s,l,null,b,n,v)),i.push(kr(_d,l,{label:y||String(a),parent:g},a,d)))});function gw(e,r){const t=new Set,n=(l,d="root")=>{if(!(!l||typeof l!="object")){l.$view==="parent"&&t.add(d),typeof l.$parent=="string"&&t.add(l.$parent);for(const[u,h]of Object.entries(l))(!u.startsWith("$")||u==="$")&&n(h,u==="$"?d:`${d}.${u}`)}};if(n(e),!t.size)return r;const o=new Map(r.nodes.map(l=>[l.data.id,l])),i=l=>{var p,m;let d=l.data.id;const u=new Set([l.data.id]);let h=l.data.parent;for(;h&&!u.has(h);)t.has(h)&&o.has(h)&&((p=Le(e,h))!=null&&p.$collapsed)&&(d=h),u.add(h),h=(m=o.get(h))==null?void 0:m.data.parent;return d},s=new Map(r.nodes.map(l=>[l.data.id,i(l)])),a=r.nodes.filter(l=>s.get(l.data.id)===l.data.id).map(l=>{if(!t.has(l.data.id))return l;const d=Le(e,l.data.id),u=!!(d!=null&&d.$collapsed);return{...l,data:{...l.data,...u?{type:"arrayView"}:{},config:{...l.data.config,parentContainer:!0,collapsed:u,...u?{labelBelow:!0,icon:(d==null?void 0:d.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(l=>l.data.id));return{nodes:a,edges:r.edges.flatMap(l=>{const d=s.get(l.data.source),u=s.get(l.data.target);return!d||!u||!c.has(d)||!c.has(u)?[]:d===l.data.source&&u===l.data.target?[l]:d===u?[]:[{...l,data:{...l.data,source:d,target:u,collapsedEndpoints:l.data.collapsedEndpoints??{source:l.data.source,target:l.data.target}}}]})}}function uo(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const r=new Map;return e.$connections.flatMap((t,n)=>{if(!t||typeof t!="object")return[];const o=t;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),s=r.get(i)??0;return r.set(i,s+1),[{value:o,key:`${i}#${s}`,index:n}]})}function sb(e,r,t){const n=uo(e).find(c=>c.key===r);if(!n)return e;const o=t(n.value),i=e.$connections.flatMap((c,l)=>l===n.index?o?[o]:[]:[c]);if(i.length)return{...e,$connections:i};const{$connections:s,...a}=e;return a}function yw(e){const r=[],t=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,s)=>t(i,`${o}.${s}`));for(const i of uo(n)){const s=i.value;r.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:s.target,type:typeof s.type=="string"?s.type:void 0,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,icon:typeof s.icon=="string"?s.icon:void 0,label:typeof s.label=="string"?s.label:void 0,color:typeof s.color=="string"?s.color:void 0,isEdgeDashed:s.style==="dashed",isEdgeAnimated:s.style==="animated",...["dashed","traveling"].includes(s.animationVariant)?{edgeAnimationVariant:s.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,s])=>[i,i==="$"?t(s,o):i.startsWith("$")?s:t(s,`${o}.${i}`)]))};return{json:t(e,"root"),edges:r}}const Br="root",Ou=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Vt(e){const r=e.split(".");for(r[0]===Br&&r.shift();r.length&&Ou(r[r.length-1]);)r.pop();return r.filter(t=>!Ou(t))}function fo(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Le(e,r){return Vt(r).reduce((t,n)=>{var o;if(t!=null)return(o=fo(t))==null?void 0:o[n]},e)}function mw(e){return Array.isArray(e)?[...e]:{...e}}function _t(e,r,t){const n=Vt(r),o=(i,s)=>{if(s===n.length)return t(i);const a=n[s],c=fo(i);if(c==null||typeof c!="object")return i;const l=o(c[a],s+1);if(Object.is(l,c[a]))return i;const d=mw(c);return d[a]=l,c!==i?{...i,$:d}:d};return o(e,0)}function nr(e,r,t){const n=t===""&&r!=="$content"||t===void 0||t===null;if(Array.isArray(e))return n?e:{[r]:t,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[r]:o[r]=t,o}function St(e,r,t,n){return _t(e,r,o=>t==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:nr(o,t,n))}const kd=(e,r,t)=>St(e,r,"$collapsed",t);function Rr(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const r=e.collapsedEndpoints??e,t=e.isInverted?r.target:r.source,n=e.isInverted?r.source:r.target,o=Vt(t).join("."),i=Vt(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function ur(e,r,t,n){if(r.connection){const a=r.connection;return _t(e,a.address,c=>sb(c,a.key,l=>{if(t==="$edgeIcon")return nr(l,"icon",n);if(t==="$edgeType")return nr(l,"type",n);if(t==="$edgeAnimationVariant")return nr(l,"animationVariant",n);if(t==="$sourceLabel"||t==="$edgeColor")return nr(l,t==="$sourceLabel"?"label":"color",n);const d=t==="$isEdgeAnimated"?"animated":"dashed";return n?{...l,style:d}:l.style===d?nr(l,"style",void 0):l}))}const{address:o,kind:i}=Rr(r),s=i==="target"&&t==="$sourceLabel"?"$targetLabel":i==="target"&&t==="$edgeType"?"$targetEdgeType":i==="target"&&t==="$edgeIcon"?"$targetIcon":i==="target"&&t==="$edgeAnimationVariant"?"$targetAnimationVariant":t;return _t(e,o,a=>nr(a,s,n))}const cb=(e,r,t)=>ur(ur(e,r,"$isEdgeAnimated",t==="animated"||void 0),r,"$isEdgeDashed",t==="dashed"||void 0);function Rd(e,r,t,n){let o=n||"";const i=_t(e,r,a=>{const c=fo(a);if(Array.isArray(c)){o=String(c.length);const d=[...c,t];return c===a?d:{...a,$:d}}const l=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!o){let d=1;for(;`node_${d}`in l;)d++;o=`node_${d}`}return l[o]=t,l}),s=Vt(r);return{json:i,address:[Br,...s,o].join(".")}}function lb(e,r){const t=Vt(r);if(!t.length)return e;const n=t[t.length-1],o=[Br,...t.slice(0,-1)].join(".");return _t(e,o,i=>{const s=fo(i);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return i;if(Array.isArray(s)){const l=s.filter((d,u)=>String(u)!==n);return s===i?l:{...i,$:l}}const{[n]:a,...c}=i;return c})}const db=(e,r,t,n)=>St(n?_t(e,r,o=>nr(o,"$targetLabel",n)):e,r,"$target",t);function Ad(e,r,t){const n=Le(e,r);return uo(n).some(({value:i})=>i.target===t.target&&i.sourceProperty===t.sourceProperty&&i.targetProperty===t.targetProperty)?e:_t(e,r,i=>nr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...t,id:t.id||jd()}]))}function ub(e,r){if(r.connection){const i=r.connection;return uo(Le(e,i.address)).some(s=>s.key===i.key)?{json:_t(e,i.address,s=>sb(s,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:t,kind:n}=Rr(r);return n==="hierarchy"?Le(e,t)===void 0?{json:e,removed:!1}:{json:_t(e,t,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:_t(e,t,i=>{const{$target:s,$targetLabel:a,...c}=i||{};return c}),removed:!0}}function hd(e,r={}){var v;const t=yw(e),{nodes:n,edges:o}=Pr(t.json,Br,[],[],r.title||"untitled",{hideDefaultObject:!!r.hideDefaultObject,sprtObjctKy:!!r.separateObjectKeys,isCntr:!!r.isCenter}),i=new Set(n.map(x=>x.data.id)),s=new Map;for(const x of n){const w=x.data.id;if(!w.endsWith(".0")||Le(e,w)!==void 0)continue;const C=w.slice(0,-2),S=Le(e,C);!i.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(_=>_.startsWith("$")&&_!=="$")&&s.set(w,C)}const a=x=>s.get(x)??x,c=new Set(n.flatMap(x=>x.data.parent?[a(x.data.parent)]:[])),l=new Map;if(r.isCenter){const x=new Map;for(const{data:w}of o){const C=Rr(w);if(C.kind==="hierarchy")l.set(a(C.address),!!w.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(w.isInverted?w.source:w.target);if(Vt(S).length!==1)continue;const _=!!w.isInverted;x.set(S,x.has(S)&&x.get(S)!==_?null:_)}}for(const[w]of l){const C=`${Br}.${Vt(w)[0]}`,S=x.get(C);typeof S=="boolean"&&l.set(w,S)}}const d=n.map(x=>{var E;const w=a(x.data.id),C=Le(e,w),S={...x.data,id:w};l.has(w)&&(S.config={...S.config,isInverted:l.get(w)});const _=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(O=>!O.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),c.has(w)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$view==="parent"&&(S.type="objectView",S.config={...S.config,typeView:"parent",parentContainer:!0,collapsed:!!C.$collapsed}),C.$view==="grid"){S.type="grid";const O=C.$gridSize;if(O!==void 0&&(!O||![O.width,O.height].every(P=>Number.isFinite(P)&&P>0&&P<=16384)))throw new Error("Invalid grid frame size.");S.config={...S.config,typeView:"grid",documentId:C.$document,gridSize:O},S.viewProps={...S.viewProps,bgColor:C.$bgColor??"transparent",borderRadius:C.$borderRadius??0,borderWidth:C.$borderWidth??0}}if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const O=C.$ports.filter(P=>P&&typeof P.id=="string"&&["source","target"].includes(P.role)&&["top","right","bottom","left"].includes(P.side));S.config={...S.config,ports:O}}if(S.parent&&(S.parent=a(S.parent)),typeof C.$label=="string"&&(S.label=C.$label,S.headerTitle=C.$label),typeof C.$subtitle=="string"&&(S.config={...S.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(S.viewProps={...S.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(S.viewProps={...S.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(S.viewProps={...S.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(S.viewProps={...S.viewProps,borderRadius:C.$borderRadius}),typeof C.$isNodeAnimated=="boolean"&&(S.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(S.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"||C.$contentFormat==="jsx"&&Array.isArray(C.$content)){S.config={...S.config,content:C.$content};const O=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(O))throw new Error("Invalid content format: expected markdown, html, or jsx.");S.config.contentFormat=O,C.$view||(S.type="objectView")}return(((E=S.config)==null?void 0:E.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(S.config={...S.config||{}},(C.$collapsed!==void 0||S.config.collapsed!==void 0)&&(S.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(S.config.icon=C.$icon)),{data:S}}),u=new Map,h=o.map(x=>{let w=a(x.data.source),C=a(x.data.target),S=x.data.isInverted;const _=Rr(x.data),k=l.get(a(_.address));_.kind==="hierarchy"&&k!==void 0&&k!==!!S&&([w,C]=[C,w],S=k);const E=`${w}->${C}`,O=u.get(E)??0;u.set(E,O+1);const P={...x.data,id:O?`${E}#${O}`:E,source:w,target:C,isInverted:S},A=Rr(P),M=Le(e,A.address);if(M&&typeof M=="object"){const T=M[A.kind==="target"?"$targetEdgeType":"$edgeType"];typeof T=="string"&&(P.type=T);const N=M[A.kind==="target"?"$targetIcon":"$edgeIcon"];typeof N=="string"&&(P.icon=N),M.$isEdgeAnimated!==void 0&&(P.isEdgeAnimated=!!M.$isEdgeAnimated);const $=M[A.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes($)&&(P.edgeAnimationVariant=$),M.$isEdgeDashed!==void 0&&(P.isEdgeDashed=!!M.$isEdgeDashed),M.$edgeColor&&(P.color=M.$edgeColor)}return{data:P}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const x=d.findIndex(w=>w.data.id===Br);x!==-1&&d.splice(x,1)}const p=new Set(d.map(x=>x.data.id));for(let x=h.length-1;x>=0;x--){const w=h[x].data,C=Rr(w);(!p.has(w.source)||!p.has(w.target)||C.kind==="hierarchy"&&((v=Le(e,C.address))==null?void 0:v.$hideParentEdge)===!0)&&h.splice(x,1)}h.push(...t.edges.filter(x=>p.has(x.data.source)&&p.has(x.data.target)));const m=gw(e,{nodes:d,edges:h}),y=m.nodes.filter(x=>{var w;return(w=x.data.config)==null?void 0:w.collapsed}).map(x=>Vt(x.data.id));if(!y.length)return m;const g=m.nodes.filter(x=>{const w=Vt(x.data.id);return!y.some(C=>C.length<w.length&&C.every((S,_)=>S===w[_]))}),b=new Set(g.map(x=>x.data.id));return{nodes:g,edges:m.edges.filter(x=>b.has(x.data.source)&&b.has(x.data.target))}}function bw(e,r){const t=new Set(e.filter(c=>{var l,d;return(d=(l=c.data)==null?void 0:l.config)==null?void 0:d.collapsed}).map(c=>c.data.id));if(!t.size)return{nodes:e,edges:r};const n=new Map(e.map(c=>[c.data.id,c])),o=new Set(e.map(c=>c.data.parent).filter(Boolean)),i=new Map(e.map(c=>{var h;let l=c.data.id,d=c.data.parent;const u=new Set([l]);for(;d&&!u.has(d);)t.has(d)&&(l=d),u.add(d),d=(h=n.get(d))==null?void 0:h.data.parent;return[c.data.id,l]})),s=new Map;for(const c of r){const l=c.data.isInverted?c.data.target:c.data.source,d=c.data.isInverted?c.data.source:c.data.target;(s.get(l)??s.set(l,[]).get(l)).push(d)}const a=new Set(e.filter(c=>i.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of t){if(o.has(c))continue;const l=[...s.get(c)||[]];for(;l.length;){const d=l.pop();t.has(d)||a.has(d)||(a.add(d),l.push(...s.get(d)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var l;return t.has(c.data.id)&&o.has(c.data.id)?{...c,data:{...c.data,type:"arrayView",label:c.data.label??c.data.headerTitle,config:{...c.data.config,parentContainer:!0,labelBelow:!0,icon:((l=c.data.config)==null?void 0:l.icon)||"PiStack"}}}:c}),edges:r.flatMap(c=>{const l=i.get(c.data.source)??c.data.source,d=i.get(c.data.target)??c.data.target;return a.has(l)||a.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Pd(e,r){const t=JSON.parse(e);let n=512;const o=(s,a=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Expected a JSON Schema object.");const c=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const d of Object.keys(s))if(!c.has(d))throw new Error(`Unsupported JSON Schema keyword: ${d}`);const l=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(u=>!["$ref","title","description"].includes(u)))throw new Error("Use $ref without sibling constraints.");if(typeof s.$ref!="string"||!s.$ref.startsWith("#/")||a.includes(s.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let d=t;for(const u of s.$ref.slice(2).split("/")){const h=u.replace(/~1/g,"/").replace(/~0/g,"~");if(!d||!Object.prototype.hasOwnProperty.call(d,h))throw new Error(`Unresolved reference: ${s.$ref}`);d=d[h]}return o(d,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(d=>d!=="anyOf"&&!l.includes(d)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(d=>o(d,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...l,"const","enum","type"].includes(h))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const d=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(d)||!d.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:d.map(h=>{if(h!==null&&!["string","number","boolean"].includes(typeof h))throw new Error("Only primitive literals are supported.");const p=h===null?"null":typeof h;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(m=>m===p||m==="integer"&&Number.isInteger(h)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:h}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(d=>typeof d!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(d=>d!=="type"&&!l.includes(d)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(d=>o({type:d},a))}}if((s.properties||s.required||s.additionalProperties!==void 0)&&s.type!=="object"&&s.type!==void 0)throw new Error("Object constraints require an object type.");if(s.items&&s.type!=="array")throw new Error("items requires an array type.");if(s.type==="object"||s.properties){if(s.additionalProperties!==void 0&&s.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!s.properties||typeof s.properties!="object"||Array.isArray(s.properties))throw new Error("Object schemas must declare properties.");if(s.required!==void 0&&(!Array.isArray(s.required)||s.required.some(u=>typeof u!="string"||!Object.prototype.hasOwnProperty.call(s.properties,u))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([u,h])=>[u,{type:o(h,a),optional:!(s.required??[]).includes(u)}]))}}if(s.type==="array")return{kind:"array",items:o(s.items,a)};if(["string","number","integer","boolean","null"].includes(s.type))return{kind:s.type};throw new Error("Every property must declare a supported type.")},i=o(t);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(s=>s.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:i.properties}}async function Md(e,r,t,n={}){var m;let o=512;const i=await import("typescript"),s=i.createSourceFile(r,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const c=new Map;for(const y of s.statements){if(!i.isInterfaceDeclaration(y)&&!i.isTypeAliasDeclaration(y))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((m=y.typeParameters)!=null&&m.length||c.has(y.name.text))throw new Error("Generics and duplicate declarations are not supported.");c.set(y.name.text,y)}const l=(y,g)=>{var C;const b={},v=y.find(S=>i.isIndexSignatureDeclaration(S));let x;if(v&&n.allowJson&&i.isIndexSignatureDeclaration(v)){if(y.filter(S=>i.isIndexSignatureDeclaration(S)).length!==1||v.parameters.length!==1||((C=v.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!v.type)throw new Error("Only one string-keyed index signature is supported for forms.");x=u(v.type,g)}return{kind:"object",properties:Object.fromEntries(y.filter(S=>S!==v||!x).map(S=>{if(!i.isPropertySignature(S)||!S.type||!S.name||!i.isIdentifier(S.name)&&!i.isStringLiteral(S.name))throw new Error("Only explicitly typed named properties are supported.");const _=u(S.type,g),k=n.allowJson?i.getJSDocTags(S).filter(E=>E.tagName.text==="port"):[];if(k.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(k.length){const[E,O,P]=String(k[0].comment??"").trim().split(/\s+/);if(E!=="config"||!O||P||!c.has(O))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const A=_.kind==="array";if((_.kind==="array"?_.items.kind:_.kind)!=="string")throw new Error(`Config port ${S.name.text} must be a string or string array reference`);b[S.name.text]={kind:"config",resourceType:O,multiple:A}}return[S.name.text,{type:_,optional:!!S.questionToken}]})),...x?{additionalProperties:x}:{},...Object.keys(b).length?{ports:b}:{}}},d=(y,g)=>{var C;if(g.includes(y))throw new Error("Recursive types are not supported.");const b=c.get(y);if(!b)throw new Error(`Unknown type: ${y}`);let v;if(i.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");v=l(b.members,[...g,y])}else v=u(b.type,[...g,y]);const x=n.allowJson?i.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!x.length)return v;if(v.kind!=="object")throw new Error("Node ports require an object interface");const w={...v.ports};for(const S of x){const[_,k,...E]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(_)||!/^[A-Za-z][\w-]*$/.test(k??""))throw new Error("Node ports require @port input|output|error Name");const O=E.length?JSON.parse(E.join(" ")):void 0;if(O!==void 0&&typeof O!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(w,k))throw new Error(`Duplicate port declaration: ${k}`);w[k]={kind:_,...typeof O=="string"?{label:O}:{}}}return{...v,ports:w}},u=(y,g)=>{var b,v,x;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(y.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(y.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(y.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(y.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(y))return u(y.type,g);if(i.isUnionTypeNode(y))return{kind:"union",types:y.types.map(w=>u(w,g))};if(i.isArrayTypeNode(y))return{kind:"array",items:u(y.elementType,g)};if(i.isTypeLiteralNode(y))return l(y.members,g);if(i.isLiteralTypeNode(y)){const w=y.literal;if(i.isStringLiteral(w))return{kind:"literal",value:w.text};if(i.isNumericLiteral(w))return{kind:"literal",value:Number(w.text)};if(w.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(w.kind===i.SyntaxKind.TrueKeyword||w.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:w.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(y)&&i.isIdentifier(y.typeName)){if(n.allowJson&&y.typeName.text==="Record"&&!c.has("Record")&&((b=y.typeArguments)==null?void 0:b.length)===2&&y.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:u(y.typeArguments[1],g)};if(y.typeName.text==="Array"&&((v=y.typeArguments)==null?void 0:v.length)===1)return{kind:"array",items:u(y.typeArguments[0],g)};if(!((x=y.typeArguments)!=null&&x.length))return d(y.typeName.text,g)}throw new Error(`Unsupported TypeScript type: ${y.getText(s)}`)},h=t??(c.has("Graph")?"Graph":c.size===1?[...c.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=d(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function fb(e,r){const t=await Md(e,r);if(Object.values(t.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:t.properties}}function pn(e,r){if(e.kind==="json"||r.kind==="json"||e.kind==="object"&&e.additionalProperties||r.kind==="object"&&r.additionalProperties)return!1;if(e.kind==="union")return e.types.every(t=>pn(t,r));if(r.kind==="union")return r.types.some(t=>pn(e,t));if(e.kind==="literal"){if(r.kind==="literal")return e.value===r.value;const t=e.value===null?"null":typeof e.value;return r.kind===t||r.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&r.kind==="number"?!0:e.kind==="array"&&r.kind==="array"?pn(e.items,r.items):e.kind==="object"&&r.kind==="object"?Object.entries(r.properties).every(([t,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,t)?e.properties[t]:void 0;return o?(n.optional||!o.optional)&&pn(o.type,n.type):n.optional}):e.kind===r.kind}function Id(e,r){if(!r.sourceProperty&&!r.targetProperty)return;const t=(s,a)=>{var d;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),l=Object.prototype.hasOwnProperty.call(e.nodes,c)?(d=e.nodes[c])==null?void 0:d.type:void 0;return a&&(l==null?void 0:l.kind)==="object"&&Object.prototype.hasOwnProperty.call(l.properties,a)?l.properties[a]:void 0},n=t(r.source,r.sourceProperty),o=t(r.target,r.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=s=>s.kind==="json"||s.kind==="object"&&(!!s.additionalProperties||Object.values(s.properties).some(a=>i(a.type)))||s.kind==="array"&&i(s.items)||s.kind==="union"&&s.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!pn(n.type,o.type))return`Incompatible property types: ${r.sourceProperty} -> ${r.targetProperty}.`}async function hb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const r=await e.text();if(/\.json$/i.test(e.name))return Pd(r,e.name);if(/\.ts$/i.test(e.name))return fb(r,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Nu=new WeakMap;function Hr(e){if(!e||typeof e!="object")return e;const r=Nu.get(e);if(r)return r;const t=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Hr(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:Hr(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:t,deleteProperty:t,defineProperty:t,setPrototypeOf:t,preventExtensions:t});return Nu.set(e,n),n}function Xr(e,r,t){var o;const n=r.split(".");for(let i=n.length;i>0;i--){const s=n.slice(0,i).join("."),a=(o=Le(e,s))==null?void 0:o.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(t,a.$type)?t[a.$type]:void 0;for(const u of n.slice(i))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(u)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,u)?c.properties[u].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const l=n.slice(i).join("."),d=Object.fromEntries(Object.entries(a.$fields??{}).filter(([u])=>!l||u.startsWith(`${l}.`)).map(([u,h])=>[l?u.slice(l.length+1):u,h]));return{type:c,fields:d,binding:a}}}async function Td(e,r){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const t=await e.text();if(e.name.endsWith(".ts")){if(!r.length||r.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(r);for(const s of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Md(t,e.name,s,{allowJson:!0});o.push([s,a]);for(const c of Object.values(a.ports??{}))c.resourceType&&i.add(c.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Pd(t,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function ho(e,r){return!e||("$in"in e?e.$in.includes(Le(r,e.$address)):Le(r,e.$address)===e.$equals)}function _n(e){const r=e.kind==="array"?e.items:e,t=r.kind==="union"?r.types:[r];if(t.every(n=>n.kind==="literal"))return t.map(n=>({label:String(n.value),value:n.value}))}function Wt(e,r,t){if(r===void 0||r==="")return t?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const s=Object.values(i).every(o);return n.delete(i),s};return o(r)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Wt(n,r,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return r===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(r)&&r.every(n=>!Wt(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!r||typeof r!="object"||Array.isArray(r)?"Expected an object":e.additionalProperties&&Object.entries(r).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Wt(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Wt(o.type,r[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return r===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(r)?void 0:"Expected a whole number";if(typeof r!==e.kind||typeof r=="number"&&!Number.isFinite(r))return`Expected ${e.kind}`}function $u(e,r){const t=r.address.split(".");if(t.shift()!=="root"||!t.length||t.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=t.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(t.some(a=>a.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...t].join("."),s=Le(e,i);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(r.op==="set"&&typeof r.value!="string")throw new Error("Node colors must be strings.");return St(e,i,n,r.op==="remove"?void 0:r.value)}return _t(e,i,a=>{const c=Array.isArray(a.$)?a.$:a;if(r.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||r.op==="set"&&Object.is(c[n],r.value))return a;const l=Array.isArray(c)?[...c]:{...c};if(Array.isArray(l)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=l.length))throw new Error("Invalid array address.");return r.op==="remove"?Array.isArray(l)?l.splice(Number(n),1):delete l[n]:Object.defineProperty(l,n,{value:structuredClone(r.value),enumerable:!0,writable:!0,configurable:!0}),c===a?l:{...a,$:l}})}function po(e,r,t){let n=$u(e,r.value===void 0?{op:"remove",address:r.address}:{op:"set",address:r.address,value:r.value});const o=t==null?void 0:t({...r,previousValue:Hr(Le(e,r.address)),data:Hr(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=$u(n,i)}return n}const En="data:image/svg+xml;base64,";function lr(e){if(e.startsWith(En))return!0;try{const r=new URL(e);return(r.protocol==="https:"||r.protocol==="http:")&&!r.username&&!r.password}catch{return!1}}async function vw(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const r=await e.text(),t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.doctype||t.querySelector("parsererror")||t.documentElement.localName!=="svg"||t.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(t.querySelector("script, foreignObject")||[...t.querySelectorAll("*")].some(i=>[...i.attributes].some(s=>/^on/i.test(s.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(r);let o="";for(const i of n)o+=String.fromCharCode(i);return En+btoa(o)}const Qt=({name:e,svg:r=!1,...t})=>{const[n,o]=j.useState(null),[i,s]=j.useState(!0),[a,c]=j.useState(!1),l=typeof e=="string"&&lr(e);if(j.useEffect(()=>{if(l||!e||e.length<2){o(null),s(!1);return}s(!0),c(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let h;switch(u){case"md":h=await import("react-icons/md");break;case"fa6":h=await import("react-icons/fa6");break;case"io5":h=await import("react-icons/io5");break;case"io":h=await import("react-icons/io");break;case"ti":h=await import("react-icons/ti");break;case"go":h=await import("react-icons/go");break;case"fi":h=await import("react-icons/fi");break;case"di":h=await import("react-icons/di");break;case"ai":h=await import("react-icons/ai");break;case"bs":h=await import("react-icons/bs");break;case"ri":h=await import("react-icons/ri");break;case"fc":h=await import("react-icons/fc");break;case"gi":h=await import("react-icons/gi");break;case"hi2":h=await import("react-icons/hi2");break;case"hi":h=await import("react-icons/hi");break;case"si":h=await import("react-icons/si");break;case"sl":h=await import("react-icons/sl");break;case"im":h=await import("react-icons/im");break;case"bi":h=await import("react-icons/bi");break;case"pi":h=await import("react-icons/pi");break;case"vsc":h=await import("react-icons/vsc");break;case"tb":h=await import("react-icons/tb");break;case"tfi":h=await import("react-icons/tfi");break;case"cg":h=await import("react-icons/cg");break;case"lia":h=await import("react-icons/lia");break;case"lu":h=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${u}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${u}`);o(()=>p)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),c(!0),o(null)}finally{s(!1)}})()},[e,l]),l){const{size:d=80,style:u,...h}=t;return r?f.jsx("image",{...h,href:e,width:d,height:d,preserveAspectRatio:"xMidYMid meet",style:u}):f.jsx("img",{...h,src:e,alt:"",width:d,height:d,referrerPolicy:"no-referrer",style:{objectFit:"contain",...u}})}return i||!n?null:f.jsx(n,{...t})};function xw(e,r){let t=e;for(const n of r){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(s=>s.startsWith("$")||["__proto__","prototype","constructor"].includes(s)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Pn(i),t=po(t,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Pn(t),t}function $n(e,r,t){const n=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(!(!n||!t||!Object.prototype.hasOwnProperty.call(t,n.type)))return{address:n.address,type:t[n.type],fields:n.fields??{}}}function Pn(e){if(!(!e||typeof e!="object"))for(const[r,t]of Object.entries(e)){if(r.startsWith("$")||["__proto__","prototype","constructor"].includes(r))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${r}`);Pn(t)}}function ww(e,r,t){Pn(r.value);const n=po(e,r,t);return Pn(n),n}function pb(e,r){const t=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const s=Le(r,n.$state);return s==null?"":typeof s=="object"?JSON.stringify(s,null,2):String(s)}let i=n;for(const[s,a]of Object.entries(n)){const c=t(a,s);c!==a&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,s,{value:c,enumerable:!0,writable:!0,configurable:!0}))}return i};return t(e)}const Cw=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),Sw=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,gn=(e,r)=>JSON.stringify([e,r]);function Mn(e,r){if(e.kind==="union"){const t=e.types.find(n=>n.kind===(Array.isArray(r)?"array":r===null?"null":typeof r)||n.kind==="literal"&&Object.is(n.value,r));return Mn(t??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},r)}return e.kind!=="json"?e:Array.isArray(r)?{kind:"array",items:{kind:"json"}}:r!==null&&typeof r=="object"||r===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:r===null?"null":typeof r}}function yn(e){const r=Mn(e,void 0);return r.kind==="object"?{}:r.kind==="array"?[]:r.kind==="literal"?r.value:r.kind==="number"||r.kind==="integer"?0:r.kind==="boolean"?!1:r.kind==="null"?null:""}function qu(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"&&!_n(e)?e.types:[e]}function jw(e,r,t){if(r.address===t.address)return;const n=Le(e,r.address),o=(i,s)=>s===void 0?!1:i.kind==="union"?i.types.some(a=>o(a,s)):i.kind==="array"?Array.isArray(s)&&s.every(a=>o(i.items,a)):i.kind==="object"?!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(i.properties).every(([a,c])=>c.optional&&s[a]===void 0||o(c.type,s[a]))&&Object.entries(s).every(([a,c])=>Object.prototype.hasOwnProperty.call(i.properties,a)||!i.additionalProperties||o(i.additionalProperties,c)):s===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Wt(i,s,!0);if(o(t.type,n))return structuredClone(n)}function gb(e,r,t,n){var c,l;const o={sourceSchema:t,sourceBindings:r,nodes:[],edges:[],schema:{...t},bindings:{...r},slots:new Map,containers:new Map},i=new Set(n.map(d=>d.data.id)),s=new Map(n.flatMap(d=>{const u=r[d.data.id];return u&&t[u.type]?[[u.address,d.data.id]]:[]})),a=(d,u,h,p,m,y=!1)=>{var _,k,E,O,P;if(m>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const g=Le(e,u),b=Mn(h,g),v=b.kind!=="object"&&b.kind!=="array";o.containers.set(d,{address:u,type:b,declared:h,scalar:v});const x=`__form:${d}`,w={...(_=o.bindings[d])==null?void 0:_.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...y?{resource:{label:"output",...b.kind==="object"?(k=b.ports)==null?void 0:k.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(g??{}).filter(A=>!Object.prototype.hasOwnProperty.call(b.properties,A)&&b.additionalProperties).map(A=>[A,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(g)?g:[]).map((A,M)=>[String(M),{type:b.items,optional:!0}])):{value:{type:_n(h)?h:b,optional:!1}};for(const[A,M]of Object.entries(S)){if(!Cw(A))throw new Error(`Unsupported structured property key: ${A}`);const T=v?u:`${u}.${A}`,N=Le(e,T),$=Mn(M.type,N),I=$.kind==="object"||$.kind==="array",W=(E=C.ports)==null?void 0:E[A],ie=(W==null?void 0:W.kind)==="config"&&(((O=w[A])==null?void 0:O.$options)||_n(M.type)),ae=M.type.kind==="json"||M.type.kind==="union"&&!_n(M.type);if(((P=w[A])==null?void 0:P.$control)==="upload"||!I&&b.kind!=="array"&&(!ae||v)||ie){C.properties[A]={...M,type:M.type.kind==="json"?$:M.type};continue}const re=s.get(T)??Sw(T),ye=b.kind==="array"?`Item ${Number(A)+1}`:A,be={address:T,owner:d,field:A,type:M.type,label:ye,nodeId:re,present:N!==void 0};if(o.slots.set(gn(d,A),be),C.ports[A]={kind:"config",resourceType:`__form:${re}`},N===void 0||(o.edges.push({data:{id:`__form-edge:${d}:${A}`,source:re,target:d,sourceProperty:"output:resource",targetProperty:`config:${A}`,isEdgeDashed:!0}}),o.containers.has(re)||s.has(T)))continue;if(i.has(re))throw new Error(`Structured node identity conflict: ${re}`);i.add(re);const L={data:{id:re,type:"objectView",label:ye,headerTitle:ye,description:{},config:{form:!0,icon:$.kind==="array"?"PiListNumbers":I?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(L),a(re,T,M.type,p,m+1,!0);const z=o.schema[`__form:${re}`];L.data.description=Object.fromEntries(Object.keys(z.properties).map(G=>[G,Le(e,$.kind==="array"||$.kind==="object"?`${T}.${G}`:T)]).filter(([,G])=>G!==void 0))}o.schema[x]=C,o.bindings[d]={...o.bindings[d],address:u,type:x,fields:w}};for(const d of n){const u=r[d.data.id];if(u!=null&&u.portResources)continue;const h=u&&t[u.type];!u||!h||Le(e,u.address)===void 0||a(d.data.id,u.address,h,(c=d.data.viewProps)==null?void 0:c.bgColor,0,o.edges.some(p=>p.data.source===d.data.id))}for(const d of o.edges){const u=o.bindings[d.data.source],h=o.schema[u.type].ports;h.resource={...h.resource,kind:"output",label:((l=h.resource)==null?void 0:l.label)??"output"}}return o}const Ar=(e="reference")=>({kind:e,text:"",paths:[""]}),yb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(r=>["__proto__","constructor","prototype"].includes(r));function _w(e,r){const t=new Set(r.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!yb(a)||!t.has(a)))throw new Error("Choose an available reference.");return[...s.paths,...s.fallback===void 0?[]:[JSON.stringify(s.fallback)]].join(" || ")},o=s=>{if(s.includes("{{")||s.includes("}}"))throw new Error("Use a reference part for dynamic values.");return s},i=s=>s.map(a=>{if(a.kind==="text")return o(a.text);if(a.kind==="conditional"){if(a.paths.length!==1||a.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(a)}}}${o(a.text)}{{/if}}`}return`{{${n(a)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const s=i(e.parts);return e.mode==="condition"?`${s} == ${JSON.stringify(e.comparison)}`:s}if(e.mode==="json"){const s=e.fields.map(a=>a.key);if(!s.length||new Set(s).size!==s.length||s.some(a=>!a||["__proto__","constructor","prototype"].includes(a)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(a=>[a.key,i(a.parts)])))}return i(e.parts)}async function Ew(e){const r=await import("typescript"),t=s=>{const a=r.createSourceFile("binding.ts",`(${s})`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!r.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const l=Ar();l.paths=[];const d=u=>{if(r.isParenthesizedExpression(u))return d(u.expression);if(r.isBinaryExpression(u)&&u.operatorToken.kind===r.SyntaxKind.BarBarToken){d(u.left),d(u.right);return}if(r.isStringLiteral(u)){if(l.fallback!==void 0)throw new Error("Multiple fallback values.");l.fallback=u.text;return}const h=u.getText(a);if(!yb(h)||l.fallback!==void 0)throw new Error("Unsupported reference expression.");l.paths.push(h)};if(d(c.expression),!l.paths.length)throw new Error("A binding needs a reference.");return l},n=s=>{const a=[];let c=0;const l=/\{\{([\s\S]*?)\}\}/g;for(const d of s.matchAll(l)){const u=d.index;if(u<c)continue;u>c&&a.push({...Ar("text"),text:s.slice(c,u)});const h=d[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",u+d[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...t(h.slice(4)),kind:"conditional",text:s.slice(u+d[0].length,p)}),c=p+7}else a.push(t(h)),c=u+d[0].length}return c<s.length&&a.push({...Ar("text"),text:s.slice(c)}),a},o={mode:"reference",parts:[Ar()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const s=JSON.parse(e);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(a=>typeof a=="string"))return{...o,mode:"json",fields:Object.entries(s).map(([a,c])=>({key:a,parts:n(c)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const s=r.createSourceFile("condition.ts",`value ${i[1].text}`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&r.isExpressionStatement(a)&&r.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===r.SyntaxKind.EqualsEqualsToken&&r.isStringLiteral(a.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:a.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function Lu({parts:e,references:r,onChange:t,disabled:n}){const o=(i,s)=>t(e.map((a,c)=>c===i?{...a,...s}:a));return f.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,s)=>f.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[f.jsxs("legend",{children:["Part ",s+1]}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsxs("span",{"data-form-select":"",style:{flex:1},children:[f.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:a=>o(s,{kind:a.target.value}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"text",children:"Text"}),f.jsx("option",{value:"conditional",children:"Conditional text"})]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Ne,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t(e.filter((a,c)=>c!==s))})]}),i.kind!=="text"&&f.jsxs(f.Fragment,{children:[i.paths.map((a,c)=>f.jsxs("label",{children:["Reference ",c+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${c+1}`,disabled:n,value:a,onChange:l=>o(s,{paths:i.paths.map((d,u)=>u===c?l.target.value:d)}),children:[f.jsx("option",{value:"",children:"Select reference"}),r.map(l=>f.jsx("option",{value:l.path,children:l.label},l.path))]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),i.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Ne,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(s,{paths:[...i.paths,""]})}),f.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:a=>o(s,{fallback:a.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&f.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:a=>o(s,{fallback:a.target.value})})]})]}),i.kind!=="reference"&&f.jsxs("label",{children:["Text",f.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:a=>o(s,{text:a.target.value})})]})]},s)),f.jsx(Ne,{"aria-label":"Add part",title:"Add part",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t([...e,Ar()])})]})}function kw({label:e,value:r,references:t,disabled:n,onChange:o}){const[i,s]=j.useState(),[a,c]=j.useState(""),[l,d]=j.useState(!1),u=async()=>{d(!0),c("");try{s(await Ew(typeof r=="string"?r:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{d(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Ne,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||l,onClick:u}),typeof r=="string"&&r.includes("{{")&&f.jsx("span",{children:"Bound value"}),i&&f.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Binding mode",f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:h=>s({...i,mode:h.target.value,parts:[Ar()]}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"condition",children:"Equals"}),f.jsx("option",{value:"template",children:"Text template"}),f.jsx("option",{value:"json",children:"JSON output"})]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?f.jsxs(f.Fragment,{children:[i.fields.map((h,p)=>f.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Output field name",f.jsx("input",{"aria-label":"Output field name",value:h.key,onChange:m=>s({...i,fields:i.fields.map((y,g)=>g===p?{...y,key:m.target.value}:y)})})]}),f.jsx(Lu,{parts:h.parts,references:t,disabled:n,onChange:m=>s({...i,fields:i.fields.map((y,g)=>g===p?{...y,parts:m}:y)})}),f.jsx(Ne,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:i.fields.filter((m,y)=>y!==p)})})]},p)),f.jsx(Ne,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:[...i.fields,{key:"",parts:[Ar()]}]})})]}):f.jsx(Lu,{parts:i.parts,references:t,disabled:n,onChange:h=>s({...i,parts:h})}),i.mode==="condition"&&f.jsxs("label",{children:["Equals",f.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:h=>s({...i,comparison:h.target.value})})]}),f.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[f.jsx(Ne,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(_w(i,t)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Ne,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function Rw({nodeAddress:e,onOpen:r}){const{structured:t,data:n,callbacks:o,editable:i,onFieldCreate:s}=j.useContext(Mt),a=He(),[c,l]=j.useState(""),[d,u]=j.useState("0"),[h,p]=j.useState(""),m=t==null?void 0:t.containers.get(e);if(!m||!n||!t)return null;const y=a.readOnly||a.config.editable===!1||!i,g=Le(n,m.address),b=qu(m.declared),v=m.type.kind==="array"?m.type.items:m.type.kind==="object"?m.type.additionalProperties:void 0,x=v?qu(v):[],w=!!s&&m.type.kind==="object"&&(v==null?void 0:v.kind)==="json",C=M=>M.kind==="literal"?String(M.value):M.kind==="string"?"Text":$t(M.kind),S=[...t.slots.values()].filter(M=>M.owner===e),_=(M,T)=>{var N;return(N=o.onFormChange)==null?void 0:N.call(o,{data:n,nodeAddress:m.address,address:M,previousValue:Le(n,M),value:T})},k=M=>{var T;a.setSelectedNodeIds([M]),(T=a.engineRef.current)==null||T.focusNode(M,90,!1)},E=(M,T)=>{if(!Array.isArray(g))return;const N=[...g];[N[M],N[M+T]]=[N[M+T],N[M]],_(m.address,N)},O=()=>{const M=x[Number(d)]??x[0];if(M)if(m.type.kind==="array")_(m.address,[...Array.isArray(g)?g:[],yn(M)]);else{if(!c||c.includes(".")||c.startsWith("$")||["__proto__","constructor","prototype"].includes(c)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(g,c)){p("Property already exists.");return}w&&(d==="file"||d==="files")?s==null||s({data:n,nodeAddress:m.address,address:`${m.address}.${c}`,previousValue:void 0,value:d==="files"?[]:""},{$control:"upload"}):_(`${m.address}.${c}`,yn(M)),l(""),p("")}},P=m.type.kind==="object"&&!!m.type.additionalProperties,A=m.type.kind==="array";return f.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[b.length>1&&f.jsxs("label",{children:["Value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsx(At,{"aria-label":"Value type",disabled:y,value:String(b.findIndex(M=>Mn(M,g).kind===m.type.kind)),onValueChange:M=>_(m.address,yn(b[Number(M)])),children:b.map((M,T)=>f.jsx("option",{value:T,children:C(M)},T))})})]}),S.map((M,T)=>f.jsxs("div",{"data-structured-slot":M.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[M.type.kind==="array"?f.jsx(Z.PiListNumbers,{size:20}):f.jsx(Z.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:$t(M.label)}),f.jsx(Ne,{"aria-label":`${M.present?r?"Edit":"Focus":"Create"} ${$t(M.label)}`,title:`${M.present?r?"Edit":"Focus":"Create"} ${$t(M.label)}`,icon:M.present?f.jsx(Z.PiMagnifyingGlass,{size:18}):f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:y&&!M.present,onClick:N=>{var $;M.present?r?r(M.nodeId):(($=N.currentTarget.closest("dialog"))==null||$.close(),k(M.nodeId)):_(M.address,yn(M.type))}}),A&&f.jsxs(f.Fragment,{children:[f.jsx(Ne,{"aria-label":`Move item ${T+1} up`,icon:f.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:y||T===0,onClick:()=>E(T,-1)}),f.jsx(Ne,{"aria-label":`Move item ${T+1} down`,icon:f.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:y||T===S.length-1,onClick:()=>E(T,1)})]}),M.present&&f.jsx(Ne,{"aria-label":`Remove ${$t(M.label)}`,icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:y,onClick:()=>A?_(m.address,g.filter((N,$)=>$!==T)):_(M.address,void 0)})]},M.address)),(A||P)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[P&&f.jsxs("label",{style:{flex:"1 1 120px",minWidth:0,display:"grid",gap:8},children:["Property name",f.jsx("input",{"aria-label":"Property name",placeholder:"Required",value:c,disabled:y,onChange:M=>l(M.target.value)})]}),x.length>1&&f.jsxs("label",{style:{flex:"1 1 100px",minWidth:0,display:"grid",gap:8},children:["New value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsxs(At,{"aria-label":"New value type",value:d,disabled:y,onValueChange:u,children:[x.map((M,T)=>f.jsx("option",{value:T,children:C(M)},T)),w&&f.jsx("option",{value:"file",children:"File"}),w&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...P||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Ne,{"aria-label":A?"Add item":"Add property",icon:f.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:y,onClick:O})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Mt=j.createContext({callbacks:{}}),Jn=so.default.div`
|
|
59
59
|
--flow-form-input-radius: 16px;
|
|
60
60
|
--flow-form-input-background: color-mix(
|
|
61
61
|
in srgb,
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
font-size: 14px;
|
|
207
207
|
margin-top: 8px;
|
|
208
208
|
}
|
|
209
|
-
`;function Fu({request:e,property:r,config:t,value:n,disabled:o}){var pe,fe,Y,H,we;const{callbacks:i,structured:s,references:a}=j.useContext(Mt),{themeColor:c}=He(),{background:l}=st(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(h),[y,g]=j.useState(""),[b,v]=j.useState(0),x=j.useRef(null),w=j.useRef(),[C,S]=j.useState(!1),[_,k]=j.useState(!1),[E,O]=j.useState(),P=((pe=t.$options)==null?void 0:pe.$source)==="callback",A=i.resolveFormOptions,{data:M,address:T,nodeAddress:N,nodeId:$}=e;j.useEffect(()=>(S(!1),k(!1),()=>{var J;(J=w.current)==null||J.abort(),w.current=void 0}),[T,N,$,o,h,t.$control,(fe=t.$upload)==null?void 0:fe.accept,(Y=t.$upload)==null?void 0:Y.maxSizeBytes]);const I=j.useRef(M);I.current=M;const W=JSON.stringify([T,$,(H=t.$options)!=null&&H.$dependsOn?t.$options.$dependsOn.map(J=>Le(M,J)):Le(M,N)]);j.useEffect(()=>{m(h),g("")},[h,T,$]),j.useEffect(()=>{if(!P)return;const J=new AbortController;return Promise.resolve().then(()=>{if(!A)throw new Error("No options resolver configured");return A({address:T,nodeAddress:N,nodeId:$,data:Hr(I.current),signal:J.signal})}).then(ve=>{if(!Array.isArray(ve)||ve.some(Q=>!Q||typeof Q.label!="string"||!["string","number","boolean"].includes(typeof Q.value)&&Q.value!==null))throw new Error("Invalid options response");J.signal.aborted||O({key:W,options:ve})}).catch(ve=>{J.signal.aborted||O({key:W,options:[],error:ve instanceof Error?ve.message:"Options unavailable"})}),()=>J.abort()},[P,A,W,T,N,$,b]);const ie=P&&(E==null?void 0:E.key)!==W,ae=P?(E==null?void 0:E.key)===W?E.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:_n(r.type),re=r.type.kind==="array",ye=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(ae?re||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),be=!r.optional||!!t.$requiredWhen&&ho(t.$requiredWhen,M),L=be?"Required":"Optional",z=ye!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=y||P&&(E==null?void 0:E.key)===W&&E.error||!z&&Wt(r.type,n,be),D=$t(t.$label??T.split(".").pop()),se=J=>{var ve;if(!(o||Object.is(J,n)))try{(ve=i.onFormChange)==null||ve.call(i,{...e,previousValue:n,value:J}),g("")}catch(Q){g(Q instanceof Error?Q.message:"Unable to update field")}},X=j.useRef(se);j.useLayoutEffect(()=>{X.current=se});const le=()=>{if(u){try{const Ee=p===""&&r.optional?void 0:JSON.parse(p),Ae=Wt(r.type,Ee,be);if(Ae){g(Ae);return}se(Ee)}catch{g("Enter valid JSON")}return}const J=r.type.kind==="number"||r.type.kind==="integer",ve=p===""&&r.optional?void 0:J&&p!==""?Number(p):p,Q=Wt(r.type,ve,be);if(J&&Q&&p!==""){g(Q);return}se(ve)},ue=async J=>{var Q,Ee,Ae;if(o||w.current||!J.length)return;const ve=new AbortController;w.current=ve,g(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!re&&J.length!==1)throw new Error("Choose one file for this field.");if(!i.uploadFormFile)throw new Error("No file upload handler configured.");const qe=(Ee=(Q=t.$upload)==null?void 0:Q.accept)==null?void 0:Ee.split(",").map(De=>De.trim().toLowerCase()).filter(Boolean);for(const De of J){if(((Ae=t.$upload)==null?void 0:Ae.maxSizeBytes)!==void 0&&De.size>t.$upload.maxSizeBytes)throw new Error(`${De.name} exceeds the file size limit.`);if(qe!=null&&qe.length&&!qe.some(rt=>rt.startsWith(".")?De.name.toLowerCase().endsWith(rt):rt.endsWith("/*")?De.type.toLowerCase().startsWith(rt.slice(0,-1)):De.type.toLowerCase()===rt))throw new Error(`${De.name} is not an accepted file type.`)}const Je=await Promise.all(J.map(async De=>{const rt=await i.uploadFormFile({...e,data:Hr(M),file:De,signal:ve.signal});if(typeof rt!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ft;try{ft=new URL(rt)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ft.protocol)||ft.username||ft.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return rt}));if(ve.signal.aborted||w.current!==ve)return;const Fe=re?[...Array.isArray(n)?n:[],...Je]:Je[0],ct=Wt(r.type,Fe,be);if(ct)throw new Error(ct);X.current(Fe)}catch(qe){ve.signal.aborted||g(qe instanceof Error?qe.message:"Unable to upload file."),ve.abort()}finally{w.current===ve&&(w.current=void 0,S(!1))}},Ce={id:d,disabled:o,"aria-label":D,"aria-required":be,"aria-invalid":!!G,"aria-describedby":G?`${d}-error`:void 0},je=Pe(c);return f.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(N.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[D,be?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${D}`,title:`Reset ${D}`,disabled:o||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>se(void 0),children:f.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&ye!=="upload"&&f.jsx(kw,{label:D,value:n,references:a,disabled:o,onChange:se}),ye==="upload"?f.jsxs("div",{"data-form-upload":re?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":Pe(l),outline:_?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),!o&&!C&&(J.dataTransfer.dropEffect="copy",k(!0))},onDragLeave:J=>{J.currentTarget.contains(J.relatedTarget)||k(!1)},onDrop:J=>{J.preventDefault(),J.stopPropagation(),k(!1),ue(Array.from(J.dataTransfer.files))},children:[f.jsx("input",{ref:x,type:"file",hidden:!0,"aria-label":`Upload ${D}`,accept:(we=t.$upload)==null?void 0:we.accept,multiple:re,disabled:o||C,onChange:J=>{const ve=Array.from(J.target.files??[]);J.target.value="",ue(ve)}}),f.jsxs("div",{"data-upload-items":"",children:[(re?Array.isArray(n)?n:[]:n?[n]:[]).map((J,ve)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof J=="string"&&lr(J)&&f.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer","aria-label":`${D} file ${ve+1}`,children:[f.jsx(Z.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Xt,{name:J,size:120,onError:Q=>{Q.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!re&&f.jsx(Ne,{"aria-label":`Replace ${D}`,title:`Replace ${D}`,icon:f.jsx(Z.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>{var Q;return(Q=x.current)==null?void 0:Q.click()}}),f.jsx(Ne,{"aria-label":`Remove ${D} file ${ve+1}`,title:"Remove file",icon:f.jsx(Z.PiTrash,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>se(re&&Array.isArray(n)?n.filter((Q,Ee)=>Ee!==ve):"")})]})]},`${ve}:${J}`)),(re||!n)&&f.jsx("button",{...Ce,type:"button","data-upload-drop":"",title:`Upload ${D}`,disabled:o||C,onClick:()=>{var J;return(J=x.current)==null?void 0:J.click()},children:f.jsx(Z.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):z?null:ye==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(At,{...Ce,disabled:o||ie||!!(E!=null&&E.error),labelCase:"preserve",value:String((ae==null?void 0:ae.findIndex(J=>Object.is(J.value,n)))??-1),onValueChange:J=>{const ve=ae==null?void 0:ae[Number(J)];ve&&se(ve.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):L}),ae==null?void 0:ae.map((J,ve)=>f.jsx("option",{value:ve,children:$t(J.label)||J.label},ve))]})}):ye==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":D,"aria-describedby":Ce["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ae==null?void 0:ae.map((J,ve)=>{const Q=re?Array.isArray(n)&&n.includes(J.value):Object.is(n,J.value);return f.jsx("button",{type:"button",disabled:o||ie,"aria-pressed":Q,style:{padding:"8px 16px",borderRadius:24,border:0,color:Q?je:"inherit",background:Q?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>se(re?Q?n.filter(Ee=>Ee!==J.value):[...Array.isArray(n)?n:[],J.value]:J.value),children:$t(J.label)||J.label},ve)}),ie&&f.jsx("span",{role:"status",children:"Loading..."})]}):ye==="textarea"?f.jsx("textarea",{...Ce,placeholder:L,value:p,onChange:J=>m(J.target.value),onBlur:le}):f.jsx("input",{...Ce,placeholder:L,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:J=>m(J.target.value),onBlur:le,onKeyDown:J=>{J.key==="Enter"&&le(),J.key==="Escape"&&m(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${d}-error`,children:G}),P&&(E==null?void 0:E.error)&&f.jsx("button",{type:"button",disabled:o,onClick:()=>{O(void 0),v(b+1)},children:"Retry"})]})}function Od({nodeAddress:e,structured:r=!1}){return r?f.jsx(Aw,{nodeAddress:e},e):f.jsx(pd,{nodeAddress:e})}function Aw({nodeAddress:e}){var u,h,p;const r=j.useContext(Mt),[t,n]=j.useState([]),o=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,i=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!o||!i))return gb(r.data,i,o,[{data:{id:e,type:"objectView"}}])},[r.data,i,o,e]);if(!s)return f.jsx(pd,{nodeAddress:e});const a=t.findIndex(m=>!s.containers.has(m)),c=a<0?t:t.slice(0,a),l=c.at(-1)??e,d=(p=[...s.slots.values()].find(m=>m.nodeId===l))==null?void 0:p.label;return f.jsxs(Mt.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ne,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Z.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:$t(d)})]}),f.jsx(pd,{nodeAddress:l,onOpen:m=>n([...c,m])},l)]})}function pd({nodeAddress:e,onOpen:r}){var S,_;const{data:t,schema:n,callbacks:o,bindings:i,editable:s,renderForm:a,structured:c}=j.useContext(Mt),{readOnly:l,config:d,colorMode:u}=He(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(Jn,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=i?$n(i,e,n):void 0,m=i?p:n&&Xr(t,e,n);if(!m)return f.jsx(Jn,{$colorMode:u,role:"status",children:"Form schema unavailable."});const y=(p==null?void 0:p.address)??e,g=Le(t,y),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(Jn,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const v=Object.entries(m.type.properties).filter(([k])=>{var E;return ho((E=m.fields[k])==null?void 0:E.$visibleWhen,t)}),x=v.length>8||v.some(([k])=>{var E;return(E=m.fields[k])==null?void 0:E.$section}),w=new Map;for(const k of v){const[E,O]=k,P=x?$t(((_=m.fields[E])==null?void 0:_.$section)??(O.type.kind==="object"||O.type.kind==="array"?E:O.optional?"Options":"General")):"";w.has(P)||w.set(P,[]),w.get(P).push(k)}const C=([k,E])=>f.jsx(Fu,{request:{data:t,address:b?y:`${y}.${k}`,nodeAddress:y,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:E,config:m.fields[k]??{},value:b?g:g==null?void 0:g[k],disabled:l||d.editable===!1||!(s??!!o.onJsonChange)},`${(g==null?void 0:g.id)??e}:${k}`);return f.jsxs(Jn,{$colorMode:u,"data-flow-form":e,onClick:k=>k.stopPropagation(),onDoubleClick:k=>k.stopPropagation(),children:[c&&f.jsx(Rw,{nodeAddress:e,onOpen:r}),!c&&p&&m.type.additionalProperties&&v.length===0&&f.jsx(Fu,{request:{data:t,address:y,nodeAddress:y},property:{type:m.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:l||d.editable===!1||!s}),[...w].map(([k,E])=>x&&E.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:k}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),E.map(C)]},k):E.map(C))]})}function mb(e){const{viewData:r}=j.useContext(Mt),{nodeById:t,edgeById:n,parentIds:o}=vr();if(r){const i=Le(r,e),s=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const s=i.isInverted?i.target:i.source,a=i.isInverted?i.source:i.target;return s===e&&a!==e&&t.has(a)})}function In(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function Tn(e,r,t,n){return{borderColor:r,borderWidth:In(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Rm(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function bb({label:e,value:r,options:t,onChange:n,disabled:o}){var i;return f.jsxs(At,{"aria-label":e,title:`Animation: ${((i=t.find(s=>s.value===r))==null?void 0:i.label)??"Mixed"}`,value:r,style:{width:104},disabled:o,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Nd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:o}){const{callbacks:i,readOnly:s,themeColor:a,colorMode:c}=He(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=st(),m=c==="dark"?Zr:Pe(p),y=j.useRef(null),g=j.useRef(null),b=j.useRef(0),[v,x]=j.useState(!1),[w,C]=j.useState("icons"),[S,_]=j.useState([]),[k,E]=j.useState("loading"),[O,P]=j.useState(""),[A,M]=j.useState(0),[T,N]=j.useState(""),[$,I]=j.useState(""),[W,ie]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!v)return;let D=!0;return import("react-icons/pi").then(se=>{D&&(_(Object.keys(se).filter(X=>X.startsWith("Pi")).sort()),E("ready"))}).catch(()=>{D&&E("unavailable")}),()=>{D=!1}},[v]),j.useEffect(()=>{var D;s&&((D=y.current)==null||D.close())},[s]),j.useEffect(()=>{var D,se,X;if(n!==void 0){if(!n||s){(D=y.current)==null||D.close();return}(se=y.current)!=null&&se.open||(I(""),C(t==="PiFileSvg"||t&&lr(t)?"custom":"icons"),N(t&&!t.startsWith(En)&&lr(t)?t:""),x(!0),(X=y.current)==null||X.showModal())}},[n,s,t]);const ae=D=>{var se,X,le;s||(r?(se=i.onEdgeIconChange)==null||se.call(i,r,D):e&&((X=i.onNodeIconChange)==null||X.call(i,e,D)),o==null||o(!1),(le=y.current)==null||le.close())},re=S.filter(D=>D.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(O.trim().toLowerCase())),ye=36,be=Math.max(1,Math.ceil(re.length/ye)),L=Math.min(A,be-1),z=re.slice(L*ye,(L+1)*ye),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${Pe(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Ue,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ne,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:Pe(a),disabled:s,onClick:()=>{var D;I(""),C(t&&lr(t)?"custom":"icons"),N(t&&!t.startsWith(En)&&lr(t)?t:""),x(!0),(D=y.current)==null||D.showModal()}})}),f.jsx(V.chakra.dialog,{ref:y,"aria-label":r?"Choose edge icon":"Choose node icon",css:gr(Pe(l),Pe(u)),onClose:()=>{x(!1),o==null||o(!1),b.current++,ie(!1)},onClick:D=>{D.stopPropagation(),D.target===D.currentTarget&&D.currentTarget.close()},onKeyDown:D=>D.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:Pe(l),color:Pe(h)},children:v&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(Ue,{label:"Remove icon",children:f.jsx(Ne,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||W,onClick:()=>ae("")})}),f.jsx(Yr,{"aria-label":"Close icon picker",onClick:()=>{var D;return(D=y.current)==null?void 0:D.close()}})]})]}),f.jsxs(V.Tabs.Root,{value:w,onValueChange:({value:D})=>{C(D),I("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(V.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(D=>f.jsx(V.Tabs.Trigger,{value:D,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:m,"--indicator-color":m},children:D==="icons"?"React icons":"Custom SVG"},D))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:W||s,onChange:async D=>{var le;const se=(le=D.target.files)==null?void 0:le[0];if(D.target.value="",!se)return;const X=++b.current;ie(!0),I("");try{const ue=await vw(se);X===b.current&&ae(ue)}catch(ue){X===b.current&&I(ue instanceof Error?ue.message:"Unable to read SVG.")}finally{X===b.current&&ie(!1)}}}),f.jsx(V.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:O,onChange:D=>{P(D.target.value),M(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[z.map(D=>f.jsx("button",{type:"button","aria-label":`Choose ${D}`,"aria-pressed":t===D,title:D,onClick:()=>ae(D),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===D?2:1}px solid ${Pe(t===D?a:u)}`,background:Pe(t===D?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(Xt,{name:D,size:24})},D)),z.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:k==="loading"?"Loading icons...":k==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[re.length," icons · ",L+1," / ",be]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Ue,{label:"Previous icons",children:f.jsx(Ne,{"aria-label":"Previous icons",icon:f.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:L===0,onClick:()=>M(L-1)})}),f.jsx(Ue,{label:"Next icons",children:f.jsx(Ne,{"aria-label":"Next icons",icon:f.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:L+1>=be,onClick:()=>M(L+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&lr(t)&&f.jsx(Xt,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:W||s,onClick:()=>{var D;return(D=g.current)==null?void 0:D.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Z.PiUploadSimple,{}),W?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:D=>{D.preventDefault(),!(W||s)&&(!lr(T.trim())||T.trim().startsWith(En)?I("Enter an HTTP or HTTPS image URL."):ae(T.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:T,disabled:W||s,onChange:D=>N(D.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(Ue,{label:"Apply URL",children:f.jsx(Ne,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:W||s||!T.trim(),style:{flexShrink:0}})})]})]})})]}),$&&f.jsx("div",{role:"alert",style:{fontSize:13},children:$})]})})]})}const no=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Zr],vb=["gray.900",Zr,"gray.600","gray.200","white"];function xb(){const{config:e}=He(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||no,show:n=>!t.has(n)}}function jt(){const{border:e}=st();return f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function Dr({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:o="text",min:i,onCommit:s}){const{colorText:a}=st(),[c,l]=j.useState(e),d=j.useRef(!1);j.useEffect(()=>l(e),[e]);const u=()=>{if(d.current)return;d.current=!0;const h=c.trim();if(o==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(i??0))){l(e);return}h!==e&&s(h)};return f.jsx(V.Input,{"aria-label":t,type:o,min:i,size:"xs",fontSize:"16px",w:n,value:c,placeholder:r,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{d.current=!1},onChange:h=>l(h.target.value),onBlur:u,onKeyDown:h=>{h.key==="Enter"&&(u(),h.target.blur()),h.key==="Escape"&&(d.current=!0,l(e),h.target.blur())}})}function Mr({colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=st(),[c,l]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=co(f.jsx(Mr,{colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i}));return f.jsx(Gr.Provider,{value:null,children:f.jsxs(V.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:m=>{var y;m.key==="Escape"&&(l(!1),(y=u.current)==null||y.focus())},children:[f.jsx(Ue,{label:`${t}: ${h}`,children:f.jsx(V.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Pe(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${Pe(a)}`,outlineOffset:"1px",onClick:()=>l(m=>!m)})}),c&&f.jsxs(V.HStack,{id:d,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(m=>{const y=r===m;return f.jsx(Ue,{label:`${t}: ${m}`,children:f.jsx(V.Box,{as:"button","aria-label":`${t} ${m}`,"aria-pressed":y,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Pe(m),...m==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:y?`2px solid ${Pe(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(m),onDoubleClick:g=>{var b;g.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},m)}),o&&f.jsx(Ue,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ne,{"aria-label":`Reset ${t}`,icon:f.jsx(V.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var m;o(),l(!1),(m=u.current)==null||m.focus()}})})]})]})})}function wb({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:o}=He(),{colorInactive:i}=st(),{edgeById:s}=vr(),{palette:a,show:c}=xb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(Yr,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Dr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:m=>{var y;return(y=t.onEdgeLabelChange)==null?void 0:y.call(t,e,m)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),h.map(m=>f.jsx(Ue,{label:m.label,children:f.jsx(Ne,{"aria-label":`Edge style ${m.key}`,"aria-pressed":u===m.key,icon:f.jsx(V.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===m.key?n:i,onClick:()=>{var y;return(y=t.onEdgeStyleChange)==null?void 0:y.call(t,e,m.key)}})},m.key)),u==="animated"&&f.jsx(bb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var y;return(y=t.onEdgeAnimationVariantChange)==null?void 0:y.call(t,e,m)}}),f.jsxs(At,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:o.readOnly,onValueChange:m=>{var y;return(y=t.onEdgeTypeChange)==null?void 0:y.call(t,e,m||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(m=>f.jsx("option",{value:m,children:m},m))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Nd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(Dr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:m=>{var y;return(y=t.onEdgeIconChange)==null?void 0:y.call(t,e,m)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Mr,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:m=>{var y;return(y=t.onEdgeColorChange)==null?void 0:y.call(t,e,m)},onReset:()=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:"Delete edge",children:f.jsx(Ne,{"aria-label":"Delete edge",icon:f.jsx(V.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=t.onEdgeDelete)==null||m.call(t,e,l),r()}})})]})]})}function Cb({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:o,fillRadiusEditedIds:i,setNodeRadiusPreview:s}=He(),{colorInactive:a}=st(),{nodeById:c}=vr(),[l,d]=j.useState(),u=j.useRef(),h=j.useRef(),p=j.useRef({callbacks:t,readOnly:n.readOnly,nodeById:c});p.current={callbacks:t,readOnly:n.readOnly,nodeById:c};const m=()=>{var C,S;clearTimeout(h.current);const w=u.current;if(u.current=void 0,!!w){if(!p.current.readOnly)for(const _ of w.ids)p.current.nodeById.has(_)&&((S=(C=p.current.callbacks).onNodeBorderRadiusChange)==null||S.call(C,_,w.radius));s(w.ids,void 0),d(void 0)}},y=j.useRef(m);y.current=m,j.useEffect(()=>{const w=()=>y.current();return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w),w()}},[]);const g=e.map(w=>{var C,S;return o!=null&&o.fill&&!i.has(w)?0:(S=(C=c.get(w))==null?void 0:C.data.viewProps)==null?void 0:S.borderRadius}),b=!g.every(w=>w===g[0]),v=l??g[0]??0,x=w=>{n.readOnly||(w!==void 0&&e.every(C=>{var S;return((S=c.get(C))==null?void 0:S.data.type)==="grid"})?(d(w),s(e,w),u.current={ids:[...e],radius:w},clearTimeout(h.current),h.current=setTimeout(m,150)):(clearTimeout(h.current),u.current=void 0,d(void 0),s(e,void 0),e.forEach(C=>{var S;return(S=t.onNodeBorderRadiusChange)==null?void 0:S.call(t,C,w)})))};return f.jsxs(f.Fragment,{children:[r&&f.jsx(jt,{}),f.jsx(V.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsx(At,{icon:f.jsx(V.Icon,{as:xx.TbBorderRadius,boxSize:5,color:a,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${b?"Mixed":g[0]===void 0?"Default":`${g[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:"radius",disabled:n.readOnly,onValueChange:()=>{},popupContent:f.jsxs(f.Fragment,{children:[f.jsx(fd,{label:"Border radius",inputLabel:"Node corner radius",min:0,max:Math.max(500,...g.map(w=>w??0)),step:1,value:v,displayValue:l!==void 0?`${l}px`:b?"Mixed":g[0]===void 0?"Default":`${v}px`,onChange:x,onChangeEnd:m}),f.jsx(Ue,{label:"Reset border radius",children:f.jsx(Ne,{"aria-label":"Reset border radius",icon:f.jsx(Z.PiEraser,{size:20}),size:"sm",variant:"ghost",color:a,disabled:n.readOnly,onClick:()=>x(void 0)})})]}),children:f.jsx("option",{value:"radius",children:"Border radius"})})})]})}function Sb({ids:e,onClose:r,afterLabel:t}){var se,X,le,ue,Ce,je,pe,fe;const{callbacks:n,colorMode:o,themeColor:i,config:s,setNodeViewMode:a,nodeViewModes:c}=He(),{colorText:l,colorInactive:d}=st(),{nodeById:u,parentIds:h}=vr(),{palette:p,show:m}=xb(),y=e.length===1,[g,b]=j.useState(""),v=y?(se=u.get(e[0]))==null?void 0:se.data:void 0,x=e.map(Y=>{var J,ve,Q,Ee,Ae,qe;const H=(J=u.get(Y))==null?void 0:J.data,we=((ve=H==null?void 0:H.config)==null?void 0:ve.typeView)??"";return we==="object"&&((Q=H==null?void 0:H.config)==null?void 0:Q.content)!==void 0&&c[Y]!=="properties"?"content":we==="icon-label"&&((Ee=H==null?void 0:H.viewProps)==null?void 0:Ee.bgColor)==="transparent"&&((Ae=H==null?void 0:H.viewProps)==null?void 0:Ae.borderWidth)===0&&((qe=H==null?void 0:H.viewProps)==null?void 0:qe.outline)===!1?"media":we}),w=x.some(Y=>Y!==x[0]),C=w?"mixed":x[0]??"",S=[{value:"text",label:"Text",view:"text",icon:Z.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Z.PiShapes},{value:"object",label:"Object",view:"object",icon:Z.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Z.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Z.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Z.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Z.PiTextAlignLeft}],_=e.some(Y=>{var we,J,ve,Q;const H=(we=u.get(Y))==null?void 0:we.data;return H&&((J=H.config)==null?void 0:J.typeView)!=="grid"&&((ve=H.config)==null?void 0:ve.typeView)!=="parent"&&(h.has(Y)||((Q=H.config)==null?void 0:Q.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},H.type))}),k=(X=v==null?void 0:v.config)==null?void 0:X.collapsed,E=mb(e[0]),O=Y=>{var H,we,J;return(((we=(H=u.get(Y))==null?void 0:H.data.viewProps)==null?void 0:we.outline)??(h.has(Y)?(J=s.parentNodeStyle)==null?void 0:J.outline:!1))===!0},P=e.every(O),A=!P&&e.some(O),M=Y=>{var H;return((H=u.get(Y))==null?void 0:H.data.isNodeAnimated)===!0},T=e.every(M),N=!T&&e.some(M),$=e.map(Y=>{var H;return((H=u.get(Y))==null?void 0:H.data.nodeAnimationVariant)??"traveling"}),I=$.every(Y=>Y===$[0])?$[0]:"",W=Y=>e.forEach(Y),[ie,ae]=j.useState(!1),re=ie&&m("color")&&m("borderColor"),ye=Y=>{var H,we,J;return(((we=(H=u.get(Y))==null?void 0:H.data.viewProps)==null?void 0:we.borderStyle)??(h.has(Y)?(J=s.parentNodeStyle)==null?void 0:J.borderStyle:"solid"))==="dashed"},be=e.every(ye),L=!be&&e.some(ye),z=e.map(Y=>{var J,ve,Q;const H=(J=u.get(Y))==null?void 0:J.data,we=h.has(Y)?In((ve=s.parentNodeStyle)==null?void 0:ve.borderWidth,6):(H==null?void 0:H.type)==="objectView"?3:2;return In((Q=H==null?void 0:H.viewProps)==null?void 0:Q.borderWidth,we)}),G=z.every(Y=>Y===z[0])?String(z[0]??""):"",D=Y=>W(H=>{var we,J;re?(we=n.onNodeBorderColorChange)==null||we.call(n,H,Y):(J=n.onNodeColorChange)==null||J.call(n,H,"bg",Y)});return f.jsxs(f.Fragment,{children:[f.jsx(Yr,{onClick:r}),f.jsx(jt,{}),y&&m("label")?f.jsx(Dr,{ariaLabel:"Node label",placeholder:"Node label",value:(v==null?void 0:v.label)??(v==null?void 0:v.headerTitle)??"",onCommit:Y=>{var H;return(H=n.onNodeLabelChange)==null?void 0:H.call(n,e[0],Y)}}):f.jsxs(V.Text,{fontSize:"xs",color:l,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,m("typeView")&&f.jsxs(At,{"aria-label":"Type view",title:_?"Type view is managed by the custom renderer or container":`Type view: ${C||"None (default)"}`,icon:f.jsx(Z.PiCards,{size:20}),style:{width:36},value:C,disabled:s.readOnly||s.editable===!1||_,onValueChange:Y=>{var we;const H=(we=S.find(J=>J.value===Y))==null?void 0:we.view;H&&W(J=>{var Q,Ee,Ae,qe,Je,Fe,ct,De,rt,ft,Oe,Xe,nt;const ve=(Q=u.get(J))==null?void 0:Q.data;Y==="media"?((Ee=n.onNodeColorChange)==null||Ee.call(n,J,"bg","transparent"),(Ae=n.onNodeBorderColorChange)==null||Ae.call(n,J,"#00000000"),(qe=n.onNodeBorderWidthChange)==null||qe.call(n,J,0),(Je=n.onNodeOutlineChange)==null||Je.call(n,J,!1)):x[e.indexOf(J)]==="media"&&((Fe=n.onNodeColorChange)==null||Fe.call(n,J,"bg",""),(ct=n.onNodeBorderColorChange)==null||ct.call(n,J,""),(De=n.onNodeBorderWidthChange)==null||De.call(n,J,void 0)),Y==="content"&&((rt=ve==null?void 0:ve.config)==null?void 0:rt.content)===void 0&&((ft=n.onNodeContentChange)==null||ft.call(n,J,"")),(Oe=n.onNodeTypeViewChange)==null||Oe.call(n,J,H),a(J,Y==="object"&&((Xe=ve==null?void 0:ve.config)==null?void 0:Xe.content)!==void 0?"properties":"default"),(nt=n.onNodeViewToggle)==null||nt.call(n,J)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),S.map(Y=>f.jsx("option",{value:Y.value,children:f.jsxs(V.HStack,{gap:"12px",children:[f.jsx(Y.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:Y.label})]})},Y.value))]}),m("style")&&f.jsx(Cb,{ids:e},e.join("\0")),m("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:P?"Restore node fill":"Remove node fill",children:f.jsx(Ne,{"aria-label":"Toggle node outline","aria-pressed":A?"mixed":P,icon:f.jsx(V.Icon,{as:P?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:P?i:d,onClick:()=>W(Y=>{var H;return(H=n.onNodeOutlineChange)==null?void 0:H.call(n,Y,!P)})})})]}),m("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),m("borderColor")&&f.jsx(Ue,{label:re?"Edit node colors":"Edit node border",children:f.jsx(Ne,{"aria-label":"Edit node border","aria-pressed":re,icon:f.jsx(V.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:re?i:d,bg:re?o==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ae(Y=>!Y)})}),f.jsx(Mr,{label:re?"Border color":"Background",colors:p,value:re?((le=v==null?void 0:v.viewProps)==null?void 0:le.borderColor)??(y&&h.has(e[0])?(ue=s.parentNodeStyle)==null?void 0:ue.borderColor:void 0):(Ce=v==null?void 0:v.viewProps)==null?void 0:Ce.bgColor,onPick:D,onReset:()=>D("")}),re&&m("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:be?"Solid border":"Dashed border",children:f.jsx(Ne,{"aria-label":"Toggle dashed border","aria-pressed":L?"mixed":be,icon:f.jsx(V.Icon,{as:be?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:be?i:d,onClick:()=>W(Y=>{var H;return(H=n.onNodeBorderStyleChange)==null?void 0:H.call(n,Y,be?"solid":"dashed")})})}),f.jsx(Dr,{ariaLabel:"Border thickness",placeholder:y?"Auto":"Mixed",width:"64px",type:"number",min:0,value:G,onCommit:Y=>W(H=>{var we;return(we=n.onNodeBorderWidthChange)==null?void 0:we.call(n,H,Y===""?void 0:Number(Y))})})]})]}),m("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:T?"Stop border animation":"Animate node border",children:f.jsx(Ne,{"aria-label":"Toggle node animation","aria-pressed":N?"mixed":T,icon:f.jsx(V.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:T?i:d,onClick:()=>W(Y=>{var H;return(H=n.onNodeAnimationChange)==null?void 0:H.call(n,Y,!T)})})}),(T||N)&&f.jsx(bb,{label:"Node animation",value:I,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:Y=>W(H=>{var we;return(we=n.onNodeAnimationVariantChange)==null?void 0:we.call(n,H,Y)})})]}),!re&&m("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Mr,{label:"Text color",colors:vb,value:(je=v==null?void 0:v.viewProps)==null?void 0:je.textColor,onPick:Y=>W(H=>{var we;return(we=n.onNodeColorChange)==null?void 0:we.call(n,H,"text",Y)}),onReset:()=>W(Y=>{var H;return(H=n.onNodeColorChange)==null?void 0:H.call(n,Y,"text","")})})]}),y&&m("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Nd,{nodeId:e[0],value:(pe=v==null?void 0:v.config)==null?void 0:pe.icon},e[0]),f.jsx(Dr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((fe=v==null?void 0:v.config)==null?void 0:fe.icon)||"",onCommit:Y=>{var H;return(H=n.onNodeIconChange)==null?void 0:H.call(n,e[0],Y)}})]}),y&&E&&m("collapse")&&k!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:k?"Expand":"Collapse",children:f.jsx(Ne,{"aria-label":k?"Expand node":"Collapse node",icon:f.jsx(V.Icon,{as:k?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:d,onClick:()=>{var Y;return(Y=n.onNodeCollapse)==null?void 0:Y.call(n,e[0],!k)}})})]}),m("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:y?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ne,{"aria-label":"Delete selected nodes",icon:f.jsx(V.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:o==="dark"?"red.300":"red.500",onClick:()=>{W(Y=>{var H,we;return(we=n.onNodeDelete)==null?void 0:we.call(n,Y,((H=u.get(Y))==null?void 0:H.data)||{id:Y})}),r()}})})]}),f.jsx(jt,{}),f.jsx(Ue,{label:"Copy selection",children:f.jsx(Ne,{"aria-label":"Copy selection",icon:f.jsx(Z.PiCopy,{size:20}),size:"sm",variant:"ghost",color:d,onClick:async()=>{var Y;try{await((Y=n.onNodesCopy)==null?void 0:Y.call(n,e)),b("")}catch(H){b(String(H))}}})}),f.jsx(Ue,{label:"Duplicate selection",children:f.jsx(Ne,{"aria-label":"Duplicate selection",icon:f.jsx(Z.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:d,disabled:s.readOnly||s.editable===!1,onClick:()=>{var Y;try{(Y=n.onNodesDuplicate)==null||Y.call(n,e),b("")}catch(H){b(String(H))}}})}),g&&f.jsx(V.Text,{role:"alert",fontSize:"xs",children:g})]})}async function jb(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(e,{filter:o=>!(o instanceof Element)||!o.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(t.slice(t.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(o=>{o.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function _b(e,r="squeed.svg"){const t=document.createElement("a");t.href=await jb(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function Eb(){const{themeColor:e}=He(),[r,t]=j.useState(!1),[n,o]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Ue,{label:"Download SVG (current view)",children:f.jsx(Ne,{"aria-label":"Download SVG",icon:f.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:r,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var a;const s=(a=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){o("Diagram not available for export.");return}t(!0),o("");try{await _b(s)}catch(c){o(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function $d({children:e,background:r,border:t,endElement:n,startElement:o,startElementWidth:i=44,framed:s=!0}){const a=j.useRef(null),[c,l]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const u=a.current;let h=u.parentElement.offsetWidth;const p=()=>{const g=u.parentElement.offsetWidth;if(g>0&&g!==h){const x=h/g;h=g,x>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&u.parentElement.animate({transform:[`scaleX(${x})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const b=u.scrollLeft>1,v=u.scrollWidth-u.clientWidth-u.scrollLeft>1;l(x=>x.left===b&&x.right===v?x:{left:b,right:v})},m=g=>{if(g.defaultPrevented||g.ctrlKey||s&&g.deltaX!==0||!(g.deltaX||g.deltaY)||u.scrollWidth<=u.clientWidth)return;g.preventDefault();const b=g.deltaMode===WheelEvent.DOM_DELTA_LINE?16:g.deltaMode===WheelEvent.DOM_DELTA_PAGE?u.clientWidth:1;u.scrollLeft+=(g.deltaX||g.deltaY)*b},y=new ResizeObserver(p);return y.observe(u),u.firstElementChild&&y.observe(u.firstElementChild),u.addEventListener("scroll",p,{passive:!0}),u.addEventListener("wheel",m,{passive:!1}),p(),()=>{y.disconnect(),u.removeEventListener("scroll",p),u.removeEventListener("wheel",m)}},[]);const d=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(V.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?gr(d,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||o?{"--flow-toolbar-start-width":o?`${i}px`:"0px"}:{}},children:[f.jsx(V.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:o?`${i}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(u=>f.jsx(V.Box,{"data-flow-toolbar-fade":u,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:u==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[u]:u==="right"&&n?44:u==="left"&&o?i:0,opacity:c[u]?1:0,background:`linear-gradient(to ${u==="left"?"right":"left"}, ${d}, transparent)`}},u)),n&&f.jsx(V.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n}),o&&f.jsx(V.Box,{position:"absolute",left:"6px",top:0,h:"50px",w:`${i-12}px`,display:"flex",alignItems:"center",justifyContent:"center",children:o})]})}async function Pw(e,r){const t=new Set,n=[],o=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,m]of Object.entries(l))p==="$"?o(m,c):p.startsWith("$")||o(m,`${c}.${p}`)};if(o(r,"root"),!t.size)return{contract:await hb(e)};const i=await Td(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Xr(r,a,i);c&&(s[a]={type:c.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function kb({message:e,onDismiss:r}){const{background:t,colorText:n,border:o}=st();return!e||typeof document>"u"?null:Vr.createPortal(f.jsxs(V.chakra.div,{role:"alert","aria-atomic":"true",css:gr(Pe(t),Pe(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:Pe(t),color:Pe(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Z.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(Yr,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function qd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=He(),{edgeById:d}=vr(),{data:u,schema:h,setSchema:p,bindings:m,structured:y}=j.useContext(Mt),g=(y==null?void 0:y.sourceBindings)??m,b=(y==null?void 0:y.sourceSchema)??h,{colorText:v}=st(),x=j.useRef(null),w=j.useRef(0),[C,S]=j.useState(!1),[_,k]=j.useState("");j.useEffect(()=>()=>{w.current++},[]),j.useEffect(()=>{w.current++,S(!1)},[a,u,g]);const E=o?[...d.values()].filter(A=>Id(o,A.data)).length:0,O=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${E} invalid or unverified connections`:"",P=co(f.jsx(qd,{showDivider:!1,compact:!0}));return f.jsx(Gr.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:P,children:[f.jsx(kb,{message:_,onDismiss:()=>k("")}),e&&f.jsx(xn,{}),f.jsxs(At,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Z.PiGraph,{size:20}):t==="properties"?f.jsx(Z.PiTable,{size:20}):f.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:t,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(V.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:ro,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:A=>{var M,T;(M=A.currentTarget.closest("[popover]"))==null||M.hidePopover(),(T=s.onWorkflowConfigurationOpen)==null||T.call(s)},children:[f.jsx(Z.PiGear,{}),"Configuration"]})]}),onValueChange:A=>{var T;const M=A==="auto"?"auto":A==="properties"?"properties":"nodes";n(M),(T=s.onEdgeModeChange)==null||T.call(s,M)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(Ue,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:f.jsx(Ne,{"aria-label":"Upload workflow interface",icon:f.jsx(Z.PiUploadSimple,{size:20}),color:Pe(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var A;return(A=x.current)==null?void 0:A.click()}})}),f.jsx("input",{ref:x,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async A=>{var N,$;const M=(N=A.target.files)==null?void 0:N[0];if(A.target.value="",!M)return;const T=++w.current;S(!0),k("");try{const I=g?await Td(M,[...new Set(Object.values(g).map(ae=>ae.schemaType??ae.type))]):void 0;if(g&&I){for(const ae of Object.values(g))if(!Object.prototype.hasOwnProperty.call(I,ae.schemaType??ae.type))throw new Error(`Missing form type: ${ae.schemaType??ae.type}`)}const{contract:W,schema:ie}=g&&I?{schema:I,contract:{name:M.name,nodes:Object.fromEntries(Object.entries(g).map(([ae,re])=>[ae,{type:I[re.schemaType??re.type],optional:!1}]))}}:await Pw(M,u);if(T!==w.current)return;p==null||p(ie),i(W),($=s.onWorkflowContractChange)==null||$.call(s,W)}catch(I){T===w.current&&k(`${M.name}: ${I instanceof Error?I.message:"Unable to load interface."}`)}finally{T===w.current&&S(!1)}}}),!r&&(O||C)&&f.jsx("span",{role:"status",title:O,style:{color:Pe(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":O}),!r&&o&&f.jsx(Ue,{label:"Remove workflow interface",children:f.jsx(Ne,{"aria-label":"Remove workflow interface",icon:f.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var A;p==null||p(void 0),i(void 0),(A=s.onWorkflowContractChange)==null||A.call(s,void 0),k("")}})})]})]})})}const Mw=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:hn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:hn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:hn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:hn.RIGHT_LEFT}],Rb=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:o,setEdgeColor:i,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:m,selectedEdgeId:y,setSelectedEdgeId:g,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:x,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:_,setIsEdgeHandlesEnabled:k,isArrayNodeMode:E,setIsArrayNodeMode:O,isPinned:P,setIsPinned:A,callbacks:M,config:T,readOnly:N}=He(),{nodeById:$,edgeById:I,parentIds:W}=vr(),ie=T.colorMode==="dark",{background:ae,border:re,colorInactive:ye,colorText:be,colorActive:L}=st(),z=ie?re:"gray.300",G=`var(--chakra-colors-${ae.replace(".","-")})`,D=`var(--chakra-colors-${(ie?re:"gray.300").replace(".","-")})`,[se,X]=j.useState(!1),[le,ue]=j.useState(!0),Ce=T.bottomBarCollapsed??le,je=j.useRef(null),pe=Em({edge:"bottom",enabled:!P,bounds:je,inside:[je]}),fe=j.useCallback(Oe=>{const Xe=r.current;if(!Xe)return;const nt=T.minZoom??.01,lt=T.maxZoom??1.5,zt=.02;let kt=Xe.zoom();switch(Oe){case"increase":kt=Math.min(lt,kt+zt),Xe.zoom(kt),Xe.center(!1);break;case"decrease":kt=Math.max(nt,kt-zt),Xe.zoom(kt),Xe.center(!1);break;case"reset":Xe.fit(50);break}},[r,T.minZoom,T.maxZoom]),Y=T.renderSelectedNodeToolbar,H=p.length>0&&!!Y,we=j.useMemo(()=>H?p.map(Oe=>{var nt;return{...((nt=$.get(Oe))==null?void 0:nt.data)??{id:Oe},isParent:W.has(Oe)}}):[],[H,p,$,W]),J=j.useCallback(()=>{var Oe;m([]),(Oe=M.onNodeDeselect)==null||Oe.call(M)},[m,M]),ve=T.renderSelectedEdgeToolbar,Q=!!y&&!!ve,Ee=j.useMemo(()=>{var Oe;return!Q||!y?null:((Oe=I.get(y))==null?void 0:Oe.data)??{id:y}},[Q,y,I]),Ae=j.useCallback(()=>{var Oe;g(null),(Oe=M.onEdgeDeselect)==null||Oe.call(M)},[g,M]),qe=T.selectionToolbar!==!1&&!N,Je=qe&&!!y&&!ve,Fe=qe&&!Je&&p.length>0&&!Y,ct=Je||Fe,De=P||pe||se||ct||T.bottomBarCollapsed===!1;j.useEffect(()=>{p.length||y?a(!1):N||(s&&A(!0),T.bottomBarCollapsed===void 0&&ue(!s))},[s,p.length,y,N,a,A,T.bottomBarCollapsed]);const rt=T.renderBottomBar,ft=iw();return rt?f.jsxs(f.Fragment,{children:[H&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Y({selectedNodeIds:p,selectedNodeData:we,onDeselect:J})}),Q&&Ee&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ve({edgeId:y,edgeData:Ee,onDeselect:Ae})}),f.jsx(V.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:rt({zoomIn:()=>fe("increase"),zoomOut:()=>fe("decrease"),resetZoom:()=>fe("reset"),direction:c,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:x,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:_,setIsEdgeHandlesEnabled:k,isArrayNodeMode:E,setIsArrayNodeMode:O,selectedNodeIds:p,selectedNodeData:we,selectedEdgeId:y,selectedEdgeData:Ee,onNodeDeselect:J,onEdgeDeselect:Ae,callbacks:M})})]}):f.jsxs(Gr.Provider,{value:ft,children:[H&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Y({selectedNodeIds:p,selectedNodeData:we,onDeselect:J})}),Q&&Ee&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ve({edgeId:y,edgeData:Ee,onDeselect:Ae})}),f.jsx(V.Box,{ref:je,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:De?"translateY(0)":"translateY(100%)",pointerEvents:De?"auto":"none",visibility:De?"visible":"hidden",opacity:De?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(V.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx($d,{background:ae,border:ie?re:"gray.300",children:f.jsxs(V.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Je?f.jsx(wb,{edgeId:y,onClose:Ae}):Fe?f.jsx(Sb,{ids:p,onClose:J}):null,f.jsxs("div",{style:{display:Je||Fe?"none":"contents"},children:[f.jsxs("span",{style:{display:T.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(Ue,{label:P?"Unpin":"Pin",children:f.jsx(Ne,{"aria-label":"Pin",icon:f.jsx(V.Icon,{as:P?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:P?t:ye,onClick:()=>{A(!P),X(!1)}})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:"Zoom Out",children:f.jsx(Ne,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(V.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:be,onClick:()=>fe("decrease")})}),f.jsx(Ue,{label:"Zoom In",children:f.jsx(Ne,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(V.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:be,onClick:()=>fe("increase")})}),f.jsx(Ue,{label:"Reset Zoom",children:f.jsx(Ne,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(V.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:be,onClick:()=>fe("reset")})}),Ce&&f.jsx(aw,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:Ce?"none":"contents"},children:[f.jsxs("span",{style:{display:T.bottomBarNavigation===!1?"none":"contents"},children:[T.edgeHandles!==!1&&f.jsx(Ue,{label:_?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ne,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":_,icon:f.jsx(V.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:_?t:ye,onClick:()=>k(!_)})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ne,{"aria-label":"Toggle zoom mode",icon:f.jsx(V.Icon,{as:b?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:ye,onClick:()=>v(!b)})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:x?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ne,{"aria-label":"Toggle multi-select",icon:f.jsx(V.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:x?t:ye,onClick:()=>w(!x)})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ne,{"aria-label":"Toggle drag mode",icon:f.jsx(V.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:ye,onClick:()=>S(!C)})})]}),T.bottomBarNavigation===!1&&(e===void 0?f.jsx(zo,{}):e?Vr.createPortal(f.jsx(zo,{}),e):null),T.bottomBarExtra&&f.jsxs(f.Fragment,{children:[T.bottomBarNavigation!==!1&&f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),T.bottomBarExtra]}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),f.jsx(tb,{})]}),f.jsx("span",{style:{display:T.bottomBarNavigation===!1||Ce&&!h?"none":"contents"},children:f.jsx(zo,{})}),f.jsxs("span",{style:{display:Ce?"none":"contents"},children:[f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),f.jsx(eb,{}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:E?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ne,{"aria-label":"Toggle array mode",icon:f.jsx(V.Icon,{as:E?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:E?t:ye,onClick:()=>{var Xe;const Oe=!E;O(Oe),(Xe=M.onArrayModeChange)==null||Xe.call(M,Oe)}})})]}),f.jsx(qd,{}),!N&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Mr,{label:"Graph theme",colors:no,value:t,includeTransparent:!1,onPick:Oe=>{var Xe;n(Oe),(Xe=M.onThemeColorChange)==null||Xe.call(M,Oe)}})]}),!N&&f.jsxs(f.Fragment,{children:[f.jsx(V.Icon,{as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),f.jsx(Mr,{label:"Graph edge color",colors:no,value:o||(ie?"gray.500":Zr),onPick:i,onReset:()=>i("")}),f.jsx(V.Icon,{as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"})]}),f.jsx(rb,{})]}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:Ce?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ne,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(V.Icon,{as:Ce?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:ye,onClick:()=>{var Oe;T.bottomBarCollapsed===void 0&&ue(!Ce),a(Ce),(Oe=M.onBottomBarCollapsedChange)==null||Oe.call(M,!Ce)}})}),!Ce&&f.jsx(Eb,{})]})]})}),!ct&&f.jsxs(V.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(V.Box,{"data-flow-direction-control":"",bg:ae,borderRadius:"30px",h:50,css:gr(G,D),px:3,cursor:"pointer",onClick:()=>X(!se),children:f.jsxs(V.Flex,{align:"center",h:"100%",children:[f.jsx(Ue,{label:"Flow Direction",children:f.jsx(Ne,{"aria-label":"Direction",onClick:Oe=>{Oe.stopPropagation(),X(!se)},icon:f.jsx(V.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:ye})}),f.jsx(V.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ie?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),se&&f.jsx(V.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(V.Box,{bg:ae,borderRadius:"30px",p:2,minW:"180px",css:gr(G,D),children:[Mw.map(Oe=>f.jsxs(V.Flex,{align:"center",gap:3,px:3,py:2,css:ro,cursor:"pointer",_hover:{bg:ie?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Xe;(Xe=M.onDirectionChange)==null||Xe.call(M,Oe.value),X(!1)},children:[f.jsx(V.Icon,{as:Oe.icon,boxSize:5,color:be}),f.jsx(V.Text,{fontSize:"sm",color:be,flex:1,whiteSpace:"nowrap",children:Oe.label}),c===Oe.value&&f.jsx(V.Icon,{as:Z.PiCheck,boxSize:4,color:L})]},Oe.value)),f.jsxs(V.Flex,{align:"center",gap:3,px:3,py:2,css:ro,cursor:"pointer",_hover:{bg:ie?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Oe;(Oe=M.onDirectionChange)==null||Oe.call(M,"C"),X(!1)},children:[f.jsx(V.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:be}),f.jsx(V.Text,{fontSize:"sm",color:be,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(V.Icon,{as:Z.PiCheck,boxSize:4,color:L})]})]})})]})]})})]})};Rb.displayName="BottomBar";const Ab=j.memo(Rb);function Iw({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(Ur,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(V.Icon,{as:Z.PiGraph,boxSize:5})})}const zu={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Pb(e,r){const t=new Map,n=(i,s)=>{if(Object.is(i,s))return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const a=Object.keys(i);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(i[c],s[c]))},o=(i,s,a)=>{if(i===s)return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of c)if(!n(i[l],s[l])){if(Object.prototype.hasOwnProperty.call(zu,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[zu[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!o(i[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(o(e,r,"root"))return t}function Tw(e,r){return Pb(e,r)!==void 0}function Ow(e,r,t){if(e===r)return t;const n=Pb(e,r);if(!n)return;const o=new Set(t.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!Le(r,i))return;return{edges:t.edges,nodes:t.nodes.map(i=>{const s=n.get(i.data.id),a=Le(e,i.data.id),c=Le(r,i.data.id);return!s&&a===c?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function gd(e){return e.kind==="literal"?e.value:e.kind==="union"?gd(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,gd(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Mb(e,r,t){var g,b,v;const n=(g=Le(e,r))==null?void 0:g.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(x=>!/^[A-Za-z0-9_-]+$/.test(x)||["__proto__","constructor","prototype"].includes(x)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),c=Xr(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[o.$type],u=o.$defaults??{};for(const[x,w]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,x)||Wt(d.properties[x].type,w,!d.properties[x].optional))throw new Error(`Invalid creation default: ${x}`);const h={...gd(d),...structuredClone(u)};((v=d.properties.id)==null?void 0:v.type.kind)==="string"&&(h.id=jd());let p=e;const m=Le(e,o.$address);if(m===void 0)p=_t(e,a,x=>({...x,[s]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const y=Rd(p,o.$address,{...h,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:y.address,json:Ad(y.json,r,{target:y.address,label:o.$edgeLabel})}}function Ib(e,r,t){var i;if(r==="root"||!Le(e,r)||!Le(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let o=t;for(;o;){if(o===r||o.startsWith(`${r}.`)||n.has(o))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(o);const s=(i=Le(e,o))==null?void 0:i.$parent;o=typeof s=="string"?s:o.includes(".")?o.slice(0,o.lastIndexOf(".")):void 0}return kd(_t(e,r,s=>({...s,$parent:t})),t,!1)}function Tb(e,r){const t=new Set(r.filter(a=>Le(e,a)!==void 0)),n=[],o=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d,`${c}.${l}`)}};o(e,"root");const i=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!i(a)&&typeof c.$parent=="string"&&i(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Ld(e,r){const t=Tb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),o=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},i=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&o(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=o(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||i(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Le(e,a));i(l),s[`node_${c+1}`]=l}),s}function Ob(e,r){const t=Ld(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),o=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),i=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&o.has(d[1])&&(d[1]=o.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return i(c),[o.get(a),c]}));return{json:_t(e,"root",a=>({...a,...s})),ids:[...o.values()].map(a=>`root.${a}`)}}function Nw(e,r){const t=o=>e&&typeof e=="object"&&o in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Nb(e,r,t,n,o){const i=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodeParentChange:(a,c)=>{var d;const l=Ib(e,a,c);(d=t.onNodeParentChange)==null||d.call(t,a,c),i(l,{type:"nodeStyle",address:a,key:"$parent",value:c})},onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Ld(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Ob(e,a);i(c.json,{type:"nodeCreate",address:c.ids[0]})},onFormChange:a=>{const c=Le(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(po(e,a,t.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),i(St(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeSubtitleChange:(a,c)=>{var l;(l=t.onNodeSubtitleChange)==null||l.call(t,a,c),i(St(e,a,"$subtitle",c),{type:"nodeStyle",address:a,key:"$subtitle",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),i(St(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!wd.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),i(St(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";i(St(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),i(St(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),i(St(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),i(St(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),i(St(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),i(St(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),i(St(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),i(St(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),i(St(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),i(kd(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var p,m;if(((p=t.onNodeCreate)==null?void 0:p.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=!!a.sourceNodeId&&a.isArrayMode&&!((m=Le(e,c))!=null&&m.$arrayDrawInitialized);let d=e,u,h=a.isArrayMode?"array":"set";for(let y=0;y<(l?2:1);y++){const g=a.sourceNodeId&&Mb(d,a.sourceNodeId,o);if(g)d=g.json,u??(u=g.address),h="form";else{const b=Nw(Le(d,c),a.isArrayMode?"list":"node"),v=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},x=Rd(d,c,v,b);d=x.json,u??(u=x.address)}}l&&(d=_t(d,c,y=>Array.isArray(y)?{$:y,$arrayDrawInitialized:!0}:{...y,$arrayDrawInitialized:!0})),i(d,{type:"nodeCreate",address:u,value:h})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),i(lb(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;i(d?Ad(e,a,d):db(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&i(cb(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=ub(e,l);d.removed&&i(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const $w=".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 qw({path:e,width:r,reversed:t,children:n,onComplete:o}){const i=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,c]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(o==null||o())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[o]),j.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:l=>{l.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${i})`,children:n})]})}const Lw=".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 Fw({path:e,color:r,width:t,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const $b=".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 oo({x:e=0,y:r=0,width:t,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=j.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2))},p=s+36,m={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[f.jsx("rect",{...m,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${i} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const zw=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 qb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Lb(e,r,t=()=>{},n=300){let o,i,s=!1;const a=()=>{s=!0,o!==void 0&&cancelAnimationFrame(o),clearTimeout(i)},c=()=>{s||(a(),r(1),t())};if(!qb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(o=requestAnimationFrame(d))};return o=requestAnimationFrame(d),i=setTimeout(c,n+100),a}function Bu(e,r,t){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of r)(s.parent===i||s.id.startsWith(`${i}.`)||t.some(c=>(c.inverted?c.target:c.source)===i&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function Bw(e,r,t){const n=t==="downward"||t==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=o.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),o.set(u,h)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},m)=>{const y=l.length===1?d/2:120+(d-280)*m/(l.length-1),g=l.find(b=>Math.abs(b.cross)<Math.abs(p));i.set(u.id,{turn:y/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return i}const Zt=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}),Dw=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Vo(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const Vw=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Du=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Nt=e=>(Math.round(e*10)/10).toString(),ht=e=>`${Nt(e.x)} ${Nt(e.y)}`,Ww=e=>e>0?1:e<0?-1:0,Vu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function Gw(e,r,t,n,o=10){const i=r.x-e.x,s=r.y-e.y,a=Vu(i,(e.w+r.w)/2),c=Vu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:i,h=Ww(u),p=n*d,m=v=>Math.abs(v)<o||Math.abs(v)>=Math.abs(d),y=m(p)||m(Math.abs(d)-Math.abs(p));let g;if(y)if(l)if(Math.abs(u)<=e.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else if(Math.abs(i)<=r.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else g=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else if(Math.abs(s)<=r.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else g=[r.x,e.y];else if(l){const v=e.y+p+e.h/2*h;g=[e.x,v,r.x,v]}else{const v=e.x+p+e.w/2*h;g=[v,e.y,v,r.y]}const b=[{x:e.x,y:e.y}];for(let v=0;v<g.length;v+=2)b.push({x:g[v],y:g[v+1]});return b.push({x:r.x,y:r.y}),b}function Uw(e,r,t){const n=r.x-e.x,o=r.y-e.y,i=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=o>0?(t.y2-e.y)/o:o<0?(t.y1-e.y)/o:1/0,a=Math.min(i,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+o*a}}function Kr(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return Uw(e,r,Zt(t));const n=r.x-e.x,o=r.y-e.y;let i=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-o*u;if(Math.abs(p)<1e-9)return;const m=a.x-e.x,y=a.y-e.y,g=(m*h-y*u)/p,b=(m*o-y*n)/p;g>=0&&g<1&&b>=-1e-9&&b<=1+1e-9&&(i=Math.min(i,g))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Fb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,o=r==="top"||r==="bottom",i=r==="top"||r==="left"?-1:1,s={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...Kr(s,{x:s.x+(o?0:i*a),y:s.y+(o?i*a:0)},e)??{x:o?s.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:s.y},side:r}}function Fr(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function Hw(e,r,t,n){const o=Fr(e,t.srcDist),i=Fr(r,t.tgtDist);if(n==="straight")return Bb(o,i,t);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&r.side==="top"?i.y-o.y:e.side==="top"&&r.side==="bottom"?o.y-i.y:e.side==="right"&&r.side==="left"?i.x-o.x:e.side==="left"&&r.side==="right"?o.x-i.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=Fr({...o,side:e.side},c),d=Fr({...i,side:r.side},c),u=t.arrowAt==="source"?bt(o,l,t.arrowGap):o,h=t.arrowAt==="target"?bt(i,d,t.arrowGap):i,p=t.arrowAt==="source"?qt(o,l,t.arrowSize,t.headShape):t.arrowAt==="target"?qt(i,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${ht(u)} C${ht(l)} ${ht(d)} ${ht(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",y=r.side==="left"||r.side==="right";let g;if(m!==y){const v=m?{x:d.x,y:l.y}:{x:l.x,y:d.y},x=(v.x-l.x)*(l.x-o.x)+(v.y-l.y)*(l.y-o.y)>=0,w=(v.x-d.x)*(d.x-i.x)+(v.y-d.y)*(d.y-i.y)>=0;g=[x&&w?v:m?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(m){const v=(l.y+d.y)/2;g=[{x:l.x,y:v},{x:d.x,y:v}]}else{const v=(l.x+d.x)/2;g=[{x:v,y:l.y},{x:v,y:d.y}]}else if(m){const v=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;g=[{x:v,y:l.y},{x:v,y:d.y}]}else{const v=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;g=[{x:l.x,y:v},{x:d.x,y:v}]}const b=[l,...g,d].filter((v,x,w)=>x===0||v.x!==w[x-1].x||v.y!==w[x-1].y);return go(u,b,h,p,n==="orthogonal"?0:t.radius)}function bt(e,r,t){const n=e.x-r.x,o=e.y-r.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-t)/i;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*o}}function qt(e,r,t,n="triangle"){const o=e.x-r.x,i=e.y-r.y,s=Math.hypot(o,i)||1,a=o/s,c=i/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${ht(e)} L${Nt(e.x-c*d)} ${Nt(e.y+a*d)} L${Nt(u-c*d)} ${Nt(h+a*d)} L${Nt(u+c*d)} ${Nt(h-a*d)} L${Nt(e.x+c*d)} ${Nt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((y,g)=>{const b=p[(g+2)%3],v=p[(g+1)%3],x=Math.hypot(b.x-y.x,b.y-y.y),w=Math.hypot(v.x-y.x,v.y-y.y),C={x:(b.x-y.x)/x,y:(b.y-y.y)/x},S={x:(v.x-y.x)/w,y:(v.y-y.y)/w},_=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),k=Math.sqrt((1-_)/(1+_)),E=Math.min(1/k,x/2,w/2);return{start:{x:y.x+C.x*E,y:y.y+C.y*E},end:{x:y.x+S.x*E,y:y.y+S.y*E},radius:E*k}}).map((y,g)=>`${g?"L":"M"}${ht(y.start)} A${Nt(y.radius)} ${Nt(y.radius)} 0 0 1 ${ht(y.end)}`).join(" ")+" Z"}function dr(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function Kw(e,r,t,n){const o={x:r.x-e.x,y:r.y-e.y},i={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),c=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-o.x/s*l,y:r.y-o.y/s*l},b:r,p2:{x:r.x+i.x/a*l,y:r.y+i.y/a*l},r:l}}function zb(e,r,t,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const y=Kr(e[m],e[m+1],r);if(y){o=m,i=y;break}}let s=-1,a=null;for(let m=e.length-1;m>0;m--){const y=Kr(e[m],e[m-1],t);if(y){s=m,a=y;break}}if(!i||!a||o>=s)return null;const c=e.slice(o+1,s),l=c[0]??a,d=c[c.length-1]??i;let u,h,p;if(n.arrowAt==="source"){const m=bt(i,l,n.srcDist);u=bt(i,l,n.srcDist+n.arrowGap),p=qt(m,l,n.arrowSize,n.headShape)}else u=bt(i,l,n.srcDist);if(n.arrowAt==="target"){const m=bt(a,d,n.tgtDist);h=bt(a,d,n.tgtDist+n.arrowGap),p=qt(m,d,n.arrowSize,n.headShape)}else h=bt(a,d,n.tgtDist);return go(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function go(e,r,t,n,o,i,s){var h;const a=[e,...r,t],c=[];let l=`M${ht(e)}`;for(let p=1;p<a.length-1;p++){const m=Kw(a[p-1],a[p],a[p+1],o);c.push(m),m.r===0?l+=` L${ht(m.b)}`:l+=` L${ht(m.p1)} Q${ht(m.b)} ${ht(m.p2)}`}l+=` L${ht(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:dr(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],m=r[u/2];d={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:dr(m.x-p.x,m.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const m=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:dr(m.x-p.b.x,m.y-p.b.y)}}else d={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:dr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&c.length===2){const g=c[0].p2,b=c[1].p1,v=Math.hypot(b.x-g.x,b.y-g.y),x=Math.min(.5,i/(2*v)),w=Math.max(x,Math.min(1-x,s));d={x:g.x+(b.x-g.x)*w,y:g.y+(b.y-g.y)*w,angle:dr(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,m=t.x-p.x,y=t.y-p.y;Math.hypot(m,y)>=i&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:dr(m,y)})}return{d:l,arrow:n,label:d}}function Wu(e,r,t,n,o,i,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:o??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*i,v=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x:v,y:c.y},{x:v,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+i);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const m=s.arrowAt==="source"?bt(c,p[0],s.arrowGap):c,y=s.arrowAt==="target"?bt(l,p[p.length-1],s.arrowGap):l,g=s.arrowAt==="source"?qt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?qt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return go(m,p,y,g,s.radius)}function Gu(e,r,t,n,o){return zb(Gw(e,r,t,n),e,r,o)}function Uu(e,r,t,n,o,i){const s=n===void 0&&o===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,m=Kr(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return m?{x:m.x+(s?0:u*i),y:m.y+(s?u*i:0)}:s?{x:l.x,y:l.y+u*(l.h/2+i)}:{x:l.x+u*(l.w/2+i),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,o,-a)}}function Jw(e,r,t,n){const o=t==="downward"||t==="upward",i=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(o?r.y-e.y:r.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},c={x:r.x-(o?0:i*s),y:r.y-(o?i*s:0)},l=n.arrowAt==="source"?bt(e,a,n.arrowGap):e,d=n.arrowAt==="target"?bt(r,c,n.arrowGap):r;return{d:`M${ht(l)} C${ht(a)} ${ht(c)} ${ht(d)}`,arrow:n.arrowAt==="source"?qt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?qt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:dr(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Bb(e,r,t){const n=t.arrowAt==="source"?bt(e,r,t.arrowGap):e,o=t.arrowAt==="target"?bt(r,e,t.arrowGap):r,i=t.arrowAt==="source"?qt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?qt(r,e,t.arrowSize,t.headShape):void 0;return go(n,[],o,i,0)}function Zw(e,r,t,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*i*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},m={x:e.x,y:e.y},y=Kr(m,h,e),g=Kr(m,p,e);if(!y||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let v=bt(y,h,t.srcDist),x=bt(g,p,t.tgtDist),w;if(t.arrowAt==="target"){const S=x;x=bt(g,p,t.tgtDist+t.arrowGap),w=qt(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=v;v=bt(y,h,t.srcDist+t.arrowGap),w=qt(S,h,t.arrowSize,t.headShape)}return{d:`M${ht(v)} Q${ht(h)} ${ht(b)} Q${ht(p)} ${ht(x)}`,arrow:w,label:{x:b.x,y:b.y,angle:dr(p.x-h.x,p.y-h.y)}}}const jr=e=>Math.round(e*1e3)/1e3;function Db(e){var h,p;const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=r.getBoundingClientRect();if(!o.width||!o.height)return;const i=(p=(h=r.closest("[data-flow-icon-label]"))==null?void 0:h.querySelector("[data-flow-icon-caption]"))==null?void 0:p.getBoundingClientRect(),s=r,a=typeof s.getScreenCTM=="function"?s.getScreenCTM():null,c=typeof s.getTotalLength=="function"?s.getTotalLength():0,l=s.points,d=(l==null?void 0:l.numberOfItems)||128,u=a&&c>0?Array.from({length:d},(m,y)=>{const g=l!=null&&l.numberOfItems?l.getItem(y):s.getPointAtLength(c*y/d);return{x:jr((a.a*g.x+a.c*g.y+a.e-t.left)/n),y:jr((a.b*g.x+a.d*g.y+a.f-t.top)/n)}}):void 0;return{left:jr((o.left-t.left)/n),top:jr((o.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:jr(o.width/n),height:r instanceof HTMLElement?r.offsetHeight:jr(o.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...i!=null&&i.height?{captionBottom:jr((i.bottom-t.top)/n)}:{},...u?{outline:u}:{}}}function kn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(o=>({x:t+o.x,y:n+o.y}))}:{}}}function Yw(e,r,t,n,o){var d;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,m]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const y=r.get(m);if(p===void 0||!y||m===h)continue;const g=t.get(m),b=JSON.stringify([h,p]),v=c.get(b)??[];v.push(g?kn(y,g):y),c.set(b,v)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(x=>x.placement==="config"))continue;const m=t.get(u),y=m?kn(p,m):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=m?kn(g,m):g,v=new Map;for(const x of h){if(x.placement!=="config")continue;const C=(c.get(JSON.stringify([u,x.property]))??[]).reduce((_,k)=>_+(i?k.y-y.y:k.x-y.x),0),S=((d=x.anchor)==null?void 0:d.side)===a?a:s;v.set(x,C<-.001?s:C>.001?a:S)}l.set(u,h.map(x=>{const w=v.get(x);if(!w)return x;const C=h.filter(k=>v.get(k)===w),S=(C.indexOf(x)+1)/(C.length+1),_=Fb(b,w,S);return{...x,anchor:_,top:_.y,height:0}}))}return l}function Hu(e,r,t){const n=new Set(r.map(a=>a.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of r)!o.has(a.id)&&(o.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(o.add(a.id),i=!0)}const s=new Set(o);for(const a of t)o.has(a.source)&&n.has(a.target)&&s.add(a.target),o.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const hr='"Helvetica Neue", Helvetica, sans-serif';let fn;const Zn=new Map;function yo(e,r){const t=`${r}|${e}`,n=Zn.get(t);if(n!==void 0)return n;fn===void 0&&(fn=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return fn?(fn.font=r,o=fn.measureText(e).width):o=e.length*(parseFloat(r)||16)*.55,Zn.size>5e3&&Zn.clear(),Zn.set(t,o),o}function Xw(e,r,t){const n=[];for(const o of String(e).split(`
|
|
210
|
-
`)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const c=s?`${s} ${a}`:a;!s||yo(c,r)<=t?s=c:(n.push(s),s=a)}n.push(s)}return n}const Ku=e=>e.stopPropagation();function Qw({id:e,rect:r,label:t,labelLayer:n,labelContent:o,style:i,onSelect:s,onCollapse:a,selected:c=!1}){const l=r.x2-r.x1,d=r.y2-r.y1,u=i.borderWidth,h=i.borderStyle==="dashed"?`${u*4} ${u*2}`:i.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+l/2,m=i.labelPosition==="top"?r.y1+i.labelMargin-i.fontSize/2:i.labelPosition==="bottom"?r.y2-i.labelMargin+i.fontSize/2:r.y1+d/2,y=t?yo(t,`bold ${i.fontSize}px ${hr}`):0,g=i.fontSize/5,b=t||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+y/2+g+8,y:m-24,width:48,height:48,"data-flow-content-toggle":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(Ue,{label:"Show icon",children:f.jsx(Ne,{"aria-label":"Show icon",icon:f.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:i.textColor},onClick:v=>{v.stopPropagation(),a(e)}})})}),o?f.jsx("foreignObject",{x:p-y/2-g,y:m-i.fontSize/2-g,width:y+2*g,height:i.fontSize+2*g,style:{overflow:"visible"},onClick:Ku,children:o}):t&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-y/2-g,y:m-i.fontSize/2-g,width:y+2*g,height:i.fontSize+2*g,fill:i.textColor==="transparent"?"transparent":i.labelBg}),f.jsx("text",{x:p,y:m,fill:i.textColor,fontSize:i.fontSize,fontWeight:"bold",fontFamily:hr,style:{fontSize:i.fontSize,fontWeight:"bold",fontFamily:hr},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:Ku,onClick:v=>{v.stopPropagation(),s==null||s(e,{shiftKey:v.shiftKey,ctrlKey:v.ctrlKey,metaKey:v.metaKey,altKey:v.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:l,height:d,rx:i.borderRadius,ry:i.borderRadius,fill:i.bgColor,fillOpacity:i.bgOpacity,stroke:i.borderColor,strokeWidth:i.borderStyle==="double"?u/3:u,strokeDasharray:h}),i.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,l-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,i.borderRadius-u*2/3),ry:Math.max(0,i.borderRadius-u*2/3),fill:"none",stroke:i.borderColor,strokeWidth:u/3}),i.animated&&u>0&&f.jsx(oo,{variant:i.animationVariant,x:r.x1,y:r.y1,width:l,height:d,radius:i.borderRadius,color:i.animationColor||i.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Vr.createPortal(b,n):b]})}const e1=j.memo(Qw),io=45,Vb=70,Er=15,Wb=50;function Gb(e,r,t=io){const n=`${t}px ${hr}`,o=e?Xw(e,n,200*t/io):[],i=r?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(l=>yo(l,n))),a=Math.max(o.length*t,r?48:0),c=o.length||r?2*Er:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const Rn=6,Ub=3,Fd=.3,t1=8,zd=Math.max(Math.pow(Rn*13.37,.9),29)*Ub-t1/Fd,Hb=Rn*Ub*2,Qn=80,r1=2*Qn+zd*Fd+100,n1=36+2*Math.max(80,Hb+zd*Fd);function yd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function md(e,r){return r==="auto"||(r==="properties"?yd(e):!yd(e))}function rr(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&yd(n))}function o1(e,r,t,n=!1,o){if(!n)return{nodes:e,edges:r};const i=e.filter(a=>rr(a.id,r,t)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:r.filter(a=>md(a,t)&&s.has(a.source)&&s.has(a.target))}}const i1=500,a1="32 18",s1=e=>e.stopPropagation();function c1({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:l,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:m,targetPort:y,propertyMode:g=!1,dir:b,turn:v,labelAtTarget:x,labelFraction:w,color:C,connectorColor:S,labelBg:_,labelLayer:k,label:E,dashed:O,animated:P,inverted:A,loopIndex:M=0,onSelect:T}){const N=n==null?void 0:n.icon,$=g?io:Vb,{lines:I,iconWidth:W,contentWidth:ie,contentHeight:ae}=j.useMemo(()=>Gb(E,N,$),[E,N,$]),re=j.useMemo(()=>{const je={srcDist:Qn,tgtDist:Qn,arrowGap:Hb,arrowSize:zd,headShape:g&&(A?h!==void 0||m:p!==void 0||y)?"square":"triangle",radius:s??(x?40:i1),arrowAt:A?"source":"target",labelTargetLength:x?ie+2*Er:void 0,labelFraction:x?w:void 0},pe=h!==void 0||p!==void 0||!!m||!!y,fe=Uu(c,l,b,h,p,0),Y=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),H=m??{...fe.sourcePoint,side:Y?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},we=y??{...fe.targetPoint,side:Y?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},J=c.x===l.x&&c.y===l.y,ve=m||y?Hw(H,we,{...je,srcDist:18,tgtDist:18},i):pe?Wu(c,l,b,h,p,v,{...je,srcDist:18,tgtDist:18,radius:s??Math.min(je.radius,40)}):J?Zw(c,M,{...je,srcDist:0,tgtDist:0}):Gu(c,l,b,v,je);if(!ve)return null;const Q=Uu(c,l,b,h,p,pe?18:Qn);m&&(Q.sourcePoint=Fr(m,18)),y&&(Q.targetPoint=Fr(y,18));const Ee=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(Ee){const Ae={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Ee({edge:n??{id:e,source:"",target:""},source:{...c},target:{...l},...Q,direction:Ae[b],sourceY:h,targetY:p,inverted:!!A,defaultGeometry:ve})??ve}return J||m||y?ve:i==="straight"?pe?Bb(Q.sourcePoint,Q.targetPoint,je):zb([c,l],c,l,je):i==="bezier"?Jw(Q.sourcePoint,Q.targetPoint,pe?b==="leftward"?"leftward":"rightward":b,je):i==="orthogonal"?pe?Wu(c,l,b,h,p,v,{...je,srcDist:18,tgtDist:18,radius:0}):Gu(c,l,b,v,{...je,radius:0}):ve},[c,e,n,i,s,a,l,g,h,p,m,y,b,v,A,M,x,w,ie]);if(!re)return null;const ye=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(g&&(h!==void 0||p!==void 0||m||y)),be=ye?`translate(${re.label.x} ${re.label.y-ae/2-2*Er})`:`translate(${re.label.x} ${re.label.y}) rotate(${re.label.angle}) translate(${b==="downward"||b==="upward"||x||Object.prototype.hasOwnProperty.call(a??{},i)?0:Wb} 0)`,L=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",z=o?L:C,G=o?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${re.label.x} ${re.label.y-I.length*$/2-55})`,children:[f.jsx("title",{children:o}),f.jsx(Xt,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:L})]}):null,D=P&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",se=!D&&(O||P)?a1:void 0,X=P&&!D?`flow-sdk-edge-anim${A?" flow-sdk-edge-anim-rev":""}`:void 0;let le=null;const ue=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(I.length||N){const je=ie,pe=ae;le=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:ue,"data-label-transform":be,"data-label-horizontal":ye||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:be,children:[f.jsx("rect",{x:-je/2-Er,y:-pe/2-Er,width:je+2*Er,height:pe+2*Er,fill:C==="transparent"?"transparent":_}),f.jsx("text",{fill:C,fontSize:$,style:{fontSize:$,fontFamily:hr},fontFamily:hr,textAnchor:"middle",dominantBaseline:"central",children:I.map((fe,Y)=>f.jsx("tspan",{x:W/2,y:(Y-(I.length-1)/2)*$,children:fe},Y))}),N&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:E?`Edge icon: ${E}`:"Edge icon"}),f.jsx("rect",{x:-je/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Xt,{name:N,svg:!0,size:48,x:-je/2,y:-24,color:C})]})]})}const Ce=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:re.d,fill:"none",stroke:z,strokeWidth:Rn,strokeOpacity:D?.35:void 0,strokeDasharray:se,className:X}),D&&f.jsx(Fw,{path:re.d,color:z,width:Rn*1.6,reversed:A})]});return f.jsxs("g",{className:"flow-sdk-edge",style:ue,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:s1,onClick:je=>{je.stopPropagation(),T==null||T(e)},children:[r?f.jsx(qw,{path:re.d,width:Rn*4,reversed:A,onComplete:()=>t==null?void 0:t(e),children:Ce}):Ce,re.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:re.arrow,fill:o?L:S??z}),k&&le?Vr.createPortal(le,k):le,k&&G?Vr.createPortal(G,k):G,f.jsx("path",{className:"flow-sdk-edge-hit",d:re.d,fill:"none",stroke:"transparent"})]})}const Ju=j.memo(c1);var Yn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function l1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Bd(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 Wo,Zu;function d1(){if(Zu)return Wo;Zu=1;function e(){this.__data__=[],this.size=0}return Wo=e,Wo}var Go,Yu;function Qr(){if(Yu)return Go;Yu=1;function e(r,t){return r===t||r!==r&&t!==t}return Go=e,Go}var Uo,Xu;function mo(){if(Xu)return Uo;Xu=1;var e=Qr();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return Uo=r,Uo}var Ho,Qu;function u1(){if(Qu)return Ho;Qu=1;var e=mo(),r=Array.prototype,t=r.splice;function n(o){var i=this.__data__,s=e(i,o);if(s<0)return!1;var a=i.length-1;return s==a?i.pop():t.call(i,s,1),--this.size,!0}return Ho=n,Ho}var Ko,ef;function f1(){if(ef)return Ko;ef=1;var e=mo();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return Ko=r,Ko}var Jo,tf;function h1(){if(tf)return Jo;tf=1;var e=mo();function r(t){return e(this.__data__,t)>-1}return Jo=r,Jo}var Zo,rf;function p1(){if(rf)return Zo;rf=1;var e=mo();function r(t,n){var o=this.__data__,i=e(o,t);return i<0?(++this.size,o.push([t,n])):o[i][1]=n,this}return Zo=r,Zo}var Yo,nf;function bo(){if(nf)return Yo;nf=1;var e=d1(),r=u1(),t=f1(),n=h1(),o=p1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Yo=i,Yo}var Xo,of;function g1(){if(of)return Xo;of=1;var e=bo();function r(){this.__data__=new e,this.size=0}return Xo=r,Xo}var Qo,af;function y1(){if(af)return Qo;af=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return Qo=e,Qo}var ei,sf;function m1(){if(sf)return ei;sf=1;function e(r){return this.__data__.get(r)}return ei=e,ei}var ti,cf;function b1(){if(cf)return ti;cf=1;function e(r){return this.__data__.has(r)}return ti=e,ti}var ri,lf;function Kb(){if(lf)return ri;lf=1;var e=typeof Yn=="object"&&Yn&&Yn.Object===Object&&Yn;return ri=e,ri}var ni,df;function Ut(){if(df)return ni;df=1;var e=Kb(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ni=t,ni}var oi,uf;function en(){if(uf)return oi;uf=1;var e=Ut(),r=e.Symbol;return oi=r,oi}var ii,ff;function v1(){if(ff)return ii;ff=1;var e=en(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function i(s){var a=t.call(s,o),c=s[o];try{s[o]=void 0;var l=!0}catch{}var d=n.call(s);return l&&(a?s[o]=c:delete s[o]),d}return ii=i,ii}var ai,hf;function x1(){if(hf)return ai;hf=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return ai=t,ai}var si,pf;function Ir(){if(pf)return si;pf=1;var e=en(),r=v1(),t=x1(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?o:n:i&&i in Object(a)?r(a):t(a)}return si=s,si}var ci,gf;function Lt(){if(gf)return ci;gf=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return ci=e,ci}var li,yf;function qn(){if(yf)return li;yf=1;var e=Ir(),r=Lt(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!r(a))return!1;var c=e(a);return c==n||c==o||c==t||c==i}return li=s,li}var di,mf;function w1(){if(mf)return di;mf=1;var e=Ut(),r=e["__core-js_shared__"];return di=r,di}var ui,bf;function C1(){if(bf)return ui;bf=1;var e=w1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return ui=t,ui}var fi,vf;function Jb(){if(vf)return fi;vf=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return fi=t,fi}var hi,xf;function S1(){if(xf)return hi;xf=1;var e=qn(),r=C1(),t=Lt(),n=Jb(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,l=a.hasOwnProperty,d=RegExp("^"+c.call(l).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:i;return p.test(n(h))}return hi=u,hi}var pi,wf;function j1(){if(wf)return pi;wf=1;function e(r,t){return r==null?void 0:r[t]}return pi=e,pi}var gi,Cf;function Tr(){if(Cf)return gi;Cf=1;var e=S1(),r=j1();function t(n,o){var i=r(n,o);return e(i)?i:void 0}return gi=t,gi}var yi,Sf;function Dd(){if(Sf)return yi;Sf=1;var e=Tr(),r=Ut(),t=e(r,"Map");return yi=t,yi}var mi,jf;function vo(){if(jf)return mi;jf=1;var e=Tr(),r=e(Object,"create");return mi=r,mi}var bi,_f;function _1(){if(_f)return bi;_f=1;var e=vo();function r(){this.__data__=e?e(null):{},this.size=0}return bi=r,bi}var vi,Ef;function E1(){if(Ef)return vi;Ef=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return vi=e,vi}var xi,kf;function k1(){if(kf)return xi;kf=1;var e=vo(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===r?void 0:a}return n.call(s,i)?s[i]:void 0}return xi=o,xi}var wi,Rf;function R1(){if(Rf)return wi;Rf=1;var e=vo(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:t.call(i,o)}return wi=n,wi}var Ci,Af;function A1(){if(Af)return Ci;Af=1;var e=vo(),r="__lodash_hash_undefined__";function t(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?r:o,this}return Ci=t,Ci}var Si,Pf;function P1(){if(Pf)return Si;Pf=1;var e=_1(),r=E1(),t=k1(),n=R1(),o=A1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Si=i,Si}var ji,Mf;function M1(){if(Mf)return ji;Mf=1;var e=P1(),r=bo(),t=Dd();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return ji=n,ji}var _i,If;function I1(){if(If)return _i;If=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return _i=e,_i}var Ei,Tf;function xo(){if(Tf)return Ei;Tf=1;var e=I1();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Ei=r,Ei}var ki,Of;function T1(){if(Of)return ki;Of=1;var e=xo();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return ki=r,ki}var Ri,Nf;function O1(){if(Nf)return Ri;Nf=1;var e=xo();function r(t){return e(this,t).get(t)}return Ri=r,Ri}var Ai,$f;function N1(){if($f)return Ai;$f=1;var e=xo();function r(t){return e(this,t).has(t)}return Ai=r,Ai}var Pi,qf;function $1(){if(qf)return Pi;qf=1;var e=xo();function r(t,n){var o=e(this,t),i=o.size;return o.set(t,n),this.size+=o.size==i?0:1,this}return Pi=r,Pi}var Mi,Lf;function Vd(){if(Lf)return Mi;Lf=1;var e=M1(),r=T1(),t=O1(),n=N1(),o=$1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Mi=i,Mi}var Ii,Ff;function q1(){if(Ff)return Ii;Ff=1;var e=bo(),r=Dd(),t=Vd(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!r||c.length<n-1)return c.push([i,s]),this.size=++a.size,this;a=this.__data__=new t(c)}return a.set(i,s),this.size=a.size,this}return Ii=o,Ii}var Ti,zf;function wo(){if(zf)return Ti;zf=1;var e=bo(),r=g1(),t=y1(),n=m1(),o=b1(),i=q1();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Ti=s,Ti}var Oi,Bf;function Wd(){if(Bf)return Oi;Bf=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Oi=e,Oi}var Ni,Df;function Zb(){if(Df)return Ni;Df=1;var e=Tr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Ni=r,Ni}var $i,Vf;function Co(){if(Vf)return $i;Vf=1;var e=Zb();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return $i=r,$i}var qi,Wf;function So(){if(Wf)return qi;Wf=1;var e=Co(),r=Qr(),t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a){var c=i[s];(!(n.call(i,s)&&r(c,a))||a===void 0&&!(s in i))&&e(i,s,a)}return qi=o,qi}var Li,Gf;function Ln(){if(Gf)return Li;Gf=1;var e=So(),r=Co();function t(n,o,i,s){var a=!i;i||(i={});for(var c=-1,l=o.length;++c<l;){var d=o[c],u=s?s(i[d],n[d],d,i,n):void 0;u===void 0&&(u=n[d]),a?r(i,d,u):e(i,d,u)}return i}return Li=t,Li}var Fi,Uf;function L1(){if(Uf)return Fi;Uf=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Fi=e,Fi}var zi,Hf;function Qt(){if(Hf)return zi;Hf=1;function e(r){return r!=null&&typeof r=="object"}return zi=e,zi}var Bi,Kf;function F1(){if(Kf)return Bi;Kf=1;var e=Ir(),r=Qt(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Bi=n,Bi}var Di,Jf;function Fn(){if(Jf)return Di;Jf=1;var e=F1(),r=Qt(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Di=i,Di}var Vi,Zf;function yt(){if(Zf)return Vi;Zf=1;var e=Array.isArray;return Vi=e,Vi}var mn={exports:{}},Wi,Yf;function z1(){if(Yf)return Wi;Yf=1;function e(){return!1}return Wi=e,Wi}mn.exports;var Xf;function tn(){return Xf||(Xf=1,(function(e,r){var t=Ut(),n=z1(),o=r&&!r.nodeType&&r,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||n;e.exports=l})(mn,mn.exports)),mn.exports}var Gi,Qf;function jo(){if(Qf)return Gi;Qf=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return Gi=t,Gi}var Ui,eh;function Gd(){if(eh)return Ui;eh=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return Ui=r,Ui}var Hi,th;function B1(){if(th)return Hi;th=1;var e=Ir(),r=Gd(),t=Qt(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",v="[object Float32Array]",x="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",_="[object Uint8Array]",k="[object Uint8ClampedArray]",E="[object Uint16Array]",O="[object Uint32Array]",P={};P[v]=P[x]=P[w]=P[C]=P[S]=P[_]=P[k]=P[E]=P[O]=!0,P[n]=P[o]=P[g]=P[i]=P[b]=P[s]=P[a]=P[c]=P[l]=P[d]=P[u]=P[h]=P[p]=P[m]=P[y]=!1;function A(M){return t(M)&&r(M.length)&&!!P[e(M)]}return Hi=A,Hi}var Ki,rh;function _o(){if(rh)return Ki;rh=1;function e(r){return function(t){return r(t)}}return Ki=e,Ki}var bn={exports:{}};bn.exports;var nh;function Ud(){return nh||(nh=1,(function(e,r){var t=Kb(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&t.process,a=(function(){try{var c=o&&o.require&&o.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(bn,bn.exports)),bn.exports}var Ji,oh;function zn(){if(oh)return Ji;oh=1;var e=B1(),r=_o(),t=Ud(),n=t&&t.isTypedArray,o=n?r(n):e;return Ji=o,Ji}var Zi,ih;function Yb(){if(ih)return Zi;ih=1;var e=L1(),r=Fn(),t=yt(),n=tn(),o=jo(),i=zn(),s=Object.prototype,a=s.hasOwnProperty;function c(l,d){var u=t(l),h=!u&&r(l),p=!u&&!h&&n(l),m=!u&&!h&&!p&&i(l),y=u||h||p||m,g=y?e(l.length,String):[],b=g.length;for(var v in l)(d||a.call(l,v))&&!(y&&(v=="length"||p&&(v=="offset"||v=="parent")||m&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||o(v,b)))&&g.push(v);return g}return Zi=c,Zi}var Yi,ah;function Eo(){if(ah)return Yi;ah=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return Yi=r,Yi}var Xi,sh;function Xb(){if(sh)return Xi;sh=1;function e(r,t){return function(n){return r(t(n))}}return Xi=e,Xi}var Qi,ch;function D1(){if(ch)return Qi;ch=1;var e=Xb(),r=e(Object.keys,Object);return Qi=r,Qi}var ea,lh;function Hd(){if(lh)return ea;lh=1;var e=Eo(),r=D1(),t=Object.prototype,n=t.hasOwnProperty;function o(i){if(!e(i))return r(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return ea=o,ea}var ta,dh;function or(){if(dh)return ta;dh=1;var e=qn(),r=Gd();function t(n){return n!=null&&r(n.length)&&!e(n)}return ta=t,ta}var ra,uh;function xr(){if(uh)return ra;uh=1;var e=Yb(),r=Hd(),t=or();function n(o){return t(o)?e(o):r(o)}return ra=n,ra}var na,fh;function V1(){if(fh)return na;fh=1;var e=Ln(),r=xr();function t(n,o){return n&&e(o,r(o),n)}return na=t,na}var oa,hh;function W1(){if(hh)return oa;hh=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return oa=e,oa}var ia,ph;function G1(){if(ph)return ia;ph=1;var e=Lt(),r=Eo(),t=W1(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=r(s),c=[];for(var l in s)l=="constructor"&&(a||!o.call(s,l))||c.push(l);return c}return ia=i,ia}var aa,gh;function Or(){if(gh)return aa;gh=1;var e=Yb(),r=G1(),t=or();function n(o){return t(o)?e(o,!0):r(o)}return aa=n,aa}var sa,yh;function U1(){if(yh)return sa;yh=1;var e=Ln(),r=Or();function t(n,o){return n&&e(o,r(o),n)}return sa=t,sa}var vn={exports:{}};vn.exports;var mh;function Qb(){return mh||(mh=1,(function(e,r){var t=Ut(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,d){if(d)return l.slice();var u=l.length,h=a?a(u):new l.constructor(u);return l.copy(h),h}e.exports=c})(vn,vn.exports)),vn.exports}var ca,bh;function ev(){if(bh)return ca;bh=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return ca=e,ca}var la,vh;function tv(){if(vh)return la;vh=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=0,s=[];++n<o;){var a=r[n];t(a,n,r)&&(s[i++]=a)}return s}return la=e,la}var da,xh;function rv(){if(xh)return da;xh=1;function e(){return[]}return da=e,da}var ua,wh;function Kd(){if(wh)return ua;wh=1;var e=tv(),r=rv(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:r;return ua=i,ua}var fa,Ch;function H1(){if(Ch)return fa;Ch=1;var e=Ln(),r=Kd();function t(n,o){return e(n,r(n),o)}return fa=t,fa}var ha,Sh;function Jd(){if(Sh)return ha;Sh=1;function e(r,t){for(var n=-1,o=t.length,i=r.length;++n<o;)r[i+n]=t[n];return r}return ha=e,ha}var pa,jh;function ko(){if(jh)return pa;jh=1;var e=Xb(),r=e(Object.getPrototypeOf,Object);return pa=r,pa}var ga,_h;function nv(){if(_h)return ga;_h=1;var e=Jd(),r=ko(),t=Kd(),n=rv(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return ga=i,ga}var ya,Eh;function K1(){if(Eh)return ya;Eh=1;var e=Ln(),r=nv();function t(n,o){return e(n,r(n),o)}return ya=t,ya}var ma,kh;function ov(){if(kh)return ma;kh=1;var e=Jd(),r=yt();function t(n,o,i){var s=o(n);return r(n)?s:e(s,i(n))}return ma=t,ma}var ba,Rh;function iv(){if(Rh)return ba;Rh=1;var e=ov(),r=Kd(),t=xr();function n(o){return e(o,t,r)}return ba=n,ba}var va,Ah;function J1(){if(Ah)return va;Ah=1;var e=ov(),r=nv(),t=Or();function n(o){return e(o,t,r)}return va=n,va}var xa,Ph;function Z1(){if(Ph)return xa;Ph=1;var e=Tr(),r=Ut(),t=e(r,"DataView");return xa=t,xa}var wa,Mh;function Y1(){if(Mh)return wa;Mh=1;var e=Tr(),r=Ut(),t=e(r,"Promise");return wa=t,wa}var Ca,Ih;function av(){if(Ih)return Ca;Ih=1;var e=Tr(),r=Ut(),t=e(r,"Set");return Ca=t,Ca}var Sa,Th;function X1(){if(Th)return Sa;Th=1;var e=Tr(),r=Ut(),t=e(r,"WeakMap");return Sa=t,Sa}var ja,Oh;function rn(){if(Oh)return ja;Oh=1;var e=Z1(),r=Dd(),t=Y1(),n=av(),o=X1(),i=Ir(),s=Jb(),a="[object Map]",c="[object Object]",l="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),m=s(r),y=s(t),g=s(n),b=s(o),v=i;return(e&&v(new e(new ArrayBuffer(1)))!=h||r&&v(new r)!=a||t&&v(t.resolve())!=l||n&&v(new n)!=d||o&&v(new o)!=u)&&(v=function(x){var w=i(x),C=w==c?x.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case m:return a;case y:return l;case g:return d;case b:return u}return w}),ja=v,ja}var _a,Nh;function Q1(){if(Nh)return _a;Nh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return _a=t,_a}var Ea,$h;function sv(){if($h)return Ea;$h=1;var e=Ut(),r=e.Uint8Array;return Ea=r,Ea}var ka,qh;function Zd(){if(qh)return ka;qh=1;var e=sv();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return ka=r,ka}var Ra,Lh;function eC(){if(Lh)return Ra;Lh=1;var e=Zd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Ra=r,Ra}var Aa,Fh;function tC(){if(Fh)return Aa;Fh=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Aa=r,Aa}var Pa,zh;function rC(){if(zh)return Pa;zh=1;var e=en(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Pa=n,Pa}var Ma,Bh;function cv(){if(Bh)return Ma;Bh=1;var e=Zd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Ma=r,Ma}var Ia,Dh;function nC(){if(Dh)return Ia;Dh=1;var e=Zd(),r=eC(),t=tC(),n=rC(),o=cv(),i="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",l="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",y="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",v="[object Int16Array]",x="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",_="[object Uint32Array]";function k(E,O,P){var A=E.constructor;switch(O){case p:return e(E);case i:case s:return new A(+E);case m:return r(E,P);case y:case g:case b:case v:case x:case w:case C:case S:case _:return o(E,P);case a:return new A;case c:case u:return new A(E);case l:return t(E);case d:return new A;case h:return n(E)}}return Ia=k,Ia}var Ta,Vh;function lv(){if(Vh)return Ta;Vh=1;var e=Lt(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Ta=t,Ta}var Oa,Wh;function dv(){if(Wh)return Oa;Wh=1;var e=lv(),r=ko(),t=Eo();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return Oa=n,Oa}var Na,Gh;function oC(){if(Gh)return Na;Gh=1;var e=rn(),r=Qt(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return Na=n,Na}var $a,Uh;function iC(){if(Uh)return $a;Uh=1;var e=oC(),r=_o(),t=Ud(),n=t&&t.isMap,o=n?r(n):e;return $a=o,$a}var qa,Hh;function aC(){if(Hh)return qa;Hh=1;var e=rn(),r=Qt(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return qa=n,qa}var La,Kh;function sC(){if(Kh)return La;Kh=1;var e=aC(),r=_o(),t=Ud(),n=t&&t.isSet,o=n?r(n):e;return La=o,La}var Fa,Jh;function uv(){if(Jh)return Fa;Jh=1;var e=wo(),r=Wd(),t=So(),n=V1(),o=U1(),i=Qb(),s=ev(),a=H1(),c=K1(),l=iv(),d=J1(),u=rn(),h=Q1(),p=nC(),m=dv(),y=yt(),g=tn(),b=iC(),v=Lt(),x=sC(),w=xr(),C=Or(),S=1,_=2,k=4,E="[object Arguments]",O="[object Array]",P="[object Boolean]",A="[object Date]",M="[object Error]",T="[object Function]",N="[object GeneratorFunction]",$="[object Map]",I="[object Number]",W="[object Object]",ie="[object RegExp]",ae="[object Set]",re="[object String]",ye="[object Symbol]",be="[object WeakMap]",L="[object ArrayBuffer]",z="[object DataView]",G="[object Float32Array]",D="[object Float64Array]",se="[object Int8Array]",X="[object Int16Array]",le="[object Int32Array]",ue="[object Uint8Array]",Ce="[object Uint8ClampedArray]",je="[object Uint16Array]",pe="[object Uint32Array]",fe={};fe[E]=fe[O]=fe[L]=fe[z]=fe[P]=fe[A]=fe[G]=fe[D]=fe[se]=fe[X]=fe[le]=fe[$]=fe[I]=fe[W]=fe[ie]=fe[ae]=fe[re]=fe[ye]=fe[ue]=fe[Ce]=fe[je]=fe[pe]=!0,fe[M]=fe[T]=fe[be]=!1;function Y(H,we,J,ve,Q,Ee){var Ae,qe=we&S,Je=we&_,Fe=we&k;if(J&&(Ae=Q?J(H,ve,Q,Ee):J(H)),Ae!==void 0)return Ae;if(!v(H))return H;var ct=y(H);if(ct){if(Ae=h(H),!qe)return s(H,Ae)}else{var De=u(H),rt=De==T||De==N;if(g(H))return i(H,qe);if(De==W||De==E||rt&&!Q){if(Ae=Je||rt?{}:m(H),!qe)return Je?c(H,o(Ae,H)):a(H,n(Ae,H))}else{if(!fe[De])return Q?H:{};Ae=p(H,De,qe)}}Ee||(Ee=new e);var ft=Ee.get(H);if(ft)return ft;Ee.set(H,Ae),x(H)?H.forEach(function(nt){Ae.add(Y(nt,we,J,nt,H,Ee))}):b(H)&&H.forEach(function(nt,lt){Ae.set(lt,Y(nt,we,J,lt,H,Ee))});var Oe=Fe?Je?d:l:Je?C:w,Xe=ct?void 0:Oe(H);return r(Xe||H,function(nt,lt){Xe&&(lt=nt,nt=H[lt]),t(Ae,lt,Y(nt,we,J,lt,H,Ee))}),Ae}return Fa=Y,Fa}var za,Zh;function cC(){if(Zh)return za;Zh=1;var e=uv(),r=4;function t(n){return e(n,r)}return za=t,za}var Ba,Yh;function Yd(){if(Yh)return Ba;Yh=1;function e(r){return function(){return r}}return Ba=e,Ba}var Da,Xh;function lC(){if(Xh)return Da;Xh=1;function e(r){return function(t,n,o){for(var i=-1,s=Object(t),a=o(t),c=a.length;c--;){var l=a[r?c:++i];if(n(s[l],l,s)===!1)break}return t}}return Da=e,Da}var Va,Qh;function Xd(){if(Qh)return Va;Qh=1;var e=lC(),r=e();return Va=r,Va}var Wa,ep;function Qd(){if(ep)return Wa;ep=1;var e=Xd(),r=xr();function t(n,o){return n&&e(n,o,r)}return Wa=t,Wa}var Ga,tp;function dC(){if(tp)return Ga;tp=1;var e=or();function r(t,n){return function(o,i){if(o==null)return o;if(!e(o))return t(o,i);for(var s=o.length,a=n?s:-1,c=Object(o);(n?a--:++a<s)&&i(c[a],a,c)!==!1;);return o}}return Ga=r,Ga}var Ua,rp;function Ro(){if(rp)return Ua;rp=1;var e=Qd(),r=dC(),t=r(e);return Ua=t,Ua}var Ha,np;function Nr(){if(np)return Ha;np=1;function e(r){return r}return Ha=e,Ha}var Ka,op;function fv(){if(op)return Ka;op=1;var e=Nr();function r(t){return typeof t=="function"?t:e}return Ka=r,Ka}var Ja,ip;function hv(){if(ip)return Ja;ip=1;var e=Wd(),r=Ro(),t=fv(),n=yt();function o(i,s){var a=n(i)?e:r;return a(i,t(s))}return Ja=o,Ja}var Za,ap;function pv(){return ap||(ap=1,Za=hv()),Za}var Ya,sp;function uC(){if(sp)return Ya;sp=1;var e=Ro();function r(t,n){var o=[];return e(t,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return Ya=r,Ya}var Xa,cp;function fC(){if(cp)return Xa;cp=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return Xa=r,Xa}var Qa,lp;function hC(){if(lp)return Qa;lp=1;function e(r){return this.__data__.has(r)}return Qa=e,Qa}var es,dp;function gv(){if(dp)return es;dp=1;var e=Vd(),r=fC(),t=hC();function n(o){var i=-1,s=o==null?0:o.length;for(this.__data__=new e;++i<s;)this.add(o[i])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,es=n,es}var ts,up;function pC(){if(up)return ts;up=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return ts=e,ts}var rs,fp;function yv(){if(fp)return rs;fp=1;function e(r,t){return r.has(t)}return rs=e,rs}var ns,hp;function mv(){if(hp)return ns;hp=1;var e=gv(),r=pC(),t=yv(),n=1,o=2;function i(s,a,c,l,d,u){var h=c&n,p=s.length,m=a.length;if(p!=m&&!(h&&m>p))return!1;var y=u.get(s),g=u.get(a);if(y&&g)return y==a&&g==s;var b=-1,v=!0,x=c&o?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var w=s[b],C=a[b];if(l)var S=h?l(C,w,b,a,s,u):l(w,C,b,s,a,u);if(S!==void 0){if(S)continue;v=!1;break}if(x){if(!r(a,function(_,k){if(!t(x,k)&&(w===_||d(w,_,c,l,u)))return x.push(k)})){v=!1;break}}else if(!(w===C||d(w,C,c,l,u))){v=!1;break}}return u.delete(s),u.delete(a),v}return ns=i,ns}var os,pp;function gC(){if(pp)return os;pp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,i){n[++t]=[i,o]}),n}return os=e,os}var is,gp;function eu(){if(gp)return is;gp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return is=e,is}var as,yp;function yC(){if(yp)return as;yp=1;var e=en(),r=sv(),t=Qr(),n=mv(),o=gC(),i=eu(),s=1,a=2,c="[object Boolean]",l="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",y="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",v="[object DataView]",x=e?e.prototype:void 0,w=x?x.valueOf:void 0;function C(S,_,k,E,O,P,A){switch(k){case v:if(S.byteLength!=_.byteLength||S.byteOffset!=_.byteOffset)return!1;S=S.buffer,_=_.buffer;case b:return!(S.byteLength!=_.byteLength||!P(new r(S),new r(_)));case c:case l:case h:return t(+S,+_);case d:return S.name==_.name&&S.message==_.message;case p:case y:return S==_+"";case u:var M=o;case m:var T=E&s;if(M||(M=i),S.size!=_.size&&!T)return!1;var N=A.get(S);if(N)return N==_;E|=a,A.set(S,_);var $=n(M(S),M(_),E,O,P,A);return A.delete(S),$;case g:if(w)return w.call(S)==w.call(_)}return!1}return as=C,as}var ss,mp;function mC(){if(mp)return ss;mp=1;var e=iv(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a,c,l,d){var u=a&r,h=e(i),p=h.length,m=e(s),y=m.length;if(p!=y&&!u)return!1;for(var g=p;g--;){var b=h[g];if(!(u?b in s:n.call(s,b)))return!1}var v=d.get(i),x=d.get(s);if(v&&x)return v==s&&x==i;var w=!0;d.set(i,s),d.set(s,i);for(var C=u;++g<p;){b=h[g];var S=i[b],_=s[b];if(c)var k=u?c(_,S,b,s,i,d):c(S,_,b,i,s,d);if(!(k===void 0?S===_||l(S,_,a,c,d):k)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var E=i.constructor,O=s.constructor;E!=O&&"constructor"in i&&"constructor"in s&&!(typeof E=="function"&&E instanceof E&&typeof O=="function"&&O instanceof O)&&(w=!1)}return d.delete(i),d.delete(s),w}return ss=o,ss}var cs,bp;function bC(){if(bp)return cs;bp=1;var e=wo(),r=mv(),t=yC(),n=mC(),o=rn(),i=yt(),s=tn(),a=zn(),c=1,l="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(y,g,b,v,x,w){var C=i(y),S=i(g),_=C?d:o(y),k=S?d:o(g);_=_==l?u:_,k=k==l?u:k;var E=_==u,O=k==u,P=_==k;if(P&&s(y)){if(!s(g))return!1;C=!0,E=!1}if(P&&!E)return w||(w=new e),C||a(y)?r(y,g,b,v,x,w):t(y,g,_,b,v,x,w);if(!(b&c)){var A=E&&p.call(y,"__wrapped__"),M=O&&p.call(g,"__wrapped__");if(A||M){var T=A?y.value():y,N=M?g.value():g;return w||(w=new e),x(T,N,b,v,w)}}return P?(w||(w=new e),n(y,g,b,v,x,w)):!1}return cs=m,cs}var ls,vp;function bv(){if(vp)return ls;vp=1;var e=bC(),r=Qt();function t(n,o,i,s,a){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,i,s,t,a)}return ls=t,ls}var ds,xp;function vC(){if(xp)return ds;xp=1;var e=wo(),r=bv(),t=1,n=2;function o(i,s,a,c){var l=a.length,d=l,u=!c;if(i==null)return!d;for(i=Object(i);l--;){var h=a[l];if(u&&h[2]?h[1]!==i[h[0]]:!(h[0]in i))return!1}for(;++l<d;){h=a[l];var p=h[0],m=i[p],y=h[1];if(u&&h[2]){if(m===void 0&&!(p in i))return!1}else{var g=new e;if(c)var b=c(m,y,p,i,s,g);if(!(b===void 0?r(y,m,t|n,c,g):b))return!1}}return!0}return ds=o,ds}var us,wp;function vv(){if(wp)return us;wp=1;var e=Lt();function r(t){return t===t&&!e(t)}return us=r,us}var fs,Cp;function xC(){if(Cp)return fs;Cp=1;var e=vv(),r=xr();function t(n){for(var o=r(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return fs=t,fs}var hs,Sp;function xv(){if(Sp)return hs;Sp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return hs=e,hs}var ps,jp;function wC(){if(jp)return ps;jp=1;var e=vC(),r=xC(),t=xv();function n(o){var i=r(o);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return ps=n,ps}var gs,_p;function nn(){if(_p)return gs;_p=1;var e=Ir(),r=Qt(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return gs=n,gs}var ys,Ep;function tu(){if(Ep)return ys;Ep=1;var e=yt(),r=nn(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,s){if(e(i))return!1;var a=typeof i;return a=="number"||a=="symbol"||a=="boolean"||i==null||r(i)?!0:n.test(i)||!t.test(i)||s!=null&&i in Object(s)}return ys=o,ys}var ms,kp;function CC(){if(kp)return ms;kp=1;var e=Vd(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],c=i.cache;if(c.has(a))return c.get(a);var l=n.apply(this,s);return i.cache=c.set(a,l)||c,l};return i.cache=new(t.Cache||e),i}return t.Cache=e,ms=t,ms}var bs,Rp;function SC(){if(Rp)return bs;Rp=1;var e=CC(),r=500;function t(n){var o=e(n,function(s){return i.size===r&&i.clear(),s}),i=o.cache;return o}return bs=t,bs}var vs,Ap;function jC(){if(Ap)return vs;Ap=1;var e=SC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(r,function(s,a,c,l){i.push(c?l.replace(t,"$1"):a||s)}),i});return vs=n,vs}var xs,Pp;function Ao(){if(Pp)return xs;Pp=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=Array(o);++n<o;)i[n]=t(r[n],n,r);return i}return xs=e,xs}var ws,Mp;function _C(){if(Mp)return ws;Mp=1;var e=en(),r=Ao(),t=yt(),n=nn(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return i?i.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return ws=s,ws}var Cs,Ip;function wv(){if(Ip)return Cs;Ip=1;var e=_C();function r(t){return t==null?"":e(t)}return Cs=r,Cs}var Ss,Tp;function Po(){if(Tp)return Ss;Tp=1;var e=yt(),r=tu(),t=jC(),n=wv();function o(i,s){return e(i)?i:r(i,s)?[i]:t(n(i))}return Ss=o,Ss}var js,Op;function Bn(){if(Op)return js;Op=1;var e=nn();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return js=r,js}var _s,Np;function Mo(){if(Np)return _s;Np=1;var e=Po(),r=Bn();function t(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[r(o[i++])];return i&&i==s?n:void 0}return _s=t,_s}var Es,$p;function EC(){if($p)return Es;$p=1;var e=Mo();function r(t,n,o){var i=t==null?void 0:e(t,n);return i===void 0?o:i}return Es=r,Es}var ks,qp;function kC(){if(qp)return ks;qp=1;function e(r,t){return r!=null&&t in Object(r)}return ks=e,ks}var Rs,Lp;function Cv(){if(Lp)return Rs;Lp=1;var e=Po(),r=Fn(),t=yt(),n=jo(),o=Gd(),i=Bn();function s(a,c,l){c=e(c,a);for(var d=-1,u=c.length,h=!1;++d<u;){var p=i(c[d]);if(!(h=a!=null&&l(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&o(u)&&n(p,u)&&(t(a)||r(a)))}return Rs=s,Rs}var As,Fp;function Sv(){if(Fp)return As;Fp=1;var e=kC(),r=Cv();function t(n,o){return n!=null&&r(n,o,e)}return As=t,As}var Ps,zp;function RC(){if(zp)return Ps;zp=1;var e=bv(),r=EC(),t=Sv(),n=tu(),o=vv(),i=xv(),s=Bn(),a=1,c=2;function l(d,u){return n(d)&&o(u)?i(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|c)}}return Ps=l,Ps}var Ms,Bp;function jv(){if(Bp)return Ms;Bp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Ms=e,Ms}var Is,Dp;function AC(){if(Dp)return Is;Dp=1;var e=Mo();function r(t){return function(n){return e(n,t)}}return Is=r,Is}var Ts,Vp;function PC(){if(Vp)return Ts;Vp=1;var e=jv(),r=AC(),t=tu(),n=Bn();function o(i){return t(i)?e(n(i)):r(i)}return Ts=o,Ts}var Os,Wp;function ir(){if(Wp)return Os;Wp=1;var e=wC(),r=RC(),t=Nr(),n=yt(),o=PC();function i(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):o(s)}return Os=i,Os}var Ns,Gp;function _v(){if(Gp)return Ns;Gp=1;var e=tv(),r=uC(),t=ir(),n=yt();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Ns=o,Ns}var $s,Up;function MC(){if(Up)return $s;Up=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return $s=t,$s}var qs,Hp;function Ev(){if(Hp)return qs;Hp=1;var e=MC(),r=Cv();function t(n,o){return n!=null&&r(n,o,e)}return qs=t,qs}var Ls,Kp;function IC(){if(Kp)return Ls;Kp=1;var e=Hd(),r=rn(),t=Fn(),n=yt(),o=or(),i=tn(),s=Eo(),a=zn(),c="[object Map]",l="[object Set]",d=Object.prototype,u=d.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||t(p)))return!p.length;var m=r(p);if(m==c||m==l)return!p.size;if(s(p))return!e(p).length;for(var y in p)if(u.call(p,y))return!1;return!0}return Ls=h,Ls}var Fs,Jp;function kv(){if(Jp)return Fs;Jp=1;function e(r){return r===void 0}return Fs=e,Fs}var zs,Zp;function Rv(){if(Zp)return zs;Zp=1;var e=Ro(),r=or();function t(n,o){var i=-1,s=r(n)?Array(n.length):[];return e(n,function(a,c,l){s[++i]=o(a,c,l)}),s}return zs=t,zs}var Bs,Yp;function Av(){if(Yp)return Bs;Yp=1;var e=Ao(),r=ir(),t=Rv(),n=yt();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Bs=o,Bs}var Ds,Xp;function TC(){if(Xp)return Ds;Xp=1;function e(r,t,n,o){var i=-1,s=r==null?0:r.length;for(o&&s&&(n=r[++i]);++i<s;)n=t(n,r[i],i,r);return n}return Ds=e,Ds}var Vs,Qp;function OC(){if(Qp)return Vs;Qp=1;function e(r,t,n,o,i){return i(r,function(s,a,c){n=o?(o=!1,s):t(n,s,a,c)}),n}return Vs=e,Vs}var Ws,eg;function Pv(){if(eg)return Ws;eg=1;var e=TC(),r=Ro(),t=ir(),n=OC(),o=yt();function i(s,a,c){var l=o(s)?e:n,d=arguments.length<3;return l(s,t(a,4),c,d,r)}return Ws=i,Ws}var Gs,tg;function NC(){if(tg)return Gs;tg=1;var e=Ir(),r=yt(),t=Qt(),n="[object String]";function o(i){return typeof i=="string"||!r(i)&&t(i)&&e(i)==n}return Gs=o,Gs}var Us,rg;function $C(){if(rg)return Us;rg=1;var e=jv(),r=e("length");return Us=r,Us}var Hs,ng;function qC(){if(ng)return Hs;ng=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function c(l){return a.test(l)}return Hs=c,Hs}var Ks,og;function LC(){if(og)return Ks;og=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+a+"|"+c+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=l+"?",y="["+i+"]?",g="(?:"+p+"(?:"+[d,u,h].join("|")+")"+y+m+")*",b=y+m+g,v="(?:"+[d+a+"?",a,u,h,s].join("|")+")",x=RegExp(c+"(?="+c+")|"+v+b,"g");function w(C){for(var S=x.lastIndex=0;x.test(C);)++S;return S}return Ks=w,Ks}var Js,ig;function FC(){if(ig)return Js;ig=1;var e=$C(),r=qC(),t=LC();function n(o){return r(o)?t(o):e(o)}return Js=n,Js}var Zs,ag;function zC(){if(ag)return Zs;ag=1;var e=Hd(),r=rn(),t=or(),n=NC(),o=FC(),i="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(t(c))return n(c)?o(c):c.length;var l=r(c);return l==i||l==s?c.size:e(c).length}return Zs=a,Zs}var Ys,sg;function BC(){if(sg)return Ys;sg=1;var e=Wd(),r=lv(),t=Qd(),n=ir(),o=ko(),i=yt(),s=tn(),a=qn(),c=Lt(),l=zn();function d(u,h,p){var m=i(u),y=m||s(u)||l(u);if(h=n(h,4),p==null){var g=u&&u.constructor;y?p=m?new g:[]:c(u)?p=a(g)?r(o(u)):{}:p={}}return(y?e:t)(u,function(b,v,x){return h(p,b,v,x)}),p}return Ys=d,Ys}var Xs,cg;function DC(){if(cg)return Xs;cg=1;var e=en(),r=Fn(),t=yt(),n=e?e.isConcatSpreadable:void 0;function o(i){return t(i)||r(i)||!!(n&&i&&i[n])}return Xs=o,Xs}var Qs,lg;function ru(){if(lg)return Qs;lg=1;var e=Jd(),r=DC();function t(n,o,i,s,a){var c=-1,l=n.length;for(i||(i=r),a||(a=[]);++c<l;){var d=n[c];o>0&&i(d)?o>1?t(d,o-1,i,s,a):e(a,d):s||(a[a.length]=d)}return a}return Qs=t,Qs}var ec,dg;function VC(){if(dg)return ec;dg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return ec=e,ec}var tc,ug;function Mv(){if(ug)return tc;ug=1;var e=VC(),r=Math.max;function t(n,o,i){return o=r(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,c=r(s.length-o,0),l=Array(c);++a<c;)l[a]=s[o+a];a=-1;for(var d=Array(o+1);++a<o;)d[a]=s[a];return d[o]=i(l),e(n,this,d)}}return tc=t,tc}var rc,fg;function WC(){if(fg)return rc;fg=1;var e=Yd(),r=Zb(),t=Nr(),n=r?function(o,i){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:t;return rc=n,rc}var nc,hg;function GC(){if(hg)return nc;hg=1;var e=800,r=16,t=Date.now;function n(o){var i=0,s=0;return function(){var a=t(),c=r-(a-s);if(s=a,c>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return nc=n,nc}var oc,pg;function Iv(){if(pg)return oc;pg=1;var e=WC(),r=GC(),t=r(e);return oc=t,oc}var ic,gg;function Io(){if(gg)return ic;gg=1;var e=Nr(),r=Mv(),t=Iv();function n(o,i){return t(r(o,i,e),o+"")}return ic=n,ic}var ac,yg;function Tv(){if(yg)return ac;yg=1;function e(r,t,n,o){for(var i=r.length,s=n+(o?1:-1);o?s--:++s<i;)if(t(r[s],s,r))return s;return-1}return ac=e,ac}var sc,mg;function UC(){if(mg)return sc;mg=1;function e(r){return r!==r}return sc=e,sc}var cc,bg;function HC(){if(bg)return cc;bg=1;function e(r,t,n){for(var o=n-1,i=r.length;++o<i;)if(r[o]===t)return o;return-1}return cc=e,cc}var lc,vg;function KC(){if(vg)return lc;vg=1;var e=Tv(),r=UC(),t=HC();function n(o,i,s){return i===i?t(o,i,s):e(o,r,s)}return lc=n,lc}var dc,xg;function JC(){if(xg)return dc;xg=1;var e=KC();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return dc=r,dc}var uc,wg;function ZC(){if(wg)return uc;wg=1;function e(r,t,n){for(var o=-1,i=r==null?0:r.length;++o<i;)if(n(t,r[o]))return!0;return!1}return uc=e,uc}var fc,Cg;function YC(){if(Cg)return fc;Cg=1;function e(){}return fc=e,fc}var hc,Sg;function XC(){if(Sg)return hc;Sg=1;var e=av(),r=YC(),t=eu(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(i){return new e(i)}:r;return hc=o,hc}var pc,jg;function QC(){if(jg)return pc;jg=1;var e=gv(),r=JC(),t=ZC(),n=yv(),o=XC(),i=eu(),s=200;function a(c,l,d){var u=-1,h=r,p=c.length,m=!0,y=[],g=y;if(d)m=!1,h=t;else if(p>=s){var b=l?null:o(c);if(b)return i(b);m=!1,h=n,g=new e}else g=l?[]:y;e:for(;++u<p;){var v=c[u],x=l?l(v):v;if(v=d||v!==0?v:0,m&&x===x){for(var w=g.length;w--;)if(g[w]===x)continue e;l&&g.push(x),y.push(v)}else h(g,x,d)||(g!==y&&g.push(x),y.push(v))}return y}return pc=a,pc}var gc,_g;function Ov(){if(_g)return gc;_g=1;var e=or(),r=Qt();function t(n){return r(n)&&e(n)}return gc=t,gc}var yc,Eg;function eS(){if(Eg)return yc;Eg=1;var e=ru(),r=Io(),t=QC(),n=Ov(),o=r(function(i){return t(e(i,1,n,!0))});return yc=o,yc}var mc,kg;function tS(){if(kg)return mc;kg=1;var e=Ao();function r(t,n){return e(n,function(o){return t[o]})}return mc=r,mc}var bc,Rg;function Nv(){if(Rg)return bc;Rg=1;var e=tS(),r=xr();function t(n){return n==null?[]:e(n,r(n))}return bc=t,bc}var vc,Ag;function Ft(){if(Ag)return vc;Ag=1;var e;if(typeof Bd=="function")try{e={clone:cC(),constant:Yd(),each:pv(),filter:_v(),has:Ev(),isArray:yt(),isEmpty:IC(),isFunction:qn(),isUndefined:kv(),keys:xr(),map:Av(),reduce:Pv(),size:zC(),transform:BC(),union:eS(),values:Nv()}}catch{}return e||(e=window._),vc=e,vc}var xc,Pg;function nu(){if(Pg)return xc;Pg=1;var e=Ft();xc=o;var r="\0",t="\0",n="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},o.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(m){h.length>1?p.setNode(m,u):p.setNode(m)}),this},o.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},o.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},o.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},o.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},o.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(y,g){d(g)&&u.setNode(g,y)}),e.each(this._edgeObjs,function(y){u.hasNode(y.v)&&u.hasNode(y.w)&&u.setEdge(y,h.edge(y))});var p={};function m(y){var g=h.parent(y);return g===void 0||u.hasNode(g)?(p[y]=g,g):g in p?p[g]:m(g)}return this._isCompound&&e.each(u.nodes(),function(y){u.setParent(y,m(y))}),u},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(m,y){return p.length>1?h.setEdge(m,y,u):h.setEdge(m,y),y}),this},o.prototype.setEdge=function(){var d,u,h,p,m=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,u=y.w,h=y.name,arguments.length===2&&(p=arguments[1],m=!0)):(d=y,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,d,u,h);if(e.has(this._edgeLabels,g))return m&&(this._edgeLabels[g]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(u),this._edgeLabels[g]=m?p:this._defaultEdgeLabelFn(d,u,h);var b=c(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[g]=b,i(this._preds[u],d),i(this._sucs[d],u),this._in[u][g]=b,this._out[d][g]=b,this._edgeCount++,this},o.prototype.edge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},o.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),m=this._edgeObjs[p];return m&&(d=m.v,u=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},o.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.v===u}):p}},o.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.w===u}):p}},o.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function i(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var m=""+u,y=""+h;if(!d&&m>y){var g=m;m=y,y=g}return m+n+y+n+(e.isUndefined(p)?r:p)}function c(d,u,h,p){var m=""+u,y=""+h;if(!d&&m>y){var g=m;m=y,y=g}var b={v:m,w:y};return p&&(b.name=p),b}function l(d,u){return a(d,u.v,u.w,u.name)}return xc}var wc,Mg;function rS(){return Mg||(Mg=1,wc="2.1.8"),wc}var Cc,Ig;function nS(){return Ig||(Ig=1,Cc={Graph:nu(),version:rS()}),Cc}var Sc,Tg;function oS(){if(Tg)return Sc;Tg=1;var e=Ft(),r=nu();Sc={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:o(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),l=s.parent(a),d={v:a};return e.isUndefined(c)||(d.value=c),e.isUndefined(l)||(d.parent=l),d})}function o(s){return e.map(s.edges(),function(a){var c=s.edge(a),l={v:a.v,w:a.w};return e.isUndefined(a.name)||(l.name=a.name),e.isUndefined(c)||(l.value=c),l})}function i(s){var a=new r(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Sc}var jc,Og;function iS(){if(Og)return jc;Og=1;var e=Ft();jc=r;function r(t){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return jc}var _c,Ng;function $v(){if(Ng)return _c;Ng=1;var e=Ft();_c=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var o=this._keyIndices;if(t=String(t),!e.has(o,t)){var i=this._arr,s=i.length;return o[t]=s,i.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,i=o+1,s=t;o<n.length&&(s=n[o].priority<n[s].priority?o:s,i<n.length&&(s=n[i].priority<n[s].priority?i:s),s!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,i;t!==0&&(i=t>>1,!(n[i].priority<o));)this._swap(t,i),t=i},r.prototype._swap=function(t,n){var o=this._arr,i=this._keyIndices,s=o[t],a=o[n];o[t]=a,o[n]=s,i[a.key]=t,i[s.key]=n},_c}var Ec,$g;function qv(){if($g)return Ec;$g=1;var e=Ft(),r=$v();Ec=n;var t=e.constant(1);function n(i,s,a,c){return o(i,String(s),a||t,c||function(l){return i.outEdges(l)})}function o(i,s,a,c){var l={},d=new r,u,h,p=function(m){var y=m.v!==u?m.v:m.w,g=l[y],b=a(m),v=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+b);v<g.distance&&(g.distance=v,g.predecessor=u,d.decrease(y,v))};for(i.nodes().forEach(function(m){var y=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:y},d.add(m,y)});d.size()>0&&(u=d.removeMin(),h=l[u],h.distance!==Number.POSITIVE_INFINITY);)c(u).forEach(p);return l}return Ec}var kc,qg;function aS(){if(qg)return kc;qg=1;var e=qv(),r=Ft();kc=t;function t(n,o,i){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return kc}var Rc,Lg;function Lv(){if(Lg)return Rc;Lg=1;var e=Ft();Rc=r;function r(t){var n=0,o=[],i={},s=[];function a(c){var l=i[c]={onStack:!0,lowlink:n,index:n++};if(o.push(c),t.successors(c).forEach(function(h){e.has(i,h)?i[h].onStack&&(l.lowlink=Math.min(l.lowlink,i[h].index)):(a(h),l.lowlink=Math.min(l.lowlink,i[h].lowlink))}),l.lowlink===l.index){var d=[],u;do u=o.pop(),i[u].onStack=!1,d.push(u);while(c!==u);s.push(d)}}return t.nodes().forEach(function(c){e.has(i,c)||a(c)}),s}return Rc}var Ac,Fg;function sS(){if(Fg)return Ac;Fg=1;var e=Ft(),r=Lv();Ac=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Ac}var Pc,zg;function cS(){if(zg)return Pc;zg=1;var e=Ft();Pc=t;var r=e.constant(1);function t(o,i,s){return n(o,i||r,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},c=o.nodes();return c.forEach(function(l){a[l]={},a[l][l]={distance:0},c.forEach(function(d){l!==d&&(a[l][d]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(d){var u=d.v===l?d.w:d.v,h=i(d);a[l][u]={distance:h,predecessor:l}})}),c.forEach(function(l){var d=a[l];c.forEach(function(u){var h=a[u];c.forEach(function(p){var m=h[l],y=d[p],g=h[p],b=m.distance+y.distance;b<g.distance&&(g.distance=b,g.predecessor=y.predecessor)})})}),a}return Pc}var Mc,Bg;function Fv(){if(Bg)return Mc;Bg=1;var e=Ft();Mc=r,r.CycleException=t;function r(n){var o={},i={},s=[];function a(c){if(e.has(i,c))throw new t;e.has(o,c)||(i[c]=!0,o[c]=!0,e.each(n.predecessors(c),a),delete i[c],s.push(c))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new t;return s}function t(){}return t.prototype=new Error,Mc}var Ic,Dg;function lS(){if(Dg)return Ic;Dg=1;var e=Fv();Ic=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ic}var Tc,Vg;function zv(){if(Vg)return Tc;Vg=1;var e=Ft();Tc=r;function r(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(o,function(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,i==="post",c,s,a)}),a}function t(n,o,i,s,a,c){e.has(s,o)||(s[o]=!0,i||c.push(o),e.each(a(o),function(l){t(n,l,i,s,a,c)}),i&&c.push(o))}return Tc}var Oc,Wg;function dS(){if(Wg)return Oc;Wg=1;var e=zv();Oc=r;function r(t,n){return e(t,n,"post")}return Oc}var Nc,Gg;function uS(){if(Gg)return Nc;Gg=1;var e=zv();Nc=r;function r(t,n){return e(t,n,"pre")}return Nc}var $c,Ug;function fS(){if(Ug)return $c;Ug=1;var e=Ft(),r=nu(),t=$v();$c=n;function n(o,i){var s=new r,a={},c=new t,l;function d(h){var p=h.v===l?h.w:h.v,m=c.priority(p);if(m!==void 0){var y=i(h);y<m&&(a[p]=l,c.decrease(p,y))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(o.nodes()[0],0);for(var u=!1;c.size()>0;){if(l=c.removeMin(),e.has(a,l))s.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+o);u=!0}o.nodeEdges(l).forEach(d)}return s}return $c}var qc,Hg;function hS(){return Hg||(Hg=1,qc={components:iS(),dijkstra:qv(),dijkstraAll:aS(),findCycles:sS(),floydWarshall:cS(),isAcyclic:lS(),postorder:dS(),preorder:uS(),prim:fS(),tarjan:Lv(),topsort:Fv()}),qc}var Lc,Kg;function pS(){if(Kg)return Lc;Kg=1;var e=nS();return Lc={Graph:e.Graph,json:oS(),alg:hS(),version:e.version},Lc}var Fc,Jg;function Gt(){if(Jg)return Fc;Jg=1;var e;if(typeof Bd=="function")try{e=pS()}catch{}return e||(e=window.graphlib),Fc=e,Fc}var zc,Zg;function gS(){if(Zg)return zc;Zg=1;var e=uv(),r=1,t=4;function n(o){return e(o,r|t)}return zc=n,zc}var Bc,Yg;function To(){if(Yg)return Bc;Yg=1;var e=Qr(),r=or(),t=jo(),n=Lt();function o(i,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?r(a)&&t(s,a.length):c=="string"&&s in a)?e(a[s],i):!1}return Bc=o,Bc}var Dc,Xg;function yS(){if(Xg)return Dc;Xg=1;var e=Io(),r=Qr(),t=To(),n=Or(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,c){a=Object(a);var l=-1,d=c.length,u=d>2?c[2]:void 0;for(u&&t(c[0],c[1],u)&&(d=1);++l<d;)for(var h=c[l],p=n(h),m=-1,y=p.length;++m<y;){var g=p[m],b=a[g];(b===void 0||r(b,o[g])&&!i.call(a,g))&&(a[g]=h[g])}return a});return Dc=s,Dc}var Vc,Qg;function mS(){if(Qg)return Vc;Qg=1;var e=ir(),r=or(),t=xr();function n(o){return function(i,s,a){var c=Object(i);if(!r(i)){var l=e(s,3);i=t(i),s=function(u){return l(c[u],u,c)}}var d=o(i,s,a);return d>-1?c[l?i[d]:d]:void 0}}return Vc=n,Vc}var Wc,ey;function bS(){if(ey)return Wc;ey=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return Wc=r,Wc}var Gc,ty;function vS(){if(ty)return Gc;ty=1;var e=bS(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return Gc=t,Gc}var Uc,ry;function xS(){if(ry)return Uc;ry=1;var e=vS(),r=Lt(),t=nn(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(l){if(typeof l=="number")return l;if(t(l))return n;if(r(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=r(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var u=i.test(l);return u||s.test(l)?a(l.slice(2),u?2:8):o.test(l)?n:+l}return Uc=c,Uc}var Hc,ny;function Bv(){if(ny)return Hc;ny=1;var e=xS(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var i=o<0?-1:1;return i*t}return o===o?o:0}return Hc=n,Hc}var Kc,oy;function wS(){if(oy)return Kc;oy=1;var e=Bv();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return Kc=r,Kc}var Jc,iy;function CS(){if(iy)return Jc;iy=1;var e=Tv(),r=ir(),t=wS(),n=Math.max;function o(i,s,a){var c=i==null?0:i.length;if(!c)return-1;var l=a==null?0:t(a);return l<0&&(l=n(c+l,0)),e(i,r(s,3),l)}return Jc=o,Jc}var Zc,ay;function SS(){if(ay)return Zc;ay=1;var e=mS(),r=CS(),t=e(r);return Zc=t,Zc}var Yc,sy;function Dv(){if(sy)return Yc;sy=1;var e=ru();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return Yc=r,Yc}var Xc,cy;function jS(){if(cy)return Xc;cy=1;var e=Xd(),r=fv(),t=Or();function n(o,i){return o==null?o:e(o,r(i),t)}return Xc=n,Xc}var Qc,ly;function _S(){if(ly)return Qc;ly=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Qc=e,Qc}var el,dy;function ES(){if(dy)return el;dy=1;var e=Co(),r=Qd(),t=ir();function n(o,i){var s={};return i=t(i,3),r(o,function(a,c,l){e(s,c,i(a,c,l))}),s}return el=n,el}var tl,uy;function ou(){if(uy)return tl;uy=1;var e=nn();function r(t,n,o){for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n(a);if(c!=null&&(l===void 0?c===c&&!e(c):o(c,l)))var l=c,d=a}return d}return tl=r,tl}var rl,fy;function kS(){if(fy)return rl;fy=1;function e(r,t){return r>t}return rl=e,rl}var nl,hy;function RS(){if(hy)return nl;hy=1;var e=ou(),r=kS(),t=Nr();function n(o){return o&&o.length?e(o,t,r):void 0}return nl=n,nl}var ol,py;function Vv(){if(py)return ol;py=1;var e=Co(),r=Qr();function t(n,o,i){(i!==void 0&&!r(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return ol=t,ol}var il,gy;function AS(){if(gy)return il;gy=1;var e=Ir(),r=ko(),t=Qt(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,c=s.call(Object);function l(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return il=l,il}var al,yy;function Wv(){if(yy)return al;yy=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return al=e,al}var sl,my;function PS(){if(my)return sl;my=1;var e=Ln(),r=Or();function t(n){return e(n,r(n))}return sl=t,sl}var cl,by;function MS(){if(by)return cl;by=1;var e=Vv(),r=Qb(),t=cv(),n=ev(),o=dv(),i=Fn(),s=yt(),a=Ov(),c=tn(),l=qn(),d=Lt(),u=AS(),h=zn(),p=Wv(),m=PS();function y(g,b,v,x,w,C,S){var _=p(g,v),k=p(b,v),E=S.get(k);if(E){e(g,v,E);return}var O=C?C(_,k,v+"",g,b,S):void 0,P=O===void 0;if(P){var A=s(k),M=!A&&c(k),T=!A&&!M&&h(k);O=k,A||M||T?s(_)?O=_:a(_)?O=n(_):M?(P=!1,O=r(k,!0)):T?(P=!1,O=t(k,!0)):O=[]:u(k)||i(k)?(O=_,i(_)?O=m(_):(!d(_)||l(_))&&(O=o(k))):P=!1}P&&(S.set(k,O),w(O,k,x,C,S),S.delete(k)),e(g,v,O)}return cl=y,cl}var ll,vy;function IS(){if(vy)return ll;vy=1;var e=wo(),r=Vv(),t=Xd(),n=MS(),o=Lt(),i=Or(),s=Wv();function a(c,l,d,u,h){c!==l&&t(l,function(p,m){if(h||(h=new e),o(p))n(c,l,m,d,a,u,h);else{var y=u?u(s(c,m),p,m+"",c,l,h):void 0;y===void 0&&(y=p),r(c,m,y)}},i)}return ll=a,ll}var dl,xy;function TS(){if(xy)return dl;xy=1;var e=Io(),r=To();function t(n){return e(function(o,i){var s=-1,a=i.length,c=a>1?i[a-1]:void 0,l=a>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,l&&r(i[0],i[1],l)&&(c=a<3?void 0:c,a=1),o=Object(o);++s<a;){var d=i[s];d&&n(o,d,s,c)}return o})}return dl=t,dl}var ul,wy;function OS(){if(wy)return ul;wy=1;var e=IS(),r=TS(),t=r(function(n,o,i){e(n,o,i)});return ul=t,ul}var fl,Cy;function Gv(){if(Cy)return fl;Cy=1;function e(r,t){return r<t}return fl=e,fl}var hl,Sy;function NS(){if(Sy)return hl;Sy=1;var e=ou(),r=Gv(),t=Nr();function n(o){return o&&o.length?e(o,t,r):void 0}return hl=n,hl}var pl,jy;function $S(){if(jy)return pl;jy=1;var e=ou(),r=ir(),t=Gv();function n(o,i){return o&&o.length?e(o,r(i,2),t):void 0}return pl=n,pl}var gl,_y;function qS(){if(_y)return gl;_y=1;var e=Ut(),r=function(){return e.Date.now()};return gl=r,gl}var yl,Ey;function LS(){if(Ey)return yl;Ey=1;var e=So(),r=Po(),t=jo(),n=Lt(),o=Bn();function i(s,a,c,l){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var m=o(a[d]),y=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return s;if(d!=h){var g=p[m];y=l?l(g,m,p):void 0,y===void 0&&(y=n(g)?g:t(a[d+1])?[]:{})}e(p,m,y),p=p[m]}return s}return yl=i,yl}var ml,ky;function FS(){if(ky)return ml;ky=1;var e=Mo(),r=LS(),t=Po();function n(o,i,s){for(var a=-1,c=i.length,l={};++a<c;){var d=i[a],u=e(o,d);s(u,d)&&r(l,t(d,o),u)}return l}return ml=n,ml}var bl,Ry;function zS(){if(Ry)return bl;Ry=1;var e=FS(),r=Sv();function t(n,o){return e(n,o,function(i,s){return r(n,s)})}return bl=t,bl}var vl,Ay;function BS(){if(Ay)return vl;Ay=1;var e=Dv(),r=Mv(),t=Iv();function n(o){return t(r(o,void 0,e),o+"")}return vl=n,vl}var xl,Py;function DS(){if(Py)return xl;Py=1;var e=zS(),r=BS(),t=r(function(n,o){return n==null?{}:e(n,o)});return xl=t,xl}var wl,My;function VS(){if(My)return wl;My=1;var e=Math.ceil,r=Math.max;function t(n,o,i,s){for(var a=-1,c=r(e((o-n)/(i||1)),0),l=Array(c);c--;)l[s?c:++a]=n,n+=i;return l}return wl=t,wl}var Cl,Iy;function WS(){if(Iy)return Cl;Iy=1;var e=VS(),r=To(),t=Bv();function n(o){return function(i,s,a){return a&&typeof a!="number"&&r(i,s,a)&&(s=a=void 0),i=t(i),s===void 0?(s=i,i=0):s=t(s),a=a===void 0?i<s?1:-1:t(a),e(i,s,a,o)}}return Cl=n,Cl}var Sl,Ty;function GS(){if(Ty)return Sl;Ty=1;var e=WS(),r=e();return Sl=r,Sl}var jl,Oy;function US(){if(Oy)return jl;Oy=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return jl=e,jl}var _l,Ny;function HS(){if(Ny)return _l;Ny=1;var e=nn();function r(t,n){if(t!==n){var o=t!==void 0,i=t===null,s=t===t,a=e(t),c=n!==void 0,l=n===null,d=n===n,u=e(n);if(!l&&!u&&!a&&t>n||a&&c&&d&&!l&&!u||i&&c&&d||!o&&d||!s)return 1;if(!i&&!a&&!u&&t<n||u&&o&&s&&!i&&!a||l&&o&&s||!c&&s||!d)return-1}return 0}return _l=r,_l}var El,$y;function KS(){if($y)return El;$y=1;var e=HS();function r(t,n,o){for(var i=-1,s=t.criteria,a=n.criteria,c=s.length,l=o.length;++i<c;){var d=e(s[i],a[i]);if(d){if(i>=l)return d;var u=o[i];return d*(u=="desc"?-1:1)}}return t.index-n.index}return El=r,El}var kl,qy;function JS(){if(qy)return kl;qy=1;var e=Ao(),r=Mo(),t=ir(),n=Rv(),o=US(),i=_o(),s=KS(),a=Nr(),c=yt();function l(d,u,h){u.length?u=e(u,function(y){return c(y)?function(g){return r(g,y.length===1?y[0]:y)}:y}):u=[a];var p=-1;u=e(u,i(t));var m=n(d,function(y,g,b){var v=e(u,function(x){return x(y)});return{criteria:v,index:++p,value:y}});return o(m,function(y,g){return s(y,g,h)})}return kl=l,kl}var Rl,Ly;function ZS(){if(Ly)return Rl;Ly=1;var e=ru(),r=JS(),t=Io(),n=To(),o=t(function(i,s){if(i==null)return[];var a=s.length;return a>1&&n(i,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),r(i,e(s,1),[])});return Rl=o,Rl}var Al,Fy;function YS(){if(Fy)return Al;Fy=1;var e=wv(),r=0;function t(n){var o=++r;return e(n)+o}return Al=t,Al}var Pl,zy;function XS(){if(zy)return Pl;zy=1;function e(r,t,n){for(var o=-1,i=r.length,s=t.length,a={};++o<i;){var c=o<s?t[o]:void 0;n(a,r[o],c)}return a}return Pl=e,Pl}var Ml,By;function QS(){if(By)return Ml;By=1;var e=So(),r=XS();function t(n,o){return r(n||[],o||[],e)}return Ml=t,Ml}var Il,Dy;function ut(){if(Dy)return Il;Dy=1;var e;if(typeof Bd=="function")try{e={cloneDeep:gS(),constant:Yd(),defaults:yS(),each:pv(),filter:_v(),find:SS(),flatten:Dv(),forEach:hv(),forIn:jS(),has:Ev(),isUndefined:kv(),last:_S(),map:Av(),mapValues:ES(),max:RS(),merge:OS(),min:NS(),minBy:$S(),now:qS(),pick:DS(),range:GS(),reduce:Pv(),sortBy:ZS(),uniqueId:YS(),values:Nv(),zipObject:QS()}}catch{}return e||(e=window._),Il=e,Il}var Tl,Vy;function ej(){if(Vy)return Tl;Vy=1,Tl=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,t)),i=i._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,o){if(n!=="_next"&&n!=="_prev")return o}return Tl}var Ol,Wy;function tj(){if(Wy)return Ol;Wy=1;var e=ut(),r=Gt().Graph,t=ej();Ol=o;var n=e.constant(1);function o(l,d){if(l.nodeCount()<=1)return[];var u=a(l,d||n),h=i(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return l.outEdges(p.v,p.w)}),!0)}function i(l,d,u){for(var h=[],p=d[d.length-1],m=d[0],y;l.nodeCount();){for(;y=m.dequeue();)s(l,d,u,y);for(;y=p.dequeue();)s(l,d,u,y);if(l.nodeCount()){for(var g=d.length-2;g>0;--g)if(y=d[g].dequeue(),y){h=h.concat(s(l,d,u,y,!0));break}}}return h}function s(l,d,u,h,p){var m=p?[]:void 0;return e.forEach(l.inEdges(h.v),function(y){var g=l.edge(y),b=l.node(y.v);p&&m.push({v:y.v,w:y.w}),b.out-=g,c(d,u,b)}),e.forEach(l.outEdges(h.v),function(y){var g=l.edge(y),b=y.w,v=l.node(b);v.in-=g,c(d,u,v)}),l.removeNode(h.v),m}function a(l,d){var u=new r,h=0,p=0;e.forEach(l.nodes(),function(g){u.setNode(g,{v:g,in:0,out:0})}),e.forEach(l.edges(),function(g){var b=u.edge(g.v,g.w)||0,v=d(g),x=b+v;u.setEdge(g.v,g.w,x),p=Math.max(p,u.node(g.v).out+=v),h=Math.max(h,u.node(g.w).in+=v)});var m=e.range(p+h+3).map(function(){return new t}),y=h+1;return e.forEach(u.nodes(),function(g){c(m,y,u.node(g))}),{graph:u,buckets:m,zeroIdx:y}}function c(l,d,u){u.out?u.in?l[u.out-u.in+d].enqueue(u):l[l.length-1].enqueue(u):l[0].enqueue(u)}return Ol}var Nl,Gy;function rj(){if(Gy)return Nl;Gy=1;var e=ut(),r=tj();Nl={run:t,undo:o};function t(i){var s=i.graph().acyclicer==="greedy"?r(i,a(i)):n(i);e.forEach(s,function(c){var l=i.edge(c);i.removeEdge(c),l.forwardName=c.name,l.reversed=!0,i.setEdge(c.w,c.v,l,e.uniqueId("rev"))});function a(c){return function(l){return c.edge(l).weight}}}function n(i){var s=[],a={},c={};function l(d){e.has(c,d)||(c[d]=!0,a[d]=!0,e.forEach(i.outEdges(d),function(u){e.has(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return e.forEach(i.nodes(),l),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,c)}})}return Nl}var $l,Uy;function Rt(){if(Uy)return $l;Uy=1;var e=ut(),r=Gt().Graph;$l={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:m,notime:y};function t(g,b,v,x){var w;do w=e.uniqueId(x);while(g.hasNode(w));return v.dummy=b,g.setNode(w,v),w}function n(g){var b=new r().setGraph(g.graph());return e.forEach(g.nodes(),function(v){b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){var x=b.edge(v.v,v.w)||{weight:0,minlen:1},w=g.edge(v);b.setEdge(v.v,v.w,{weight:x.weight+w.weight,minlen:Math.max(x.minlen,w.minlen)})}),b}function o(g){var b=new r({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(v){g.children(v).length||b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){b.setEdge(v,g.edge(v))}),b}function i(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.outEdges(v),function(w){x[w.w]=(x[w.w]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.inEdges(v),function(w){x[w.v]=(x[w.v]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function a(g,b){var v=g.x,x=g.y,w=b.x-v,C=b.y-x,S=g.width/2,_=g.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var k,E;return Math.abs(C)*S>Math.abs(w)*_?(C<0&&(_=-_),k=_*w/C,E=_):(w<0&&(S=-S),k=S,E=S*C/w),{x:v+k,y:x+E}}function c(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(v){var x=g.node(v),w=x.rank;e.isUndefined(w)||(b[w][x.order]=v)}),b}function l(g){var b=e.min(e.map(g.nodes(),function(v){return g.node(v).rank}));e.forEach(g.nodes(),function(v){var x=g.node(v);e.has(x,"rank")&&(x.rank-=b)})}function d(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),v=[];e.forEach(g.nodes(),function(C){var S=g.node(C).rank-b;v[S]||(v[S]=[]),v[S].push(C)});var x=0,w=g.graph().nodeRankFactor;e.forEach(v,function(C,S){e.isUndefined(C)&&S%w!==0?--x:x&&e.forEach(C,function(_){g.node(_).rank+=x})})}function u(g,b,v,x){var w={width:0,height:0};return arguments.length>=4&&(w.rank=v,w.order=x),t(g,"border",w,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var v=g.node(b).rank;if(!e.isUndefined(v))return v}))}function p(g,b){var v={lhs:[],rhs:[]};return e.forEach(g,function(x){b(x)?v.lhs.push(x):v.rhs.push(x)}),v}function m(g,b){var v=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-v)+"ms")}}function y(g,b){return b()}return $l}var ql,Hy;function nj(){if(Hy)return ql;Hy=1;var e=ut(),r=Rt();ql={run:t,undo:o};function t(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,c=i.node(a).rank,l=s.w,d=i.node(l).rank,u=s.name,h=i.edge(s),p=h.labelRank;if(d!==c+1){i.removeEdge(s);var m,y,g;for(g=0,++c;c<d;++g,++c)h.points=[],y={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},m=r.addDummyNode(i,"edge",y,"_d"),c===p&&(y.width=h.width,y.height=h.height,y.dummy="edge-label",y.labelpos=h.labelpos),i.setEdge(a,m,{weight:h.weight},u),g===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:h.weight},u)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),c=a.edgeLabel,l;for(i.setEdge(a.edgeObj,c);a.dummy;)l=i.successors(s)[0],i.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=l,a=i.node(s)})}return ql}var Ll,Ky;function ao(){if(Ky)return Ll;Ky=1;var e=ut();Ll={longestPath:r,slack:t};function r(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var c=e.min(e.map(n.outEdges(s),function(l){return i(l.w)-n.edge(l).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),i)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Ll}var Fl,Jy;function Uv(){if(Jy)return Fl;Jy=1;var e=ut(),r=Gt().Graph,t=ao().slack;Fl=n;function n(a){var c=new r({directed:!1}),l=a.nodes()[0],d=a.nodeCount();c.setNode(l,{});for(var u,h;o(c,a)<d;)u=i(c,a),h=c.hasNode(u.v)?t(a,u):-t(a,u),s(c,a,h);return c}function o(a,c){function l(d){e.forEach(c.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(c,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),l(p))})}return e.forEach(a.nodes(),l),a.nodeCount()}function i(a,c){return e.minBy(c.edges(),function(l){if(a.hasNode(l.v)!==a.hasNode(l.w))return t(c,l)})}function s(a,c,l){e.forEach(a.nodes(),function(d){c.node(d).rank+=l})}return Fl}var zl,Zy;function oj(){if(Zy)return zl;Zy=1;var e=ut(),r=Uv(),t=ao().slack,n=ao().longestPath,o=Gt().alg.preorder,i=Gt().alg.postorder,s=Rt().simplify;zl=a,a.initLowLimValues=u,a.initCutValues=c,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=m,a.exchangeEdges=y;function a(x){x=s(x),n(x);var w=r(x);u(w),c(w,x);for(var C,S;C=p(w);)S=m(w,x,C),y(w,x,C,S)}function c(x,w){var C=i(x,x.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){l(x,w,S)})}function l(x,w,C){var S=x.node(C),_=S.parent;x.edge(C,_).cutvalue=d(x,w,C)}function d(x,w,C){var S=x.node(C),_=S.parent,k=!0,E=w.edge(C,_),O=0;return E||(k=!1,E=w.edge(_,C)),O=E.weight,e.forEach(w.nodeEdges(C),function(P){var A=P.v===C,M=A?P.w:P.v;if(M!==_){var T=A===k,N=w.edge(P).weight;if(O+=T?N:-N,b(x,C,M)){var $=x.edge(C,M).cutvalue;O+=T?-$:$}}}),O}function u(x,w){arguments.length<2&&(w=x.nodes()[0]),h(x,{},1,w)}function h(x,w,C,S,_){var k=C,E=x.node(S);return w[S]=!0,e.forEach(x.neighbors(S),function(O){e.has(w,O)||(C=h(x,w,C,O,S))}),E.low=k,E.lim=C++,_?E.parent=_:delete E.parent,C}function p(x){return e.find(x.edges(),function(w){return x.edge(w).cutvalue<0})}function m(x,w,C){var S=C.v,_=C.w;w.hasEdge(S,_)||(S=C.w,_=C.v);var k=x.node(S),E=x.node(_),O=k,P=!1;k.lim>E.lim&&(O=E,P=!0);var A=e.filter(w.edges(),function(M){return P===v(x,x.node(M.v),O)&&P!==v(x,x.node(M.w),O)});return e.minBy(A,function(M){return t(w,M)})}function y(x,w,C,S){var _=C.v,k=C.w;x.removeEdge(_,k),x.setEdge(S.v,S.w,{}),u(x),c(x,w),g(x,w)}function g(x,w){var C=e.find(x.nodes(),function(_){return!w.node(_).parent}),S=o(x,C);S=S.slice(1),e.forEach(S,function(_){var k=x.node(_).parent,E=w.edge(_,k),O=!1;E||(E=w.edge(k,_),O=!0),w.node(_).rank=w.node(k).rank+(O?E.minlen:-E.minlen)})}function b(x,w,C){return x.hasEdge(w,C)}function v(x,w,C){return C.low<=w.lim&&w.lim<=C.lim}return zl}var Bl,Yy;function ij(){if(Yy)return Bl;Yy=1;var e=ao(),r=e.longestPath,t=Uv(),n=oj();Bl=o;function o(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":i(c);break;default:a(c)}}var i=r;function s(c){r(c),t(c)}function a(c){n(c)}return Bl}var Dl,Xy;function aj(){if(Xy)return Dl;Xy=1;var e=ut();Dl=r;function r(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),c=a.edgeObj,l=t(o,i,c.v,c.w),d=l.path,u=l.lca,h=0,p=d[h],m=!0;s!==c.w;){if(a=o.node(s),m){for(;(p=d[h])!==u&&o.node(p).maxRank<a.rank;)h++;p===u&&(m=!1)}if(!m){for(;h<d.length-1&&o.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}o.setParent(s,p),s=o.successors(s)[0]}})}function t(o,i,s,a){var c=[],l=[],d=Math.min(i[s].low,i[a].low),u=Math.max(i[s].lim,i[a].lim),h,p;h=s;do h=o.parent(h),c.push(h);while(h&&(i[h].low>d||u>i[h].lim));for(p=h,h=a;(h=o.parent(h))!==p;)l.push(h);return{path:c.concat(l.reverse()),lca:p}}function n(o){var i={},s=0;function a(c){var l=s;e.forEach(o.children(c),a),i[c]={low:l,lim:s++}}return e.forEach(o.children(),a),i}return Dl}var Vl,Qy;function sj(){if(Qy)return Vl;Qy=1;var e=ut(),r=Rt();Vl={run:t,cleanup:s};function t(a){var c=r.addDummyNode(a,"root",{},"_root"),l=o(a),d=e.max(e.values(l))-1,u=2*d+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=i(a)+1;e.forEach(a.children(),function(p){n(a,c,u,h,d,l,p)}),a.graph().nodeRankFactor=u}function n(a,c,l,d,u,h,p){var m=a.children(p);if(!m.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:l});return}var y=r.addBorderNode(a,"_bt"),g=r.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(y,p),b.borderTop=y,a.setParent(g,p),b.borderBottom=g,e.forEach(m,function(v){n(a,c,l,d,u,h,v);var x=a.node(v),w=x.borderTop?x.borderTop:v,C=x.borderBottom?x.borderBottom:v,S=x.borderTop?d:2*d,_=w!==C?1:u-h[p]+1;a.setEdge(y,w,{weight:S,minlen:_,nestingEdge:!0}),a.setEdge(C,g,{weight:S,minlen:_,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,y,{weight:0,minlen:u+h[p]})}function o(a){var c={};function l(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){l(p,u+1)}),c[d]=u}return e.forEach(a.children(),function(d){l(d,1)}),c}function i(a){return e.reduce(a.edges(),function(c,l){return c+a.edge(l).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(l){var d=a.edge(l);d.nestingEdge&&a.removeEdge(l)})}return Vl}var Wl,em;function cj(){if(em)return Wl;em=1;var e=ut(),r=Rt();Wl=t;function t(o){function i(s){var a=o.children(s),c=o.node(s);if(a.length&&e.forEach(a,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var l=c.minRank,d=c.maxRank+1;l<d;++l)n(o,"borderLeft","_bl",s,c,l),n(o,"borderRight","_br",s,c,l)}}e.forEach(o.children(),i)}function n(o,i,s,a,c,l){var d={width:0,height:0,rank:l,borderType:i},u=c[i][l-1],h=r.addDummyNode(o,"border",d,s);c[i][l]=h,o.setParent(h,a),u&&o.setEdge(u,h,{weight:1})}return Wl}var Gl,tm;function lj(){if(tm)return Gl;tm=1;var e=ut();Gl={adjust:r,undo:t};function r(l){var d=l.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(l)}function t(l){var d=l.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&i(l),(d==="lr"||d==="rl")&&(a(l),n(l))}function n(l){e.forEach(l.nodes(),function(d){o(l.node(d))}),e.forEach(l.edges(),function(d){o(l.edge(d))})}function o(l){var d=l.width;l.width=l.height,l.height=d}function i(l){e.forEach(l.nodes(),function(d){s(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(l){l.y=-l.y}function a(l){e.forEach(l.nodes(),function(d){c(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,c),e.has(u,"x")&&c(u)})}function c(l){var d=l.x;l.x=l.y,l.y=d}return Gl}var Ul,rm;function dj(){if(rm)return Ul;rm=1;var e=ut();Ul=r;function r(t){var n={},o=e.filter(t.nodes(),function(l){return!t.children(l).length}),i=e.max(e.map(o,function(l){return t.node(l).rank})),s=e.map(e.range(i+1),function(){return[]});function a(l){if(!e.has(n,l)){n[l]=!0;var d=t.node(l);s[d.rank].push(l),e.forEach(t.successors(l),a)}}var c=e.sortBy(o,function(l){return t.node(l).rank});return e.forEach(c,a),s}return Ul}var Hl,nm;function uj(){if(nm)return Hl;nm=1;var e=ut();Hl=r;function r(n,o){for(var i=0,s=1;s<o.length;++s)i+=t(n,o[s-1],o[s]);return i}function t(n,o,i){for(var s=e.zipObject(i,e.map(i,function(h,p){return p})),a=e.flatten(e.map(o,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var l=2*c-1;c-=1;var d=e.map(new Array(l),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;d[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*m})),u}return Hl}var Kl,om;function fj(){if(om)return Kl;om=1;var e=ut();Kl=r;function r(t,n){return e.map(n,function(o){var i=t.inEdges(o);if(i.length){var s=e.reduce(i,function(a,c){var l=t.edge(c),d=t.node(c.v);return{sum:a.sum+l.weight*d.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return Kl}var Jl,im;function hj(){if(im)return Jl;im=1;var e=ut();Jl=r;function r(o,i){var s={};e.forEach(o,function(c,l){var d=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:l};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(i.edges(),function(c){var l=s[c.v],d=s[c.w];!e.isUndefined(l)&&!e.isUndefined(d)&&(d.indegree++,l.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return t(a)}function t(o){var i=[];function s(l){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(l.barycenter)||d.barycenter>=l.barycenter)&&n(l,d)}}function a(l){return function(d){d.in.push(l),--d.indegree===0&&o.push(d)}}for(;o.length;){var c=o.pop();i.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(i,function(l){return!l.merged}),function(l){return e.pick(l,["vs","i","barycenter","weight"])})}function n(o,i){var s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Jl}var Zl,am;function pj(){if(am)return Zl;am=1;var e=ut(),r=Rt();Zl=t;function t(i,s){var a=r.partition(i,function(y){return e.has(y,"barycenter")}),c=a.lhs,l=e.sortBy(a.rhs,function(y){return-y.i}),d=[],u=0,h=0,p=0;c.sort(o(!!s)),p=n(d,l,p),e.forEach(c,function(y){p+=y.vs.length,d.push(y.vs),u+=y.barycenter*y.weight,h+=y.weight,p=n(d,l,p)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=u/h,m.weight=h),m}function n(i,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),i.push(c.vs),a++;return a}function o(i){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}}return Zl}var Yl,sm;function gj(){if(sm)return Yl;sm=1;var e=ut(),r=fj(),t=hj(),n=pj();Yl=o;function o(a,c,l,d){var u=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,y={};p&&(u=e.filter(u,function(C){return C!==p&&C!==m}));var g=r(a,u);e.forEach(g,function(C){if(a.children(C.v).length){var S=o(a,C.v,l,d);y[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=t(g,l);i(b,y);var v=n(b,d);if(p&&(v.vs=e.flatten([p,v.vs,m],!0),a.predecessors(p).length)){var x=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(m)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+x.order+w.order)/(v.weight+2),v.weight+=2}return v}function i(a,c){e.forEach(a,function(l){l.vs=e.flatten(l.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return Yl}var Xl,cm;function yj(){if(cm)return Xl;cm=1;var e=ut(),r=Gt().Graph;Xl=t;function t(o,i,s){var a=n(o),c=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(l){return o.node(l)});return e.forEach(o.nodes(),function(l){var d=o.node(l),u=o.parent(l);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(l),c.setParent(l,u||a),e.forEach(o[s](l),function(h){var p=h.v===l?h.w:h.v,m=c.edge(p,l),y=e.isUndefined(m)?0:m.weight;c.setEdge(p,l,{weight:o.edge(h).weight+y})}),e.has(d,"minRank")&&c.setNode(l,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return Xl}var Ql,lm;function mj(){if(lm)return Ql;lm=1;var e=ut();Ql=r;function r(t,n,o){var i={},s;e.forEach(o,function(a){for(var c=t.parent(a),l,d;c;){if(l=t.parent(c),l?(d=i[l],i[l]=c):(d=s,s=c),d&&d!==c){n.setEdge(d,c);return}c=l}})}return Ql}var ed,dm;function bj(){if(dm)return ed;dm=1;var e=ut(),r=dj(),t=uj(),n=gj(),o=yj(),i=mj(),s=Gt().Graph,a=Rt();ed=c;function c(h){var p=a.maxRank(h),m=l(h,e.range(1,p+1),"inEdges"),y=l(h,e.range(p-1,-1,-1),"outEdges"),g=r(h);u(h,g);for(var b=Number.POSITIVE_INFINITY,v,x=0,w=0;w<4;++x,++w){d(x%2?m:y,x%4>=2),g=a.buildLayerMatrix(h);var C=t(h,g);C<b&&(w=0,v=e.cloneDeep(g),b=C)}u(h,v)}function l(h,p,m){return e.map(p,function(y){return o(h,y,m)})}function d(h,p){var m=new s;e.forEach(h,function(y){var g=y.graph().root,b=n(y,g,m,p);e.forEach(b.vs,function(v,x){y.node(v).order=x}),i(y,m,b.vs)})}function u(h,p){e.forEach(p,function(m){e.forEach(m,function(y,g){h.node(y).order=g})})}return ed}var td,um;function vj(){if(um)return td;um=1;var e=ut(),r=Gt().Graph,t=Rt();td={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,v){var x={};function w(C,S){var _=0,k=0,E=C.length,O=e.last(S);return e.forEach(S,function(P,A){var M=i(b,P),T=M?b.node(M).order:E;(M||P===O)&&(e.forEach(S.slice(k,A+1),function(N){e.forEach(b.predecessors(N),function($){var I=b.node($),W=I.order;(W<_||T<W)&&!(I.dummy&&b.node(N).dummy)&&s(x,$,N)})}),k=A+1,_=T)}),S}return e.reduce(v,w),x}function o(b,v){var x={};function w(S,_,k,E,O){var P;e.forEach(e.range(_,k),function(A){P=S[A],b.node(P).dummy&&e.forEach(b.predecessors(P),function(M){var T=b.node(M);T.dummy&&(T.order<E||T.order>O)&&s(x,M,P)})})}function C(S,_){var k=-1,E,O=0;return e.forEach(_,function(P,A){if(b.node(P).dummy==="border"){var M=b.predecessors(P);M.length&&(E=b.node(M[0]).order,w(_,O,A,k,E),O=A,k=E)}w(_,O,_.length,E,S.length)}),_}return e.reduce(v,C),x}function i(b,v){if(b.node(v).dummy)return e.find(b.predecessors(v),function(x){return b.node(x).dummy})}function s(b,v,x){if(v>x){var w=v;v=x,x=w}var C=b[v];C||(b[v]=C={}),C[x]=!0}function a(b,v,x){if(v>x){var w=v;v=x,x=w}return e.has(b[v],x)}function c(b,v,x,w){var C={},S={},_={};return e.forEach(v,function(k){e.forEach(k,function(E,O){C[E]=E,S[E]=E,_[E]=O})}),e.forEach(v,function(k){var E=-1;e.forEach(k,function(O){var P=w(O);if(P.length){P=e.sortBy(P,function($){return _[$]});for(var A=(P.length-1)/2,M=Math.floor(A),T=Math.ceil(A);M<=T;++M){var N=P[M];S[O]===O&&E<_[N]&&!a(x,O,N)&&(S[N]=O,S[O]=C[O]=C[N],E=_[N])}}})}),{root:C,align:S}}function l(b,v,x,w,C){var S={},_=d(b,v,x,C),k=C?"borderLeft":"borderRight";function E(A,M){for(var T=_.nodes(),N=T.pop(),$={};N;)$[N]?A(N):($[N]=!0,T.push(N),T=T.concat(M(N))),N=T.pop()}function O(A){S[A]=_.inEdges(A).reduce(function(M,T){return Math.max(M,S[T.v]+_.edge(T))},0)}function P(A){var M=_.outEdges(A).reduce(function(N,$){return Math.min(N,S[$.w]-_.edge($))},Number.POSITIVE_INFINITY),T=b.node(A);M!==Number.POSITIVE_INFINITY&&T.borderType!==k&&(S[A]=Math.max(S[A],M))}return E(O,_.predecessors.bind(_)),E(P,_.successors.bind(_)),e.forEach(w,function(A){S[A]=S[x[A]]}),S}function d(b,v,x,w){var C=new r,S=b.graph(),_=y(S.nodesep,S.edgesep,w);return e.forEach(v,function(k){var E;e.forEach(k,function(O){var P=x[O];if(C.setNode(P),E){var A=x[E],M=C.edge(A,P);C.setEdge(A,P,Math.max(_(b,O,E),M||0))}E=O})}),C}function u(b,v){return e.minBy(e.values(v),function(x){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(x,function(S,_){var k=g(b,_)/2;w=Math.max(S+k,w),C=Math.min(S-k,C)}),w-C})}function h(b,v){var x=e.values(v),w=e.min(x),C=e.max(x);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(_){var k=S+_,E=b[k],O;if(E!==v){var P=e.values(E);O=_==="l"?w-e.min(P):C-e.max(P),O&&(b[k]=e.mapValues(E,function(A){return A+O}))}})})}function p(b,v){return e.mapValues(b.ul,function(x,w){if(v)return b[v.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function m(b){var v=t.buildLayerMatrix(b),x=e.merge(n(b,v),o(b,v)),w={},C;e.forEach(["u","d"],function(_){C=_==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(k){k==="r"&&(C=e.map(C,function(A){return e.values(A).reverse()}));var E=(_==="u"?b.predecessors:b.successors).bind(b),O=c(b,C,x,E),P=l(b,C,O.root,O.align,k==="r");k==="r"&&(P=e.mapValues(P,function(A){return-A})),w[_+k]=P})});var S=u(b,w);return h(w,S),p(w,b.graph().align)}function y(b,v,x){return function(w,C,S){var _=w.node(C),k=w.node(S),E=0,O;if(E+=_.width/2,e.has(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":O=-_.width/2;break;case"r":O=_.width/2;break}if(O&&(E+=x?O:-O),O=0,E+=(_.dummy?v:b)/2,E+=(k.dummy?v:b)/2,E+=k.width/2,e.has(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":O=k.width/2;break;case"r":O=-k.width/2;break}return O&&(E+=x?O:-O),O=0,E}}function g(b,v){return b.node(v).width}return td}var rd,fm;function xj(){if(fm)return rd;fm=1;var e=ut(),r=Rt(),t=vj().positionX;rd=n;function n(i){i=r.asNonCompoundGraph(i),o(i),e.forEach(t(i),function(s,a){i.node(a).x=s})}function o(i){var s=r.buildLayerMatrix(i),a=i.graph().ranksep,c=0;e.forEach(s,function(l){var d=e.max(e.map(l,function(u){return i.node(u).height}));e.forEach(l,function(u){i.node(u).y=c+d/2}),c+=d+a})}return rd}var nd,hm;function wj(){if(hm)return nd;hm=1;var e=ut(),r=rj(),t=nj(),n=ij(),o=Rt().normalizeRanks,i=aj(),s=Rt().removeEmptyRanks,a=sj(),c=cj(),l=lj(),d=bj(),u=xj(),h=Rt(),p=Gt().Graph;nd=m;function m(L,z){var G=z&&z.debugTiming?h.time:h.notime;G("layout",function(){var D=G(" buildLayoutGraph",function(){return E(L)});G(" runLayout",function(){y(D,G)}),G(" updateInputGraph",function(){g(L,D)})})}function y(L,z){z(" makeSpaceForEdgeLabels",function(){O(L)}),z(" removeSelfEdges",function(){ie(L)}),z(" acyclic",function(){r.run(L)}),z(" nestingGraph.run",function(){a.run(L)}),z(" rank",function(){n(h.asNonCompoundGraph(L))}),z(" injectEdgeLabelProxies",function(){P(L)}),z(" removeEmptyRanks",function(){s(L)}),z(" nestingGraph.cleanup",function(){a.cleanup(L)}),z(" normalizeRanks",function(){o(L)}),z(" assignRankMinMax",function(){A(L)}),z(" removeEdgeLabelProxies",function(){M(L)}),z(" normalize.run",function(){t.run(L)}),z(" parentDummyChains",function(){i(L)}),z(" addBorderSegments",function(){c(L)}),z(" order",function(){d(L)}),z(" insertSelfEdges",function(){ae(L)}),z(" adjustCoordinateSystem",function(){l.adjust(L)}),z(" position",function(){u(L)}),z(" positionSelfEdges",function(){re(L)}),z(" removeBorderNodes",function(){W(L)}),z(" normalize.undo",function(){t.undo(L)}),z(" fixupEdgeLabelCoords",function(){$(L)}),z(" undoCoordinateSystem",function(){l.undo(L)}),z(" translateGraph",function(){T(L)}),z(" assignNodeIntersects",function(){N(L)}),z(" reversePoints",function(){I(L)}),z(" acyclic.undo",function(){r.undo(L)})}function g(L,z){e.forEach(L.nodes(),function(G){var D=L.node(G),se=z.node(G);D&&(D.x=se.x,D.y=se.y,z.children(G).length&&(D.width=se.width,D.height=se.height))}),e.forEach(L.edges(),function(G){var D=L.edge(G),se=z.edge(G);D.points=se.points,e.has(se,"x")&&(D.x=se.x,D.y=se.y)}),L.graph().width=z.graph().width,L.graph().height=z.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},k=["labelpos"];function E(L){var z=new p({multigraph:!0,compound:!0}),G=be(L.graph());return z.setGraph(e.merge({},v,ye(G,b),e.pick(G,x))),e.forEach(L.nodes(),function(D){var se=be(L.node(D));z.setNode(D,e.defaults(ye(se,w),C)),z.setParent(D,L.parent(D))}),e.forEach(L.edges(),function(D){var se=be(L.edge(D));z.setEdge(D,e.merge({},_,ye(se,S),e.pick(se,k)))}),z}function O(L){var z=L.graph();z.ranksep/=2,e.forEach(L.edges(),function(G){var D=L.edge(G);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(z.rankdir==="TB"||z.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function P(L){e.forEach(L.edges(),function(z){var G=L.edge(z);if(G.width&&G.height){var D=L.node(z.v),se=L.node(z.w),X={rank:(se.rank-D.rank)/2+D.rank,e:z};h.addDummyNode(L,"edge-proxy",X,"_ep")}})}function A(L){var z=0;e.forEach(L.nodes(),function(G){var D=L.node(G);D.borderTop&&(D.minRank=L.node(D.borderTop).rank,D.maxRank=L.node(D.borderBottom).rank,z=e.max(z,D.maxRank))}),L.graph().maxRank=z}function M(L){e.forEach(L.nodes(),function(z){var G=L.node(z);G.dummy==="edge-proxy"&&(L.edge(G.e).labelRank=G.rank,L.removeNode(z))})}function T(L){var z=Number.POSITIVE_INFINITY,G=0,D=Number.POSITIVE_INFINITY,se=0,X=L.graph(),le=X.marginx||0,ue=X.marginy||0;function Ce(je){var pe=je.x,fe=je.y,Y=je.width,H=je.height;z=Math.min(z,pe-Y/2),G=Math.max(G,pe+Y/2),D=Math.min(D,fe-H/2),se=Math.max(se,fe+H/2)}e.forEach(L.nodes(),function(je){Ce(L.node(je))}),e.forEach(L.edges(),function(je){var pe=L.edge(je);e.has(pe,"x")&&Ce(pe)}),z-=le,D-=ue,e.forEach(L.nodes(),function(je){var pe=L.node(je);pe.x-=z,pe.y-=D}),e.forEach(L.edges(),function(je){var pe=L.edge(je);e.forEach(pe.points,function(fe){fe.x-=z,fe.y-=D}),e.has(pe,"x")&&(pe.x-=z),e.has(pe,"y")&&(pe.y-=D)}),X.width=G-z+le,X.height=se-D+ue}function N(L){e.forEach(L.edges(),function(z){var G=L.edge(z),D=L.node(z.v),se=L.node(z.w),X,le;G.points?(X=G.points[0],le=G.points[G.points.length-1]):(G.points=[],X=se,le=D),G.points.unshift(h.intersectRect(D,X)),G.points.push(h.intersectRect(se,le))})}function $(L){e.forEach(L.edges(),function(z){var G=L.edge(z);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 I(L){e.forEach(L.edges(),function(z){var G=L.edge(z);G.reversed&&G.points.reverse()})}function W(L){e.forEach(L.nodes(),function(z){if(L.children(z).length){var G=L.node(z),D=L.node(G.borderTop),se=L.node(G.borderBottom),X=L.node(e.last(G.borderLeft)),le=L.node(e.last(G.borderRight));G.width=Math.abs(le.x-X.x),G.height=Math.abs(se.y-D.y),G.x=X.x+G.width/2,G.y=D.y+G.height/2}}),e.forEach(L.nodes(),function(z){L.node(z).dummy==="border"&&L.removeNode(z)})}function ie(L){e.forEach(L.edges(),function(z){if(z.v===z.w){var G=L.node(z.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:z,label:L.edge(z)}),L.removeEdge(z)}})}function ae(L){var z=h.buildLayerMatrix(L);e.forEach(z,function(G){var D=0;e.forEach(G,function(se,X){var le=L.node(se);le.order=X+D,e.forEach(le.selfEdges,function(ue){h.addDummyNode(L,"selfedge",{width:ue.label.width,height:ue.label.height,rank:le.rank,order:X+ ++D,e:ue.e,label:ue.label},"_se")}),delete le.selfEdges})})}function re(L){e.forEach(L.nodes(),function(z){var G=L.node(z);if(G.dummy==="selfedge"){var D=L.node(G.e.v),se=D.x+D.width/2,X=D.y,le=G.x-se,ue=D.height/2;L.setEdge(G.e,G.label),L.removeNode(z),G.label.points=[{x:se+2*le/3,y:X-ue},{x:se+5*le/6,y:X-ue},{x:se+le,y:X},{x:se+5*le/6,y:X+ue},{x:se+2*le/3,y:X+ue}],G.label.x=G.x,G.label.y=G.y}})}function ye(L,z){return e.mapValues(e.pick(L,z),Number)}function be(L){var z={};return e.forEach(L,function(G,D){z[D.toLowerCase()]=G}),z}return nd}var od,pm;function Cj(){if(pm)return od;pm=1;var e=ut(),r=Rt(),t=Gt().Graph;od={debugOrdering:n};function n(o){var i=r.buildLayerMatrix(o),s=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+o.node(a).rank)}),e.forEach(o.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(i,function(a,c){var l="layer"+c;s.setNode(l,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return od}var id,gm;function Sj(){return gm||(gm=1,id="0.8.5"),id}var ad,ym;function jj(){return ym||(ym=1,ad={graphlib:Gt(),layout:wj(),debug:Cj(),util:{time:Rt().time,notime:Rt().notime},version:Sj()}),ad}var _j=jj();const mm=l1(_j);function Ej(e,r,t){var d;const n=new Set(e.map(u=>u.id)),o=new Set;for(const u of e)u.parent&&n.has(u.parent)&&o.add(u.parent);const i=new mm.graphlib.Graph({multigraph:!0,compound:!0}),s=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);i.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*s):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*s):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*s):t.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const u of e)i.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&i.setParent(u.id,u.parent);for(const u of r){if(!n.has(u.source)||!n.has(u.target)||o.has(u.source)||o.has(u.target))continue;const h=Gb(u.label,u.icon??((d=u.data)==null?void 0:d.icon),t.edgeLabelFontSize),p=t.rankDir==="LR"||t.rankDir==="RL",m=(h.width?h.width+2*Wb:0)+(u.connectorClearance??0);i.setEdge(u.source,u.target,{minlen:1,weight:1,...m?{width:p?m:Math.max(1,h.height),height:p?Math.max(1,h.height):m,labelpos:"c"}:{}},u.id)}mm.layout(i);const a=new Map;for(const u of e){if(o.has(u.id))continue;const h=i.node(u.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(u.id,{x:h.x,y:h.y})}const c=t.compact?1:t.spacingFactor;if(c&&c!==1&&a.size){let u=1/0,h=1/0,p=-1/0,m=-1/0;a.forEach(b=>{u=Math.min(u,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),m=Math.max(m,b.y)});const y=(u+p)/2,g=(h+m)/2;a.forEach((b,v)=>a.set(v,{x:y+(b.x-y)*c,y:g+(b.y-g)*c}))}const l=t.nodeAlignment??"center";if(l!=="center"){const u=t.rankDir==="LR"||t.rankDir==="RL",h=u?"x":"y",p=u?"width":"height",m=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,y=l==="leading"?-m:m,g=new Map;for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h];g.set(x,Math.max(g.get(x)??0,b[p]))}for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h],w=(g.get(x)-b[p])/2;a.set(b.id,{...v,[h]:x+y*w})}}return a}function bd(e,r,t,n,o,i){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const c=(u,h=new Set)=>{var m;const p=(m=a.get(u))==null?void 0:m.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+c(p,h))},l=[...s.keys()].sort((u,h)=>c(h)-c(u)),d=new Map;for(const u of l){const h=i==null?void 0:i.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}let m=null;for(const b of s.get(u)||[]){let v=d.get(b);if(!v){const x=r.get(b);if(!x)continue;const w=t.get(b)||{w:60,h:60};v={x1:x.x-w.w/2,y1:x.y-w.h/2,x2:x.x+w.w/2,y2:x.y+w.h/2}}m=m?{x1:Math.min(m.x1,v.x1),y1:Math.min(m.y1,v.y1),x2:Math.max(m.x2,v.x2),y2:Math.max(m.y2,v.y2)}:{...v}}if(!m)continue;const y=n(u);m={x1:m.x1-y,y1:m.y1-y,x2:m.x2+y,y2:m.y2+y};const g=o(u);if(g){const b=m.x2-m.x1,v=m.y2-m.y1;if(g.w>b){const x=(g.w-b)/2;m.x1-=x,m.x2+=x}if(g.h>v){const x=(g.h-v)/2;m.y1-=x,m.y2+=x}}d.set(u,m)}return d}function bm(e,r,t){var c,l,d;const n=[...r.weights],o=n.reduce((u,h)=>u+h,0),i=n[r.index]+n[r.index+1],s=Math.min(i*.95,Math.max(i*.05,n[r.index]+t/r.length*o));n[r.index]=s,n[r.index+1]=i-s;const a={...(l=(c=e.adjustment)==null?void 0:c.sections)==null?void 0:l[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function Hv(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r))||n.members!==void 0&&(!Array.isArray(n.members)||n.members.length>1e4||!n.members.every(o=>Array.isArray(o)&&o.length>0&&o.length<=1e4&&o.every(i=>typeof i=="string"&&i.length>0))||new Set(n.members.flat()).size!==n.members.flat().length))throw new RangeError("Invalid grid section proportions.")}function iu(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Dn(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const c=a.parent&&r.has(a.parent)?a.parent:void 0,l=t.get(c)??[];l.push(a.id),t.set(c,l)}const n=[],o=new Map,i=a=>{const c=t.get(a),l=c?c.flatMap(i):e.positions.has(a)?[a]:[];return o.set(a,l),c&&n.push(c),l},s=t.get(void 0)??[];return s.forEach(i),n.push(s),{groups:n,leaves:o,children:t,roots:s}}function pr(e,r,t=e.fixedSizes){const n=bd(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const o of e.nodes){if(n.has(o.id))continue;const i=r.get(o.id),s=e.sizes.get(o.id);i&&s&&n.set(o.id,Zt({...i,...s}))}return n}function Kv(e,r,t,n){const o=t.get(e),i=t.get(r);if(!o||!i)return;const s={x:Math.min(o.x2-i.x1,i.x2-o.x1)+n,y:Math.min(o.y2-i.y1,i.y2-o.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function On(e,r,t){const n=[];for(const o of e)for(let i=0;i<o.length;i++)for(let s=i+1;s<o.length;s++){const a=Kv(o[i],o[s],r,t);a&&n.push(a)}return n}function Jv(e,r={}){const t=iu(r),{groups:n}=Dn(e);return On(n,pr(e,e.positions),t)}function Zv(e,r,t,n){var a,c,l;const o=new Set(e),i=(((l=(c=(a=r.adjustment)==null?void 0:a.sections)==null?void 0:c[t])==null?void 0:l.members)??[]).map(d=>d.filter(u=>o.delete(u))).filter(d=>d.length),s=e.filter(d=>o.has(d));for(let d=0;d<s.length;d+=n)i.push(s.slice(d,d+n));return i}function kj(e,r,t,n,o){var v,x,w,C;if(t===n)return;const{groups:i,leaves:s}=Dn(e),a=i.find(S=>S.includes(t)&&S.includes(n));if(!a||a.some(S=>e.fixedIds.has(S)||(s.get(S)??[]).some(_=>e.fixedIds.has(_))))return;const c=pr(e,e.positions);if(a.some(S=>!c.has(S)))return;const l=((v=e.nodes.find(S=>S.id===t))==null?void 0:v.parent)??"canvas",d=(w=(x=r.adjustment)==null?void 0:x.sections)==null?void 0:w[l],u=[],h=[...a].sort((S,_)=>{const k=c.get(S),E=c.get(_),O=(k.y1+k.y2-E.y1-E.y2)/2;return Math.abs(O)>1?O:k.x1-E.x1});for(const S of h){const _=u.at(-1),k=c.get(S),E=_&&c.get(_[0]);E&&Math.abs(k.y1+k.y2-E.y1-E.y2)<2?_.push(S):u.push([S])}const p=u.map((S,_)=>{var k;return{weight:((k=d==null?void 0:d.rows)==null?void 0:k[_])??1,cells:S.map((E,O)=>{var P,A;return{id:E,weight:((A=(P=d==null?void 0:d.columns)==null?void 0:P[_])==null?void 0:A[O])??1}})}});for(const S of p)S.cells=S.cells.filter(_=>_.id!==t);const m=p.filter(S=>S.cells.length),y=m.findIndex(S=>S.cells.some(_=>_.id===n)),g=m[y];if(!g)return;o==="above"||o==="below"?m.splice(y+(o==="below"?1:0),0,{weight:1,cells:[{id:t,weight:1}]}):g.cells.splice(g.cells.findIndex(S=>S.id===n)+(o==="after"?1:0),0,{id:t,weight:1});const b=m.map(S=>S.cells.map(_=>_.id));if(JSON.stringify(b)!==JSON.stringify(u))return{...r,adjustment:{...r.adjustment,sections:{...(C=r.adjustment)==null?void 0:C.sections,[l]:{...d,members:b,rows:m.map(S=>S.weight),columns:m.map(S=>S.cells.map(_=>_.weight))}}}}}function sd(e,r={}){var d;Hv(r.adjustment);const t=iu(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(u=>!Number.isFinite(u)||u<0))throw new RangeError("Grid gaps must be finite and non-negative.");const o=r.padding??0;if(!Number.isFinite(o)||o<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return Rj(e,r,n,o);const{groups:i,leaves:s}=Dn(e),a=new Map([...e.positions].map(([u,h])=>[u,{...h}])),c=new Set;for(const u of i){const h=pr(e,a),p=u.filter(P=>h.has(P));if(p.length<2)continue;if(p.some(P=>e.fixedIds.has(P)||(s.get(P)??[]).some(A=>e.fixedIds.has(A)))){p.forEach(P=>c.add(P));continue}const y=p.map(P=>h.get(P)),g=Math.max(...y.map(P=>P.x2-P.x1)),b=Math.max(...y.map(P=>P.y2-P.y1)),v=Math.min(p.length,r.columns??Math.ceil(Math.sqrt(p.length))),x=((d=e.nodes.find(P=>P.id===p[0]))==null?void 0:d.parent)??"canvas",w=Zv(p,r,x,v),C=Math.max(...w.map(P=>P.length)),S=g+n.x,_=b+n.y,k=y.map(P=>({x:(P.x1+P.x2)/2,y:(P.y1+P.y2)/2})),E=(Math.min(...k.map(P=>P.x))+Math.max(...k.map(P=>P.x)))/2,O=(Math.min(...k.map(P=>P.y))+Math.max(...k.map(P=>P.y)))/2;w.forEach((P,A)=>P.forEach((M,T)=>{const N=h.get(M),$={x:E+(T-(C-1)/2)*S-(N.x1+N.x2)/2,y:O+(A-(w.length-1)/2)*_-(N.y1+N.y2)/2};for(const I of s.get(M)??[]){const W=a.get(I);a.set(I,{x:W.x+$.x,y:W.y+$.y})}}))}const l=[...a].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:a,movedNodeIds:l,skippedNodeIds:[...c],collisions:On(i,pr(e,a),Math.min(n.x,n.y))}}function Rj(e,r,t,n){const{groups:o,children:i,roots:s}=Dn(e),a=new Map([...e.positions].map(([g,b])=>[g,{...b}]));if(e.nodes.some(g=>e.fixedIds.has(g.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(g=>g.id),collisions:Jv(e,{margin:Math.min(t.x,t.y)})};const c=e.viewportSize,l=Math.min(n,Math.max(0,(c.w-1)/2)),d=Math.min(n,Math.max(0,(c.h-1)/2)),u={x1:l,y1:d,x2:Math.max(l+1,c.w-l),y2:Math.max(d+1,c.h-d)},h=new Map,p=[],m=(g,b,v="canvas")=>{var T,N;if(!g.length)return;const x=b.x2-b.x1,w=b.y2-b.y1,C=Math.min(g.length,r.columns??Math.max(1,Math.round(Math.sqrt(g.length*x/w)))),S=Zv(g,r,v,C),_=S.length,k=Math.min(t.y,w/(2*_)),E=(N=(T=r.adjustment)==null?void 0:T.sections)==null?void 0:N[v],O=Array.from({length:_},($,I)=>{var W;return((W=E==null?void 0:E.rows)==null?void 0:W[I])??1}),P=O.reduce(($,I)=>$+I,0),A=w-(_-1)*k;let M=b.y1;for(let $=0;$<_;$++){const I=A*O[$]/P,W=S[$].length,ie=Math.min(t.x,x/(2*W)),ae=Array.from({length:W},(L,z)=>{var G,D;return((D=(G=E==null?void 0:E.columns)==null?void 0:G[$])==null?void 0:D[z])??1}),re=ae.reduce((L,z)=>L+z,0),ye=x-(W-1)*ie;let be=b.x1;for(let L=0;L<W;L++){const z=S[$][L],G=ye*ae[L]/re,D=i.get(z);if(D){a.set(z,{x:be+G/2,y:M+I/2}),h.set(z,{w:G,h:I});const se=Math.min(e.padding(z),Math.max(0,(Math.min(G,I)-1)/2));m(D,{x1:be+se,y1:M+se,x2:be+G-se,y2:M+I-se},z)}else a.has(z)&&(a.set(z,{x:be+G/2,y:M+I/2}),h.set(z,{w:G,h:I}));L<W-1&&p.push({section:v,axis:"x",row:$,index:L,weights:ae,length:ye,position:{x:be+G+ie/2,y:M+I/2}}),be+=G+ie}$<_-1&&p.push({section:v,axis:"y",row:$,index:$,weights:O,length:A,position:{x:b.x1+x/2,y:M+I+k/2}}),M+=I+k}};m(s,u);const y=[...a].filter(([g,b])=>{const v=e.positions.get(g);return!v||b.x!==v.x||b.y!==v.y}).map(([g])=>g);return{positions:a,movedNodeIds:y,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:On(o,pr({...e,sizes:h},a,h),0)}}function Aj(e,r={}){const t=iu(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:o,leaves:i}=Dn(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(i.get(u)??[]).some(h=>e.fixedIds.has(h));let c=On(o,pr(e,s),t),l=0;for(;c.length&&l<n;){let u=!1;for(const h of o){if(h.length<2)continue;const p=pr(e,s),m=(y,g,b)=>{for(const x of i.get(y)??[])s.get(x)[g]+=b;const v=p.get(y);g==="x"?(v.x1+=b,v.x2+=b):(v.y1+=b,v.y2+=b)};for(let y=0;y<h.length;y++)for(let g=y+1;g<h.length;g++){const b=h[y],v=h[g],x=Kv(b,v,p,t);if(!x)continue;const w=a(b),C=a(v);if(w&&C)continue;const S=x.overlap.x<=x.overlap.y?"x":"y",_=p.get(b),k=p.get(v),E=S==="x"?_.x1+_.x2<=k.x1+k.x2?-1:1:_.y1+_.y2<=k.y1+k.y2?-1:1,O=x.overlap[S];w||m(b,S,E*O/(C?1:2)),C||m(v,S,-E*O/(w?1:2)),u=!0}}if(l++,c=On(o,pr(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:c,iterations:l,resolved:c.length===0}}function Pj({dividers:e,options:r,zoom:t,onChange:n}){const o=j.useRef();return f.jsx(f.Fragment,{children:e.map(i=>{const s=i.axis==="x",a=s?Z.PiArrowsHorizontal:Z.PiArrowsVertical,c=`${s?"Column":"Row"} divider ${i.index+1}${s?` in row ${i.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":c,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*i.weights[i.index]/(i.weights[i.index]+i.weights[i.index+1])),title:c,"data-flow-grid-adjustment":"",style:{position:"absolute",left:i.position.x,top:i.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:l=>{if(l.button!==0)return;l.preventDefault(),l.stopPropagation();const d=l.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();o.current={pointerId:l.pointerId,start:s?l.clientX:l.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:i,options:r},l.currentTarget.setPointerCapture(l.pointerId)},onPointerMove:l=>{const d=o.current;if(!d||d.pointerId!==l.pointerId)return;l.preventDefault(),l.stopPropagation();const u=((s?l.clientX:l.clientY)-d.start)/d.scale;n(bm(d.options,d.divider,u))},onPointerUp:l=>{o.current&&(l.stopPropagation(),o.current=void 0,l.currentTarget.releasePointerCapture(l.pointerId))},onPointerCancel:()=>{o.current&&n(o.current.options),o.current=void 0},onLostPointerCapture:()=>{o.current=void 0},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.key==="Escape"&&o.current&&(n(o.current.options),o.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(l.key);d<0||(l.preventDefault(),l.stopPropagation(),n(bm(r,i,i.length*(l.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${i.section}:${i.axis}:${i.row}:${i.index}`)})})}const vm=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top,cd=new WeakMap;function xm(e,r){const t=[...r.querySelectorAll(".flow-sdk-edge-label")];if(!t.length){cd.delete(r);return}const n=r==null?void 0:r.getScreenCTM();if(!r||!n)return;const o=n.inverse(),i=(u,h=0)=>{const p=u.getBoundingClientRect(),m=new DOMPoint(p.left,p.top).matrixTransform(o),y=new DOMPoint(p.right,p.bottom).matrixTransform(o);return{left:m.x-h,right:y.x+h,top:m.y-h,bottom:y.y+h}},s=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>u.closest(".flow-sdk-canvas")===e).filter(u=>{const h=u.getBoundingClientRect(),p=getComputedStyle(u);return h.width>0&&h.height>0&&p.visibility!=="hidden"&&p.opacity!=="0"}).map(u=>i(u,24));for(const u of r.querySelectorAll(".flow-sdk-container-label"))s.push(i(u,12));const a=new Map([...e.querySelectorAll(".flow-sdk-edge")].filter(u=>u.closest(".flow-sdk-canvas")===e).map(u=>[u.dataset.edgeId,u.querySelector("path")])),c=JSON.stringify([s,[...a].map(([u,h])=>[u,h==null?void 0:h.getAttribute("d")]),t.map(u=>{var m;const h=u.getBBox(),p=(m=u.querySelector("rect"))==null?void 0:m.getBBox();return[u.dataset.edgeId,u.dataset.labelTransform,u.dataset.labelHorizontal,h.x,h.y,h.width,h.height,p==null?void 0:p.width,p==null?void 0:p.height]})],(u,h)=>typeof h=="number"?Math.round(h*1e3)/1e3:h),l=cd.get(r);if((l==null?void 0:l.geometry)===c&&t.every(u=>l.transforms.has(u))){for(const u of t){const h=l.transforms.get(u);u.getAttribute("transform")!==h&&u.setAttribute("transform",h)}return}for(const u of t)u.setAttribute("transform",u.dataset.labelTransform??"");const d=new Map(t.map(u=>[u,i(u,8)]));for(const u of t){const h=u.dataset.labelHorizontal==="true",p=d.get(u);d.delete(u);const m=E=>s.some(O=>vm(E,O))||[...d.values()].some(O=>vm(E,O));if(!h&&!m(p)){d.set(u,p);continue}const y=a.get(u.dataset.edgeId),g=u.querySelector("rect");if(!y||!g)continue;const b=g.getBBox(),v=y.getTotalLength();if(!Number.isFinite(v)||v<=0)continue;const x=(p.left+p.right)/2,w=(p.top+p.bottom)/2,C=Math.min(256,Math.max(16,Math.ceil(v/24))),S=Array.from({length:C+1},(E,O)=>y.getPointAtLength(v*O/C)),k=Array.from({length:C+1},(E,O)=>{const P=v*O/C,A=S[O],M=h?{x:A.x,y:A.y-b.height/2-15}:A,T=y.getPointAtLength(Math.max(0,P-2)),N=y.getPointAtLength(Math.min(v,P+2));let $=Math.atan2(N.y-T.y,N.x-T.x)*180/Math.PI;$>90&&($-=180),$<-90&&($+=180);const I=Math.abs($)<1;h&&($=0);const W=$*Math.PI/180,ie=Math.abs(Math.cos(W))*b.width+Math.abs(Math.sin(W))*b.height,ae=Math.abs(Math.sin(W))*b.width+Math.abs(Math.cos(W))*b.height;return{point:M,angle:$,straight:I,score:Math.hypot(M.x-x,M.y-w),bounds:{left:M.x-ie/2-8,right:M.x+ie/2+8,top:M.y-ae/2-8,bottom:M.y+ae/2+8}}}).sort((E,O)=>E.score-O.score).find(E=>!m(E.bounds)&&(!h||E.straight&&!S.some(O=>O.x>E.bounds.left&&O.x<E.bounds.right&&O.y>E.bounds.top&&O.y<E.bounds.bottom)));k?(u.setAttribute("transform",`translate(${k.point.x} ${k.point.y}) rotate(${k.angle})`),d.set(u,k.bounds)):d.set(u,p)}cd.set(r,{geometry:c,transforms:new Map(t.map(u=>[u,u.getAttribute("transform")??""]))})}function Mj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Db(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],s=new Set(i.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return i.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const d=Fb(n?kn(o,n):o,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const l=a.getBoundingClientRect();return!l.width||!l.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((l.top-r.top)/t*1e3)/1e3,height:Math.round(l.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function Ij({id:e,x:r,y:t,placed:n,hidden:o,gridDraggable:i,gridDragging:s,gridDropTarget:a,gridSize:c,gridPreview:l,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:m,hasCollapseControl:y,handleColor:g,animated:b,animationColor:v,animationWidth:x=8,animationVariant:w,width:C=0,height:S=0,propertyMode:_,reversePorts:k,direction:E="LR",onPropertyRows:O,onSurface:P,children:A}){var D,se;const M=j.useRef(null),[T,N]=j.useState([]),$=m??T,[I,W]=j.useState(),ie=j.useId(),ae=j.useRef(),re=!!l,ye=!!(l!=null&&l.floating);j.useLayoutEffect(()=>{var je;const X=M.current;if(!X||!re)return;const le=X.cloneNode(!0);le.removeAttribute("data-node-id"),le.removeAttribute("data-grid-dragging"),le.removeAttribute("data-grid-draggable"),le.removeAttribute("data-grid-drop-target"),le.setAttribute("data-grid-preview",e),le.setAttribute("aria-hidden","true"),le.setAttribute("inert","");const ue=[le,...le.querySelectorAll("*")],Ce=new Map(ue.filter(pe=>pe.id).map(pe=>[pe.id,`${pe.id}-${ie}`]));for(const pe of ue){pe.id&&(pe.id=Ce.get(pe.id));for(const fe of[...pe.attributes]){if(fe.name==="id")continue;let Y=fe.value;for(const[H,we]of Ce)Y===`#${H}`&&(Y=`#${we}`),Y=Y.split(`url(#${H})`).join(`url(#${we})`);Y!==fe.value&&pe.setAttribute(fe.name,Y)}}if(Object.assign(le.style,{opacity:"0.35",zIndex:ye?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),ye){const pe=getComputedStyle(X);le.setAttribute("data-grid-preview-floating",""),Object.assign(le.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:pe.font,color:pe.color});for(const fe of ue)fe.removeAttribute("data-node-id"),fe.style.pointerEvents="none"}return le.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(pe=>pe.remove()),(je=ye?document.body:X.parentElement)==null||je.appendChild(le),ae.current=le,()=>{le.remove(),ae.current=void 0}},[e,ie,re,ye]),j.useLayoutEffect(()=>{const X=ae.current;if(!X||!l)return;const{x:le,y:ue,size:Ce}=l;if(ye&&M.current){const fe=M.current,Y=fe.getBoundingClientRect(),H=Y.width/fe.offsetWidth||1,we=Y.height/fe.offsetHeight||1,J=Y.left+(le-r)*H,ve=Y.top+(ue-t)*we;X.style.transform=`translate3d(${J}px, ${ve}px, 0) scale(${H}, ${we})`,X.style.width=`${fe.offsetWidth}px`,X.style.height=`${fe.offsetHeight}px`;return}const je=Ce?Math.round(le-Ce.w/2):le,pe=Ce?Math.round(ue-Ce.h/2):ue;X.style.transform=Ce?`translate3d(${je}px, ${pe}px, 0)`:`translate(-50%, -50%) translate3d(${je}px, ${pe}px, 0)`,X.style.width=Ce?`${Math.round(le+Ce.w/2)-je}px`:"",X.style.height=Ce?`${Math.round(ue+Ce.h/2)-pe}px`:"",Ce&&(X.style.setProperty("--flow-grid-width",`${Ce.w}px`),X.style.setProperty("--flow-grid-height",`${Ce.h}px`),X.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,Ce.w/8,Ce.h/5))}px`))},[l==null?void 0:l.x,l==null?void 0:l.y,(D=l==null?void 0:l.size)==null?void 0:D.w,(se=l==null?void 0:l.size)==null?void 0:se.h,ye,r,t]),j.useLayoutEffect(()=>{const X=M.current;if(!X)return;const le=()=>{const je=Db(X);W(pe=>JSON.stringify(pe)===JSON.stringify(je)?pe:je),P==null||P(e,je)};le();const ue=new ResizeObserver(le);ue.observe(X);const Ce=X.querySelector("[data-flow-node-surface]");return Ce&&ue.observe(Ce),()=>ue.disconnect()},[e,A,P]),j.useLayoutEffect(()=>(d(e,M.current),()=>{d(e,null),P==null||P(e,void 0)}),[e,d,P]),j.useLayoutEffect(()=>{const X=M.current;if(!X)return;let le="";const ue=()=>{const fe=Mj(X),Y=_?fe:fe.filter(we=>we.anchor),H=JSON.stringify(Y);H!==le&&(le=H,N(Y),O==null||O(e,Y))};if(ue(),!_&&!X.querySelector("[data-flow-port-side]"))return;const Ce=new ResizeObserver(ue),je=()=>{Ce.disconnect(),Ce.observe(X),X.querySelectorAll("[data-flow-property]").forEach(fe=>Ce.observe(fe)),ue()};je();const pe=new MutationObserver(je);return pe.observe(X,{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"]}),X.addEventListener("scroll",ue,!0),()=>{Ce.disconnect(),pe.disconnect(),X.removeEventListener("scroll",ue,!0)}},[e,_,O,A]);const be=c?Math.round(r-c.w/2):0,L=c?Math.round(t-c.h/2):0,z=c?Math.round(r+c.w/2)-be:void 0,G=c?Math.round(t+c.h/2)-L:void 0;return f.jsxs("div",{ref:M,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":i||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":c?"":void 0,style:{transform:c?`translate3d(${be}px, ${L}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden",cursor:i?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:l?0:s?.75:void 0,outline:a?`2px solid ${g||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:z,height:G,...c?{"--flow-grid-width":`${c.w}px`,"--flow-grid-height":`${c.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,c.w/8,c.h/5))}px`}:{}},children:[A,!c&&b&&x>0&&C>0&&S>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(oo,{variant:w,x:((I==null?void 0:I.left)??0)+x/2,y:((I==null?void 0:I.top)??0)+x/2,width:((I==null?void 0:I.width)??C)-x,height:((I==null?void 0:I.height)??S)-x,radius:((I==null?void 0:I.radius)??0)-x/2,path:I!=null&&I.outline?`M${I.outline.map(X=>`${X.x} ${X.y}`).join(" L")} Z`:void 0,color:v||g||"currentColor",strokeWidth:x})}),u&&_&&$.map(X=>["source","target"].filter(le=>!X.role||X.role===le).filter(le=>h||(p==null?void 0:p.has(`${le}:${X.property}`))).map(le=>{var ue;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":X.property,"data-port-role":le,"data-port-side":(ue=X.anchor)==null?void 0:ue.side,"aria-label":`${le==="source"?"Connect":"Input"} ${X.property}`,title:`${le==="source"?"Connect":"Input"} ${X.property}`,style:{color:g,...X.anchor?{top:X.anchor.y,left:X.anchor.x-16}:{top:X.top+X.height/2,[le==="source"!=!!k?"right":"left"]:-16}},onClick:Ce=>Ce.stopPropagation()},`${X.property}:${le}`)})),u&&!y&&(!_||!$.length)&&(!_||!$.some(X=>X.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:g,left:((I==null?void 0:I.left)??0)+(E==="RL"?-36:E==="LR"?(I==null?void 0:I.width)??C:((I==null?void 0:I.width)??C)/2),top:((I==null?void 0:I.top)??0)+(E==="BT"?-36:E==="TB"?(I==null?void 0:I.height)??S:((I==null?void 0:I.height)??S)/2),transform:E==="BT"||E==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:X=>X.stopPropagation(),children:f.jsx(Z.PiPlusBold,{size:24})})]})}const Tj=j.memo(Ij);function Oj(e,r,t){const[n,o]=j.useState(()=>({nodes:new Set,edges:new Set})),i=j.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=r.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),l=new Set(c.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>l.has(p)));if(!t)return{nodes:a,edges:l,ready:l};for(const p of e)c.filter(y=>y.target===p.id&&y.source!==y.target).every(y=>u.has(y.id))&&d.add(p.id);let h=new Set(c.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!c.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(m=>!d.has(m.id));p&&d.add(p.id),h=new Set(c.filter(m=>d.has(m.source)).map(m=>m.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);j.useLayoutEffect(()=>{o(a=>{const c=t?i:{nodes:new Set,edges:new Set},l=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return l(a.nodes,c.nodes)&&l(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[i,t]);const s=j.useCallback(a=>{o(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}class Nj{constructor(r,t,n){Ot(this,"_pan");Ot(this,"_zoom");Ot(this,"minZoom");Ot(this,"maxZoom");Ot(this,"size",{w:0,h:0});Ot(this,"listeners",new Set);Ot(this,"cancelTransition");Ot(this,"animationVersion",0);Ot(this,"captureTransition");Ot(this,"animationsDisabled",!1);Ot(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,o={pan:{...r.pan},zoom:this.clamp(r.zoom)},i=this.animationVersion,s=qb(t,this.animationsDisabled),a=c=>{if(i!==this.animationVersion)return;const l=s?c:1;this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Lb(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const o=this.clamp(t);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:t.x-(t.x-this._pan.x)*i,y:t.y-(t.y-this._pan.y)*i},n)}fit(r,t=0,n=!1,o=1){const i=r.x2-r.x1,s=r.y2-r.y1;if(!(i>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*t)/i,(this.size.h-2*t)/s))*o);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const $j={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},Xn={w:60,h:60},ld=4,qj=30,Lj=500,Fj=45;function wm(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function zj(e){var yu,mu,bu,vu,xu;const{nodes:r,edges:t,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:l=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:m,lineColor:y,drawMode:g,dragMode:b,multiSelect:v,isPerformanceMode:x,disableAnimations:w=!1}=e,[C,S]=j.useState(null),_=j.useMemo(()=>C?(C.mode==="connections"?Hu:Bu)(C.id,r,t):null,[C,r,t]),k=i==="auto"||i==="properties",E=j.useMemo(()=>t.filter(R=>md(R,i)&&(!_||_.has(R.source)&&_.has(R.target))),[t,i,_]),O=j.useMemo(()=>o1(r,t,i,s,_),[r,t,i,s,_]),P=j.useRef(O);P.current=O;const A=j.useRef(e);A.current=e;const M=j.useRef(null),T=j.useRef(null),N=j.useRef(null),$=j.useRef(null),I=j.useMemo(()=>new Nj(p,u,h),[]);j.useEffect(()=>{I.minZoom=u,I.maxZoom=h},[I,u,h]),j.useLayoutEffect(()=>{I.setAnimationsDisabled(w)},[I,w]);const W=j.useRef(new Map),ie=j.useRef(new Map),ae=j.useRef(new Map),re=j.useRef(null),[ye,be]=j.useState(new Map),L=j.useCallback((R,q)=>{be(F=>{if(JSON.stringify(F.get(R))===JSON.stringify(q))return F;const K=new Map(F);return q?K.set(R,q):K.delete(R),K})},[]),[z,G]=j.useState(new Map),D=j.useRef(z),se=j.useCallback((R,q)=>{G(F=>{if(JSON.stringify(F.get(R)??[])===JSON.stringify(q))return F;const K=new Map(F);return q.length?K.set(R,q):K.delete(R),K})},[]),[X,le]=j.useState(()=>new Map),ue=j.useRef(X);ue.current=X;const[Ce,je]=j.useState(new Map),pe=j.useRef(Ce),fe=()=>{pe.current=new Map,je(pe.current)},Y=j.useRef(new Map),H=j.useRef(null),we=j.useRef(!1),[J,ve]=j.useState(0),Q=j.useRef(),Ee=j.useRef(),Ae=j.useRef(null),qe=j.useRef(!1),Je=j.useRef(null),Fe=j.useRef(null),ct=j.useRef(),De=j.useRef(l),rt=s,ft=j.useRef(rt),[Oe,Xe]=j.useState(!0),[nt,lt]=j.useState(!!((yu=e.initialNodeGrid)!=null&&yu.enabled)),[zt,kt]=j.useState([]),et=j.useRef((mu=e.initialNodeGrid)!=null&&mu.enabled?{options:{...e.initialNodeGrid.options,animate:!1},order:[...e.initialNodeGrid.order??e.initialNodeGrid.options.order??r.map(R=>R.id)],previousPositions:new Map,previousViewport:p,previousSize:{w:0,h:0},ready:!1}:null),[We,Ht]=j.useState(null),dt=j.useRef(null);dt.current=_;const er=j.useRef(1);er.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const ar=j.useRef(null),Bt=j.useRef(r),Dt=j.useRef([]),Kt=j.useRef(!1),tr=()=>{var R;(R=Ae.current)==null||R.call(Ae),Ae.current=null},$r=()=>{Fe.current=null,Dt.current.length&&(Kt.current=!0),!we.current&&A.current.fitOnInit!==!1&&(qe.current=!0),clearTimeout(Ee.current),Ee.current=setTimeout(()=>{we.current=ue.current.size>0,ve(R=>R+1)},Lj)},ze=(R,q,F,K=$r,de)=>{tr();const Me=new Map(ue.current),Se=new Map([...W.current,...pe.current]);Ae.current=Lb(q,ke=>{const Ye=new Map;if(R.forEach((me,Te)=>{const Be=Me.get(Te);Ye.set(Te,Be?{x:Be.x+(me.x-Be.x)*ke,y:Be.y+(me.y-Be.y)*ke}:me)}),ue.current=Ye,le(Ye),de){const me=new Map;for(const[Te,Be]of de){const ee=Se.get(Te)??Be;me.set(Te,{w:ee.w+(Be.w-ee.w)*ke,h:ee.h+(Be.h-ee.h)*ke})}pe.current=me,je(me)}F==null||F(ke)},K)},ce=()=>{var Ye;if(clearTimeout(Q.current),et.current){mt.arrangeNodesInGrid(et.current.options);return}pe.current.size&&fe();const R=A.current,q=er.current,F=P.current,K=F.nodes.map(me=>{const Te=ie.current.get(me.id);Te&&(Te.offsetWidth||Te.offsetHeight)&&W.current.set(me.id,{w:Te.offsetWidth,h:Te.offsetHeight});const Be=W.current.get(me.id)||Xn;return{id:me.id,parent:me.parent,width:Be.w,height:Be.h}});let de;try{const me=R.compactPropertyLayout,Te=R.edgeMode!=="nodes"&&R.edgeMode!=="workflow",Be=F.edges.map(ee=>({...ee,connectorClearance:me?Te&&(ee.sourceProperty!==void 0||ee.targetProperty!==void 0)?n1:r1:0}));de=Ej(K,Be,{edgeLabelFontSize:R.edgeMode==="nodes"||R.edgeMode==="workflow"?Vb:io,rankDir:R.direction,compact:me,nodeAlignment:R.nodeAlignment,rankSep:R.rankSep*q,edgeSep:R.edgeSep*q,nodeSep:5*q,spacingFactor:R.spacingFactor??1.3,compactSpacingScale:(R.compactSpacingScale??(R.spacingFactor??1.3)/1.3)*q})}catch(me){console.warn("[flow-sdk] layout failed",me);return}const Me=Fe.current?null:H.current;H.current=null;const Se=Me&&de.get(Me.id);if(Me&&Se){const me={x:Me.position.x-Se.x,y:Me.position.y-Se.y};de=new Map([...de].map(([Te,Be])=>[Te,{x:Be.x+me.x,y:Be.y+me.y}]))}for(const[me,Te]of Y.current)de.has(me)?de.set(me,Te):R.nodes.some(Be=>Be.id===me)||Y.current.delete(me);if(Fe.current){const me=JSON.stringify([K,[...de],I.size,R.isPerformanceMode,R.disableAnimations]);if(((Ye=ct.current)==null?void 0:Ye.focus)===Fe.current&&ct.current.geometry===me)return;ct.current={focus:Fe.current,geometry:me}}else ct.current=void 0;const ke=I.coordinate(()=>{var me;return(me=Fe.current)==null?void 0:me.call(Fe,de)});ze(de,we.current&&!R.isPerformanceMode&&!R.disableAnimations,ke)},B=j.useCallback(()=>{clearTimeout(Ee.current),clearTimeout(Q.current),Q.current=setTimeout(ce,A.current.layoutDebounce)},[]);j.useLayoutEffect(()=>{const R=new Map(Bt.current.map(q=>[q.id,q]));r.some(q=>{var F;return((F=R.get(q.id))==null?void 0:F.collapsed)===!0&&!q.collapsed})&&(Dt.current=r.filter(q=>!R.has(q.id)).map(q=>q.id)),Bt.current=r,De.current!==l&&ue.current.size>0&&(we.current=!0,qe.current=!1,clearTimeout(Ee.current)),De.current=l,ft.current!==rt&&(qe.current=!Je.current),ft.current=rt,B()},[r,t,O.nodes,O.edges,rt,n,o,a,c,B,l,d,w,e.nodeGridSpacing]),j.useEffect(()=>()=>{clearTimeout(Q.current),clearTimeout(Ee.current),tr()},[]);const oe=j.useCallback((R,q)=>{var F,K;if(!re.current&&typeof ResizeObserver<"u"&&(re.current=new ResizeObserver(de=>{let Me=!1;for(const Se of de){const ke=ae.current.get(Se.target);if(!ke||pe.current.has(ke))continue;const Ye=Se.target,me=Ye.offsetWidth,Te=Ye.offsetHeight;if(!me&&!Te)continue;const Be=W.current.get(ke);if(Be&&Be.w===me&&Be.h===Te)continue;const ee=ue.current.get(ke);Be&&ee&&we.current&&!H.current&&(H.current={id:ke,position:{...ee}}),W.current.set(ke,{w:me,h:Te}),Me=!0}Me&&B()})),q){ie.current.set(R,q),ae.current.set(q,R),(F=re.current)==null||F.observe(q);const de=q.offsetWidth,Me=q.offsetHeight;!pe.current.has(R)&&(de||Me)&&W.current.set(R,{w:de,h:Me})}else{const de=ie.current.get(R);de&&((K=re.current)==null||K.unobserve(de),ae.current.delete(de)),ie.current.delete(R),W.current.delete(R),D.current.has(R)&&se(R,[])}B()},[B,se]);j.useEffect(()=>()=>{var R;return(R=re.current)==null?void 0:R.disconnect()},[]);const $e=R=>{var K;const q=(K=A.current.nodes.find(de=>de.id===R))==null?void 0:K.label;if(!q)return;const F=A.current.containerStyle(R);return{w:yo(q,`bold ${F.fontSize}px ${hr}`)+2*Fj,h:0}},U=j.useMemo(()=>{const R=new Map;for(const q of r)q.label&&R.set(q.id,q.label);return R},[r]),ge=j.useMemo(()=>bd(O.nodes,X,new Map([...W.current,...Ce]),R=>m(R).padding,$e,Ce),[O.nodes,X,m,U,Ce]),Ie=j.useRef(ge);Ie.current=ge;const xe=j.useCallback(R=>{const q=Ie.current.get(R);if(q)return Dw(q);const F=ue.current.get(R);if(!F)return;const K=pe.current.get(R)||W.current.get(R)||Xn;return{x:F.x,y:F.y,w:K.w,h:K.h}},[]),Ze=j.useMemo(()=>{const R=new Map;for(const q of r){const F=xe(q.id);F&&R.set(q.id,F)}return Yw(z,R,ye,t,n)},[z,r,X,ge,ye,t,n,xe]);D.current=Ze;const Qe=(R,q)=>{var de;if(!k||q===void 0)return;const F=(de=Ze.get(R))==null?void 0:de.find(Me=>Me.property===q),K=xe(R);return F&&!F.anchor&&K?K.y-K.h/2+F.top+F.height/2:void 0},Ke=(R,q)=>{var de,Me;if(q===void 0)return;const F=(Me=(de=Ze.get(R))==null?void 0:de.find(Se=>Se.property===q))==null?void 0:Me.anchor,K=xe(R);return F&&K?{x:K.x-K.w/2+F.x,y:K.y-K.h/2+F.y,side:F.side}:void 0},vt=(R,q)=>{const F=xe(R),K=ye.get(R);return F&&K&&!ge.has(R)&&Qe(R,q)===void 0?kn(F,(n==="TB"||n==="BT")&&K.captionBottom!==void 0?{...K,height:Math.max(K.height,K.captionBottom-K.top),outline:void 0}:K):F},It=()=>{const R=[];ue.current.forEach((q,F)=>{if(Ie.current.has(F))return;const K=xe(F);K&&R.push(Zt(K))}),Ie.current.forEach(q=>R.push(q));try{for(const q of[T.current,N.current]){const F=q==null?void 0:q.getBBox();F&&F.width>0&&F.height>0&&R.push({x1:F.x,y1:F.y,x2:F.x+F.width,y2:F.y+F.height})}}catch{}return Vo(R)},Jt=()=>{var F,K;const{pan:R,zoom:q}=I;$.current&&($.current.style.transform=`translate3d(${R.x}px, ${R.y}px, 0) scale(${q})`),(F=T.current)==null||F.setAttribute("transform",`translate(${R.x} ${R.y}) scale(${q})`),(K=N.current)==null||K.setAttribute("transform",`translate(${R.x} ${R.y}) scale(${q})`)};j.useEffect(()=>{Jt();let R=null,q;const F=I.onChange(()=>{Jt();const K=M.current;K&&(K.classList.add("flow-sdk-busy"),clearTimeout(q),q=setTimeout(()=>K.classList.remove("flow-sdk-busy"),150)),R===null&&(R=requestAnimationFrame(()=>{var de,Me;R=null,(Me=(de=A.current).onViewportChange)==null||Me.call(de,I.state)}))});return()=>{F(),clearTimeout(q),R!==null&&cancelAnimationFrame(R)}},[]),j.useLayoutEffect(()=>{const R=M.current;if(!R)return;const q=()=>{var Se;if(!R.getClientRects().length)return;let K=R.clientWidth,de=R.clientHeight;de||(de=Math.max(0,window.innerHeight-R.getBoundingClientRect().top-100),de&&(R.style.height=`${de}px`)),K||(K=window.innerWidth,K&&(R.style.width=`${K}px`));const Me=I.size.w!==K||I.size.h!==de;I.size={w:K,h:de},Me&&((Se=et.current)!=null&&Se.options.fill)&&B(),!we.current&&!ue.current.size&&A.current.fitOnInit!==!1&&(I.set({x:K/2,y:de/2}),Jt())};if(q(),typeof ResizeObserver>"u")return;const F=new ResizeObserver(q);return F.observe(R),()=>F.disconnect()},[I]),j.useLayoutEffect(()=>{if(Kt.current){Kt.current=!1;const q=Dt.current.flatMap(K=>{const de=xe(K);return de?[Zt(de)]:[]});Dt.current=[];const F=Vo(q);if(F){qe.current=!1,I.center(F,A.current.animateViewport);return}}if(!qe.current)return;qe.current=!1;const R=It();R&&(I.fit(R,50,we.current&&A.current.animateViewport),we.current||Jt())},[X]);const mt=j.useMemo(()=>{const R=ee=>{const te=A.current;if(te.nodeGridSpacing!=="layout")return ee;const he=te.direction==="LR"||te.direction==="RL";return{...ee,gaps:{x:he?te.rankSep:te.edgeSep,y:he?te.edgeSep:te.rankSep}}},q=()=>{const ee=A.current,te=P.current.nodes.filter(he=>rr(he.id,ee.edges,ee.edgeMode)&&(!dt.current||dt.current.has(he.id)));return{nodes:te,positions:ue.current,sizes:new Map(te.map(he=>[he.id,W.current.get(he.id)??Xn])),padding:he=>A.current.containerStyle(he).padding,minSize:$e,fixedIds:new Set(Y.current.keys()),viewportSize:{...I.size}}},F=ee=>Bu(ee,A.current.nodes,A.current.edges),K=(ee,te=!0,he=()=>{},ne,Ge,Re=!1)=>{clearTimeout(Q.current),clearTimeout(Ee.current),Re||(Fe.current=null),Je.current=null,qe.current=!1,Dt.current=[],Kt.current=!1;const _e=te&&!A.current.isPerformanceMode&&!A.current.disableAnimations,it=I.coordinate(()=>{var Ve;ne?ne(_e):Re&&((Ve=Fe.current)==null||Ve.call(Fe,ee))});ze(new Map([...ee].map(([Ve,gt])=>[Ve,{...gt}])),_e,it,he,Ge)},de=(ee,te=50,he=A.current.animateViewport,ne=1,Ge=!1)=>{const Re=_e=>{const it=P.current,Ve=ee??new Set(it.nodes.map(Et=>Et.id)),gt=new Set(it.nodes.map(Et=>Et.parent).filter(Boolean));if(!_e&&(!ee||[...ee].some(Et=>gt.has(Et))))return;const sr=_e&&bd(it.nodes,_e,W.current,Et=>A.current.containerStyle(Et).padding,$e),cr=Vo([...Ve].flatMap(Et=>{const sn=sr==null?void 0:sr.get(Et);if(sn)return[sn];const cn=_e==null?void 0:_e.get(Et),Kn=W.current.get(Et)||Xn,ln=cn?{...cn,...Kn}:xe(Et);return ln?[Zt(ln)]:[]}));cr&&(qe.current=!1,Dt.current=[],Kt.current=!1,I.fit(cr,Number.isFinite(te)?Math.max(0,te):50,he,ne))};Fe.current=Ge?Re:null,Ge||Re(ue.current)},Me=(ee,te,he,ne)=>{var Re;if(!xe(ee))return;const Ge=te==="connections"?ke(ee):F(ee);if(te==="connections"&&er.current===1.25&&((Re=dt.current)==null?void 0:Re.size)===Ge.size&&[...Ge].every(_e=>dt.current.has(_e))){S({id:ee,mode:te});return}ar.current||(ar.current={pan:{...I.pan},zoom:I.zoom}),dt.current=Ge,A.current.compactPropertyLayout&&(qe.current=!1,Je.current=()=>de(dt.current??Ge,he,ne)),S({id:ee,mode:te}),A.current.compactPropertyLayout||de(Ge,he,ne)},Se=ee=>{Je.current?Je.current=ee:ee()},ke=ee=>Hu(ee,A.current.nodes,A.current.edges),Ye=(ee=>{var te,he,ne;if(ee===void 0)return I.zoom;ee<I.zoom&&((te=et.current)!=null&&te.options.fill)&&!A.current.readOnly&&((ne=(he=A.current).onNodeGridZoomOut)==null?void 0:ne.call(he,et.current.options))===!0||(Fe.current=null,I.set(void 0,ee))}),me=(ee=>{if(ee===void 0)return I.pan;Fe.current=null,I.set(ee)}),Te=(ee,te)=>{var ne;const he=(ne=M.current)==null?void 0:ne.getBoundingClientRect();return{x:ee-((he==null?void 0:he.left)??0),y:te-((he==null?void 0:he.top)??0)}},Be=(ee=0,te=A.current.animateViewport,he=!1)=>{if(he){de(void 0,ee,te,1,!0);return}Fe.current=null,Se(()=>{const ne=It();ne&&I.fit(ne,ee,te)})};return{zoom:Ye,pan:me,setEdgesVisible:Xe,focusNode:(ee,te,he,ne)=>Se(()=>de(new Set([ee]),te,he,.6,ne)),focusBranch:(ee,te,he,ne)=>Se(()=>de(F(ee),te,he,1,ne)),focusConnections:(ee,te,he,ne)=>Se(()=>de(ke(ee),te,he,1,ne)),isolateConnections:(ee,te,he)=>Me(ee,"connections",te,he),isolateBranch:(ee,te,he)=>Me(ee,"branch",te,he),restoreView:(ee=A.current.animateViewport,te)=>{Fe.current=null;const he=A.current.compactPropertyLayout&&!!dt.current;dt.current=null,S(null);const ne=te??ar.current;ar.current=null,he?Je.current=()=>{ne&&I.transition(ne,ee)}:ne&&Se(()=>I.transition(ne,ee))},zoomAt:(ee,te)=>{var he,ne,Ge;ee<I.zoom&&((he=et.current)!=null&&he.options.fill)&&!A.current.readOnly&&((Ge=(ne=A.current).onNodeGridZoomOut)==null?void 0:Ge.call(ne,et.current.options))===!0||(Fe.current=null,I.zoomAt(ee,te))},fit:Be,centerAndFit:Be,center:(ee=A.current.animateViewport)=>{Fe.current=null;const te=It();te&&I.center(te,ee)},clientToModel:(ee,te)=>I.renderedToModel(Te(ee,te)),modelToClient:ee=>{var ne;const te=(ne=M.current)==null?void 0:ne.getBoundingClientRect(),he=I.modelToRendered(ee);return{x:he.x+((te==null?void 0:te.left)??0),y:he.y+((te==null?void 0:te.top)??0)}},getNodeBox:ee=>xe(ee),detectNodeCollisions:ee=>{const te=q();return Jv({...te,sizes:new Map([...te.sizes,...pe.current]),fixedSizes:pe.current},ee)},resolveNodeCollisions:(ee={})=>{const te=Aj(q(),ee);return te.movedNodeIds.length&&K(te.positions,ee.animate),te},arrangeNodesInGrid:(ee={})=>{const te=q(),he=et.current;if(he){te.positions=new Map(te.positions);for(const Ve of te.nodes)te.positions.has(Ve.id)||te.positions.set(Ve.id,I.renderedToModel({x:I.size.w/2,y:I.size.h/2}));const Re=new Set(te.nodes.map(Ve=>Ve.id));he.order=he.order.filter(Ve=>Re.has(Ve));const _e=new Set(he.order);he.order.push(...te.nodes.filter(Ve=>!_e.has(Ve.id)).map(Ve=>Ve.id));const it=new Map(he.order.map((Ve,gt)=>[Ve,gt]));te.nodes=[...te.nodes].sort((Ve,gt)=>it.get(Ve.id)-it.get(gt.id))}const ne=sd(te,R(ee));kt(ne.dividers??[]),he&&(he.ready=!1);const Ge=()=>{he&&(he.ready=!0),he&&te.nodes.length&&!we.current&&(we.current=!0,A.current.fitOnInit!==!1&&!ee.fill?mt.centerAndFit(50,!1):A.current.fitOnInit===!1&&I.transition(p,!1)),ve(Re=>Re+1)};return!ne.sizes&&pe.current.size&&fe(),te.nodes.some(Re=>!ue.current.has(Re.id))||ne.movedNodeIds.length||ne.bounds||Fe.current?K(ne.positions,ee.animate,Ge,ne.bounds&&(!he||!pe.current.size)?()=>I.transition({zoom:1,pan:{x:0,y:0}},!1):void 0,ne.sizes,!!he&&!ne.bounds):Ge(),ne},setNodeGridMode:(ee,te={})=>{var he,ne,Ge,Re;if(te.order&&(!Array.isArray(te.order)||te.order.some(_e=>typeof _e!="string")||new Set(te.order).size!==te.order.length))throw new Error("Invalid grid node order.");if(ee){sd(q(),R(te));const _e=!et.current||et.current.options.fill&&!te.fill;Fe.current=null,et.current||(et.current={options:te,order:q().nodes.map(it=>it.id),previousPositions:new Map([...ue.current].map(([it,Ve])=>[it,{...Ve}])),previousViewport:{zoom:I.zoom,pan:{...I.pan}},previousSize:{...I.size},ready:!1}),_e&&mt.centerAndFit(80,te.animate,!0),te.order&&(et.current.order=[...te.order]),et.current.options={...te},lt(!0),mt.arrangeNodesInGrid(te),(ne=(he=A.current).onNodeGridModeChange)==null||ne.call(he,{...te,order:[...et.current.order]})}else{const _e=et.current;if(!_e)return;if(I.size.w===_e.previousSize.w&&I.size.h===_e.previousSize.h&&ue.current.size===_e.previousPositions.size&&[...ue.current.keys()].every(gt=>_e.previousPositions.has(gt))?Fe.current=()=>I.transition(_e.previousViewport,te.animate!==!1&&!A.current.disableAnimations&&!A.current.isPerformanceMode):mt.centerAndFit(80,te.animate,!0),et.current=null,lt(!1),fe(),(Re=(Ge=A.current).onNodeGridModeChange)==null||Re.call(Ge,null),Ht(null),!_e.previousPositions.size){B();return}const Ve=new Map([...ue.current].map(([gt,sr])=>[gt,_e.previousPositions.get(gt)??sr]));K(Ve,te.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(ee,te,he)=>{var Et,sn,cn,Kn,ln;const ne=et.current;if(!ne||!ne.ready||A.current.readOnly||ee===te)return!1;const Ge=q(),Re=Ge.nodes.find(dn=>dn.id===ee),_e=Ge.nodes.find(dn=>dn.id===te);if(!Re||!_e||Re.parent!==_e.parent)return!1;const it=sd(Ge,R(ne.options));if(it.skippedNodeIds.includes(ee)||it.skippedNodeIds.includes(te))return!1;const Ve=ne.order.indexOf(ee),gt=ne.order.indexOf(te);if(Ve<0||gt<0)return!1;[ne.order[Ve],ne.order[gt]]=[ne.order[gt],ne.order[Ve]],Fe.current=null,ne.options={...ne.options,order:[...ne.order]};const sr=Re.parent??"canvas",cr=(sn=(Et=ne.options.adjustment)==null?void 0:Et.sections)==null?void 0:sn[sr];return cr!=null&&cr.members&&(ne.options={...ne.options,adjustment:{...ne.options.adjustment,sections:{...(cn=ne.options.adjustment)==null?void 0:cn.sections,[sr]:{...cr,members:cr.members.map(dn=>dn.map(Lo=>Lo===ee?te:Lo===te?ee:Lo))}}}}),mt.arrangeNodesInGrid({...ne.options,animate:he??ne.options.animate}),(ln=(Kn=A.current).onNodeGridModeChange)==null||ln.call(Kn,{...ne.options}),!0},setNodePosition:(ee,te,he)=>{if(!ue.current.has(ee)||te&&(!Number.isFinite(te.x)||!Number.isFinite(te.y)))return!1;if(tr(),!te)return Y.current.delete(ee),B(),!0;const ne=new Map(ue.current);return ne.set(ee,{...te}),(he==null?void 0:he.persist)===!1?Y.current.delete(ee):Y.current.set(ee,{...te}),ue.current=ne,le(ne),(he==null?void 0:he.persist)===!1&&B(),!0},onViewportChange:ee=>I.onChange(ee)}},[]);j.useEffect(()=>{var R,q;return(q=(R=A.current).onInit)==null||q.call(R,mt),()=>I.cancelAnimation()},[mt]),j.useEffect(()=>{var R,q;if(J>0){const F=Je.current;Je.current=null,F==null||F(),(q=(R=A.current).onLayoutComplete)==null||q.call(R,mt)}},[mt,J]);const pt=j.useRef(null),xt=j.useRef(new Map),Tt=j.useRef(!1),[wr,Gn]=j.useState(null),[at,on]=j.useState(null),Un=R=>{const q=M.current.getBoundingClientRect();return{x:(R.clientX-q.left)*(M.current.clientWidth/q.width||1),y:(R.clientY-q.top)*(M.current.clientHeight/q.height||1)}},Hn=(R,q)=>{const F=A.current.nodes;for(let K=F.length-1;K>=0;K--){const de=F[K].id;if(!rr(de,A.current.edges,A.current.edgeMode)||dt.current&&!dt.current.has(de)||de===q||Ie.current.has(de))continue;const Me=xe(de);if(Me&&Du(R,Zt(Me)))return de}for(const[K,de]of Ie.current)if(rr(K,A.current.edges,A.current.edgeMode)&&!(dt.current&&!dt.current.has(K))&&K!==q&&Du(R,de))return K;return null},uu=(R,q)=>{const F=A.current.nodes.find(ke=>ke.id===R),K=xe(R);if(!F||!K)return null;const de=Zt({...K,x:K.x+q.x,y:K.y+q.y});let Me=null,Se=0;for(const ke of A.current.nodes){if(ke.id===R||ke.parent!==F.parent||Y.current.has(ke.id)||Ie.current.has(ke.id)||!rr(ke.id,A.current.edges,A.current.edgeMode)||dt.current&&!dt.current.has(ke.id))continue;const Ye=xe(ke.id);if(!Ye)continue;const me=Zt(Ye),Te=Math.max(0,Math.min(de.x2,me.x2)-Math.max(de.x1,me.x1))*Math.max(0,Math.min(de.y2,me.y2)-Math.max(de.y1,me.y1));Te>Se&&(Se=Te,Me=ke.id)}return Me},fu=(R,q)=>{const F=et.current;if(!(F!=null&&F.ready)||A.current.readOnly)return;const K=A.current.nodes.filter(Te=>rr(Te.id,A.current.edges,A.current.edgeMode)&&(!dt.current||dt.current.has(Te.id))),de=K.find(Te=>Te.id===R);if(!de)return;const Me=M.current,Se=I.zoom*(Me&&Me.clientWidth?Me.getBoundingClientRect().width/Me.clientWidth:1),ke=24/Se;let Ye;for(const Te of K){if(Te.id===R||Te.parent!==de.parent)continue;const Be=xe(Te.id);if(!Be)continue;const ee=Zt(Be),te=Math.min(Be.w/4,ke),he=Math.min(Be.h/4,ke),ne=3/Se,Ge=[];if(q.y>ee.y1+he&&q.y<ee.y2-he)for(const Re of["before","after"]){const _e=Re==="before"?ee.x1:ee.x2,it=Math.abs(q.x-_e),Ve=Re==="before"?q.x<_e:q.x>_e;it<=(Ve?ke:te)&&Ge.push({side:Re,distance:it,marker:{x1:_e-ne/2,x2:_e+ne/2,y1:ee.y1,y2:ee.y2}})}if(q.x>=ee.x1&&q.x<=ee.x2)for(const Re of["above","below"]){const _e=Re==="above"?ee.y1:ee.y2,it=Math.abs(q.y-_e),Ve=Re==="above"?q.y<_e:q.y>_e;it<=(Ve?ke:he)&&Ge.push({side:Re,distance:it,marker:{x1:ee.x1,x2:ee.x2,y1:_e-ne/2,y2:_e+ne/2}})}for(const Re of Ge)(!Ye||Re.distance<Ye.distance)&&(Ye={id:Te.id,...Re})}if(!Ye)return;const me=kj({nodes:K,positions:ue.current,sizes:new Map([...W.current,...pe.current]),fixedSizes:pe.current,padding:Te=>A.current.containerStyle(Te).padding,minSize:$e,fixedIds:new Set(Y.current.keys())},F.options,R,Ye.id,Ye.side);return me?{options:me,marker:Ye.marker}:void 0},Oo=(R,q)=>{if(A.current.edgeMode==="nodes"||A.current.edgeMode==="workflow")return null;const F=A.current.direction==="RL",K=Math.max(16,6/I.zoom);let de=null;for(const Me of[...A.current.nodes].reverse()){if(!rr(Me.id,A.current.edges,A.current.edgeMode)||dt.current&&!dt.current.has(Me.id))continue;const Se=xe(Me.id),ke=D.current.get(Me.id);if(!Se||!ke||Ie.current.has(Me.id))continue;const Ye=Se.x+(q==="source"!==F?1:-1)*Se.w/2;for(const me of ke){if(me.role&&me.role!==q)continue;const Te=Se.y-Se.h/2+me.top,Be=Math.hypot(R.x-(me.anchor?Se.x-Se.w/2+me.anchor.x:Ye),R.y-Te-me.height/2);if(!me.anchor&&R.x>=Se.x-Se.w/2&&R.x<=Se.x+Se.w/2&&R.y>=Te&&R.y<=Te+me.height)return{nodeId:Me.id,property:me.property};Be<=K&&(!de||Be<de.distance)&&(de={nodeId:Me.id,property:me.property,distance:Be})}}return de},ix=R=>{var ke,Ye;if(!R.currentTarget.contains(R.target)||(pt.current||(Tt.current=!1),R.target.closest(".flow-sdk-canvas")!==R.currentTarget)||R.button!==0||A.current.readOnly)return;const q=R.target;if(q.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const F=A.current,K=Un(R);if(R.pointerType==="touch"){xt.current.set(R.pointerId,K);const me=wm(xt.current);if(me){Ht(null),pt.current={kind:"pinch",distance:me.distance,zoom:I.zoom,anchor:I.renderedToModel(me.center)},on(null),Gn(null),Tt.current=!0;for(const Te of xt.current.keys())R.currentTarget.setPointerCapture(Te);return}}if(pt.current)return;const de=!et.current||!!F.nodeGridConnections,Me=F.drawHandles&&q.closest(".flow-sdk-handle"),Se=F.drawHandles&&q.closest(".flow-sdk-property-port");if((!de||!Me&&!Se&&(!F.drawMode||R.shiftKey))&&(et.current||R.shiftKey&&(F.onNodeGridDrop||F.onNodeParentChange))){if(et.current&&!et.current.ready||q.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const me=(ke=q.closest("[data-node-id]"))==null?void 0:ke.dataset.nodeId;if(me&&!Y.current.has(me)){q.setPointerCapture(R.pointerId),pt.current={kind:"grid",pointerId:R.pointerId,captureTarget:q,source:me,start:K,moved:!1};return}if(me)return}if(de&&(F.drawMode||Me||Se)){const me=I.renderedToModel(K),Te=F.drawMode?Oo(me,"source"):null,Be=Se||Me,ee=Be?(Ye=Be.closest("[data-node-id]"))==null?void 0:Ye.dataset.nodeId:(Te==null?void 0:Te.nodeId)??Hn(me),te=Se?Se.dataset.property:Te==null?void 0:Te.property;if(ee){pt.current={kind:"draw",pointerId:R.pointerId,source:ee,sourceProperty:te,reverse:(Se==null?void 0:Se.dataset.portRole)==="target",startClient:{x:R.clientX,y:R.clientY}},Tt.current=!0,on({source:ee,sourceProperty:te,point:me,target:null}),R.currentTarget.setPointerCapture(R.pointerId);return}}q.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(Fe.current=null,F.multiSelect?pt.current={kind:"box",pointerId:R.pointerId,start:K,current:K}:F.dragMode?pt.current={kind:"pan",pointerId:R.pointerId,start:K,pan0:I.pan,moved:!1}:pt.current={kind:"tap",pointerId:R.pointerId,start:K,moved:!1},R.currentTarget.setPointerCapture(R.pointerId))},ax=R=>{var K,de,Me;const q=pt.current;if(!q||A.current.readOnly)return;const F=Un(R);if(xt.current.has(R.pointerId)&&xt.current.set(R.pointerId,F),q.kind==="pinch"){const Se=wm(xt.current);if(!Se)return;const ke=Math.max(I.minZoom,Math.min(I.maxZoom,q.zoom*Se.distance/q.distance));if(ke<I.zoom&&((K=et.current)!=null&&K.options.fill)&&((Me=(de=A.current).onNodeGridZoomOut)==null?void 0:Me.call(de,et.current.options))===!0)return;I.set({x:Se.center.x-q.anchor.x*ke,y:Se.center.y-q.anchor.y*ke},ke);return}if(q.pointerId===R.pointerId)switch(q.kind){case"grid":{const Se={x:F.x-q.start.x,y:F.y-q.start.y};if(!q.moved&&Math.hypot(Se.x,Se.y)<=ld)return;q.moved||(tr(),Fe.current=null,I.cancelAnimation()),q.moved=!0,Tt.current=!0,R.preventDefault();const ke={x:Se.x/I.zoom,y:Se.y/I.zoom},Ye=!R.shiftKey&&F.x>=0&&F.y>=0&&F.x<=I.size.w&&F.y<=I.size.h?fu(q.source,I.renderedToModel(F)):void 0;Ht({source:q.source,offset:ke,target:R.shiftKey||Ye?null:uu(q.source,ke),shiftKey:R.shiftKey,insertion:Ye});break}case"pan":{const Se=F.x-q.start.x,ke=F.y-q.start.y;if(!q.moved&&Math.hypot(Se,ke)<=ld)return;q.moved=!0,Tt.current=!0,I.set({x:q.pan0.x+Se,y:q.pan0.y+ke});break}case"tap":{Math.hypot(F.x-q.start.x,F.y-q.start.y)>ld&&(q.moved=!0);break}case"box":{Tt.current=!0,q.current=F,Gn({x1:Math.min(q.start.x,F.x),y1:Math.min(q.start.y,F.y),x2:Math.max(q.start.x,F.x),y2:Math.max(q.start.y,F.y)});break}case"draw":{const Se=I.renderedToModel(F),ke=Oo(Se,q.reverse?"source":"target");on(q.reverse&&ke?{source:ke.nodeId,sourceProperty:ke.property,point:Se,target:q.source,targetProperty:q.sourceProperty}:{source:q.source,sourceProperty:q.sourceProperty,point:Se,target:(ke==null?void 0:ke.nodeId)??Hn(Se,q.source),targetProperty:ke==null?void 0:ke.property});break}}},hu=(R,q)=>{var de,Me,Se,ke,Ye,me,Te,Be,ee,te,he;xt.current.delete(R.pointerId);const F=pt.current;if(!F)return;if(F.kind==="pinch"){const ne=[...xt.current][0];pt.current=ne&&A.current.dragMode&&!q?{kind:"pan",pointerId:ne[0],start:ne[1],pan0:I.pan,moved:!0}:null;return}if(F.pointerId!==R.pointerId)return;pt.current=null;try{(F.kind==="grid"?F.captureTarget:R.currentTarget).releasePointerCapture(R.pointerId)}catch{}const K=A.current;switch(q=q||!!K.readOnly,F.kind){case"grid":{if(Ht(null),q||!F.moved)break;const ne=Un(R);if(!R.shiftKey&&ne.x>=0&&ne.y>=0&&ne.x<=I.size.w&&ne.y<=I.size.h){const Re=fu(F.source,I.renderedToModel(ne));if(Re){mt.setNodeGridMode(!0,{...Re.options,animate:!1});break}}if(((de=K.onNodeGridDrop)==null?void 0:de.call(K,F.source,{x:R.clientX,y:R.clientY},{shiftKey:R.shiftKey,ctrlKey:R.ctrlKey,metaKey:R.metaKey,altKey:R.altKey}))===!0||ne.x<0||ne.y<0||ne.x>I.size.w||ne.y>I.size.h)break;if(R.shiftKey){const Re=new Map(K.nodes.map(Ve=>[Ve.id,Ve]));let _e=Hn(I.renderedToModel(ne),F.source);const it=new Set;for(;_e&&!((Me=Re.get(_e))!=null&&Me.acceptsChildren)&&!it.has(_e);)it.add(_e),_e=((Se=Re.get(_e))==null?void 0:Se.parent)??null;if(_e&&((ke=Re.get(_e))!=null&&ke.acceptsChildren)){let Ve=_e;const gt=new Set;for(;Ve&&!gt.has(Ve);)gt.add(Ve),Ve=(Ye=Re.get(Ve))==null?void 0:Ye.parent;gt.has(F.source)||(me=K.onNodeParentChange)==null||me.call(K,F.source,_e)}break}if(!et.current)break;const Ge=uu(F.source,{x:(ne.x-F.start.x)/I.zoom,y:(ne.y-F.start.y)/I.zoom});Ge&&mt.swapGridNodes(F.source,Ge,!1);break}case"pan":case"tap":!q&&!F.moved&&((Te=K.onBackgroundTap)==null||Te.call(K));break;case"box":{if(Gn(null),q)break;const ne=I.renderedToModel(F.start),Ge=I.renderedToModel(F.current),Re={x1:Math.min(ne.x,Ge.x),y1:Math.min(ne.y,Ge.y),x2:Math.max(ne.x,Ge.x),y2:Math.max(ne.y,Ge.y)};if(Re.x2-Re.x1<1&&Re.y2-Re.y1<1){(Be=K.onBackgroundTap)==null||Be.call(K);break}const _e=[];for(const it of K.nodes){const Ve=xe(it.id);Ve&&Vw(Zt(Ve),Re)&&_e.push(it.id)}_e.length&&((ee=K.onBoxSelect)==null||ee.call(K,_e));break}case"draw":{if(on(null),q)break;const ne=Un(R),Ge=I.renderedToModel(ne),Re=Oo(Ge,F.reverse?"source":"target"),_e=(Re==null?void 0:Re.nodeId)??Hn(Ge);if(_e===F.source&&(F.sourceProperty===void 0||(Re==null?void 0:Re.property)===void 0||Re.property===F.sourceProperty))break;_e?(te=K.onEdgeDraw)==null||te.call(K,F.reverse?_e:F.source,F.reverse?F.source:_e,F.sourceProperty!==void 0||(Re==null?void 0:Re.property)!==void 0?{sourceProperty:F.reverse?Re==null?void 0:Re.property:F.sourceProperty,targetProperty:F.reverse?F.sourceProperty:Re==null?void 0:Re.property}:void 0):Math.max(Math.abs(R.clientX-F.startClient.x),Math.abs(R.clientY-F.startClient.y))>qj&&((he=K.onDrawIntoSpace)==null||he.call(K,F.source,Ge,F.sourceProperty,F.reverse));break}}},Cr=j.useCallback(()=>{var F;const R=pt.current,q=[...xt.current.keys()];R&&R.kind!=="pinch"&&q.push(R.pointerId),pt.current=null,xt.current.clear(),Ht(null),on(null),Gn(null);for(const K of q)(R==null?void 0:R.kind)==="grid"&&R.captureTarget.hasPointerCapture(K)&&R.captureTarget.releasePointerCapture(K),(F=M.current)!=null&&F.hasPointerCapture(K)&&M.current.releasePointerCapture(K)},[]);j.useEffect(()=>{const R=q=>{q.key==="Escape"&&Cr()};return window.addEventListener("keydown",R),window.addEventListener("blur",Cr),()=>{window.removeEventListener("keydown",R),window.removeEventListener("blur",Cr),pt.current=null,xt.current.clear()}},[Cr]),j.useEffect(()=>{Cr()},[g,b,v,i,n,e.drawHandles,e.readOnly,nt,Cr]);const sx=j.useMemo(()=>{const R=new Map,q=new Map;for(const F of E){if(F.source!==F.target)continue;const K=R.get(F.source)??0;R.set(F.source,K+1),q.set(F.id,K)}return q},[E]),No=$j[n],[Sr,cx]=j.useState(null),$o=Oj(r,E,!!((bu=e.edgeReveal)!=null&&bu.revealNodes));j.useLayoutEffect(()=>{M.current&&Sr&&xm(M.current,Sr)}),j.useEffect(()=>{const R=M.current;if(!R||!Sr)return;const q=R.ownerDocument.fonts,F=()=>xm(R,Sr);return q==null||q.addEventListener("loadingdone",F),()=>q==null?void 0:q.removeEventListener("loadingdone",F)},[Sr]);const qo=Bw(E,vt,No),lx=e.onEdgeSelect,dx=e.onContainerSelect,pu=at?at.target&&vt(at.target,at.targetProperty)||{x:at.point.x,y:at.point.y,w:1,h:1}:null,gu=at?vt(at.source,at.sourceProperty):null,an=!nt||!!e.nodeGridConnections,ux=["flow-sdk-canvas",g&&an?"flow-sdk-draw":"",x?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:M,className:ux,"data-edge-mode":i,"data-node-grid":nt||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:ix,onPointerMove:ax,onPointerUp:R=>hu(R,!1),onPointerCancel:R=>hu(R,!0),onLostPointerCapture:R=>{const q=pt.current;q&&(q.kind==="pinch"||q.pointerId===R.pointerId)&&Cr()},onClickCapture:R=>{if(!R.currentTarget.contains(R.target))return;const q=R.target instanceof Element&&R.target.closest("button[data-flow-fullscreen]");(Tt.current||e.readOnly&&!q)&&(R.preventDefault(),R.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:T,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...ge].filter(([R])=>rr(R,t,i)).filter(([R])=>!_||_.has(R)).map(([R,q])=>{var F,K;return f.jsx(e1,{id:R,rect:q,label:U.get(R),labelLayer:Sr,labelContent:(F=r.find(de=>de.id===R&&de.label!==void 0))==null?void 0:F.element,style:m(R),onSelect:dx,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(K=e.selectedNodeIds)==null?void 0:K.includes(R)},R)})}),f.jsx("g",{className:"flow-sdk-edges",children:Oe&&an&&E.map(R=>{var K,de,Me;if(!$o.ready.has(R.id)||_&&(!_.has(R.source)||!_.has(R.target)))return null;const q=vt(R.source,R.sourceProperty),F=vt(R.target,R.targetProperty);return!q||!F?null:f.jsx(Ju,{id:R.id,edgeData:R.data,validationIssue:R.validationIssue,edgeType:R.type,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:$o.complete,source:q,target:F,sourceProperty:R.sourceProperty,targetProperty:R.targetProperty,sourceY:Qe(R.source,R.sourceProperty),targetY:Qe(R.target,R.targetProperty),sourcePort:Ke(R.source,R.sourceProperty),targetPort:Ke(R.target,R.targetProperty),dir:No,turn:((K=qo.get(R.id))==null?void 0:K.turn)??R.turn,labelAtTarget:(de=qo.get(R.id))==null?void 0:de.labelAtTarget,labelFraction:(Me=qo.get(R.id))==null?void 0:Me.labelFraction,color:R.color,connectorColor:R.connectorColor,labelBg:R.labelBg,label:R.label,labelLayer:Sr,dashed:R.dashed,animated:R.animated&&!x,inverted:R.inverted,loopIndex:sx.get(R.id)??0,onSelect:lx},R.id)})}),Oe&&an&&at&&md(at,i)&&gu&&pu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(Ju,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:at.source,target:at.target??"",sourceProperty:at.sourceProperty,targetProperty:at.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:gu,target:pu,sourceProperty:at.sourceProperty,targetProperty:at.targetProperty,sourceY:Qe(at.source,at.sourceProperty),sourcePort:Ke(at.source,at.sourceProperty),targetPort:at.target?Ke(at.target,at.targetProperty):void 0,targetY:at.target?Qe(at.target,at.targetProperty):void 0,dir:No,turn:.5,color:y,labelBg:y})})]})}),f.jsxs("div",{ref:$,className:"flow-sdk-nodes",children:[(We==null?void 0:We.insertion)&&f.jsx("div",{className:"flow-sdk-box","data-grid-insertion":"",style:{left:We.insertion.marker.x1,top:We.insertion.marker.y1,width:We.insertion.marker.x2-We.insertion.marker.x1,height:We.insertion.marker.y2-We.insertion.marker.y1,background:y,border:0}}),nt&&((vu=et.current)==null?void 0:vu.options.fill)&&((xu=et.current.options.adjustment)==null?void 0:xu.enabled)&&!e.readOnly&&f.jsx(Pj,{dividers:zt,options:et.current.options,zoom:I.zoom,onChange:R=>mt.setNodeGridMode(!0,{...R,animate:!1})}),r.map(R=>{var Ge,Re;const q=X.get(R.id),F=ge.get(R.id);if(F&&R.label!==void 0)return null;const K=(q==null?void 0:q.x)??(F?(F.x1+F.x2)/2:0),de=(q==null?void 0:q.y)??(F?(F.y1+F.y2)/2:0),Me=We!=null&&We.target?R.id===We.source?We.target:R.id===We.target?We.source:void 0:void 0,Se=Me?X.get(Me):void 0,ke=We?X.get(We.source):void 0,Ye=We!=null&&We.target?X.get(We.target):void 0,me=ke&&Ye?{x:Ye.x-ke.x,y:Ye.y-ke.y}:void 0,Te=me?me.x**2+me.y**2:0,Be=Te&&We&&me?Math.max(0,Math.min(1,(We.offset.x*me.x+We.offset.y*me.y)/Te)):0,ee=Se?{x:K+(Se.x-K)*Be,y:de+(Se.y-de)*Be}:(We==null?void 0:We.source)===R.id?{x:K+We.offset.x,y:de+We.offset.y}:void 0,te=Ce.get(R.id),he=Me?Ce.get(Me):void 0,ne=te&&he?{w:te.w+(he.w-te.w)*Be,h:te.h+(he.h-te.h)*Be}:te;return f.jsx(Tj,{id:R.id,x:K,y:de,gridDraggable:nt&&!e.readOnly&&!Y.current.has(R.id),gridDragging:(We==null?void 0:We.source)===R.id,gridDropTarget:(We==null?void 0:We.target)===R.id,gridSize:Ce.get(R.id),gridPreview:ee?{...ee,size:ne,floating:We==null?void 0:We.shiftKey}:void 0,placed:!!q||!!F,hidden:!nt&&!$o.shown.has(R.id)||!rr(R.id,t,i)||!!_&&!_.has(R.id),onMount:oe,drawHandles:e.drawHandles&&!e.readOnly&&an,drawMode:g&&an,connectedPorts:new Set(E.flatMap(_e=>[..._e.source===R.id&&_e.sourceProperty!==void 0?[`source:${_e.sourceProperty}`]:[],..._e.target===R.id&&_e.targetProperty!==void 0?[`target:${_e.targetProperty}`]:[]])),hasCollapseControl:R.hasCollapseControl,handleColor:y,animated:R.animated&&!F&&!x&&!nt,animationColor:R.animationColor,animationWidth:R.animationWidth,animationVariant:R.animationVariant,width:(Ge=W.current.get(R.id))==null?void 0:Ge.w,height:(Re=W.current.get(R.id))==null?void 0:Re.h,propertyMode:k,resolvedRows:Ze.get(R.id),reversePorts:n==="RL",direction:n,onPropertyRows:se,onSurface:L,children:te?R.fillElement??R.element:R.element},R.id)})]}),wr&&f.jsx("div",{className:"flow-sdk-box",style:{left:wr.x1,top:wr.y1,width:wr.x2-wr.x1,height:wr.y2-wr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:N,transform:`translate(${I.pan.x} ${I.pan.y}) scale(${I.zoom})`,children:f.jsx("g",{ref:cx,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const Bj=j.memo(zj);function au(e=!0){const r=j.useRef(null);return j.useEffect(()=>{if(!e||!r.current)return;const t=i=>{i.stopPropagation()},n=r.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,t)),()=>{o.forEach(i=>n.removeEventListener(i,t))}},[e]),r}const Jr=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:l,config:d,readOnly:u}=He(),h=d.editable&&!u,[p,m]=j.useState(r),[y,g]=j.useState(),b=j.useRef(null),v=j.useRef(!1),x=au(s);j.useEffect(()=>{if(s&&(v.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var S;if(v.current)return;v.current=!0;const C=p.trim();C&&C!==r&&((S=l.onNodeLabelChange)==null||S.call(l,e,C)),c()};return!h||!s?f.jsx(V.Text,{color:t,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),m(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:x,style:{position:"relative",width:"max-content",minWidth:y==null?void 0:y.width,maxWidth:900,height:y==null?void 0:y.height},children:[f.jsx(V.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(V.Input,{ref:b,value:p,onChange:C=>m(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(v.current=!0,c())},color:t,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})};function Yv({id:e,label:r,role:t,side:n,position:o=.5,placement:i,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const Dj=so.default.dialog`
|
|
209
|
+
`;function Fu({request:e,property:r,config:t,value:n,disabled:o}){var pe,fe,Y,H,we;const{callbacks:i,structured:s,references:a}=j.useContext(Mt),{themeColor:c}=He(),{background:l}=st(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(h),[y,g]=j.useState(""),[b,v]=j.useState(0),x=j.useRef(null),w=j.useRef(),[C,S]=j.useState(!1),[_,k]=j.useState(!1),[E,O]=j.useState(),P=((pe=t.$options)==null?void 0:pe.$source)==="callback",A=i.resolveFormOptions,{data:M,address:T,nodeAddress:N,nodeId:$}=e;j.useEffect(()=>(S(!1),k(!1),()=>{var J;(J=w.current)==null||J.abort(),w.current=void 0}),[T,N,$,o,h,t.$control,(fe=t.$upload)==null?void 0:fe.accept,(Y=t.$upload)==null?void 0:Y.maxSizeBytes]);const I=j.useRef(M);I.current=M;const W=JSON.stringify([T,$,(H=t.$options)!=null&&H.$dependsOn?t.$options.$dependsOn.map(J=>Le(M,J)):Le(M,N)]);j.useEffect(()=>{m(h),g("")},[h,T,$]),j.useEffect(()=>{if(!P)return;const J=new AbortController;return Promise.resolve().then(()=>{if(!A)throw new Error("No options resolver configured");return A({address:T,nodeAddress:N,nodeId:$,data:Hr(I.current),signal:J.signal})}).then(ve=>{if(!Array.isArray(ve)||ve.some(Q=>!Q||typeof Q.label!="string"||!["string","number","boolean"].includes(typeof Q.value)&&Q.value!==null))throw new Error("Invalid options response");J.signal.aborted||O({key:W,options:ve})}).catch(ve=>{J.signal.aborted||O({key:W,options:[],error:ve instanceof Error?ve.message:"Options unavailable"})}),()=>J.abort()},[P,A,W,T,N,$,b]);const ie=P&&(E==null?void 0:E.key)!==W,ae=P?(E==null?void 0:E.key)===W?E.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:_n(r.type),re=r.type.kind==="array",ye=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(ae?re||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),be=!r.optional||!!t.$requiredWhen&&ho(t.$requiredWhen,M),L=be?"Required":"Optional",z=ye!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=y||P&&(E==null?void 0:E.key)===W&&E.error||!z&&Wt(r.type,n,be),D=$t(t.$label??T.split(".").pop()),se=J=>{var ve;if(!(o||Object.is(J,n)))try{(ve=i.onFormChange)==null||ve.call(i,{...e,previousValue:n,value:J}),g("")}catch(Q){g(Q instanceof Error?Q.message:"Unable to update field")}},X=j.useRef(se);j.useLayoutEffect(()=>{X.current=se});const le=()=>{if(u){try{const Ee=p===""&&r.optional?void 0:JSON.parse(p),Ae=Wt(r.type,Ee,be);if(Ae){g(Ae);return}se(Ee)}catch{g("Enter valid JSON")}return}const J=r.type.kind==="number"||r.type.kind==="integer",ve=p===""&&r.optional?void 0:J&&p!==""?Number(p):p,Q=Wt(r.type,ve,be);if(J&&Q&&p!==""){g(Q);return}se(ve)},ue=async J=>{var Q,Ee,Ae;if(o||w.current||!J.length)return;const ve=new AbortController;w.current=ve,g(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!re&&J.length!==1)throw new Error("Choose one file for this field.");if(!i.uploadFormFile)throw new Error("No file upload handler configured.");const qe=(Ee=(Q=t.$upload)==null?void 0:Q.accept)==null?void 0:Ee.split(",").map(De=>De.trim().toLowerCase()).filter(Boolean);for(const De of J){if(((Ae=t.$upload)==null?void 0:Ae.maxSizeBytes)!==void 0&&De.size>t.$upload.maxSizeBytes)throw new Error(`${De.name} exceeds the file size limit.`);if(qe!=null&&qe.length&&!qe.some(rt=>rt.startsWith(".")?De.name.toLowerCase().endsWith(rt):rt.endsWith("/*")?De.type.toLowerCase().startsWith(rt.slice(0,-1)):De.type.toLowerCase()===rt))throw new Error(`${De.name} is not an accepted file type.`)}const Je=await Promise.all(J.map(async De=>{const rt=await i.uploadFormFile({...e,data:Hr(M),file:De,signal:ve.signal});if(typeof rt!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ft;try{ft=new URL(rt)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ft.protocol)||ft.username||ft.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return rt}));if(ve.signal.aborted||w.current!==ve)return;const Fe=re?[...Array.isArray(n)?n:[],...Je]:Je[0],ct=Wt(r.type,Fe,be);if(ct)throw new Error(ct);X.current(Fe)}catch(qe){ve.signal.aborted||g(qe instanceof Error?qe.message:"Unable to upload file."),ve.abort()}finally{w.current===ve&&(w.current=void 0,S(!1))}},Ce={id:d,disabled:o,"aria-label":D,"aria-required":be,"aria-invalid":!!G,"aria-describedby":G?`${d}-error`:void 0},je=Pe(c);return f.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(N.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[D,be?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${D}`,title:`Reset ${D}`,disabled:o||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>se(void 0),children:f.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&ye!=="upload"&&f.jsx(kw,{label:D,value:n,references:a,disabled:o,onChange:se}),ye==="upload"?f.jsxs("div",{"data-form-upload":re?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":Pe(l),outline:_?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),!o&&!C&&(J.dataTransfer.dropEffect="copy",k(!0))},onDragLeave:J=>{J.currentTarget.contains(J.relatedTarget)||k(!1)},onDrop:J=>{J.preventDefault(),J.stopPropagation(),k(!1),ue(Array.from(J.dataTransfer.files))},children:[f.jsx("input",{ref:x,type:"file",hidden:!0,"aria-label":`Upload ${D}`,accept:(we=t.$upload)==null?void 0:we.accept,multiple:re,disabled:o||C,onChange:J=>{const ve=Array.from(J.target.files??[]);J.target.value="",ue(ve)}}),f.jsxs("div",{"data-upload-items":"",children:[(re?Array.isArray(n)?n:[]:n?[n]:[]).map((J,ve)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof J=="string"&&lr(J)&&f.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer","aria-label":`${D} file ${ve+1}`,children:[f.jsx(Z.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Qt,{name:J,size:120,onError:Q=>{Q.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!re&&f.jsx(Ne,{"aria-label":`Replace ${D}`,title:`Replace ${D}`,icon:f.jsx(Z.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>{var Q;return(Q=x.current)==null?void 0:Q.click()}}),f.jsx(Ne,{"aria-label":`Remove ${D} file ${ve+1}`,title:"Remove file",icon:f.jsx(Z.PiTrash,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>se(re&&Array.isArray(n)?n.filter((Q,Ee)=>Ee!==ve):"")})]})]},`${ve}:${J}`)),(re||!n)&&f.jsx("button",{...Ce,type:"button","data-upload-drop":"",title:`Upload ${D}`,disabled:o||C,onClick:()=>{var J;return(J=x.current)==null?void 0:J.click()},children:f.jsx(Z.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):z?null:ye==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(At,{...Ce,disabled:o||ie||!!(E!=null&&E.error),labelCase:"preserve",value:String((ae==null?void 0:ae.findIndex(J=>Object.is(J.value,n)))??-1),onValueChange:J=>{const ve=ae==null?void 0:ae[Number(J)];ve&&se(ve.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):L}),ae==null?void 0:ae.map((J,ve)=>f.jsx("option",{value:ve,children:$t(J.label)||J.label},ve))]})}):ye==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":D,"aria-describedby":Ce["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ae==null?void 0:ae.map((J,ve)=>{const Q=re?Array.isArray(n)&&n.includes(J.value):Object.is(n,J.value);return f.jsx("button",{type:"button",disabled:o||ie,"aria-pressed":Q,style:{padding:"8px 16px",borderRadius:24,border:0,color:Q?je:"inherit",background:Q?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>se(re?Q?n.filter(Ee=>Ee!==J.value):[...Array.isArray(n)?n:[],J.value]:J.value),children:$t(J.label)||J.label},ve)}),ie&&f.jsx("span",{role:"status",children:"Loading..."})]}):ye==="textarea"?f.jsx("textarea",{...Ce,placeholder:L,value:p,onChange:J=>m(J.target.value),onBlur:le}):f.jsx("input",{...Ce,placeholder:L,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:J=>m(J.target.value),onBlur:le,onKeyDown:J=>{J.key==="Enter"&&le(),J.key==="Escape"&&m(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${d}-error`,children:G}),P&&(E==null?void 0:E.error)&&f.jsx("button",{type:"button",disabled:o,onClick:()=>{O(void 0),v(b+1)},children:"Retry"})]})}function Od({nodeAddress:e,structured:r=!1}){return r?f.jsx(Aw,{nodeAddress:e},e):f.jsx(pd,{nodeAddress:e})}function Aw({nodeAddress:e}){var u,h,p;const r=j.useContext(Mt),[t,n]=j.useState([]),o=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,i=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!o||!i))return gb(r.data,i,o,[{data:{id:e,type:"objectView"}}])},[r.data,i,o,e]);if(!s)return f.jsx(pd,{nodeAddress:e});const a=t.findIndex(m=>!s.containers.has(m)),c=a<0?t:t.slice(0,a),l=c.at(-1)??e,d=(p=[...s.slots.values()].find(m=>m.nodeId===l))==null?void 0:p.label;return f.jsxs(Mt.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ne,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Z.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:$t(d)})]}),f.jsx(pd,{nodeAddress:l,onOpen:m=>n([...c,m])},l)]})}function pd({nodeAddress:e,onOpen:r}){var S,_;const{data:t,schema:n,callbacks:o,bindings:i,editable:s,renderForm:a,structured:c}=j.useContext(Mt),{readOnly:l,config:d,colorMode:u}=He(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(Jn,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=i?$n(i,e,n):void 0,m=i?p:n&&Xr(t,e,n);if(!m)return f.jsx(Jn,{$colorMode:u,role:"status",children:"Form schema unavailable."});const y=(p==null?void 0:p.address)??e,g=Le(t,y),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(Jn,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const v=Object.entries(m.type.properties).filter(([k])=>{var E;return ho((E=m.fields[k])==null?void 0:E.$visibleWhen,t)}),x=v.length>8||v.some(([k])=>{var E;return(E=m.fields[k])==null?void 0:E.$section}),w=new Map;for(const k of v){const[E,O]=k,P=x?$t(((_=m.fields[E])==null?void 0:_.$section)??(O.type.kind==="object"||O.type.kind==="array"?E:O.optional?"Options":"General")):"";w.has(P)||w.set(P,[]),w.get(P).push(k)}const C=([k,E])=>f.jsx(Fu,{request:{data:t,address:b?y:`${y}.${k}`,nodeAddress:y,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:E,config:m.fields[k]??{},value:b?g:g==null?void 0:g[k],disabled:l||d.editable===!1||!(s??!!o.onJsonChange)},`${(g==null?void 0:g.id)??e}:${k}`);return f.jsxs(Jn,{$colorMode:u,"data-flow-form":e,onClick:k=>k.stopPropagation(),onDoubleClick:k=>k.stopPropagation(),children:[c&&f.jsx(Rw,{nodeAddress:e,onOpen:r}),!c&&p&&m.type.additionalProperties&&v.length===0&&f.jsx(Fu,{request:{data:t,address:y,nodeAddress:y},property:{type:m.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:l||d.editable===!1||!s}),[...w].map(([k,E])=>x&&E.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:k}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),E.map(C)]},k):E.map(C))]})}function mb(e){const{viewData:r}=j.useContext(Mt),{nodeById:t,edgeById:n,parentIds:o}=vr();if(r){const i=Le(r,e),s=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const s=i.isInverted?i.target:i.source,a=i.isInverted?i.source:i.target;return s===e&&a!==e&&t.has(a)})}function In(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function Tn(e,r,t,n){return{borderColor:r,borderWidth:In(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Rm(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function bb({label:e,value:r,options:t,onChange:n,disabled:o}){var i;return f.jsxs(At,{"aria-label":e,title:`Animation: ${((i=t.find(s=>s.value===r))==null?void 0:i.label)??"Mixed"}`,value:r,style:{width:104},disabled:o,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Nd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:o}){const{callbacks:i,readOnly:s,themeColor:a,colorMode:c}=He(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=st(),m=c==="dark"?Zr:Pe(p),y=j.useRef(null),g=j.useRef(null),b=j.useRef(0),[v,x]=j.useState(!1),[w,C]=j.useState("icons"),[S,_]=j.useState([]),[k,E]=j.useState("loading"),[O,P]=j.useState(""),[A,M]=j.useState(0),[T,N]=j.useState(""),[$,I]=j.useState(""),[W,ie]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!v)return;let D=!0;return import("react-icons/pi").then(se=>{D&&(_(Object.keys(se).filter(X=>X.startsWith("Pi")).sort()),E("ready"))}).catch(()=>{D&&E("unavailable")}),()=>{D=!1}},[v]),j.useEffect(()=>{var D;s&&((D=y.current)==null||D.close())},[s]),j.useEffect(()=>{var D,se,X;if(n!==void 0){if(!n||s){(D=y.current)==null||D.close();return}(se=y.current)!=null&&se.open||(I(""),C(t==="PiFileSvg"||t&&lr(t)?"custom":"icons"),N(t&&!t.startsWith(En)&&lr(t)?t:""),x(!0),(X=y.current)==null||X.showModal())}},[n,s,t]);const ae=D=>{var se,X,le;s||(r?(se=i.onEdgeIconChange)==null||se.call(i,r,D):e&&((X=i.onNodeIconChange)==null||X.call(i,e,D)),o==null||o(!1),(le=y.current)==null||le.close())},re=S.filter(D=>D.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(O.trim().toLowerCase())),ye=36,be=Math.max(1,Math.ceil(re.length/ye)),L=Math.min(A,be-1),z=re.slice(L*ye,(L+1)*ye),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${Pe(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Ue,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ne,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:Pe(a),disabled:s,onClick:()=>{var D;I(""),C(t&&lr(t)?"custom":"icons"),N(t&&!t.startsWith(En)&&lr(t)?t:""),x(!0),(D=y.current)==null||D.showModal()}})}),f.jsx(V.chakra.dialog,{ref:y,"aria-label":r?"Choose edge icon":"Choose node icon",css:gr(Pe(l),Pe(u)),onClose:()=>{x(!1),o==null||o(!1),b.current++,ie(!1)},onClick:D=>{D.stopPropagation(),D.target===D.currentTarget&&D.currentTarget.close()},onKeyDown:D=>D.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:Pe(l),color:Pe(h)},children:v&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(Ue,{label:"Remove icon",children:f.jsx(Ne,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||W,onClick:()=>ae("")})}),f.jsx(Yr,{"aria-label":"Close icon picker",onClick:()=>{var D;return(D=y.current)==null?void 0:D.close()}})]})]}),f.jsxs(V.Tabs.Root,{value:w,onValueChange:({value:D})=>{C(D),I("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(V.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(D=>f.jsx(V.Tabs.Trigger,{value:D,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:m,"--indicator-color":m},children:D==="icons"?"React icons":"Custom SVG"},D))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:W||s,onChange:async D=>{var le;const se=(le=D.target.files)==null?void 0:le[0];if(D.target.value="",!se)return;const X=++b.current;ie(!0),I("");try{const ue=await vw(se);X===b.current&&ae(ue)}catch(ue){X===b.current&&I(ue instanceof Error?ue.message:"Unable to read SVG.")}finally{X===b.current&&ie(!1)}}}),f.jsx(V.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:O,onChange:D=>{P(D.target.value),M(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[z.map(D=>f.jsx("button",{type:"button","aria-label":`Choose ${D}`,"aria-pressed":t===D,title:D,onClick:()=>ae(D),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===D?2:1}px solid ${Pe(t===D?a:u)}`,background:Pe(t===D?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(Qt,{name:D,size:24})},D)),z.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:k==="loading"?"Loading icons...":k==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[re.length," icons · ",L+1," / ",be]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Ue,{label:"Previous icons",children:f.jsx(Ne,{"aria-label":"Previous icons",icon:f.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:L===0,onClick:()=>M(L-1)})}),f.jsx(Ue,{label:"Next icons",children:f.jsx(Ne,{"aria-label":"Next icons",icon:f.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:L+1>=be,onClick:()=>M(L+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&lr(t)&&f.jsx(Qt,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:W||s,onClick:()=>{var D;return(D=g.current)==null?void 0:D.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Z.PiUploadSimple,{}),W?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:D=>{D.preventDefault(),!(W||s)&&(!lr(T.trim())||T.trim().startsWith(En)?I("Enter an HTTP or HTTPS image URL."):ae(T.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:T,disabled:W||s,onChange:D=>N(D.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(Ue,{label:"Apply URL",children:f.jsx(Ne,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:W||s||!T.trim(),style:{flexShrink:0}})})]})]})})]}),$&&f.jsx("div",{role:"alert",style:{fontSize:13},children:$})]})})]})}const no=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Zr],vb=["gray.900",Zr,"gray.600","gray.200","white"];function xb(){const{config:e}=He(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||no,show:n=>!t.has(n)}}function jt(){const{border:e}=st();return f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function Dr({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:o="text",min:i,onCommit:s}){const{colorText:a}=st(),[c,l]=j.useState(e),d=j.useRef(!1);j.useEffect(()=>l(e),[e]);const u=()=>{if(d.current)return;d.current=!0;const h=c.trim();if(o==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(i??0))){l(e);return}h!==e&&s(h)};return f.jsx(V.Input,{"aria-label":t,type:o,min:i,size:"xs",fontSize:"16px",w:n,value:c,placeholder:r,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{d.current=!1},onChange:h=>l(h.target.value),onBlur:u,onKeyDown:h=>{h.key==="Enter"&&(u(),h.target.blur()),h.key==="Escape"&&(d.current=!0,l(e),h.target.blur())}})}function Mr({colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=st(),[c,l]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=co(f.jsx(Mr,{colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i}));return f.jsx(Gr.Provider,{value:null,children:f.jsxs(V.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:m=>{var y;m.key==="Escape"&&(l(!1),(y=u.current)==null||y.focus())},children:[f.jsx(Ue,{label:`${t}: ${h}`,children:f.jsx(V.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Pe(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${Pe(a)}`,outlineOffset:"1px",onClick:()=>l(m=>!m)})}),c&&f.jsxs(V.HStack,{id:d,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(m=>{const y=r===m;return f.jsx(Ue,{label:`${t}: ${m}`,children:f.jsx(V.Box,{as:"button","aria-label":`${t} ${m}`,"aria-pressed":y,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Pe(m),...m==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:y?`2px solid ${Pe(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(m),onDoubleClick:g=>{var b;g.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},m)}),o&&f.jsx(Ue,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ne,{"aria-label":`Reset ${t}`,icon:f.jsx(V.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var m;o(),l(!1),(m=u.current)==null||m.focus()}})})]})]})})}function wb({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:o}=He(),{colorInactive:i}=st(),{edgeById:s}=vr(),{palette:a,show:c}=xb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(Yr,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Dr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:m=>{var y;return(y=t.onEdgeLabelChange)==null?void 0:y.call(t,e,m)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),h.map(m=>f.jsx(Ue,{label:m.label,children:f.jsx(Ne,{"aria-label":`Edge style ${m.key}`,"aria-pressed":u===m.key,icon:f.jsx(V.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===m.key?n:i,onClick:()=>{var y;return(y=t.onEdgeStyleChange)==null?void 0:y.call(t,e,m.key)}})},m.key)),u==="animated"&&f.jsx(bb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var y;return(y=t.onEdgeAnimationVariantChange)==null?void 0:y.call(t,e,m)}}),f.jsxs(At,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:o.readOnly,onValueChange:m=>{var y;return(y=t.onEdgeTypeChange)==null?void 0:y.call(t,e,m||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(m=>f.jsx("option",{value:m,children:m},m))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Nd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(Dr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:m=>{var y;return(y=t.onEdgeIconChange)==null?void 0:y.call(t,e,m)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Mr,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:m=>{var y;return(y=t.onEdgeColorChange)==null?void 0:y.call(t,e,m)},onReset:()=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:"Delete edge",children:f.jsx(Ne,{"aria-label":"Delete edge",icon:f.jsx(V.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=t.onEdgeDelete)==null||m.call(t,e,l),r()}})})]})]})}function Cb({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:o,fillRadiusEditedIds:i,setNodeRadiusPreview:s}=He(),{colorInactive:a}=st(),{nodeById:c}=vr(),[l,d]=j.useState(),u=j.useRef(),h=j.useRef(),p=j.useRef({callbacks:t,readOnly:n.readOnly,nodeById:c});p.current={callbacks:t,readOnly:n.readOnly,nodeById:c};const m=()=>{var C,S;clearTimeout(h.current);const w=u.current;if(u.current=void 0,!!w){if(!p.current.readOnly)for(const _ of w.ids)p.current.nodeById.has(_)&&((S=(C=p.current.callbacks).onNodeBorderRadiusChange)==null||S.call(C,_,w.radius));s(w.ids,void 0),d(void 0)}},y=j.useRef(m);y.current=m,j.useEffect(()=>{const w=()=>y.current();return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w),w()}},[]);const g=e.map(w=>{var C,S;return o!=null&&o.fill&&!i.has(w)?0:(S=(C=c.get(w))==null?void 0:C.data.viewProps)==null?void 0:S.borderRadius}),b=!g.every(w=>w===g[0]),v=l??g[0]??0,x=w=>{n.readOnly||(w!==void 0&&e.every(C=>{var S;return((S=c.get(C))==null?void 0:S.data.type)==="grid"})?(d(w),s(e,w),u.current={ids:[...e],radius:w},clearTimeout(h.current),h.current=setTimeout(m,150)):(clearTimeout(h.current),u.current=void 0,d(void 0),s(e,void 0),e.forEach(C=>{var S;return(S=t.onNodeBorderRadiusChange)==null?void 0:S.call(t,C,w)})))};return f.jsxs(f.Fragment,{children:[r&&f.jsx(jt,{}),f.jsx(V.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsx(At,{icon:f.jsx(V.Icon,{as:xx.TbBorderRadius,boxSize:5,color:a,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${b?"Mixed":g[0]===void 0?"Default":`${g[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:"radius",disabled:n.readOnly,onValueChange:()=>{},popupContent:f.jsxs(f.Fragment,{children:[f.jsx(fd,{label:"Border radius",inputLabel:"Node corner radius",min:0,max:Math.max(500,...g.map(w=>w??0)),step:1,value:v,displayValue:l!==void 0?`${l}px`:b?"Mixed":g[0]===void 0?"Default":`${v}px`,onChange:x,onChangeEnd:m}),f.jsx(Ue,{label:"Reset border radius",children:f.jsx(Ne,{"aria-label":"Reset border radius",icon:f.jsx(Z.PiEraser,{size:20}),size:"sm",variant:"ghost",color:a,disabled:n.readOnly,onClick:()=>x(void 0)})})]}),children:f.jsx("option",{value:"radius",children:"Border radius"})})})]})}function Sb({ids:e,onClose:r,afterLabel:t}){var se,X,le,ue,Ce,je,pe,fe;const{callbacks:n,colorMode:o,themeColor:i,config:s,setNodeViewMode:a,nodeViewModes:c}=He(),{colorText:l,colorInactive:d}=st(),{nodeById:u,parentIds:h}=vr(),{palette:p,show:m}=xb(),y=e.length===1,[g,b]=j.useState(""),v=y?(se=u.get(e[0]))==null?void 0:se.data:void 0,x=e.map(Y=>{var J,ve,Q,Ee,Ae,qe;const H=(J=u.get(Y))==null?void 0:J.data,we=((ve=H==null?void 0:H.config)==null?void 0:ve.typeView)??"";return we==="object"&&((Q=H==null?void 0:H.config)==null?void 0:Q.content)!==void 0&&c[Y]!=="properties"?"content":we==="icon-label"&&((Ee=H==null?void 0:H.viewProps)==null?void 0:Ee.bgColor)==="transparent"&&((Ae=H==null?void 0:H.viewProps)==null?void 0:Ae.borderWidth)===0&&((qe=H==null?void 0:H.viewProps)==null?void 0:qe.outline)===!1?"media":we}),w=x.some(Y=>Y!==x[0]),C=w?"mixed":x[0]??"",S=[{value:"text",label:"Text",view:"text",icon:Z.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Z.PiShapes},{value:"object",label:"Object",view:"object",icon:Z.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Z.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Z.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Z.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Z.PiTextAlignLeft}],_=e.some(Y=>{var we,J,ve,Q;const H=(we=u.get(Y))==null?void 0:we.data;return H&&((J=H.config)==null?void 0:J.typeView)!=="grid"&&((ve=H.config)==null?void 0:ve.typeView)!=="parent"&&(h.has(Y)||((Q=H.config)==null?void 0:Q.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},H.type))}),k=(X=v==null?void 0:v.config)==null?void 0:X.collapsed,E=mb(e[0]),O=Y=>{var H,we,J;return(((we=(H=u.get(Y))==null?void 0:H.data.viewProps)==null?void 0:we.outline)??(h.has(Y)?(J=s.parentNodeStyle)==null?void 0:J.outline:!1))===!0},P=e.every(O),A=!P&&e.some(O),M=Y=>{var H;return((H=u.get(Y))==null?void 0:H.data.isNodeAnimated)===!0},T=e.every(M),N=!T&&e.some(M),$=e.map(Y=>{var H;return((H=u.get(Y))==null?void 0:H.data.nodeAnimationVariant)??"traveling"}),I=$.every(Y=>Y===$[0])?$[0]:"",W=Y=>e.forEach(Y),[ie,ae]=j.useState(!1),re=ie&&m("color")&&m("borderColor"),ye=Y=>{var H,we,J;return(((we=(H=u.get(Y))==null?void 0:H.data.viewProps)==null?void 0:we.borderStyle)??(h.has(Y)?(J=s.parentNodeStyle)==null?void 0:J.borderStyle:"solid"))==="dashed"},be=e.every(ye),L=!be&&e.some(ye),z=e.map(Y=>{var J,ve,Q;const H=(J=u.get(Y))==null?void 0:J.data,we=h.has(Y)?In((ve=s.parentNodeStyle)==null?void 0:ve.borderWidth,6):(H==null?void 0:H.type)==="objectView"?3:2;return In((Q=H==null?void 0:H.viewProps)==null?void 0:Q.borderWidth,we)}),G=z.every(Y=>Y===z[0])?String(z[0]??""):"",D=Y=>W(H=>{var we,J;re?(we=n.onNodeBorderColorChange)==null||we.call(n,H,Y):(J=n.onNodeColorChange)==null||J.call(n,H,"bg",Y)});return f.jsxs(f.Fragment,{children:[f.jsx(Yr,{onClick:r}),f.jsx(jt,{}),y&&m("label")?f.jsx(Dr,{ariaLabel:"Node label",placeholder:"Node label",value:(v==null?void 0:v.label)??(v==null?void 0:v.headerTitle)??"",onCommit:Y=>{var H;return(H=n.onNodeLabelChange)==null?void 0:H.call(n,e[0],Y)}}):f.jsxs(V.Text,{fontSize:"xs",color:l,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,m("typeView")&&f.jsxs(At,{"aria-label":"Type view",title:_?"Type view is managed by the custom renderer or container":`Type view: ${C||"None (default)"}`,icon:f.jsx(Z.PiCards,{size:20}),style:{width:36},value:C,disabled:s.readOnly||s.editable===!1||_,onValueChange:Y=>{var we;const H=(we=S.find(J=>J.value===Y))==null?void 0:we.view;H&&W(J=>{var Q,Ee,Ae,qe,Je,Fe,ct,De,rt,ft,Oe,Xe,nt;const ve=(Q=u.get(J))==null?void 0:Q.data;Y==="media"?((Ee=n.onNodeColorChange)==null||Ee.call(n,J,"bg","transparent"),(Ae=n.onNodeBorderColorChange)==null||Ae.call(n,J,"#00000000"),(qe=n.onNodeBorderWidthChange)==null||qe.call(n,J,0),(Je=n.onNodeOutlineChange)==null||Je.call(n,J,!1)):x[e.indexOf(J)]==="media"&&((Fe=n.onNodeColorChange)==null||Fe.call(n,J,"bg",""),(ct=n.onNodeBorderColorChange)==null||ct.call(n,J,""),(De=n.onNodeBorderWidthChange)==null||De.call(n,J,void 0)),Y==="content"&&((rt=ve==null?void 0:ve.config)==null?void 0:rt.content)===void 0&&((ft=n.onNodeContentChange)==null||ft.call(n,J,"")),(Oe=n.onNodeTypeViewChange)==null||Oe.call(n,J,H),a(J,Y==="object"&&((Xe=ve==null?void 0:ve.config)==null?void 0:Xe.content)!==void 0?"properties":"default"),(nt=n.onNodeViewToggle)==null||nt.call(n,J)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),S.map(Y=>f.jsx("option",{value:Y.value,children:f.jsxs(V.HStack,{gap:"12px",children:[f.jsx(Y.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:Y.label})]})},Y.value))]}),m("style")&&f.jsx(Cb,{ids:e},e.join("\0")),m("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:P?"Restore node fill":"Remove node fill",children:f.jsx(Ne,{"aria-label":"Toggle node outline","aria-pressed":A?"mixed":P,icon:f.jsx(V.Icon,{as:P?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:P?i:d,onClick:()=>W(Y=>{var H;return(H=n.onNodeOutlineChange)==null?void 0:H.call(n,Y,!P)})})})]}),m("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),m("borderColor")&&f.jsx(Ue,{label:re?"Edit node colors":"Edit node border",children:f.jsx(Ne,{"aria-label":"Edit node border","aria-pressed":re,icon:f.jsx(V.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:re?i:d,bg:re?o==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ae(Y=>!Y)})}),f.jsx(Mr,{label:re?"Border color":"Background",colors:p,value:re?((le=v==null?void 0:v.viewProps)==null?void 0:le.borderColor)??(y&&h.has(e[0])?(ue=s.parentNodeStyle)==null?void 0:ue.borderColor:void 0):(Ce=v==null?void 0:v.viewProps)==null?void 0:Ce.bgColor,onPick:D,onReset:()=>D("")}),re&&m("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:be?"Solid border":"Dashed border",children:f.jsx(Ne,{"aria-label":"Toggle dashed border","aria-pressed":L?"mixed":be,icon:f.jsx(V.Icon,{as:be?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:be?i:d,onClick:()=>W(Y=>{var H;return(H=n.onNodeBorderStyleChange)==null?void 0:H.call(n,Y,be?"solid":"dashed")})})}),f.jsx(Dr,{ariaLabel:"Border thickness",placeholder:y?"Auto":"Mixed",width:"64px",type:"number",min:0,value:G,onCommit:Y=>W(H=>{var we;return(we=n.onNodeBorderWidthChange)==null?void 0:we.call(n,H,Y===""?void 0:Number(Y))})})]})]}),m("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:T?"Stop border animation":"Animate node border",children:f.jsx(Ne,{"aria-label":"Toggle node animation","aria-pressed":N?"mixed":T,icon:f.jsx(V.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:T?i:d,onClick:()=>W(Y=>{var H;return(H=n.onNodeAnimationChange)==null?void 0:H.call(n,Y,!T)})})}),(T||N)&&f.jsx(bb,{label:"Node animation",value:I,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:Y=>W(H=>{var we;return(we=n.onNodeAnimationVariantChange)==null?void 0:we.call(n,H,Y)})})]}),!re&&m("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Mr,{label:"Text color",colors:vb,value:(je=v==null?void 0:v.viewProps)==null?void 0:je.textColor,onPick:Y=>W(H=>{var we;return(we=n.onNodeColorChange)==null?void 0:we.call(n,H,"text",Y)}),onReset:()=>W(Y=>{var H;return(H=n.onNodeColorChange)==null?void 0:H.call(n,Y,"text","")})})]}),y&&m("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Nd,{nodeId:e[0],value:(pe=v==null?void 0:v.config)==null?void 0:pe.icon},e[0]),f.jsx(Dr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((fe=v==null?void 0:v.config)==null?void 0:fe.icon)||"",onCommit:Y=>{var H;return(H=n.onNodeIconChange)==null?void 0:H.call(n,e[0],Y)}})]}),y&&E&&m("collapse")&&k!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:k?"Expand":"Collapse",children:f.jsx(Ne,{"aria-label":k?"Expand node":"Collapse node",icon:f.jsx(V.Icon,{as:k?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:d,onClick:()=>{var Y;return(Y=n.onNodeCollapse)==null?void 0:Y.call(n,e[0],!k)}})})]}),m("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ue,{label:y?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ne,{"aria-label":"Delete selected nodes",icon:f.jsx(V.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:o==="dark"?"red.300":"red.500",onClick:()=>{W(Y=>{var H,we;return(we=n.onNodeDelete)==null?void 0:we.call(n,Y,((H=u.get(Y))==null?void 0:H.data)||{id:Y})}),r()}})})]}),f.jsx(jt,{}),f.jsx(Ue,{label:"Copy selection",children:f.jsx(Ne,{"aria-label":"Copy selection",icon:f.jsx(Z.PiCopy,{size:20}),size:"sm",variant:"ghost",color:d,onClick:async()=>{var Y;try{await((Y=n.onNodesCopy)==null?void 0:Y.call(n,e)),b("")}catch(H){b(String(H))}}})}),f.jsx(Ue,{label:"Duplicate selection",children:f.jsx(Ne,{"aria-label":"Duplicate selection",icon:f.jsx(Z.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:d,disabled:s.readOnly||s.editable===!1,onClick:()=>{var Y;try{(Y=n.onNodesDuplicate)==null||Y.call(n,e),b("")}catch(H){b(String(H))}}})}),g&&f.jsx(V.Text,{role:"alert",fontSize:"xs",children:g})]})}async function jb(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(e,{filter:o=>!(o instanceof Element)||!o.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(t.slice(t.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(o=>{o.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function _b(e,r="squeed.svg"){const t=document.createElement("a");t.href=await jb(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function Eb(){const{themeColor:e}=He(),[r,t]=j.useState(!1),[n,o]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Ue,{label:"Download SVG (current view)",children:f.jsx(Ne,{"aria-label":"Download SVG",icon:f.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:r,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var a;const s=(a=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){o("Diagram not available for export.");return}t(!0),o("");try{await _b(s)}catch(c){o(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function $d({children:e,background:r,border:t,endElement:n,startElement:o,startElementWidth:i=44,framed:s=!0}){const a=j.useRef(null),[c,l]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const u=a.current;let h=u.parentElement.offsetWidth;const p=()=>{const g=u.parentElement.offsetWidth;if(g>0&&g!==h){const x=h/g;h=g,x>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&u.parentElement.animate({transform:[`scaleX(${x})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const b=u.scrollLeft>1,v=u.scrollWidth-u.clientWidth-u.scrollLeft>1;l(x=>x.left===b&&x.right===v?x:{left:b,right:v})},m=g=>{if(g.defaultPrevented||g.ctrlKey||s&&g.deltaX!==0||!(g.deltaX||g.deltaY)||u.scrollWidth<=u.clientWidth)return;g.preventDefault();const b=g.deltaMode===WheelEvent.DOM_DELTA_LINE?16:g.deltaMode===WheelEvent.DOM_DELTA_PAGE?u.clientWidth:1;u.scrollLeft+=(g.deltaX||g.deltaY)*b},y=new ResizeObserver(p);return y.observe(u),u.firstElementChild&&y.observe(u.firstElementChild),u.addEventListener("scroll",p,{passive:!0}),u.addEventListener("wheel",m,{passive:!1}),p(),()=>{y.disconnect(),u.removeEventListener("scroll",p),u.removeEventListener("wheel",m)}},[]);const d=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(V.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?gr(d,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||o?{"--flow-toolbar-start-width":o?`${i}px`:"0px"}:{}},children:[f.jsx(V.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:o?`${i}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(u=>f.jsx(V.Box,{"data-flow-toolbar-fade":u,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:u==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[u]:u==="right"&&n?44:u==="left"&&o?i:0,opacity:c[u]?1:0,background:`linear-gradient(to ${u==="left"?"right":"left"}, ${d}, transparent)`}},u)),n&&f.jsx(V.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n}),o&&f.jsx(V.Box,{position:"absolute",left:"6px",top:0,h:"50px",w:`${i-12}px`,display:"flex",alignItems:"center",justifyContent:"center",children:o})]})}async function Pw(e,r){const t=new Set,n=[],o=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,m]of Object.entries(l))p==="$"?o(m,c):p.startsWith("$")||o(m,`${c}.${p}`)};if(o(r,"root"),!t.size)return{contract:await hb(e)};const i=await Td(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Xr(r,a,i);c&&(s[a]={type:c.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function kb({message:e,onDismiss:r}){const{background:t,colorText:n,border:o}=st();return!e||typeof document>"u"?null:Vr.createPortal(f.jsxs(V.chakra.div,{role:"alert","aria-atomic":"true",css:gr(Pe(t),Pe(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:Pe(t),color:Pe(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Z.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(Yr,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function qd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=He(),{edgeById:d}=vr(),{data:u,schema:h,setSchema:p,bindings:m,structured:y}=j.useContext(Mt),g=(y==null?void 0:y.sourceBindings)??m,b=(y==null?void 0:y.sourceSchema)??h,{colorText:v}=st(),x=j.useRef(null),w=j.useRef(0),[C,S]=j.useState(!1),[_,k]=j.useState("");j.useEffect(()=>()=>{w.current++},[]),j.useEffect(()=>{w.current++,S(!1)},[a,u,g]);const E=o?[...d.values()].filter(A=>Id(o,A.data)).length:0,O=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${E} invalid or unverified connections`:"",P=co(f.jsx(qd,{showDivider:!1,compact:!0}));return f.jsx(Gr.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:P,children:[f.jsx(kb,{message:_,onDismiss:()=>k("")}),e&&f.jsx(xn,{}),f.jsxs(At,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Z.PiGraph,{size:20}):t==="properties"?f.jsx(Z.PiTable,{size:20}):f.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:t,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(V.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:ro,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:A=>{var M,T;(M=A.currentTarget.closest("[popover]"))==null||M.hidePopover(),(T=s.onWorkflowConfigurationOpen)==null||T.call(s)},children:[f.jsx(Z.PiGear,{}),"Configuration"]})]}),onValueChange:A=>{var T;const M=A==="auto"?"auto":A==="properties"?"properties":"nodes";n(M),(T=s.onEdgeModeChange)==null||T.call(s,M)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(Ue,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:f.jsx(Ne,{"aria-label":"Upload workflow interface",icon:f.jsx(Z.PiUploadSimple,{size:20}),color:Pe(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var A;return(A=x.current)==null?void 0:A.click()}})}),f.jsx("input",{ref:x,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async A=>{var N,$;const M=(N=A.target.files)==null?void 0:N[0];if(A.target.value="",!M)return;const T=++w.current;S(!0),k("");try{const I=g?await Td(M,[...new Set(Object.values(g).map(ae=>ae.schemaType??ae.type))]):void 0;if(g&&I){for(const ae of Object.values(g))if(!Object.prototype.hasOwnProperty.call(I,ae.schemaType??ae.type))throw new Error(`Missing form type: ${ae.schemaType??ae.type}`)}const{contract:W,schema:ie}=g&&I?{schema:I,contract:{name:M.name,nodes:Object.fromEntries(Object.entries(g).map(([ae,re])=>[ae,{type:I[re.schemaType??re.type],optional:!1}]))}}:await Pw(M,u);if(T!==w.current)return;p==null||p(ie),i(W),($=s.onWorkflowContractChange)==null||$.call(s,W)}catch(I){T===w.current&&k(`${M.name}: ${I instanceof Error?I.message:"Unable to load interface."}`)}finally{T===w.current&&S(!1)}}}),!r&&(O||C)&&f.jsx("span",{role:"status",title:O,style:{color:Pe(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":O}),!r&&o&&f.jsx(Ue,{label:"Remove workflow interface",children:f.jsx(Ne,{"aria-label":"Remove workflow interface",icon:f.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var A;p==null||p(void 0),i(void 0),(A=s.onWorkflowContractChange)==null||A.call(s,void 0),k("")}})})]})]})})}const Mw=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:hn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:hn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:hn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:hn.RIGHT_LEFT}],Rb=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:o,setEdgeColor:i,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:m,selectedEdgeId:y,setSelectedEdgeId:g,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:x,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:_,setIsEdgeHandlesEnabled:k,isArrayNodeMode:E,setIsArrayNodeMode:O,isPinned:P,setIsPinned:A,callbacks:M,config:T,readOnly:N}=He(),{nodeById:$,edgeById:I,parentIds:W}=vr(),ie=T.colorMode==="dark",{background:ae,border:re,colorInactive:ye,colorText:be,colorActive:L}=st(),z=ie?re:"gray.300",G=`var(--chakra-colors-${ae.replace(".","-")})`,D=`var(--chakra-colors-${(ie?re:"gray.300").replace(".","-")})`,[se,X]=j.useState(!1),[le,ue]=j.useState(!0),Ce=T.bottomBarCollapsed??le,je=j.useRef(null),pe=Em({edge:"bottom",enabled:!P,bounds:je,inside:[je]}),fe=j.useCallback(Oe=>{const Xe=r.current;if(!Xe)return;const nt=T.minZoom??.01,lt=T.maxZoom??1.5,zt=.02;let kt=Xe.zoom();switch(Oe){case"increase":kt=Math.min(lt,kt+zt),Xe.zoom(kt),Xe.center(!1);break;case"decrease":kt=Math.max(nt,kt-zt),Xe.zoom(kt),Xe.center(!1);break;case"reset":Xe.fit(50);break}},[r,T.minZoom,T.maxZoom]),Y=T.renderSelectedNodeToolbar,H=p.length>0&&!!Y,we=j.useMemo(()=>H?p.map(Oe=>{var nt;return{...((nt=$.get(Oe))==null?void 0:nt.data)??{id:Oe},isParent:W.has(Oe)}}):[],[H,p,$,W]),J=j.useCallback(()=>{var Oe;m([]),(Oe=M.onNodeDeselect)==null||Oe.call(M)},[m,M]),ve=T.renderSelectedEdgeToolbar,Q=!!y&&!!ve,Ee=j.useMemo(()=>{var Oe;return!Q||!y?null:((Oe=I.get(y))==null?void 0:Oe.data)??{id:y}},[Q,y,I]),Ae=j.useCallback(()=>{var Oe;g(null),(Oe=M.onEdgeDeselect)==null||Oe.call(M)},[g,M]),qe=T.selectionToolbar!==!1&&!N,Je=qe&&!!y&&!ve,Fe=qe&&!Je&&p.length>0&&!Y,ct=Je||Fe,De=P||pe||se||ct||T.bottomBarCollapsed===!1;j.useEffect(()=>{p.length||y?a(!1):N||(s&&A(!0),T.bottomBarCollapsed===void 0&&ue(!s))},[s,p.length,y,N,a,A,T.bottomBarCollapsed]);const rt=T.renderBottomBar,ft=iw();return rt?f.jsxs(f.Fragment,{children:[H&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Y({selectedNodeIds:p,selectedNodeData:we,onDeselect:J})}),Q&&Ee&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ve({edgeId:y,edgeData:Ee,onDeselect:Ae})}),f.jsx(V.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:rt({zoomIn:()=>fe("increase"),zoomOut:()=>fe("decrease"),resetZoom:()=>fe("reset"),direction:c,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:x,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:_,setIsEdgeHandlesEnabled:k,isArrayNodeMode:E,setIsArrayNodeMode:O,selectedNodeIds:p,selectedNodeData:we,selectedEdgeId:y,selectedEdgeData:Ee,onNodeDeselect:J,onEdgeDeselect:Ae,callbacks:M})})]}):f.jsxs(Gr.Provider,{value:ft,children:[H&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Y({selectedNodeIds:p,selectedNodeData:we,onDeselect:J})}),Q&&Ee&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ve({edgeId:y,edgeData:Ee,onDeselect:Ae})}),f.jsx(V.Box,{ref:je,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:De?"translateY(0)":"translateY(100%)",pointerEvents:De?"auto":"none",visibility:De?"visible":"hidden",opacity:De?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(V.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx($d,{background:ae,border:ie?re:"gray.300",children:f.jsxs(V.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Je?f.jsx(wb,{edgeId:y,onClose:Ae}):Fe?f.jsx(Sb,{ids:p,onClose:J}):null,f.jsxs("div",{style:{display:Je||Fe?"none":"contents"},children:[f.jsxs("span",{style:{display:T.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(Ue,{label:P?"Unpin":"Pin",children:f.jsx(Ne,{"aria-label":"Pin",icon:f.jsx(V.Icon,{as:P?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:P?t:ye,onClick:()=>{A(!P),X(!1)}})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:"Zoom Out",children:f.jsx(Ne,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(V.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:be,onClick:()=>fe("decrease")})}),f.jsx(Ue,{label:"Zoom In",children:f.jsx(Ne,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(V.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:be,onClick:()=>fe("increase")})}),f.jsx(Ue,{label:"Reset Zoom",children:f.jsx(Ne,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(V.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:be,onClick:()=>fe("reset")})}),Ce&&f.jsx(aw,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:Ce?"none":"contents"},children:[f.jsxs("span",{style:{display:T.bottomBarNavigation===!1?"none":"contents"},children:[T.edgeHandles!==!1&&f.jsx(Ue,{label:_?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ne,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":_,icon:f.jsx(V.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:_?t:ye,onClick:()=>k(!_)})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ne,{"aria-label":"Toggle zoom mode",icon:f.jsx(V.Icon,{as:b?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:ye,onClick:()=>v(!b)})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:x?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ne,{"aria-label":"Toggle multi-select",icon:f.jsx(V.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:x?t:ye,onClick:()=>w(!x)})}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ne,{"aria-label":"Toggle drag mode",icon:f.jsx(V.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:ye,onClick:()=>S(!C)})})]}),T.bottomBarNavigation===!1&&(e===void 0?f.jsx(zo,{}):e?Vr.createPortal(f.jsx(zo,{}),e):null),T.bottomBarExtra&&f.jsxs(f.Fragment,{children:[T.bottomBarNavigation!==!1&&f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),T.bottomBarExtra]}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),f.jsx(tb,{})]}),f.jsx("span",{style:{display:T.bottomBarNavigation===!1||Ce&&!h?"none":"contents"},children:f.jsx(zo,{})}),f.jsxs("span",{style:{display:Ce?"none":"contents"},children:[f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),f.jsx(eb,{}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:E?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ne,{"aria-label":"Toggle array mode",icon:f.jsx(V.Icon,{as:E?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:E?t:ye,onClick:()=>{var Xe;const Oe=!E;O(Oe),(Xe=M.onArrayModeChange)==null||Xe.call(M,Oe)}})})]}),f.jsx(qd,{}),!N&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Mr,{label:"Graph theme",colors:no,value:t,includeTransparent:!1,onPick:Oe=>{var Xe;n(Oe),(Xe=M.onThemeColorChange)==null||Xe.call(M,Oe)}})]}),!N&&f.jsxs(f.Fragment,{children:[f.jsx(V.Icon,{as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"}),f.jsx(Mr,{label:"Graph edge color",colors:no,value:o||(ie?"gray.500":Zr),onPick:i,onReset:()=>i("")}),f.jsx(V.Icon,{as:Z.PiLineVerticalThin,boxSize:5,color:z,role:"separator","aria-orientation":"vertical"})]}),f.jsx(rb,{})]}),f.jsx(V.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:z}),f.jsx(Ue,{label:Ce?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ne,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(V.Icon,{as:Ce?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:ye,onClick:()=>{var Oe;T.bottomBarCollapsed===void 0&&ue(!Ce),a(Ce),(Oe=M.onBottomBarCollapsedChange)==null||Oe.call(M,!Ce)}})}),!Ce&&f.jsx(Eb,{})]})]})}),!ct&&f.jsxs(V.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(V.Box,{"data-flow-direction-control":"",bg:ae,borderRadius:"30px",h:50,css:gr(G,D),px:3,cursor:"pointer",onClick:()=>X(!se),children:f.jsxs(V.Flex,{align:"center",h:"100%",children:[f.jsx(Ue,{label:"Flow Direction",children:f.jsx(Ne,{"aria-label":"Direction",onClick:Oe=>{Oe.stopPropagation(),X(!se)},icon:f.jsx(V.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:ye})}),f.jsx(V.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ie?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),se&&f.jsx(V.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(V.Box,{bg:ae,borderRadius:"30px",p:2,minW:"180px",css:gr(G,D),children:[Mw.map(Oe=>f.jsxs(V.Flex,{align:"center",gap:3,px:3,py:2,css:ro,cursor:"pointer",_hover:{bg:ie?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Xe;(Xe=M.onDirectionChange)==null||Xe.call(M,Oe.value),X(!1)},children:[f.jsx(V.Icon,{as:Oe.icon,boxSize:5,color:be}),f.jsx(V.Text,{fontSize:"sm",color:be,flex:1,whiteSpace:"nowrap",children:Oe.label}),c===Oe.value&&f.jsx(V.Icon,{as:Z.PiCheck,boxSize:4,color:L})]},Oe.value)),f.jsxs(V.Flex,{align:"center",gap:3,px:3,py:2,css:ro,cursor:"pointer",_hover:{bg:ie?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Oe;(Oe=M.onDirectionChange)==null||Oe.call(M,"C"),X(!1)},children:[f.jsx(V.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:be}),f.jsx(V.Text,{fontSize:"sm",color:be,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(V.Icon,{as:Z.PiCheck,boxSize:4,color:L})]})]})})]})]})})]})};Rb.displayName="BottomBar";const Ab=j.memo(Rb);function Iw({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(Ur,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(V.Icon,{as:Z.PiGraph,boxSize:5})})}const zu={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Pb(e,r){const t=new Map,n=(i,s)=>{if(Object.is(i,s))return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const a=Object.keys(i);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(i[c],s[c]))},o=(i,s,a)=>{if(i===s)return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of c)if(!n(i[l],s[l])){if(Object.prototype.hasOwnProperty.call(zu,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[zu[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!o(i[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(o(e,r,"root"))return t}function Tw(e,r){return Pb(e,r)!==void 0}function Ow(e,r,t){if(e===r)return t;const n=Pb(e,r);if(!n)return;const o=new Set(t.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!Le(r,i))return;return{edges:t.edges,nodes:t.nodes.map(i=>{const s=n.get(i.data.id),a=Le(e,i.data.id),c=Le(r,i.data.id);return!s&&a===c?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function gd(e){return e.kind==="literal"?e.value:e.kind==="union"?gd(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,gd(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Mb(e,r,t){var g,b,v;const n=(g=Le(e,r))==null?void 0:g.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(x=>!/^[A-Za-z0-9_-]+$/.test(x)||["__proto__","constructor","prototype"].includes(x)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),c=Xr(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[o.$type],u=o.$defaults??{};for(const[x,w]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,x)||Wt(d.properties[x].type,w,!d.properties[x].optional))throw new Error(`Invalid creation default: ${x}`);const h={...gd(d),...structuredClone(u)};((v=d.properties.id)==null?void 0:v.type.kind)==="string"&&(h.id=jd());let p=e;const m=Le(e,o.$address);if(m===void 0)p=_t(e,a,x=>({...x,[s]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const y=Rd(p,o.$address,{...h,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:y.address,json:Ad(y.json,r,{target:y.address,label:o.$edgeLabel})}}function Ib(e,r,t){var i;if(r==="root"||!Le(e,r)||!Le(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let o=t;for(;o;){if(o===r||o.startsWith(`${r}.`)||n.has(o))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(o);const s=(i=Le(e,o))==null?void 0:i.$parent;o=typeof s=="string"?s:o.includes(".")?o.slice(0,o.lastIndexOf(".")):void 0}return kd(_t(e,r,s=>({...s,$parent:t})),t,!1)}function Tb(e,r){const t=new Set(r.filter(a=>Le(e,a)!==void 0)),n=[],o=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d,`${c}.${l}`)}};o(e,"root");const i=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!i(a)&&typeof c.$parent=="string"&&i(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Ld(e,r){const t=Tb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),o=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},i=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&o(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=o(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||i(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Le(e,a));i(l),s[`node_${c+1}`]=l}),s}function Ob(e,r){const t=Ld(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),o=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),i=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&o.has(d[1])&&(d[1]=o.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return i(c),[o.get(a),c]}));return{json:_t(e,"root",a=>({...a,...s})),ids:[...o.values()].map(a=>`root.${a}`)}}function Nw(e,r){const t=o=>e&&typeof e=="object"&&o in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Nb(e,r,t,n,o){const i=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodeParentChange:(a,c)=>{var d;const l=Ib(e,a,c);(d=t.onNodeParentChange)==null||d.call(t,a,c),i(l,{type:"nodeStyle",address:a,key:"$parent",value:c})},onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Ld(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Ob(e,a);i(c.json,{type:"nodeCreate",address:c.ids[0]})},onFormChange:a=>{const c=Le(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(po(e,a,t.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),i(St(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeSubtitleChange:(a,c)=>{var l;(l=t.onNodeSubtitleChange)==null||l.call(t,a,c),i(St(e,a,"$subtitle",c),{type:"nodeStyle",address:a,key:"$subtitle",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),i(St(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!wd.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),i(St(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";i(St(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),i(St(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),i(St(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),i(St(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),i(St(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),i(St(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),i(St(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),i(St(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),i(St(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),i(kd(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var p,m;if(((p=t.onNodeCreate)==null?void 0:p.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=!!a.sourceNodeId&&a.isArrayMode&&!((m=Le(e,c))!=null&&m.$arrayDrawInitialized);let d=e,u,h=a.isArrayMode?"array":"set";for(let y=0;y<(l?2:1);y++){const g=a.sourceNodeId&&Mb(d,a.sourceNodeId,o);if(g)d=g.json,u??(u=g.address),h="form";else{const b=Nw(Le(d,c),a.isArrayMode?"list":"node"),v=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},x=Rd(d,c,v,b);d=x.json,u??(u=x.address)}}l&&(d=_t(d,c,y=>Array.isArray(y)?{$:y,$arrayDrawInitialized:!0}:{...y,$arrayDrawInitialized:!0})),i(d,{type:"nodeCreate",address:u,value:h})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),i(lb(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;i(d?Ad(e,a,d):db(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&i(cb(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&i(ur(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=ub(e,l);d.removed&&i(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const $w=".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 qw({path:e,width:r,reversed:t,children:n,onComplete:o}){const i=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,c]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(o==null||o())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[o]),j.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:l=>{l.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${i})`,children:n})]})}const Lw=".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 Fw({path:e,color:r,width:t,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const $b=".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 oo({x:e=0,y:r=0,width:t,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=j.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2))},p=s+36,m={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[f.jsx("rect",{...m,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${i} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const zw=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 qb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Lb(e,r,t=()=>{},n=300){let o,i,s=!1;const a=()=>{s=!0,o!==void 0&&cancelAnimationFrame(o),clearTimeout(i)},c=()=>{s||(a(),r(1),t())};if(!qb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(o=requestAnimationFrame(d))};return o=requestAnimationFrame(d),i=setTimeout(c,n+100),a}function Bu(e,r,t){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of r)(s.parent===i||s.id.startsWith(`${i}.`)||t.some(c=>(c.inverted?c.target:c.source)===i&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function Bw(e,r,t){const n=t==="downward"||t==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=o.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),o.set(u,h)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},m)=>{const y=l.length===1?d/2:120+(d-280)*m/(l.length-1),g=l.find(b=>Math.abs(b.cross)<Math.abs(p));i.set(u.id,{turn:y/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return i}const Zt=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}),Dw=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Vo(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const Vw=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Du=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Nt=e=>(Math.round(e*10)/10).toString(),ht=e=>`${Nt(e.x)} ${Nt(e.y)}`,Ww=e=>e>0?1:e<0?-1:0,Vu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function Gw(e,r,t,n,o=10){const i=r.x-e.x,s=r.y-e.y,a=Vu(i,(e.w+r.w)/2),c=Vu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:i,h=Ww(u),p=n*d,m=v=>Math.abs(v)<o||Math.abs(v)>=Math.abs(d),y=m(p)||m(Math.abs(d)-Math.abs(p));let g;if(y)if(l)if(Math.abs(u)<=e.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else if(Math.abs(i)<=r.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else g=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else if(Math.abs(s)<=r.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else g=[r.x,e.y];else if(l){const v=e.y+p+e.h/2*h;g=[e.x,v,r.x,v]}else{const v=e.x+p+e.w/2*h;g=[v,e.y,v,r.y]}const b=[{x:e.x,y:e.y}];for(let v=0;v<g.length;v+=2)b.push({x:g[v],y:g[v+1]});return b.push({x:r.x,y:r.y}),b}function Uw(e,r,t){const n=r.x-e.x,o=r.y-e.y,i=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=o>0?(t.y2-e.y)/o:o<0?(t.y1-e.y)/o:1/0,a=Math.min(i,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+o*a}}function Kr(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return Uw(e,r,Zt(t));const n=r.x-e.x,o=r.y-e.y;let i=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-o*u;if(Math.abs(p)<1e-9)return;const m=a.x-e.x,y=a.y-e.y,g=(m*h-y*u)/p,b=(m*o-y*n)/p;g>=0&&g<1&&b>=-1e-9&&b<=1+1e-9&&(i=Math.min(i,g))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Fb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,o=r==="top"||r==="bottom",i=r==="top"||r==="left"?-1:1,s={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...Kr(s,{x:s.x+(o?0:i*a),y:s.y+(o?i*a:0)},e)??{x:o?s.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:s.y},side:r}}function Fr(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function Hw(e,r,t,n){const o=Fr(e,t.srcDist),i=Fr(r,t.tgtDist);if(n==="straight")return Bb(o,i,t);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&r.side==="top"?i.y-o.y:e.side==="top"&&r.side==="bottom"?o.y-i.y:e.side==="right"&&r.side==="left"?i.x-o.x:e.side==="left"&&r.side==="right"?o.x-i.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=Fr({...o,side:e.side},c),d=Fr({...i,side:r.side},c),u=t.arrowAt==="source"?bt(o,l,t.arrowGap):o,h=t.arrowAt==="target"?bt(i,d,t.arrowGap):i,p=t.arrowAt==="source"?qt(o,l,t.arrowSize,t.headShape):t.arrowAt==="target"?qt(i,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${ht(u)} C${ht(l)} ${ht(d)} ${ht(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",y=r.side==="left"||r.side==="right";let g;if(m!==y){const v=m?{x:d.x,y:l.y}:{x:l.x,y:d.y},x=(v.x-l.x)*(l.x-o.x)+(v.y-l.y)*(l.y-o.y)>=0,w=(v.x-d.x)*(d.x-i.x)+(v.y-d.y)*(d.y-i.y)>=0;g=[x&&w?v:m?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(m){const v=(l.y+d.y)/2;g=[{x:l.x,y:v},{x:d.x,y:v}]}else{const v=(l.x+d.x)/2;g=[{x:v,y:l.y},{x:v,y:d.y}]}else if(m){const v=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;g=[{x:v,y:l.y},{x:v,y:d.y}]}else{const v=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;g=[{x:l.x,y:v},{x:d.x,y:v}]}const b=[l,...g,d].filter((v,x,w)=>x===0||v.x!==w[x-1].x||v.y!==w[x-1].y);return go(u,b,h,p,n==="orthogonal"?0:t.radius)}function bt(e,r,t){const n=e.x-r.x,o=e.y-r.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-t)/i;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*o}}function qt(e,r,t,n="triangle"){const o=e.x-r.x,i=e.y-r.y,s=Math.hypot(o,i)||1,a=o/s,c=i/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${ht(e)} L${Nt(e.x-c*d)} ${Nt(e.y+a*d)} L${Nt(u-c*d)} ${Nt(h+a*d)} L${Nt(u+c*d)} ${Nt(h-a*d)} L${Nt(e.x+c*d)} ${Nt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((y,g)=>{const b=p[(g+2)%3],v=p[(g+1)%3],x=Math.hypot(b.x-y.x,b.y-y.y),w=Math.hypot(v.x-y.x,v.y-y.y),C={x:(b.x-y.x)/x,y:(b.y-y.y)/x},S={x:(v.x-y.x)/w,y:(v.y-y.y)/w},_=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),k=Math.sqrt((1-_)/(1+_)),E=Math.min(1/k,x/2,w/2);return{start:{x:y.x+C.x*E,y:y.y+C.y*E},end:{x:y.x+S.x*E,y:y.y+S.y*E},radius:E*k}}).map((y,g)=>`${g?"L":"M"}${ht(y.start)} A${Nt(y.radius)} ${Nt(y.radius)} 0 0 1 ${ht(y.end)}`).join(" ")+" Z"}function dr(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function Kw(e,r,t,n){const o={x:r.x-e.x,y:r.y-e.y},i={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),c=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-o.x/s*l,y:r.y-o.y/s*l},b:r,p2:{x:r.x+i.x/a*l,y:r.y+i.y/a*l},r:l}}function zb(e,r,t,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const y=Kr(e[m],e[m+1],r);if(y){o=m,i=y;break}}let s=-1,a=null;for(let m=e.length-1;m>0;m--){const y=Kr(e[m],e[m-1],t);if(y){s=m,a=y;break}}if(!i||!a||o>=s)return null;const c=e.slice(o+1,s),l=c[0]??a,d=c[c.length-1]??i;let u,h,p;if(n.arrowAt==="source"){const m=bt(i,l,n.srcDist);u=bt(i,l,n.srcDist+n.arrowGap),p=qt(m,l,n.arrowSize,n.headShape)}else u=bt(i,l,n.srcDist);if(n.arrowAt==="target"){const m=bt(a,d,n.tgtDist);h=bt(a,d,n.tgtDist+n.arrowGap),p=qt(m,d,n.arrowSize,n.headShape)}else h=bt(a,d,n.tgtDist);return go(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function go(e,r,t,n,o,i,s){var h;const a=[e,...r,t],c=[];let l=`M${ht(e)}`;for(let p=1;p<a.length-1;p++){const m=Kw(a[p-1],a[p],a[p+1],o);c.push(m),m.r===0?l+=` L${ht(m.b)}`:l+=` L${ht(m.p1)} Q${ht(m.b)} ${ht(m.p2)}`}l+=` L${ht(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:dr(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],m=r[u/2];d={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:dr(m.x-p.x,m.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const m=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:dr(m.x-p.b.x,m.y-p.b.y)}}else d={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:dr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&c.length===2){const g=c[0].p2,b=c[1].p1,v=Math.hypot(b.x-g.x,b.y-g.y),x=Math.min(.5,i/(2*v)),w=Math.max(x,Math.min(1-x,s));d={x:g.x+(b.x-g.x)*w,y:g.y+(b.y-g.y)*w,angle:dr(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,m=t.x-p.x,y=t.y-p.y;Math.hypot(m,y)>=i&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:dr(m,y)})}return{d:l,arrow:n,label:d}}function Wu(e,r,t,n,o,i,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:o??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*i,v=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x:v,y:c.y},{x:v,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+i);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const m=s.arrowAt==="source"?bt(c,p[0],s.arrowGap):c,y=s.arrowAt==="target"?bt(l,p[p.length-1],s.arrowGap):l,g=s.arrowAt==="source"?qt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?qt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return go(m,p,y,g,s.radius)}function Gu(e,r,t,n,o){return zb(Gw(e,r,t,n),e,r,o)}function Uu(e,r,t,n,o,i){const s=n===void 0&&o===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,m=Kr(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return m?{x:m.x+(s?0:u*i),y:m.y+(s?u*i:0)}:s?{x:l.x,y:l.y+u*(l.h/2+i)}:{x:l.x+u*(l.w/2+i),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,o,-a)}}function Jw(e,r,t,n){const o=t==="downward"||t==="upward",i=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(o?r.y-e.y:r.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},c={x:r.x-(o?0:i*s),y:r.y-(o?i*s:0)},l=n.arrowAt==="source"?bt(e,a,n.arrowGap):e,d=n.arrowAt==="target"?bt(r,c,n.arrowGap):r;return{d:`M${ht(l)} C${ht(a)} ${ht(c)} ${ht(d)}`,arrow:n.arrowAt==="source"?qt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?qt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:dr(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Bb(e,r,t){const n=t.arrowAt==="source"?bt(e,r,t.arrowGap):e,o=t.arrowAt==="target"?bt(r,e,t.arrowGap):r,i=t.arrowAt==="source"?qt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?qt(r,e,t.arrowSize,t.headShape):void 0;return go(n,[],o,i,0)}function Zw(e,r,t,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*i*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},m={x:e.x,y:e.y},y=Kr(m,h,e),g=Kr(m,p,e);if(!y||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let v=bt(y,h,t.srcDist),x=bt(g,p,t.tgtDist),w;if(t.arrowAt==="target"){const S=x;x=bt(g,p,t.tgtDist+t.arrowGap),w=qt(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=v;v=bt(y,h,t.srcDist+t.arrowGap),w=qt(S,h,t.arrowSize,t.headShape)}return{d:`M${ht(v)} Q${ht(h)} ${ht(b)} Q${ht(p)} ${ht(x)}`,arrow:w,label:{x:b.x,y:b.y,angle:dr(p.x-h.x,p.y-h.y)}}}const jr=e=>Math.round(e*1e3)/1e3;function Db(e){var h,p;const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=r.getBoundingClientRect();if(!o.width||!o.height)return;const i=(p=(h=r.closest("[data-flow-icon-label]"))==null?void 0:h.querySelector("[data-flow-icon-caption]"))==null?void 0:p.getBoundingClientRect(),s=r,a=typeof s.getScreenCTM=="function"?s.getScreenCTM():null,c=typeof s.getTotalLength=="function"?s.getTotalLength():0,l=s.points,d=(l==null?void 0:l.numberOfItems)||128,u=a&&c>0?Array.from({length:d},(m,y)=>{const g=l!=null&&l.numberOfItems?l.getItem(y):s.getPointAtLength(c*y/d);return{x:jr((a.a*g.x+a.c*g.y+a.e-t.left)/n),y:jr((a.b*g.x+a.d*g.y+a.f-t.top)/n)}}):void 0;return{left:jr((o.left-t.left)/n),top:jr((o.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:jr(o.width/n),height:r instanceof HTMLElement?r.offsetHeight:jr(o.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...i!=null&&i.height?{captionBottom:jr((i.bottom-t.top)/n)}:{},...u?{outline:u}:{}}}function kn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(o=>({x:t+o.x,y:n+o.y}))}:{}}}function Yw(e,r,t,n,o){var d;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,m]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const y=r.get(m);if(p===void 0||!y||m===h)continue;const g=t.get(m),b=JSON.stringify([h,p]),v=c.get(b)??[];v.push(g?kn(y,g):y),c.set(b,v)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(x=>x.placement==="config"))continue;const m=t.get(u),y=m?kn(p,m):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=m?kn(g,m):g,v=new Map;for(const x of h){if(x.placement!=="config")continue;const C=(c.get(JSON.stringify([u,x.property]))??[]).reduce((_,k)=>_+(i?k.y-y.y:k.x-y.x),0),S=((d=x.anchor)==null?void 0:d.side)===a?a:s;v.set(x,C<-.001?s:C>.001?a:S)}l.set(u,h.map(x=>{const w=v.get(x);if(!w)return x;const C=h.filter(k=>v.get(k)===w),S=(C.indexOf(x)+1)/(C.length+1),_=Fb(b,w,S);return{...x,anchor:_,top:_.y,height:0}}))}return l}function Hu(e,r,t){const n=new Set(r.map(a=>a.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of r)!o.has(a.id)&&(o.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(o.add(a.id),i=!0)}const s=new Set(o);for(const a of t)o.has(a.source)&&n.has(a.target)&&s.add(a.target),o.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const hr='"Helvetica Neue", Helvetica, sans-serif';let fn;const Zn=new Map;function yo(e,r){const t=`${r}|${e}`,n=Zn.get(t);if(n!==void 0)return n;fn===void 0&&(fn=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return fn?(fn.font=r,o=fn.measureText(e).width):o=e.length*(parseFloat(r)||16)*.55,Zn.size>5e3&&Zn.clear(),Zn.set(t,o),o}function Xw(e,r,t){const n=[];for(const o of String(e).split(`
|
|
210
|
+
`)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const c=s?`${s} ${a}`:a;!s||yo(c,r)<=t?s=c:(n.push(s),s=a)}n.push(s)}return n}const Ku=e=>e.stopPropagation();function Qw({id:e,rect:r,label:t,labelLayer:n,labelContent:o,style:i,onSelect:s,onCollapse:a,selected:c=!1}){const l=r.x2-r.x1,d=r.y2-r.y1,u=i.borderWidth,h=i.borderStyle==="dashed"?`${u*4} ${u*2}`:i.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+l/2,m=i.labelPosition==="top"?r.y1+i.labelMargin-i.fontSize/2:i.labelPosition==="bottom"?r.y2-i.labelMargin+i.fontSize/2:r.y1+d/2,y=t?yo(t,`bold ${i.fontSize}px ${hr}`):0,g=i.fontSize/5,b=t||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+y/2+g+8,y:m-24,width:48,height:48,"data-flow-content-toggle":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(Ue,{label:"Show icon",children:f.jsx(Ne,{"aria-label":"Show icon",icon:f.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:i.textColor},onClick:v=>{v.stopPropagation(),a(e)}})})}),o?f.jsx("foreignObject",{x:p-y/2-g,y:m-i.fontSize/2-g,width:y+2*g,height:i.fontSize+2*g,style:{overflow:"visible"},onClick:Ku,children:o}):t&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-y/2-g,y:m-i.fontSize/2-g,width:y+2*g,height:i.fontSize+2*g,fill:i.textColor==="transparent"?"transparent":i.labelBg}),f.jsx("text",{x:p,y:m,fill:i.textColor,fontSize:i.fontSize,fontWeight:"bold",fontFamily:hr,style:{fontSize:i.fontSize,fontWeight:"bold",fontFamily:hr},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:Ku,onClick:v=>{v.stopPropagation(),s==null||s(e,{shiftKey:v.shiftKey,ctrlKey:v.ctrlKey,metaKey:v.metaKey,altKey:v.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:l,height:d,rx:i.borderRadius,ry:i.borderRadius,fill:i.bgColor,fillOpacity:i.bgOpacity,stroke:i.borderColor,strokeWidth:i.borderStyle==="double"?u/3:u,strokeDasharray:h}),i.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,l-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,i.borderRadius-u*2/3),ry:Math.max(0,i.borderRadius-u*2/3),fill:"none",stroke:i.borderColor,strokeWidth:u/3}),i.animated&&u>0&&f.jsx(oo,{variant:i.animationVariant,x:r.x1,y:r.y1,width:l,height:d,radius:i.borderRadius,color:i.animationColor||i.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Vr.createPortal(b,n):b]})}const e1=j.memo(Qw),io=45,Vb=70,Er=15,Wb=50;function Gb(e,r,t=io){const n=`${t}px ${hr}`,o=e?Xw(e,n,200*t/io):[],i=r?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(l=>yo(l,n))),a=Math.max(o.length*t,r?48:0),c=o.length||r?2*Er:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const Rn=6,Ub=3,Fd=.3,t1=8,zd=Math.max(Math.pow(Rn*13.37,.9),29)*Ub-t1/Fd,Hb=Rn*Ub*2,Qn=80,r1=2*Qn+zd*Fd+100,n1=36+2*Math.max(80,Hb+zd*Fd);function yd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function md(e,r){return r==="auto"||(r==="properties"?yd(e):!yd(e))}function Yt(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&yd(n))}function o1(e,r,t,n=!1,o){if(!n)return{nodes:e,edges:r};const i=e.filter(a=>Yt(a.id,r,t)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:r.filter(a=>md(a,t)&&s.has(a.source)&&s.has(a.target))}}const i1=500,a1="32 18",s1=e=>e.stopPropagation();function c1({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:l,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:m,targetPort:y,propertyMode:g=!1,dir:b,turn:v,labelAtTarget:x,labelFraction:w,color:C,connectorColor:S,labelBg:_,labelLayer:k,label:E,dashed:O,animated:P,inverted:A,loopIndex:M=0,onSelect:T}){const N=n==null?void 0:n.icon,$=g?io:Vb,{lines:I,iconWidth:W,contentWidth:ie,contentHeight:ae}=j.useMemo(()=>Gb(E,N,$),[E,N,$]),re=j.useMemo(()=>{const je={srcDist:Qn,tgtDist:Qn,arrowGap:Hb,arrowSize:zd,headShape:g&&(A?h!==void 0||m:p!==void 0||y)?"square":"triangle",radius:s??(x?40:i1),arrowAt:A?"source":"target",labelTargetLength:x?ie+2*Er:void 0,labelFraction:x?w:void 0},pe=h!==void 0||p!==void 0||!!m||!!y,fe=Uu(c,l,b,h,p,0),Y=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),H=m??{...fe.sourcePoint,side:Y?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},we=y??{...fe.targetPoint,side:Y?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},J=c.x===l.x&&c.y===l.y,ve=m||y?Hw(H,we,{...je,srcDist:18,tgtDist:18},i):pe?Wu(c,l,b,h,p,v,{...je,srcDist:18,tgtDist:18,radius:s??Math.min(je.radius,40)}):J?Zw(c,M,{...je,srcDist:0,tgtDist:0}):Gu(c,l,b,v,je);if(!ve)return null;const Q=Uu(c,l,b,h,p,pe?18:Qn);m&&(Q.sourcePoint=Fr(m,18)),y&&(Q.targetPoint=Fr(y,18));const Ee=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(Ee){const Ae={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Ee({edge:n??{id:e,source:"",target:""},source:{...c},target:{...l},...Q,direction:Ae[b],sourceY:h,targetY:p,inverted:!!A,defaultGeometry:ve})??ve}return J||m||y?ve:i==="straight"?pe?Bb(Q.sourcePoint,Q.targetPoint,je):zb([c,l],c,l,je):i==="bezier"?Jw(Q.sourcePoint,Q.targetPoint,pe?b==="leftward"?"leftward":"rightward":b,je):i==="orthogonal"?pe?Wu(c,l,b,h,p,v,{...je,srcDist:18,tgtDist:18,radius:0}):Gu(c,l,b,v,{...je,radius:0}):ve},[c,e,n,i,s,a,l,g,h,p,m,y,b,v,A,M,x,w,ie]);if(!re)return null;const ye=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(g&&(h!==void 0||p!==void 0||m||y)),be=ye?`translate(${re.label.x} ${re.label.y-ae/2-2*Er})`:`translate(${re.label.x} ${re.label.y}) rotate(${re.label.angle}) translate(${b==="downward"||b==="upward"||x||Object.prototype.hasOwnProperty.call(a??{},i)?0:Wb} 0)`,L=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",z=o?L:C,G=o?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${re.label.x} ${re.label.y-I.length*$/2-55})`,children:[f.jsx("title",{children:o}),f.jsx(Qt,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:L})]}):null,D=P&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",se=!D&&(O||P)?a1:void 0,X=P&&!D?`flow-sdk-edge-anim${A?" flow-sdk-edge-anim-rev":""}`:void 0;let le=null;const ue=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(I.length||N){const je=ie,pe=ae;le=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:ue,"data-label-transform":be,"data-label-horizontal":ye||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:be,children:[f.jsx("rect",{x:-je/2-Er,y:-pe/2-Er,width:je+2*Er,height:pe+2*Er,fill:C==="transparent"?"transparent":_}),f.jsx("text",{fill:C,fontSize:$,style:{fontSize:$,fontFamily:hr},fontFamily:hr,textAnchor:"middle",dominantBaseline:"central",children:I.map((fe,Y)=>f.jsx("tspan",{x:W/2,y:(Y-(I.length-1)/2)*$,children:fe},Y))}),N&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:E?`Edge icon: ${E}`:"Edge icon"}),f.jsx("rect",{x:-je/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Qt,{name:N,svg:!0,size:48,x:-je/2,y:-24,color:C})]})]})}const Ce=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:re.d,fill:"none",stroke:z,strokeWidth:Rn,strokeOpacity:D?.35:void 0,strokeDasharray:se,className:X}),D&&f.jsx(Fw,{path:re.d,color:z,width:Rn*1.6,reversed:A})]});return f.jsxs("g",{className:"flow-sdk-edge",style:ue,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:s1,onClick:je=>{je.stopPropagation(),T==null||T(e)},children:[r?f.jsx(qw,{path:re.d,width:Rn*4,reversed:A,onComplete:()=>t==null?void 0:t(e),children:Ce}):Ce,re.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:re.arrow,fill:o?L:S??z}),k&&le?Vr.createPortal(le,k):le,k&&G?Vr.createPortal(G,k):G,f.jsx("path",{className:"flow-sdk-edge-hit",d:re.d,fill:"none",stroke:"transparent"})]})}const Ju=j.memo(c1);var Yn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function l1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Bd(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 Wo,Zu;function d1(){if(Zu)return Wo;Zu=1;function e(){this.__data__=[],this.size=0}return Wo=e,Wo}var Go,Yu;function Qr(){if(Yu)return Go;Yu=1;function e(r,t){return r===t||r!==r&&t!==t}return Go=e,Go}var Uo,Xu;function mo(){if(Xu)return Uo;Xu=1;var e=Qr();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return Uo=r,Uo}var Ho,Qu;function u1(){if(Qu)return Ho;Qu=1;var e=mo(),r=Array.prototype,t=r.splice;function n(o){var i=this.__data__,s=e(i,o);if(s<0)return!1;var a=i.length-1;return s==a?i.pop():t.call(i,s,1),--this.size,!0}return Ho=n,Ho}var Ko,ef;function f1(){if(ef)return Ko;ef=1;var e=mo();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return Ko=r,Ko}var Jo,tf;function h1(){if(tf)return Jo;tf=1;var e=mo();function r(t){return e(this.__data__,t)>-1}return Jo=r,Jo}var Zo,rf;function p1(){if(rf)return Zo;rf=1;var e=mo();function r(t,n){var o=this.__data__,i=e(o,t);return i<0?(++this.size,o.push([t,n])):o[i][1]=n,this}return Zo=r,Zo}var Yo,nf;function bo(){if(nf)return Yo;nf=1;var e=d1(),r=u1(),t=f1(),n=h1(),o=p1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Yo=i,Yo}var Xo,of;function g1(){if(of)return Xo;of=1;var e=bo();function r(){this.__data__=new e,this.size=0}return Xo=r,Xo}var Qo,af;function y1(){if(af)return Qo;af=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return Qo=e,Qo}var ei,sf;function m1(){if(sf)return ei;sf=1;function e(r){return this.__data__.get(r)}return ei=e,ei}var ti,cf;function b1(){if(cf)return ti;cf=1;function e(r){return this.__data__.has(r)}return ti=e,ti}var ri,lf;function Kb(){if(lf)return ri;lf=1;var e=typeof Yn=="object"&&Yn&&Yn.Object===Object&&Yn;return ri=e,ri}var ni,df;function Ut(){if(df)return ni;df=1;var e=Kb(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ni=t,ni}var oi,uf;function en(){if(uf)return oi;uf=1;var e=Ut(),r=e.Symbol;return oi=r,oi}var ii,ff;function v1(){if(ff)return ii;ff=1;var e=en(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function i(s){var a=t.call(s,o),c=s[o];try{s[o]=void 0;var l=!0}catch{}var d=n.call(s);return l&&(a?s[o]=c:delete s[o]),d}return ii=i,ii}var ai,hf;function x1(){if(hf)return ai;hf=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return ai=t,ai}var si,pf;function Ir(){if(pf)return si;pf=1;var e=en(),r=v1(),t=x1(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?o:n:i&&i in Object(a)?r(a):t(a)}return si=s,si}var ci,gf;function Lt(){if(gf)return ci;gf=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return ci=e,ci}var li,yf;function qn(){if(yf)return li;yf=1;var e=Ir(),r=Lt(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!r(a))return!1;var c=e(a);return c==n||c==o||c==t||c==i}return li=s,li}var di,mf;function w1(){if(mf)return di;mf=1;var e=Ut(),r=e["__core-js_shared__"];return di=r,di}var ui,bf;function C1(){if(bf)return ui;bf=1;var e=w1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return ui=t,ui}var fi,vf;function Jb(){if(vf)return fi;vf=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return fi=t,fi}var hi,xf;function S1(){if(xf)return hi;xf=1;var e=qn(),r=C1(),t=Lt(),n=Jb(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,l=a.hasOwnProperty,d=RegExp("^"+c.call(l).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:i;return p.test(n(h))}return hi=u,hi}var pi,wf;function j1(){if(wf)return pi;wf=1;function e(r,t){return r==null?void 0:r[t]}return pi=e,pi}var gi,Cf;function Tr(){if(Cf)return gi;Cf=1;var e=S1(),r=j1();function t(n,o){var i=r(n,o);return e(i)?i:void 0}return gi=t,gi}var yi,Sf;function Dd(){if(Sf)return yi;Sf=1;var e=Tr(),r=Ut(),t=e(r,"Map");return yi=t,yi}var mi,jf;function vo(){if(jf)return mi;jf=1;var e=Tr(),r=e(Object,"create");return mi=r,mi}var bi,_f;function _1(){if(_f)return bi;_f=1;var e=vo();function r(){this.__data__=e?e(null):{},this.size=0}return bi=r,bi}var vi,Ef;function E1(){if(Ef)return vi;Ef=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return vi=e,vi}var xi,kf;function k1(){if(kf)return xi;kf=1;var e=vo(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===r?void 0:a}return n.call(s,i)?s[i]:void 0}return xi=o,xi}var wi,Rf;function R1(){if(Rf)return wi;Rf=1;var e=vo(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:t.call(i,o)}return wi=n,wi}var Ci,Af;function A1(){if(Af)return Ci;Af=1;var e=vo(),r="__lodash_hash_undefined__";function t(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?r:o,this}return Ci=t,Ci}var Si,Pf;function P1(){if(Pf)return Si;Pf=1;var e=_1(),r=E1(),t=k1(),n=R1(),o=A1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Si=i,Si}var ji,Mf;function M1(){if(Mf)return ji;Mf=1;var e=P1(),r=bo(),t=Dd();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return ji=n,ji}var _i,If;function I1(){if(If)return _i;If=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return _i=e,_i}var Ei,Tf;function xo(){if(Tf)return Ei;Tf=1;var e=I1();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Ei=r,Ei}var ki,Of;function T1(){if(Of)return ki;Of=1;var e=xo();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return ki=r,ki}var Ri,Nf;function O1(){if(Nf)return Ri;Nf=1;var e=xo();function r(t){return e(this,t).get(t)}return Ri=r,Ri}var Ai,$f;function N1(){if($f)return Ai;$f=1;var e=xo();function r(t){return e(this,t).has(t)}return Ai=r,Ai}var Pi,qf;function $1(){if(qf)return Pi;qf=1;var e=xo();function r(t,n){var o=e(this,t),i=o.size;return o.set(t,n),this.size+=o.size==i?0:1,this}return Pi=r,Pi}var Mi,Lf;function Vd(){if(Lf)return Mi;Lf=1;var e=M1(),r=T1(),t=O1(),n=N1(),o=$1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Mi=i,Mi}var Ii,Ff;function q1(){if(Ff)return Ii;Ff=1;var e=bo(),r=Dd(),t=Vd(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!r||c.length<n-1)return c.push([i,s]),this.size=++a.size,this;a=this.__data__=new t(c)}return a.set(i,s),this.size=a.size,this}return Ii=o,Ii}var Ti,zf;function wo(){if(zf)return Ti;zf=1;var e=bo(),r=g1(),t=y1(),n=m1(),o=b1(),i=q1();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Ti=s,Ti}var Oi,Bf;function Wd(){if(Bf)return Oi;Bf=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Oi=e,Oi}var Ni,Df;function Zb(){if(Df)return Ni;Df=1;var e=Tr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Ni=r,Ni}var $i,Vf;function Co(){if(Vf)return $i;Vf=1;var e=Zb();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return $i=r,$i}var qi,Wf;function So(){if(Wf)return qi;Wf=1;var e=Co(),r=Qr(),t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a){var c=i[s];(!(n.call(i,s)&&r(c,a))||a===void 0&&!(s in i))&&e(i,s,a)}return qi=o,qi}var Li,Gf;function Ln(){if(Gf)return Li;Gf=1;var e=So(),r=Co();function t(n,o,i,s){var a=!i;i||(i={});for(var c=-1,l=o.length;++c<l;){var d=o[c],u=s?s(i[d],n[d],d,i,n):void 0;u===void 0&&(u=n[d]),a?r(i,d,u):e(i,d,u)}return i}return Li=t,Li}var Fi,Uf;function L1(){if(Uf)return Fi;Uf=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Fi=e,Fi}var zi,Hf;function er(){if(Hf)return zi;Hf=1;function e(r){return r!=null&&typeof r=="object"}return zi=e,zi}var Bi,Kf;function F1(){if(Kf)return Bi;Kf=1;var e=Ir(),r=er(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Bi=n,Bi}var Di,Jf;function Fn(){if(Jf)return Di;Jf=1;var e=F1(),r=er(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Di=i,Di}var Vi,Zf;function yt(){if(Zf)return Vi;Zf=1;var e=Array.isArray;return Vi=e,Vi}var mn={exports:{}},Wi,Yf;function z1(){if(Yf)return Wi;Yf=1;function e(){return!1}return Wi=e,Wi}mn.exports;var Xf;function tn(){return Xf||(Xf=1,(function(e,r){var t=Ut(),n=z1(),o=r&&!r.nodeType&&r,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||n;e.exports=l})(mn,mn.exports)),mn.exports}var Gi,Qf;function jo(){if(Qf)return Gi;Qf=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return Gi=t,Gi}var Ui,eh;function Gd(){if(eh)return Ui;eh=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return Ui=r,Ui}var Hi,th;function B1(){if(th)return Hi;th=1;var e=Ir(),r=Gd(),t=er(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",v="[object Float32Array]",x="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",_="[object Uint8Array]",k="[object Uint8ClampedArray]",E="[object Uint16Array]",O="[object Uint32Array]",P={};P[v]=P[x]=P[w]=P[C]=P[S]=P[_]=P[k]=P[E]=P[O]=!0,P[n]=P[o]=P[g]=P[i]=P[b]=P[s]=P[a]=P[c]=P[l]=P[d]=P[u]=P[h]=P[p]=P[m]=P[y]=!1;function A(M){return t(M)&&r(M.length)&&!!P[e(M)]}return Hi=A,Hi}var Ki,rh;function _o(){if(rh)return Ki;rh=1;function e(r){return function(t){return r(t)}}return Ki=e,Ki}var bn={exports:{}};bn.exports;var nh;function Ud(){return nh||(nh=1,(function(e,r){var t=Kb(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&t.process,a=(function(){try{var c=o&&o.require&&o.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(bn,bn.exports)),bn.exports}var Ji,oh;function zn(){if(oh)return Ji;oh=1;var e=B1(),r=_o(),t=Ud(),n=t&&t.isTypedArray,o=n?r(n):e;return Ji=o,Ji}var Zi,ih;function Yb(){if(ih)return Zi;ih=1;var e=L1(),r=Fn(),t=yt(),n=tn(),o=jo(),i=zn(),s=Object.prototype,a=s.hasOwnProperty;function c(l,d){var u=t(l),h=!u&&r(l),p=!u&&!h&&n(l),m=!u&&!h&&!p&&i(l),y=u||h||p||m,g=y?e(l.length,String):[],b=g.length;for(var v in l)(d||a.call(l,v))&&!(y&&(v=="length"||p&&(v=="offset"||v=="parent")||m&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||o(v,b)))&&g.push(v);return g}return Zi=c,Zi}var Yi,ah;function Eo(){if(ah)return Yi;ah=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return Yi=r,Yi}var Xi,sh;function Xb(){if(sh)return Xi;sh=1;function e(r,t){return function(n){return r(t(n))}}return Xi=e,Xi}var Qi,ch;function D1(){if(ch)return Qi;ch=1;var e=Xb(),r=e(Object.keys,Object);return Qi=r,Qi}var ea,lh;function Hd(){if(lh)return ea;lh=1;var e=Eo(),r=D1(),t=Object.prototype,n=t.hasOwnProperty;function o(i){if(!e(i))return r(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return ea=o,ea}var ta,dh;function or(){if(dh)return ta;dh=1;var e=qn(),r=Gd();function t(n){return n!=null&&r(n.length)&&!e(n)}return ta=t,ta}var ra,uh;function xr(){if(uh)return ra;uh=1;var e=Yb(),r=Hd(),t=or();function n(o){return t(o)?e(o):r(o)}return ra=n,ra}var na,fh;function V1(){if(fh)return na;fh=1;var e=Ln(),r=xr();function t(n,o){return n&&e(o,r(o),n)}return na=t,na}var oa,hh;function W1(){if(hh)return oa;hh=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return oa=e,oa}var ia,ph;function G1(){if(ph)return ia;ph=1;var e=Lt(),r=Eo(),t=W1(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=r(s),c=[];for(var l in s)l=="constructor"&&(a||!o.call(s,l))||c.push(l);return c}return ia=i,ia}var aa,gh;function Or(){if(gh)return aa;gh=1;var e=Yb(),r=G1(),t=or();function n(o){return t(o)?e(o,!0):r(o)}return aa=n,aa}var sa,yh;function U1(){if(yh)return sa;yh=1;var e=Ln(),r=Or();function t(n,o){return n&&e(o,r(o),n)}return sa=t,sa}var vn={exports:{}};vn.exports;var mh;function Qb(){return mh||(mh=1,(function(e,r){var t=Ut(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,d){if(d)return l.slice();var u=l.length,h=a?a(u):new l.constructor(u);return l.copy(h),h}e.exports=c})(vn,vn.exports)),vn.exports}var ca,bh;function ev(){if(bh)return ca;bh=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return ca=e,ca}var la,vh;function tv(){if(vh)return la;vh=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=0,s=[];++n<o;){var a=r[n];t(a,n,r)&&(s[i++]=a)}return s}return la=e,la}var da,xh;function rv(){if(xh)return da;xh=1;function e(){return[]}return da=e,da}var ua,wh;function Kd(){if(wh)return ua;wh=1;var e=tv(),r=rv(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:r;return ua=i,ua}var fa,Ch;function H1(){if(Ch)return fa;Ch=1;var e=Ln(),r=Kd();function t(n,o){return e(n,r(n),o)}return fa=t,fa}var ha,Sh;function Jd(){if(Sh)return ha;Sh=1;function e(r,t){for(var n=-1,o=t.length,i=r.length;++n<o;)r[i+n]=t[n];return r}return ha=e,ha}var pa,jh;function ko(){if(jh)return pa;jh=1;var e=Xb(),r=e(Object.getPrototypeOf,Object);return pa=r,pa}var ga,_h;function nv(){if(_h)return ga;_h=1;var e=Jd(),r=ko(),t=Kd(),n=rv(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return ga=i,ga}var ya,Eh;function K1(){if(Eh)return ya;Eh=1;var e=Ln(),r=nv();function t(n,o){return e(n,r(n),o)}return ya=t,ya}var ma,kh;function ov(){if(kh)return ma;kh=1;var e=Jd(),r=yt();function t(n,o,i){var s=o(n);return r(n)?s:e(s,i(n))}return ma=t,ma}var ba,Rh;function iv(){if(Rh)return ba;Rh=1;var e=ov(),r=Kd(),t=xr();function n(o){return e(o,t,r)}return ba=n,ba}var va,Ah;function J1(){if(Ah)return va;Ah=1;var e=ov(),r=nv(),t=Or();function n(o){return e(o,t,r)}return va=n,va}var xa,Ph;function Z1(){if(Ph)return xa;Ph=1;var e=Tr(),r=Ut(),t=e(r,"DataView");return xa=t,xa}var wa,Mh;function Y1(){if(Mh)return wa;Mh=1;var e=Tr(),r=Ut(),t=e(r,"Promise");return wa=t,wa}var Ca,Ih;function av(){if(Ih)return Ca;Ih=1;var e=Tr(),r=Ut(),t=e(r,"Set");return Ca=t,Ca}var Sa,Th;function X1(){if(Th)return Sa;Th=1;var e=Tr(),r=Ut(),t=e(r,"WeakMap");return Sa=t,Sa}var ja,Oh;function rn(){if(Oh)return ja;Oh=1;var e=Z1(),r=Dd(),t=Y1(),n=av(),o=X1(),i=Ir(),s=Jb(),a="[object Map]",c="[object Object]",l="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),m=s(r),y=s(t),g=s(n),b=s(o),v=i;return(e&&v(new e(new ArrayBuffer(1)))!=h||r&&v(new r)!=a||t&&v(t.resolve())!=l||n&&v(new n)!=d||o&&v(new o)!=u)&&(v=function(x){var w=i(x),C=w==c?x.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case m:return a;case y:return l;case g:return d;case b:return u}return w}),ja=v,ja}var _a,Nh;function Q1(){if(Nh)return _a;Nh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return _a=t,_a}var Ea,$h;function sv(){if($h)return Ea;$h=1;var e=Ut(),r=e.Uint8Array;return Ea=r,Ea}var ka,qh;function Zd(){if(qh)return ka;qh=1;var e=sv();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return ka=r,ka}var Ra,Lh;function eC(){if(Lh)return Ra;Lh=1;var e=Zd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Ra=r,Ra}var Aa,Fh;function tC(){if(Fh)return Aa;Fh=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Aa=r,Aa}var Pa,zh;function rC(){if(zh)return Pa;zh=1;var e=en(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Pa=n,Pa}var Ma,Bh;function cv(){if(Bh)return Ma;Bh=1;var e=Zd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Ma=r,Ma}var Ia,Dh;function nC(){if(Dh)return Ia;Dh=1;var e=Zd(),r=eC(),t=tC(),n=rC(),o=cv(),i="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",l="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",y="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",v="[object Int16Array]",x="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",_="[object Uint32Array]";function k(E,O,P){var A=E.constructor;switch(O){case p:return e(E);case i:case s:return new A(+E);case m:return r(E,P);case y:case g:case b:case v:case x:case w:case C:case S:case _:return o(E,P);case a:return new A;case c:case u:return new A(E);case l:return t(E);case d:return new A;case h:return n(E)}}return Ia=k,Ia}var Ta,Vh;function lv(){if(Vh)return Ta;Vh=1;var e=Lt(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Ta=t,Ta}var Oa,Wh;function dv(){if(Wh)return Oa;Wh=1;var e=lv(),r=ko(),t=Eo();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return Oa=n,Oa}var Na,Gh;function oC(){if(Gh)return Na;Gh=1;var e=rn(),r=er(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return Na=n,Na}var $a,Uh;function iC(){if(Uh)return $a;Uh=1;var e=oC(),r=_o(),t=Ud(),n=t&&t.isMap,o=n?r(n):e;return $a=o,$a}var qa,Hh;function aC(){if(Hh)return qa;Hh=1;var e=rn(),r=er(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return qa=n,qa}var La,Kh;function sC(){if(Kh)return La;Kh=1;var e=aC(),r=_o(),t=Ud(),n=t&&t.isSet,o=n?r(n):e;return La=o,La}var Fa,Jh;function uv(){if(Jh)return Fa;Jh=1;var e=wo(),r=Wd(),t=So(),n=V1(),o=U1(),i=Qb(),s=ev(),a=H1(),c=K1(),l=iv(),d=J1(),u=rn(),h=Q1(),p=nC(),m=dv(),y=yt(),g=tn(),b=iC(),v=Lt(),x=sC(),w=xr(),C=Or(),S=1,_=2,k=4,E="[object Arguments]",O="[object Array]",P="[object Boolean]",A="[object Date]",M="[object Error]",T="[object Function]",N="[object GeneratorFunction]",$="[object Map]",I="[object Number]",W="[object Object]",ie="[object RegExp]",ae="[object Set]",re="[object String]",ye="[object Symbol]",be="[object WeakMap]",L="[object ArrayBuffer]",z="[object DataView]",G="[object Float32Array]",D="[object Float64Array]",se="[object Int8Array]",X="[object Int16Array]",le="[object Int32Array]",ue="[object Uint8Array]",Ce="[object Uint8ClampedArray]",je="[object Uint16Array]",pe="[object Uint32Array]",fe={};fe[E]=fe[O]=fe[L]=fe[z]=fe[P]=fe[A]=fe[G]=fe[D]=fe[se]=fe[X]=fe[le]=fe[$]=fe[I]=fe[W]=fe[ie]=fe[ae]=fe[re]=fe[ye]=fe[ue]=fe[Ce]=fe[je]=fe[pe]=!0,fe[M]=fe[T]=fe[be]=!1;function Y(H,we,J,ve,Q,Ee){var Ae,qe=we&S,Je=we&_,Fe=we&k;if(J&&(Ae=Q?J(H,ve,Q,Ee):J(H)),Ae!==void 0)return Ae;if(!v(H))return H;var ct=y(H);if(ct){if(Ae=h(H),!qe)return s(H,Ae)}else{var De=u(H),rt=De==T||De==N;if(g(H))return i(H,qe);if(De==W||De==E||rt&&!Q){if(Ae=Je||rt?{}:m(H),!qe)return Je?c(H,o(Ae,H)):a(H,n(Ae,H))}else{if(!fe[De])return Q?H:{};Ae=p(H,De,qe)}}Ee||(Ee=new e);var ft=Ee.get(H);if(ft)return ft;Ee.set(H,Ae),x(H)?H.forEach(function(nt){Ae.add(Y(nt,we,J,nt,H,Ee))}):b(H)&&H.forEach(function(nt,lt){Ae.set(lt,Y(nt,we,J,lt,H,Ee))});var Oe=Fe?Je?d:l:Je?C:w,Xe=ct?void 0:Oe(H);return r(Xe||H,function(nt,lt){Xe&&(lt=nt,nt=H[lt]),t(Ae,lt,Y(nt,we,J,lt,H,Ee))}),Ae}return Fa=Y,Fa}var za,Zh;function cC(){if(Zh)return za;Zh=1;var e=uv(),r=4;function t(n){return e(n,r)}return za=t,za}var Ba,Yh;function Yd(){if(Yh)return Ba;Yh=1;function e(r){return function(){return r}}return Ba=e,Ba}var Da,Xh;function lC(){if(Xh)return Da;Xh=1;function e(r){return function(t,n,o){for(var i=-1,s=Object(t),a=o(t),c=a.length;c--;){var l=a[r?c:++i];if(n(s[l],l,s)===!1)break}return t}}return Da=e,Da}var Va,Qh;function Xd(){if(Qh)return Va;Qh=1;var e=lC(),r=e();return Va=r,Va}var Wa,ep;function Qd(){if(ep)return Wa;ep=1;var e=Xd(),r=xr();function t(n,o){return n&&e(n,o,r)}return Wa=t,Wa}var Ga,tp;function dC(){if(tp)return Ga;tp=1;var e=or();function r(t,n){return function(o,i){if(o==null)return o;if(!e(o))return t(o,i);for(var s=o.length,a=n?s:-1,c=Object(o);(n?a--:++a<s)&&i(c[a],a,c)!==!1;);return o}}return Ga=r,Ga}var Ua,rp;function Ro(){if(rp)return Ua;rp=1;var e=Qd(),r=dC(),t=r(e);return Ua=t,Ua}var Ha,np;function Nr(){if(np)return Ha;np=1;function e(r){return r}return Ha=e,Ha}var Ka,op;function fv(){if(op)return Ka;op=1;var e=Nr();function r(t){return typeof t=="function"?t:e}return Ka=r,Ka}var Ja,ip;function hv(){if(ip)return Ja;ip=1;var e=Wd(),r=Ro(),t=fv(),n=yt();function o(i,s){var a=n(i)?e:r;return a(i,t(s))}return Ja=o,Ja}var Za,ap;function pv(){return ap||(ap=1,Za=hv()),Za}var Ya,sp;function uC(){if(sp)return Ya;sp=1;var e=Ro();function r(t,n){var o=[];return e(t,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return Ya=r,Ya}var Xa,cp;function fC(){if(cp)return Xa;cp=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return Xa=r,Xa}var Qa,lp;function hC(){if(lp)return Qa;lp=1;function e(r){return this.__data__.has(r)}return Qa=e,Qa}var es,dp;function gv(){if(dp)return es;dp=1;var e=Vd(),r=fC(),t=hC();function n(o){var i=-1,s=o==null?0:o.length;for(this.__data__=new e;++i<s;)this.add(o[i])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,es=n,es}var ts,up;function pC(){if(up)return ts;up=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return ts=e,ts}var rs,fp;function yv(){if(fp)return rs;fp=1;function e(r,t){return r.has(t)}return rs=e,rs}var ns,hp;function mv(){if(hp)return ns;hp=1;var e=gv(),r=pC(),t=yv(),n=1,o=2;function i(s,a,c,l,d,u){var h=c&n,p=s.length,m=a.length;if(p!=m&&!(h&&m>p))return!1;var y=u.get(s),g=u.get(a);if(y&&g)return y==a&&g==s;var b=-1,v=!0,x=c&o?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var w=s[b],C=a[b];if(l)var S=h?l(C,w,b,a,s,u):l(w,C,b,s,a,u);if(S!==void 0){if(S)continue;v=!1;break}if(x){if(!r(a,function(_,k){if(!t(x,k)&&(w===_||d(w,_,c,l,u)))return x.push(k)})){v=!1;break}}else if(!(w===C||d(w,C,c,l,u))){v=!1;break}}return u.delete(s),u.delete(a),v}return ns=i,ns}var os,pp;function gC(){if(pp)return os;pp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,i){n[++t]=[i,o]}),n}return os=e,os}var is,gp;function eu(){if(gp)return is;gp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return is=e,is}var as,yp;function yC(){if(yp)return as;yp=1;var e=en(),r=sv(),t=Qr(),n=mv(),o=gC(),i=eu(),s=1,a=2,c="[object Boolean]",l="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",y="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",v="[object DataView]",x=e?e.prototype:void 0,w=x?x.valueOf:void 0;function C(S,_,k,E,O,P,A){switch(k){case v:if(S.byteLength!=_.byteLength||S.byteOffset!=_.byteOffset)return!1;S=S.buffer,_=_.buffer;case b:return!(S.byteLength!=_.byteLength||!P(new r(S),new r(_)));case c:case l:case h:return t(+S,+_);case d:return S.name==_.name&&S.message==_.message;case p:case y:return S==_+"";case u:var M=o;case m:var T=E&s;if(M||(M=i),S.size!=_.size&&!T)return!1;var N=A.get(S);if(N)return N==_;E|=a,A.set(S,_);var $=n(M(S),M(_),E,O,P,A);return A.delete(S),$;case g:if(w)return w.call(S)==w.call(_)}return!1}return as=C,as}var ss,mp;function mC(){if(mp)return ss;mp=1;var e=iv(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a,c,l,d){var u=a&r,h=e(i),p=h.length,m=e(s),y=m.length;if(p!=y&&!u)return!1;for(var g=p;g--;){var b=h[g];if(!(u?b in s:n.call(s,b)))return!1}var v=d.get(i),x=d.get(s);if(v&&x)return v==s&&x==i;var w=!0;d.set(i,s),d.set(s,i);for(var C=u;++g<p;){b=h[g];var S=i[b],_=s[b];if(c)var k=u?c(_,S,b,s,i,d):c(S,_,b,i,s,d);if(!(k===void 0?S===_||l(S,_,a,c,d):k)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var E=i.constructor,O=s.constructor;E!=O&&"constructor"in i&&"constructor"in s&&!(typeof E=="function"&&E instanceof E&&typeof O=="function"&&O instanceof O)&&(w=!1)}return d.delete(i),d.delete(s),w}return ss=o,ss}var cs,bp;function bC(){if(bp)return cs;bp=1;var e=wo(),r=mv(),t=yC(),n=mC(),o=rn(),i=yt(),s=tn(),a=zn(),c=1,l="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(y,g,b,v,x,w){var C=i(y),S=i(g),_=C?d:o(y),k=S?d:o(g);_=_==l?u:_,k=k==l?u:k;var E=_==u,O=k==u,P=_==k;if(P&&s(y)){if(!s(g))return!1;C=!0,E=!1}if(P&&!E)return w||(w=new e),C||a(y)?r(y,g,b,v,x,w):t(y,g,_,b,v,x,w);if(!(b&c)){var A=E&&p.call(y,"__wrapped__"),M=O&&p.call(g,"__wrapped__");if(A||M){var T=A?y.value():y,N=M?g.value():g;return w||(w=new e),x(T,N,b,v,w)}}return P?(w||(w=new e),n(y,g,b,v,x,w)):!1}return cs=m,cs}var ls,vp;function bv(){if(vp)return ls;vp=1;var e=bC(),r=er();function t(n,o,i,s,a){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,i,s,t,a)}return ls=t,ls}var ds,xp;function vC(){if(xp)return ds;xp=1;var e=wo(),r=bv(),t=1,n=2;function o(i,s,a,c){var l=a.length,d=l,u=!c;if(i==null)return!d;for(i=Object(i);l--;){var h=a[l];if(u&&h[2]?h[1]!==i[h[0]]:!(h[0]in i))return!1}for(;++l<d;){h=a[l];var p=h[0],m=i[p],y=h[1];if(u&&h[2]){if(m===void 0&&!(p in i))return!1}else{var g=new e;if(c)var b=c(m,y,p,i,s,g);if(!(b===void 0?r(y,m,t|n,c,g):b))return!1}}return!0}return ds=o,ds}var us,wp;function vv(){if(wp)return us;wp=1;var e=Lt();function r(t){return t===t&&!e(t)}return us=r,us}var fs,Cp;function xC(){if(Cp)return fs;Cp=1;var e=vv(),r=xr();function t(n){for(var o=r(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return fs=t,fs}var hs,Sp;function xv(){if(Sp)return hs;Sp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return hs=e,hs}var ps,jp;function wC(){if(jp)return ps;jp=1;var e=vC(),r=xC(),t=xv();function n(o){var i=r(o);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return ps=n,ps}var gs,_p;function nn(){if(_p)return gs;_p=1;var e=Ir(),r=er(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return gs=n,gs}var ys,Ep;function tu(){if(Ep)return ys;Ep=1;var e=yt(),r=nn(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,s){if(e(i))return!1;var a=typeof i;return a=="number"||a=="symbol"||a=="boolean"||i==null||r(i)?!0:n.test(i)||!t.test(i)||s!=null&&i in Object(s)}return ys=o,ys}var ms,kp;function CC(){if(kp)return ms;kp=1;var e=Vd(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],c=i.cache;if(c.has(a))return c.get(a);var l=n.apply(this,s);return i.cache=c.set(a,l)||c,l};return i.cache=new(t.Cache||e),i}return t.Cache=e,ms=t,ms}var bs,Rp;function SC(){if(Rp)return bs;Rp=1;var e=CC(),r=500;function t(n){var o=e(n,function(s){return i.size===r&&i.clear(),s}),i=o.cache;return o}return bs=t,bs}var vs,Ap;function jC(){if(Ap)return vs;Ap=1;var e=SC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(r,function(s,a,c,l){i.push(c?l.replace(t,"$1"):a||s)}),i});return vs=n,vs}var xs,Pp;function Ao(){if(Pp)return xs;Pp=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=Array(o);++n<o;)i[n]=t(r[n],n,r);return i}return xs=e,xs}var ws,Mp;function _C(){if(Mp)return ws;Mp=1;var e=en(),r=Ao(),t=yt(),n=nn(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return i?i.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return ws=s,ws}var Cs,Ip;function wv(){if(Ip)return Cs;Ip=1;var e=_C();function r(t){return t==null?"":e(t)}return Cs=r,Cs}var Ss,Tp;function Po(){if(Tp)return Ss;Tp=1;var e=yt(),r=tu(),t=jC(),n=wv();function o(i,s){return e(i)?i:r(i,s)?[i]:t(n(i))}return Ss=o,Ss}var js,Op;function Bn(){if(Op)return js;Op=1;var e=nn();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return js=r,js}var _s,Np;function Mo(){if(Np)return _s;Np=1;var e=Po(),r=Bn();function t(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[r(o[i++])];return i&&i==s?n:void 0}return _s=t,_s}var Es,$p;function EC(){if($p)return Es;$p=1;var e=Mo();function r(t,n,o){var i=t==null?void 0:e(t,n);return i===void 0?o:i}return Es=r,Es}var ks,qp;function kC(){if(qp)return ks;qp=1;function e(r,t){return r!=null&&t in Object(r)}return ks=e,ks}var Rs,Lp;function Cv(){if(Lp)return Rs;Lp=1;var e=Po(),r=Fn(),t=yt(),n=jo(),o=Gd(),i=Bn();function s(a,c,l){c=e(c,a);for(var d=-1,u=c.length,h=!1;++d<u;){var p=i(c[d]);if(!(h=a!=null&&l(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&o(u)&&n(p,u)&&(t(a)||r(a)))}return Rs=s,Rs}var As,Fp;function Sv(){if(Fp)return As;Fp=1;var e=kC(),r=Cv();function t(n,o){return n!=null&&r(n,o,e)}return As=t,As}var Ps,zp;function RC(){if(zp)return Ps;zp=1;var e=bv(),r=EC(),t=Sv(),n=tu(),o=vv(),i=xv(),s=Bn(),a=1,c=2;function l(d,u){return n(d)&&o(u)?i(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|c)}}return Ps=l,Ps}var Ms,Bp;function jv(){if(Bp)return Ms;Bp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Ms=e,Ms}var Is,Dp;function AC(){if(Dp)return Is;Dp=1;var e=Mo();function r(t){return function(n){return e(n,t)}}return Is=r,Is}var Ts,Vp;function PC(){if(Vp)return Ts;Vp=1;var e=jv(),r=AC(),t=tu(),n=Bn();function o(i){return t(i)?e(n(i)):r(i)}return Ts=o,Ts}var Os,Wp;function ir(){if(Wp)return Os;Wp=1;var e=wC(),r=RC(),t=Nr(),n=yt(),o=PC();function i(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):o(s)}return Os=i,Os}var Ns,Gp;function _v(){if(Gp)return Ns;Gp=1;var e=tv(),r=uC(),t=ir(),n=yt();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Ns=o,Ns}var $s,Up;function MC(){if(Up)return $s;Up=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return $s=t,$s}var qs,Hp;function Ev(){if(Hp)return qs;Hp=1;var e=MC(),r=Cv();function t(n,o){return n!=null&&r(n,o,e)}return qs=t,qs}var Ls,Kp;function IC(){if(Kp)return Ls;Kp=1;var e=Hd(),r=rn(),t=Fn(),n=yt(),o=or(),i=tn(),s=Eo(),a=zn(),c="[object Map]",l="[object Set]",d=Object.prototype,u=d.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||t(p)))return!p.length;var m=r(p);if(m==c||m==l)return!p.size;if(s(p))return!e(p).length;for(var y in p)if(u.call(p,y))return!1;return!0}return Ls=h,Ls}var Fs,Jp;function kv(){if(Jp)return Fs;Jp=1;function e(r){return r===void 0}return Fs=e,Fs}var zs,Zp;function Rv(){if(Zp)return zs;Zp=1;var e=Ro(),r=or();function t(n,o){var i=-1,s=r(n)?Array(n.length):[];return e(n,function(a,c,l){s[++i]=o(a,c,l)}),s}return zs=t,zs}var Bs,Yp;function Av(){if(Yp)return Bs;Yp=1;var e=Ao(),r=ir(),t=Rv(),n=yt();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Bs=o,Bs}var Ds,Xp;function TC(){if(Xp)return Ds;Xp=1;function e(r,t,n,o){var i=-1,s=r==null?0:r.length;for(o&&s&&(n=r[++i]);++i<s;)n=t(n,r[i],i,r);return n}return Ds=e,Ds}var Vs,Qp;function OC(){if(Qp)return Vs;Qp=1;function e(r,t,n,o,i){return i(r,function(s,a,c){n=o?(o=!1,s):t(n,s,a,c)}),n}return Vs=e,Vs}var Ws,eg;function Pv(){if(eg)return Ws;eg=1;var e=TC(),r=Ro(),t=ir(),n=OC(),o=yt();function i(s,a,c){var l=o(s)?e:n,d=arguments.length<3;return l(s,t(a,4),c,d,r)}return Ws=i,Ws}var Gs,tg;function NC(){if(tg)return Gs;tg=1;var e=Ir(),r=yt(),t=er(),n="[object String]";function o(i){return typeof i=="string"||!r(i)&&t(i)&&e(i)==n}return Gs=o,Gs}var Us,rg;function $C(){if(rg)return Us;rg=1;var e=jv(),r=e("length");return Us=r,Us}var Hs,ng;function qC(){if(ng)return Hs;ng=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function c(l){return a.test(l)}return Hs=c,Hs}var Ks,og;function LC(){if(og)return Ks;og=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+a+"|"+c+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=l+"?",y="["+i+"]?",g="(?:"+p+"(?:"+[d,u,h].join("|")+")"+y+m+")*",b=y+m+g,v="(?:"+[d+a+"?",a,u,h,s].join("|")+")",x=RegExp(c+"(?="+c+")|"+v+b,"g");function w(C){for(var S=x.lastIndex=0;x.test(C);)++S;return S}return Ks=w,Ks}var Js,ig;function FC(){if(ig)return Js;ig=1;var e=$C(),r=qC(),t=LC();function n(o){return r(o)?t(o):e(o)}return Js=n,Js}var Zs,ag;function zC(){if(ag)return Zs;ag=1;var e=Hd(),r=rn(),t=or(),n=NC(),o=FC(),i="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(t(c))return n(c)?o(c):c.length;var l=r(c);return l==i||l==s?c.size:e(c).length}return Zs=a,Zs}var Ys,sg;function BC(){if(sg)return Ys;sg=1;var e=Wd(),r=lv(),t=Qd(),n=ir(),o=ko(),i=yt(),s=tn(),a=qn(),c=Lt(),l=zn();function d(u,h,p){var m=i(u),y=m||s(u)||l(u);if(h=n(h,4),p==null){var g=u&&u.constructor;y?p=m?new g:[]:c(u)?p=a(g)?r(o(u)):{}:p={}}return(y?e:t)(u,function(b,v,x){return h(p,b,v,x)}),p}return Ys=d,Ys}var Xs,cg;function DC(){if(cg)return Xs;cg=1;var e=en(),r=Fn(),t=yt(),n=e?e.isConcatSpreadable:void 0;function o(i){return t(i)||r(i)||!!(n&&i&&i[n])}return Xs=o,Xs}var Qs,lg;function ru(){if(lg)return Qs;lg=1;var e=Jd(),r=DC();function t(n,o,i,s,a){var c=-1,l=n.length;for(i||(i=r),a||(a=[]);++c<l;){var d=n[c];o>0&&i(d)?o>1?t(d,o-1,i,s,a):e(a,d):s||(a[a.length]=d)}return a}return Qs=t,Qs}var ec,dg;function VC(){if(dg)return ec;dg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return ec=e,ec}var tc,ug;function Mv(){if(ug)return tc;ug=1;var e=VC(),r=Math.max;function t(n,o,i){return o=r(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,c=r(s.length-o,0),l=Array(c);++a<c;)l[a]=s[o+a];a=-1;for(var d=Array(o+1);++a<o;)d[a]=s[a];return d[o]=i(l),e(n,this,d)}}return tc=t,tc}var rc,fg;function WC(){if(fg)return rc;fg=1;var e=Yd(),r=Zb(),t=Nr(),n=r?function(o,i){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:t;return rc=n,rc}var nc,hg;function GC(){if(hg)return nc;hg=1;var e=800,r=16,t=Date.now;function n(o){var i=0,s=0;return function(){var a=t(),c=r-(a-s);if(s=a,c>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return nc=n,nc}var oc,pg;function Iv(){if(pg)return oc;pg=1;var e=WC(),r=GC(),t=r(e);return oc=t,oc}var ic,gg;function Io(){if(gg)return ic;gg=1;var e=Nr(),r=Mv(),t=Iv();function n(o,i){return t(r(o,i,e),o+"")}return ic=n,ic}var ac,yg;function Tv(){if(yg)return ac;yg=1;function e(r,t,n,o){for(var i=r.length,s=n+(o?1:-1);o?s--:++s<i;)if(t(r[s],s,r))return s;return-1}return ac=e,ac}var sc,mg;function UC(){if(mg)return sc;mg=1;function e(r){return r!==r}return sc=e,sc}var cc,bg;function HC(){if(bg)return cc;bg=1;function e(r,t,n){for(var o=n-1,i=r.length;++o<i;)if(r[o]===t)return o;return-1}return cc=e,cc}var lc,vg;function KC(){if(vg)return lc;vg=1;var e=Tv(),r=UC(),t=HC();function n(o,i,s){return i===i?t(o,i,s):e(o,r,s)}return lc=n,lc}var dc,xg;function JC(){if(xg)return dc;xg=1;var e=KC();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return dc=r,dc}var uc,wg;function ZC(){if(wg)return uc;wg=1;function e(r,t,n){for(var o=-1,i=r==null?0:r.length;++o<i;)if(n(t,r[o]))return!0;return!1}return uc=e,uc}var fc,Cg;function YC(){if(Cg)return fc;Cg=1;function e(){}return fc=e,fc}var hc,Sg;function XC(){if(Sg)return hc;Sg=1;var e=av(),r=YC(),t=eu(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(i){return new e(i)}:r;return hc=o,hc}var pc,jg;function QC(){if(jg)return pc;jg=1;var e=gv(),r=JC(),t=ZC(),n=yv(),o=XC(),i=eu(),s=200;function a(c,l,d){var u=-1,h=r,p=c.length,m=!0,y=[],g=y;if(d)m=!1,h=t;else if(p>=s){var b=l?null:o(c);if(b)return i(b);m=!1,h=n,g=new e}else g=l?[]:y;e:for(;++u<p;){var v=c[u],x=l?l(v):v;if(v=d||v!==0?v:0,m&&x===x){for(var w=g.length;w--;)if(g[w]===x)continue e;l&&g.push(x),y.push(v)}else h(g,x,d)||(g!==y&&g.push(x),y.push(v))}return y}return pc=a,pc}var gc,_g;function Ov(){if(_g)return gc;_g=1;var e=or(),r=er();function t(n){return r(n)&&e(n)}return gc=t,gc}var yc,Eg;function eS(){if(Eg)return yc;Eg=1;var e=ru(),r=Io(),t=QC(),n=Ov(),o=r(function(i){return t(e(i,1,n,!0))});return yc=o,yc}var mc,kg;function tS(){if(kg)return mc;kg=1;var e=Ao();function r(t,n){return e(n,function(o){return t[o]})}return mc=r,mc}var bc,Rg;function Nv(){if(Rg)return bc;Rg=1;var e=tS(),r=xr();function t(n){return n==null?[]:e(n,r(n))}return bc=t,bc}var vc,Ag;function Ft(){if(Ag)return vc;Ag=1;var e;if(typeof Bd=="function")try{e={clone:cC(),constant:Yd(),each:pv(),filter:_v(),has:Ev(),isArray:yt(),isEmpty:IC(),isFunction:qn(),isUndefined:kv(),keys:xr(),map:Av(),reduce:Pv(),size:zC(),transform:BC(),union:eS(),values:Nv()}}catch{}return e||(e=window._),vc=e,vc}var xc,Pg;function nu(){if(Pg)return xc;Pg=1;var e=Ft();xc=o;var r="\0",t="\0",n="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},o.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(m){h.length>1?p.setNode(m,u):p.setNode(m)}),this},o.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},o.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},o.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},o.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},o.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(y,g){d(g)&&u.setNode(g,y)}),e.each(this._edgeObjs,function(y){u.hasNode(y.v)&&u.hasNode(y.w)&&u.setEdge(y,h.edge(y))});var p={};function m(y){var g=h.parent(y);return g===void 0||u.hasNode(g)?(p[y]=g,g):g in p?p[g]:m(g)}return this._isCompound&&e.each(u.nodes(),function(y){u.setParent(y,m(y))}),u},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(m,y){return p.length>1?h.setEdge(m,y,u):h.setEdge(m,y),y}),this},o.prototype.setEdge=function(){var d,u,h,p,m=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,u=y.w,h=y.name,arguments.length===2&&(p=arguments[1],m=!0)):(d=y,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,d,u,h);if(e.has(this._edgeLabels,g))return m&&(this._edgeLabels[g]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(u),this._edgeLabels[g]=m?p:this._defaultEdgeLabelFn(d,u,h);var b=c(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[g]=b,i(this._preds[u],d),i(this._sucs[d],u),this._in[u][g]=b,this._out[d][g]=b,this._edgeCount++,this},o.prototype.edge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},o.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),m=this._edgeObjs[p];return m&&(d=m.v,u=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},o.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.v===u}):p}},o.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.w===u}):p}},o.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function i(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var m=""+u,y=""+h;if(!d&&m>y){var g=m;m=y,y=g}return m+n+y+n+(e.isUndefined(p)?r:p)}function c(d,u,h,p){var m=""+u,y=""+h;if(!d&&m>y){var g=m;m=y,y=g}var b={v:m,w:y};return p&&(b.name=p),b}function l(d,u){return a(d,u.v,u.w,u.name)}return xc}var wc,Mg;function rS(){return Mg||(Mg=1,wc="2.1.8"),wc}var Cc,Ig;function nS(){return Ig||(Ig=1,Cc={Graph:nu(),version:rS()}),Cc}var Sc,Tg;function oS(){if(Tg)return Sc;Tg=1;var e=Ft(),r=nu();Sc={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:o(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),l=s.parent(a),d={v:a};return e.isUndefined(c)||(d.value=c),e.isUndefined(l)||(d.parent=l),d})}function o(s){return e.map(s.edges(),function(a){var c=s.edge(a),l={v:a.v,w:a.w};return e.isUndefined(a.name)||(l.name=a.name),e.isUndefined(c)||(l.value=c),l})}function i(s){var a=new r(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Sc}var jc,Og;function iS(){if(Og)return jc;Og=1;var e=Ft();jc=r;function r(t){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return jc}var _c,Ng;function $v(){if(Ng)return _c;Ng=1;var e=Ft();_c=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var o=this._keyIndices;if(t=String(t),!e.has(o,t)){var i=this._arr,s=i.length;return o[t]=s,i.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,i=o+1,s=t;o<n.length&&(s=n[o].priority<n[s].priority?o:s,i<n.length&&(s=n[i].priority<n[s].priority?i:s),s!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,i;t!==0&&(i=t>>1,!(n[i].priority<o));)this._swap(t,i),t=i},r.prototype._swap=function(t,n){var o=this._arr,i=this._keyIndices,s=o[t],a=o[n];o[t]=a,o[n]=s,i[a.key]=t,i[s.key]=n},_c}var Ec,$g;function qv(){if($g)return Ec;$g=1;var e=Ft(),r=$v();Ec=n;var t=e.constant(1);function n(i,s,a,c){return o(i,String(s),a||t,c||function(l){return i.outEdges(l)})}function o(i,s,a,c){var l={},d=new r,u,h,p=function(m){var y=m.v!==u?m.v:m.w,g=l[y],b=a(m),v=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+b);v<g.distance&&(g.distance=v,g.predecessor=u,d.decrease(y,v))};for(i.nodes().forEach(function(m){var y=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:y},d.add(m,y)});d.size()>0&&(u=d.removeMin(),h=l[u],h.distance!==Number.POSITIVE_INFINITY);)c(u).forEach(p);return l}return Ec}var kc,qg;function aS(){if(qg)return kc;qg=1;var e=qv(),r=Ft();kc=t;function t(n,o,i){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return kc}var Rc,Lg;function Lv(){if(Lg)return Rc;Lg=1;var e=Ft();Rc=r;function r(t){var n=0,o=[],i={},s=[];function a(c){var l=i[c]={onStack:!0,lowlink:n,index:n++};if(o.push(c),t.successors(c).forEach(function(h){e.has(i,h)?i[h].onStack&&(l.lowlink=Math.min(l.lowlink,i[h].index)):(a(h),l.lowlink=Math.min(l.lowlink,i[h].lowlink))}),l.lowlink===l.index){var d=[],u;do u=o.pop(),i[u].onStack=!1,d.push(u);while(c!==u);s.push(d)}}return t.nodes().forEach(function(c){e.has(i,c)||a(c)}),s}return Rc}var Ac,Fg;function sS(){if(Fg)return Ac;Fg=1;var e=Ft(),r=Lv();Ac=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Ac}var Pc,zg;function cS(){if(zg)return Pc;zg=1;var e=Ft();Pc=t;var r=e.constant(1);function t(o,i,s){return n(o,i||r,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},c=o.nodes();return c.forEach(function(l){a[l]={},a[l][l]={distance:0},c.forEach(function(d){l!==d&&(a[l][d]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(d){var u=d.v===l?d.w:d.v,h=i(d);a[l][u]={distance:h,predecessor:l}})}),c.forEach(function(l){var d=a[l];c.forEach(function(u){var h=a[u];c.forEach(function(p){var m=h[l],y=d[p],g=h[p],b=m.distance+y.distance;b<g.distance&&(g.distance=b,g.predecessor=y.predecessor)})})}),a}return Pc}var Mc,Bg;function Fv(){if(Bg)return Mc;Bg=1;var e=Ft();Mc=r,r.CycleException=t;function r(n){var o={},i={},s=[];function a(c){if(e.has(i,c))throw new t;e.has(o,c)||(i[c]=!0,o[c]=!0,e.each(n.predecessors(c),a),delete i[c],s.push(c))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new t;return s}function t(){}return t.prototype=new Error,Mc}var Ic,Dg;function lS(){if(Dg)return Ic;Dg=1;var e=Fv();Ic=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ic}var Tc,Vg;function zv(){if(Vg)return Tc;Vg=1;var e=Ft();Tc=r;function r(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(o,function(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,i==="post",c,s,a)}),a}function t(n,o,i,s,a,c){e.has(s,o)||(s[o]=!0,i||c.push(o),e.each(a(o),function(l){t(n,l,i,s,a,c)}),i&&c.push(o))}return Tc}var Oc,Wg;function dS(){if(Wg)return Oc;Wg=1;var e=zv();Oc=r;function r(t,n){return e(t,n,"post")}return Oc}var Nc,Gg;function uS(){if(Gg)return Nc;Gg=1;var e=zv();Nc=r;function r(t,n){return e(t,n,"pre")}return Nc}var $c,Ug;function fS(){if(Ug)return $c;Ug=1;var e=Ft(),r=nu(),t=$v();$c=n;function n(o,i){var s=new r,a={},c=new t,l;function d(h){var p=h.v===l?h.w:h.v,m=c.priority(p);if(m!==void 0){var y=i(h);y<m&&(a[p]=l,c.decrease(p,y))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(o.nodes()[0],0);for(var u=!1;c.size()>0;){if(l=c.removeMin(),e.has(a,l))s.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+o);u=!0}o.nodeEdges(l).forEach(d)}return s}return $c}var qc,Hg;function hS(){return Hg||(Hg=1,qc={components:iS(),dijkstra:qv(),dijkstraAll:aS(),findCycles:sS(),floydWarshall:cS(),isAcyclic:lS(),postorder:dS(),preorder:uS(),prim:fS(),tarjan:Lv(),topsort:Fv()}),qc}var Lc,Kg;function pS(){if(Kg)return Lc;Kg=1;var e=nS();return Lc={Graph:e.Graph,json:oS(),alg:hS(),version:e.version},Lc}var Fc,Jg;function Gt(){if(Jg)return Fc;Jg=1;var e;if(typeof Bd=="function")try{e=pS()}catch{}return e||(e=window.graphlib),Fc=e,Fc}var zc,Zg;function gS(){if(Zg)return zc;Zg=1;var e=uv(),r=1,t=4;function n(o){return e(o,r|t)}return zc=n,zc}var Bc,Yg;function To(){if(Yg)return Bc;Yg=1;var e=Qr(),r=or(),t=jo(),n=Lt();function o(i,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?r(a)&&t(s,a.length):c=="string"&&s in a)?e(a[s],i):!1}return Bc=o,Bc}var Dc,Xg;function yS(){if(Xg)return Dc;Xg=1;var e=Io(),r=Qr(),t=To(),n=Or(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,c){a=Object(a);var l=-1,d=c.length,u=d>2?c[2]:void 0;for(u&&t(c[0],c[1],u)&&(d=1);++l<d;)for(var h=c[l],p=n(h),m=-1,y=p.length;++m<y;){var g=p[m],b=a[g];(b===void 0||r(b,o[g])&&!i.call(a,g))&&(a[g]=h[g])}return a});return Dc=s,Dc}var Vc,Qg;function mS(){if(Qg)return Vc;Qg=1;var e=ir(),r=or(),t=xr();function n(o){return function(i,s,a){var c=Object(i);if(!r(i)){var l=e(s,3);i=t(i),s=function(u){return l(c[u],u,c)}}var d=o(i,s,a);return d>-1?c[l?i[d]:d]:void 0}}return Vc=n,Vc}var Wc,ey;function bS(){if(ey)return Wc;ey=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return Wc=r,Wc}var Gc,ty;function vS(){if(ty)return Gc;ty=1;var e=bS(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return Gc=t,Gc}var Uc,ry;function xS(){if(ry)return Uc;ry=1;var e=vS(),r=Lt(),t=nn(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(l){if(typeof l=="number")return l;if(t(l))return n;if(r(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=r(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var u=i.test(l);return u||s.test(l)?a(l.slice(2),u?2:8):o.test(l)?n:+l}return Uc=c,Uc}var Hc,ny;function Bv(){if(ny)return Hc;ny=1;var e=xS(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var i=o<0?-1:1;return i*t}return o===o?o:0}return Hc=n,Hc}var Kc,oy;function wS(){if(oy)return Kc;oy=1;var e=Bv();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return Kc=r,Kc}var Jc,iy;function CS(){if(iy)return Jc;iy=1;var e=Tv(),r=ir(),t=wS(),n=Math.max;function o(i,s,a){var c=i==null?0:i.length;if(!c)return-1;var l=a==null?0:t(a);return l<0&&(l=n(c+l,0)),e(i,r(s,3),l)}return Jc=o,Jc}var Zc,ay;function SS(){if(ay)return Zc;ay=1;var e=mS(),r=CS(),t=e(r);return Zc=t,Zc}var Yc,sy;function Dv(){if(sy)return Yc;sy=1;var e=ru();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return Yc=r,Yc}var Xc,cy;function jS(){if(cy)return Xc;cy=1;var e=Xd(),r=fv(),t=Or();function n(o,i){return o==null?o:e(o,r(i),t)}return Xc=n,Xc}var Qc,ly;function _S(){if(ly)return Qc;ly=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Qc=e,Qc}var el,dy;function ES(){if(dy)return el;dy=1;var e=Co(),r=Qd(),t=ir();function n(o,i){var s={};return i=t(i,3),r(o,function(a,c,l){e(s,c,i(a,c,l))}),s}return el=n,el}var tl,uy;function ou(){if(uy)return tl;uy=1;var e=nn();function r(t,n,o){for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n(a);if(c!=null&&(l===void 0?c===c&&!e(c):o(c,l)))var l=c,d=a}return d}return tl=r,tl}var rl,fy;function kS(){if(fy)return rl;fy=1;function e(r,t){return r>t}return rl=e,rl}var nl,hy;function RS(){if(hy)return nl;hy=1;var e=ou(),r=kS(),t=Nr();function n(o){return o&&o.length?e(o,t,r):void 0}return nl=n,nl}var ol,py;function Vv(){if(py)return ol;py=1;var e=Co(),r=Qr();function t(n,o,i){(i!==void 0&&!r(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return ol=t,ol}var il,gy;function AS(){if(gy)return il;gy=1;var e=Ir(),r=ko(),t=er(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,c=s.call(Object);function l(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return il=l,il}var al,yy;function Wv(){if(yy)return al;yy=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return al=e,al}var sl,my;function PS(){if(my)return sl;my=1;var e=Ln(),r=Or();function t(n){return e(n,r(n))}return sl=t,sl}var cl,by;function MS(){if(by)return cl;by=1;var e=Vv(),r=Qb(),t=cv(),n=ev(),o=dv(),i=Fn(),s=yt(),a=Ov(),c=tn(),l=qn(),d=Lt(),u=AS(),h=zn(),p=Wv(),m=PS();function y(g,b,v,x,w,C,S){var _=p(g,v),k=p(b,v),E=S.get(k);if(E){e(g,v,E);return}var O=C?C(_,k,v+"",g,b,S):void 0,P=O===void 0;if(P){var A=s(k),M=!A&&c(k),T=!A&&!M&&h(k);O=k,A||M||T?s(_)?O=_:a(_)?O=n(_):M?(P=!1,O=r(k,!0)):T?(P=!1,O=t(k,!0)):O=[]:u(k)||i(k)?(O=_,i(_)?O=m(_):(!d(_)||l(_))&&(O=o(k))):P=!1}P&&(S.set(k,O),w(O,k,x,C,S),S.delete(k)),e(g,v,O)}return cl=y,cl}var ll,vy;function IS(){if(vy)return ll;vy=1;var e=wo(),r=Vv(),t=Xd(),n=MS(),o=Lt(),i=Or(),s=Wv();function a(c,l,d,u,h){c!==l&&t(l,function(p,m){if(h||(h=new e),o(p))n(c,l,m,d,a,u,h);else{var y=u?u(s(c,m),p,m+"",c,l,h):void 0;y===void 0&&(y=p),r(c,m,y)}},i)}return ll=a,ll}var dl,xy;function TS(){if(xy)return dl;xy=1;var e=Io(),r=To();function t(n){return e(function(o,i){var s=-1,a=i.length,c=a>1?i[a-1]:void 0,l=a>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,l&&r(i[0],i[1],l)&&(c=a<3?void 0:c,a=1),o=Object(o);++s<a;){var d=i[s];d&&n(o,d,s,c)}return o})}return dl=t,dl}var ul,wy;function OS(){if(wy)return ul;wy=1;var e=IS(),r=TS(),t=r(function(n,o,i){e(n,o,i)});return ul=t,ul}var fl,Cy;function Gv(){if(Cy)return fl;Cy=1;function e(r,t){return r<t}return fl=e,fl}var hl,Sy;function NS(){if(Sy)return hl;Sy=1;var e=ou(),r=Gv(),t=Nr();function n(o){return o&&o.length?e(o,t,r):void 0}return hl=n,hl}var pl,jy;function $S(){if(jy)return pl;jy=1;var e=ou(),r=ir(),t=Gv();function n(o,i){return o&&o.length?e(o,r(i,2),t):void 0}return pl=n,pl}var gl,_y;function qS(){if(_y)return gl;_y=1;var e=Ut(),r=function(){return e.Date.now()};return gl=r,gl}var yl,Ey;function LS(){if(Ey)return yl;Ey=1;var e=So(),r=Po(),t=jo(),n=Lt(),o=Bn();function i(s,a,c,l){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var m=o(a[d]),y=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return s;if(d!=h){var g=p[m];y=l?l(g,m,p):void 0,y===void 0&&(y=n(g)?g:t(a[d+1])?[]:{})}e(p,m,y),p=p[m]}return s}return yl=i,yl}var ml,ky;function FS(){if(ky)return ml;ky=1;var e=Mo(),r=LS(),t=Po();function n(o,i,s){for(var a=-1,c=i.length,l={};++a<c;){var d=i[a],u=e(o,d);s(u,d)&&r(l,t(d,o),u)}return l}return ml=n,ml}var bl,Ry;function zS(){if(Ry)return bl;Ry=1;var e=FS(),r=Sv();function t(n,o){return e(n,o,function(i,s){return r(n,s)})}return bl=t,bl}var vl,Ay;function BS(){if(Ay)return vl;Ay=1;var e=Dv(),r=Mv(),t=Iv();function n(o){return t(r(o,void 0,e),o+"")}return vl=n,vl}var xl,Py;function DS(){if(Py)return xl;Py=1;var e=zS(),r=BS(),t=r(function(n,o){return n==null?{}:e(n,o)});return xl=t,xl}var wl,My;function VS(){if(My)return wl;My=1;var e=Math.ceil,r=Math.max;function t(n,o,i,s){for(var a=-1,c=r(e((o-n)/(i||1)),0),l=Array(c);c--;)l[s?c:++a]=n,n+=i;return l}return wl=t,wl}var Cl,Iy;function WS(){if(Iy)return Cl;Iy=1;var e=VS(),r=To(),t=Bv();function n(o){return function(i,s,a){return a&&typeof a!="number"&&r(i,s,a)&&(s=a=void 0),i=t(i),s===void 0?(s=i,i=0):s=t(s),a=a===void 0?i<s?1:-1:t(a),e(i,s,a,o)}}return Cl=n,Cl}var Sl,Ty;function GS(){if(Ty)return Sl;Ty=1;var e=WS(),r=e();return Sl=r,Sl}var jl,Oy;function US(){if(Oy)return jl;Oy=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return jl=e,jl}var _l,Ny;function HS(){if(Ny)return _l;Ny=1;var e=nn();function r(t,n){if(t!==n){var o=t!==void 0,i=t===null,s=t===t,a=e(t),c=n!==void 0,l=n===null,d=n===n,u=e(n);if(!l&&!u&&!a&&t>n||a&&c&&d&&!l&&!u||i&&c&&d||!o&&d||!s)return 1;if(!i&&!a&&!u&&t<n||u&&o&&s&&!i&&!a||l&&o&&s||!c&&s||!d)return-1}return 0}return _l=r,_l}var El,$y;function KS(){if($y)return El;$y=1;var e=HS();function r(t,n,o){for(var i=-1,s=t.criteria,a=n.criteria,c=s.length,l=o.length;++i<c;){var d=e(s[i],a[i]);if(d){if(i>=l)return d;var u=o[i];return d*(u=="desc"?-1:1)}}return t.index-n.index}return El=r,El}var kl,qy;function JS(){if(qy)return kl;qy=1;var e=Ao(),r=Mo(),t=ir(),n=Rv(),o=US(),i=_o(),s=KS(),a=Nr(),c=yt();function l(d,u,h){u.length?u=e(u,function(y){return c(y)?function(g){return r(g,y.length===1?y[0]:y)}:y}):u=[a];var p=-1;u=e(u,i(t));var m=n(d,function(y,g,b){var v=e(u,function(x){return x(y)});return{criteria:v,index:++p,value:y}});return o(m,function(y,g){return s(y,g,h)})}return kl=l,kl}var Rl,Ly;function ZS(){if(Ly)return Rl;Ly=1;var e=ru(),r=JS(),t=Io(),n=To(),o=t(function(i,s){if(i==null)return[];var a=s.length;return a>1&&n(i,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),r(i,e(s,1),[])});return Rl=o,Rl}var Al,Fy;function YS(){if(Fy)return Al;Fy=1;var e=wv(),r=0;function t(n){var o=++r;return e(n)+o}return Al=t,Al}var Pl,zy;function XS(){if(zy)return Pl;zy=1;function e(r,t,n){for(var o=-1,i=r.length,s=t.length,a={};++o<i;){var c=o<s?t[o]:void 0;n(a,r[o],c)}return a}return Pl=e,Pl}var Ml,By;function QS(){if(By)return Ml;By=1;var e=So(),r=XS();function t(n,o){return r(n||[],o||[],e)}return Ml=t,Ml}var Il,Dy;function ut(){if(Dy)return Il;Dy=1;var e;if(typeof Bd=="function")try{e={cloneDeep:gS(),constant:Yd(),defaults:yS(),each:pv(),filter:_v(),find:SS(),flatten:Dv(),forEach:hv(),forIn:jS(),has:Ev(),isUndefined:kv(),last:_S(),map:Av(),mapValues:ES(),max:RS(),merge:OS(),min:NS(),minBy:$S(),now:qS(),pick:DS(),range:GS(),reduce:Pv(),sortBy:ZS(),uniqueId:YS(),values:Nv(),zipObject:QS()}}catch{}return e||(e=window._),Il=e,Il}var Tl,Vy;function ej(){if(Vy)return Tl;Vy=1,Tl=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,t)),i=i._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,o){if(n!=="_next"&&n!=="_prev")return o}return Tl}var Ol,Wy;function tj(){if(Wy)return Ol;Wy=1;var e=ut(),r=Gt().Graph,t=ej();Ol=o;var n=e.constant(1);function o(l,d){if(l.nodeCount()<=1)return[];var u=a(l,d||n),h=i(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return l.outEdges(p.v,p.w)}),!0)}function i(l,d,u){for(var h=[],p=d[d.length-1],m=d[0],y;l.nodeCount();){for(;y=m.dequeue();)s(l,d,u,y);for(;y=p.dequeue();)s(l,d,u,y);if(l.nodeCount()){for(var g=d.length-2;g>0;--g)if(y=d[g].dequeue(),y){h=h.concat(s(l,d,u,y,!0));break}}}return h}function s(l,d,u,h,p){var m=p?[]:void 0;return e.forEach(l.inEdges(h.v),function(y){var g=l.edge(y),b=l.node(y.v);p&&m.push({v:y.v,w:y.w}),b.out-=g,c(d,u,b)}),e.forEach(l.outEdges(h.v),function(y){var g=l.edge(y),b=y.w,v=l.node(b);v.in-=g,c(d,u,v)}),l.removeNode(h.v),m}function a(l,d){var u=new r,h=0,p=0;e.forEach(l.nodes(),function(g){u.setNode(g,{v:g,in:0,out:0})}),e.forEach(l.edges(),function(g){var b=u.edge(g.v,g.w)||0,v=d(g),x=b+v;u.setEdge(g.v,g.w,x),p=Math.max(p,u.node(g.v).out+=v),h=Math.max(h,u.node(g.w).in+=v)});var m=e.range(p+h+3).map(function(){return new t}),y=h+1;return e.forEach(u.nodes(),function(g){c(m,y,u.node(g))}),{graph:u,buckets:m,zeroIdx:y}}function c(l,d,u){u.out?u.in?l[u.out-u.in+d].enqueue(u):l[l.length-1].enqueue(u):l[0].enqueue(u)}return Ol}var Nl,Gy;function rj(){if(Gy)return Nl;Gy=1;var e=ut(),r=tj();Nl={run:t,undo:o};function t(i){var s=i.graph().acyclicer==="greedy"?r(i,a(i)):n(i);e.forEach(s,function(c){var l=i.edge(c);i.removeEdge(c),l.forwardName=c.name,l.reversed=!0,i.setEdge(c.w,c.v,l,e.uniqueId("rev"))});function a(c){return function(l){return c.edge(l).weight}}}function n(i){var s=[],a={},c={};function l(d){e.has(c,d)||(c[d]=!0,a[d]=!0,e.forEach(i.outEdges(d),function(u){e.has(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return e.forEach(i.nodes(),l),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,c)}})}return Nl}var $l,Uy;function Rt(){if(Uy)return $l;Uy=1;var e=ut(),r=Gt().Graph;$l={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:m,notime:y};function t(g,b,v,x){var w;do w=e.uniqueId(x);while(g.hasNode(w));return v.dummy=b,g.setNode(w,v),w}function n(g){var b=new r().setGraph(g.graph());return e.forEach(g.nodes(),function(v){b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){var x=b.edge(v.v,v.w)||{weight:0,minlen:1},w=g.edge(v);b.setEdge(v.v,v.w,{weight:x.weight+w.weight,minlen:Math.max(x.minlen,w.minlen)})}),b}function o(g){var b=new r({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(v){g.children(v).length||b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){b.setEdge(v,g.edge(v))}),b}function i(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.outEdges(v),function(w){x[w.w]=(x[w.w]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.inEdges(v),function(w){x[w.v]=(x[w.v]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function a(g,b){var v=g.x,x=g.y,w=b.x-v,C=b.y-x,S=g.width/2,_=g.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var k,E;return Math.abs(C)*S>Math.abs(w)*_?(C<0&&(_=-_),k=_*w/C,E=_):(w<0&&(S=-S),k=S,E=S*C/w),{x:v+k,y:x+E}}function c(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(v){var x=g.node(v),w=x.rank;e.isUndefined(w)||(b[w][x.order]=v)}),b}function l(g){var b=e.min(e.map(g.nodes(),function(v){return g.node(v).rank}));e.forEach(g.nodes(),function(v){var x=g.node(v);e.has(x,"rank")&&(x.rank-=b)})}function d(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),v=[];e.forEach(g.nodes(),function(C){var S=g.node(C).rank-b;v[S]||(v[S]=[]),v[S].push(C)});var x=0,w=g.graph().nodeRankFactor;e.forEach(v,function(C,S){e.isUndefined(C)&&S%w!==0?--x:x&&e.forEach(C,function(_){g.node(_).rank+=x})})}function u(g,b,v,x){var w={width:0,height:0};return arguments.length>=4&&(w.rank=v,w.order=x),t(g,"border",w,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var v=g.node(b).rank;if(!e.isUndefined(v))return v}))}function p(g,b){var v={lhs:[],rhs:[]};return e.forEach(g,function(x){b(x)?v.lhs.push(x):v.rhs.push(x)}),v}function m(g,b){var v=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-v)+"ms")}}function y(g,b){return b()}return $l}var ql,Hy;function nj(){if(Hy)return ql;Hy=1;var e=ut(),r=Rt();ql={run:t,undo:o};function t(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,c=i.node(a).rank,l=s.w,d=i.node(l).rank,u=s.name,h=i.edge(s),p=h.labelRank;if(d!==c+1){i.removeEdge(s);var m,y,g;for(g=0,++c;c<d;++g,++c)h.points=[],y={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},m=r.addDummyNode(i,"edge",y,"_d"),c===p&&(y.width=h.width,y.height=h.height,y.dummy="edge-label",y.labelpos=h.labelpos),i.setEdge(a,m,{weight:h.weight},u),g===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:h.weight},u)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),c=a.edgeLabel,l;for(i.setEdge(a.edgeObj,c);a.dummy;)l=i.successors(s)[0],i.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=l,a=i.node(s)})}return ql}var Ll,Ky;function ao(){if(Ky)return Ll;Ky=1;var e=ut();Ll={longestPath:r,slack:t};function r(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var c=e.min(e.map(n.outEdges(s),function(l){return i(l.w)-n.edge(l).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),i)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Ll}var Fl,Jy;function Uv(){if(Jy)return Fl;Jy=1;var e=ut(),r=Gt().Graph,t=ao().slack;Fl=n;function n(a){var c=new r({directed:!1}),l=a.nodes()[0],d=a.nodeCount();c.setNode(l,{});for(var u,h;o(c,a)<d;)u=i(c,a),h=c.hasNode(u.v)?t(a,u):-t(a,u),s(c,a,h);return c}function o(a,c){function l(d){e.forEach(c.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(c,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),l(p))})}return e.forEach(a.nodes(),l),a.nodeCount()}function i(a,c){return e.minBy(c.edges(),function(l){if(a.hasNode(l.v)!==a.hasNode(l.w))return t(c,l)})}function s(a,c,l){e.forEach(a.nodes(),function(d){c.node(d).rank+=l})}return Fl}var zl,Zy;function oj(){if(Zy)return zl;Zy=1;var e=ut(),r=Uv(),t=ao().slack,n=ao().longestPath,o=Gt().alg.preorder,i=Gt().alg.postorder,s=Rt().simplify;zl=a,a.initLowLimValues=u,a.initCutValues=c,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=m,a.exchangeEdges=y;function a(x){x=s(x),n(x);var w=r(x);u(w),c(w,x);for(var C,S;C=p(w);)S=m(w,x,C),y(w,x,C,S)}function c(x,w){var C=i(x,x.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){l(x,w,S)})}function l(x,w,C){var S=x.node(C),_=S.parent;x.edge(C,_).cutvalue=d(x,w,C)}function d(x,w,C){var S=x.node(C),_=S.parent,k=!0,E=w.edge(C,_),O=0;return E||(k=!1,E=w.edge(_,C)),O=E.weight,e.forEach(w.nodeEdges(C),function(P){var A=P.v===C,M=A?P.w:P.v;if(M!==_){var T=A===k,N=w.edge(P).weight;if(O+=T?N:-N,b(x,C,M)){var $=x.edge(C,M).cutvalue;O+=T?-$:$}}}),O}function u(x,w){arguments.length<2&&(w=x.nodes()[0]),h(x,{},1,w)}function h(x,w,C,S,_){var k=C,E=x.node(S);return w[S]=!0,e.forEach(x.neighbors(S),function(O){e.has(w,O)||(C=h(x,w,C,O,S))}),E.low=k,E.lim=C++,_?E.parent=_:delete E.parent,C}function p(x){return e.find(x.edges(),function(w){return x.edge(w).cutvalue<0})}function m(x,w,C){var S=C.v,_=C.w;w.hasEdge(S,_)||(S=C.w,_=C.v);var k=x.node(S),E=x.node(_),O=k,P=!1;k.lim>E.lim&&(O=E,P=!0);var A=e.filter(w.edges(),function(M){return P===v(x,x.node(M.v),O)&&P!==v(x,x.node(M.w),O)});return e.minBy(A,function(M){return t(w,M)})}function y(x,w,C,S){var _=C.v,k=C.w;x.removeEdge(_,k),x.setEdge(S.v,S.w,{}),u(x),c(x,w),g(x,w)}function g(x,w){var C=e.find(x.nodes(),function(_){return!w.node(_).parent}),S=o(x,C);S=S.slice(1),e.forEach(S,function(_){var k=x.node(_).parent,E=w.edge(_,k),O=!1;E||(E=w.edge(k,_),O=!0),w.node(_).rank=w.node(k).rank+(O?E.minlen:-E.minlen)})}function b(x,w,C){return x.hasEdge(w,C)}function v(x,w,C){return C.low<=w.lim&&w.lim<=C.lim}return zl}var Bl,Yy;function ij(){if(Yy)return Bl;Yy=1;var e=ao(),r=e.longestPath,t=Uv(),n=oj();Bl=o;function o(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":i(c);break;default:a(c)}}var i=r;function s(c){r(c),t(c)}function a(c){n(c)}return Bl}var Dl,Xy;function aj(){if(Xy)return Dl;Xy=1;var e=ut();Dl=r;function r(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),c=a.edgeObj,l=t(o,i,c.v,c.w),d=l.path,u=l.lca,h=0,p=d[h],m=!0;s!==c.w;){if(a=o.node(s),m){for(;(p=d[h])!==u&&o.node(p).maxRank<a.rank;)h++;p===u&&(m=!1)}if(!m){for(;h<d.length-1&&o.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}o.setParent(s,p),s=o.successors(s)[0]}})}function t(o,i,s,a){var c=[],l=[],d=Math.min(i[s].low,i[a].low),u=Math.max(i[s].lim,i[a].lim),h,p;h=s;do h=o.parent(h),c.push(h);while(h&&(i[h].low>d||u>i[h].lim));for(p=h,h=a;(h=o.parent(h))!==p;)l.push(h);return{path:c.concat(l.reverse()),lca:p}}function n(o){var i={},s=0;function a(c){var l=s;e.forEach(o.children(c),a),i[c]={low:l,lim:s++}}return e.forEach(o.children(),a),i}return Dl}var Vl,Qy;function sj(){if(Qy)return Vl;Qy=1;var e=ut(),r=Rt();Vl={run:t,cleanup:s};function t(a){var c=r.addDummyNode(a,"root",{},"_root"),l=o(a),d=e.max(e.values(l))-1,u=2*d+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=i(a)+1;e.forEach(a.children(),function(p){n(a,c,u,h,d,l,p)}),a.graph().nodeRankFactor=u}function n(a,c,l,d,u,h,p){var m=a.children(p);if(!m.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:l});return}var y=r.addBorderNode(a,"_bt"),g=r.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(y,p),b.borderTop=y,a.setParent(g,p),b.borderBottom=g,e.forEach(m,function(v){n(a,c,l,d,u,h,v);var x=a.node(v),w=x.borderTop?x.borderTop:v,C=x.borderBottom?x.borderBottom:v,S=x.borderTop?d:2*d,_=w!==C?1:u-h[p]+1;a.setEdge(y,w,{weight:S,minlen:_,nestingEdge:!0}),a.setEdge(C,g,{weight:S,minlen:_,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,y,{weight:0,minlen:u+h[p]})}function o(a){var c={};function l(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){l(p,u+1)}),c[d]=u}return e.forEach(a.children(),function(d){l(d,1)}),c}function i(a){return e.reduce(a.edges(),function(c,l){return c+a.edge(l).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(l){var d=a.edge(l);d.nestingEdge&&a.removeEdge(l)})}return Vl}var Wl,em;function cj(){if(em)return Wl;em=1;var e=ut(),r=Rt();Wl=t;function t(o){function i(s){var a=o.children(s),c=o.node(s);if(a.length&&e.forEach(a,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var l=c.minRank,d=c.maxRank+1;l<d;++l)n(o,"borderLeft","_bl",s,c,l),n(o,"borderRight","_br",s,c,l)}}e.forEach(o.children(),i)}function n(o,i,s,a,c,l){var d={width:0,height:0,rank:l,borderType:i},u=c[i][l-1],h=r.addDummyNode(o,"border",d,s);c[i][l]=h,o.setParent(h,a),u&&o.setEdge(u,h,{weight:1})}return Wl}var Gl,tm;function lj(){if(tm)return Gl;tm=1;var e=ut();Gl={adjust:r,undo:t};function r(l){var d=l.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(l)}function t(l){var d=l.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&i(l),(d==="lr"||d==="rl")&&(a(l),n(l))}function n(l){e.forEach(l.nodes(),function(d){o(l.node(d))}),e.forEach(l.edges(),function(d){o(l.edge(d))})}function o(l){var d=l.width;l.width=l.height,l.height=d}function i(l){e.forEach(l.nodes(),function(d){s(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(l){l.y=-l.y}function a(l){e.forEach(l.nodes(),function(d){c(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,c),e.has(u,"x")&&c(u)})}function c(l){var d=l.x;l.x=l.y,l.y=d}return Gl}var Ul,rm;function dj(){if(rm)return Ul;rm=1;var e=ut();Ul=r;function r(t){var n={},o=e.filter(t.nodes(),function(l){return!t.children(l).length}),i=e.max(e.map(o,function(l){return t.node(l).rank})),s=e.map(e.range(i+1),function(){return[]});function a(l){if(!e.has(n,l)){n[l]=!0;var d=t.node(l);s[d.rank].push(l),e.forEach(t.successors(l),a)}}var c=e.sortBy(o,function(l){return t.node(l).rank});return e.forEach(c,a),s}return Ul}var Hl,nm;function uj(){if(nm)return Hl;nm=1;var e=ut();Hl=r;function r(n,o){for(var i=0,s=1;s<o.length;++s)i+=t(n,o[s-1],o[s]);return i}function t(n,o,i){for(var s=e.zipObject(i,e.map(i,function(h,p){return p})),a=e.flatten(e.map(o,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var l=2*c-1;c-=1;var d=e.map(new Array(l),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;d[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*m})),u}return Hl}var Kl,om;function fj(){if(om)return Kl;om=1;var e=ut();Kl=r;function r(t,n){return e.map(n,function(o){var i=t.inEdges(o);if(i.length){var s=e.reduce(i,function(a,c){var l=t.edge(c),d=t.node(c.v);return{sum:a.sum+l.weight*d.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return Kl}var Jl,im;function hj(){if(im)return Jl;im=1;var e=ut();Jl=r;function r(o,i){var s={};e.forEach(o,function(c,l){var d=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:l};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(i.edges(),function(c){var l=s[c.v],d=s[c.w];!e.isUndefined(l)&&!e.isUndefined(d)&&(d.indegree++,l.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return t(a)}function t(o){var i=[];function s(l){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(l.barycenter)||d.barycenter>=l.barycenter)&&n(l,d)}}function a(l){return function(d){d.in.push(l),--d.indegree===0&&o.push(d)}}for(;o.length;){var c=o.pop();i.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(i,function(l){return!l.merged}),function(l){return e.pick(l,["vs","i","barycenter","weight"])})}function n(o,i){var s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Jl}var Zl,am;function pj(){if(am)return Zl;am=1;var e=ut(),r=Rt();Zl=t;function t(i,s){var a=r.partition(i,function(y){return e.has(y,"barycenter")}),c=a.lhs,l=e.sortBy(a.rhs,function(y){return-y.i}),d=[],u=0,h=0,p=0;c.sort(o(!!s)),p=n(d,l,p),e.forEach(c,function(y){p+=y.vs.length,d.push(y.vs),u+=y.barycenter*y.weight,h+=y.weight,p=n(d,l,p)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=u/h,m.weight=h),m}function n(i,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),i.push(c.vs),a++;return a}function o(i){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}}return Zl}var Yl,sm;function gj(){if(sm)return Yl;sm=1;var e=ut(),r=fj(),t=hj(),n=pj();Yl=o;function o(a,c,l,d){var u=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,y={};p&&(u=e.filter(u,function(C){return C!==p&&C!==m}));var g=r(a,u);e.forEach(g,function(C){if(a.children(C.v).length){var S=o(a,C.v,l,d);y[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=t(g,l);i(b,y);var v=n(b,d);if(p&&(v.vs=e.flatten([p,v.vs,m],!0),a.predecessors(p).length)){var x=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(m)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+x.order+w.order)/(v.weight+2),v.weight+=2}return v}function i(a,c){e.forEach(a,function(l){l.vs=e.flatten(l.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return Yl}var Xl,cm;function yj(){if(cm)return Xl;cm=1;var e=ut(),r=Gt().Graph;Xl=t;function t(o,i,s){var a=n(o),c=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(l){return o.node(l)});return e.forEach(o.nodes(),function(l){var d=o.node(l),u=o.parent(l);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(l),c.setParent(l,u||a),e.forEach(o[s](l),function(h){var p=h.v===l?h.w:h.v,m=c.edge(p,l),y=e.isUndefined(m)?0:m.weight;c.setEdge(p,l,{weight:o.edge(h).weight+y})}),e.has(d,"minRank")&&c.setNode(l,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return Xl}var Ql,lm;function mj(){if(lm)return Ql;lm=1;var e=ut();Ql=r;function r(t,n,o){var i={},s;e.forEach(o,function(a){for(var c=t.parent(a),l,d;c;){if(l=t.parent(c),l?(d=i[l],i[l]=c):(d=s,s=c),d&&d!==c){n.setEdge(d,c);return}c=l}})}return Ql}var ed,dm;function bj(){if(dm)return ed;dm=1;var e=ut(),r=dj(),t=uj(),n=gj(),o=yj(),i=mj(),s=Gt().Graph,a=Rt();ed=c;function c(h){var p=a.maxRank(h),m=l(h,e.range(1,p+1),"inEdges"),y=l(h,e.range(p-1,-1,-1),"outEdges"),g=r(h);u(h,g);for(var b=Number.POSITIVE_INFINITY,v,x=0,w=0;w<4;++x,++w){d(x%2?m:y,x%4>=2),g=a.buildLayerMatrix(h);var C=t(h,g);C<b&&(w=0,v=e.cloneDeep(g),b=C)}u(h,v)}function l(h,p,m){return e.map(p,function(y){return o(h,y,m)})}function d(h,p){var m=new s;e.forEach(h,function(y){var g=y.graph().root,b=n(y,g,m,p);e.forEach(b.vs,function(v,x){y.node(v).order=x}),i(y,m,b.vs)})}function u(h,p){e.forEach(p,function(m){e.forEach(m,function(y,g){h.node(y).order=g})})}return ed}var td,um;function vj(){if(um)return td;um=1;var e=ut(),r=Gt().Graph,t=Rt();td={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,v){var x={};function w(C,S){var _=0,k=0,E=C.length,O=e.last(S);return e.forEach(S,function(P,A){var M=i(b,P),T=M?b.node(M).order:E;(M||P===O)&&(e.forEach(S.slice(k,A+1),function(N){e.forEach(b.predecessors(N),function($){var I=b.node($),W=I.order;(W<_||T<W)&&!(I.dummy&&b.node(N).dummy)&&s(x,$,N)})}),k=A+1,_=T)}),S}return e.reduce(v,w),x}function o(b,v){var x={};function w(S,_,k,E,O){var P;e.forEach(e.range(_,k),function(A){P=S[A],b.node(P).dummy&&e.forEach(b.predecessors(P),function(M){var T=b.node(M);T.dummy&&(T.order<E||T.order>O)&&s(x,M,P)})})}function C(S,_){var k=-1,E,O=0;return e.forEach(_,function(P,A){if(b.node(P).dummy==="border"){var M=b.predecessors(P);M.length&&(E=b.node(M[0]).order,w(_,O,A,k,E),O=A,k=E)}w(_,O,_.length,E,S.length)}),_}return e.reduce(v,C),x}function i(b,v){if(b.node(v).dummy)return e.find(b.predecessors(v),function(x){return b.node(x).dummy})}function s(b,v,x){if(v>x){var w=v;v=x,x=w}var C=b[v];C||(b[v]=C={}),C[x]=!0}function a(b,v,x){if(v>x){var w=v;v=x,x=w}return e.has(b[v],x)}function c(b,v,x,w){var C={},S={},_={};return e.forEach(v,function(k){e.forEach(k,function(E,O){C[E]=E,S[E]=E,_[E]=O})}),e.forEach(v,function(k){var E=-1;e.forEach(k,function(O){var P=w(O);if(P.length){P=e.sortBy(P,function($){return _[$]});for(var A=(P.length-1)/2,M=Math.floor(A),T=Math.ceil(A);M<=T;++M){var N=P[M];S[O]===O&&E<_[N]&&!a(x,O,N)&&(S[N]=O,S[O]=C[O]=C[N],E=_[N])}}})}),{root:C,align:S}}function l(b,v,x,w,C){var S={},_=d(b,v,x,C),k=C?"borderLeft":"borderRight";function E(A,M){for(var T=_.nodes(),N=T.pop(),$={};N;)$[N]?A(N):($[N]=!0,T.push(N),T=T.concat(M(N))),N=T.pop()}function O(A){S[A]=_.inEdges(A).reduce(function(M,T){return Math.max(M,S[T.v]+_.edge(T))},0)}function P(A){var M=_.outEdges(A).reduce(function(N,$){return Math.min(N,S[$.w]-_.edge($))},Number.POSITIVE_INFINITY),T=b.node(A);M!==Number.POSITIVE_INFINITY&&T.borderType!==k&&(S[A]=Math.max(S[A],M))}return E(O,_.predecessors.bind(_)),E(P,_.successors.bind(_)),e.forEach(w,function(A){S[A]=S[x[A]]}),S}function d(b,v,x,w){var C=new r,S=b.graph(),_=y(S.nodesep,S.edgesep,w);return e.forEach(v,function(k){var E;e.forEach(k,function(O){var P=x[O];if(C.setNode(P),E){var A=x[E],M=C.edge(A,P);C.setEdge(A,P,Math.max(_(b,O,E),M||0))}E=O})}),C}function u(b,v){return e.minBy(e.values(v),function(x){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(x,function(S,_){var k=g(b,_)/2;w=Math.max(S+k,w),C=Math.min(S-k,C)}),w-C})}function h(b,v){var x=e.values(v),w=e.min(x),C=e.max(x);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(_){var k=S+_,E=b[k],O;if(E!==v){var P=e.values(E);O=_==="l"?w-e.min(P):C-e.max(P),O&&(b[k]=e.mapValues(E,function(A){return A+O}))}})})}function p(b,v){return e.mapValues(b.ul,function(x,w){if(v)return b[v.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function m(b){var v=t.buildLayerMatrix(b),x=e.merge(n(b,v),o(b,v)),w={},C;e.forEach(["u","d"],function(_){C=_==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(k){k==="r"&&(C=e.map(C,function(A){return e.values(A).reverse()}));var E=(_==="u"?b.predecessors:b.successors).bind(b),O=c(b,C,x,E),P=l(b,C,O.root,O.align,k==="r");k==="r"&&(P=e.mapValues(P,function(A){return-A})),w[_+k]=P})});var S=u(b,w);return h(w,S),p(w,b.graph().align)}function y(b,v,x){return function(w,C,S){var _=w.node(C),k=w.node(S),E=0,O;if(E+=_.width/2,e.has(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":O=-_.width/2;break;case"r":O=_.width/2;break}if(O&&(E+=x?O:-O),O=0,E+=(_.dummy?v:b)/2,E+=(k.dummy?v:b)/2,E+=k.width/2,e.has(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":O=k.width/2;break;case"r":O=-k.width/2;break}return O&&(E+=x?O:-O),O=0,E}}function g(b,v){return b.node(v).width}return td}var rd,fm;function xj(){if(fm)return rd;fm=1;var e=ut(),r=Rt(),t=vj().positionX;rd=n;function n(i){i=r.asNonCompoundGraph(i),o(i),e.forEach(t(i),function(s,a){i.node(a).x=s})}function o(i){var s=r.buildLayerMatrix(i),a=i.graph().ranksep,c=0;e.forEach(s,function(l){var d=e.max(e.map(l,function(u){return i.node(u).height}));e.forEach(l,function(u){i.node(u).y=c+d/2}),c+=d+a})}return rd}var nd,hm;function wj(){if(hm)return nd;hm=1;var e=ut(),r=rj(),t=nj(),n=ij(),o=Rt().normalizeRanks,i=aj(),s=Rt().removeEmptyRanks,a=sj(),c=cj(),l=lj(),d=bj(),u=xj(),h=Rt(),p=Gt().Graph;nd=m;function m(L,z){var G=z&&z.debugTiming?h.time:h.notime;G("layout",function(){var D=G(" buildLayoutGraph",function(){return E(L)});G(" runLayout",function(){y(D,G)}),G(" updateInputGraph",function(){g(L,D)})})}function y(L,z){z(" makeSpaceForEdgeLabels",function(){O(L)}),z(" removeSelfEdges",function(){ie(L)}),z(" acyclic",function(){r.run(L)}),z(" nestingGraph.run",function(){a.run(L)}),z(" rank",function(){n(h.asNonCompoundGraph(L))}),z(" injectEdgeLabelProxies",function(){P(L)}),z(" removeEmptyRanks",function(){s(L)}),z(" nestingGraph.cleanup",function(){a.cleanup(L)}),z(" normalizeRanks",function(){o(L)}),z(" assignRankMinMax",function(){A(L)}),z(" removeEdgeLabelProxies",function(){M(L)}),z(" normalize.run",function(){t.run(L)}),z(" parentDummyChains",function(){i(L)}),z(" addBorderSegments",function(){c(L)}),z(" order",function(){d(L)}),z(" insertSelfEdges",function(){ae(L)}),z(" adjustCoordinateSystem",function(){l.adjust(L)}),z(" position",function(){u(L)}),z(" positionSelfEdges",function(){re(L)}),z(" removeBorderNodes",function(){W(L)}),z(" normalize.undo",function(){t.undo(L)}),z(" fixupEdgeLabelCoords",function(){$(L)}),z(" undoCoordinateSystem",function(){l.undo(L)}),z(" translateGraph",function(){T(L)}),z(" assignNodeIntersects",function(){N(L)}),z(" reversePoints",function(){I(L)}),z(" acyclic.undo",function(){r.undo(L)})}function g(L,z){e.forEach(L.nodes(),function(G){var D=L.node(G),se=z.node(G);D&&(D.x=se.x,D.y=se.y,z.children(G).length&&(D.width=se.width,D.height=se.height))}),e.forEach(L.edges(),function(G){var D=L.edge(G),se=z.edge(G);D.points=se.points,e.has(se,"x")&&(D.x=se.x,D.y=se.y)}),L.graph().width=z.graph().width,L.graph().height=z.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},k=["labelpos"];function E(L){var z=new p({multigraph:!0,compound:!0}),G=be(L.graph());return z.setGraph(e.merge({},v,ye(G,b),e.pick(G,x))),e.forEach(L.nodes(),function(D){var se=be(L.node(D));z.setNode(D,e.defaults(ye(se,w),C)),z.setParent(D,L.parent(D))}),e.forEach(L.edges(),function(D){var se=be(L.edge(D));z.setEdge(D,e.merge({},_,ye(se,S),e.pick(se,k)))}),z}function O(L){var z=L.graph();z.ranksep/=2,e.forEach(L.edges(),function(G){var D=L.edge(G);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(z.rankdir==="TB"||z.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function P(L){e.forEach(L.edges(),function(z){var G=L.edge(z);if(G.width&&G.height){var D=L.node(z.v),se=L.node(z.w),X={rank:(se.rank-D.rank)/2+D.rank,e:z};h.addDummyNode(L,"edge-proxy",X,"_ep")}})}function A(L){var z=0;e.forEach(L.nodes(),function(G){var D=L.node(G);D.borderTop&&(D.minRank=L.node(D.borderTop).rank,D.maxRank=L.node(D.borderBottom).rank,z=e.max(z,D.maxRank))}),L.graph().maxRank=z}function M(L){e.forEach(L.nodes(),function(z){var G=L.node(z);G.dummy==="edge-proxy"&&(L.edge(G.e).labelRank=G.rank,L.removeNode(z))})}function T(L){var z=Number.POSITIVE_INFINITY,G=0,D=Number.POSITIVE_INFINITY,se=0,X=L.graph(),le=X.marginx||0,ue=X.marginy||0;function Ce(je){var pe=je.x,fe=je.y,Y=je.width,H=je.height;z=Math.min(z,pe-Y/2),G=Math.max(G,pe+Y/2),D=Math.min(D,fe-H/2),se=Math.max(se,fe+H/2)}e.forEach(L.nodes(),function(je){Ce(L.node(je))}),e.forEach(L.edges(),function(je){var pe=L.edge(je);e.has(pe,"x")&&Ce(pe)}),z-=le,D-=ue,e.forEach(L.nodes(),function(je){var pe=L.node(je);pe.x-=z,pe.y-=D}),e.forEach(L.edges(),function(je){var pe=L.edge(je);e.forEach(pe.points,function(fe){fe.x-=z,fe.y-=D}),e.has(pe,"x")&&(pe.x-=z),e.has(pe,"y")&&(pe.y-=D)}),X.width=G-z+le,X.height=se-D+ue}function N(L){e.forEach(L.edges(),function(z){var G=L.edge(z),D=L.node(z.v),se=L.node(z.w),X,le;G.points?(X=G.points[0],le=G.points[G.points.length-1]):(G.points=[],X=se,le=D),G.points.unshift(h.intersectRect(D,X)),G.points.push(h.intersectRect(se,le))})}function $(L){e.forEach(L.edges(),function(z){var G=L.edge(z);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 I(L){e.forEach(L.edges(),function(z){var G=L.edge(z);G.reversed&&G.points.reverse()})}function W(L){e.forEach(L.nodes(),function(z){if(L.children(z).length){var G=L.node(z),D=L.node(G.borderTop),se=L.node(G.borderBottom),X=L.node(e.last(G.borderLeft)),le=L.node(e.last(G.borderRight));G.width=Math.abs(le.x-X.x),G.height=Math.abs(se.y-D.y),G.x=X.x+G.width/2,G.y=D.y+G.height/2}}),e.forEach(L.nodes(),function(z){L.node(z).dummy==="border"&&L.removeNode(z)})}function ie(L){e.forEach(L.edges(),function(z){if(z.v===z.w){var G=L.node(z.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:z,label:L.edge(z)}),L.removeEdge(z)}})}function ae(L){var z=h.buildLayerMatrix(L);e.forEach(z,function(G){var D=0;e.forEach(G,function(se,X){var le=L.node(se);le.order=X+D,e.forEach(le.selfEdges,function(ue){h.addDummyNode(L,"selfedge",{width:ue.label.width,height:ue.label.height,rank:le.rank,order:X+ ++D,e:ue.e,label:ue.label},"_se")}),delete le.selfEdges})})}function re(L){e.forEach(L.nodes(),function(z){var G=L.node(z);if(G.dummy==="selfedge"){var D=L.node(G.e.v),se=D.x+D.width/2,X=D.y,le=G.x-se,ue=D.height/2;L.setEdge(G.e,G.label),L.removeNode(z),G.label.points=[{x:se+2*le/3,y:X-ue},{x:se+5*le/6,y:X-ue},{x:se+le,y:X},{x:se+5*le/6,y:X+ue},{x:se+2*le/3,y:X+ue}],G.label.x=G.x,G.label.y=G.y}})}function ye(L,z){return e.mapValues(e.pick(L,z),Number)}function be(L){var z={};return e.forEach(L,function(G,D){z[D.toLowerCase()]=G}),z}return nd}var od,pm;function Cj(){if(pm)return od;pm=1;var e=ut(),r=Rt(),t=Gt().Graph;od={debugOrdering:n};function n(o){var i=r.buildLayerMatrix(o),s=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+o.node(a).rank)}),e.forEach(o.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(i,function(a,c){var l="layer"+c;s.setNode(l,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return od}var id,gm;function Sj(){return gm||(gm=1,id="0.8.5"),id}var ad,ym;function jj(){return ym||(ym=1,ad={graphlib:Gt(),layout:wj(),debug:Cj(),util:{time:Rt().time,notime:Rt().notime},version:Sj()}),ad}var _j=jj();const mm=l1(_j);function Ej(e,r,t){var d;const n=new Set(e.map(u=>u.id)),o=new Set;for(const u of e)u.parent&&n.has(u.parent)&&o.add(u.parent);const i=new mm.graphlib.Graph({multigraph:!0,compound:!0}),s=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);i.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*s):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*s):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*s):t.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const u of e)i.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&i.setParent(u.id,u.parent);for(const u of r){if(!n.has(u.source)||!n.has(u.target)||o.has(u.source)||o.has(u.target))continue;const h=Gb(u.label,u.icon??((d=u.data)==null?void 0:d.icon),t.edgeLabelFontSize),p=t.rankDir==="LR"||t.rankDir==="RL",m=(h.width?h.width+2*Wb:0)+(u.connectorClearance??0);i.setEdge(u.source,u.target,{minlen:1,weight:1,...m?{width:p?m:Math.max(1,h.height),height:p?Math.max(1,h.height):m,labelpos:"c"}:{}},u.id)}mm.layout(i);const a=new Map;for(const u of e){if(o.has(u.id))continue;const h=i.node(u.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(u.id,{x:h.x,y:h.y})}const c=t.compact?1:t.spacingFactor;if(c&&c!==1&&a.size){let u=1/0,h=1/0,p=-1/0,m=-1/0;a.forEach(b=>{u=Math.min(u,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),m=Math.max(m,b.y)});const y=(u+p)/2,g=(h+m)/2;a.forEach((b,v)=>a.set(v,{x:y+(b.x-y)*c,y:g+(b.y-g)*c}))}const l=t.nodeAlignment??"center";if(l!=="center"){const u=t.rankDir==="LR"||t.rankDir==="RL",h=u?"x":"y",p=u?"width":"height",m=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,y=l==="leading"?-m:m,g=new Map;for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h];g.set(x,Math.max(g.get(x)??0,b[p]))}for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h],w=(g.get(x)-b[p])/2;a.set(b.id,{...v,[h]:x+y*w})}}return a}function bd(e,r,t,n,o,i){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const c=(u,h=new Set)=>{var m;const p=(m=a.get(u))==null?void 0:m.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+c(p,h))},l=[...s.keys()].sort((u,h)=>c(h)-c(u)),d=new Map;for(const u of l){const h=i==null?void 0:i.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}let m=null;for(const b of s.get(u)||[]){let v=d.get(b);if(!v){const x=r.get(b);if(!x)continue;const w=t.get(b)||{w:60,h:60};v={x1:x.x-w.w/2,y1:x.y-w.h/2,x2:x.x+w.w/2,y2:x.y+w.h/2}}m=m?{x1:Math.min(m.x1,v.x1),y1:Math.min(m.y1,v.y1),x2:Math.max(m.x2,v.x2),y2:Math.max(m.y2,v.y2)}:{...v}}if(!m)continue;const y=n(u);m={x1:m.x1-y,y1:m.y1-y,x2:m.x2+y,y2:m.y2+y};const g=o(u);if(g){const b=m.x2-m.x1,v=m.y2-m.y1;if(g.w>b){const x=(g.w-b)/2;m.x1-=x,m.x2+=x}if(g.h>v){const x=(g.h-v)/2;m.y1-=x,m.y2+=x}}d.set(u,m)}return d}function bm(e,r,t){var c,l,d;const n=[...r.weights],o=n.reduce((u,h)=>u+h,0),i=n[r.index]+n[r.index+1],s=Math.min(i*.95,Math.max(i*.05,n[r.index]+t/r.length*o));n[r.index]=s,n[r.index+1]=i-s;const a={...(l=(c=e.adjustment)==null?void 0:c.sections)==null?void 0:l[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function Hv(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r))||n.members!==void 0&&(!Array.isArray(n.members)||n.members.length>1e4||!n.members.every(o=>Array.isArray(o)&&o.length>0&&o.length<=1e4&&o.every(i=>typeof i=="string"&&i.length>0))||new Set(n.members.flat()).size!==n.members.flat().length))throw new RangeError("Invalid grid section proportions.")}function iu(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Dn(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const c=a.parent&&r.has(a.parent)?a.parent:void 0,l=t.get(c)??[];l.push(a.id),t.set(c,l)}const n=[],o=new Map,i=a=>{const c=t.get(a),l=c?c.flatMap(i):e.positions.has(a)?[a]:[];return o.set(a,l),c&&n.push(c),l},s=t.get(void 0)??[];return s.forEach(i),n.push(s),{groups:n,leaves:o,children:t,roots:s}}function pr(e,r,t=e.fixedSizes){const n=bd(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const o of e.nodes){if(n.has(o.id))continue;const i=r.get(o.id),s=e.sizes.get(o.id);i&&s&&n.set(o.id,Zt({...i,...s}))}return n}function Kv(e,r,t,n){const o=t.get(e),i=t.get(r);if(!o||!i)return;const s={x:Math.min(o.x2-i.x1,i.x2-o.x1)+n,y:Math.min(o.y2-i.y1,i.y2-o.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function On(e,r,t){const n=[];for(const o of e)for(let i=0;i<o.length;i++)for(let s=i+1;s<o.length;s++){const a=Kv(o[i],o[s],r,t);a&&n.push(a)}return n}function Jv(e,r={}){const t=iu(r),{groups:n}=Dn(e);return On(n,pr(e,e.positions),t)}function Zv(e,r,t,n){var a,c,l;const o=new Set(e),i=(((l=(c=(a=r.adjustment)==null?void 0:a.sections)==null?void 0:c[t])==null?void 0:l.members)??[]).map(d=>d.filter(u=>o.delete(u))).filter(d=>d.length),s=e.filter(d=>o.has(d));for(let d=0;d<s.length;d+=n)i.push(s.slice(d,d+n));return i}function kj(e,r,t,n,o){var v,x,w,C;if(t===n)return;const{groups:i,leaves:s}=Dn(e),a=i.find(S=>S.includes(t)&&S.includes(n));if(!a||a.some(S=>e.fixedIds.has(S)||(s.get(S)??[]).some(_=>e.fixedIds.has(_))))return;const c=pr(e,e.positions);if(a.some(S=>!c.has(S)))return;const l=((v=e.nodes.find(S=>S.id===t))==null?void 0:v.parent)??"canvas",d=(w=(x=r.adjustment)==null?void 0:x.sections)==null?void 0:w[l],u=[],h=[...a].sort((S,_)=>{const k=c.get(S),E=c.get(_),O=(k.y1+k.y2-E.y1-E.y2)/2;return Math.abs(O)>1?O:k.x1-E.x1});for(const S of h){const _=u.at(-1),k=c.get(S),E=_&&c.get(_[0]);E&&Math.abs(k.y1+k.y2-E.y1-E.y2)<2?_.push(S):u.push([S])}const p=u.map((S,_)=>{var k;return{weight:((k=d==null?void 0:d.rows)==null?void 0:k[_])??1,cells:S.map((E,O)=>{var P,A;return{id:E,weight:((A=(P=d==null?void 0:d.columns)==null?void 0:P[_])==null?void 0:A[O])??1}})}});for(const S of p)S.cells=S.cells.filter(_=>_.id!==t);const m=p.filter(S=>S.cells.length),y=m.findIndex(S=>S.cells.some(_=>_.id===n)),g=m[y];if(!g)return;o==="above"||o==="below"?m.splice(y+(o==="below"?1:0),0,{weight:1,cells:[{id:t,weight:1}]}):g.cells.splice(g.cells.findIndex(S=>S.id===n)+(o==="after"?1:0),0,{id:t,weight:1});const b=m.map(S=>S.cells.map(_=>_.id));if(JSON.stringify(b)!==JSON.stringify(u))return{...r,adjustment:{...r.adjustment,sections:{...(C=r.adjustment)==null?void 0:C.sections,[l]:{...d,members:b,rows:m.map(S=>S.weight),columns:m.map(S=>S.cells.map(_=>_.weight))}}}}}function sd(e,r={}){var d;Hv(r.adjustment);const t=iu(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(u=>!Number.isFinite(u)||u<0))throw new RangeError("Grid gaps must be finite and non-negative.");const o=r.padding??0;if(!Number.isFinite(o)||o<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return Rj(e,r,n,o);const{groups:i,leaves:s}=Dn(e),a=new Map([...e.positions].map(([u,h])=>[u,{...h}])),c=new Set;for(const u of i){const h=pr(e,a),p=u.filter(P=>h.has(P));if(p.length<2)continue;if(p.some(P=>e.fixedIds.has(P)||(s.get(P)??[]).some(A=>e.fixedIds.has(A)))){p.forEach(P=>c.add(P));continue}const y=p.map(P=>h.get(P)),g=Math.max(...y.map(P=>P.x2-P.x1)),b=Math.max(...y.map(P=>P.y2-P.y1)),v=Math.min(p.length,r.columns??Math.ceil(Math.sqrt(p.length))),x=((d=e.nodes.find(P=>P.id===p[0]))==null?void 0:d.parent)??"canvas",w=Zv(p,r,x,v),C=Math.max(...w.map(P=>P.length)),S=g+n.x,_=b+n.y,k=y.map(P=>({x:(P.x1+P.x2)/2,y:(P.y1+P.y2)/2})),E=(Math.min(...k.map(P=>P.x))+Math.max(...k.map(P=>P.x)))/2,O=(Math.min(...k.map(P=>P.y))+Math.max(...k.map(P=>P.y)))/2;w.forEach((P,A)=>P.forEach((M,T)=>{const N=h.get(M),$={x:E+(T-(C-1)/2)*S-(N.x1+N.x2)/2,y:O+(A-(w.length-1)/2)*_-(N.y1+N.y2)/2};for(const I of s.get(M)??[]){const W=a.get(I);a.set(I,{x:W.x+$.x,y:W.y+$.y})}}))}const l=[...a].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:a,movedNodeIds:l,skippedNodeIds:[...c],collisions:On(i,pr(e,a),Math.min(n.x,n.y))}}function Rj(e,r,t,n){const{groups:o,children:i,roots:s}=Dn(e),a=new Map([...e.positions].map(([g,b])=>[g,{...b}]));if(e.nodes.some(g=>e.fixedIds.has(g.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(g=>g.id),collisions:Jv(e,{margin:Math.min(t.x,t.y)})};const c=e.viewportSize,l=Math.min(n,Math.max(0,(c.w-1)/2)),d=Math.min(n,Math.max(0,(c.h-1)/2)),u={x1:l,y1:d,x2:Math.max(l+1,c.w-l),y2:Math.max(d+1,c.h-d)},h=new Map,p=[],m=(g,b,v="canvas")=>{var T,N;if(!g.length)return;const x=b.x2-b.x1,w=b.y2-b.y1,C=Math.min(g.length,r.columns??Math.max(1,Math.round(Math.sqrt(g.length*x/w)))),S=Zv(g,r,v,C),_=S.length,k=Math.min(t.y,w/(2*_)),E=(N=(T=r.adjustment)==null?void 0:T.sections)==null?void 0:N[v],O=Array.from({length:_},($,I)=>{var W;return((W=E==null?void 0:E.rows)==null?void 0:W[I])??1}),P=O.reduce(($,I)=>$+I,0),A=w-(_-1)*k;let M=b.y1;for(let $=0;$<_;$++){const I=A*O[$]/P,W=S[$].length,ie=Math.min(t.x,x/(2*W)),ae=Array.from({length:W},(L,z)=>{var G,D;return((D=(G=E==null?void 0:E.columns)==null?void 0:G[$])==null?void 0:D[z])??1}),re=ae.reduce((L,z)=>L+z,0),ye=x-(W-1)*ie;let be=b.x1;for(let L=0;L<W;L++){const z=S[$][L],G=ye*ae[L]/re,D=i.get(z);if(D){a.set(z,{x:be+G/2,y:M+I/2}),h.set(z,{w:G,h:I});const se=Math.min(e.padding(z),Math.max(0,(Math.min(G,I)-1)/2));m(D,{x1:be+se,y1:M+se,x2:be+G-se,y2:M+I-se},z)}else a.has(z)&&(a.set(z,{x:be+G/2,y:M+I/2}),h.set(z,{w:G,h:I}));L<W-1&&p.push({section:v,axis:"x",row:$,index:L,weights:ae,length:ye,position:{x:be+G+ie/2,y:M+I/2}}),be+=G+ie}$<_-1&&p.push({section:v,axis:"y",row:$,index:$,weights:O,length:A,position:{x:b.x1+x/2,y:M+I+k/2}}),M+=I+k}};m(s,u);const y=[...a].filter(([g,b])=>{const v=e.positions.get(g);return!v||b.x!==v.x||b.y!==v.y}).map(([g])=>g);return{positions:a,movedNodeIds:y,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:On(o,pr({...e,sizes:h},a,h),0)}}function Aj(e,r={}){const t=iu(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:o,leaves:i}=Dn(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(i.get(u)??[]).some(h=>e.fixedIds.has(h));let c=On(o,pr(e,s),t),l=0;for(;c.length&&l<n;){let u=!1;for(const h of o){if(h.length<2)continue;const p=pr(e,s),m=(y,g,b)=>{for(const x of i.get(y)??[])s.get(x)[g]+=b;const v=p.get(y);g==="x"?(v.x1+=b,v.x2+=b):(v.y1+=b,v.y2+=b)};for(let y=0;y<h.length;y++)for(let g=y+1;g<h.length;g++){const b=h[y],v=h[g],x=Kv(b,v,p,t);if(!x)continue;const w=a(b),C=a(v);if(w&&C)continue;const S=x.overlap.x<=x.overlap.y?"x":"y",_=p.get(b),k=p.get(v),E=S==="x"?_.x1+_.x2<=k.x1+k.x2?-1:1:_.y1+_.y2<=k.y1+k.y2?-1:1,O=x.overlap[S];w||m(b,S,E*O/(C?1:2)),C||m(v,S,-E*O/(w?1:2)),u=!0}}if(l++,c=On(o,pr(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:c,iterations:l,resolved:c.length===0}}function Pj({dividers:e,options:r,zoom:t,onChange:n}){const o=j.useRef();return f.jsx(f.Fragment,{children:e.map(i=>{const s=i.axis==="x",a=s?Z.PiArrowsHorizontal:Z.PiArrowsVertical,c=`${s?"Column":"Row"} divider ${i.index+1}${s?` in row ${i.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":c,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*i.weights[i.index]/(i.weights[i.index]+i.weights[i.index+1])),title:c,"data-flow-grid-adjustment":"",style:{position:"absolute",left:i.position.x,top:i.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:l=>{if(l.button!==0)return;l.preventDefault(),l.stopPropagation();const d=l.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();o.current={pointerId:l.pointerId,start:s?l.clientX:l.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:i,options:r},l.currentTarget.setPointerCapture(l.pointerId)},onPointerMove:l=>{const d=o.current;if(!d||d.pointerId!==l.pointerId)return;l.preventDefault(),l.stopPropagation();const u=((s?l.clientX:l.clientY)-d.start)/d.scale;n(bm(d.options,d.divider,u))},onPointerUp:l=>{o.current&&(l.stopPropagation(),o.current=void 0,l.currentTarget.releasePointerCapture(l.pointerId))},onPointerCancel:()=>{o.current&&n(o.current.options),o.current=void 0},onLostPointerCapture:()=>{o.current=void 0},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.key==="Escape"&&o.current&&(n(o.current.options),o.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(l.key);d<0||(l.preventDefault(),l.stopPropagation(),n(bm(r,i,i.length*(l.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${i.section}:${i.axis}:${i.row}:${i.index}`)})})}const vm=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top,cd=new WeakMap;function xm(e,r){const t=[...r.querySelectorAll(".flow-sdk-edge-label")];if(!t.length){cd.delete(r);return}const n=r==null?void 0:r.getScreenCTM();if(!r||!n)return;const o=n.inverse(),i=(u,h=0)=>{const p=u.getBoundingClientRect(),m=new DOMPoint(p.left,p.top).matrixTransform(o),y=new DOMPoint(p.right,p.bottom).matrixTransform(o);return{left:m.x-h,right:y.x+h,top:m.y-h,bottom:y.y+h}},s=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>u.closest(".flow-sdk-canvas")===e).filter(u=>{const h=u.getBoundingClientRect(),p=getComputedStyle(u);return h.width>0&&h.height>0&&p.visibility!=="hidden"&&p.opacity!=="0"}).map(u=>i(u,24));for(const u of r.querySelectorAll(".flow-sdk-container-label"))s.push(i(u,12));const a=new Map([...e.querySelectorAll(".flow-sdk-edge")].filter(u=>u.closest(".flow-sdk-canvas")===e).map(u=>[u.dataset.edgeId,u.querySelector("path")])),c=JSON.stringify([s,[...a].map(([u,h])=>[u,h==null?void 0:h.getAttribute("d")]),t.map(u=>{var m;const h=u.getBBox(),p=(m=u.querySelector("rect"))==null?void 0:m.getBBox();return[u.dataset.edgeId,u.dataset.labelTransform,u.dataset.labelHorizontal,h.x,h.y,h.width,h.height,p==null?void 0:p.width,p==null?void 0:p.height]})],(u,h)=>typeof h=="number"?Math.round(h*1e3)/1e3:h),l=cd.get(r);if((l==null?void 0:l.geometry)===c&&t.every(u=>l.transforms.has(u))){for(const u of t){const h=l.transforms.get(u);u.getAttribute("transform")!==h&&u.setAttribute("transform",h)}return}for(const u of t)u.setAttribute("transform",u.dataset.labelTransform??"");const d=new Map(t.map(u=>[u,i(u,8)]));for(const u of t){const h=u.dataset.labelHorizontal==="true",p=d.get(u);d.delete(u);const m=E=>s.some(O=>vm(E,O))||[...d.values()].some(O=>vm(E,O));if(!h&&!m(p)){d.set(u,p);continue}const y=a.get(u.dataset.edgeId),g=u.querySelector("rect");if(!y||!g)continue;const b=g.getBBox(),v=y.getTotalLength();if(!Number.isFinite(v)||v<=0)continue;const x=(p.left+p.right)/2,w=(p.top+p.bottom)/2,C=Math.min(256,Math.max(16,Math.ceil(v/24))),S=Array.from({length:C+1},(E,O)=>y.getPointAtLength(v*O/C)),k=Array.from({length:C+1},(E,O)=>{const P=v*O/C,A=S[O],M=h?{x:A.x,y:A.y-b.height/2-15}:A,T=y.getPointAtLength(Math.max(0,P-2)),N=y.getPointAtLength(Math.min(v,P+2));let $=Math.atan2(N.y-T.y,N.x-T.x)*180/Math.PI;$>90&&($-=180),$<-90&&($+=180);const I=Math.abs($)<1;h&&($=0);const W=$*Math.PI/180,ie=Math.abs(Math.cos(W))*b.width+Math.abs(Math.sin(W))*b.height,ae=Math.abs(Math.sin(W))*b.width+Math.abs(Math.cos(W))*b.height;return{point:M,angle:$,straight:I,score:Math.hypot(M.x-x,M.y-w),bounds:{left:M.x-ie/2-8,right:M.x+ie/2+8,top:M.y-ae/2-8,bottom:M.y+ae/2+8}}}).sort((E,O)=>E.score-O.score).find(E=>!m(E.bounds)&&(!h||E.straight&&!S.some(O=>O.x>E.bounds.left&&O.x<E.bounds.right&&O.y>E.bounds.top&&O.y<E.bounds.bottom)));k?(u.setAttribute("transform",`translate(${k.point.x} ${k.point.y}) rotate(${k.angle})`),d.set(u,k.bounds)):d.set(u,p)}cd.set(r,{geometry:c,transforms:new Map(t.map(u=>[u,u.getAttribute("transform")??""]))})}function Mj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Db(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],s=new Set(i.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return i.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const d=Fb(n?kn(o,n):o,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const l=a.getBoundingClientRect();return!l.width||!l.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((l.top-r.top)/t*1e3)/1e3,height:Math.round(l.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function Ij({id:e,x:r,y:t,placed:n,hidden:o,gridDraggable:i,gridDragging:s,gridDropTarget:a,gridSize:c,gridPreview:l,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:m,hasCollapseControl:y,handleColor:g,animated:b,animationColor:v,animationWidth:x=8,animationVariant:w,width:C=0,height:S=0,propertyMode:_,reversePorts:k,direction:E="LR",onPropertyRows:O,onSurface:P,children:A}){var D,se;const M=j.useRef(null),[T,N]=j.useState([]),$=m??T,[I,W]=j.useState(),ie=j.useId(),ae=j.useRef(),re=!!l,ye=!!(l!=null&&l.floating);j.useLayoutEffect(()=>{var je;const X=M.current;if(!X||!re)return;const le=X.cloneNode(!0);le.removeAttribute("data-node-id"),le.removeAttribute("data-grid-dragging"),le.removeAttribute("data-grid-draggable"),le.removeAttribute("data-grid-drop-target"),le.setAttribute("data-grid-preview",e),le.setAttribute("aria-hidden","true"),le.setAttribute("inert","");const ue=[le,...le.querySelectorAll("*")],Ce=new Map(ue.filter(pe=>pe.id).map(pe=>[pe.id,`${pe.id}-${ie}`]));for(const pe of ue){pe.id&&(pe.id=Ce.get(pe.id));for(const fe of[...pe.attributes]){if(fe.name==="id")continue;let Y=fe.value;for(const[H,we]of Ce)Y===`#${H}`&&(Y=`#${we}`),Y=Y.split(`url(#${H})`).join(`url(#${we})`);Y!==fe.value&&pe.setAttribute(fe.name,Y)}}if(Object.assign(le.style,{opacity:"0.35",zIndex:ye?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),ye){const pe=getComputedStyle(X);le.setAttribute("data-grid-preview-floating",""),Object.assign(le.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:pe.font,color:pe.color});for(const fe of ue)fe.removeAttribute("data-node-id"),fe.style.pointerEvents="none"}return le.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(pe=>pe.remove()),(je=ye?document.body:X.parentElement)==null||je.appendChild(le),ae.current=le,()=>{le.remove(),ae.current=void 0}},[e,ie,re,ye]),j.useLayoutEffect(()=>{const X=ae.current;if(!X||!l)return;const{x:le,y:ue,size:Ce}=l;if(ye&&M.current){const fe=M.current,Y=fe.getBoundingClientRect(),H=Y.width/fe.offsetWidth||1,we=Y.height/fe.offsetHeight||1,J=Y.left+(le-r)*H,ve=Y.top+(ue-t)*we;X.style.transform=`translate3d(${J}px, ${ve}px, 0) scale(${H}, ${we})`,X.style.width=`${fe.offsetWidth}px`,X.style.height=`${fe.offsetHeight}px`;return}const je=Ce?Math.round(le-Ce.w/2):le,pe=Ce?Math.round(ue-Ce.h/2):ue;X.style.transform=Ce?`translate3d(${je}px, ${pe}px, 0)`:`translate(-50%, -50%) translate3d(${je}px, ${pe}px, 0)`,X.style.width=Ce?`${Math.round(le+Ce.w/2)-je}px`:"",X.style.height=Ce?`${Math.round(ue+Ce.h/2)-pe}px`:"",Ce&&(X.style.setProperty("--flow-grid-width",`${Ce.w}px`),X.style.setProperty("--flow-grid-height",`${Ce.h}px`),X.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,Ce.w/8,Ce.h/5))}px`))},[l==null?void 0:l.x,l==null?void 0:l.y,(D=l==null?void 0:l.size)==null?void 0:D.w,(se=l==null?void 0:l.size)==null?void 0:se.h,ye,r,t]),j.useLayoutEffect(()=>{const X=M.current;if(!X)return;const le=()=>{const je=Db(X);W(pe=>JSON.stringify(pe)===JSON.stringify(je)?pe:je),P==null||P(e,je)};le();const ue=new ResizeObserver(le);ue.observe(X);const Ce=X.querySelector("[data-flow-node-surface]");return Ce&&ue.observe(Ce),()=>ue.disconnect()},[e,A,P]),j.useLayoutEffect(()=>(d(e,M.current),()=>{d(e,null),P==null||P(e,void 0)}),[e,d,P]),j.useLayoutEffect(()=>{const X=M.current;if(!X)return;let le="";const ue=()=>{const fe=Mj(X),Y=_?fe:fe.filter(we=>we.anchor),H=JSON.stringify(Y);H!==le&&(le=H,N(Y),O==null||O(e,Y))};if(ue(),!_&&!X.querySelector("[data-flow-port-side]"))return;const Ce=new ResizeObserver(ue),je=()=>{Ce.disconnect(),Ce.observe(X),X.querySelectorAll("[data-flow-property]").forEach(fe=>Ce.observe(fe)),ue()};je();const pe=new MutationObserver(je);return pe.observe(X,{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"]}),X.addEventListener("scroll",ue,!0),()=>{Ce.disconnect(),pe.disconnect(),X.removeEventListener("scroll",ue,!0)}},[e,_,O,A]);const be=c?Math.round(r-c.w/2):0,L=c?Math.round(t-c.h/2):0,z=c?Math.round(r+c.w/2)-be:void 0,G=c?Math.round(t+c.h/2)-L:void 0;return f.jsxs("div",{ref:M,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":i||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":c?"":void 0,style:{transform:c?`translate3d(${be}px, ${L}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden",cursor:i?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:l?0:s?.75:void 0,outline:a?`2px solid ${g||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:z,height:G,...c?{"--flow-grid-width":`${c.w}px`,"--flow-grid-height":`${c.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,c.w/8,c.h/5))}px`}:{}},children:[A,!c&&b&&x>0&&C>0&&S>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(oo,{variant:w,x:((I==null?void 0:I.left)??0)+x/2,y:((I==null?void 0:I.top)??0)+x/2,width:((I==null?void 0:I.width)??C)-x,height:((I==null?void 0:I.height)??S)-x,radius:((I==null?void 0:I.radius)??0)-x/2,path:I!=null&&I.outline?`M${I.outline.map(X=>`${X.x} ${X.y}`).join(" L")} Z`:void 0,color:v||g||"currentColor",strokeWidth:x})}),u&&_&&$.map(X=>["source","target"].filter(le=>!X.role||X.role===le).filter(le=>h||(p==null?void 0:p.has(`${le}:${X.property}`))).map(le=>{var ue;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":X.property,"data-port-role":le,"data-port-side":(ue=X.anchor)==null?void 0:ue.side,"aria-label":`${le==="source"?"Connect":"Input"} ${X.property}`,title:`${le==="source"?"Connect":"Input"} ${X.property}`,style:{color:g,...X.anchor?{top:X.anchor.y,left:X.anchor.x-16}:{top:X.top+X.height/2,[le==="source"!=!!k?"right":"left"]:-16}},onClick:Ce=>Ce.stopPropagation()},`${X.property}:${le}`)})),u&&!y&&(!_||!$.length)&&(!_||!$.some(X=>X.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:g,left:((I==null?void 0:I.left)??0)+(E==="RL"?-36:E==="LR"?(I==null?void 0:I.width)??C:((I==null?void 0:I.width)??C)/2),top:((I==null?void 0:I.top)??0)+(E==="BT"?-36:E==="TB"?(I==null?void 0:I.height)??S:((I==null?void 0:I.height)??S)/2),transform:E==="BT"||E==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:X=>X.stopPropagation(),children:f.jsx(Z.PiPlusBold,{size:24})})]})}const Tj=j.memo(Ij);function Oj(e,r,t){const[n,o]=j.useState(()=>({nodes:new Set,edges:new Set})),i=j.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=r.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),l=new Set(c.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>l.has(p)));if(!t)return{nodes:a,edges:l,ready:l};for(const p of e)c.filter(y=>y.target===p.id&&y.source!==y.target).every(y=>u.has(y.id))&&d.add(p.id);let h=new Set(c.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!c.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(m=>!d.has(m.id));p&&d.add(p.id),h=new Set(c.filter(m=>d.has(m.source)).map(m=>m.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);j.useLayoutEffect(()=>{o(a=>{const c=t?i:{nodes:new Set,edges:new Set},l=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return l(a.nodes,c.nodes)&&l(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[i,t]);const s=j.useCallback(a=>{o(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}class Nj{constructor(r,t,n){Ot(this,"_pan");Ot(this,"_zoom");Ot(this,"minZoom");Ot(this,"maxZoom");Ot(this,"size",{w:0,h:0});Ot(this,"listeners",new Set);Ot(this,"cancelTransition");Ot(this,"animationVersion",0);Ot(this,"captureTransition");Ot(this,"animationsDisabled",!1);Ot(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,o={pan:{...r.pan},zoom:this.clamp(r.zoom)},i=this.animationVersion,s=qb(t,this.animationsDisabled),a=c=>{if(i!==this.animationVersion)return;const l=s?c:1;this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Lb(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const o=this.clamp(t);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:t.x-(t.x-this._pan.x)*i,y:t.y-(t.y-this._pan.y)*i},n)}fit(r,t=0,n=!1,o=1){const i=r.x2-r.x1,s=r.y2-r.y1;if(!(i>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*t)/i,(this.size.h-2*t)/s))*o);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const $j={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},Xn={w:60,h:60},ld=4,qj=30,Lj=500,Fj=45;function wm(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function zj(e){var yu,mu,bu,vu,xu;const{nodes:r,edges:t,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:l=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:m,lineColor:y,drawMode:g,dragMode:b,multiSelect:v,isPerformanceMode:x,disableAnimations:w=!1}=e,[C,S]=j.useState(null),_=j.useMemo(()=>C?(C.mode==="connections"?Hu:Bu)(C.id,r,t):null,[C,r,t]),k=i==="auto"||i==="properties",E=j.useMemo(()=>t.filter(R=>md(R,i)&&(!_||_.has(R.source)&&_.has(R.target))),[t,i,_]),O=j.useMemo(()=>o1(r,t,i,s,_),[r,t,i,s,_]),P=j.useRef(O);P.current=O;const A=j.useRef(e);A.current=e;const M=j.useRef(null),T=j.useRef(null),N=j.useRef(null),$=j.useRef(null),I=j.useMemo(()=>new Nj(p,u,h),[]);j.useEffect(()=>{I.minZoom=u,I.maxZoom=h},[I,u,h]),j.useLayoutEffect(()=>{I.setAnimationsDisabled(w)},[I,w]);const W=j.useRef(new Map),ie=j.useRef(new Map),ae=j.useRef(new Map),re=j.useRef(null),[ye,be]=j.useState(new Map),L=j.useCallback((R,q)=>{be(F=>{if(JSON.stringify(F.get(R))===JSON.stringify(q))return F;const K=new Map(F);return q?K.set(R,q):K.delete(R),K})},[]),[z,G]=j.useState(new Map),D=j.useRef(z),se=j.useCallback((R,q)=>{G(F=>{if(JSON.stringify(F.get(R)??[])===JSON.stringify(q))return F;const K=new Map(F);return q.length?K.set(R,q):K.delete(R),K})},[]),[X,le]=j.useState(()=>new Map),ue=j.useRef(X);ue.current=X;const[Ce,je]=j.useState(new Map),pe=j.useRef(Ce),fe=()=>{pe.current=new Map,je(pe.current)},Y=j.useRef(new Map),H=j.useRef(null),we=j.useRef(!1),[J,ve]=j.useState(0),Q=j.useRef(),Ee=j.useRef(),Ae=j.useRef(null),qe=j.useRef(!1),Je=j.useRef(null),Fe=j.useRef(null),ct=j.useRef(),De=j.useRef(l),rt=s,ft=j.useRef(rt),[Oe,Xe]=j.useState(!0),[nt,lt]=j.useState(!!((yu=e.initialNodeGrid)!=null&&yu.enabled)),[zt,kt]=j.useState([]),et=j.useRef((mu=e.initialNodeGrid)!=null&&mu.enabled?{options:{...e.initialNodeGrid.options,animate:!1},order:[...e.initialNodeGrid.order??e.initialNodeGrid.options.order??r.map(R=>R.id)],previousPositions:new Map,previousViewport:p,previousSize:{w:0,h:0},ready:!1}:null),[We,Ht]=j.useState(null),dt=j.useRef(null);dt.current=_;const tr=j.useRef(1);tr.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const ar=j.useRef(null),Bt=j.useRef(r),Dt=j.useRef([]),Kt=j.useRef(!1),rr=()=>{var R;(R=Ae.current)==null||R.call(Ae),Ae.current=null},$r=()=>{Fe.current=null,Dt.current.length&&(Kt.current=!0),!we.current&&A.current.fitOnInit!==!1&&(qe.current=!0),clearTimeout(Ee.current),Ee.current=setTimeout(()=>{we.current=ue.current.size>0,ve(R=>R+1)},Lj)},ze=(R,q,F,K=$r,de)=>{rr();const Me=new Map(ue.current),Se=new Map([...W.current,...pe.current]);Ae.current=Lb(q,ke=>{const Ye=new Map;if(R.forEach((me,Te)=>{const Be=Me.get(Te);Ye.set(Te,Be?{x:Be.x+(me.x-Be.x)*ke,y:Be.y+(me.y-Be.y)*ke}:me)}),ue.current=Ye,le(Ye),de){const me=new Map;for(const[Te,Be]of de){const ee=Se.get(Te)??Be;me.set(Te,{w:ee.w+(Be.w-ee.w)*ke,h:ee.h+(Be.h-ee.h)*ke})}pe.current=me,je(me)}F==null||F(ke)},K)},ce=()=>{var Ye;if(clearTimeout(Q.current),et.current){mt.arrangeNodesInGrid(et.current.options);return}pe.current.size&&fe();const R=A.current,q=tr.current,F=P.current,K=F.nodes.map(me=>{const Te=ie.current.get(me.id);Te&&(Te.offsetWidth||Te.offsetHeight)&&W.current.set(me.id,{w:Te.offsetWidth,h:Te.offsetHeight});const Be=W.current.get(me.id)||Xn;return{id:me.id,parent:me.parent,width:Be.w,height:Be.h}});let de;try{const me=R.compactPropertyLayout,Te=R.edgeMode!=="nodes"&&R.edgeMode!=="workflow",Be=F.edges.map(ee=>({...ee,connectorClearance:me?Te&&(ee.sourceProperty!==void 0||ee.targetProperty!==void 0)?n1:r1:0}));de=Ej(K,Be,{edgeLabelFontSize:R.edgeMode==="nodes"||R.edgeMode==="workflow"?Vb:io,rankDir:R.direction,compact:me,nodeAlignment:R.nodeAlignment,rankSep:R.rankSep*q,edgeSep:R.edgeSep*q,nodeSep:5*q,spacingFactor:R.spacingFactor??1.3,compactSpacingScale:(R.compactSpacingScale??(R.spacingFactor??1.3)/1.3)*q})}catch(me){console.warn("[flow-sdk] layout failed",me);return}const Me=Fe.current?null:H.current;H.current=null;const Se=Me&&de.get(Me.id);if(Me&&Se){const me={x:Me.position.x-Se.x,y:Me.position.y-Se.y};de=new Map([...de].map(([Te,Be])=>[Te,{x:Be.x+me.x,y:Be.y+me.y}]))}for(const[me,Te]of Y.current)de.has(me)?de.set(me,Te):R.nodes.some(Be=>Be.id===me)||Y.current.delete(me);if(Fe.current){const me=JSON.stringify([K,[...de],I.size,R.isPerformanceMode,R.disableAnimations]);if(((Ye=ct.current)==null?void 0:Ye.focus)===Fe.current&&ct.current.geometry===me)return;ct.current={focus:Fe.current,geometry:me}}else ct.current=void 0;const ke=I.coordinate(()=>{var me;return(me=Fe.current)==null?void 0:me.call(Fe,de)});ze(de,we.current&&!R.isPerformanceMode&&!R.disableAnimations,ke)},B=j.useCallback(()=>{clearTimeout(Ee.current),clearTimeout(Q.current),Q.current=setTimeout(ce,A.current.layoutDebounce)},[]);j.useLayoutEffect(()=>{const R=new Map(Bt.current.map(q=>[q.id,q]));r.some(q=>{var F;return((F=R.get(q.id))==null?void 0:F.collapsed)===!0&&!q.collapsed})&&(Dt.current=r.filter(q=>!R.has(q.id)).map(q=>q.id)),Bt.current=r,De.current!==l&&ue.current.size>0&&(we.current=!0,qe.current=!1,clearTimeout(Ee.current)),De.current=l,ft.current!==rt&&(qe.current=!Je.current),ft.current=rt,B()},[r,t,O.nodes,O.edges,rt,n,o,a,c,B,l,d,w,e.nodeGridSpacing]),j.useEffect(()=>()=>{clearTimeout(Q.current),clearTimeout(Ee.current),rr()},[]);const oe=j.useCallback((R,q)=>{var F,K;if(!re.current&&typeof ResizeObserver<"u"&&(re.current=new ResizeObserver(de=>{let Me=!1;for(const Se of de){const ke=ae.current.get(Se.target);if(!ke||pe.current.has(ke))continue;const Ye=Se.target,me=Ye.offsetWidth,Te=Ye.offsetHeight;if(!me&&!Te)continue;const Be=W.current.get(ke);if(Be&&Be.w===me&&Be.h===Te)continue;const ee=ue.current.get(ke);Be&&ee&&we.current&&!H.current&&(H.current={id:ke,position:{...ee}}),W.current.set(ke,{w:me,h:Te}),Me=!0}Me&&B()})),q){ie.current.set(R,q),ae.current.set(q,R),(F=re.current)==null||F.observe(q);const de=q.offsetWidth,Me=q.offsetHeight;!pe.current.has(R)&&(de||Me)&&W.current.set(R,{w:de,h:Me})}else{const de=ie.current.get(R);de&&((K=re.current)==null||K.unobserve(de),ae.current.delete(de)),ie.current.delete(R),W.current.delete(R),D.current.has(R)&&se(R,[])}B()},[B,se]);j.useEffect(()=>()=>{var R;return(R=re.current)==null?void 0:R.disconnect()},[]);const $e=R=>{var K;const q=(K=A.current.nodes.find(de=>de.id===R))==null?void 0:K.label;if(!q)return;const F=A.current.containerStyle(R);return{w:yo(q,`bold ${F.fontSize}px ${hr}`)+2*Fj,h:0}},U=j.useMemo(()=>{const R=new Map;for(const q of r)q.label&&R.set(q.id,q.label);return R},[r]),ge=j.useMemo(()=>bd(O.nodes,X,new Map([...W.current,...Ce]),R=>m(R).padding,$e,Ce),[O.nodes,X,m,U,Ce]),Ie=j.useRef(ge);Ie.current=ge;const xe=j.useCallback(R=>{const q=Ie.current.get(R);if(q)return Dw(q);const F=ue.current.get(R);if(!F)return;const K=pe.current.get(R)||W.current.get(R)||Xn;return{x:F.x,y:F.y,w:K.w,h:K.h}},[]),Ze=j.useMemo(()=>{const R=new Map;for(const q of r){const F=xe(q.id);F&&R.set(q.id,F)}return Yw(z,R,ye,t,n)},[z,r,X,ge,ye,t,n,xe]);D.current=Ze;const Qe=(R,q)=>{var de;if(!k||q===void 0)return;const F=(de=Ze.get(R))==null?void 0:de.find(Me=>Me.property===q),K=xe(R);return F&&!F.anchor&&K?K.y-K.h/2+F.top+F.height/2:void 0},Ke=(R,q)=>{var de,Me;if(q===void 0)return;const F=(Me=(de=Ze.get(R))==null?void 0:de.find(Se=>Se.property===q))==null?void 0:Me.anchor,K=xe(R);return F&&K?{x:K.x-K.w/2+F.x,y:K.y-K.h/2+F.y,side:F.side}:void 0},vt=(R,q)=>{const F=xe(R),K=ye.get(R);return F&&K&&!ge.has(R)&&Qe(R,q)===void 0?kn(F,(n==="TB"||n==="BT")&&K.captionBottom!==void 0?{...K,height:Math.max(K.height,K.captionBottom-K.top),outline:void 0}:K):F},It=()=>{const R=[];ue.current.forEach((q,F)=>{if(Ie.current.has(F))return;const K=xe(F);K&&R.push(Zt(K))}),Ie.current.forEach(q=>R.push(q));try{for(const q of[T.current,N.current]){const F=q==null?void 0:q.getBBox();F&&F.width>0&&F.height>0&&R.push({x1:F.x,y1:F.y,x2:F.x+F.width,y2:F.y+F.height})}}catch{}return Vo(R)},Jt=()=>{var F,K;const{pan:R,zoom:q}=I;$.current&&($.current.style.transform=`translate3d(${R.x}px, ${R.y}px, 0) scale(${q})`),(F=T.current)==null||F.setAttribute("transform",`translate(${R.x} ${R.y}) scale(${q})`),(K=N.current)==null||K.setAttribute("transform",`translate(${R.x} ${R.y}) scale(${q})`)};j.useEffect(()=>{Jt();let R=null,q;const F=I.onChange(()=>{Jt();const K=M.current;K&&(K.classList.add("flow-sdk-busy"),clearTimeout(q),q=setTimeout(()=>K.classList.remove("flow-sdk-busy"),150)),R===null&&(R=requestAnimationFrame(()=>{var de,Me;R=null,(Me=(de=A.current).onViewportChange)==null||Me.call(de,I.state)}))});return()=>{F(),clearTimeout(q),R!==null&&cancelAnimationFrame(R)}},[]),j.useLayoutEffect(()=>{const R=M.current;if(!R)return;const q=()=>{var Se;if(!R.getClientRects().length)return;let K=R.clientWidth,de=R.clientHeight;de||(de=Math.max(0,window.innerHeight-R.getBoundingClientRect().top-100),de&&(R.style.height=`${de}px`)),K||(K=window.innerWidth,K&&(R.style.width=`${K}px`));const Me=I.size.w!==K||I.size.h!==de;I.size={w:K,h:de},Me&&((Se=et.current)!=null&&Se.options.fill)&&B(),!we.current&&!ue.current.size&&A.current.fitOnInit!==!1&&(I.set({x:K/2,y:de/2}),Jt())};if(q(),typeof ResizeObserver>"u")return;const F=new ResizeObserver(q);return F.observe(R),()=>F.disconnect()},[I]),j.useLayoutEffect(()=>{if(Kt.current){Kt.current=!1;const q=Dt.current.flatMap(K=>{const de=xe(K);return de?[Zt(de)]:[]});Dt.current=[];const F=Vo(q);if(F){qe.current=!1,I.center(F,A.current.animateViewport);return}}if(!qe.current)return;qe.current=!1;const R=It();R&&(I.fit(R,50,we.current&&A.current.animateViewport),we.current||Jt())},[X]);const mt=j.useMemo(()=>{const R=ee=>{const te=A.current;if(te.nodeGridSpacing!=="layout")return ee;const he=te.direction==="LR"||te.direction==="RL";return{...ee,gaps:{x:he?te.rankSep:te.edgeSep,y:he?te.edgeSep:te.rankSep}}},q=()=>{const ee=A.current,te=P.current.nodes.filter(he=>Yt(he.id,ee.edges,ee.edgeMode)&&(!dt.current||dt.current.has(he.id)));return{nodes:te,positions:ue.current,sizes:new Map(te.map(he=>[he.id,W.current.get(he.id)??Xn])),padding:he=>A.current.containerStyle(he).padding,minSize:$e,fixedIds:new Set(Y.current.keys()),viewportSize:{...I.size}}},F=ee=>Bu(ee,A.current.nodes,A.current.edges),K=(ee,te=!0,he=()=>{},ne,Ge,Re=!1)=>{clearTimeout(Q.current),clearTimeout(Ee.current),Re||(Fe.current=null),Je.current=null,qe.current=!1,Dt.current=[],Kt.current=!1;const _e=te&&!A.current.isPerformanceMode&&!A.current.disableAnimations,it=I.coordinate(()=>{var Ve;ne?ne(_e):Re&&((Ve=Fe.current)==null||Ve.call(Fe,ee))});ze(new Map([...ee].map(([Ve,gt])=>[Ve,{...gt}])),_e,it,he,Ge)},de=(ee,te=50,he=A.current.animateViewport,ne=1,Ge=!1)=>{const Re=_e=>{const it=P.current,Ve=ee??new Set(it.nodes.map(Et=>Et.id)),gt=new Set(it.nodes.map(Et=>Et.parent).filter(Boolean));if(!_e&&(!ee||[...ee].some(Et=>gt.has(Et))))return;const sr=_e&&bd(it.nodes,_e,W.current,Et=>A.current.containerStyle(Et).padding,$e),cr=Vo([...Ve].flatMap(Et=>{const sn=sr==null?void 0:sr.get(Et);if(sn)return[sn];const cn=_e==null?void 0:_e.get(Et),Kn=W.current.get(Et)||Xn,ln=cn?{...cn,...Kn}:xe(Et);return ln?[Zt(ln)]:[]}));cr&&(qe.current=!1,Dt.current=[],Kt.current=!1,I.fit(cr,Number.isFinite(te)?Math.max(0,te):50,he,ne))};Fe.current=Ge?Re:null,Ge||Re(ue.current)},Me=(ee,te,he,ne)=>{var Re;if(!xe(ee))return;const Ge=te==="connections"?ke(ee):F(ee);if(te==="connections"&&tr.current===1.25&&((Re=dt.current)==null?void 0:Re.size)===Ge.size&&[...Ge].every(_e=>dt.current.has(_e))){S({id:ee,mode:te});return}ar.current||(ar.current={pan:{...I.pan},zoom:I.zoom}),dt.current=Ge,A.current.compactPropertyLayout&&(qe.current=!1,Je.current=()=>de(dt.current??Ge,he,ne)),S({id:ee,mode:te}),A.current.compactPropertyLayout||de(Ge,he,ne)},Se=ee=>{Je.current?Je.current=ee:ee()},ke=ee=>Hu(ee,A.current.nodes,A.current.edges),Ye=(ee=>{var te,he,ne;if(ee===void 0)return I.zoom;ee<I.zoom&&((te=et.current)!=null&&te.options.fill)&&!A.current.readOnly&&((ne=(he=A.current).onNodeGridZoomOut)==null?void 0:ne.call(he,et.current.options))===!0||(Fe.current=null,I.set(void 0,ee))}),me=(ee=>{if(ee===void 0)return I.pan;Fe.current=null,I.set(ee)}),Te=(ee,te)=>{var ne;const he=(ne=M.current)==null?void 0:ne.getBoundingClientRect();return{x:ee-((he==null?void 0:he.left)??0),y:te-((he==null?void 0:he.top)??0)}},Be=(ee=0,te=A.current.animateViewport,he=!1)=>{if(he){de(void 0,ee,te,1,!0);return}Fe.current=null,Se(()=>{const ne=It();ne&&I.fit(ne,ee,te)})};return{zoom:Ye,pan:me,setEdgesVisible:Xe,focusNode:(ee,te,he,ne)=>Se(()=>de(new Set([ee]),te,he,.6,ne)),focusBranch:(ee,te,he,ne)=>Se(()=>de(F(ee),te,he,1,ne)),focusConnections:(ee,te,he,ne)=>Se(()=>de(ke(ee),te,he,1,ne)),isolateConnections:(ee,te,he)=>Me(ee,"connections",te,he),isolateBranch:(ee,te,he)=>Me(ee,"branch",te,he),restoreView:(ee=A.current.animateViewport,te)=>{Fe.current=null;const he=A.current.compactPropertyLayout&&!!dt.current;dt.current=null,S(null);const ne=te??ar.current;ar.current=null,he?Je.current=()=>{ne&&I.transition(ne,ee)}:ne&&Se(()=>I.transition(ne,ee))},zoomAt:(ee,te)=>{var he,ne,Ge;ee<I.zoom&&((he=et.current)!=null&&he.options.fill)&&!A.current.readOnly&&((Ge=(ne=A.current).onNodeGridZoomOut)==null?void 0:Ge.call(ne,et.current.options))===!0||(Fe.current=null,I.zoomAt(ee,te))},fit:Be,centerAndFit:Be,center:(ee=A.current.animateViewport)=>{Fe.current=null;const te=It();te&&I.center(te,ee)},clientToModel:(ee,te)=>I.renderedToModel(Te(ee,te)),modelToClient:ee=>{var ne;const te=(ne=M.current)==null?void 0:ne.getBoundingClientRect(),he=I.modelToRendered(ee);return{x:he.x+((te==null?void 0:te.left)??0),y:he.y+((te==null?void 0:te.top)??0)}},getNodeBox:ee=>xe(ee),detectNodeCollisions:ee=>{const te=q();return Jv({...te,sizes:new Map([...te.sizes,...pe.current]),fixedSizes:pe.current},ee)},resolveNodeCollisions:(ee={})=>{const te=Aj(q(),ee);return te.movedNodeIds.length&&K(te.positions,ee.animate),te},arrangeNodesInGrid:(ee={})=>{const te=q(),he=et.current;if(he){te.positions=new Map(te.positions);for(const Ve of te.nodes)te.positions.has(Ve.id)||te.positions.set(Ve.id,I.renderedToModel({x:I.size.w/2,y:I.size.h/2}));const Re=new Set(te.nodes.map(Ve=>Ve.id));he.order=he.order.filter(Ve=>Re.has(Ve));const _e=new Set(he.order);he.order.push(...te.nodes.filter(Ve=>!_e.has(Ve.id)).map(Ve=>Ve.id));const it=new Map(he.order.map((Ve,gt)=>[Ve,gt]));te.nodes=[...te.nodes].sort((Ve,gt)=>it.get(Ve.id)-it.get(gt.id))}const ne=sd(te,R(ee));kt(ne.dividers??[]),he&&(he.ready=!1);const Ge=()=>{he&&(he.ready=!0),he&&te.nodes.length&&!we.current&&(we.current=!0,A.current.fitOnInit!==!1&&!ee.fill?mt.centerAndFit(50,!1):A.current.fitOnInit===!1&&I.transition(p,!1)),ve(Re=>Re+1)};return!ne.sizes&&pe.current.size&&fe(),te.nodes.some(Re=>!ue.current.has(Re.id))||ne.movedNodeIds.length||ne.bounds||Fe.current?K(ne.positions,ee.animate,Ge,ne.bounds&&(!he||!pe.current.size)?()=>I.transition({zoom:1,pan:{x:0,y:0}},!1):void 0,ne.sizes,!!he&&!ne.bounds):Ge(),ne},setNodeGridMode:(ee,te={})=>{var he,ne,Ge,Re;if(te.order&&(!Array.isArray(te.order)||te.order.some(_e=>typeof _e!="string")||new Set(te.order).size!==te.order.length))throw new Error("Invalid grid node order.");if(ee){sd(q(),R(te));const _e=!et.current||et.current.options.fill&&!te.fill;Fe.current=null,et.current||(et.current={options:te,order:q().nodes.map(it=>it.id),previousPositions:new Map([...ue.current].map(([it,Ve])=>[it,{...Ve}])),previousViewport:{zoom:I.zoom,pan:{...I.pan}},previousSize:{...I.size},ready:!1}),_e&&mt.centerAndFit(80,te.animate,!0),te.order&&(et.current.order=[...te.order]),et.current.options={...te},lt(!0),mt.arrangeNodesInGrid(te),(ne=(he=A.current).onNodeGridModeChange)==null||ne.call(he,{...te,order:[...et.current.order]})}else{const _e=et.current;if(!_e)return;if(I.size.w===_e.previousSize.w&&I.size.h===_e.previousSize.h&&ue.current.size===_e.previousPositions.size&&[...ue.current.keys()].every(gt=>_e.previousPositions.has(gt))?Fe.current=()=>I.transition(_e.previousViewport,te.animate!==!1&&!A.current.disableAnimations&&!A.current.isPerformanceMode):mt.centerAndFit(80,te.animate,!0),et.current=null,lt(!1),fe(),(Re=(Ge=A.current).onNodeGridModeChange)==null||Re.call(Ge,null),Ht(null),!_e.previousPositions.size){B();return}const Ve=new Map([...ue.current].map(([gt,sr])=>[gt,_e.previousPositions.get(gt)??sr]));K(Ve,te.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(ee,te,he)=>{var Et,sn,cn,Kn,ln;const ne=et.current;if(!ne||!ne.ready||A.current.readOnly||ee===te)return!1;const Ge=q(),Re=Ge.nodes.find(dn=>dn.id===ee),_e=Ge.nodes.find(dn=>dn.id===te);if(!Re||!_e||Re.parent!==_e.parent)return!1;const it=sd(Ge,R(ne.options));if(it.skippedNodeIds.includes(ee)||it.skippedNodeIds.includes(te))return!1;const Ve=ne.order.indexOf(ee),gt=ne.order.indexOf(te);if(Ve<0||gt<0)return!1;[ne.order[Ve],ne.order[gt]]=[ne.order[gt],ne.order[Ve]],Fe.current=null,ne.options={...ne.options,order:[...ne.order]};const sr=Re.parent??"canvas",cr=(sn=(Et=ne.options.adjustment)==null?void 0:Et.sections)==null?void 0:sn[sr];return cr!=null&&cr.members&&(ne.options={...ne.options,adjustment:{...ne.options.adjustment,sections:{...(cn=ne.options.adjustment)==null?void 0:cn.sections,[sr]:{...cr,members:cr.members.map(dn=>dn.map(Lo=>Lo===ee?te:Lo===te?ee:Lo))}}}}),mt.arrangeNodesInGrid({...ne.options,animate:he??ne.options.animate}),(ln=(Kn=A.current).onNodeGridModeChange)==null||ln.call(Kn,{...ne.options}),!0},setNodePosition:(ee,te,he)=>{if(!ue.current.has(ee)||te&&(!Number.isFinite(te.x)||!Number.isFinite(te.y)))return!1;if(rr(),!te)return Y.current.delete(ee),B(),!0;const ne=new Map(ue.current);return ne.set(ee,{...te}),(he==null?void 0:he.persist)===!1?Y.current.delete(ee):Y.current.set(ee,{...te}),ue.current=ne,le(ne),(he==null?void 0:he.persist)===!1&&B(),!0},onViewportChange:ee=>I.onChange(ee)}},[]);j.useEffect(()=>{var R,q;return(q=(R=A.current).onInit)==null||q.call(R,mt),()=>I.cancelAnimation()},[mt]),j.useEffect(()=>{var R,q;if(J>0){const F=Je.current;Je.current=null,F==null||F(),(q=(R=A.current).onLayoutComplete)==null||q.call(R,mt)}},[mt,J]);const pt=j.useRef(null),xt=j.useRef(new Map),Tt=j.useRef(!1),[wr,Gn]=j.useState(null),[at,on]=j.useState(null),Un=R=>{const q=M.current.getBoundingClientRect();return{x:(R.clientX-q.left)*(M.current.clientWidth/q.width||1),y:(R.clientY-q.top)*(M.current.clientHeight/q.height||1)}},Hn=(R,q)=>{const F=A.current.nodes;for(let K=F.length-1;K>=0;K--){const de=F[K].id;if(!Yt(de,A.current.edges,A.current.edgeMode)||dt.current&&!dt.current.has(de)||de===q||Ie.current.has(de))continue;const Me=xe(de);if(Me&&Du(R,Zt(Me)))return de}for(const[K,de]of Ie.current)if(Yt(K,A.current.edges,A.current.edgeMode)&&!(dt.current&&!dt.current.has(K))&&K!==q&&Du(R,de))return K;return null},uu=(R,q)=>{const F=A.current.nodes.find(ke=>ke.id===R),K=xe(R);if(!F||!K)return null;const de=Zt({...K,x:K.x+q.x,y:K.y+q.y});let Me=null,Se=0;for(const ke of A.current.nodes){if(ke.id===R||ke.parent!==F.parent||Y.current.has(ke.id)||Ie.current.has(ke.id)||!Yt(ke.id,A.current.edges,A.current.edgeMode)||dt.current&&!dt.current.has(ke.id))continue;const Ye=xe(ke.id);if(!Ye)continue;const me=Zt(Ye),Te=Math.max(0,Math.min(de.x2,me.x2)-Math.max(de.x1,me.x1))*Math.max(0,Math.min(de.y2,me.y2)-Math.max(de.y1,me.y1));Te>Se&&(Se=Te,Me=ke.id)}return Me},fu=(R,q)=>{const F=et.current;if(!(F!=null&&F.ready)||A.current.readOnly)return;const K=A.current.nodes.filter(Te=>Yt(Te.id,A.current.edges,A.current.edgeMode)&&(!dt.current||dt.current.has(Te.id))),de=K.find(Te=>Te.id===R);if(!de)return;const Me=M.current,Se=I.zoom*(Me&&Me.clientWidth?Me.getBoundingClientRect().width/Me.clientWidth:1),ke=24/Se;let Ye;for(const Te of K){if(Te.id===R||Te.parent!==de.parent)continue;const Be=xe(Te.id);if(!Be)continue;const ee=Zt(Be),te=Math.min(Be.w/4,ke),he=Math.min(Be.h/4,ke),ne=3/Se,Ge=[];if(q.y>ee.y1+he&&q.y<ee.y2-he)for(const Re of["before","after"]){const _e=Re==="before"?ee.x1:ee.x2,it=Math.abs(q.x-_e),Ve=Re==="before"?q.x<_e:q.x>_e;it<=(Ve?ke:te)&&Ge.push({side:Re,distance:it,marker:{x1:_e-ne/2,x2:_e+ne/2,y1:ee.y1,y2:ee.y2}})}if(q.x>=ee.x1&&q.x<=ee.x2)for(const Re of["above","below"]){const _e=Re==="above"?ee.y1:ee.y2,it=Math.abs(q.y-_e),Ve=Re==="above"?q.y<_e:q.y>_e;it<=(Ve?ke:he)&&Ge.push({side:Re,distance:it,marker:{x1:ee.x1,x2:ee.x2,y1:_e-ne/2,y2:_e+ne/2}})}for(const Re of Ge)(!Ye||Re.distance<Ye.distance)&&(Ye={id:Te.id,...Re})}if(!Ye)return;const me=kj({nodes:K,positions:ue.current,sizes:new Map([...W.current,...pe.current]),fixedSizes:pe.current,padding:Te=>A.current.containerStyle(Te).padding,minSize:$e,fixedIds:new Set(Y.current.keys())},F.options,R,Ye.id,Ye.side);return me?{options:me,marker:Ye.marker}:void 0},Oo=(R,q)=>{if(A.current.edgeMode==="nodes"||A.current.edgeMode==="workflow")return null;const F=A.current.direction==="RL",K=Math.max(16,6/I.zoom);let de=null;for(const Me of[...A.current.nodes].reverse()){if(!Yt(Me.id,A.current.edges,A.current.edgeMode)||dt.current&&!dt.current.has(Me.id))continue;const Se=xe(Me.id),ke=D.current.get(Me.id);if(!Se||!ke||Ie.current.has(Me.id))continue;const Ye=Se.x+(q==="source"!==F?1:-1)*Se.w/2;for(const me of ke){if(me.role&&me.role!==q)continue;const Te=Se.y-Se.h/2+me.top,Be=Math.hypot(R.x-(me.anchor?Se.x-Se.w/2+me.anchor.x:Ye),R.y-Te-me.height/2);if(!me.anchor&&R.x>=Se.x-Se.w/2&&R.x<=Se.x+Se.w/2&&R.y>=Te&&R.y<=Te+me.height)return{nodeId:Me.id,property:me.property};Be<=K&&(!de||Be<de.distance)&&(de={nodeId:Me.id,property:me.property,distance:Be})}}return de},ix=R=>{var ke,Ye;if(!R.currentTarget.contains(R.target)||(pt.current||(Tt.current=!1),R.target.closest(".flow-sdk-canvas")!==R.currentTarget)||R.button!==0||A.current.readOnly)return;const q=R.target;if(q.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const F=A.current,K=Un(R);if(R.pointerType==="touch"){xt.current.set(R.pointerId,K);const me=wm(xt.current);if(me){Ht(null),pt.current={kind:"pinch",distance:me.distance,zoom:I.zoom,anchor:I.renderedToModel(me.center)},on(null),Gn(null),Tt.current=!0;for(const Te of xt.current.keys())R.currentTarget.setPointerCapture(Te);return}}if(pt.current)return;const de=!et.current||!!F.nodeGridConnections,Me=F.drawHandles&&q.closest(".flow-sdk-handle"),Se=F.drawHandles&&q.closest(".flow-sdk-property-port");if((!de||!Me&&!Se&&(!F.drawMode||R.shiftKey))&&(et.current||R.shiftKey&&(F.onNodeGridDrop||F.onNodeParentChange))){if(et.current&&!et.current.ready||q.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const me=(ke=q.closest("[data-node-id]"))==null?void 0:ke.dataset.nodeId;if(me&&!Y.current.has(me)){q.setPointerCapture(R.pointerId),pt.current={kind:"grid",pointerId:R.pointerId,captureTarget:q,source:me,start:K,moved:!1};return}if(me)return}if(de&&(F.drawMode||Me||Se)){const me=I.renderedToModel(K),Te=F.drawMode?Oo(me,"source"):null,Be=Se||Me,ee=Be?(Ye=Be.closest("[data-node-id]"))==null?void 0:Ye.dataset.nodeId:(Te==null?void 0:Te.nodeId)??Hn(me),te=Se?Se.dataset.property:Te==null?void 0:Te.property;if(ee){pt.current={kind:"draw",pointerId:R.pointerId,source:ee,sourceProperty:te,reverse:(Se==null?void 0:Se.dataset.portRole)==="target",startClient:{x:R.clientX,y:R.clientY}},Tt.current=!0,on({source:ee,sourceProperty:te,point:me,target:null}),R.currentTarget.setPointerCapture(R.pointerId);return}}q.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(Fe.current=null,F.multiSelect?pt.current={kind:"box",pointerId:R.pointerId,start:K,current:K}:F.dragMode?pt.current={kind:"pan",pointerId:R.pointerId,start:K,pan0:I.pan,moved:!1}:pt.current={kind:"tap",pointerId:R.pointerId,start:K,moved:!1},R.currentTarget.setPointerCapture(R.pointerId))},ax=R=>{var K,de,Me;const q=pt.current;if(!q||A.current.readOnly)return;const F=Un(R);if(xt.current.has(R.pointerId)&&xt.current.set(R.pointerId,F),q.kind==="pinch"){const Se=wm(xt.current);if(!Se)return;const ke=Math.max(I.minZoom,Math.min(I.maxZoom,q.zoom*Se.distance/q.distance));if(ke<I.zoom&&((K=et.current)!=null&&K.options.fill)&&((Me=(de=A.current).onNodeGridZoomOut)==null?void 0:Me.call(de,et.current.options))===!0)return;I.set({x:Se.center.x-q.anchor.x*ke,y:Se.center.y-q.anchor.y*ke},ke);return}if(q.pointerId===R.pointerId)switch(q.kind){case"grid":{const Se={x:F.x-q.start.x,y:F.y-q.start.y};if(!q.moved&&Math.hypot(Se.x,Se.y)<=ld)return;q.moved||(rr(),Fe.current=null,I.cancelAnimation()),q.moved=!0,Tt.current=!0,R.preventDefault();const ke={x:Se.x/I.zoom,y:Se.y/I.zoom},Ye=!R.shiftKey&&F.x>=0&&F.y>=0&&F.x<=I.size.w&&F.y<=I.size.h?fu(q.source,I.renderedToModel(F)):void 0;Ht({source:q.source,offset:ke,target:R.shiftKey||Ye?null:uu(q.source,ke),shiftKey:R.shiftKey,insertion:Ye});break}case"pan":{const Se=F.x-q.start.x,ke=F.y-q.start.y;if(!q.moved&&Math.hypot(Se,ke)<=ld)return;q.moved=!0,Tt.current=!0,I.set({x:q.pan0.x+Se,y:q.pan0.y+ke});break}case"tap":{Math.hypot(F.x-q.start.x,F.y-q.start.y)>ld&&(q.moved=!0);break}case"box":{Tt.current=!0,q.current=F,Gn({x1:Math.min(q.start.x,F.x),y1:Math.min(q.start.y,F.y),x2:Math.max(q.start.x,F.x),y2:Math.max(q.start.y,F.y)});break}case"draw":{const Se=I.renderedToModel(F),ke=Oo(Se,q.reverse?"source":"target");on(q.reverse&&ke?{source:ke.nodeId,sourceProperty:ke.property,point:Se,target:q.source,targetProperty:q.sourceProperty}:{source:q.source,sourceProperty:q.sourceProperty,point:Se,target:(ke==null?void 0:ke.nodeId)??Hn(Se,q.source),targetProperty:ke==null?void 0:ke.property});break}}},hu=(R,q)=>{var de,Me,Se,ke,Ye,me,Te,Be,ee,te,he;xt.current.delete(R.pointerId);const F=pt.current;if(!F)return;if(F.kind==="pinch"){const ne=[...xt.current][0];pt.current=ne&&A.current.dragMode&&!q?{kind:"pan",pointerId:ne[0],start:ne[1],pan0:I.pan,moved:!0}:null;return}if(F.pointerId!==R.pointerId)return;pt.current=null;try{(F.kind==="grid"?F.captureTarget:R.currentTarget).releasePointerCapture(R.pointerId)}catch{}const K=A.current;switch(q=q||!!K.readOnly,F.kind){case"grid":{if(Ht(null),q||!F.moved)break;const ne=Un(R);if(!R.shiftKey&&ne.x>=0&&ne.y>=0&&ne.x<=I.size.w&&ne.y<=I.size.h){const Re=fu(F.source,I.renderedToModel(ne));if(Re){mt.setNodeGridMode(!0,{...Re.options,animate:!1});break}}if(((de=K.onNodeGridDrop)==null?void 0:de.call(K,F.source,{x:R.clientX,y:R.clientY},{shiftKey:R.shiftKey,ctrlKey:R.ctrlKey,metaKey:R.metaKey,altKey:R.altKey}))===!0||ne.x<0||ne.y<0||ne.x>I.size.w||ne.y>I.size.h)break;if(R.shiftKey){const Re=new Map(K.nodes.map(Ve=>[Ve.id,Ve]));let _e=Hn(I.renderedToModel(ne),F.source);const it=new Set;for(;_e&&!((Me=Re.get(_e))!=null&&Me.acceptsChildren)&&!it.has(_e);)it.add(_e),_e=((Se=Re.get(_e))==null?void 0:Se.parent)??null;if(_e&&((ke=Re.get(_e))!=null&&ke.acceptsChildren)){let Ve=_e;const gt=new Set;for(;Ve&&!gt.has(Ve);)gt.add(Ve),Ve=(Ye=Re.get(Ve))==null?void 0:Ye.parent;gt.has(F.source)||(me=K.onNodeParentChange)==null||me.call(K,F.source,_e)}break}if(!et.current)break;const Ge=uu(F.source,{x:(ne.x-F.start.x)/I.zoom,y:(ne.y-F.start.y)/I.zoom});Ge&&mt.swapGridNodes(F.source,Ge,!1);break}case"pan":case"tap":!q&&!F.moved&&((Te=K.onBackgroundTap)==null||Te.call(K));break;case"box":{if(Gn(null),q)break;const ne=I.renderedToModel(F.start),Ge=I.renderedToModel(F.current),Re={x1:Math.min(ne.x,Ge.x),y1:Math.min(ne.y,Ge.y),x2:Math.max(ne.x,Ge.x),y2:Math.max(ne.y,Ge.y)};if(Re.x2-Re.x1<1&&Re.y2-Re.y1<1){(Be=K.onBackgroundTap)==null||Be.call(K);break}const _e=[];for(const it of K.nodes){const Ve=xe(it.id);Ve&&Vw(Zt(Ve),Re)&&_e.push(it.id)}_e.length&&((ee=K.onBoxSelect)==null||ee.call(K,_e));break}case"draw":{if(on(null),q)break;const ne=Un(R),Ge=I.renderedToModel(ne),Re=Oo(Ge,F.reverse?"source":"target"),_e=(Re==null?void 0:Re.nodeId)??Hn(Ge);if(_e===F.source&&(F.sourceProperty===void 0||(Re==null?void 0:Re.property)===void 0||Re.property===F.sourceProperty))break;_e?(te=K.onEdgeDraw)==null||te.call(K,F.reverse?_e:F.source,F.reverse?F.source:_e,F.sourceProperty!==void 0||(Re==null?void 0:Re.property)!==void 0?{sourceProperty:F.reverse?Re==null?void 0:Re.property:F.sourceProperty,targetProperty:F.reverse?F.sourceProperty:Re==null?void 0:Re.property}:void 0):Math.max(Math.abs(R.clientX-F.startClient.x),Math.abs(R.clientY-F.startClient.y))>qj&&((he=K.onDrawIntoSpace)==null||he.call(K,F.source,Ge,F.sourceProperty,F.reverse));break}}},Cr=j.useCallback(()=>{var F;const R=pt.current,q=[...xt.current.keys()];R&&R.kind!=="pinch"&&q.push(R.pointerId),pt.current=null,xt.current.clear(),Ht(null),on(null),Gn(null);for(const K of q)(R==null?void 0:R.kind)==="grid"&&R.captureTarget.hasPointerCapture(K)&&R.captureTarget.releasePointerCapture(K),(F=M.current)!=null&&F.hasPointerCapture(K)&&M.current.releasePointerCapture(K)},[]);j.useEffect(()=>{const R=q=>{q.key==="Escape"&&Cr()};return window.addEventListener("keydown",R),window.addEventListener("blur",Cr),()=>{window.removeEventListener("keydown",R),window.removeEventListener("blur",Cr),pt.current=null,xt.current.clear()}},[Cr]),j.useEffect(()=>{Cr()},[g,b,v,i,n,e.drawHandles,e.readOnly,nt,Cr]);const sx=j.useMemo(()=>{const R=new Map,q=new Map;for(const F of E){if(F.source!==F.target)continue;const K=R.get(F.source)??0;R.set(F.source,K+1),q.set(F.id,K)}return q},[E]),No=$j[n],[Sr,cx]=j.useState(null),$o=Oj(r,E,!!((bu=e.edgeReveal)!=null&&bu.revealNodes));j.useLayoutEffect(()=>{M.current&&Sr&&xm(M.current,Sr)}),j.useEffect(()=>{const R=M.current;if(!R||!Sr)return;const q=R.ownerDocument.fonts,F=()=>xm(R,Sr);return q==null||q.addEventListener("loadingdone",F),()=>q==null?void 0:q.removeEventListener("loadingdone",F)},[Sr]);const qo=Bw(E,vt,No),lx=e.onEdgeSelect,dx=e.onContainerSelect,pu=at?at.target&&vt(at.target,at.targetProperty)||{x:at.point.x,y:at.point.y,w:1,h:1}:null,gu=at?vt(at.source,at.sourceProperty):null,an=!nt||!!e.nodeGridConnections,ux=["flow-sdk-canvas",g&&an?"flow-sdk-draw":"",x?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:M,className:ux,"data-edge-mode":i,"data-node-grid":nt||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:ix,onPointerMove:ax,onPointerUp:R=>hu(R,!1),onPointerCancel:R=>hu(R,!0),onLostPointerCapture:R=>{const q=pt.current;q&&(q.kind==="pinch"||q.pointerId===R.pointerId)&&Cr()},onClickCapture:R=>{if(!R.currentTarget.contains(R.target))return;const q=R.target instanceof Element&&R.target.closest("button[data-flow-fullscreen]");(Tt.current||e.readOnly&&!q)&&(R.preventDefault(),R.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:T,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...ge].filter(([R])=>Yt(R,t,i)).filter(([R])=>!_||_.has(R)).map(([R,q])=>{var F,K;return f.jsx(e1,{id:R,rect:q,label:U.get(R),labelLayer:Sr,labelContent:(F=r.find(de=>de.id===R&&de.label!==void 0))==null?void 0:F.element,style:m(R),onSelect:dx,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(K=e.selectedNodeIds)==null?void 0:K.includes(R)},R)})}),f.jsx("g",{className:"flow-sdk-edges",children:Oe&&an&&E.map(R=>{var K,de,Me;if(!$o.ready.has(R.id)||_&&(!_.has(R.source)||!_.has(R.target)))return null;const q=vt(R.source,R.sourceProperty),F=vt(R.target,R.targetProperty);return!q||!F?null:f.jsx(Ju,{id:R.id,edgeData:R.data,validationIssue:R.validationIssue,edgeType:R.type,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:$o.complete,source:q,target:F,sourceProperty:R.sourceProperty,targetProperty:R.targetProperty,sourceY:Qe(R.source,R.sourceProperty),targetY:Qe(R.target,R.targetProperty),sourcePort:Ke(R.source,R.sourceProperty),targetPort:Ke(R.target,R.targetProperty),dir:No,turn:((K=qo.get(R.id))==null?void 0:K.turn)??R.turn,labelAtTarget:(de=qo.get(R.id))==null?void 0:de.labelAtTarget,labelFraction:(Me=qo.get(R.id))==null?void 0:Me.labelFraction,color:R.color,connectorColor:R.connectorColor,labelBg:R.labelBg,label:R.label,labelLayer:Sr,dashed:R.dashed,animated:R.animated&&!x,inverted:R.inverted,loopIndex:sx.get(R.id)??0,onSelect:lx},R.id)})}),Oe&&an&&at&&md(at,i)&&gu&&pu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(Ju,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:at.source,target:at.target??"",sourceProperty:at.sourceProperty,targetProperty:at.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:gu,target:pu,sourceProperty:at.sourceProperty,targetProperty:at.targetProperty,sourceY:Qe(at.source,at.sourceProperty),sourcePort:Ke(at.source,at.sourceProperty),targetPort:at.target?Ke(at.target,at.targetProperty):void 0,targetY:at.target?Qe(at.target,at.targetProperty):void 0,dir:No,turn:.5,color:y,labelBg:y})})]})}),f.jsxs("div",{ref:$,className:"flow-sdk-nodes",children:[(We==null?void 0:We.insertion)&&f.jsx("div",{className:"flow-sdk-box","data-grid-insertion":"",style:{left:We.insertion.marker.x1,top:We.insertion.marker.y1,width:We.insertion.marker.x2-We.insertion.marker.x1,height:We.insertion.marker.y2-We.insertion.marker.y1,background:y,border:0}}),nt&&((vu=et.current)==null?void 0:vu.options.fill)&&((xu=et.current.options.adjustment)==null?void 0:xu.enabled)&&!e.readOnly&&f.jsx(Pj,{dividers:zt,options:et.current.options,zoom:I.zoom,onChange:R=>mt.setNodeGridMode(!0,{...R,animate:!1})}),r.map(R=>{var Ge,Re;const q=X.get(R.id),F=ge.get(R.id);if(F&&R.label!==void 0)return null;const K=(q==null?void 0:q.x)??(F?(F.x1+F.x2)/2:0),de=(q==null?void 0:q.y)??(F?(F.y1+F.y2)/2:0),Me=We!=null&&We.target?R.id===We.source?We.target:R.id===We.target?We.source:void 0:void 0,Se=Me?X.get(Me):void 0,ke=We?X.get(We.source):void 0,Ye=We!=null&&We.target?X.get(We.target):void 0,me=ke&&Ye?{x:Ye.x-ke.x,y:Ye.y-ke.y}:void 0,Te=me?me.x**2+me.y**2:0,Be=Te&&We&&me?Math.max(0,Math.min(1,(We.offset.x*me.x+We.offset.y*me.y)/Te)):0,ee=Se?{x:K+(Se.x-K)*Be,y:de+(Se.y-de)*Be}:(We==null?void 0:We.source)===R.id?{x:K+We.offset.x,y:de+We.offset.y}:void 0,te=Ce.get(R.id),he=Me?Ce.get(Me):void 0,ne=te&&he?{w:te.w+(he.w-te.w)*Be,h:te.h+(he.h-te.h)*Be}:te;return f.jsx(Tj,{id:R.id,x:K,y:de,gridDraggable:nt&&!e.readOnly&&!Y.current.has(R.id),gridDragging:(We==null?void 0:We.source)===R.id,gridDropTarget:(We==null?void 0:We.target)===R.id,gridSize:Ce.get(R.id),gridPreview:ee?{...ee,size:ne,floating:We==null?void 0:We.shiftKey}:void 0,placed:!!q||!!F,hidden:!nt&&!$o.shown.has(R.id)||!Yt(R.id,t,i)||!!_&&!_.has(R.id),onMount:oe,drawHandles:e.drawHandles&&!e.readOnly&&an,drawMode:g&&an,connectedPorts:new Set(E.flatMap(_e=>[..._e.source===R.id&&_e.sourceProperty!==void 0?[`source:${_e.sourceProperty}`]:[],..._e.target===R.id&&_e.targetProperty!==void 0?[`target:${_e.targetProperty}`]:[]])),hasCollapseControl:R.hasCollapseControl,handleColor:y,animated:R.animated&&!F&&!x&&!nt,animationColor:R.animationColor,animationWidth:R.animationWidth,animationVariant:R.animationVariant,width:(Ge=W.current.get(R.id))==null?void 0:Ge.w,height:(Re=W.current.get(R.id))==null?void 0:Re.h,propertyMode:k,resolvedRows:Ze.get(R.id),reversePorts:n==="RL",direction:n,onPropertyRows:se,onSurface:L,children:te?R.fillElement??R.element:R.element},R.id)})]}),wr&&f.jsx("div",{className:"flow-sdk-box",style:{left:wr.x1,top:wr.y1,width:wr.x2-wr.x1,height:wr.y2-wr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:N,transform:`translate(${I.pan.x} ${I.pan.y}) scale(${I.zoom})`,children:f.jsx("g",{ref:cx,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const Bj=j.memo(zj);function au(e=!0){const r=j.useRef(null);return j.useEffect(()=>{if(!e||!r.current)return;const t=i=>{i.stopPropagation()},n=r.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,t)),()=>{o.forEach(i=>n.removeEventListener(i,t))}},[e]),r}const Jr=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:l,config:d,readOnly:u}=He(),h=d.editable&&!u,[p,m]=j.useState(r),[y,g]=j.useState(),b=j.useRef(null),v=j.useRef(!1),x=au(s);j.useEffect(()=>{if(s&&(v.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var S;if(v.current)return;v.current=!0;const C=p.trim();C&&C!==r&&((S=l.onNodeLabelChange)==null||S.call(l,e,C)),c()};return!h||!s?f.jsx(V.Text,{color:t,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),m(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:x,style:{position:"relative",width:"max-content",minWidth:y==null?void 0:y.width,maxWidth:900,height:y==null?void 0:y.height},children:[f.jsx(V.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(V.Input,{ref:b,value:p,onChange:C=>m(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(v.current=!0,c())},color:t,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})};function Yv({id:e,label:r,role:t,side:n,position:o=.5,placement:i,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const Dj=so.default.dialog`
|
|
211
211
|
${e=>gr(e.$surface,e.$border)}
|
|
212
212
|
&,
|
|
213
213
|
&:hover {
|
|
@@ -277,8 +277,8 @@
|
|
|
277
277
|
black calc(100% - 32px),
|
|
278
278
|
transparent
|
|
279
279
|
);
|
|
280
|
-
`;function su({nodeAddress:e,active:r,label:t,open:n=!1,onClose:o,children:i,filter:s,height:a,width:c}){const{background:l,border:d,colorText:u}=st(),{colorMode:h}=He(),p=j.useRef(null),m=j.useId(),{data:y,schema:g,bindings:b}=j.useContext(Mt),v=i!==void 0||!!(y&&g&&(b?$n(b,e,g):Xr(y,e,g)));j.useEffect(()=>{var w,C,S,_,k;!r||!v||!n?(w=p.current)==null||w.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(k=(_=p.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||k.focus())},[r,v,n]);const x=Pe(l);return v?f.jsx(f.Fragment,{children:typeof document<"u"&&Vr.createPortal(f.jsx(Dj,{ref:p,id:m,$surface:x,$border:Pe(d),"aria-label":`Configure ${t}`,onClose:o,onPointerDown:w=>w.stopPropagation(),onWheel:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),onClick:w=>{var C;w.stopPropagation(),w.target===w.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:Pe(u),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:t}),f.jsx(Yr,{"aria-label":"Close node configuration",onClick:()=>{var w;return(w=p.current)==null?void 0:w.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(Vj,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:i??f.jsx(Od,{nodeAddress:e})})]})}),document.body)}):null}const vd=({icon:e,label:r,onClick:t,color:n,boxSize:o=6,...i})=>{const{background:s,border:a,colorText:c}=st();return f.jsx(Ue,{label:r,children:f.jsx(V.Flex,{asChild:!0,p:0,border:0,bg:"transparent",children:f.jsx("button",{type:"button","aria-label":r,onClick:t,children:f.jsx(V.Icon,{as:e,boxSize:o,color:n,cursor:t?"pointer":void 0})})})})},Wj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:o,editOnMount:i=!1,hoverLeaveDelay:s=0})=>{var je,pe,fe,Y,H,we,J,ve;const{selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isMultiSelectMode:u,nodeGridOptions:h,isPerformanceMode:p,engineRef:m,callbacks:y,config:g,themeColor:b,direction:v,nodeViewModes:x}=He(),{background:w,border:C,colorText:S}=st(),_=j.useRef(null),k=j.useRef(null);j.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const[E,O]=j.useState(!1),[P,A]=j.useState(i&&!!g.editable&&!g.readOnly),[M,T]=j.useState(!1),N=e==null?void 0:e.id,$=mb(N),I=a.includes(N),W=(je=g.nodeOverlayActions)==null?void 0:je.filter(Q=>!Q.nodeTypes||Q.nodeTypes.includes(e==null?void 0:e.type)),ie=g.renderNodeOverlay,ae=(e==null?void 0:e.type)==="grid"?(pe=g.customViews)==null?void 0:pe.gridHoverControls:void 0,re=(e==null?void 0:e.type)==="grid"?"20px":"-100px",ye=(e==null?void 0:e.type)==="grid"?"top center":void 0,be=(e==null?void 0:e.type)==="grid"?"translateX(-50%) scale3d(1.8, 1.8, 1)":"translateX(-50%) scale3d(3, 3, 1)",L=(()=>{var Q;try{const Ee=(Q=m.current)==null?void 0:Q.zoom();return Ee!==void 0&&Ee<.08}catch{return!1}})(),z=j.useCallback((Q,Ee=!1)=>{var qe,Je,Fe,ct;if(P||g.readOnly||h!=null&&h.fill&&!Q.shiftKey)return;const Ae={shiftKey:Q.shiftKey,ctrlKey:Q.ctrlKey,metaKey:Q.metaKey,altKey:Q.altKey,...Ee?{viewToggle:!0}:{}};if(l&&(d(null),(qe=y.onEdgeDeselect)==null||qe.call(y)),u||Q.shiftKey&&(h!=null&&h.fill)){const De=a.includes(N),rt=De?a.filter(ft=>ft!==N):[...a,N];c(rt),De?(Je=y.onNodeDeselect)==null||Je.call(y):(Fe=y.onNodeSelect)==null||Fe.call(y,N,e,Ae)}else c([N]),(ct=y.onNodeSelect)==null||ct.call(y,N,e,Ae)},[N,e,a,l,u,h,P,c,d,y,g]),G=j.useCallback(()=>{var Q;P||g.readOnly||(Q=y.onNodeDoubleClick)==null||Q.call(y,N,e)},[N,e,P,y,g]),D=j.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>O(!0),100)},[]),se=j.useCallback(Q=>{var Ee;Q.relatedTarget instanceof Node&&((Ee=_.current)!=null&&Ee.contains(Q.relatedTarget))||(k.current&&clearTimeout(k.current),s?k.current=setTimeout(()=>O(!1),s):O(!1))},[s]),X=!!((fe=e==null?void 0:e.config)!=null&&fe.form),le={tabIndex:X?0:void 0,"aria-haspopup":X?"dialog":void 0,"aria-expanded":X?M:void 0,onDoubleClickCapture:Q=>{var Ee;!X&&!o||g.readOnly||P||!Q.currentTarget.contains(Q.target)||Q.target instanceof Element&&Q.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(Q.preventDefault(),Q.stopPropagation(),c([N]),o?o():T(!0),(Ee=y.onNodeDoubleClick)==null||Ee.call(y,N,e))},onKeyDown:Q=>{!X&&!o||g.readOnly||Q.target!==Q.currentTarget||Q.key!=="Enter"||(Q.preventDefault(),Q.stopPropagation(),c([N]),o?o():T(!0))}},ue=X&&f.jsx(su,{nodeAddress:N,active:I,label:e.label||e.headerTitle||"Node",open:M,onClose:()=>{var Q;T(!1),I&&((Q=_.current)==null||Q.focus({preventScroll:!0}))}}),Ce=Array.isArray((Y=e==null?void 0:e.config)==null?void 0:Y.ports)?e.config.ports.map(Q=>f.jsx(Yv,{...Q},`${Q.id}:${Q.role}`)):null;return n?f.jsxs(V.Box,{ref:_,...le,onClick:z,onDoubleClick:G,onMouseEnter:D,onMouseLeave:se,cursor:"pointer",position:"relative",children:[ue,!p&&(ie||W&&W.length>0)&&E&&!L&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>O(!0),onMouseLeave:se}),ie?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",pointerEvents:"auto",transform:be,onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:ie({nodeId:N,nodeData:e,isRoot:N==="root",isParent:!0,isHovered:E,setIsHovered:O})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:be,boxShadow:"lg",onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,children:[W.map((Q,Ee)=>f.jsxs(V.Box,{display:"contents",children:[Ee>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(vd,{icon:Q.icon,label:Q.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:Ae=>{var qe;Ae.stopPropagation(),(qe=y.onNodeHoverAction)==null||qe.call(y,Q.id,N,e)}})]},Q.id)),ae&&f.jsx(ae,{data:e})]})})]}),r({id:N,data:e,isActive:I,isHovered:E,isLowZoom:L,isEditing:P,onSelect:z,onEditStart:()=>A(!0),onEditEnd:()=>A(!1)}),$&&!((H=e==null?void 0:e.config)!=null&&H.parentContainer)&&((we=e==null?void 0:e.config)==null?void 0:we.collapsed)!==void 0&&(()=>{var Ae;const Q=v==="TB"||v==="BT",Ee=t||v==="RL";return f.jsx(V.IconButton,{position:"absolute",...Q?{[v==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Ee?void 0:"-75px",left:Ee?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:g.readOnly,onClick:qe=>{var Je;qe.stopPropagation(),(Je=y.onNodeCollapse)==null||Je.call(y,N,!e.config.collapsed)},bgColor:Pe(((Ae=e==null?void 0:e.viewProps)==null?void 0:Ae.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:Pe("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:Pe("gray.800")})})})()]}):f.jsxs(V.Box,{ref:_,...le,onClick:z,onDoubleClick:G,onMouseEnter:D,onMouseLeave:se,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[ue,Ce,!p&&(ie||W&&W.length>0)&&E&&!L&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>O(!0),onMouseLeave:se}),ie?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",pointerEvents:"auto",transform:be,onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:ie({nodeId:N,nodeData:e,isRoot:N==="root",isParent:!!n,isHovered:E,setIsHovered:O})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:be,boxShadow:"lg",onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,children:[W.map((Q,Ee)=>f.jsxs(V.Box,{display:"contents",children:[Ee>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(vd,{icon:Q.icon,label:Q.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:Ae=>{var qe;Ae.stopPropagation(),(qe=y.onNodeHoverAction)==null||qe.call(y,Q.id,N,e)}})]},Q.id)),ae&&f.jsx(ae,{data:e})]})})]}),f.jsxs(V.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[$&&!((J=e==null?void 0:e.config)!=null&&J.parentContainer)&&((ve=e==null?void 0:e.config)==null?void 0:ve.collapsed)!==void 0&&!n&&(()=>{var qe,Je,Fe;const Q=v==="TB"||v==="BT",Ee=t||v==="RL",Ae=(qe=e==null?void 0:e.config)!=null&&qe.labelBelow&&x[N]!=="properties"?((((Je=e==null?void 0:e.viewProps)==null?void 0:Je.fontSize)||1)*100+100)/2:void 0;return f.jsx(V.IconButton,{position:"absolute",...Q?{[v==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Ee?void 0:Ae===void 0?"-75px":`calc(50% - ${Ae+75}px)`,left:Ee?Ae===void 0?"-75px":`calc(50% - ${Ae+75}px)`:void 0,alignSelf:Ae===void 0?"center":void 0,top:Ae===void 0?void 0:`${Ae}px`,transform:Ae===void 0?void 0:"translateY(-50%)",zIndex:Ae===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:g.readOnly,onClick:ct=>{var De;ct.stopPropagation(),(De=y.onNodeCollapse)==null||De.call(y,N,!e.config.collapsed)},bgColor:Pe(((Fe=e==null?void 0:e.viewProps)==null?void 0:Fe.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:Pe("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:Pe("gray.800")})})})(),r({id:N,data:e,isActive:I,isHovered:E,isLowZoom:L,isEditing:P,onSelect:z,onEditStart:()=>A(!0),onEditEnd:()=>A(!1)})]})]})},Vn=j.memo(Wj),Gj=({id:e,data:r,isActive:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var y,g,b,v,x,w,C,S;const{themeColor:s}=He(),{colorText:a}=st(),c=((y=r==null?void 0:r.viewProps)==null?void 0:y.bgColor)==="transparent",l=((g=r==null?void 0:r.viewProps)==null?void 0:g.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=Nn(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=Pe(((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||(c||l?a:h)),m=((x=r==null?void 0:r.viewProps)==null?void 0:x.borderColor)||(l?!c&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(V.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:l?"transparent":d,...Tn(r==null?void 0:r.viewProps,m,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(V.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=r==null?void 0:r.config)==null?void 0:S.icon)&&f.jsx(V.Box,{flexShrink:0,children:f.jsx(Xt,{name:r.config.icon,size:80,color:p})}),f.jsx(Jr,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Wn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=He();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>r(o,"properties"),restoreNodeView:o=>r(o,"default"),toggleNodeView:o=>r(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:r}}function cu(e,r,t){const{readOnly:n,selectedNodeIds:o}=He(),i=o.includes(e),s=j.useRef(i),a=j.useRef(t);a.current=t,j.useEffect(()=>{s.current&&!i&&r&&!n&&a.current(),s.current=i},[i,r,n])}const Uj=({id:e,isActive:r,data:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var x,w,C,S,_,k,E,O,P,A,M,T,N,$,I;const{themeColor:s}=He(),{colorText:a}=st(),c=((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)==="transparent",l=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!c&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=Nn(d),m=Pe(((S=t==null?void 0:t.viewProps)==null?void 0:S.textColor)||(c||l?a:p)),y=c&&!l&&!((_=t==null?void 0:t.viewProps)!=null&&_.borderColor)?"transparent":Pe(((k=t==null?void 0:t.viewProps)==null?void 0:k.borderColor)||(l?d:u)),g=c||l?"transparent":d!=null&&d.startsWith("#")?d:Pe(h),b=(E=t==null?void 0:t.config)==null?void 0:E.icon,v=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((O=t==null?void 0:t.config)!=null&&O.labelBelow){const W=(((P=t==null?void 0:t.viewProps)==null?void 0:P.fontSize)||1)*100;return f.jsxs(V.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":m},direction:"column",align:"center",gap:"24px",width:`${Math.max(W+200,360)}px`,position:"relative",children:[f.jsx(V.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${W+100}px`,height:`${W+100}px`,flexShrink:0,borderRadius:(A=t==null?void 0:t.viewProps)==null?void 0:A.borderRadius,backgroundColor:g,...Tn(t==null?void 0:t.viewProps,y,r,2),children:!!b&&f.jsx(Xt,{name:b,size:W,color:m})}),f.jsxs(V.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Jr,{nodeId:e,label:v,color:`var(--flow-grid-caption-color, ${Pe(((M=t==null?void 0:t.viewProps)==null?void 0:M.textColor)||a)})`,isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((T=t.config)==null?void 0:T.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(V.Text,{"data-flow-node-subtitle":"",color:Pe(((N=t==null?void 0:t.viewProps)==null?void 0:N.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(V.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:($=t==null?void 0:t.viewProps)==null?void 0:$.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...Tn(t==null?void 0:t.viewProps,y,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(V.Flex,{align:"center",py:14,mr:v?8:0,flexShrink:0,children:f.jsx(Xt,{name:b,size:(((I=t==null?void 0:t.viewProps)==null?void 0:I.fontSize)||1)*100,color:m},m)}),(v||!b)&&f.jsx(V.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Jr,{nodeId:e,label:v,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function lu({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=Uj,...o}){const{colorMode:i,callbacks:s}=He();return f.jsx(Vn,{...o,hoverLeaveDelay:e?350:0,children:a=>f.jsxs(V.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&(a.isHovered||a.isActive)&&f.jsx(V.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(Ue,{label:r,children:f.jsx(Ne,{"aria-label":r,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:t,onClick:c=>{var l;c.stopPropagation(),a.isActive||a.onSelect(c,!0),(l=s.onNodeViewToggle)==null||l.call(s,o.data.id),e()}})})})]})})}const Hj=`${$b}
|
|
280
|
+
`;function su({nodeAddress:e,active:r,label:t,open:n=!1,onClose:o,children:i,filter:s,height:a,width:c}){const{background:l,border:d,colorText:u}=st(),{colorMode:h}=He(),p=j.useRef(null),m=j.useId(),{data:y,schema:g,bindings:b}=j.useContext(Mt),v=i!==void 0||!!(y&&g&&(b?$n(b,e,g):Xr(y,e,g)));j.useEffect(()=>{var w,C,S,_,k;!r||!v||!n?(w=p.current)==null||w.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(k=(_=p.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||k.focus())},[r,v,n]);const x=Pe(l);return v?f.jsx(f.Fragment,{children:typeof document<"u"&&Vr.createPortal(f.jsx(Dj,{ref:p,id:m,$surface:x,$border:Pe(d),"aria-label":`Configure ${t}`,onClose:o,onPointerDown:w=>w.stopPropagation(),onWheel:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),onClick:w=>{var C;w.stopPropagation(),w.target===w.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:Pe(u),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:t}),f.jsx(Yr,{"aria-label":"Close node configuration",onClick:()=>{var w;return(w=p.current)==null?void 0:w.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(Vj,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:i??f.jsx(Od,{nodeAddress:e})})]})}),document.body)}):null}const vd=({icon:e,label:r,onClick:t,color:n,boxSize:o=6,...i})=>{const{background:s,border:a,colorText:c}=st();return f.jsx(Ue,{label:r,children:f.jsx(V.Flex,{asChild:!0,p:0,border:0,bg:"transparent",children:f.jsx("button",{type:"button","aria-label":r,onClick:t,children:f.jsx(V.Icon,{as:e,boxSize:o,color:n,cursor:t?"pointer":void 0})})})})},Wj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:o,editOnMount:i=!1,hoverLeaveDelay:s=0})=>{var je,pe,fe,Y,H,we,J,ve;const{selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isMultiSelectMode:u,nodeGridOptions:h,isPerformanceMode:p,engineRef:m,callbacks:y,config:g,themeColor:b,direction:v,nodeViewModes:x}=He(),{background:w,border:C,colorText:S}=st(),_=j.useRef(null),k=j.useRef(null);j.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const[E,O]=j.useState(!1),[P,A]=j.useState(i&&!!g.editable&&!g.readOnly),[M,T]=j.useState(!1),N=e==null?void 0:e.id,$=mb(N),I=a.includes(N),W=(je=g.nodeOverlayActions)==null?void 0:je.filter(Q=>!Q.nodeTypes||Q.nodeTypes.includes(e==null?void 0:e.type)),ie=g.renderNodeOverlay,ae=(e==null?void 0:e.type)==="grid"?(pe=g.customViews)==null?void 0:pe.gridHoverControls:void 0,re=(e==null?void 0:e.type)==="grid"?"20px":"-100px",ye=(e==null?void 0:e.type)==="grid"?"top center":void 0,be=(e==null?void 0:e.type)==="grid"?"translateX(-50%) scale3d(1.8, 1.8, 1)":"translateX(-50%) scale3d(3, 3, 1)",L=(()=>{var Q;try{const Ee=(Q=m.current)==null?void 0:Q.zoom();return Ee!==void 0&&Ee<.08}catch{return!1}})(),z=j.useCallback((Q,Ee=!1)=>{var qe,Je,Fe,ct;if(P||g.readOnly||h!=null&&h.fill&&!Q.shiftKey)return;const Ae={shiftKey:Q.shiftKey,ctrlKey:Q.ctrlKey,metaKey:Q.metaKey,altKey:Q.altKey,...Ee?{viewToggle:!0}:{}};if(l&&(d(null),(qe=y.onEdgeDeselect)==null||qe.call(y)),u||Q.shiftKey&&(h!=null&&h.fill)){const De=a.includes(N),rt=De?a.filter(ft=>ft!==N):[...a,N];c(rt),De?(Je=y.onNodeDeselect)==null||Je.call(y):(Fe=y.onNodeSelect)==null||Fe.call(y,N,e,Ae)}else c([N]),(ct=y.onNodeSelect)==null||ct.call(y,N,e,Ae)},[N,e,a,l,u,h,P,c,d,y,g]),G=j.useCallback(()=>{var Q;P||g.readOnly||(Q=y.onNodeDoubleClick)==null||Q.call(y,N,e)},[N,e,P,y,g]),D=j.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>O(!0),100)},[]),se=j.useCallback(Q=>{var Ee;Q.relatedTarget instanceof Node&&((Ee=_.current)!=null&&Ee.contains(Q.relatedTarget))||(k.current&&clearTimeout(k.current),s?k.current=setTimeout(()=>O(!1),s):O(!1))},[s]),X=!!((fe=e==null?void 0:e.config)!=null&&fe.form),le={tabIndex:X?0:void 0,"aria-haspopup":X?"dialog":void 0,"aria-expanded":X?M:void 0,onDoubleClickCapture:Q=>{var Ee;!X&&!o||g.readOnly||P||!Q.currentTarget.contains(Q.target)||Q.target instanceof Element&&Q.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(Q.preventDefault(),Q.stopPropagation(),c([N]),o?o():T(!0),(Ee=y.onNodeDoubleClick)==null||Ee.call(y,N,e))},onKeyDown:Q=>{!X&&!o||g.readOnly||Q.target!==Q.currentTarget||Q.key!=="Enter"||(Q.preventDefault(),Q.stopPropagation(),c([N]),o?o():T(!0))}},ue=X&&f.jsx(su,{nodeAddress:N,active:I,label:e.label||e.headerTitle||"Node",open:M,onClose:()=>{var Q;T(!1),I&&((Q=_.current)==null||Q.focus({preventScroll:!0}))}}),Ce=Array.isArray((Y=e==null?void 0:e.config)==null?void 0:Y.ports)?e.config.ports.map(Q=>f.jsx(Yv,{...Q},`${Q.id}:${Q.role}`)):null;return n?f.jsxs(V.Box,{ref:_,...le,onClick:z,onDoubleClick:G,onMouseEnter:D,onMouseLeave:se,cursor:"pointer",position:"relative",children:[ue,!p&&(ie||W&&W.length>0)&&E&&!L&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>O(!0),onMouseLeave:se}),ie?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",pointerEvents:"auto",transform:be,onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:ie({nodeId:N,nodeData:e,isRoot:N==="root",isParent:!0,isHovered:E,setIsHovered:O})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:be,boxShadow:"lg",onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,children:[W.map((Q,Ee)=>f.jsxs(V.Box,{display:"contents",children:[Ee>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(vd,{icon:Q.icon,label:Q.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:Ae=>{var qe;Ae.stopPropagation(),(qe=y.onNodeHoverAction)==null||qe.call(y,Q.id,N,e)}})]},Q.id)),ae&&f.jsx(ae,{data:e})]})})]}),r({id:N,data:e,isActive:I,isHovered:E,isLowZoom:L,isEditing:P,onSelect:z,onEditStart:()=>A(!0),onEditEnd:()=>A(!1)}),$&&!((H=e==null?void 0:e.config)!=null&&H.parentContainer)&&((we=e==null?void 0:e.config)==null?void 0:we.collapsed)!==void 0&&(()=>{var Ae;const Q=v==="TB"||v==="BT",Ee=t||v==="RL";return f.jsx(V.IconButton,{position:"absolute",...Q?{[v==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Ee?void 0:"-75px",left:Ee?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:g.readOnly,onClick:qe=>{var Je;qe.stopPropagation(),(Je=y.onNodeCollapse)==null||Je.call(y,N,!e.config.collapsed)},bgColor:Pe(((Ae=e==null?void 0:e.viewProps)==null?void 0:Ae.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:Pe("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:Pe("gray.800")})})})()]}):f.jsxs(V.Box,{ref:_,...le,onClick:z,onDoubleClick:G,onMouseEnter:D,onMouseLeave:se,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[ue,Ce,!p&&(ie||W&&W.length>0)&&E&&!L&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>O(!0),onMouseLeave:se}),ie?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",pointerEvents:"auto",transform:be,onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:ie({nodeId:N,nodeData:e,isRoot:N==="root",isParent:!!n,isHovered:E,setIsHovered:O})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:be,boxShadow:"lg",onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,children:[W.map((Q,Ee)=>f.jsxs(V.Box,{display:"contents",children:[Ee>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(vd,{icon:Q.icon,label:Q.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:Ae=>{var qe;Ae.stopPropagation(),(qe=y.onNodeHoverAction)==null||qe.call(y,Q.id,N,e)}})]},Q.id)),ae&&f.jsx(ae,{data:e})]})})]}),f.jsxs(V.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[$&&!((J=e==null?void 0:e.config)!=null&&J.parentContainer)&&((ve=e==null?void 0:e.config)==null?void 0:ve.collapsed)!==void 0&&!n&&(()=>{var qe,Je,Fe;const Q=v==="TB"||v==="BT",Ee=t||v==="RL",Ae=(qe=e==null?void 0:e.config)!=null&&qe.labelBelow&&x[N]!=="properties"?((((Je=e==null?void 0:e.viewProps)==null?void 0:Je.fontSize)||1)*100+100)/2:void 0;return f.jsx(V.IconButton,{position:"absolute",...Q?{[v==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Ee?void 0:Ae===void 0?"-75px":`calc(50% - ${Ae+75}px)`,left:Ee?Ae===void 0?"-75px":`calc(50% - ${Ae+75}px)`:void 0,alignSelf:Ae===void 0?"center":void 0,top:Ae===void 0?void 0:`${Ae}px`,transform:Ae===void 0?void 0:"translateY(-50%)",zIndex:Ae===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:g.readOnly,onClick:ct=>{var De;ct.stopPropagation(),(De=y.onNodeCollapse)==null||De.call(y,N,!e.config.collapsed)},bgColor:Pe(((Fe=e==null?void 0:e.viewProps)==null?void 0:Fe.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:Pe("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:Pe("gray.800")})})})(),r({id:N,data:e,isActive:I,isHovered:E,isLowZoom:L,isEditing:P,onSelect:z,onEditStart:()=>A(!0),onEditEnd:()=>A(!1)})]})]})},Vn=j.memo(Wj),Gj=({id:e,data:r,isActive:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var y,g,b,v,x,w,C,S;const{themeColor:s}=He(),{colorText:a}=st(),c=((y=r==null?void 0:r.viewProps)==null?void 0:y.bgColor)==="transparent",l=((g=r==null?void 0:r.viewProps)==null?void 0:g.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=Nn(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=Pe(((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||(c||l?a:h)),m=((x=r==null?void 0:r.viewProps)==null?void 0:x.borderColor)||(l?!c&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(V.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:l?"transparent":d,...Tn(r==null?void 0:r.viewProps,m,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(V.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=r==null?void 0:r.config)==null?void 0:S.icon)&&f.jsx(V.Box,{flexShrink:0,children:f.jsx(Qt,{name:r.config.icon,size:80,color:p})}),f.jsx(Jr,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Wn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=He();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>r(o,"properties"),restoreNodeView:o=>r(o,"default"),toggleNodeView:o=>r(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:r}}function cu(e,r,t){const{readOnly:n,selectedNodeIds:o}=He(),i=o.includes(e),s=j.useRef(i),a=j.useRef(t);a.current=t,j.useEffect(()=>{s.current&&!i&&r&&!n&&a.current(),s.current=i},[i,r,n])}const Uj=({id:e,isActive:r,data:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var x,w,C,S,_,k,E,O,P,A,M,T,N,$,I;const{themeColor:s}=He(),{colorText:a}=st(),c=((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)==="transparent",l=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!c&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=Nn(d),m=Pe(((S=t==null?void 0:t.viewProps)==null?void 0:S.textColor)||(c||l?a:p)),y=c&&!l&&!((_=t==null?void 0:t.viewProps)!=null&&_.borderColor)?"transparent":Pe(((k=t==null?void 0:t.viewProps)==null?void 0:k.borderColor)||(l?d:u)),g=c||l?"transparent":d!=null&&d.startsWith("#")?d:Pe(h),b=(E=t==null?void 0:t.config)==null?void 0:E.icon,v=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((O=t==null?void 0:t.config)!=null&&O.labelBelow){const W=(((P=t==null?void 0:t.viewProps)==null?void 0:P.fontSize)||1)*100;return f.jsxs(V.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":m},direction:"column",align:"center",gap:"24px",width:`${Math.max(W+200,360)}px`,position:"relative",children:[f.jsx(V.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${W+100}px`,height:`${W+100}px`,flexShrink:0,borderRadius:(A=t==null?void 0:t.viewProps)==null?void 0:A.borderRadius,backgroundColor:g,...Tn(t==null?void 0:t.viewProps,y,r,2),children:!!b&&f.jsx(Qt,{name:b,size:W,color:m})}),f.jsxs(V.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Jr,{nodeId:e,label:v,color:`var(--flow-grid-caption-color, ${Pe(((M=t==null?void 0:t.viewProps)==null?void 0:M.textColor)||a)})`,isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((T=t.config)==null?void 0:T.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(V.Text,{"data-flow-node-subtitle":"",color:Pe(((N=t==null?void 0:t.viewProps)==null?void 0:N.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(V.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:($=t==null?void 0:t.viewProps)==null?void 0:$.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...Tn(t==null?void 0:t.viewProps,y,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(V.Flex,{align:"center",py:14,mr:v?8:0,flexShrink:0,children:f.jsx(Qt,{name:b,size:(((I=t==null?void 0:t.viewProps)==null?void 0:I.fontSize)||1)*100,color:m},m)}),(v||!b)&&f.jsx(V.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Jr,{nodeId:e,label:v,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function lu({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=Uj,...o}){const{colorMode:i,callbacks:s}=He();return f.jsx(Vn,{...o,hoverLeaveDelay:e?350:0,children:a=>f.jsxs(V.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&(a.isHovered||a.isActive)&&f.jsx(V.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(Ue,{label:r,children:f.jsx(Ne,{"aria-label":r,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:t,onClick:c=>{var l;c.stopPropagation(),a.isActive||a.onSelect(c,!0),(l=s.onNodeViewToggle)==null||l.call(s,o.data.id),e()}})})})]})})}const Hj=`${$b}
|
|
281
281
|
[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:flow-sdk-node-border 2.4s linear infinite!important}
|
|
282
282
|
[data-flow-loading-border][data-flow-loading-border][data-motion-disabled] .flow-sdk-node-border-animation{animation:none!important}
|
|
283
|
-
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function Xv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:o}=He(),{colorText:i}=st(),s=j.useRef(null),[a,c]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const m=u.parentElement,y={width:u.clientWidth,height:u.clientHeight,radius:t??(m&&parseFloat(getComputedStyle(m).borderTopLeftRadius)||0)};c(g=>g.width===y.width&&g.height===y.height&&g.radius===y.radius?g:y)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=Pe(o||i),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:Hj}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(oo,{...d,strokeWidth:6})}),f.jsx(oo,{...d})]})]})}function Kj({content:e,format:r,onEdit:t}){var N;const{config:n,colorMode:o}=He(),{background:i,border:s,colorInactive:a}=st(),c=(N=n.customViews)==null?void 0:N.jsxContent,l=typeof e=="string"?e:JSON.stringify(e,null,2);let d,u;if(r==="jsx")try{const $=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray($)||$.some(I=>!I||typeof I!="object"||Array.isArray(I)||typeof I.type!="string"))throw new Error("JSX content must be an array of components with a type.");d=$}catch($){u=$ instanceof Error?$.message:"Invalid components array."}const h=j.useRef(null),p=j.useRef(null),m=j.useRef(null),y=j.useRef(!1),[g,b]=j.useState(!1),[v,x]=j.useState(""),w=!!t;j.useEffect(()=>{const $=()=>{var W;const I=document.fullscreenElement===p.current;b(I),y.current&&!I&&!document.fullscreenElement&&((W=m.current)==null||W.focus({preventScroll:!0})),y.current=I};return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const C=async()=>{var $;x("");try{if(document.fullscreenElement===p.current)await document.exitFullscreen();else if(($=p.current)!=null&&$.requestFullscreen)await p.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(I){x(I instanceof Error?I.message:"Unable to change fullscreen.")}},[S,_]=j.useState(),[k,E]=j.useState(),[O,P]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let $=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-BsKd0dD4.cjs")).then(({contentPreviewDocument:I})=>I(l,r,w)).then(I=>{$||_({content:l,format:r,editable:w,document:I})},I=>{$||_({content:l,format:r,editable:w,error:I instanceof Error?I.message:String(I)})}),()=>{$=!0}},[l,r,w]),j.useEffect(()=>{if(!t)return;const $=async I=>{var W,ie;if(!(!((W=h.current)!=null&&W.contentWindow)||I.source!==h.current.contentWindow||((ie=I.data)==null?void 0:ie.type)!=="squeed:content-edit"))try{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()}catch(ae){x(ae instanceof Error?ae.message:"Unable to close fullscreen.")}};return window.addEventListener("message",$),()=>window.removeEventListener("message",$)},[t]);const A=(S==null?void 0:S.content)===l&&S.format===r&&S.editable===w?S:void 0,M=!!A&&A===O,T=r!=="jsx"&&!(A!=null&&A.error)&&!M&&(!A||k!==A);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:l}),f.jsxs(V.Box,{ref:p,position:"relative",w:"100%",h:"100%","aria-busy":r!=="jsx"?T:void 0,bg:r==="jsx"&&o==="dark"?"gray.900":"white",onDoubleClick:$=>{r!=="jsx"||!t||$.defaultPrevented||$.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||($.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I))))},onKeyDownCapture:$=>{$.key!=="Escape"||document.fullscreenElement!==p.current||($.preventDefault(),$.stopPropagation(),C())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-content-toolbar], &:focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(V.Box,{role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:g?1:0,pointerEvents:g?"auto":"none",children:f.jsx($d,{background:i,border:o==="dark"?s:"gray.300",children:f.jsxs(V.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&f.jsx(Ne,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Z.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I)))}}),f.jsx(Ne,{ref:m,"data-flow-fullscreen":"","aria-label":g?"Exit fullscreen":"Expand preview",title:g?"Exit fullscreen":"Expand preview","aria-expanded":g,icon:g?f.jsx(Z.PiArrowsIn,{size:20}):f.jsx(Z.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),C()}})]})})}),v&&f.jsx(V.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:v}),r==="jsx"?u?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:u}):c&&d?f.jsx(c,{components:d,colorMode:o,fillHeight:!0}):f.jsx(V.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):A!=null&&A.error||M?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(A==null?void 0:A.error)||"Content preview could not be loaded."}):A!=null&&A.document?f.jsx("iframe",{ref:h,title:`${r.toUpperCase()} content preview`,sandbox:w?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:A.document,onLoad:()=>E(A),onError:()=>P(A),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:T?"hidden":"visible"}},A.document):null,f.jsx(Xv,{active:T,label:"Loading HTML content"})]})]})}const Cm=1.55;function Jj({nodeId:e,content:r,color:t,format:n="markdown"}){const{callbacks:o,config:i,readOnly:s,nodeGridOptions:a}=He(),c=!!i.editable&&!s,l=c&&!a,d=typeof r=="string"?r:JSON.stringify(r,null,2),[u,h]=j.useState(!1),[p,m]=j.useState(d),[y,g]=j.useState(""),[b,v]=j.useState(),x=j.useRef(null),w=j.useRef(!1),C=au(u);j.useLayoutEffect(()=>{const k=x.current;!u||!k||(k.style.height="auto",k.style.height=`${Math.max((b==null?void 0:b.height)??0,k.scrollHeight)}px`)},[p,u,b]),j.useEffect(()=>{var k,E;c?u&&(w.current=!1,(k=x.current)==null||k.focus({preventScroll:!0}),(E=x.current)==null||E.select()):h(!1)},[u,c]);const S=(k,E=!1)=>{!c||a&&!E||(v({width:k.offsetWidth,height:k.offsetHeight}),m(d),g(""),h(!0))},_=()=>{var E;if(w.current||!c)return;let k=p;if(n==="jsx")try{if(k=JSON.parse(p),!Array.isArray(k)||k.some(O=>!O||typeof O!="object"||Array.isArray(O)||typeof O.type!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(O){g(O instanceof Error?O.message:"Invalid components array.");return}w.current=!0,p!==d&&((E=o.onNodeContentChange)==null||E.call(o,e,k)),h(!1)};return(!u||!c)&&n!=="markdown"?f.jsx(V.Box,{ref:C,w:"100%",position:"relative","data-flow-content":"",children:f.jsx(Kj,{content:r,format:n,onEdit:l?()=>{C.current&&S(C.current)}:void 0})}):!u||!c?f.jsx(V.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:Cm,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:l?"text":void 0,tabIndex:l?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:k=>{!c||a&&!k.shiftKey||k.target instanceof Element&&k.target.closest("a, button, input")||(k.stopPropagation(),S(k.currentTarget,k.shiftKey))},onDoubleClick:k=>{k.stopPropagation(),S(k.currentTarget,k.shiftKey)},onKeyDown:k=>{c&&(!a||k.shiftKey)&&k.key==="Enter"&&k.target===k.currentTarget&&(k.preventDefault(),k.stopPropagation(),S(k.currentTarget,k.shiftKey))},children:f.jsx(Cx.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:d||(i.editable&&!s?"Write your content here":"")})}):f.jsxs("div",{ref:C,style:{width:b==null?void 0:b.width,minHeight:b==null?void 0:b.height,maxWidth:"100%"},children:[f.jsx(V.Textarea,{ref:x,"aria-label":"Node content",placeholder:"Write your content here",value:p,"aria-invalid":!!y,onChange:k=>m(k.target.value),onBlur:_,onKeyDown:k=>{k.stopPropagation(),!k.nativeEvent.isComposing&&(k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&(k.preventDefault(),_()),k.key==="Escape"&&(w.current=!0,h(!1)))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:Cm,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),y&&f.jsx(V.Box,{role:"alert",fontSize:"14px",color:"red.500",children:y})]})}const Zj=(e,r,t)=>{var h,p,m,y;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[o]=n.split("."),i=Nn(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?Pe(n):Pe(i.bgColor),d=Pe(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(a?c:i.textColor)),u=Pe(((y=e==null?void 0:e.viewProps)==null?void 0:y.borderColor)||(s?n==="transparent"?r:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?c:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:l,hextextColor:d,hexborderColor:u}},Yj=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,Xj=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Qv=600,Qj=3,e_=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function t_({headerTitle:e,hasContent:r,data:t,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isHovered:c,isEditing:l,onSelect:d,onEditStart:u,onEditEnd:h,props:p,objVisible:m,setObjVisible:y,onShowNativeIcon:g}){var w,C;const{callbacks:b}=He(),v=p.onShowIcon??g,x=v?"Show icon":m?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((w=t.config)==null?void 0:w.form)||(a||c)&&g)&&f.jsxs(V.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!r?"transparent":o.hexborderColor,children:[!!n&&f.jsx(V.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Xt,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),f.jsx(Jr,{nodeId:s,label:Xj(e),color:((C=t==null?void 0:t.viewProps)==null?void 0:C.textColor)||o.propertyColor,isEditing:l,onEditStart:u,onEditEnd:h}),(a||c)&&(r||v)&&f.jsx(V.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Ue,{label:x,children:f.jsx(Ne,{"aria-label":x,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:S=>{var _;S.stopPropagation(),a||d(S),v?v():y(!m),(_=b.onNodeViewToggle)==null||_.call(b,s)}})})})]})})}function r_({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=vr(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(V.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var M,T,N;const m=r&&Object.keys(r).find($=>$.slice($.indexOf(":")+1)===u),y=t&&((M=n==null?void 0:n.type.ports)==null?void 0:M[u]),g=m??(y?`${y.kind}:${u}`:u),b=o.find($=>$.id===g),v=m?"source":b==null?void 0:b.role,x=d.has(`source:${g}`),w=d.has(`target:${g}`),C=i.some($=>$.id===u),S=h===""&&(C||(v?d.has(`${v}:${g}`):x||w)),_=v??(x!==w?x?"source":"target":void 0),k=(b==null?void 0:b.side)??(_?_==="source"!=(a==="RL")?"right":"left":void 0),E=S&&k==="right"?"right":"left",O=(b==null?void 0:b.label)??(y==null?void 0:y.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),P=Yt(s.wordBeforeDot)[typeof h],A=Yt(s.wordBeforeDot).property;return f.jsxs(V.Box,{"data-flow-property":m&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":v,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(V.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(V.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(V.Text,{py:5,px:10,w:"100%",textAlign:E,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((T=e==null?void 0:e.viewProps)==null?void 0:T.textColor)||(s.isTransparent?s.hextextColor:A),children:O})}),!S&&f.jsx(V.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:Qv,maxH:200,children:f.jsx(V.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((N=e==null?void 0:e.viewProps)==null?void 0:N.textColor)||(s.isTransparent?s.hextextColor:P),fontWeight:400,children:Yj(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(V.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function n_(e){var x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n}=He(),o=Wn(),i=o.getNodeViewMode(e.data.id)==="properties",s=k=>o.setNodeViewMode(e.data.id,k?"properties":"default"),a=!!e.onShowIcon||i||typeof((x=e.data.config)==null?void 0:x.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=j.useContext(Mt),u=(S=c==null?void 0:c[e.data.id])==null?void 0:S.portResources,h=c?$n(c,e.data.id,d):l&&d?Xr(l,e.data.id,d):void 0,p=h&&Le(l,"address"in h?h.address:e.data.id),m=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(k=>{var E;return Object.prototype.hasOwnProperty.call(p,k)&&ho((E=h.fields[k])==null?void 0:E.$visibleWhen,l)}).map(k=>[k,p[k]!==null&&typeof p[k]=="object"?JSON.stringify(p[k],null,2):p[k]===null?"null":p[k]])):{},y=u?Object.fromEntries(Object.entries(u).map(([k,E])=>{var O;return[k.slice(k.indexOf(":")+1),((O=Le(l,E))==null?void 0:O.name)??E.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,g=a&&!u?((_=e.data.config)==null?void 0:_.ports)??[]:[],b=g.filter(k=>!Object.prototype.hasOwnProperty.call(y,k.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([E,O])=>`${O.kind}:${E}`===k.id&&Object.prototype.hasOwnProperty.call(y,E))),v={...y,...Object.fromEntries(b.map(k=>[k.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:v,inspectionPorts:g,extraPorts:b}}const du=e=>{var v,x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=n_(e),h=Wn(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&(typeof((v=e.data.config)==null?void 0:v.content)=="string"||((x=e.data.config)==null?void 0:x.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),y=j.useRef(p);p&&(y.current=!0),cu(e.data.id,m&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&y.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((S=e.data.config)!=null&&S.parentContainer)&&!m?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(lu,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((_=e.data.config)==null?void 0:_.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(Vn,{...e,data:{...e.data,description:l},hoverLeaveDelay:m||e.onShowIcon||b?350:0,children:({id:k,data:E,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N})=>{var L,z,G,D,se,X,le,ue,Ce,je;const $=Zj(E,r,t),I=E.label??E.headerTitle,W=Object.entries(E.description||{}).length>0,ie=e_(E.description),ae=(z=(L=e.data)==null?void 0:L.config)==null?void 0:z.icon,re=(D=(G=e.data)==null?void 0:G.config)==null?void 0:D.content,ye=((se=E==null?void 0:E.viewProps)==null?void 0:se.borderRadius)??"53px",be=Tn(E==null?void 0:E.viewProps,$.hexborderColor,O,Qj);return f.jsx(V.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:ye,overflow:"hidden",alignItems:"center",style:{backgroundColor:$.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:m||e.onShowIcon?ie+Qv+be.borderWidth*2:void 0,...be,children:f.jsxs(V.Flex,{width:"100%",direction:"column",borderRadius:ye,borderColor:$.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(t_,{headerTitle:I,hasContent:m,data:E,icon:ae,colors:$,hasConfig:W,id:k,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:b}),m&&!o?f.jsx(V.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:$.highlightColor,p:["html","jsx"].includes((le=(X=e.data)==null?void 0:X.config)==null?void 0:le.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(Jj,{nodeId:k,content:re,format:(Ce=(ue=e.data)==null?void 0:ue.config)==null?void 0:Ce.contentFormat,color:((je=E==null?void 0:E.viewProps)==null?void 0:je.textColor)||$.hextextColor})}):f.jsx(r_,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:$,direction:n,uniformKeyWidth:ie})]})})}})};du.displayName="NodeJsonObjectView";const ex=e=>{var h,p,m,y,g,b,v,x,w,C,S;const r=Wn(),[t,n]=j.useState(!1),o=r.getNodeViewMode(e.data.id)==="properties",i=_=>{n(_),r.setNodeViewMode(e.data.id,_?"properties":"default")},{callbacks:s,readOnly:a}=He(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;cu(e.data.id,o&&((y=(m=e.data)==null?void 0:m.config)==null?void 0:y.labelBelow)&&!c,()=>i(!1));const l=c?"Show parent":"Show properties",d=c||((b=(g=e.data)==null?void 0:g.config)==null?void 0:b.form)||((w=(x=(v=e.data)==null?void 0:v.config)==null?void 0:x.ports)==null?void 0:w.length),u=d?()=>{var _;c?(_=s.onNodeCollapse)==null||_.call(s,e.data.id,!1):i(!0)}:void 0;return!c&&d&&o?f.jsx(du,{...e,editOnMount:t,onShowIcon:()=>i(!1)}):f.jsx(lu,{...e,onOpenView:u&&(c||(S=(C=e.data)==null?void 0:C.config)!=null&&S.labelBelow)?()=>{var _;u(),(_=s.onNodeViewToggle)==null||_.call(s,e.data.id)}:void 0,toggleLabel:l,toggleDisabled:c&&a,onExpand:u})};function o_(e){var b,v,x,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:o,nodeRadiusPreviews:i,nodeViewModes:s,allNodesIconLabel:a}=He(),c=i[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=j.useState(!1),u=Wn(),{border:h,colorText:p}=st(),m=(v=r.customViews)==null?void 0:v.gridContent,y=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",g=j.useRef(y);return y&&(g.current=!0),cu(e.data.id,a&&!y&&g.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),y?f.jsx(V.Box,{"data-grid-document":((x=e.data.config)==null?void 0:x.documentId)??"",children:f.jsx(lu,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx(Vn,{...e,onOpenView:()=>d(!0),children:({data:_,isActive:k})=>{var E,O,P,A,M,T,N,$;return f.jsx(V.Box,{"data-flow-node-surface":"","data-grid-document":((E=_.config)==null?void 0:E.documentId)??"",width:`${((P=(O=_.config)==null?void 0:O.gridSize)==null?void 0:P.width)??600}px`,height:`${((M=(A=_.config)==null?void 0:A.gridSize)==null?void 0:M.height)??440}px`,overflow:"hidden",position:"relative",bg:((T=_.viewProps)==null?void 0:T.bgColor)??"transparent",color:((N=_.viewProps)==null?void 0:N.textColor)??p,borderRadius:`${c??0}px`,...Tn(_.viewProps,Pe((($=_.viewProps)==null?void 0:$.borderColor)??h),k,0),children:m?f.jsx(m,{...e}):f.jsx(V.Box,{p:4,children:_.label??"Grid"})})}}),f.jsx(su,{nodeAddress:e.data.id,active:o.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(Mt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:_=>{var E,O,P;if(n||!r.editable)return;const k=String(_.value??"");_.address==="root.metadata.label"?(E=t.onNodeLabelChange)==null||E.call(t,e.data.id,k):_.address==="root.metadata.subtitle"?(O=t.onNodeSubtitleChange)==null||O.call(t,e.data.id,k):_.address==="root.metadata.icon"&&((P=t.onNodeIconChange)==null||P.call(t,e.data.id,k))}}},children:f.jsx(Od,{nodeAddress:e.data.id})})})]})}const tx=e=>f.jsx(ex,{...e,renderCompact:Gj}),rx=e=>f.jsx(ex,{...e}),nx=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=He();return f.jsx(Vn,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(V.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:hr,lineHeight:1,w:"fit-content",children:f.jsx(Jr,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};tx.displayName="text";rx.displayName="arrayView";nx.displayName="ParentContainerView";const i_={grid:o_,objectView:du,arrayView:rx,text:tx,parentContainer:nx},a_=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=He(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(V.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(V.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(V.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(V.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},s_=.4,_r={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},c_=({nodes:e,edges:r})=>{var ze;const{themeColor:t,spacing:n,edgeRadius:o,backgroundVariant:i,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:m,engineRef:y,callbacks:g,config:b,selectedNodeIds:v,setSelectedNodeIds:x,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:_,fillRadiusEditedIds:k,isZoomMode:E,setIsZoomMode:O,isMultiSelectMode:P,setIsMultiSelectMode:A,isDragMode:M,setIsDragMode:T,isEdgeHandlesEnabled:N,setIsEdgeHandlesEnabled:$,isArrayNodeMode:I}=He(),W=j.useRef(null),[ie,ae]=j.useState(null),re=j.useRef(null),ye=e.length>200;j.useEffect(()=>{S(ye)},[ye,S]);const{edgeSep:be,rankSep:L,spacingFactor:z}=j.useMemo(()=>{const ce=zw(e.length),B=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:ce.edgeSep*B,rankSep:ce.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:G}=Nn(t),{canvas:D,borderSecondary:se,colorText:X}=st(),le=i==="transparent"?"transparent":b.backgroundColor||D,ue=j.useCallback(ce=>{if(!ce)return Pe(t);switch(ce){case"dark":return Pe(le);case"light":return Pe(se);default:return Pe(ce)}},[t,le,se]),Ce=b.colorMode==="dark",je=Ce?Pe("gray.500"):Zr,pe=Ce?G!=null&&G.includes("gray")?"whitesmoke":ue(G):je,fe=c?ue(c):je,Y=j.useMemo(()=>{var ce;return b.initialViewport||{pan:{x:0,y:0},zoom:(ce=b.nodeGrid)!=null&&ce.enabled&&b.nodeGrid.options.fill?1:.01}},[]),H=l==="C"?"LR":l,we=j.useCallback(ce=>{const B={...m,...ce};return{...B,bgColor:B.bgColor||t,bgOpacity:B.outline?0:B.bgOpacity??s_}},[m,t]),J=j.useMemo(()=>{var B;const ce=new Map;for(const oe of e)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[e]),ve=j.useMemo(()=>{var B;const ce=new Map;for(const oe of r)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[r]),Q=j.useCallback(ce=>{var U;const B=(U=J.get(ce))==null?void 0:U.data,oe=we(B==null?void 0:B.viewProps),$e=Pe(oe.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!ye,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:Pe(oe.borderColor||t),bgColor:oe.outline?"transparent":$e,bgOpacity:oe.bgOpacity,borderColor:oe.borderColor?Pe(oe.borderColor):oe.outline&&oe.bgColor==="transparent"?Pe(t):$e,borderWidth:In(oe.borderWidth,_r.borderWidth),borderStyle:oe.borderStyle??_r.borderStyle,borderRadius:oe.borderRadius??_r.borderRadius,textColor:oe.textColor?Pe(oe.textColor):oe.outline||oe.bgColor==="transparent"?Pe(X):$e,fontSize:oe.fontSize??_r.fontSize,labelPosition:oe.labelPosition??_r.labelPosition,labelMargin:_r.labelMargin,labelBg:wu(ue("dark"),$e,oe.bgOpacity)??ue("dark"),padding:oe.padding??_r.padding}},[we,J,X,t,ye,ue]),Ee=j.useMemo(()=>{var oe,$e;const ce=new Map;for(const U of r){const ge=(oe=U.data)==null?void 0:oe.source,Ie=($e=U.data)==null?void 0:$e.target;if(!ge||!Ie||ge===Ie)continue;const xe=ge<Ie?`${ge}|${Ie}`:`${Ie}|${ge}`,Ze=ce.get(xe);Ze?Ze.push({id:U.data.id,source:ge}):ce.set(xe,[{id:U.data.id,source:ge}])}const B=new Map;for(const[U,ge]of ce){if(ge.length<2)continue;const Ie=U.split("|")[0],xe=Math.min(20,70/ge.length);ge.forEach(({id:Ze,source:Qe},Ke)=>{const vt=50+(Ke-(ge.length-1)/2)*xe;B.set(Ze,(Qe===Ie?vt:100-vt)/100)})}return B},[r]),Ae=j.useMemo(()=>{const ce=ue("dark");return r.filter(B=>{var oe;return((oe=B.data)==null?void 0:oe.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var ge,Ie,xe,Ze,Qe,Ke;let oe=ce;const $e=(Ie=(ge=J.get(B.source))==null?void 0:ge.data)==null?void 0:Ie.parent,U=(Ze=(xe=J.get(B.target))==null?void 0:xe.data)==null?void 0:Ze.parent;if($e&&$e===U){const vt=we((Ke=(Qe=J.get($e))==null?void 0:Qe.data)==null?void 0:Ke.viewProps),It=wu(ce,Pe(vt.bgColor),vt.bgOpacity);It&&(oe=It)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(u==="auto"||u==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?Id(p,B):void 0,color:c?fe:B.color?Pe(B.color):fe,connectorColor:c?fe:B.color?Pe(B.color):pe,labelBg:oe,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:Ee.get(B.id)??.5}})},[r,fe,pe,c,Ee,b.edgeType,u,p,J,we,ue]),qe=j.useMemo(()=>{var B;const ce=new Set;for(const oe of e)(B=oe.data)!=null&&B.parent&&ce.add(oe.data.parent);return ce},[e]),Je=j.useMemo(()=>{const ce=new Map;for(const B of r){const oe=B.data.isInverted?B.data.target:B.data.source;oe&&!ce.has(oe)&&ce.set(oe,B.data)}for(const B of r){if(B.data.connection)continue;const oe=B.data.isInverted?B.data.target:B.data.source,$e=B.data.isInverted?B.data.source:B.data.target;$e.startsWith(`${oe}.`)&&(ce.set(oe,B.data),ce.set($e,B.data))}return ce},[r]),Fe=j.useMemo(()=>{const ce={...i_,...b.customViews};return e.filter(B=>{var oe;return(oe=B.data)==null?void 0:oe.id}).map(B=>{var xe,Ze,Qe,Ke,vt,It;const oe=qe.has(B.data.id)&&!B.data.parent,$e=oe?B.data.label??B.data.headerTitle??"Container":void 0,U=oe?ce.parentContainer:ce[B.data.type]||ce.text,ge=Je.get(B.data.id),Ie={...B,isInverted:((xe=B.data.config)==null?void 0:xe.isInverted)??(ge==null?void 0:ge.isInverted),isParent:oe,containerStyle:oe?Q(B.data.id):void 0};return{id:B.data.id,collapsed:(Ze=B.data.config)==null?void 0:Ze.collapsed,parent:B.data.parent,acceptsChildren:!!((Qe=B.data.config)!=null&&Qe.parentContainer)||qe.has(B.data.id),label:$e,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((Ke=B.data.config)==null?void 0:Ke.collapsed)!==void 0,animationColor:Pe(((vt=B.data.viewProps)==null?void 0:vt.borderColor)||t),animationWidth:In((It=B.data.viewProps)==null?void 0:It.borderWidth,8),element:j.createElement(U,{...Ie,key:`${B.data.id}-${t}`}),fillElement:k.has(B.data.id)?void 0:j.createElement(U,{...Ie,data:{...B.data,viewProps:{...B.data.viewProps,borderRadius:0}},containerStyle:Ie.containerStyle?{...Ie.containerStyle,borderRadius:0}:void 0,key:`${B.data.id}-${t}`})}})},[e,qe,Je,t,b.customViews,Q,k]),ct=j.useMemo(()=>ye?300:e.length>50?150:e.length>20?100:50,[e.length,ye]),De=j.useRef(b);De.current=b;const rt=j.useRef(E);rt.current=E;const ft=j.useRef(I);ft.current=I;const Oe=j.useRef(v);Oe.current=v;const Xe=j.useRef(w);Xe.current=w;const nt=j.useRef(P);nt.current=P;const lt=j.useRef(J);lt.current=J;const zt=j.useRef(ve);zt.current=ve;const kt=j.useRef(new Map);j.useEffect(()=>{var oe,$e;const ce=new Map([...ve].filter(([,U])=>J.has(U.data.source)&&J.has(U.data.target))),B=kt.current;kt.current=ce;for(const[U,ge]of B)ce.has(U)||(Xe.current===U&&(C(null),(oe=g.onEdgeDeselect)==null||oe.call(g)),($e=g.onEdgeRemove)==null||$e.call(g,U,ge.data))},[ve,J,g,C]),j.useEffect(()=>{const ce=W.current;if(!ie||!ce)return;let B=null,oe=null,$e=0,U=0,ge=0,Ie=0,xe=0;const Ze=Qe=>{var It;if(De.current.readOnly||De.current.minZoom===De.current.maxZoom&&De.current.minZoom!==void 0&&((It=ce.parentElement)!=null&&It.closest(".flow-sdk-canvas")))return;const Ke=ce.ownerDocument.fullscreenElement;if(Ke&&Ke!==ce&&ce.contains(Ke)&&Qe.target instanceof Node&&Ke.contains(Qe.target))return;Qe.preventDefault(),Qe.stopPropagation(),rt.current||Qe.metaKey||Qe.ctrlKey?(ge+=Qe.deltaY,Ie=Qe.clientX,xe=Qe.clientY,oe===null&&(oe=requestAnimationFrame(()=>{oe=null;const Jt=De.current,mt=ie.zoom(),pt=ge;ge=0;let xt=mt-pt*.05/100;xt=Math.max(Jt.minZoom??.01,Math.min(Jt.maxZoom??1.5,xt));const Tt=ce.getBoundingClientRect();ie.zoomAt(xt,{x:Ie-Tt.left,y:xe-Tt.top})}))):($e+=Qe.deltaX,U+=Qe.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const Jt=ie.pan(),mt=ie.zoom(),pt=.35,xt=$e,Tt=U;$e=0,U=0,ie.pan({x:Jt.x+-xt*pt/mt,y:Jt.y+-Tt*pt/mt})})))};return ce.addEventListener("wheel",Ze,{passive:!1}),()=>{ce.removeEventListener("wheel",Ze),B!==null&&cancelAnimationFrame(B),oe!==null&&cancelAnimationFrame(oe)}},[ie]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const ce=B=>{var $e,U,ge,Ie;if(De.current.readOnly)return;const oe=B.target;if(!(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.isContentEditable)){if((B.key==="z"||B.key==="Z")&&O(!rt.current),(B.key==="m"||B.key==="M")&&A(!P),(B.key==="d"||B.key==="D")&&T(!M),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&oe.tagName!=="SELECT"&&$(!N),(B.key==="Delete"||B.key==="Backspace")&&Xe.current){B.preventDefault();const xe=Xe.current;(U=g.onEdgeDelete)==null||U.call(g,xe,(($e=zt.current.get(xe))==null?void 0:$e.data)??{id:xe}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Oe.current.length>0){B.preventDefault();const xe=Oe.current.filter(Ze=>Ze!=="root");if(xe.length===0)return;for(const Ze of xe){const Qe=(ge=lt.current.get(Ze))==null?void 0:ge.data;(Ie=g.onNodeDelete)==null||Ie.call(g,Ze,Qe||{})}x([])}}};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[P,M,N,$,O,A,T,b.disableKeyboardShortcuts,g,x,C]);const et=j.useCallback(ce=>{var B;y.current=ce,ae(ce),(B=g.onInit)==null||B.call(g,ce)},[y,g]),We=j.useCallback(ce=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,ce)},[g]),Ht=j.useCallback(ce=>{var oe,$e,U;const B=((oe=zt.current.get(ce))==null?void 0:oe.data)??{id:ce};if(Xe.current===ce&&nt.current){C(null),($e=g.onEdgeDeselect)==null||$e.call(g);return}Oe.current.length&&x([]),C(ce),(U=g.onEdgeSelect)==null||U.call(g,ce,B)},[g,C,x]),dt=j.useCallback(()=>{var ce,B,oe,$e,U;if(a(b.bottomBarCollapsed??(Oe.current.length>0||!!Xe.current||!s)),(ce=g.onBackgroundClick)==null||ce.call(g),!De.current.readOnly){const ge=new Set;for(const Ie of Oe.current){let xe=lt.current.get(Ie);for(;xe&&!ge.has(xe.data.id);)ge.add(xe.data.id),qe.has(xe.data.id)&&((B=xe.data.config)==null?void 0:B.collapsed)!==!0&&((oe=g.onNodeCollapse)==null||oe.call(g,xe.data.id,!0)),xe=xe.data.parent?lt.current.get(xe.data.parent):void 0}}Oe.current.length&&(x([]),($e=g.onNodeDeselect)==null||$e.call(g)),Xe.current&&(C(null),(U=g.onEdgeDeselect)==null||U.call(g))},[g,x,C,a,s,b.bottomBarCollapsed,qe]),er=j.useCallback(ce=>{var $e,U;const B=Oe.current,oe=ce.filter(ge=>!B.includes(ge));if(oe.length){x([...B,...oe]);for(const ge of oe)(U=g.onNodeSelect)==null||U.call(g,ge,(($e=lt.current.get(ge))==null?void 0:$e.data)??{id:ge})}},[g,x]),ar=j.useCallback((ce,B)=>{var oe,$e;x([ce]),($e=g.onNodeSelect)==null||$e.call(g,ce,((oe=lt.current.get(ce))==null?void 0:oe.data)??{id:ce},B)},[g,x]),Bt=j.useRef(null),Dt=j.useCallback((ce,B,oe)=>{var $e;Bt.current={source:ce,target:B,edgeIds:new Set(zt.current.keys())};try{($e=g.onEdgeCreate)==null||$e.call(g,ce,B,oe)}catch(U){throw Bt.current=null,U}},[g]),Kt=j.useCallback((ce,B,oe,$e=!1)=>{var U,ge;if(re.current={sourceId:ce,nodeIds:new Set(lt.current.keys()),reverse:$e},!(u==="properties"&&((U=g.onNodeCreateRequest)==null?void 0:U.call(g,{sourceNodeId:ce,position:B,sourceProperty:oe,reverse:$e}))===!0)){if(oe!==void 0||$e){re.current=null;return}(ge=g.onNodeCreate)==null||ge.call(g,{type:"text",sourceNodeId:ce,position:B,isArrayMode:ft.current})}},[g,u]),tr=!b.readOnly&&N&&b.edgeHandles!==!1,$r=i==="transparent"?"none":i;return f.jsx(a_,{pattern:$r,backgroundColor:le,children:f.jsx(V.Box,{ref:W,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Bj,{nodes:Fe,edges:Ae,direction:H,nodeAlignment:d,onContainerCollapse:ce=>{var B,oe;(B=g.onNodeCollapse)==null||B.call(g,ce,!0),(oe=g.onNodeViewToggle)==null||oe.call(g,ce)},selectedNodeIds:v,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:L,edgeSep:be,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,initialNodeGrid:b.nodeGrid,spacingFactor:z,compactSpacingScale:n,layoutDebounce:ct,isPerformanceMode:ye,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:Y,fitOnInit:!b.initialViewport&&!((ze=b.nodeGrid)!=null&&ze.enabled&&b.nodeGrid.options.fill),readOnly:!!b.readOnly,containerStyle:Q,lineColor:c?fe:pe,drawMode:tr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:M,multiSelect:!!P,onInit:et,onLayoutComplete:ce=>{var ge;(ge=g.onLayoutComplete)==null||ge.call(g,ce);const B=Bt.current;B&&(!lt.current.has(B.source)||!lt.current.has(B.target)?Bt.current=null:r.some(({data:Ie})=>Ie.source===B.source&&Ie.target===B.target&&!B.edgeIds.has(Ie.id))&&ce.getNodeBox(B.source)&&ce.getNodeBox(B.target)&&(Bt.current=null,ce.focusConnections(B.source)));const oe=re.current;if(!oe)return;if(!lt.current.has(oe.sourceId)){re.current=null;return}const U=e.filter(Ie=>!oe.nodeIds.has(Ie.data.id)).filter(Ie=>r.some(({data:xe})=>xe.source===oe.sourceId&&xe.target===Ie.data.id||xe.target===oe.sourceId&&xe.source===Ie.data.id));!U.length||U.some(Ie=>!ce.getNodeBox(Ie.data.id))||(re.current=null,ce.focusBranch(oe.reverse?U[0].data.id:oe.sourceId))},onNodeGridModeChange:_,onNodeGridZoomOut:g.onNodeGridZoomOut,onNodeGridDrop:g.onNodeGridDrop,onNodeParentChange:g.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:We,onBackgroundTap:dt,onBoxSelect:er,onEdgeSelect:Ht,onContainerSelect:ar,onEdgeDraw:Dt,onDrawIntoSpace:Kt})})})},ox=j.memo(c_),l_=".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 Sm=!1;function d_(){if(Sm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=l_+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+$b+Lw+$w+".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}',Sm=!0}function u_({loading:e=!1,loader:r,...t}){var c,l;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Tw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!i,a=e||s;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==t.json&&o(t)},[e,i,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>o(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(V.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{var h;const u=(d==null?void 0:d.contains(document.activeElement))&&((h=document.activeElement)==null?void 0:h.matches("input, textarea, [contenteditable=true]"));a&&(e||!u)?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(f_,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(V.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function f_({title:e="untitled",json:r,forms:t,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){d_();const[u,h]=j.useState(),[p,m]=j.useState(!1),y=i.formSchema??u,g=j.useMemo(()=>r&&t?pb(r,t.state):r,[r,t==null?void 0:t.state]),b=i.direction==="C",v=j.useMemo(()=>{let P,A;return M=>(A=P&&A?Ow(P,M,A)??hd(M,{title:e,isCenter:b}):hd(M,{title:e,isCenter:b}),P=M,A)},[e,b]),x=j.useMemo(()=>g?v(g):null,[g,v]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&y?gb(t.state,t.bindings,y,(x==null?void 0:x.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,y,x,n]),C=(w==null?void 0:w.schema)??y,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),_=j.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(A=>{var ie,ae,re,ye;const M=r?(ie=Le(r,A.data.id))==null?void 0:ie.$view:(ae=A.data.config)==null?void 0:ae.typeView,T=M&&wd.includes(M)?M:void 0,N=T?T==="icon-label":(re=A.data.config)==null?void 0:re.labelBelow,$=T==="object"?"objectView":T==="text"?"text":N?"arrayView":A.data.type,I=C&&(t?$n(S,A.data.id,C):r&&Xr(r,A.data.id,C)),W=(((ye=A.data.config)==null?void 0:ye.ports)??[]).map(be=>({...be}));if(w&&I){const be=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[L,z]of Object.entries(I.type.ports??{})){const G=`${z.kind}:${L}`,D=W.find(se=>se.id===G);D?D.label===void 0&&z.label!==void 0&&(D.label=z.label):W.push({id:G,...z.label!==void 0?{label:z.label}:{},role:z.kind==="input"||z.kind==="config"?"target":"source",side:be[z.kind],...z.kind==="config"?{placement:"config"}:{}})}for(const L of W){const z=W.filter(G=>G.side===L.side);L.position=(z.indexOf(L)+1)/(z.length+1)}}return I||N||T?{...A,data:{...A.data,type:$,...t?{description:Object.fromEntries(Object.entries(A.data.description??{}).filter(([be])=>!be.startsWith("$")&&!(w!=null&&w.slots.has(gn(A.data.id,be)))))}:{},config:{...A.data.config,...w&&I?{ports:W}:{},...I?{form:!0}:{},...T?{typeView:T,labelBelow:!!N}:N?{labelBelow:!0}:{}}}}:A}),[x,n,r,C,S,w,i.direction]),k=j.useMemo(()=>[...(x==null?void 0:x.edges)??o??[],...(w==null?void 0:w.edges)??[]],[x==null?void 0:x.edges,o,w==null?void 0:w.edges]),E=j.useMemo(()=>{const P=r&&x?Nb(r,x.edges,s,s.onJsonChange,y):{...s};if(w){const A=new Set([...w.nodes.map(M=>M.data.id),...w.edges.map(M=>M.data.id)]);for(const M of Object.keys(P)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const T=P[M];P[M]=(N,...$)=>{if(!A.has(N))return T==null?void 0:T(N,...$)}}}return{...P,onAllNodesIconLabelChange:A=>{var M;m(A),(M=P.onAllNodesIconLabelChange)==null||M.call(P,A)}}},[r,x,s,y,w]),O=j.useMemo(()=>{if(!t)return E;let P=t.state;const A=T=>{if(i.readOnly||i.editable===!1)return;const N=t.onStateChange??t.onChange;if(!N)return;const $=ww(P,T,s.onFormChange);$!==P&&(P=$,N($,{...T,data:$}))},M=(T,N,$)=>{var W;const I=r&&((W=Le(r,T))==null?void 0:W[N]);return!I||typeof I.$state!="string"?!1:(A({address:I.$state,nodeAddress:T,previousValue:Le(P,I.$state),value:$,data:P}),!0)};return{...E,onFormChange:A,onNodeCreateRequest:T=>{var I,W;const N=(I=T.sourceProperty)!=null&&I.startsWith("config:")?T.sourceProperty.slice(7):void 0,$=N!==void 0&&(w==null?void 0:w.slots.get(gn(T.sourceNodeId,N)));return $?($.present||A({data:P,nodeAddress:$.address.split(".").slice(0,-1).join("."),address:$.address,value:yn($.type),previousValue:void 0}),!0):((W=E.onNodeCreateRequest)==null?void 0:W.call(E,T))??!1},onNodeDelete:(T,N)=>{var re,ye;if(!(w!=null&&w.nodes.some(be=>be.data.id===T)))return(re=E.onNodeDelete)==null?void 0:re.call(E,T,N);const $=w&&[...w.slots.values()].find(be=>be.nodeId===T);if(!$)return(ye=E.onNodeDelete)==null?void 0:ye.call(E,T,N);const I=$.address.split("."),W=I.pop(),ie=I.join("."),ae=Le(P,ie);A(Array.isArray(ae)?{data:P,nodeAddress:ie,address:ie,previousValue:ae,value:ae.filter((be,L)=>String(L)!==W)}:{data:P,nodeAddress:ie,address:$.address,previousValue:Le(P,$.address),value:void 0})},onEdgeCreate:(T,N,$)=>{var ie,ae;const I=((ie=$==null?void 0:$.targetProperty)==null?void 0:ie.startsWith("config:"))&&(w==null?void 0:w.slots.get(gn(N,$.targetProperty.slice(7)))),W=w==null?void 0:w.containers.get(T);if(I&&W&&($==null?void 0:$.sourceProperty)==="output:resource"){const re=jw(P,W,I);re!==void 0&&A({data:P,nodeAddress:I.address.split(".").slice(0,-1).join("."),address:I.address,previousValue:Le(P,I.address),value:re});return}I||w!=null&&w.nodes.some(re=>re.data.id===T||re.data.id===N)||(ae=E.onEdgeCreate)==null||ae.call(E,T,N,$)},onEdgeDelete:(T,N)=>{var ye;const $=w==null?void 0:w.edges.find(be=>be.data.id===T);if(!$)return(ye=E.onEdgeDelete)==null?void 0:ye.call(E,T,N);const I=w.slots.get(gn($.data.target,$.data.targetProperty.slice(7))),W=I.address.split("."),ie=W.pop(),ae=W.join("."),re=Le(P,ae);A(Array.isArray(re)?{data:P,nodeAddress:ae,address:ae,previousValue:re,value:re.filter((be,L)=>String(L)!==ie)}:{data:P,nodeAddress:ae,address:I.address,previousValue:Le(P,I.address),value:void 0})},onNodeContentChange:(T,N)=>{var $,I;M(T,"$content",N)?($=s.onNodeContentChange)==null||$.call(s,T,N):(I=E.onNodeContentChange)==null||I.call(E,T,N)},onNodeLabelChange:(T,N)=>{var $,I;M(T,"$label",N)?($=s.onNodeLabelChange)==null||$.call(s,T,N):(I=E.onNodeLabelChange)==null||I.call(E,T,N)}}},[E,t,r,s,w,i.readOnly,i.editable]);return f.jsx(Mt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:P=>{var A;h(P),(A=s.onFormSchemaChange)==null||A.call(s,P)},callbacks:O},children:f.jsx(Mm,{config:w?{...i,formSchema:C}:i,callbacks:O,nodes:_,edges:k,children:f.jsxs(V.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":i.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(ox,{nodes:_,edges:k}),l&&f.jsx(Ab,{}),d]})})})}function h_(e){return xd(JSON.parse(e))}function xd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);t(i)}r.delete(n)}};return t(e),structuredClone(e)}function p_(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=xd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=xd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function g_(e,r){const t=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,s)=>t(i,o[s])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,s])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i==="$content"&&n.$contentFormat==="jsx"&&o.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(o[i]))return[[i,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(o[i][l]))]];if(i.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=t(s,o[i]);return a===void 0?[]:[[i,a]]}))};return t(e,r)??{}}function eo(e){let r="",t=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,i(),new Error("JSON stream exceeds the size limit.");r=c,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,i();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,i(),r=""}}}function y_(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let o=eo(e),i=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:i,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(y=!1)=>{o.snapshot(r.slice(0,i)),i===r.length?(s=!1,u(),o.finish()):y&&o.flush()},p=y=>{s=!1,u(),o.cancel(),d(),e.onError(y)},m=()=>{if(c=void 0,!(!s||a)){i=Math.min(r.length,i+l);try{h()}catch(y){p(y);return}d(),s&&(c=setTimeout(m,t))}};return{play(){a||s||(i===r.length&&(o.cancel(),o=eo(e),i=0),s=!0,d(),c=setTimeout(m,t))},pause(){a||(s=!1,u(),o.flush(),d())},seek(y){if(!a){if(!Number.isFinite(y))throw new Error("Playback position must be finite.");u(),i=Math.max(0,Math.min(r.length,Math.round(y))),o.cancel(),o=eo(e);try{h(!0)}catch(g){p(g);return}d(),s&&(c=setTimeout(m,t))}},dispose(){a=!0,s=!1,u(),o.cancel()}}}function m_({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:o}=j.useContext(Mt),{colorText:i,background:s}=st();if((l=o==null?void 0:o[e])!=null&&l.portResources)return null;const a=o&&$n(o,e,n);if(!t||!a)return null;const c=Le(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:Pe(i),background:Pe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!ho(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:$t(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=Ab;exports.CollapseAllToggle=eb;exports.CompactPropertyLayoutToggle=tb;exports.ConnectionsOnlyToggle=Iw;exports.DEFAULT_PALETTE=no;exports.DiagramAppearanceControls=rb;exports.DynamicIcon=Xt;exports.EdgeTools=wb;exports.EditableLabel=Jr;exports.ErrorToast=kb;exports.FlowDiagram=u_;exports.FlowDiagramProvider=Mm;exports.FlowPort=Yv;exports.FlowView=ox;exports.FormDocumentContext=Mt;exports.GridAdjustmentToggle=nb;exports.LIGHT_BLACK=Zr;exports.LoadingBorder=Xv;exports.NODE_TYPE_VIEWS=wd;exports.NodeBorderRadiusControl=Cb;exports.NodeConfigSummary=m_;exports.NodeForm=Od;exports.NodeFormPopover=su;exports.NodeIconPicker=Nd;exports.NodeTools=Sb;exports.NodeView=Vn;exports.SvgExportButton=Eb;exports.Swatches=Mr;exports.TEXT_PALETTE=vb;exports.ToolbarCloseButton=Yr;exports.ToolbarCommitInput=Dr;exports.ToolbarDivider=xn;exports.ToolbarIconButton=Ne;exports.ToolbarRangeInput=Sd;exports.ToolbarScrollContainer=$d;exports.ToolbarSelect=At;exports.ToolbarTooltip=Ue;exports.TooltipIconButton=vd;exports.WorkflowControls=qd;exports.addChild=Rd;exports.addConnection=Ad;exports.addTargetEdge=db;exports.addressToPath=Vt;exports.applyCollapsed=bw;exports.applyFormChange=po;exports.applyStateEdits=xw;exports.bindSqueedCallbacks=Nb;exports.compileSqueed=hd;exports.connectionIssue=Id;exports.contentObjTheme=Yt;exports.copySelection=Ld;exports.createFlowDiagram=Pr;exports.createFlowDocumentActions=p_;exports.createFormNode=Mb;exports.createJsonPlayback=y_;exports.createJsonStream=eo;exports.createWorkflowExecution=Sx;exports.downloadSvg=_b;exports.duplicateSelection=Ob;exports.exportSvg=jb;exports.formValueError=Wt;exports.getChakraColorHex=Pe;exports.getColorVariant=km;exports.getDarkerHexColor=to;exports.getInteractionSurface=gr;exports.getNode=Le;exports.getSelectionRoots=Tb;exports.parseFlowDocument=h_;exports.parseJsonContract=Pd;exports.parseTypeScriptContract=fb;exports.parseTypeScriptForm=Md;exports.projectJsonPlaybackPreview=g_;exports.readFormSchema=Td;exports.readWorkflowContract=hb;exports.removeEdge=ub;exports.removeNode=lb;exports.reparentNode=Ib;exports.resolveEdgeOwner=Rr;exports.resolveStateView=pb;exports.setCollapsed=kd;exports.setEdgeProp=ur;exports.setEdgeStyle=cb;exports.setNodeProp=St;exports.updateNode=_t;exports.useCustomColors=st;exports.useEdgeProximity=Em;exports.useFlowData=vr;exports.useFlowDiagramContext=He;exports.useNodeViewActions=Wn;exports.useStopPropagation=au;exports.useThemeContentColors=Nn;exports.validateGridAdjustment=Hv;
|
|
283
|
+
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function Xv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:o}=He(),{colorText:i}=st(),s=j.useRef(null),[a,c]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const m=u.parentElement,y={width:u.clientWidth,height:u.clientHeight,radius:t??(m&&parseFloat(getComputedStyle(m).borderTopLeftRadius)||0)};c(g=>g.width===y.width&&g.height===y.height&&g.radius===y.radius?g:y)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=Pe(o||i),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:Hj}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(oo,{...d,strokeWidth:6})}),f.jsx(oo,{...d})]})]})}function Kj({content:e,format:r,onEdit:t}){var N;const{config:n,colorMode:o}=He(),{background:i,border:s,colorInactive:a}=st(),c=(N=n.customViews)==null?void 0:N.jsxContent,l=typeof e=="string"?e:JSON.stringify(e,null,2);let d,u;if(r==="jsx")try{const $=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray($)||$.some(I=>!I||typeof I!="object"||Array.isArray(I)||typeof I.type!="string"))throw new Error("JSX content must be an array of components with a type.");d=$}catch($){u=$ instanceof Error?$.message:"Invalid components array."}const h=j.useRef(null),p=j.useRef(null),m=j.useRef(null),y=j.useRef(!1),[g,b]=j.useState(!1),[v,x]=j.useState(""),w=!!t;j.useEffect(()=>{const $=()=>{var W;const I=document.fullscreenElement===p.current;b(I),y.current&&!I&&!document.fullscreenElement&&((W=m.current)==null||W.focus({preventScroll:!0})),y.current=I};return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const C=async()=>{var $;x("");try{if(document.fullscreenElement===p.current)await document.exitFullscreen();else if(($=p.current)!=null&&$.requestFullscreen)await p.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(I){x(I instanceof Error?I.message:"Unable to change fullscreen.")}},[S,_]=j.useState(),[k,E]=j.useState(),[O,P]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let $=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-BsKd0dD4.cjs")).then(({contentPreviewDocument:I})=>I(l,r,w)).then(I=>{$||_({content:l,format:r,editable:w,document:I})},I=>{$||_({content:l,format:r,editable:w,error:I instanceof Error?I.message:String(I)})}),()=>{$=!0}},[l,r,w]),j.useEffect(()=>{if(!t)return;const $=async I=>{var W,ie;if(!(!((W=h.current)!=null&&W.contentWindow)||I.source!==h.current.contentWindow||((ie=I.data)==null?void 0:ie.type)!=="squeed:content-edit"))try{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()}catch(ae){x(ae instanceof Error?ae.message:"Unable to close fullscreen.")}};return window.addEventListener("message",$),()=>window.removeEventListener("message",$)},[t]);const A=(S==null?void 0:S.content)===l&&S.format===r&&S.editable===w?S:void 0,M=!!A&&A===O,T=r!=="jsx"&&!(A!=null&&A.error)&&!M&&(!A||k!==A);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:l}),f.jsxs(V.Box,{ref:p,position:"relative",w:"100%",h:"100%","aria-busy":r!=="jsx"?T:void 0,bg:r==="jsx"&&o==="dark"?"gray.900":"white",onDoubleClick:$=>{r!=="jsx"||!t||$.defaultPrevented||$.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||($.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I))))},onKeyDownCapture:$=>{$.key!=="Escape"||document.fullscreenElement!==p.current||($.preventDefault(),$.stopPropagation(),C())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-content-toolbar], &:focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(V.Box,{role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:g?1:0,pointerEvents:g?"auto":"none",children:f.jsx($d,{background:i,border:o==="dark"?s:"gray.300",children:f.jsxs(V.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&f.jsx(Ne,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Z.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I)))}}),f.jsx(Ne,{ref:m,"data-flow-fullscreen":"","aria-label":g?"Exit fullscreen":"Expand preview",title:g?"Exit fullscreen":"Expand preview","aria-expanded":g,icon:g?f.jsx(Z.PiArrowsIn,{size:20}):f.jsx(Z.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),C()}})]})})}),v&&f.jsx(V.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:v}),r==="jsx"?u?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:u}):c&&d?f.jsx(c,{components:d,colorMode:o,fillHeight:!0}):f.jsx(V.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):A!=null&&A.error||M?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(A==null?void 0:A.error)||"Content preview could not be loaded."}):A!=null&&A.document?f.jsx("iframe",{ref:h,title:`${r.toUpperCase()} content preview`,sandbox:w?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:A.document,onLoad:()=>E(A),onError:()=>P(A),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:T?"hidden":"visible"}},A.document):null,f.jsx(Xv,{active:T,label:"Loading HTML content"})]})]})}const Cm=1.55;function Jj({nodeId:e,content:r,color:t,format:n="markdown"}){const{callbacks:o,config:i,readOnly:s,nodeGridOptions:a}=He(),c=!!i.editable&&!s,l=c&&!a,d=typeof r=="string"?r:JSON.stringify(r,null,2),[u,h]=j.useState(!1),[p,m]=j.useState(d),[y,g]=j.useState(""),[b,v]=j.useState(),x=j.useRef(null),w=j.useRef(!1),C=au(u);j.useLayoutEffect(()=>{const k=x.current;!u||!k||(k.style.height="auto",k.style.height=`${Math.max((b==null?void 0:b.height)??0,k.scrollHeight)}px`)},[p,u,b]),j.useEffect(()=>{var k,E;c?u&&(w.current=!1,(k=x.current)==null||k.focus({preventScroll:!0}),(E=x.current)==null||E.select()):h(!1)},[u,c]);const S=(k,E=!1)=>{!c||a&&!E||(v({width:k.offsetWidth,height:k.offsetHeight}),m(d),g(""),h(!0))},_=()=>{var E;if(w.current||!c)return;let k=p;if(n==="jsx")try{if(k=JSON.parse(p),!Array.isArray(k)||k.some(O=>!O||typeof O!="object"||Array.isArray(O)||typeof O.type!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(O){g(O instanceof Error?O.message:"Invalid components array.");return}w.current=!0,p!==d&&((E=o.onNodeContentChange)==null||E.call(o,e,k)),h(!1)};return(!u||!c)&&n!=="markdown"?f.jsx(V.Box,{ref:C,w:"100%",position:"relative","data-flow-content":"",children:f.jsx(Kj,{content:r,format:n,onEdit:l?()=>{C.current&&S(C.current)}:void 0})}):!u||!c?f.jsx(V.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:Cm,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:l?"text":void 0,tabIndex:l?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:k=>{!c||a&&!k.shiftKey||k.target instanceof Element&&k.target.closest("a, button, input")||(k.stopPropagation(),S(k.currentTarget,k.shiftKey))},onDoubleClick:k=>{k.stopPropagation(),S(k.currentTarget,k.shiftKey)},onKeyDown:k=>{c&&(!a||k.shiftKey)&&k.key==="Enter"&&k.target===k.currentTarget&&(k.preventDefault(),k.stopPropagation(),S(k.currentTarget,k.shiftKey))},children:f.jsx(Cx.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:d||(i.editable&&!s?"Write your content here":"")})}):f.jsxs("div",{ref:C,style:{width:b==null?void 0:b.width,minHeight:b==null?void 0:b.height,maxWidth:"100%"},children:[f.jsx(V.Textarea,{ref:x,"aria-label":"Node content",placeholder:"Write your content here",value:p,"aria-invalid":!!y,onChange:k=>m(k.target.value),onBlur:_,onKeyDown:k=>{k.stopPropagation(),!k.nativeEvent.isComposing&&(k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&(k.preventDefault(),_()),k.key==="Escape"&&(w.current=!0,h(!1)))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:Cm,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),y&&f.jsx(V.Box,{role:"alert",fontSize:"14px",color:"red.500",children:y})]})}const Zj=(e,r,t)=>{var h,p,m,y;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[o]=n.split("."),i=Nn(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?Pe(n):Pe(i.bgColor),d=Pe(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(a?c:i.textColor)),u=Pe(((y=e==null?void 0:e.viewProps)==null?void 0:y.borderColor)||(s?n==="transparent"?r:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?c:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:l,hextextColor:d,hexborderColor:u}},Yj=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,Xj=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Qv=600,Qj=3,e_=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function t_({headerTitle:e,hasContent:r,data:t,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isHovered:c,isEditing:l,onSelect:d,onEditStart:u,onEditEnd:h,props:p,objVisible:m,setObjVisible:y,onShowNativeIcon:g}){var w,C;const{callbacks:b}=He(),v=p.onShowIcon??g,x=v?"Show icon":m?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((w=t.config)==null?void 0:w.form)||(a||c)&&g)&&f.jsxs(V.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!r?"transparent":o.hexborderColor,children:[!!n&&f.jsx(V.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Qt,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),f.jsx(Jr,{nodeId:s,label:Xj(e),color:((C=t==null?void 0:t.viewProps)==null?void 0:C.textColor)||o.propertyColor,isEditing:l,onEditStart:u,onEditEnd:h}),(a||c)&&(r||v)&&f.jsx(V.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Ue,{label:x,children:f.jsx(Ne,{"aria-label":x,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:S=>{var _;S.stopPropagation(),a||d(S),v?v():y(!m),(_=b.onNodeViewToggle)==null||_.call(b,s)}})})})]})})}function r_({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=vr(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(V.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var M,T,N;const m=r&&Object.keys(r).find($=>$.slice($.indexOf(":")+1)===u),y=t&&((M=n==null?void 0:n.type.ports)==null?void 0:M[u]),g=m??(y?`${y.kind}:${u}`:u),b=o.find($=>$.id===g),v=m?"source":b==null?void 0:b.role,x=d.has(`source:${g}`),w=d.has(`target:${g}`),C=i.some($=>$.id===u),S=h===""&&(C||(v?d.has(`${v}:${g}`):x||w)),_=v??(x!==w?x?"source":"target":void 0),k=(b==null?void 0:b.side)??(_?_==="source"!=(a==="RL")?"right":"left":void 0),E=S&&k==="right"?"right":"left",O=(b==null?void 0:b.label)??(y==null?void 0:y.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),P=Xt(s.wordBeforeDot)[typeof h],A=Xt(s.wordBeforeDot).property;return f.jsxs(V.Box,{"data-flow-property":m&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":v,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(V.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(V.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(V.Text,{py:5,px:10,w:"100%",textAlign:E,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((T=e==null?void 0:e.viewProps)==null?void 0:T.textColor)||(s.isTransparent?s.hextextColor:A),children:O})}),!S&&f.jsx(V.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:Qv,maxH:200,children:f.jsx(V.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((N=e==null?void 0:e.viewProps)==null?void 0:N.textColor)||(s.isTransparent?s.hextextColor:P),fontWeight:400,children:Yj(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(V.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function n_(e){var x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n}=He(),o=Wn(),i=o.getNodeViewMode(e.data.id)==="properties",s=k=>o.setNodeViewMode(e.data.id,k?"properties":"default"),a=!!e.onShowIcon||i||typeof((x=e.data.config)==null?void 0:x.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=j.useContext(Mt),u=(S=c==null?void 0:c[e.data.id])==null?void 0:S.portResources,h=c?$n(c,e.data.id,d):l&&d?Xr(l,e.data.id,d):void 0,p=h&&Le(l,"address"in h?h.address:e.data.id),m=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(k=>{var E;return Object.prototype.hasOwnProperty.call(p,k)&&ho((E=h.fields[k])==null?void 0:E.$visibleWhen,l)}).map(k=>[k,p[k]!==null&&typeof p[k]=="object"?JSON.stringify(p[k],null,2):p[k]===null?"null":p[k]])):{},y=u?Object.fromEntries(Object.entries(u).map(([k,E])=>{var O;return[k.slice(k.indexOf(":")+1),((O=Le(l,E))==null?void 0:O.name)??E.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,g=a&&!u?((_=e.data.config)==null?void 0:_.ports)??[]:[],b=g.filter(k=>!Object.prototype.hasOwnProperty.call(y,k.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([E,O])=>`${O.kind}:${E}`===k.id&&Object.prototype.hasOwnProperty.call(y,E))),v={...y,...Object.fromEntries(b.map(k=>[k.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:v,inspectionPorts:g,extraPorts:b}}const du=e=>{var v,x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=n_(e),h=Wn(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&(typeof((v=e.data.config)==null?void 0:v.content)=="string"||((x=e.data.config)==null?void 0:x.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),y=j.useRef(p);p&&(y.current=!0),cu(e.data.id,m&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&y.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((S=e.data.config)!=null&&S.parentContainer)&&!m?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(lu,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((_=e.data.config)==null?void 0:_.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(Vn,{...e,data:{...e.data,description:l},hoverLeaveDelay:m||e.onShowIcon||b?350:0,children:({id:k,data:E,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N})=>{var L,z,G,D,se,X,le,ue,Ce,je;const $=Zj(E,r,t),I=E.label??E.headerTitle,W=Object.entries(E.description||{}).length>0,ie=e_(E.description),ae=(z=(L=e.data)==null?void 0:L.config)==null?void 0:z.icon,re=(D=(G=e.data)==null?void 0:G.config)==null?void 0:D.content,ye=((se=E==null?void 0:E.viewProps)==null?void 0:se.borderRadius)??"53px",be=Tn(E==null?void 0:E.viewProps,$.hexborderColor,O,Qj);return f.jsx(V.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:ye,overflow:"hidden",alignItems:"center",style:{backgroundColor:$.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:m||e.onShowIcon?ie+Qv+be.borderWidth*2:void 0,...be,children:f.jsxs(V.Flex,{width:"100%",direction:"column",borderRadius:ye,borderColor:$.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(t_,{headerTitle:I,hasContent:m,data:E,icon:ae,colors:$,hasConfig:W,id:k,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:b}),m&&!o?f.jsx(V.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:$.highlightColor,p:["html","jsx"].includes((le=(X=e.data)==null?void 0:X.config)==null?void 0:le.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(Jj,{nodeId:k,content:re,format:(Ce=(ue=e.data)==null?void 0:ue.config)==null?void 0:Ce.contentFormat,color:((je=E==null?void 0:E.viewProps)==null?void 0:je.textColor)||$.hextextColor})}):f.jsx(r_,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:$,direction:n,uniformKeyWidth:ie})]})})}})};du.displayName="NodeJsonObjectView";const ex=e=>{var h,p,m,y,g,b,v,x,w,C,S;const r=Wn(),[t,n]=j.useState(!1),o=r.getNodeViewMode(e.data.id)==="properties",i=_=>{n(_),r.setNodeViewMode(e.data.id,_?"properties":"default")},{callbacks:s,readOnly:a}=He(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;cu(e.data.id,o&&((y=(m=e.data)==null?void 0:m.config)==null?void 0:y.labelBelow)&&!c,()=>i(!1));const l=c?"Show parent":"Show properties",d=c||((b=(g=e.data)==null?void 0:g.config)==null?void 0:b.form)||((w=(x=(v=e.data)==null?void 0:v.config)==null?void 0:x.ports)==null?void 0:w.length),u=d?()=>{var _;c?(_=s.onNodeCollapse)==null||_.call(s,e.data.id,!1):i(!0)}:void 0;return!c&&d&&o?f.jsx(du,{...e,editOnMount:t,onShowIcon:()=>i(!1)}):f.jsx(lu,{...e,onOpenView:u&&(c||(S=(C=e.data)==null?void 0:C.config)!=null&&S.labelBelow)?()=>{var _;u(),(_=s.onNodeViewToggle)==null||_.call(s,e.data.id)}:void 0,toggleLabel:l,toggleDisabled:c&&a,onExpand:u})};function o_(e){var b,v,x,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:o,nodeRadiusPreviews:i,nodeViewModes:s,allNodesIconLabel:a}=He(),c=i[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=j.useState(!1),u=Wn(),{border:h,colorText:p}=st(),m=(v=r.customViews)==null?void 0:v.gridContent,y=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",g=j.useRef(y);return y&&(g.current=!0),cu(e.data.id,a&&!y&&g.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),y?f.jsx(V.Box,{"data-grid-document":((x=e.data.config)==null?void 0:x.documentId)??"",children:f.jsx(lu,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx(Vn,{...e,onOpenView:()=>d(!0),children:({data:_,isActive:k})=>{var E,O,P,A,M,T,N,$;return f.jsx(V.Box,{"data-flow-node-surface":"","data-grid-document":((E=_.config)==null?void 0:E.documentId)??"",width:`${((P=(O=_.config)==null?void 0:O.gridSize)==null?void 0:P.width)??600}px`,height:`${((M=(A=_.config)==null?void 0:A.gridSize)==null?void 0:M.height)??440}px`,overflow:"hidden",position:"relative",bg:((T=_.viewProps)==null?void 0:T.bgColor)??"transparent",color:((N=_.viewProps)==null?void 0:N.textColor)??p,borderRadius:`${c??0}px`,...Tn(_.viewProps,Pe((($=_.viewProps)==null?void 0:$.borderColor)??h),k,0),children:m?f.jsx(m,{...e}):f.jsx(V.Box,{p:4,children:_.label??"Grid"})})}}),f.jsx(su,{nodeAddress:e.data.id,active:o.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(Mt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:_=>{var E,O,P;if(n||!r.editable)return;const k=String(_.value??"");_.address==="root.metadata.label"?(E=t.onNodeLabelChange)==null||E.call(t,e.data.id,k):_.address==="root.metadata.subtitle"?(O=t.onNodeSubtitleChange)==null||O.call(t,e.data.id,k):_.address==="root.metadata.icon"&&((P=t.onNodeIconChange)==null||P.call(t,e.data.id,k))}}},children:f.jsx(Od,{nodeAddress:e.data.id})})})]})}const tx=e=>f.jsx(ex,{...e,renderCompact:Gj}),rx=e=>f.jsx(ex,{...e}),nx=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=He();return f.jsx(Vn,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(V.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:hr,lineHeight:1,w:"fit-content",children:f.jsx(Jr,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};tx.displayName="text";rx.displayName="arrayView";nx.displayName="ParentContainerView";const i_={grid:o_,objectView:du,arrayView:rx,text:tx,parentContainer:nx},a_=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=He(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(V.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(V.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(V.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(V.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},s_=.4,_r={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},c_=({nodes:e,edges:r})=>{var ze;const{themeColor:t,spacing:n,edgeRadius:o,backgroundVariant:i,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:m,engineRef:y,callbacks:g,config:b,selectedNodeIds:v,setSelectedNodeIds:x,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:_,fillRadiusEditedIds:k,isZoomMode:E,setIsZoomMode:O,isMultiSelectMode:P,setIsMultiSelectMode:A,isDragMode:M,setIsDragMode:T,isEdgeHandlesEnabled:N,setIsEdgeHandlesEnabled:$,isArrayNodeMode:I}=He(),W=j.useRef(null),[ie,ae]=j.useState(null),re=j.useRef(null),ye=e.length>200;j.useEffect(()=>{S(ye)},[ye,S]);const{edgeSep:be,rankSep:L,spacingFactor:z}=j.useMemo(()=>{const ce=zw(e.length),B=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:ce.edgeSep*B,rankSep:ce.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:G}=Nn(t),{canvas:D,borderSecondary:se,colorText:X}=st(),le=i==="transparent"?"transparent":b.backgroundColor||D,ue=j.useCallback(ce=>{if(!ce)return Pe(t);switch(ce){case"dark":return Pe(le);case"light":return Pe(se);default:return Pe(ce)}},[t,le,se]),Ce=b.colorMode==="dark",je=Ce?Pe("gray.500"):Zr,pe=Ce?G!=null&&G.includes("gray")?"whitesmoke":ue(G):je,fe=c?ue(c):je,Y=j.useMemo(()=>{var ce;return b.initialViewport||{pan:{x:0,y:0},zoom:(ce=b.nodeGrid)!=null&&ce.enabled&&b.nodeGrid.options.fill?1:.01}},[]),H=l==="C"?"LR":l,we=j.useCallback(ce=>{const B={...m,...ce};return{...B,bgColor:B.bgColor||t,bgOpacity:B.outline?0:B.bgOpacity??s_}},[m,t]),J=j.useMemo(()=>{var B;const ce=new Map;for(const oe of e)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[e]),ve=j.useMemo(()=>{var B;const ce=new Map;for(const oe of r)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[r]),Q=j.useCallback(ce=>{var U;const B=(U=J.get(ce))==null?void 0:U.data,oe=we(B==null?void 0:B.viewProps),$e=Pe(oe.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!ye,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:Pe(oe.borderColor||t),bgColor:oe.outline?"transparent":$e,bgOpacity:oe.bgOpacity,borderColor:oe.borderColor?Pe(oe.borderColor):oe.outline&&oe.bgColor==="transparent"?Pe(t):$e,borderWidth:In(oe.borderWidth,_r.borderWidth),borderStyle:oe.borderStyle??_r.borderStyle,borderRadius:oe.borderRadius??_r.borderRadius,textColor:oe.textColor?Pe(oe.textColor):oe.outline||oe.bgColor==="transparent"?Pe(X):$e,fontSize:oe.fontSize??_r.fontSize,labelPosition:oe.labelPosition??_r.labelPosition,labelMargin:_r.labelMargin,labelBg:wu(ue("dark"),$e,oe.bgOpacity)??ue("dark"),padding:oe.padding??_r.padding}},[we,J,X,t,ye,ue]),Ee=j.useMemo(()=>{var oe,$e;const ce=new Map;for(const U of r){const ge=(oe=U.data)==null?void 0:oe.source,Ie=($e=U.data)==null?void 0:$e.target;if(!ge||!Ie||ge===Ie)continue;const xe=ge<Ie?`${ge}|${Ie}`:`${Ie}|${ge}`,Ze=ce.get(xe);Ze?Ze.push({id:U.data.id,source:ge}):ce.set(xe,[{id:U.data.id,source:ge}])}const B=new Map;for(const[U,ge]of ce){if(ge.length<2)continue;const Ie=U.split("|")[0],xe=Math.min(20,70/ge.length);ge.forEach(({id:Ze,source:Qe},Ke)=>{const vt=50+(Ke-(ge.length-1)/2)*xe;B.set(Ze,(Qe===Ie?vt:100-vt)/100)})}return B},[r]),Ae=j.useMemo(()=>{const ce=ue("dark");return r.filter(B=>{var oe;return((oe=B.data)==null?void 0:oe.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var ge,Ie,xe,Ze,Qe,Ke;let oe=ce;const $e=(Ie=(ge=J.get(B.source))==null?void 0:ge.data)==null?void 0:Ie.parent,U=(Ze=(xe=J.get(B.target))==null?void 0:xe.data)==null?void 0:Ze.parent;if($e&&$e===U){const vt=we((Ke=(Qe=J.get($e))==null?void 0:Qe.data)==null?void 0:Ke.viewProps),It=wu(ce,Pe(vt.bgColor),vt.bgOpacity);It&&(oe=It)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(u==="auto"||u==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?Id(p,B):void 0,color:c?fe:B.color?Pe(B.color):fe,connectorColor:c?fe:B.color?Pe(B.color):pe,labelBg:oe,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:Ee.get(B.id)??.5}})},[r,fe,pe,c,Ee,b.edgeType,u,p,J,we,ue]),qe=j.useMemo(()=>{var B;const ce=new Set;for(const oe of e)(B=oe.data)!=null&&B.parent&&ce.add(oe.data.parent);return ce},[e]),Je=j.useMemo(()=>{const ce=new Map;for(const B of r){const oe=B.data.isInverted?B.data.target:B.data.source;oe&&!ce.has(oe)&&ce.set(oe,B.data)}for(const B of r){if(B.data.connection)continue;const oe=B.data.isInverted?B.data.target:B.data.source,$e=B.data.isInverted?B.data.source:B.data.target;$e.startsWith(`${oe}.`)&&(ce.set(oe,B.data),ce.set($e,B.data))}return ce},[r]),Fe=j.useMemo(()=>{const ce={...i_,...b.customViews};return e.filter(B=>{var oe;return(oe=B.data)==null?void 0:oe.id}).map(B=>{var xe,Ze,Qe,Ke,vt,It;const oe=qe.has(B.data.id)&&!B.data.parent,$e=oe?B.data.label??B.data.headerTitle??"Container":void 0,U=oe?ce.parentContainer:ce[B.data.type]||ce.text,ge=Je.get(B.data.id),Ie={...B,isInverted:((xe=B.data.config)==null?void 0:xe.isInverted)??(ge==null?void 0:ge.isInverted),isParent:oe,containerStyle:oe?Q(B.data.id):void 0};return{id:B.data.id,collapsed:(Ze=B.data.config)==null?void 0:Ze.collapsed,parent:B.data.parent,acceptsChildren:!!((Qe=B.data.config)!=null&&Qe.parentContainer)||qe.has(B.data.id),label:$e,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((Ke=B.data.config)==null?void 0:Ke.collapsed)!==void 0,animationColor:Pe(((vt=B.data.viewProps)==null?void 0:vt.borderColor)||t),animationWidth:In((It=B.data.viewProps)==null?void 0:It.borderWidth,8),element:j.createElement(U,{...Ie,key:`${B.data.id}-${t}`}),fillElement:k.has(B.data.id)?void 0:j.createElement(U,{...Ie,data:{...B.data,viewProps:{...B.data.viewProps,borderRadius:0}},containerStyle:Ie.containerStyle?{...Ie.containerStyle,borderRadius:0}:void 0,key:`${B.data.id}-${t}`})}})},[e,qe,Je,t,b.customViews,Q,k]),ct=j.useMemo(()=>ye?300:e.length>50?150:e.length>20?100:50,[e.length,ye]),De=j.useRef(b);De.current=b;const rt=j.useRef(E);rt.current=E;const ft=j.useRef(I);ft.current=I;const Oe=j.useRef(v);Oe.current=v;const Xe=j.useRef(w);Xe.current=w;const nt=j.useRef(P);nt.current=P;const lt=j.useRef(J);lt.current=J;const zt=j.useRef(ve);zt.current=ve;const kt=j.useRef(new Map);j.useEffect(()=>{var oe,$e;const ce=new Map([...ve].filter(([,U])=>J.has(U.data.source)&&J.has(U.data.target))),B=kt.current;kt.current=ce;for(const[U,ge]of B)ce.has(U)||(Xe.current===U&&(C(null),(oe=g.onEdgeDeselect)==null||oe.call(g)),($e=g.onEdgeRemove)==null||$e.call(g,U,ge.data))},[ve,J,g,C]),j.useEffect(()=>{const ce=W.current;if(!ie||!ce)return;let B=null,oe=null,$e=0,U=0,ge=0,Ie=0,xe=0;const Ze=Qe=>{var It;if(De.current.readOnly||De.current.minZoom===De.current.maxZoom&&De.current.minZoom!==void 0&&((It=ce.parentElement)!=null&&It.closest(".flow-sdk-canvas")))return;const Ke=ce.ownerDocument.fullscreenElement;if(Ke&&Ke!==ce&&ce.contains(Ke)&&Qe.target instanceof Node&&Ke.contains(Qe.target))return;Qe.preventDefault(),Qe.stopPropagation(),rt.current||Qe.metaKey||Qe.ctrlKey?(ge+=Qe.deltaY,Ie=Qe.clientX,xe=Qe.clientY,oe===null&&(oe=requestAnimationFrame(()=>{oe=null;const Jt=De.current,mt=ie.zoom(),pt=ge;ge=0;let xt=mt-pt*.05/100;xt=Math.max(Jt.minZoom??.01,Math.min(Jt.maxZoom??1.5,xt));const Tt=ce.getBoundingClientRect();ie.zoomAt(xt,{x:Ie-Tt.left,y:xe-Tt.top})}))):($e+=Qe.deltaX,U+=Qe.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const Jt=ie.pan(),mt=ie.zoom(),pt=.35,xt=$e,Tt=U;$e=0,U=0,ie.pan({x:Jt.x+-xt*pt/mt,y:Jt.y+-Tt*pt/mt})})))};return ce.addEventListener("wheel",Ze,{passive:!1}),()=>{ce.removeEventListener("wheel",Ze),B!==null&&cancelAnimationFrame(B),oe!==null&&cancelAnimationFrame(oe)}},[ie]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const ce=B=>{var $e,U,ge,Ie;if(De.current.readOnly)return;const oe=B.target;if(!(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.isContentEditable)){if((B.key==="z"||B.key==="Z")&&O(!rt.current),(B.key==="m"||B.key==="M")&&A(!P),(B.key==="d"||B.key==="D")&&T(!M),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&oe.tagName!=="SELECT"&&$(!N),(B.key==="Delete"||B.key==="Backspace")&&Xe.current){B.preventDefault();const xe=Xe.current;(U=g.onEdgeDelete)==null||U.call(g,xe,(($e=zt.current.get(xe))==null?void 0:$e.data)??{id:xe}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Oe.current.length>0){B.preventDefault();const xe=Oe.current.filter(Ze=>Ze!=="root");if(xe.length===0)return;for(const Ze of xe){const Qe=(ge=lt.current.get(Ze))==null?void 0:ge.data;(Ie=g.onNodeDelete)==null||Ie.call(g,Ze,Qe||{})}x([])}}};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[P,M,N,$,O,A,T,b.disableKeyboardShortcuts,g,x,C]);const et=j.useCallback(ce=>{var B;y.current=ce,ae(ce),(B=g.onInit)==null||B.call(g,ce)},[y,g]),We=j.useCallback(ce=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,ce)},[g]),Ht=j.useCallback(ce=>{var oe,$e,U;const B=((oe=zt.current.get(ce))==null?void 0:oe.data)??{id:ce};if(Xe.current===ce&&nt.current){C(null),($e=g.onEdgeDeselect)==null||$e.call(g);return}Oe.current.length&&x([]),C(ce),(U=g.onEdgeSelect)==null||U.call(g,ce,B)},[g,C,x]),dt=j.useCallback(()=>{var ce,B,oe,$e,U;if(a(b.bottomBarCollapsed??(Oe.current.length>0||!!Xe.current||!s)),(ce=g.onBackgroundClick)==null||ce.call(g),!De.current.readOnly){const ge=new Set;for(const Ie of Oe.current){let xe=lt.current.get(Ie);for(;xe&&!ge.has(xe.data.id);)ge.add(xe.data.id),qe.has(xe.data.id)&&((B=xe.data.config)==null?void 0:B.collapsed)!==!0&&((oe=g.onNodeCollapse)==null||oe.call(g,xe.data.id,!0)),xe=xe.data.parent?lt.current.get(xe.data.parent):void 0}}Oe.current.length&&(x([]),($e=g.onNodeDeselect)==null||$e.call(g)),Xe.current&&(C(null),(U=g.onEdgeDeselect)==null||U.call(g))},[g,x,C,a,s,b.bottomBarCollapsed,qe]),tr=j.useCallback(ce=>{var $e,U;const B=Oe.current,oe=ce.filter(ge=>!B.includes(ge));if(oe.length){x([...B,...oe]);for(const ge of oe)(U=g.onNodeSelect)==null||U.call(g,ge,(($e=lt.current.get(ge))==null?void 0:$e.data)??{id:ge})}},[g,x]),ar=j.useCallback((ce,B)=>{var oe,$e;x([ce]),($e=g.onNodeSelect)==null||$e.call(g,ce,((oe=lt.current.get(ce))==null?void 0:oe.data)??{id:ce},B)},[g,x]),Bt=j.useRef(null),Dt=j.useCallback((ce,B,oe)=>{var $e;Bt.current={source:ce,target:B,edgeIds:new Set(zt.current.keys())};try{($e=g.onEdgeCreate)==null||$e.call(g,ce,B,oe)}catch(U){throw Bt.current=null,U}},[g]),Kt=j.useCallback((ce,B,oe,$e=!1)=>{var U,ge;if(re.current={sourceId:ce,nodeIds:new Set(lt.current.keys()),reverse:$e},!(u==="properties"&&((U=g.onNodeCreateRequest)==null?void 0:U.call(g,{sourceNodeId:ce,position:B,sourceProperty:oe,reverse:$e}))===!0)){if(oe!==void 0||$e){re.current=null;return}(ge=g.onNodeCreate)==null||ge.call(g,{type:"text",sourceNodeId:ce,position:B,isArrayMode:ft.current})}},[g,u]),rr=!b.readOnly&&N&&b.edgeHandles!==!1,$r=i==="transparent"?"none":i;return f.jsx(a_,{pattern:$r,backgroundColor:le,children:f.jsx(V.Box,{ref:W,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Bj,{nodes:Fe,edges:Ae,direction:H,nodeAlignment:d,onContainerCollapse:ce=>{var B,oe;(B=g.onNodeCollapse)==null||B.call(g,ce,!0),(oe=g.onNodeViewToggle)==null||oe.call(g,ce)},selectedNodeIds:v,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:L,edgeSep:be,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,initialNodeGrid:b.nodeGrid,spacingFactor:z,compactSpacingScale:n,layoutDebounce:ct,isPerformanceMode:ye,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:Y,fitOnInit:!b.initialViewport&&!((ze=b.nodeGrid)!=null&&ze.enabled&&b.nodeGrid.options.fill),readOnly:!!b.readOnly,containerStyle:Q,lineColor:c?fe:pe,drawMode:rr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:M,multiSelect:!!P,onInit:et,onLayoutComplete:ce=>{var ge;(ge=g.onLayoutComplete)==null||ge.call(g,ce);const B=Bt.current;B&&(!lt.current.has(B.source)||!lt.current.has(B.target)?Bt.current=null:r.some(({data:Ie})=>Ie.source===B.source&&Ie.target===B.target&&!B.edgeIds.has(Ie.id))&&ce.getNodeBox(B.source)&&ce.getNodeBox(B.target)&&(Bt.current=null,ce.focusConnections(B.source)));const oe=re.current;if(!oe)return;if(!lt.current.has(oe.sourceId)){re.current=null;return}const U=e.filter(Ie=>!oe.nodeIds.has(Ie.data.id)).filter(Ie=>r.some(({data:xe})=>xe.source===oe.sourceId&&xe.target===Ie.data.id||xe.target===oe.sourceId&&xe.source===Ie.data.id));!U.length||U.some(Ie=>!ce.getNodeBox(Ie.data.id))||(re.current=null,ce.focusBranch(oe.reverse?U[0].data.id:oe.sourceId))},onNodeGridModeChange:_,onNodeGridZoomOut:g.onNodeGridZoomOut,onNodeGridDrop:g.onNodeGridDrop,onNodeParentChange:g.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:We,onBackgroundTap:dt,onBoxSelect:tr,onEdgeSelect:Ht,onContainerSelect:ar,onEdgeDraw:Dt,onDrawIntoSpace:Kt})})})},ox=j.memo(c_),l_=".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 Sm=!1;function d_(){if(Sm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=l_+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+$b+Lw+$w+".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}',Sm=!0}function u_({loading:e=!1,loader:r,...t}){var c,l;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Tw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!i,a=e||s;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==t.json&&o(t)},[e,i,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>o(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(V.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{var h;const u=(d==null?void 0:d.contains(document.activeElement))&&((h=document.activeElement)==null?void 0:h.matches("input, textarea, [contenteditable=true]"));a&&(e||!u)?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(f_,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(V.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function f_({title:e="untitled",json:r,forms:t,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){d_();const[u,h]=j.useState(),[p,m]=j.useState(!1),y=i.formSchema??u,g=j.useMemo(()=>r&&t?pb(r,t.state):r,[r,t==null?void 0:t.state]),b=i.direction==="C",v=j.useMemo(()=>{let P,A;return M=>(A=P&&A?Ow(P,M,A)??hd(M,{title:e,isCenter:b}):hd(M,{title:e,isCenter:b}),P=M,A)},[e,b]),x=j.useMemo(()=>g?v(g):null,[g,v]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&y?gb(t.state,t.bindings,y,(x==null?void 0:x.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,y,x,n]),C=(w==null?void 0:w.schema)??y,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),_=j.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(A=>{var ie,ae,re,ye;const M=r?(ie=Le(r,A.data.id))==null?void 0:ie.$view:(ae=A.data.config)==null?void 0:ae.typeView,T=M&&wd.includes(M)?M:void 0,N=T?T==="icon-label":(re=A.data.config)==null?void 0:re.labelBelow,$=T==="object"?"objectView":T==="text"?"text":N?"arrayView":A.data.type,I=C&&(t?$n(S,A.data.id,C):r&&Xr(r,A.data.id,C)),W=(((ye=A.data.config)==null?void 0:ye.ports)??[]).map(be=>({...be}));if(w&&I){const be=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[L,z]of Object.entries(I.type.ports??{})){const G=`${z.kind}:${L}`,D=W.find(se=>se.id===G);D?D.label===void 0&&z.label!==void 0&&(D.label=z.label):W.push({id:G,...z.label!==void 0?{label:z.label}:{},role:z.kind==="input"||z.kind==="config"?"target":"source",side:be[z.kind],...z.kind==="config"?{placement:"config"}:{}})}for(const L of W){const z=W.filter(G=>G.side===L.side);L.position=(z.indexOf(L)+1)/(z.length+1)}}return I||N||T?{...A,data:{...A.data,type:$,...t?{description:Object.fromEntries(Object.entries(A.data.description??{}).filter(([be])=>!be.startsWith("$")&&!(w!=null&&w.slots.has(gn(A.data.id,be)))))}:{},config:{...A.data.config,...w&&I?{ports:W}:{},...I?{form:!0}:{},...T?{typeView:T,labelBelow:!!N}:N?{labelBelow:!0}:{}}}}:A}),[x,n,r,C,S,w,i.direction]),k=j.useMemo(()=>[...(x==null?void 0:x.edges)??o??[],...(w==null?void 0:w.edges)??[]],[x==null?void 0:x.edges,o,w==null?void 0:w.edges]),E=j.useMemo(()=>{const P=r&&x?Nb(r,x.edges,s,s.onJsonChange,y):{...s};if(w){const A=new Set([...w.nodes.map(M=>M.data.id),...w.edges.map(M=>M.data.id)]);for(const M of Object.keys(P)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const T=P[M];P[M]=(N,...$)=>{if(!A.has(N))return T==null?void 0:T(N,...$)}}}return{...P,onAllNodesIconLabelChange:A=>{var M;m(A),(M=P.onAllNodesIconLabelChange)==null||M.call(P,A)}}},[r,x,s,y,w]),O=j.useMemo(()=>{if(!t)return E;let P=t.state;const A=T=>{if(i.readOnly||i.editable===!1)return;const N=t.onStateChange??t.onChange;if(!N)return;const $=ww(P,T,s.onFormChange);$!==P&&(P=$,N($,{...T,data:$}))},M=(T,N,$)=>{var W;const I=r&&((W=Le(r,T))==null?void 0:W[N]);return!I||typeof I.$state!="string"?!1:(A({address:I.$state,nodeAddress:T,previousValue:Le(P,I.$state),value:$,data:P}),!0)};return{...E,onFormChange:A,onNodeCreateRequest:T=>{var I,W;const N=(I=T.sourceProperty)!=null&&I.startsWith("config:")?T.sourceProperty.slice(7):void 0,$=N!==void 0&&(w==null?void 0:w.slots.get(gn(T.sourceNodeId,N)));return $?($.present||A({data:P,nodeAddress:$.address.split(".").slice(0,-1).join("."),address:$.address,value:yn($.type),previousValue:void 0}),!0):((W=E.onNodeCreateRequest)==null?void 0:W.call(E,T))??!1},onNodeDelete:(T,N)=>{var re,ye;if(!(w!=null&&w.nodes.some(be=>be.data.id===T)))return(re=E.onNodeDelete)==null?void 0:re.call(E,T,N);const $=w&&[...w.slots.values()].find(be=>be.nodeId===T);if(!$)return(ye=E.onNodeDelete)==null?void 0:ye.call(E,T,N);const I=$.address.split("."),W=I.pop(),ie=I.join("."),ae=Le(P,ie);A(Array.isArray(ae)?{data:P,nodeAddress:ie,address:ie,previousValue:ae,value:ae.filter((be,L)=>String(L)!==W)}:{data:P,nodeAddress:ie,address:$.address,previousValue:Le(P,$.address),value:void 0})},onEdgeCreate:(T,N,$)=>{var ie,ae;const I=((ie=$==null?void 0:$.targetProperty)==null?void 0:ie.startsWith("config:"))&&(w==null?void 0:w.slots.get(gn(N,$.targetProperty.slice(7)))),W=w==null?void 0:w.containers.get(T);if(I&&W&&($==null?void 0:$.sourceProperty)==="output:resource"){const re=jw(P,W,I);re!==void 0&&A({data:P,nodeAddress:I.address.split(".").slice(0,-1).join("."),address:I.address,previousValue:Le(P,I.address),value:re});return}I||w!=null&&w.nodes.some(re=>re.data.id===T||re.data.id===N)||(ae=E.onEdgeCreate)==null||ae.call(E,T,N,$)},onEdgeDelete:(T,N)=>{var ye;const $=w==null?void 0:w.edges.find(be=>be.data.id===T);if(!$)return(ye=E.onEdgeDelete)==null?void 0:ye.call(E,T,N);const I=w.slots.get(gn($.data.target,$.data.targetProperty.slice(7))),W=I.address.split("."),ie=W.pop(),ae=W.join("."),re=Le(P,ae);A(Array.isArray(re)?{data:P,nodeAddress:ae,address:ae,previousValue:re,value:re.filter((be,L)=>String(L)!==ie)}:{data:P,nodeAddress:ae,address:I.address,previousValue:Le(P,I.address),value:void 0})},onNodeContentChange:(T,N)=>{var $,I;M(T,"$content",N)?($=s.onNodeContentChange)==null||$.call(s,T,N):(I=E.onNodeContentChange)==null||I.call(E,T,N)},onNodeLabelChange:(T,N)=>{var $,I;M(T,"$label",N)?($=s.onNodeLabelChange)==null||$.call(s,T,N):(I=E.onNodeLabelChange)==null||I.call(E,T,N)}}},[E,t,r,s,w,i.readOnly,i.editable]);return f.jsx(Mt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:P=>{var A;h(P),(A=s.onFormSchemaChange)==null||A.call(s,P)},callbacks:O},children:f.jsx(Mm,{config:w?{...i,formSchema:C}:i,callbacks:O,nodes:_,edges:k,children:f.jsxs(V.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":i.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(ox,{nodes:_,edges:k}),l&&f.jsx(Ab,{}),d]})})})}function h_(e){return xd(JSON.parse(e))}function xd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);t(i)}r.delete(n)}};return t(e),structuredClone(e)}function p_(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=xd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=xd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function g_(e,r){const t=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,s)=>t(i,o[s])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,s])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i==="$content"&&n.$contentFormat==="jsx"&&o.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(o[i]))return[[i,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(o[i][l]))]];if(i.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=t(s,o[i]);return a===void 0?[]:[[i,a]]}))};return t(e,r)??{}}function eo(e){let r="",t=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,i(),new Error("JSON stream exceeds the size limit.");r=c,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,i();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,i(),r=""}}}function y_(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let o=eo(e),i=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:i,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(y=!1)=>{o.snapshot(r.slice(0,i)),i===r.length?(s=!1,u(),o.finish()):y&&o.flush()},p=y=>{s=!1,u(),o.cancel(),d(),e.onError(y)},m=()=>{if(c=void 0,!(!s||a)){i=Math.min(r.length,i+l);try{h()}catch(y){p(y);return}d(),s&&(c=setTimeout(m,t))}};return{play(){a||s||(i===r.length&&(o.cancel(),o=eo(e),i=0),s=!0,d(),c=setTimeout(m,t))},pause(){a||(s=!1,u(),o.flush(),d())},seek(y){if(!a){if(!Number.isFinite(y))throw new Error("Playback position must be finite.");u(),i=Math.max(0,Math.min(r.length,Math.round(y))),o.cancel(),o=eo(e);try{h(!0)}catch(g){p(g);return}d(),s&&(c=setTimeout(m,t))}},dispose(){a=!0,s=!1,u(),o.cancel()}}}function m_({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:o}=j.useContext(Mt),{colorText:i,background:s}=st();if((l=o==null?void 0:o[e])!=null&&l.portResources)return null;const a=o&&$n(o,e,n);if(!t||!a)return null;const c=Le(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:Pe(i),background:Pe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!ho(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:$t(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=Ab;exports.CollapseAllToggle=eb;exports.CompactPropertyLayoutToggle=tb;exports.ConnectionsOnlyToggle=Iw;exports.DEFAULT_PALETTE=no;exports.DiagramAppearanceControls=rb;exports.DynamicIcon=Qt;exports.EdgeTools=wb;exports.EditableLabel=Jr;exports.ErrorToast=kb;exports.FlowDiagram=u_;exports.FlowDiagramProvider=Mm;exports.FlowPort=Yv;exports.FlowView=ox;exports.FormDocumentContext=Mt;exports.GridAdjustmentToggle=nb;exports.LIGHT_BLACK=Zr;exports.LoadingBorder=Xv;exports.NODE_TYPE_VIEWS=wd;exports.NodeBorderRadiusControl=Cb;exports.NodeConfigSummary=m_;exports.NodeForm=Od;exports.NodeFormPopover=su;exports.NodeIconPicker=Nd;exports.NodeTools=Sb;exports.NodeView=Vn;exports.SvgExportButton=Eb;exports.Swatches=Mr;exports.TEXT_PALETTE=vb;exports.ToolbarCloseButton=Yr;exports.ToolbarCommitInput=Dr;exports.ToolbarDivider=xn;exports.ToolbarIconButton=Ne;exports.ToolbarRangeInput=Sd;exports.ToolbarScrollContainer=$d;exports.ToolbarSelect=At;exports.ToolbarTooltip=Ue;exports.TooltipIconButton=vd;exports.WorkflowControls=qd;exports.addChild=Rd;exports.addConnection=Ad;exports.addTargetEdge=db;exports.addressToPath=Vt;exports.applyCollapsed=bw;exports.applyFormChange=po;exports.applyStateEdits=xw;exports.bindSqueedCallbacks=Nb;exports.compileSqueed=hd;exports.connectionIssue=Id;exports.contentObjTheme=Xt;exports.copySelection=Ld;exports.createFlowDiagram=Pr;exports.createFlowDocumentActions=p_;exports.createFormNode=Mb;exports.createJsonPlayback=y_;exports.createJsonStream=eo;exports.createWorkflowExecution=Sx;exports.downloadSvg=_b;exports.duplicateSelection=Ob;exports.exportSvg=jb;exports.formValueError=Wt;exports.getChakraColorHex=Pe;exports.getColorVariant=km;exports.getDarkerHexColor=to;exports.getInteractionSurface=gr;exports.getNode=Le;exports.getSelectionRoots=Tb;exports.isNodeVisible=Yt;exports.parseFlowDocument=h_;exports.parseJsonContract=Pd;exports.parseTypeScriptContract=fb;exports.parseTypeScriptForm=Md;exports.projectJsonPlaybackPreview=g_;exports.readFormSchema=Td;exports.readWorkflowContract=hb;exports.removeEdge=ub;exports.removeNode=lb;exports.reparentNode=Ib;exports.resolveEdgeOwner=Rr;exports.resolveStateView=pb;exports.setCollapsed=kd;exports.setEdgeProp=ur;exports.setEdgeStyle=cb;exports.setNodeProp=St;exports.updateNode=_t;exports.useCustomColors=st;exports.useEdgeProximity=Em;exports.useFlowData=vr;exports.useFlowDiagramContext=He;exports.useNodeViewActions=Wn;exports.useStopPropagation=au;exports.useThemeContentColors=Nn;exports.validateGridAdjustment=Hv;
|
|
284
284
|
//# sourceMappingURL=index.cjs.map
|