1(function(){"use strict";function O(M){if(M.length<3)return 0;const S=M.slice().sort((e,i)=>e[0]===i[0]?e[1]-i[1]:e[0]-i[0]),m=(e,i,w)=>(i[0]-e[0])*(w[1]-e[1])-(i[1]-e[1])*(w[0]-e[0]),d=[];for(const e of S){for(;d.length>=2&&m(d[d.length-2],d[d.length-1],e)<=0;)d.pop();d.push(e)}const f=[];for(let e=S.length-1;e>=0;e--){const i=S[e];for(;f.length>=2&&m(f[f.length-2],f[f.length-1],i)<=0;)f.pop();f.push(i)}f.pop(),d.pop();const v=d.concat(f);if(v.length<3)return 0;let g=0;for(let e=0;e<v.length;e++){const[i,w]=v[e],[k,z]=v[(e+1)%v.length];g+=i*z-k*w}return Math.abs(g)/2}function P(M,S){const m=new Map;for(const g of M)m.has(g.region_id)||m.set(g.region_id,[]),m.get(g.region_id).push(g);const d=new Map,f=new Map;for(const[g,e]of m)for(const i of e)f.set(i.id,g);for(const g of S){const e=f.get(g.a),i=f.get(g.b);e!==void 0&&i!==void 0&&e===i&&(d.has(e)||d.set(e,[]),d.get(e).push(g))}const v={};for(const[g,e]of m){const i=e.length,w=[],k=new Set;let z=0;for(const t of e)k.add(t.id),t.deg>0&&w.push(t.id),t.planets&&(z+=t.planets);const b=w.length,Q=i-b,j=d.get(g)||[],x=j.length,T=x?j.reduce((t,o)=>t+o.len,0)/x:0,U=e.map(t=>[t.x,t.z]),J=O(U),V=J>0?i/J*100:0,W=i>0?b/i*100:0,X=b>0?2*x/b:0,D=new Map;for(const t of j)D.has(t.a)||D.set(t.a,[]),D.get(t.a).push(t.b),D.has(t.b)||D.set(t.b,[]),D.get(t.b).push(t.a);const R=(t,o)=>{const l=t.x-o.x,p=t.y-o.y,r=t.z-o.z;return Math.sqrt(l*l+p*p+r*r)},Y=(t,o)=>{if(t.id===o.id)return{d:0,h:0};const l=[[t.id]],p=new Set([t.id]);for(;l.length;){const r=l.shift(),a=r[r.length-1];if(a===o.id){let n=0;for(let c=0;c<r.length-1;c++){const s=r[c],h=r[c+1],y=e.find(_=>_.id===s),u=e.find(_=>_.id===h);n+=R(y,u)}return{d:n,h:r.length-1}}for(const n of D.get(a)||[])p.has(n)||(p.add(n),l.push([...r,n]))}return null},H=new Map,Z=(t,o)=>{const l=t.id<o.id?t.id+"|"+o.id:o.id+"|"+t.id,p=H.get(l);if(p)return p;const r=Y(t,o);if(r){const c={gateDistance:r.d,gateHops:r.h,shipDistance:R(t,o),chooseShip:!1};return H.set(l,c),c}const n={gateDistance:null,gateHops:null,shipDistance:R(t,o),chooseShip:!0};return H.set(l,n),n},G=t=>{if(t.length<=1)return{distance:0,gateJumps:0,shipJumps:0,shipDistance:0};let o=t[0];for(const s of t)s.deg>o.deg&&(o=s);const l=new Set(t.filter(s=>s.id!==o.id).map(s=>s.id));let p=o,r=0,a=0,n=0,c=0;for(;l.size;){let s=null;for(const h of l){const y=t.find(tt=>tt.id===h),u=Z(p,y);if(!s){s={sys:y,ev:u};continue}const _=s.ev;(!u.chooseShip&&_.chooseShip||u.chooseShip===_.chooseShip&&(u.chooseShip?u.shipDistance:u.gateDistance)<(_.chooseShip?_.shipDistance:_.gateDistance))&&(s={sys:y,ev:u})}if(!s)break;s.ev.chooseShip?(r+=s.ev.shipDistance,c+=s.ev.shipDistance,n+=1):(r+=s.ev.gateDistance,a+=s.ev.gateHops),l.delete(s.sys.id),p=s.sys}return{distance:r,gateJumps:a,shipJumps:n,shipDistance:c}};let I=0,B=0;if(b>0){const t=e.filter(l=>l.deg>0),o=G(t);I=o.distance,B=o.gateJumps}let C=0,q=0,A=0,N=0;if(i>0){const t=G(e);C=t.distance,q=t.gateJumps,A=t.shipJumps,N=t.shipDistance}const $=q+A;let E=0;if(i>1){const t=new Map,o=new Map;for(const a of e)t.set(a.id,a.id),o.set(a.id,0);const l=a=>{const n=t.get(a);if(n!==a){const c=l(n);return t.set(a,c),c}return n},p=(a,n)=>{let c=l(a),s=l(n);if(c===s)return!1;let h=o.get(c),y=o.get(s);return h<y?t.set(c,s):y<h?t.set(s,c):(t.set(s,c),o.set(c,h+1)),!0};for(const a of j)p(a.a,a.b);const r=new Set(e.map(a=>l(a.id)));if(r.size>1){const a=[];for(let n=0;n<e.length;n++)for(let c=n+1;c<e.length;c++){const s=e[n],h=e[c];if(l(s.id)===l(h.id))continue;const y=s.x-h.x,u=s.y-h.y,_=s.z-h.z,K=Math.sqrt(y*y+u*u+_*_);a.push({a:s.id,b:h.id,len:K})}a.sort((n,c)=>n.len-c.len);for(const n of a)if(p(n.a,n.b)&&(E=n.len,r.size===1))break}else E=0}const L=i>0?z/i:0;let F=!1;for(const t of e)if(t.has_station){F=!0;break}v[g]={systems_total:i,systems_gated:b,systems_isolated:Q,connectivity_pct:W,gate_links:x,avg_gate_distance_ly:T,avg_gate_degree:X,footprint_area_ly2:J,system_density_per_100_ly2:V,est_gated_distance_ly:I,est_gated_gate_jumps:B,est_all_distance_ly:C,all_gate_jumps:q,ship_jumps:A,ship_jump_ly:N,total_jumps:$,min_jump_range_ly:E,total_planets:z,avg_planets_per_system:L,has_station:F}}return v}self.onmessage=function(M){const S=M.data;if(S.type==="compute")try{const d={type:"result",regions:P(S.systems,S.gates)};self.postMessage(d)}catch{const d={type:"result",regions:{}};self.postMessage(d)}}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.