@fieldwangai/agentflow 0.1.64 → 0.1.66

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.
@@ -62,9 +62,9 @@ ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFil
62
62
 
63
63
  `,`
64
64
  +`).split(`
65
- `)),f=d.reduce((u,p)=>u.concat(...p),[]);return[d,f]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??mN,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var k,g;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&sA(m))return!1;const b=yN(m.code,l);if(i.current.add(m[b]),gN(a,i.current,!1)){const v=((g=(k=m.composedPath)==null?void 0:k.call(m))==null?void 0:g[0])||m.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&m.preventDefault(),r(!0)}},u=m=>{const y=yN(m.code,l);gN(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(m[y]),m.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function gN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function yN(e,t){return t.includes(e)?"code":"key"}const Z5=()=>{const e=Hn();return h.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:a,panZoom:l}=e.getState(),c=e0(t,r,s,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,u=n.snapToGrid??i;return xp(d,r,u,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=eg(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function IA(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const c of a)eH(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function eH(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function tg(e,t){return IA(e,t)}function a0(e,t){return IA(e,t)}function Ul(e,t){return{id:e,type:"select",selected:t}}function ou(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(Ul(i.id,a)))}return r}function xN({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function wN(e){return{id:e.id,type:"remove"}}const bN=e=>f3(e),tH=e=>XP(e);function TA(e){return h.forwardRef(e)}function vN(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>nH(()=>n(s=>s+BigInt(1))));return mb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function nH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const RA=h.createContext(null);function rH({children:e}){const t=Hn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:u,nodeLookup:p,fitViewQueued:m,onNodesChangeMiddlewareMap:y}=t.getState();let b=c;for(const g of l)b=typeof g=="function"?g(b):g;let k=xN({items:b,lookup:p});for(const g of y.values())k=g(k);f&&d(b),k.length>0?u==null||u(k):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:v,setNodes:x}=t.getState();g&&x(v)})},[]),r=vN(n),s=h.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:p}=t.getState();let m=c;for(const y of l)m=typeof y=="function"?y(m):y;f?d(m):u&&u(xN({items:m,lookup:p}))},[]),i=vN(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(RA.Provider,{value:a,children:e})}function sH(){const e=h.useContext(RA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const iH=e=>!!e.panZoom;function wc(){const e=Z5(),t=Hn(),n=sH(),r=Vt(iH),s=h.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),a=u=>{n.nodeQueue.push(u)},l=u=>{n.edgeQueue.push(u)},c=u=>{var g,v;const{nodeLookup:p,nodeOrigin:m}=t.getState(),y=bN(u)?u:p.get(u.id),b=y.parentId?nA(y.position,y.measured,y.parentId,p,m):y.position,k={...y,position:b,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((v=y.measured)==null?void 0:v.height)??y.height};return Ru(k)},d=(u,p,m={replace:!1})=>{a(y=>y.map(b=>{if(b.id===u){const k=typeof p=="function"?p(b):p;return m.replace&&bN(k)?k:{...b,...k}}return b}))},f=(u,p,m={replace:!1})=>{l(y=>y.map(b=>{if(b.id===u){const k=typeof p=="function"?p(b):p;return m.replace&&tH(k)?k:{...b,...k}}return b}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var p;return(p=i(u))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(p=>({...p}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:a,setEdges:l,addNodes:u=>{const p=Array.isArray(u)?u:[u];n.nodeQueue.push(m=>[...m,...p])},addEdges:u=>{const p=Array.isArray(u)?u:[u];n.edgeQueue.push(m=>[...m,...p])},toObject:()=>{const{nodes:u=[],edges:p=[],transform:m}=t.getState(),[y,b,k]=m;return{nodes:u.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x:y,y:b,zoom:k}}},deleteElements:async({nodes:u=[],edges:p=[]})=>{const{nodes:m,edges:y,onNodesDelete:b,onEdgesDelete:k,triggerNodeChanges:g,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:N}=t.getState(),{nodes:_,edges:C}=await y3({nodesToRemove:u,edgesToRemove:p,nodes:m,edges:y,onBeforeDelete:N}),T=C.length>0,H=_.length>0;if(T){const M=C.map(wN);k==null||k(C),v(M)}if(H){const M=_.map(wN);b==null||b(_),g(M)}return(H||T)&&(x==null||x({nodes:_,edges:C})),{deletedNodes:_,deletedEdges:C}},getIntersectingNodes:(u,p=!0,m)=>{const y=XS(u),b=y?u:c(u),k=m!==void 0;return b?(m||t.getState().nodes).filter(g=>{const v=t.getState().nodeLookup.get(g.id);if(v&&!y&&(g.id===u.id||!v.internals.positionAbsolute))return!1;const x=Ru(k?g:v),N=Uf(x,b);return p&&N>0||N>=x.width*x.height||N>=b.width*b.height}):[]},isNodeIntersecting:(u,p,m=!0)=>{const b=XS(u)?u:c(u);if(!b)return!1;const k=Uf(b,p);return m&&k>0||k>=p.width*p.height||k>=b.width*b.height},updateNode:d,updateNodeData:(u,p,m={replace:!1})=>{d(u,y=>{const b=typeof p=="function"?p(y):p;return m.replace?{...y,data:b}:{...y,data:{...y.data,...b}}},m)},updateEdge:f,updateEdgeData:(u,p,m={replace:!1})=>{f(u,y=>{const b=typeof p=="function"?p(y):p;return m.replace?{...y,data:b}:{...y,data:{...y.data,...b}}},m)},getNodesBounds:u=>{const{nodeLookup:p,nodeOrigin:m}=t.getState();return p3(u,{nodeLookup:p,nodeOrigin:m})},getHandleConnections:({type:u,id:p,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${u}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:u,handleId:p,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${u?p?`-${u}-${p}`:`-${u}`:""}`))==null?void 0:y.values())??[])},fitView:async u=>{const p=t.getState().fitViewResolver??v3();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:p}),n.nodeQueue.push(m=>[...m]),p.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const kN=e=>e.selected,oH=typeof window<"u"?window:void 0;function aH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Hn(),{deleteElements:r}=wc(),s=Yf(e,{actInsideInputWithModifier:!1}),i=Yf(t,{target:oH});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(kN),edges:a.filter(kN)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function lH(e){const t=Hn();h.useEffect(()=>{const n=()=>{var s,i,a,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=t0(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Io.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const ny={position:"absolute",width:"100%",height:"100%",top:0,left:0},cH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function uH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=nc.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:u,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:b,noPanClassName:k,onViewportChange:g,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:N}){const _=Hn(),C=h.useRef(null),{userSelectionActive:T,lib:H,connectionInProgress:M}=Vt(cH,Yn),F=Yf(p),D=h.useRef();lH(C);const $=h.useCallback(W=>{g==null||g({x:W[0],y:W[1],zoom:W[2]}),v||_.setState({transform:W})},[g,v]);return h.useEffect(()=>{if(C.current){D.current=r5({domNode:C.current,minZoom:f,maxZoom:u,translateExtent:d,viewport:c,onDraggingChange:I=>_.setState(z=>z.paneDragging===I?z:{paneDragging:I}),onPanZoomStart:(I,z)=>{const{onViewportChangeStart:P,onMoveStart:L}=_.getState();L==null||L(I,z),P==null||P(z)},onPanZoom:(I,z)=>{const{onViewportChange:P,onMove:L}=_.getState();L==null||L(I,z),P==null||P(z)},onPanZoomEnd:(I,z)=>{const{onViewportChangeEnd:P,onMoveEnd:L}=_.getState();L==null||L(I,z),P==null||P(z)}});const{x:W,y:O,zoom:R}=D.current.getViewport();return _.setState({panZoom:D.current,transform:[W,O,R],domNode:C.current.closest(".react-flow")}),()=>{var I;(I=D.current)==null||I.destroy()}}},[]),h.useEffect(()=>{var W;(W=D.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:m,noPanClassName:k,userSelectionActive:T,noWheelClassName:b,lib:H,onTransformChange:$,connectionInProgress:M,selectionOnDrag:N,paneClickDistance:x})},[e,t,n,r,s,i,a,l,F,m,k,T,b,H,$,M,N,x]),o.jsx("div",{className:"react-flow__renderer",ref:C,style:ny,children:y})}const dH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function fH(){const{userSelectionActive:e,userSelectionRect:t}=Vt(dH,Yn);return e&&t?o.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const yx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},pH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function hH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Vf.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:m,children:y}){const b=Hn(),{userSelectionActive:k,elementsSelectable:g,dragging:v,connectionInProgress:x}=Vt(pH,Yn),N=g&&(e||k),_=h.useRef(null),C=h.useRef(),T=h.useRef(new Set),H=h.useRef(new Set),M=h.useRef(!1),F=P=>{if(M.current||x){M.current=!1;return}c==null||c(P),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},D=P=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){P.preventDefault();return}d==null||d(P)},$=f?P=>f(P):void 0,W=P=>{M.current&&(P.stopPropagation(),M.current=!1)},O=P=>{var fe,me;const{domNode:L}=b.getState();if(C.current=L==null?void 0:L.getBoundingClientRect(),!C.current)return;const E=P.target===_.current;if(!E&&!!P.target.closest(".nokey")||!e||!(i&&E||t)||P.button!==0||!P.isPrimary)return;(me=(fe=P.target)==null?void 0:fe.setPointerCapture)==null||me.call(fe,P.pointerId),M.current=!1;const{x:V,y:ie}=Xi(P.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:ie,x:V,y:ie}}),E||(P.stopPropagation(),P.preventDefault())},R=P=>{const{userSelectionRect:L,transform:E,nodeLookup:X,edgeLookup:ee,connectionLookup:V,triggerNodeChanges:ie,triggerEdgeChanges:fe,defaultEdgeOptions:me,resetSelectedElements:ge}=b.getState();if(!C.current||!L)return;const{x:Z,y:ae}=Xi(P.nativeEvent,C.current),{startX:xe,startY:pe}=L;if(!M.current){const qe=t?0:s;if(Math.hypot(Z-xe,ae-pe)<=qe)return;ge(),a==null||a(P)}M.current=!0;const _e={startX:xe,startY:pe,x:Z<xe?Z:xe,y:ae<pe?ae:pe,width:Math.abs(Z-xe),height:Math.abs(ae-pe)},je=T.current,Ve=H.current;T.current=new Set(Zv(X,_e,E,n===Vf.Partial,!0).map(qe=>qe.id)),H.current=new Set;const et=(me==null?void 0:me.selectable)??!0;for(const qe of T.current){const dt=V.get(qe);if(dt)for(const{edgeId:He}of dt.values()){const bt=ee.get(He);bt&&(bt.selectable??et)&&H.current.add(He)}}if(!JS(je,T.current)){const qe=ou(X,T.current,!0);ie(qe)}if(!JS(Ve,H.current)){const qe=ou(ee,H.current);fe(qe)}b.setState({userSelectionRect:_e,userSelectionActive:!0,nodesSelectionActive:!1})},I=P=>{var L,E;P.button===0&&((E=(L=P.target)==null?void 0:L.releasePointerCapture)==null||E.call(L,P.pointerId),!k&&P.target===_.current&&b.getState().userSelectionRect&&(F==null||F(P)),b.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(l==null||l(P),b.setState({nodesSelectionActive:T.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:br(["react-flow__pane",{draggable:z,dragging:v,selection:e}]),onClick:N?void 0:yx(F,_),onContextMenu:yx(D,_),onWheel:yx($,_),onPointerEnter:N?void 0:u,onPointerMove:N?R:p,onPointerUp:N?I:void 0,onPointerDownCapture:N?O:void 0,onClickCapture:N?W:void 0,onPointerLeave:m,ref:_,style:ny,children:[y,o.jsx(fH,{})]})}function gb({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",Io.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function LA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=Hn(),[c,d]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=W3({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{gb({id:u,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,r,t,i,e,s,a]),c}const mH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function MA(){const e=Hn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),u=new Map,p=mH(a),m=s?i[0]:5,y=s?i[1]:5,b=n.direction.x*m*n.factor,k=n.direction.y*y*n.factor;for(const[,g]of d){if(!p(g))continue;let v={x:g.internals.positionAbsolute.x+b,y:g.internals.positionAbsolute.y+k};s&&(v=yp(v,i));const{position:x,positionAbsolute:N}=JP({nodeId:g.id,nextPosition:v,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});g.position=x,g.internals.positionAbsolute=N,u.set(g.id,g)}c(u)},[])}const l0=h.createContext(null),gH=l0.Provider;l0.Consumer;const OA=()=>h.useContext(l0),yH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),xH=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Iu.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function wH({type:e="source",position:t=Ze.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:u,...p},m){var R,I;const y=a||null,b=e==="target",k=Hn(),g=OA(),{connectOnClick:v,noPanClassName:x,rfId:N}=Vt(yH,Yn),{connectingFrom:_,connectingTo:C,clickConnecting:T,isPossibleEndHandle:H,connectionInProcess:M,clickConnectionInProcess:F,valid:D}=Vt(xH(g,y,e),Yn);g||(I=(R=k.getState()).onError)==null||I.call(R,"010",Io.error010());const $=z=>{const{defaultEdgeOptions:P,onConnect:L,hasDefaultEdges:E}=k.getState(),X={...P,...z};if(E){const{edges:ee,setEdges:V}=k.getState();V(qf(X,ee))}L==null||L(X),l==null||l(X)},W=z=>{if(!g)return;const P=iA(z.nativeEvent);if(s&&(P&&z.button===0||!P)){const L=k.getState();hb.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:b,handleId:y,nodeId:g,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...E)=>{var X,ee;return(ee=(X=k.getState()).onConnectEnd)==null?void 0:ee.call(X,...E)},updateConnection:L.updateConnection,onConnect:$,isValidConnection:n||((...E)=>{var X,ee;return((ee=(X=k.getState()).isValidConnection)==null?void 0:ee.call(X,...E))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}P?f==null||f(z):u==null||u(z)},O=z=>{const{onClickConnectStart:P,onClickConnectEnd:L,connectionClickStartHandle:E,connectionMode:X,isValidConnection:ee,lib:V,rfId:ie,nodeLookup:fe,connection:me}=k.getState();if(!g||!E&&!s)return;if(!E){P==null||P(z.nativeEvent,{nodeId:g,handleId:y,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ge=rA(z.target),Z=n||ee,{connection:ae,isValid:xe}=hb.isValid(z.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:X,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:Z,flowId:ie,doc:ge,lib:V,nodeLookup:fe});xe&&ae&&$(ae);const pe=structuredClone(me);delete pe.inProgress,pe.toPosition=pe.toHandle?pe.toHandle.position:null,L==null||L(z,pe),k.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${N}-${g}-${y}-${e}`,className:br(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:T,connectingfrom:_,connectingto:C,valid:D,connectionindicator:r&&(!M||H)&&(M||F?i:s)}]),onMouseDown:W,onTouchStart:W,onClick:v?O:void 0,ref:m,...p,children:c})}const Fs=h.memo(TA(wH));function bH({data:e,isConnectable:t,sourcePosition:n=Ze.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Fs,{type:"source",position:n,isConnectable:t})]})}function vH({data:e,isConnectable:t,targetPosition:n=Ze.Top,sourcePosition:r=Ze.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Fs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Fs,{type:"source",position:r,isConnectable:t})]})}function kH(){return null}function SH({data:e,isConnectable:t,targetPosition:n=Ze.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Fs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const ng={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},SN={input:bH,default:vH,output:SH,group:kH};function NH(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const jH=e=>{const{width:t,height:n,x:r,y:s}=gp(e.nodeLookup,{filter:i=>!!i.selected});return{width:Gi(t)?t:null,height:Gi(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function CH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Hn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Vt(jH,Yn),c=MA(),d=h.useRef(null);h.useEffect(()=>{var m;n||(m=d.current)==null||m.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&i!==null;if(LA({nodeRef:d,disabled:!f}),!f)return null;const u=e?m=>{const y=r.getState().nodes.filter(b=>b.selected);e(m,y)}:void 0,p=m=>{Object.prototype.hasOwnProperty.call(ng,m.key)&&(m.preventDefault(),c({direction:ng[m.key],factor:m.shiftKey?4:1}))};return o.jsx("div",{className:br(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const NN=typeof window<"u"?window:void 0,EH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function $A({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:u,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:g,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:N,panOnScrollSpeed:_,panOnScrollMode:C,zoomOnDoubleClick:T,panOnDrag:H,defaultViewport:M,translateExtent:F,minZoom:D,maxZoom:$,preventScrolling:W,onSelectionContextMenu:O,noWheelClassName:R,noPanClassName:I,disableKeyboardA11y:z,onViewportChange:P,isControlledViewport:L}){const{nodesSelectionActive:E,userSelectionActive:X}=Vt(EH,Yn),ee=Yf(d,{target:NN}),V=Yf(b,{target:NN}),ie=V||H,fe=V||N,me=f&&ie!==!0,ge=ee||X||me;return aH({deleteKeyCode:c,multiSelectionKeyCode:y}),o.jsx(uH,{onPaneContextMenu:i,elementsSelectable:g,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:fe,panOnScrollSpeed:_,panOnScrollMode:C,zoomOnDoubleClick:T,panOnDrag:!ee&&ie,defaultViewport:M,translateExtent:F,minZoom:D,maxZoom:$,zoomActivationKeyCode:k,preventScrolling:W,noWheelClassName:R,noPanClassName:I,onViewportChange:P,isControlledViewport:L,paneClickDistance:l,selectionOnDrag:me,children:o.jsxs(hH,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:ie,isSelecting:!!ge,selectionMode:u,selectionKeyPressed:ee,paneClickDistance:l,selectionOnDrag:me,children:[e,E&&o.jsx(CH,{onSelectionContextMenu:O,noPanClassName:I,disableKeyboardA11y:z})]})})}$A.displayName="FlowRenderer";const _H=h.memo($A),PH=e=>t=>e?Zv(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function AH(e){return Vt(h.useCallback(PH(e),[e]),Yn)}const IH=e=>e.updateNodeInternals;function TH(){const e=Vt(IH),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function RH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Hn(),i=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),d=h.useRef(t),f=n&&!!e.internals.handleBounds;return h.useEffect(()=>{i.current&&!e.hidden&&(!f||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[f,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(i.current){const u=d.current!==t,p=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(u||p||m)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function LH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:u,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:b,nodeTypes:k,nodeClickDistance:g,onError:v}){const{node:x,internals:N,isParent:_}=Vt(Z=>{const ae=Z.nodeLookup.get(e),xe=Z.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:xe}},Yn);let C=x.type||"default",T=(k==null?void 0:k[C])||SN[C];T===void 0&&(v==null||v("003",Io.error003(C)),C="default",T=(k==null?void 0:k.default)||SN.default);const H=!!(x.draggable||l&&typeof x.draggable>"u"),M=!!(x.selectable||c&&typeof x.selectable>"u"),F=!!(x.connectable||d&&typeof x.connectable>"u"),D=!!(x.focusable||f&&typeof x.focusable>"u"),$=Hn(),W=tA(x),O=RH({node:x,nodeType:C,hasDimensions:W,resizeObserver:u}),R=LA({nodeRef:O,disabled:x.hidden||!H,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:g}),I=MA();if(x.hidden)return null;const z=ga(x),P=NH(x),L=M||H||t||n||r||s,E=n?Z=>n(Z,{...N.userNode}):void 0,X=r?Z=>r(Z,{...N.userNode}):void 0,ee=s?Z=>s(Z,{...N.userNode}):void 0,V=i?Z=>i(Z,{...N.userNode}):void 0,ie=a?Z=>a(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:ae,nodeDragThreshold:xe}=$.getState();M&&(!ae||!H||xe>0)&&gb({id:e,store:$,nodeRef:O}),t&&t(Z,{...N.userNode})},me=Z=>{if(!(sA(Z.nativeEvent)||y)){if(KP.includes(Z.key)&&M){const ae=Z.key==="Escape";gb({id:e,store:$,unselect:ae,nodeRef:O})}else if(H&&x.selected&&Object.prototype.hasOwnProperty.call(ng,Z.key)){Z.preventDefault();const{ariaLabelConfig:ae}=$.getState();$.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),I({direction:ng[Z.key],factor:Z.shiftKey?4:1})}}},ge=()=>{var Ve;if(y||!((Ve=O.current)!=null&&Ve.matches(":focus-visible")))return;const{transform:Z,width:ae,height:xe,autoPanOnNodeFocus:pe,setCenter:_e}=$.getState();if(!pe)return;Zv(new Map([[e,x]]),{x:0,y:0,width:ae,height:xe},Z,!0).length>0||_e(x.position.x+z.width/2,x.position.y+z.height/2,{zoom:Z[2]})};return o.jsx("div",{className:br(["react-flow__node",`react-flow__node-${C}`,{[m]:H},x.className,{selected:x.selected,selectable:M,parent:_,draggable:H,dragging:R}]),ref:O,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:W?"visible":"hidden",...x.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:X,onMouseLeave:ee,onContextMenu:V,onClick:fe,onDoubleClick:ie,onKeyDown:D?me:void 0,tabIndex:D?0:void 0,onFocus:D?ge:void 0,role:x.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${_A}-${b}`,"aria-label":x.ariaLabel,...x.domAttributes,children:o.jsx(gH,{value:e,children:o.jsx(T,{id:e,data:x.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:x.selected??!1,selectable:M,draggable:H,deletable:x.deletable??!0,isConnectable:F,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:R,dragHandle:x.dragHandle,zIndex:N.z,parentId:x.parentId,...z})})})}var MH=h.memo(LH);const OH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function DA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Vt(OH,Yn),a=AH(e.onlyRenderVisibleElements),l=TH();return o.jsx("div",{className:"react-flow__nodes",style:ny,children:a.map(c=>o.jsx(MH,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}DA.displayName="NodeRenderer";const $H=h.memo(DA);function DH(e){return Vt(h.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&j3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Yn)}const FH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},zH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},jN={[$s.Arrow]:FH,[$s.ArrowClosed]:zH};function HH(e){const t=Hn();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(jN,e)?jN[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Io.error009(e)),null)},[e])}const BH=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=HH(t);return c?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:o.jsx(c,{color:n,strokeWidth:a})}):null},FA=({defaultColor:e,rfId:t})=>{const n=Vt(i=>i.edges),r=Vt(i=>i.defaultEdgeOptions),s=h.useMemo(()=>T3(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:s.map(i=>o.jsx(BH,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};FA.displayName="MarkerDefinitions";var WH=h.memo(FA);function zA({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[u,p]=h.useState({x:1,y:0,width:0,height:0}),m=br(["react-flow__edge-textwrapper",d]),y=h.useRef(null);return h.useEffect(()=>{if(y.current){const b=y.current.getBBox();p({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:m,visibility:u.width?"visible":"hidden",...f,children:[s&&o.jsx("rect",{width:u.width+2*a[0],x:-a[0],y:-a[1],height:u.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}zA.displayName="EdgeText";const VH=h.memo(zA);function ry({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...f,d:e,fill:"none",className:br(["react-flow__edge-path",f.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Gi(t)&&Gi(n)?o.jsx(VH,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function CN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ze.Left||e===Ze.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function HA({sourceX:e,sourceY:t,sourcePosition:n=Ze.Bottom,targetX:r,targetY:s,targetPosition:i=Ze.Top}){const[a,l]=CN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=CN({pos:i,x1:r,y1:s,x2:e,y2:t}),[f,u,p,m]=oA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${s}`,f,u,p,m]}function BA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,interactionWidth:g})=>{const[v,x,N]=HA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),_=e.isInternal?void 0:t;return o.jsx(ry,{id:_,path:v,labelX:x,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,interactionWidth:g})})}const UH=BA({isInternal:!1}),WA=BA({isInternal:!0});UH.displayName="SimpleBezierEdge";WA.displayName="SimpleBezierEdgeInternal";function VA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,sourcePosition:m=Ze.Bottom,targetPosition:y=Ze.Top,markerEnd:b,markerStart:k,pathOptions:g,interactionWidth:v})=>{const[x,N,_]=db({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:i,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),C=e.isInternal?void 0:t;return o.jsx(ry,{id:C,path:x,labelX:N,labelY:_,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:b,markerStart:k,interactionWidth:v})})}const UA=VA({isInternal:!1}),KA=VA({isInternal:!0});UA.displayName="SmoothStepEdge";KA.displayName="SmoothStepEdgeInternal";function qA(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(UA,{...n,id:r,pathOptions:h.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const KH=qA({isInternal:!1}),YA=qA({isInternal:!0});KH.displayName="StepEdge";YA.displayName="StepEdgeInternal";function GA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:y,interactionWidth:b})=>{const[k,g,v]=cA({sourceX:n,sourceY:r,targetX:s,targetY:i}),x=e.isInternal?void 0:t;return o.jsx(ry,{id:x,path:k,labelX:g,labelY:v,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:y,interactionWidth:b})})}const qH=GA({isInternal:!1}),XA=GA({isInternal:!0});qH.displayName="StraightEdge";XA.displayName="StraightEdgeInternal";function JA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Ze.Bottom,targetPosition:l=Ze.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,pathOptions:g,interactionWidth:v})=>{const[x,N,_]=aA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:g==null?void 0:g.curvature}),C=e.isInternal?void 0:t;return o.jsx(ry,{id:C,path:x,labelX:N,labelY:_,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,interactionWidth:v})})}const YH=JA({isInternal:!1}),QA=JA({isInternal:!0});YH.displayName="BezierEdge";QA.displayName="BezierEdgeInternal";const EN={default:QA,straight:XA,step:YA,smoothstep:KA,simplebezier:WA},_N={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},GH=(e,t,n)=>n===Ze.Left?e-t:n===Ze.Right?e+t:e,XH=(e,t,n)=>n===Ze.Top?e-t:n===Ze.Bottom?e+t:e,PN="react-flow__edgeupdater";function AN({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:l}){return o.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:br([PN,`${PN}-${l}`]),cx:GH(t,r,e),cy:XH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function JH({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:u,setReconnecting:p,setUpdateHover:m}){const y=Hn(),b=(N,_)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:T,connectionMode:H,connectionRadius:M,lib:F,onConnectStart:D,cancelConnection:$,nodeLookup:W,rfId:O,panBy:R,updateConnection:I}=y.getState(),z=_.type==="target",P=(X,ee)=>{p(!1),u==null||u(X,n,_.type,ee)},L=X=>d==null?void 0:d(n,X),E=(X,ee)=>{p(!0),f==null||f(N,n,_.type),D==null||D(X,ee)};hb.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:H,connectionRadius:M,domNode:T,handleId:_.id,nodeId:_.nodeId,nodeLookup:W,isTarget:z,edgeUpdaterType:_.type,lib:F,flowId:O,cancelConnection:$,panBy:R,isValidConnection:(...X)=>{var ee,V;return((V=(ee=y.getState()).isValidConnection)==null?void 0:V.call(ee,...X))??!0},onConnect:L,onConnectStart:E,onConnectEnd:(...X)=>{var ee,V;return(V=(ee=y.getState()).onConnectEnd)==null?void 0:V.call(ee,...X)},onReconnectEnd:P,updateConnection:I,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},k=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>m(!0),x=()=>m(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(AN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:k,onMouseEnter:v,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&o.jsx(AN,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function QH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,rfId:y,edgeTypes:b,noPanClassName:k,onError:g,disableKeyboardA11y:v}){let x=Vt(_e=>_e.edgeLookup.get(e));const N=Vt(_e=>_e.defaultEdgeOptions);x=N?{...N,...x}:x;let _=x.type||"default",C=(b==null?void 0:b[_])||EN[_];C===void 0&&(g==null||g("011",Io.error011(_)),_="default",C=(b==null?void 0:b.default)||EN.default);const T=!!(x.focusable||t&&typeof x.focusable>"u"),H=typeof u<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),M=!!(x.selectable||r&&typeof x.selectable>"u"),F=h.useRef(null),[D,$]=h.useState(!1),[W,O]=h.useState(!1),R=Hn(),{zIndex:I,sourceX:z,sourceY:P,targetX:L,targetY:E,sourcePosition:X,targetPosition:ee}=Vt(h.useCallback(_e=>{const je=_e.nodeLookup.get(x.source),Ve=_e.nodeLookup.get(x.target);if(!je||!Ve)return{zIndex:x.zIndex,..._N};const et=I3({id:e,sourceNode:je,targetNode:Ve,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:_e.connectionMode,onError:g});return{zIndex:N3({selected:x.selected,zIndex:x.zIndex,sourceNode:je,targetNode:Ve,elevateOnSelect:_e.elevateEdgesOnSelect,zIndexMode:_e.zIndexMode}),...et||_N}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Yn),V=h.useMemo(()=>x.markerStart?`url('#${fb(x.markerStart,y)}')`:void 0,[x.markerStart,y]),ie=h.useMemo(()=>x.markerEnd?`url('#${fb(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||z===null||P===null||L===null||E===null)return null;const fe=_e=>{var qe;const{addSelectedEdges:je,unselectNodesAndEdges:Ve,multiSelectionActive:et}=R.getState();M&&(R.setState({nodesSelectionActive:!1}),x.selected&&et?(Ve({nodes:[],edges:[x]}),(qe=F.current)==null||qe.blur()):je([e])),s&&s(_e,x)},me=i?_e=>{i(_e,{...x})}:void 0,ge=a?_e=>{a(_e,{...x})}:void 0,Z=l?_e=>{l(_e,{...x})}:void 0,ae=c?_e=>{c(_e,{...x})}:void 0,xe=d?_e=>{d(_e,{...x})}:void 0,pe=_e=>{var je;if(!v&&KP.includes(_e.key)&&M){const{unselectNodesAndEdges:Ve,addSelectedEdges:et}=R.getState();_e.key==="Escape"?((je=F.current)==null||je.blur(),Ve({edges:[x]})):et([e])}};return o.jsx("svg",{style:{zIndex:I},children:o.jsxs("g",{className:br(["react-flow__edge",`react-flow__edge-${_}`,x.className,k,{selected:x.selected,animated:x.animated,inactive:!M&&!s,updating:D,selectable:M}]),onClick:fe,onDoubleClick:me,onContextMenu:ge,onMouseEnter:Z,onMouseMove:ae,onMouseLeave:xe,onKeyDown:T?pe:void 0,tabIndex:T?0:void 0,role:x.ariaRole??(T?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":T?`${PA}-${y}`:void 0,ref:F,...x.domAttributes,children:[!W&&o.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:M,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:z,sourceY:P,targetX:L,targetY:E,sourcePosition:X,targetPosition:ee,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:V,markerEnd:ie,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),H&&o.jsx(JH,{edge:x,isReconnectable:H,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,sourceX:z,sourceY:P,targetX:L,targetY:E,sourcePosition:X,targetPosition:ee,setUpdateHover:$,setReconnecting:O})]})})}var ZH=h.memo(QH);const e4=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ZA({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:p,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:b}){const{edgesFocusable:k,edgesReconnectable:g,elementsSelectable:v,onError:x}=Vt(e4,Yn),N=DH(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(WH,{defaultColor:e,rfId:n}),N.map(_=>o.jsx(ZH,{id:_,edgesFocusable:k,edgesReconnectable:g,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:u,onDoubleClick:p,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:b},_))]})}ZA.displayName="EdgeRenderer";const t4=h.memo(ZA),n4=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function r4({children:e}){const t=Vt(n4);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function s4(e){const t=wc(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const i4=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function o4(e){const t=Vt(i4),n=Hn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function a4(e){return e.connection.inProgress?{...e.connection,to:xp(e.connection.to,e.transform)}:{...e.connection}}function l4(e){return a4}function c4(e){const t=l4();return Vt(t,Yn)}const u4=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function d4({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Vt(u4,Yn);return!(i&&s&&c)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:br(["react-flow__connection",GP(l)]),children:o.jsx(eI,{style:t,type:n,CustomComponent:r,isValid:l})})})}const eI=({style:e,type:t=Va.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:u,toPosition:p,pointer:m}=c4();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:p,connectionStatus:GP(r),toNode:f,toHandle:u,pointer:m});let y="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case Va.Bezier:[y]=aA(b);break;case Va.SimpleBezier:[y]=HA(b);break;case Va.Step:[y]=db({...b,borderRadius:0});break;case Va.SmoothStep:[y]=db(b);break;default:[y]=cA(b)}return o.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};eI.displayName="ConnectionLine";const f4={};function IN(e=f4){h.useRef(e),Hn(),h.useEffect(()=>{},[e])}function p4(){Hn(),h.useRef(!1),h.useEffect(()=>{},[])}function tI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:p,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:b,connectionLineComponent:k,connectionLineContainerStyle:g,selectionKeyCode:v,selectionOnDrag:x,selectionMode:N,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:T,deleteKeyCode:H,onlyRenderVisibleElements:M,elementsSelectable:F,defaultViewport:D,translateExtent:$,minZoom:W,maxZoom:O,preventScrolling:R,defaultMarkerColor:I,zoomOnScroll:z,zoomOnPinch:P,panOnScroll:L,panOnScrollSpeed:E,panOnScrollMode:X,zoomOnDoubleClick:ee,panOnDrag:V,onPaneClick:ie,onPaneMouseEnter:fe,onPaneMouseMove:me,onPaneMouseLeave:ge,onPaneScroll:Z,onPaneContextMenu:ae,paneClickDistance:xe,nodeClickDistance:pe,onEdgeContextMenu:_e,onEdgeMouseEnter:je,onEdgeMouseMove:Ve,onEdgeMouseLeave:et,reconnectRadius:qe,onReconnect:dt,onReconnectStart:He,onReconnectEnd:bt,noDragClassName:sn,noWheelClassName:on,noPanClassName:an,disableKeyboardA11y:Yt,nodeExtent:En,rfId:hn,viewport:ue,onViewportChange:ke}){return IN(e),IN(t),p4(),s4(n),o4(ue),o.jsx(_H,{onPaneClick:ie,onPaneMouseEnter:fe,onPaneMouseMove:me,onPaneMouseLeave:ge,onPaneContextMenu:ae,onPaneScroll:Z,paneClickDistance:xe,deleteKeyCode:H,selectionKeyCode:v,selectionOnDrag:x,selectionMode:N,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:T,elementsSelectable:F,zoomOnScroll:z,zoomOnPinch:P,zoomOnDoubleClick:ee,panOnScroll:L,panOnScrollSpeed:E,panOnScrollMode:X,panOnDrag:V,defaultViewport:D,translateExtent:$,minZoom:W,maxZoom:O,onSelectionContextMenu:u,preventScrolling:R,noDragClassName:sn,noWheelClassName:on,noPanClassName:an,disableKeyboardA11y:Yt,onViewportChange:ke,isControlledViewport:!!ue,children:o.jsxs(r4,{children:[o.jsx(t4,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:dt,onReconnectStart:He,onReconnectEnd:bt,onlyRenderVisibleElements:M,onEdgeContextMenu:_e,onEdgeMouseEnter:je,onEdgeMouseMove:Ve,onEdgeMouseLeave:et,reconnectRadius:qe,defaultMarkerColor:I,noPanClassName:an,disableKeyboardA11y:Yt,rfId:hn}),o.jsx(d4,{style:b,type:y,component:k,containerStyle:g}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx($H,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:pe,onlyRenderVisibleElements:M,noPanClassName:an,noDragClassName:sn,disableKeyboardA11y:Yt,nodeExtent:En,rfId:hn}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}tI.displayName="GraphView";const h4=h.memo(tI),TN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:u,zIndexMode:p="basic"}={})=>{const m=new Map,y=new Map,b=new Map,k=new Map,g=r??t??[],v=n??e??[],x=f??[0,0],N=u??Wf;fA(b,k,g);const{nodesInitialized:_}=pb(v,m,y,{nodeOrigin:x,nodeExtent:N,zIndexMode:p});let C=[0,0,1];if(a&&s&&i){const T=gp(m,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:H,y:M,zoom:F}=e0(T,s,i,c,d,(l==null?void 0:l.padding)??.1);C=[H,M,F]}return{rfId:"1",width:s??0,height:i??0,transform:C,nodes:v,nodesInitialized:_,nodeLookup:m,parentLookup:y,edges:g,edgeLookup:k,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Wf,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Iu.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...YP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:x3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:qP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},m4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p})=>L5((m,y)=>{async function b(){const{nodeLookup:k,panZoom:g,fitViewOptions:v,fitViewResolver:x,width:N,height:_,minZoom:C,maxZoom:T}=y();g&&(await g3({nodes:k,width:N,height:_,panZoom:g,minZoom:C,maxZoom:T},v),x==null||x.resolve(!0),m({fitViewResolver:null}))}return{...TN({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:k=>{const{nodeLookup:g,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:N,fitViewQueued:_,zIndexMode:C,nodesSelectionActive:T}=y(),{nodesInitialized:H,hasSelectedNodes:M}=pb(k,g,v,{nodeOrigin:x,nodeExtent:u,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),F=T&&M;_&&H?(b(),m({nodes:k,nodesInitialized:H,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):m({nodes:k,nodesInitialized:H,nodesSelectionActive:F})},setEdges:k=>{const{connectionLookup:g,edgeLookup:v}=y();fA(g,v,k),m({edges:k})},setDefaultNodesAndEdges:(k,g)=>{if(k){const{setNodes:v}=y();v(k),m({hasDefaultNodes:!0})}if(g){const{setEdges:v}=y();v(g),m({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:g,nodeLookup:v,parentLookup:x,domNode:N,nodeOrigin:_,nodeExtent:C,debug:T,fitViewQueued:H,zIndexMode:M}=y(),{changes:F,updatedInternals:D}=F3(k,v,x,N,_,C,M);D&&(M3(v,x,{nodeOrigin:_,nodeExtent:C,zIndexMode:M}),H?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(F==null?void 0:F.length)>0&&(T&&console.log("React Flow: trigger node changes",F),g==null||g(F)))},updateNodePositions:(k,g=!1)=>{const v=[];let x=[];const{nodeLookup:N,triggerNodeChanges:_,connection:C,updateConnection:T,onNodesChangeMiddlewareMap:H}=y();for(const[M,F]of k){const D=N.get(M),$=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(F!=null&&F.position)),W={id:M,type:"position",position:$?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:g};if(D&&C.inProgress&&C.fromNode.id===D.id){const O=hc(D,C.fromHandle,Ze.Left,!0);T({...C,from:O})}$&&D.parentId&&v.push({id:M,parentId:D.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),x.push(W)}if(v.length>0){const{parentLookup:M,nodeOrigin:F}=y(),D=o0(v,N,M,F);x.push(...D)}for(const M of H.values())x=M(x);_(x)},triggerNodeChanges:k=>{const{onNodesChange:g,setNodes:v,nodes:x,hasDefaultNodes:N,debug:_}=y();if(k!=null&&k.length){if(N){const C=tg(k,x);v(C)}_&&console.log("React Flow: trigger node changes",k),g==null||g(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:g,setEdges:v,edges:x,hasDefaultEdges:N,debug:_}=y();if(k!=null&&k.length){if(N){const C=a0(k,x);v(C)}_&&console.log("React Flow: trigger edge changes",k),g==null||g(k)}},addSelectedNodes:k=>{const{multiSelectionActive:g,edgeLookup:v,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:_}=y();if(g){const C=k.map(T=>Ul(T,!0));N(C);return}N(ou(x,new Set([...k]),!0)),_(ou(v))},addSelectedEdges:k=>{const{multiSelectionActive:g,edgeLookup:v,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:_}=y();if(g){const C=k.map(T=>Ul(T,!0));_(C);return}_(ou(v,new Set([...k]))),N(ou(x,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:g}={})=>{const{edges:v,nodes:x,nodeLookup:N,triggerNodeChanges:_,triggerEdgeChanges:C}=y(),T=k||x,H=g||v,M=[];for(const D of T){if(!D.selected)continue;const $=N.get(D.id);$&&($.selected=!1),M.push(Ul(D.id,!1))}const F=[];for(const D of H)D.selected&&F.push(Ul(D.id,!1));_(M),C(F)},setMinZoom:k=>{const{panZoom:g,maxZoom:v}=y();g==null||g.setScaleExtent([k,v]),m({minZoom:k})},setMaxZoom:k=>{const{panZoom:g,minZoom:v}=y();g==null||g.setScaleExtent([v,k]),m({maxZoom:k})},setTranslateExtent:k=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(k),m({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:g,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:N}=y();if(!N)return;const _=g.reduce((T,H)=>H.selected?[...T,Ul(H.id,!1)]:T,[]),C=k.reduce((T,H)=>H.selected?[...T,Ul(H.id,!1)]:T,[]);v(_),x(C)},setNodeExtent:k=>{const{nodes:g,nodeLookup:v,parentLookup:x,nodeOrigin:N,elevateNodesOnSelect:_,nodeExtent:C,zIndexMode:T}=y();k[0][0]===C[0][0]&&k[0][1]===C[0][1]&&k[1][0]===C[1][0]&&k[1][1]===C[1][1]||(pb(g,v,x,{nodeOrigin:N,nodeExtent:k,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:T}),m({nodeExtent:k}))},panBy:k=>{const{transform:g,width:v,height:x,panZoom:N,translateExtent:_}=y();return z3({delta:k,panZoom:N,transform:g,translateExtent:_,width:v,height:x})},setCenter:async(k,g,v)=>{const{width:x,height:N,maxZoom:_,panZoom:C}=y();if(!C)return Promise.resolve(!1);const T=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:_;return await C.setViewport({x:x/2-k*T,y:N/2-g*T,zoom:T},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...YP}})},updateConnection:k=>{m({connection:k})},reset:()=>m({...TN()})}},Object.is);function sy({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p,children:m}){const[y]=h.useState(()=>m4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:u,zIndexMode:p}));return o.jsx(M5,{value:y,children:o.jsx(rH,{children:m})})}function g4({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m}){return h.useContext(ty)?o.jsx(o.Fragment,{children:e}):o.jsx(sy,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m,children:e})}const y4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function x4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:u,onMoveEnd:p,onConnect:m,onConnectStart:y,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:g,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:_,onNodeDoubleClick:C,onNodeDragStart:T,onNodeDrag:H,onNodeDragStop:M,onNodesDelete:F,onEdgesDelete:D,onDelete:$,onSelectionChange:W,onSelectionDragStart:O,onSelectionDrag:R,onSelectionDragStop:I,onSelectionContextMenu:z,onSelectionStart:P,onSelectionEnd:L,onBeforeDelete:E,connectionMode:X,connectionLineType:ee=Va.Bezier,connectionLineStyle:V,connectionLineComponent:ie,connectionLineContainerStyle:fe,deleteKeyCode:me="Backspace",selectionKeyCode:ge="Shift",selectionOnDrag:Z=!1,selectionMode:ae=Vf.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:pe=Kf()?"Meta":"Control",zoomActivationKeyCode:_e=Kf()?"Meta":"Control",snapToGrid:je,snapGrid:Ve,onlyRenderVisibleElements:et=!1,selectNodesOnDrag:qe,nodesDraggable:dt,autoPanOnNodeFocus:He,nodesConnectable:bt,nodesFocusable:sn,nodeOrigin:on=AA,edgesFocusable:an,edgesReconnectable:Yt,elementsSelectable:En=!0,defaultViewport:hn=Y5,minZoom:ue=.5,maxZoom:ke=2,translateExtent:De=Wf,preventScrolling:rt=!0,nodeExtent:at,defaultMarkerColor:Lt="#b1b1b7",zoomOnScroll:st=!0,zoomOnPinch:mn=!0,panOnScroll:Zt=!1,panOnScrollSpeed:ar=.5,panOnScrollMode:_n=nc.Free,zoomOnDoubleClick:gn=!0,panOnDrag:bn=!0,onPaneClick:lr,onPaneMouseEnter:ve,onPaneMouseMove:$e,onPaneMouseLeave:nt,onPaneScroll:zt,onPaneContextMenu:oe,paneClickDistance:Te=1,nodeClickDistance:Ue=0,children:Ht,onReconnect:yn,onReconnectStart:cr,onReconnectEnd:Hs,onEdgeContextMenu:as,onEdgeDoubleClick:hr,onEdgeMouseEnter:Zn,onEdgeMouseMove:Vr,onEdgeMouseLeave:ot,reconnectRadius:Ur=10,onNodesChange:Ai,onEdgesChange:xa,noDragClassName:xs="nodrag",noWheelClassName:Ie="nowheel",noPanClassName:cn="nopan",fitView:mr,fitViewOptions:ht,connectOnClick:Oe,attributionPosition:Kr,proOptions:Gn,defaultEdgeOptions:qr,elevateNodesOnSelect:Cr=!0,elevateEdgesOnSelect:ut=!1,disableKeyboardA11y:Ut=!1,autoPanOnConnect:un,autoPanOnNodeDrag:Er,autoPanSpeed:tt,connectionRadius:gr,isValidConnection:Bs,onError:wa,style:ws,id:Oo,nodeDragThreshold:vr,connectionDragThreshold:$o,viewport:Ii,onViewportChange:xn,width:er,height:bs,colorMode:Yr="light",debug:li,onScroll:Ws,ariaLabelConfig:K,zIndexMode:we="basic",...Le},Me){const Ke=Oo||"1",en=Q5(Yr),Mt=h.useCallback(wn=>{wn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ws==null||Ws(wn)},[Ws]);return o.jsx("div",{"data-testid":"rf__wrapper",...Le,onScroll:Mt,style:{...ws,...y4},ref:Me,className:br(["react-flow",s,en]),id:Oo,role:"application",children:o.jsxs(g4,{nodes:e,edges:t,width:er,height:bs,fitView:mr,fitViewOptions:ht,minZoom:ue,maxZoom:ke,nodeOrigin:on,nodeExtent:at,zIndexMode:we,children:[o.jsx(J5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:y,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:g,nodesDraggable:dt,autoPanOnNodeFocus:He,nodesConnectable:bt,nodesFocusable:sn,edgesFocusable:an,edgesReconnectable:Yt,elementsSelectable:En,elevateNodesOnSelect:Cr,elevateEdgesOnSelect:ut,minZoom:ue,maxZoom:ke,nodeExtent:at,onNodesChange:Ai,onEdgesChange:xa,snapToGrid:je,snapGrid:Ve,connectionMode:X,translateExtent:De,connectOnClick:Oe,defaultEdgeOptions:qr,fitView:mr,fitViewOptions:ht,onNodesDelete:F,onEdgesDelete:D,onDelete:$,onNodeDragStart:T,onNodeDrag:H,onNodeDragStop:M,onSelectionDrag:R,onSelectionDragStart:O,onSelectionDragStop:I,onMove:f,onMoveStart:u,onMoveEnd:p,noPanClassName:cn,nodeOrigin:on,rfId:Ke,autoPanOnConnect:un,autoPanOnNodeDrag:Er,autoPanSpeed:tt,onError:wa,connectionRadius:gr,isValidConnection:Bs,selectNodesOnDrag:qe,nodeDragThreshold:vr,connectionDragThreshold:$o,onBeforeDelete:E,debug:li,ariaLabelConfig:K,zIndexMode:we}),o.jsx(h4,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:_,onNodeDoubleClick:C,nodeTypes:i,edgeTypes:a,connectionLineType:ee,connectionLineStyle:V,connectionLineComponent:ie,connectionLineContainerStyle:fe,selectionKeyCode:ge,selectionOnDrag:Z,selectionMode:ae,deleteKeyCode:me,multiSelectionKeyCode:pe,panActivationKeyCode:xe,zoomActivationKeyCode:_e,onlyRenderVisibleElements:et,defaultViewport:hn,translateExtent:De,minZoom:ue,maxZoom:ke,preventScrolling:rt,zoomOnScroll:st,zoomOnPinch:mn,zoomOnDoubleClick:gn,panOnScroll:Zt,panOnScrollSpeed:ar,panOnScrollMode:_n,panOnDrag:bn,onPaneClick:lr,onPaneMouseEnter:ve,onPaneMouseMove:$e,onPaneMouseLeave:nt,onPaneScroll:zt,onPaneContextMenu:oe,paneClickDistance:Te,nodeClickDistance:Ue,onSelectionContextMenu:z,onSelectionStart:P,onSelectionEnd:L,onReconnect:yn,onReconnectStart:cr,onReconnectEnd:Hs,onEdgeContextMenu:as,onEdgeDoubleClick:hr,onEdgeMouseEnter:Zn,onEdgeMouseMove:Vr,onEdgeMouseLeave:ot,reconnectRadius:Ur,defaultMarkerColor:Lt,noDragClassName:xs,noWheelClassName:Ie,noPanClassName:cn,rfId:Ke,disableKeyboardA11y:Ut,nodeExtent:at,viewport:Ii,onViewportChange:xn}),o.jsx(q5,{onSelectionChange:W}),Ht,o.jsx(B5,{proOptions:Gn,position:Kr}),o.jsx(H5,{rfId:Ke,disableKeyboardA11y:Ut})]})})}var c0=TA(x4);function u0(){const e=Hn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],i=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&i.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function nI(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>tg(s,i)),[]);return[t,n,r]}function rI(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>a0(s,i)),[]);return[t,n,r]}function w4({dimensions:e,lineWidth:t,variant:n,className:r}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:br(["react-flow__background-pattern",n,r])})}function b4({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:br(["react-flow__background-pattern","dots",t])})}var sl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(sl||(sl={}));const v4={[sl.Dots]:1,[sl.Lines]:1,[sl.Cross]:6},k4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function sI({id:e,variant:t=sl.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:d,patternClassName:f}){const u=h.useRef(null),{transform:p,patternId:m}=Vt(k4,Yn),y=r||v4[t],b=t===sl.Dots,k=t===sl.Cross,g=Array.isArray(n)?n:[n,n],v=[g[0]*p[2]||1,g[1]*p[2]||1],x=y*p[2],N=Array.isArray(i)?i:[i,i],_=k?[x,x]:v,C=[N[0]*p[2]||1+_[0]/2,N[1]*p[2]||1+_[1]/2],T=`${m}${e||""}`;return o.jsxs("svg",{className:br(["react-flow__background",d]),style:{...c,...ny,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:u,"data-testid":"rf__background",children:[o.jsx("pattern",{id:T,x:p[0]%v[0],y:p[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:b?o.jsx(b4,{radius:x/2,className:f}):o.jsx(w4,{dimensions:_,lineWidth:s,variant:t,className:f})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${T})`})]})}sI.displayName="Background";const d0=h.memo(sI);function S4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function N4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function j4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function C4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function E4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Th({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:br(["react-flow__controls-button",t]),...n,children:e})}const _4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function iI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:f,position:u="bottom-left",orientation:p="vertical","aria-label":m}){const y=Hn(),{isInteractive:b,minZoomReached:k,maxZoomReached:g,ariaLabelConfig:v}=Vt(_4,Yn),{zoomIn:x,zoomOut:N,fitView:_}=wc(),C=()=>{x(),i==null||i()},T=()=>{N(),a==null||a()},H=()=>{_(s),l==null||l()},M=()=>{y.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},F=p==="horizontal"?"horizontal":"vertical";return o.jsxs($u,{className:br(["react-flow__controls",F,d]),position:u,style:e,"data-testid":"rf__controls","aria-label":m??v["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(Th,{onClick:C,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:g,children:o.jsx(S4,{})}),o.jsx(Th,{onClick:T,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:k,children:o.jsx(N4,{})})]}),n&&o.jsx(Th,{className:"react-flow__controls-fitview",onClick:H,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:o.jsx(j4,{})}),r&&o.jsx(Th,{className:"react-flow__controls-interactive",onClick:M,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:b?o.jsx(E4,{}):o.jsx(C4,{})}),f]})}iI.displayName="Controls";const P4=h.memo(iI);function A4({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:u,selected:p,onClick:m}){const{background:y,backgroundColor:b}=i||{},k=a||y||b;return o.jsx("rect",{className:br(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:k,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?g=>m(g,e):void 0})}const I4=h.memo(A4),T4=e=>e.nodes.map(t=>t.id),xx=e=>e instanceof Function?e:()=>e;function R4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=I4,onClick:a}){const l=Vt(T4,Yn),c=xx(t),d=xx(e),f=xx(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(M4,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:u},p))})}function L4({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:f,y:u,width:p,height:m}=Vt(y=>{const b=y.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const k=b.internals.userNode,{x:g,y:v}=b.internals.positionAbsolute,{width:x,height:N}=ga(k);return{node:k,x:g,y:v,width:x,height:N}},Yn);return!d||d.hidden||!tA(d)?null:o.jsx(l,{x:f,y:u,width:p,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:c,id:d.id})}const M4=h.memo(L4);var O4=h.memo(R4);const $4=200,D4=150,F4=e=>!e.hidden,z4=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?eA(gp(e.nodeLookup,{filter:F4}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},H4="react-flow__minimap-desc";function oI({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:u,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:b=!1,zoomable:k=!1,ariaLabel:g,inversePan:v,zoomStep:x=1,offsetScale:N=5}){const _=Hn(),C=h.useRef(null),{boundingRect:T,viewBB:H,rfId:M,panZoom:F,translateExtent:D,flowWidth:$,flowHeight:W,ariaLabelConfig:O}=Vt(z4,Yn),R=(e==null?void 0:e.width)??$4,I=(e==null?void 0:e.height)??D4,z=T.width/R,P=T.height/I,L=Math.max(z,P),E=L*R,X=L*I,ee=N*L,V=T.x-(E-T.width)/2-ee,ie=T.y-(X-T.height)/2-ee,fe=E+ee*2,me=X+ee*2,ge=`${H4}-${M}`,Z=h.useRef(0),ae=h.useRef();Z.current=L,h.useEffect(()=>{if(C.current&&F)return ae.current=G3({domNode:C.current,panZoom:F,getTransform:()=>_.getState().transform,getViewScale:()=>Z.current}),()=>{var je;(je=ae.current)==null||je.destroy()}},[F]),h.useEffect(()=>{var je;(je=ae.current)==null||je.update({translateExtent:D,width:$,height:W,inversePan:v,pannable:b,zoomStep:x,zoomable:k})},[b,k,v,x,D,$,W]);const xe=m?je=>{var qe;const[Ve,et]=((qe=ae.current)==null?void 0:qe.pointer(je))||[0,0];m(je,{x:Ve,y:et})}:void 0,pe=y?h.useCallback((je,Ve)=>{const et=_.getState().nodeLookup.get(Ve).internals.userNode;y(je,et)},[]):void 0,_e=g??O["minimap.ariaLabel"];return o.jsx($u,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*L:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:br(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:R,height:I,viewBox:`${V} ${ie} ${fe} ${me}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ge,ref:C,onClick:xe,children:[_e&&o.jsx("title",{id:ge,children:_e}),o.jsx(O4,{onClick:pe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-ee},${ie-ee}h${fe+ee*2}v${me+ee*2}h${-fe-ee*2}z
66
- M${H.x},${H.y}h${H.width}v${H.height}h${-H.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}oI.displayName="MiniMap";const B4=h.memo(oI),W4=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,V4={[Mu.Line]:"right",[Mu.Handle]:"bottom-right"};function U4({nodeId:e,position:t,variant:n=Mu.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:p,autoScale:m=!0,shouldResize:y,onResizeStart:b,onResize:k,onResizeEnd:g}){const v=OA(),x=typeof e=="string"?e:v,N=Hn(),_=h.useRef(null),C=n===Mu.Handle,T=Vt(h.useCallback(W4(C&&m),[C,m]),Yn),H=h.useRef(null),M=t??V4[n];h.useEffect(()=>{if(!(!_.current||!x))return H.current||(H.current=c5({domNode:_.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:D,transform:$,snapGrid:W,snapToGrid:O,nodeOrigin:R,domNode:I}=N.getState();return{nodeLookup:D,transform:$,snapGrid:W,snapToGrid:O,nodeOrigin:R,paneDomNode:I}},onChange:(D,$)=>{const{triggerNodeChanges:W,nodeLookup:O,parentLookup:R,nodeOrigin:I}=N.getState(),z=[],P={x:D.x,y:D.y},L=O.get(x);if(L&&L.expandParent&&L.parentId){const E=L.origin??I,X=D.width??L.measured.width??0,ee=D.height??L.measured.height??0,V={id:L.id,parentId:L.parentId,rect:{width:X,height:ee,...nA({x:D.x??L.position.x,y:D.y??L.position.y},{width:X,height:ee},L.parentId,O,E)}},ie=o0([V],O,R,I);z.push(...ie),P.x=D.x?Math.max(E[0]*X,D.x):void 0,P.y=D.y?Math.max(E[1]*ee,D.y):void 0}if(P.x!==void 0&&P.y!==void 0){const E={id:x,type:"position",position:{...P}};z.push(E)}if(D.width!==void 0&&D.height!==void 0){const X={id:x,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};z.push(X)}for(const E of $){const X={...E,type:"position"};z.push(X)}W(z)},onEnd:({width:D,height:$})=>{const W={id:x,type:"dimensions",resizing:!1,dimensions:{width:D,height:$}};N.getState().triggerNodeChanges([W])}})),H.current.update({controlPosition:M,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:p,onResizeStart:b,onResize:k,onResizeEnd:g,shouldResize:y}),()=>{var D;(D=H.current)==null||D.destroy()}},[M,l,c,d,f,u,b,k,g,y]);const F=M.split("-");return o.jsx("div",{className:br(["react-flow__resize-control","nodrag",...F,n,r]),ref:_,style:{...s,scale:T,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:i})}const aI=h.memo(U4);function K4(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const q4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Y4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G4={};function RN(e,t){return(G4.jsx?Y4:q4).test(e)}const X4=/[ \t\n\f\r]/g;function J4(e){return typeof e=="object"?e.type==="text"?LN(e.value):!1:LN(e)}function LN(e){return e.replace(X4,"")===""}let wp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};wp.prototype.normal={};wp.prototype.property={};wp.prototype.space=void 0;function lI(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new wp(n,r,t)}function yb(e){return e.toLowerCase()}class zs{constructor(t,n){this.attribute=n,this.property=t}}zs.prototype.attribute="";zs.prototype.booleanish=!1;zs.prototype.boolean=!1;zs.prototype.commaOrSpaceSeparated=!1;zs.prototype.commaSeparated=!1;zs.prototype.defined=!1;zs.prototype.mustUseProperty=!1;zs.prototype.number=!1;zs.prototype.overloadedBoolean=!1;zs.prototype.property="";zs.prototype.spaceSeparated=!1;zs.prototype.space=void 0;let Q4=0;const Pt=bc(),yr=bc(),xb=bc(),Ae=bc(),Tn=bc(),xu=bc(),Xs=bc();function bc(){return 2**++Q4}const wb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Pt,booleanish:yr,commaOrSpaceSeparated:Xs,commaSeparated:xu,number:Ae,overloadedBoolean:xb,spaceSeparated:Tn},Symbol.toStringTag,{value:"Module"})),wx=Object.keys(wb);class f0 extends zs{constructor(t,n,r,s){let i=-1;if(super(t,n),MN(this,"space",s),typeof r=="number")for(;++i<wx.length;){const a=wx[i];MN(this,wx[i],(r&wb[a])===wb[a])}}}f0.prototype.defined=!0;function MN(e,t,n){n&&(e[t]=n)}function Yu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new f0(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[yb(r)]=r,n[yb(i.attribute)]=r}return new wp(t,n,e.space)}const cI=Yu({properties:{ariaActiveDescendant:null,ariaAtomic:yr,ariaAutoComplete:null,ariaBusy:yr,ariaChecked:yr,ariaColCount:Ae,ariaColIndex:Ae,ariaColSpan:Ae,ariaControls:Tn,ariaCurrent:null,ariaDescribedBy:Tn,ariaDetails:null,ariaDisabled:yr,ariaDropEffect:Tn,ariaErrorMessage:null,ariaExpanded:yr,ariaFlowTo:Tn,ariaGrabbed:yr,ariaHasPopup:null,ariaHidden:yr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Tn,ariaLevel:Ae,ariaLive:null,ariaModal:yr,ariaMultiLine:yr,ariaMultiSelectable:yr,ariaOrientation:null,ariaOwns:Tn,ariaPlaceholder:null,ariaPosInSet:Ae,ariaPressed:yr,ariaReadOnly:yr,ariaRelevant:null,ariaRequired:yr,ariaRoleDescription:Tn,ariaRowCount:Ae,ariaRowIndex:Ae,ariaRowSpan:Ae,ariaSelected:yr,ariaSetSize:Ae,ariaSort:null,ariaValueMax:Ae,ariaValueMin:Ae,ariaValueNow:Ae,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function uI(e,t){return t in e?e[t]:t}function dI(e,t){return uI(e,t.toLowerCase())}const Z4=Yu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xu,acceptCharset:Tn,accessKey:Tn,action:null,allow:null,allowFullScreen:Pt,allowPaymentRequest:Pt,allowUserMedia:Pt,alt:null,as:null,async:Pt,autoCapitalize:null,autoComplete:Tn,autoFocus:Pt,autoPlay:Pt,blocking:Tn,capture:null,charSet:null,checked:Pt,cite:null,className:Tn,cols:Ae,colSpan:null,content:null,contentEditable:yr,controls:Pt,controlsList:Tn,coords:Ae|xu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Pt,defer:Pt,dir:null,dirName:null,disabled:Pt,download:xb,draggable:yr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Pt,formTarget:null,headers:Tn,height:Ae,hidden:xb,high:Ae,href:null,hrefLang:null,htmlFor:Tn,httpEquiv:Tn,id:null,imageSizes:null,imageSrcSet:null,inert:Pt,inputMode:null,integrity:null,is:null,isMap:Pt,itemId:null,itemProp:Tn,itemRef:Tn,itemScope:Pt,itemType:Tn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Pt,low:Ae,manifest:null,max:null,maxLength:Ae,media:null,method:null,min:null,minLength:Ae,multiple:Pt,muted:Pt,name:null,nonce:null,noModule:Pt,noValidate:Pt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Pt,optimum:Ae,pattern:null,ping:Tn,placeholder:null,playsInline:Pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Pt,referrerPolicy:null,rel:Tn,required:Pt,reversed:Pt,rows:Ae,rowSpan:Ae,sandbox:Tn,scope:null,scoped:Pt,seamless:Pt,selected:Pt,shadowRootClonable:Pt,shadowRootDelegatesFocus:Pt,shadowRootMode:null,shape:null,size:Ae,sizes:null,slot:null,span:Ae,spellCheck:yr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ae,step:null,style:null,tabIndex:Ae,target:null,title:null,translate:null,type:null,typeMustMatch:Pt,useMap:null,value:yr,width:Ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Tn,axis:null,background:null,bgColor:null,border:Ae,borderColor:null,bottomMargin:Ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Pt,declare:Pt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ae,leftMargin:Ae,link:null,longDesc:null,lowSrc:null,marginHeight:Ae,marginWidth:Ae,noResize:Pt,noHref:Pt,noShade:Pt,noWrap:Pt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ae,rules:null,scheme:null,scrolling:yr,standby:null,summary:null,text:null,topMargin:Ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ae,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Pt,disableRemotePlayback:Pt,prefix:null,property:null,results:Ae,security:null,unselectable:null},space:"html",transform:dI}),eB=Yu({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xs,accentHeight:Ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ae,amplitude:Ae,arabicForm:null,ascent:Ae,attributeName:null,attributeType:null,azimuth:Ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ae,by:null,calcMode:null,capHeight:Ae,className:Tn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ae,diffuseConstant:Ae,direction:null,display:null,dur:null,divisor:Ae,dominantBaseline:null,download:Pt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ae,enableBackground:null,end:null,event:null,exponent:Ae,externalResourcesRequired:null,fill:null,fillOpacity:Ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xu,g2:xu,glyphName:xu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ae,horizOriginX:Ae,horizOriginY:Ae,id:null,ideographic:Ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ae,k:Ae,k1:Ae,k2:Ae,k3:Ae,k4:Ae,kernelMatrix:Xs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ae,overlineThickness:Ae,paintOrder:null,panose1:null,path:null,pathLength:Ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Tn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ae,pointsAtY:Ae,pointsAtZ:Ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xs,rev:Xs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xs,requiredFeatures:Xs,requiredFonts:Xs,requiredFormats:Xs,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ae,specularExponent:Ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ae,strikethroughThickness:Ae,string:null,stroke:null,strokeDashArray:Xs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ae,strokeOpacity:Ae,strokeWidth:null,style:null,surfaceScale:Ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xs,tabIndex:Ae,tableValues:null,target:null,targetX:Ae,targetY:Ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ae,underlineThickness:Ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ae,values:null,vAlphabetic:Ae,vMathematical:Ae,vectorEffect:null,vHanging:Ae,vIdeographic:Ae,version:null,vertAdvY:Ae,vertOriginX:Ae,vertOriginY:Ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:uI}),fI=Yu({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),pI=Yu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:dI}),hI=Yu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),tB={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},nB=/[A-Z]/g,ON=/-[a-z]/g,rB=/^data[-\w.:]+$/i;function sB(e,t){const n=yb(t);let r=t,s=zs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&rB.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(ON,oB);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!ON.test(i)){let a=i.replace(nB,iB);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=f0}return new s(r,t)}function iB(e){return"-"+e.toLowerCase()}function oB(e){return e.charAt(1).toUpperCase()}const aB=lI([cI,Z4,fI,pI,hI],"html"),p0=lI([cI,eB,fI,pI,hI],"svg");function lB(e){return e.join(" ").trim()}var h0={},$N=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,cB=/\n/g,uB=/^\s*/,dB=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,fB=/^:\s*/,pB=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,hB=/^[;\s]*/,mB=/^\s+|\s+$/g,gB=`
67
- `,DN="/",FN="*",ql="",yB="comment",xB="declaration";function wB(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(y){var b=y.match(cB);b&&(n+=b.length);var k=y.lastIndexOf(gB);r=~k?y.length-k:r+y.length}function i(){var y={line:n,column:r};return function(b){return b.position=new a(y),d(),b}}function a(y){this.start=y,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(y){var b=new Error(t.source+":"+n+":"+r+": "+y);if(b.reason=y,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(y){var b=y.exec(e);if(b){var k=b[0];return s(k),e=e.slice(k.length),b}}function d(){c(uB)}function f(y){var b;for(y=y||[];b=u();)b!==!1&&y.push(b);return y}function u(){var y=i();if(!(DN!=e.charAt(0)||FN!=e.charAt(1))){for(var b=2;ql!=e.charAt(b)&&(FN!=e.charAt(b)||DN!=e.charAt(b+1));)++b;if(b+=2,ql===e.charAt(b-1))return l("End of comment missing");var k=e.slice(2,b-2);return r+=2,s(k),e=e.slice(b),r+=2,y({type:yB,comment:k})}}function p(){var y=i(),b=c(dB);if(b){if(u(),!c(fB))return l("property missing ':'");var k=c(pB),g=y({type:xB,property:zN(b[0].replace($N,ql)),value:k?zN(k[0].replace($N,ql)):ql});return c(hB),g}}function m(){var y=[];f(y);for(var b;b=p();)b!==!1&&(y.push(b),f(y));return y}return d(),m()}function zN(e){return e?e.replace(mB,ql):ql}var bB=wB,vB=bf&&bf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(h0,"__esModule",{value:!0});h0.default=SB;const kB=vB(bB);function SB(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,kB.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:l}=i;s?t(a,l,i):l&&(n=n||{},n[a]=l)}),n}var iy={};Object.defineProperty(iy,"__esModule",{value:!0});iy.camelCase=void 0;var NB=/^--[a-zA-Z0-9_-]+$/,jB=/-([a-z])/g,CB=/^[^-]+$/,EB=/^-(webkit|moz|ms|o|khtml)-/,_B=/^-(ms)-/,PB=function(e){return!e||CB.test(e)||NB.test(e)},AB=function(e,t){return t.toUpperCase()},HN=function(e,t){return"".concat(t,"-")},IB=function(e,t){return t===void 0&&(t={}),PB(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(_B,HN):e=e.replace(EB,HN),e.replace(jB,AB))};iy.camelCase=IB;var TB=bf&&bf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},RB=TB(h0),LB=iy;function bb(e,t){var n={};return!e||typeof e!="string"||(0,RB.default)(e,function(r,s){r&&s&&(n[(0,LB.camelCase)(r,t)]=s)}),n}bb.default=bb;var MB=bb;const OB=hl(MB),mI=gI("end"),m0=gI("start");function gI(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function $B(e){const t=m0(e),n=mI(e);if(t&&n)return{start:t,end:n}}function hf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?BN(e.position):"start"in e||"end"in e?BN(e):"line"in e||"column"in e?vb(e):""}function vb(e){return WN(e&&e.line)+":"+WN(e&&e.column)}function BN(e){return vb(e&&e.start)+"-"+vb(e&&e.end)}function WN(e){return e&&typeof e=="number"?e:1}class is extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=hf(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}is.prototype.file="";is.prototype.name="";is.prototype.reason="";is.prototype.message="";is.prototype.stack="";is.prototype.column=void 0;is.prototype.line=void 0;is.prototype.ancestors=void 0;is.prototype.cause=void 0;is.prototype.fatal=void 0;is.prototype.place=void 0;is.prototype.ruleId=void 0;is.prototype.source=void 0;const g0={}.hasOwnProperty,DB=new Map,FB=/[A-Z]/g,zB=new Set(["table","tbody","thead","tfoot","tr"]),HB=new Set(["td","th"]),yI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function BB(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=XB(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=GB(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?p0:aB,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=xI(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function xI(e,t,n){if(t.type==="element")return WB(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return VB(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return KB(e,t,n);if(t.type==="mdxjsEsm")return UB(e,t);if(t.type==="root")return qB(e,t,n);if(t.type==="text")return YB(e,t)}function WB(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=p0,e.schema=s),e.ancestors.push(t);const i=bI(e,t.tagName,!1),a=JB(e,t);let l=x0(e,t);return zB.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!J4(c):!0})),wI(e,a,i,t),y0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function VB(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Gf(e,t.position)}function UB(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Gf(e,t.position)}function KB(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=p0,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:bI(e,t.name,!0),a=QB(e,t),l=x0(e,t);return wI(e,a,i,t),y0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function qB(e,t,n){const r={};return y0(r,x0(e,t)),e.create(t,e.Fragment,r,n)}function YB(e,t){return t.value}function wI(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function y0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function GB(e,t,n){return r;function r(s,i,a,l){const d=Array.isArray(a.children)?n:t;return l?d(i,a,l):d(i,a)}}function XB(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=m0(r);return t(s,i,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function JB(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&g0.call(t.properties,s)){const i=ZB(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&HB.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function QB(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Gf(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else Gf(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function x0(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:DB;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const d=s.get(c)||0;a=c+"-"+d,s.set(c,d+1)}}const l=xI(e,i,a);l!==void 0&&n.push(l)}return n}function ZB(e,t,n){const r=sB(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?K4(n):lB(n)),r.property==="style"){let s=typeof n=="object"?n:e6(e,String(n));return e.stylePropertyNameCase==="css"&&(s=t6(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?tB[r.property]||r.property:r.attribute,n]}}function e6(e,t){try{return OB(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new is("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=yI+"#cannot-parse-style-attribute",s}}function bI(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const l=RN(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=RN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return g0.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Gf(e)}function Gf(e,t){const n=new is("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=yI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function t6(e){const t={};let n;for(n in e)g0.call(e,n)&&(t[n6(n)]=e[n]);return t}function n6(e){let t=e.replace(FB,r6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function r6(e){return"-"+e.toLowerCase()}const bx={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},s6={};function i6(e,t){const n=s6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return vI(e,r,s)}function vI(e,t,n){if(o6(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return VN(e.children,t,n)}return Array.isArray(e)?VN(e,t,n):""}function VN(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=vI(e[s],t,n);return r.join("")}function o6(e){return!!(e&&typeof e=="object")}const UN=document.createElement("i");function w0(e){const t="&"+e+";";UN.innerHTML=t;const n=UN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function To(e,t,n,r){const s=e.length;let i=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function Ni(e,t){return e.length>0?(To(e,e.length,0,t),e):t}const KN={}.hasOwnProperty;function a6(e){const t={};let n=-1;for(;++n<e.length;)l6(t,e[n]);return t}function l6(e,t){let n;for(n in t){const s=(KN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){KN.call(s,a)||(s[a]=[]);const l=i[a];c6(s[a],Array.isArray(l)?l:l?[l]:[])}}}function c6(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);To(e,0,0,r)}function kI(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function wu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const So=xl(/[A-Za-z]/),ti=xl(/[\dA-Za-z]/),u6=xl(/[#-'*+\--9=?A-Z^-~]/);function kb(e){return e!==null&&(e<32||e===127)}const Sb=xl(/\d/),d6=xl(/[\dA-Fa-f]/),f6=xl(/[!-/:-@[-`{-~]/);function wt(e){return e!==null&&e<-2}function Ds(e){return e!==null&&(e<0||e===32)}function rn(e){return e===-2||e===-1||e===32}const p6=xl(new RegExp("\\p{P}|\\p{S}","u")),h6=xl(/\s/);function xl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gu(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&ti(e.charCodeAt(n+1))&&ti(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),s=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Ln(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return rn(c)?(e.enter(n),l(c)):t(c)}function l(c){return rn(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const m6={tokenize:g6};function g6(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Ln(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return wt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const y6={tokenize:x6},qN={tokenize:w6};function x6(e){const t=this,n=[];let r=0,s,i,a;return l;function l(x){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,c,d)(x)}return d(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const N=t.events.length;let _=N,C;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){C=t.events[_][1].end;break}g(r);let T=N;for(;T<t.events.length;)t.events[T][1].end={...C},T++;return To(t.events,_+1,0,t.events.slice(N)),t.events.length=T,d(x)}return l(x)}function d(x){if(r===n.length){if(!s)return p(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(qN,f,u)(x)}function f(x){return s&&v(),g(r),p(x)}function u(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function p(x){return t.containerState={},e.attempt(qN,m,y)(x)}function m(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function y(x){if(x===null){s&&v(),g(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),b(x)}function b(x){if(x===null){k(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return wt(x)?(e.consume(x),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),b)}function k(x,N){const _=t.sliceStream(x);if(N&&_.push(null),x.previous=i,i&&(i.next=x),i=x,s.defineSkip(x.start),s.write(_),t.parser.lazy[x.start.line]){let C=s.events.length;for(;C--;)if(s.events[C][1].start.offset<a&&(!s.events[C][1].end||s.events[C][1].end.offset>a))return;const T=t.events.length;let H=T,M,F;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(M){F=t.events[H][1].end;break}M=!0}for(g(r),C=T;C<t.events.length;)t.events[C][1].end={...F},C++;To(t.events,H+1,0,t.events.slice(T)),t.events.length=C}}function g(x){let N=n.length;for(;N-- >x;){const _=n[N];t.containerState=_[1],_[0].exit.call(t,e)}n.length=x}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function w6(e,t,n){return Ln(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function YN(e){if(e===null||Ds(e)||h6(e))return 1;if(p6(e))return 2}function b0(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const Nb={name:"attention",resolveAll:b6,tokenize:v6};function b6(e,t){let n=-1,r,s,i,a,l,c,d,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const u={...e[r][1].end},p={...e[n][1].start};GN(u,-c),GN(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Ni(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Ni(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=Ni(d,b0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Ni(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,d=Ni(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,To(e,r-1,n-r+3,d),n=r+d.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function v6(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=YN(r);let i;return a;function a(c){return i=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===i)return e.consume(c),l;const d=e.exit("attentionSequence"),f=YN(c),u=!f||f===2&&s||n.includes(c),p=!s||s===2&&f||n.includes(r);return d._open=!!(i===42?u:u&&(s||!p)),d._close=!!(i===42?p:p&&(f||!u)),t(c)}}function GN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const k6={name:"autolink",tokenize:S6};function S6(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(m){return So(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||ti(m)?(r=1,l(m)):d(m)}function l(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||ti(m))&&r++<32?(e.consume(m),l):(r=0,d(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||kb(m)?n(m):(e.consume(m),c)}function d(m){return m===64?(e.consume(m),f):u6(m)?(e.consume(m),d):n(m)}function f(m){return ti(m)?u(m):n(m)}function u(m){return m===46?(e.consume(m),r=0,f):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||ti(m))&&r++<63){const y=m===45?p:u;return e.consume(m),y}return n(m)}}const oy={partial:!0,tokenize:N6};function N6(e,t,n){return r;function r(i){return rn(i)?Ln(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||wt(i)?t(i):n(i)}}const SI={continuation:{tokenize:C6},exit:E6,name:"blockQuote",tokenize:j6};function j6(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return rn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function C6(e,t,n){const r=this;return s;function s(a){return rn(a)?Ln(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(SI,t,n)(a)}}function E6(e){e.exit("blockQuote")}const NI={name:"characterEscape",tokenize:_6};function _6(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return f6(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const jI={name:"characterReference",tokenize:P6};function P6(e,t,n){const r=this;let s=0,i,a;return l;function l(u){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),c}function c(u){return u===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(u),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=ti,f(u))}function d(u){return u===88||u===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(u),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=d6,f):(e.enter("characterReferenceValue"),i=7,a=Sb,f(u))}function f(u){if(u===59&&s){const p=e.exit("characterReferenceValue");return a===ti&&!w0(r.sliceSerialize(p))?n(u):(e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(u)&&s++<i?(e.consume(u),f):n(u)}}const XN={partial:!0,tokenize:I6},JN={concrete:!0,name:"codeFenced",tokenize:A6};function A6(e,t,n){const r=this,s={partial:!0,tokenize:_};let i=0,a=0,l;return c;function c(C){return d(C)}function d(C){const T=r.events[r.events.length-1];return i=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(C)}function f(C){return C===l?(a++,e.consume(C),f):a<3?n(C):(e.exit("codeFencedFenceSequence"),rn(C)?Ln(e,u,"whitespace")(C):u(C))}function u(C){return C===null||wt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(XN,b,N)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u(C)):rn(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ln(e,m,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function m(C){return C===null||wt(C)?u(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),u(C)):C===96&&C===l?n(C):(e.consume(C),y)}function b(C){return e.attempt(s,N,k)(C)}function k(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return i>0&&rn(C)?Ln(e,v,"linePrefix",i+1)(C):v(C)}function v(C){return C===null||wt(C)?e.check(XN,b,N)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||wt(C)?(e.exit("codeFlowValue"),v(C)):(e.consume(C),x)}function N(C){return e.exit("codeFenced"),t(C)}function _(C,T,H){let M=0;return F;function F(R){return C.enter("lineEnding"),C.consume(R),C.exit("lineEnding"),D}function D(R){return C.enter("codeFencedFence"),rn(R)?Ln(C,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):$(R)}function $(R){return R===l?(C.enter("codeFencedFenceSequence"),W(R)):H(R)}function W(R){return R===l?(M++,C.consume(R),W):M>=a?(C.exit("codeFencedFenceSequence"),rn(R)?Ln(C,O,"whitespace")(R):O(R)):H(R)}function O(R){return R===null||wt(R)?(C.exit("codeFencedFence"),T(R)):H(R)}}}function I6(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const vx={name:"codeIndented",tokenize:R6},T6={partial:!0,tokenize:L6};function R6(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),Ln(e,i,"linePrefix",5)(d)}function i(d){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):wt(d)?e.attempt(T6,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||wt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function L6(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):Ln(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):wt(a)?s(a):n(a)}}const M6={name:"codeText",previous:$6,resolve:O6,tokenize:D6};function O6(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function $6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function D6(e,t,n){let r=0,s,i;return a;function a(u){return e.enter("codeText"),e.enter("codeTextSequence"),l(u)}function l(u){return u===96?(e.consume(u),r++,l):(e.exit("codeTextSequence"),c(u))}function c(u){return u===null?n(u):u===32?(e.enter("space"),e.consume(u),e.exit("space"),c):u===96?(i=e.enter("codeTextSequence"),s=0,f(u)):wt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("codeTextData"),d(u))}function d(u){return u===null||u===32||u===96||wt(u)?(e.exit("codeTextData"),c(u)):(e.consume(u),d)}function f(u){return u===96?(e.consume(u),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(u)):(i.type="codeTextData",d(u))}}class F6{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&$d(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),$d(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),$d(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);$d(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);$d(this.left,n.reverse())}}}function $d(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function CI(e){const t={};let n=-1,r,s,i,a,l,c,d;const f=new F6(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,z6(f,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=f.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(f.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...f.get(s)[1].start},l=f.slice(s,n),l.unshift(r),f.splice(s,n-s+1,l))}}return To(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function z6(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],d={};let f,u,p=-1,m=n,y=0,b=0;const k=[b];for(;m;){for(;e.get(++s)[1]!==m;);i.push(s),m._tokenizer||(f=r.sliceStream(m),m.next||f.push(null),u&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(b=p+1,k.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):k.pop(),p=k.length;p--;){const g=l.slice(k[p],k[p+1]),v=i.pop();c.push([v,v+g.length-1]),e.splice(v,2,g)}for(c.reverse(),p=-1;++p<c.length;)d[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return d}const H6={resolve:W6,tokenize:V6},B6={partial:!0,tokenize:U6};function W6(e){return CI(e),e}function V6(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?i(l):wt(l)?e.check(B6,a,i)(l):(e.consume(l),s)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function U6(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ln(e,i,"linePrefix")}function i(a){if(a===null||wt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function EI(e,t,n,r,s,i,a,l,c){const d=c||Number.POSITIVE_INFINITY;let f=0;return u;function u(g){return g===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(g),e.exit(i),p):g===null||g===32||g===41||kb(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(g))}function p(g){return g===62?(e.enter(i),e.consume(g),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||wt(g)?n(g):(e.consume(g),g===92?y:m)}function y(g){return g===60||g===62||g===92?(e.consume(g),m):m(g)}function b(g){return!f&&(g===null||g===41||Ds(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):f<d&&g===40?(e.consume(g),f++,b):g===41?(e.consume(g),f--,b):g===null||g===32||g===40||kb(g)?n(g):(e.consume(g),g===92?k:b)}function k(g){return g===40||g===41||g===92?(e.consume(g),b):b(g)}}function _I(e,t,n,r,s,i){const a=this;let l=0,c;return d;function d(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(i),f}function f(m){return l>999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(i),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):wt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||wt(m)||l++>999?(e.exit("chunkString"),f(m)):(e.consume(m),c||(c=!rn(m)),m===92?p:u)}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,u):u(m)}}function PI(e,t,n,r,s,i){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(i),d(p))}function d(p){return p===a?(e.exit(i),c(a)):p===null?n(p):wt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Ln(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||wt(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?u:f)}function u(p){return p===a||p===92?(e.consume(p),f):f(p)}}function mf(e,t){let n;return r;function r(s){return wt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):rn(s)?Ln(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const K6={name:"definition",tokenize:Y6},q6={partial:!0,tokenize:G6};function Y6(e,t,n){const r=this;let s;return i;function i(m){return e.enter("definition"),a(m)}function a(m){return _I.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=wu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return Ds(m)?mf(e,d)(m):d(m)}function d(m){return EI(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(q6,u,u)(m)}function u(m){return rn(m)?Ln(e,p,"whitespace")(m):p(m)}function p(m){return m===null||wt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function G6(e,t,n){return r;function r(l){return Ds(l)?mf(e,s)(l):n(l)}function s(l){return PI(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return rn(l)?Ln(e,a,"whitespace")(l):a(l)}function a(l){return l===null||wt(l)?t(l):n(l)}}const X6={name:"hardBreakEscape",tokenize:J6};function J6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return wt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Q6={name:"headingAtx",resolve:Z6,tokenize:e8};function Z6(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},To(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function e8(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Ds(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||wt(f)?(e.exit("atxHeading"),t(f)):rn(f)?Ln(e,l,"whitespace")(f):(e.enter("atxHeadingText"),d(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),l(f))}function d(f){return f===null||f===35||Ds(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),d)}}const t8=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],QN=["pre","script","style","textarea"],n8={concrete:!0,name:"htmlFlow",resolveTo:i8,tokenize:o8},r8={partial:!0,tokenize:l8},s8={partial:!0,tokenize:a8};function i8(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function o8(e,t,n){const r=this;let s,i,a,l,c;return d;function d(V){return f(V)}function f(V){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(V),u}function u(V){return V===33?(e.consume(V),p):V===47?(e.consume(V),i=!0,b):V===63?(e.consume(V),s=3,r.interrupt?t:E):So(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function p(V){return V===45?(e.consume(V),s=2,m):V===91?(e.consume(V),s=5,l=0,y):So(V)?(e.consume(V),s=4,r.interrupt?t:E):n(V)}function m(V){return V===45?(e.consume(V),r.interrupt?t:E):n(V)}function y(V){const ie="CDATA[";return V===ie.charCodeAt(l++)?(e.consume(V),l===ie.length?r.interrupt?t:$:y):n(V)}function b(V){return So(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function k(V){if(V===null||V===47||V===62||Ds(V)){const ie=V===47,fe=a.toLowerCase();return!ie&&!i&&QN.includes(fe)?(s=1,r.interrupt?t(V):$(V)):t8.includes(a.toLowerCase())?(s=6,ie?(e.consume(V),g):r.interrupt?t(V):$(V)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(V):i?v(V):x(V))}return V===45||ti(V)?(e.consume(V),a+=String.fromCharCode(V),k):n(V)}function g(V){return V===62?(e.consume(V),r.interrupt?t:$):n(V)}function v(V){return rn(V)?(e.consume(V),v):F(V)}function x(V){return V===47?(e.consume(V),F):V===58||V===95||So(V)?(e.consume(V),N):rn(V)?(e.consume(V),x):F(V)}function N(V){return V===45||V===46||V===58||V===95||ti(V)?(e.consume(V),N):_(V)}function _(V){return V===61?(e.consume(V),C):rn(V)?(e.consume(V),_):x(V)}function C(V){return V===null||V===60||V===61||V===62||V===96?n(V):V===34||V===39?(e.consume(V),c=V,T):rn(V)?(e.consume(V),C):H(V)}function T(V){return V===c?(e.consume(V),c=null,M):V===null||wt(V)?n(V):(e.consume(V),T)}function H(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||Ds(V)?_(V):(e.consume(V),H)}function M(V){return V===47||V===62||rn(V)?x(V):n(V)}function F(V){return V===62?(e.consume(V),D):n(V)}function D(V){return V===null||wt(V)?$(V):rn(V)?(e.consume(V),D):n(V)}function $(V){return V===45&&s===2?(e.consume(V),I):V===60&&s===1?(e.consume(V),z):V===62&&s===4?(e.consume(V),X):V===63&&s===3?(e.consume(V),E):V===93&&s===5?(e.consume(V),L):wt(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(r8,ee,W)(V)):V===null||wt(V)?(e.exit("htmlFlowData"),W(V)):(e.consume(V),$)}function W(V){return e.check(s8,O,ee)(V)}function O(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),R}function R(V){return V===null||wt(V)?W(V):(e.enter("htmlFlowData"),$(V))}function I(V){return V===45?(e.consume(V),E):$(V)}function z(V){return V===47?(e.consume(V),a="",P):$(V)}function P(V){if(V===62){const ie=a.toLowerCase();return QN.includes(ie)?(e.consume(V),X):$(V)}return So(V)&&a.length<8?(e.consume(V),a+=String.fromCharCode(V),P):$(V)}function L(V){return V===93?(e.consume(V),E):$(V)}function E(V){return V===62?(e.consume(V),X):V===45&&s===2?(e.consume(V),E):$(V)}function X(V){return V===null||wt(V)?(e.exit("htmlFlowData"),ee(V)):(e.consume(V),X)}function ee(V){return e.exit("htmlFlow"),t(V)}}function a8(e,t,n){const r=this;return s;function s(a){return wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function l8(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(oy,t,n)}}const c8={name:"htmlText",tokenize:u8};function u8(e,t,n){const r=this;let s,i,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),d):E===47?(e.consume(E),_):E===63?(e.consume(E),x):So(E)?(e.consume(E),H):n(E)}function d(E){return E===45?(e.consume(E),f):E===91?(e.consume(E),i=0,y):So(E)?(e.consume(E),v):n(E)}function f(E){return E===45?(e.consume(E),m):n(E)}function u(E){return E===null?n(E):E===45?(e.consume(E),p):wt(E)?(a=u,z(E)):(e.consume(E),u)}function p(E){return E===45?(e.consume(E),m):u(E)}function m(E){return E===62?I(E):E===45?p(E):u(E)}function y(E){const X="CDATA[";return E===X.charCodeAt(i++)?(e.consume(E),i===X.length?b:y):n(E)}function b(E){return E===null?n(E):E===93?(e.consume(E),k):wt(E)?(a=b,z(E)):(e.consume(E),b)}function k(E){return E===93?(e.consume(E),g):b(E)}function g(E){return E===62?I(E):E===93?(e.consume(E),g):b(E)}function v(E){return E===null||E===62?I(E):wt(E)?(a=v,z(E)):(e.consume(E),v)}function x(E){return E===null?n(E):E===63?(e.consume(E),N):wt(E)?(a=x,z(E)):(e.consume(E),x)}function N(E){return E===62?I(E):x(E)}function _(E){return So(E)?(e.consume(E),C):n(E)}function C(E){return E===45||ti(E)?(e.consume(E),C):T(E)}function T(E){return wt(E)?(a=T,z(E)):rn(E)?(e.consume(E),T):I(E)}function H(E){return E===45||ti(E)?(e.consume(E),H):E===47||E===62||Ds(E)?M(E):n(E)}function M(E){return E===47?(e.consume(E),I):E===58||E===95||So(E)?(e.consume(E),F):wt(E)?(a=M,z(E)):rn(E)?(e.consume(E),M):I(E)}function F(E){return E===45||E===46||E===58||E===95||ti(E)?(e.consume(E),F):D(E)}function D(E){return E===61?(e.consume(E),$):wt(E)?(a=D,z(E)):rn(E)?(e.consume(E),D):M(E)}function $(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,W):wt(E)?(a=$,z(E)):rn(E)?(e.consume(E),$):(e.consume(E),O)}function W(E){return E===s?(e.consume(E),s=void 0,R):E===null?n(E):wt(E)?(a=W,z(E)):(e.consume(E),W)}function O(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Ds(E)?M(E):(e.consume(E),O)}function R(E){return E===47||E===62||Ds(E)?M(E):n(E)}function I(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function z(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),P}function P(E){return rn(E)?Ln(e,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):L(E)}function L(E){return e.enter("htmlTextData"),a(E)}}const v0={name:"labelEnd",resolveAll:h8,resolveTo:m8,tokenize:g8},d8={tokenize:y8},f8={tokenize:x8},p8={tokenize:w8};function h8(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&To(e,0,e.length,n),e}function m8(e,t){let n=e.length,r=0,s,i,a,l;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=Ni(l,e.slice(i+1,i+r+3)),l=Ni(l,[["enter",f,t]]),l=Ni(l,b0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Ni(l,[["exit",f,t],e[a-2],e[a-1],["exit",d,t]]),l=Ni(l,e.slice(a+1)),l=Ni(l,[["exit",c,t]]),To(e,i,e.length,l),e}function g8(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return l;function l(p){return i?i._inactive?u(p):(a=r.parser.defined.includes(wu(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(d8,f,a?f:u)(p):p===91?e.attempt(f8,f,a?d:u)(p):a?f(p):u(p)}function d(p){return e.attempt(p8,f,u)(p)}function f(p){return t(p)}function u(p){return i._balanced=!0,n(p)}}function y8(e,t,n){return r;function r(u){return e.enter("resource"),e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),s}function s(u){return Ds(u)?mf(e,i)(u):i(u)}function i(u){return u===41?f(u):EI(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return Ds(u)?mf(e,c)(u):f(u)}function l(u){return n(u)}function c(u){return u===34||u===39||u===40?PI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):f(u)}function d(u){return Ds(u)?mf(e,f)(u):f(u)}function f(u){return u===41?(e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),e.exit("resource"),t):n(u)}}function x8(e,t,n){const r=this;return s;function s(l){return _I.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(wu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function w8(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const b8={name:"labelStartImage",resolveAll:v0.resolveAll,tokenize:v8};function v8(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const k8={name:"labelStartLink",resolveAll:v0.resolveAll,tokenize:S8};function S8(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const kx={name:"lineEnding",tokenize:N8};function N8(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ln(e,t,"linePrefix")}}const pm={name:"thematicBreak",tokenize:j8};function j8(e,t,n){let r=0,s;return i;function i(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),c(d)):r>=3&&(d===null||wt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),rn(d)?Ln(e,l,"whitespace")(d):l(d))}}const Es={continuation:{tokenize:P8},exit:I8,name:"list",tokenize:_8},C8={partial:!0,tokenize:T8},E8={partial:!0,tokenize:A8};function _8(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:Sb(m)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(pm,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return Sb(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(oy,r.interrupt?n:f,e.attempt(C8,p,u))}function f(m){return r.containerState.initialBlankLine=!0,i++,p(m)}function u(m){return rn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function P8(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(oy,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ln(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!rn(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(E8,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ln(e,e.attempt(Es,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function A8(e,t,n){const r=this;return Ln(e,s,"listItemIndent",r.containerState.size+1);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function I8(e){e.exit(this.containerState.type)}function T8(e,t,n){const r=this;return Ln(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!rn(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const ZN={name:"setextUnderline",resolveTo:R8,tokenize:L8};function R8(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function L8(e,t,n){const r=this;let s;return i;function i(d){let f=r.events.length,u;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){u=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||u)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===s?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),rn(d)?Ln(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||wt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const M8={tokenize:O8};function O8(e){const t=this,n=e.attempt(oy,r,e.attempt(this.parser.constructs.flowInitial,s,Ln(e,e.attempt(this.parser.constructs.flow,s,e.attempt(H6,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const $8={resolveAll:II()},D8=AI("string"),F8=AI("text");function AI(e){return{resolveAll:II(e==="text"?z8:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,l);return a;function a(f){return d(f)?i(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return d(f)?(n.exit("data"),i(f)):(n.consume(f),c)}function d(f){if(f===null)return!0;const u=s[f];let p=-1;if(u)for(;++p<u.length;){const m=u[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function II(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function z8(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let i=s.length,a=-1,l=0,c;for(;i--;){const d=s[i];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)c=!0,l++;else if(d!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const H8={42:Es,43:Es,45:Es,48:Es,49:Es,50:Es,51:Es,52:Es,53:Es,54:Es,55:Es,56:Es,57:Es,62:SI},B8={91:K6},W8={[-2]:vx,[-1]:vx,32:vx},V8={35:Q6,42:pm,45:[ZN,pm],60:n8,61:ZN,95:pm,96:JN,126:JN},U8={38:jI,92:NI},K8={[-5]:kx,[-4]:kx,[-3]:kx,33:b8,38:jI,42:Nb,60:[k6,c8],91:k8,92:[X6,NI],93:v0,95:Nb,96:M6},q8={null:[Nb,$8]},Y8={null:[42,95]},G8={null:[]},X8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Y8,contentInitial:B8,disable:G8,document:H8,flow:V8,flowInitial:W8,insideSpan:q8,string:U8,text:K8},Symbol.toStringTag,{value:"Module"}));function J8(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let a=[],l=[];const c={attempt:T(_),check:T(C),consume:v,enter:x,exit:N,interrupt:T(C,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:y,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:u};let f=t.tokenize.call(d,c);return t.resolveAll&&i.push(t),d;function u(D){return a=Ni(a,D),k(),a[a.length-1]!==null?[]:(H(t,0),d.events=b0(i,d.events,d),d.events)}function p(D,$){return Z8(m(D),$)}function m(D){return Q8(a,D)}function y(){const{_bufferIndex:D,_index:$,line:W,column:O,offset:R}=r;return{_bufferIndex:D,_index:$,line:W,column:O,offset:R}}function b(D){s[D.line]=D.column,F()}function k(){let D;for(;r._index<a.length;){const $=a[r._index];if(typeof $=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<$.length;)g($.charCodeAt(r._bufferIndex));else g($)}}function g(D){f=f(D)}function v(D){wt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,F()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=D}function x(D,$){const W=$||{};return W.type=D,W.start=y(),d.events.push(["enter",W,d]),l.push(W),W}function N(D){const $=l.pop();return $.end=y(),d.events.push(["exit",$,d]),$}function _(D,$){H(D,$.from)}function C(D,$){$.restore()}function T(D,$){return W;function W(O,R,I){let z,P,L,E;return Array.isArray(O)?ee(O):"tokenize"in O?ee([O]):X(O);function X(me){return ge;function ge(Z){const ae=Z!==null&&me[Z],xe=Z!==null&&me.null,pe=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(xe)?xe:xe?[xe]:[]];return ee(pe)(Z)}}function ee(me){return z=me,P=0,me.length===0?I:V(me[P])}function V(me){return ge;function ge(Z){return E=M(),L=me,me.partial||(d.currentConstruct=me),me.name&&d.parser.constructs.disable.null.includes(me.name)?fe():me.tokenize.call($?Object.assign(Object.create(d),$):d,c,ie,fe)(Z)}}function ie(me){return D(L,E),R}function fe(me){return E.restore(),++P<z.length?V(z[P]):I}}}function H(D,$){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&To(d.events,$,d.events.length-$,D.resolve(d.events.slice($),d)),D.resolveTo&&(d.events=D.resolveTo(d.events,d))}function M(){const D=y(),$=d.previous,W=d.currentConstruct,O=d.events.length,R=Array.from(l);return{from:O,restore:I};function I(){r=D,d.previous=$,d.currentConstruct=W,d.events.length=O,l=R,F()}}function F(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function Q8(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function Z8(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
65
+ `)),f=d.reduce((u,p)=>u.concat(...p),[]);return[d,f]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??mN,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var k,g;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&sA(m))return!1;const b=yN(m.code,l);if(i.current.add(m[b]),gN(a,i.current,!1)){const v=((g=(k=m.composedPath)==null?void 0:k.call(m))==null?void 0:g[0])||m.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&m.preventDefault(),r(!0)}},u=m=>{const y=yN(m.code,l);gN(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(m[y]),m.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function gN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function yN(e,t){return t.includes(e)?"code":"key"}const Z5=()=>{const e=Hn();return h.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:a,panZoom:l}=e.getState(),c=e0(t,r,s,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,u=n.snapToGrid??i;return xp(d,r,u,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=eg(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function IA(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const c of a)eH(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function eH(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function tg(e,t){return IA(e,t)}function a0(e,t){return IA(e,t)}function Ul(e,t){return{id:e,type:"select",selected:t}}function ou(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(Ul(i.id,a)))}return r}function xN({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function wN(e){return{id:e.id,type:"remove"}}const bN=e=>f3(e),tH=e=>XP(e);function TA(e){return h.forwardRef(e)}function vN(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>nH(()=>n(s=>s+BigInt(1))));return mb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function nH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const RA=h.createContext(null);function rH({children:e}){const t=Hn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:u,nodeLookup:p,fitViewQueued:m,onNodesChangeMiddlewareMap:y}=t.getState();let b=c;for(const g of l)b=typeof g=="function"?g(b):g;let k=xN({items:b,lookup:p});for(const g of y.values())k=g(k);f&&d(b),k.length>0?u==null||u(k):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:v,setNodes:x}=t.getState();g&&x(v)})},[]),r=vN(n),s=h.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:p}=t.getState();let m=c;for(const y of l)m=typeof y=="function"?y(m):y;f?d(m):u&&u(xN({items:m,lookup:p}))},[]),i=vN(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(RA.Provider,{value:a,children:e})}function sH(){const e=h.useContext(RA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const iH=e=>!!e.panZoom;function wc(){const e=Z5(),t=Hn(),n=sH(),r=Vt(iH),s=h.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),a=u=>{n.nodeQueue.push(u)},l=u=>{n.edgeQueue.push(u)},c=u=>{var g,v;const{nodeLookup:p,nodeOrigin:m}=t.getState(),y=bN(u)?u:p.get(u.id),b=y.parentId?nA(y.position,y.measured,y.parentId,p,m):y.position,k={...y,position:b,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((v=y.measured)==null?void 0:v.height)??y.height};return Ru(k)},d=(u,p,m={replace:!1})=>{a(y=>y.map(b=>{if(b.id===u){const k=typeof p=="function"?p(b):p;return m.replace&&bN(k)?k:{...b,...k}}return b}))},f=(u,p,m={replace:!1})=>{l(y=>y.map(b=>{if(b.id===u){const k=typeof p=="function"?p(b):p;return m.replace&&tH(k)?k:{...b,...k}}return b}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var p;return(p=i(u))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(p=>({...p}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:a,setEdges:l,addNodes:u=>{const p=Array.isArray(u)?u:[u];n.nodeQueue.push(m=>[...m,...p])},addEdges:u=>{const p=Array.isArray(u)?u:[u];n.edgeQueue.push(m=>[...m,...p])},toObject:()=>{const{nodes:u=[],edges:p=[],transform:m}=t.getState(),[y,b,k]=m;return{nodes:u.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x:y,y:b,zoom:k}}},deleteElements:async({nodes:u=[],edges:p=[]})=>{const{nodes:m,edges:y,onNodesDelete:b,onEdgesDelete:k,triggerNodeChanges:g,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:N}=t.getState(),{nodes:_,edges:C}=await y3({nodesToRemove:u,edgesToRemove:p,nodes:m,edges:y,onBeforeDelete:N}),T=C.length>0,H=_.length>0;if(T){const M=C.map(wN);k==null||k(C),v(M)}if(H){const M=_.map(wN);b==null||b(_),g(M)}return(H||T)&&(x==null||x({nodes:_,edges:C})),{deletedNodes:_,deletedEdges:C}},getIntersectingNodes:(u,p=!0,m)=>{const y=XS(u),b=y?u:c(u),k=m!==void 0;return b?(m||t.getState().nodes).filter(g=>{const v=t.getState().nodeLookup.get(g.id);if(v&&!y&&(g.id===u.id||!v.internals.positionAbsolute))return!1;const x=Ru(k?g:v),N=Uf(x,b);return p&&N>0||N>=x.width*x.height||N>=b.width*b.height}):[]},isNodeIntersecting:(u,p,m=!0)=>{const b=XS(u)?u:c(u);if(!b)return!1;const k=Uf(b,p);return m&&k>0||k>=p.width*p.height||k>=b.width*b.height},updateNode:d,updateNodeData:(u,p,m={replace:!1})=>{d(u,y=>{const b=typeof p=="function"?p(y):p;return m.replace?{...y,data:b}:{...y,data:{...y.data,...b}}},m)},updateEdge:f,updateEdgeData:(u,p,m={replace:!1})=>{f(u,y=>{const b=typeof p=="function"?p(y):p;return m.replace?{...y,data:b}:{...y,data:{...y.data,...b}}},m)},getNodesBounds:u=>{const{nodeLookup:p,nodeOrigin:m}=t.getState();return p3(u,{nodeLookup:p,nodeOrigin:m})},getHandleConnections:({type:u,id:p,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${u}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:u,handleId:p,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${u?p?`-${u}-${p}`:`-${u}`:""}`))==null?void 0:y.values())??[])},fitView:async u=>{const p=t.getState().fitViewResolver??v3();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:p}),n.nodeQueue.push(m=>[...m]),p.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const kN=e=>e.selected,oH=typeof window<"u"?window:void 0;function aH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Hn(),{deleteElements:r}=wc(),s=Yf(e,{actInsideInputWithModifier:!1}),i=Yf(t,{target:oH});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(kN),edges:a.filter(kN)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function lH(e){const t=Hn();h.useEffect(()=>{const n=()=>{var s,i,a,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=t0(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Io.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const ny={position:"absolute",width:"100%",height:"100%",top:0,left:0},cH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function uH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=nc.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:u,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:b,noPanClassName:k,onViewportChange:g,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:N}){const _=Hn(),C=h.useRef(null),{userSelectionActive:T,lib:H,connectionInProgress:M}=Vt(cH,Yn),F=Yf(p),D=h.useRef();lH(C);const $=h.useCallback(W=>{g==null||g({x:W[0],y:W[1],zoom:W[2]}),v||_.setState({transform:W})},[g,v]);return h.useEffect(()=>{if(C.current){D.current=r5({domNode:C.current,minZoom:f,maxZoom:u,translateExtent:d,viewport:c,onDraggingChange:I=>_.setState(z=>z.paneDragging===I?z:{paneDragging:I}),onPanZoomStart:(I,z)=>{const{onViewportChangeStart:P,onMoveStart:L}=_.getState();L==null||L(I,z),P==null||P(z)},onPanZoom:(I,z)=>{const{onViewportChange:P,onMove:L}=_.getState();L==null||L(I,z),P==null||P(z)},onPanZoomEnd:(I,z)=>{const{onViewportChangeEnd:P,onMoveEnd:L}=_.getState();L==null||L(I,z),P==null||P(z)}});const{x:W,y:O,zoom:R}=D.current.getViewport();return _.setState({panZoom:D.current,transform:[W,O,R],domNode:C.current.closest(".react-flow")}),()=>{var I;(I=D.current)==null||I.destroy()}}},[]),h.useEffect(()=>{var W;(W=D.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:m,noPanClassName:k,userSelectionActive:T,noWheelClassName:b,lib:H,onTransformChange:$,connectionInProgress:M,selectionOnDrag:N,paneClickDistance:x})},[e,t,n,r,s,i,a,l,F,m,k,T,b,H,$,M,N,x]),o.jsx("div",{className:"react-flow__renderer",ref:C,style:ny,children:y})}const dH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function fH(){const{userSelectionActive:e,userSelectionRect:t}=Vt(dH,Yn);return e&&t?o.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const yx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},pH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function hH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Vf.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:m,children:y}){const b=Hn(),{userSelectionActive:k,elementsSelectable:g,dragging:v,connectionInProgress:x}=Vt(pH,Yn),N=g&&(e||k),_=h.useRef(null),C=h.useRef(),T=h.useRef(new Set),H=h.useRef(new Set),M=h.useRef(!1),F=P=>{if(M.current||x){M.current=!1;return}c==null||c(P),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},D=P=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){P.preventDefault();return}d==null||d(P)},$=f?P=>f(P):void 0,W=P=>{M.current&&(P.stopPropagation(),M.current=!1)},O=P=>{var fe,me;const{domNode:L}=b.getState();if(C.current=L==null?void 0:L.getBoundingClientRect(),!C.current)return;const E=P.target===_.current;if(!E&&!!P.target.closest(".nokey")||!e||!(i&&E||t)||P.button!==0||!P.isPrimary)return;(me=(fe=P.target)==null?void 0:fe.setPointerCapture)==null||me.call(fe,P.pointerId),M.current=!1;const{x:V,y:ie}=Xi(P.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:ie,x:V,y:ie}}),E||(P.stopPropagation(),P.preventDefault())},R=P=>{const{userSelectionRect:L,transform:E,nodeLookup:X,edgeLookup:ee,connectionLookup:V,triggerNodeChanges:ie,triggerEdgeChanges:fe,defaultEdgeOptions:me,resetSelectedElements:ge}=b.getState();if(!C.current||!L)return;const{x:Z,y:ae}=Xi(P.nativeEvent,C.current),{startX:xe,startY:pe}=L;if(!M.current){const qe=t?0:s;if(Math.hypot(Z-xe,ae-pe)<=qe)return;ge(),a==null||a(P)}M.current=!0;const _e={startX:xe,startY:pe,x:Z<xe?Z:xe,y:ae<pe?ae:pe,width:Math.abs(Z-xe),height:Math.abs(ae-pe)},je=T.current,Ve=H.current;T.current=new Set(Zv(X,_e,E,n===Vf.Partial,!0).map(qe=>qe.id)),H.current=new Set;const et=(me==null?void 0:me.selectable)??!0;for(const qe of T.current){const dt=V.get(qe);if(dt)for(const{edgeId:He}of dt.values()){const bt=ee.get(He);bt&&(bt.selectable??et)&&H.current.add(He)}}if(!JS(je,T.current)){const qe=ou(X,T.current,!0);ie(qe)}if(!JS(Ve,H.current)){const qe=ou(ee,H.current);fe(qe)}b.setState({userSelectionRect:_e,userSelectionActive:!0,nodesSelectionActive:!1})},I=P=>{var L,E;P.button===0&&((E=(L=P.target)==null?void 0:L.releasePointerCapture)==null||E.call(L,P.pointerId),!k&&P.target===_.current&&b.getState().userSelectionRect&&(F==null||F(P)),b.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(l==null||l(P),b.setState({nodesSelectionActive:T.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:br(["react-flow__pane",{draggable:z,dragging:v,selection:e}]),onClick:N?void 0:yx(F,_),onContextMenu:yx(D,_),onWheel:yx($,_),onPointerEnter:N?void 0:u,onPointerMove:N?R:p,onPointerUp:N?I:void 0,onPointerDownCapture:N?O:void 0,onClickCapture:N?W:void 0,onPointerLeave:m,ref:_,style:ny,children:[y,o.jsx(fH,{})]})}function gb({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",Io.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function LA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=Hn(),[c,d]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=W3({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{gb({id:u,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,r,t,i,e,s,a]),c}const mH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function MA(){const e=Hn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),u=new Map,p=mH(a),m=s?i[0]:5,y=s?i[1]:5,b=n.direction.x*m*n.factor,k=n.direction.y*y*n.factor;for(const[,g]of d){if(!p(g))continue;let v={x:g.internals.positionAbsolute.x+b,y:g.internals.positionAbsolute.y+k};s&&(v=yp(v,i));const{position:x,positionAbsolute:N}=JP({nodeId:g.id,nextPosition:v,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});g.position=x,g.internals.positionAbsolute=N,u.set(g.id,g)}c(u)},[])}const l0=h.createContext(null),gH=l0.Provider;l0.Consumer;const OA=()=>h.useContext(l0),yH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),xH=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Iu.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function wH({type:e="source",position:t=Ze.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:u,...p},m){var R,I;const y=a||null,b=e==="target",k=Hn(),g=OA(),{connectOnClick:v,noPanClassName:x,rfId:N}=Vt(yH,Yn),{connectingFrom:_,connectingTo:C,clickConnecting:T,isPossibleEndHandle:H,connectionInProcess:M,clickConnectionInProcess:F,valid:D}=Vt(xH(g,y,e),Yn);g||(I=(R=k.getState()).onError)==null||I.call(R,"010",Io.error010());const $=z=>{const{defaultEdgeOptions:P,onConnect:L,hasDefaultEdges:E}=k.getState(),X={...P,...z};if(E){const{edges:ee,setEdges:V}=k.getState();V(qf(X,ee))}L==null||L(X),l==null||l(X)},W=z=>{if(!g)return;const P=iA(z.nativeEvent);if(s&&(P&&z.button===0||!P)){const L=k.getState();hb.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:b,handleId:y,nodeId:g,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...E)=>{var X,ee;return(ee=(X=k.getState()).onConnectEnd)==null?void 0:ee.call(X,...E)},updateConnection:L.updateConnection,onConnect:$,isValidConnection:n||((...E)=>{var X,ee;return((ee=(X=k.getState()).isValidConnection)==null?void 0:ee.call(X,...E))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}P?f==null||f(z):u==null||u(z)},O=z=>{const{onClickConnectStart:P,onClickConnectEnd:L,connectionClickStartHandle:E,connectionMode:X,isValidConnection:ee,lib:V,rfId:ie,nodeLookup:fe,connection:me}=k.getState();if(!g||!E&&!s)return;if(!E){P==null||P(z.nativeEvent,{nodeId:g,handleId:y,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ge=rA(z.target),Z=n||ee,{connection:ae,isValid:xe}=hb.isValid(z.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:X,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:Z,flowId:ie,doc:ge,lib:V,nodeLookup:fe});xe&&ae&&$(ae);const pe=structuredClone(me);delete pe.inProgress,pe.toPosition=pe.toHandle?pe.toHandle.position:null,L==null||L(z,pe),k.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${N}-${g}-${y}-${e}`,className:br(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:T,connectingfrom:_,connectingto:C,valid:D,connectionindicator:r&&(!M||H)&&(M||F?i:s)}]),onMouseDown:W,onTouchStart:W,onClick:v?O:void 0,ref:m,...p,children:c})}const Fs=h.memo(TA(wH));function bH({data:e,isConnectable:t,sourcePosition:n=Ze.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Fs,{type:"source",position:n,isConnectable:t})]})}function vH({data:e,isConnectable:t,targetPosition:n=Ze.Top,sourcePosition:r=Ze.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Fs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Fs,{type:"source",position:r,isConnectable:t})]})}function kH(){return null}function SH({data:e,isConnectable:t,targetPosition:n=Ze.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Fs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const ng={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},SN={input:bH,default:vH,output:SH,group:kH};function NH(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const jH=e=>{const{width:t,height:n,x:r,y:s}=gp(e.nodeLookup,{filter:i=>!!i.selected});return{width:Gi(t)?t:null,height:Gi(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function CH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Hn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Vt(jH,Yn),c=MA(),d=h.useRef(null);h.useEffect(()=>{var m;n||(m=d.current)==null||m.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&i!==null;if(LA({nodeRef:d,disabled:!f}),!f)return null;const u=e?m=>{const y=r.getState().nodes.filter(b=>b.selected);e(m,y)}:void 0,p=m=>{Object.prototype.hasOwnProperty.call(ng,m.key)&&(m.preventDefault(),c({direction:ng[m.key],factor:m.shiftKey?4:1}))};return o.jsx("div",{className:br(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const NN=typeof window<"u"?window:void 0,EH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function $A({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:u,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:g,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:N,panOnScrollSpeed:_,panOnScrollMode:C,zoomOnDoubleClick:T,panOnDrag:H,defaultViewport:M,translateExtent:F,minZoom:D,maxZoom:$,preventScrolling:W,onSelectionContextMenu:O,noWheelClassName:R,noPanClassName:I,disableKeyboardA11y:z,onViewportChange:P,isControlledViewport:L}){const{nodesSelectionActive:E,userSelectionActive:X}=Vt(EH,Yn),ee=Yf(d,{target:NN}),V=Yf(b,{target:NN}),ie=V||H,fe=V||N,me=f&&ie!==!0,ge=ee||X||me;return aH({deleteKeyCode:c,multiSelectionKeyCode:y}),o.jsx(uH,{onPaneContextMenu:i,elementsSelectable:g,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:fe,panOnScrollSpeed:_,panOnScrollMode:C,zoomOnDoubleClick:T,panOnDrag:!ee&&ie,defaultViewport:M,translateExtent:F,minZoom:D,maxZoom:$,zoomActivationKeyCode:k,preventScrolling:W,noWheelClassName:R,noPanClassName:I,onViewportChange:P,isControlledViewport:L,paneClickDistance:l,selectionOnDrag:me,children:o.jsxs(hH,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:ie,isSelecting:!!ge,selectionMode:u,selectionKeyPressed:ee,paneClickDistance:l,selectionOnDrag:me,children:[e,E&&o.jsx(CH,{onSelectionContextMenu:O,noPanClassName:I,disableKeyboardA11y:z})]})})}$A.displayName="FlowRenderer";const _H=h.memo($A),PH=e=>t=>e?Zv(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function AH(e){return Vt(h.useCallback(PH(e),[e]),Yn)}const IH=e=>e.updateNodeInternals;function TH(){const e=Vt(IH),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function RH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Hn(),i=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),d=h.useRef(t),f=n&&!!e.internals.handleBounds;return h.useEffect(()=>{i.current&&!e.hidden&&(!f||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[f,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(i.current){const u=d.current!==t,p=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(u||p||m)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function LH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:u,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:b,nodeTypes:k,nodeClickDistance:g,onError:v}){const{node:x,internals:N,isParent:_}=Vt(Z=>{const ae=Z.nodeLookup.get(e),xe=Z.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:xe}},Yn);let C=x.type||"default",T=(k==null?void 0:k[C])||SN[C];T===void 0&&(v==null||v("003",Io.error003(C)),C="default",T=(k==null?void 0:k.default)||SN.default);const H=!!(x.draggable||l&&typeof x.draggable>"u"),M=!!(x.selectable||c&&typeof x.selectable>"u"),F=!!(x.connectable||d&&typeof x.connectable>"u"),D=!!(x.focusable||f&&typeof x.focusable>"u"),$=Hn(),W=tA(x),O=RH({node:x,nodeType:C,hasDimensions:W,resizeObserver:u}),R=LA({nodeRef:O,disabled:x.hidden||!H,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:g}),I=MA();if(x.hidden)return null;const z=ga(x),P=NH(x),L=M||H||t||n||r||s,E=n?Z=>n(Z,{...N.userNode}):void 0,X=r?Z=>r(Z,{...N.userNode}):void 0,ee=s?Z=>s(Z,{...N.userNode}):void 0,V=i?Z=>i(Z,{...N.userNode}):void 0,ie=a?Z=>a(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:ae,nodeDragThreshold:xe}=$.getState();M&&(!ae||!H||xe>0)&&gb({id:e,store:$,nodeRef:O}),t&&t(Z,{...N.userNode})},me=Z=>{if(!(sA(Z.nativeEvent)||y)){if(KP.includes(Z.key)&&M){const ae=Z.key==="Escape";gb({id:e,store:$,unselect:ae,nodeRef:O})}else if(H&&x.selected&&Object.prototype.hasOwnProperty.call(ng,Z.key)){Z.preventDefault();const{ariaLabelConfig:ae}=$.getState();$.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),I({direction:ng[Z.key],factor:Z.shiftKey?4:1})}}},ge=()=>{var Ve;if(y||!((Ve=O.current)!=null&&Ve.matches(":focus-visible")))return;const{transform:Z,width:ae,height:xe,autoPanOnNodeFocus:pe,setCenter:_e}=$.getState();if(!pe)return;Zv(new Map([[e,x]]),{x:0,y:0,width:ae,height:xe},Z,!0).length>0||_e(x.position.x+z.width/2,x.position.y+z.height/2,{zoom:Z[2]})};return o.jsx("div",{className:br(["react-flow__node",`react-flow__node-${C}`,{[m]:H},x.className,{selected:x.selected,selectable:M,parent:_,draggable:H,dragging:R}]),ref:O,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:W?"visible":"hidden",...x.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:X,onMouseLeave:ee,onContextMenu:V,onClick:fe,onDoubleClick:ie,onKeyDown:D?me:void 0,tabIndex:D?0:void 0,onFocus:D?ge:void 0,role:x.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${_A}-${b}`,"aria-label":x.ariaLabel,...x.domAttributes,children:o.jsx(gH,{value:e,children:o.jsx(T,{id:e,data:x.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:x.selected??!1,selectable:M,draggable:H,deletable:x.deletable??!0,isConnectable:F,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:R,dragHandle:x.dragHandle,zIndex:N.z,parentId:x.parentId,...z})})})}var MH=h.memo(LH);const OH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function DA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Vt(OH,Yn),a=AH(e.onlyRenderVisibleElements),l=TH();return o.jsx("div",{className:"react-flow__nodes",style:ny,children:a.map(c=>o.jsx(MH,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}DA.displayName="NodeRenderer";const $H=h.memo(DA);function DH(e){return Vt(h.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&j3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Yn)}const FH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},zH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},jN={[$s.Arrow]:FH,[$s.ArrowClosed]:zH};function HH(e){const t=Hn();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(jN,e)?jN[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Io.error009(e)),null)},[e])}const BH=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=HH(t);return c?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:o.jsx(c,{color:n,strokeWidth:a})}):null},FA=({defaultColor:e,rfId:t})=>{const n=Vt(i=>i.edges),r=Vt(i=>i.defaultEdgeOptions),s=h.useMemo(()=>T3(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:s.map(i=>o.jsx(BH,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};FA.displayName="MarkerDefinitions";var WH=h.memo(FA);function zA({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[u,p]=h.useState({x:1,y:0,width:0,height:0}),m=br(["react-flow__edge-textwrapper",d]),y=h.useRef(null);return h.useEffect(()=>{if(y.current){const b=y.current.getBBox();p({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:m,visibility:u.width?"visible":"hidden",...f,children:[s&&o.jsx("rect",{width:u.width+2*a[0],x:-a[0],y:-a[1],height:u.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}zA.displayName="EdgeText";const VH=h.memo(zA);function ry({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...f,d:e,fill:"none",className:br(["react-flow__edge-path",f.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Gi(t)&&Gi(n)?o.jsx(VH,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function CN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ze.Left||e===Ze.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function HA({sourceX:e,sourceY:t,sourcePosition:n=Ze.Bottom,targetX:r,targetY:s,targetPosition:i=Ze.Top}){const[a,l]=CN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=CN({pos:i,x1:r,y1:s,x2:e,y2:t}),[f,u,p,m]=oA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${s}`,f,u,p,m]}function BA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,interactionWidth:g})=>{const[v,x,N]=HA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),_=e.isInternal?void 0:t;return o.jsx(ry,{id:_,path:v,labelX:x,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,interactionWidth:g})})}const UH=BA({isInternal:!1}),WA=BA({isInternal:!0});UH.displayName="SimpleBezierEdge";WA.displayName="SimpleBezierEdgeInternal";function VA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,sourcePosition:m=Ze.Bottom,targetPosition:y=Ze.Top,markerEnd:b,markerStart:k,pathOptions:g,interactionWidth:v})=>{const[x,N,_]=db({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:i,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),C=e.isInternal?void 0:t;return o.jsx(ry,{id:C,path:x,labelX:N,labelY:_,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:b,markerStart:k,interactionWidth:v})})}const UA=VA({isInternal:!1}),KA=VA({isInternal:!0});UA.displayName="SmoothStepEdge";KA.displayName="SmoothStepEdgeInternal";function qA(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(UA,{...n,id:r,pathOptions:h.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const KH=qA({isInternal:!1}),YA=qA({isInternal:!0});KH.displayName="StepEdge";YA.displayName="StepEdgeInternal";function GA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:y,interactionWidth:b})=>{const[k,g,v]=cA({sourceX:n,sourceY:r,targetX:s,targetY:i}),x=e.isInternal?void 0:t;return o.jsx(ry,{id:x,path:k,labelX:g,labelY:v,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:y,interactionWidth:b})})}const qH=GA({isInternal:!1}),XA=GA({isInternal:!0});qH.displayName="StraightEdge";XA.displayName="StraightEdgeInternal";function JA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Ze.Bottom,targetPosition:l=Ze.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,pathOptions:g,interactionWidth:v})=>{const[x,N,_]=aA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:g==null?void 0:g.curvature}),C=e.isInternal?void 0:t;return o.jsx(ry,{id:C,path:x,labelX:N,labelY:_,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:k,interactionWidth:v})})}const YH=JA({isInternal:!1}),QA=JA({isInternal:!0});YH.displayName="BezierEdge";QA.displayName="BezierEdgeInternal";const EN={default:QA,straight:XA,step:YA,smoothstep:KA,simplebezier:WA},_N={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},GH=(e,t,n)=>n===Ze.Left?e-t:n===Ze.Right?e+t:e,XH=(e,t,n)=>n===Ze.Top?e-t:n===Ze.Bottom?e+t:e,PN="react-flow__edgeupdater";function AN({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:l}){return o.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:br([PN,`${PN}-${l}`]),cx:GH(t,r,e),cy:XH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function JH({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:u,setReconnecting:p,setUpdateHover:m}){const y=Hn(),b=(N,_)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:T,connectionMode:H,connectionRadius:M,lib:F,onConnectStart:D,cancelConnection:$,nodeLookup:W,rfId:O,panBy:R,updateConnection:I}=y.getState(),z=_.type==="target",P=(X,ee)=>{p(!1),u==null||u(X,n,_.type,ee)},L=X=>d==null?void 0:d(n,X),E=(X,ee)=>{p(!0),f==null||f(N,n,_.type),D==null||D(X,ee)};hb.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:H,connectionRadius:M,domNode:T,handleId:_.id,nodeId:_.nodeId,nodeLookup:W,isTarget:z,edgeUpdaterType:_.type,lib:F,flowId:O,cancelConnection:$,panBy:R,isValidConnection:(...X)=>{var ee,V;return((V=(ee=y.getState()).isValidConnection)==null?void 0:V.call(ee,...X))??!0},onConnect:L,onConnectStart:E,onConnectEnd:(...X)=>{var ee,V;return(V=(ee=y.getState()).onConnectEnd)==null?void 0:V.call(ee,...X)},onReconnectEnd:P,updateConnection:I,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},k=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>m(!0),x=()=>m(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(AN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:k,onMouseEnter:v,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&o.jsx(AN,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function QH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,rfId:y,edgeTypes:b,noPanClassName:k,onError:g,disableKeyboardA11y:v}){let x=Vt(_e=>_e.edgeLookup.get(e));const N=Vt(_e=>_e.defaultEdgeOptions);x=N?{...N,...x}:x;let _=x.type||"default",C=(b==null?void 0:b[_])||EN[_];C===void 0&&(g==null||g("011",Io.error011(_)),_="default",C=(b==null?void 0:b.default)||EN.default);const T=!!(x.focusable||t&&typeof x.focusable>"u"),H=typeof u<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),M=!!(x.selectable||r&&typeof x.selectable>"u"),F=h.useRef(null),[D,$]=h.useState(!1),[W,O]=h.useState(!1),R=Hn(),{zIndex:I,sourceX:z,sourceY:P,targetX:L,targetY:E,sourcePosition:X,targetPosition:ee}=Vt(h.useCallback(_e=>{const je=_e.nodeLookup.get(x.source),Ve=_e.nodeLookup.get(x.target);if(!je||!Ve)return{zIndex:x.zIndex,..._N};const et=I3({id:e,sourceNode:je,targetNode:Ve,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:_e.connectionMode,onError:g});return{zIndex:N3({selected:x.selected,zIndex:x.zIndex,sourceNode:je,targetNode:Ve,elevateOnSelect:_e.elevateEdgesOnSelect,zIndexMode:_e.zIndexMode}),...et||_N}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Yn),V=h.useMemo(()=>x.markerStart?`url('#${fb(x.markerStart,y)}')`:void 0,[x.markerStart,y]),ie=h.useMemo(()=>x.markerEnd?`url('#${fb(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||z===null||P===null||L===null||E===null)return null;const fe=_e=>{var qe;const{addSelectedEdges:je,unselectNodesAndEdges:Ve,multiSelectionActive:et}=R.getState();M&&(R.setState({nodesSelectionActive:!1}),x.selected&&et?(Ve({nodes:[],edges:[x]}),(qe=F.current)==null||qe.blur()):je([e])),s&&s(_e,x)},me=i?_e=>{i(_e,{...x})}:void 0,ge=a?_e=>{a(_e,{...x})}:void 0,Z=l?_e=>{l(_e,{...x})}:void 0,ae=c?_e=>{c(_e,{...x})}:void 0,xe=d?_e=>{d(_e,{...x})}:void 0,pe=_e=>{var je;if(!v&&KP.includes(_e.key)&&M){const{unselectNodesAndEdges:Ve,addSelectedEdges:et}=R.getState();_e.key==="Escape"?((je=F.current)==null||je.blur(),Ve({edges:[x]})):et([e])}};return o.jsx("svg",{style:{zIndex:I},children:o.jsxs("g",{className:br(["react-flow__edge",`react-flow__edge-${_}`,x.className,k,{selected:x.selected,animated:x.animated,inactive:!M&&!s,updating:D,selectable:M}]),onClick:fe,onDoubleClick:me,onContextMenu:ge,onMouseEnter:Z,onMouseMove:ae,onMouseLeave:xe,onKeyDown:T?pe:void 0,tabIndex:T?0:void 0,role:x.ariaRole??(T?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":T?`${PA}-${y}`:void 0,ref:F,...x.domAttributes,children:[!W&&o.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:M,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:z,sourceY:P,targetX:L,targetY:E,sourcePosition:X,targetPosition:ee,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:V,markerEnd:ie,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),H&&o.jsx(JH,{edge:x,isReconnectable:H,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,sourceX:z,sourceY:P,targetX:L,targetY:E,sourcePosition:X,targetPosition:ee,setUpdateHover:$,setReconnecting:O})]})})}var ZH=h.memo(QH);const eB=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ZA({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:p,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:b}){const{edgesFocusable:k,edgesReconnectable:g,elementsSelectable:v,onError:x}=Vt(eB,Yn),N=DH(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(WH,{defaultColor:e,rfId:n}),N.map(_=>o.jsx(ZH,{id:_,edgesFocusable:k,edgesReconnectable:g,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:u,onDoubleClick:p,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:b},_))]})}ZA.displayName="EdgeRenderer";const tB=h.memo(ZA),nB=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function rB({children:e}){const t=Vt(nB);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function sB(e){const t=wc(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const iB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function oB(e){const t=Vt(iB),n=Hn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function aB(e){return e.connection.inProgress?{...e.connection,to:xp(e.connection.to,e.transform)}:{...e.connection}}function lB(e){return aB}function cB(e){const t=lB();return Vt(t,Yn)}const uB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function dB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Vt(uB,Yn);return!(i&&s&&c)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:br(["react-flow__connection",GP(l)]),children:o.jsx(eI,{style:t,type:n,CustomComponent:r,isValid:l})})})}const eI=({style:e,type:t=Va.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:u,toPosition:p,pointer:m}=cB();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:p,connectionStatus:GP(r),toNode:f,toHandle:u,pointer:m});let y="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case Va.Bezier:[y]=aA(b);break;case Va.SimpleBezier:[y]=HA(b);break;case Va.Step:[y]=db({...b,borderRadius:0});break;case Va.SmoothStep:[y]=db(b);break;default:[y]=cA(b)}return o.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};eI.displayName="ConnectionLine";const fB={};function IN(e=fB){h.useRef(e),Hn(),h.useEffect(()=>{},[e])}function pB(){Hn(),h.useRef(!1),h.useEffect(()=>{},[])}function tI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:p,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:b,connectionLineComponent:k,connectionLineContainerStyle:g,selectionKeyCode:v,selectionOnDrag:x,selectionMode:N,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:T,deleteKeyCode:H,onlyRenderVisibleElements:M,elementsSelectable:F,defaultViewport:D,translateExtent:$,minZoom:W,maxZoom:O,preventScrolling:R,defaultMarkerColor:I,zoomOnScroll:z,zoomOnPinch:P,panOnScroll:L,panOnScrollSpeed:E,panOnScrollMode:X,zoomOnDoubleClick:ee,panOnDrag:V,onPaneClick:ie,onPaneMouseEnter:fe,onPaneMouseMove:me,onPaneMouseLeave:ge,onPaneScroll:Z,onPaneContextMenu:ae,paneClickDistance:xe,nodeClickDistance:pe,onEdgeContextMenu:_e,onEdgeMouseEnter:je,onEdgeMouseMove:Ve,onEdgeMouseLeave:et,reconnectRadius:qe,onReconnect:dt,onReconnectStart:He,onReconnectEnd:bt,noDragClassName:sn,noWheelClassName:on,noPanClassName:an,disableKeyboardA11y:Yt,nodeExtent:En,rfId:hn,viewport:ue,onViewportChange:ke}){return IN(e),IN(t),pB(),sB(n),oB(ue),o.jsx(_H,{onPaneClick:ie,onPaneMouseEnter:fe,onPaneMouseMove:me,onPaneMouseLeave:ge,onPaneContextMenu:ae,onPaneScroll:Z,paneClickDistance:xe,deleteKeyCode:H,selectionKeyCode:v,selectionOnDrag:x,selectionMode:N,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:T,elementsSelectable:F,zoomOnScroll:z,zoomOnPinch:P,zoomOnDoubleClick:ee,panOnScroll:L,panOnScrollSpeed:E,panOnScrollMode:X,panOnDrag:V,defaultViewport:D,translateExtent:$,minZoom:W,maxZoom:O,onSelectionContextMenu:u,preventScrolling:R,noDragClassName:sn,noWheelClassName:on,noPanClassName:an,disableKeyboardA11y:Yt,onViewportChange:ke,isControlledViewport:!!ue,children:o.jsxs(rB,{children:[o.jsx(tB,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:dt,onReconnectStart:He,onReconnectEnd:bt,onlyRenderVisibleElements:M,onEdgeContextMenu:_e,onEdgeMouseEnter:je,onEdgeMouseMove:Ve,onEdgeMouseLeave:et,reconnectRadius:qe,defaultMarkerColor:I,noPanClassName:an,disableKeyboardA11y:Yt,rfId:hn}),o.jsx(dB,{style:b,type:y,component:k,containerStyle:g}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx($H,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:pe,onlyRenderVisibleElements:M,noPanClassName:an,noDragClassName:sn,disableKeyboardA11y:Yt,nodeExtent:En,rfId:hn}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}tI.displayName="GraphView";const hB=h.memo(tI),TN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:u,zIndexMode:p="basic"}={})=>{const m=new Map,y=new Map,b=new Map,k=new Map,g=r??t??[],v=n??e??[],x=f??[0,0],N=u??Wf;fA(b,k,g);const{nodesInitialized:_}=pb(v,m,y,{nodeOrigin:x,nodeExtent:N,zIndexMode:p});let C=[0,0,1];if(a&&s&&i){const T=gp(m,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:H,y:M,zoom:F}=e0(T,s,i,c,d,(l==null?void 0:l.padding)??.1);C=[H,M,F]}return{rfId:"1",width:s??0,height:i??0,transform:C,nodes:v,nodesInitialized:_,nodeLookup:m,parentLookup:y,edges:g,edgeLookup:k,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Wf,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Iu.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...YP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:x3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:qP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},mB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p})=>L5((m,y)=>{async function b(){const{nodeLookup:k,panZoom:g,fitViewOptions:v,fitViewResolver:x,width:N,height:_,minZoom:C,maxZoom:T}=y();g&&(await g3({nodes:k,width:N,height:_,panZoom:g,minZoom:C,maxZoom:T},v),x==null||x.resolve(!0),m({fitViewResolver:null}))}return{...TN({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:k=>{const{nodeLookup:g,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:N,fitViewQueued:_,zIndexMode:C,nodesSelectionActive:T}=y(),{nodesInitialized:H,hasSelectedNodes:M}=pb(k,g,v,{nodeOrigin:x,nodeExtent:u,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),F=T&&M;_&&H?(b(),m({nodes:k,nodesInitialized:H,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):m({nodes:k,nodesInitialized:H,nodesSelectionActive:F})},setEdges:k=>{const{connectionLookup:g,edgeLookup:v}=y();fA(g,v,k),m({edges:k})},setDefaultNodesAndEdges:(k,g)=>{if(k){const{setNodes:v}=y();v(k),m({hasDefaultNodes:!0})}if(g){const{setEdges:v}=y();v(g),m({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:g,nodeLookup:v,parentLookup:x,domNode:N,nodeOrigin:_,nodeExtent:C,debug:T,fitViewQueued:H,zIndexMode:M}=y(),{changes:F,updatedInternals:D}=F3(k,v,x,N,_,C,M);D&&(M3(v,x,{nodeOrigin:_,nodeExtent:C,zIndexMode:M}),H?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(F==null?void 0:F.length)>0&&(T&&console.log("React Flow: trigger node changes",F),g==null||g(F)))},updateNodePositions:(k,g=!1)=>{const v=[];let x=[];const{nodeLookup:N,triggerNodeChanges:_,connection:C,updateConnection:T,onNodesChangeMiddlewareMap:H}=y();for(const[M,F]of k){const D=N.get(M),$=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(F!=null&&F.position)),W={id:M,type:"position",position:$?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:g};if(D&&C.inProgress&&C.fromNode.id===D.id){const O=hc(D,C.fromHandle,Ze.Left,!0);T({...C,from:O})}$&&D.parentId&&v.push({id:M,parentId:D.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),x.push(W)}if(v.length>0){const{parentLookup:M,nodeOrigin:F}=y(),D=o0(v,N,M,F);x.push(...D)}for(const M of H.values())x=M(x);_(x)},triggerNodeChanges:k=>{const{onNodesChange:g,setNodes:v,nodes:x,hasDefaultNodes:N,debug:_}=y();if(k!=null&&k.length){if(N){const C=tg(k,x);v(C)}_&&console.log("React Flow: trigger node changes",k),g==null||g(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:g,setEdges:v,edges:x,hasDefaultEdges:N,debug:_}=y();if(k!=null&&k.length){if(N){const C=a0(k,x);v(C)}_&&console.log("React Flow: trigger edge changes",k),g==null||g(k)}},addSelectedNodes:k=>{const{multiSelectionActive:g,edgeLookup:v,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:_}=y();if(g){const C=k.map(T=>Ul(T,!0));N(C);return}N(ou(x,new Set([...k]),!0)),_(ou(v))},addSelectedEdges:k=>{const{multiSelectionActive:g,edgeLookup:v,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:_}=y();if(g){const C=k.map(T=>Ul(T,!0));_(C);return}_(ou(v,new Set([...k]))),N(ou(x,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:g}={})=>{const{edges:v,nodes:x,nodeLookup:N,triggerNodeChanges:_,triggerEdgeChanges:C}=y(),T=k||x,H=g||v,M=[];for(const D of T){if(!D.selected)continue;const $=N.get(D.id);$&&($.selected=!1),M.push(Ul(D.id,!1))}const F=[];for(const D of H)D.selected&&F.push(Ul(D.id,!1));_(M),C(F)},setMinZoom:k=>{const{panZoom:g,maxZoom:v}=y();g==null||g.setScaleExtent([k,v]),m({minZoom:k})},setMaxZoom:k=>{const{panZoom:g,minZoom:v}=y();g==null||g.setScaleExtent([v,k]),m({maxZoom:k})},setTranslateExtent:k=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(k),m({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:g,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:N}=y();if(!N)return;const _=g.reduce((T,H)=>H.selected?[...T,Ul(H.id,!1)]:T,[]),C=k.reduce((T,H)=>H.selected?[...T,Ul(H.id,!1)]:T,[]);v(_),x(C)},setNodeExtent:k=>{const{nodes:g,nodeLookup:v,parentLookup:x,nodeOrigin:N,elevateNodesOnSelect:_,nodeExtent:C,zIndexMode:T}=y();k[0][0]===C[0][0]&&k[0][1]===C[0][1]&&k[1][0]===C[1][0]&&k[1][1]===C[1][1]||(pb(g,v,x,{nodeOrigin:N,nodeExtent:k,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:T}),m({nodeExtent:k}))},panBy:k=>{const{transform:g,width:v,height:x,panZoom:N,translateExtent:_}=y();return z3({delta:k,panZoom:N,transform:g,translateExtent:_,width:v,height:x})},setCenter:async(k,g,v)=>{const{width:x,height:N,maxZoom:_,panZoom:C}=y();if(!C)return Promise.resolve(!1);const T=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:_;return await C.setViewport({x:x/2-k*T,y:N/2-g*T,zoom:T},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...YP}})},updateConnection:k=>{m({connection:k})},reset:()=>m({...TN()})}},Object.is);function sy({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p,children:m}){const[y]=h.useState(()=>mB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:u,zIndexMode:p}));return o.jsx(M5,{value:y,children:o.jsx(rH,{children:m})})}function gB({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m}){return h.useContext(ty)?o.jsx(o.Fragment,{children:e}):o.jsx(sy,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m,children:e})}const yB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function xB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:u,onMoveEnd:p,onConnect:m,onConnectStart:y,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:g,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:_,onNodeDoubleClick:C,onNodeDragStart:T,onNodeDrag:H,onNodeDragStop:M,onNodesDelete:F,onEdgesDelete:D,onDelete:$,onSelectionChange:W,onSelectionDragStart:O,onSelectionDrag:R,onSelectionDragStop:I,onSelectionContextMenu:z,onSelectionStart:P,onSelectionEnd:L,onBeforeDelete:E,connectionMode:X,connectionLineType:ee=Va.Bezier,connectionLineStyle:V,connectionLineComponent:ie,connectionLineContainerStyle:fe,deleteKeyCode:me="Backspace",selectionKeyCode:ge="Shift",selectionOnDrag:Z=!1,selectionMode:ae=Vf.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:pe=Kf()?"Meta":"Control",zoomActivationKeyCode:_e=Kf()?"Meta":"Control",snapToGrid:je,snapGrid:Ve,onlyRenderVisibleElements:et=!1,selectNodesOnDrag:qe,nodesDraggable:dt,autoPanOnNodeFocus:He,nodesConnectable:bt,nodesFocusable:sn,nodeOrigin:on=AA,edgesFocusable:an,edgesReconnectable:Yt,elementsSelectable:En=!0,defaultViewport:hn=Y5,minZoom:ue=.5,maxZoom:ke=2,translateExtent:De=Wf,preventScrolling:rt=!0,nodeExtent:at,defaultMarkerColor:Lt="#b1b1b7",zoomOnScroll:st=!0,zoomOnPinch:mn=!0,panOnScroll:Zt=!1,panOnScrollSpeed:ar=.5,panOnScrollMode:_n=nc.Free,zoomOnDoubleClick:gn=!0,panOnDrag:bn=!0,onPaneClick:lr,onPaneMouseEnter:ve,onPaneMouseMove:$e,onPaneMouseLeave:nt,onPaneScroll:zt,onPaneContextMenu:oe,paneClickDistance:Te=1,nodeClickDistance:Ue=0,children:Ht,onReconnect:yn,onReconnectStart:cr,onReconnectEnd:Hs,onEdgeContextMenu:as,onEdgeDoubleClick:hr,onEdgeMouseEnter:Zn,onEdgeMouseMove:Vr,onEdgeMouseLeave:ot,reconnectRadius:Ur=10,onNodesChange:Ai,onEdgesChange:xa,noDragClassName:xs="nodrag",noWheelClassName:Ie="nowheel",noPanClassName:cn="nopan",fitView:mr,fitViewOptions:ht,connectOnClick:Oe,attributionPosition:Kr,proOptions:Gn,defaultEdgeOptions:qr,elevateNodesOnSelect:Cr=!0,elevateEdgesOnSelect:ut=!1,disableKeyboardA11y:Ut=!1,autoPanOnConnect:un,autoPanOnNodeDrag:Er,autoPanSpeed:tt,connectionRadius:gr,isValidConnection:Bs,onError:wa,style:ws,id:Oo,nodeDragThreshold:vr,connectionDragThreshold:$o,viewport:Ii,onViewportChange:xn,width:er,height:bs,colorMode:Yr="light",debug:li,onScroll:Ws,ariaLabelConfig:K,zIndexMode:we="basic",...Le},Me){const Ke=Oo||"1",en=Q5(Yr),Mt=h.useCallback(wn=>{wn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ws==null||Ws(wn)},[Ws]);return o.jsx("div",{"data-testid":"rf__wrapper",...Le,onScroll:Mt,style:{...ws,...yB},ref:Me,className:br(["react-flow",s,en]),id:Oo,role:"application",children:o.jsxs(gB,{nodes:e,edges:t,width:er,height:bs,fitView:mr,fitViewOptions:ht,minZoom:ue,maxZoom:ke,nodeOrigin:on,nodeExtent:at,zIndexMode:we,children:[o.jsx(J5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:y,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:g,nodesDraggable:dt,autoPanOnNodeFocus:He,nodesConnectable:bt,nodesFocusable:sn,edgesFocusable:an,edgesReconnectable:Yt,elementsSelectable:En,elevateNodesOnSelect:Cr,elevateEdgesOnSelect:ut,minZoom:ue,maxZoom:ke,nodeExtent:at,onNodesChange:Ai,onEdgesChange:xa,snapToGrid:je,snapGrid:Ve,connectionMode:X,translateExtent:De,connectOnClick:Oe,defaultEdgeOptions:qr,fitView:mr,fitViewOptions:ht,onNodesDelete:F,onEdgesDelete:D,onDelete:$,onNodeDragStart:T,onNodeDrag:H,onNodeDragStop:M,onSelectionDrag:R,onSelectionDragStart:O,onSelectionDragStop:I,onMove:f,onMoveStart:u,onMoveEnd:p,noPanClassName:cn,nodeOrigin:on,rfId:Ke,autoPanOnConnect:un,autoPanOnNodeDrag:Er,autoPanSpeed:tt,onError:wa,connectionRadius:gr,isValidConnection:Bs,selectNodesOnDrag:qe,nodeDragThreshold:vr,connectionDragThreshold:$o,onBeforeDelete:E,debug:li,ariaLabelConfig:K,zIndexMode:we}),o.jsx(hB,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:_,onNodeDoubleClick:C,nodeTypes:i,edgeTypes:a,connectionLineType:ee,connectionLineStyle:V,connectionLineComponent:ie,connectionLineContainerStyle:fe,selectionKeyCode:ge,selectionOnDrag:Z,selectionMode:ae,deleteKeyCode:me,multiSelectionKeyCode:pe,panActivationKeyCode:xe,zoomActivationKeyCode:_e,onlyRenderVisibleElements:et,defaultViewport:hn,translateExtent:De,minZoom:ue,maxZoom:ke,preventScrolling:rt,zoomOnScroll:st,zoomOnPinch:mn,zoomOnDoubleClick:gn,panOnScroll:Zt,panOnScrollSpeed:ar,panOnScrollMode:_n,panOnDrag:bn,onPaneClick:lr,onPaneMouseEnter:ve,onPaneMouseMove:$e,onPaneMouseLeave:nt,onPaneScroll:zt,onPaneContextMenu:oe,paneClickDistance:Te,nodeClickDistance:Ue,onSelectionContextMenu:z,onSelectionStart:P,onSelectionEnd:L,onReconnect:yn,onReconnectStart:cr,onReconnectEnd:Hs,onEdgeContextMenu:as,onEdgeDoubleClick:hr,onEdgeMouseEnter:Zn,onEdgeMouseMove:Vr,onEdgeMouseLeave:ot,reconnectRadius:Ur,defaultMarkerColor:Lt,noDragClassName:xs,noWheelClassName:Ie,noPanClassName:cn,rfId:Ke,disableKeyboardA11y:Ut,nodeExtent:at,viewport:Ii,onViewportChange:xn}),o.jsx(q5,{onSelectionChange:W}),Ht,o.jsx(B5,{proOptions:Gn,position:Kr}),o.jsx(H5,{rfId:Ke,disableKeyboardA11y:Ut})]})})}var c0=TA(xB);function u0(){const e=Hn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],i=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&i.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function nI(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>tg(s,i)),[]);return[t,n,r]}function rI(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>a0(s,i)),[]);return[t,n,r]}function wB({dimensions:e,lineWidth:t,variant:n,className:r}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:br(["react-flow__background-pattern",n,r])})}function bB({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:br(["react-flow__background-pattern","dots",t])})}var sl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(sl||(sl={}));const vB={[sl.Dots]:1,[sl.Lines]:1,[sl.Cross]:6},kB=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function sI({id:e,variant:t=sl.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:d,patternClassName:f}){const u=h.useRef(null),{transform:p,patternId:m}=Vt(kB,Yn),y=r||vB[t],b=t===sl.Dots,k=t===sl.Cross,g=Array.isArray(n)?n:[n,n],v=[g[0]*p[2]||1,g[1]*p[2]||1],x=y*p[2],N=Array.isArray(i)?i:[i,i],_=k?[x,x]:v,C=[N[0]*p[2]||1+_[0]/2,N[1]*p[2]||1+_[1]/2],T=`${m}${e||""}`;return o.jsxs("svg",{className:br(["react-flow__background",d]),style:{...c,...ny,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:u,"data-testid":"rf__background",children:[o.jsx("pattern",{id:T,x:p[0]%v[0],y:p[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:b?o.jsx(bB,{radius:x/2,className:f}):o.jsx(wB,{dimensions:_,lineWidth:s,variant:t,className:f})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${T})`})]})}sI.displayName="Background";const d0=h.memo(sI);function SB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function NB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function jB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function CB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function EB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Th({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:br(["react-flow__controls-button",t]),...n,children:e})}const _B=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function iI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:f,position:u="bottom-left",orientation:p="vertical","aria-label":m}){const y=Hn(),{isInteractive:b,minZoomReached:k,maxZoomReached:g,ariaLabelConfig:v}=Vt(_B,Yn),{zoomIn:x,zoomOut:N,fitView:_}=wc(),C=()=>{x(),i==null||i()},T=()=>{N(),a==null||a()},H=()=>{_(s),l==null||l()},M=()=>{y.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},F=p==="horizontal"?"horizontal":"vertical";return o.jsxs($u,{className:br(["react-flow__controls",F,d]),position:u,style:e,"data-testid":"rf__controls","aria-label":m??v["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(Th,{onClick:C,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:g,children:o.jsx(SB,{})}),o.jsx(Th,{onClick:T,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:k,children:o.jsx(NB,{})})]}),n&&o.jsx(Th,{className:"react-flow__controls-fitview",onClick:H,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:o.jsx(jB,{})}),r&&o.jsx(Th,{className:"react-flow__controls-interactive",onClick:M,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:b?o.jsx(EB,{}):o.jsx(CB,{})}),f]})}iI.displayName="Controls";const PB=h.memo(iI);function AB({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:u,selected:p,onClick:m}){const{background:y,backgroundColor:b}=i||{},k=a||y||b;return o.jsx("rect",{className:br(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:k,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?g=>m(g,e):void 0})}const IB=h.memo(AB),TB=e=>e.nodes.map(t=>t.id),xx=e=>e instanceof Function?e:()=>e;function RB({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=IB,onClick:a}){const l=Vt(TB,Yn),c=xx(t),d=xx(e),f=xx(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(MB,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:u},p))})}function LB({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:f,y:u,width:p,height:m}=Vt(y=>{const b=y.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const k=b.internals.userNode,{x:g,y:v}=b.internals.positionAbsolute,{width:x,height:N}=ga(k);return{node:k,x:g,y:v,width:x,height:N}},Yn);return!d||d.hidden||!tA(d)?null:o.jsx(l,{x:f,y:u,width:p,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:c,id:d.id})}const MB=h.memo(LB);var OB=h.memo(RB);const $B=200,DB=150,FB=e=>!e.hidden,zB=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?eA(gp(e.nodeLookup,{filter:FB}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},HB="react-flow__minimap-desc";function oI({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:u,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:b=!1,zoomable:k=!1,ariaLabel:g,inversePan:v,zoomStep:x=1,offsetScale:N=5}){const _=Hn(),C=h.useRef(null),{boundingRect:T,viewBB:H,rfId:M,panZoom:F,translateExtent:D,flowWidth:$,flowHeight:W,ariaLabelConfig:O}=Vt(zB,Yn),R=(e==null?void 0:e.width)??$B,I=(e==null?void 0:e.height)??DB,z=T.width/R,P=T.height/I,L=Math.max(z,P),E=L*R,X=L*I,ee=N*L,V=T.x-(E-T.width)/2-ee,ie=T.y-(X-T.height)/2-ee,fe=E+ee*2,me=X+ee*2,ge=`${HB}-${M}`,Z=h.useRef(0),ae=h.useRef();Z.current=L,h.useEffect(()=>{if(C.current&&F)return ae.current=G3({domNode:C.current,panZoom:F,getTransform:()=>_.getState().transform,getViewScale:()=>Z.current}),()=>{var je;(je=ae.current)==null||je.destroy()}},[F]),h.useEffect(()=>{var je;(je=ae.current)==null||je.update({translateExtent:D,width:$,height:W,inversePan:v,pannable:b,zoomStep:x,zoomable:k})},[b,k,v,x,D,$,W]);const xe=m?je=>{var qe;const[Ve,et]=((qe=ae.current)==null?void 0:qe.pointer(je))||[0,0];m(je,{x:Ve,y:et})}:void 0,pe=y?h.useCallback((je,Ve)=>{const et=_.getState().nodeLookup.get(Ve).internals.userNode;y(je,et)},[]):void 0,_e=g??O["minimap.ariaLabel"];return o.jsx($u,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*L:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:br(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:R,height:I,viewBox:`${V} ${ie} ${fe} ${me}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ge,ref:C,onClick:xe,children:[_e&&o.jsx("title",{id:ge,children:_e}),o.jsx(OB,{onClick:pe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-ee},${ie-ee}h${fe+ee*2}v${me+ee*2}h${-fe-ee*2}z
66
+ M${H.x},${H.y}h${H.width}v${H.height}h${-H.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}oI.displayName="MiniMap";const BB=h.memo(oI),WB=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,VB={[Mu.Line]:"right",[Mu.Handle]:"bottom-right"};function UB({nodeId:e,position:t,variant:n=Mu.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:p,autoScale:m=!0,shouldResize:y,onResizeStart:b,onResize:k,onResizeEnd:g}){const v=OA(),x=typeof e=="string"?e:v,N=Hn(),_=h.useRef(null),C=n===Mu.Handle,T=Vt(h.useCallback(WB(C&&m),[C,m]),Yn),H=h.useRef(null),M=t??VB[n];h.useEffect(()=>{if(!(!_.current||!x))return H.current||(H.current=c5({domNode:_.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:D,transform:$,snapGrid:W,snapToGrid:O,nodeOrigin:R,domNode:I}=N.getState();return{nodeLookup:D,transform:$,snapGrid:W,snapToGrid:O,nodeOrigin:R,paneDomNode:I}},onChange:(D,$)=>{const{triggerNodeChanges:W,nodeLookup:O,parentLookup:R,nodeOrigin:I}=N.getState(),z=[],P={x:D.x,y:D.y},L=O.get(x);if(L&&L.expandParent&&L.parentId){const E=L.origin??I,X=D.width??L.measured.width??0,ee=D.height??L.measured.height??0,V={id:L.id,parentId:L.parentId,rect:{width:X,height:ee,...nA({x:D.x??L.position.x,y:D.y??L.position.y},{width:X,height:ee},L.parentId,O,E)}},ie=o0([V],O,R,I);z.push(...ie),P.x=D.x?Math.max(E[0]*X,D.x):void 0,P.y=D.y?Math.max(E[1]*ee,D.y):void 0}if(P.x!==void 0&&P.y!==void 0){const E={id:x,type:"position",position:{...P}};z.push(E)}if(D.width!==void 0&&D.height!==void 0){const X={id:x,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};z.push(X)}for(const E of $){const X={...E,type:"position"};z.push(X)}W(z)},onEnd:({width:D,height:$})=>{const W={id:x,type:"dimensions",resizing:!1,dimensions:{width:D,height:$}};N.getState().triggerNodeChanges([W])}})),H.current.update({controlPosition:M,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:p,onResizeStart:b,onResize:k,onResizeEnd:g,shouldResize:y}),()=>{var D;(D=H.current)==null||D.destroy()}},[M,l,c,d,f,u,b,k,g,y]);const F=M.split("-");return o.jsx("div",{className:br(["react-flow__resize-control","nodrag",...F,n,r]),ref:_,style:{...s,scale:T,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:i})}const aI=h.memo(UB);function KB(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const qB=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YB=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GB={};function RN(e,t){return(GB.jsx?YB:qB).test(e)}const XB=/[ \t\n\f\r]/g;function JB(e){return typeof e=="object"?e.type==="text"?LN(e.value):!1:LN(e)}function LN(e){return e.replace(XB,"")===""}let wp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};wp.prototype.normal={};wp.prototype.property={};wp.prototype.space=void 0;function lI(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new wp(n,r,t)}function yb(e){return e.toLowerCase()}class zs{constructor(t,n){this.attribute=n,this.property=t}}zs.prototype.attribute="";zs.prototype.booleanish=!1;zs.prototype.boolean=!1;zs.prototype.commaOrSpaceSeparated=!1;zs.prototype.commaSeparated=!1;zs.prototype.defined=!1;zs.prototype.mustUseProperty=!1;zs.prototype.number=!1;zs.prototype.overloadedBoolean=!1;zs.prototype.property="";zs.prototype.spaceSeparated=!1;zs.prototype.space=void 0;let QB=0;const Pt=bc(),yr=bc(),xb=bc(),Ae=bc(),Tn=bc(),xu=bc(),Xs=bc();function bc(){return 2**++QB}const wb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Pt,booleanish:yr,commaOrSpaceSeparated:Xs,commaSeparated:xu,number:Ae,overloadedBoolean:xb,spaceSeparated:Tn},Symbol.toStringTag,{value:"Module"})),wx=Object.keys(wb);class f0 extends zs{constructor(t,n,r,s){let i=-1;if(super(t,n),MN(this,"space",s),typeof r=="number")for(;++i<wx.length;){const a=wx[i];MN(this,wx[i],(r&wb[a])===wb[a])}}}f0.prototype.defined=!0;function MN(e,t,n){n&&(e[t]=n)}function Yu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new f0(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[yb(r)]=r,n[yb(i.attribute)]=r}return new wp(t,n,e.space)}const cI=Yu({properties:{ariaActiveDescendant:null,ariaAtomic:yr,ariaAutoComplete:null,ariaBusy:yr,ariaChecked:yr,ariaColCount:Ae,ariaColIndex:Ae,ariaColSpan:Ae,ariaControls:Tn,ariaCurrent:null,ariaDescribedBy:Tn,ariaDetails:null,ariaDisabled:yr,ariaDropEffect:Tn,ariaErrorMessage:null,ariaExpanded:yr,ariaFlowTo:Tn,ariaGrabbed:yr,ariaHasPopup:null,ariaHidden:yr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Tn,ariaLevel:Ae,ariaLive:null,ariaModal:yr,ariaMultiLine:yr,ariaMultiSelectable:yr,ariaOrientation:null,ariaOwns:Tn,ariaPlaceholder:null,ariaPosInSet:Ae,ariaPressed:yr,ariaReadOnly:yr,ariaRelevant:null,ariaRequired:yr,ariaRoleDescription:Tn,ariaRowCount:Ae,ariaRowIndex:Ae,ariaRowSpan:Ae,ariaSelected:yr,ariaSetSize:Ae,ariaSort:null,ariaValueMax:Ae,ariaValueMin:Ae,ariaValueNow:Ae,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function uI(e,t){return t in e?e[t]:t}function dI(e,t){return uI(e,t.toLowerCase())}const ZB=Yu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xu,acceptCharset:Tn,accessKey:Tn,action:null,allow:null,allowFullScreen:Pt,allowPaymentRequest:Pt,allowUserMedia:Pt,alt:null,as:null,async:Pt,autoCapitalize:null,autoComplete:Tn,autoFocus:Pt,autoPlay:Pt,blocking:Tn,capture:null,charSet:null,checked:Pt,cite:null,className:Tn,cols:Ae,colSpan:null,content:null,contentEditable:yr,controls:Pt,controlsList:Tn,coords:Ae|xu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Pt,defer:Pt,dir:null,dirName:null,disabled:Pt,download:xb,draggable:yr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Pt,formTarget:null,headers:Tn,height:Ae,hidden:xb,high:Ae,href:null,hrefLang:null,htmlFor:Tn,httpEquiv:Tn,id:null,imageSizes:null,imageSrcSet:null,inert:Pt,inputMode:null,integrity:null,is:null,isMap:Pt,itemId:null,itemProp:Tn,itemRef:Tn,itemScope:Pt,itemType:Tn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Pt,low:Ae,manifest:null,max:null,maxLength:Ae,media:null,method:null,min:null,minLength:Ae,multiple:Pt,muted:Pt,name:null,nonce:null,noModule:Pt,noValidate:Pt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Pt,optimum:Ae,pattern:null,ping:Tn,placeholder:null,playsInline:Pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Pt,referrerPolicy:null,rel:Tn,required:Pt,reversed:Pt,rows:Ae,rowSpan:Ae,sandbox:Tn,scope:null,scoped:Pt,seamless:Pt,selected:Pt,shadowRootClonable:Pt,shadowRootDelegatesFocus:Pt,shadowRootMode:null,shape:null,size:Ae,sizes:null,slot:null,span:Ae,spellCheck:yr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ae,step:null,style:null,tabIndex:Ae,target:null,title:null,translate:null,type:null,typeMustMatch:Pt,useMap:null,value:yr,width:Ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Tn,axis:null,background:null,bgColor:null,border:Ae,borderColor:null,bottomMargin:Ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Pt,declare:Pt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ae,leftMargin:Ae,link:null,longDesc:null,lowSrc:null,marginHeight:Ae,marginWidth:Ae,noResize:Pt,noHref:Pt,noShade:Pt,noWrap:Pt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ae,rules:null,scheme:null,scrolling:yr,standby:null,summary:null,text:null,topMargin:Ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ae,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Pt,disableRemotePlayback:Pt,prefix:null,property:null,results:Ae,security:null,unselectable:null},space:"html",transform:dI}),e4=Yu({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xs,accentHeight:Ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ae,amplitude:Ae,arabicForm:null,ascent:Ae,attributeName:null,attributeType:null,azimuth:Ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ae,by:null,calcMode:null,capHeight:Ae,className:Tn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ae,diffuseConstant:Ae,direction:null,display:null,dur:null,divisor:Ae,dominantBaseline:null,download:Pt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ae,enableBackground:null,end:null,event:null,exponent:Ae,externalResourcesRequired:null,fill:null,fillOpacity:Ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xu,g2:xu,glyphName:xu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ae,horizOriginX:Ae,horizOriginY:Ae,id:null,ideographic:Ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ae,k:Ae,k1:Ae,k2:Ae,k3:Ae,k4:Ae,kernelMatrix:Xs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ae,overlineThickness:Ae,paintOrder:null,panose1:null,path:null,pathLength:Ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Tn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ae,pointsAtY:Ae,pointsAtZ:Ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xs,rev:Xs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xs,requiredFeatures:Xs,requiredFonts:Xs,requiredFormats:Xs,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ae,specularExponent:Ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ae,strikethroughThickness:Ae,string:null,stroke:null,strokeDashArray:Xs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ae,strokeOpacity:Ae,strokeWidth:null,style:null,surfaceScale:Ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xs,tabIndex:Ae,tableValues:null,target:null,targetX:Ae,targetY:Ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ae,underlineThickness:Ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ae,values:null,vAlphabetic:Ae,vMathematical:Ae,vectorEffect:null,vHanging:Ae,vIdeographic:Ae,version:null,vertAdvY:Ae,vertOriginX:Ae,vertOriginY:Ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:uI}),fI=Yu({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),pI=Yu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:dI}),hI=Yu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),t4={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},n4=/[A-Z]/g,ON=/-[a-z]/g,r4=/^data[-\w.:]+$/i;function s4(e,t){const n=yb(t);let r=t,s=zs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&r4.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(ON,o4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!ON.test(i)){let a=i.replace(n4,i4);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=f0}return new s(r,t)}function i4(e){return"-"+e.toLowerCase()}function o4(e){return e.charAt(1).toUpperCase()}const a4=lI([cI,ZB,fI,pI,hI],"html"),p0=lI([cI,e4,fI,pI,hI],"svg");function l4(e){return e.join(" ").trim()}var h0={},$N=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,c4=/\n/g,u4=/^\s*/,d4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,f4=/^:\s*/,p4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,h4=/^[;\s]*/,m4=/^\s+|\s+$/g,g4=`
67
+ `,DN="/",FN="*",ql="",y4="comment",x4="declaration";function w4(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(y){var b=y.match(c4);b&&(n+=b.length);var k=y.lastIndexOf(g4);r=~k?y.length-k:r+y.length}function i(){var y={line:n,column:r};return function(b){return b.position=new a(y),d(),b}}function a(y){this.start=y,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(y){var b=new Error(t.source+":"+n+":"+r+": "+y);if(b.reason=y,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(y){var b=y.exec(e);if(b){var k=b[0];return s(k),e=e.slice(k.length),b}}function d(){c(u4)}function f(y){var b;for(y=y||[];b=u();)b!==!1&&y.push(b);return y}function u(){var y=i();if(!(DN!=e.charAt(0)||FN!=e.charAt(1))){for(var b=2;ql!=e.charAt(b)&&(FN!=e.charAt(b)||DN!=e.charAt(b+1));)++b;if(b+=2,ql===e.charAt(b-1))return l("End of comment missing");var k=e.slice(2,b-2);return r+=2,s(k),e=e.slice(b),r+=2,y({type:y4,comment:k})}}function p(){var y=i(),b=c(d4);if(b){if(u(),!c(f4))return l("property missing ':'");var k=c(p4),g=y({type:x4,property:zN(b[0].replace($N,ql)),value:k?zN(k[0].replace($N,ql)):ql});return c(h4),g}}function m(){var y=[];f(y);for(var b;b=p();)b!==!1&&(y.push(b),f(y));return y}return d(),m()}function zN(e){return e?e.replace(m4,ql):ql}var b4=w4,v4=bf&&bf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(h0,"__esModule",{value:!0});h0.default=S4;const k4=v4(b4);function S4(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,k4.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:l}=i;s?t(a,l,i):l&&(n=n||{},n[a]=l)}),n}var iy={};Object.defineProperty(iy,"__esModule",{value:!0});iy.camelCase=void 0;var N4=/^--[a-zA-Z0-9_-]+$/,j4=/-([a-z])/g,C4=/^[^-]+$/,E4=/^-(webkit|moz|ms|o|khtml)-/,_4=/^-(ms)-/,P4=function(e){return!e||C4.test(e)||N4.test(e)},A4=function(e,t){return t.toUpperCase()},HN=function(e,t){return"".concat(t,"-")},I4=function(e,t){return t===void 0&&(t={}),P4(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(_4,HN):e=e.replace(E4,HN),e.replace(j4,A4))};iy.camelCase=I4;var T4=bf&&bf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},R4=T4(h0),L4=iy;function bb(e,t){var n={};return!e||typeof e!="string"||(0,R4.default)(e,function(r,s){r&&s&&(n[(0,L4.camelCase)(r,t)]=s)}),n}bb.default=bb;var M4=bb;const O4=hl(M4),mI=gI("end"),m0=gI("start");function gI(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function $4(e){const t=m0(e),n=mI(e);if(t&&n)return{start:t,end:n}}function hf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?BN(e.position):"start"in e||"end"in e?BN(e):"line"in e||"column"in e?vb(e):""}function vb(e){return WN(e&&e.line)+":"+WN(e&&e.column)}function BN(e){return vb(e&&e.start)+"-"+vb(e&&e.end)}function WN(e){return e&&typeof e=="number"?e:1}class is extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=hf(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}is.prototype.file="";is.prototype.name="";is.prototype.reason="";is.prototype.message="";is.prototype.stack="";is.prototype.column=void 0;is.prototype.line=void 0;is.prototype.ancestors=void 0;is.prototype.cause=void 0;is.prototype.fatal=void 0;is.prototype.place=void 0;is.prototype.ruleId=void 0;is.prototype.source=void 0;const g0={}.hasOwnProperty,D4=new Map,F4=/[A-Z]/g,z4=new Set(["table","tbody","thead","tfoot","tr"]),H4=new Set(["td","th"]),yI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function B4(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=X4(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=G4(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?p0:a4,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=xI(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function xI(e,t,n){if(t.type==="element")return W4(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return V4(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return K4(e,t,n);if(t.type==="mdxjsEsm")return U4(e,t);if(t.type==="root")return q4(e,t,n);if(t.type==="text")return Y4(e,t)}function W4(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=p0,e.schema=s),e.ancestors.push(t);const i=bI(e,t.tagName,!1),a=J4(e,t);let l=x0(e,t);return z4.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!JB(c):!0})),wI(e,a,i,t),y0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function V4(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Gf(e,t.position)}function U4(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Gf(e,t.position)}function K4(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=p0,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:bI(e,t.name,!0),a=Q4(e,t),l=x0(e,t);return wI(e,a,i,t),y0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function q4(e,t,n){const r={};return y0(r,x0(e,t)),e.create(t,e.Fragment,r,n)}function Y4(e,t){return t.value}function wI(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function y0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function G4(e,t,n){return r;function r(s,i,a,l){const d=Array.isArray(a.children)?n:t;return l?d(i,a,l):d(i,a)}}function X4(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=m0(r);return t(s,i,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function J4(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&g0.call(t.properties,s)){const i=Z4(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&H4.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Q4(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Gf(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else Gf(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function x0(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:D4;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const d=s.get(c)||0;a=c+"-"+d,s.set(c,d+1)}}const l=xI(e,i,a);l!==void 0&&n.push(l)}return n}function Z4(e,t,n){const r=s4(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?KB(n):l4(n)),r.property==="style"){let s=typeof n=="object"?n:e6(e,String(n));return e.stylePropertyNameCase==="css"&&(s=t6(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?t4[r.property]||r.property:r.attribute,n]}}function e6(e,t){try{return O4(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new is("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=yI+"#cannot-parse-style-attribute",s}}function bI(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const l=RN(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=RN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return g0.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Gf(e)}function Gf(e,t){const n=new is("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=yI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function t6(e){const t={};let n;for(n in e)g0.call(e,n)&&(t[n6(n)]=e[n]);return t}function n6(e){let t=e.replace(F4,r6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function r6(e){return"-"+e.toLowerCase()}const bx={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},s6={};function i6(e,t){const n=s6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return vI(e,r,s)}function vI(e,t,n){if(o6(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return VN(e.children,t,n)}return Array.isArray(e)?VN(e,t,n):""}function VN(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=vI(e[s],t,n);return r.join("")}function o6(e){return!!(e&&typeof e=="object")}const UN=document.createElement("i");function w0(e){const t="&"+e+";";UN.innerHTML=t;const n=UN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function To(e,t,n,r){const s=e.length;let i=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function Ni(e,t){return e.length>0?(To(e,e.length,0,t),e):t}const KN={}.hasOwnProperty;function a6(e){const t={};let n=-1;for(;++n<e.length;)l6(t,e[n]);return t}function l6(e,t){let n;for(n in t){const s=(KN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){KN.call(s,a)||(s[a]=[]);const l=i[a];c6(s[a],Array.isArray(l)?l:l?[l]:[])}}}function c6(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);To(e,0,0,r)}function kI(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function wu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const So=xl(/[A-Za-z]/),ti=xl(/[\dA-Za-z]/),u6=xl(/[#-'*+\--9=?A-Z^-~]/);function kb(e){return e!==null&&(e<32||e===127)}const Sb=xl(/\d/),d6=xl(/[\dA-Fa-f]/),f6=xl(/[!-/:-@[-`{-~]/);function wt(e){return e!==null&&e<-2}function Ds(e){return e!==null&&(e<0||e===32)}function rn(e){return e===-2||e===-1||e===32}const p6=xl(new RegExp("\\p{P}|\\p{S}","u")),h6=xl(/\s/);function xl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gu(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&ti(e.charCodeAt(n+1))&&ti(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),s=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Ln(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return rn(c)?(e.enter(n),l(c)):t(c)}function l(c){return rn(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const m6={tokenize:g6};function g6(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Ln(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return wt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const y6={tokenize:x6},qN={tokenize:w6};function x6(e){const t=this,n=[];let r=0,s,i,a;return l;function l(x){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,c,d)(x)}return d(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const N=t.events.length;let _=N,C;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){C=t.events[_][1].end;break}g(r);let T=N;for(;T<t.events.length;)t.events[T][1].end={...C},T++;return To(t.events,_+1,0,t.events.slice(N)),t.events.length=T,d(x)}return l(x)}function d(x){if(r===n.length){if(!s)return p(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(qN,f,u)(x)}function f(x){return s&&v(),g(r),p(x)}function u(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function p(x){return t.containerState={},e.attempt(qN,m,y)(x)}function m(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function y(x){if(x===null){s&&v(),g(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),b(x)}function b(x){if(x===null){k(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return wt(x)?(e.consume(x),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),b)}function k(x,N){const _=t.sliceStream(x);if(N&&_.push(null),x.previous=i,i&&(i.next=x),i=x,s.defineSkip(x.start),s.write(_),t.parser.lazy[x.start.line]){let C=s.events.length;for(;C--;)if(s.events[C][1].start.offset<a&&(!s.events[C][1].end||s.events[C][1].end.offset>a))return;const T=t.events.length;let H=T,M,F;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(M){F=t.events[H][1].end;break}M=!0}for(g(r),C=T;C<t.events.length;)t.events[C][1].end={...F},C++;To(t.events,H+1,0,t.events.slice(T)),t.events.length=C}}function g(x){let N=n.length;for(;N-- >x;){const _=n[N];t.containerState=_[1],_[0].exit.call(t,e)}n.length=x}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function w6(e,t,n){return Ln(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function YN(e){if(e===null||Ds(e)||h6(e))return 1;if(p6(e))return 2}function b0(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const Nb={name:"attention",resolveAll:b6,tokenize:v6};function b6(e,t){let n=-1,r,s,i,a,l,c,d,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const u={...e[r][1].end},p={...e[n][1].start};GN(u,-c),GN(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Ni(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Ni(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=Ni(d,b0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Ni(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,d=Ni(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,To(e,r-1,n-r+3,d),n=r+d.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function v6(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=YN(r);let i;return a;function a(c){return i=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===i)return e.consume(c),l;const d=e.exit("attentionSequence"),f=YN(c),u=!f||f===2&&s||n.includes(c),p=!s||s===2&&f||n.includes(r);return d._open=!!(i===42?u:u&&(s||!p)),d._close=!!(i===42?p:p&&(f||!u)),t(c)}}function GN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const k6={name:"autolink",tokenize:S6};function S6(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(m){return So(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||ti(m)?(r=1,l(m)):d(m)}function l(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||ti(m))&&r++<32?(e.consume(m),l):(r=0,d(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||kb(m)?n(m):(e.consume(m),c)}function d(m){return m===64?(e.consume(m),f):u6(m)?(e.consume(m),d):n(m)}function f(m){return ti(m)?u(m):n(m)}function u(m){return m===46?(e.consume(m),r=0,f):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||ti(m))&&r++<63){const y=m===45?p:u;return e.consume(m),y}return n(m)}}const oy={partial:!0,tokenize:N6};function N6(e,t,n){return r;function r(i){return rn(i)?Ln(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||wt(i)?t(i):n(i)}}const SI={continuation:{tokenize:C6},exit:E6,name:"blockQuote",tokenize:j6};function j6(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return rn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function C6(e,t,n){const r=this;return s;function s(a){return rn(a)?Ln(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(SI,t,n)(a)}}function E6(e){e.exit("blockQuote")}const NI={name:"characterEscape",tokenize:_6};function _6(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return f6(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const jI={name:"characterReference",tokenize:P6};function P6(e,t,n){const r=this;let s=0,i,a;return l;function l(u){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),c}function c(u){return u===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(u),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=ti,f(u))}function d(u){return u===88||u===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(u),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=d6,f):(e.enter("characterReferenceValue"),i=7,a=Sb,f(u))}function f(u){if(u===59&&s){const p=e.exit("characterReferenceValue");return a===ti&&!w0(r.sliceSerialize(p))?n(u):(e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(u)&&s++<i?(e.consume(u),f):n(u)}}const XN={partial:!0,tokenize:I6},JN={concrete:!0,name:"codeFenced",tokenize:A6};function A6(e,t,n){const r=this,s={partial:!0,tokenize:_};let i=0,a=0,l;return c;function c(C){return d(C)}function d(C){const T=r.events[r.events.length-1];return i=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(C)}function f(C){return C===l?(a++,e.consume(C),f):a<3?n(C):(e.exit("codeFencedFenceSequence"),rn(C)?Ln(e,u,"whitespace")(C):u(C))}function u(C){return C===null||wt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(XN,b,N)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u(C)):rn(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ln(e,m,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function m(C){return C===null||wt(C)?u(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),u(C)):C===96&&C===l?n(C):(e.consume(C),y)}function b(C){return e.attempt(s,N,k)(C)}function k(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return i>0&&rn(C)?Ln(e,v,"linePrefix",i+1)(C):v(C)}function v(C){return C===null||wt(C)?e.check(XN,b,N)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||wt(C)?(e.exit("codeFlowValue"),v(C)):(e.consume(C),x)}function N(C){return e.exit("codeFenced"),t(C)}function _(C,T,H){let M=0;return F;function F(R){return C.enter("lineEnding"),C.consume(R),C.exit("lineEnding"),D}function D(R){return C.enter("codeFencedFence"),rn(R)?Ln(C,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):$(R)}function $(R){return R===l?(C.enter("codeFencedFenceSequence"),W(R)):H(R)}function W(R){return R===l?(M++,C.consume(R),W):M>=a?(C.exit("codeFencedFenceSequence"),rn(R)?Ln(C,O,"whitespace")(R):O(R)):H(R)}function O(R){return R===null||wt(R)?(C.exit("codeFencedFence"),T(R)):H(R)}}}function I6(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const vx={name:"codeIndented",tokenize:R6},T6={partial:!0,tokenize:L6};function R6(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),Ln(e,i,"linePrefix",5)(d)}function i(d){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):wt(d)?e.attempt(T6,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||wt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function L6(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):Ln(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):wt(a)?s(a):n(a)}}const M6={name:"codeText",previous:$6,resolve:O6,tokenize:D6};function O6(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function $6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function D6(e,t,n){let r=0,s,i;return a;function a(u){return e.enter("codeText"),e.enter("codeTextSequence"),l(u)}function l(u){return u===96?(e.consume(u),r++,l):(e.exit("codeTextSequence"),c(u))}function c(u){return u===null?n(u):u===32?(e.enter("space"),e.consume(u),e.exit("space"),c):u===96?(i=e.enter("codeTextSequence"),s=0,f(u)):wt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("codeTextData"),d(u))}function d(u){return u===null||u===32||u===96||wt(u)?(e.exit("codeTextData"),c(u)):(e.consume(u),d)}function f(u){return u===96?(e.consume(u),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(u)):(i.type="codeTextData",d(u))}}class F6{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&$d(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),$d(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),$d(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);$d(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);$d(this.left,n.reverse())}}}function $d(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function CI(e){const t={};let n=-1,r,s,i,a,l,c,d;const f=new F6(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,z6(f,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=f.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(f.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...f.get(s)[1].start},l=f.slice(s,n),l.unshift(r),f.splice(s,n-s+1,l))}}return To(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function z6(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],d={};let f,u,p=-1,m=n,y=0,b=0;const k=[b];for(;m;){for(;e.get(++s)[1]!==m;);i.push(s),m._tokenizer||(f=r.sliceStream(m),m.next||f.push(null),u&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(b=p+1,k.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):k.pop(),p=k.length;p--;){const g=l.slice(k[p],k[p+1]),v=i.pop();c.push([v,v+g.length-1]),e.splice(v,2,g)}for(c.reverse(),p=-1;++p<c.length;)d[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return d}const H6={resolve:W6,tokenize:V6},B6={partial:!0,tokenize:U6};function W6(e){return CI(e),e}function V6(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?i(l):wt(l)?e.check(B6,a,i)(l):(e.consume(l),s)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function U6(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ln(e,i,"linePrefix")}function i(a){if(a===null||wt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function EI(e,t,n,r,s,i,a,l,c){const d=c||Number.POSITIVE_INFINITY;let f=0;return u;function u(g){return g===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(g),e.exit(i),p):g===null||g===32||g===41||kb(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(g))}function p(g){return g===62?(e.enter(i),e.consume(g),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||wt(g)?n(g):(e.consume(g),g===92?y:m)}function y(g){return g===60||g===62||g===92?(e.consume(g),m):m(g)}function b(g){return!f&&(g===null||g===41||Ds(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):f<d&&g===40?(e.consume(g),f++,b):g===41?(e.consume(g),f--,b):g===null||g===32||g===40||kb(g)?n(g):(e.consume(g),g===92?k:b)}function k(g){return g===40||g===41||g===92?(e.consume(g),b):b(g)}}function _I(e,t,n,r,s,i){const a=this;let l=0,c;return d;function d(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(i),f}function f(m){return l>999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(i),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):wt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||wt(m)||l++>999?(e.exit("chunkString"),f(m)):(e.consume(m),c||(c=!rn(m)),m===92?p:u)}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,u):u(m)}}function PI(e,t,n,r,s,i){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(i),d(p))}function d(p){return p===a?(e.exit(i),c(a)):p===null?n(p):wt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Ln(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||wt(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?u:f)}function u(p){return p===a||p===92?(e.consume(p),f):f(p)}}function mf(e,t){let n;return r;function r(s){return wt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):rn(s)?Ln(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const K6={name:"definition",tokenize:Y6},q6={partial:!0,tokenize:G6};function Y6(e,t,n){const r=this;let s;return i;function i(m){return e.enter("definition"),a(m)}function a(m){return _I.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=wu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return Ds(m)?mf(e,d)(m):d(m)}function d(m){return EI(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(q6,u,u)(m)}function u(m){return rn(m)?Ln(e,p,"whitespace")(m):p(m)}function p(m){return m===null||wt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function G6(e,t,n){return r;function r(l){return Ds(l)?mf(e,s)(l):n(l)}function s(l){return PI(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return rn(l)?Ln(e,a,"whitespace")(l):a(l)}function a(l){return l===null||wt(l)?t(l):n(l)}}const X6={name:"hardBreakEscape",tokenize:J6};function J6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return wt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Q6={name:"headingAtx",resolve:Z6,tokenize:e8};function Z6(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},To(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function e8(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Ds(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||wt(f)?(e.exit("atxHeading"),t(f)):rn(f)?Ln(e,l,"whitespace")(f):(e.enter("atxHeadingText"),d(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),l(f))}function d(f){return f===null||f===35||Ds(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),d)}}const t8=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],QN=["pre","script","style","textarea"],n8={concrete:!0,name:"htmlFlow",resolveTo:i8,tokenize:o8},r8={partial:!0,tokenize:l8},s8={partial:!0,tokenize:a8};function i8(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function o8(e,t,n){const r=this;let s,i,a,l,c;return d;function d(V){return f(V)}function f(V){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(V),u}function u(V){return V===33?(e.consume(V),p):V===47?(e.consume(V),i=!0,b):V===63?(e.consume(V),s=3,r.interrupt?t:E):So(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function p(V){return V===45?(e.consume(V),s=2,m):V===91?(e.consume(V),s=5,l=0,y):So(V)?(e.consume(V),s=4,r.interrupt?t:E):n(V)}function m(V){return V===45?(e.consume(V),r.interrupt?t:E):n(V)}function y(V){const ie="CDATA[";return V===ie.charCodeAt(l++)?(e.consume(V),l===ie.length?r.interrupt?t:$:y):n(V)}function b(V){return So(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function k(V){if(V===null||V===47||V===62||Ds(V)){const ie=V===47,fe=a.toLowerCase();return!ie&&!i&&QN.includes(fe)?(s=1,r.interrupt?t(V):$(V)):t8.includes(a.toLowerCase())?(s=6,ie?(e.consume(V),g):r.interrupt?t(V):$(V)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(V):i?v(V):x(V))}return V===45||ti(V)?(e.consume(V),a+=String.fromCharCode(V),k):n(V)}function g(V){return V===62?(e.consume(V),r.interrupt?t:$):n(V)}function v(V){return rn(V)?(e.consume(V),v):F(V)}function x(V){return V===47?(e.consume(V),F):V===58||V===95||So(V)?(e.consume(V),N):rn(V)?(e.consume(V),x):F(V)}function N(V){return V===45||V===46||V===58||V===95||ti(V)?(e.consume(V),N):_(V)}function _(V){return V===61?(e.consume(V),C):rn(V)?(e.consume(V),_):x(V)}function C(V){return V===null||V===60||V===61||V===62||V===96?n(V):V===34||V===39?(e.consume(V),c=V,T):rn(V)?(e.consume(V),C):H(V)}function T(V){return V===c?(e.consume(V),c=null,M):V===null||wt(V)?n(V):(e.consume(V),T)}function H(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||Ds(V)?_(V):(e.consume(V),H)}function M(V){return V===47||V===62||rn(V)?x(V):n(V)}function F(V){return V===62?(e.consume(V),D):n(V)}function D(V){return V===null||wt(V)?$(V):rn(V)?(e.consume(V),D):n(V)}function $(V){return V===45&&s===2?(e.consume(V),I):V===60&&s===1?(e.consume(V),z):V===62&&s===4?(e.consume(V),X):V===63&&s===3?(e.consume(V),E):V===93&&s===5?(e.consume(V),L):wt(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(r8,ee,W)(V)):V===null||wt(V)?(e.exit("htmlFlowData"),W(V)):(e.consume(V),$)}function W(V){return e.check(s8,O,ee)(V)}function O(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),R}function R(V){return V===null||wt(V)?W(V):(e.enter("htmlFlowData"),$(V))}function I(V){return V===45?(e.consume(V),E):$(V)}function z(V){return V===47?(e.consume(V),a="",P):$(V)}function P(V){if(V===62){const ie=a.toLowerCase();return QN.includes(ie)?(e.consume(V),X):$(V)}return So(V)&&a.length<8?(e.consume(V),a+=String.fromCharCode(V),P):$(V)}function L(V){return V===93?(e.consume(V),E):$(V)}function E(V){return V===62?(e.consume(V),X):V===45&&s===2?(e.consume(V),E):$(V)}function X(V){return V===null||wt(V)?(e.exit("htmlFlowData"),ee(V)):(e.consume(V),X)}function ee(V){return e.exit("htmlFlow"),t(V)}}function a8(e,t,n){const r=this;return s;function s(a){return wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function l8(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(oy,t,n)}}const c8={name:"htmlText",tokenize:u8};function u8(e,t,n){const r=this;let s,i,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),d):E===47?(e.consume(E),_):E===63?(e.consume(E),x):So(E)?(e.consume(E),H):n(E)}function d(E){return E===45?(e.consume(E),f):E===91?(e.consume(E),i=0,y):So(E)?(e.consume(E),v):n(E)}function f(E){return E===45?(e.consume(E),m):n(E)}function u(E){return E===null?n(E):E===45?(e.consume(E),p):wt(E)?(a=u,z(E)):(e.consume(E),u)}function p(E){return E===45?(e.consume(E),m):u(E)}function m(E){return E===62?I(E):E===45?p(E):u(E)}function y(E){const X="CDATA[";return E===X.charCodeAt(i++)?(e.consume(E),i===X.length?b:y):n(E)}function b(E){return E===null?n(E):E===93?(e.consume(E),k):wt(E)?(a=b,z(E)):(e.consume(E),b)}function k(E){return E===93?(e.consume(E),g):b(E)}function g(E){return E===62?I(E):E===93?(e.consume(E),g):b(E)}function v(E){return E===null||E===62?I(E):wt(E)?(a=v,z(E)):(e.consume(E),v)}function x(E){return E===null?n(E):E===63?(e.consume(E),N):wt(E)?(a=x,z(E)):(e.consume(E),x)}function N(E){return E===62?I(E):x(E)}function _(E){return So(E)?(e.consume(E),C):n(E)}function C(E){return E===45||ti(E)?(e.consume(E),C):T(E)}function T(E){return wt(E)?(a=T,z(E)):rn(E)?(e.consume(E),T):I(E)}function H(E){return E===45||ti(E)?(e.consume(E),H):E===47||E===62||Ds(E)?M(E):n(E)}function M(E){return E===47?(e.consume(E),I):E===58||E===95||So(E)?(e.consume(E),F):wt(E)?(a=M,z(E)):rn(E)?(e.consume(E),M):I(E)}function F(E){return E===45||E===46||E===58||E===95||ti(E)?(e.consume(E),F):D(E)}function D(E){return E===61?(e.consume(E),$):wt(E)?(a=D,z(E)):rn(E)?(e.consume(E),D):M(E)}function $(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,W):wt(E)?(a=$,z(E)):rn(E)?(e.consume(E),$):(e.consume(E),O)}function W(E){return E===s?(e.consume(E),s=void 0,R):E===null?n(E):wt(E)?(a=W,z(E)):(e.consume(E),W)}function O(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Ds(E)?M(E):(e.consume(E),O)}function R(E){return E===47||E===62||Ds(E)?M(E):n(E)}function I(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function z(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),P}function P(E){return rn(E)?Ln(e,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):L(E)}function L(E){return e.enter("htmlTextData"),a(E)}}const v0={name:"labelEnd",resolveAll:h8,resolveTo:m8,tokenize:g8},d8={tokenize:y8},f8={tokenize:x8},p8={tokenize:w8};function h8(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&To(e,0,e.length,n),e}function m8(e,t){let n=e.length,r=0,s,i,a,l;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=Ni(l,e.slice(i+1,i+r+3)),l=Ni(l,[["enter",f,t]]),l=Ni(l,b0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Ni(l,[["exit",f,t],e[a-2],e[a-1],["exit",d,t]]),l=Ni(l,e.slice(a+1)),l=Ni(l,[["exit",c,t]]),To(e,i,e.length,l),e}function g8(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return l;function l(p){return i?i._inactive?u(p):(a=r.parser.defined.includes(wu(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(d8,f,a?f:u)(p):p===91?e.attempt(f8,f,a?d:u)(p):a?f(p):u(p)}function d(p){return e.attempt(p8,f,u)(p)}function f(p){return t(p)}function u(p){return i._balanced=!0,n(p)}}function y8(e,t,n){return r;function r(u){return e.enter("resource"),e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),s}function s(u){return Ds(u)?mf(e,i)(u):i(u)}function i(u){return u===41?f(u):EI(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return Ds(u)?mf(e,c)(u):f(u)}function l(u){return n(u)}function c(u){return u===34||u===39||u===40?PI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):f(u)}function d(u){return Ds(u)?mf(e,f)(u):f(u)}function f(u){return u===41?(e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),e.exit("resource"),t):n(u)}}function x8(e,t,n){const r=this;return s;function s(l){return _I.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(wu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function w8(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const b8={name:"labelStartImage",resolveAll:v0.resolveAll,tokenize:v8};function v8(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const k8={name:"labelStartLink",resolveAll:v0.resolveAll,tokenize:S8};function S8(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const kx={name:"lineEnding",tokenize:N8};function N8(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ln(e,t,"linePrefix")}}const pm={name:"thematicBreak",tokenize:j8};function j8(e,t,n){let r=0,s;return i;function i(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),c(d)):r>=3&&(d===null||wt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),rn(d)?Ln(e,l,"whitespace")(d):l(d))}}const Es={continuation:{tokenize:P8},exit:I8,name:"list",tokenize:_8},C8={partial:!0,tokenize:T8},E8={partial:!0,tokenize:A8};function _8(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:Sb(m)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(pm,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return Sb(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(oy,r.interrupt?n:f,e.attempt(C8,p,u))}function f(m){return r.containerState.initialBlankLine=!0,i++,p(m)}function u(m){return rn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function P8(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(oy,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ln(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!rn(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(E8,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ln(e,e.attempt(Es,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function A8(e,t,n){const r=this;return Ln(e,s,"listItemIndent",r.containerState.size+1);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function I8(e){e.exit(this.containerState.type)}function T8(e,t,n){const r=this;return Ln(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!rn(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const ZN={name:"setextUnderline",resolveTo:R8,tokenize:L8};function R8(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function L8(e,t,n){const r=this;let s;return i;function i(d){let f=r.events.length,u;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){u=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||u)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===s?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),rn(d)?Ln(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||wt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const M8={tokenize:O8};function O8(e){const t=this,n=e.attempt(oy,r,e.attempt(this.parser.constructs.flowInitial,s,Ln(e,e.attempt(this.parser.constructs.flow,s,e.attempt(H6,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const $8={resolveAll:II()},D8=AI("string"),F8=AI("text");function AI(e){return{resolveAll:II(e==="text"?z8:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,l);return a;function a(f){return d(f)?i(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return d(f)?(n.exit("data"),i(f)):(n.consume(f),c)}function d(f){if(f===null)return!0;const u=s[f];let p=-1;if(u)for(;++p<u.length;){const m=u[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function II(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function z8(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let i=s.length,a=-1,l=0,c;for(;i--;){const d=s[i];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)c=!0,l++;else if(d!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const H8={42:Es,43:Es,45:Es,48:Es,49:Es,50:Es,51:Es,52:Es,53:Es,54:Es,55:Es,56:Es,57:Es,62:SI},B8={91:K6},W8={[-2]:vx,[-1]:vx,32:vx},V8={35:Q6,42:pm,45:[ZN,pm],60:n8,61:ZN,95:pm,96:JN,126:JN},U8={38:jI,92:NI},K8={[-5]:kx,[-4]:kx,[-3]:kx,33:b8,38:jI,42:Nb,60:[k6,c8],91:k8,92:[X6,NI],93:v0,95:Nb,96:M6},q8={null:[Nb,$8]},Y8={null:[42,95]},G8={null:[]},X8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Y8,contentInitial:B8,disable:G8,document:H8,flow:V8,flowInitial:W8,insideSpan:q8,string:U8,text:K8},Symbol.toStringTag,{value:"Module"}));function J8(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let a=[],l=[];const c={attempt:T(_),check:T(C),consume:v,enter:x,exit:N,interrupt:T(C,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:y,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:u};let f=t.tokenize.call(d,c);return t.resolveAll&&i.push(t),d;function u(D){return a=Ni(a,D),k(),a[a.length-1]!==null?[]:(H(t,0),d.events=b0(i,d.events,d),d.events)}function p(D,$){return Z8(m(D),$)}function m(D){return Q8(a,D)}function y(){const{_bufferIndex:D,_index:$,line:W,column:O,offset:R}=r;return{_bufferIndex:D,_index:$,line:W,column:O,offset:R}}function b(D){s[D.line]=D.column,F()}function k(){let D;for(;r._index<a.length;){const $=a[r._index];if(typeof $=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<$.length;)g($.charCodeAt(r._bufferIndex));else g($)}}function g(D){f=f(D)}function v(D){wt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,F()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=D}function x(D,$){const W=$||{};return W.type=D,W.start=y(),d.events.push(["enter",W,d]),l.push(W),W}function N(D){const $=l.pop();return $.end=y(),d.events.push(["exit",$,d]),$}function _(D,$){H(D,$.from)}function C(D,$){$.restore()}function T(D,$){return W;function W(O,R,I){let z,P,L,E;return Array.isArray(O)?ee(O):"tokenize"in O?ee([O]):X(O);function X(me){return ge;function ge(Z){const ae=Z!==null&&me[Z],xe=Z!==null&&me.null,pe=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(xe)?xe:xe?[xe]:[]];return ee(pe)(Z)}}function ee(me){return z=me,P=0,me.length===0?I:V(me[P])}function V(me){return ge;function ge(Z){return E=M(),L=me,me.partial||(d.currentConstruct=me),me.name&&d.parser.constructs.disable.null.includes(me.name)?fe():me.tokenize.call($?Object.assign(Object.create(d),$):d,c,ie,fe)(Z)}}function ie(me){return D(L,E),R}function fe(me){return E.restore(),++P<z.length?V(z[P]):I}}}function H(D,$){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&To(d.events,$,d.events.length-$,D.resolve(d.events.slice($),d)),D.resolveTo&&(d.events=D.resolveTo(d.events,d))}function M(){const D=y(),$=d.previous,W=d.currentConstruct,O=d.events.length,R=Array.from(l);return{from:O,restore:I};function I(){r=D,d.previous=$,d.currentConstruct=W,d.events.length=O,l=R,F()}}function F(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function Q8(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function Z8(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
68
68
  `;break}case-3:{a=`\r
69
69
  `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(i)}s=i===-2,r.push(a)}return r.join("")}function eW(e){const r={constructs:a6([X8,...(e||{}).extensions||[]]),content:s(m6),defined:[],document:s(y6),flow:s(M8),lazy:{},string:s(D8),text:s(F8)};return r;function s(i){return a;function a(l){return J8(r,i,l)}}}function tW(e){for(;!CI(e););return e}const ej=/[\0\t\n\r]/g;function nW(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let d,f,u,p,m;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t="",n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(ej.lastIndex=u,d=ej.exec(i),p=d&&d.index!==void 0?d.index:i.length,m=i.charCodeAt(p),!d){t=i.slice(u);break}if(m===10&&u===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),u<p&&(c.push(i.slice(u,p)),e+=p-u),m){case 0:{c.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,c.push(-2);e++<f;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}u=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const rW=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function sW(e){return e.replace(rW,iW)}function iW(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return kI(n.slice(i?2:1),i?16:10)}return w0(n)||e}const TI={}.hasOwnProperty;function oW(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),aW(n)(tW(eW(n).document().write(nW()(e,t,!0))))}function aW(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(bt),autolinkProtocol:M,autolinkEmail:M,atxHeading:i(et),blockQuote:i(xe),characterEscape:M,characterReference:M,codeFenced:i(pe),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(pe,a),codeText:i(_e,a),codeTextData:M,data:M,codeFlowValue:M,definition:i(je),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(Ve),hardBreakEscape:i(qe),hardBreakTrailing:i(qe),htmlFlow:i(dt,a),htmlFlowData:M,htmlText:i(dt,a),htmlTextData:M,image:i(He),label:a,link:i(bt),listItem:i(on),listItemValue:p,listOrdered:i(sn,u),listUnordered:i(sn),paragraph:i(an),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(et),strong:i(Yt),thematicBreak:i(hn)},exit:{atxHeading:c(),atxHeadingSequence:_,autolink:c(),autolinkEmail:ae,autolinkProtocol:Z,blockQuote:c(),characterEscapeValue:F,characterReferenceMarkerHexadecimal:fe,characterReferenceMarkerNumeric:fe,characterReferenceValue:me,characterReference:ge,codeFenced:c(k),codeFencedFence:b,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:F,codeIndented:c(g),codeText:c(R),codeTextData:F,data:F,definition:c(),definitionDestinationString:N,definitionLabelString:v,definitionTitleString:x,emphasis:c(),hardBreakEscape:c($),hardBreakTrailing:c($),htmlFlow:c(W),htmlFlowData:F,htmlText:c(O),htmlTextData:F,image:c(z),label:L,labelText:P,lineEnding:D,link:c(I),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ie,resourceDestinationString:E,resourceTitleString:X,resource:ee,setextHeading:c(H),setextHeadingLineSequence:T,setextHeadingText:C,strong:c(),thematicBreak:c()}};RI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ue){let ke={type:"root",children:[]};const De={stack:[ke],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:f,data:n},rt=[];let at=-1;for(;++at<ue.length;)if(ue[at][1].type==="listOrdered"||ue[at][1].type==="listUnordered")if(ue[at][0]==="enter")rt.push(at);else{const Lt=rt.pop();at=s(ue,Lt,at)}for(at=-1;++at<ue.length;){const Lt=t[ue[at][0]];TI.call(Lt,ue[at][1].type)&&Lt[ue[at][1].type].call(Object.assign({sliceSerialize:ue[at][2].sliceSerialize},De),ue[at][1])}if(De.tokenStack.length>0){const Lt=De.tokenStack[De.tokenStack.length-1];(Lt[1]||tj).call(De,void 0,Lt[0])}for(ke.position={start:Da(ue.length>0?ue[0][1].start:{line:1,column:1,offset:0}),end:Da(ue.length>0?ue[ue.length-2][1].end:{line:1,column:1,offset:0})},at=-1;++at<t.transforms.length;)ke=t.transforms[at](ke)||ke;return ke}function s(ue,ke,De){let rt=ke-1,at=-1,Lt=!1,st,mn,Zt,ar;for(;++rt<=De;){const _n=ue[rt];switch(_n[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{_n[0]==="enter"?at++:at--,ar=void 0;break}case"lineEndingBlank":{_n[0]==="enter"&&(st&&!ar&&!at&&!Zt&&(Zt=rt),ar=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ar=void 0}if(!at&&_n[0]==="enter"&&_n[1].type==="listItemPrefix"||at===-1&&_n[0]==="exit"&&(_n[1].type==="listUnordered"||_n[1].type==="listOrdered")){if(st){let gn=rt;for(mn=void 0;gn--;){const bn=ue[gn];if(bn[1].type==="lineEnding"||bn[1].type==="lineEndingBlank"){if(bn[0]==="exit")continue;mn&&(ue[mn][1].type="lineEndingBlank",Lt=!0),bn[1].type="lineEnding",mn=gn}else if(!(bn[1].type==="linePrefix"||bn[1].type==="blockQuotePrefix"||bn[1].type==="blockQuotePrefixWhitespace"||bn[1].type==="blockQuoteMarker"||bn[1].type==="listItemIndent"))break}Zt&&(!mn||Zt<mn)&&(st._spread=!0),st.end=Object.assign({},mn?ue[mn][1].start:_n[1].end),ue.splice(mn||rt,0,["exit",st,_n[2]]),rt++,De++}if(_n[1].type==="listItemPrefix"){const gn={type:"listItem",_spread:!1,start:Object.assign({},_n[1].start),end:void 0};st=gn,ue.splice(rt,0,["enter",gn,_n[2]]),rt++,De++,Zt=void 0,ar=!0}}}return ue[ke][1]._spread=Lt,De}function i(ue,ke){return De;function De(rt){l.call(this,ue(rt),rt),ke&&ke.call(this,rt)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ue,ke,De){this.stack[this.stack.length-1].children.push(ue),this.stack.push(ue),this.tokenStack.push([ke,De||void 0]),ue.position={start:Da(ke.start),end:void 0}}function c(ue){return ke;function ke(De){ue&&ue.call(this,De),d.call(this,De)}}function d(ue,ke){const De=this.stack.pop(),rt=this.tokenStack.pop();if(rt)rt[0].type!==ue.type&&(ke?ke.call(this,ue,rt[0]):(rt[1]||tj).call(this,ue,rt[0]));else throw new Error("Cannot close `"+ue.type+"` ("+hf({start:ue.start,end:ue.end})+"): it’s not open");De.position.end=Da(ue.end)}function f(){return i6(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function p(ue){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(ue),10),this.data.expectingFirstListItemValue=void 0}}function m(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=ue}function y(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=ue}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ue.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ue.replace(/(\r?\n|\r)$/g,"")}function v(ue){const ke=this.resume(),De=this.stack[this.stack.length-1];De.label=ke,De.identifier=wu(this.sliceSerialize(ue)).toLowerCase()}function x(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ue}function N(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ue}function _(ue){const ke=this.stack[this.stack.length-1];if(!ke.depth){const De=this.sliceSerialize(ue).length;ke.depth=De}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function T(ue){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(ue).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function M(ue){const De=this.stack[this.stack.length-1].children;let rt=De[De.length-1];(!rt||rt.type!=="text")&&(rt=En(),rt.position={start:Da(ue.start),end:void 0},De.push(rt)),this.stack.push(rt)}function F(ue){const ke=this.stack.pop();ke.value+=this.sliceSerialize(ue),ke.position.end=Da(ue.end)}function D(ue){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const De=ke.children[ke.children.length-1];De.position.end=Da(ue.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(M.call(this,ue),F.call(this,ue))}function $(){this.data.atHardBreak=!0}function W(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ue}function O(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ue}function R(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ue}function I(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=ke,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function z(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=ke,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function P(ue){const ke=this.sliceSerialize(ue),De=this.stack[this.stack.length-2];De.label=sW(ke),De.identifier=wu(ke).toLowerCase()}function L(){const ue=this.stack[this.stack.length-1],ke=this.resume(),De=this.stack[this.stack.length-1];if(this.data.inReference=!0,De.type==="link"){const rt=ue.children;De.children=rt}else De.alt=ke}function E(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ue}function X(){const ue=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ue}function ee(){this.data.inReference=void 0}function V(){this.data.referenceType="collapsed"}function ie(ue){const ke=this.resume(),De=this.stack[this.stack.length-1];De.label=ke,De.identifier=wu(this.sliceSerialize(ue)).toLowerCase(),this.data.referenceType="full"}function fe(ue){this.data.characterReferenceType=ue.type}function me(ue){const ke=this.sliceSerialize(ue),De=this.data.characterReferenceType;let rt;De?(rt=kI(ke,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):rt=w0(ke);const at=this.stack[this.stack.length-1];at.value+=rt}function ge(ue){const ke=this.stack.pop();ke.position.end=Da(ue.end)}function Z(ue){F.call(this,ue);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(ue)}function ae(ue){F.call(this,ue);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(ue)}function xe(){return{type:"blockquote",children:[]}}function pe(){return{type:"code",lang:null,meta:null,value:""}}function _e(){return{type:"inlineCode",value:""}}function je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ve(){return{type:"emphasis",children:[]}}function et(){return{type:"heading",depth:0,children:[]}}function qe(){return{type:"break"}}function dt(){return{type:"html",value:""}}function He(){return{type:"image",title:null,url:"",alt:null}}function bt(){return{type:"link",title:null,url:"",children:[]}}function sn(ue){return{type:"list",ordered:ue.type==="listOrdered",start:null,spread:ue._spread,children:[]}}function on(ue){return{type:"listItem",spread:ue._spread,checked:null,children:[]}}function an(){return{type:"paragraph",children:[]}}function Yt(){return{type:"strong",children:[]}}function En(){return{type:"text",value:""}}function hn(){return{type:"thematicBreak"}}}function Da(e){return{line:e.line,column:e.column,offset:e.offset}}function RI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?RI(e,r):lW(e,r)}}function lW(e,t){let n;for(n in t)if(TI.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function tj(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+hf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+hf({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+hf({start:t.start,end:t.end})+") is still open")}function cW(e){const t=this;t.parser=n;function n(r){return oW(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function uW(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function dW(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
70
  `}]}function fW(e,t){const n=t.value?t.value+`
@@ -72,11 +72,11 @@ ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFil
72
72
  `}),f.type==="element"&&f.tagName==="p"&&!s?a.push(...f.children):a.push(f)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
73
  `});const d={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,d),e.applyData(t,d)}function NW(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=MI(n[r])}return t}function MI(e){const t=e.spread;return t??e.children.length>1}function jW(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function CW(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EW(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function _W(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PW(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),s.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=m0(t.children[1]),c=mI(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function AW(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const d=[];for(;++c<l;){const u=t.children[c],p={},m=a?a[c]:void 0;m&&(p.align=m);let y={type:"element",tagName:i,properties:p,children:[]};u&&(y.children=e.all(u),e.patch(u,y),y=e.applyData(u,y)),d.push(y)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,f),e.applyData(t,f)}function IW(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const nj=9,rj=32;function TW(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(sj(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(sj(t.slice(s),s>0,!1)),i.join("")}function sj(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===nj||i===rj;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===nj||i===rj;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function RW(e,t){const n={type:"text",value:TW(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function LW(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const MW={blockquote:uW,break:dW,code:fW,delete:pW,emphasis:hW,footnoteReference:mW,heading:gW,html:yW,imageReference:xW,image:wW,inlineCode:bW,linkReference:vW,link:kW,listItem:SW,list:jW,paragraph:CW,root:EW,strong:_W,table:PW,tableCell:IW,tableRow:AW,text:RW,thematicBreak:LW,toml:Rh,yaml:Rh,definition:Rh,footnoteDefinition:Rh};function Rh(){}const OI=-1,ay=0,gf=1,rg=2,k0=3,S0=4,N0=5,j0=6,$I=7,DI=8,ij=typeof self=="object"?self:globalThis,OW=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,a]=t[s];switch(i){case ay:case OI:return n(a,s);case gf:{const l=n([],s);for(const c of a)l.push(r(c));return l}case rg:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case k0:return n(new Date(a),s);case S0:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case N0:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case j0:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case $I:{const{name:l,message:c}=a;return n(new ij[l](c),s)}case DI:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new ij[i](a),s)};return r},oj=e=>OW(new Map,e)(0),Dc="",{toString:$W}={},{keys:DW}=Object,Dd=e=>{const t=typeof e;if(t!=="object"||!e)return[ay,t];const n=$W.call(e).slice(8,-1);switch(n){case"Array":return[gf,Dc];case"Object":return[rg,Dc];case"Date":return[k0,Dc];case"RegExp":return[S0,Dc];case"Map":return[N0,Dc];case"Set":return[j0,Dc];case"DataView":return[gf,n]}return n.includes("Array")?[gf,n]:n.includes("Error")?[$I,n]:[rg,n]},Lh=([e,t])=>e===ay&&(t==="function"||t==="symbol"),FW=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},i=a=>{if(n.has(a))return n.get(a);let[l,c]=Dd(a);switch(l){case ay:{let f=a;switch(c){case"bigint":l=DI,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return s([OI],a)}return s([l,f],a)}case gf:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const f=[],u=s([l,f],a);for(const p of a)f.push(i(p));return u}case rg:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(t&&"toJSON"in a)return i(a.toJSON());const f=[],u=s([l,f],a);for(const p of DW(a))(e||!Lh(Dd(a[p])))&&f.push([i(p),i(a[p])]);return u}case k0:return s([l,a.toISOString()],a);case S0:{const{source:f,flags:u}=a;return s([l,{source:f,flags:u}],a)}case N0:{const f=[],u=s([l,f],a);for(const[p,m]of a)(e||!(Lh(Dd(p))||Lh(Dd(m))))&&f.push([i(p),i(m)]);return u}case j0:{const f=[],u=s([l,f],a);for(const p of a)(e||!Lh(Dd(p)))&&f.push(i(p));return u}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return i},aj=(e,{json:t,lossy:n}={})=>{const r=[];return FW(!(t||n),!!t,new Map,r)(e),r},sg=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?oj(aj(e,t)):structuredClone(e):(e,t)=>oj(aj(e,t));function zW(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function HW(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function BW(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||zW,r=e.options.footnoteBackLabel||HW,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[c]);if(!d)continue;const f=e.all(d),u=String(d.identifier).toUpperCase(),p=Gu(u.toLowerCase());let m=0;const y=[],b=e.footnoteCounts.get(u);for(;b!==void 0&&++m<=b;){y.length>0&&y.push({type:"text",value:" "});let v=typeof n=="string"?n:n(c,m);typeof v=="string"&&(v={type:"text",value:v}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,m),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const k=f[f.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const v=k.children[k.children.length-1];v&&v.type==="text"?v.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...y)}else f.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(d,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...sg(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
74
74
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
75
- `}]}}const FI=function(e){if(e==null)return KW;if(typeof e=="function")return ly(e);if(typeof e=="object")return Array.isArray(e)?WW(e):VW(e);if(typeof e=="string")return UW(e);throw new Error("Expected function, string, or object as test")};function WW(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=FI(e[n]);return ly(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function VW(e){const t=e;return ly(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function UW(e){return ly(t);function t(n){return n&&n.type===e}}function ly(e){return t;function t(n,r,s){return!!(qW(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function KW(){return!0}function qW(e){return e!==null&&typeof e=="object"&&"type"in e}const zI=[],YW=!0,lj=!1,GW="skip";function XW(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=FI(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,f){const u=c&&typeof c=="object"?c:{};if(typeof u.type=="string"){const m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=zI,y,b,k;if((!t||i(c,d,f[f.length-1]||void 0))&&(m=JW(n(c,f)),m[0]===lj))return m;if("children"in c&&c.children){const g=c;if(g.children&&m[0]!==GW)for(b=(r?g.children.length:-1)+a,k=f.concat(g);b>-1&&b<g.children.length;){const v=g.children[b];if(y=l(v,b,k)(),y[0]===lj)return y;b=typeof y[1]=="number"?y[1]:b+a}}return m}}}function JW(e){return Array.isArray(e)?e:typeof e=="number"?[YW,e]:e==null?zI:[e]}function HI(e,t,n,r){let s,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,s=n):(i=t,a=n,s=r),XW(e,i,l,s);function l(c,d){const f=d[d.length-1],u=f?f.children.indexOf(c):void 0;return a(c,u,f)}}const jb={}.hasOwnProperty,QW={};function ZW(e,t){const n=t||QW,r=new Map,s=new Map,i=new Map,a={...MW,...n.handlers},l={all:d,applyData:t9,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:e9,wrap:r9};return HI(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const u=f.type==="definition"?r:s,p=String(f.identifier).toUpperCase();u.has(p)||u.set(p,f)}}),l;function c(f,u){const p=f.type,m=l.handlers[p];if(jb.call(l.handlers,p)&&m)return m(l,f,u);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in f){const{children:b,...k}=f,g=sg(k);return g.children=l.all(f),g}return sg(f)}return(l.options.unknownHandler||n9)(l,f,u)}function d(f){const u=[];if("children"in f){const p=f.children;let m=-1;for(;++m<p.length;){const y=l.one(p[m],f);if(y){if(m&&p[m-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=cj(y.value)),!Array.isArray(y)&&y.type==="element")){const b=y.children[0];b&&b.type==="text"&&(b.value=cj(b.value))}Array.isArray(y)?u.push(...y):u.push(y)}}}return u}}function e9(e,t){e.position&&(t.position=$B(e))}function t9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&i&&Object.assign(n.properties,sg(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function n9(e,t){const n=t.data||{},r="value"in t&&!(jb.call(n,"hProperties")||jb.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function r9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
75
+ `}]}}const FI=function(e){if(e==null)return KW;if(typeof e=="function")return ly(e);if(typeof e=="object")return Array.isArray(e)?WW(e):VW(e);if(typeof e=="string")return UW(e);throw new Error("Expected function, string, or object as test")};function WW(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=FI(e[n]);return ly(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function VW(e){const t=e;return ly(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function UW(e){return ly(t);function t(n){return n&&n.type===e}}function ly(e){return t;function t(n,r,s){return!!(qW(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function KW(){return!0}function qW(e){return e!==null&&typeof e=="object"&&"type"in e}const zI=[],YW=!0,lj=!1,GW="skip";function XW(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=FI(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,f){const u=c&&typeof c=="object"?c:{};if(typeof u.type=="string"){const m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=zI,y,b,k;if((!t||i(c,d,f[f.length-1]||void 0))&&(m=JW(n(c,f)),m[0]===lj))return m;if("children"in c&&c.children){const g=c;if(g.children&&m[0]!==GW)for(b=(r?g.children.length:-1)+a,k=f.concat(g);b>-1&&b<g.children.length;){const v=g.children[b];if(y=l(v,b,k)(),y[0]===lj)return y;b=typeof y[1]=="number"?y[1]:b+a}}return m}}}function JW(e){return Array.isArray(e)?e:typeof e=="number"?[YW,e]:e==null?zI:[e]}function HI(e,t,n,r){let s,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,s=n):(i=t,a=n,s=r),XW(e,i,l,s);function l(c,d){const f=d[d.length-1],u=f?f.children.indexOf(c):void 0;return a(c,u,f)}}const jb={}.hasOwnProperty,QW={};function ZW(e,t){const n=t||QW,r=new Map,s=new Map,i=new Map,a={...MW,...n.handlers},l={all:d,applyData:t9,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:e9,wrap:r9};return HI(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const u=f.type==="definition"?r:s,p=String(f.identifier).toUpperCase();u.has(p)||u.set(p,f)}}),l;function c(f,u){const p=f.type,m=l.handlers[p];if(jb.call(l.handlers,p)&&m)return m(l,f,u);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in f){const{children:b,...k}=f,g=sg(k);return g.children=l.all(f),g}return sg(f)}return(l.options.unknownHandler||n9)(l,f,u)}function d(f){const u=[];if("children"in f){const p=f.children;let m=-1;for(;++m<p.length;){const y=l.one(p[m],f);if(y){if(m&&p[m-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=cj(y.value)),!Array.isArray(y)&&y.type==="element")){const b=y.children[0];b&&b.type==="text"&&(b.value=cj(b.value))}Array.isArray(y)?u.push(...y):u.push(y)}}}return u}}function e9(e,t){e.position&&(t.position=$4(e))}function t9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&i&&Object.assign(n.properties,sg(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function n9(e,t){const n=t.data||{},r="value"in t&&!(jb.call(n,"hProperties")||jb.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function r9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
76
76
  `});++r<e.length;)r&&n.push({type:"text",value:`
77
77
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
78
78
  `}),n}function cj(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function uj(e,t){const n=ZW(e,t),r=n.one(e,void 0),s=BW(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
79
- `},s),i}function s9(e,t){return e&&"run"in e?async function(n,r){const s=uj(n,{file:r,...t});await e.run(s,r)}:function(n,r){return uj(n,{file:r,...e||t})}}function dj(e){if(e)throw e}var hm=Object.prototype.hasOwnProperty,BI=Object.prototype.toString,fj=Object.defineProperty,pj=Object.getOwnPropertyDescriptor,hj=function(t){return typeof Array.isArray=="function"?Array.isArray(t):BI.call(t)==="[object Array]"},mj=function(t){if(!t||BI.call(t)!=="[object Object]")return!1;var n=hm.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&hm.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||hm.call(t,s)},gj=function(t,n){fj&&n.name==="__proto__"?fj(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},yj=function(t,n){if(n==="__proto__")if(hm.call(t,n)){if(pj)return pj(t,n).value}else return;return t[n]},i9=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,d=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<d;++c)if(t=arguments[c],t!=null)for(n in t)r=yj(l,n),s=yj(t,n),l!==s&&(f&&s&&(mj(s)||(i=hj(s)))?(i?(i=!1,a=r&&hj(r)?r:[]):a=r&&mj(r)?r:{},gj(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&gj(l,{name:n,newValue:s}));return l};const Sx=hl(i9);function Cb(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function o9(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...d){const f=e[++i];let u=-1;if(c){a(c);return}for(;++u<s.length;)(d[u]===null||d[u]===void 0)&&(d[u]=s[u]);s=d,f?a9(f,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function a9(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(d){const f=d;if(l&&n)throw f;return s(f)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...l){n||(n=!0,t(a,...l))}function i(a){s(null,a)}}const yo={basename:l9,dirname:c9,extname:u9,join:d9,sep:"/"};function l9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');bp(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else a<0&&(i=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function c9(e){if(bp(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function u9(e){bp(e);let t=e.length,n=-1,r=0,s=-1,i=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function d9(...e){let t=-1,n;for(;++t<e.length;)bp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":f9(n)}function f9(e){bp(e);const t=e.codePointAt(0)===47;let n=p9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function p9(e,t){let n="",r=0,s=-1,i=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=a,i=0;continue}}else if(n.length>0){n="",r=0,s=a,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,i=0}else l===46&&i>-1?i++:i=-1}return n}function bp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const h9={cwd:m9};function m9(){return"/"}function Eb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function g9(e){if(typeof e=="string")e=new URL(e);else if(!Eb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return y9(e)}function y9(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const Nx=["history","path","basename","stem","extname","dirname"];class WI{constructor(t){let n;t?Eb(t)?n={path:t}:typeof t=="string"||x9(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":h9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Nx.length;){const i=Nx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)Nx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?yo.basename(this.path):void 0}set basename(t){Cx(t,"basename"),jx(t,"basename"),this.path=yo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?yo.dirname(this.path):void 0}set dirname(t){xj(this.basename,"dirname"),this.path=yo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?yo.extname(this.path):void 0}set extname(t){if(jx(t,"extname"),xj(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=yo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Eb(t)&&(t=g9(t)),Cx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?yo.basename(this.path,this.extname):void 0}set stem(t){Cx(t,"stem"),jx(t,"stem"),this.path=yo.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new is(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function jx(e,t){if(e&&e.includes(yo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+yo.sep+"`")}function Cx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function xj(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function x9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const w9=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},b9={}.hasOwnProperty;class C0 extends w9{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=o9()}copy(){const t=new C0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Sx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Px("data",this.frozen),this.namespace[t]=n,this):b9.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Px("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Mh(t),r=this.parser||this.Parser;return Ex("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ex("process",this.parser||this.Parser),_x("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=Mh(t),c=r.parse(l);r.run(c,l,function(f,u,p){if(f||!u||!p)return d(f);const m=u,y=r.stringify(m,p);S9(y)?p.value=y:p.result=y,d(f,p)});function d(f,u){f||!u?a(f):i?i(u):n(void 0,u)}}}processSync(t){let n=!1,r;return this.freeze(),Ex("processSync",this.parser||this.Parser),_x("processSync",this.compiler||this.Compiler),this.process(t,s),bj("processSync","process",n),r;function s(i,a){n=!0,dj(i),r=a}}run(t,n,r){wj(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const c=Mh(n);s.run(t,c,d);function d(f,u,p){const m=u||t;f?l(f):a?a(m):r(void 0,m,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),bj("runSync","run",r),s;function i(a,l){dj(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Mh(n),s=this.compiler||this.Compiler;return _x("stringify",s),wj(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Px("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(d){if(typeof d=="function")c(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[f,...u]=d;c(f,u)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(s.settings=Sx(!0,s.settings,d.settings))}function l(d){let f=-1;if(d!=null)if(Array.isArray(d))for(;++f<d.length;){const u=d[f];i(u)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,f){let u=-1,p=-1;for(;++u<r.length;)if(r[u][0]===d){p=u;break}if(p===-1)r.push([d,...f]);else if(f.length>0){let[m,...y]=f;const b=r[p][1];Cb(b)&&Cb(m)&&(m=Sx(!0,b,m)),r[p]=[d,m,...y]}}}}const v9=new C0().freeze();function Ex(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function _x(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Px(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function wj(e){if(!Cb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function bj(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Mh(e){return k9(e)?e:new WI(e)}function k9(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function S9(e){return typeof e=="string"||N9(e)}function N9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const j9="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",vj=[],kj={allowDangerousHtml:!0},C9=/^(https?|ircs?|mailto|xmpp)$/i,E9=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function vp(e){const t=_9(e),n=P9(e);return A9(t.runSync(t.parse(n),n),e)}function _9(e){const t=e.rehypePlugins||vj,n=e.remarkPlugins||vj,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...kj}:kj;return v9().use(cW).use(n).use(s9,r).use(t)}function P9(e){const t=e.children||"",n=new WI;return typeof t=="string"&&(n.value=t),n}function A9(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||I9;for(const f of E9)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+j9+f.id,void 0);return HI(e,d),BB(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(f,u,p){if(f.type==="raw"&&p&&typeof u=="number")return a?p.children.splice(u,1):p.children[u]={type:"text",value:f.value},u;if(f.type==="element"){let m;for(m in bx)if(Object.hasOwn(bx,m)&&Object.hasOwn(f.properties,m)){const y=f.properties[m],b=bx[m];(b===null||b.includes(f.tagName))&&(f.properties[m]=c(String(y||""),m,f))}}if(f.type==="element"){let m=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!m&&r&&typeof u=="number"&&(m=!r(f,u,p)),m&&p&&typeof u=="number")return l&&f.children?p.children.splice(u,1,...f.children):p.children.splice(u,1),u}}}function I9(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||C9.test(e.slice(0,t))?e:""}function T9(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function ig(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>ig(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${ig(t[r])}`).join(",")}}`}function Sj(e){return ig({id:e.id,type:e.type,position:e.position,data:e.data,parentId:e.parentId,extent:e.extent,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition,hidden:e.hidden})}function Xf(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function Nj(e){return ig({source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,type:e.type,label:e.label,data:e.data,markerStart:e.markerStart,markerEnd:e.markerEnd,animated:e.animated,hidden:e.hidden,style:e.style})}function jj(e,t){return!T9(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function Cj(e,t=!1){const n=new Map;for(const r of e){const s=Xf(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function R9(e,t,n,r){const s=new Map(e.map(v=>[v.id,v])),i=new Set(n.map(v=>v.id)),a=new Set,l=[],c=[],d=n.map(v=>{const x=s.get(v.id);return x?Sj(x)===Sj(v)?(a.add(v.id),x):(c.push(v.id),jj(v,x)):(l.push(v.id),v)}),f=Cj(t),u=Cj(r,!0),p=new Set,m=[],y=[],b=r.map(v=>{const x=Xf(v),N=f.get(x);return N?Nj(N)===Nj(v)?(p.add(x),N):(y.push(x),jj(v,N)):(m.push(x),v)}),k=e.filter(v=>!i.has(v.id)).map(v=>v.id),g=t.map(v=>Xf(v)).filter(v=>!u.has(v));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:k,addedEdgeKeys:m,updatedEdgeKeys:y,removedEdgeKeys:g},stats:{nodeAdded:l.length,nodeRemoved:k.length,nodeReused:a.size,edgeAdded:m.length,edgeRemoved:g.length,edgeReused:p.size,nextEdgeCount:u.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function VI(e){return typeof e>"u"||e===null}function L9(e){return typeof e=="object"&&e!==null}function M9(e){return Array.isArray(e)?e:VI(e)?[]:[e]}function O9(e,t){var n,r,s,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)s=i[n],e[s]=t[s];return e}function $9(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function D9(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var F9=VI,z9=L9,H9=M9,B9=$9,W9=D9,V9=O9,Nr={isNothing:F9,isObject:z9,toArray:H9,repeat:B9,isNegativeZero:W9,extend:V9};function UI(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
79
+ `},s),i}function s9(e,t){return e&&"run"in e?async function(n,r){const s=uj(n,{file:r,...t});await e.run(s,r)}:function(n,r){return uj(n,{file:r,...e||t})}}function dj(e){if(e)throw e}var hm=Object.prototype.hasOwnProperty,BI=Object.prototype.toString,fj=Object.defineProperty,pj=Object.getOwnPropertyDescriptor,hj=function(t){return typeof Array.isArray=="function"?Array.isArray(t):BI.call(t)==="[object Array]"},mj=function(t){if(!t||BI.call(t)!=="[object Object]")return!1;var n=hm.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&hm.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||hm.call(t,s)},gj=function(t,n){fj&&n.name==="__proto__"?fj(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},yj=function(t,n){if(n==="__proto__")if(hm.call(t,n)){if(pj)return pj(t,n).value}else return;return t[n]},i9=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,d=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<d;++c)if(t=arguments[c],t!=null)for(n in t)r=yj(l,n),s=yj(t,n),l!==s&&(f&&s&&(mj(s)||(i=hj(s)))?(i?(i=!1,a=r&&hj(r)?r:[]):a=r&&mj(r)?r:{},gj(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&gj(l,{name:n,newValue:s}));return l};const Sx=hl(i9);function Cb(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function o9(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...d){const f=e[++i];let u=-1;if(c){a(c);return}for(;++u<s.length;)(d[u]===null||d[u]===void 0)&&(d[u]=s[u]);s=d,f?a9(f,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function a9(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(d){const f=d;if(l&&n)throw f;return s(f)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...l){n||(n=!0,t(a,...l))}function i(a){s(null,a)}}const yo={basename:l9,dirname:c9,extname:u9,join:d9,sep:"/"};function l9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');bp(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else a<0&&(i=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function c9(e){if(bp(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function u9(e){bp(e);let t=e.length,n=-1,r=0,s=-1,i=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function d9(...e){let t=-1,n;for(;++t<e.length;)bp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":f9(n)}function f9(e){bp(e);const t=e.codePointAt(0)===47;let n=p9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function p9(e,t){let n="",r=0,s=-1,i=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=a,i=0;continue}}else if(n.length>0){n="",r=0,s=a,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,i=0}else l===46&&i>-1?i++:i=-1}return n}function bp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const h9={cwd:m9};function m9(){return"/"}function Eb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function g9(e){if(typeof e=="string")e=new URL(e);else if(!Eb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return y9(e)}function y9(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const Nx=["history","path","basename","stem","extname","dirname"];class WI{constructor(t){let n;t?Eb(t)?n={path:t}:typeof t=="string"||x9(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":h9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Nx.length;){const i=Nx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)Nx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?yo.basename(this.path):void 0}set basename(t){Cx(t,"basename"),jx(t,"basename"),this.path=yo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?yo.dirname(this.path):void 0}set dirname(t){xj(this.basename,"dirname"),this.path=yo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?yo.extname(this.path):void 0}set extname(t){if(jx(t,"extname"),xj(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=yo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Eb(t)&&(t=g9(t)),Cx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?yo.basename(this.path,this.extname):void 0}set stem(t){Cx(t,"stem"),jx(t,"stem"),this.path=yo.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new is(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function jx(e,t){if(e&&e.includes(yo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+yo.sep+"`")}function Cx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function xj(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function x9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const w9=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},b9={}.hasOwnProperty;class C0 extends w9{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=o9()}copy(){const t=new C0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Sx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Px("data",this.frozen),this.namespace[t]=n,this):b9.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Px("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Mh(t),r=this.parser||this.Parser;return Ex("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ex("process",this.parser||this.Parser),_x("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=Mh(t),c=r.parse(l);r.run(c,l,function(f,u,p){if(f||!u||!p)return d(f);const m=u,y=r.stringify(m,p);S9(y)?p.value=y:p.result=y,d(f,p)});function d(f,u){f||!u?a(f):i?i(u):n(void 0,u)}}}processSync(t){let n=!1,r;return this.freeze(),Ex("processSync",this.parser||this.Parser),_x("processSync",this.compiler||this.Compiler),this.process(t,s),bj("processSync","process",n),r;function s(i,a){n=!0,dj(i),r=a}}run(t,n,r){wj(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const c=Mh(n);s.run(t,c,d);function d(f,u,p){const m=u||t;f?l(f):a?a(m):r(void 0,m,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),bj("runSync","run",r),s;function i(a,l){dj(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Mh(n),s=this.compiler||this.Compiler;return _x("stringify",s),wj(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Px("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(d){if(typeof d=="function")c(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[f,...u]=d;c(f,u)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(s.settings=Sx(!0,s.settings,d.settings))}function l(d){let f=-1;if(d!=null)if(Array.isArray(d))for(;++f<d.length;){const u=d[f];i(u)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,f){let u=-1,p=-1;for(;++u<r.length;)if(r[u][0]===d){p=u;break}if(p===-1)r.push([d,...f]);else if(f.length>0){let[m,...y]=f;const b=r[p][1];Cb(b)&&Cb(m)&&(m=Sx(!0,b,m)),r[p]=[d,m,...y]}}}}const v9=new C0().freeze();function Ex(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function _x(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Px(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function wj(e){if(!Cb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function bj(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Mh(e){return k9(e)?e:new WI(e)}function k9(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function S9(e){return typeof e=="string"||N9(e)}function N9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const j9="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",vj=[],kj={allowDangerousHtml:!0},C9=/^(https?|ircs?|mailto|xmpp)$/i,E9=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function vp(e){const t=_9(e),n=P9(e);return A9(t.runSync(t.parse(n),n),e)}function _9(e){const t=e.rehypePlugins||vj,n=e.remarkPlugins||vj,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...kj}:kj;return v9().use(cW).use(n).use(s9,r).use(t)}function P9(e){const t=e.children||"",n=new WI;return typeof t=="string"&&(n.value=t),n}function A9(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||I9;for(const f of E9)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+j9+f.id,void 0);return HI(e,d),B4(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(f,u,p){if(f.type==="raw"&&p&&typeof u=="number")return a?p.children.splice(u,1):p.children[u]={type:"text",value:f.value},u;if(f.type==="element"){let m;for(m in bx)if(Object.hasOwn(bx,m)&&Object.hasOwn(f.properties,m)){const y=f.properties[m],b=bx[m];(b===null||b.includes(f.tagName))&&(f.properties[m]=c(String(y||""),m,f))}}if(f.type==="element"){let m=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!m&&r&&typeof u=="number"&&(m=!r(f,u,p)),m&&p&&typeof u=="number")return l&&f.children?p.children.splice(u,1,...f.children):p.children.splice(u,1),u}}}function I9(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||C9.test(e.slice(0,t))?e:""}function T9(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function ig(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>ig(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${ig(t[r])}`).join(",")}}`}function Sj(e){return ig({id:e.id,type:e.type,position:e.position,data:e.data,parentId:e.parentId,extent:e.extent,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition,hidden:e.hidden})}function Xf(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function Nj(e){return ig({source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,type:e.type,label:e.label,data:e.data,markerStart:e.markerStart,markerEnd:e.markerEnd,animated:e.animated,hidden:e.hidden,style:e.style})}function jj(e,t){return!T9(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function Cj(e,t=!1){const n=new Map;for(const r of e){const s=Xf(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function R9(e,t,n,r){const s=new Map(e.map(v=>[v.id,v])),i=new Set(n.map(v=>v.id)),a=new Set,l=[],c=[],d=n.map(v=>{const x=s.get(v.id);return x?Sj(x)===Sj(v)?(a.add(v.id),x):(c.push(v.id),jj(v,x)):(l.push(v.id),v)}),f=Cj(t),u=Cj(r,!0),p=new Set,m=[],y=[],b=r.map(v=>{const x=Xf(v),N=f.get(x);return N?Nj(N)===Nj(v)?(p.add(x),N):(y.push(x),jj(v,N)):(m.push(x),v)}),k=e.filter(v=>!i.has(v.id)).map(v=>v.id),g=t.map(v=>Xf(v)).filter(v=>!u.has(v));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:k,addedEdgeKeys:m,updatedEdgeKeys:y,removedEdgeKeys:g},stats:{nodeAdded:l.length,nodeRemoved:k.length,nodeReused:a.size,edgeAdded:m.length,edgeRemoved:g.length,edgeReused:p.size,nextEdgeCount:u.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function VI(e){return typeof e>"u"||e===null}function L9(e){return typeof e=="object"&&e!==null}function M9(e){return Array.isArray(e)?e:VI(e)?[]:[e]}function O9(e,t){var n,r,s,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)s=i[n],e[s]=t[s];return e}function $9(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function D9(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var F9=VI,z9=L9,H9=M9,B9=$9,W9=D9,V9=O9,Nr={isNothing:F9,isObject:z9,toArray:H9,repeat:B9,isNegativeZero:W9,extend:V9};function UI(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
80
80
 
81
81
  `+e.mark.snippet),r+" "+n):r}function Jf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=UI(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Jf.prototype=Object.create(Error.prototype);Jf.prototype.constructor=Jf;Jf.prototype.toString=function(t){return this.name+": "+UI(this,t)};var hs=Jf;function Ax(e,t,n,r,s){var i="",a="",l=Math.floor(s/2)-1;return r-t>l&&(i=" ... ",t=r-l+i.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function Ix(e,t){return Nr.repeat(" ",t-e.length)+e}function U9(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],i,a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)d=Ax(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),u),l=Nr.repeat(" ",t.indent)+Ix((e.line-c+1).toString(),f)+" | "+d.str+`
82
82
  `+l;for(d=Ax(e.buffer,r[a],s[a],e.position,u),l+=Nr.repeat(" ",t.indent)+Ix((e.line+1).toString(),f)+" | "+d.str+`
@@ -125,11 +125,11 @@ script: node -e "console.log('TODO: scripts/x.mjs')"
125
125
 
126
126
  `).trimEnd()}function Lx(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function PK(e){const t=String(e||"");let n="",r=0;dg.lastIndex=0;let s;for(;s=dg.exec(t);)n+=Lx(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Lx(s[0])}</span>`,r=s.index+s[0].length;return n+=Lx(t.slice(r)),n||" "}function AK(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+i+a+l)}function HT({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var bn,lr;const{t:f}=Mn(),u=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),y=NK(e),b=jK(y),k=(e==null?void 0:e.isRunMode)??!1,g=!!(e!=null&&e.readOnly),v=(e==null?void 0:e.isExecuting)??!1,x=(e==null?void 0:e.isDim)??!1,N=(e==null?void 0:e.nodeStatus)??null,_=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",T=C.startsWith("provide_"),H=C==="provide_bool",M=C==="provide_str",F=C==="provide_file",D=C==="agent_subAgent",$=D&&!k,W=H?CK(p[0]):!1,O=T?String(((bn=p[0])==null?void 0:bn.value)??((lr=p[0])==null?void 0:lr.default)??(e==null?void 0:e.body)??""):"",R=String((e==null?void 0:e.body)||""),I=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),z=!T&&!$&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",P=Ts(e==null?void 0:e.images),L=h.useRef(!1),E=h.useRef(!1),X=h.useRef(null),ee=h.useRef(null),V=h.useRef(null),[ie,fe]=h.useState(O),[me,ge]=h.useState(R);h.useEffect(()=>{L.current||fe(O)},[n,O]),h.useEffect(()=>{E.current||ge(R)},[n,R]),h.useEffect(()=>{const ve=ee.current;if(!ve)return;const $e=AK(ve,me);ve.style.minHeight=`${$e}px`,ve.style.height="",V.current&&(V.current.style.minHeight=`${$e}px`,V.current.style.height="")},[me]),h.useEffect(()=>{const ve=X.current,$e=e==null?void 0:e.onNodeContentResize;if(!$||!ve||!$e||typeof ResizeObserver>"u")return;let nt=0;const zt=()=>{window.cancelAnimationFrame(nt),nt=window.requestAnimationFrame(()=>$e(n))},oe=new ResizeObserver(zt);return oe.observe(ve),zt(),()=>{window.cancelAnimationFrame(nt),oe.disconnect()}},[e==null?void 0:e.onNodeContentResize,$,n]);const Z=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],ae=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],xe=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],pe=((e==null?void 0:e.model)??"").trim(),_e=m==="agent"&&!C.startsWith("tool_nodejs"),je=new Set(Z.map(Xo)),Ve=new Set(ae.map(Xo)),et=new Set(xe.map(Xo)),qe=pe?pe.startsWith("cursor:")||pe.startsWith("opencode:")||pe.startsWith("claude-code:")?pe:et.has(pe)?`claude-code:${pe}`:Ve.has(pe)?`opencode:${pe}`:je.has(pe)?`cursor:${pe}`:pe:"",dt=pe&&!qe.startsWith("cursor:")&&!qe.startsWith("opencode:")&&!qe.startsWith("claude-code:")&&!je.has(pe)&&!Ve.has(pe)&&!et.has(pe),He=pe.startsWith("cursor:")?pe.slice(7):pe.startsWith("opencode:")?pe.slice(9):pe.startsWith("claude-code:")?pe.slice(12):pe,bt=ve=>{if(g)return;const $e=ve.target.value;d&&d(n,$e)},sn=ve=>{ve.stopPropagation(),!g&&r&&r(n)},on=ve=>{ve.stopPropagation(),s&&s()},an=ve=>{ve.stopPropagation(),!g&&(i==null||i(n,ve.target.value==="true"?"true":"false"))},Yt=ve=>{if(ve.stopPropagation(),g)return;const $e=ve.target.value;fe($e),L.current||i==null||i(n,$e)},En=ve=>{ve.stopPropagation(),L.current=!0},hn=ve=>{if(ve.stopPropagation(),g)return;L.current=!1;const $e=ve.currentTarget.value;fe($e),i==null||i(n,$e)},ue=()=>{g||i==null||i(n,ie)},ke=ve=>{if(ve.stopPropagation(),g)return;const $e=window.prompt("文件路径",ie);$e!=null&&(fe($e),i==null||i(n,$e))},De=ve=>{if(ge(ve),a==null||a(n,ve),l){const $e=lK(P,ve);($e.length!==P.length||$e.some((nt,zt)=>{var oe;return nt.id!==((oe=P[zt])==null?void 0:oe.id)}))&&l(n,$e)}},rt=ve=>{if(ve.stopPropagation(),g)return;const $e=ve.target.value;E.current?ge($e):De($e)},at=ve=>{ve.stopPropagation(),!g&&(E.current=!0)},Lt=ve=>{if(ve.stopPropagation(),g)return;E.current=!1;const $e=ve.currentTarget.value;De($e)},st=()=>{g||De(me)},mn=async ve=>{if(g)return;const $e=await OT({files:ve,body:me,images:P});$e&&(ge($e.body),a==null||a(n,$e.body),l==null||l(n,$e.images))},Zt=(ve,$e)=>{if(ve.stopPropagation(),g)return;const nt=P.filter(oe=>oe.id!==$e.id),zt=_K(me,$e.label);ge(zt),a==null||a(n,zt),l==null||l(n,nt)},ar=ve=>{if(g)return;const $e=MT(ve);$e.length!==0&&(ve.preventDefault(),ve.stopPropagation(),mn($e).catch(()=>{}))},_n=ve=>{if(g)return;const $e=fg(ve);$e.length!==0&&(ve.preventDefault(),ve.stopPropagation(),mn($e).catch(()=>{}))},gn=()=>{const ve=ee.current,$e=V.current;!ve||!$e||($e.scrollTop=ve.scrollTop,$e.scrollLeft=ve.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(v?" af-flow-node--executing":"")+(N==="success"?" af-flow-node--done":"")+(N==="failed"?" af-flow-node--failed":"")+(N==="running"&&!v?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+($?" af-flow-node--inline-body-editor":"")+(M?" af-flow-node--provide-text":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:y,children:b}),!k&&_e&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:$r,onMouseDown:$r,onClick:$r,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:qe,onChange:bt,onPointerDown:$r,onMouseDown:$r,onClick:$r,"aria-label":f("flow:node.model"),title:He||f("flow:node.defaultModel"),disabled:g,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),dt&&o.jsx("option",{value:pe,children:pe}),Z.length>0&&o.jsx("optgroup",{label:"Cursor",children:Z.map(ve=>o.jsx("option",{value:`cursor:${Xo(ve)}`,children:Xo(ve)},`c-${ve}`))}),ae.length>0&&o.jsx("optgroup",{label:"OpenCode",children:ae.map(ve=>o.jsx("option",{value:`opencode:${Xo(ve)}`,children:Xo(ve)},`o-${ve}`))}),xe.length>0&&o.jsx("optgroup",{label:"Claude Code",children:xe.map(ve=>o.jsx("option",{value:`claude-code:${Xo(ve)}`,children:Xo(ve)},`cc-${ve}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),v&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),N==="running"&&!v&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),N==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:_!=null&&String(_).trim()!==""?_:"--"}),N==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!k&&T&&!H&&!M&&!F&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:on,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!k&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:g,onClick:sn,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:u.map((ve,$e)=>{if(ve.showOnNode===!1)return null;const nt=f("flow:node.inputTooltip",{name:ve.name||`#${$e}`,type:ve.type})+(ve.default!=null&&ve.default!==""?f("flow:node.defaultSuffix",{value:ve.default}):""),zt=ve.name||`#${$e+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:nt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[zt,ve.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Fs,{type:"target",position:Ze.Left,id:`input-${$e}`,className:"af-flow-node__handle",style:{background:or(ve.type)},title:nt})]},`in-${$e}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:I}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,H?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(W?" af-flow-node__bool-select--true":""),value:W?"true":"false",onChange:an,onPointerDown:$r,onMouseDown:$r,onClick:$r,"aria-label":"Boolean value",title:W?"true":"false",disabled:g,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):M?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ie,onChange:Yt,onCompositionStart:En,onCompositionEnd:hn,onBlur:ue,onPointerDown:$r,onMouseDown:$r,onClick:$r,placeholder:"输入文本",rows:2,readOnly:g}):F?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:$r,onMouseDown:$r,onClick:$r,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:ie,onChange:Yt,onCompositionStart:En,onCompositionEnd:hn,onBlur:ue,placeholder:"选择或输入文件路径",title:ie||"选择或输入文件路径",readOnly:g}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:ke,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):D&&!k?o.jsxs("div",{ref:X,className:"af-flow-node__prompt-stack nodrag",children:[o.jsx("pre",{ref:V,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:PK(me)+`
127
127
  `}}),o.jsx("textarea",{ref:ee,className:"af-flow-node__prompt-editor nodrag",value:me,onChange:rt,onCompositionStart:at,onCompositionEnd:Lt,onBlur:st,onPaste:ar,onDrop:_n,onScroll:gn,onDragOver:ve=>{fg(ve).length>0&&ve.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:g})]}):null,D&&P.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:P.map((ve,$e)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:ve.name,children:[o.jsx("img",{src:ve.dataUrl,alt:""}),o.jsxs("span",{children:["[",ve.label||`image ${$e+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:nt=>Zt(nt,ve),onPointerDown:$r,onMouseDown:$r,"aria-label":`删除 ${ve.label||`image ${$e+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ve.id||$e))}):null,z?o.jsx("span",{className:"af-flow-node__prompt-preview",title:z,children:z}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((ve,$e)=>{if(ve.showOnNode===!1)return null;const nt=f("flow:node.outputTooltip",{name:ve.name||`#${$e}`,type:ve.type})+(ve.default!=null&&ve.default!==""?f("flow:node.defaultSuffix",{value:ve.default}):""),zt=ve.name||`#${$e+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:nt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[zt,ve.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Fs,{type:"source",position:Ze.Right,id:`output-${$e}`,className:"af-flow-node__handle",style:{background:or(ve.type)},title:nt})]},`out-${$e}`)})})]})]})}const Sp="flowNode";function BT(e){if(!e||!(e instanceof Element))return!1;if(e.closest('[contenteditable="true"]'))return!0;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function mg(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function IK(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function WT({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Mn(),a=h.useId(),l=h.useRef(null),[c,d]=h.useState(""),[f,u]=h.useState(!1),[p,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),u(!1);const g=requestAnimationFrame(()=>{var v;return(v=l.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),b=y===n;async function k(g){if(g.preventDefault(),!(!b||f)){u(!0),m("");try{const v=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await v.json().catch(()=>({}));if(!v.ok){m(typeof x.error=="string"?x.error:i("project:archiveModal.archiveFailed"));return}s()}catch(v){m(String((v==null?void 0:v.message)||v))}finally{u(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>d(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!b})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||f,children:i(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function qj({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:f}){const{t:u}=Mn(),p=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const g=requestAnimationFrame(()=>{var x;return(x=m.current)==null?void 0:x.focus()});function v(x){x.key==="Escape"&&f(),x.key==="Enter"&&d()}return window.addEventListener("keydown",v),()=>{cancelAnimationFrame(g),window.removeEventListener("keydown",v)}},[e,f,d]),!e)return null;const y=r??u("common:common.confirm","确定"),b=s??u("common:common.cancel","取消"),k=t??u("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&f()},children:o.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:k}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:f,"aria-label":b,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:f,children:b}),a&&c?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:y})]})]})]})})}function VT({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Mn(),l=h.useId(),c=h.useRef(null),[d,f]=h.useState(""),[u,p]=h.useState(!1),[m,y]=h.useState("");if(h.useEffect(()=>{if(!e)return;f(""),y(""),p(!1);const v=requestAnimationFrame(()=>{var x;return(x=c.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(v)},[e,n]),!e)return null;const b=d.trim(),k=b===n;async function g(v){if(v.preventDefault(),!k||u)return;p(!0),y("");let x=null;try{const N=new AbortController;x=setTimeout(()=>N.abort(),15e3);const _=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:b,flowArchived:s}),signal:N.signal}),C=await _.json().catch(()=>({}));if(!_.ok){y(typeof C.error=="string"?C.error:a("project:deleteModal.deleteFailed"));return}try{for(let T=localStorage.length-1;T>=0;T--){const H=localStorage.key(T);H&&(H.startsWith(`af:composer-sessions:${n}:${r}`)||H.startsWith(`af:composer-active-session:${n}:${r}`)||H.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(H)}}catch{}await i()}catch(N){if((N==null?void 0:N.name)==="AbortError"){y(a("project:deleteModal.deleteTimeout"));return}y(String((N==null?void 0:N.message)||N))}finally{x&&clearTimeout(x),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:g,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:v=>f(v.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!k})]}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||u,children:a(u?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function TK({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Hi({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(TK,{children:t})]},n))})}function UT({open:e,onClose:t}){const{t:n}=Mn(),r=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=IK()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(Hi,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(Hi,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Hi,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(Hi,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(Hi,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(Hi,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(Hi,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(Hi,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(Hi,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(Hi,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(Hi,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function RK(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function KT({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Mn(),[i,a]=h.useState(""),[l,c]=h.useState(0),d=h.useRef(null),f=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var b;return(b=d.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(y)},[e]);const u=h.useMemo(()=>{const y=(r||[]).map(g=>{var v,x,N;return{id:g.id,label:((v=g.data)==null?void 0:v.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((N=g.data)==null?void 0:N.schemaType)||""}}),b=i.trim(),k=y.map(g=>({e:g,s:RK(g,b)})).filter(g=>g.s>0);return k.sort((g,v)=>v.s-g.s||g.e.id.localeCompare(v.e.id)),k.slice(0,50).map(g=>g.e)},[r,i]);if(h.useEffect(()=>{l>=u.length&&c(0)},[u.length,l]),h.useEffect(()=>{var b;const y=(b=f.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=y=>{const b=u[y];b&&(n(b.id),t())},m=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(b=>Math.min(u.length-1,b+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(b=>Math.max(0,b-1));return}y.key==="Enter"&&(y.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:y=>{a(y.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:u.length})]}),u.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:u.map((y,b)=>o.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(b),onMouseDown:k=>{k.preventDefault(),p(b)},children:[o.jsx("span",{className:"af-jump-panel__id",children:y.id}),y.label&&y.label!==y.id&&o.jsx("span",{className:"af-jump-panel__label",children:y.label}),y.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:y.definitionId})]},y.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function LK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=Mn(),f=h.useId(),u=h.useRef(null),p=h.useRef(null),[m,y]=h.useState(""),[b,k]=h.useState(""),[g,v]=h.useState(!1),[x,N]=h.useState(!1),[_,C]=h.useState(!1),[T,H]=h.useState(""),[M,F]=h.useState("");if(h.useEffect(()=>{if(!e||!i)return;y(""),k(""),H(""),F(""),v(!0),N(!1),C(!1);const I=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const P=await fetch(`/api/pipeline-file-content?${I}`),L=await P.json();if(!P.ok)throw new Error(L.error||"HTTP "+P.status);y(L.content||""),k(L.content||"")}catch(P){H(P.message||String(P))}finally{v(!1)}})();const z=requestAnimationFrame(()=>{var P;return(P=u.current)==null?void 0:P.focus()});return()=>cancelAnimationFrame(z)},[e,i,n,r,s]),!e)return null;const D=m!==b;async function $(I){if(I.preventDefault(),!x){N(!0),H(""),F("");try{const z=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),P=await fetch(`/api/pipeline-file-save?${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),L=await P.json();if(!P.ok)throw new Error(L.error||"HTTP "+P.status);k(m),F(d("flow:fileEdit.saved")),l&&l()}catch(z){H(z.message||String(z))}finally{N(!1)}}}async function W(){if(!(!c||_||!m)){C(!0),H("");try{const I=await c(m);typeof I=="string"&&I&&y(I)}catch(I){H(I.message||String(I))}finally{C(!1)}}}function O(){y(b),H(""),F("")}const R=m.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:o.jsxs("div",{ref:u,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:I=>I.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:g?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):T&&!m?o.jsx("div",{className:"af-file-edit-error",children:T}):o.jsxs(o.Fragment,{children:[R&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:m,onChange:I=>y(I.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(T||M)&&!g&&o.jsx("div",{className:`af-file-edit-status${M?" af-file-edit-status--success":""}`,children:M||T}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:O,disabled:!D||x||_,children:d("flow:fileEdit.reset")}),c&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:W,disabled:_||x||!m,children:d(_?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:$,disabled:!D||x||_,children:d(x?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const qT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),MK=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function OK(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function $K(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function Yj(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function YT(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(qT.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function GT(e){return{inputNames:Yj(e==null?void 0:e.inputs),outputNames:Yj(e==null?void 0:e.outputs)}}function DK(e,t,n){const r=GT(t),s=$K(e),i=[];for(const a of s)if(!YT(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function FK(e,t){const n=GT(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],c=YT(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function zK(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function HK(e){return e.map(t=>{const n=zK(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function BK(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of MK)qT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function WK(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function VK(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),d=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function $h({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:f}=Mn(),u=h.useId(),p=h.useRef(null),m=h.useRef(null),[y,b]=h.useState(0),[k,g]=h.useState(0),[v,x]=h.useState(null),N=h.useMemo(()=>Ts(c),[c]),_=h.useMemo(()=>DK(e,a,f),[e,a,f]),C=_.length>0,T=h.useMemo(()=>FK(e,a),[e,a]),H=h.useMemo(()=>HK(T),[T]),M=h.useMemo(()=>n?null:OK(e,y),[e,y,n]),F=h.useMemo(()=>{if(!M)return[];const I=BK(a,f);return WK(I,M.query)},[M,a,f]);h.useEffect(()=>{g(I=>{const z=Math.max(0,F.length-1);return Math.min(Math.max(0,I),z)})},[F.length]);const D=h.useCallback(()=>{const I=p.current;if(!I||!M||F.length===0){x(null);return}const z=VK(I,y);if(!z){x(null);return}const P=4,L=44,E=13.5*16,X=Math.min(F.length*L+8,E);let ee=z.bottom+P;ee+X>window.innerHeight-8&&(ee=Math.max(8,z.top-X-P));const V=288;let ie=z.left;ie=Math.max(8,Math.min(ie,window.innerWidth-V-8)),x({top:ee,left:ie})},[M,F.length,y]);h.useLayoutEffect(()=>{if(!M||F.length===0){x(null);return}const I=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(I)},[M,F.length,y,e,D]),h.useEffect(()=>{if(!M||F.length===0)return;const I=()=>D();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[M,F.length,D]);const $=h.useCallback(I=>{if(!M)return;const{atIndex:z}=M,P=e.slice(0,z)+"${"+I+"}"+e.slice(y);t(P);const L=z+I.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(L,L)),b(L)})},[M,e,y,t]),W=h.useCallback(()=>{const I=p.current,z=m.current;!I||!z||(z.scrollTop=I.scrollTop,z.scrollLeft=I.scrollLeft,M&&F.length>0&&queueMicrotask(()=>D()))},[M,F.length,D]),O=h.useCallback(I=>{if(!n&&M&&F.length>0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter")){if(I.key==="ArrowDown")I.preventDefault(),g(z=>(z+1)%F.length);else if(I.key==="ArrowUp")I.preventDefault(),g(z=>(z-1+F.length)%F.length);else if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();const z=F[k];z&&$(z.insert)}}},[n,M,F,k,$]),R=h.useCallback(async I=>{if(n||typeof d!="function")return!1;const z=await OT({files:I,body:e,images:N});return z?(t(z.body),d(z.images),queueMicrotask(()=>{const P=p.current;if(!P)return;P.focus();const L=z.body.length;P.setSelectionRange(L,L),b(L)}),!0):!1},[n,N,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[N.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:N.map((I,z)=>o.jsxs("span",{className:"af-body-image-chip",title:I.name,children:[o.jsx("img",{src:I.dataUrl,alt:""}),o.jsxs("span",{children:["[",I.label||`image ${z+1}`,"]"]})]},I.id||z))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:H+`
128
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?u:void 0,onChange:I=>{t(I.target.value),b(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onClick:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onKeyUp:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??z.value.length)},onKeyDown:O,onPaste:I=>{const z=MT(I);z.length!==0&&(I.preventDefault(),R(z).catch(()=>{}))},onDragOver:I=>{fg(I).length>0&&I.preventDefault()},onDrop:I=>{const z=fg(I);z.length!==0&&(I.preventDefault(),R(z).catch(()=>{}))},onScroll:W})]}),M&&F.length>0&&v?Fr.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:F.map((I,z)=>o.jsx("li",{role:"option","aria-selected":z===k,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>g(z),onClick:()=>$(I.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,C?o.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:_.map(I=>I.message).join(" · ")}):null]})}const XT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Dh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Gj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Mn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((p,m)=>m!==u)),d=(u,p,m)=>{const y=n.map((b,k)=>{if(k!==u)return b;const g={...b,[p]:m};return p==="required"&&m===!0&&(g.showOnNode=!0),g});r(y)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((u,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function JT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:f,ioSlots:u}){const{t:p}=Mn(),[m,y]=h.useState(!1),[b,k]=h.useState(!1),[g,v]=h.useState({status:"idle",message:""}),x=h.useCallback($=>{t(W=>W&&{...W,...$})},[t]),{cursorList:N,opencodeList:_,claudeCodeList:C,currentNotInLists:T}=h.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],O=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],R=new Set([...$,...W,...O].map(Dh)),I=((e==null?void 0:e.model)??"").trim(),z=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!R.has(z)?I:"";return{cursorList:$,opencodeList:W,claudeCodeList:O,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const H=String(e.script??""),M=n==="tool_nodejs"||H.trim()!=="",F=typeof c=="function"&&!i&&(e==null?void 0:e.newId),D=async()=>{if(F){v({status:"running",message:p("flow:nodeProps.publishRunning")});try{const $=await c(e,n);v({status:"success",message:$!=null&&$.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):p("flow:nodeProps.publishSuccess")})}catch($){v({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!F||g.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,g.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:dl.includes(e.role)?e.role:p("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:i,children:dl.map($=>o.jsx("option",{value:$,children:$},$))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?T||$:""})(),onChange:$=>x({model:$.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),T?o.jsxs("option",{value:T,children:[T,p("flow:nodeProps.yamlValueNotInList")]}):null,N.length>0?o.jsx("optgroup",{label:"Cursor",children:N.map($=>o.jsx("option",{value:Dh($),children:$},`c-${$}`))}):null,_.length>0?o.jsx("optgroup",{label:"OpenCode",children:_.map($=>o.jsx("option",{value:Dh($),children:$},`o-${$}`))}):null,C.length>0?o.jsx("optgroup",{label:"Claude Code",children:C.map($=>o.jsx("option",{value:`claude-code:${Dh($)}`,children:$},`cc-${$}`))}):null]})]}),o.jsx(Gj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:i,requiredReadonly:!d}),o.jsx(Gj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:i,requiredReadonly:!d}),M?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($h,{value:H,onChange:$=>x({script:$}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($h,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&k(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($h,{value:H,onChange:$=>x({script:$}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:$=>{$.target===$.currentTarget&&y(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($h,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function R0(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function UK(e){const t=R0(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function QT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Xj({text:e}){const{t}=Mn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(vp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Jj({o:e}){var r;const{t}=Mn(),n=R0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:QT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(vp,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Qj(e){return UK(e)}function Zj(e){var r;if(!e)return null;const t=R0(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?QT(String(n)):String(n)}function e1({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const t1=2e4,ZT="af:run-node-ctx-width";function mm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function qa(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):qa(mm())}function KK(){try{const e=localStorage.getItem(ZT);if(e==null)return qa(mm());const t=parseInt(e,10);return Number.isFinite(t)?qa(t):qa(mm())}catch{return qa(mm())}}async function n1(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function qK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function YK({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Mn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(KK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,p]=h.useState(!0),[m,y]=h.useState(""),[b,k]=h.useState([]),[g,v]=h.useState(null),[x,N]=h.useState(null),_=h.useRef(null),C=h.useRef(null),T=h.useRef(0),H=h.useRef(0);h.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),L=()=>l(P.matches);return P.addEventListener("change",L),()=>P.removeEventListener("change",L)},[]),h.useEffect(()=>{function P(){d(L=>qa(L))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const M=h.useCallback(()=>{d(P=>{const L=qa(P);try{localStorage.setItem(ZT,String(L))}catch{}return L})},[]),F=h.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const L=P.currentTarget;f.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:c},L.setPointerCapture(P.pointerId)},[a,c]),D=h.useCallback(P=>{const L=f.current;if(!L.active||P.pointerId!==L.pointerId)return;const E=L.startX-P.clientX;d(qa(L.startW+E))},[]),$=h.useCallback(P=>{const L=f.current;if(!(!L.active||P.pointerId!==L.pointerId)){L.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}M()}},[M]),W=h.useCallback(()=>{const P=f.current;P.active&&(P.active=!1,M())},[M]),O=h.useCallback(P=>{const L=Array.isArray(P)?P:[];k(L),v(E=>E&&L.some(X=>X.execId===E)?E:L.length>0?L[L.length-1].execId:null)},[]),R=h.useCallback(()=>{if(!e||!t)return;const P=++T.current,L=new AbortController,E=window.setTimeout(()=>L.abort(),t1);(async()=>{try{const X=await n1(t,e,n,L.signal);if(P!==T.current)return;O(Array.isArray(X.rounds)?X.rounds:[])}catch{}finally{window.clearTimeout(E)}})()},[e,t,n,O]);h.useEffect(()=>{if(!e||!t){p(!1),y(""),k([]);return}const P=++H.current;p(!0),y(""),k([]),v(null);const L=new AbortController,E=window.setTimeout(()=>L.abort(),t1);return(async()=>{try{const X=await n1(t,e,n,L.signal);if(P!==H.current)return;O(Array.isArray(X.rounds)?X.rounds:[])}catch(X){if(P!==H.current)return;const ee=(X==null?void 0:X.name)==="AbortError"?"requestTimeout":X.message||String(X);y(ee)}finally{window.clearTimeout(E),P===H.current&&p(!1)}})(),()=>{L.abort(),H.current++,T.current++}},[e,t,n,O]),h.useEffect(()=>{r&&R()},[r,R]),h.useEffect(()=>{clearInterval(C.current);const P=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(P&&P.status==="running"))&&e&&t&&(C.current=setInterval(()=>R(),2e3)),()=>clearInterval(C.current)},[b,e,t,n,r,R]),h.useEffect(()=>{_.current&&(_.current.scrollTop=0)},[g]);const I=b.find(P=>P.execId===g),z=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:z,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:F,onPointerMove:D,onPointerUp:$,onPointerCancel:$,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:qK(i,m)}),!u&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+XK((I==null?void 0:I.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(g??""),onChange:P=>{const L=P.target.value;v(L==="latest"?"latest":Number(L))},children:[...b].reverse().map(P=>{const L=P.execId==="latest"?i("flow:runContext.latest"):`#${P.execId}`,E=JK(i,P.status),X=P.finishedAt?` · ${GK(P.finishedAt)}`:"";return o.jsx("option",{value:String(P.execId),children:`${L} · ${E}${X}`},P.execId)})})]}),I&&o.jsxs("div",{className:"af-run-ctx-body",ref:_,children:[I.inputs&&I.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,L)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${L}`))]}),I.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Xj,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,L)=>{const E=Qj(P),X=Zj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:E}):null,o.jsx(e1,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Jj,{o:P})]},`${P.slot}-${L}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),x&&I&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&N(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:x==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[x==="prompt"&&I.prompt!=null&&o.jsx(Xj,{text:I.prompt}),x==="output"&&I.outputs&&I.outputs.map((P,L)=>{const E=Qj(P),X=Zj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",children:E}):null,o.jsx(e1,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Jj,{o:P})]},`${P.slot}-${L}`)})]})]})})]})}function GK(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function XK(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function JK(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function QK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Mn(),[d,f]=h.useState({}),[u,p]=h.useState(null),[m,y]=h.useState({}),[b,k]=h.useState(!0),[g,v]=h.useState(!1),[x,N]=h.useState(""),[_,C]=h.useState(!1),[T,H]=h.useState(null),M=h.useRef(null),F=h.useRef(!0),D=h.useRef({});h.useMemo(()=>{var E,X,ee;const L={};for(const V of r){const ie=(ee=(X=(E=V.data)==null?void 0:E.outputs)==null?void 0:X[0])==null?void 0:ee.default;ie!=null&&ie!==""&&(L[V.id]=String(ie))}return D.current=L,L},[r]);const $=h.useMemo(()=>{var E;const L={};for(const X of i){if(!((E=X.data)!=null&&E.inputs))continue;const ee=X.data.inputs;for(let V=0;V<ee.length;V++){const ie=ee[V];if(!(ie!=null&&ie.name))continue;const fe=s.find(ge=>ge.target===X.id&&ge.targetHandle===`input-${V}`);if(!(fe!=null&&fe.source))continue;r.find(ge=>ge.id===fe.source)&&(L[fe.source]=ie.name)}}return L},[i,s,r]);h.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),h.useEffect(()=>{if(!e){k(!1);return}k(!0);const L=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&L.set("archived","1"),fetch(`/api/flow/run-config?${L.toString()}`).then(E=>{if(!E.ok)throw new Error(`HTTP ${E.status}`);return E.json()}).then(E=>{var ee;if(!F.current)return;f(E.presets||{}),p(E.activePreset||null);const X=E.activePreset&&((ee=E.presets)!=null&&ee[E.activePreset])?E.presets[E.activePreset]:{};y({...D.current,...X}),k(!1)}).catch(()=>{F.current&&(y(D.current),k(!1))})},[e,t,n]),h.useEffect(()=>{var E;if(!a)return;const L={};for(const[X,ee]of Object.entries(m)){const V=$[X];if(!V)continue;const ie=r.find(me=>me.id===X);if(!ie)continue;(((E=ie.data)==null?void 0:E.definitionId)||"").startsWith("provide_file")?L[V]={type:"file",path:ee}:L[V]={type:"str",value:ee}}a(L)},[m,$,r,a]);const W=h.useCallback((L,E)=>{y(X=>({...X,[L]:E}))},[]),O=h.useCallback(L=>{L!==u&&(p(L),L&&d[L]?y({...D.current,...d[L]}):y(D.current))},[u,d]),R=h.useCallback(async()=>{if(x.trim()){v(!0);try{const L={...d,[x.trim()]:m},E={flowId:e,flowSource:t,archived:n,presets:L,activePreset:x.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&(f(L),p(x.trim()),N(""),C(!1))}finally{v(!1)}}},[e,t,n,d,m,x]),I=h.useCallback(async()=>{if(u){v(!0);try{const L={...d};delete L[u];const E=Object.keys(L)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:E})})).ok&&(f(L),p(E),E&&L[E]?y({...D.current,...L[E]}):y(D.current))}finally{v(!1)}}},[e,t,n,d,u]),z=h.useCallback(async()=>{if(u){v(!0);try{const L={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:u})})).ok&&f(L)}finally{v(!1)}}},[e,t,n,d,u,m]),P=Object.keys(d);return P.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:L=>O(L.target.value||null),disabled:g,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),P.map(L=>o.jsx("option",{value:L,children:L},L))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>C(!0),disabled:g,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:z,disabled:g,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:g,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),_&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:x,onChange:L=>N(L.target.value),disabled:g}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:R,disabled:g||!x.trim(),children:c(g?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{C(!1),N("")},disabled:g,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(L=>{var ge,Z;const E=((ge=L.data)==null?void 0:ge.definitionId)||"",X=E.startsWith("provide_file"),ee=E==="provide_bool",V=((Z=L.data)==null?void 0:Z.label)||L.id,ie=L.id,fe=m[ie]||"",me=["true","1","yes","on"].includes(String(fe).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(X?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:X?"description":ee?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),ee?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>H({instanceId:ie,label:V,content:fe}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ie}),ee?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(me?" af-run-config-bool-toggle--true":""),onClick:()=>W(ie,me?"false":"true"),"aria-pressed":me,children:me?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:fe,onChange:ae=>W(ie,ae.target.value),placeholder:c(X?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ie)})})]}),T&&Fr.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:T.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>H(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:M,className:"af-provide-edit-modal__textarea",defaultValue:T.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!T||!M.current||(W(T.instanceId,M.current.value),H(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>H(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const e2={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},ZK={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function e7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function t7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function n7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function r1(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(e2))if(r.includes(e))return n;return"other"}function r7({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=ZK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const y=i[m];return y==null?`${m}:null`:typeof y=="object"?`${m}:{…}`:`${m}:${String(y).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(u=>{u.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:t7(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function s7({open:e,onClose:t,flowId:n}){var H;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,c]=h.useState(null),[d,f]=h.useState(null),[u,p]=h.useState(!1),[m,y]=h.useState(!0),[b,k]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[g,v]=h.useState(""),x=h.useRef(null),N=h.useCallback(async()=>{a(!0);try{const M=m&&n?`?flowId=${encodeURIComponent(n)}`:"",D=await(await fetch(`/api/composer-logs${M}`)).json();s(Array.isArray(D.sessions)?D.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),_=h.useCallback(async M=>{if(!M){f(null);return}p(!0);try{const D=await(await fetch(`/api/composer-logs/${encodeURIComponent(M)}`)).json();f(D)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&N()},[e,N]),h.useEffect(()=>{if(!(!e||!l))return _(l),x.current=setInterval(()=>_(l),2e3),()=>{x.current&&clearInterval(x.current),x.current=null}},[e,l,_]);const C=h.useMemo(()=>{const M=(d==null?void 0:d.events)||[],F=g.trim().toLowerCase();return M.filter(D=>{const $=r1(D.tag,D.payload);return!b[$]&&$!=="other"?!1:F?[D.tag,JSON.stringify(D.payload||"")].join(" ").toLowerCase().includes(F):!0})},[d,b,g]),T=h.useMemo(()=>{const M=(d==null?void 0:d.events)||[],F={};for(const D of M){const $=r1(D.tag,D.payload);F[$]=(F[$]||0)+1}return F},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:M=>y(M.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:N,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(M=>{const F=l===M.sessionId;return o.jsxs("div",{onClick:()=>c(M.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:F?"rgba(124,77,255,0.18)":"transparent",borderLeft:F?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:n7(M.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:M.flowId||"(no flow)"}),M.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:M.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[e7(M.size)," · ",M.model||"default"]})]},M.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(e2).map(M=>o.jsxs("button",{type:"button",onClick:()=>k(F=>({...F,[M]:!F[M]})),style:{background:b[M]?"rgba(124,77,255,0.25)":"transparent",color:b[M]?"#e8deff":"#6a6a6a",border:`1px solid ${b[M]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[M," ",T[M]!=null?`(${T[M]})`:""]},M)),o.jsx("input",{type:"text",placeholder:"search…",value:g,onChange:M=>v(M.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&C.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((H=d.events)==null?void 0:H.length)||0," total)"]}),C.map((M,F)=>o.jsx(r7,{event:M,defaultExpanded:M.tag==="error"},`${M.ts}_${F}`))]})]})]})]}):null}const i7="0.1.64";function s1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Mx(e,t){return t==="running"?s1(e):e==null||!Number.isFinite(e)||e<=0?"--":s1(e)}const t2=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function o7(e){var v,x,N,_,C,T,H,M,F,D,$;const{setNodes:t}=wc(),n=u0(),{modelLists:r,onModelChange:s}=h.useContext(t2),i=h.useRef(null),a=!!((v=e.data)!=null&&v.readOnly),l=(x=e.data)!=null&&x.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((N=e.data)==null?void 0:N.definitionId)==="agent_subAgent"&&!((_=e.data)!=null&&_.isRunMode)&&!a,d=h.useCallback(W=>{const O=()=>n(W);window.requestAnimationFrame(O),window.setTimeout(O,80)},[n]),f=h.useCallback((W,O)=>{const R=f1(O);R&&(t(I=>I.map(z=>{var E,X,ee,V,ie,fe;if(z.id!==W)return z;const P=Number(((X=(E=z.data)==null?void 0:E.displaySize)==null?void 0:X.width)||z.width||((ee=z.measured)==null?void 0:ee.width)||0),L=Number(((ie=(V=z.data)==null?void 0:V.displaySize)==null?void 0:ie.height)||z.height||((fe=z.measured)==null?void 0:fe.height)||0);return Math.abs(P-R.width)<2&&Math.abs(L-R.height)<2?z:{...z,width:R.width,height:R.height,data:{...z.data,displaySize:R}}})),d(W))},[d,t]),u=h.useCallback(W=>{if(a)return;const O=i.current;if(!O)return;const R=O.getBoundingClientRect();f(W,{width:Math.max(R.width,O.scrollWidth),height:Math.max(R.height,O.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var ie,fe,me,ge,Z,ae;if(!c)return;W.preventDefault(),W.stopPropagation();const O=i.current,R=O==null?void 0:O.getBoundingClientRect(),I=Number(((fe=(ie=e.data)==null?void 0:ie.displaySize)==null?void 0:fe.width)||e.width||((me=e.measured)==null?void 0:me.width)||(R==null?void 0:R.width)||i2),z=Number(((Z=(ge=e.data)==null?void 0:ge.displaySize)==null?void 0:Z.height)||e.height||((ae=e.measured)==null?void 0:ae.height)||(R==null?void 0:R.height)||Ob),P=W.clientX,L=W.clientY,E=e.id;let X=0;const ee=xe=>{const pe=f1({width:I+xe.clientX-P,height:z+xe.clientY-L});pe&&(window.cancelAnimationFrame(X),X=window.requestAnimationFrame(()=>f(E,pe)))},V=()=>{window.cancelAnimationFrame(X),window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(E)};window.addEventListener("pointermove",ee),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,(T=(C=e.data)==null?void 0:C.displaySize)==null?void 0:T.height,(M=(H=e.data)==null?void 0:H.displaySize)==null?void 0:M.width,e.height,e.id,(F=e.measured)==null?void 0:F.height,(D=e.measured)==null?void 0:D.width,e.width,d,c]),m=h.useCallback(W=>{t(O=>O.filter(R=>R.id!==W))},[t]),y=h.useCallback(()=>{var I,z,P,L,E,X,ee,V;const W=((I=e.data)==null?void 0:I.definitionId)||"",O=((z=e.data)==null?void 0:z.label)||e.id,R=((E=(L=(P=e.data)==null?void 0:P.outputs)==null?void 0:L[0])==null?void 0:E.value)||((V=(ee=(X=e.data)==null?void 0:X.outputs)==null?void 0:ee[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:O,definitionId:W,content:R},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,O)=>{t(R=>R.map(I=>{var P;if(I.id!==W)return I;const z=Array.isArray((P=I.data)==null?void 0:P.outputs)&&I.data.outputs.length?I.data.outputs.map((L,E)=>E===0?{...L,default:O,value:O}:L):[{type:"bool",name:"value",default:O,value:O}];return{...I,data:{...I.data,body:"",outputs:z}}}))},[t]),k=h.useCallback((W,O)=>{t(R=>R.map(I=>I.id===W?{...I,data:{...I.data,body:O}}:I))},[t]),g=h.useCallback((W,O)=>{t(R=>R.map(I=>I.id===W?{...I,data:{...I.data,images:Ts(O)}}:I))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx(HT,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:y,onProvideValueChange:b,onNodeBodyChange:k,onNodeImagesChange:g,modelLists:r,onModelChange:s}),c?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":(($=e.data)==null?void 0:$.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const a7={[Sp]:o7},Jd=["CONTROL","TOOL","PROVIDE","AGENT"],l7=1200,i1="af-flow-node--sync-flash",o1="af-flow-edge--sync-flash";function a1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function l1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function L0(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function c7(e){const t=L0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Fh(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function n2(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function r2(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Ox(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function c1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function u1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function u7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function d7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function s2(e,t,n,r,s){const i=c7(e),a={id:t,type:Sp,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return tp(a,r,s)}const i2=320,f7=220,p7=1600,Ob=104,h7=900;function d1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function f1(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:d1(t,f7,p7)||i2,height:d1(n,Ob,h7)||Ob}}function m7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function p1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=zu(i,e.sourceHandle||"output-0","source"),c=zu(a,e.targetHandle||"input-0","target");return!l||!c?!1:Fu(l,c)}function g7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=zu(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:zT(a)}:null}function y7(e,t,n){var a;const r=s2(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Fu(n.slot,c):Fu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function x7(e,t){return t?e.map((n,r)=>{const s=y7(n,e,t);if(!s)return null;const i=L0(n);return{def:n,order:r,category:i,categoryRank:Jd.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:n2(s.hydrated.data||n),description:r2(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const w7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function b7(e){const t=new Set,n=[];let r;const s=new RegExp(w7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function h1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function Zo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function zh(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(Zo),d=a.map(Zo);return l.map(Zo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function v7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function $x(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function k7({steps:e}){const{t}=Mn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
128
+ `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?u:void 0,onChange:I=>{t(I.target.value),b(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onClick:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onKeyUp:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??z.value.length)},onKeyDown:O,onPaste:I=>{const z=MT(I);z.length!==0&&(I.preventDefault(),R(z).catch(()=>{}))},onDragOver:I=>{fg(I).length>0&&I.preventDefault()},onDrop:I=>{const z=fg(I);z.length!==0&&(I.preventDefault(),R(z).catch(()=>{}))},onScroll:W})]}),M&&F.length>0&&v?Fr.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:F.map((I,z)=>o.jsx("li",{role:"option","aria-selected":z===k,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>g(z),onClick:()=>$(I.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,C?o.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:_.map(I=>I.message).join(" · ")}):null]})}const XT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Dh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Gj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Mn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((p,m)=>m!==u)),d=(u,p,m)=>{const y=n.map((b,k)=>{if(k!==u)return b;const g={...b,[p]:m};return p==="required"&&m===!0&&(g.showOnNode=!0),g});r(y)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((u,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function JT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:f,ioSlots:u}){const{t:p}=Mn(),[m,y]=h.useState(!1),[b,k]=h.useState(!1),[g,v]=h.useState({status:"idle",message:""}),x=h.useCallback($=>{t(W=>W&&{...W,...$})},[t]),{cursorList:N,opencodeList:_,claudeCodeList:C,currentNotInLists:T}=h.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],O=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],R=new Set([...$,...W,...O].map(Dh)),I=((e==null?void 0:e.model)??"").trim(),z=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!R.has(z)?I:"";return{cursorList:$,opencodeList:W,claudeCodeList:O,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const H=String(e.script??""),M=n==="tool_nodejs"||H.trim()!=="",F=typeof c=="function"&&!i&&(e==null?void 0:e.newId),D=async()=>{if(F){v({status:"running",message:p("flow:nodeProps.publishRunning")});try{const $=await c(e,n);v({status:"success",message:$!=null&&$.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):p("flow:nodeProps.publishSuccess")})}catch($){v({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!F||g.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,g.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:dl.includes(e.role)?e.role:p("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:i,children:dl.map($=>o.jsx("option",{value:$,children:$},$))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?T||$:""})(),onChange:$=>x({model:$.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),T?o.jsxs("option",{value:T,children:[T,p("flow:nodeProps.yamlValueNotInList")]}):null,N.length>0?o.jsx("optgroup",{label:"Cursor",children:N.map($=>o.jsx("option",{value:Dh($),children:$},`c-${$}`))}):null,_.length>0?o.jsx("optgroup",{label:"OpenCode",children:_.map($=>o.jsx("option",{value:Dh($),children:$},`o-${$}`))}):null,C.length>0?o.jsx("optgroup",{label:"Claude Code",children:C.map($=>o.jsx("option",{value:`claude-code:${Dh($)}`,children:$},`cc-${$}`))}):null]})]}),o.jsx(Gj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:i,requiredReadonly:!d}),o.jsx(Gj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:i,requiredReadonly:!d}),M?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($h,{value:H,onChange:$=>x({script:$}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($h,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&k(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($h,{value:H,onChange:$=>x({script:$}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:$=>{$.target===$.currentTarget&&y(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($h,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function R0(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function UK(e){const t=R0(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function QT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Xj({text:e}){const{t}=Mn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(vp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Jj({o:e}){var r;const{t}=Mn(),n=R0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:QT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(vp,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Qj(e){return UK(e)}function Zj(e){var r;if(!e)return null;const t=R0(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?QT(String(n)):String(n)}function e1({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const t1=2e4,ZT="af:run-node-ctx-width";function mm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function qa(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):qa(mm())}function KK(){try{const e=localStorage.getItem(ZT);if(e==null)return qa(mm());const t=parseInt(e,10);return Number.isFinite(t)?qa(t):qa(mm())}catch{return qa(mm())}}async function n1(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function qK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function YK({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Mn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(KK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,p]=h.useState(!0),[m,y]=h.useState(""),[b,k]=h.useState([]),[g,v]=h.useState(null),[x,N]=h.useState(null),_=h.useRef(null),C=h.useRef(null),T=h.useRef(0),H=h.useRef(0);h.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),L=()=>l(P.matches);return P.addEventListener("change",L),()=>P.removeEventListener("change",L)},[]),h.useEffect(()=>{function P(){d(L=>qa(L))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const M=h.useCallback(()=>{d(P=>{const L=qa(P);try{localStorage.setItem(ZT,String(L))}catch{}return L})},[]),F=h.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const L=P.currentTarget;f.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:c},L.setPointerCapture(P.pointerId)},[a,c]),D=h.useCallback(P=>{const L=f.current;if(!L.active||P.pointerId!==L.pointerId)return;const E=L.startX-P.clientX;d(qa(L.startW+E))},[]),$=h.useCallback(P=>{const L=f.current;if(!(!L.active||P.pointerId!==L.pointerId)){L.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}M()}},[M]),W=h.useCallback(()=>{const P=f.current;P.active&&(P.active=!1,M())},[M]),O=h.useCallback(P=>{const L=Array.isArray(P)?P:[];k(L),v(E=>E&&L.some(X=>X.execId===E)?E:L.length>0?L[L.length-1].execId:null)},[]),R=h.useCallback(()=>{if(!e||!t)return;const P=++T.current,L=new AbortController,E=window.setTimeout(()=>L.abort(),t1);(async()=>{try{const X=await n1(t,e,n,L.signal);if(P!==T.current)return;O(Array.isArray(X.rounds)?X.rounds:[])}catch{}finally{window.clearTimeout(E)}})()},[e,t,n,O]);h.useEffect(()=>{if(!e||!t){p(!1),y(""),k([]);return}const P=++H.current;p(!0),y(""),k([]),v(null);const L=new AbortController,E=window.setTimeout(()=>L.abort(),t1);return(async()=>{try{const X=await n1(t,e,n,L.signal);if(P!==H.current)return;O(Array.isArray(X.rounds)?X.rounds:[])}catch(X){if(P!==H.current)return;const ee=(X==null?void 0:X.name)==="AbortError"?"requestTimeout":X.message||String(X);y(ee)}finally{window.clearTimeout(E),P===H.current&&p(!1)}})(),()=>{L.abort(),H.current++,T.current++}},[e,t,n,O]),h.useEffect(()=>{r&&R()},[r,R]),h.useEffect(()=>{clearInterval(C.current);const P=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(P&&P.status==="running"))&&e&&t&&(C.current=setInterval(()=>R(),2e3)),()=>clearInterval(C.current)},[b,e,t,n,r,R]),h.useEffect(()=>{_.current&&(_.current.scrollTop=0)},[g]);const I=b.find(P=>P.execId===g),z=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:z,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:F,onPointerMove:D,onPointerUp:$,onPointerCancel:$,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:qK(i,m)}),!u&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+XK((I==null?void 0:I.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(g??""),onChange:P=>{const L=P.target.value;v(L==="latest"?"latest":Number(L))},children:[...b].reverse().map(P=>{const L=P.execId==="latest"?i("flow:runContext.latest"):`#${P.execId}`,E=JK(i,P.status),X=P.finishedAt?` · ${GK(P.finishedAt)}`:"";return o.jsx("option",{value:String(P.execId),children:`${L} · ${E}${X}`},P.execId)})})]}),I&&o.jsxs("div",{className:"af-run-ctx-body",ref:_,children:[I.inputs&&I.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,L)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${L}`))]}),I.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Xj,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,L)=>{const E=Qj(P),X=Zj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:E}):null,o.jsx(e1,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Jj,{o:P})]},`${P.slot}-${L}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),x&&I&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&N(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:x==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[x==="prompt"&&I.prompt!=null&&o.jsx(Xj,{text:I.prompt}),x==="output"&&I.outputs&&I.outputs.map((P,L)=>{const E=Qj(P),X=Zj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",children:E}):null,o.jsx(e1,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Jj,{o:P})]},`${P.slot}-${L}`)})]})]})})]})}function GK(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function XK(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function JK(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function QK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Mn(),[d,f]=h.useState({}),[u,p]=h.useState(null),[m,y]=h.useState({}),[b,k]=h.useState(!0),[g,v]=h.useState(!1),[x,N]=h.useState(""),[_,C]=h.useState(!1),[T,H]=h.useState(null),M=h.useRef(null),F=h.useRef(!0),D=h.useRef({});h.useMemo(()=>{var E,X,ee;const L={};for(const V of r){const ie=(ee=(X=(E=V.data)==null?void 0:E.outputs)==null?void 0:X[0])==null?void 0:ee.default;ie!=null&&ie!==""&&(L[V.id]=String(ie))}return D.current=L,L},[r]);const $=h.useMemo(()=>{var E;const L={};for(const X of i){if(!((E=X.data)!=null&&E.inputs))continue;const ee=X.data.inputs;for(let V=0;V<ee.length;V++){const ie=ee[V];if(!(ie!=null&&ie.name))continue;const fe=s.find(ge=>ge.target===X.id&&ge.targetHandle===`input-${V}`);if(!(fe!=null&&fe.source))continue;r.find(ge=>ge.id===fe.source)&&(L[fe.source]=ie.name)}}return L},[i,s,r]);h.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),h.useEffect(()=>{if(!e){k(!1);return}k(!0);const L=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&L.set("archived","1"),fetch(`/api/flow/run-config?${L.toString()}`).then(E=>{if(!E.ok)throw new Error(`HTTP ${E.status}`);return E.json()}).then(E=>{var ee;if(!F.current)return;f(E.presets||{}),p(E.activePreset||null);const X=E.activePreset&&((ee=E.presets)!=null&&ee[E.activePreset])?E.presets[E.activePreset]:{};y({...D.current,...X}),k(!1)}).catch(()=>{F.current&&(y(D.current),k(!1))})},[e,t,n]),h.useEffect(()=>{var E;if(!a)return;const L={};for(const[X,ee]of Object.entries(m)){const V=$[X];if(!V)continue;const ie=r.find(me=>me.id===X);if(!ie)continue;(((E=ie.data)==null?void 0:E.definitionId)||"").startsWith("provide_file")?L[V]={type:"file",path:ee}:L[V]={type:"str",value:ee}}a(L)},[m,$,r,a]);const W=h.useCallback((L,E)=>{y(X=>({...X,[L]:E}))},[]),O=h.useCallback(L=>{L!==u&&(p(L),L&&d[L]?y({...D.current,...d[L]}):y(D.current))},[u,d]),R=h.useCallback(async()=>{if(x.trim()){v(!0);try{const L={...d,[x.trim()]:m},E={flowId:e,flowSource:t,archived:n,presets:L,activePreset:x.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&(f(L),p(x.trim()),N(""),C(!1))}finally{v(!1)}}},[e,t,n,d,m,x]),I=h.useCallback(async()=>{if(u){v(!0);try{const L={...d};delete L[u];const E=Object.keys(L)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:E})})).ok&&(f(L),p(E),E&&L[E]?y({...D.current,...L[E]}):y(D.current))}finally{v(!1)}}},[e,t,n,d,u]),z=h.useCallback(async()=>{if(u){v(!0);try{const L={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:u})})).ok&&f(L)}finally{v(!1)}}},[e,t,n,d,u,m]),P=Object.keys(d);return P.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:L=>O(L.target.value||null),disabled:g,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),P.map(L=>o.jsx("option",{value:L,children:L},L))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>C(!0),disabled:g,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:z,disabled:g,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:g,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),_&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:x,onChange:L=>N(L.target.value),disabled:g}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:R,disabled:g||!x.trim(),children:c(g?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{C(!1),N("")},disabled:g,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(L=>{var ge,Z;const E=((ge=L.data)==null?void 0:ge.definitionId)||"",X=E.startsWith("provide_file"),ee=E==="provide_bool",V=((Z=L.data)==null?void 0:Z.label)||L.id,ie=L.id,fe=m[ie]||"",me=["true","1","yes","on"].includes(String(fe).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(X?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:X?"description":ee?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),ee?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>H({instanceId:ie,label:V,content:fe}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ie}),ee?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(me?" af-run-config-bool-toggle--true":""),onClick:()=>W(ie,me?"false":"true"),"aria-pressed":me,children:me?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:fe,onChange:ae=>W(ie,ae.target.value),placeholder:c(X?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ie)})})]}),T&&Fr.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:T.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>H(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:M,className:"af-provide-edit-modal__textarea",defaultValue:T.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!T||!M.current||(W(T.instanceId,M.current.value),H(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>H(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const e2={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},ZK={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function e7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function t7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function n7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function r1(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(e2))if(r.includes(e))return n;return"other"}function r7({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=ZK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const y=i[m];return y==null?`${m}:null`:typeof y=="object"?`${m}:{…}`:`${m}:${String(y).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(u=>{u.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:t7(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function s7({open:e,onClose:t,flowId:n}){var H;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,c]=h.useState(null),[d,f]=h.useState(null),[u,p]=h.useState(!1),[m,y]=h.useState(!0),[b,k]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[g,v]=h.useState(""),x=h.useRef(null),N=h.useCallback(async()=>{a(!0);try{const M=m&&n?`?flowId=${encodeURIComponent(n)}`:"",D=await(await fetch(`/api/composer-logs${M}`)).json();s(Array.isArray(D.sessions)?D.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),_=h.useCallback(async M=>{if(!M){f(null);return}p(!0);try{const D=await(await fetch(`/api/composer-logs/${encodeURIComponent(M)}`)).json();f(D)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&N()},[e,N]),h.useEffect(()=>{if(!(!e||!l))return _(l),x.current=setInterval(()=>_(l),2e3),()=>{x.current&&clearInterval(x.current),x.current=null}},[e,l,_]);const C=h.useMemo(()=>{const M=(d==null?void 0:d.events)||[],F=g.trim().toLowerCase();return M.filter(D=>{const $=r1(D.tag,D.payload);return!b[$]&&$!=="other"?!1:F?[D.tag,JSON.stringify(D.payload||"")].join(" ").toLowerCase().includes(F):!0})},[d,b,g]),T=h.useMemo(()=>{const M=(d==null?void 0:d.events)||[],F={};for(const D of M){const $=r1(D.tag,D.payload);F[$]=(F[$]||0)+1}return F},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:M=>y(M.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:N,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(M=>{const F=l===M.sessionId;return o.jsxs("div",{onClick:()=>c(M.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:F?"rgba(124,77,255,0.18)":"transparent",borderLeft:F?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:n7(M.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:M.flowId||"(no flow)"}),M.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:M.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[e7(M.size)," · ",M.model||"default"]})]},M.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(e2).map(M=>o.jsxs("button",{type:"button",onClick:()=>k(F=>({...F,[M]:!F[M]})),style:{background:b[M]?"rgba(124,77,255,0.25)":"transparent",color:b[M]?"#e8deff":"#6a6a6a",border:`1px solid ${b[M]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[M," ",T[M]!=null?`(${T[M]})`:""]},M)),o.jsx("input",{type:"text",placeholder:"search…",value:g,onChange:M=>v(M.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&C.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((H=d.events)==null?void 0:H.length)||0," total)"]}),C.map((M,F)=>o.jsx(r7,{event:M,defaultExpanded:M.tag==="error"},`${M.ts}_${F}`))]})]})]})]}):null}const i7="0.1.66";function s1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Mx(e,t){return t==="running"?s1(e):e==null||!Number.isFinite(e)||e<=0?"--":s1(e)}const t2=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function o7(e){var v,x,N,_,C,T,H,M,F,D,$;const{setNodes:t}=wc(),n=u0(),{modelLists:r,onModelChange:s}=h.useContext(t2),i=h.useRef(null),a=!!((v=e.data)!=null&&v.readOnly),l=(x=e.data)!=null&&x.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((N=e.data)==null?void 0:N.definitionId)==="agent_subAgent"&&!((_=e.data)!=null&&_.isRunMode)&&!a,d=h.useCallback(W=>{const O=()=>n(W);window.requestAnimationFrame(O),window.setTimeout(O,80)},[n]),f=h.useCallback((W,O)=>{const R=f1(O);R&&(t(I=>I.map(z=>{var E,X,ee,V,ie,fe;if(z.id!==W)return z;const P=Number(((X=(E=z.data)==null?void 0:E.displaySize)==null?void 0:X.width)||z.width||((ee=z.measured)==null?void 0:ee.width)||0),L=Number(((ie=(V=z.data)==null?void 0:V.displaySize)==null?void 0:ie.height)||z.height||((fe=z.measured)==null?void 0:fe.height)||0);return Math.abs(P-R.width)<2&&Math.abs(L-R.height)<2?z:{...z,width:R.width,height:R.height,data:{...z.data,displaySize:R}}})),d(W))},[d,t]),u=h.useCallback(W=>{if(a)return;const O=i.current;if(!O)return;const R=O.getBoundingClientRect();f(W,{width:Math.max(R.width,O.scrollWidth),height:Math.max(R.height,O.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var ie,fe,me,ge,Z,ae;if(!c)return;W.preventDefault(),W.stopPropagation();const O=i.current,R=O==null?void 0:O.getBoundingClientRect(),I=Number(((fe=(ie=e.data)==null?void 0:ie.displaySize)==null?void 0:fe.width)||e.width||((me=e.measured)==null?void 0:me.width)||(R==null?void 0:R.width)||i2),z=Number(((Z=(ge=e.data)==null?void 0:ge.displaySize)==null?void 0:Z.height)||e.height||((ae=e.measured)==null?void 0:ae.height)||(R==null?void 0:R.height)||Ob),P=W.clientX,L=W.clientY,E=e.id;let X=0;const ee=xe=>{const pe=f1({width:I+xe.clientX-P,height:z+xe.clientY-L});pe&&(window.cancelAnimationFrame(X),X=window.requestAnimationFrame(()=>f(E,pe)))},V=()=>{window.cancelAnimationFrame(X),window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(E)};window.addEventListener("pointermove",ee),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,(T=(C=e.data)==null?void 0:C.displaySize)==null?void 0:T.height,(M=(H=e.data)==null?void 0:H.displaySize)==null?void 0:M.width,e.height,e.id,(F=e.measured)==null?void 0:F.height,(D=e.measured)==null?void 0:D.width,e.width,d,c]),m=h.useCallback(W=>{t(O=>O.filter(R=>R.id!==W))},[t]),y=h.useCallback(()=>{var I,z,P,L,E,X,ee,V;const W=((I=e.data)==null?void 0:I.definitionId)||"",O=((z=e.data)==null?void 0:z.label)||e.id,R=((E=(L=(P=e.data)==null?void 0:P.outputs)==null?void 0:L[0])==null?void 0:E.value)||((V=(ee=(X=e.data)==null?void 0:X.outputs)==null?void 0:ee[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:O,definitionId:W,content:R},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,O)=>{t(R=>R.map(I=>{var P;if(I.id!==W)return I;const z=Array.isArray((P=I.data)==null?void 0:P.outputs)&&I.data.outputs.length?I.data.outputs.map((L,E)=>E===0?{...L,default:O,value:O}:L):[{type:"bool",name:"value",default:O,value:O}];return{...I,data:{...I.data,body:"",outputs:z}}}))},[t]),k=h.useCallback((W,O)=>{t(R=>R.map(I=>I.id===W?{...I,data:{...I.data,body:O}}:I))},[t]),g=h.useCallback((W,O)=>{t(R=>R.map(I=>I.id===W?{...I,data:{...I.data,images:Ts(O)}}:I))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx(HT,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:y,onProvideValueChange:b,onNodeBodyChange:k,onNodeImagesChange:g,modelLists:r,onModelChange:s}),c?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":(($=e.data)==null?void 0:$.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const a7={[Sp]:o7},Jd=["CONTROL","TOOL","PROVIDE","AGENT"],l7=1200,i1="af-flow-node--sync-flash",o1="af-flow-edge--sync-flash";function a1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function l1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function L0(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function c7(e){const t=L0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Fh(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function n2(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function r2(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Ox(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function c1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function u1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function u7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function d7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function s2(e,t,n,r,s){const i=c7(e),a={id:t,type:Sp,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return tp(a,r,s)}const i2=320,f7=220,p7=1600,Ob=104,h7=900;function d1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function f1(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:d1(t,f7,p7)||i2,height:d1(n,Ob,h7)||Ob}}function m7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function p1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=zu(i,e.sourceHandle||"output-0","source"),c=zu(a,e.targetHandle||"input-0","target");return!l||!c?!1:Fu(l,c)}function g7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=zu(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:zT(a)}:null}function y7(e,t,n){var a;const r=s2(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Fu(n.slot,c):Fu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function x7(e,t){return t?e.map((n,r)=>{const s=y7(n,e,t);if(!s)return null;const i=L0(n);return{def:n,order:r,category:i,categoryRank:Jd.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:n2(s.hydrated.data||n),description:r2(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const w7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function b7(e){const t=new Set,n=[];let r;const s=new RegExp(w7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function h1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function Zo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function zh(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(Zo),d=a.map(Zo);return l.map(Zo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function v7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function $x(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function k7({steps:e}){const{t}=Mn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
129
  `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:v7(s)}):null]}):null})]},n.index)})})}function S7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function N7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
130
  ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function j7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function C7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function m1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=Mn(),a=h.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return h.useEffect(()=>{if(!s||!a.current)return;const c=a.current;requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(g1,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(g1,{segments:t,running:n})})]})}function g1({segments:e,running:t=!1}){const{t:n}=Mn(),r=e.filter(u=>u.kind==="assistant").map(u=>u.text).join(""),s=e.filter(u=>u.kind==="result").map(u=>u.text).join(""),i=S7(r,s),a=e.filter(u=>u.kind==="error").map(u=>u.text).join(`
131
131
  `),l=e.filter(u=>u.kind!=="error"),c=i?l.filter(u=>u.kind!=="result"):l,d=N7(c),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((u,p)=>o.jsxs("section",{className:C7(u.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:j7(u.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`${u.kind}-${p}`)),t&&!f?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function E7({fitViewEpoch:e}){const{fitView:t}=wc(),n=h.useRef(t);return n.current=t,h.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function _7({onReady:e}){const t=u0();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function y1(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function x1(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}const gm=1500,w1=500,P7=262144,A7=2e3;function Dx(e){return typeof e!="string"?"":e.length<=A7?e:`[log line truncated, ${e.length} chars]`}const I7=gm;function T7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:Dx(s)}}catch{return{ts:n,type:"info",text:Dx(s)}}return{ts:n,type:"log",text:Dx(`[${r}] ${s}`)}}function b1(e){if(!e)return[];const t=[],n=e.split(`
132
- `);for(let r=n.length-1;r>=0&&t.length<I7;r--){const s=n[r];if(!s)continue;const i=T7(s);i&&t.push(i)}return t.reverse(),t}function R7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const i=e[s],a=t[s];if(!a)return!1;if(i!==a&&(i.status!==a.status||(i.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function L7(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function M7({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:f,onNodeClick:u,onNodeDoubleClick:p,onEdgeClick:m,onFlowInit:y,onDrop:b,onDragOver:k,hideMinimapAndControls:g,bottomSlot:v}){const{t:x}=Mn(),N=!s,_=N||t==="pan"?!0:[1,2],C=N?!1:t==="select",T="af-flow-canvas"+(N?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),H=h.useCallback(()=>{},[]),M=h.useMemo(()=>{const F=new Map(n.map(R=>[R.id,R])),D=new Set(n.filter(R=>R.selected).map(R=>R.id)),$=D.size>0,W=(R,I)=>{const z=/^#([0-9a-f]{6})$/i.exec(R);if(!z)return R;const P=parseInt(z[1],16);return`rgba(${P>>16&255}, ${P>>8&255}, ${P&255}, ${I})`},O="#ff5169";return r.map(R=>{var pe,_e,je,Ve;const I=F.get(R.source),z=F.get(R.target),P=/^output-(\d+)$/.exec(R.sourceHandle||""),L=/^input-(\d+)$/.exec(R.targetHandle||""),E=I&&P?(_e=(pe=I.data)==null?void 0:pe.outputs)==null?void 0:_e[parseInt(P[1],10)]:null,X=z&&L?(Ve=(je=z.data)==null?void 0:je.inputs)==null?void 0:Ve[parseInt(L[1],10)]:null,ee=E!=null&&E.type?or(E.type):null,V=X!=null&&X.type?or(X.type):null,ie=ee&&V&&ee!==V,fe=$&&(D.has(R.source)||D.has(R.target)),me=R.style||{};if(ie){const et=R.selected?.95:fe?.85:.78,qe=W(O,et);return{...R,className:((R.className||"")+" af-flow-edge--type-mismatch"+(fe?" af-flow-edge--adjacent":"")).trim(),style:{...me,stroke:qe,strokeWidth:fe?2.75:2.5,strokeDasharray:"6 4"},markerEnd:R.markerEnd&&typeof R.markerEnd=="object"?{...R.markerEnd,color:qe}:{type:$s.ArrowClosed,color:qe}}}const ge=ee||V;if(!ge)return fe?{...R,className:((R.className||"")+" af-flow-edge--adjacent").trim(),style:{...me,strokeWidth:2.5}}:R;const Z=fe||R.selected?.7:.38,ae=W(ge,Z),xe=fe?2.5:me.strokeWidth??2;return{...R,className:((R.className||"")+(fe?" af-flow-edge--adjacent":"")).trim(),style:{...me,stroke:ae,strokeWidth:xe},markerEnd:R.markerEnd&&typeof R.markerEnd=="object"?{...R.markerEnd,color:ae}:{type:$s.ArrowClosed,color:ae}}})},[n,r]);return o.jsxs(c0,{className:T,nodes:n,edges:M,onNodesChange:s||H,onEdgesChange:i||H,onConnect:N?void 0:a,onConnectStart:N?void 0:l,onConnectEnd:N?void 0:c,isValidConnection:N?void 0:d,onNodesDelete:N?void 0:f,onNodeClick:u,onNodeDoubleClick:N?void 0:p,onEdgeClick:N?void 0:m,onInit:y,onDrop:N?void 0:b,onDragOver:N?void 0:k,nodeTypes:a7,selectionOnDrag:C,panOnDrag:_,nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N,edgesFocusable:!N,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[o.jsx(d0,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx($u,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(g?" af-flow-bottom-unified-panel--solo":""),children:o.jsxs("div",{className:"af-flow-bottom-unified-row"+(g?" af-flow-bottom-unified-row--solo":""),children:[g?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:o.jsx(B4,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:F=>{var $;const D=((($=F.data)==null?void 0:$.schemaType)??"agent").toLowerCase();return D==="control"?"rgba(237, 108, 2, 0.85)":D==="provide"?"rgba(0, 228, 117, 0.35)":D==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:v}),g?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(P4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!g&&o.jsx($u,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:F,color:D})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:D}}),o.jsx("span",{className:"af-pin-legend__label",children:F})]},F))}),o.jsx(E7,{fitViewEpoch:e}),!N&&n.length===0?o.jsxs("div",{className:"af-flow-empty-hint",children:[o.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),o.jsx("p",{className:"af-flow-empty-hint-text",children:x("flow:emptyCanvas.composerHint")}),o.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:x("flow:emptyCanvas.composerSub")}})]}):null]})}function v1(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams(window.location.search),n=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&n.set("flowArchived","1"),t.get("panel")==="settings"&&n.set("panel","settings"),window.history.replaceState({},"","/flow?"+n.toString())}function O7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function bi(e){return e==="builtin"||e==="admin"}function zc(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function $7(e){var r,s,i,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const o2="af:run-console-height",xf=230,Fd={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Hh={};function ym(e){if(!Number.isFinite(e))return xf;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function D7(){try{const e=localStorage.getItem(o2);if(e==null)return xf;const t=parseInt(e,10);return Number.isFinite(t)?ym(t):xf}catch{return xf}}function F7(){var uk,dk;const{t:e,i18n:t}=Mn(),{navigate:n,path:r}=Ro(),s=h.useRef(null),i=h.useRef(new Map),a=h.useCallback(w=>{s.current=typeof w=="function"?w:null},[]),[l,c]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState(null),[m,y]=h.useState(0),[b,k]=h.useState(""),[g,v]=h.useState(""),[x,N]=h.useState(""),[_,C]=h.useState(""),[T,H]=h.useState(!1),[M,F]=h.useState(""),[D,$]=h.useState(!1),[W,O]=h.useState(""),[R,I]=h.useState(!1),[z,P]=h.useState(!1),[L,E]=h.useState(!1),[X,ee]=h.useState(null),[V,ie]=h.useState(!1),[fe,me]=h.useState(!1),ge=h.useRef(!1),[Z,ae]=h.useState([]),[xe,pe]=h.useState(""),[_e,je]=h.useState("nodes"),Ve=h.useRef(null),[et,qe]=h.useState([]),[dt,He]=h.useState(!1),[bt,sn]=h.useState(""),[on,an]=h.useState(!1),[Yt,En]=h.useState({name:"",id:"",description:""}),[hn,ue]=h.useState(!1),[ke,De]=h.useState(""),[rt,at]=h.useState(""),Lt=h.useRef(null),[st,mn]=h.useState([]),[Zt,ar]=h.useState(!1),[_n,gn]=h.useState(""),[bn,lr]=h.useState(""),[ve,$e]=h.useState(null),[nt,zt]=h.useState(null),[oe,Te]=h.useState([]),[Ue,Ht]=h.useState(""),[yn,cr]=h.useState(!1),Hs=h.useCallback(w=>{Lt.current&&window.clearTimeout(Lt.current),at(w),Lt.current=window.setTimeout(()=>{at(""),Lt.current=null},3800)},[]),as=h.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const B=()=>{var q;return(q=s.current)==null?void 0:q.call(s,j)};window.requestAnimationFrame(B),window.setTimeout(B,80)},[]);h.useEffect(()=>()=>{Lt.current&&window.clearTimeout(Lt.current)},[]);const[hr,Zn]=h.useState(!1),[Vr,ot]=h.useState({files:[]}),[Ur,Ai]=h.useState(!1),[xa,xs]=h.useState(!0);h.useEffect(()=>{let w=!1;const j=()=>{fetch("/api/flows",{method:"HEAD"}).then(q=>{w||xs(q.ok)}).catch(()=>{w||xs(!1)})};j();const B=window.setInterval(j,5e3);return()=>{w=!0,window.clearInterval(B)}},[]),h.useEffect(()=>{let w=!1;return fetch("/api/dev-info").then(j=>j.json()).then(j=>{w||wa(!!(j!=null&&j.isDev))}).catch(()=>{}),()=>{w=!0}},[]),h.useEffect(()=>{u!=null&&u.id&&oP(u.id,u.source??"user","pipeline",!!u.archived)},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const[Ie,cn]=h.useState("edit"),[mr,ht]=h.useState([]),Oe=h.useRef(0),[Kr,Gn]=h.useState(new Set),[qr,Cr]=h.useState({}),[ut,Ut]=h.useState(null),[un,Er]=h.useState(0),[tt,gr]=h.useState(!1),[Bs,wa]=h.useState(!1),[ws,Oo]=h.useState(!1),[vr,$o]=h.useState(D7),Ii=h.useRef({active:!1,pointerId:-1,startY:0,startH:xf}),[xn,er]=h.useState(null),[bs,Yr]=h.useState(null),[li,Ws]=h.useState({}),K=h.useRef(li);h.useEffect(()=>{K.current=li},[li]);const[we,Le]=h.useState(!1),[Me,Ke]=h.useState(!1),[en,Mt]=h.useState({}),[wn,Gr]=h.useState({}),[ls,Vs]=h.useState(null),[ur,ba]=h.useState(Fd),[nd,Pp]=h.useState(!1),[Ti,va]=h.useState(!1),[wl,_r]=h.useState(""),[bl,vl]=h.useState(""),[Kt,vc]=h.useState(Hh),[Bt,kl]=h.useState(null),so=h.useRef(0),ci=h.useRef(null),Do=h.useRef(null),rd=h.useRef(!0),Fo=h.useRef(!1),[kr,Sl]=h.useState(null),[ui,Ri]=h.useState(null),[kc,zo]=h.useState(!1),[ka,Ho]=h.useState(""),[Nl,jl]=h.useState(!1),sd=h.useRef(null),[di,Lr]=h.useState(null),[id,fi]=h.useState(!1),[Sa,Bo]=h.useState(null),[vs,od]=h.useState(!1),[Xr,Na]=h.useState(null),pi=h.useRef(null),[ks,Pe]=h.useState(""),[Ss,ja]=h.useState(0),[Ca,hi]=h.useState(0),[Ap,ad]=h.useState("pan"),[Bn,io]=h.useState(!1),[On,Ip]=h.useState(!1),ld=h.useRef(null),cd=h.useRef(null),Ea=h.useRef(null),[Tp,Rp]=h.useState(0),[gt,ud]=h.useState(null),[Lp,Cl]=h.useState(""),[vt,Mp]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[mi,El]=h.useState(""),[Sc,yy]=h.useState(""),[gi,Op]=h.useState([]),[dr,oo]=h.useState([]),[dd,$p]=h.useState(!1),[_l,Dp]=h.useState([]),[fd,Us]=h.useState(!1),[Fp,Pl]=h.useState(()=>new Set),[Li,mt]=h.useState(!1),Gt=h.useRef(null),Nc=h.useRef(null),[xy,pd]=h.useState({}),jc=h.useCallback(w=>{if(!w)return null;const j=w.id,B=w.source??"user",q=w.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${j}:${B}${q?":"+q:""}`,activeKey:`af:composer-active-session:${j}:${B}${q?":"+q:""}`}},[]),zp=h.useCallback(w=>{if(!w)return"";const j=w.id,B=w.source??"user",q=w.archived?"archived":"";return`af:composer-skills:pipeline:${j}:${B}${q?":"+q:""}`},[]),Hp=h.useCallback(w=>{const j=jc(w);if(!j)return{sessions:[],activeSessionId:null};try{const B=localStorage.getItem(j.sessionsKey);if(!B)return{sessions:[],activeSessionId:null};const q=JSON.parse(B);if(!Array.isArray(q))return{sessions:[],activeSessionId:null};const Y=q.filter(te=>te&&typeof te.id=="string").map(te=>({...te,running:!1,statusLine:te.running?e("flow:composer.pageRefreshReset"):te.statusLine,steps:[]}));let J=null;try{J=localStorage.getItem(j.activeKey),J&&!Y.some(te=>te.id===J)&&(J=null)}catch{J=null}return{sessions:Y,activeSessionId:J}}catch{return{sessions:[],activeSessionId:null}}},[jc]),Cc=h.useCallback((w,j,B)=>{const q=jc(w);if(q)try{localStorage.setItem(q.sessionsKey,JSON.stringify(j)),B?localStorage.setItem(q.activeKey,B):localStorage.removeItem(q.activeKey)}catch{}},[jc]),Wo=h.useRef(0),Al=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[cs,Jr]=h.useState([]),[tr,ao]=h.useState(null),lo=h.useMemo(()=>zp(u),[zp,u]),[Ec,Vo]=h.useState(""),Wn=h.useMemo(()=>{if(!u)return null;const w=u.id,j=u.source??"user",B=u.archived?"archived":"";return`${w}:${j}${B?":"+B:""}`},[u]),_a=h.useRef(!1);h.useEffect(()=>{if(!Wn){Jr([]),ao(null),Al.current={sessions:[],activeSessionId:null,flowKey:null};return}const w=Al.current;if(w.flowKey===Wn)return;w.flowKey=Wn,_a.current&&w.sessions.length>0&&Cc(u,w.sessions,w.activeSessionId);const{sessions:j,activeSessionId:B}=Hp(u);if(j.length===0){const q=`session-1-${Date.now()}`,Y={id:q,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};w.sessions=[Y],w.activeSessionId=q,Jr([Y]),ao(q)}else{const q=j[j.length-1];if(q&&(!q.thread||q.thread.length===0))Wo.current=$x(j),w.sessions=j,w.activeSessionId=q.id,Jr(j),ao(q.id);else{const J=$x(j)+1;Wo.current=J;const te=`session-${J}-${Date.now()}`,ne={id:te,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},ye=[...j,ne];w.sessions=ye,w.activeSessionId=te,Jr(ye),ao(te)}}_a.current=!0},[Wn,u,Hp,Cc]);const Pn=h.useMemo(()=>cs.find(w=>w.id===tr)||null,[cs,tr]),An=(Pn==null?void 0:Pn.running)??!1,Il=(Pn==null?void 0:Pn.statusLine)??"",Uo=(Pn==null?void 0:Pn.segments)??[],co=(Pn==null?void 0:Pn.thread)??[],hd=(Pn==null?void 0:Pn.steps)??[];Pn==null||Pn.outputDismissed;const jt=(Pn==null?void 0:Pn.phaseContext)??null,md=h.useRef([]),[_c,Ko]=h.useState(!1),Tl=h.useRef(null),Bp=h.useRef(null);h.useEffect(()=>{const w=Bp.current;w&&requestAnimationFrame(()=>{w.scrollTop=w.scrollHeight})},[co,Uo]);const Pc=h.useRef(null),Ac=h.useRef(!1),Rl=h.useRef(null),Wp=h.useCallback(w=>{const j=++Wo.current,B=`session-${j}-${Date.now()}`,q={id:B,label:w||e("flow:composer.conversationLabel",{n:j}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Jr(Y=>[...Y,q]),ao(B),B},[]);h.useEffect(()=>{!u||!_a.current||(Al.current.sessions=cs,Al.current.activeSessionId=tr,Cc(u,cs,tr))},[cs,tr,u,Cc]),h.useEffect(()=>{Wo.current=Math.max(Wo.current,$x(cs))},[cs]);const Vp=h.useCallback(w=>{var j;Pc.current===w&&((j=Tl.current)==null||j.abort()),Jr(B=>{const q=B.filter(J=>J.id!==w);if(B.some((J,te)=>J.id===w&&B.findIndex(ne=>ne.id===tr)===te)||tr===w){const J=q;J.length>0?ao(J[J.length-1].id):setTimeout(()=>{Wo.current=0;const te=++Wo.current,ne=`session-${te}-${Date.now()}`,ye={id:ne,label:e("flow:composer.conversationLabel",{n:te}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Jr(be=>[...be,ye]),ao(ne)},0)}return q})},[tr]),Qr=h.useCallback(w=>{Jr(j=>{const B=j.findIndex(J=>J.id===tr);if(B<0)return j;const q={...j[B]};w(q);const Y=[...j];return Y[B]=q,Y})},[tr]),Up=h.useCallback(w=>{Qr(j=>{j.running=w})},[Qr]),Ks=h.useCallback(w=>{Qr(j=>{j.statusLine=w})},[Qr]),qs=h.useCallback(w=>{Qr(j=>{typeof w=="function"?j.segments=w(j.segments):j.segments=w})},[Qr]),Kp=h.useCallback(w=>{Qr(j=>{typeof w=="function"?j.thread=w(j.thread):j.thread=w})},[Qr]),yi=h.useCallback(w=>{Qr(j=>{typeof w=="function"?j.steps=w(j.steps):j.steps=w})},[Qr]),qp=h.useCallback(w=>{Qr(j=>{j.outputDismissed=w})},[Qr]),Ll=h.useCallback(w=>{Qr(j=>{j.phaseContext=typeof w=="function"?w(j.phaseContext):w})},[Qr]),qo=h.useCallback(w=>{ao(w),Jr(j=>{const B=j.findIndex(Y=>Y.id===w);if(B<0||!j[B].outputDismissed)return j;const q=[...j];return q[B]={...j[B],outputDismissed:!1},q})},[]);h.useEffect(()=>{md.current=Uo},[Uo]);const nr=h.useRef({}),xi=h.useRef(!1),Mi=h.useRef(null),Ic=h.useRef(null),uo=h.useRef(null),Pa=h.useRef(!1),gd=h.useRef(0),Ml=h.useRef(""),[Et,kt,wy]=nI([]),[vn,Xt,by]=rI([]),Ys=h.useRef(Et),Yo=h.useRef(vn),yd=h.useRef(null),Tc=h.useRef(null),Yp=h.useRef(null),Ol=h.useRef(null),[dn,Oi]=h.useState(null),Gp=h.useCallback(w=>{var j;nr.current=(j=w==null?void 0:w.extra)!=null&&j.instances&&typeof w.extra.instances=="object"?w.extra.instances:{},kt(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),Xt(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),Oi(null)},[Xt,kt]),vy=h.useMemo(()=>({instances:nr.current}),[vn,Et]),{resetHistory:xd,undo:wd,redo:S}=FT({nodes:Et,edges:vn,extra:vy,enabled:!!u&&Pa.current&&Ie==="edit",onRestore:Gp}),A=h.useMemo(()=>Et.filter(w=>{var j;return(((j=w.data)==null?void 0:j.definitionId)||"").startsWith("provide_")}),[Et]),U=h.useMemo(()=>{var j;const w={};for(const B of Et){if(!((j=B.data)!=null&&j.inputs))continue;const q=B.data.inputs;for(let Y=0;Y<q.length;Y++){const J=q[Y];if(!(J!=null&&J.name))continue;const te=vn.find(ye=>ye.target===B.id&&ye.targetHandle===`input-${Y}`);if(!(te!=null&&te.source))continue;A.find(ye=>ye.id===te.source)&&(w[te.source]=J.name)}}return w},[Et,vn,A]),G=h.useMemo(()=>{if(Ie==="edit"||Kr.size===0)return null;const w=new Set(Kr);for(const j of vn)Kr.has(j.source)&&w.add(j.target),Kr.has(j.target)&&w.add(j.source);return w},[Ie,Kr,vn]),Q=h.useMemo(()=>Ie==="edit"?Et:Et.map(w=>{var j,B;return{...w,draggable:!1,connectable:!1,data:{...w.data,isRunMode:!0,isExecuting:Kr.has(w.id),nodeStatus:((j=qr[w.id])==null?void 0:j.status)??null,nodeElapsed:((B=qr[w.id])==null?void 0:B.elapsed)??null,isDim:G?!G.has(w.id):!1}}}),[Ie,Et,Kr,qr,G]),se=h.useMemo(()=>G?vn.map(w=>{const j=Kr.has(w.source)||Kr.has(w.target),B=w.className?w.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",q=j?"af-flow-edge--focus":"af-flow-edge--dim";return{...w,className:(B?B+" ":"")+q}}):vn,[vn,Kr,G]);h.useEffect(()=>{if(!u){Gr({}),Vs(null),ba(Fd),vc(Hh),kl(null),_r(""),vl("");return}const w=new URLSearchParams({flowId:u.id,flowSource:u.source||"user"});u.archived&&w.set("archived","1"),fetch(`/api/flow/run-config?${w.toString()}`).then(j=>j.json()).then(j=>{Gr(j.presets||{}),Vs(j.activePreset||null)}).catch(()=>{Gr({}),Vs(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const re=h.useCallback(w=>{so.current+=1,ba(w)},[]),le=h.useCallback(async(w,j={})=>{if(!w)return;const B=!!j.quiet,q=!!j.force,Y=so.current;B||(Pp(!0),_r(""),vl(""));const J=new URLSearchParams({flowId:w.id,flowSource:w.source||"user"});w.archived&&J.set("archived","1");try{const te=await fetch(`/api/flow/schedule?${J.toString()}`),ne=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ne.error||`HTTP ${te.status}`);if(!q&&so.current!==Y)return;ba({...Fd,...ne.schedule||{}}),vc(ne.state&&typeof ne.state=="object"?ne.state:Hh),kl(ne.status||null)}catch(te){if(!q&&so.current!==Y)return;ba(Fd),vc(Hh),kl(null),_r(String(te.message||te))}finally{Pp(!1)}},[]);h.useEffect(()=>{if(!u)return;let w=!1;return(async()=>{await le(u)})(),()=>{w=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,le]),h.useEffect(()=>{var B,q,Y,J;if(!ls||!wn[ls]||A.length===0)return;const w=wn[ls],j={};for(const te of A){const ne=U[te.id];if(!ne)continue;const ye=((B=te.data)==null?void 0:B.definitionId)||"",be=w[te.id]??((J=(Y=(q=te.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"";ye.startsWith("provide_file")?j[ne]={type:"file",path:be}:j[ne]={type:"str",value:be}}Object.keys(j).length>0&&Ws(j)},[ls,wn,A,U]);const he=h.useCallback(()=>{if(!Xr||!pi.current)return;const w=pi.current.value;kt(j=>j.map(B=>{var q,Y;return B.id!==Xr.instanceId?B:{...B,data:{...B.data,outputs:((Y=(q=B.data)==null?void 0:q.outputs)==null?void 0:Y.map((J,te)=>te===0?{...J,default:w}:J))||[{type:"text",name:"value",default:w}]}}})),Na(null)},[Xr,kt]),ce=h.useMemo(()=>{const w=Et.filter(j=>j.selected);return w.length===1?w[0]:null},[Et]),Ce=h.useMemo(()=>u?iK(Et,vn,e):[],[u,Et,vn,e]),Be=h.useMemo(()=>Ce.map(w=>w.key).join("|"),[Ce]),yt=h.useMemo(()=>Ce.some(w=>String((w==null?void 0:w.level)||"warning").toLowerCase()==="error"),[Ce]);h.useLayoutEffect(()=>{ie(Ce.length>0&&!yt)},[Be,u==null?void 0:u.id,u==null?void 0:u.source,Ce.length,yt]),Ea.current=ce,h.useEffect(()=>{Ys.current=Et},[Et]),h.useEffect(()=>{const w=i.current,j=new Map,B=[];for(const te of Et){const ne=m7(te);j.set(te.id,ne),w.get(te.id)!==ne&&B.push(te.id)}if(i.current=j,B.length===0)return;const q=()=>B.forEach(te=>{var ne;return(ne=s.current)==null?void 0:ne.call(s,te)}),Y=window.requestAnimationFrame(q),J=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Y),window.clearTimeout(J)}},[Et]),h.useEffect(()=>{Yo.current=vn},[vn]),h.useEffect(()=>{Yp.current=dn},[dn]),h.useEffect(()=>{if(!dn)return;const w=B=>{B.key==="Escape"&&Oi(null)},j=B=>{var q,Y;(Y=(q=B.target)==null?void 0:q.closest)!=null&&Y.call(q,".af-connect-node-menu")||Oi(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",j)}},[dn]),h.useEffect(()=>()=>{uo.current!=null&&(clearTimeout(uo.current),uo.current=null)},[]);const Xe=h.useMemo(()=>{var j;if(!ce)return null;const w=(j=ce.data)==null?void 0:j.definitionId;return Z.find(B=>B.id===w)??null},[ce,Z]),_t=h.useMemo(()=>{const w={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const j of Z){const B=L0(j);w[B].push(j)}for(const j of Jd)w[j].sort((B,q)=>B.id.localeCompare(q.id));return w},[Z]),kn=h.useMemo(()=>{const w=xe.trim().toLowerCase();if(!w)return _t;const j={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const B of Jd)j[B]=_t[B].filter(q=>d7(q,w));return j},[_t,xe]),us=h.useMemo(()=>Jd.reduce((w,j)=>w+kn[j].length,0),[kn]),ln=h.useMemo(()=>Z.filter(w=>{const j=String(w.id??""),B=String(w.source??"");return j.startsWith("marketplace:")||B==="marketplace"||B==="collection"}),[Z]),fn=h.useMemo(()=>{const w=new Set;for(const j of ln){const B=String(j.id??"");if(B&&(w.add(B),B.startsWith("marketplace:"))){const q=B.slice(12),[Y]=q.split("@");Y&&w.add(`marketplace:${Y}`)}}return w},[ln]),rr=h.useCallback(async()=>{f("");try{const w=await fetch("/api/flows");if(!w.ok)throw new Error("HTTP "+w.status);c(await w.json())}catch(w){f(String(w.message||w))}},[]);h.useEffect(()=>{rr()},[rr]),h.useEffect(()=>{if(r!=="/flow")return;const w=new URLSearchParams(window.location.search);w.get("new")==="1"&&!w.get("flowId")&&n("/projects?new=1")},[r,n]),h.useEffect(()=>{if(r!=="/flow"||!u)return;new URLSearchParams(window.location.search).get("panel")==="settings"&&zt("settings")},[r,u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{let w=!1;const j=()=>{fetch("/api/model-lists").then(q=>q.json()).then(q=>{w||Mp({cursor:Array.isArray(q.cursor)?q.cursor.map(String):[],opencode:Array.isArray(q.opencode)?q.opencode.map(String):[],claudeCode:Array.isArray(q.claudeCode)?q.claudeCode.map(String):[]})}).catch(()=>{})};j();const B=setTimeout(j,4e3);return()=>{w=!0,clearTimeout(B)}},[]),h.useEffect(()=>{let w=!1;return fetch("/api/skills").then(j=>j.json()).then(j=>{if(w)return;const B=Array.isArray(j.skills)?j.skills.filter(q=>q&&typeof q.key=="string"&&q.key.trim()).map(q=>({key:String(q.key),name:String(q.name||q.id||q.key),description:q.description?String(q.description):"",sourceLabel:q.sourceLabel?String(q.sourceLabel):""})):[];Op(B),$p(!0)}).catch(()=>{}),()=>{w=!0}},[]),h.useEffect(()=>{let w=!1;return fetch("/api/skill-collections").then(j=>j.json()).then(j=>{w||(Dp(rl(j)),Us(!0))}).catch(()=>{}),()=>{w=!0}},[]),h.useEffect(()=>{if(Vo(""),!(!dd||!fd)){if(!lo){oo([]);return}oo(uP(lo,"pipeline",gi,_l)),Vo(lo)}},[_l,fd,gi,dd,lo]),h.useEffect(()=>{if(!(Ec!==lo||!lo))try{localStorage.setItem(lo,JSON.stringify(dr))}catch{}},[dr,lo,Ec]);const Tt=h.useCallback(async w=>{const j=w.source??"user",B=!!w.archived,q=new URLSearchParams({flowId:w.id,flowSource:j});B&&q.set("archived","1");const Y=new URLSearchParams({flowId:w.id,flowSource:j});B&&Y.set("archived","1"),Y.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[J,te]=await Promise.all([fetch("/api/flow?"+q.toString()),fetch("/api/nodes?"+Y.toString())]),ne=await J.json();if(!J.ok||ne.error)throw new Error(ne.error||e("flow:nodePropsError.loadFlowFailed"));const ye=await te.json();if(!te.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const be=Array.isArray(ye)?ye:Array.isArray(ye==null?void 0:ye.nodes)?ye.nodes:[],ze=!Array.isArray(ye)&&(ye==null?void 0:ye.pipelineTranslations)||{},de=nK(ne.flowYaml||"");if(de.error)throw new Error(de.error);const Fe={...de.instances||{}},Ne=de.nodes.map(Sn=>tp(Sn,Fe,be,ze,w.id)),xt=DT(de.edges,Ne);return{flowSource:j,paletteList:be,instances:Fe,flowDescriptionText:de.description??"",viewport:x1(de.viewport),nodes:Ne,edges:xt}},[t.language,e]),$t=h.useCallback(async(w,j={})=>{const B=!!j.preserveComposer,q=B&&!!j.incrementalSync;Pa.current=!1,gd.current+=1,p(w),v(""),B||(N(""),pe(""),zt(null),k(""),F(""),O(""),Pe(""),Kp([]),qs([]),yi([]),qp(!1),Ll(null),ad("pan")),q||(nr.current={},kt([]),Xt([])),v1(w);try{const Y=await Tt(w);if(ae(Y.paletteList),nr.current=Y.instances,k(Y.flowDescriptionText),F(w.id||""),q){const J=Ys.current,te=Yo.current;try{const ne=R9(J,te,Y.nodes,Y.edges),ye=new Set([...ne.changes.addedNodeIds,...ne.changes.updatedNodeIds]),be=new Set([...ne.changes.addedEdgeKeys,...ne.changes.updatedEdgeKeys]),ze=ye.size>0?ne.nodes.map(Fe=>ye.has(Fe.id)?{...Fe,className:a1(Fe.className,i1)}:Fe):ne.nodes,de=be.size>0?ne.edges.map(Fe=>be.has(Xf(Fe))?{...Fe,className:a1(Fe.className,o1)}:Fe):ne.edges;kt(ze),Xt(de),uo.current!=null&&(clearTimeout(uo.current),uo.current=null),(ye.size>0||be.size>0)&&(uo.current=window.setTimeout(()=>{uo.current=null,ye.size>0&&kt(Fe=>Fe.map(Ne=>{if(!ye.has(Ne.id))return Ne;const xt=l1(Ne.className,i1);return xt===String(Ne.className||"")?Ne:{...Ne,className:xt}})),be.size>0&&Xt(Fe=>Fe.map(Ne=>{if(!be.has(Xf(Ne)))return Ne;const xt=l1(Ne.className,o1);return xt===String(Ne.className||"")?Ne:{...Ne,className:xt}}))},l7))}catch{kt(Y.nodes),Xt(Y.edges)}}else if(kt(Y.nodes),Xt(Y.edges),Ic.current=Y.viewport||null,Y.viewport){const J=()=>{var te;try{(te=Mi.current)==null||te.setViewport(Y.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else y(J=>J+1);vh(w.id,Y.flowSource),Rp(J=>J+1),xd(Y.nodes,Y.edges,{instances:Y.instances});try{Ml.current=Bj(Y.nodes,Y.edges,Y.instances,{description:Y.flowDescriptionText,viewport:Ic.current})}catch{Ml.current=""}Pa.current=!0}catch(Y){v(String(Y.message||Y))}},[Tt,xd,kt,Xt]),We=h.useCallback(async()=>{if(!(u!=null&&u.id))return;const w=u.source??"user",j=new URLSearchParams({flowId:u.id,flowSource:w});u.archived&&j.set("archived","1"),j.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const B=await fetch("/api/nodes?"+j.toString()),q=await B.json();if(!B.ok)throw new Error((q==null?void 0:q.error)||e("flow:nodePropsError.loadNodesFailed"));const Y=Array.isArray(q)?q:Array.isArray(q==null?void 0:q.nodes)?q.nodes:[];ae(Y)},[u,e,t.language]),Ct=h.useCallback(async()=>{ar(!0),gn("");try{const w=await fetch("/api/marketplace/nodes"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error((j==null?void 0:j.error)||"Failed to load marketplace nodes");mn(Array.isArray(j==null?void 0:j.nodes)?j.nodes:[])}catch(w){gn(String(w.message||w)),mn([])}finally{ar(!1)}},[]),Pr=h.useCallback(async()=>{He(!0),sn("");try{const w=await fetch("/api/marketplace/flow-snippets"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error((j==null?void 0:j.error)||"Failed to load flow snippets");qe(Array.isArray(j==null?void 0:j.snippets)?j.snippets:[])}catch(w){sn(String(w.message||w)),qe([])}finally{He(!1)}},[]);h.useEffect(()=>{u&&(Ct(),Pr())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Ct,Pr]);const Aa=h.useCallback(async w=>{if(!u||!w)return;const j=w.definitionId||`marketplace:${w.id}${w.version?`@${w.version}`:""}`;if(j){lr(j),gn("");try{const B=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,nodeSpec:j})}),q=await B.json().catch(()=>({}));if(!B.ok||(q==null?void 0:q.ok)===!1)throw new Error((q==null?void 0:q.error)||"Failed to install marketplace node");await We()}catch(B){gn(String(B.message||B))}finally{lr("")}}},[u,We]),$l=h.useCallback(async(w,j)=>{const B={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:j,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:u==null?void 0:u.id,flowSource:(u==null?void 0:u.source)||"user"},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),Y=await q.json();if(!q.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Publish failed");return await We(),Y},[We,u]),Se=h.useCallback(async()=>{var q;if(!u||ge.current)return;const w=u.id,j=u.source??"user",B=((q=Ea.current)==null?void 0:q.id)??null;ge.current=!0,me(!0);try{await $t({id:w,source:j,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),B&&kt(Y=>Y.map(J=>({...J,selected:J.id===B})))}finally{ge.current=!1,me(!1)}},[u,u==null?void 0:u.archived,$t,kt]);h.useEffect(()=>{if(xi.current||l.length===0)return;const w=new URLSearchParams(window.location.search),j=w.get("flowId");if(!j)return;const B=w.get("flowSource")??"user",q=w.get("flowArchived")==="1",Y=l.find(J=>J.id===j&&(J.source??"user")===B&&!!J.archived===q);Y&&(xi.current=!0,$t(Y))},[l,$t]);const lt=h.useRef(0);h.useEffect(()=>{if(!u)return;const w=u.id,j=u.source??"user",B=!!u.archived;lt.current=0;let q=!1;const Y=async()=>{var ne;if(q)return;const te=new URLSearchParams({flowId:w,flowSource:j,v:String(lt.current)});B&&te.set("archived","1");try{const ye=await fetch("/api/flow-editor-sync-poll?"+te.toString());if(!ye.ok||q)return;const be=await ye.json();if(q)return;if(be.changed){lt.current=be.version;const ze=((ne=Ea.current)==null?void 0:ne.id)??null;await $t({id:w,source:j,archived:B},{preserveComposer:!0,incrementalSync:!0}),await le({id:w,source:j,archived:B},{quiet:!0,force:!0}),ze&&kt(de=>de.map(Fe=>({...Fe,selected:Fe.id===ze})))}else lt.current=be.version}catch{}},J=window.setInterval(Y,2e3);return Y(),()=>{q=!0,window.clearInterval(J)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,$t,le,kt]);const ft=h.useMemo(()=>x?x.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":x===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[x]);h.useEffect(()=>{if(!x)return;x===e("flow:status.saved")||x.startsWith(e("flow:status.runInTerminal"));const w=x.startsWith(e("flow:status.runInTerminal"))?5200:2800,j=window.setTimeout(()=>N(""),w);return()=>clearTimeout(j)},[x,e]),h.useEffect(()=>{C("")},[u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{const w=()=>{window.__provideEditContent&&(Na(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",w),()=>window.removeEventListener("provide-expand",w)},[]),h.useEffect(()=>{var ne,ye,be,ze,de,Fe,Ne;if(!ce){ud(null);return}const w=nr.current[ce.id]||{},{inputs:j,outputs:B}=$T(ce),q=String(((ne=ce.data)==null?void 0:ne.definitionId)??ce.id??""),Y=((ye=ce.data)==null?void 0:ye.script)!=null?String(ce.data.script):void 0,J=w.script!=null?String(w.script):void 0,te=q==="tool_nodejs"||Y&&Y.trim()!==""||J&&J.trim()!==""?String(Y??J??""):"";ud({id:ce.id,newId:ce.id,label:String(((be=ce.data)==null?void 0:be.label)??ce.id),role:((ze=ce.data)==null?void 0:ze.role)??"普通",model:String(((de=ce.data)==null?void 0:de.model)??w.model??""),body:String(((Fe=ce.data)==null?void 0:Fe.body)??w.body??""),images:Ts(((Ne=ce.data)==null?void 0:Ne.images)??w.images),script:te,inputs:j,outputs:B})},[ce==null?void 0:ce.id,Tp]),h.useEffect(()=>{u&&(ce||(cd.current=null,zt(w=>w==="node"?null:w)))},[u,ce==null?void 0:ce.id]);const pt=h.useCallback(()=>{cd.current=null,zt(w=>w==="settings"||w==="history"?w:"node")},[]),Re=h.useCallback((w,j)=>{w.metaKey||w.ctrlKey||w.shiftKey||Ie!=="edit"&&Yr((j==null?void 0:j.id)??null)},[Ie]),It=h.useCallback((w,j)=>{Ie==="edit"&&(w.preventDefault(),kt(B=>B.map(q=>({...q,selected:q.id===j.id}))),Xt(B=>B.map(q=>({...q,selected:!1}))),pt())},[pt,Ie,Xt,kt]),tn=h.useCallback((w,j)=>{if(Ie!=="edit")return;const B=w.metaKey||w.ctrlKey||w.shiftKey;Xt(q=>q.map(Y=>Y.id===j.id?{...Y,selected:!Y.selected||!B}:B?Y:{...Y,selected:!1})),B||kt(q=>q.map(Y=>({...Y,selected:!1})))},[Ie,Xt,kt]),Jt=h.useCallback(w=>p1(w,Ys.current),[]),$n=h.useCallback(w=>{if(!p1(w,Ys.current)){N("端口类型不匹配,已取消连线");return}Oi(null),kt(j=>pg(j,w)),Xt(j=>{const B=j.filter(q=>!(q.target===w.target&&q.targetHandle===w.targetHandle));return qf({...w,markerEnd:{type:$s.ArrowClosed}},B)})},[Xt,kt]),Vn=h.useCallback((w,j)=>{Tc.current=g7(j,Ys.current),Oi(null)},[]),Dt=h.useCallback((w,j)=>{var Ne,xt,Sn,Nn;const B=Tc.current;if(Tc.current=null,!u||!B||j!=null&&j.toNode)return;const q=x7(Z,B);if(q.length===0){N(`没有匹配 ${B.slotType} 端口的节点`);return}const Y=((xt=(Ne=w==null?void 0:w.changedTouches)==null?void 0:Ne[0])==null?void 0:xt.clientX)??(w==null?void 0:w.clientX),J=((Nn=(Sn=w==null?void 0:w.changedTouches)==null?void 0:Sn[0])==null?void 0:Nn.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(Y)||!Number.isFinite(J))return;const te=Mi.current,ne=document.querySelector(".af-pipeline-flow .react-flow");if(!te||!ne)return;const ye=ne.getBoundingClientRect(),be=320,ze=Math.min(440,104+q.length*58),de=Math.max(12,Math.min(Y-ye.left,ye.width-be-12)),Fe=Math.max(12,Math.min(J-ye.top,ye.height-ze-12));Oi({left:de,top:Fe,flowPosition:te.screenToFlowPosition({x:Y,y:J}),draft:B,candidates:q,query:""})},[Z,u]),nn=h.useCallback(w=>{for(const j of w)delete nr.current[j.id]},[]),Zr=h.useCallback(w=>{Mi.current=w},[]),Ns=h.useCallback(w=>{kt(B=>B.map(q=>({...q,selected:q.id===w}))),Xt(B=>B.map(q=>({...q,selected:!1}))),pt();const j=()=>{var ye,be,ze;const B=Mi.current;if(!(B!=null&&B.getNode))return;const q=B.getNode(w);if(!q)return;const Y=(ye=B.getInternalNode)==null?void 0:ye.call(B,w),J=((be=Y==null?void 0:Y.measured)==null?void 0:be.width)??(Y==null?void 0:Y.width)??q.width??200,te=((ze=Y==null?void 0:Y.measured)==null?void 0:ze.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:ne}=B.getViewport();B.setCenter(q.position.x+J/2,q.position.y+te/2,{zoom:y1(ne),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(j))},[kt,Xt,pt]),Gs=h.useCallback(w=>{kt(B=>B.map(q=>({...q,selected:q.id===w}))),Xt(B=>B.map(q=>({...q,selected:!1})));const j=()=>{var be,ze,de;const B=Mi.current;if(!(B!=null&&B.getNode))return;const q=B.getNode(w);if(!q)return;const Y=(be=B.getInternalNode)==null?void 0:be.call(B,w),J=((ze=Y==null?void 0:Y.measured)==null?void 0:ze.width)??(Y==null?void 0:Y.width)??q.width??200,te=((de=Y==null?void 0:Y.measured)==null?void 0:de.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:ne}=B.getViewport(),ye=y1(ne);B.setCenter(q.position.x+J/2,q.position.y+te/2,{zoom:ye,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(j))},[kt,Xt]),Mr=h.useCallback((w,j)=>{const B=`node-${Date.now()}`;return s2(w,B,j,nr.current,Z)},[Z]),Dl=h.useCallback(w=>{if(!u||!w)return;let j={x:180,y:160};const B=Mi.current,q=document.querySelector(".af-pipeline-flow .react-flow");if(B&&q){const Y=q.getBoundingClientRect();j=B.screenToFlowPosition({x:Y.left+Y.width*.45,y:Y.top+Y.height*.38})}kt(Y=>[...Y,Mr(w,j)])},[u,kt,Mr]),Ia=h.useCallback(w=>{const j=Yp.current;if(!u||!j||!(w!=null&&w.def))return;const B=Mr(w.def,j.flowPosition),q=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:B.id,targetHandle:`input-${w.slotIndex}`}:{source:B.id,sourceHandle:`output-${w.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};kt(Y=>pg([...Y,B],q)),Xt(Y=>{const J=Y.filter(te=>!(te.target===q.target&&te.targetHandle===q.targetHandle));return qf({...q,markerEnd:{type:$s.ArrowClosed}},J)}),Oi(null)},[u,Mr,kt,Xt]),Ta=h.useCallback(w=>{w.preventDefault(),w.dataTransfer.dropEffect="move"},[]),bd=h.useCallback(w=>{var te;if(w.preventDefault(),!u)return;const j=Mi.current;if(!j)return;const B=j.screenToFlowPosition({x:w.clientX,y:w.clientY}),q=w.dataTransfer.getData("application/agentflow-snippet");if(q){const ne=et.find(ye=>`${ye.id}@${ye.version}`===q);ne&&((te=Ol.current)==null||te.call(Ol,ne,B));return}const Y=w.dataTransfer.getData("application/agentflow-node");if(!Y)return;const J=Z.find(ne=>ne.id===Y);J&&kt(ne=>[...ne,Mr(J,B)])},[u,Z,et,kt,Mr]),wi=h.useCallback(async(w,j)=>{if(!u)return;const B=Bj(w,j,nr.current,{description:b,viewport:Ic.current});if(B!==Ml.current){N(e("flow:status.saving"));try{const q=O7(u.source),Y=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:q,flowYaml:B,...u.archived?{flowArchived:!0}:{}})}),J=await Y.json();if(!Y.ok||!J.success)throw new Error(J.error||e("flow:status.saveFailed"));if(Ml.current=B,N(e("flow:status.saved")),bi(u.source)&&q==="workspace"){const te={id:u.id,source:"workspace",path:void 0};p(te),v1(te),vh(u.id,"workspace")}}catch(q){N(e("flow:status.saveFailed")+": "+(q.message||q))}}},[u,b]);h.useEffect(()=>{if(!u||!Pa.current||Ie!=="edit"||u.archived)return;const w=gd.current,j=setTimeout(()=>{w===gd.current&&Pa.current&&wi(Ys.current,Yo.current)},400);return()=>clearTimeout(j)},[Et,vn,b,Ie,u,wi]);const Xp=h.useCallback(async w=>{if(!u||u.archived)return;const j=u.source??"user";if(!(j!=="user"&&j!=="workspace")&&j!==w){H(!0),C("");try{const B=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:j,toSource:w})}),q=await B.json().catch(()=>({}));if(!B.ok)throw new Error(typeof q.error=="string"?q.error:e("flow:composer.requestFailed"));const Y=q.flowSource==="workspace"||q.flowSource==="user"?q.flowSource:w;let J={id:u.id,source:Y,archived:u.archived};try{const te=await fetch("/api/flows");if(te.ok){const ne=await te.json(),ye=Array.isArray(ne)?ne.find(be=>be.id===u.id&&(be.source??"user")===Y&&!!be.archived==!!u.archived):null;ye&&(J=ye)}}catch{}await $t(J,{preserveComposer:!0}),vh(u.id,Y)}catch(B){C(String(B.message||B))}finally{H(!1)}}},[u,$t]),ky=h.useCallback(async()=>{if(u){va(!0),_r(""),vl("");try{const w=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,schedule:ur})}),j=await w.json().catch(()=>({}));if(!w.ok||!j.success)throw new Error(j.error||"Failed to save schedule");ba({...Fd,...j.schedule||{}}),vl(e("flow:schedule.saved")),await le(u,{quiet:!0,force:!0})}catch(w){_r(String(w.message||w))}finally{va(!1)}}},[u,ur,le,e]),pR=h.useCallback(async()=>{u&&(await wi(Ys.current,Yo.current),!u.archived&&u.source!=="builtin"&&await ky())},[u,wi,ky]),Jp=h.useCallback(async()=>{if(!u||!M.trim())return;const w=M.trim();if(w===u.id){O("");return}$(!0),O("");try{const j=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",newFlowId:w})}),B=await j.json().catch(()=>({}));if(!j.ok)throw new Error(typeof B.error=="string"?B.error:e("flow:composer.requestFailed"));let q={id:B.flowId,source:B.flowSource??u.source,archived:u.archived};try{const Y=await fetch("/api/flows");if(Y.ok){const J=await Y.json(),te=Array.isArray(J)?J.find(ne=>ne.id===B.flowId&&(ne.source??"user")===(B.flowSource??u.source)):null;te&&(q=te)}}catch{}await $t(q,{preserveComposer:!0}),vh(B.flowId,B.flowSource??u.source)}catch(j){O(String(j.message||j))}finally{$(!1)}},[u,M,$t]),Q0=h.useCallback(w=>{navigator.clipboard.writeText(w).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(()=>{})},[]),Sy=h.useCallback(()=>{wi(Et,vn)},[wi,Et,vn]),Z0=h.useCallback(()=>{var j,B;if(!u)return;const w=x1((B=(j=Mi.current)==null?void 0:j.getViewport)==null?void 0:B.call(j));w&&(Ic.current=w,N("已固定 Pipeline 进入视角"),wi(Ys.current,Yo.current))},[wi,u]),hR=h.useCallback((w,j)=>{const B=j.trim()===""||j==="default"?void 0:j.trim(),q=Et.map(Y=>Y.id===w?{...Y,data:{...Y.data,model:B}}:Y);kt(q),wi(q,vn)},[Et,vn,kt,wi]),Qp=h.useCallback(()=>{var xt,Sn;if(!gt||!u||!ce)return!1;const w=ce.id,j=gt.newId.trim();if(Cl(""),!XT.test(j))return Cl(e("flow:nodePropsError.invalidInstanceId")),!1;if(Et.some(Nn=>Nn.id===j&&Nn.id!==w))return Cl(e("flow:nodePropsError.duplicateInstanceId")),!1;const B=gt.role.trim(),q=dl.includes(B)?B:"普通",Y=gt.model.trim(),J=Nn=>(Array.isArray(Nn)?Nn:[]).map(Wt=>({type:String((Wt==null?void 0:Wt.type)??"节点").trim()||"节点",name:String((Wt==null?void 0:Wt.name)??""),default:String((Wt==null?void 0:Wt.default)??""),required:!!(Wt!=null&&Wt.required),showOnNode:(Wt==null?void 0:Wt.showOnNode)!=null?Wt.showOnNode!==!1:!!(Wt!=null&&Wt.required)||String((Wt==null?void 0:Wt.type)??"节点").trim().toLowerCase()==="node"})),te=J(gt.inputs),ne=J(gt.outputs),ye=String(((xt=ce.data)==null?void 0:xt.definitionId)??j),be=ye.startsWith("provide_"),ze={...ce.data,label:gt.label.trim()||j,displayLabel:gt.label.trim()||j,role:q,model:Y===""||Y==="default"?void 0:Y,body:be?"":gt.body,images:be?[]:Ts(gt.images),inputs:te,outputs:be&&Array.isArray((Sn=ce.data)==null?void 0:Sn.outputs)?ce.data.outputs:ne},de=String(gt.script??"").trim();ye==="tool_nodejs"||de!==""?ze.script=String(gt.script??""):delete ze.script;let Fe,Ne=vn;if(j!==w){const Nn={...nr.current},Wt={...Nn[w]||{}};delete Nn[w],Nn[j]=Wt,nr.current=Nn,Fe=Et.map(St=>St.id!==w?St:{...St,id:j,selected:!0,data:ze}),Ne=vn.map((St,Qt)=>({...St,source:St.source===w?j:St.source,target:St.target===w?j:St.target,id:`e-${St.source===w?j:St.source}-${St.target===w?j:St.target}-${Qt}`}))}else Fe=Et.map(Nn=>Nn.id===w?{...Nn,data:ze}:Nn);return kt(Fe),Xt(Ne),as(j),wi(Fe,Ne),!0},[gt,u,ce,Et,vn,kt,Xt,as,wi]),Ny=h.useCallback(()=>{var Sn,Nn;if(!gt||!u||!ce)return!1;const w=ce.id,j=gt.role.trim(),B=dl.includes(j)?j:"普通",q=gt.model.trim(),Y=Wt=>(Array.isArray(Wt)?Wt:[]).map(St=>({type:String((St==null?void 0:St.type)??"节点").trim()||"节点",name:String((St==null?void 0:St.name)??""),default:String((St==null?void 0:St.default)??""),required:!!(St!=null&&St.required),showOnNode:(St==null?void 0:St.showOnNode)!=null?St.showOnNode!==!1:!!(St!=null&&St.required)||String((St==null?void 0:St.type)??"节点").trim().toLowerCase()==="node"})),J=Y(gt.inputs),te=Y(gt.outputs),ne=String(((Sn=ce.data)==null?void 0:Sn.definitionId)??w),ye=ne.startsWith("provide_"),be=gt.label.trim()||w,ze=q===""||q==="default"?void 0:q,de={...ce.data,label:be,displayLabel:be,role:B,model:ze,body:ye?"":gt.body,images:ye?[]:Ts(gt.images),inputs:J,outputs:ye&&Array.isArray((Nn=ce.data)==null?void 0:Nn.outputs)?ce.data.outputs:te},Fe=String(gt.script??"").trim();ne==="tool_nodejs"||Fe!==""?de.script=String(gt.script??""):delete de.script;const Ne=ce.data||{};return(Ne.label!==de.label||Ne.role!==de.role||Ne.model!==de.model||Ne.body!==de.body||JSON.stringify(Ts(Ne.images))!==JSON.stringify(de.images)||(Ne.script??void 0)!==(de.script??void 0)||JSON.stringify(Ne.inputs||[])!==JSON.stringify(J)||JSON.stringify(Ne.outputs||[])!==JSON.stringify(te))&&(kt(Wt=>Wt.map(St=>St.id===w?{...St,data:de}:St)),as(w)),!0},[gt,u,ce,kt,as]),ek=h.useRef(Ny);h.useEffect(()=>{ek.current=Ny},[Ny]),h.useEffect(()=>{if(!gt||!u||!Pa.current||Ie!=="edit")return;const w=setTimeout(()=>{ek.current()},400);return()=>clearTimeout(w)},[gt,u,Ie]);const mR=h.useCallback(()=>{if(!(!gt||!ce)){if(gt.newId.trim()===ce.id){Cl("");return}Qp()}},[gt,ce,Qp]);h.useEffect(()=>{const w=j=>{var te,ne,ye;if(Ie!=="edit")return;const B=BT(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){if(nt==="node"&&ce&&gt){j.preventDefault(),j.stopPropagation(),Qp()||Sy();return}if(B)return;j.preventDefault(),j.stopPropagation(),Sy();return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),Ip(be=>!be);return}if(On)return;if(Bn){if(j.key==="Escape"){j.preventDefault(),io(!1);return}if(mg(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),io(!1);return}(j.key==="v"||j.key==="V"||j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&j.preventDefault();return}if(B)return;const q=j.key.toLowerCase(),Y=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&q==="z",J=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&q==="z"||q==="y");if(Y||J){j.preventDefault(),j.stopPropagation();const be=Y?wd():S();N(be?Y?"Undo canvas change":"Redo canvas change":Y?"Nothing to undo":"Nothing to redo");return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="c"){const be=RT(Ys.current,Yo.current,nr.current);be&&(j.preventDefault(),j.stopPropagation(),yd.current=be,N(`Copied ${be.nodes.length} node${be.nodes.length>1?"s":""}`));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="v"){const be=LT(yd.current,Ys.current,Yo.current,nr.current);be&&(j.preventDefault(),j.stopPropagation(),nr.current=be.instances,kt(be.nodes),Xt(be.edges),N(`Pasted ${be.pastedNodeIds.length} node${be.pastedNodeIds.length>1?"s":""}`));return}if((j.key==="a"||j.key==="A")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),j.stopPropagation(),(te=Ve.current)==null||te.focus(),(ye=(ne=Ve.current)==null?void 0:ne.select)==null||ye.call(ne);return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),kt(be=>be.map(ze=>({...ze,selected:!0}))),Xt(be=>be.map(ze=>({...ze,selected:!1})));return}if(mg(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),io(be=>!be);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),ad("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),ad("pan");return}if((j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Z0();return}};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[Sy,Z0,Bn,On,nt,ce,gt,Qp,Ie,wd,S]),h.useEffect(()=>{if(Ie!=="running"||ut==null)return;let w=Math.floor((Date.now()-ut)/1e3);const j=setInterval(()=>{const B=Date.now()-ut,q=Math.floor(B/1e3);q!==w&&(w=q,Er(B))},500);return()=>clearInterval(j)},[Ie,ut]),h.useEffect(()=>{const w=Do.current;!w||!w.parentElement||rd.current&&(Fo.current=!0,w.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Fo.current=!1}))},[mr]),h.useEffect(()=>{const w=Do.current;if(!w)return;const j=w.parentElement;if(!j)return;const B=()=>{if(Fo.current)return;const q=j.scrollHeight-j.scrollTop-j.clientHeight;rd.current=q<40};return j.addEventListener("scroll",B,{passive:!0}),()=>j.removeEventListener("scroll",B)},[tt,Ie]),h.useEffect(()=>{if(Ie==="edit"||!tt)return;rd.current=!0;const w=Do.current;w&&(Fo.current=!0,w.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Fo.current=!1}))},[Ie,tt]),h.useEffect(()=>{mr.length>gm+w1&&ht(w=>w.length>gm+w1?w.slice(-gm):w)},[mr]);const gR=h.useCallback(w=>{if(w.button!==0)return;w.preventDefault();const j=w.currentTarget;Ii.current={active:!0,pointerId:w.pointerId,startY:w.clientY,startH:vr},j.setPointerCapture(w.pointerId)},[vr]),yR=h.useCallback(w=>{const j=Ii.current;if(!j.active||w.pointerId!==j.pointerId)return;const B=j.startY-w.clientY;$o(ym(j.startH+B))},[]),Zp=h.useCallback(()=>{$o(w=>{const j=ym(w);try{localStorage.setItem(o2,String(j))}catch{}return j})},[]),tk=h.useCallback(w=>{const j=Ii.current;if(!(!j.active||w.pointerId!==j.pointerId)){j.active=!1;try{w.currentTarget.releasePointerCapture(w.pointerId)}catch{}Zp()}},[Zp]),xR=h.useCallback(()=>{const w=Ii.current;w.active&&(w.active=!1,Zp())},[Zp]);h.useEffect(()=>{function w(){$o(j=>ym(j))}return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]);const fo=h.useCallback(async(w={})=>{if(!u)return;const j=w.runUuid!=null&&String(w.runUuid).trim()?String(w.runUuid).trim():null,B=w.cliInputsOverride??K.current,q=!!w.prepareOnly;if(cn(q?"ready":"running"),ht(q?[]:[{ts:new Date().toISOString(),type:"info",text:j?e("flow:run.connectingApiResume",{uuid:j}):e("flow:run.connectingApi")}]),Gn(new Set),Cr({}),gr(!q),zt(null),j||er(null),q)return;if(!j){const J=Date.now();Ut(J),Er(0)}const Y=new AbortController;ci.current=Y;try{const J=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",...j?{uuid:j}:{},cliInputs:B}),signal:Y.signal});if(!J.ok){const de=await J.json().catch(()=>({error:e("flow:composer.requestFailed")}));ht(Fe=>[...Fe,{ts:new Date().toISOString(),type:"error",text:de.error||e("flow:composer.requestFailed")}]),cn("error");return}if(ht(de=>[...de,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){ht(de=>[...de,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),cn("error");return}const te=J.body.getReader(),ne=new TextDecoder;let ye="";const be=de=>{const Fe=de.ts||new Date().toISOString();if(de.type==="event")if(de.event==="node-start")Gn(Ne=>new Set(Ne).add(de.instanceId)),Cr(Ne=>({...Ne,[de.instanceId]:{status:"running",startMs:Date.now()}})),ht(Ne=>[...Ne,{ts:Fe,type:"node-start",text:de.label?e("flow:run.nodeStartWithLabel",{instanceId:de.instanceId,label:de.label}):e("flow:run.nodeStart",{instanceId:de.instanceId})}]);else if(de.event==="node-done"){Gn(xt=>{const Sn=new Set(xt);return Sn.delete(de.instanceId),Sn});const Ne=de.elapsed??null;Cr(xt=>({...xt,[de.instanceId]:{status:"success",elapsed:Ne}})),ht(xt=>[...xt,{ts:Fe,type:"node-done",text:Ne?e("flow:run.nodeDoneWithElapsed",{instanceId:de.instanceId,elapsed:Ne}):e("flow:run.nodeDone",{instanceId:de.instanceId})}])}else if(de.event==="node-failed")Gn(Ne=>{const xt=new Set(Ne);return xt.delete(de.instanceId),xt}),Cr(Ne=>({...Ne,[de.instanceId]:{status:"failed",elapsed:de.elapsed??null}})),ht(Ne=>[...Ne,{ts:Fe,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:de.instanceId})}]);else if(de.event==="apply-start"){if(de.uuid&&er(String(de.uuid)),typeof de.runStartTime=="number"&&de.runStartTime>0)Ut(de.runStartTime),Er(Math.max(0,Date.now()-de.runStartTime));else if(typeof de.totalExecutedMs=="number"&&de.totalExecutedMs>0){const Ne=Date.now()-de.totalExecutedMs;Ut(Ne),Er(de.totalExecutedMs)}ht(Ne=>[...Ne,{ts:Fe,type:"info",text:e("flow:run.pipelineStart",{uuid:de.uuid||"?"})}])}else de.event==="apply-done"?ht(Ne=>[...Ne,{ts:Fe,type:"info",text:de.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:de.totalElapsed}):e("flow:run.pipelineDone")}]):de.event==="apply-paused"?ht(Ne=>[...Ne,{ts:Fe,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(de.pendingNodes||[]).join(", ")})}]):ht(Ne=>[...Ne,{ts:Fe,type:"event",text:`[${de.event}] ${JSON.stringify(de)}`}]);else de.type==="user-check-content"?(Sl({instanceId:de.instanceId,execId:de.execId??1,inputPath:de.inputPath,outputPath:de.outputPath,content:de.content||""}),Ri(de.content||""),zo(!1),Ho(""),jl(!1),ht(Ne=>[...Ne,{ts:Fe,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:de.instanceId})}])):de.type==="user-ask-prompt"?(Lr({instanceId:de.instanceId,execId:de.execId??1,question:de.question||"",options:Array.isArray(de.options)?de.options:[]}),fi(!1),ht(Ne=>[...Ne,{ts:Fe,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:de.instanceId,defaultValue:`等待用户选择 (${de.instanceId})`})}])):de.type==="tool-print-content"?(Bo({instanceId:de.instanceId,execId:de.execId??1,content:de.content||"",createdAt:Date.now()}),od(!1)):de.type==="log"?ht(Ne=>[...Ne,{ts:Fe,type:"log",text:de.text!=null?String(de.text):""}]):de.type==="error"?ht(Ne=>[...Ne,{ts:Fe,type:"error",text:de.message||e("flow:run.unknownError")}]):de.type==="done"?ht(Ne=>[...Ne,{ts:Fe,type:"done",text:e("flow:run.executionEnd",{exitCode:de.exitCode??"?"})}]):ht(Ne=>[...Ne,{ts:Fe,type:"log",text:JSON.stringify(de)}])},ze=de=>{if(de.trim())try{be(JSON.parse(de))}catch{ht(Fe=>[...Fe,{ts:new Date().toISOString(),type:"log",text:de}])}};for(;;){const{done:de,value:Fe}=await te.read();ye+=ne.decode(Fe??new Uint8Array,{stream:!de});const Ne=ye.split(`
132
+ `);for(let r=n.length-1;r>=0&&t.length<I7;r--){const s=n[r];if(!s)continue;const i=T7(s);i&&t.push(i)}return t.reverse(),t}function R7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const i=e[s],a=t[s];if(!a)return!1;if(i!==a&&(i.status!==a.status||(i.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function L7(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function M7({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:f,onNodeClick:u,onNodeDoubleClick:p,onEdgeClick:m,onFlowInit:y,onDrop:b,onDragOver:k,hideMinimapAndControls:g,bottomSlot:v}){const{t:x}=Mn(),N=!s,_=N||t==="pan"?!0:[1,2],C=N?!1:t==="select",T="af-flow-canvas"+(N?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),H=h.useCallback(()=>{},[]),M=h.useMemo(()=>{const F=new Map(n.map(R=>[R.id,R])),D=new Set(n.filter(R=>R.selected).map(R=>R.id)),$=D.size>0,W=(R,I)=>{const z=/^#([0-9a-f]{6})$/i.exec(R);if(!z)return R;const P=parseInt(z[1],16);return`rgba(${P>>16&255}, ${P>>8&255}, ${P&255}, ${I})`},O="#ff5169";return r.map(R=>{var pe,_e,je,Ve;const I=F.get(R.source),z=F.get(R.target),P=/^output-(\d+)$/.exec(R.sourceHandle||""),L=/^input-(\d+)$/.exec(R.targetHandle||""),E=I&&P?(_e=(pe=I.data)==null?void 0:pe.outputs)==null?void 0:_e[parseInt(P[1],10)]:null,X=z&&L?(Ve=(je=z.data)==null?void 0:je.inputs)==null?void 0:Ve[parseInt(L[1],10)]:null,ee=E!=null&&E.type?or(E.type):null,V=X!=null&&X.type?or(X.type):null,ie=ee&&V&&ee!==V,fe=$&&(D.has(R.source)||D.has(R.target)),me=R.style||{};if(ie){const et=R.selected?.95:fe?.85:.78,qe=W(O,et);return{...R,className:((R.className||"")+" af-flow-edge--type-mismatch"+(fe?" af-flow-edge--adjacent":"")).trim(),style:{...me,stroke:qe,strokeWidth:fe?2.75:2.5,strokeDasharray:"6 4"},markerEnd:R.markerEnd&&typeof R.markerEnd=="object"?{...R.markerEnd,color:qe}:{type:$s.ArrowClosed,color:qe}}}const ge=ee||V;if(!ge)return fe?{...R,className:((R.className||"")+" af-flow-edge--adjacent").trim(),style:{...me,strokeWidth:2.5}}:R;const Z=fe||R.selected?.7:.38,ae=W(ge,Z),xe=fe?2.5:me.strokeWidth??2;return{...R,className:((R.className||"")+(fe?" af-flow-edge--adjacent":"")).trim(),style:{...me,stroke:ae,strokeWidth:xe},markerEnd:R.markerEnd&&typeof R.markerEnd=="object"?{...R.markerEnd,color:ae}:{type:$s.ArrowClosed,color:ae}}})},[n,r]);return o.jsxs(c0,{className:T,nodes:n,edges:M,onNodesChange:s||H,onEdgesChange:i||H,onConnect:N?void 0:a,onConnectStart:N?void 0:l,onConnectEnd:N?void 0:c,isValidConnection:N?void 0:d,onNodesDelete:N?void 0:f,onNodeClick:u,onNodeDoubleClick:N?void 0:p,onEdgeClick:N?void 0:m,onInit:y,onDrop:N?void 0:b,onDragOver:N?void 0:k,nodeTypes:a7,selectionOnDrag:C,panOnDrag:_,nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N,edgesFocusable:!N,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[o.jsx(d0,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx($u,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(g?" af-flow-bottom-unified-panel--solo":""),children:o.jsxs("div",{className:"af-flow-bottom-unified-row"+(g?" af-flow-bottom-unified-row--solo":""),children:[g?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:o.jsx(BB,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:F=>{var $;const D=((($=F.data)==null?void 0:$.schemaType)??"agent").toLowerCase();return D==="control"?"rgba(237, 108, 2, 0.85)":D==="provide"?"rgba(0, 228, 117, 0.35)":D==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:v}),g?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(PB,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!g&&o.jsx($u,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:F,color:D})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:D}}),o.jsx("span",{className:"af-pin-legend__label",children:F})]},F))}),o.jsx(E7,{fitViewEpoch:e}),!N&&n.length===0?o.jsxs("div",{className:"af-flow-empty-hint",children:[o.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),o.jsx("p",{className:"af-flow-empty-hint-text",children:x("flow:emptyCanvas.composerHint")}),o.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:x("flow:emptyCanvas.composerSub")}})]}):null]})}function v1(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams(window.location.search),n=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&n.set("flowArchived","1"),t.get("panel")==="settings"&&n.set("panel","settings"),window.history.replaceState({},"","/flow?"+n.toString())}function O7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function bi(e){return e==="builtin"||e==="admin"}function zc(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function $7(e){var r,s,i,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const o2="af:run-console-height",xf=230,Fd={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Hh={};function ym(e){if(!Number.isFinite(e))return xf;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function D7(){try{const e=localStorage.getItem(o2);if(e==null)return xf;const t=parseInt(e,10);return Number.isFinite(t)?ym(t):xf}catch{return xf}}function F7(){var uk,dk;const{t:e,i18n:t}=Mn(),{navigate:n,path:r}=Ro(),s=h.useRef(null),i=h.useRef(new Map),a=h.useCallback(w=>{s.current=typeof w=="function"?w:null},[]),[l,c]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState(null),[m,y]=h.useState(0),[b,k]=h.useState(""),[g,v]=h.useState(""),[x,N]=h.useState(""),[_,C]=h.useState(""),[T,H]=h.useState(!1),[M,F]=h.useState(""),[D,$]=h.useState(!1),[W,O]=h.useState(""),[R,I]=h.useState(!1),[z,P]=h.useState(!1),[L,E]=h.useState(!1),[X,ee]=h.useState(null),[V,ie]=h.useState(!1),[fe,me]=h.useState(!1),ge=h.useRef(!1),[Z,ae]=h.useState([]),[xe,pe]=h.useState(""),[_e,je]=h.useState("nodes"),Ve=h.useRef(null),[et,qe]=h.useState([]),[dt,He]=h.useState(!1),[bt,sn]=h.useState(""),[on,an]=h.useState(!1),[Yt,En]=h.useState({name:"",id:"",description:""}),[hn,ue]=h.useState(!1),[ke,De]=h.useState(""),[rt,at]=h.useState(""),Lt=h.useRef(null),[st,mn]=h.useState([]),[Zt,ar]=h.useState(!1),[_n,gn]=h.useState(""),[bn,lr]=h.useState(""),[ve,$e]=h.useState(null),[nt,zt]=h.useState(null),[oe,Te]=h.useState([]),[Ue,Ht]=h.useState(""),[yn,cr]=h.useState(!1),Hs=h.useCallback(w=>{Lt.current&&window.clearTimeout(Lt.current),at(w),Lt.current=window.setTimeout(()=>{at(""),Lt.current=null},3800)},[]),as=h.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const B=()=>{var q;return(q=s.current)==null?void 0:q.call(s,j)};window.requestAnimationFrame(B),window.setTimeout(B,80)},[]);h.useEffect(()=>()=>{Lt.current&&window.clearTimeout(Lt.current)},[]);const[hr,Zn]=h.useState(!1),[Vr,ot]=h.useState({files:[]}),[Ur,Ai]=h.useState(!1),[xa,xs]=h.useState(!0);h.useEffect(()=>{let w=!1;const j=()=>{fetch("/api/flows",{method:"HEAD"}).then(q=>{w||xs(q.ok)}).catch(()=>{w||xs(!1)})};j();const B=window.setInterval(j,5e3);return()=>{w=!0,window.clearInterval(B)}},[]),h.useEffect(()=>{let w=!1;return fetch("/api/dev-info").then(j=>j.json()).then(j=>{w||wa(!!(j!=null&&j.isDev))}).catch(()=>{}),()=>{w=!0}},[]),h.useEffect(()=>{u!=null&&u.id&&oP(u.id,u.source??"user","pipeline",!!u.archived)},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const[Ie,cn]=h.useState("edit"),[mr,ht]=h.useState([]),Oe=h.useRef(0),[Kr,Gn]=h.useState(new Set),[qr,Cr]=h.useState({}),[ut,Ut]=h.useState(null),[un,Er]=h.useState(0),[tt,gr]=h.useState(!1),[Bs,wa]=h.useState(!1),[ws,Oo]=h.useState(!1),[vr,$o]=h.useState(D7),Ii=h.useRef({active:!1,pointerId:-1,startY:0,startH:xf}),[xn,er]=h.useState(null),[bs,Yr]=h.useState(null),[li,Ws]=h.useState({}),K=h.useRef(li);h.useEffect(()=>{K.current=li},[li]);const[we,Le]=h.useState(!1),[Me,Ke]=h.useState(!1),[en,Mt]=h.useState({}),[wn,Gr]=h.useState({}),[ls,Vs]=h.useState(null),[ur,ba]=h.useState(Fd),[nd,Pp]=h.useState(!1),[Ti,va]=h.useState(!1),[wl,_r]=h.useState(""),[bl,vl]=h.useState(""),[Kt,vc]=h.useState(Hh),[Bt,kl]=h.useState(null),so=h.useRef(0),ci=h.useRef(null),Do=h.useRef(null),rd=h.useRef(!0),Fo=h.useRef(!1),[kr,Sl]=h.useState(null),[ui,Ri]=h.useState(null),[kc,zo]=h.useState(!1),[ka,Ho]=h.useState(""),[Nl,jl]=h.useState(!1),sd=h.useRef(null),[di,Lr]=h.useState(null),[id,fi]=h.useState(!1),[Sa,Bo]=h.useState(null),[vs,od]=h.useState(!1),[Xr,Na]=h.useState(null),pi=h.useRef(null),[ks,Pe]=h.useState(""),[Ss,ja]=h.useState(0),[Ca,hi]=h.useState(0),[Ap,ad]=h.useState("pan"),[Bn,io]=h.useState(!1),[On,Ip]=h.useState(!1),ld=h.useRef(null),cd=h.useRef(null),Ea=h.useRef(null),[Tp,Rp]=h.useState(0),[gt,ud]=h.useState(null),[Lp,Cl]=h.useState(""),[vt,Mp]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[mi,El]=h.useState(""),[Sc,yy]=h.useState(""),[gi,Op]=h.useState([]),[dr,oo]=h.useState([]),[dd,$p]=h.useState(!1),[_l,Dp]=h.useState([]),[fd,Us]=h.useState(!1),[Fp,Pl]=h.useState(()=>new Set),[Li,mt]=h.useState(!1),Gt=h.useRef(null),Nc=h.useRef(null),[xy,pd]=h.useState({}),jc=h.useCallback(w=>{if(!w)return null;const j=w.id,B=w.source??"user",q=w.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${j}:${B}${q?":"+q:""}`,activeKey:`af:composer-active-session:${j}:${B}${q?":"+q:""}`}},[]),zp=h.useCallback(w=>{if(!w)return"";const j=w.id,B=w.source??"user",q=w.archived?"archived":"";return`af:composer-skills:pipeline:${j}:${B}${q?":"+q:""}`},[]),Hp=h.useCallback(w=>{const j=jc(w);if(!j)return{sessions:[],activeSessionId:null};try{const B=localStorage.getItem(j.sessionsKey);if(!B)return{sessions:[],activeSessionId:null};const q=JSON.parse(B);if(!Array.isArray(q))return{sessions:[],activeSessionId:null};const Y=q.filter(te=>te&&typeof te.id=="string").map(te=>({...te,running:!1,statusLine:te.running?e("flow:composer.pageRefreshReset"):te.statusLine,steps:[]}));let J=null;try{J=localStorage.getItem(j.activeKey),J&&!Y.some(te=>te.id===J)&&(J=null)}catch{J=null}return{sessions:Y,activeSessionId:J}}catch{return{sessions:[],activeSessionId:null}}},[jc]),Cc=h.useCallback((w,j,B)=>{const q=jc(w);if(q)try{localStorage.setItem(q.sessionsKey,JSON.stringify(j)),B?localStorage.setItem(q.activeKey,B):localStorage.removeItem(q.activeKey)}catch{}},[jc]),Wo=h.useRef(0),Al=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[cs,Jr]=h.useState([]),[tr,ao]=h.useState(null),lo=h.useMemo(()=>zp(u),[zp,u]),[Ec,Vo]=h.useState(""),Wn=h.useMemo(()=>{if(!u)return null;const w=u.id,j=u.source??"user",B=u.archived?"archived":"";return`${w}:${j}${B?":"+B:""}`},[u]),_a=h.useRef(!1);h.useEffect(()=>{if(!Wn){Jr([]),ao(null),Al.current={sessions:[],activeSessionId:null,flowKey:null};return}const w=Al.current;if(w.flowKey===Wn)return;w.flowKey=Wn,_a.current&&w.sessions.length>0&&Cc(u,w.sessions,w.activeSessionId);const{sessions:j,activeSessionId:B}=Hp(u);if(j.length===0){const q=`session-1-${Date.now()}`,Y={id:q,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};w.sessions=[Y],w.activeSessionId=q,Jr([Y]),ao(q)}else{const q=j[j.length-1];if(q&&(!q.thread||q.thread.length===0))Wo.current=$x(j),w.sessions=j,w.activeSessionId=q.id,Jr(j),ao(q.id);else{const J=$x(j)+1;Wo.current=J;const te=`session-${J}-${Date.now()}`,ne={id:te,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},ye=[...j,ne];w.sessions=ye,w.activeSessionId=te,Jr(ye),ao(te)}}_a.current=!0},[Wn,u,Hp,Cc]);const Pn=h.useMemo(()=>cs.find(w=>w.id===tr)||null,[cs,tr]),An=(Pn==null?void 0:Pn.running)??!1,Il=(Pn==null?void 0:Pn.statusLine)??"",Uo=(Pn==null?void 0:Pn.segments)??[],co=(Pn==null?void 0:Pn.thread)??[],hd=(Pn==null?void 0:Pn.steps)??[];Pn==null||Pn.outputDismissed;const jt=(Pn==null?void 0:Pn.phaseContext)??null,md=h.useRef([]),[_c,Ko]=h.useState(!1),Tl=h.useRef(null),Bp=h.useRef(null);h.useEffect(()=>{const w=Bp.current;w&&requestAnimationFrame(()=>{w.scrollTop=w.scrollHeight})},[co,Uo]);const Pc=h.useRef(null),Ac=h.useRef(!1),Rl=h.useRef(null),Wp=h.useCallback(w=>{const j=++Wo.current,B=`session-${j}-${Date.now()}`,q={id:B,label:w||e("flow:composer.conversationLabel",{n:j}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Jr(Y=>[...Y,q]),ao(B),B},[]);h.useEffect(()=>{!u||!_a.current||(Al.current.sessions=cs,Al.current.activeSessionId=tr,Cc(u,cs,tr))},[cs,tr,u,Cc]),h.useEffect(()=>{Wo.current=Math.max(Wo.current,$x(cs))},[cs]);const Vp=h.useCallback(w=>{var j;Pc.current===w&&((j=Tl.current)==null||j.abort()),Jr(B=>{const q=B.filter(J=>J.id!==w);if(B.some((J,te)=>J.id===w&&B.findIndex(ne=>ne.id===tr)===te)||tr===w){const J=q;J.length>0?ao(J[J.length-1].id):setTimeout(()=>{Wo.current=0;const te=++Wo.current,ne=`session-${te}-${Date.now()}`,ye={id:ne,label:e("flow:composer.conversationLabel",{n:te}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Jr(be=>[...be,ye]),ao(ne)},0)}return q})},[tr]),Qr=h.useCallback(w=>{Jr(j=>{const B=j.findIndex(J=>J.id===tr);if(B<0)return j;const q={...j[B]};w(q);const Y=[...j];return Y[B]=q,Y})},[tr]),Up=h.useCallback(w=>{Qr(j=>{j.running=w})},[Qr]),Ks=h.useCallback(w=>{Qr(j=>{j.statusLine=w})},[Qr]),qs=h.useCallback(w=>{Qr(j=>{typeof w=="function"?j.segments=w(j.segments):j.segments=w})},[Qr]),Kp=h.useCallback(w=>{Qr(j=>{typeof w=="function"?j.thread=w(j.thread):j.thread=w})},[Qr]),yi=h.useCallback(w=>{Qr(j=>{typeof w=="function"?j.steps=w(j.steps):j.steps=w})},[Qr]),qp=h.useCallback(w=>{Qr(j=>{j.outputDismissed=w})},[Qr]),Ll=h.useCallback(w=>{Qr(j=>{j.phaseContext=typeof w=="function"?w(j.phaseContext):w})},[Qr]),qo=h.useCallback(w=>{ao(w),Jr(j=>{const B=j.findIndex(Y=>Y.id===w);if(B<0||!j[B].outputDismissed)return j;const q=[...j];return q[B]={...j[B],outputDismissed:!1},q})},[]);h.useEffect(()=>{md.current=Uo},[Uo]);const nr=h.useRef({}),xi=h.useRef(!1),Mi=h.useRef(null),Ic=h.useRef(null),uo=h.useRef(null),Pa=h.useRef(!1),gd=h.useRef(0),Ml=h.useRef(""),[Et,kt,wy]=nI([]),[vn,Xt,by]=rI([]),Ys=h.useRef(Et),Yo=h.useRef(vn),yd=h.useRef(null),Tc=h.useRef(null),Yp=h.useRef(null),Ol=h.useRef(null),[dn,Oi]=h.useState(null),Gp=h.useCallback(w=>{var j;nr.current=(j=w==null?void 0:w.extra)!=null&&j.instances&&typeof w.extra.instances=="object"?w.extra.instances:{},kt(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),Xt(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),Oi(null)},[Xt,kt]),vy=h.useMemo(()=>({instances:nr.current}),[vn,Et]),{resetHistory:xd,undo:wd,redo:S}=FT({nodes:Et,edges:vn,extra:vy,enabled:!!u&&Pa.current&&Ie==="edit",onRestore:Gp}),A=h.useMemo(()=>Et.filter(w=>{var j;return(((j=w.data)==null?void 0:j.definitionId)||"").startsWith("provide_")}),[Et]),U=h.useMemo(()=>{var j;const w={};for(const B of Et){if(!((j=B.data)!=null&&j.inputs))continue;const q=B.data.inputs;for(let Y=0;Y<q.length;Y++){const J=q[Y];if(!(J!=null&&J.name))continue;const te=vn.find(ye=>ye.target===B.id&&ye.targetHandle===`input-${Y}`);if(!(te!=null&&te.source))continue;A.find(ye=>ye.id===te.source)&&(w[te.source]=J.name)}}return w},[Et,vn,A]),G=h.useMemo(()=>{if(Ie==="edit"||Kr.size===0)return null;const w=new Set(Kr);for(const j of vn)Kr.has(j.source)&&w.add(j.target),Kr.has(j.target)&&w.add(j.source);return w},[Ie,Kr,vn]),Q=h.useMemo(()=>Ie==="edit"?Et:Et.map(w=>{var j,B;return{...w,draggable:!1,connectable:!1,data:{...w.data,isRunMode:!0,isExecuting:Kr.has(w.id),nodeStatus:((j=qr[w.id])==null?void 0:j.status)??null,nodeElapsed:((B=qr[w.id])==null?void 0:B.elapsed)??null,isDim:G?!G.has(w.id):!1}}}),[Ie,Et,Kr,qr,G]),se=h.useMemo(()=>G?vn.map(w=>{const j=Kr.has(w.source)||Kr.has(w.target),B=w.className?w.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",q=j?"af-flow-edge--focus":"af-flow-edge--dim";return{...w,className:(B?B+" ":"")+q}}):vn,[vn,Kr,G]);h.useEffect(()=>{if(!u){Gr({}),Vs(null),ba(Fd),vc(Hh),kl(null),_r(""),vl("");return}const w=new URLSearchParams({flowId:u.id,flowSource:u.source||"user"});u.archived&&w.set("archived","1"),fetch(`/api/flow/run-config?${w.toString()}`).then(j=>j.json()).then(j=>{Gr(j.presets||{}),Vs(j.activePreset||null)}).catch(()=>{Gr({}),Vs(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const re=h.useCallback(w=>{so.current+=1,ba(w)},[]),le=h.useCallback(async(w,j={})=>{if(!w)return;const B=!!j.quiet,q=!!j.force,Y=so.current;B||(Pp(!0),_r(""),vl(""));const J=new URLSearchParams({flowId:w.id,flowSource:w.source||"user"});w.archived&&J.set("archived","1");try{const te=await fetch(`/api/flow/schedule?${J.toString()}`),ne=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ne.error||`HTTP ${te.status}`);if(!q&&so.current!==Y)return;ba({...Fd,...ne.schedule||{}}),vc(ne.state&&typeof ne.state=="object"?ne.state:Hh),kl(ne.status||null)}catch(te){if(!q&&so.current!==Y)return;ba(Fd),vc(Hh),kl(null),_r(String(te.message||te))}finally{Pp(!1)}},[]);h.useEffect(()=>{if(!u)return;let w=!1;return(async()=>{await le(u)})(),()=>{w=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,le]),h.useEffect(()=>{var B,q,Y,J;if(!ls||!wn[ls]||A.length===0)return;const w=wn[ls],j={};for(const te of A){const ne=U[te.id];if(!ne)continue;const ye=((B=te.data)==null?void 0:B.definitionId)||"",be=w[te.id]??((J=(Y=(q=te.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"";ye.startsWith("provide_file")?j[ne]={type:"file",path:be}:j[ne]={type:"str",value:be}}Object.keys(j).length>0&&Ws(j)},[ls,wn,A,U]);const he=h.useCallback(()=>{if(!Xr||!pi.current)return;const w=pi.current.value;kt(j=>j.map(B=>{var q,Y;return B.id!==Xr.instanceId?B:{...B,data:{...B.data,outputs:((Y=(q=B.data)==null?void 0:q.outputs)==null?void 0:Y.map((J,te)=>te===0?{...J,default:w}:J))||[{type:"text",name:"value",default:w}]}}})),Na(null)},[Xr,kt]),ce=h.useMemo(()=>{const w=Et.filter(j=>j.selected);return w.length===1?w[0]:null},[Et]),Ce=h.useMemo(()=>u?iK(Et,vn,e):[],[u,Et,vn,e]),Be=h.useMemo(()=>Ce.map(w=>w.key).join("|"),[Ce]),yt=h.useMemo(()=>Ce.some(w=>String((w==null?void 0:w.level)||"warning").toLowerCase()==="error"),[Ce]);h.useLayoutEffect(()=>{ie(Ce.length>0&&!yt)},[Be,u==null?void 0:u.id,u==null?void 0:u.source,Ce.length,yt]),Ea.current=ce,h.useEffect(()=>{Ys.current=Et},[Et]),h.useEffect(()=>{const w=i.current,j=new Map,B=[];for(const te of Et){const ne=m7(te);j.set(te.id,ne),w.get(te.id)!==ne&&B.push(te.id)}if(i.current=j,B.length===0)return;const q=()=>B.forEach(te=>{var ne;return(ne=s.current)==null?void 0:ne.call(s,te)}),Y=window.requestAnimationFrame(q),J=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Y),window.clearTimeout(J)}},[Et]),h.useEffect(()=>{Yo.current=vn},[vn]),h.useEffect(()=>{Yp.current=dn},[dn]),h.useEffect(()=>{if(!dn)return;const w=B=>{B.key==="Escape"&&Oi(null)},j=B=>{var q,Y;(Y=(q=B.target)==null?void 0:q.closest)!=null&&Y.call(q,".af-connect-node-menu")||Oi(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",j)}},[dn]),h.useEffect(()=>()=>{uo.current!=null&&(clearTimeout(uo.current),uo.current=null)},[]);const Xe=h.useMemo(()=>{var j;if(!ce)return null;const w=(j=ce.data)==null?void 0:j.definitionId;return Z.find(B=>B.id===w)??null},[ce,Z]),_t=h.useMemo(()=>{const w={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const j of Z){const B=L0(j);w[B].push(j)}for(const j of Jd)w[j].sort((B,q)=>B.id.localeCompare(q.id));return w},[Z]),kn=h.useMemo(()=>{const w=xe.trim().toLowerCase();if(!w)return _t;const j={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const B of Jd)j[B]=_t[B].filter(q=>d7(q,w));return j},[_t,xe]),us=h.useMemo(()=>Jd.reduce((w,j)=>w+kn[j].length,0),[kn]),ln=h.useMemo(()=>Z.filter(w=>{const j=String(w.id??""),B=String(w.source??"");return j.startsWith("marketplace:")||B==="marketplace"||B==="collection"}),[Z]),fn=h.useMemo(()=>{const w=new Set;for(const j of ln){const B=String(j.id??"");if(B&&(w.add(B),B.startsWith("marketplace:"))){const q=B.slice(12),[Y]=q.split("@");Y&&w.add(`marketplace:${Y}`)}}return w},[ln]),rr=h.useCallback(async()=>{f("");try{const w=await fetch("/api/flows");if(!w.ok)throw new Error("HTTP "+w.status);c(await w.json())}catch(w){f(String(w.message||w))}},[]);h.useEffect(()=>{rr()},[rr]),h.useEffect(()=>{if(r!=="/flow")return;const w=new URLSearchParams(window.location.search);w.get("new")==="1"&&!w.get("flowId")&&n("/projects?new=1")},[r,n]),h.useEffect(()=>{if(r!=="/flow"||!u)return;new URLSearchParams(window.location.search).get("panel")==="settings"&&zt("settings")},[r,u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{let w=!1;const j=()=>{fetch("/api/model-lists").then(q=>q.json()).then(q=>{w||Mp({cursor:Array.isArray(q.cursor)?q.cursor.map(String):[],opencode:Array.isArray(q.opencode)?q.opencode.map(String):[],claudeCode:Array.isArray(q.claudeCode)?q.claudeCode.map(String):[]})}).catch(()=>{})};j();const B=setTimeout(j,4e3);return()=>{w=!0,clearTimeout(B)}},[]),h.useEffect(()=>{let w=!1;return fetch("/api/skills").then(j=>j.json()).then(j=>{if(w)return;const B=Array.isArray(j.skills)?j.skills.filter(q=>q&&typeof q.key=="string"&&q.key.trim()).map(q=>({key:String(q.key),name:String(q.name||q.id||q.key),description:q.description?String(q.description):"",sourceLabel:q.sourceLabel?String(q.sourceLabel):""})):[];Op(B),$p(!0)}).catch(()=>{}),()=>{w=!0}},[]),h.useEffect(()=>{let w=!1;return fetch("/api/skill-collections").then(j=>j.json()).then(j=>{w||(Dp(rl(j)),Us(!0))}).catch(()=>{}),()=>{w=!0}},[]),h.useEffect(()=>{if(Vo(""),!(!dd||!fd)){if(!lo){oo([]);return}oo(uP(lo,"pipeline",gi,_l)),Vo(lo)}},[_l,fd,gi,dd,lo]),h.useEffect(()=>{if(!(Ec!==lo||!lo))try{localStorage.setItem(lo,JSON.stringify(dr))}catch{}},[dr,lo,Ec]);const Tt=h.useCallback(async w=>{const j=w.source??"user",B=!!w.archived,q=new URLSearchParams({flowId:w.id,flowSource:j});B&&q.set("archived","1");const Y=new URLSearchParams({flowId:w.id,flowSource:j});B&&Y.set("archived","1"),Y.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[J,te]=await Promise.all([fetch("/api/flow?"+q.toString()),fetch("/api/nodes?"+Y.toString())]),ne=await J.json();if(!J.ok||ne.error)throw new Error(ne.error||e("flow:nodePropsError.loadFlowFailed"));const ye=await te.json();if(!te.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const be=Array.isArray(ye)?ye:Array.isArray(ye==null?void 0:ye.nodes)?ye.nodes:[],ze=!Array.isArray(ye)&&(ye==null?void 0:ye.pipelineTranslations)||{},de=nK(ne.flowYaml||"");if(de.error)throw new Error(de.error);const Fe={...de.instances||{}},Ne=de.nodes.map(Sn=>tp(Sn,Fe,be,ze,w.id)),xt=DT(de.edges,Ne);return{flowSource:j,paletteList:be,instances:Fe,flowDescriptionText:de.description??"",viewport:x1(de.viewport),nodes:Ne,edges:xt}},[t.language,e]),$t=h.useCallback(async(w,j={})=>{const B=!!j.preserveComposer,q=B&&!!j.incrementalSync;Pa.current=!1,gd.current+=1,p(w),v(""),B||(N(""),pe(""),zt(null),k(""),F(""),O(""),Pe(""),Kp([]),qs([]),yi([]),qp(!1),Ll(null),ad("pan")),q||(nr.current={},kt([]),Xt([])),v1(w);try{const Y=await Tt(w);if(ae(Y.paletteList),nr.current=Y.instances,k(Y.flowDescriptionText),F(w.id||""),q){const J=Ys.current,te=Yo.current;try{const ne=R9(J,te,Y.nodes,Y.edges),ye=new Set([...ne.changes.addedNodeIds,...ne.changes.updatedNodeIds]),be=new Set([...ne.changes.addedEdgeKeys,...ne.changes.updatedEdgeKeys]),ze=ye.size>0?ne.nodes.map(Fe=>ye.has(Fe.id)?{...Fe,className:a1(Fe.className,i1)}:Fe):ne.nodes,de=be.size>0?ne.edges.map(Fe=>be.has(Xf(Fe))?{...Fe,className:a1(Fe.className,o1)}:Fe):ne.edges;kt(ze),Xt(de),uo.current!=null&&(clearTimeout(uo.current),uo.current=null),(ye.size>0||be.size>0)&&(uo.current=window.setTimeout(()=>{uo.current=null,ye.size>0&&kt(Fe=>Fe.map(Ne=>{if(!ye.has(Ne.id))return Ne;const xt=l1(Ne.className,i1);return xt===String(Ne.className||"")?Ne:{...Ne,className:xt}})),be.size>0&&Xt(Fe=>Fe.map(Ne=>{if(!be.has(Xf(Ne)))return Ne;const xt=l1(Ne.className,o1);return xt===String(Ne.className||"")?Ne:{...Ne,className:xt}}))},l7))}catch{kt(Y.nodes),Xt(Y.edges)}}else if(kt(Y.nodes),Xt(Y.edges),Ic.current=Y.viewport||null,Y.viewport){const J=()=>{var te;try{(te=Mi.current)==null||te.setViewport(Y.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else y(J=>J+1);vh(w.id,Y.flowSource),Rp(J=>J+1),xd(Y.nodes,Y.edges,{instances:Y.instances});try{Ml.current=Bj(Y.nodes,Y.edges,Y.instances,{description:Y.flowDescriptionText,viewport:Ic.current})}catch{Ml.current=""}Pa.current=!0}catch(Y){v(String(Y.message||Y))}},[Tt,xd,kt,Xt]),We=h.useCallback(async()=>{if(!(u!=null&&u.id))return;const w=u.source??"user",j=new URLSearchParams({flowId:u.id,flowSource:w});u.archived&&j.set("archived","1"),j.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const B=await fetch("/api/nodes?"+j.toString()),q=await B.json();if(!B.ok)throw new Error((q==null?void 0:q.error)||e("flow:nodePropsError.loadNodesFailed"));const Y=Array.isArray(q)?q:Array.isArray(q==null?void 0:q.nodes)?q.nodes:[];ae(Y)},[u,e,t.language]),Ct=h.useCallback(async()=>{ar(!0),gn("");try{const w=await fetch("/api/marketplace/nodes"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error((j==null?void 0:j.error)||"Failed to load marketplace nodes");mn(Array.isArray(j==null?void 0:j.nodes)?j.nodes:[])}catch(w){gn(String(w.message||w)),mn([])}finally{ar(!1)}},[]),Pr=h.useCallback(async()=>{He(!0),sn("");try{const w=await fetch("/api/marketplace/flow-snippets"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error((j==null?void 0:j.error)||"Failed to load flow snippets");qe(Array.isArray(j==null?void 0:j.snippets)?j.snippets:[])}catch(w){sn(String(w.message||w)),qe([])}finally{He(!1)}},[]);h.useEffect(()=>{u&&(Ct(),Pr())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Ct,Pr]);const Aa=h.useCallback(async w=>{if(!u||!w)return;const j=w.definitionId||`marketplace:${w.id}${w.version?`@${w.version}`:""}`;if(j){lr(j),gn("");try{const B=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,nodeSpec:j})}),q=await B.json().catch(()=>({}));if(!B.ok||(q==null?void 0:q.ok)===!1)throw new Error((q==null?void 0:q.error)||"Failed to install marketplace node");await We()}catch(B){gn(String(B.message||B))}finally{lr("")}}},[u,We]),$l=h.useCallback(async(w,j)=>{const B={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:j,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:u==null?void 0:u.id,flowSource:(u==null?void 0:u.source)||"user"},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),Y=await q.json();if(!q.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Publish failed");return await We(),Y},[We,u]),Se=h.useCallback(async()=>{var q;if(!u||ge.current)return;const w=u.id,j=u.source??"user",B=((q=Ea.current)==null?void 0:q.id)??null;ge.current=!0,me(!0);try{await $t({id:w,source:j,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),B&&kt(Y=>Y.map(J=>({...J,selected:J.id===B})))}finally{ge.current=!1,me(!1)}},[u,u==null?void 0:u.archived,$t,kt]);h.useEffect(()=>{if(xi.current||l.length===0)return;const w=new URLSearchParams(window.location.search),j=w.get("flowId");if(!j)return;const B=w.get("flowSource")??"user",q=w.get("flowArchived")==="1",Y=l.find(J=>J.id===j&&(J.source??"user")===B&&!!J.archived===q);Y&&(xi.current=!0,$t(Y))},[l,$t]);const lt=h.useRef(0);h.useEffect(()=>{if(!u)return;const w=u.id,j=u.source??"user",B=!!u.archived;lt.current=0;let q=!1;const Y=async()=>{var ne;if(q)return;const te=new URLSearchParams({flowId:w,flowSource:j,v:String(lt.current)});B&&te.set("archived","1");try{const ye=await fetch("/api/flow-editor-sync-poll?"+te.toString());if(!ye.ok||q)return;const be=await ye.json();if(q)return;if(be.changed){lt.current=be.version;const ze=((ne=Ea.current)==null?void 0:ne.id)??null;await $t({id:w,source:j,archived:B},{preserveComposer:!0,incrementalSync:!0}),await le({id:w,source:j,archived:B},{quiet:!0,force:!0}),ze&&kt(de=>de.map(Fe=>({...Fe,selected:Fe.id===ze})))}else lt.current=be.version}catch{}},J=window.setInterval(Y,2e3);return Y(),()=>{q=!0,window.clearInterval(J)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,$t,le,kt]);const ft=h.useMemo(()=>x?x.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":x===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[x]);h.useEffect(()=>{if(!x)return;x===e("flow:status.saved")||x.startsWith(e("flow:status.runInTerminal"));const w=x.startsWith(e("flow:status.runInTerminal"))?5200:2800,j=window.setTimeout(()=>N(""),w);return()=>clearTimeout(j)},[x,e]),h.useEffect(()=>{C("")},[u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{const w=()=>{window.__provideEditContent&&(Na(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",w),()=>window.removeEventListener("provide-expand",w)},[]),h.useEffect(()=>{var ne,ye,be,ze,de,Fe,Ne;if(!ce){ud(null);return}const w=nr.current[ce.id]||{},{inputs:j,outputs:B}=$T(ce),q=String(((ne=ce.data)==null?void 0:ne.definitionId)??ce.id??""),Y=((ye=ce.data)==null?void 0:ye.script)!=null?String(ce.data.script):void 0,J=w.script!=null?String(w.script):void 0,te=q==="tool_nodejs"||Y&&Y.trim()!==""||J&&J.trim()!==""?String(Y??J??""):"";ud({id:ce.id,newId:ce.id,label:String(((be=ce.data)==null?void 0:be.label)??ce.id),role:((ze=ce.data)==null?void 0:ze.role)??"普通",model:String(((de=ce.data)==null?void 0:de.model)??w.model??""),body:String(((Fe=ce.data)==null?void 0:Fe.body)??w.body??""),images:Ts(((Ne=ce.data)==null?void 0:Ne.images)??w.images),script:te,inputs:j,outputs:B})},[ce==null?void 0:ce.id,Tp]),h.useEffect(()=>{u&&(ce||(cd.current=null,zt(w=>w==="node"?null:w)))},[u,ce==null?void 0:ce.id]);const pt=h.useCallback(()=>{cd.current=null,zt(w=>w==="settings"||w==="history"?w:"node")},[]),Re=h.useCallback((w,j)=>{w.metaKey||w.ctrlKey||w.shiftKey||Ie!=="edit"&&Yr((j==null?void 0:j.id)??null)},[Ie]),It=h.useCallback((w,j)=>{Ie==="edit"&&(w.preventDefault(),kt(B=>B.map(q=>({...q,selected:q.id===j.id}))),Xt(B=>B.map(q=>({...q,selected:!1}))),pt())},[pt,Ie,Xt,kt]),tn=h.useCallback((w,j)=>{if(Ie!=="edit")return;const B=w.metaKey||w.ctrlKey||w.shiftKey;Xt(q=>q.map(Y=>Y.id===j.id?{...Y,selected:!Y.selected||!B}:B?Y:{...Y,selected:!1})),B||kt(q=>q.map(Y=>({...Y,selected:!1})))},[Ie,Xt,kt]),Jt=h.useCallback(w=>p1(w,Ys.current),[]),$n=h.useCallback(w=>{if(!p1(w,Ys.current)){N("端口类型不匹配,已取消连线");return}Oi(null),kt(j=>pg(j,w)),Xt(j=>{const B=j.filter(q=>!(q.target===w.target&&q.targetHandle===w.targetHandle));return qf({...w,markerEnd:{type:$s.ArrowClosed}},B)})},[Xt,kt]),Vn=h.useCallback((w,j)=>{Tc.current=g7(j,Ys.current),Oi(null)},[]),Dt=h.useCallback((w,j)=>{var Ne,xt,Sn,Nn;const B=Tc.current;if(Tc.current=null,!u||!B||j!=null&&j.toNode)return;const q=x7(Z,B);if(q.length===0){N(`没有匹配 ${B.slotType} 端口的节点`);return}const Y=((xt=(Ne=w==null?void 0:w.changedTouches)==null?void 0:Ne[0])==null?void 0:xt.clientX)??(w==null?void 0:w.clientX),J=((Nn=(Sn=w==null?void 0:w.changedTouches)==null?void 0:Sn[0])==null?void 0:Nn.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(Y)||!Number.isFinite(J))return;const te=Mi.current,ne=document.querySelector(".af-pipeline-flow .react-flow");if(!te||!ne)return;const ye=ne.getBoundingClientRect(),be=320,ze=Math.min(440,104+q.length*58),de=Math.max(12,Math.min(Y-ye.left,ye.width-be-12)),Fe=Math.max(12,Math.min(J-ye.top,ye.height-ze-12));Oi({left:de,top:Fe,flowPosition:te.screenToFlowPosition({x:Y,y:J}),draft:B,candidates:q,query:""})},[Z,u]),nn=h.useCallback(w=>{for(const j of w)delete nr.current[j.id]},[]),Zr=h.useCallback(w=>{Mi.current=w},[]),Ns=h.useCallback(w=>{kt(B=>B.map(q=>({...q,selected:q.id===w}))),Xt(B=>B.map(q=>({...q,selected:!1}))),pt();const j=()=>{var ye,be,ze;const B=Mi.current;if(!(B!=null&&B.getNode))return;const q=B.getNode(w);if(!q)return;const Y=(ye=B.getInternalNode)==null?void 0:ye.call(B,w),J=((be=Y==null?void 0:Y.measured)==null?void 0:be.width)??(Y==null?void 0:Y.width)??q.width??200,te=((ze=Y==null?void 0:Y.measured)==null?void 0:ze.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:ne}=B.getViewport();B.setCenter(q.position.x+J/2,q.position.y+te/2,{zoom:y1(ne),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(j))},[kt,Xt,pt]),Gs=h.useCallback(w=>{kt(B=>B.map(q=>({...q,selected:q.id===w}))),Xt(B=>B.map(q=>({...q,selected:!1})));const j=()=>{var be,ze,de;const B=Mi.current;if(!(B!=null&&B.getNode))return;const q=B.getNode(w);if(!q)return;const Y=(be=B.getInternalNode)==null?void 0:be.call(B,w),J=((ze=Y==null?void 0:Y.measured)==null?void 0:ze.width)??(Y==null?void 0:Y.width)??q.width??200,te=((de=Y==null?void 0:Y.measured)==null?void 0:de.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:ne}=B.getViewport(),ye=y1(ne);B.setCenter(q.position.x+J/2,q.position.y+te/2,{zoom:ye,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(j))},[kt,Xt]),Mr=h.useCallback((w,j)=>{const B=`node-${Date.now()}`;return s2(w,B,j,nr.current,Z)},[Z]),Dl=h.useCallback(w=>{if(!u||!w)return;let j={x:180,y:160};const B=Mi.current,q=document.querySelector(".af-pipeline-flow .react-flow");if(B&&q){const Y=q.getBoundingClientRect();j=B.screenToFlowPosition({x:Y.left+Y.width*.45,y:Y.top+Y.height*.38})}kt(Y=>[...Y,Mr(w,j)])},[u,kt,Mr]),Ia=h.useCallback(w=>{const j=Yp.current;if(!u||!j||!(w!=null&&w.def))return;const B=Mr(w.def,j.flowPosition),q=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:B.id,targetHandle:`input-${w.slotIndex}`}:{source:B.id,sourceHandle:`output-${w.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};kt(Y=>pg([...Y,B],q)),Xt(Y=>{const J=Y.filter(te=>!(te.target===q.target&&te.targetHandle===q.targetHandle));return qf({...q,markerEnd:{type:$s.ArrowClosed}},J)}),Oi(null)},[u,Mr,kt,Xt]),Ta=h.useCallback(w=>{w.preventDefault(),w.dataTransfer.dropEffect="move"},[]),bd=h.useCallback(w=>{var te;if(w.preventDefault(),!u)return;const j=Mi.current;if(!j)return;const B=j.screenToFlowPosition({x:w.clientX,y:w.clientY}),q=w.dataTransfer.getData("application/agentflow-snippet");if(q){const ne=et.find(ye=>`${ye.id}@${ye.version}`===q);ne&&((te=Ol.current)==null||te.call(Ol,ne,B));return}const Y=w.dataTransfer.getData("application/agentflow-node");if(!Y)return;const J=Z.find(ne=>ne.id===Y);J&&kt(ne=>[...ne,Mr(J,B)])},[u,Z,et,kt,Mr]),wi=h.useCallback(async(w,j)=>{if(!u)return;const B=Bj(w,j,nr.current,{description:b,viewport:Ic.current});if(B!==Ml.current){N(e("flow:status.saving"));try{const q=O7(u.source),Y=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:q,flowYaml:B,...u.archived?{flowArchived:!0}:{}})}),J=await Y.json();if(!Y.ok||!J.success)throw new Error(J.error||e("flow:status.saveFailed"));if(Ml.current=B,N(e("flow:status.saved")),bi(u.source)&&q==="workspace"){const te={id:u.id,source:"workspace",path:void 0};p(te),v1(te),vh(u.id,"workspace")}}catch(q){N(e("flow:status.saveFailed")+": "+(q.message||q))}}},[u,b]);h.useEffect(()=>{if(!u||!Pa.current||Ie!=="edit"||u.archived)return;const w=gd.current,j=setTimeout(()=>{w===gd.current&&Pa.current&&wi(Ys.current,Yo.current)},400);return()=>clearTimeout(j)},[Et,vn,b,Ie,u,wi]);const Xp=h.useCallback(async w=>{if(!u||u.archived)return;const j=u.source??"user";if(!(j!=="user"&&j!=="workspace")&&j!==w){H(!0),C("");try{const B=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:j,toSource:w})}),q=await B.json().catch(()=>({}));if(!B.ok)throw new Error(typeof q.error=="string"?q.error:e("flow:composer.requestFailed"));const Y=q.flowSource==="workspace"||q.flowSource==="user"?q.flowSource:w;let J={id:u.id,source:Y,archived:u.archived};try{const te=await fetch("/api/flows");if(te.ok){const ne=await te.json(),ye=Array.isArray(ne)?ne.find(be=>be.id===u.id&&(be.source??"user")===Y&&!!be.archived==!!u.archived):null;ye&&(J=ye)}}catch{}await $t(J,{preserveComposer:!0}),vh(u.id,Y)}catch(B){C(String(B.message||B))}finally{H(!1)}}},[u,$t]),ky=h.useCallback(async()=>{if(u){va(!0),_r(""),vl("");try{const w=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,schedule:ur})}),j=await w.json().catch(()=>({}));if(!w.ok||!j.success)throw new Error(j.error||"Failed to save schedule");ba({...Fd,...j.schedule||{}}),vl(e("flow:schedule.saved")),await le(u,{quiet:!0,force:!0})}catch(w){_r(String(w.message||w))}finally{va(!1)}}},[u,ur,le,e]),pR=h.useCallback(async()=>{u&&(await wi(Ys.current,Yo.current),!u.archived&&u.source!=="builtin"&&await ky())},[u,wi,ky]),Jp=h.useCallback(async()=>{if(!u||!M.trim())return;const w=M.trim();if(w===u.id){O("");return}$(!0),O("");try{const j=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",newFlowId:w})}),B=await j.json().catch(()=>({}));if(!j.ok)throw new Error(typeof B.error=="string"?B.error:e("flow:composer.requestFailed"));let q={id:B.flowId,source:B.flowSource??u.source,archived:u.archived};try{const Y=await fetch("/api/flows");if(Y.ok){const J=await Y.json(),te=Array.isArray(J)?J.find(ne=>ne.id===B.flowId&&(ne.source??"user")===(B.flowSource??u.source)):null;te&&(q=te)}}catch{}await $t(q,{preserveComposer:!0}),vh(B.flowId,B.flowSource??u.source)}catch(j){O(String(j.message||j))}finally{$(!1)}},[u,M,$t]),Q0=h.useCallback(w=>{navigator.clipboard.writeText(w).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(()=>{})},[]),Sy=h.useCallback(()=>{wi(Et,vn)},[wi,Et,vn]),Z0=h.useCallback(()=>{var j,B;if(!u)return;const w=x1((B=(j=Mi.current)==null?void 0:j.getViewport)==null?void 0:B.call(j));w&&(Ic.current=w,N("已固定 Pipeline 进入视角"),wi(Ys.current,Yo.current))},[wi,u]),hR=h.useCallback((w,j)=>{const B=j.trim()===""||j==="default"?void 0:j.trim(),q=Et.map(Y=>Y.id===w?{...Y,data:{...Y.data,model:B}}:Y);kt(q),wi(q,vn)},[Et,vn,kt,wi]),Qp=h.useCallback(()=>{var xt,Sn;if(!gt||!u||!ce)return!1;const w=ce.id,j=gt.newId.trim();if(Cl(""),!XT.test(j))return Cl(e("flow:nodePropsError.invalidInstanceId")),!1;if(Et.some(Nn=>Nn.id===j&&Nn.id!==w))return Cl(e("flow:nodePropsError.duplicateInstanceId")),!1;const B=gt.role.trim(),q=dl.includes(B)?B:"普通",Y=gt.model.trim(),J=Nn=>(Array.isArray(Nn)?Nn:[]).map(Wt=>({type:String((Wt==null?void 0:Wt.type)??"节点").trim()||"节点",name:String((Wt==null?void 0:Wt.name)??""),default:String((Wt==null?void 0:Wt.default)??""),required:!!(Wt!=null&&Wt.required),showOnNode:(Wt==null?void 0:Wt.showOnNode)!=null?Wt.showOnNode!==!1:!!(Wt!=null&&Wt.required)||String((Wt==null?void 0:Wt.type)??"节点").trim().toLowerCase()==="node"})),te=J(gt.inputs),ne=J(gt.outputs),ye=String(((xt=ce.data)==null?void 0:xt.definitionId)??j),be=ye.startsWith("provide_"),ze={...ce.data,label:gt.label.trim()||j,displayLabel:gt.label.trim()||j,role:q,model:Y===""||Y==="default"?void 0:Y,body:be?"":gt.body,images:be?[]:Ts(gt.images),inputs:te,outputs:be&&Array.isArray((Sn=ce.data)==null?void 0:Sn.outputs)?ce.data.outputs:ne},de=String(gt.script??"").trim();ye==="tool_nodejs"||de!==""?ze.script=String(gt.script??""):delete ze.script;let Fe,Ne=vn;if(j!==w){const Nn={...nr.current},Wt={...Nn[w]||{}};delete Nn[w],Nn[j]=Wt,nr.current=Nn,Fe=Et.map(St=>St.id!==w?St:{...St,id:j,selected:!0,data:ze}),Ne=vn.map((St,Qt)=>({...St,source:St.source===w?j:St.source,target:St.target===w?j:St.target,id:`e-${St.source===w?j:St.source}-${St.target===w?j:St.target}-${Qt}`}))}else Fe=Et.map(Nn=>Nn.id===w?{...Nn,data:ze}:Nn);return kt(Fe),Xt(Ne),as(j),wi(Fe,Ne),!0},[gt,u,ce,Et,vn,kt,Xt,as,wi]),Ny=h.useCallback(()=>{var Sn,Nn;if(!gt||!u||!ce)return!1;const w=ce.id,j=gt.role.trim(),B=dl.includes(j)?j:"普通",q=gt.model.trim(),Y=Wt=>(Array.isArray(Wt)?Wt:[]).map(St=>({type:String((St==null?void 0:St.type)??"节点").trim()||"节点",name:String((St==null?void 0:St.name)??""),default:String((St==null?void 0:St.default)??""),required:!!(St!=null&&St.required),showOnNode:(St==null?void 0:St.showOnNode)!=null?St.showOnNode!==!1:!!(St!=null&&St.required)||String((St==null?void 0:St.type)??"节点").trim().toLowerCase()==="node"})),J=Y(gt.inputs),te=Y(gt.outputs),ne=String(((Sn=ce.data)==null?void 0:Sn.definitionId)??w),ye=ne.startsWith("provide_"),be=gt.label.trim()||w,ze=q===""||q==="default"?void 0:q,de={...ce.data,label:be,displayLabel:be,role:B,model:ze,body:ye?"":gt.body,images:ye?[]:Ts(gt.images),inputs:J,outputs:ye&&Array.isArray((Nn=ce.data)==null?void 0:Nn.outputs)?ce.data.outputs:te},Fe=String(gt.script??"").trim();ne==="tool_nodejs"||Fe!==""?de.script=String(gt.script??""):delete de.script;const Ne=ce.data||{};return(Ne.label!==de.label||Ne.role!==de.role||Ne.model!==de.model||Ne.body!==de.body||JSON.stringify(Ts(Ne.images))!==JSON.stringify(de.images)||(Ne.script??void 0)!==(de.script??void 0)||JSON.stringify(Ne.inputs||[])!==JSON.stringify(J)||JSON.stringify(Ne.outputs||[])!==JSON.stringify(te))&&(kt(Wt=>Wt.map(St=>St.id===w?{...St,data:de}:St)),as(w)),!0},[gt,u,ce,kt,as]),ek=h.useRef(Ny);h.useEffect(()=>{ek.current=Ny},[Ny]),h.useEffect(()=>{if(!gt||!u||!Pa.current||Ie!=="edit")return;const w=setTimeout(()=>{ek.current()},400);return()=>clearTimeout(w)},[gt,u,Ie]);const mR=h.useCallback(()=>{if(!(!gt||!ce)){if(gt.newId.trim()===ce.id){Cl("");return}Qp()}},[gt,ce,Qp]);h.useEffect(()=>{const w=j=>{var te,ne,ye;if(Ie!=="edit")return;const B=BT(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){if(nt==="node"&&ce&&gt){j.preventDefault(),j.stopPropagation(),Qp()||Sy();return}if(B)return;j.preventDefault(),j.stopPropagation(),Sy();return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),Ip(be=>!be);return}if(On)return;if(Bn){if(j.key==="Escape"){j.preventDefault(),io(!1);return}if(mg(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),io(!1);return}(j.key==="v"||j.key==="V"||j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&j.preventDefault();return}if(B)return;const q=j.key.toLowerCase(),Y=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&q==="z",J=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&q==="z"||q==="y");if(Y||J){j.preventDefault(),j.stopPropagation();const be=Y?wd():S();N(be?Y?"Undo canvas change":"Redo canvas change":Y?"Nothing to undo":"Nothing to redo");return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="c"){const be=RT(Ys.current,Yo.current,nr.current);be&&(j.preventDefault(),j.stopPropagation(),yd.current=be,N(`Copied ${be.nodes.length} node${be.nodes.length>1?"s":""}`));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="v"){const be=LT(yd.current,Ys.current,Yo.current,nr.current);be&&(j.preventDefault(),j.stopPropagation(),nr.current=be.instances,kt(be.nodes),Xt(be.edges),N(`Pasted ${be.pastedNodeIds.length} node${be.pastedNodeIds.length>1?"s":""}`));return}if((j.key==="a"||j.key==="A")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),j.stopPropagation(),(te=Ve.current)==null||te.focus(),(ye=(ne=Ve.current)==null?void 0:ne.select)==null||ye.call(ne);return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),kt(be=>be.map(ze=>({...ze,selected:!0}))),Xt(be=>be.map(ze=>({...ze,selected:!1})));return}if(mg(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),io(be=>!be);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),ad("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),ad("pan");return}if((j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Z0();return}};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[Sy,Z0,Bn,On,nt,ce,gt,Qp,Ie,wd,S]),h.useEffect(()=>{if(Ie!=="running"||ut==null)return;let w=Math.floor((Date.now()-ut)/1e3);const j=setInterval(()=>{const B=Date.now()-ut,q=Math.floor(B/1e3);q!==w&&(w=q,Er(B))},500);return()=>clearInterval(j)},[Ie,ut]),h.useEffect(()=>{const w=Do.current;!w||!w.parentElement||rd.current&&(Fo.current=!0,w.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Fo.current=!1}))},[mr]),h.useEffect(()=>{const w=Do.current;if(!w)return;const j=w.parentElement;if(!j)return;const B=()=>{if(Fo.current)return;const q=j.scrollHeight-j.scrollTop-j.clientHeight;rd.current=q<40};return j.addEventListener("scroll",B,{passive:!0}),()=>j.removeEventListener("scroll",B)},[tt,Ie]),h.useEffect(()=>{if(Ie==="edit"||!tt)return;rd.current=!0;const w=Do.current;w&&(Fo.current=!0,w.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Fo.current=!1}))},[Ie,tt]),h.useEffect(()=>{mr.length>gm+w1&&ht(w=>w.length>gm+w1?w.slice(-gm):w)},[mr]);const gR=h.useCallback(w=>{if(w.button!==0)return;w.preventDefault();const j=w.currentTarget;Ii.current={active:!0,pointerId:w.pointerId,startY:w.clientY,startH:vr},j.setPointerCapture(w.pointerId)},[vr]),yR=h.useCallback(w=>{const j=Ii.current;if(!j.active||w.pointerId!==j.pointerId)return;const B=j.startY-w.clientY;$o(ym(j.startH+B))},[]),Zp=h.useCallback(()=>{$o(w=>{const j=ym(w);try{localStorage.setItem(o2,String(j))}catch{}return j})},[]),tk=h.useCallback(w=>{const j=Ii.current;if(!(!j.active||w.pointerId!==j.pointerId)){j.active=!1;try{w.currentTarget.releasePointerCapture(w.pointerId)}catch{}Zp()}},[Zp]),xR=h.useCallback(()=>{const w=Ii.current;w.active&&(w.active=!1,Zp())},[Zp]);h.useEffect(()=>{function w(){$o(j=>ym(j))}return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]);const fo=h.useCallback(async(w={})=>{if(!u)return;const j=w.runUuid!=null&&String(w.runUuid).trim()?String(w.runUuid).trim():null,B=w.cliInputsOverride??K.current,q=!!w.prepareOnly;if(cn(q?"ready":"running"),ht(q?[]:[{ts:new Date().toISOString(),type:"info",text:j?e("flow:run.connectingApiResume",{uuid:j}):e("flow:run.connectingApi")}]),Gn(new Set),Cr({}),gr(!q),zt(null),j||er(null),q)return;if(!j){const J=Date.now();Ut(J),Er(0)}const Y=new AbortController;ci.current=Y;try{const J=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",...j?{uuid:j}:{},cliInputs:B}),signal:Y.signal});if(!J.ok){const de=await J.json().catch(()=>({error:e("flow:composer.requestFailed")}));ht(Fe=>[...Fe,{ts:new Date().toISOString(),type:"error",text:de.error||e("flow:composer.requestFailed")}]),cn("error");return}if(ht(de=>[...de,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){ht(de=>[...de,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),cn("error");return}const te=J.body.getReader(),ne=new TextDecoder;let ye="";const be=de=>{const Fe=de.ts||new Date().toISOString();if(de.type==="event")if(de.event==="node-start")Gn(Ne=>new Set(Ne).add(de.instanceId)),Cr(Ne=>({...Ne,[de.instanceId]:{status:"running",startMs:Date.now()}})),ht(Ne=>[...Ne,{ts:Fe,type:"node-start",text:de.label?e("flow:run.nodeStartWithLabel",{instanceId:de.instanceId,label:de.label}):e("flow:run.nodeStart",{instanceId:de.instanceId})}]);else if(de.event==="node-done"){Gn(xt=>{const Sn=new Set(xt);return Sn.delete(de.instanceId),Sn});const Ne=de.elapsed??null;Cr(xt=>({...xt,[de.instanceId]:{status:"success",elapsed:Ne}})),ht(xt=>[...xt,{ts:Fe,type:"node-done",text:Ne?e("flow:run.nodeDoneWithElapsed",{instanceId:de.instanceId,elapsed:Ne}):e("flow:run.nodeDone",{instanceId:de.instanceId})}])}else if(de.event==="node-failed")Gn(Ne=>{const xt=new Set(Ne);return xt.delete(de.instanceId),xt}),Cr(Ne=>({...Ne,[de.instanceId]:{status:"failed",elapsed:de.elapsed??null}})),ht(Ne=>[...Ne,{ts:Fe,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:de.instanceId})}]);else if(de.event==="apply-start"){if(de.uuid&&er(String(de.uuid)),typeof de.runStartTime=="number"&&de.runStartTime>0)Ut(de.runStartTime),Er(Math.max(0,Date.now()-de.runStartTime));else if(typeof de.totalExecutedMs=="number"&&de.totalExecutedMs>0){const Ne=Date.now()-de.totalExecutedMs;Ut(Ne),Er(de.totalExecutedMs)}ht(Ne=>[...Ne,{ts:Fe,type:"info",text:e("flow:run.pipelineStart",{uuid:de.uuid||"?"})}])}else de.event==="apply-done"?ht(Ne=>[...Ne,{ts:Fe,type:"info",text:de.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:de.totalElapsed}):e("flow:run.pipelineDone")}]):de.event==="apply-paused"?ht(Ne=>[...Ne,{ts:Fe,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(de.pendingNodes||[]).join(", ")})}]):ht(Ne=>[...Ne,{ts:Fe,type:"event",text:`[${de.event}] ${JSON.stringify(de)}`}]);else de.type==="user-check-content"?(Sl({instanceId:de.instanceId,execId:de.execId??1,inputPath:de.inputPath,outputPath:de.outputPath,content:de.content||""}),Ri(de.content||""),zo(!1),Ho(""),jl(!1),ht(Ne=>[...Ne,{ts:Fe,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:de.instanceId})}])):de.type==="user-ask-prompt"?(Lr({instanceId:de.instanceId,execId:de.execId??1,question:de.question||"",options:Array.isArray(de.options)?de.options:[]}),fi(!1),ht(Ne=>[...Ne,{ts:Fe,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:de.instanceId,defaultValue:`等待用户选择 (${de.instanceId})`})}])):de.type==="tool-print-content"?(Bo({instanceId:de.instanceId,execId:de.execId??1,content:de.content||"",createdAt:Date.now()}),od(!1)):de.type==="log"?ht(Ne=>[...Ne,{ts:Fe,type:"log",text:de.text!=null?String(de.text):""}]):de.type==="error"?ht(Ne=>[...Ne,{ts:Fe,type:"error",text:de.message||e("flow:run.unknownError")}]):de.type==="done"?ht(Ne=>[...Ne,{ts:Fe,type:"done",text:e("flow:run.executionEnd",{exitCode:de.exitCode??"?"})}]):ht(Ne=>[...Ne,{ts:Fe,type:"log",text:JSON.stringify(de)}])},ze=de=>{if(de.trim())try{be(JSON.parse(de))}catch{ht(Fe=>[...Fe,{ts:new Date().toISOString(),type:"log",text:de}])}};for(;;){const{done:de,value:Fe}=await te.read();ye+=ne.decode(Fe??new Uint8Array,{stream:!de});const Ne=ye.split(`
133
133
  `);ye=Ne.pop()??"";for(const xt of Ne)ze(xt);if(de)break}ye.trim()&&ze(ye),cn("done")}catch(J){J.name==="AbortError"?(ht(te=>[...te,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),cn("stopped")):(ht(te=>[...te,{ts:new Date().toISOString(),type:"error",text:J.message||e("flow:run.unknownError")}]),cn("error"))}finally{ci.current=null,Gn(new Set)}},[u]),[wR,jy]=h.useState(!1),bR=h.useCallback(()=>{jy(!0)},[]),vR=h.useCallback(async()=>{if(jy(!1),ci.current&&(ci.current.abort(),ci.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}cn("stopped"),Gn(new Set)},[u]),Fl=h.useCallback(()=>{cn("edit"),Gn(new Set),Cr({}),Yr(null),er(null)},[]),[kR,eh]=h.useState(!1),SR=h.useCallback(async()=>{if(eh(!1),ci.current&&(ci.current.abort(),ci.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}Fl()},[u,Fl]),NR=h.useCallback(()=>{eh(!1),n("/projects")},[n]),jR=h.useCallback(w=>{const j=w.runId!=null&&String(w.runId).trim()?String(w.runId).trim():null,B=w.flowId!=null&&String(w.flowId).trim()?String(w.flowId).trim():(u==null?void 0:u.id)!=null?String(u.id):null;er(j);const q=w.status||"unknown";let Y="stopped";q==="success"?Y="done":q==="failed"?Y="error":q==="running"?Y="running":Y="stopped",cn(Y);const J=typeof w.at=="number"?w.at:null;if(Y==="running"&&J!=null?(Ut(J),Er(Math.max(0,Date.now()-J))):J!=null&&typeof w.endedAt=="number"&&w.endedAt>J?(Ut(null),Er(w.endedAt-J)):(Ut(null),Er(Math.max(0,w.durationMs??0))),ht([]),Gn(new Set),Cr({}),Yr(null),zt(null),gr(!1),j&&B){const te=new URLSearchParams({flowId:B,runId:j});fetch(`/api/run-node-statuses?${te}`).then(ne=>ne.json()).then(ne=>{const ye=ne.statuses&&typeof ne.statuses=="object"?ne.statuses:{},be={};for(const[ze,de]of Object.entries(ye))de&&typeof de=="object"&&typeof de.status=="string"&&(be[ze]={status:de.status,...de.elapsed!=null&&String(de.elapsed).trim()!==""?{elapsed:String(de.elapsed)}:{}});Cr(be)}).catch(()=>{})}},[u==null?void 0:u.id]);h.useEffect(()=>{if(!(u!=null&&u.id)||Ie!=="edit")return;let w=!1;return(async()=>{try{const j=await fetch("/api/pipeline-recent-runs"),B=await j.json();if(w||!j.ok)return;const Y=(Array.isArray(B.runs)?B.runs:[]).find(ne=>ne.flowId===u.id&&ne.status==="running");if(!Y||w)return;const J=Y.runId||null;er(J),cn("running"),gr(!0),Ut(Y.at||Date.now()),Oe.current=0;const te=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${J},已恢复运行视图`}];if(J){const ne=new URLSearchParams({flowId:u.id,runId:J}),be=await(await fetch(`/api/run-node-statuses?${ne}`)).json();if(w)return;const ze=be.statuses&&typeof be.statuses=="object"?be.statuses:{},de={},Fe=new Set;for(const[Ne,xt]of Object.entries(ze))xt&&typeof xt=="object"&&typeof xt.status=="string"&&(de[Ne]={status:xt.status,...xt.elapsed!=null&&String(xt.elapsed).trim()!==""?{elapsed:String(xt.elapsed)}:{}},xt.status==="running"&&Fe.add(Ne));Cr(de),Gn(Fe);try{const Ne=new URLSearchParams({flowId:u.id,runId:J,sinceBytes:"0",tailBytes:"262144"}),xt=await fetch(`/api/run-log?${Ne}`);if(xt.ok){const Sn=await xt.json();if(!w){Oe.current=Number(Sn.bytes||0);const Nn=b1(typeof Sn.text=="string"?Sn.text:"");ht([...Nn,...te]);return}}}catch{}}ht(te)}catch{}})(),()=>{w=!0}},[u==null?void 0:u.id]),h.useEffect(()=>{if(Ie==="edit"||!(u!=null&&u.id)||!xn)return;let w=!1,j=null;const B=async()=>{try{const q=new URLSearchParams({flowId:u.id,runId:xn}),Y=await fetch(`/api/run-node-statuses?${q}`);if(!Y.ok)return;const J=await Y.json();if(w)return;const te=J.statuses&&typeof J.statuses=="object"?J.statuses:{},ne={},ye=new Set;for(const[be,ze]of Object.entries(te))ze&&typeof ze=="object"&&typeof ze.status=="string"&&(ne[be]={status:ze.status,...ze.elapsed!=null&&String(ze.elapsed).trim()!==""?{elapsed:String(ze.elapsed)}:{}},ze.status==="running"&&ye.add(be));Cr(be=>R7(be,ne)?be:ne),Gn(be=>L7(be,ye)?be:ye);try{const be=new URLSearchParams({flowId:u.id,runId:xn,sinceBytes:String(Oe.current||0),tailBytes:String(P7)}),ze=await fetch(`/api/run-log?${be}`);if(ze.ok){const de=await ze.json();if(w)return;const Fe=Number(de.bytes||0),Ne=typeof de.text=="string"?de.text:"";if(Ne){const xt=b1(Ne);xt.length>0&&ht(Sn=>[...Sn,...xt])}Oe.current=Fe}}catch{}try{const be=await fetch("/api/pipeline-recent-runs");if(!be.ok)return;const ze=await be.json();if(w)return;const Fe=(Array.isArray(ze.runs)?ze.runs:[]).find(Ne=>Ne.flowId===u.id&&Ne.runId===xn);if(Fe&&Fe.status){const Ne=Fe.status;Ne==="running"?cn(xt=>xt==="running"?xt:"running"):Ne==="success"?cn("done"):Ne==="failed"?cn("error"):(Ne==="stopped"||Ne==="interrupted")&&cn("stopped")}}catch{}}catch{}};return B(),j=window.setInterval(B,2500),()=>{w=!0,j&&window.clearInterval(j)}},[Ie,u==null?void 0:u.id,xn]),h.useEffect(()=>{if(nt!=="history"||!u)return;let w=!1;return(async()=>{cr(!0),Ht("");try{const j=await fetch("/api/pipeline-recent-runs"),B=await j.json();if(!j.ok)throw new Error(B.error||"HTTP "+j.status);w||Te(Array.isArray(B.runs)?B.runs:[])}catch(j){w||(Ht(String(j.message||j)),Te([]))}finally{w||cr(!1)}})(),()=>{w=!0}},[nt,u]),h.useEffect(()=>{if(!u){ot({files:[]});return}let w=!1;return(async()=>{Ai(!0);try{const j=new URLSearchParams({flowId:u.id,flowSource:u.source||"user",archived:u.archived?"1":"0"}),B=await fetch(`/api/pipeline-files?${j}`),q=await B.json();if(!B.ok)throw new Error(q.error||"HTTP "+B.status);w||ot({files:Array.isArray(q.files)?q.files:[],path:q.path,error:q.error})}catch(j){w||ot({files:[],error:j.message||String(j)})}finally{w||Ai(!1)}})(),()=>{w=!0}},[u]);const vd=h.useMemo(()=>u?oe.filter(w=>w&&w.flowId===u.id).sort((w,j)=>j.at-w.at):[],[oe,u]),ds=h.useMemo(()=>{let w=0,j=0,B=0,q=0,Y=0;for(const J of vd){const te=J.status||"unknown";te==="success"?w+=1:te==="failed"?j+=1:te==="running"?B+=1:te==="stopped"?q+=1:te==="interrupted"&&(Y+=1)}return{success:w,failed:j,running:B,stopped:q,interrupted:Y}},[vd]),kd=h.useMemo(()=>u?h1(ks,Ss):null,[u,ks,Ss]),$i=h.useMemo(()=>{if(!kd||!u)return[];const w=kd.query.toLowerCase(),j=Y=>w?Y.some(J=>J&&String(J).toLowerCase().includes(w)):!0,B=Et.map(Y=>{var be,ze;const J=Y.id,te=String(((be=Y.data)==null?void 0:be.label)??J),ne=(ze=Y.data)!=null&&ze.definitionId?String(Y.data.definitionId):"",ye=[te!==J?te:"",ne&&ne!==J?ne:""].filter(Boolean);return{id:J,label:te,defId:ne,subs:ye}}).filter(({id:Y,label:J,defId:te})=>j([Y,J,te])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,18).map(({id:Y,label:J,defId:te})=>{const ne=[J!==Y?J:null,te||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:Y,title:Y,subtitle:ne}}),q=Z.filter(Y=>Y&&Y.id&&j([Y.id,Y.label,Y.description])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,22).map(Y=>({kind:"definition",id:Y.id,title:Y.id,subtitle:Y.label&&Y.label!==Y.id?String(Y.label):String(Y.type||"")}));return[...B,...q]},[kd,Et,Z,u]),Sd=h.useMemo(()=>{const w=$i.filter(B=>B.kind==="instance"),j=$i.filter(B=>B.kind==="definition");return{instances:w,definitions:j}},[$i]);h.useEffect(()=>{hi(w=>{const j=Math.max(0,$i.length-1);return Math.min(Math.max(0,w),j)})},[$i]);const nk=h.useMemo(()=>b7(ks),[ks]),Or=h.useMemo(()=>Et.filter(w=>w.selected),[Et]),Cy=h.useMemo(()=>new Set(Or.map(w=>w.id)),[Or]),th=h.useMemo(()=>vn.filter(w=>Cy.has(w.source)&&Cy.has(w.target)),[vn,Cy]),rk=h.useMemo(()=>{const w=xe.trim().toLowerCase();return w?et.filter(j=>[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].filter(Boolean).some(B=>String(B).toLowerCase().includes(w))):et},[et,xe]),sk=h.useCallback((w,j)=>{const B=String(w||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",q=Date.now().toString(36);let Y=`${B}-${q}`,J=2;for(;j.has(Y);)Y=`${B}-${q}-${J}`,J+=1;return j.add(Y),Y},[]),ik=h.useCallback((w,j)=>{var Qt,fs;if(!u||!w)return;const B=w.snippet&&typeof w.snippet=="object"?w.snippet:{},q=B.instances&&typeof B.instances=="object"?B.instances:{},Y=Object.keys(q);if(Y.length===0)return;const J=new Set(Ys.current.map(Je=>Je.id)),te={};for(const Je of Y)te[Je]=sk(Je,J);const ne=(Qt=B.ui)!=null&&Qt.nodePositions&&typeof B.ui.nodePositions=="object"?B.ui.nodePositions:{},ye=(fs=B.ui)!=null&&fs.nodeSizes&&typeof B.ui.nodeSizes=="object"?B.ui.nodeSizes:{},be=Y.map(Je=>{const jn=ne[Je];return{id:Je,x:typeof(jn==null?void 0:jn.x)=="number"?jn.x:0,y:typeof(jn==null?void 0:jn.y)=="number"?jn.y:0}}),ze=Math.min(...be.map(Je=>Je.x)),de=Math.min(...be.map(Je=>Je.y));let Fe=j||{x:180,y:160};const Ne=Mi.current,xt=document.querySelector(".af-pipeline-flow .react-flow");if(!j&&Ne&&xt){const Je=xt.getBoundingClientRect();Fe=Ne.screenToFlowPosition({x:Je.left+Je.width*.48,y:Je.top+Je.height*.32})}const Sn={};for(const Je of Y)Sn[te[Je]]={...q[Je]||{}};nr.current={...nr.current,...Sn};const Nn=Y.map(Je=>{const jn=q[Je]||{},po=be.find(jd=>jd.id===Je)||{x:0,y:0},Di=ye[Je]&&typeof ye[Je].width=="number"&&typeof ye[Je].height=="number"?{width:ye[Je].width,height:ye[Je].height}:null,Hl={id:te[Je],type:"flowNode",selected:!0,position:{x:Fe.x+(po.x-ze),y:Fe.y+(po.y-de)},...Di?{width:Di.width,height:Di.height}:{},data:{label:jn.label||te[Je],definitionId:jn.definitionId||Je,role:jn.role||"normal",body:jn.body||"",script:jn.script||"",...Di?{displaySize:Di}:{}}};return tp(Hl,nr.current,Z,{},u.id)}),Wt=new Set(Y),St=(Array.isArray(B.edges)?B.edges:[]).filter(Je=>Wt.has(Je==null?void 0:Je.source)&&Wt.has(Je==null?void 0:Je.target)).map((Je,jn)=>({id:`e-${te[Je.source]}-${te[Je.target]}-${Date.now()}-${jn}`,source:te[Je.source],target:te[Je.target],sourceHandle:Je.sourceHandle??void 0,targetHandle:Je.targetHandle??void 0,markerEnd:{type:$s.ArrowClosed}}));kt(Je=>[...Je.map(jn=>({...jn,selected:!1})),...Nn]),Xt(Je=>[...Je.map(jn=>({...jn,selected:!1})),...St]),N(`已添加流程片段:${w.displayName||w.id}`)},[sk,Z,u,Xt,kt]);Ol.current=ik;const CR=h.useCallback(()=>{var B,q;if(Or.length<2){sn("请先在画布上选择至少两个节点。"),je("flows");return}const w=Or[0],j=Or.length===2?`${((B=w.data)==null?void 0:B.label)||w.id} 片段`:`${((q=w.data)==null?void 0:q.label)||w.id} 等 ${Or.length} 个节点`;En({name:j,id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),De(""),an(!0),je("flows")},[Or]),ER=h.useCallback(async()=>{var J,te;if(!u||Or.length<2)return;const w=Yt.name.trim();if(!w){De("请填写片段名称。");return}const j=kp(Or,nr.current),B={},q={};for(const ne of Or){B[ne.id]={x:((J=ne.position)==null?void 0:J.x)||0,y:((te=ne.position)==null?void 0:te.y)||0};const ye=$7(ne);ye&&(q[ne.id]=ye)}const Y=th.map(ne=>({source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle??null,targetHandle:ne.targetHandle??null}));ue(!0),De("");try{const ne=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Yt.id,name:w,displayName:w,version:"1.0.0",description:Yt.description,snippet:{instances:j,edges:Y,ui:{nodePositions:B,nodeSizes:q}}})}),ye=await ne.json().catch(()=>({}));if(!ne.ok||(ye==null?void 0:ye.ok)===!1)throw new Error((ye==null?void 0:ye.error)||"Publish failed");an(!1),N(`流程片段已发布:${ye.id||w}`),Hs(`流程片段已发布:${ye.id||w}`),await Pr(),je("flows")}catch(ne){De(String(ne.message||ne))}finally{ue(!1)}},[u,Or,th,Yt,Pr,Hs]),nh=h.useMemo(()=>{const w=[],j=new Set;for(const Y of Or)j.add(Y.id),w.push({node:Y,kind:"canvas"});const B=new Map(Et.map(Y=>[Y.id,Y])),q=new Map(Z.map(Y=>[Y.id,Y]));for(const Y of nk){if(j.has(Y))continue;const J=B.get(Y);if(J){j.add(Y),w.push({node:J,kind:"mention"});continue}const te=q.get(Y);te&&(j.add(Y),w.push({definition:te,kind:"definition"}))}return w},[Or,nk,Et,Z]),js=h.useMemo(()=>{const w=Array.isArray(vt==null?void 0:vt.cursor)?vt.cursor:[],j=Array.isArray(vt==null?void 0:vt.opencode)?vt.opencode:[],B=Array.isArray(vt==null?void 0:vt.claudeCode)?vt.claudeCode:[],q=j.map(be=>`opencode:${Zo(be)}`),Y=B.map(be=>`claude-code:${Zo(be)}`),J=new Set([...w,...j,...B].map(Zo).concat(q).concat(Y)),te=(mi||"").trim(),ne=zh(mi,w,j,B),ye=ne&&!J.has(ne)&&!J.has(te)?te:"";return{cursorList:w,opencodeList:j,claudeCodeList:B,currentNotInLists:ye}},[vt,mi]),Ey=h.useMemo(()=>new Set(dr),[dr]),_y=dr.length,rh=h.useMemo(()=>{const w=new Map(gi.map(J=>[J.key,J])),j=new Set,B=new Set,q=_l.map(J=>{const te=cl(J,gi).map(ne=>w.get(ne)).filter(Boolean);for(const ne of te)j.add(ne.key),B.add(String(ne.name||ne.id||ne.key||"").trim());return{...J,skills:te}}).filter(J=>J.skills.length>0),Y=gi.filter(J=>{const te=String(J.name||J.id||J.key||"").trim();return!j.has(J.key)&&!B.has(te)});return{groups:q,ungrouped:Y}},[_l,gi]),Rc=h.useCallback(()=>{const w=Gt.current;if(!w)return;const j=w.getBoundingClientRect(),B=Math.min(400,Math.max(300,window.innerWidth-24)),q=Math.min(Math.max(12,j.right-B),window.innerWidth-B-12),Y=Math.max(140,j.top-22),J=Math.min(360,Y);pd({position:"fixed",left:`${q}px`,top:`${Math.max(12,j.top-J-10)}px`,width:`${B}px`,maxHeight:`${J}px`})},[]);h.useEffect(()=>{const w=Array.isArray(vt==null?void 0:vt.cursor)?vt.cursor:[],j=Array.isArray(vt==null?void 0:vt.opencode)?vt.opencode:[],B=Array.isArray(vt==null?void 0:vt.claudeCode)?vt.claudeCode:[];El(q=>{const Y=zh(q,w,j,B);return Y===q?q:Y})},[vt.cursor,vt.opencode,vt.claudeCode]),h.useEffect(()=>{if(!Li)return;Rc();const w=B=>{var Y,J;const q=B.target;(Y=Gt.current)!=null&&Y.contains(q)||(J=Nc.current)!=null&&J.contains(q)||mt(!1)},j=B=>{B.key==="Escape"&&mt(!1)};return window.addEventListener("resize",Rc),window.addEventListener("scroll",Rc,!0),document.addEventListener("pointerdown",w),document.addEventListener("keydown",j),()=>{window.removeEventListener("resize",Rc),window.removeEventListener("scroll",Rc,!0),document.removeEventListener("pointerdown",w),document.removeEventListener("keydown",j)}},[Li,Rc]);const zl=h.useCallback(async(w,j={})=>{var St;if(!u||Ac.current)return;const B=j.phaseContextSnapshot,q=(typeof w=="string"?w:ks).trim();if(!q)return;const Y=md.current;Ac.current=!0,Up(!0),Ks(e("flow:composer.connecting")),zt(Qt=>Qt!=="composer"?"composer":Qt);const J=[...co];if(Y.length>0&&J.push({type:"assistant",segments:[...Y]}),Kp([...J,{type:"user",text:q}]),J.filter(Qt=>Qt.type==="user").length===0){const Qt=q.replace(/\s+/g," ").slice(0,30)+(q.length>30?"…":"");Jr(fs=>fs.map(Je=>Je.id===tr?{...Je,label:Qt}:Je))}const te=J.map(Qt=>Qt.type==="user"?{role:"user",text:Qt.text}:{role:"assistant",text:(Qt.segments||[]).filter(Je=>Je.kind==="assistant"||Je.kind==="result").map(Je=>Je.text).join(`
134
134
  `)}).filter(Qt=>Qt.text),ne=B??jt;Pe(""),qs([]),yi([]),qp(!1);const ye=new AbortController;Tl.current=ye,Pc.current=tr;let be=null;const ze=Array.isArray(vt==null?void 0:vt.cursor)?vt.cursor:[],de=Array.isArray(vt==null?void 0:vt.opencode)?vt.opencode:[],Fe=Array.isArray(vt==null?void 0:vt.claudeCode)?vt.claudeCode:[],Ne=zh(mi,ze,de,Fe),xt=nh.filter(Qt=>Qt.kind!=="definition"&&Qt.node).map(Qt=>Qt.node.id),Sn=u;let Nn=!1,Wt=!1;try{be=setTimeout(()=>ye.abort(),12e4);const Qt={prompt:q,model:Ne,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:xt,thread:te,selectedSkills:dr};ne&&ne.nextPhase&&!ne.isLastPhase&&(Qt.phaseContext={phaseIndex:ne.nextPhase.index,phases:ne.phases,userPromptOriginal:ne.userPromptOriginal||q}),Sc&&(Qt.phaseRole=Sc);const fs=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qt),signal:ye.signal});if(be&&(clearTimeout(be),be=null),!fs.ok){let Di=fs.statusText||e("flow:composer.requestFailed");try{const Hl=await fs.json();Hl&&Hl.error&&(Di=String(Hl.error))}catch{}Ks(Di),qs([{kind:"error",text:Di}]);return}const Je=(St=fs.body)==null?void 0:St.getReader();if(!Je){Ks(e("flow:composer.cannotReadStream"));return}const jn=new TextDecoder;let po="";for(;;){const{done:Di,value:Hl}=await Je.read();if(Di)break;for(po+=jn.decode(Hl,{stream:!0});;){const jd=po.indexOf(`
135
135
  `);if(jd<0)break;const fk=po.slice(0,jd).trim();if(po=po.slice(jd+1),!fk)continue;let Qe;try{Qe=JSON.parse(fk)}catch{continue}if(Qe.type==="status"&&typeof Qe.line=="string"&&Ks(Qe.line),Qe.type==="natural"&&typeof Qe.text=="string"&&Qe.text){const In=typeof Qe.kind=="string"&&Qe.kind?Qe.kind:"assistant";qs(Cn=>[...Cn,{kind:In,text:Qe.text}])}if(Qe.type==="error"&&Qe.message){Wt=!0;const In=Qe.code?` [${Qe.code}]`:"",Cn=String(Qe.message)+In;Ks(Cn),qs(Cs=>[...Cs,{kind:"error",text:Cn}])}if(Qe.type==="plan"&&Array.isArray(Qe.steps)){yi(Qe.steps.map(Cn=>({...Cn,status:"pending"})));const In=Qe.steps.map((Cn,Cs)=>`${Cs+1}. ${Cn.description||Cn.type}`).join(`
@@ -142,7 +142,7 @@ ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function j7(e,t){return
142
142
  `);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(i){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
143
143
  `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function mo(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function cq(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>mo(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>mo(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>mo(i[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:mo(s)||`Column ${i+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,i)=>({key:String(i),label:mo(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>mo(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>mo(s[a])):s&&typeof s=="object"?r.map(i=>mo(s[i.key])):r.map((i,a)=>a===0?mo(s):""))}}function uq(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=cq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
144
144
  `).split(`
145
- `).filter(l=>l.trim());if(s.length>=2&&sa(s[0]).length>1&&a2(s[1])){const l=sa(s[0]),c=l2(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>sa(d)),error:""}}const i=r.includes(" ")?" ":",",a=lq(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function O0({content:e}){const t=h.useMemo(()=>uq(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:mo(n[i])},`${s.key}-${i}`))},r))})]})})}function $0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>tq(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),B7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const dq="af:workspace-graph:v2",Vc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],fq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),pq={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},hq={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},mq={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},gq=new Set(["png","jpg","jpeg","gif","webp","svg"]),yq=320,d2=180,f2=960,Db=96,p2=900,Fb="display-ref:",xq="0.1.64";function wq(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function xo(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function gg(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return gq.has(n)}function yg(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=xo(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function bq(e,t){const n=String(e||"").trim();if(!n)return"";const r=xo(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function vq(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function kq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function Sq(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function Nq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!Sq(e)}function jq(e){const t=String(e||"").trim();if(!t)return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function C1(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function Cq(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,i=Number.isFinite(r)&&Number.isFinite(s)?`(+${C1(r)} / 总 ${C1(s)})`:"";return`${t+1}. ${n}${i}`}function E1(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function h2(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function m2(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function D0(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function Qd(e){const t=String(D0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function _1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function xg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Zd(e){return xg(e)}function zb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Fx(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function P1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function A1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function I1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=zu(s.get(n),e.sourceHandle||"output-0","source"),a=zu(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Fu(i,a))}function Eq(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=zu(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:zT(a)}:null}function _q(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Fu(t.slot,a):Fu(a,t.slot)))continue;const c=Qd(n);return{def:n,order:r,category:c,categoryRank:Vc.indexOf(c),slot:a,slotIndex:i,displayLabel:Zd(n),description:zb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function ef(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function Pq(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function Aq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Bh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:Aq(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function g2(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function Iq(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[g2(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function zx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=x2(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const y=r[m]||{},b=y.definitionId||m,k=t.find(H=>H.id===b),g=D0(k)||b,v=t.find(H=>H.id===g)||k,x=y.marketplaceRef||m2(k),N=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},_=!!Kn(g),C=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,T=bu(C,{display:_});return{id:m,type:Sp,position:N,...T?{width:T.width,height:T.height}:{},data:{label:y.label||xg(k)||xg(v)||m,definitionId:g,...x?{marketplaceRef:x}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:h2(g,v||k),role:y.role||"normal",model:y.model||void 0,body:y.body||"",script:y.script||"",...T?{nodeSize:T}:{},..._&&T?{displaySize:T}:{}}}}).map(m=>tp(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,y)=>({id:m.id||`we-${m.source}-${m.target}-${y}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:$s.ArrowClosed}}));return{nodes:d,edges:DT(f,d),instances:r}}function T1(e){return`${Fb}${e}`}function Hx(e){const t=String(e||"");return t.startsWith(Fb)?t.slice(Fb.length):t}function y2(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Hb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Kn((p=u==null?void 0:u.data)==null?void 0:p.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const u of r){const p=String(u||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,p)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const p=bu(d[u],{display:!0});p&&(c[u]=p)});const f=y2(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function Tq(e,t=[]){return Hb(e,t)}function Rq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Lq(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function R1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function bu(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:R1(n,d2,f2)||yq,height:R1(r,Db,p2)||Db}}function Uc(e){var s,i,a,l,c,d,f,u,p,m,y;const t=!!Kn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:u.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return bu({width:n,height:r},{display:t})}function Wh(e,t,n){var l,c;const r=x2(kp(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const f=Uc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function x2(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Kn(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function Kn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function sc(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Kn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Hu(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function Mq(e){let t=String(e||"").replace(/\r\n/g,`
145
+ `).filter(l=>l.trim());if(s.length>=2&&sa(s[0]).length>1&&a2(s[1])){const l=sa(s[0]),c=l2(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>sa(d)),error:""}}const i=r.includes(" ")?" ":",",a=lq(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function O0({content:e}){const t=h.useMemo(()=>uq(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:mo(n[i])},`${s.key}-${i}`))},r))})]})})}function $0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>tq(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),B7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const dq="af:workspace-graph:v2",Vc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],fq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),pq={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},hq={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},mq={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},gq=new Set(["png","jpg","jpeg","gif","webp","svg"]),yq=320,d2=180,f2=960,Db=96,p2=900,Fb="display-ref:",xq="0.1.66";function wq(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function xo(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function gg(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return gq.has(n)}function yg(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=xo(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function bq(e,t){const n=String(e||"").trim();if(!n)return"";const r=xo(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function vq(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function kq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function Sq(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function Nq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!Sq(e)}function jq(e){const t=String(e||"").trim();if(!t)return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function C1(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function Cq(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,i=Number.isFinite(r)&&Number.isFinite(s)?`(+${C1(r)} / 总 ${C1(s)})`:"";return`${t+1}. ${n}${i}`}function E1(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function h2(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function m2(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function D0(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function Qd(e){const t=String(D0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function _1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function xg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Zd(e){return xg(e)}function zb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Fx(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function P1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function A1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function I1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=zu(s.get(n),e.sourceHandle||"output-0","source"),a=zu(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Fu(i,a))}function Eq(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=zu(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:zT(a)}:null}function _q(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Fu(t.slot,a):Fu(a,t.slot)))continue;const c=Qd(n);return{def:n,order:r,category:c,categoryRank:Vc.indexOf(c),slot:a,slotIndex:i,displayLabel:Zd(n),description:zb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function ef(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function Pq(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function Aq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Bh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:Aq(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function g2(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function Iq(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[g2(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function zx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=x2(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const y=r[m]||{},b=y.definitionId||m,k=t.find(H=>H.id===b),g=D0(k)||b,v=t.find(H=>H.id===g)||k,x=y.marketplaceRef||m2(k),N=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},_=!!Kn(g),C=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,T=bu(C,{display:_});return{id:m,type:Sp,position:N,...T?{width:T.width,height:T.height}:{},data:{label:y.label||xg(k)||xg(v)||m,definitionId:g,...x?{marketplaceRef:x}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:h2(g,v||k),role:y.role||"normal",model:y.model||void 0,body:y.body||"",script:y.script||"",...T?{nodeSize:T}:{},..._&&T?{displaySize:T}:{}}}}).map(m=>tp(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,y)=>({id:m.id||`we-${m.source}-${m.target}-${y}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:$s.ArrowClosed}}));return{nodes:d,edges:DT(f,d),instances:r}}function T1(e){return`${Fb}${e}`}function Hx(e){const t=String(e||"");return t.startsWith(Fb)?t.slice(Fb.length):t}function y2(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Hb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Kn((p=u==null?void 0:u.data)==null?void 0:p.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const u of r){const p=String(u||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,p)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const p=bu(d[u],{display:!0});p&&(c[u]=p)});const f=y2(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function Tq(e,t=[]){return Hb(e,t)}function Rq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Lq(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function R1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function bu(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:R1(n,d2,f2)||yq,height:R1(r,Db,p2)||Db}}function Uc(e){var s,i,a,l,c,d,f,u,p,m,y;const t=!!Kn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:u.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return bu({width:n,height:r},{display:t})}function Wh(e,t,n){var l,c;const r=x2(kp(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const f=Uc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function x2(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Kn(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function Kn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function sc(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Kn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Hu(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function Mq(e){let t=String(e||"").replace(/\r\n/g,`
146
146
  `).trim();return t.includes(`
147
147
  `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
148
148
  $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams: