webapp.flowDiagram-b222e15a.d5bac7fc.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of langgraph4j-studio Show documentation
Show all versions of langgraph4j-studio Show documentation
an **embed playground webapp** to run a Langgraph4j workflow in visual way
function e(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0})}var t=globalThis.parcelRequire0031,r=t.register;r("4FlE0",function(r,n){e(r.exports,"r",()=>O);var i=t("hV1gR"),l=t("c0ySZ"),a=t("hl1Sc"),d=t("4jcZX"),o=t("4LkSm"),s=t("fmBVZ"),h=t("2YFJl");let g={},c={},f={},u=()=>{c={},f={},g={}},w=(e,t)=>((0,d.l).trace("In isDescendant",t," ",e," = ",c[t].includes(e)),!!c[t].includes(e)),p=(e,t)=>((0,d.l).info("Descendants of ",t," is ",c[t]),(0,d.l).info("Edge is ",e),e.v!==t&&e.w!==t&&(c[t]?c[t].includes(e.v)||w(e.v,t)||w(e.w,t)||c[t].includes(e.w):((0,d.l).debug("Tilt, ",t,",not in descendants"),!1))),v=(e,t,r,n)=>{(0,d.l).warn("Copying children of ",e,"root",n,"data",t.node(e),n);let i=t.children(e)||[];e!==n&&i.push(e),(0,d.l).warn("Copying (nodes) clusterId",e,"nodes",i),i.forEach(i=>{if(t.children(i).length>0)v(i,t,r,n);else{let l=t.node(i);(0,d.l).info("cp ",i," to ",n," with parent ",e),r.setNode(i,l),n!==t.parent(i)&&((0,d.l).warn("Setting parent",i,t.parent(i)),r.setParent(i,t.parent(i))),e!==n&&i!==e?((0,d.l).debug("Setting parent",i,e),r.setParent(i,e)):((0,d.l).info("In copy ",e,"root",n,"data",t.node(e),n),(0,d.l).debug("Not Setting parent for node=",i,"cluster!==rootId",e!==n,"node!==clusterId",i!==e));let a=t.edges(i);(0,d.l).debug("Copying Edges",a),a.forEach(i=>{(0,d.l).info("Edge",i);let l=t.edge(i.v,i.w,i.name);(0,d.l).info("Edge data",l,n);try{p(i,n)?((0,d.l).info("Copying as ",i.v,i.w,l,i.name),r.setEdge(i.v,i.w,l,i.name),(0,d.l).info("newGraph edges ",r.edges(),r.edge(r.edges()[0]))):(0,d.l).info("Skipping copy of edge ",i.v,"-->",i.w," rootId: ",n," clusterId:",e)}catch(e){(0,d.l).error(e)}})}(0,d.l).debug("Removing node",i),t.removeNode(i)})},y=(e,t)=>{let r=t.children(e),n=[...r];for(let i of r)f[i]=e,n=[...n,...y(i,t)];return n},x=(e,t)=>{(0,d.l).trace("Searching",e);let r=t.children(e);if((0,d.l).trace("Searching children of id ",e,r),r.length<1)return(0,d.l).trace("This is a valid node",e),e;for(let n of r){let r=x(n,t);if(r)return(0,d.l).trace("Found replacement for",e," => ",r),r}},m=e=>g[e]&&g[e].externalConnections&&g[e]?g[e].id:e,b=(e,t)=>{if(!e||t>10){(0,d.l).debug("Opting out, no graph ");return}for(let t of((0,d.l).debug("Opting in, graph "),e.nodes().forEach(function(t){e.children(t).length>0&&((0,d.l).warn("Cluster identified",t," Replacement id in edges: ",x(t,e)),c[t]=y(t,e),g[t]={id:x(t,e),clusterData:e.node(t)})}),e.nodes().forEach(function(t){let r=e.children(t),n=e.edges();r.length>0?((0,d.l).debug("Cluster identified",t,c),n.forEach(e=>{e.v!==t&&e.w!==t&&w(e.v,t)^w(e.w,t)&&((0,d.l).warn("Edge: ",e," leaves cluster ",t),(0,d.l).warn("Descendants of XXX ",t,": ",c[t]),g[t].externalConnections=!0)})):(0,d.l).debug("Not a cluster ",t,c)}),Object.keys(g))){let r=g[t].id,n=e.parent(r);n!==t&&g[n]&&!g[n].externalConnections&&(g[t].id=n)}e.edges().forEach(function(t){let r=e.edge(t);(0,d.l).warn("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(t)),(0,d.l).warn("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(e.edge(t)));let n=t.v,i=t.w;if((0,d.l).warn("Fix XXX",g,"ids:",t.v,t.w,"Translating: ",g[t.v]," --- ",g[t.w]),g[t.v]&&g[t.w]&&g[t.v]===g[t.w]){(0,d.l).warn("Fixing and trixing link to self - removing XXX",t.v,t.w,t.name),(0,d.l).warn("Fixing and trixing - removing XXX",t.v,t.w,t.name),n=m(t.v),i=m(t.w),e.removeEdge(t.v,t.w,t.name);let l=t.w+"---"+t.v;e.setNode(l,{domId:l,id:l,labelStyle:"",labelText:r.label,padding:0,shape:"labelRect",style:""});let a=structuredClone(r),o=structuredClone(r);a.label="",a.arrowTypeEnd="none",o.label="",a.fromCluster=t.v,o.toCluster=t.v,e.setEdge(n,l,a,t.name+"-cyclic-special"),e.setEdge(l,i,o,t.name+"-cyclic-special")}else(g[t.v]||g[t.w])&&((0,d.l).warn("Fixing and trixing - removing XXX",t.v,t.w,t.name),n=m(t.v),i=m(t.w),e.removeEdge(t.v,t.w,t.name),n!==t.v&&(g[e.parent(n)].externalConnections=!0,r.fromCluster=t.v),i!==t.w&&(g[e.parent(i)].externalConnections=!0,r.toCluster=t.w),(0,d.l).warn("Fix Replacing with XXX",n,i,t.name),e.setEdge(n,i,r,t.name))}),(0,d.l).warn("Adjusted Graph",l.write(e)),E(e,0),(0,d.l).trace(g)},E=(e,t)=>{if((0,d.l).warn("extractor - ",t,l.write(e),e.children("D")),t>10){(0,d.l).error("Bailing out");return}let r=e.nodes(),n=!1;for(let t of r){let r=e.children(t);n=n||r.length>0}if(!n){(0,d.l).debug("Done, no node has children",e.nodes());return}for(let n of((0,d.l).debug("Nodes = ",r,t),r))if((0,d.l).debug("Extracting node",n,g,g[n]&&!g[n].externalConnections,!e.parent(n),e.node(n),e.children("D")," Depth ",t),g[n]){if(!g[n].externalConnections&&e.children(n)&&e.children(n).length>0){(0,d.l).warn("Cluster without external connections, without a parent and with children",n,t);let r="TB"===e.graph().rankdir?"LR":"TB";g[n]&&g[n].clusterData&&g[n].clusterData.dir&&(r=g[n].clusterData.dir,(0,d.l).warn("Fixing dir",g[n].clusterData.dir,r));let i=new o.Graph({multigraph:!0,compound:!0}).setGraph({rankdir:r,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});(0,d.l).warn("Old graph before copy",l.write(e)),v(n,e,i,n),e.setNode(n,{clusterNode:!0,id:n,clusterData:g[n].clusterData,labelText:g[n].labelText,graph:i}),(0,d.l).warn("New graph after copy node: (",n,")",l.write(i)),(0,d.l).debug("Old graph after copy",l.write(e))}else(0,d.l).warn("Cluster ** ",n," **not meeting the criteria !externalConnections:",!g[n].externalConnections," no parent: ",!e.parent(n)," children ",e.children(n)&&e.children(n).length>0,e.children("D"),t),(0,d.l).debug(g)}else(0,d.l).debug("Not a cluster",n,t);for(let n of(r=e.nodes(),(0,d.l).warn("New list of nodes",r),r)){let r=e.node(n);(0,d.l).warn(" Now next level",n,r),r.clusterNode&&E(r.graph,t+1)}},N=(e,t)=>{if(0===t.length)return[];let r=Object.assign(t);return t.forEach(t=>{let n=e.children(t),i=N(e,n);r=[...r,...i]}),r},X=e=>N(e,e.children()),C={rect:(e,t)=>{(0,d.l).info("Creating subgraph rect for ",t.id,t);let r=(0,d.c)(),n=e.insert("g").attr("class","cluster"+(t.class?" "+t.class:"")).attr("id",t.id),i=n.insert("rect",":first-child"),l=(0,d.m)(r.flowchart.htmlLabels),o=n.insert("g").attr("class","cluster-label"),g="markdown"===t.labelType?(0,s.a)(o,t.labelText,{style:t.labelStyle,useHtmlLabels:l}):o.node().appendChild((0,a.c)(t.labelText,t.labelStyle,void 0,!0)),c=g.getBBox();if((0,d.m)(r.flowchart.htmlLabels)){let e=g.children[0],t=(0,h.select)(g);c=e.getBoundingClientRect(),t.attr("width",c.width),t.attr("height",c.height)}let f=0*t.padding,u=t.width<=c.width+f?c.width+f:t.width;t.width<=c.width+f?t.diff=(c.width-t.width)/2-t.padding/2:t.diff=-t.padding/2,(0,d.l).trace("Data ",t,JSON.stringify(t)),i.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("x",t.x-u/2).attr("y",t.y-t.height/2-f/2).attr("width",u).attr("height",t.height+f);let{subGraphTitleTopMargin:w}=(0,a.g)(r);l?o.attr("transform",`translate(${t.x-c.width/2}, ${t.y-t.height/2+w})`):o.attr("transform",`translate(${t.x}, ${t.y-t.height/2+w})`);let p=i.node().getBBox();return t.width=p.width,t.height=p.height,t.intersect=function(e){return(0,a.i)(t,e)},n},roundedWithTitle:(e,t)=>{let r=(0,d.c)(),n=e.insert("g").attr("class",t.classes).attr("id",t.id),i=n.insert("rect",":first-child"),l=n.insert("g").attr("class","cluster-label"),o=n.append("rect"),s=l.node().appendChild((0,a.c)(t.labelText,t.labelStyle,void 0,!0)),g=s.getBBox();if((0,d.m)(r.flowchart.htmlLabels)){let e=s.children[0],t=(0,h.select)(s);g=e.getBoundingClientRect(),t.attr("width",g.width),t.attr("height",g.height)}g=s.getBBox();let c=0*t.padding,f=c/2,u=t.width<=g.width+t.padding?g.width+t.padding:t.width;t.width<=g.width+t.padding?t.diff=(g.width+0*t.padding-t.width)/2:t.diff=-t.padding/2,i.attr("class","outer").attr("x",t.x-u/2-f).attr("y",t.y-t.height/2-f).attr("width",u+c).attr("height",t.height+c),o.attr("class","inner").attr("x",t.x-u/2-f).attr("y",t.y-t.height/2-f+g.height-1).attr("width",u+c).attr("height",t.height+c-g.height-3);let{subGraphTitleTopMargin:w}=(0,a.g)(r);l.attr("transform",`translate(${t.x-g.width/2}, ${t.y-t.height/2-t.padding/3+((0,d.m)(r.flowchart.htmlLabels)?5:3)+w})`);let p=i.node().getBBox();return t.height=p.height,t.intersect=function(e){return(0,a.i)(t,e)},n},noteGroup:(e,t)=>{let r=e.insert("g").attr("class","note-cluster").attr("id",t.id),n=r.insert("rect",":first-child"),i=0*t.padding,l=i/2;n.attr("rx",t.rx).attr("ry",t.ry).attr("x",t.x-t.width/2-l).attr("y",t.y-t.height/2-l).attr("width",t.width+i).attr("height",t.height+i).attr("fill","none");let d=n.node().getBBox();return t.width=d.width,t.height=d.height,t.intersect=function(e){return(0,a.i)(t,e)},r},divider:(e,t)=>{let r=e.insert("g").attr("class",t.classes).attr("id",t.id),n=r.insert("rect",":first-child"),i=0*t.padding;n.attr("class","divider").attr("x",t.x-t.width/2-i/2).attr("y",t.y-t.height/2).attr("width",t.width+i).attr("height",t.height+i);let l=n.node().getBBox();return t.width=l.width,t.height=l.height,t.diff=-t.padding/2,t.intersect=function(e){return(0,a.i)(t,e)},r}},S={},T=(e,t)=>{(0,d.l).trace("Inserting cluster");let r=t.shape||"rect";S[t.id]=C[r](e,t)},B=()=>{S={}},D=async(e,t,r,n,o,s)=>{(0,d.l).info("Graph in recursive render: XXX",l.write(t),o);let h=t.graph().rankdir;(0,d.l).trace("Dir in recursive render - dir:",h);let c=e.insert("g").attr("class","root");t.nodes()?(0,d.l).info("Recursive render XXX",t.nodes()):(0,d.l).info("No nodes found for",t),t.edges().length>0&&(0,d.l).trace("Recursive edges",t.edge(t.edges()[0]));let f=c.insert("g").attr("class","clusters"),u=c.insert("g").attr("class","edgePaths"),w=c.insert("g").attr("class","edgeLabels"),p=c.insert("g").attr("class","nodes");await Promise.all(t.nodes().map(async function(e){let i=t.node(e);if(void 0!==o){let r=JSON.parse(JSON.stringify(o.clusterData));(0,d.l).info("Setting data for cluster XXX (",e,") ",r,o),t.setNode(o.id,r),t.parent(e)||((0,d.l).trace("Setting parent",e,o.id),t.setParent(e,o.id,r))}if((0,d.l).info("(Insert) Node XXX"+e+": "+JSON.stringify(t.node(e))),i&&i.clusterNode){(0,d.l).info("Cluster identified",e,i.width,t.node(e));let l=await D(p,i.graph,r,n,t.node(e),s),o=l.elem;(0,a.u)(i,o),i.diff=l.diff||0,(0,d.l).info("Node bounds (abc123)",e,i,i.width,i.x,i.y),(0,a.s)(o,i),(0,d.l).warn("Recursive render complete ",o,i)}else t.children(e).length>0?((0,d.l).info("Cluster - the non recursive path XXX",e,i.id,i,t),(0,d.l).info(x(i.id,t)),g[i.id]={id:x(i.id,t),node:i}):((0,d.l).info("Node - the non recursive path",e,i.id,i),await (0,a.e)(p,t.node(e),h))})),t.edges().forEach(function(e){let r=t.edge(e.v,e.w,e.name);(0,d.l).info("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(e)),(0,d.l).info("Edge "+e.v+" -> "+e.w+": ",e," ",JSON.stringify(t.edge(e))),(0,d.l).info("Fix",g,"ids:",e.v,e.w,"Translating: ",g[e.v],g[e.w]),(0,a.f)(w,r)}),t.edges().forEach(function(e){(0,d.l).info("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(e))}),(0,d.l).info("#############################################"),(0,d.l).info("### Layout ###"),(0,d.l).info("#############################################"),(0,d.l).info(t),(0,i.layout)(t),(0,d.l).info("Graph after layout:",l.write(t));let v=0,{subGraphTitleTotalMargin:y}=(0,a.g)(s);return X(t).forEach(function(e){let r=t.node(e);(0,d.l).info("Position "+e+": "+JSON.stringify(t.node(e))),(0,d.l).info("Position "+e+": ("+r.x,","+r.y,") width: ",r.width," height: ",r.height),r&&r.clusterNode?(r.y+=y,(0,a.p)(r)):t.children(e).length>0?(r.height+=y,T(f,r),g[r.id].node=r):(r.y+=y/2,(0,a.p)(r))}),t.edges().forEach(function(e){let i=t.edge(e);(0,d.l).info("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(i),i),i.points.forEach(e=>e.y+=y/2);let l=(0,a.h)(u,e,i,g,r,t,n);(0,a.j)(i,l)}),t.nodes().forEach(function(e){let r=t.node(e);(0,d.l).info(e,r.type,r.diff),"group"===r.type&&(v=r.diff)}),{elem:c,diff:v}},O=async(e,t,r,n,i)=>{(0,a.a)(e,r,n,i),(0,a.b)(),(0,a.d)(),B(),u(),(0,d.l).warn("Graph at first:",JSON.stringify(l.write(t))),b(t),(0,d.l).warn("Graph after:",JSON.stringify(l.write(t)));let o=(0,d.c)();await D(e,t,n,i,void 0,o)}}),r("c0ySZ",function(r,n){e(r.exports,"write",()=>d);var i=t("hNIl0");t("fpekr");var l=t("1G4S6"),a=t("3kePu");function d(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:a.default(e.nodes(),function(t){var r=e.node(t),n=e.parent(t),i={v:t};return l.default(r)||(i.value=r),l.default(n)||(i.parent=n),i}),edges:a.default(e.edges(),function(t){var r=e.edge(t),n={v:t.v,w:t.w};return l.default(t.name)||(n.name=t.name),l.default(r)||(n.value=r),n})};return l.default(e.graph())||(t.value=i.default(e.graph())),t}t("2rLgF")});
//# sourceMappingURL=flowDiagram-b222e15a.d5bac7fc.js.map