worldorbit 2.5.9 → 2.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var WorldOrbitMarkdown=(()=>{var Oe=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var Rt=(e,t)=>{for(var r in t)Oe(e,r,{get:t[r],enumerable:!0})},zt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pt(t))!Bt.call(e,o)&&o!==r&&Oe(e,o,{get:()=>t[o],enumerable:!(n=Ct(t,o))||n.enumerable});return e};var Nt=e=>zt(Oe({},"__esModule",{value:!0}),e);var Bo={};Rt(Bo,{rehypeWorldOrbit:()=>Mt,remarkWorldOrbit:()=>Ot,renderWorldOrbitBlock:()=>_,renderWorldOrbitError:()=>_e});var d=class e extends Error{line;column;constructor(t,r,n){let o=r===void 0?"":` (line ${r}${n===void 0?"":`, column ${n}`})`;super(`${t}${o}`),this.name="WorldOrbitError",this.line=r,this.column=n}static fromLocation(t,r){return new e(t,r?.line,r?.column)}};var q=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],O=q.filter(e=>e!=="system"),Wt=["star","planet","moon","asteroid","comet","structure","phenomenon"],Ye=["structure","phenomenon"],L=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],_t=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function y(e,t){return{key:e,...t}}var ae=new Set(q),Ue=new Map([y("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:L}),y("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"distance"}),y("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"distance"}),y("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:L}),y("period",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"duration"}),y("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"angle"}),y("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"angle"}),y("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"angle"}),y("at",{kind:"string",placement:!0,arity:"single",objectTypes:Ye}),y("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Ye}),y("free",{kind:"string",placement:!0,arity:"single",objectTypes:_t}),y("kind",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("class",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("culture",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:q}),y("color",{kind:"string",placement:!1,arity:"single",objectTypes:q}),y("image",{kind:"string",placement:!1,arity:"single",objectTypes:Wt}),y("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:q}),y("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"radius"}),y("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"mass"}),y("density",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"generic"}),y("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"generic"}),y("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"generic"}),y("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:O}),y("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),y("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),y("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),y("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("on",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("source",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"duration"})].map(e=>[e.key,e])),Yt=new Set(Ue.keys());function T(e){return Ue.get(e)}function se(e){return Yt.has(e)}function qe(e,t){return e.objectTypes.includes(t)}function Xe(e,t){switch(e){case"distance":return t===null||["au","km","m","ly","pc","kpc","re","sol"].includes(t);case"radius":return t===null||["km","m","re","rj","sol"].includes(t);case"mass":return t===null||["me","mj","sol"].includes(t);case"duration":return t===null||["s","min","h","d","y","ky","my","gy"].includes(t);case"angle":return t===null||t==="deg";case"generic":return!0}}function X(e,t={}){let r=[],n=t.columnOffset??0,o="",i=null,a=!1,s=!1,u=null,l=()=>{i!==null&&(r.push({value:o,column:i,quoted:a}),o="",i=null,a=!1)};for(let c=0;c<e.length;c++){let f=e[c],p=n+c+1;if(s&&f==="\\"){let h=e[c+1];if(h==='"'||h==="\\"){o+=h,c++;continue}}if(f==='"'){s?s=!1:(i===null&&(i=p),a=!0,u=p,s=!0);continue}if(!s&&/\s/.test(f)){l();continue}i===null&&(i=p),o+=f}if(s)throw new d("Unclosed quote in line",t.line,u??n+e.length);return l(),r}function le(e){return e.match(/^\s*/)?.[0].length??0}function H(e){let t=e.split(/\r?\n/),r=[],n=null,o=!1,i=null;for(let a=0;a<t.length;a++){let s=t[a],u=a+1;if(!s.trim())continue;let l=le(s),c=X(s.slice(l),{line:u,columnOffset:l});if(c.length!==0){if(l===0){o=!1,i=null;let f=Ut(c,u);r.push(f),n=f;continue}if(!n)throw new d("Indented line without parent object",u,l+1);if(c.length===1&&c[0].value==="info"){o=!0,i=l;continue}o&&l<=(i??0)&&(o=!1),o?n.infoEntries.push(Ht(c,u)):n.blockFields.push(Xt(c,u))}}return{type:"document",objects:r}}function Ut(e,t){if(e.length<2)throw new d("Invalid object declaration",t,e[0]?.column??1);let[r,n,...o]=e;if(!ae.has(r.value))throw new d(`Unknown object type "${r.value}"`,t,r.column);return{type:"object",objectType:r.value,name:n.value,inlineFields:qt(o,t),blockFields:[],infoEntries:[],location:{line:t,column:r.column}}}function qt(e,t){let r=[],n=0;for(;n<e.length;){let o=e[n],i=T(o.value);if(!i)throw new d(`Unknown field "${o.value}"`,t,o.column);n++;let a=[];if(i.arity==="multiple")for(;n<e.length&&!se(e[n].value);)a.push(e[n]),n++;else{let s=e[n];s&&(a.push(s),n++)}if(a.length===0)throw new d(`Missing value for field "${o.value}"`,t,o.column);r.push({type:"field",key:o.value,values:a.map(s=>s.value),location:{line:t,column:o.column}})}return r}function Xt(e,t){if(e.length<2)throw new d("Invalid field line",t,e[0]?.column??1);if(!T(e[0].value))throw new d(`Unknown field "${e[0].value}"`,t,e[0].column);return{type:"field",key:e[0].value,values:e.slice(1).map(r=>r.value),location:{line:t,column:e[0].column}}}function Ht(e,t){if(e.length<2)throw new d("Invalid info entry",t,e[0]?.column??1);return{type:"info-entry",key:e[0].value,value:e.slice(1).map(r=>r.value).join(" "),location:{line:t,column:e[0].column}}}var He=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Gt=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Kt=/^[A-Za-z][A-Za-z0-9+.-]*:/;function B(e){let t=null,r=[];for(let n of e.objects){let o=Jt(n);if(n.objectType==="system"){if(t)throw d.fromLocation("Only one system object is allowed",n.location);t=o}else r.push(o)}return{format:"worldorbit",version:"1.0",system:t,objects:r}}function Jt(e){let t=[...e.inlineFields,...e.blockFields];Zt(e.objectType,t);let r=Qt(t),n=er(e.objectType,r),o=tr(r),i=or(e.infoEntries);return e.objectType==="system"?{type:"system",id:e.name,properties:o,info:i}:{type:e.objectType,id:e.name,properties:o,placement:n,info:i}}function Zt(e,t){for(let r of t){let n=T(r.key);if(!n)throw d.fromLocation(`Unknown field "${r.key}"`,r.location);if(!qe(n,e))throw d.fromLocation(`Field "${r.key}" is not valid on "${e}"`,r.location);if(n.arity==="single"&&r.values.length!==1)throw d.fromLocation(`Field "${r.key}" expects exactly one value`,r.location)}}function Qt(e){let t=new Map;for(let r of e){if(t.has(r.key))throw d.fromLocation(`Duplicate field "${r.key}"`,r.location);t.set(r.key,r)}return t}function er(e,t){let r=t.has("orbit"),n=t.has("at"),o=t.has("surface"),i=t.has("free"),a=[r,n,o,i].filter(Boolean).length;if(a>1){let s=t.get("orbit")??t.get("at")??t.get("surface")??t.get("free");throw d.fromLocation("Object has multiple placement modes",s?.location)}if(e==="system"&&a>0)throw d.fromLocation("System objects cannot declare placement",[...t.values()][0]?.location);if(r)return{mode:"orbit",target:ce(t,"orbit"),distance:N(t,"distance"),semiMajor:N(t,"semiMajor"),eccentricity:sr(t,"eccentricity"),period:N(t,"period"),angle:N(t,"angle"),inclination:N(t,"inclination"),phase:N(t,"phase")};if(n){let s=ue(t,"at"),u=ce(t,"at");return{mode:"at",target:u,reference:ir(u,s.location)}}if(o)return{mode:"surface",target:ce(t,"surface")};if(i){let s=ce(t,"free"),u=ar(s);return{mode:"free",distance:u??void 0,descriptor:u?void 0:s}}return null}function tr(e){let t={};for(let[r,n]of e.entries()){let o=T(r);if(!(!o||o.placement))switch(o.kind){case"list":t[r]=n.values;break;case"boolean":t[r]=lr(n);break;case"number":t[r]=Ke(W(n),r,n.location);break;case"unit":t[r]=Ge(W(n),n.location,r);break;case"string":t[r]=rr(r,n);break}}return t}function rr(e,t){let r=t.values.join(" ").trim();return e==="image"&&nr(r,t.location),r}function nr(e,t){if(!e)throw d.fromLocation('Field "image" must not be empty',t);if(e.startsWith("//"))throw d.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',t);let r=e.match(Kt);if(!r)return;let n=r[0].slice(0,-1).toLowerCase();if(n!=="http"&&n!=="https")throw d.fromLocation(`Field "image" does not support the "${n}" scheme`,t)}function or(e){let t={};for(let r of e){if(r.key in t)throw d.fromLocation(`Duplicate info key "${r.key}"`,r.location);t[r.key]=r.value}return t}function ir(e,t){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(e))throw d.fromLocation(`Invalid special position "${e}"`,t);let r=e.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(r)return{kind:"lagrange",primary:r[1],secondary:r[2],point:r[3]};let n=e.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(n)return{kind:"lagrange",primary:n[1],secondary:null,point:n[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(e))throw d.fromLocation(`Invalid special position "${e}"`,t);let o=e.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return o?{kind:"anchor",objectId:o[1],anchor:o[2]}:{kind:"named",name:e}}function Ge(e,t,r){let n=e.match(He);if(!n)throw d.fromLocation(`Invalid unit value "${e}"`,t);let o={value:Number(n[1]),unit:n[2]??null};if(r){let i=T(r);if(i?.unitFamily&&!Xe(i.unitFamily,o.unit))throw d.fromLocation(`Unit "${o.unit??"none"}" is not valid for "${r}"`,t)}return o}function ar(e){let t=e.match(He);return t?{value:Number(t[1]),unit:t[2]??null}:null}function N(e,t){if(!e.has(t))return;let r=ue(e,t);return Ge(W(r),r.location,t)}function sr(e,t){if(!e.has(t))return;let r=ue(e,t);return Ke(W(r),t,r.location)}function Ke(e,t,r){let n=Number(e);if(!Number.isFinite(n))throw d.fromLocation(`Invalid numeric value "${e}" for "${t}"`,r);return n}function lr(e){let t=W(e).toLowerCase(),r=Gt.get(t);if(r===void 0)throw d.fromLocation(`Invalid boolean value "${t}" for "${e.key}"`,e.location);return r}function ue(e,t){let r=e.get(t);if(!r)throw new d(`Missing value for key "${t}"`);return r}function ce(e,t){return W(ue(e,t))}function W(e){if(e.values.length!==1)throw d.fromLocation(`Field "${e.key}" expects exactly one value`,e.location);return e.values[0]}var cr=new Set(["star","planet","moon","asteroid","comet"]);function V(e){let t=new Set,r=new Map;for(let n of e.objects){if(t.has(n.id))throw new d(`Duplicate object id "${n.id}"`);t.add(n.id),r.set(n.id,n)}for(let n of e.objects)if(n.placement){if((n.placement.mode==="orbit"||n.placement.mode==="surface")&&!t.has(n.placement.target))throw new d(`Unknown placement target "${n.placement.target}" on "${n.id}"`);if(n.placement.mode==="surface"){let o=r.get(n.placement.target);if(!o||!cr.has(o.type))throw new d(`Surface target "${n.placement.target}" on "${n.id}" is not surface-capable`)}n.placement.mode==="at"&&(n.placement.reference.kind==="lagrange"&&ur(n,n.placement.reference,t),n.placement.reference.kind==="anchor"&&dr(n,n.placement.reference,t))}}function ur(e,t,r){if(!r.has(t.primary))throw new d(`Unknown Lagrange reference "${t.primary}" on "${e.id}"`);if(t.secondary&&!r.has(t.secondary))throw new d(`Unknown Lagrange reference "${t.secondary}" on "${e.id}"`)}function dr(e,t,r){if(!r.has(t.objectId))throw new d(`Unknown anchor target "${t.objectId}" on "${e.id}"`)}function E(e,t,r=`${t}.failed`){return e instanceof d?{code:r,severity:"error",source:t,message:e.message,line:e.line,column:e.column}:e instanceof Error?{code:r,severity:"error",source:t,message:e.message}:{code:r,severity:"error",source:t,message:String(e)}}var G=1495978707e-1,fr=6371,pr=71492,mr=695700,hr=63241.077,br=206264.806,gr=206264806,rt=.68,yr=.2,nt=28;function F(e,t={}){let r=xr(t),n=r.width,o=r.height,i=r.padding,a=wr(e),s=vr(e,t.projection),u=jr(a,t.scaleModel),l=Sr(a),c=e.system?.id??null,f=new Map(e.objects.map(b=>[b.id,b])),p=tn(e.objects,f),h=new Map,g=[],w=[],m=[],x=[],j=[],S=new Map,Y=new Map;for(let b of e.objects){let k=b.placement;if(!k){m.push(b);continue}if(k.mode==="orbit"){Qe(Y,k.target,b);continue}if(k.mode==="surface"){Qe(S,k.target,b);continue}if(k.mode==="at"){j.push(b);continue}x.push(b)}let A=x.length>0?n*.42:n/2,re=o/2,D={orbitChildren:Y,surfaceChildren:S,objectMap:f,spacingFactor:l,projection:s,scaleModel:u},$e=m.find(b=>b.type==="star")??m[0]??null;$e&&Te($e,A,re,0,h,g,w,D);let Se=m.filter(b=>b.id!==$e?.id);if(Se.length>0){let b=Math.min(n,o)*.28*l*u.orbitDistanceMultiplier;Se.forEach((k,I)=>{let ke=Z(I,Se.length,-Math.PI/2),P=Q(ke,b,s,1);Te(k,A+P.x,re+P.y,0,h,g,w,D)})}x.forEach((b,k)=>{let I=n-i-140-ln(b.placement?.mode==="free"?b.placement.distance:void 0,u),ke=Math.max(76,(o-i*2-180)/Math.max(1,x.length)*l)*u.freePlacementMultiplier,P=i+92+k*ke;h.set(b.id,{object:b,x:I,y:P,radius:me(b,0,u),sortKey:be(I,P,0)}),w.push({object:b,groupId:p.groupIds.get(b.id)??null,x1:I-60,y1:P,x2:I-18,y2:P,mode:"free"}),fe(b,h,g,w,D,1)}),j.forEach((b,k)=>{if(h.has(b.id)||!b.placement||b.placement.mode!=="at")return;let I=Qr(b.placement.reference,h,f,k,j.length,n,o,i,D);h.set(b.id,{object:b,x:I.x,y:I.y,radius:me(b,2,u),sortKey:be(I.x,I.y,2),anchorX:I.anchorX,anchorY:I.anchorY}),I.anchorX!==void 0&&I.anchorY!==void 0&&w.push({object:b,groupId:p.groupIds.get(b.id)??null,x1:I.anchorX,y1:I.anchorY,x2:I.x,y2:I.y,mode:"at"}),fe(b,h,g,w,D,2)});let U=[...h.values()].map(b=>kr(b,u,p)),ne=g.map(b=>Or(b,p.groupIds.get(b.object.id)??null)),oe=w.map(b=>Tr(b)),ie=Mr(U,o,u.labelMultiplier),Lt=Ar(ne,oe,U,ie),Vt=Dr(U,ne,oe,ie,p),Et=Lr(e,s,r.preset,p,f),Ft=qr(n,o,U,ne,oe,ie);return{width:n,height:o,padding:i,renderPreset:r.preset,projection:s,scaleModel:u,title:String(e.system?.properties.title??e.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:`${et(s)} view - ${et(a)} layout`,systemId:c,viewMode:s,layoutPreset:a,metadata:{format:e.format,version:e.version,view:s,scale:String(e.system?.properties.scale??a),units:String(e.system?.properties.units??"mixed"),preset:r.preset??"custom"},contentBounds:Ft,layers:Lt,groups:Vt,viewpoints:Et,objects:U,orbitVisuals:ne,leaders:oe,labels:ie}}function wr(e){switch(String(e.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function xr(e){let t=Ir(e.preset);return{width:e.width??t.width,height:e.height??t.height,padding:e.padding??t.padding,preset:e.preset??null}}function Ir(e){switch(e){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function vr(e,t){return t==="topdown"||t==="isometric"?t:String(e.system?.properties.view??"topdown").toLowerCase()==="isometric"?"isometric":"topdown"}function jr(e,t){return{...$r(e),...t}}function $r(e){switch(e){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40}}}function Sr(e){switch(e){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function kr(e,t,r){let{object:n,x:o,y:i,radius:a,sortKey:s,anchorX:u,anchorY:l}=e;return{renderId:ye(n.id),objectId:n.id,object:n,parentId:r.parentIds.get(n.id)??null,ancestorIds:r.ancestorIds.get(n.id)??[],childIds:r.childIds.get(n.id)??[],groupId:r.groupIds.get(n.id)??null,x:o,y:i,radius:a,visualRadius:sn(n,a,t),sortKey:s,anchorX:u,anchorY:l,label:n.id,secondaryLabel:n.type==="structure"?String(n.properties.kind??n.type):n.type,fillColor:un(n.properties.color),imageHref:typeof n.properties.image=="string"&&n.properties.image.trim()?n.properties.image:void 0,hidden:n.properties.hidden===!0}}function Or(e,t){return{renderId:`${ye(e.object.id)}-orbit`,objectId:e.object.id,object:e.object,parentId:e.parentId,groupId:t,kind:e.kind,cx:e.cx,cy:e.cy,radius:e.radius,rx:e.rx,ry:e.ry,rotationDeg:e.rotationDeg,band:e.band,bandThickness:e.bandThickness,frontArcPath:e.frontArcPath,backArcPath:e.backArcPath,hidden:e.object.properties.hidden===!0}}function Tr(e){return{renderId:`${ye(e.object.id)}-leader-${e.mode}`,objectId:e.object.id,object:e.object,groupId:e.groupId,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,mode:e.mode,hidden:e.object.properties.hidden===!0}}function Mr(e,t,r){let n=[],o=[],i=[...e].filter(a=>!a.hidden).sort((a,s)=>a.sortKey-s.sortKey);for(let a of i){let s=a.y>t*.62?-1:1,u=dn(a,r),l=a.y+s*(a.radius+18*r),c=l+s*(16*r),f=Je(a.x,l,c,u,s),p=0;for(;o.some(h=>on(h,f))&&p<10;)l+=s*14*r,c+=s*14*r,f=Je(a.x,l,c,u,s),p+=1;o.push(f),n.push({renderId:`${a.renderId}-label`,objectId:a.objectId,object:a.object,groupId:a.groupId,label:a.label,secondaryLabel:a.secondaryLabel,x:a.x,y:l,secondaryY:c,textAnchor:"middle",direction:s<0?"above":"below",hidden:a.hidden})}return n}function Ar(e,t,r,n){let o=e.filter(a=>!a.hidden&&!!a.backArcPath).map(a=>a.renderId),i=e.filter(a=>!a.hidden).map(a=>a.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:t.filter(a=>!a.hidden).map(a=>a.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:i},{id:"objects",renderIds:r.filter(a=>!a.hidden).map(a=>a.renderId)},{id:"labels",renderIds:n.filter(a=>!a.hidden).map(a=>a.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function Dr(e,t,r,n,o){let i=new Map,a=s=>{if(!s)return null;let u=i.get(s);if(u)return u;let l=o.groupRoots.get(s)??null,c={renderId:s,rootObjectId:l,label:l??s,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:J(0,0,0,0)};return i.set(s,c),c};for(let s of e){let u=a(s.groupId);u&&!s.hidden&&u.objectIds.push(s.objectId)}for(let s of t){let u=a(s.groupId);u&&!s.hidden&&u.orbitIds.push(s.objectId)}for(let s of r){let u=a(s.groupId);u&&!s.hidden&&u.leaderIds.push(s.objectId)}for(let s of n){let u=a(s.groupId);u&&!s.hidden&&u.labelIds.push(s.objectId)}for(let s of i.values())s.contentBounds=rn(s,e,t,r,n);return[...i.values()].sort((s,u)=>s.label.localeCompare(u.label))}function Lr(e,t,r,n,o){let i=Vr(e,t,r),a=new Map;for(let[l,c]of Object.entries(e.system?.info??{})){if(!l.startsWith("viewpoint."))continue;let[f,p,...h]=l.split(".");if(f!=="viewpoint"||!p||h.length===0)continue;let g=_r(p);if(!g)continue;let w=h.join(".").toLowerCase(),m=a.get(g)??{id:g};Er(m,w,c,t,r,n,o),a.set(g,m)}let s=[...a.values()].map(l=>Fr(l,t,r,o)).filter(Boolean),u=s.findIndex(l=>l.id===i.id);return u>=0?s.splice(u,1,{...i,...s[u],layers:{...i.layers,...s[u].layers},filter:s[u].filter??i.filter,generated:!1}):s.unshift(i),s.sort((l,c)=>l.id==="overview"?-1:c.id==="overview"?1:l.label.localeCompare(c.label))}function Vr(e,t,r){return{id:"overview",label:e.system?.properties.title?`${String(e.system.properties.title)} Overview`:"Overview",summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,projection:t,preset:r,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function Er(e,t,r,n,o,i,a){let s=r.trim();switch(t){case"label":case"title":s&&(e.label=s);return;case"summary":case"description":s&&(e.summary=s);return;case"focus":case"object":s&&(e.focus=s);return;case"select":case"selection":s&&(e.select=s);return;case"projection":case"view":e.projection=Pr(s)??n;return;case"preset":e.preset=Br(s)??o;return;case"rotation":case"angle":e.rotationDeg=ot(s)??e.rotationDeg??0;return;case"zoom":case"scale":e.scale=Rr(s);return;case"layers":e.layers=zr(s);return;case"query":e.filter={...e.filter??de(),query:s||null};return;case"types":case"objecttypes":e.filter={...e.filter??de(),objectTypes:Nr(s)};return;case"tags":e.filter={...e.filter??de(),tags:ge(s)};return;case"groups":e.filter={...e.filter??de(),groupIds:Wr(s,i,a)};return}}function Fr(e,t,r,n){let o=e.focus&&n.has(e.focus)?e.focus:null,i=e.select&&n.has(e.select)?e.select:o,a=Cr(e.filter),s=e.label?.trim()||Yr(e.id);return{id:e.id,label:s,summary:e.summary?.trim()||Ur(s,o,a),objectId:o,selectedObjectId:i,projection:e.projection??t,preset:e.preset??r,rotationDeg:e.rotationDeg??0,scale:e.scale??null,layers:e.layers??{},filter:a,generated:!1}}function de(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Cr(e){if(!e)return null;let t={query:e.query?.trim()||null,objectTypes:[...new Set(e.objectTypes)],tags:[...new Set(e.tags)],groupIds:[...new Set(e.groupIds)]};return t.query||t.objectTypes.length>0||t.tags.length>0||t.groupIds.length>0?t:null}function Pr(e){return e.toLowerCase()==="isometric"?"isometric":e.toLowerCase()==="topdown"?"topdown":null}function Br(e){let t=e.toLowerCase();return t==="diagram"||t==="presentation"||t==="atlas-card"||t==="markdown"?t:null}function ot(e){let t=Number(e);return Number.isFinite(t)?t:null}function Rr(e){let t=ot(e);return t!==null&&t>0?t:null}function zr(e){let t={};for(let r of ge(e)){let n=!r.startsWith("-")&&!r.startsWith("!"),o=r.replace(/^[-!]+/,"").toLowerCase();if(o==="orbits"){t["orbits-back"]=n,t["orbits-front"]=n;continue}(o==="background"||o==="guides"||o==="orbits-back"||o==="orbits-front"||o==="objects"||o==="labels"||o==="metadata")&&(t[o]=n)}return t}function Nr(e){return ge(e).filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Wr(e,t,r){return ge(e).map(n=>n.startsWith("wo-")&&n.endsWith("-group")?n:t.groupIds.has(n)?t.groupIds.get(n)??K(n):(r.has(n),K(n)))}function ge(e){return e.split(/[\s,]+/).map(t=>t.trim()).filter(Boolean)}function _r(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Yr(e){return e.split(/[-_]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" ")}function Ur(e,t,r){let n=[e];return t&&n.push(`focus ${t}`),r?.objectTypes.length&&n.push(r.objectTypes.join("/")),r?.tags.length&&n.push(`tags ${r.tags.join(", ")}`),r?.query&&n.push(`query "${r.query}"`),n.join(" - ")}function qr(e,t,r,n,o,i){let a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,c=(f,p)=>{a=Math.min(a,f),s=Math.min(s,p),u=Math.max(u,f),l=Math.max(l,p)};for(let f of n)f.hidden||it(f,c);for(let f of o)f.hidden||(c(f.x1,f.y1),c(f.x2,f.y2));for(let f of r)f.hidden||at(f,c);for(let f of i)f.hidden||st(f,c);return!Number.isFinite(a)||!Number.isFinite(s)?J(0,0,e,t):J(a,s,u,l)}function it(e,t){let r=e.bandThickness!==void 0?e.bandThickness/2+4:e.band?10:3;if(e.kind==="circle"&&e.radius!==void 0){t(e.cx-e.radius-r,e.cy-e.radius-r),t(e.cx+e.radius+r,e.cy+e.radius+r);return}let n=e.rx??e.radius??0,o=e.ry??e.radius??0,i=ct(e.cx,e.cy,n,o,e.rotationDeg,0,Math.PI*2,nt*2);for(let a of i)t(a.x-r,a.y-r),t(a.x+r,a.y+r)}function J(e,t,r,n){return{minX:e,minY:t,maxX:r,maxY:n,width:r-e,height:n-t,centerX:e+(r-e)/2,centerY:t+(n-t)/2}}function at(e,t){t(e.x-e.visualRadius-24,e.y-e.visualRadius-16),t(e.x+e.visualRadius+24,e.y+e.visualRadius+36)}function st(e,t){let n=fn(e.label,e.secondaryLabel,1);t(e.x-n,e.y-18),t(e.x+n,e.y+8),t(e.x-n,e.secondaryY-14),t(e.x+n,e.secondaryY+8)}function Te(e,t,r,n,o,i,a,s){o.has(e.id)||(o.set(e.id,{object:e,x:t,y:r,radius:me(e,n,s.scaleModel),sortKey:be(t,r,n)}),fe(e,o,i,a,s,n+1))}function fe(e,t,r,n,o,i){let a=t.get(e.id);if(!a)return;let s=[...o.orbitChildren.get(e.id)??[]].sort(Xr),u=Hr(s,a.radius,o.spacingFactor,o.scaleModel);s.forEach((c,f)=>{let p=Gr(c,f,s.length,a,u,o);r.push({object:c,parentId:e.id,kind:p.kind,cx:p.cx,cy:p.cy,radius:p.radius,rx:p.rx,ry:p.ry,rotationDeg:p.rotationDeg,band:p.band,bandThickness:p.bandThickness,frontArcPath:p.frontArcPath,backArcPath:p.backArcPath}),Te(c,p.objectX,p.objectY,i,t,r,n,o)});let l=[...o.surfaceChildren.get(e.id)??[]];l.forEach((c,f)=>{let p=Z(f,l.length,-Math.PI/3),h=28*o.spacingFactor,g=Q(p,a.radius,o.projection,o.projection==="isometric"?.9:1),w=Q(p,a.radius+h,o.projection,o.projection==="isometric"?.9:1),m=a.x+g.x,x=a.y+g.y,j=a.x+w.x,S=a.y+w.y;t.set(c.id,{object:c,x:j,y:S,radius:me(c,i+1,o.scaleModel),sortKey:be(j,S,i+1),anchorX:m,anchorY:x}),n.push({object:c,groupId:o.objectMap.has(c.id)?K(nn(c,o.objectMap)):null,x1:m,y1:x,x2:j,y2:S,mode:"surface"}),fe(c,t,r,n,o,i+1)})}function Xr(e,t){let r=pe(e),n=pe(t);return r!==null&&n!==null&&r!==n?r-n:r!==null&&n===null?-1:r===null&&n!==null?1:e.id.localeCompare(t.id)}function Hr(e,t,r,n){let o=e.map(f=>pe(f)),i=o.filter(f=>f!==null),a=t+56*r*n.orbitDistanceMultiplier,s=(e.length>2?54:64)*r*n.orbitDistanceMultiplier;if(i.length===0)return{metrics:o,minMetric:0,maxMetric:0,metricSpread:0,innerPx:a,stepPx:s,pixelSpread:Math.max(s*Math.max(e.length-1,1),s)};let u=Math.min(...i),l=Math.max(...i),c=l-u;return{metrics:o,minMetric:u,maxMetric:l,metricSpread:c,innerPx:a,stepPx:s,pixelSpread:Math.max(s*Math.max(e.length-1,1),s)}}function Gr(e,t,r,n,o,i){let a=e.placement,s=e.type==="belt"||e.type==="ring";if(!a||a.mode!=="orbit"){let D=o.innerPx+t*o.stepPx;return{kind:"circle",cx:n.x,cy:n.y,radius:D,rotationDeg:0,band:s,bandThickness:s?12*i.scaleModel.ringThicknessMultiplier:void 0,objectX:n.x,objectY:n.y-D}}let u=v(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),l=Kr(e,t,o),c=Math.max(l*Math.sqrt(1-u*u),l*.18),f=Ae(a.inclination)??0,p=i.projection==="isometric"?Math.max(yr,Math.cos(De(f)))*rt:1,h=Math.max(c*p,l*.14),g=Ae(a.angle)??0,w=l*u,m=dt(-w,0,g),x=n.x+m.x,j=n.y+m.y,S=Jr(a.phase,t,r),Y=ut(x,j,l,h,g,S),A=i.projection==="topdown"&&u<=1e-4&&Math.abs(g)<=1e-4,re=s?Zr(e,l,o,i.scaleModel):void 0;return{kind:A?"circle":"ellipse",cx:A?n.x:x,cy:A?n.y:j,radius:A?l:void 0,rx:A?void 0:l,ry:A?void 0:h,rotationDeg:g,band:s,bandThickness:re,frontArcPath:i.projection==="isometric"||s?Ze(x,j,l,h,g,0,Math.PI):void 0,backArcPath:i.projection==="isometric"||s?Ze(x,j,l,h,g,Math.PI,Math.PI*2):void 0,objectX:Y.x,objectY:Y.y}}function Kr(e,t,r){let n=pe(e);return n===null?r.innerPx+t*r.stepPx:r.metricSpread>0?r.innerPx+(n-r.minMetric)/r.metricSpread*r.pixelSpread:r.innerPx+Math.log10(n+1)*r.stepPx}function pe(e){return!e.placement||e.placement.mode!=="orbit"?null:he(e.placement.semiMajor??e.placement.distance??null)}function Jr(e,t,r){let n=e?Ae(e):null;return n!==null?De(n-90):Z(t,r,-Math.PI/2)}function Zr(e,t,r,n){let o=he(Me(e.properties.inner)),i=he(Me(e.properties.outer));if(o!==null&&i!==null){let s=Math.abs(i-o);if(r.metricSpread>0)return v(s/r.metricSpread*r.pixelSpread*n.ringThicknessMultiplier,8,54);let u=Math.max(Math.max(o,i),1e-4);return v(s/u*t*.75*n.ringThicknessMultiplier,8,48)}return(e.type==="belt"?18:12)*n.ringThicknessMultiplier}function Qr(e,t,r,n,o,i,a,s,u){if(e.kind==="lagrange")return en(e,t,r,i,a);if(e.kind==="anchor"){let l=t.get(e.objectId);if(l){let c=Z(n,o,Math.PI/5),f=(l.radius+36)*u.scaleModel.labelMultiplier,p=Q(c,f,u.projection,u.projection==="isometric"?.92:1);return{x:l.x+p.x,y:l.y+p.y,anchorX:l.x,anchorY:l.y}}}if(e.kind==="named"){let l=t.get(e.name);if(l){let c=Z(n,o,Math.PI/6),f=(l.radius+36)*u.scaleModel.labelMultiplier,p=Q(c,f,u.projection,u.projection==="isometric"?.92:1);return{x:l.x+p.x,y:l.y+p.y,anchorX:l.x,anchorY:l.y}}}return{x:i-s-170,y:a-s-86-n*58*u.scaleModel.freePlacementMultiplier}}function en(e,t,r,n,o){let i=e.secondary?t.get(e.primary):an(e.primary,t,r),a=t.get(e.secondary??e.primary);if(!i||!a)return{x:n*.7,y:o*.25};let s=a.x-i.x,u=a.y-i.y,l=Math.hypot(s,u)||1,c=s/l,f=u/l,p=-f,h=c,g=v(l*.25,24,68);switch(e.point){case"L1":return{x:a.x-c*g,y:a.y-f*g,anchorX:a.x,anchorY:a.y};case"L2":return{x:a.x+c*g,y:a.y+f*g,anchorX:a.x,anchorY:a.y};case"L3":return{x:i.x-c*g,y:i.y-f*g,anchorX:i.x,anchorY:i.y};case"L4":return{x:a.x+(c*.5-p*.8660254)*g,y:a.y+(f*.5-h*.8660254)*g,anchorX:a.x,anchorY:a.y};case"L5":return{x:a.x+(c*.5+p*.8660254)*g,y:a.y+(f*.5+h*.8660254)*g,anchorX:a.x,anchorY:a.y}}}function tn(e,t){let r=new Map,n=new Map;for(let l of e){let c=lt(l,t);if(r.set(l.id,c),c){let f=n.get(c);f?f.push(l.id):n.set(c,[l.id])}n.has(l.id)||n.set(l.id,[])}let o=new Map,i=new Map,a=new Map,s=l=>{let c=o.get(l);if(c)return c;let f=new Set,p=[],h=r.get(l)??null;for(;h&&!f.has(h);)p.push(h),f.add(h),h=r.get(h)??null;return o.set(l,p),p},u=l=>{let c=a.get(i.get(l)??"");if(c)return c;let f=r.get(l)??null,p=t.get(l),h=l;return p?.placement&&p.placement.mode!=="free"&&f&&(h=u(f)),h};for(let l of e){s(l.id);let c=u(l.id),f=K(c);i.set(l.id,f),a.set(f,c)}return{parentIds:r,childIds:n,ancestorIds:o,groupIds:i,groupRoots:a}}function lt(e,t){let r=e.placement;if(!r)return null;switch(r.mode){case"orbit":case"surface":return t.has(r.target)?r.target:null;case"at":switch(r.reference.kind){case"anchor":return t.has(r.reference.objectId)?r.reference.objectId:null;case"named":return t.has(r.reference.name)?r.reference.name:null;case"lagrange":return r.reference.secondary&&t.has(r.reference.secondary)?r.reference.secondary:t.has(r.reference.primary)?r.reference.primary:null}case"free":return null}}function rn(e,t,r,n,o){let i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,l=(c,f)=>{i=Math.min(i,c),a=Math.min(a,f),s=Math.max(s,c),u=Math.max(u,f)};for(let c of t)!c.hidden&&e.objectIds.includes(c.objectId)&&at(c,l);for(let c of r)!c.hidden&&e.orbitIds.includes(c.objectId)&&it(c,l);for(let c of n)!c.hidden&&e.leaderIds.includes(c.objectId)&&(l(c.x1,c.y1),l(c.x2,c.y2));for(let c of o)!c.hidden&&e.labelIds.includes(c.objectId)&&st(c,l);return!Number.isFinite(i)||!Number.isFinite(a)?J(0,0,0,0):J(i,a,s,u)}function nn(e,t){let r=e,n=new Set;for(;r.placement&&r.placement.mode!=="free"&&!n.has(r.id);){n.add(r.id);let o=lt(r,t);if(!o)break;let i=t.get(o);if(!i)break;r=i}return r.id}function Je(e,t,r,n,o){return{left:e-n,right:e+n,top:Math.min(t,r)-(o<0?18:12),bottom:Math.max(t,r)+(o<0?8:12)}}function on(e,t){return!(e.right<t.left||t.right<e.left||e.bottom<t.top||t.bottom<e.top)}function an(e,t,r){let n=r.get(e);return!n?.placement||n.placement.mode!=="orbit"?t.get(e):t.get(n.placement.target)}function me(e,t,r){let n=cn(e.properties.radius,r);if(n!==null)return n;let o=r.bodyRadiusMultiplier;switch(e.type){case"star":return v((t===0?28:20)*o,r.minBodyRadius,r.maxBodyRadius);case"planet":return v(12*o,r.minBodyRadius,r.maxBodyRadius);case"moon":return v(7*o,r.minBodyRadius,r.maxBodyRadius);case"belt":return v(5*o,r.minBodyRadius,r.maxBodyRadius);case"asteroid":return v(5*o,r.minBodyRadius,r.maxBodyRadius);case"comet":return v(6*o,r.minBodyRadius,r.maxBodyRadius);case"ring":return v(5*o,r.minBodyRadius,r.maxBodyRadius);case"structure":return v(6*o,r.minBodyRadius,r.maxBodyRadius);case"phenomenon":return v(8*o,r.minBodyRadius,r.maxBodyRadius)}}function sn(e,t,r){let n=typeof e.properties.atmosphere=="string"?4:0;switch(e.type){case"star":return t*2.4;case"phenomenon":return t*1.25;case"structure":return t+2;default:return Math.min(t+n,r.maxBodyRadius+10)}}function he(e){if(!e)return null;switch(e.unit){case"au":return e.value;case"km":return e.value/G;case"m":return e.value/1e3/G;case"ly":return e.value*hr;case"pc":return e.value*br;case"kpc":return e.value*gr;case"re":return e.value*fr/G;case"rj":return e.value*pr/G;case"sol":return e.value*mr/G;default:return e.value}}function ln(e,t){let r=he(e??null);return r===null||r<=0?0:v(r*96*t.freePlacementMultiplier,0,420)}function cn(e,t){let r=Me(e);if(!r)return null;let n;switch(r.unit){case"sol":n=v(r.value*22,14,40);break;case"re":n=v(r.value*10,6,18);break;case"km":n=v(Math.log10(Math.max(r.value,1))*2.6,4,16);break;default:n=v(r.value*4,4,20);break}return v(n*t.bodyRadiusMultiplier,t.minBodyRadius,t.maxBodyRadius)}function Me(e){return!e||typeof e!="object"||!("value"in e)?null:e}function Ae(e){return e&&(e.unit==="deg"||e.unit===null)?e.value:null}function Z(e,t,r){return t<=1?r:r+e*Math.PI*2/t}function Ze(e,t,r,n,o,i,a){let s=ct(e,t,r,n,o,i,a,nt);return s.length===0?"":s.map((u,l)=>`${l===0?"M":"L"} ${tt(u.x)} ${tt(u.y)}`).join(" ")}function ct(e,t,r,n,o,i,a,s){let u=[];for(let l=0;l<=s;l+=1){let c=i+(a-i)*l/s;u.push(ut(e,t,r,n,o,c))}return u}function ut(e,t,r,n,o,i){let a=r*Math.cos(i),s=n*Math.sin(i),u=dt(a,s,o);return{x:e+u.x,y:t+u.y}}function dt(e,t,r){let n=De(r);return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}}function Q(e,t,r,n){let o=r==="isometric"?rt*n:n;return{x:Math.cos(e)*t,y:Math.sin(e)*t*o}}function be(e,t,r){return t*1e3+e+r*.01}function v(e,t,r){return Math.min(Math.max(e,t),r)}function Qe(e,t,r){let n=e.get(t);n?n.push(r):e.set(t,[r])}function ye(e){return`wo-${e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function K(e){return`${ye(e)}-group`}function un(e){return typeof e=="string"&&e.trim()?e:void 0}function dn(e,t){let r=e.label.length*4.6*t+18,n=e.secondaryLabel.length*3.9*t+18;return Math.max(r,n,e.visualRadius+18)}function fn(e,t,r){let n=e.length*4.6*r+18,o=t.length*3.9*r+18;return Math.max(n,o,24)}function et(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}function De(e){return e*Math.PI/180}function tt(e){return Number.isInteger(e)?String(e):e.toFixed(2)}function we(e){return{format:"worldorbit",version:"1.0",system:e.system?{type:"system",id:e.system.id,properties:hn(e.system),info:bn(e.system)}:null,objects:e.objects.map(pn)}}function pn(e){return{...e,properties:mn(e.properties),placement:e.placement?structuredClone(e.placement):null,info:{...e.info}}}function mn(e){let t={};for(let[r,n]of Object.entries(e)){if(Array.isArray(n)){t[r]=[...n];continue}if(n&&typeof n=="object"&&"value"in n){t[r]={value:n.value,unit:n.unit};continue}t[r]=n}return t}function hn(e){let t={};return e.title&&(t.title=e.title),t.view=e.defaults.view,e.defaults.scale&&(t.scale=e.defaults.scale),e.defaults.units&&(t.units=e.defaults.units),t}function bn(e){let t={...e.atlasMetadata};e.defaults.theme&&(t["atlas.theme"]=e.defaults.theme);for(let r of e.viewpoints){let n=`viewpoint.${r.id}`;t[`${n}.label`]=r.label,r.summary&&(t[`${n}.summary`]=r.summary),r.focusObjectId&&(t[`${n}.focus`]=r.focusObjectId),r.selectedObjectId&&(t[`${n}.select`]=r.selectedObjectId),r.projection&&(t[`${n}.projection`]=r.projection),r.preset&&(t[`${n}.preset`]=r.preset),r.zoom!==null&&(t[`${n}.zoom`]=String(r.zoom)),r.rotationDeg!==0&&(t[`${n}.rotation`]=String(r.rotationDeg));let o=gn(r.layers);o&&(t[`${n}.layers`]=o),r.filter?.query&&(t[`${n}.query`]=r.filter.query),(r.filter?.objectTypes.length??0)>0&&(t[`${n}.types`]=r.filter?.objectTypes.join(" ")??""),(r.filter?.tags.length??0)>0&&(t[`${n}.tags`]=r.filter?.tags.join(" ")??""),(r.filter?.groupIds.length??0)>0&&(t[`${n}.groups`]=r.filter?.groupIds.join(" ")??"")}for(let r of e.annotations){let n=`annotation.${r.id}`;t[`${n}.label`]=r.label,r.targetObjectId&&(t[`${n}.target`]=r.targetObjectId),t[`${n}.body`]=r.body,r.tags.length>0&&(t[`${n}.tags`]=r.tags.join(" ")),r.sourceObjectId&&(t[`${n}.source`]=r.sourceObjectId)}return t}function gn(e){let t=[],r=e["orbits-front"],n=e["orbits-back"];(r!==void 0||n!==void 0)&&t.push(r!==!1||n!==!1?"orbits":"-orbits");for(let o of["background","guides","objects","labels","metadata"])e[o]!==void 0&&t.push(e[o]?o:`-${o}`);return t.join(" ")}function Ve(e){return xn(e,"2.0")}function xn(e,t){let r=e.split(/\r?\n/),n=!1,o="2.0",i=null,a=null,s=[],u=!1,l=!1,c=new Set,f=new Set;for(let w=0;w<r.length;w++){let m=r[w],x=w+1;if(!m.trim())continue;let j=le(m),S=X(m.slice(j),{line:x,columnOffset:j});if(S.length!==0){if(!n){o=In(S,x),n=!0;continue}if(j===0){a=vn(S,x,i,s,c,f,{sawDefaults:u,sawAtlas:l}),a.kind==="system"?i=a.system:a.kind==="defaults"?u=!0:a.kind==="atlas"&&(l=!0);continue}if(!a)throw new d("Indented line without parent atlas section",x,j+1);On(a,j,S,x)}}if(!n)throw new d('Missing required atlas schema header "schema 2.0"');let h=B({type:"document",objects:s}).objects;return V({format:"worldorbit",version:"1.0",system:null,objects:h}),{format:"worldorbit",version:t,sourceVersion:"1.0",system:i,objects:h,diagnostics:o==="2.0-draft"&&t==="2.0"?[{code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}]:[]}}function In(e,t){if(e.length!==2||e[0].value.toLowerCase()!=="schema"||e[1].value.toLowerCase()!=="2.0-draft"&&e[1].value.toLowerCase()!=="2.0")throw new d('Expected atlas header "schema 2.0" or legacy "schema 2.0-draft"',t,e[0]?.column??1);return e[1].value.toLowerCase()==="2.0-draft"?"2.0-draft":"2.0"}function vn(e,t,r,n,o,i,a){switch(e[0]?.value.toLowerCase()){case"system":if(r)throw new d('Atlas section "system" may only appear once',t,e[0].column);return jn(e,t);case"defaults":if(!r)throw new d('Atlas section "defaults" requires a preceding system declaration',t,e[0].column);if(a.sawDefaults)throw new d('Atlas section "defaults" may only appear once',t,e[0].column);return{kind:"defaults",system:r,seenFields:new Set};case"atlas":if(!r)throw new d('Atlas section "atlas" requires a preceding system declaration',t,e[0].column);if(a.sawAtlas)throw new d('Atlas section "atlas" may only appear once',t,e[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new d('Atlas section "viewpoint" requires a preceding system declaration',t,e[0].column);return $n(e,t,r,o);case"annotation":if(!r)throw new d('Atlas section "annotation" requires a preceding system declaration',t,e[0].column);return Sn(e,t,r,i);case"object":return kn(e,t,n);default:throw new d(`Unknown atlas section "${e[0]?.value??""}"`,t,e[0]?.column??1)}}function jn(e,t){if(e.length!==2)throw new d("Invalid atlas system declaration",t,e[0]?.column??1);return{kind:"system",system:{type:"system",id:e[1].value,title:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},seenFields:new Set}}function $n(e,t,r,n){if(e.length!==2)throw new d("Invalid viewpoint declaration",t,e[0]?.column??1);let o=mt(e[1].value);if(!o)throw new d("Viewpoint id must not be empty",t,e[1].column);if(n.has(o))throw new d(`Duplicate viewpoint id "${o}"`,t,e[1].column);let i={id:o,label:ht(o),summary:"",focusObjectId:null,selectedObjectId:null,projection:r.defaults.view,preset:r.defaults.preset,zoom:null,rotationDeg:0,layers:{},filter:null};return r.viewpoints.push(i),n.add(o),{kind:"viewpoint",viewpoint:i,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set}}function Sn(e,t,r,n){if(e.length!==2)throw new d("Invalid annotation declaration",t,e[0]?.column??1);let o=mt(e[1].value);if(!o)throw new d("Annotation id must not be empty",t,e[1].column);if(n.has(o))throw new d(`Duplicate annotation id "${o}"`,t,e[1].column);let i={id:o,label:ht(o),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return r.annotations.push(i),n.add(o),{kind:"annotation",annotation:i,seenFields:new Set}}function kn(e,t,r){if(e.length<3)throw new d("Invalid atlas object declaration",t,e[0]?.column??1);let n=e[1],o=e[2],i=n.value;if(!ae.has(i)||i==="system")throw new d(`Unknown object type "${n.value}"`,t,n.column);let a={type:"object",objectType:i,name:o.value,inlineFields:zn(e.slice(3),t),blockFields:[],infoEntries:[],location:{line:t,column:n.column}};return r.push(a),{kind:"object",objectNode:a,inInfoBlock:!1,infoIndent:null}}function On(e,t,r,n){switch(e.kind){case"system":Tn(e,r,n);return;case"defaults":Mn(e,r,n);return;case"atlas":An(e,t,r,n);return;case"viewpoint":Dn(e,t,r,n);return;case"annotation":Vn(e,r,n);return;case"object":En(e,t,r,n);return}}function Tn(e,t,r){if(ee(t,e.seenFields,r)!=="title")throw new d(`Unknown system atlas field "${t[0].value}"`,r,t[0].column);e.system.title=C(t,r)}function Mn(e,t,r){let n=ee(t,e.seenFields,r),o=C(t,r);switch(n){case"view":e.system.defaults.view=ft(o,r,t[0].column);return;case"scale":e.system.defaults.scale=o;return;case"units":e.system.defaults.units=o;return;case"preset":e.system.defaults.preset=pt(o,r,t[0].column);return;case"theme":e.system.defaults.theme=o;return;default:throw new d(`Unknown defaults field "${t[0].value}"`,r,t[0].column)}}function An(e,t,r,n){if(e.inMetadata&&t<=(e.metadataIndent??0)&&(e.inMetadata=!1,e.metadataIndent=null),e.inMetadata){if(r.length<2)throw new d("Invalid atlas metadata entry",n,r[0]?.column??1);let o=r[0].value;if(o in e.system.atlasMetadata)throw new d(`Duplicate atlas metadata key "${o}"`,n,r[0].column);e.system.atlasMetadata[o]=C(r,n);return}if(r.length===1&&r[0].value.toLowerCase()==="metadata"){e.inMetadata=!0,e.metadataIndent=t;return}throw new d(`Unknown atlas field "${r[0].value}"`,n,r[0].column)}function Dn(e,t,r,n){if(e.inFilter&&t<=(e.filterIndent??0)&&(e.inFilter=!1,e.filterIndent=null),e.inFilter){Ln(e,r,n);return}if(r.length===1&&r[0].value.toLowerCase()==="filter"){if(e.seenFields.has("filter"))throw new d('Duplicate viewpoint field "filter"',n,r[0].column);e.seenFields.add("filter"),e.inFilter=!0,e.filterIndent=t;return}let o=ee(r,e.seenFields,n),i=C(r,n);switch(o){case"label":e.viewpoint.label=i;return;case"summary":e.viewpoint.summary=i;return;case"focus":e.viewpoint.focusObjectId=i;return;case"select":e.viewpoint.selectedObjectId=i;return;case"projection":e.viewpoint.projection=ft(i,n,r[0].column);return;case"preset":e.viewpoint.preset=pt(i,n,r[0].column);return;case"zoom":e.viewpoint.zoom=Pn(i,n,r[0].column,"zoom");return;case"rotation":e.viewpoint.rotationDeg=Bn(i,n,r[0].column,"rotation");return;case"layers":e.viewpoint.layers=Cn(r.slice(1),n);return;default:throw new d(`Unknown viewpoint field "${r[0].value}"`,n,r[0].column)}}function Ln(e,t,r){let n=ee(t,e.seenFilterFields,r),o=e.viewpoint.filter??Rn();switch(n){case"query":o.query=C(t,r);break;case"objecttypes":o.objectTypes=Fn(t.slice(1),r);break;case"tags":o.tags=Le(t.slice(1),r,"tags");break;case"groups":o.groupIds=Le(t.slice(1),r,"groups");break;default:throw new d(`Unknown viewpoint filter field "${t[0].value}"`,r,t[0].column)}e.viewpoint.filter=o}function Vn(e,t,r){switch(ee(t,e.seenFields,r)){case"label":e.annotation.label=C(t,r);return;case"target":e.annotation.targetObjectId=C(t,r);return;case"body":e.annotation.body=C(t,r);return;case"tags":e.annotation.tags=Le(t.slice(1),r,"tags");return;default:throw new d(`Unknown annotation field "${t[0].value}"`,r,t[0].column)}}function En(e,t,r,n){if(r.length===1&&r[0].value==="info"){e.inInfoBlock=!0,e.infoIndent=t;return}if(e.inInfoBlock&&t<=(e.infoIndent??0)&&(e.inInfoBlock=!1,e.infoIndent=null),e.inInfoBlock){e.objectNode.infoEntries.push(Wn(r,n));return}e.objectNode.blockFields.push(Nn(r,n))}function ee(e,t,r){if(e.length<2)throw new d("Invalid atlas field line",r,e[0]?.column??1);let n=e[0].value.toLowerCase();if(t.has(n))throw new d(`Duplicate atlas field "${e[0].value}"`,r,e[0].column);return t.add(n),n}function C(e,t){if(e.length<2)throw new d("Missing value for atlas field",t,e[0]?.column??1);return e.slice(1).map(r=>r.value).join(" ").trim()}function Fn(e,t){if(e.length===0)throw new d("Missing value for atlas field",t);return e.map(r=>{let n=r.value;if(n!=="star"&&n!=="planet"&&n!=="moon"&&n!=="belt"&&n!=="asteroid"&&n!=="comet"&&n!=="ring"&&n!=="structure"&&n!=="phenomenon")throw new d(`Unknown viewpoint object type "${r.value}"`,t,r.column);return n})}function Le(e,t,r){if(e.length===0)throw new d(`Missing value for field "${r}"`,t);return e.map(n=>n.value)}function Cn(e,t){if(e.length===0)throw new d('Missing value for field "layers"',t);let r={};for(let n of e){let o=!n.value.startsWith("-")&&!n.value.startsWith("!"),i=n.value.replace(/^[-!]+/,"").toLowerCase();if(i==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}if(i==="background"||i==="guides"||i==="orbits-back"||i==="orbits-front"||i==="objects"||i==="labels"||i==="metadata"){r[i]=o;continue}throw new d(`Unknown layer token "${n.value}"`,t,n.column)}return r}function ft(e,t,r){let n=e.toLowerCase();if(n==="topdown"||n==="isometric")return n;throw new d(`Unknown projection "${e}"`,t,r)}function pt(e,t,r){let n=e.toLowerCase();if(n==="diagram"||n==="presentation"||n==="atlas-card"||n==="markdown")return n;throw new d(`Unknown render preset "${e}"`,t,r)}function Pn(e,t,r,n){let o=Number(e);if(!Number.isFinite(o)||o<=0)throw new d(`Field "${n}" expects a positive number`,t,r);return o}function Bn(e,t,r,n){let o=Number(e);if(!Number.isFinite(o))throw new d(`Field "${n}" expects a finite number`,t,r);return o}function Rn(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function zn(e,t){let r=[],n=0;for(;n<e.length;){let o=e[n],i=T(o.value);if(!i)throw new d(`Unknown field "${o.value}"`,t,o.column);n++;let a=[];if(i.arity==="multiple")for(;n<e.length&&!se(e[n].value);)a.push(e[n]),n++;else{let s=e[n];s&&(a.push(s),n++)}if(a.length===0)throw new d(`Missing value for field "${o.value}"`,t,o.column);r.push({type:"field",key:o.value,values:a.map(s=>s.value),location:{line:t,column:o.column}})}return r}function Nn(e,t){if(e.length<2)throw new d("Invalid field line",t,e[0]?.column??1);if(!T(e[0].value))throw new d(`Unknown field "${e[0].value}"`,t,e[0].column);return{type:"field",key:e[0].value,values:e.slice(1).map(r=>r.value),location:{line:t,column:e[0].column}}}function Wn(e,t){if(e.length<2)throw new d("Invalid info entry",t,e[0]?.column??1);return{type:"info-entry",key:e[0].value,value:e.slice(1).map(r=>r.value).join(" "),location:{line:t,column:e[0].column}}}function mt(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function ht(e){return e.split(/[-_]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" ")}var Yn=/^schema\s+2(?:\.0)?$/i,Un=/^schema\s+2\.0-draft$/i;function bt(e){for(let t of e.split(/\r?\n/)){let r=t.trim();if(r)return Un.test(r)?"2.0-draft":Yn.test(r)?"2.0":"1.0"}return"1.0"}function R(e){let t=gt(e);if(!t.ok||!t.value){let r=t.diagnostics[0];throw new d(r?.message??"Failed to load WorldOrbit source",r?.line,r?.column)}return t.value}function gt(e){let t=bt(e);if(t==="2.0"||t==="2.0-draft")return qn(e,t);let r;try{r=H(e)}catch(o){return{ok:!1,value:null,diagnostics:[E(o,"parse")]}}let n;try{n=B(r)}catch(o){return{ok:!1,value:null,diagnostics:[E(o,"normalize")]}}try{V(n)}catch(o){return{ok:!1,value:null,diagnostics:[E(o,"validate")]}}return{ok:!0,value:{schemaVersion:t,ast:r,document:n,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function qn(e,t){let r;try{r=Ve(e)}catch(i){return{ok:!1,value:null,diagnostics:[E(i,"parse","load.atlas.failed")]}}let n;try{n=we(r)}catch(i){return{ok:!1,value:null,diagnostics:[E(i,"normalize","load.atlas.materialize.failed")]}}try{V(n)}catch(i){return{ok:!1,value:null,diagnostics:[E(i,"validate","load.atlas.validate.failed")]}}return{ok:!0,value:{schemaVersion:t,ast:null,document:n,atlasDocument:r,draftDocument:r,diagnostics:[...r.diagnostics]},diagnostics:[...r.diagnostics]}}var Gn={background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},xe={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function Ee(e){return e?typeof e=="string"?xe[e]??xe.atlas:{...xe.atlas,...e}:xe.atlas}function Fe(e){return{...Gn,...e}}function Ie(e){if(!e)return null;let t={query:e.query?.trim()||void 0,objectTypes:Ce(e.objectTypes??[]),tags:Ce((e.tags??[]).map(r=>r.trim()).filter(Boolean)),groupIds:Ce((e.groupIds??[]).map(r=>r.trim()).filter(Boolean)),includeAncestors:e.includeAncestors??!0};return Kn(t)?t:null}function Kn(e){return!!(e&&(e.query?.trim()||e.objectTypes?.length||e.tags?.length||e.groupIds?.length))}function Pe(e,t){let r=Ie(t),n=new Set;for(let o of e.objects)if(!o.hidden&&Jn(o,r)&&(n.add(o.objectId),r?.includeAncestors!==!1))for(let i of o.ancestorIds)n.add(i);return r?n:new Set(e.objects.filter(o=>!o.hidden).map(o=>o.objectId))}function Jn(e,t){if(!t)return!0;if(t.objectTypes?.length&&!t.objectTypes.includes(e.object.type)||t.groupIds?.length&&(!e.groupId||!t.groupIds.includes(e.groupId)))return!1;if(t.tags?.length){let r=Array.isArray(e.object.properties.tags)?e.object.properties.tags.filter(n=>typeof n=="string"):[];if(!t.tags.every(n=>r.includes(n)))return!1}if(t.query?.trim()){let r=Zn(e.object,e.label).toLowerCase();if(!t.query.toLowerCase().split(/\s+/).filter(Boolean).every(o=>r.includes(o)))return!1}return!0}function Zn(e,t){let r=Object.values(e.info),n=Object.values(e.properties).flatMap(o=>Array.isArray(o)?o:typeof o=="object"&&o&&"value"in o?[String(o.value),String(o.unit??"")]:[String(o)]).filter(Boolean);return[e.id,t,e.type,...n,...r].join(" ")}function Ce(e){return[...new Set(e)]}var Be="worldorbit-camera-root";function z(e,t={}){let r=Ee(t.theme),n=mo(t.preset??e.renderPreset??void 0),o=Fe({...n.layers,...t.layers}),i=t.subtitle??e.subtitle,a=Pe(e,t.filter??null),s=e.objects.filter(m=>!m.hidden).filter(m=>a.has(m.objectId)).filter(m=>o.structures||!ve(m.object)).sort((m,x)=>m.sortKey-x.sortKey),u=e.labels.filter(m=>!m.hidden).filter(m=>a.has(m.objectId)).filter(m=>o.structures||!ve(m.object)),l=eo(s),c=o.orbits?Qn(e,a,o.structures):{back:"",front:""},f=o.guides?e.leaders.filter(m=>!m.hidden).filter(m=>a.has(m.objectId)).filter(m=>o.structures||!ve(m.object)).map(m=>`<line class="wo-leader wo-leader-${m.mode}" x1="${m.x1}" y1="${m.y1}" x2="${m.x2}" y2="${m.y2}" data-render-id="${$(m.renderId)}" data-group-id="${M(m.groupId??"")}" />`).join(""):"",p=o.objects?s.map(m=>to(m,t.selectedObjectId??null,r)).join(""):"",h=o.labels?u.map(m=>ro(e,m,t.selectedObjectId??null)).join(""):"",g=o.metadata?`<text class="wo-title" x="56" y="64">${$(e.title)}</text>
|
|
2
|
-
<text class="wo-subtitle" x="56" y="88">${
|
|
3
|
-
<text class="wo-meta" x="56" y="${e.height-42}">${
|
|
1
|
+
"use strict";var WorldOrbitMarkdown=(()=>{var Oe=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var Rt=(e,t)=>{for(var r in t)Oe(e,r,{get:t[r],enumerable:!0})},zt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pt(t))!Bt.call(e,o)&&o!==r&&Oe(e,o,{get:()=>t[o],enumerable:!(n=Ct(t,o))||n.enumerable});return e};var Nt=e=>zt(Oe({},"__esModule",{value:!0}),e);var Bo={};Rt(Bo,{rehypeWorldOrbit:()=>Mt,remarkWorldOrbit:()=>Ot,renderWorldOrbitBlock:()=>_,renderWorldOrbitError:()=>Ye});var d=class e extends Error{line;column;constructor(t,r,n){let o=r===void 0?"":` (line ${r}${n===void 0?"":`, column ${n}`})`;super(`${t}${o}`),this.name="WorldOrbitError",this.line=r,this.column=n}static fromLocation(t,r){return new e(t,r?.line,r?.column)}};var q=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],O=q.filter(e=>e!=="system"),Wt=["star","planet","moon","asteroid","comet","structure","phenomenon"],Ue=["structure","phenomenon"],L=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],_t=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function y(e,t){return{key:e,...t}}var ae=new Set(q),qe=new Map([y("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:L}),y("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"distance"}),y("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"distance"}),y("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:L}),y("period",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"duration"}),y("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"angle"}),y("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"angle"}),y("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:L,unitFamily:"angle"}),y("at",{kind:"string",placement:!0,arity:"single",objectTypes:Ue}),y("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Ue}),y("free",{kind:"string",placement:!0,arity:"single",objectTypes:_t}),y("kind",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("class",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("culture",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:q}),y("color",{kind:"string",placement:!1,arity:"single",objectTypes:q}),y("image",{kind:"string",placement:!1,arity:"single",objectTypes:Wt}),y("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:q}),y("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"radius"}),y("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"mass"}),y("density",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"generic"}),y("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"generic"}),y("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"generic"}),y("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:O}),y("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),y("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),y("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),y("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),y("on",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("source",{kind:"string",placement:!1,arity:"single",objectTypes:O}),y("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:O,unitFamily:"duration"})].map(e=>[e.key,e])),Yt=new Set(qe.keys());function T(e){return qe.get(e)}function se(e){return Yt.has(e)}function Xe(e,t){return e.objectTypes.includes(t)}function He(e,t){switch(e){case"distance":return t===null||["au","km","m","ly","pc","kpc","re","sol"].includes(t);case"radius":return t===null||["km","m","re","rj","sol"].includes(t);case"mass":return t===null||["me","mj","sol"].includes(t);case"duration":return t===null||["s","min","h","d","y","ky","my","gy"].includes(t);case"angle":return t===null||t==="deg";case"generic":return!0}}function X(e,t={}){let r=[],n=t.columnOffset??0,o="",i=null,a=!1,s=!1,l=null,c=()=>{i!==null&&(r.push({value:o,column:i,quoted:a}),o="",i=null,a=!1)};for(let u=0;u<e.length;u++){let f=e[u],p=n+u+1;if(s&&f==="\\"){let h=e[u+1];if(h==='"'||h==="\\"){o+=h,u++;continue}}if(f==='"'){s?s=!1:(i===null&&(i=p),a=!0,l=p,s=!0);continue}if(!s&&/\s/.test(f)){c();continue}i===null&&(i=p),o+=f}if(s)throw new d("Unclosed quote in line",t.line,l??n+e.length);return c(),r}function le(e){return e.match(/^\s*/)?.[0].length??0}function H(e){let t=e.split(/\r?\n/),r=[],n=null,o=!1,i=null;for(let a=0;a<t.length;a++){let s=t[a],l=a+1;if(!s.trim())continue;let c=le(s),u=X(s.slice(c),{line:l,columnOffset:c});if(u.length!==0){if(c===0){o=!1,i=null;let f=Ut(u,l);r.push(f),n=f;continue}if(!n)throw new d("Indented line without parent object",l,c+1);if(u.length===1&&u[0].value==="info"){o=!0,i=c;continue}o&&c<=(i??0)&&(o=!1),o?n.infoEntries.push(Ht(u,l)):n.blockFields.push(Xt(u,l))}}return{type:"document",objects:r}}function Ut(e,t){if(e.length<2)throw new d("Invalid object declaration",t,e[0]?.column??1);let[r,n,...o]=e;if(!ae.has(r.value))throw new d(`Unknown object type "${r.value}"`,t,r.column);return{type:"object",objectType:r.value,name:n.value,inlineFields:qt(o,t),blockFields:[],infoEntries:[],location:{line:t,column:r.column}}}function qt(e,t){let r=[],n=0;for(;n<e.length;){let o=e[n],i=T(o.value);if(!i)throw new d(`Unknown field "${o.value}"`,t,o.column);n++;let a=[];if(i.arity==="multiple")for(;n<e.length&&!se(e[n].value);)a.push(e[n]),n++;else{let s=e[n];s&&(a.push(s),n++)}if(a.length===0)throw new d(`Missing value for field "${o.value}"`,t,o.column);r.push({type:"field",key:o.value,values:a.map(s=>s.value),location:{line:t,column:o.column}})}return r}function Xt(e,t){if(e.length<2)throw new d("Invalid field line",t,e[0]?.column??1);if(!T(e[0].value))throw new d(`Unknown field "${e[0].value}"`,t,e[0].column);return{type:"field",key:e[0].value,values:e.slice(1).map(r=>r.value),location:{line:t,column:e[0].column}}}function Ht(e,t){if(e.length<2)throw new d("Invalid info entry",t,e[0]?.column??1);return{type:"info-entry",key:e[0].value,value:e.slice(1).map(r=>r.value).join(" "),location:{line:t,column:e[0].column}}}var Ge=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Gt=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Kt=/^[A-Za-z][A-Za-z0-9+.-]*:/;function B(e){let t=null,r=[];for(let n of e.objects){let o=Jt(n);if(n.objectType==="system"){if(t)throw d.fromLocation("Only one system object is allowed",n.location);t=o}else r.push(o)}return{format:"worldorbit",version:"1.0",system:t,objects:r}}function Jt(e){let t=[...e.inlineFields,...e.blockFields];Zt(e.objectType,t);let r=Qt(t),n=er(e.objectType,r),o=tr(r),i=or(e.infoEntries);return e.objectType==="system"?{type:"system",id:e.name,properties:o,info:i}:{type:e.objectType,id:e.name,properties:o,placement:n,info:i}}function Zt(e,t){for(let r of t){let n=T(r.key);if(!n)throw d.fromLocation(`Unknown field "${r.key}"`,r.location);if(!Xe(n,e))throw d.fromLocation(`Field "${r.key}" is not valid on "${e}"`,r.location);if(n.arity==="single"&&r.values.length!==1)throw d.fromLocation(`Field "${r.key}" expects exactly one value`,r.location)}}function Qt(e){let t=new Map;for(let r of e){if(t.has(r.key))throw d.fromLocation(`Duplicate field "${r.key}"`,r.location);t.set(r.key,r)}return t}function er(e,t){let r=t.has("orbit"),n=t.has("at"),o=t.has("surface"),i=t.has("free"),a=[r,n,o,i].filter(Boolean).length;if(a>1){let s=t.get("orbit")??t.get("at")??t.get("surface")??t.get("free");throw d.fromLocation("Object has multiple placement modes",s?.location)}if(e==="system"&&a>0)throw d.fromLocation("System objects cannot declare placement",[...t.values()][0]?.location);if(r)return{mode:"orbit",target:ce(t,"orbit"),distance:N(t,"distance"),semiMajor:N(t,"semiMajor"),eccentricity:sr(t,"eccentricity"),period:N(t,"period"),angle:N(t,"angle"),inclination:N(t,"inclination"),phase:N(t,"phase")};if(n){let s=ue(t,"at"),l=ce(t,"at");return{mode:"at",target:l,reference:ir(l,s.location)}}if(o)return{mode:"surface",target:ce(t,"surface")};if(i){let s=ce(t,"free"),l=ar(s);return{mode:"free",distance:l??void 0,descriptor:l?void 0:s}}return null}function tr(e){let t={};for(let[r,n]of e.entries()){let o=T(r);if(!(!o||o.placement))switch(o.kind){case"list":t[r]=n.values;break;case"boolean":t[r]=lr(n);break;case"number":t[r]=Je(W(n),r,n.location);break;case"unit":t[r]=Ke(W(n),n.location,r);break;case"string":t[r]=rr(r,n);break}}return t}function rr(e,t){let r=t.values.join(" ").trim();return e==="image"&&nr(r,t.location),r}function nr(e,t){if(!e)throw d.fromLocation('Field "image" must not be empty',t);if(e.startsWith("//"))throw d.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',t);let r=e.match(Kt);if(!r)return;let n=r[0].slice(0,-1).toLowerCase();if(n!=="http"&&n!=="https")throw d.fromLocation(`Field "image" does not support the "${n}" scheme`,t)}function or(e){let t={};for(let r of e){if(r.key in t)throw d.fromLocation(`Duplicate info key "${r.key}"`,r.location);t[r.key]=r.value}return t}function ir(e,t){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(e))throw d.fromLocation(`Invalid special position "${e}"`,t);let r=e.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(r)return{kind:"lagrange",primary:r[1],secondary:r[2],point:r[3]};let n=e.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(n)return{kind:"lagrange",primary:n[1],secondary:null,point:n[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(e))throw d.fromLocation(`Invalid special position "${e}"`,t);let o=e.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return o?{kind:"anchor",objectId:o[1],anchor:o[2]}:{kind:"named",name:e}}function Ke(e,t,r){let n=e.match(Ge);if(!n)throw d.fromLocation(`Invalid unit value "${e}"`,t);let o={value:Number(n[1]),unit:n[2]??null};if(r){let i=T(r);if(i?.unitFamily&&!He(i.unitFamily,o.unit))throw d.fromLocation(`Unit "${o.unit??"none"}" is not valid for "${r}"`,t)}return o}function ar(e){let t=e.match(Ge);return t?{value:Number(t[1]),unit:t[2]??null}:null}function N(e,t){if(!e.has(t))return;let r=ue(e,t);return Ke(W(r),r.location,t)}function sr(e,t){if(!e.has(t))return;let r=ue(e,t);return Je(W(r),t,r.location)}function Je(e,t,r){let n=Number(e);if(!Number.isFinite(n))throw d.fromLocation(`Invalid numeric value "${e}" for "${t}"`,r);return n}function lr(e){let t=W(e).toLowerCase(),r=Gt.get(t);if(r===void 0)throw d.fromLocation(`Invalid boolean value "${t}" for "${e.key}"`,e.location);return r}function ue(e,t){let r=e.get(t);if(!r)throw new d(`Missing value for key "${t}"`);return r}function ce(e,t){return W(ue(e,t))}function W(e){if(e.values.length!==1)throw d.fromLocation(`Field "${e.key}" expects exactly one value`,e.location);return e.values[0]}var cr=new Set(["star","planet","moon","asteroid","comet"]);function V(e){let t=new Set,r=new Map;for(let n of e.objects){if(t.has(n.id))throw new d(`Duplicate object id "${n.id}"`);t.add(n.id),r.set(n.id,n)}for(let n of e.objects)if(n.placement){if((n.placement.mode==="orbit"||n.placement.mode==="surface")&&!t.has(n.placement.target))throw new d(`Unknown placement target "${n.placement.target}" on "${n.id}"`);if(n.placement.mode==="surface"){let o=r.get(n.placement.target);if(!o||!cr.has(o.type))throw new d(`Surface target "${n.placement.target}" on "${n.id}" is not surface-capable`)}n.placement.mode==="at"&&(n.placement.reference.kind==="lagrange"&&ur(n,n.placement.reference,t),n.placement.reference.kind==="anchor"&&dr(n,n.placement.reference,t))}}function ur(e,t,r){if(!r.has(t.primary))throw new d(`Unknown Lagrange reference "${t.primary}" on "${e.id}"`);if(t.secondary&&!r.has(t.secondary))throw new d(`Unknown Lagrange reference "${t.secondary}" on "${e.id}"`)}function dr(e,t,r){if(!r.has(t.objectId))throw new d(`Unknown anchor target "${t.objectId}" on "${e.id}"`)}function E(e,t,r=`${t}.failed`){return e instanceof d?{code:r,severity:"error",source:t,message:e.message,line:e.line,column:e.column}:e instanceof Error?{code:r,severity:"error",source:t,message:e.message}:{code:r,severity:"error",source:t,message:String(e)}}var G=1495978707e-1,fr=6371,pr=71492,mr=695700,hr=63241.077,br=206264.806,gr=206264806,nt=.68,yr=.2,ot=28;function F(e,t={}){let r=xr(t),n=r.width,o=r.height,i=r.padding,a=wr(e),s=vr(e,t.projection),l=$r(a,t.scaleModel),c=Sr(a),u=e.system?.id??null,f=new Map(e.objects.map(b=>[b.id,b])),p=tn(e.objects,f),h=new Map,g=[],w=[],m=[],x=[],$=[],S=new Map,Y=new Map;for(let b of e.objects){let k=b.placement;if(!k){m.push(b);continue}if(k.mode==="orbit"){et(Y,k.target,b);continue}if(k.mode==="surface"){et(S,k.target,b);continue}if(k.mode==="at"){$.push(b);continue}x.push(b)}let A=x.length>0?n*.42:n/2,re=o/2,D={orbitChildren:Y,surfaceChildren:S,objectMap:f,spacingFactor:c,projection:s,scaleModel:l},je=m.find(b=>b.type==="star")??m[0]??null;je&&Te(je,A,re,0,h,g,w,D);let Se=m.filter(b=>b.id!==je?.id);if(Se.length>0){let b=Math.min(n,o)*.28*c*l.orbitDistanceMultiplier;Se.forEach((k,I)=>{let ke=Z(I,Se.length,-Math.PI/2),P=Q(ke,b,s,1);Te(k,A+P.x,re+P.y,0,h,g,w,D)})}x.forEach((b,k)=>{let I=n-i-140-ln(b.placement?.mode==="free"?b.placement.distance:void 0,l),ke=Math.max(76,(o-i*2-180)/Math.max(1,x.length)*c)*l.freePlacementMultiplier,P=i+92+k*ke;h.set(b.id,{object:b,x:I,y:P,radius:me(b,0,l),sortKey:be(I,P,0)}),w.push({object:b,groupId:p.groupIds.get(b.id)??null,x1:I-60,y1:P,x2:I-18,y2:P,mode:"free"}),fe(b,h,g,w,D,1)}),$.forEach((b,k)=>{if(h.has(b.id)||!b.placement||b.placement.mode!=="at")return;let I=Qr(b.placement.reference,h,f,k,$.length,n,o,i,D);h.set(b.id,{object:b,x:I.x,y:I.y,radius:me(b,2,l),sortKey:be(I.x,I.y,2),anchorX:I.anchorX,anchorY:I.anchorY}),I.anchorX!==void 0&&I.anchorY!==void 0&&w.push({object:b,groupId:p.groupIds.get(b.id)??null,x1:I.anchorX,y1:I.anchorY,x2:I.x,y2:I.y,mode:"at"}),fe(b,h,g,w,D,2)});let U=[...h.values()].map(b=>kr(b,l,p)),ne=g.map(b=>Or(b,p.groupIds.get(b.object.id)??null)),oe=w.map(b=>Tr(b)),ie=Mr(U,o,l.labelMultiplier),Lt=Ar(ne,oe,U,ie),Vt=Dr(U,ne,oe,ie,p),Et=Lr(e,s,r.preset,p,f),Ft=qr(n,o,U,ne,oe,ie);return{width:n,height:o,padding:i,renderPreset:r.preset,projection:s,scaleModel:l,title:String(e.system?.properties.title??e.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:`${tt(s)} view - ${tt(a)} layout`,systemId:u,viewMode:s,layoutPreset:a,metadata:{format:e.format,version:e.version,view:s,scale:String(e.system?.properties.scale??a),units:String(e.system?.properties.units??"mixed"),preset:r.preset??"custom"},contentBounds:Ft,layers:Lt,groups:Vt,viewpoints:Et,objects:U,orbitVisuals:ne,leaders:oe,labels:ie}}function wr(e){switch(String(e.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function xr(e){let t=Ir(e.preset);return{width:e.width??t.width,height:e.height??t.height,padding:e.padding??t.padding,preset:e.preset??null}}function Ir(e){switch(e){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function vr(e,t){return t==="topdown"||t==="isometric"?t:String(e.system?.properties.view??"topdown").toLowerCase()==="isometric"?"isometric":"topdown"}function $r(e,t){return{...jr(e),...t}}function jr(e){switch(e){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40}}}function Sr(e){switch(e){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function kr(e,t,r){let{object:n,x:o,y:i,radius:a,sortKey:s,anchorX:l,anchorY:c}=e;return{renderId:ye(n.id),objectId:n.id,object:n,parentId:r.parentIds.get(n.id)??null,ancestorIds:r.ancestorIds.get(n.id)??[],childIds:r.childIds.get(n.id)??[],groupId:r.groupIds.get(n.id)??null,x:o,y:i,radius:a,visualRadius:sn(n,a,t),sortKey:s,anchorX:l,anchorY:c,label:n.id,secondaryLabel:n.type==="structure"?String(n.properties.kind??n.type):n.type,fillColor:un(n.properties.color),imageHref:typeof n.properties.image=="string"&&n.properties.image.trim()?n.properties.image:void 0,hidden:n.properties.hidden===!0}}function Or(e,t){return{renderId:`${ye(e.object.id)}-orbit`,objectId:e.object.id,object:e.object,parentId:e.parentId,groupId:t,kind:e.kind,cx:e.cx,cy:e.cy,radius:e.radius,rx:e.rx,ry:e.ry,rotationDeg:e.rotationDeg,band:e.band,bandThickness:e.bandThickness,frontArcPath:e.frontArcPath,backArcPath:e.backArcPath,hidden:e.object.properties.hidden===!0}}function Tr(e){return{renderId:`${ye(e.object.id)}-leader-${e.mode}`,objectId:e.object.id,object:e.object,groupId:e.groupId,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,mode:e.mode,hidden:e.object.properties.hidden===!0}}function Mr(e,t,r){let n=[],o=[],i=[...e].filter(a=>!a.hidden).sort((a,s)=>a.sortKey-s.sortKey);for(let a of i){let s=a.y>t*.62?-1:1,l=dn(a,r),c=a.y+s*(a.radius+18*r),u=c+s*(16*r),f=Ze(a.x,c,u,l,s),p=0;for(;o.some(h=>on(h,f))&&p<10;)c+=s*14*r,u+=s*14*r,f=Ze(a.x,c,u,l,s),p+=1;o.push(f),n.push({renderId:`${a.renderId}-label`,objectId:a.objectId,object:a.object,groupId:a.groupId,label:a.label,secondaryLabel:a.secondaryLabel,x:a.x,y:c,secondaryY:u,textAnchor:"middle",direction:s<0?"above":"below",hidden:a.hidden})}return n}function Ar(e,t,r,n){let o=e.filter(a=>!a.hidden&&!!a.backArcPath).map(a=>a.renderId),i=e.filter(a=>!a.hidden).map(a=>a.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:t.filter(a=>!a.hidden).map(a=>a.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:i},{id:"objects",renderIds:r.filter(a=>!a.hidden).map(a=>a.renderId)},{id:"labels",renderIds:n.filter(a=>!a.hidden).map(a=>a.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function Dr(e,t,r,n,o){let i=new Map,a=s=>{if(!s)return null;let l=i.get(s);if(l)return l;let c=o.groupRoots.get(s)??null,u={renderId:s,rootObjectId:c,label:c??s,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:J(0,0,0,0)};return i.set(s,u),u};for(let s of e){let l=a(s.groupId);l&&!s.hidden&&l.objectIds.push(s.objectId)}for(let s of t){let l=a(s.groupId);l&&!s.hidden&&l.orbitIds.push(s.objectId)}for(let s of r){let l=a(s.groupId);l&&!s.hidden&&l.leaderIds.push(s.objectId)}for(let s of n){let l=a(s.groupId);l&&!s.hidden&&l.labelIds.push(s.objectId)}for(let s of i.values())s.contentBounds=rn(s,e,t,r,n);return[...i.values()].sort((s,l)=>s.label.localeCompare(l.label))}function Lr(e,t,r,n,o){let i=Vr(e,t,r),a=new Map;for(let[c,u]of Object.entries(e.system?.info??{})){if(!c.startsWith("viewpoint."))continue;let[f,p,...h]=c.split(".");if(f!=="viewpoint"||!p||h.length===0)continue;let g=_r(p);if(!g)continue;let w=h.join(".").toLowerCase(),m=a.get(g)??{id:g};Er(m,w,u,t,r,n,o),a.set(g,m)}let s=[...a.values()].map(c=>Fr(c,t,r,o)).filter(Boolean),l=s.findIndex(c=>c.id===i.id);return l>=0?s.splice(l,1,{...i,...s[l],layers:{...i.layers,...s[l].layers},filter:s[l].filter??i.filter,generated:!1}):s.unshift(i),s.sort((c,u)=>c.id==="overview"?-1:u.id==="overview"?1:c.label.localeCompare(u.label))}function Vr(e,t,r){return{id:"overview",label:e.system?.properties.title?`${String(e.system.properties.title)} Overview`:"Overview",summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,projection:t,preset:r,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function Er(e,t,r,n,o,i,a){let s=r.trim();switch(t){case"label":case"title":s&&(e.label=s);return;case"summary":case"description":s&&(e.summary=s);return;case"focus":case"object":s&&(e.focus=s);return;case"select":case"selection":s&&(e.select=s);return;case"projection":case"view":e.projection=Pr(s)??n;return;case"preset":e.preset=Br(s)??o;return;case"rotation":case"angle":e.rotationDeg=it(s)??e.rotationDeg??0;return;case"zoom":case"scale":e.scale=Rr(s);return;case"layers":e.layers=zr(s);return;case"query":e.filter={...e.filter??de(),query:s||null};return;case"types":case"objecttypes":e.filter={...e.filter??de(),objectTypes:Nr(s)};return;case"tags":e.filter={...e.filter??de(),tags:ge(s)};return;case"groups":e.filter={...e.filter??de(),groupIds:Wr(s,i,a)};return}}function Fr(e,t,r,n){let o=e.focus&&n.has(e.focus)?e.focus:null,i=e.select&&n.has(e.select)?e.select:o,a=Cr(e.filter),s=e.label?.trim()||Yr(e.id);return{id:e.id,label:s,summary:e.summary?.trim()||Ur(s,o,a),objectId:o,selectedObjectId:i,projection:e.projection??t,preset:e.preset??r,rotationDeg:e.rotationDeg??0,scale:e.scale??null,layers:e.layers??{},filter:a,generated:!1}}function de(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function Cr(e){if(!e)return null;let t={query:e.query?.trim()||null,objectTypes:[...new Set(e.objectTypes)],tags:[...new Set(e.tags)],groupIds:[...new Set(e.groupIds)]};return t.query||t.objectTypes.length>0||t.tags.length>0||t.groupIds.length>0?t:null}function Pr(e){return e.toLowerCase()==="isometric"?"isometric":e.toLowerCase()==="topdown"?"topdown":null}function Br(e){let t=e.toLowerCase();return t==="diagram"||t==="presentation"||t==="atlas-card"||t==="markdown"?t:null}function it(e){let t=Number(e);return Number.isFinite(t)?t:null}function Rr(e){let t=it(e);return t!==null&&t>0?t:null}function zr(e){let t={};for(let r of ge(e)){let n=!r.startsWith("-")&&!r.startsWith("!"),o=r.replace(/^[-!]+/,"").toLowerCase();if(o==="orbits"){t["orbits-back"]=n,t["orbits-front"]=n;continue}(o==="background"||o==="guides"||o==="orbits-back"||o==="orbits-front"||o==="objects"||o==="labels"||o==="metadata")&&(t[o]=n)}return t}function Nr(e){return ge(e).filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Wr(e,t,r){return ge(e).map(n=>n.startsWith("wo-")&&n.endsWith("-group")?n:t.groupIds.has(n)?t.groupIds.get(n)??K(n):(r.has(n),K(n)))}function ge(e){return e.split(/[\s,]+/).map(t=>t.trim()).filter(Boolean)}function _r(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Yr(e){return e.split(/[-_]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" ")}function Ur(e,t,r){let n=[e];return t&&n.push(`focus ${t}`),r?.objectTypes.length&&n.push(r.objectTypes.join("/")),r?.tags.length&&n.push(`tags ${r.tags.join(", ")}`),r?.query&&n.push(`query "${r.query}"`),n.join(" - ")}function qr(e,t,r,n,o,i){let a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=(f,p)=>{a=Math.min(a,f),s=Math.min(s,p),l=Math.max(l,f),c=Math.max(c,p)};for(let f of n)f.hidden||at(f,u);for(let f of o)f.hidden||(u(f.x1,f.y1),u(f.x2,f.y2));for(let f of r)f.hidden||st(f,u);for(let f of i)f.hidden||lt(f,u);return!Number.isFinite(a)||!Number.isFinite(s)?J(0,0,e,t):J(a,s,l,c)}function at(e,t){let r=e.bandThickness!==void 0?e.bandThickness/2+4:e.band?10:3;if(e.kind==="circle"&&e.radius!==void 0){t(e.cx-e.radius-r,e.cy-e.radius-r),t(e.cx+e.radius+r,e.cy+e.radius+r);return}let n=e.rx??e.radius??0,o=e.ry??e.radius??0,i=ut(e.cx,e.cy,n,o,e.rotationDeg,0,Math.PI*2,ot*2);for(let a of i)t(a.x-r,a.y-r),t(a.x+r,a.y+r)}function J(e,t,r,n){return{minX:e,minY:t,maxX:r,maxY:n,width:r-e,height:n-t,centerX:e+(r-e)/2,centerY:t+(n-t)/2}}function st(e,t){t(e.x-e.visualRadius-24,e.y-e.visualRadius-16),t(e.x+e.visualRadius+24,e.y+e.visualRadius+36)}function lt(e,t){let n=fn(e.label,e.secondaryLabel,1);t(e.x-n,e.y-18),t(e.x+n,e.y+8),t(e.x-n,e.secondaryY-14),t(e.x+n,e.secondaryY+8)}function Te(e,t,r,n,o,i,a,s){o.has(e.id)||(o.set(e.id,{object:e,x:t,y:r,radius:me(e,n,s.scaleModel),sortKey:be(t,r,n)}),fe(e,o,i,a,s,n+1))}function fe(e,t,r,n,o,i){let a=t.get(e.id);if(!a)return;let s=[...o.orbitChildren.get(e.id)??[]].sort(Xr),l=Hr(s,a.radius,o.spacingFactor,o.scaleModel);s.forEach((u,f)=>{let p=Gr(u,f,s.length,a,l,o);r.push({object:u,parentId:e.id,kind:p.kind,cx:p.cx,cy:p.cy,radius:p.radius,rx:p.rx,ry:p.ry,rotationDeg:p.rotationDeg,band:p.band,bandThickness:p.bandThickness,frontArcPath:p.frontArcPath,backArcPath:p.backArcPath}),Te(u,p.objectX,p.objectY,i,t,r,n,o)});let c=[...o.surfaceChildren.get(e.id)??[]];c.forEach((u,f)=>{let p=Z(f,c.length,-Math.PI/3),h=28*o.spacingFactor,g=Q(p,a.radius,o.projection,o.projection==="isometric"?.9:1),w=Q(p,a.radius+h,o.projection,o.projection==="isometric"?.9:1),m=a.x+g.x,x=a.y+g.y,$=a.x+w.x,S=a.y+w.y;t.set(u.id,{object:u,x:$,y:S,radius:me(u,i+1,o.scaleModel),sortKey:be($,S,i+1),anchorX:m,anchorY:x}),n.push({object:u,groupId:o.objectMap.has(u.id)?K(nn(u,o.objectMap)):null,x1:m,y1:x,x2:$,y2:S,mode:"surface"}),fe(u,t,r,n,o,i+1)})}function Xr(e,t){let r=pe(e),n=pe(t);return r!==null&&n!==null&&r!==n?r-n:r!==null&&n===null?-1:r===null&&n!==null?1:e.id.localeCompare(t.id)}function Hr(e,t,r,n){let o=e.map(f=>pe(f)),i=o.filter(f=>f!==null),a=t+56*r*n.orbitDistanceMultiplier,s=(e.length>2?54:64)*r*n.orbitDistanceMultiplier;if(i.length===0)return{metrics:o,minMetric:0,maxMetric:0,metricSpread:0,innerPx:a,stepPx:s,pixelSpread:Math.max(s*Math.max(e.length-1,1),s)};let l=Math.min(...i),c=Math.max(...i),u=c-l;return{metrics:o,minMetric:l,maxMetric:c,metricSpread:u,innerPx:a,stepPx:s,pixelSpread:Math.max(s*Math.max(e.length-1,1),s)}}function Gr(e,t,r,n,o,i){let a=e.placement,s=e.type==="belt"||e.type==="ring";if(!a||a.mode!=="orbit"){let D=o.innerPx+t*o.stepPx;return{kind:"circle",cx:n.x,cy:n.y,radius:D,rotationDeg:0,band:s,bandThickness:s?12*i.scaleModel.ringThicknessMultiplier:void 0,objectX:n.x,objectY:n.y-D}}let l=v(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),c=Kr(e,t,o),u=Math.max(c*Math.sqrt(1-l*l),c*.18),f=Ae(a.inclination)??0,p=i.projection==="isometric"?Math.max(yr,Math.cos(De(f)))*nt:1,h=Math.max(u*p,c*.14),g=Ae(a.angle)??0,w=c*l,m=ft(-w,0,g),x=n.x+m.x,$=n.y+m.y,S=Jr(a.phase,t,r),Y=dt(x,$,c,h,g,S),A=i.projection==="topdown"&&l<=1e-4&&Math.abs(g)<=1e-4,re=s?Zr(e,c,o,i.scaleModel):void 0;return{kind:A?"circle":"ellipse",cx:A?n.x:x,cy:A?n.y:$,radius:A?c:void 0,rx:A?void 0:c,ry:A?void 0:h,rotationDeg:g,band:s,bandThickness:re,frontArcPath:i.projection==="isometric"||s?Qe(x,$,c,h,g,0,Math.PI):void 0,backArcPath:i.projection==="isometric"||s?Qe(x,$,c,h,g,Math.PI,Math.PI*2):void 0,objectX:Y.x,objectY:Y.y}}function Kr(e,t,r){let n=pe(e);return n===null?r.innerPx+t*r.stepPx:r.metricSpread>0?r.innerPx+(n-r.minMetric)/r.metricSpread*r.pixelSpread:r.innerPx+Math.log10(n+1)*r.stepPx}function pe(e){return!e.placement||e.placement.mode!=="orbit"?null:he(e.placement.semiMajor??e.placement.distance??null)}function Jr(e,t,r){let n=e?Ae(e):null;return n!==null?De(n-90):Z(t,r,-Math.PI/2)}function Zr(e,t,r,n){let o=he(Me(e.properties.inner)),i=he(Me(e.properties.outer));if(o!==null&&i!==null){let s=Math.abs(i-o);if(r.metricSpread>0)return v(s/r.metricSpread*r.pixelSpread*n.ringThicknessMultiplier,8,54);let l=Math.max(Math.max(o,i),1e-4);return v(s/l*t*.75*n.ringThicknessMultiplier,8,48)}return(e.type==="belt"?18:12)*n.ringThicknessMultiplier}function Qr(e,t,r,n,o,i,a,s,l){if(e.kind==="lagrange")return en(e,t,r,i,a);if(e.kind==="anchor"){let c=t.get(e.objectId);if(c){let u=Z(n,o,Math.PI/5),f=(c.radius+36)*l.scaleModel.labelMultiplier,p=Q(u,f,l.projection,l.projection==="isometric"?.92:1);return{x:c.x+p.x,y:c.y+p.y,anchorX:c.x,anchorY:c.y}}}if(e.kind==="named"){let c=t.get(e.name);if(c){let u=Z(n,o,Math.PI/6),f=(c.radius+36)*l.scaleModel.labelMultiplier,p=Q(u,f,l.projection,l.projection==="isometric"?.92:1);return{x:c.x+p.x,y:c.y+p.y,anchorX:c.x,anchorY:c.y}}}return{x:i-s-170,y:a-s-86-n*58*l.scaleModel.freePlacementMultiplier}}function en(e,t,r,n,o){let i=e.secondary?t.get(e.primary):an(e.primary,t,r),a=t.get(e.secondary??e.primary);if(!i||!a)return{x:n*.7,y:o*.25};let s=a.x-i.x,l=a.y-i.y,c=Math.hypot(s,l)||1,u=s/c,f=l/c,p=-f,h=u,g=v(c*.25,24,68);switch(e.point){case"L1":return{x:a.x-u*g,y:a.y-f*g,anchorX:a.x,anchorY:a.y};case"L2":return{x:a.x+u*g,y:a.y+f*g,anchorX:a.x,anchorY:a.y};case"L3":return{x:i.x-u*g,y:i.y-f*g,anchorX:i.x,anchorY:i.y};case"L4":return{x:a.x+(u*.5-p*.8660254)*g,y:a.y+(f*.5-h*.8660254)*g,anchorX:a.x,anchorY:a.y};case"L5":return{x:a.x+(u*.5+p*.8660254)*g,y:a.y+(f*.5+h*.8660254)*g,anchorX:a.x,anchorY:a.y}}}function tn(e,t){let r=new Map,n=new Map;for(let c of e){let u=ct(c,t);if(r.set(c.id,u),u){let f=n.get(u);f?f.push(c.id):n.set(u,[c.id])}n.has(c.id)||n.set(c.id,[])}let o=new Map,i=new Map,a=new Map,s=c=>{let u=o.get(c);if(u)return u;let f=new Set,p=[],h=r.get(c)??null;for(;h&&!f.has(h);)p.push(h),f.add(h),h=r.get(h)??null;return o.set(c,p),p},l=c=>{let u=a.get(i.get(c)??"");if(u)return u;let f=r.get(c)??null,p=t.get(c),h=c;return p?.placement&&p.placement.mode!=="free"&&f&&(h=l(f)),h};for(let c of e){s(c.id);let u=l(c.id),f=K(u);i.set(c.id,f),a.set(f,u)}return{parentIds:r,childIds:n,ancestorIds:o,groupIds:i,groupRoots:a}}function ct(e,t){let r=e.placement;if(!r)return null;switch(r.mode){case"orbit":case"surface":return t.has(r.target)?r.target:null;case"at":switch(r.reference.kind){case"anchor":return t.has(r.reference.objectId)?r.reference.objectId:null;case"named":return t.has(r.reference.name)?r.reference.name:null;case"lagrange":return r.reference.secondary&&t.has(r.reference.secondary)?r.reference.secondary:t.has(r.reference.primary)?r.reference.primary:null}case"free":return null}}function rn(e,t,r,n,o){let i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,c=(u,f)=>{i=Math.min(i,u),a=Math.min(a,f),s=Math.max(s,u),l=Math.max(l,f)};for(let u of t)!u.hidden&&e.objectIds.includes(u.objectId)&&st(u,c);for(let u of r)!u.hidden&&e.orbitIds.includes(u.objectId)&&at(u,c);for(let u of n)!u.hidden&&e.leaderIds.includes(u.objectId)&&(c(u.x1,u.y1),c(u.x2,u.y2));for(let u of o)!u.hidden&&e.labelIds.includes(u.objectId)&<(u,c);return!Number.isFinite(i)||!Number.isFinite(a)?J(0,0,0,0):J(i,a,s,l)}function nn(e,t){let r=e,n=new Set;for(;r.placement&&r.placement.mode!=="free"&&!n.has(r.id);){n.add(r.id);let o=ct(r,t);if(!o)break;let i=t.get(o);if(!i)break;r=i}return r.id}function Ze(e,t,r,n,o){return{left:e-n,right:e+n,top:Math.min(t,r)-(o<0?18:12),bottom:Math.max(t,r)+(o<0?8:12)}}function on(e,t){return!(e.right<t.left||t.right<e.left||e.bottom<t.top||t.bottom<e.top)}function an(e,t,r){let n=r.get(e);return!n?.placement||n.placement.mode!=="orbit"?t.get(e):t.get(n.placement.target)}function me(e,t,r){let n=cn(e.properties.radius,r);if(n!==null)return n;let o=r.bodyRadiusMultiplier;switch(e.type){case"star":return v((t===0?28:20)*o,r.minBodyRadius,r.maxBodyRadius);case"planet":return v(12*o,r.minBodyRadius,r.maxBodyRadius);case"moon":return v(7*o,r.minBodyRadius,r.maxBodyRadius);case"belt":return v(5*o,r.minBodyRadius,r.maxBodyRadius);case"asteroid":return v(5*o,r.minBodyRadius,r.maxBodyRadius);case"comet":return v(6*o,r.minBodyRadius,r.maxBodyRadius);case"ring":return v(5*o,r.minBodyRadius,r.maxBodyRadius);case"structure":return v(6*o,r.minBodyRadius,r.maxBodyRadius);case"phenomenon":return v(8*o,r.minBodyRadius,r.maxBodyRadius)}}function sn(e,t,r){let n=typeof e.properties.atmosphere=="string"?4:0;switch(e.type){case"star":return t*2.4;case"phenomenon":return t*1.25;case"structure":return t+2;default:return Math.min(t+n,r.maxBodyRadius+10)}}function he(e){if(!e)return null;switch(e.unit){case"au":return e.value;case"km":return e.value/G;case"m":return e.value/1e3/G;case"ly":return e.value*hr;case"pc":return e.value*br;case"kpc":return e.value*gr;case"re":return e.value*fr/G;case"rj":return e.value*pr/G;case"sol":return e.value*mr/G;default:return e.value}}function ln(e,t){let r=he(e??null);return r===null||r<=0?0:v(r*96*t.freePlacementMultiplier,0,420)}function cn(e,t){let r=Me(e);if(!r)return null;let n;switch(r.unit){case"sol":n=v(r.value*22,14,40);break;case"re":n=v(r.value*10,6,18);break;case"km":n=v(Math.log10(Math.max(r.value,1))*2.6,4,16);break;default:n=v(r.value*4,4,20);break}return v(n*t.bodyRadiusMultiplier,t.minBodyRadius,t.maxBodyRadius)}function Me(e){return!e||typeof e!="object"||!("value"in e)?null:e}function Ae(e){return e&&(e.unit==="deg"||e.unit===null)?e.value:null}function Z(e,t,r){return t<=1?r:r+e*Math.PI*2/t}function Qe(e,t,r,n,o,i,a){let s=ut(e,t,r,n,o,i,a,ot);return s.length===0?"":s.map((l,c)=>`${c===0?"M":"L"} ${rt(l.x)} ${rt(l.y)}`).join(" ")}function ut(e,t,r,n,o,i,a,s){let l=[];for(let c=0;c<=s;c+=1){let u=i+(a-i)*c/s;l.push(dt(e,t,r,n,o,u))}return l}function dt(e,t,r,n,o,i){let a=r*Math.cos(i),s=n*Math.sin(i),l=ft(a,s,o);return{x:e+l.x,y:t+l.y}}function ft(e,t,r){let n=De(r);return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}}function Q(e,t,r,n){let o=r==="isometric"?nt*n:n;return{x:Math.cos(e)*t,y:Math.sin(e)*t*o}}function be(e,t,r){return t*1e3+e+r*.01}function v(e,t,r){return Math.min(Math.max(e,t),r)}function et(e,t,r){let n=e.get(t);n?n.push(r):e.set(t,[r])}function ye(e){return`wo-${e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function K(e){return`${ye(e)}-group`}function un(e){return typeof e=="string"&&e.trim()?e:void 0}function dn(e,t){let r=e.label.length*4.6*t+18,n=e.secondaryLabel.length*3.9*t+18;return Math.max(r,n,e.visualRadius+18)}function fn(e,t,r){let n=e.length*4.6*r+18,o=t.length*3.9*r+18;return Math.max(n,o,24)}function tt(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}function De(e){return e*Math.PI/180}function rt(e){return Number.isInteger(e)?String(e):e.toFixed(2)}function we(e){return{format:"worldorbit",version:"1.0",system:e.system?{type:"system",id:e.system.id,properties:hn(e.system),info:bn(e.system)}:null,objects:e.objects.map(pn)}}function pn(e){return{...e,properties:mn(e.properties),placement:e.placement?structuredClone(e.placement):null,info:{...e.info}}}function mn(e){let t={};for(let[r,n]of Object.entries(e)){if(Array.isArray(n)){t[r]=[...n];continue}if(n&&typeof n=="object"&&"value"in n){t[r]={value:n.value,unit:n.unit};continue}t[r]=n}return t}function hn(e){let t={};return e.title&&(t.title=e.title),t.view=e.defaults.view,e.defaults.scale&&(t.scale=e.defaults.scale),e.defaults.units&&(t.units=e.defaults.units),t}function bn(e){let t={...e.atlasMetadata};e.defaults.theme&&(t["atlas.theme"]=e.defaults.theme);for(let r of e.viewpoints){let n=`viewpoint.${r.id}`;t[`${n}.label`]=r.label,r.summary&&(t[`${n}.summary`]=r.summary),r.focusObjectId&&(t[`${n}.focus`]=r.focusObjectId),r.selectedObjectId&&(t[`${n}.select`]=r.selectedObjectId),r.projection&&(t[`${n}.projection`]=r.projection),r.preset&&(t[`${n}.preset`]=r.preset),r.zoom!==null&&(t[`${n}.zoom`]=String(r.zoom)),r.rotationDeg!==0&&(t[`${n}.rotation`]=String(r.rotationDeg));let o=gn(r.layers);o&&(t[`${n}.layers`]=o),r.filter?.query&&(t[`${n}.query`]=r.filter.query),(r.filter?.objectTypes.length??0)>0&&(t[`${n}.types`]=r.filter?.objectTypes.join(" ")??""),(r.filter?.tags.length??0)>0&&(t[`${n}.tags`]=r.filter?.tags.join(" ")??""),(r.filter?.groupIds.length??0)>0&&(t[`${n}.groups`]=r.filter?.groupIds.join(" ")??"")}for(let r of e.annotations){let n=`annotation.${r.id}`;t[`${n}.label`]=r.label,r.targetObjectId&&(t[`${n}.target`]=r.targetObjectId),t[`${n}.body`]=r.body,r.tags.length>0&&(t[`${n}.tags`]=r.tags.join(" ")),r.sourceObjectId&&(t[`${n}.source`]=r.sourceObjectId)}return t}function gn(e){let t=[],r=e["orbits-front"],n=e["orbits-back"];(r!==void 0||n!==void 0)&&t.push(r!==!1||n!==!1?"orbits":"-orbits");for(let o of["background","guides","objects","labels","metadata"])e[o]!==void 0&&t.push(e[o]?o:`-${o}`);return t.join(" ")}function Ve(e){return xn(e,"2.0")}function xn(e,t){let r=e.split(/\r?\n/),n=!1,o="2.0",i=null,a=null,s=[],l=!1,c=!1,u=new Set,f=new Set;for(let w=0;w<r.length;w++){let m=r[w],x=w+1;if(!m.trim())continue;let $=le(m),S=X(m.slice($),{line:x,columnOffset:$});if(S.length!==0){if(!n){o=In(S,x),n=!0;continue}if($===0){a=vn(S,x,i,s,u,f,{sawDefaults:l,sawAtlas:c}),a.kind==="system"?i=a.system:a.kind==="defaults"?l=!0:a.kind==="atlas"&&(c=!0);continue}if(!a)throw new d("Indented line without parent atlas section",x,$+1);On(a,$,S,x)}}if(!n)throw new d('Missing required atlas schema header "schema 2.0"');let h=B({type:"document",objects:s}).objects;return V({format:"worldorbit",version:"1.0",system:null,objects:h}),{format:"worldorbit",version:t,sourceVersion:"1.0",system:i,objects:h,diagnostics:o==="2.0-draft"&&t==="2.0"?[{code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}]:[]}}function In(e,t){if(e.length!==2||e[0].value.toLowerCase()!=="schema"||e[1].value.toLowerCase()!=="2.0-draft"&&e[1].value.toLowerCase()!=="2.0")throw new d('Expected atlas header "schema 2.0" or legacy "schema 2.0-draft"',t,e[0]?.column??1);return e[1].value.toLowerCase()==="2.0-draft"?"2.0-draft":"2.0"}function vn(e,t,r,n,o,i,a){switch(e[0]?.value.toLowerCase()){case"system":if(r)throw new d('Atlas section "system" may only appear once',t,e[0].column);return $n(e,t);case"defaults":if(!r)throw new d('Atlas section "defaults" requires a preceding system declaration',t,e[0].column);if(a.sawDefaults)throw new d('Atlas section "defaults" may only appear once',t,e[0].column);return{kind:"defaults",system:r,seenFields:new Set};case"atlas":if(!r)throw new d('Atlas section "atlas" requires a preceding system declaration',t,e[0].column);if(a.sawAtlas)throw new d('Atlas section "atlas" may only appear once',t,e[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new d('Atlas section "viewpoint" requires a preceding system declaration',t,e[0].column);return jn(e,t,r,o);case"annotation":if(!r)throw new d('Atlas section "annotation" requires a preceding system declaration',t,e[0].column);return Sn(e,t,r,i);case"object":return kn(e,t,n);default:throw new d(`Unknown atlas section "${e[0]?.value??""}"`,t,e[0]?.column??1)}}function $n(e,t){if(e.length!==2)throw new d("Invalid atlas system declaration",t,e[0]?.column??1);return{kind:"system",system:{type:"system",id:e[1].value,title:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},seenFields:new Set}}function jn(e,t,r,n){if(e.length!==2)throw new d("Invalid viewpoint declaration",t,e[0]?.column??1);let o=ht(e[1].value);if(!o)throw new d("Viewpoint id must not be empty",t,e[1].column);if(n.has(o))throw new d(`Duplicate viewpoint id "${o}"`,t,e[1].column);let i={id:o,label:bt(o),summary:"",focusObjectId:null,selectedObjectId:null,projection:r.defaults.view,preset:r.defaults.preset,zoom:null,rotationDeg:0,layers:{},filter:null};return r.viewpoints.push(i),n.add(o),{kind:"viewpoint",viewpoint:i,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set}}function Sn(e,t,r,n){if(e.length!==2)throw new d("Invalid annotation declaration",t,e[0]?.column??1);let o=ht(e[1].value);if(!o)throw new d("Annotation id must not be empty",t,e[1].column);if(n.has(o))throw new d(`Duplicate annotation id "${o}"`,t,e[1].column);let i={id:o,label:bt(o),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return r.annotations.push(i),n.add(o),{kind:"annotation",annotation:i,seenFields:new Set}}function kn(e,t,r){if(e.length<3)throw new d("Invalid atlas object declaration",t,e[0]?.column??1);let n=e[1],o=e[2],i=n.value;if(!ae.has(i)||i==="system")throw new d(`Unknown object type "${n.value}"`,t,n.column);let a={type:"object",objectType:i,name:o.value,inlineFields:zn(e.slice(3),t),blockFields:[],infoEntries:[],location:{line:t,column:n.column}};return r.push(a),{kind:"object",objectNode:a,inInfoBlock:!1,infoIndent:null}}function On(e,t,r,n){switch(e.kind){case"system":Tn(e,r,n);return;case"defaults":Mn(e,r,n);return;case"atlas":An(e,t,r,n);return;case"viewpoint":Dn(e,t,r,n);return;case"annotation":Vn(e,r,n);return;case"object":En(e,t,r,n);return}}function Tn(e,t,r){if(ee(t,e.seenFields,r)!=="title")throw new d(`Unknown system atlas field "${t[0].value}"`,r,t[0].column);e.system.title=C(t,r)}function Mn(e,t,r){let n=ee(t,e.seenFields,r),o=C(t,r);switch(n){case"view":e.system.defaults.view=pt(o,r,t[0].column);return;case"scale":e.system.defaults.scale=o;return;case"units":e.system.defaults.units=o;return;case"preset":e.system.defaults.preset=mt(o,r,t[0].column);return;case"theme":e.system.defaults.theme=o;return;default:throw new d(`Unknown defaults field "${t[0].value}"`,r,t[0].column)}}function An(e,t,r,n){if(e.inMetadata&&t<=(e.metadataIndent??0)&&(e.inMetadata=!1,e.metadataIndent=null),e.inMetadata){if(r.length<2)throw new d("Invalid atlas metadata entry",n,r[0]?.column??1);let o=r[0].value;if(o in e.system.atlasMetadata)throw new d(`Duplicate atlas metadata key "${o}"`,n,r[0].column);e.system.atlasMetadata[o]=C(r,n);return}if(r.length===1&&r[0].value.toLowerCase()==="metadata"){e.inMetadata=!0,e.metadataIndent=t;return}throw new d(`Unknown atlas field "${r[0].value}"`,n,r[0].column)}function Dn(e,t,r,n){if(e.inFilter&&t<=(e.filterIndent??0)&&(e.inFilter=!1,e.filterIndent=null),e.inFilter){Ln(e,r,n);return}if(r.length===1&&r[0].value.toLowerCase()==="filter"){if(e.seenFields.has("filter"))throw new d('Duplicate viewpoint field "filter"',n,r[0].column);e.seenFields.add("filter"),e.inFilter=!0,e.filterIndent=t;return}let o=ee(r,e.seenFields,n),i=C(r,n);switch(o){case"label":e.viewpoint.label=i;return;case"summary":e.viewpoint.summary=i;return;case"focus":e.viewpoint.focusObjectId=i;return;case"select":e.viewpoint.selectedObjectId=i;return;case"projection":e.viewpoint.projection=pt(i,n,r[0].column);return;case"preset":e.viewpoint.preset=mt(i,n,r[0].column);return;case"zoom":e.viewpoint.zoom=Pn(i,n,r[0].column,"zoom");return;case"rotation":e.viewpoint.rotationDeg=Bn(i,n,r[0].column,"rotation");return;case"layers":e.viewpoint.layers=Cn(r.slice(1),n);return;default:throw new d(`Unknown viewpoint field "${r[0].value}"`,n,r[0].column)}}function Ln(e,t,r){let n=ee(t,e.seenFilterFields,r),o=e.viewpoint.filter??Rn();switch(n){case"query":o.query=C(t,r);break;case"objecttypes":o.objectTypes=Fn(t.slice(1),r);break;case"tags":o.tags=Le(t.slice(1),r,"tags");break;case"groups":o.groupIds=Le(t.slice(1),r,"groups");break;default:throw new d(`Unknown viewpoint filter field "${t[0].value}"`,r,t[0].column)}e.viewpoint.filter=o}function Vn(e,t,r){switch(ee(t,e.seenFields,r)){case"label":e.annotation.label=C(t,r);return;case"target":e.annotation.targetObjectId=C(t,r);return;case"body":e.annotation.body=C(t,r);return;case"tags":e.annotation.tags=Le(t.slice(1),r,"tags");return;default:throw new d(`Unknown annotation field "${t[0].value}"`,r,t[0].column)}}function En(e,t,r,n){if(r.length===1&&r[0].value==="info"){e.inInfoBlock=!0,e.infoIndent=t;return}if(e.inInfoBlock&&t<=(e.infoIndent??0)&&(e.inInfoBlock=!1,e.infoIndent=null),e.inInfoBlock){e.objectNode.infoEntries.push(Wn(r,n));return}e.objectNode.blockFields.push(Nn(r,n))}function ee(e,t,r){if(e.length<2)throw new d("Invalid atlas field line",r,e[0]?.column??1);let n=e[0].value.toLowerCase();if(t.has(n))throw new d(`Duplicate atlas field "${e[0].value}"`,r,e[0].column);return t.add(n),n}function C(e,t){if(e.length<2)throw new d("Missing value for atlas field",t,e[0]?.column??1);return e.slice(1).map(r=>r.value).join(" ").trim()}function Fn(e,t){if(e.length===0)throw new d("Missing value for atlas field",t);return e.map(r=>{let n=r.value;if(n!=="star"&&n!=="planet"&&n!=="moon"&&n!=="belt"&&n!=="asteroid"&&n!=="comet"&&n!=="ring"&&n!=="structure"&&n!=="phenomenon")throw new d(`Unknown viewpoint object type "${r.value}"`,t,r.column);return n})}function Le(e,t,r){if(e.length===0)throw new d(`Missing value for field "${r}"`,t);return e.map(n=>n.value)}function Cn(e,t){if(e.length===0)throw new d('Missing value for field "layers"',t);let r={};for(let n of e){let o=!n.value.startsWith("-")&&!n.value.startsWith("!"),i=n.value.replace(/^[-!]+/,"").toLowerCase();if(i==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}if(i==="background"||i==="guides"||i==="orbits-back"||i==="orbits-front"||i==="objects"||i==="labels"||i==="metadata"){r[i]=o;continue}throw new d(`Unknown layer token "${n.value}"`,t,n.column)}return r}function pt(e,t,r){let n=e.toLowerCase();if(n==="topdown"||n==="isometric")return n;throw new d(`Unknown projection "${e}"`,t,r)}function mt(e,t,r){let n=e.toLowerCase();if(n==="diagram"||n==="presentation"||n==="atlas-card"||n==="markdown")return n;throw new d(`Unknown render preset "${e}"`,t,r)}function Pn(e,t,r,n){let o=Number(e);if(!Number.isFinite(o)||o<=0)throw new d(`Field "${n}" expects a positive number`,t,r);return o}function Bn(e,t,r,n){let o=Number(e);if(!Number.isFinite(o))throw new d(`Field "${n}" expects a finite number`,t,r);return o}function Rn(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function zn(e,t){let r=[],n=0;for(;n<e.length;){let o=e[n],i=T(o.value);if(!i)throw new d(`Unknown field "${o.value}"`,t,o.column);n++;let a=[];if(i.arity==="multiple")for(;n<e.length&&!se(e[n].value);)a.push(e[n]),n++;else{let s=e[n];s&&(a.push(s),n++)}if(a.length===0)throw new d(`Missing value for field "${o.value}"`,t,o.column);r.push({type:"field",key:o.value,values:a.map(s=>s.value),location:{line:t,column:o.column}})}return r}function Nn(e,t){if(e.length<2)throw new d("Invalid field line",t,e[0]?.column??1);if(!T(e[0].value))throw new d(`Unknown field "${e[0].value}"`,t,e[0].column);return{type:"field",key:e[0].value,values:e.slice(1).map(r=>r.value),location:{line:t,column:e[0].column}}}function Wn(e,t){if(e.length<2)throw new d("Invalid info entry",t,e[0]?.column??1);return{type:"info-entry",key:e[0].value,value:e.slice(1).map(r=>r.value).join(" "),location:{line:t,column:e[0].column}}}function ht(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function bt(e){return e.split(/[-_]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" ")}var Yn=/^schema\s+2(?:\.0)?$/i,Un=/^schema\s+2\.0-draft$/i;function gt(e){for(let t of e.split(/\r?\n/)){let r=t.trim();if(r)return Un.test(r)?"2.0-draft":Yn.test(r)?"2.0":"1.0"}return"1.0"}function R(e){let t=yt(e);if(!t.ok||!t.value){let r=t.diagnostics[0];throw new d(r?.message??"Failed to load WorldOrbit source",r?.line,r?.column)}return t.value}function yt(e){let t=gt(e);if(t==="2.0"||t==="2.0-draft")return qn(e,t);let r;try{r=H(e)}catch(o){return{ok:!1,value:null,diagnostics:[E(o,"parse")]}}let n;try{n=B(r)}catch(o){return{ok:!1,value:null,diagnostics:[E(o,"normalize")]}}try{V(n)}catch(o){return{ok:!1,value:null,diagnostics:[E(o,"validate")]}}return{ok:!0,value:{schemaVersion:t,ast:r,document:n,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function qn(e,t){let r;try{r=Ve(e)}catch(i){return{ok:!1,value:null,diagnostics:[E(i,"parse","load.atlas.failed")]}}let n;try{n=we(r)}catch(i){return{ok:!1,value:null,diagnostics:[E(i,"normalize","load.atlas.materialize.failed")]}}try{V(n)}catch(i){return{ok:!1,value:null,diagnostics:[E(i,"validate","load.atlas.validate.failed")]}}return{ok:!0,value:{schemaVersion:t,ast:null,document:n,atlasDocument:r,draftDocument:r,diagnostics:[...r.diagnostics]},diagnostics:[...r.diagnostics]}}var Gn={background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},xe={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function Ee(e){return e?typeof e=="string"?xe[e]??xe.atlas:{...xe.atlas,...e}:xe.atlas}function Fe(e){return{...Gn,...e}}function Ie(e){if(!e)return null;let t={query:e.query?.trim()||void 0,objectTypes:Ce(e.objectTypes??[]),tags:Ce((e.tags??[]).map(r=>r.trim()).filter(Boolean)),groupIds:Ce((e.groupIds??[]).map(r=>r.trim()).filter(Boolean)),includeAncestors:e.includeAncestors??!0};return Kn(t)?t:null}function Kn(e){return!!(e&&(e.query?.trim()||e.objectTypes?.length||e.tags?.length||e.groupIds?.length))}function Pe(e,t){let r=Ie(t),n=new Set;for(let o of e.objects)if(!o.hidden&&Jn(o,r)&&(n.add(o.objectId),r?.includeAncestors!==!1))for(let i of o.ancestorIds)n.add(i);return r?n:new Set(e.objects.filter(o=>!o.hidden).map(o=>o.objectId))}function Jn(e,t){if(!t)return!0;if(t.objectTypes?.length&&!t.objectTypes.includes(e.object.type)||t.groupIds?.length&&(!e.groupId||!t.groupIds.includes(e.groupId)))return!1;if(t.tags?.length){let r=Array.isArray(e.object.properties.tags)?e.object.properties.tags.filter(n=>typeof n=="string"):[];if(!t.tags.every(n=>r.includes(n)))return!1}if(t.query?.trim()){let r=Zn(e.object,e.label).toLowerCase();if(!t.query.toLowerCase().split(/\s+/).filter(Boolean).every(o=>r.includes(o)))return!1}return!0}function Zn(e,t){let r=Object.values(e.info),n=Object.values(e.properties).flatMap(o=>Array.isArray(o)?o:typeof o=="object"&&o&&"value"in o?[String(o.value),String(o.unit??"")]:[String(o)]).filter(Boolean);return[e.id,t,e.type,...n,...r].join(" ")}function Ce(e){return[...new Set(e)]}var Be="worldorbit-camera-root";function z(e,t={}){let r=Ee(t.theme),n=mo(t.preset??e.renderPreset??void 0),o=Fe({...n.layers,...t.layers}),i=t.subtitle??e.subtitle,a=Pe(e,t.filter??null),s=e.objects.filter(m=>!m.hidden).filter(m=>a.has(m.objectId)).filter(m=>o.structures||!ve(m.object)).sort((m,x)=>m.sortKey-x.sortKey),l=e.labels.filter(m=>!m.hidden).filter(m=>a.has(m.objectId)).filter(m=>o.structures||!ve(m.object)),c=eo(s),u=o.orbits?Qn(e,a,o.structures):{back:"",front:""},f=o.guides?e.leaders.filter(m=>!m.hidden).filter(m=>a.has(m.objectId)).filter(m=>o.structures||!ve(m.object)).map(m=>`<line class="wo-leader wo-leader-${m.mode}" x1="${m.x1}" y1="${m.y1}" x2="${m.x2}" y2="${m.y2}" data-render-id="${j(m.renderId)}" data-group-id="${M(m.groupId??"")}" />`).join(""):"",p=o.objects?s.map(m=>to(m,t.selectedObjectId??null,r)).join(""):"",h=o.labels?l.map(m=>ro(e,m,t.selectedObjectId??null)).join(""):"",g=o.metadata?`<text class="wo-title" x="56" y="64">${j(e.title)}</text>
|
|
2
|
+
<text class="wo-subtitle" x="56" y="88">${j(i)}</text>
|
|
3
|
+
<text class="wo-meta" x="56" y="${e.height-42}">${j(bo(e))}</text>`:"",w=o.background?`<rect class="wo-bg" x="0" y="0" width="${e.width}" height="${e.height}" rx="28" ry="28" />
|
|
4
4
|
<rect class="wo-bg-glow" x="0" y="0" width="${e.width}" height="${e.height}" rx="28" ry="28" />
|
|
5
5
|
${o.guides?ho(e.width,e.height):""}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" data-worldorbit-svg="true" width="${e.width}" height="${e.height}" viewBox="0 0 ${e.width} ${e.height}" preserveAspectRatio="xMidYMid meet" role="img" aria-labelledby="worldorbit-title worldorbit-desc">
|
|
6
|
-
<title id="worldorbit-title">${
|
|
7
|
-
<desc id="worldorbit-desc">A ${
|
|
6
|
+
<title id="worldorbit-title">${j(e.title)}</title>
|
|
7
|
+
<desc id="worldorbit-desc">A ${j(e.viewMode)} WorldOrbit render with ${s.length} visible objects.</desc>
|
|
8
8
|
<defs>
|
|
9
9
|
<linearGradient id="wo-bg" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
10
10
|
<stop offset="0%" stop-color="${r.backgroundStart}" />
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<stop offset="0%" stop-color="${r.backgroundGlow}" />
|
|
19
19
|
<stop offset="100%" stop-color="transparent" />
|
|
20
20
|
</radialGradient>
|
|
21
|
-
${
|
|
21
|
+
${c}
|
|
22
22
|
</defs>
|
|
23
23
|
<style>
|
|
24
24
|
.wo-bg { fill: url(#wo-bg); }
|
|
@@ -59,23 +59,28 @@
|
|
|
59
59
|
<g data-worldorbit-world="true">
|
|
60
60
|
<g data-worldorbit-camera-root="${Be}" id="${Be}">
|
|
61
61
|
<g data-worldorbit-world-content="true">
|
|
62
|
-
${o.orbits?`<g data-layer-id="orbits-back">${
|
|
62
|
+
${o.orbits?`<g data-layer-id="orbits-back">${u.back}</g>`:""}
|
|
63
63
|
${o.guides?`<g data-layer-id="guides">${f}</g>`:""}
|
|
64
64
|
${o.objects?`<g data-layer-id="objects">${p}</g>`:""}
|
|
65
|
-
${o.orbits?`<g data-layer-id="orbits-front">${
|
|
65
|
+
${o.orbits?`<g data-layer-id="orbits-front">${u.front}</g>`:""}
|
|
66
66
|
${o.labels?`<g data-layer-id="labels">${h}</g>`:""}
|
|
67
67
|
</g>
|
|
68
68
|
</g>
|
|
69
69
|
</g>
|
|
70
|
-
</svg>`}function Qn(e,t,r){let n=[],o=[];for(let i of e.orbitVisuals.filter(a=>!a.hidden&&t.has(a.objectId)&&(r||!ve(a.object)))){let a=i.bandThickness??(i.band?10:1.5),s=i.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",
|
|
70
|
+
</svg>`}function Qn(e,t,r){let n=[],o=[];for(let i of e.orbitVisuals.filter(a=>!a.hidden&&t.has(a.objectId)&&(r||!ve(a.object)))){let a=i.bandThickness??(i.band?10:1.5),s=i.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",l=`data-render-id="${j(i.renderId)}" data-orbit-object-id="${M(i.objectId)}" data-parent-id="${M(i.parentId)}" data-group-id="${M(i.groupId??"")}"`;if(i.backArcPath||i.frontArcPath){i.backArcPath&&n.push(`<path class="${s} wo-orbit-back" d="${i.backArcPath}" stroke-width="${a}" ${l} />`),i.frontArcPath&&o.push(`<path class="${s} wo-orbit-front" d="${i.frontArcPath}" stroke-width="${a}" ${l} />`);continue}if(i.kind==="ellipse"){let c=i.rx??i.radius??0,u=i.ry??i.radius??0;o.push(`<ellipse class="${s} wo-orbit-front" cx="${i.cx}" cy="${i.cy}" rx="${c}" ry="${u}" transform="rotate(${i.rotationDeg} ${i.cx} ${i.cy})" stroke-width="${a}" ${l} />`);continue}o.push(`<circle class="${s} wo-orbit-front" cx="${i.cx}" cy="${i.cy}" r="${i.radius??0}" stroke-width="${a}" ${l} />`)}return{back:n.join(""),front:o.join("")}}function eo(e){return e.filter(t=>!!t.imageHref).map(t=>io(t)).join("")}function to(e,t,r){let{object:n,x:o,y:i,radius:a,visualRadius:s}=e,l=t===e.objectId?" wo-object-selected":"",c=n.properties.kind?` wo-kind-${String(n.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=so(e,r),f=oo(e),p=f?xt(n,o,i,a,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${n.type}${c}${l}" data-object-id="${j(e.objectId)}" data-parent-id="${M(e.parentId??"")}" data-group-id="${M(e.groupId??"")}" data-render-id="${j(e.renderId)}" tabindex="0" role="button" aria-label="${j(`${n.type} ${e.objectId}`)}">
|
|
71
71
|
<circle class="wo-selection-ring" cx="${o}" cy="${i}" r="${s+8}" />
|
|
72
|
-
${no(e,
|
|
73
|
-
${
|
|
72
|
+
${no(e,u)}
|
|
73
|
+
${xt(n,o,i,a,u)}
|
|
74
74
|
${f}
|
|
75
75
|
${p}
|
|
76
|
-
</g>`}function ro(e,t,r){let n=r===t.objectId?" wo-object-label-selected":"",o=e.scaleModel.labelMultiplier;return`<g class="wo-object-label${n}" data-object-id="${
|
|
77
|
-
<text class="wo-label" x="${t.x}" y="${t.y}" text-anchor="${t.textAnchor}" font-size="${14*o}">${
|
|
78
|
-
<text class="wo-label-secondary" x="${t.x}" y="${t.secondaryY}" text-anchor="${t.textAnchor}" font-size="${11*o}">${
|
|
79
|
-
</g>`}function
|
|
76
|
+
</g>`}function ro(e,t,r){let n=r===t.objectId?" wo-object-label-selected":"",o=e.scaleModel.labelMultiplier;return`<g class="wo-object-label${n}" data-object-id="${j(t.objectId)}" data-group-id="${M(t.groupId??"")}" data-render-id="${j(t.renderId)}">
|
|
77
|
+
<text class="wo-label" x="${t.x}" y="${t.y}" text-anchor="${t.textAnchor}" font-size="${14*o}">${j(t.label)}</text>
|
|
78
|
+
<text class="wo-label-secondary" x="${t.x}" y="${t.secondaryY}" text-anchor="${t.textAnchor}" font-size="${11*o}">${j(t.secondaryLabel)}</text>
|
|
79
|
+
</g>`}function xt(e,t,r,n,o,i={}){let a=i.outlineOnly?"transparent":o.fill,s=o.tail??o.fill;switch(e.type){case"star":return i.outlineOnly?`<circle cx="${t}" cy="${r}" r="${n}" fill="transparent" stroke="${o.stroke}" stroke-width="2" />`:`<circle cx="${t}" cy="${r}" r="${n*2.4}" fill="${o.glow??"url(#wo-star-glow)"}" opacity="0.84" />
|
|
80
80
|
<circle cx="${t}" cy="${r}" r="${n}" fill="${a}" stroke="${o.stroke}" stroke-width="2" />`;case"planet":case"moon":case"belt":case"asteroid":case"ring":return`<circle cx="${t}" cy="${r}" r="${n}" fill="${a}" stroke="${o.stroke}" stroke-width="${i.outlineOnly?1.5:1.4}" />`;case"comet":return i.outlineOnly?`<circle cx="${t}" cy="${r}" r="${n}" fill="transparent" stroke="${o.stroke}" stroke-width="1.4" />`:`<path d="M ${t-n*2} ${r+n*1.3} Q ${t-n*.7} ${r+n*.3} ${t-n*.45} ${r}" fill="none" stroke="${s}" stroke-width="${Math.max(2,n*.8)}" stroke-linecap="round" opacity="0.85" />
|
|
81
|
-
<circle cx="${t}" cy="${r}" r="${n}" fill="${a}" stroke="${o.stroke}" stroke-width="1.4" />`;case"structure":return`<polygon points="${jt(t,r,n)}" fill="${a}" stroke="${o.stroke}" stroke-width="1.4" />`;case"phenomenon":
|
|
81
|
+
<circle cx="${t}" cy="${r}" r="${n}" fill="${a}" stroke="${o.stroke}" stroke-width="1.4" />`;case"structure":return`<polygon points="${jt(t,r,n)}" fill="${a}" stroke="${o.stroke}" stroke-width="1.4" />`;case"phenomenon":{let l=String(e.properties.kind??"").toLowerCase().replace(/_/g,"-");return i.outlineOnly?l==="black-hole"||l==="nebula"||l==="galaxy"||l==="dwarf-galaxy"?`<circle cx="${t}" cy="${r}" r="${n}" fill="transparent" stroke="${o.stroke}" stroke-width="1.4" />`:`<polygon points="${Re(t,r,n)}" fill="transparent" stroke="${o.stroke}" stroke-width="1.4" />`:l==="black-hole"?`<ellipse cx="${t}" cy="${r}" rx="${n*2.4}" ry="${n*.55}" fill="none" stroke="${o.accentRing??o.stroke}" stroke-width="3.5" />
|
|
82
|
+
<circle cx="${t}" cy="${r}" r="${n}" fill="${a}" stroke="${o.stroke}" stroke-width="2" />`:l==="galaxy"?`<ellipse cx="${t}" cy="${r}" rx="${n*2.6}" ry="${n}" fill="${o.halo??"none"}" stroke="none" />
|
|
83
|
+
<ellipse cx="${t}" cy="${r}" rx="${n*1.5}" ry="${n*.42}" fill="${a}" stroke="${o.stroke}" stroke-width="1.2" />
|
|
84
|
+
<circle cx="${t}" cy="${r}" r="${n*.28}" fill="${o.core??"#fff"}" stroke="none" />`:l==="dwarf-galaxy"?`<ellipse cx="${t}" cy="${r}" rx="${n*1.6}" ry="${n*.55}" fill="${a}" stroke="${o.stroke}" stroke-width="1" />
|
|
85
|
+
<circle cx="${t}" cy="${r}" r="${n*.25}" fill="${o.core??"#fff"}" stroke="none" />`:l==="nebula"?`<circle cx="${t}" cy="${r}" r="${n*2.2}" fill="${o.halo??"none"}" stroke="none" />
|
|
86
|
+
<circle cx="${t}" cy="${r}" r="${n}" fill="${a}" stroke="${o.stroke}" stroke-width="1" />`:`<polygon points="${Re(t,r,n)}" fill="${a}" stroke="${o.stroke}" stroke-width="1.4" />`}}}function no(e,t){if(!t.atmosphere)return"";let{object:r,x:n,y:o,radius:i}=e;return r.type!=="planet"&&r.type!=="moon"&&r.type!=="asteroid"?"":`<circle cx="${n}" cy="${o}" r="${i+4}" fill="none" stroke="${t.atmosphere}" stroke-width="4" opacity="0.45" />`}function oo(e){if(!e.imageHref)return"";let t=ao(e);return`<image class="wo-object-image" x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" href="${M(e.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${M($t(e))})" />`}function io(e){let{x:t,y:r,radius:n}=e,o="";switch(e.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":o=`<circle cx="${t}" cy="${r}" r="${n}" />`;break;case"structure":o=`<polygon points="${jt(t,r,n)}" />`;break;case"phenomenon":o=`<polygon points="${Re(t,r,n)}" />`;break;default:return""}return`<clipPath id="${M($t(e))}" clipPathUnits="userSpaceOnUse">${o}</clipPath>`}function ao(e){let{object:t,x:r,y:n,radius:o}=e;switch(t.type){case"structure":return{x:r-o,y:n-o,width:o*2,height:o*2};case"phenomenon":return{x:r-o*1.2,y:n-o*1.2,width:o*2.4,height:o*2.4};default:return{x:r-o,y:n-o,width:o*2,height:o*2}}}function so(e,t){let r=String(e.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),n=lo(e.object.type,r,t),o=e.fillColor&&yo(e.fillColor)?e.fillColor:n.fill,i=It(e.object.properties.albedo),a=It(e.object.properties.temperature),s=uo(o,a,i,e.object.type),l=te(s,"#ffffff",.4)??n.stroke,c=po(e.object.properties.atmosphere),u=e.object.type==="star"?vt(te(s,"#fff2cb",.4)??s,.82):void 0;return{fill:s,stroke:l,glow:u,atmosphere:c,tail:e.object.type==="comet"?vt(te(s,"#ffffff",.5)??s,.72):void 0}}function lo(e,t,r){switch(e){case"star":return{fill:r.starCore,stroke:r.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:r.accentStrong,stroke:"#fff2ea"};case"phenomenon":return co(t)}}function co(e){return e==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:e==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:e==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:e==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:e==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function uo(e,t,r,n){let o=e;if(t!==null){let i=fo(t,n);o=te(o,i,n==="star"?.42:.2)??o}if(r!==null){let i=Math.min(Math.max(r,0),1);o=te(o,i>=.5?"#ffffff":"#0f1520",Math.abs(i-.5)*.7)??o}return o}function fo(e,t){return t==="star"?e>=8e3?"#d7ebff":e>=6e3?"#fff3d8":e>=4e3?"#ffd39a":"#ff9d76":e<=180?"#8fd8ff":e>=600?"#ffb56e":"#fff1c4"}function po(e){if(typeof e!="string"||!e.trim())return;let t=e.trim().toLowerCase();return t.includes("methane")?"rgba(134, 236, 255, 0.75)":t.includes("nitrogen")||t.includes("oxygen")||t.includes("air")?"rgba(122, 194, 255, 0.75)":t.includes("carbon")||t.includes("co2")?"rgba(255, 198, 138, 0.75)":t.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function mo(e){switch(e){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function It(e){return typeof e=="number"?e:e&&typeof e=="object"&&"value"in e?e.value:null}function $t(e){return`${e.renderId}-clip`}function jt(e,t,r){return`${e},${t-r} ${e+r},${t} ${e},${t+r} ${e-r},${t}`}function Re(e,t,r){return`${e},${t-r*1.2} ${e+r*.9},${t-r*.3} ${e+r*1.2},${t+r*.8} ${e},${t+r*1.2} ${e-r*1.1},${t+r*.3} ${e-r*.8},${t-r*.8}`}function ho(e,t){let r=Array.from({length:10},(o,i)=>{let a=90+i*((e-180)/9);return`<line class="wo-grid" x1="${a}" y1="120" x2="${a}" y2="${t-70}" />`}).join(""),n=Array.from({length:6},(o,i)=>{let a=150+i*((t-240)/5);return`<line class="wo-grid" x1="56" y1="${a}" x2="${e-56}" y2="${a}" />`}).join("");return`${r}${n}`}function bo(e){return[`${e.layoutPreset} layout`,`${e.viewMode} view`,`${e.renderPreset??"custom"} preset`,`schema ${e.metadata.version??"1.0"}`].join(" - ")}function ve(e){return e.type==="structure"||e.type==="phenomenon"}function te(e,t,r){let n=ze(e),o=ze(t);if(!n||!o)return;let i=Math.min(Math.max(r,0),1);return go({r:Math.round(n.r+(o.r-n.r)*i),g:Math.round(n.g+(o.g-n.g)*i),b:Math.round(n.b+(o.b-n.b)*i)})}function vt(e,t){let r=ze(e);return r?`rgba(${r.r}, ${r.g}, ${r.b}, ${t})`:e}function ze(e){let t=e.trim();return/^#[0-9a-f]{6}$/i.test(t)?{r:Number.parseInt(t.slice(1,3),16),g:Number.parseInt(t.slice(3,5),16),b:Number.parseInt(t.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(t)?{r:Number.parseInt(t[1]+t[1],16),g:Number.parseInt(t[2]+t[2],16),b:Number.parseInt(t[3]+t[3],16)}:null}function go(e){let t=r=>r.toString(16).padStart(2,"0");return`#${t(e.r)}${t(e.g)}${t(e.b)}`}function yo(e){return!!e.trim()}function j(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function M(e){return j(e)}function St(e){return encodeURIComponent(JSON.stringify(e))}function We(e,t,r={}){return{version:"2.0",mode:t,scene:e,options:{initialViewpointId:r.initialViewpointId,initialSelectionObjectId:r.initialSelectionObjectId,initialFilter:r.initialFilter??null,atlasState:r.atlasState??null,minimap:r.minimap}}}function _e(e,t={}){let r={...e,options:{...e.options,theme:t.theme??e.options?.theme,layers:t.layers??e.options?.layers,subtitle:t.subtitle??e.options?.subtitle,preset:t.preset??e.options?.preset,initialViewpointId:t.initialViewpointId??e.options?.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId??e.options?.initialSelectionObjectId,initialFilter:t.initialFilter??e.options?.initialFilter??null,atlasState:t.atlasState??e.options?.atlasState??null,minimap:t.minimap??e.options?.minimap}},n=z(e.scene,{theme:r.options?.theme,layers:r.options?.layers,filter:r.options?.initialFilter??null,selectedObjectId:r.options?.initialSelectionObjectId??null,subtitle:r.options?.subtitle,preset:r.options?.preset});return`<div class="${$e(t.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${e.mode}" data-worldorbit-preset="${$e(r.options?.preset??e.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${$e(r.options?.initialViewpointId??"")}" data-worldorbit-payload="${$e(St(r))}">${n}</div>`}function $e(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function _(e,t={}){try{let r=R(e),n=F(r.document,Fo(r,t));return(t.mode??"static")==="interactive"?_e(We(n,"interactive",{initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}),{className:t.className??"worldorbit-block worldorbit-interactive",theme:t.theme,layers:t.layers,subtitle:t.subtitle,preset:t.preset,initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}):`<figure class="${Eo(t.className??"worldorbit-block worldorbit-static")}">${z(n,t)}</figure>`}catch(r){if(t.strict)throw r;return Ye(r instanceof Error?r.message:String(r))}}function Ye(e){return`<pre class="worldorbit-error">WorldOrbit error: ${kt(e)}</pre>`}function kt(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function Eo(e){return kt(e).replaceAll('"',""")}function Fo(e,t){let r=e.atlasDocument??e.draftDocument;return t.preset||!r?.system?.defaults.preset?t:{...t,preset:r.system.defaults.preset}}function Ot(e={}){return function(r){Tt(r,(n,o,i)=>{!i||o===-1||n.type!=="code"||!Co(n.lang)||(i.children[o]={type:"html",value:_(n.value??"",e)})})}}function Tt(e,t,r=null){let n=e.children??[];for(let o=0;o<n.length;o+=1){let i=n[o];t(i,o,e),Tt(i,t,e)}r||t(e,-1,null)}function Co(e){return(e??"").trim().toLowerCase()==="worldorbit"}function Mt(e={}){return function(r){At(r,(n,o,i)=>{if(!i||o===-1||n.type!=="element"||n.tagName!=="pre")return;let a=n.children?.[0];if(!a||a.type!=="element"||a.tagName!=="code"||!Po(a.properties?.className).includes("language-worldorbit"))return;let l=Dt(a);i.children[o]={type:"raw",value:_(l,e)}})}}function At(e,t,r=null){let n=e.children??[];for(let o=0;o<n.length;o+=1){let i=n[o];t(i,o,e),At(i,t,e)}r||t(e,-1,null)}function Po(e){return Array.isArray(e)?e.map(t=>String(t)):typeof e=="string"?e.split(/\s+/).filter(Boolean):[]}function Dt(e){return e.type==="text"?e.value??"":(e.children??[]).map(t=>Dt(t)).join("")}return Nt(Bo);})();
|