import{N as O,n as _,Q as A,e2 as B,r as a,cL as M,e,B as i,ea as P,Y as R}from"./index-_6SmYgWK.js";import{C as T,I as J,a as z,b as G,c as L,B as V}from"./style-Djw-NCXs.js";/* empty css              */import{A as $,I as H,S as Q,a as W,E as Y}from"./EditNodeDialog-DcOiZAxi.js";import{M as Z}from"./MarketplaceCanvasHeader-rXny5-dD.js";import{u as q,b as K,R as U}from"./DocStoreInputHandler-CaPW_OoW.js";import"./NodeInfoDialog-BSQc04od.js";import"./Table-DcZ35doG.js";import"./config-DpuVAZLd.js";import"./ExpandMore-DfVpxsz-.js";import"./AssistantDialog-CjH6GuIO.js";import"./v4-CtRu48qb.js";import"./string-BbYD24iH.js";const X={agentFlow:W,stickyNote:Q,iteration:H},ee={agentFlow:$},ue=()=>{const c=O(),d=_(),p=A(t=>t.customization),{state:g}=B(),{flowData:s,name:f}=g,[u,m,x]=q(),[w,N,h]=K(),[b,l]=a.useState(!1),[j,k]=a.useState({}),[n,C]=a.useState(!1),[r,E]=a.useState(!0),S=a.useRef(null),{setReactFlowInstance:v}=a.useContext(M);a.useEffect(()=>{if(s){const t=JSON.parse(s);m(t.nodes||[]),N(t.edges||[])}},[s]);const D=t=>{const o=JSON.stringify(t);d("/v2/agentcanvas",{state:{templateFlowData:o}})},F=a.useCallback((t,o)=>{if(!(!o||!o.data)&&o.data.name!=="stickyNoteAgentflow"){const I={data:o.data,inputParams:o.data.inputParams.filter(y=>!y.hidden),disabled:!0};k(I),l(!0)}});return e.jsx(e.Fragment,{children:e.jsxs(i,{children:[e.jsx(P,{enableColorOnDark:!0,position:"fixed",color:"inherit",elevation:1,sx:{bgcolor:c.palette.background.default},children:e.jsx(R,{children:e.jsx(Z,{flowName:f,flowData:JSON.parse(s),onChatflowCopy:t=>D(t)})})}),e.jsx(i,{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:u,edges:w,onNodesChange:x,onEdgesChange:h,onNodeDoubleClick:F,onInit:v,nodeTypes:X,edgeTypes:ee,fitView:!0,minZoom:.1,snapGrid:[25,25],snapToGrid:n,children:[e.jsxs(T,{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:()=>{C(!n)},title:"toggle snapping","aria-label":"toggle snapping",children:n?e.jsx(J,{}):e.jsx(z,{})}),e.jsx("button",{className:"react-flow__controls-button react-flow__controls-interactive",onClick:()=>{E(!r)},title:"toggle background","aria-label":"toggle background",children:r?e.jsx(G,{}):e.jsx(L,{})})]}),r&&e.jsx(V,{color:"#aaa",gap:16}),e.jsx(Y,{show:b,dialogProps:j,onCancel:()=>l(!1)})]})})})})]})})};export{ue as default};
