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