import{N as j,r as l,e,aH as F,B as r,L as T,T as h,aJ as d,A as B,M as E,P as M,n as R,Q as D,e2 as O,ea as _,Y as L}from"./index-_6SmYgWK.js";import{C as W,I as $,a as G,b as H,c as J,B as z}from"./style-Djw-NCXs.js";/* empty css              */import{N as b,u as q,b as Q,R as U}from"./DocStoreInputHandler-CaPW_OoW.js";import{b as V,A as Y,S as Z}from"./StickyNote-BfttINhy.js";import{L as K}from"./llamaindex-B_JSDULd.js";import{M as X}from"./MarketplaceCanvasHeader-rXny5-dD.js";import"./ExpandMore-DfVpxsz-.js";import"./AssistantDialog-CjH6GuIO.js";import"./v4-CtRu48qb.js";import"./string-BbYD24iH.js";const ee=F(E)(({theme:t})=>({background:t.palette.card.main,color:t.darkTextPrimary,border:"solid 1px",borderColor:t.palette.primary[200]+75,width:"300px",height:"auto",padding:"10px",boxShadow:"0 2px 14px 0 rgb(32 40 45 / 8%)","&:hover":{borderColor:t.palette.primary.main}})),y=({data:t})=>{const o=j(),[p,c]=l.useState(!1),[i,g]=l.useState({}),x=()=>{const s={data:t,inputParams:t.inputParams.filter(n=>n.additionalParams),disabled:!0,confirmButtonName:"Save",cancelButtonName:"Cancel"};g(s),c(!0)};return e.jsxs(e.Fragment,{children:[e.jsx(ee,{content:!1,sx:{padding:0,borderColor:t.selected?o.palette.primary.main:o.palette.text.secondary},border:!1,children:e.jsxs(r,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"},children:[e.jsx(r,{style:{width:50,marginRight:10,padding:5},children:e.jsx("div",{style:{...o.typography.commonAvatar,...o.typography.largeAvatar,borderRadius:"50%",backgroundColor:"white",cursor:"grab"},children:e.jsx("img",{style:{width:"100%",height:"100%",padding:5,objectFit:"contain"},src:`${T}/api/v1/node-icon/${t.name}`,alt:"Notification"})})}),e.jsx(r,{children:e.jsx(h,{sx:{fontSize:"1rem",fontWeight:500},children:t.label})}),e.jsx("div",{style:{flexGrow:1}}),t.tags&&t.tags.includes("LlamaIndex")&&e.jsx(e.Fragment,{children:e.jsx("div",{style:{borderRadius:"50%",padding:15},children:e.jsx("img",{style:{width:"25px",height:"25px",borderRadius:"50%",objectFit:"contain"},src:K,alt:"LlamaIndex"})})})]}),(t.inputAnchors.length>0||t.inputParams.length>0)&&e.jsxs(e.Fragment,{children:[e.jsx(d,{}),e.jsx(r,{sx:{background:o.palette.asyncSelect.main,p:1},children:e.jsx(h,{sx:{fontWeight:500,textAlign:"center"},children:"Inputs"})}),e.jsx(d,{})]}),t.inputAnchors.map((s,n)=>e.jsx(b,{disabled:!0,inputAnchor:s,data:t},n)),t.inputParams.filter(s=>s.display!==!1).map((s,n)=>e.jsx(b,{disabled:!0,inputParam:s,data:t},n)),t.inputParams.find(s=>s.additionalParams)&&e.jsx("div",{style:{textAlign:"center",marginTop:t.inputParams.filter(s=>s.additionalParams).length===t.inputParams.length+t.inputAnchors.length?20:0},children:e.jsx(B,{sx:{borderRadius:25,width:"90%",mb:2},variant:"outlined",onClick:x,children:"Additional Parameters"})}),e.jsx(d,{}),e.jsx(r,{sx:{background:o.palette.asyncSelect.main,p:1},children:e.jsx(h,{sx:{fontWeight:500,textAlign:"center"},children:"Output"})}),e.jsx(d,{}),t.outputAnchors.map((s,n)=>e.jsx(V,{disabled:!0,outputAnchor:s,data:t},n))]})}),e.jsx(Y,{show:p,dialogProps:i,onCancel:()=>c(!1)})]})};y.propTypes={data:M.object};const te={customNode:y,stickyNote:Z},se={buttonedge:""},me=()=>{const t=j(),o=R(),p=D(a=>a.customization),{state:c}=O(),{flowData:i,name:g}=c,[x,s,n]=q(),[w,v,C]=Q(),[m,N]=l.useState(!1),[u,k]=l.useState(!0),S=l.useRef(null);l.useEffect(()=>{if(i){const a=JSON.parse(i);s(a.nodes||[]),v(a.edges||[])}},[i]);const A=a=>{const P=((a==null?void 0:a.nodes)||[]).some(f=>f.data.category==="Multi Agents"||f.data.category==="Sequential Agents"),I=JSON.stringify(a);o(`/${P?"agentcanvas":"canvas"}`,{state:{templateFlowData:I}})};return e.jsx(e.Fragment,{children:e.jsxs(r,{children:[e.jsx(_,{enableColorOnDark:!0,position:"fixed",color:"inherit",elevation:1,sx:{bgcolor:t.palette.background.default},children:e.jsx(L,{children:e.jsx(X,{flowName:g,flowData:JSON.parse(i),onChatflowCopy:a=>A(a)})})}),e.jsx(r,{sx:{pt:"70px",height:"100vh",width:"100%"},children:e.jsx("div",{className:"reactflow-parent-wrapper",children:e.jsx("div",{className:"reactflow-wrapper",ref:S,children:e.jsxs(U,{nodes:x,edges:w,onNodesChange:n,onEdgesChange:C,nodesDraggable:!1,nodeTypes:te,edgeTypes:se,fitView:!0,minZoom:.1,snapGrid:[25,25],snapToGrid:m,children:[e.jsxs(W,{className:p.isDarkMode?"dark-mode-controls":"",style:{display:"flex",flexDirection:"row",left:"50%",transform:"translate(-50%, -50%)"},children:[e.jsx("button",{className:"react-flow__controls-button react-flow__controls-interactive",onClick:()=>{N(!m)},title:"toggle snapping","aria-label":"toggle snapping",children:m?e.jsx($,{}):e.jsx(G,{})}),e.jsx("button",{className:"react-flow__controls-button react-flow__controls-interactive",onClick:()=>{k(!u)},title:"toggle background","aria-label":"toggle background",children:u?e.jsx(H,{}):e.jsx(J,{})})]}),u&&e.jsx(z,{color:"#aaa",gap:16})]})})})})]})})};export{me as default};
