UNPKG

code-server

Version:

Run VS Code on a remote server.

2 lines (1 loc) • 5.5 kB
import{a as P}from"./chunk-Q4UTCILM.js";import{a as y}from"./chunk-TZZ523SA.js";var w=5,O=1e-5,X=2,Y=.6,R=1e-6;function N(t){let e=[];for(let s=0;s<t.length-1;s++)e.push({a:t[s],b:t[s+1]});return e}y(N,"buildSegmentList");function T(t,e,s,i){let r=e.x-t.x,o=e.y-t.y,a=i.x-s.x,d=i.y-s.y,u=r*d-o*a;if(u===0)return null;let n=s.x-t.x,c=s.y-t.y,p=(n*d-c*a)/u,l=(n*o-c*r)/u;return p<=R||p>=1-R||l<=R||l>=1-R?null:{point:{x:t.x+p*r,y:t.y+p*o},tA:p,tB:l}}y(T,"segmentIntersection");function v(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}y(v,"isHorizontalSeg");function B(t,e,s){if(t.curve!=="rounded")return!1;let i=t.points,r=i[e],o=i[e+1];if(!r||!o)return!1;let a=Math.hypot(o.x-r.x,o.y-r.y),d=s*a,u=e>0?L(i[e-1],r,o,w):null;if(u&&d<u.cutLen)return!0;let n=e+2<i.length?L(r,o,i[e+2],w):null;return n!==null&&a-d<n.cutLen}y(B,"crossingSitsInRoundedCorner");function C(t){let e=[];for(let s=0;s<t.length;s++){let i=t[s],r=N(i.points);for(let o=s+1;o<t.length;o++){let a=t[o],d=N(a.points);for(let[u,n]of r.entries())for(let[c,p]of d.entries()){let l=T(n.a,n.b,p.a,p.b);if(!l||B(i,u,l.tA)||B(a,c,l.tB))continue;let g=v(n),S=v(p);(g!==S?g:!1)?e.push({jumpEdgeId:i.id,otherEdgeId:a.id,segIndex:u,t:l.tA,point:l.point}):e.push({jumpEdgeId:a.id,otherEdgeId:i.id,segIndex:c,t:l.tB,point:l.point})}}}return e}y(C,"findEdgeIntersections");function M(t){let e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}y(M,"fmt");function A(t){return`${M(t.x)},${M(t.y)}`}y(A,"pointToString");function D(t){let e=t.b.x-t.a.x,s=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(s)?e>=0?1:0:s>=0?1:0}y(D,"getArcSweepFlag");function _(t,e){if(t.length<2)return t.map(o=>({...o}));let s=t.map(o=>({...o})),i=e.arrowTypeStart&&P[e.arrowTypeStart];if(i){let o=t[0],a=t[1],d=Math.atan2(a.y-o.y,a.x-o.x);s[0].x=o.x+i*Math.cos(d),s[0].y=o.y+i*Math.sin(d)}let r=e.arrowTypeEnd&&P[e.arrowTypeEnd];if(r){let o=t.length,a=t[o-2],d=t[o-1],u=Math.atan2(d.y-a.y,d.x-a.x);s[o-1].x=d.x-r*Math.cos(u),s[o-1].y=d.y-r*Math.sin(u)}return s}y(_,"applyMarkerOffsets");function k(t,e,s,i,r){let o=t.point.x,a=t.point.y,d={x:o-e*t.r,y:a-s*t.r},u={x:o+e*t.r,y:a+s*t.r},n=[`L${A(d)}`];return r==="arc"?n.push(`A${M(t.r)},${M(t.r)} 0 0 ${i} ${A(u)}`):n.push(`M${A(u)}`),n}y(k,"emitJump");function L(t,e,s,i){let r=e.x-t.x,o=e.y-t.y,a=s.x-e.x,d=s.y-e.y,u=Math.hypot(r,o),n=Math.hypot(a,d);if(u<O||n<O)return null;let c=r/u,p=o/u,l=a/n,g=d/n,S=c*l+p*g,b=Math.max(-1,Math.min(1,S)),x=Math.acos(b);if(x<O||Math.abs(Math.PI-x)<O)return null;let h=Math.min(i/Math.sin(x/2),u/2,n/2);return{startX:e.x-c*h,startY:e.y-p*h,endX:e.x+l*h,endY:e.y+g*h,ctrlX:e.x,ctrlY:e.y,cutLen:h}}y(L,"computeRoundedCorner");function H(t,e,s){let i=t.points;if(i.length<2)return"";let r=_(i,t),o=t.curve==="rounded",a=N(r),d=new Map;for(let n of e){let c=a[n.segIndex];if(!c)continue;let p=Math.hypot(c.b.x-c.a.x,c.b.y-c.a.y),l=d.get(n.segIndex)??[];l.push({t:n.t,point:n.point,d:n.t*p,r:s.jumpRadius}),d.set(n.segIndex,l)}let u=[`M${A(r[0])}`];for(let n=0;n<a.length;n++){let c=a[n],p=Math.hypot(c.b.x-c.a.x,c.b.y-c.a.y),l=p===0?0:(c.b.x-c.a.x)/p,g=p===0?0:(c.b.y-c.a.y)/p,S=D(c),b=0;if(o&&n>0){let f=L(r[n-1],r[n],r[n+1]??r[n],w);f&&(b=f.cutLen)}let x=p,h=null;o&&n<a.length-1&&(h=L(r[n],r[n+1],r[n+2]??r[n+1],w),h&&(x=p-h.cutLen));let $=s.jumpRadius*Y,m=[...d.get(n)??[]].sort((f,E)=>f.t-E.t).filter(f=>{let E=Math.min(f.d-b,x-f.d)-X;return f.r=Math.min(f.r,E),f.r>=$});for(let f=0;f<m.length-1;f++){let E=m[f+1].d-m[f].d;if(m[f].r+m[f+1].r>E){let I=E/2;m[f].r=Math.min(m[f].r,I),m[f+1].r=Math.min(m[f+1].r,I)}}for(let f of m)f.r<$||u.push(...k(f,l,g,S,s.jumpStyle));o&&h?(u.push(`L${M(h.startX)},${M(h.startY)}`),u.push(`Q${M(h.ctrlX)},${M(h.ctrlY)} ${M(h.endX)},${M(h.endY)}`)):u.push(`L${A(c.b)}`)}return u.join(" ")}y(H,"rewriteEdgePath");function J(t){return/^[\d\s+,.LMelm-]*$/.test(t)}y(J,"isStraightPath");function U(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}y(U,"curveSupportsLineHops");function j(t){if(!t)return null;try{let e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),s=JSON.parse(e);if(!Array.isArray(s))return null;let i=[];for(let r of s)r&&typeof r.x=="number"&&typeof r.y=="number"&&i.push({x:r.x,y:r.y});return i.length>=2?i:null}catch{return null}}y(j,"decodeDataPoints");function F(t,e,s){if(!s.enabled)return;let i=t.node();if(!i)return;let r=new Map;for(let n of e)r.set(n.id,n);let o=new Map;for(let n of i.querySelectorAll("path[data-id]")){let c=n.getAttribute("data-id");c!==null&&!o.has(c)&&o.set(c,n)}let a=[];for(let n of e){let c=o.get(n.id);if(!c)continue;let l=j(c.getAttribute("data-points"))??n.points;a.push({...n,points:l})}let d=C(a);if(d.length===0)return;let u=new Map;for(let n of d){let c=u.get(n.jumpEdgeId)??[];c.push(n),u.set(n.jumpEdgeId,c)}for(let n of a){let c=u.get(n.id);if(!c||c.length===0)continue;let l=r.get(n.id)?.curve;if(l!==void 0&&!U(l))continue;let g=o.get(n.id);if(!g)continue;if(l===void 0){let m=g.getAttribute("d")??"";if(!J(m))continue}let S=g.getAttribute("style")??"",b=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(S),x=b?Number.parseFloat(b[1]):null,h=b?Number.parseFloat(b[2]):null,$=H(n,c,s);if(g.setAttribute("d",$),x!==null&&h!==null&&typeof g.getTotalLength=="function"){let m=g.getTotalLength(),f=Math.max(0,m-x-h),E=`0 ${x} ${f} ${h}`,I=S.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${E};`).replace(/;\s*;+/g,";");g.setAttribute("style",I)}}}y(F,"applyLineJumpsToSvg");export{F as a};