(function(){let e=[],t=[],n=null,r=!1,i=0,a=null;function o(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function s(e){let{vx:t,vy:n,pinned:r,...i}=e;return{...i}}function c(){self.postMessage({type:`tick`,nodes:e.map(s)})}function l(){if(!n||n.animationSpeed<=0)return;i+=1;let a=new Map(e.map(e=>[e.id,e])),s=Math.max(.12,Math.min(1.6,n.animationSpeed));for(let t of e)t.pinned||(t.vx+=(590-t.x)*n.centerStrength*s,t.vy+=(360-t.y)*n.centerStrength*s);let l=e.length>180?Math.max(1,Math.ceil(e.length/180)):1;for(let t=0;t<e.length;t++){let r=t+1+(l>1?(i+t)%l:0);for(let i=r;i<e.length;i+=l){let r=e[t],a=e[i],c=a.x-r.x,l=a.y-r.y,u=c*c+l*l;u<.01&&(c=o(`${r.id}:${a.id}`)-.5,l=o(`${a.id}:${r.id}`)-.5,u=c*c+l*l+.01);let d=Math.sqrt(u),f=n.collisionRadius+Math.min(28,10+r.degree*1.2)+Math.min(28,10+a.degree*1.2),p=Math.max(0,f-d)*.22,m=(n.chargeStrength/Math.max(160,u)+p)*s,h=c/d*m,g=l/d*m;r.pinned||(r.vx-=h,r.vy-=g),a.pinned||(a.vx+=h,a.vy+=g)}}for(let e of t){let t=a.get(e.source),r=a.get(e.target);if(!t||!r)continue;let i=r.x-t.x,o=r.y-t.y,c=Math.sqrt(i*i+o*o)||1,l=(c-n.linkDistance/Math.max(.9,Math.min(2.6,e.weight??1)))*.012*s,u=i/c*l,d=o/c*l;t.pinned||(t.vx+=u,t.vy+=d),r.pinned||(r.vx-=u,r.vy-=d)}for(let t of e){if(t.pinned){t.vx=0,t.vy=0;continue}t.vx*=.9,t.vy*=.9,t.x+=Math.max(-18,Math.min(18,t.vx)),t.y+=Math.max(-18,Math.min(18,t.vy))}let u=e.length>320?4:r||e.length>180?2:1;i%u===0&&c()}function u(){a&&clearInterval(a),a=null}self.onmessage=o=>{let s=o.data;if(s.type===`stop`){u();return}if(s.type===`pin`){let t=e.find(e=>e.id===s.id);if(!t)return;t.pinned=s.pinned,typeof s.x==`number`&&(t.x=s.x),typeof s.y==`number`&&(t.y=s.y),t.vx=0,t.vy=0,c();return}u(),e=s.nodes.map(e=>({...e,vx:e.vx??0,vy:e.vy??0})),t=s.edges,n=s.physics,r=s.lightweight,i=0,c(),a=setInterval(l,16)}})();