kaabalah 6.9.0 → 6.11.0

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.
@@ -162,12 +162,13 @@ function getArcheometerRenderModel(options = {}) {
162
162
  };
163
163
  const frameRadius = round(Math.max(0, Math.min(viewBox.width, viewBox.height) / 2 - padding));
164
164
  const outerRadius = round(Math.max(0, frameRadius - ARCHEOMETER_OUTER_CROWN_BLEED * scale));
165
- return {
165
+ const rings = buildRings(outerRadius, frameRadius);
166
+ const modelBase = {
166
167
  viewBox,
167
168
  center,
168
169
  outerRadius,
169
170
  scale,
170
- rings: buildRings(outerRadius, frameRadius),
171
+ rings,
171
172
  palette: resolvePalette(options.palette),
172
173
  rotationDegrees: options.rotationDegrees ?? 0,
173
174
  layers: { ...DEFAULT_LAYERS, ...options.layers ?? {} },
@@ -179,6 +180,10 @@ function getArcheometerRenderModel(options = {}) {
179
180
  zodiacSigns: options.zodiacSigns ?? DEFAULT_ARCHEOMETER_ZODIAC,
180
181
  planetaryPoints: options.planetaryPoints ?? DEFAULT_ARCHEOMETER_PLANETS
181
182
  };
183
+ return {
184
+ ...modelBase,
185
+ geometry: buildArcheometerGeometry(modelBase)
186
+ };
182
187
  }
183
188
  var DEFAULT_ARCHETYPE_UTTERANCE = DEFAULT_ARCHEOMETER_UTTERANCE;
184
189
  var DEFAULT_ARCHETYPE_TRIANGLES = DEFAULT_ARCHEOMETER_TRIANGLES;
@@ -294,7 +299,6 @@ function renderDegreeCrown(push, model) {
294
299
  function renderZodiacUtterance(push, model) {
295
300
  const { center, rings, palette, scale } = model;
296
301
  const ring = rings.zodiacUtterance;
297
- const sorted = sortedByDegree(model.utterance);
298
302
  push(`<g id="archeometer-zodiacal-utterance" aria-label="zodiacal crown of the utterance">`);
299
303
  for (let i = 0; i < 12; i++) {
300
304
  const degree = i * 30;
@@ -312,9 +316,9 @@ function renderZodiacUtterance(push, model) {
312
316
  )}" stroke-opacity="0.34" stroke-width="${fmt(0.7 * scale)}"/>`
313
317
  );
314
318
  }
315
- for (const point of sorted) {
316
- const a = angleOf(model, point.degree);
317
- const p = polarToXY(center, ring.r1 + (ring.r2 - ring.r1) * 0.58, a);
319
+ for (const geometry of model.geometry.utterancePoints) {
320
+ const point = geometry.data;
321
+ const p = geometry.anchor;
318
322
  const shieldR = (ring.r2 - ring.r1) * 0.22;
319
323
  const letterParts = point.letter.split(",").map((part) => part.trim()).filter(Boolean);
320
324
  const isStacked = letterParts.length > 1;
@@ -343,11 +347,11 @@ function renderPlanetaryUtterance(push, model) {
343
347
  const { center, rings, palette, scale } = model;
344
348
  const ring = rings.planetaryUtterance;
345
349
  const clipOuter = planetaryTriangleClipOuterRadius(rings);
346
- const vertexRadius = clipOuter;
347
350
  push(`<g id="archeometer-planetary-utterance" aria-label="four trigones of the planetary utterance">`);
348
351
  push(`<g clip-path="url(#archeometer-planetary-clip)">`);
349
- for (const triangle of model.triangles) {
350
- const vertices = triangle.vertices.map((degree) => polarToXY(center, vertexRadius, angleOf(model, degree)));
352
+ for (const triangleGeometry of model.geometry.triangles) {
353
+ const triangle = triangleGeometry.data;
354
+ const vertices = triangleGeometry.vertices;
351
355
  if (triangle.vertexFills) {
352
356
  const centroid = polygonCentroid(vertices);
353
357
  const midpoints = vertices.map((vertex, index) => midpoint(vertex, vertices[(index + 1) % vertices.length]));
@@ -356,17 +360,18 @@ function renderPlanetaryUtterance(push, model) {
356
360
  const nextMidpoint = midpoints[index];
357
361
  push(`<path class="archeometer-trigone-vertex-fill" data-triangle="${escapeAttr(triangle.id)}" data-degree="${fmt(normalizeDegrees(triangle.vertices[index]))}" d="${polygonPath([vertex, nextMidpoint, centroid, previousMidpoint])}" fill="${escapeAttr(triangle.vertexFills[index])}" fill-opacity="0.54" stroke="none"/>`);
358
362
  }
359
- push(`<path class="archeometer-trigone" data-triangle="${escapeAttr(triangle.id)}" d="${polygonPath(vertices)}" fill="none" stroke="${escapeAttr(palette.ink)}" stroke-opacity="0.82" stroke-width="${fmt(1.35 * scale)}"/>`);
363
+ push(`<path class="archeometer-trigone" data-triangle="${escapeAttr(triangle.id)}" d="${triangleGeometry.path}" fill="none" stroke="${escapeAttr(palette.ink)}" stroke-opacity="0.82" stroke-width="${fmt(1.35 * scale)}"/>`);
360
364
  } else {
361
- push(`<path class="archeometer-trigone" data-triangle="${escapeAttr(triangle.id)}" d="${polygonPath(vertices)}" fill="${escapeAttr(triangle.fill)}" fill-opacity="0.52" stroke="${escapeAttr(palette.ink)}" stroke-opacity="0.82" stroke-width="${fmt(1.35 * scale)}"/>`);
365
+ push(`<path class="archeometer-trigone" data-triangle="${escapeAttr(triangle.id)}" d="${triangleGeometry.path}" fill="${escapeAttr(triangle.fill)}" fill-opacity="0.52" stroke="${escapeAttr(palette.ink)}" stroke-opacity="0.82" stroke-width="${fmt(1.35 * scale)}"/>`);
362
366
  }
363
367
  }
364
368
  push(`</g>`);
365
- for (const label of sortedByDegree(model.triangleLabels)) {
369
+ for (const labelGeometry of model.geometry.triangleLabels) {
370
+ const label = labelGeometry.data;
366
371
  if (!label.label)
367
372
  continue;
368
373
  const a = angleOf(model, label.degree);
369
- const labelPoint = polarToXY(center, ring.r1 + (clipOuter - ring.r1) * 0.56, a);
374
+ const labelPoint = labelGeometry.anchor;
370
375
  push(textSvg(label.label, labelPoint, 12 * scale, palette.ink, 0, "middle", 700));
371
376
  if (label.number !== void 0) {
372
377
  const numberPoint = polarToXY(center, ring.r1 + (clipOuter - ring.r1) * 0.8, a);
@@ -396,10 +401,11 @@ function renderCosmologicalMusic(push, model) {
396
401
  push(`<path class="archeometer-music-staff-line" data-degree="${fmt(normalizeDegrees(note.degree))}" d="${arcSegmentPath(center, r, start, end)}" fill="none" stroke="${escapeAttr(palette.ink)}" stroke-opacity="0.58" stroke-width="${fmt(0.48 * scale)}" stroke-linecap="round"/>`);
397
402
  }
398
403
  }
399
- for (const note of notes) {
404
+ for (const noteGeometry of model.geometry.musicalNotes) {
405
+ const note = noteGeometry.data;
400
406
  if (!note.note)
401
407
  continue;
402
- const p = polarToXY(center, (ring.r1 + ring.r2) / 2, angleOf(model, note.degree));
408
+ const p = noteGeometry.anchor;
403
409
  push(textSvg(note.note, p, 11.8 * scale, palette.ink, tangentRotation(angleOf(model, note.degree)), "middle", 700));
404
410
  }
405
411
  push(`</g>`);
@@ -409,7 +415,8 @@ function renderAstralZodiac(push, model) {
409
415
  const ring = rings.astralZodiac;
410
416
  const ringWidth = ring.r2 - ring.r1;
411
417
  push(`<g id="archeometer-astral-zodiac" aria-label="astral zodiacal crown">`);
412
- for (const sign of sortedByDegree(model.zodiacSigns)) {
418
+ for (const signGeometry of model.geometry.zodiacSigns) {
419
+ const sign = signGeometry.data;
413
420
  const sector = annularSectorPath(
414
421
  center,
415
422
  ring.r1,
@@ -427,9 +434,10 @@ function renderAstralZodiac(push, model) {
427
434
  }
428
435
  const markerRadius = Math.min(ringWidth * 0.33, 13 * scale);
429
436
  const glyphSize = 17.5 * scale;
430
- for (const sign of sortedByDegree(model.zodiacSigns)) {
437
+ for (const signGeometry of model.geometry.zodiacSigns) {
438
+ const sign = signGeometry.data;
431
439
  const pointColor = triangleVertexFillForDegree(model, sign.degree) ?? sign.color ?? nearestUtterance(sign.degree, model.utterance)?.color ?? palette.ringFills.astralZodiac;
432
- const p = polarToXY(center, (ring.r1 + ring.r2) / 2, angleOf(model, sign.degree));
440
+ const p = signGeometry.anchor;
433
441
  push(
434
442
  `<g class="archeometer-zodiac-sign" data-sign="${escapeAttr(sign.name)}" data-degree="${fmt(
435
443
  normalizeDegrees(sign.degree)
@@ -450,7 +458,8 @@ function renderAstralPlanetary(push, model) {
450
458
  const ring = rings.astralPlanetary;
451
459
  const ringWidth = ring.r2 - ring.r1;
452
460
  push(`<g id="archeometer-astral-planetary" aria-label="astral planetary crown">`);
453
- for (const planet of sortedByDegree(model.planetaryPoints)) {
461
+ for (const planetGeometry of model.geometry.planetaryPoints) {
462
+ const planet = planetGeometry.data;
454
463
  const pointColor = triangleVertexFillForDegree(model, planet.degree) ?? planet.color ?? nearestUtterance(planet.degree, model.utterance)?.color ?? palette.ringFills.astralPlanetary;
455
464
  const sector = annularSectorPath(
456
465
  center,
@@ -471,8 +480,9 @@ function renderAstralPlanetary(push, model) {
471
480
  push(lineSvg(line, palette.ringStroke, 0.6 * scale, 0.42, "archeometer-astral-planetary-divider", ` data-degree="${fmt(degree)}"`));
472
481
  }
473
482
  const markerRadius = Math.min(ringWidth * 0.33, 13 * scale);
474
- for (const planet of sortedByDegree(model.planetaryPoints)) {
475
- const p = polarToXY(center, (ring.r1 + ring.r2) / 2, angleOf(model, planet.degree));
483
+ for (const planetGeometry of model.geometry.planetaryPoints) {
484
+ const planet = planetGeometry.data;
485
+ const p = planetGeometry.anchor;
476
486
  const color = triangleVertexFillForDegree(model, planet.degree) ?? planet.color ?? nearestUtterance(planet.degree, model.utterance)?.color ?? palette.ink;
477
487
  const glyphSize = (planet.name === "Moon" ? 17 : 18.5) * scale;
478
488
  push(
@@ -634,6 +644,84 @@ function renderFrame(push, model) {
634
644
  );
635
645
  push(`</g>`);
636
646
  }
647
+ function buildArcheometerGeometry(model) {
648
+ const { center, rings, scale } = model;
649
+ const utteranceRing = rings.zodiacUtterance;
650
+ const triangleLabelRing = rings.planetaryUtterance;
651
+ const musicRing = rings.cosmologicalMusic;
652
+ const zodiacRing = rings.astralZodiac;
653
+ const planetRing = rings.astralPlanetary;
654
+ const planetaryClipOuter = planetaryTriangleClipOuterRadius(rings);
655
+ const whiteRaySolarRadius = rings.solarCenter.r2;
656
+ const pointHitRadius = Math.max(11 * scale, 8);
657
+ const element = (layerId, idPrefix, item, radius, hitRadius = pointHitRadius) => {
658
+ const anchor = polarToXY(center, radius, angleOf(model, item.degree));
659
+ return {
660
+ id: `${idPrefix}-${slugForGeometry(item.id ?? item.name ?? item.note ?? item.label ?? item.degree)}`,
661
+ layerId,
662
+ data: item,
663
+ degree: normalizeDegrees(item.degree),
664
+ anchor,
665
+ hitTarget: { kind: "circle", cx: anchor.x, cy: anchor.y, r: hitRadius }
666
+ };
667
+ };
668
+ const triangles = model.triangles.map((triangle) => {
669
+ const vertices = triangle.vertices.map(
670
+ (degree) => polarToXY(center, planetaryClipOuter, angleOf(model, degree))
671
+ );
672
+ const centroid = polygonCentroid(vertices);
673
+ return {
674
+ id: `triangle-${slugForGeometry(triangle.id)}`,
675
+ layerId: "planetaryUtterance",
676
+ data: triangle,
677
+ vertices,
678
+ centroid,
679
+ path: polygonPath(vertices),
680
+ hitTarget: { kind: "polygon", points: vertices }
681
+ };
682
+ });
683
+ const degreeTicks = Array.from({ length: 12 }, (_, index) => {
684
+ const degree = index * 30;
685
+ const angle = angleOf(model, degree);
686
+ return {
687
+ id: `degree-${degree}`,
688
+ degree,
689
+ outerAnchor: polarToXY(center, (rings.degreeOuter.r1 + rings.degreeOuter.r2) / 2, angle),
690
+ innerAnchor: polarToXY(center, (rings.degreeInner.r1 + rings.degreeInner.r2) / 2, angle)
691
+ };
692
+ });
693
+ const rays = Array.from({ length: 12 }, (_, index) => index * 30).filter((degree) => degree !== 90 && degree !== 270).map((degree) => ({
694
+ id: `white-ray-${degree}`,
695
+ degree,
696
+ layerId: "whiteRays",
697
+ line: lineFromPolar(center, whiteRaySolarRadius, 3.3, angleOf(model, degree))
698
+ }));
699
+ return {
700
+ utterancePoints: sortedByDegree(model.utterance).map(
701
+ (point) => element("zodiacUtterance", "utterance", point, utteranceRing.r1 + (utteranceRing.r2 - utteranceRing.r1) * 0.58)
702
+ ),
703
+ triangles,
704
+ triangleLabels: sortedByDegree(model.triangleLabels).map(
705
+ (label) => element("triangleLabels", "triangle-label", label, triangleLabelRing.r1 + (planetaryClipOuter - triangleLabelRing.r1) * 0.56)
706
+ ),
707
+ musicalNotes: sortedByDegree(model.musicalNotes).map(
708
+ (note) => element("cosmologicalMusic", "music", note, (musicRing.r1 + musicRing.r2) / 2)
709
+ ),
710
+ zodiacSigns: sortedByDegree(model.zodiacSigns).map(
711
+ (sign) => element("astralZodiac", "zodiac", sign, (zodiacRing.r1 + zodiacRing.r2) / 2, Math.min((zodiacRing.r2 - zodiacRing.r1) * 0.33, 13 * scale))
712
+ ),
713
+ planetaryPoints: sortedByDegree(model.planetaryPoints).map(
714
+ (planet) => element("astralPlanetary", "planet", planet, (planetRing.r1 + planetRing.r2) / 2, Math.min((planetRing.r2 - planetRing.r1) * 0.33, 13 * scale))
715
+ ),
716
+ degreeTicks,
717
+ rays,
718
+ center: {
719
+ id: "solar-center",
720
+ anchor: center,
721
+ hitTarget: { kind: "circle", cx: center.x, cy: center.y, r: rings.solarCenter.r2 }
722
+ }
723
+ };
724
+ }
637
725
  function buildRings(contentRadius, frameRadius = contentRadius) {
638
726
  const ring = (id2, r1, r2, radius = contentRadius) => ({
639
727
  id: id2,
@@ -775,6 +863,9 @@ function polygonCentroid(points) {
775
863
  function sortedByDegree(items) {
776
864
  return [...items].sort((a, b) => normalizeDegrees(a.degree) - normalizeDegrees(b.degree));
777
865
  }
866
+ function slugForGeometry(value) {
867
+ return String(value).trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item";
868
+ }
778
869
  function nearestUtterance(degree, utterance) {
779
870
  let best;
780
871
  let bestDelta = Number.POSITIVE_INFINITY;
@@ -1253,7 +1344,7 @@ function generateAstroGlyphSvg(keyOrGlyph, options = {}) {
1253
1344
  const svg = generateGlyphSvg(glyph.primitives, options);
1254
1345
  return svg.replace("<svg ", `<svg data-astro-glyph="${escapeAttr2(glyph.key)}" data-astro-glyph-category="${glyph.category}" `);
1255
1346
  }
1256
- function getAstroWheelRenderModel(chart, options = {}) {
1347
+ function buildAstroWheelSvgModel(chart, options = {}) {
1257
1348
  const viewBox = normalizeViewBox2(options.viewBox);
1258
1349
  const palette = resolvePalette2(options.palette, options.background ?? "transparent");
1259
1350
  const excludedBodies = resolveExcludedBodies(options.excludeBodies);
@@ -1261,7 +1352,7 @@ function getAstroWheelRenderModel(chart, options = {}) {
1261
1352
  viewBox.width / ASTRO_WHEEL_DEFAULT_VIEWBOX.width,
1262
1353
  viewBox.height / ASTRO_WHEEL_DEFAULT_VIEWBOX.height
1263
1354
  );
1264
- const padding = options.padding ?? round2(18 * scale + getExternalPointPadding(options, scale));
1355
+ const padding = options.padding ?? round2(18 * scale + getExternalPointPadding());
1265
1356
  const center = {
1266
1357
  x: round2(viewBox.minX + viewBox.width / 2),
1267
1358
  y: round2(viewBox.minY + viewBox.height / 2)
@@ -1271,6 +1362,7 @@ function getAstroWheelRenderModel(chart, options = {}) {
1271
1362
  const rings = buildRings2(outerRadius, options.layout?.rings);
1272
1363
  const pointConnectorMode = options.layout?.pointConnectors ?? "auto";
1273
1364
  const maxPointDisplacementDegrees = options.layout?.maxPointDisplacementDegrees ?? DEFAULT_POINT_DISPLACEMENT_DEGREES;
1365
+ const railVisibility = resolveRailVisibility(options.layout?.rails);
1274
1366
  const resolvedPoints = resolvePointOptions(options.points);
1275
1367
  const resolvedHouses = resolveHouseOptions(options.houses);
1276
1368
  const resolvedAspects = resolveAspectOptions(options.aspects);
@@ -1289,7 +1381,7 @@ function getAstroWheelRenderModel(chart, options = {}) {
1289
1381
  rings,
1290
1382
  scale
1291
1383
  }) : [];
1292
- const basePointLayer = buildPointLayer({
1384
+ const basePointGroup = buildPointGroup({
1293
1385
  layer: {
1294
1386
  id: "birth",
1295
1387
  label: "Birth",
@@ -1308,28 +1400,15 @@ function getAstroWheelRenderModel(chart, options = {}) {
1308
1400
  palette,
1309
1401
  excludedBodies,
1310
1402
  pointConnectorMode,
1311
- maxDisplacementDegrees: maxPointDisplacementDegrees
1403
+ maxDisplacementDegrees: maxPointDisplacementDegrees,
1404
+ railVisibility
1312
1405
  });
1313
- const extraPointLayers = (options.pointLayers ?? []).map(
1314
- (layer) => buildPointLayer({
1315
- layer,
1316
- center,
1317
- angleOf: angleOf2,
1318
- rings,
1319
- scale,
1320
- palette,
1321
- excludedBodies,
1322
- pointConnectorMode,
1323
- maxDisplacementDegrees: maxPointDisplacementDegrees
1324
- })
1325
- );
1326
- const pointLayers = [
1327
- ...resolvedPoints.enabled ? [basePointLayer] : [],
1328
- ...extraPointLayers
1406
+ const pointGroups = [
1407
+ ...resolvedPoints.enabled ? [basePointGroup] : []
1329
1408
  ];
1330
- const points = pointLayers.flatMap((layer) => [...layer.points]);
1409
+ const points = pointGroups.flatMap((layer) => [...layer.points]);
1331
1410
  const pointByKey = Object.fromEntries(points.map((point) => [point.key, point]));
1332
- const baseAspectLayer = resolvedAspects.enabled ? buildAspectLayer({
1411
+ const baseAspectGroup = resolvedAspects.enabled ? buildAspectGroup({
1333
1412
  layer: {
1334
1413
  id: "birth",
1335
1414
  label: "Birth aspects",
@@ -1345,23 +1424,11 @@ function getAstroWheelRenderModel(chart, options = {}) {
1345
1424
  palette,
1346
1425
  excludedBodies
1347
1426
  }) : null;
1348
- const extraAspectLayers = (options.aspectLayers ?? []).map(
1349
- (layer) => buildAspectLayer({
1350
- layer,
1351
- chart: layer.chart ?? chart,
1352
- pointByKey,
1353
- center,
1354
- angleOf: angleOf2,
1355
- rings,
1356
- palette,
1357
- excludedBodies
1358
- })
1359
- );
1360
- const aspectLayers = [
1361
- ...baseAspectLayer ? [baseAspectLayer] : [],
1362
- ...extraAspectLayers
1427
+ const aspectGroups = [
1428
+ ...baseAspectGroup ? [baseAspectGroup] : []
1363
1429
  ];
1364
- const aspectLines = aspectLayers.flatMap((layer) => [...layer.aspectLines]);
1430
+ const aspectLines = aspectGroups.flatMap((layer) => [...layer.aspectLines]);
1431
+ const positionRails = basePointGroup.rails;
1365
1432
  return {
1366
1433
  viewBox,
1367
1434
  center,
@@ -1375,13 +1442,14 @@ function getAstroWheelRenderModel(chart, options = {}) {
1375
1442
  points,
1376
1443
  pointByKey,
1377
1444
  aspectLines,
1378
- pointLayers,
1379
- aspectLayers,
1445
+ pointGroups,
1446
+ aspectGroups,
1447
+ positionRails,
1380
1448
  palette
1381
1449
  };
1382
1450
  }
1383
1451
  function generateAstroWheelSvg(chart, options = {}) {
1384
- const model = getAstroWheelRenderModel(chart, options);
1452
+ const model = buildAstroWheelSvgModel(chart, options);
1385
1453
  const viewBox = model.viewBox;
1386
1454
  const zodiacOptions = resolveZodiacOptions(options.zodiac);
1387
1455
  const houseOptions = resolveHouseOptions(options.houses);
@@ -1405,6 +1473,7 @@ function generateAstroWheelSvg(chart, options = {}) {
1405
1473
  `<rect x="${fmt2(viewBox.minX)}" y="${fmt2(viewBox.minY)}" width="${fmt2(viewBox.width)}" height="${fmt2(viewBox.height)}" fill="${escapeAttr2(background)}"/>`
1406
1474
  );
1407
1475
  }
1476
+ renderAspectBoundary(push, model);
1408
1477
  renderAspects(push, model);
1409
1478
  renderZodiac(push, model, zodiacOptions);
1410
1479
  renderHouses(push, model, houseOptions);
@@ -1435,23 +1504,15 @@ function renderSvgDefs(push, model) {
1435
1504
  push(`</defs>`);
1436
1505
  }
1437
1506
  function renderAspects(push, model) {
1438
- if (model.aspectLayers.length === 0) {
1507
+ if (model.aspectGroups.length === 0) {
1439
1508
  return;
1440
1509
  }
1441
- const guideRadius = model.rings.aspects.r2 * 0.96;
1442
- const innerGuideRadius = guideRadius * 0.52;
1443
1510
  push(`<g id="astro-wheel-aspects" aria-label="aspects">`);
1444
- push(
1445
- `<circle cx="${fmt2(model.center.x)}" cy="${fmt2(model.center.y)}" r="${fmt2(guideRadius)}" fill="none" stroke="${escapeAttr2(model.palette.aspectGuide)}" stroke-opacity="0.9" stroke-width="${fmt2(1.25 * model.scale)}"/>`
1446
- );
1447
- push(
1448
- `<circle cx="${fmt2(model.center.x)}" cy="${fmt2(model.center.y)}" r="${fmt2(innerGuideRadius)}" fill="none" stroke="${escapeAttr2(model.palette.aspectGuide)}" stroke-opacity="0.28" stroke-width="${fmt2(model.scale)}"/>`
1449
- );
1450
- for (const layer of model.aspectLayers) {
1451
- push(`<g class="astro-wheel-aspect-layer" data-aspect-layer="${escapeAttr2(layer.id)}"${layer.label ? ` aria-label="${escapeAttr2(layer.label)}"` : ""}>`);
1511
+ for (const layer of model.aspectGroups) {
1512
+ push(`<g class="astro-wheel-aspect-group" data-aspect-group="${escapeAttr2(layer.id)}"${layer.label ? ` aria-label="${escapeAttr2(layer.label)}"` : ""}>`);
1452
1513
  for (const aspect of layer.aspectLines) {
1453
1514
  push(
1454
- `<line data-aspect-layer="${escapeAttr2(aspect.layerId)}" data-aspect="${escapeAttr2(aspect.aspect)}" data-planet-a="${escapeAttr2(aspect.planetA)}" data-planet-b="${escapeAttr2(aspect.planetB)}" x1="${fmt2(aspect.line.x1)}" y1="${fmt2(aspect.line.y1)}" x2="${fmt2(aspect.line.x2)}" y2="${fmt2(aspect.line.y2)}" stroke="${escapeAttr2(aspect.color)}" stroke-opacity="${fmt2(aspect.opacity)}" stroke-width="${fmt2(aspect.strokeWidth * model.scale)}" stroke-linecap="round"/>`
1515
+ `<line data-aspect-group="${escapeAttr2(aspect.groupId)}" data-aspect="${escapeAttr2(aspect.aspect)}" data-planet-a="${escapeAttr2(aspect.planetA)}" data-planet-b="${escapeAttr2(aspect.planetB)}" x1="${fmt2(aspect.line.x1)}" y1="${fmt2(aspect.line.y1)}" x2="${fmt2(aspect.line.x2)}" y2="${fmt2(aspect.line.y2)}" stroke="${escapeAttr2(aspect.color)}" stroke-opacity="${fmt2(aspect.opacity)}" stroke-width="${fmt2(aspect.strokeWidth * model.scale)}" stroke-linecap="round"/>`
1455
1516
  );
1456
1517
  }
1457
1518
  push(`</g>`);
@@ -1461,6 +1522,11 @@ function renderAspects(push, model) {
1461
1522
  );
1462
1523
  push(`</g>`);
1463
1524
  }
1525
+ function renderAspectBoundary(push, model) {
1526
+ push(
1527
+ `<circle id="astro-wheel-aspect-boundary" cx="${fmt2(model.center.x)}" cy="${fmt2(model.center.y)}" r="${fmt2(model.rings.aspects.r2)}" fill="none" stroke="${escapeAttr2(model.palette.aspectGuide)}" stroke-opacity="0.9" stroke-width="${fmt2(1.25 * model.scale)}"/>`
1528
+ );
1529
+ }
1464
1530
  function renderZodiac(push, model, options) {
1465
1531
  if (!options.segments && !options.glyphs && !options.ticks) {
1466
1532
  return;
@@ -1533,30 +1599,21 @@ function renderHouses(push, model, options) {
1533
1599
  );
1534
1600
  }
1535
1601
  }
1536
- if (options.angles) {
1537
- for (const marker of model.angleMarkers) {
1538
- push(`<g data-angle-marker="${marker.key}">`);
1539
- push(
1540
- `<line x1="${fmt2(marker.line.x1)}" y1="${fmt2(marker.line.y1)}" x2="${fmt2(marker.line.x2)}" y2="${fmt2(marker.line.y2)}" stroke="${escapeAttr2(model.palette.angleLine)}" stroke-width="${fmt2(2 * model.scale)}"/>`
1541
- );
1542
- push(`</g>`);
1543
- }
1544
- }
1545
1602
  push(`</g>`);
1546
1603
  }
1547
1604
  function renderPlanets(push, model) {
1548
- if (model.pointLayers.length === 0) {
1605
+ if (model.pointGroups.length === 0) {
1549
1606
  return;
1550
1607
  }
1551
1608
  push(`<g id="astro-wheel-planets" aria-label="planets">`);
1552
- for (const layer of model.pointLayers) {
1553
- renderPointLayerGuide(push, layer, model);
1609
+ for (const layer of model.pointGroups) {
1610
+ renderPointGroupGuide(push, layer, model);
1554
1611
  }
1555
- for (const layer of model.pointLayers) {
1556
- push(`<g class="astro-wheel-point-layer" data-point-layer="${escapeAttr2(layer.id)}"${layer.label ? ` aria-label="${escapeAttr2(layer.label)}"` : ""}>`);
1612
+ for (const layer of model.pointGroups) {
1613
+ push(`<g class="astro-wheel-point-group" data-point-group="${escapeAttr2(layer.id)}"${layer.label ? ` aria-label="${escapeAttr2(layer.label)}"` : ""}>`);
1557
1614
  for (const point of layer.points) {
1558
1615
  push(
1559
- `<g class="astro-wheel-point" data-point-layer="${escapeAttr2(point.layerId)}" data-point-key="${escapeAttr2(point.key)}" data-point-name="${escapeAttr2(point.name)}" data-point-kind="${point.kind}" data-longitude="${fmt2(point.longitude)}">`
1616
+ `<g class="astro-wheel-point" data-point-group="${escapeAttr2(point.groupId)}" data-point-key="${escapeAttr2(point.key)}" data-point-name="${escapeAttr2(point.name)}" data-point-kind="${point.kind}" data-longitude="${fmt2(point.longitude)}">`
1560
1617
  );
1561
1618
  push(`<title>${escapeText2(point.name)} ${fmt2(point.longitude)}\xB0</title>`);
1562
1619
  push(
@@ -1577,17 +1634,17 @@ function renderPlanets(push, model) {
1577
1634
  }
1578
1635
  push(`</g>`);
1579
1636
  }
1580
- function renderPointLayerGuide(push, layer, model) {
1637
+ function renderPointGroupGuide(push, layer, model) {
1581
1638
  const isExternal = layer.radius > model.rings.houses.r2 + model.scale;
1582
1639
  if (!isExternal) {
1583
1640
  return;
1584
1641
  }
1585
1642
  push(
1586
- `<circle class="astro-wheel-external-point-ring" data-point-layer="${escapeAttr2(layer.id)}" cx="${fmt2(model.center.x)}" cy="${fmt2(model.center.y)}" r="${fmt2(layer.radius)}" fill="none" stroke="${escapeAttr2(layer.tickColor)}" stroke-opacity="0.32" stroke-width="${fmt2(1.15 * model.scale)}"/>`
1643
+ `<circle class="astro-wheel-external-point-ring" data-point-group="${escapeAttr2(layer.id)}" cx="${fmt2(model.center.x)}" cy="${fmt2(model.center.y)}" r="${fmt2(layer.radius)}" fill="none" stroke="${escapeAttr2(layer.tickColor)}" stroke-opacity="0.32" stroke-width="${fmt2(1.15 * model.scale)}"/>`
1587
1644
  );
1588
1645
  }
1589
1646
  function renderGlyphOverlay(push, model) {
1590
- if (model.angleMarkers.length === 0 && model.pointLayers.length === 0) {
1647
+ if (model.angleMarkers.length === 0 && model.pointGroups.length === 0) {
1591
1648
  return;
1592
1649
  }
1593
1650
  push(`<g id="astro-wheel-glyph-layer" aria-label="chart glyphs">`);
@@ -1598,10 +1655,10 @@ function renderGlyphOverlay(push, model) {
1598
1655
  }
1599
1656
  push(`</g>`);
1600
1657
  }
1601
- if (model.pointLayers.length > 0) {
1658
+ if (model.pointGroups.length > 0) {
1602
1659
  push(`<g id="astro-wheel-point-glyphs" aria-label="planet glyphs">`);
1603
- for (const layer of model.pointLayers) {
1604
- push(`<g class="astro-wheel-point-glyph-layer" data-point-layer="${escapeAttr2(layer.id)}"${layer.label ? ` aria-label="${escapeAttr2(layer.label)} glyphs"` : ""}>`);
1660
+ for (const layer of model.pointGroups) {
1661
+ push(`<g class="astro-wheel-point-glyph-layer" data-point-group="${escapeAttr2(layer.id)}"${layer.label ? ` aria-label="${escapeAttr2(layer.label)} glyphs"` : ""}>`);
1605
1662
  for (const point of layer.points) {
1606
1663
  renderPointLabelGroup(push, point, model);
1607
1664
  }
@@ -1614,37 +1671,21 @@ function renderGlyphOverlay(push, model) {
1614
1671
  function renderAngleGlyph(push, marker, model) {
1615
1672
  const label = angleDisplayLabel(marker.key);
1616
1673
  const position = formatInlinePosition(marker.zodiacPosition);
1617
- const labelFontSize = marker.labelFontSize;
1618
- const positionFontSize = clamp(marker.labelFontSize * 0.52, 5.5 * model.scale, 9 * model.scale);
1619
- const signScale = positionFontSize * 0.88;
1620
- const gap = clamp(3.2 * model.scale, 2.5, 5);
1621
- const labelWidth = estimateTextWidth(label, labelFontSize);
1674
+ const positionFontSize = clamp(marker.labelFontSize * 0.62, 6 * model.scale, 10 * model.scale);
1675
+ const gap = clamp(3 * model.scale, 2, 5);
1622
1676
  const degreeWidth = estimateTextWidth(position.degreesText, positionFontSize);
1623
1677
  const minutesWidth = estimateTextWidth(position.minutesText, positionFontSize);
1624
- const totalWidth = labelWidth + gap + degreeWidth + gap + signScale + gap + minutesWidth;
1678
+ const totalWidth = degreeWidth + gap + minutesWidth;
1625
1679
  const startX = -totalWidth / 2;
1626
- const labelX = startX;
1627
- const degreeX = labelX + labelWidth + gap;
1628
- const signX = degreeX + degreeWidth + gap + signScale / 2;
1629
- const minutesX = signX + signScale / 2 + gap;
1680
+ const degreeX = startX;
1681
+ const minutesX = degreeX + degreeWidth + gap;
1630
1682
  push(
1631
1683
  `<g class="astro-wheel-angle-glyph-label" data-angle-marker="${marker.key}" data-longitude="${fmt2(marker.longitude)}" transform="translate(${fmt2(marker.labelPosition.x)} ${fmt2(marker.labelPosition.y)}) rotate(${fmt2(marker.labelRotation)})" filter="url(#${GLYPH_OUTLINE_FILTER_ID})">`
1632
1684
  );
1633
1685
  push(`<title>${escapeText2(`${label} ${position.degreesText} ${position.sign} ${position.minutesText}`)}</title>`);
1634
- push(
1635
- `<text class="astro-wheel-angle-label" x="${fmt2(labelX)}" y="0" font-family="${textFontFamily2()}" font-size="${fmt2(labelFontSize)}" text-anchor="start" dominant-baseline="middle" fill="${escapeAttr2(model.palette.angleLabel)}" font-weight="700">${escapeText2(label)}</text>`
1636
- );
1637
1686
  push(
1638
1687
  `<text class="astro-wheel-angle-degree" x="${fmt2(degreeX)}" y="0" font-family="${textFontFamily2()}" font-size="${fmt2(positionFontSize)}" text-anchor="start" dominant-baseline="middle" fill="${escapeAttr2(model.palette.angleLabel)}">${escapeText2(position.degreesText)}</text>`
1639
1688
  );
1640
- renderInlineSignGlyph(
1641
- push,
1642
- position.sign,
1643
- signX,
1644
- 0,
1645
- signScale,
1646
- model.palette.angleLabel
1647
- );
1648
1689
  push(
1649
1690
  `<text class="astro-wheel-angle-minutes" x="${fmt2(minutesX)}" y="0" font-family="${textFontFamily2()}" font-size="${fmt2(positionFontSize)}" text-anchor="start" dominant-baseline="middle" fill="${escapeAttr2(model.palette.angleLabel)}">${escapeText2(position.minutesText)}</text>`
1650
1691
  );
@@ -1658,24 +1699,29 @@ function angleDisplayLabel(key) {
1658
1699
  return key;
1659
1700
  }
1660
1701
  function renderPointLabelGroup(push, point, model) {
1661
- const layout = getPointLabelLayout(point, model.scale);
1662
- const boundsAttr = point.labelBounds ? ` data-label-bounds="${escapeAttr2(formatLabelBounds(point.labelBounds))}"` : "";
1663
1702
  push(
1664
- `<g class="astro-wheel-point-label" data-point-layer="${escapeAttr2(point.layerId)}" data-point-key="${escapeAttr2(point.key)}" data-point-name="${escapeAttr2(point.name)}" data-point-kind="${point.kind}" data-longitude="${fmt2(point.longitude)}"${boundsAttr} transform="translate(${fmt2(point.glyphPosition.x)} ${fmt2(point.glyphPosition.y)})" filter="url(#${GLYPH_OUTLINE_FILTER_ID})">`
1703
+ `<g class="astro-wheel-point-label" data-point-group="${escapeAttr2(point.groupId)}" data-point-key="${escapeAttr2(point.key)}" data-point-name="${escapeAttr2(point.name)}" data-point-kind="${point.kind}" data-longitude="${fmt2(point.longitude)}" data-display-longitude="${fmt2(point.displayLongitude)}" data-house="${point.house ?? ""}" transform="translate(${fmt2(point.glyphPosition.x)} ${fmt2(point.glyphPosition.y)})" filter="url(#${GLYPH_OUTLINE_FILTER_ID})">`
1665
1704
  );
1666
1705
  push(`<title>${escapeText2(pointLabelTitle(point))}</title>`);
1667
- renderPointGlyph(push, point, layout.glyphX, layout.glyphY, layout.glyphScale, model.palette.glyphHalo);
1668
- if (point.retrograde) {
1669
- renderRetrogradeMarker(
1670
- push,
1671
- layout.retrogradeX,
1672
- layout.retrogradeY,
1673
- layout.retrogradeFontSize,
1674
- point.color
1706
+ renderPointGlyph(push, point, 0, 0, point.glyphScale, model.palette.glyphHalo);
1707
+ push(`</g>`);
1708
+ for (const label of point.railLabels) {
1709
+ if (!label.visible)
1710
+ continue;
1711
+ push(
1712
+ `<g class="astro-wheel-position-rail-label" data-point-group="${escapeAttr2(point.groupId)}" data-point-key="${escapeAttr2(point.key)}" data-point-name="${escapeAttr2(point.name)}" data-position-rail="${label.railId}" transform="translate(${fmt2(label.position.x)} ${fmt2(label.position.y)})" filter="url(#${GLYPH_OUTLINE_FILTER_ID})">`
1675
1713
  );
1714
+ if (label.railId === "sign" && label.sign) {
1715
+ renderInlineSignGlyph(push, label.sign, 0, 0, label.glyphScale ?? label.fontSize, point.color);
1716
+ } else if (label.railId === "retrograde") {
1717
+ renderRetrogradeMarker(push, 0, 0, label.fontSize, point.color);
1718
+ } else {
1719
+ push(
1720
+ `<text class="astro-wheel-point-${label.railId}" x="0" y="0" font-family="${textFontFamily2()}" font-size="${fmt2(label.fontSize)}" text-anchor="middle" dominant-baseline="middle" fill="${escapeAttr2(point.color)}" fill-opacity="0.9">${escapeText2(label.text)}</text>`
1721
+ );
1722
+ }
1723
+ push(`</g>`);
1676
1724
  }
1677
- renderPointInlineDegreeLabel(push, point, layout);
1678
- push(`</g>`);
1679
1725
  }
1680
1726
  function renderPointGlyph(push, point, x, y, glyphScale, glyphFill) {
1681
1727
  const glyph = point.glyphKey ? getAstroGlyph(point.glyphKey) : resolvePointGlyph(point.name);
@@ -1708,18 +1754,6 @@ function renderRetrogradeMarker(push, x, y, fontSize, color) {
1708
1754
  `<text class="astro-wheel-point-retrograde" x="${fmt2(x)}" y="${fmt2(y)}" font-family="${textFontFamily2()}" font-size="${fmt2(fontSize)}" text-anchor="middle" dominant-baseline="middle" fill="${escapeAttr2(color)}" font-weight="700">R</text>`
1709
1755
  );
1710
1756
  }
1711
- function renderPointInlineDegreeLabel(push, point, layout) {
1712
- if (!layout.position) {
1713
- return;
1714
- }
1715
- push(
1716
- `<text class="astro-wheel-point-degree" x="${fmt2(layout.degreeX)}" y="${fmt2(layout.degreeY)}" font-family="${textFontFamily2()}" font-size="${fmt2(layout.fontSize)}" text-anchor="start" dominant-baseline="middle" fill="${escapeAttr2(point.color)}" fill-opacity="0.9">${escapeText2(layout.position.degreesText)}</text>`
1717
- );
1718
- renderInlineSignGlyph(push, layout.position.sign, layout.signX, layout.signY, layout.signScale, point.color);
1719
- push(
1720
- `<text class="astro-wheel-point-minutes" x="${fmt2(layout.minutesX)}" y="${fmt2(layout.minutesY)}" font-family="${textFontFamily2()}" font-size="${fmt2(layout.fontSize)}" text-anchor="start" dominant-baseline="middle" fill="${escapeAttr2(point.color)}" fill-opacity="0.9">${escapeText2(layout.position.minutesText)}</text>`
1721
- );
1722
- }
1723
1757
  function renderInlineSignGlyph(push, sign, x, y, glyphScale, color) {
1724
1758
  const glyph = ZODIAC_GLYPHS[sign];
1725
1759
  if (glyph) {
@@ -1735,89 +1769,6 @@ function renderInlineSignGlyph(push, sign, x, y, glyphScale, color) {
1735
1769
  `<text class="astro-wheel-point-sign-glyph" x="${fmt2(x)}" y="${fmt2(y)}" font-family="${symbolFontFamily()}" font-size="${fmt2(glyphScale)}" text-anchor="middle" dominant-baseline="middle" fill="${escapeAttr2(color)}">${escapeText2(sign.charAt(0).toUpperCase())}</text>`
1736
1770
  );
1737
1771
  }
1738
- function getPointLabelLayout(point, scale) {
1739
- const glyphScale = point.glyphFontSize * 0.66;
1740
- const fontSize = clamp(point.glyphFontSize * 0.31, 5.5 * scale, 9 * scale);
1741
- const signScale = fontSize * 0.82;
1742
- const gap = clamp(3.2 * scale, 2.4, 5);
1743
- const railGap = clamp(4.4 * scale, 3.2, 7);
1744
- const retrogradeFontSize = clamp(fontSize * 0.74, 4.4 * scale, 7.2 * scale);
1745
- const retrogradeTextWidth = point.retrograde ? estimateTextWidth("Rx", retrogradeFontSize) : 0;
1746
- const retrogradeGap = point.retrograde ? clamp(1.7 * scale, 1.2, 3) : 0;
1747
- const position = point.zodiacPosition ? formatInlinePosition(point.zodiacPosition) : null;
1748
- const degreeWidth = position ? estimateTextWidth(position.degreesText, fontSize) : 0;
1749
- const minutesWidth = position ? estimateTextWidth(position.minutesText, fontSize) : 0;
1750
- const positionWidth = position ? degreeWidth + gap + signScale + gap + minutesWidth : 0;
1751
- const positionHeight = position ? Math.max(fontSize, signScale) : 0;
1752
- const inwardX = -Math.cos(point.labelAngle);
1753
- const inwardY = -Math.sin(point.labelAngle);
1754
- const glyphHalf = glyphScale / 2;
1755
- const retrogradeCenterDistance = point.retrograde ? glyphHalf + retrogradeGap + retrogradeTextWidth / 2 : 0;
1756
- const retrogradeRailWidth = point.retrograde ? retrogradeGap + retrogradeTextWidth : 0;
1757
- const positionCenterDistance = position ? glyphHalf + retrogradeRailWidth + railGap + positionWidth / 2 : 0;
1758
- const positionCenterX = inwardX * positionCenterDistance;
1759
- const positionCenterY = inwardY * positionCenterDistance;
1760
- const positionLeftX = positionCenterX - positionWidth / 2;
1761
- const glyphX = 0;
1762
- const glyphY = 0;
1763
- const retrogradeX = inwardX * retrogradeCenterDistance;
1764
- const retrogradeY = inwardY * retrogradeCenterDistance;
1765
- const degreeX = positionLeftX;
1766
- const degreeY = positionCenterY;
1767
- const signX = degreeX + degreeWidth + gap + signScale / 2;
1768
- const signY = positionCenterY;
1769
- const minutesX = signX + signScale / 2 + gap;
1770
- const minutesY = positionCenterY;
1771
- const boxes = [
1772
- {
1773
- x: -glyphHalf,
1774
- y: -glyphHalf,
1775
- width: glyphScale,
1776
- height: glyphScale
1777
- }
1778
- ];
1779
- if (point.retrograde) {
1780
- boxes.push({
1781
- x: retrogradeX - retrogradeTextWidth / 2,
1782
- y: retrogradeY - retrogradeFontSize / 2,
1783
- width: retrogradeTextWidth,
1784
- height: retrogradeFontSize
1785
- });
1786
- }
1787
- if (position) {
1788
- boxes.push({
1789
- x: positionLeftX,
1790
- y: positionCenterY - positionHeight / 2,
1791
- width: positionWidth,
1792
- height: positionHeight
1793
- });
1794
- }
1795
- const boundsX = Math.min(...boxes.map((box) => box.x));
1796
- const boundsY = Math.min(...boxes.map((box) => box.y));
1797
- const boundsMaxX = Math.max(...boxes.map((box) => box.x + box.width));
1798
- const boundsMaxY = Math.max(...boxes.map((box) => box.y + box.height));
1799
- return {
1800
- glyphScale,
1801
- glyphX,
1802
- glyphY,
1803
- fontSize,
1804
- degreeX,
1805
- degreeY,
1806
- signX,
1807
- signScale,
1808
- signY,
1809
- minutesX,
1810
- minutesY,
1811
- retrogradeX,
1812
- retrogradeY,
1813
- retrogradeFontSize,
1814
- boundsX,
1815
- boundsY,
1816
- width: boundsMaxX - boundsX,
1817
- height: boundsMaxY - boundsY,
1818
- position
1819
- };
1820
- }
1821
1772
  function formatInlinePosition(position) {
1822
1773
  let degrees = Math.floor(position.decimalDegrees);
1823
1774
  let minutes = Math.round((position.decimalDegrees - degrees) * 60);
@@ -1842,70 +1793,6 @@ function pointLabelTitle(point) {
1842
1793
  function estimateTextWidth(value, fontSize) {
1843
1794
  return value.length * fontSize * 0.56;
1844
1795
  }
1845
- function labelBoundsFor(position, layout, padding) {
1846
- const width = layout.width + padding * 2;
1847
- const height = layout.height + padding * 2;
1848
- return {
1849
- x: round2(position.x + layout.boundsX - padding),
1850
- y: round2(position.y + layout.boundsY - padding),
1851
- width: round2(width),
1852
- height: round2(height)
1853
- };
1854
- }
1855
- function constrainLabelInsideCircle(params) {
1856
- const { center, layout, padding, maxRadius } = params;
1857
- if (!Number.isFinite(maxRadius)) {
1858
- return {
1859
- position: params.position,
1860
- bounds: labelBoundsFor(params.position, layout, padding),
1861
- moved: false
1862
- };
1863
- }
1864
- let position = params.position;
1865
- let moved = false;
1866
- for (let attempt = 0; attempt < 6; attempt++) {
1867
- const bounds = labelBoundsFor(position, layout, padding);
1868
- const overflow = labelBoundsCircleOverflow(center, bounds, maxRadius);
1869
- if (overflow <= 0) {
1870
- return { position, bounds, moved };
1871
- }
1872
- const dx = position.x - center.x;
1873
- const dy = position.y - center.y;
1874
- const distance = Math.max(Math.hypot(dx, dy), 1);
1875
- position = {
1876
- x: round2(position.x - dx / distance * (overflow + 0.75)),
1877
- y: round2(position.y - dy / distance * (overflow + 0.75))
1878
- };
1879
- moved = true;
1880
- }
1881
- return {
1882
- position,
1883
- bounds: labelBoundsFor(position, layout, padding),
1884
- moved
1885
- };
1886
- }
1887
- function labelBoundsCircleOverflow(center, bounds, maxRadius) {
1888
- const corners = [
1889
- { x: bounds.x, y: bounds.y },
1890
- { x: bounds.x + bounds.width, y: bounds.y },
1891
- { x: bounds.x, y: bounds.y + bounds.height },
1892
- { x: bounds.x + bounds.width, y: bounds.y + bounds.height }
1893
- ];
1894
- const farthestCorner = Math.max(
1895
- ...corners.map(
1896
- (corner) => Math.hypot(corner.x - center.x, corner.y - center.y)
1897
- )
1898
- );
1899
- return farthestCorner - maxRadius;
1900
- }
1901
- function formatLabelBounds(bounds) {
1902
- return `${fmt2(bounds.x)} ${fmt2(bounds.y)} ${fmt2(bounds.width)} ${fmt2(bounds.height)}`;
1903
- }
1904
- function projectedLabelWidthAlongTangent(angleRad, bounds) {
1905
- const tangentX = -Math.sin(angleRad);
1906
- const tangentY = Math.cos(angleRad);
1907
- return Math.abs(tangentX) * bounds.width + Math.abs(tangentY) * bounds.height;
1908
- }
1909
1796
  var POINT_GLYPH_ALIASES = {
1910
1797
  "mean node": "north node",
1911
1798
  "true node": "north node",
@@ -1940,13 +1827,7 @@ function resolvePointGlyph(name) {
1940
1827
  return PLANET_GLYPHS[resolved] ?? ANGLE_GLYPHS[resolved] ?? null;
1941
1828
  }
1942
1829
  function getExternalPointPadding(options, scale) {
1943
- const externalLayers = options.pointLayers?.filter((layer) => layer.radius === "external") ?? [];
1944
- if (externalLayers.length === 0) {
1945
- return 0;
1946
- }
1947
- return Math.max(
1948
- ...externalLayers.map((layer) => (layer.radiusOffset ?? 18) + 36 * scale)
1949
- );
1830
+ return 0;
1950
1831
  }
1951
1832
  function buildZodiacSegments(params) {
1952
1833
  const { center, angleOf: angleOf2, rings, scale, palette } = params;
@@ -1988,7 +1869,7 @@ function buildHouseCusps(params) {
1988
1869
  const ring = rings.houses;
1989
1870
  const spokeInnerRadius = rings.aspects.r2;
1990
1871
  const spokeOuterRadius = ring.r2 + 4 * scale;
1991
- const labelRadius = ring.r2 + 12 * scale;
1872
+ const labelRadius = (ring.r1 + ring.r2) / 2;
1992
1873
  const labelFontSize = clamp((ring.r2 - ring.r1) * 0.48, 10 * scale, 19 * scale);
1993
1874
  return houses.map((house, index) => {
1994
1875
  const angle = angleOf2(house.longitude);
@@ -2009,10 +1890,7 @@ function buildAngleMarkers(params) {
2009
1890
  const { chart, center, angleOf: angleOf2, rings, scale } = params;
2010
1891
  const ring = rings.houses;
2011
1892
  const labelFontSize = clamp((ring.r2 - ring.r1) * 0.32, 8 * scale, 18 * scale);
2012
- const labelRadius = Math.min(
2013
- ring.r2 + 9 * scale,
2014
- ring.r2 - Math.max(10 * scale, labelFontSize * 0.6)
2015
- );
1893
+ const labelRadius = rings.zodiac.r1 + (rings.zodiac.r2 - rings.zodiac.r1) * 0.32;
2016
1894
  const markers = [
2017
1895
  { key: "ASC", position: chart.houses.ascendant },
2018
1896
  { key: "MC", position: chart.houses.mc },
@@ -2044,7 +1922,7 @@ function buildAngleMarkers(params) {
2044
1922
  };
2045
1923
  });
2046
1924
  }
2047
- function buildPointLayer(params) {
1925
+ function buildPointGroup(params) {
2048
1926
  const {
2049
1927
  layer,
2050
1928
  center,
@@ -2054,10 +1932,11 @@ function buildPointLayer(params) {
2054
1932
  palette,
2055
1933
  excludedBodies,
2056
1934
  pointConnectorMode,
2057
- maxDisplacementDegrees
1935
+ maxDisplacementDegrees,
1936
+ railVisibility
2058
1937
  } = params;
2059
1938
  const ring = rings.planets;
2060
- const requestedRadius = resolvePointLayerRadius(layer, rings);
1939
+ const requestedRadius = resolvePointGroupRadius(layer, rings);
2061
1940
  const requestedExternalLayer = requestedRadius > rings.houses.r2 + scale;
2062
1941
  const thickness = ring.r2 - ring.r1;
2063
1942
  const glyphFontSize = clamp(thickness * 0.68, 14 * scale, 30 * scale) * (layer.glyphScale ?? 1);
@@ -2069,6 +1948,19 @@ function buildPointLayer(params) {
2069
1948
  ) : requestedRadius;
2070
1949
  const isExternalLayer = radius > rings.houses.r2 + scale;
2071
1950
  const tickLength = Math.min(14 * scale, thickness * 0.34);
1951
+ const layerRailVisibility = resolveLayerRailVisibility({
1952
+ layer,
1953
+ fallback: railVisibility,
1954
+ external: isExternalLayer
1955
+ });
1956
+ const rails = buildPositionRails({
1957
+ ring,
1958
+ scale,
1959
+ visibility: layerRailVisibility,
1960
+ layerRadius: radius,
1961
+ external: isExternalLayer,
1962
+ glyphFontSize
1963
+ });
2072
1964
  const collisionPadding = Math.max(2 * scale, 1.5);
2073
1965
  const zodiacKeepOutGap = Math.max(5 * scale, 4);
2074
1966
  const labelMaxRadius = isExternalLayer ? Number.POSITIVE_INFINITY : rings.zodiac.r1 - zodiacKeepOutGap;
@@ -2077,6 +1969,7 @@ function buildPointLayer(params) {
2077
1969
  const tickColor = layer.tickColor ?? color;
2078
1970
  const pointIntents = seeds.map((seed) => {
2079
1971
  const tickAngle = angleOf2(seed.longitude);
1972
+ const trueAnchor = polarToXY2(center.x, center.y, rings.aspects.r2, tickAngle);
2080
1973
  const pointGlyphFontSize = seed.kind === "vertex" ? glyphFontSize * 0.82 : glyphFontSize;
2081
1974
  const rawGlyphRadius = radius;
2082
1975
  const glyphRadius = isExternalLayer ? rawGlyphRadius : clamp(
@@ -2085,37 +1978,43 @@ function buildPointLayer(params) {
2085
1978
  labelMaxRadius - pointGlyphFontSize * 0.5
2086
1979
  );
2087
1980
  const connectorRadius = glyphRadius;
1981
+ const glyphClearance = pointGlyphFontSize * 0.34;
2088
1982
  const tickLine = isExternalLayer ? lineFromPolar2(
2089
1983
  center,
2090
- rings.houses.r2 + 2 * scale,
2091
- connectorRadius,
1984
+ Math.max(rings.aspects.r1, rings.aspects.r2 - tickLength * 0.5),
1985
+ rings.aspects.r2 + tickLength * 0.5,
2092
1986
  tickAngle
2093
1987
  ) : lineFromPolar2(
2094
1988
  center,
2095
1989
  Math.min(ring.r2, connectorRadius + tickLength),
2096
- connectorRadius,
1990
+ Math.min(ring.r2, connectorRadius + glyphClearance),
2097
1991
  tickAngle
2098
1992
  );
2099
1993
  const idealPosition = polarToXY2(center.x, center.y, glyphRadius, tickAngle);
2100
- const point = makeAstroWheelPoint({
1994
+ makeAstroWheelPoint({
2101
1995
  layer,
2102
1996
  seed,
2103
1997
  tickLine,
1998
+ trueAngle: tickAngle,
1999
+ displayAngle: tickAngle,
2000
+ trueAnchor,
2104
2001
  labelAngle: tickAngle,
2105
2002
  glyphPosition: idealPosition,
2106
2003
  glyphFontSize: pointGlyphFontSize,
2004
+ rails,
2005
+ houses: layer.chart?.houses.houses,
2006
+ center,
2107
2007
  color,
2108
2008
  tickColor
2109
2009
  });
2110
- const layout = getPointLabelLayout(point, scale);
2111
- const labelBounds = labelBoundsFor(idealPosition, layout, collisionPadding);
2112
- const labelTangentDemandPx = projectedLabelWidthAlongTangent(tickAngle, labelBounds);
2010
+ const labelTangentDemandPx = pointGlyphFontSize * 0.72;
2113
2011
  const configuredTangentDemandPx = layer.collisionThresholdDegrees ? deg2rad2(clamp(layer.collisionThresholdDegrees, 0, 30)) * glyphRadius : 0;
2114
2012
  const tangentDemandPx = Math.max(labelTangentDemandPx, configuredTangentDemandPx);
2115
2013
  return {
2116
2014
  seed,
2117
2015
  tickAngle,
2118
2016
  tickLine,
2017
+ trueAnchor,
2119
2018
  connectorRadius,
2120
2019
  glyphRadius,
2121
2020
  pointGlyphFontSize,
@@ -2144,42 +2043,37 @@ function buildPointLayer(params) {
2144
2043
  layer,
2145
2044
  seed: intent.seed,
2146
2045
  tickLine: intent.tickLine,
2046
+ trueAngle: intent.tickAngle,
2047
+ displayAngle: visualAngle,
2048
+ trueAnchor: intent.trueAnchor,
2147
2049
  labelAngle: visualAngle,
2148
2050
  glyphPosition,
2149
2051
  glyphFontSize: intent.pointGlyphFontSize,
2052
+ rails,
2053
+ houses: layer.chart?.houses.houses,
2054
+ center,
2150
2055
  color,
2151
2056
  tickColor
2152
2057
  });
2153
- const layout = getPointLabelLayout(point, scale);
2154
- const constrainedLabel = constrainLabelInsideCircle({
2058
+ const leaderArc = buildPointConnector({
2155
2059
  center,
2156
- position: glyphPosition,
2157
- layout,
2158
- padding: collisionPadding,
2159
- maxRadius: labelMaxRadius
2060
+ tickAngle: intent.tickAngle,
2061
+ labelAngle: visualAngle,
2062
+ connectorRadius: intent.connectorRadius,
2063
+ glyphPosition,
2064
+ mode: pointConnectorMode
2065
+ });
2066
+ const connector = buildPointLineConnector({
2067
+ trueAnchor: point.trueAnchor,
2068
+ glyphPosition,
2069
+ mode: pointConnectorMode,
2070
+ tickAngle: intent.tickAngle,
2071
+ displayAngle: visualAngle
2160
2072
  });
2161
- if (constrainedLabel.moved) {
2162
- glyphPosition = constrainedLabel.position;
2163
- point = {
2164
- ...point,
2165
- glyphPosition,
2166
- leaderLine: void 0
2167
- };
2168
- }
2169
- point = {
2170
- ...point,
2171
- leaderArc: buildPointConnector({
2172
- center,
2173
- tickAngle: intent.tickAngle,
2174
- labelAngle: visualAngle,
2175
- connectorRadius: intent.connectorRadius,
2176
- glyphPosition,
2177
- mode: pointConnectorMode
2178
- })
2179
- };
2180
2073
  return {
2181
2074
  ...point,
2182
- labelBounds: constrainedLabel.bounds
2075
+ leaderArc,
2076
+ connector
2183
2077
  };
2184
2078
  });
2185
2079
  return {
@@ -2188,6 +2082,7 @@ function buildPointLayer(params) {
2188
2082
  color,
2189
2083
  tickColor,
2190
2084
  radius,
2085
+ rails,
2191
2086
  points
2192
2087
  };
2193
2088
  }
@@ -2196,21 +2091,42 @@ function makeAstroWheelPoint(params) {
2196
2091
  layer,
2197
2092
  seed,
2198
2093
  tickLine,
2094
+ trueAngle,
2095
+ displayAngle,
2096
+ trueAnchor,
2199
2097
  labelAngle,
2200
2098
  glyphPosition,
2201
2099
  glyphFontSize,
2100
+ rails,
2101
+ houses,
2102
+ center,
2202
2103
  color,
2203
2104
  tickColor
2204
2105
  } = params;
2106
+ const houseContext = houses ? getHouseContext(seed.longitude, houses) : {};
2107
+ const railLabels = buildPointRailLabels({
2108
+ seed,
2109
+ rails,
2110
+ center,
2111
+ displayAngle,
2112
+ glyphFontSize
2113
+ });
2114
+ const glyphScale = glyphFontSize * 0.66;
2205
2115
  return {
2206
- layerId: layer.id,
2116
+ groupId: layer.id,
2207
2117
  key: seed.key,
2208
2118
  name: seed.name,
2209
2119
  kind: seed.kind,
2210
2120
  glyph: seed.glyph,
2211
2121
  glyphKey: seed.glyphKey,
2212
2122
  longitude: normalizeAngle(seed.longitude),
2213
- displayLongitude: normalizeAngle(seed.longitude),
2123
+ displayLongitude: normalizeAngle(seed.longitude + rad2deg2(signedAngleDelta(displayAngle, trueAngle))),
2124
+ trueAnchor,
2125
+ trueAngle,
2126
+ displayAngle,
2127
+ house: houseContext.house,
2128
+ nearestCuspHouse: houseContext.nearestCuspHouse,
2129
+ nearestCuspDistanceDegrees: houseContext.nearestCuspDistanceDegrees,
2214
2130
  zodiacPosition: seed.zodiacPosition,
2215
2131
  tickLine,
2216
2132
  labelAngle,
@@ -2218,27 +2134,158 @@ function makeAstroWheelPoint(params) {
2218
2134
  leaderLine: void 0,
2219
2135
  glyphPosition,
2220
2136
  glyphFontSize,
2137
+ glyphScale,
2138
+ railLabels,
2139
+ hitTarget: {
2140
+ kind: "circle",
2141
+ cx: glyphPosition.x,
2142
+ cy: glyphPosition.y,
2143
+ r: round2(glyphScale * 0.72)
2144
+ },
2221
2145
  retrograde: seed.retrograde,
2222
2146
  color,
2223
2147
  tickColor
2224
2148
  };
2225
2149
  }
2226
- function buildAspectLayer(params) {
2150
+ function resolveRailVisibility(input) {
2151
+ if (!input || input === "glyph-only") {
2152
+ return { degree: false, sign: false, minutes: false, retrograde: false };
2153
+ }
2154
+ if (input === "compact") {
2155
+ return { degree: true, sign: true, minutes: false, retrograde: true };
2156
+ }
2157
+ if (input === "full") {
2158
+ return { degree: true, sign: true, minutes: true, retrograde: true };
2159
+ }
2160
+ return {
2161
+ degree: input.degree ?? true,
2162
+ sign: input.sign ?? true,
2163
+ minutes: input.minutes ?? true,
2164
+ retrograde: input.retrograde ?? true
2165
+ };
2166
+ }
2167
+ function resolveLayerRailVisibility(params) {
2168
+ if (params.layer.rails) {
2169
+ return resolveRailVisibility(params.layer.rails);
2170
+ }
2171
+ if (params.external) {
2172
+ return {
2173
+ degree: params.fallback.degree,
2174
+ sign: false,
2175
+ minutes: false,
2176
+ retrograde: false
2177
+ };
2178
+ }
2179
+ return params.fallback;
2180
+ }
2181
+ function buildPositionRails(params) {
2182
+ const { ring, scale, visibility, layerRadius, external, glyphFontSize } = params;
2183
+ if (external) {
2184
+ const gap = Math.max(2.4 * scale, 2);
2185
+ const step = Math.max(glyphFontSize * 0.22, 4.2 * scale);
2186
+ const firstRailRadius = layerRadius + glyphFontSize * 0.42 + gap;
2187
+ return [
2188
+ { id: "degree", label: "Degree", radius: round2(firstRailRadius), visible: visibility.degree },
2189
+ { id: "minutes", label: "Minutes", radius: round2(firstRailRadius + step * 2), visible: visibility.minutes },
2190
+ { id: "sign", label: "Sign", radius: round2(firstRailRadius + step), visible: visibility.sign },
2191
+ { id: "retrograde", label: "Retrograde", radius: round2(firstRailRadius + step * 3), visible: visibility.retrograde }
2192
+ ];
2193
+ }
2194
+ const thickness = ring.r2 - ring.r1;
2195
+ const inset = Math.max(2 * scale, 1.5);
2196
+ return [
2197
+ { id: "degree", label: "Degree", radius: round2(ring.r1 + thickness * 0.52 + inset), visible: visibility.degree },
2198
+ { id: "minutes", label: "Minutes", radius: round2(ring.r1 + thickness * 0.24 + inset), visible: visibility.minutes },
2199
+ { id: "sign", label: "Sign", radius: round2(ring.r1 + thickness * 0.38 + inset), visible: visibility.sign },
2200
+ { id: "retrograde", label: "Retrograde", radius: round2(ring.r1 + thickness * 0.1 + inset), visible: visibility.retrograde }
2201
+ ];
2202
+ }
2203
+ function buildPointRailLabels(params) {
2204
+ const position = params.seed.zodiacPosition ? formatInlinePosition(params.seed.zodiacPosition) : null;
2205
+ const fontSize = clamp(params.glyphFontSize * 0.25, 5, 8);
2206
+ return params.rails.flatMap((rail) => {
2207
+ let text = "";
2208
+ let sign;
2209
+ let glyphScale;
2210
+ if (rail.id === "degree")
2211
+ text = position?.degreesText ?? "";
2212
+ if (rail.id === "sign") {
2213
+ sign = position?.sign;
2214
+ text = sign ? ASTRO_WHEEL_ZODIAC_SIGNS.find((entry) => entry.sign === sign)?.glyph ?? sign : "";
2215
+ glyphScale = fontSize * 0.78;
2216
+ }
2217
+ if (rail.id === "minutes")
2218
+ text = position?.minutesText ?? "";
2219
+ if (rail.id === "retrograde")
2220
+ text = params.seed.retrograde ? "R" : "";
2221
+ if (!text)
2222
+ return [];
2223
+ return [{
2224
+ railId: rail.id,
2225
+ text,
2226
+ sign,
2227
+ position: polarToXY2(params.center.x, params.center.y, rail.radius, params.displayAngle),
2228
+ angle: params.displayAngle,
2229
+ fontSize,
2230
+ glyphScale,
2231
+ visible: rail.visible
2232
+ }];
2233
+ });
2234
+ }
2235
+ function getHouseContext(longitude, houses) {
2236
+ if (houses.length === 0) {
2237
+ return {};
2238
+ }
2239
+ const lon = normalizeAngle(longitude);
2240
+ let house = houses.length;
2241
+ let nearestCuspHouse = 1;
2242
+ let nearestCuspDistanceDegrees = Number.POSITIVE_INFINITY;
2243
+ for (let index = 0; index < houses.length; index++) {
2244
+ const cusp = normalizeAngle(houses[index].longitude);
2245
+ const next = normalizeAngle(houses[(index + 1) % houses.length].longitude);
2246
+ const span = clamp360(next - cusp);
2247
+ const offset = clamp360(lon - cusp);
2248
+ const distance = Math.abs(shortestLongitudeDistance(lon, cusp));
2249
+ if (offset < span || Math.abs(offset - span) < 1e-4) {
2250
+ house = index + 1;
2251
+ }
2252
+ if (distance < nearestCuspDistanceDegrees) {
2253
+ nearestCuspDistanceDegrees = distance;
2254
+ nearestCuspHouse = index + 1;
2255
+ }
2256
+ }
2257
+ return {
2258
+ house,
2259
+ nearestCuspHouse,
2260
+ nearestCuspDistanceDegrees: round2(nearestCuspDistanceDegrees)
2261
+ };
2262
+ }
2263
+ function buildPointLineConnector(params) {
2264
+ if (params.mode === "never")
2265
+ return void 0;
2266
+ if (params.mode === "auto" && circularAngleDistance(params.tickAngle, params.displayAngle) < deg2rad2(0.35)) {
2267
+ return void 0;
2268
+ }
2269
+ return {
2270
+ x1: params.trueAnchor.x,
2271
+ y1: params.trueAnchor.y,
2272
+ x2: params.glyphPosition.x,
2273
+ y2: params.glyphPosition.y
2274
+ };
2275
+ }
2276
+ function buildAspectGroup(params) {
2227
2277
  const { layer, chart, pointByKey, center, angleOf: angleOf2, rings, palette, excludedBodies } = params;
2228
- const sourceEdges = getSourceAspectEdges(chart, {
2278
+ const sourceEdges = layer.edges ? layer.edges : getSourceAspectEdges(chart, {
2229
2279
  edges: layer.edges,
2230
2280
  aspectSpecs: layer.aspectSpecs
2231
2281
  });
2232
2282
  const aspectRadius = layer.radius ?? rings.aspects.r2 * (layer.radiusScale ?? 0.96);
2233
- const layerPointPrefix = pointKeyPrefix(layer.pointLayerId);
2234
- const layerPointPrefixA = layer.pointLayerIdA ? pointKeyPrefix(layer.pointLayerIdA) : layerPointPrefix;
2235
- const layerPointPrefixB = layer.pointLayerIdB ? pointKeyPrefix(layer.pointLayerIdB) : layerPointPrefix;
2236
2283
  const aspectLines = sourceEdges.flatMap((edge) => {
2237
2284
  if (isExcludedBody(edge.planetA, excludedBodies) || isExcludedBody(edge.planetB, excludedBodies)) {
2238
2285
  return [];
2239
2286
  }
2240
- const planetAKey = layerPointPrefixA + normalizePointKey(edge.planetA);
2241
- const planetBKey = layerPointPrefixB + normalizePointKey(edge.planetB);
2287
+ const planetAKey = normalizePointKey(edge.planetA);
2288
+ const planetBKey = normalizePointKey(edge.planetB);
2242
2289
  const planetA = pointByKey[planetAKey];
2243
2290
  const planetB = pointByKey[planetBKey];
2244
2291
  if (!planetA || !planetB) {
@@ -2247,10 +2294,10 @@ function buildAspectLayer(params) {
2247
2294
  const spec = findAspectSpec(edge.aspect, layer.aspectSpecs);
2248
2295
  const maxOrb = spec?.orb ?? 8;
2249
2296
  const opacity = clamp((1 - edge.orb / Math.max(maxOrb, 1e-3)) * (layer.opacityScale ?? 1), 0.25, 0.92);
2250
- const a = polarToXY2(center.x, center.y, aspectRadius, angleOf2(planetA.longitude));
2251
- const b = polarToXY2(center.x, center.y, aspectRadius, angleOf2(planetB.longitude));
2297
+ const a = layer.radius || layer.radiusScale ? polarToXY2(center.x, center.y, aspectRadius, angleOf2(planetA.longitude)) : planetA.trueAnchor;
2298
+ const b = layer.radius || layer.radiusScale ? polarToXY2(center.x, center.y, aspectRadius, angleOf2(planetB.longitude)) : planetB.trueAnchor;
2252
2299
  return [{
2253
- layerId: layer.id,
2300
+ groupId: layer.id,
2254
2301
  planetA: planetA.name,
2255
2302
  planetB: planetB.name,
2256
2303
  planetAKey,
@@ -2309,9 +2356,9 @@ function getPointSeeds(layer, excludedBodies) {
2309
2356
  }
2310
2357
  return seeds.filter((seed) => !isExcludedBody(seed.name, excludedBodies)).sort((a, b) => normalizeAngle(a.longitude) - normalizeAngle(b.longitude));
2311
2358
  }
2312
- function planetSeed(key, planet, layerId) {
2359
+ function planetSeed(key, planet, groupId) {
2313
2360
  return {
2314
- key: layerPointKey(layerId, key || planet.name),
2361
+ key: layerPointKey(groupId, key || planet.name),
2315
2362
  name: planet.name,
2316
2363
  kind: "planet",
2317
2364
  glyph: pointGlyph(planet.name),
@@ -2321,9 +2368,9 @@ function planetSeed(key, planet, layerId) {
2321
2368
  zodiacPosition: planet.zodiacPosition
2322
2369
  };
2323
2370
  }
2324
- function nodeSeed(key, node, layerId) {
2371
+ function nodeSeed(key, node, groupId) {
2325
2372
  return {
2326
- key: layerPointKey(layerId, node.name || key),
2373
+ key: layerPointKey(groupId, node.name || key),
2327
2374
  name: node.name,
2328
2375
  kind: "node",
2329
2376
  glyph: pointGlyph(node.name),
@@ -2332,9 +2379,9 @@ function nodeSeed(key, node, layerId) {
2332
2379
  zodiacPosition: node
2333
2380
  };
2334
2381
  }
2335
- function pointSeed(point, layerId) {
2382
+ function pointSeed(point, groupId) {
2336
2383
  return {
2337
- key: layerPointKey(layerId, point.key ?? point.name),
2384
+ key: layerPointKey(groupId, point.key ?? point.name),
2338
2385
  name: point.name,
2339
2386
  kind: point.kind ?? "planet",
2340
2387
  glyph: point.glyph ?? pointGlyph(point.name),
@@ -2349,7 +2396,7 @@ function solveCircularLabelAngles(items, options) {
2349
2396
  if (items.length === 0) {
2350
2397
  return [];
2351
2398
  }
2352
- const normalized = items.map((item) => ({
2399
+ const normalized = seedExactAngleClusters(items, { paddingPx, maxDisplacementRad }).map((item) => ({
2353
2400
  ...item,
2354
2401
  idealAngle: clampRad(item.idealAngle)
2355
2402
  })).sort((a, b) => a.idealAngle - b.idealAngle);
@@ -2388,8 +2435,8 @@ function solveCircularLabelAngles(items, options) {
2388
2435
  }
2389
2436
  const solved = linear.map((item) => ({
2390
2437
  ...item,
2391
- visualAngle: item.idealAngle
2392
- }));
2438
+ visualAngle: item.visualAngleSeed ?? item.idealAngle
2439
+ })).sort((a, b) => a.visualAngle - b.visualAngle);
2393
2440
  for (let iteration = 0; iteration < 50; iteration++) {
2394
2441
  const forces = new Array(solved.length).fill(0);
2395
2442
  let maxForce = 0;
@@ -2432,6 +2479,38 @@ function solveCircularLabelAngles(items, options) {
2432
2479
  visualAngle: clampRad(item.visualAngle)
2433
2480
  }));
2434
2481
  }
2482
+ function seedExactAngleClusters(items, options) {
2483
+ const seeded = items.map((item) => ({
2484
+ ...item,
2485
+ idealAngle: clampRad(item.idealAngle)
2486
+ }));
2487
+ const groups = /* @__PURE__ */ new Map();
2488
+ for (const item of seeded) {
2489
+ const key = item.idealAngle.toFixed(6);
2490
+ const group = groups.get(key);
2491
+ if (group) {
2492
+ group.push(item);
2493
+ } else {
2494
+ groups.set(key, [item]);
2495
+ }
2496
+ }
2497
+ for (const group of groups.values()) {
2498
+ if (group.length < 2) {
2499
+ continue;
2500
+ }
2501
+ const center = group[0].idealAngle;
2502
+ const largestDemand = Math.max(
2503
+ ...group.map((item) => labelAngularHalfDemand(item, options.paddingPx) * 2)
2504
+ );
2505
+ const maxStep = group.length > 1 ? options.maxDisplacementRad * 2 / (group.length - 1) : largestDemand;
2506
+ const step = Math.min(largestDemand, maxStep);
2507
+ const midpoint2 = (group.length - 1) / 2;
2508
+ group.forEach((item, index) => {
2509
+ item.visualAngleSeed = center + (index - midpoint2) * step;
2510
+ });
2511
+ }
2512
+ return seeded;
2513
+ }
2435
2514
  function clampAngleAroundIdeal(value, ideal, maxDistance) {
2436
2515
  if (!Number.isFinite(maxDistance) || maxDistance >= Math.PI) {
2437
2516
  return value;
@@ -2458,6 +2537,9 @@ function circularAngleDistance(a, b) {
2458
2537
  const delta = Math.abs(clampRad(a) - clampRad(b));
2459
2538
  return Math.min(delta, TAU2 - delta);
2460
2539
  }
2540
+ function rad2deg2(radians) {
2541
+ return radians * (360 / TAU2);
2542
+ }
2461
2543
  function buildPointConnector(params) {
2462
2544
  const { center, tickAngle, labelAngle, connectorRadius, glyphPosition, mode } = params;
2463
2545
  const displacement = circularAngleDistance(tickAngle, labelAngle);
@@ -2525,6 +2607,9 @@ function getAspectMatch(lonA, lonB, specs) {
2525
2607
  }
2526
2608
  return null;
2527
2609
  }
2610
+ function shortestLongitudeDistance(a, b) {
2611
+ return (normalizeAngle(a) - normalizeAngle(b) + 540) % 360 - 180;
2612
+ }
2528
2613
  function findAspectSpec(aspect, specs = ASTRO_WHEEL_DEFAULT_ASPECT_SPECS) {
2529
2614
  return specs.find((spec) => spec.name === aspect);
2530
2615
  }
@@ -2657,7 +2742,7 @@ function resolveAspectOptions(options) {
2657
2742
  aspectSpecs: options.aspectSpecs
2658
2743
  };
2659
2744
  }
2660
- function resolvePointLayerRadius(layer, rings) {
2745
+ function resolvePointGroupRadius(layer, rings) {
2661
2746
  const ring = rings.planets;
2662
2747
  if (layer.radius === "external") {
2663
2748
  return rings.houses.r2 + (layer.radiusOffset ?? 18);
@@ -2690,12 +2775,9 @@ function isExcludedBody(name, excludedBodies) {
2690
2775
  function normalizePointKey(value) {
2691
2776
  return value.trim().toLocaleLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ");
2692
2777
  }
2693
- function layerPointKey(layerId, value) {
2778
+ function layerPointKey(groupId, value) {
2694
2779
  const key = normalizePointKey(value);
2695
- return layerId === "birth" ? key : `${layerId}:${key}`;
2696
- }
2697
- function pointKeyPrefix(layerId) {
2698
- return !layerId || layerId === "birth" ? "" : `${layerId}:`;
2780
+ return groupId === "birth" ? key : `${groupId}:${key}`;
2699
2781
  }
2700
2782
  function renderGlyphPrimitives(push, primitives, options) {
2701
2783
  for (const p of primitives) {
@@ -3763,6 +3845,6 @@ function escapeAttr3(value) {
3763
3845
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3764
3846
  }
3765
3847
 
3766
- export { ANGLE_GLYPHS, ANGLE_GLYPH_PRIMITIVES, ARCHEOMETER_DEFAULT_VIEWBOX, ASPECT_GLYPHS, ASPECT_GLYPH_PRIMITIVES, ASTRO_GLYPHS, ASTRO_WHEEL_DEFAULT_ASPECT_SPECS, ASTRO_WHEEL_DEFAULT_VIEWBOX, ASTRO_WHEEL_POINT_GLYPHS, ASTRO_WHEEL_ZODIAC_SIGNS, DEFAULT_ARCHEOMETER_MUSICAL_NOTES, DEFAULT_ARCHEOMETER_PLANETS, DEFAULT_ARCHEOMETER_SECTOR_CORRESPONDENCES, DEFAULT_ARCHEOMETER_TRIANGLES, DEFAULT_ARCHEOMETER_TRIANGLE_LABELS, DEFAULT_ARCHEOMETER_UTTERANCE, DEFAULT_ARCHEOMETER_ZODIAC, DEFAULT_ARCHETYPE_MUSICAL_NOTES, DEFAULT_ARCHETYPE_PLANETS, DEFAULT_ARCHETYPE_TRIANGLES, DEFAULT_ARCHETYPE_UTTERANCE, DEFAULT_ARCHETYPE_ZODIAC, PLANET_GLYPHS, PLANET_GLYPH_PRIMITIVES, TREE_PATH_IDS, TREE_SPHERE_IDS, TREE_SPHERE_NAMES, TREE_SVG_DEFAULT_VIEWBOX, ZODIAC_GLYPHS, ZODIAC_GLYPH_PRIMITIVES, generateArcheometerSvg, generateAstroGlyphSvg, generateAstroWheelSvg, generateGlyphSvg, generateTreeSvg, getArcheometerRenderModel, getAstroGlyph, getAstroWheelRenderModel, getRouteActivations, getTreeLayout, getTreeRenderModel, listAstroGlyphs };
3848
+ export { ANGLE_GLYPHS, ANGLE_GLYPH_PRIMITIVES, ARCHEOMETER_DEFAULT_VIEWBOX, ASPECT_GLYPHS, ASPECT_GLYPH_PRIMITIVES, ASTRO_GLYPHS, ASTRO_WHEEL_DEFAULT_ASPECT_SPECS, ASTRO_WHEEL_DEFAULT_VIEWBOX, ASTRO_WHEEL_POINT_GLYPHS, ASTRO_WHEEL_ZODIAC_SIGNS, DEFAULT_ARCHEOMETER_MUSICAL_NOTES, DEFAULT_ARCHEOMETER_PLANETS, DEFAULT_ARCHEOMETER_SECTOR_CORRESPONDENCES, DEFAULT_ARCHEOMETER_TRIANGLES, DEFAULT_ARCHEOMETER_TRIANGLE_LABELS, DEFAULT_ARCHEOMETER_UTTERANCE, DEFAULT_ARCHEOMETER_ZODIAC, DEFAULT_ARCHETYPE_MUSICAL_NOTES, DEFAULT_ARCHETYPE_PLANETS, DEFAULT_ARCHETYPE_TRIANGLES, DEFAULT_ARCHETYPE_UTTERANCE, DEFAULT_ARCHETYPE_ZODIAC, PLANET_GLYPHS, PLANET_GLYPH_PRIMITIVES, TREE_PATH_IDS, TREE_SPHERE_IDS, TREE_SPHERE_NAMES, TREE_SVG_DEFAULT_VIEWBOX, ZODIAC_GLYPHS, ZODIAC_GLYPH_PRIMITIVES, generateArcheometerSvg, generateAstroGlyphSvg, generateAstroWheelSvg, generateGlyphSvg, generateTreeSvg, getArcheometerRenderModel, getAstroGlyph, getRouteActivations, getTreeLayout, getTreeRenderModel, listAstroGlyphs };
3767
3849
  //# sourceMappingURL=out.js.map
3768
- //# sourceMappingURL=chunk-THD4XOYR.mjs.map
3850
+ //# sourceMappingURL=chunk-4MACEIWO.mjs.map