mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 08:45:40 +08:00
2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
import{_ as u,l as i}from"./mermaid.core.TSSz6aZW.js";import{i as m,G as y}from"./graph.BvS0Xx32.js";import{b as _,m as X}from"./map.DsahiwlY.js";var j=4;function p(e){return _(e,j)}function C(e){var r={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:F(e),edges:M(e)};return m(e.graph())||(r.value=p(e.graph())),r}function F(e){return X(e.nodes(),function(r){var n=e.node(r),s=e.parent(r),t={v:r};return m(n)||(t.value=n),m(s)||(t.parent=s),t})}function M(e){return X(e.edges(),function(r){var n=e.edge(r),s={v:r.v,w:r.w};return m(r.name)||(s.name=r.name),m(n)||(s.value=n),s})}var c=new Map,w=new Map,A=new Map,J=u(()=>{w.clear(),A.clear(),c.clear()},"clear"),v=u((e,r)=>{const n=w.get(r)||[];return i.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),R=u((e,r)=>{const n=w.get(r)||[];return i.info("Descendants of ",r," is ",n),i.info("Edge is ",e),e.v===r||e.w===r?!1:n?n.includes(e.v)||v(e.v,r)||v(e.w,r)||n.includes(e.w):(i.debug("Tilt, ",r,",not in descendants"),!1)},"edgeInCluster"),b=u((e,r,n,s)=>{i.warn("Copying children of ",e,"root",s,"data",r.node(e),s);const t=r.children(e)||[];e!==s&&t.push(e),i.warn("Copying (nodes) clusterId",e,"nodes",t),t.forEach(o=>{if(r.children(o).length>0)b(o,r,n,s);else{const l=r.node(o);i.info("cp ",o," to ",s," with parent ",e),n.setNode(o,l),s!==r.parent(o)&&(i.warn("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o))),e!==s&&o!==e?(i.debug("Setting parent",o,e),n.setParent(o,e)):(i.info("In copy ",e,"root",s,"data",r.node(e),s),i.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==s,"node!==clusterId",o!==e));const f=r.edges(o);i.debug("Copying Edges",f),f.forEach(a=>{i.info("Edge",a);const d=r.edge(a.v,a.w,a.name);i.info("Edge data",d,s);try{if(R(a,s)){const g=w.get(s)||[],E=g.includes(a.v)||v(a.v,s)||a.v===s,x=g.includes(a.w)||v(a.w,s)||a.w===s;if(E&&x)i.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),i.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else{const N=E?s:a.v,h=x?s:a.w;i.info("Rebinding cross-boundary edge as ",N,h,d,a.name),r.setEdge(N,h,d,a.name)}}else i.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",s," clusterId:",e)}catch(g){i.error(g)}})}i.debug("Removing node",o),r.removeNode(o)})},"copy"),O=u((e,r)=>{const n=r.children(e);let s=[...n];for(const t of n)A.set(t,e),s=[...s,...O(t,r)];return s},"extractDescendants"),P=u((e,r,n)=>{const s=e.edges().filter(a=>a.v===r||a.w===r),t=e.edges().filter(a=>a.v===n||a.w===n),o=s.map(a=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),l=t.map(a=>({v:a.v,w:a.w}));return o.filter(a=>l.some(d=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),D=u((e,r,n)=>{const s=r.children(e);if(i.trace("Searching children of id ",e,s),s.length<1)return e;let t;for(const o of s){const l=D(o,r,n),f=P(r,n,l);if(l)if(f.length>0)t=l;else return l}return t},"findNonClusterChild"),S=u(e=>!c.has(e)||!c.get(e).externalConnections?e:c.has(e)?c.get(e).id:e,"getAnchorId"),U=u((e,r)=>{if(!e||r>10){i.debug("Opting out, no graph ");return}else i.debug("Opting in, graph ");e.nodes().forEach(function(n){e.children(n).length>0&&(i.warn("Cluster identified",n," Replacement id in edges: ",D(n,e,n)),w.set(n,O(n,e)),c.set(n,{id:D(n,e,n),clusterData:e.node(n)}))}),e.nodes().forEach(function(n){const s=e.children(n),t=e.edges();s.length>0?(i.debug("Cluster identified",n,w),t.forEach(o=>{const l=v(o.v,n),f=v(o.w,n);l^f&&(i.warn("Edge: ",o," leaves cluster ",n),i.warn("Descendants of XXX ",n,": ",w.get(n)),c.get(n).externalConnections=!0)})):i.debug("Not a cluster ",n,w)});for(let n of c.keys()){const s=c.get(n).id,t=e.parent(s);t!==n&&c.has(t)&&!c.get(t).externalConnections&&(c.get(n).id=t);const o=e.edges().some(l=>l.v===n);if(s&&c.get(n)?.externalConnections&&o&&L(e,s,n)){const l=T(e,n,e.parent(s));l&&(c.get(n).id=l)}}e.edges().forEach(function(n){const s=e.edge(n);i.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),i.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let t=n.v,o=n.w;if(i.warn("Fix XXX",c,"ids:",n.v,n.w,"Translating: ",c.get(n.v)," --- ",c.get(n.w)),c.get(n.v)||c.get(n.w)){if(i.warn("Fixing and trying - removing XXX",n.v,n.w,n.name),t=S(n.v),o=S(n.w),e.removeEdge(n.v,n.w,n.name),t!==n.v){const l=e.parent(t);c.get(l).externalConnections=!0,s.fromCluster=n.v}if(o!==n.w){const l=e.parent(o);c.get(l).externalConnections=!0,s.toCluster=n.w}i.warn("Fix Replacing with XXX",t,o,n.name),e.setEdge(t,o,s,n.name)}}),i.warn("Adjusted Graph",C(e)),k(e,0),i.trace(c)},"adjustClustersAndEdges"),k=u((e,r)=>{if(i.warn("extractor - ",r,C(e),e.children("D")),r>10){i.error("Bailing out");return}let n=e.nodes(),s=!1;for(const t of n){const o=e.children(t);s=s||o.length>0}if(!s){i.debug("Done, no node has children",e.nodes());return}i.debug("Nodes = ",n,r);for(const t of n)if(i.debug("Extracting node",t,c,c.has(t)&&!c.get(t).externalConnections,!e.parent(t),e.node(t),e.children("D")," Depth ",r),!c.has(t))i.debug("Not a cluster",t,r);else if(c.get(t)?.clusterData?.explicitDir&&e.children(t)&&e.children(t).length>0){i.warn("Cluster with explicit dir, creating subgraph for children",t,r);const o=c.get(t).clusterData.dir,l=new y({multigraph:!0,compound:!0}).setGraph({rankdir:o,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});b(t,e,l,t);const f=e.node(t)||{};e.setNode(t,{...f,clusterNode:!0,id:t,clusterData:c.get(t).clusterData,label:c.get(t).label,graph:l}),i.warn("Subgraph for cluster with explicit dir created:",t,C(l))}else if(!c.get(t).externalConnections&&e.children(t)&&e.children(t).length>0){i.warn("Cluster without external connections, without a parent and with children",t,r);let l=e.graph().rankdir==="TB"?"LR":"TB";c.get(t)?.clusterData?.dir&&(l=c.get(t).clusterData.dir,i.warn("Fixing dir",c.get(t).clusterData.dir,l));const f=new y({multigraph:!0,compound:!0}).setGraph({rankdir:l,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});b(t,e,f,t);const a=e.node(t)||{};e.setNode(t,{...a,clusterNode:!0,id:t,clusterData:c.get(t).clusterData,label:c.get(t).label,graph:f}),i.debug("Old graph after copy",C(e))}else i.warn("Cluster ** ",t," **not meeting the criteria !externalConnections:",!c.get(t).externalConnections," no parent: ",!e.parent(t)," children ",e.children(t)&&e.children(t).length>0,e.children("D"),r),i.debug(c);n=e.nodes(),i.warn("New list of nodes",n);for(const t of n){const o=e.node(t);i.warn(" Now next level",t,o),o?.clusterNode&&k(o.graph,r+1)}},"extractor"),B=u((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach(s=>{const t=e.children(s),o=B(e,t);n=[...n,...o]}),n},"sorter"),W=u(e=>B(e,e.children()),"sortNodesByHierarchy"),L=u((e,r,n)=>{let s=e.parent(r);for(;s&&s!==n;){const t=c.get(s);if(t&&!t.externalConnections)return!0;s=e.parent(s)}return!1},"isNodeInExtractableCluster"),T=u((e,r,n)=>{const s=e.children(r)??[];for(const t of s){if(t===n||v(t,n))continue;const o=D(t,e,r);if(o&&!L(e,o,r))return o}return null},"findSafeAnchorNode");export{U as a,c as b,J as c,D as f,W as s,C as w};
|