1 line
2.8 KiB
JavaScript
1 line
2.8 KiB
JavaScript
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{t}from"./react-QV7DAAIx.js";import{At as n,Ct as r,Dt as i,Et as a,Q as o,Yt as s,Zt as c,in as l,jt as u,lt as d,st as f,xt as p}from"./semi-65W_4I1v.js";var m=e(t(),1),h={target:i,infra:f,auth:r,finding:d,chain:s,exploit:c,poc:o,vulnerability:l,missing:a,goal:n,step:s,fact:u,receipt:o,observation:d,memory:p,digest:u,guidance:c};function g({type:e}){let t=h[e]||u;return(0,m.jsx)(`span`,{className:`graph-node-icon`,"aria-hidden":`true`,children:(0,m.jsx)(t,{size:`small`})})}function _({id:e,title:t,type:n,category:r,color:i,factKey:a,boundary:o,ports:s=[],selected:c,card:l,onSelect:u,onPreview:d}){let{density:f,box:p}=l,h=f===`detail`,_=Math.min(Math.max(p.width/216,1),1.6);return(0,m.jsxs)(`button`,{type:`button`,className:`graph-node graph-node--${f}`,title:t,"aria-label":t,"aria-pressed":c,"data-root":n===`goal`||n===`target`||void 0,"data-boundary":o||void 0,"data-wrap":f===`standard`&&p.height>=50||void 0,style:{...p,"--graph-node-color":i,"--graph-node-text-scale":_},onClick:()=>u(e),onMouseEnter:()=>d?.(e,!0),onMouseLeave:()=>d?.(e,!1),onFocus:()=>d?.(e,!0),onBlur:()=>d?.(e,!1),children:[(0,m.jsxs)(`span`,{className:`graph-node-content`,children:[f!==`compact`&&(0,m.jsxs)(`span`,{className:`graph-node-kind`,children:[(0,m.jsx)(g,{type:n}),(0,m.jsx)(`span`,{children:r})]}),(0,m.jsx)(`span`,{className:`graph-node-title`,dir:`auto`,children:t}),h&&p.height>=84&&a&&t!==a&&(0,m.jsx)(`span`,{className:`graph-node-keyline`,dir:`auto`,children:a})]}),h&&[...s].map(e=>(0,m.jsx)(`span`,{className:`graph-node-port is-${e}`,"aria-hidden":`true`},e))]})}function v(e,{anchorId:t,allowCompact:n=()=>!0}={}){let r=e.width(),i=e.height(),a=216*e.zoom(),o=98*e.zoom(),s=o>=68?`detail`:o>=36?`standard`:`compact`,c=[];for(let l of e.nodes(`:visible`)){let e=l.id();if(l.hasClass(`dim`)||s===`compact`&&e!==t&&(a<49||!n(l)))continue;let{x:u,y:d}=l.renderedPosition(),f=u-a/2,p=d-o/2;if(f+a<=0||f>=r||p+o<=0||p>=i)continue;let m={left:f,top:p,width:a,height:o};e===t&&a<49&&(m={left:Math.max(3,f),top:d-13,width:Math.min(108,r-Math.max(3,f)),height:26}),c.push({id:e,density:s,box:m})}return c}function y(e,t,n={x:e.width()/2,y:e.height()/2}){e.zoom({level:e.zoom()*t,renderedPosition:n})}function b(e,t){let n=n=>{if(!n.deltaY)return;n.preventDefault();let{left:r,top:i,height:a}=e.getBoundingClientRect(),o=n.deltaMode===1?33:n.deltaMode===2?a:1;y(t,10**(-n.deltaY*o/1250),{x:n.clientX-r,y:n.clientY-i})};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)}function x(e,t){let n=new Map,r=new Set;for(let i of e){if(t(i.target)||n.has(i.target))continue;let e=i.source;for(;e&&e!==i.target;)e=n.get(e);e!==i.target&&(n.set(i.target,i.source),r.add(i))}return{parents:n,parentEdges:r}}export{v as a,b as i,_ as n,y as o,g as r,x as t}; |