@zodiacs/engine 1.0.0 → 1.1.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +1020 -0
  2. package/LICENSING.md +168 -27
  3. package/NOTICE +78 -12
  4. package/README.md +288 -44
  5. package/dist/{api-WbxJ4Wj-.d.ts → api-ChL1N2Sr.d.ts} +33 -2
  6. package/dist/{ayanamsa--YQ46fET.d.ts → ayanamsa-ClFzkKmV.d.ts} +2 -1
  7. package/dist/calc.d.ts +90 -4
  8. package/dist/calc.js +360 -126
  9. package/dist/chunk-2PZYJQV5.js +83 -0
  10. package/dist/{chunk-7TRLIFFI.js → chunk-4XOYTBLS.js} +1 -1
  11. package/dist/chunk-767FTO7O.js +48 -0
  12. package/dist/{chunk-YIITY7Q7.js → chunk-7Y2F2IWN.js} +19 -17
  13. package/dist/{chunk-OG4OYTJJ.js → chunk-B4M2Y7FT.js} +1 -129
  14. package/dist/{chunk-PFGUCNOK.js → chunk-BMDASNPB.js} +6 -6
  15. package/dist/chunk-I3L4POY7.js +18 -0
  16. package/dist/{chunk-CHSYDKBL.js → chunk-LNGURVNH.js} +3 -3
  17. package/dist/{chunk-DMGHYCDI.js → chunk-NNOSOOWS.js} +1 -1
  18. package/dist/chunk-OVXQQEXL.js +41 -0
  19. package/dist/{chunk-SRXBTP5H.js → chunk-QLIEEICB.js} +201 -190
  20. package/dist/chunk-RMBWKZI2.js +130 -0
  21. package/dist/{chunk-FTX3JDJA.js → chunk-TZVPZHZM.js} +42 -23
  22. package/dist/{chunk-WS3TDSP3.js → chunk-WBTWY2OB.js} +7 -3
  23. package/dist/chunk-Y4E3WJU5.js +87 -0
  24. package/dist/chunk-YPU3MDNI.js +852 -0
  25. package/dist/conventions.d.ts +70 -0
  26. package/dist/conventions.js +26 -0
  27. package/dist/crossings.d.ts +15 -4
  28. package/dist/de440-pack.d.ts +43 -0
  29. package/dist/de440-pack.js +16 -0
  30. package/dist/de440.d.ts +113 -0
  31. package/dist/de440.js +19 -0
  32. package/dist/ephemeris-exTSqBgb.d.ts +60 -0
  33. package/dist/geo.d.ts +16 -4
  34. package/dist/geo.js +2 -2
  35. package/dist/{houses-CFERsAlK.d.ts → houses-Bh7GCnPi.d.ts} +3 -3
  36. package/dist/houses-extra.d.ts +5 -4
  37. package/dist/index.d.ts +8 -6
  38. package/dist/index.js +40 -28
  39. package/dist/{internal-math-DJJ8BYex.d.ts → internal-math-CxenuGfm.d.ts} +2 -2
  40. package/dist/internal-math.d.ts +4 -3
  41. package/dist/internal-math.js +14 -12
  42. package/dist/internal.d.ts +16 -7
  43. package/dist/internal.js +25 -4
  44. package/dist/lite-composite.js +114 -0
  45. package/dist/lite-declinations.js +253 -0
  46. package/dist/lite-dignities.js +333 -0
  47. package/dist/lite-sect.js +72 -0
  48. package/dist/lite.d.ts +82 -0
  49. package/dist/lite.js +4 -0
  50. package/dist/receipt.d.ts +3 -2
  51. package/dist/receipt.js +143 -65
  52. package/dist/{rulers-Dla6h_Sm.d.ts → rulers-CSSWtiWF.d.ts} +1 -1
  53. package/dist/sky.d.ts +4 -3
  54. package/dist/sky.js +17 -10
  55. package/dist/techniques.d.ts +102 -6
  56. package/dist/techniques.js +131 -56
  57. package/dist/time-bands-CZA9AlLg.d.ts +36 -0
  58. package/dist/time-scale-DIFNa0gz.d.ts +47 -0
  59. package/dist/time.d.ts +81 -0
  60. package/dist/time.js +74 -0
  61. package/dist/timing.d.ts +6 -5
  62. package/dist/timing.js +24 -17
  63. package/dist/types-DpPdtXgO.d.ts +335 -0
  64. package/dist/vedic.d.ts +112 -4
  65. package/dist/vedic.js +369 -14
  66. package/dist/window.d.ts +22 -2
  67. package/dist/window.js +86 -28
  68. package/dist/{zone-history-ghdyO0Sc.d.ts → zone-history-BxmDCcTK.d.ts} +32 -10
  69. package/package.json +24 -3
  70. package/dist/types-B-yb_tGL.d.ts +0 -240
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  PROGRESSION_DAYS_PER_YEAR,
3
3
  progressedBodies,
4
4
  progressedInstant
5
- } from "./chunk-CHSYDKBL.js";
5
+ } from "./chunk-LNGURVNH.js";
6
6
  import {
7
7
  chartDeclinations,
8
8
  chartPoints,
@@ -19,13 +19,7 @@ import {
19
19
  summarizePair,
20
20
  synastry,
21
21
  transits
22
- } from "./chunk-FTX3JDJA.js";
23
- import "./chunk-CPALRSPC.js";
24
- import {
25
- findLongitudeCrossingsWith,
26
- searchLongitudeCrossingsWith
27
- } from "./chunk-TSS2SZWQ.js";
28
- import "./chunk-PFGUCNOK.js";
22
+ } from "./chunk-TZVPZHZM.js";
29
23
  import {
30
24
  DECLINATION_ORB,
31
25
  DECLINATION_ORB_LUMINARY,
@@ -42,6 +36,7 @@ import {
42
36
  declinationOf,
43
37
  declinationOrb,
44
38
  declinationsForBodies,
39
+ defaultEphemeris,
45
40
  eclipticToEquatorial,
46
41
  exactSign,
47
42
  exactSum,
@@ -53,8 +48,24 @@ import {
53
48
  midpoint,
54
49
  roundedValue,
55
50
  sectOf,
56
- signOf
57
- } from "./chunk-SRXBTP5H.js";
51
+ setDefaultEphemeris,
52
+ signOf,
53
+ withEphemeris
54
+ } from "./chunk-QLIEEICB.js";
55
+ import "./chunk-CPALRSPC.js";
56
+ import {
57
+ ASPECTS,
58
+ ASPECT_BODIES,
59
+ ASPECT_TYPES,
60
+ ENGINE_VERSION,
61
+ EPHEMERIS,
62
+ STATIONARY_RELATIVE_SPEED,
63
+ aspectMotion,
64
+ findAspects,
65
+ matchAspect,
66
+ separation
67
+ } from "./chunk-B4M2Y7FT.js";
68
+ import "./chunk-2PZYJQV5.js";
58
69
  import {
59
70
  DELTA_T_IERS_MODEL,
60
71
  EPHEMERIS_SPAN,
@@ -62,11 +73,12 @@ import {
62
73
  outsideReferenceSpan
63
74
  } from "./chunk-B5LKF437.js";
64
75
  import {
65
- DELTA_T_MODEL,
66
- DELTA_T_TABLE,
67
- deltaT,
68
- deltaTAt
69
- } from "./chunk-BHJXUY67.js";
76
+ findLongitudeCrossingsWith,
77
+ searchLongitudeCrossingsWith
78
+ } from "./chunk-TSS2SZWQ.js";
79
+ import "./chunk-767FTO7O.js";
80
+ import "./chunk-YPU3MDNI.js";
81
+ import "./chunk-Y4E3WJU5.js";
70
82
  import {
71
83
  HOUSE_SYSTEMS,
72
84
  PLACIDUS_POLAR_FALLBACK,
@@ -93,28 +105,25 @@ import {
93
105
  vehlowCusps,
94
106
  vertexOf,
95
107
  wholeSignCusps
96
- } from "./chunk-DMGHYCDI.js";
108
+ } from "./chunk-NNOSOOWS.js";
97
109
  import {
98
- ASPECTS,
99
- ASPECT_BODIES,
100
- ASPECT_TYPES,
101
110
  ELEMENTS,
102
- ENGINE_VERSION,
103
- EPHEMERIS,
104
111
  MODALITIES,
105
112
  SIGNS,
106
113
  SIGN_NAMES,
107
114
  SIGN_SLUGS,
108
- STATIONARY_RELATIVE_SPEED,
109
- aspectMotion,
110
115
  degreeInSign,
111
- findAspects,
112
- matchAspect,
113
116
  normalizeLongitude,
114
- separation,
115
117
  signForLongitude,
116
118
  signIndexForLongitude
117
- } from "./chunk-OG4OYTJJ.js";
119
+ } from "./chunk-RMBWKZI2.js";
120
+ import {
121
+ DELTA_T_MODEL,
122
+ DELTA_T_TABLE,
123
+ deltaT,
124
+ deltaTAt
125
+ } from "./chunk-BHJXUY67.js";
126
+ import "./chunk-BMDASNPB.js";
118
127
 
119
128
  // src/configured-aspects.ts
120
129
  var ASPECT_POLICY_SCHEMA = "zodiacs.aspect-policy.v1";
@@ -357,6 +366,7 @@ export {
357
366
  declinationOf,
358
367
  declinationOrb,
359
368
  declinationsForBodies,
369
+ defaultEphemeris,
360
370
  degreeInSign,
361
371
  deltaT,
362
372
  deltaTAt,
@@ -401,6 +411,7 @@ export {
401
411
  searchLongitudeCrossingsWith,
402
412
  sectOf,
403
413
  separation,
414
+ setDefaultEphemeris,
404
415
  signForLongitude,
405
416
  signIndexForLongitude,
406
417
  summarizePair,
@@ -409,5 +420,6 @@ export {
409
420
  transits,
410
421
  vehlowCusps,
411
422
  vertexOf,
412
- wholeSignCusps
423
+ wholeSignCusps,
424
+ withEphemeris
413
425
  };
@@ -1,5 +1,5 @@
1
- import { f as AspectType, c as BodyPosition, n as Aspect, Z as ZodiacSign, v as SignDefinition } from './types-B-yb_tGL.js';
2
- import './houses-CFERsAlK.js';
1
+ import { f as AspectType, c as BodyPosition, o as Aspect, Z as ZodiacSign, v as SignDefinition } from './types-DpPdtXgO.js';
2
+ import './houses-Bh7GCnPi.js';
3
3
 
4
4
  interface AspectDefinition {
5
5
  readonly type: AspectType;
@@ -1,4 +1,5 @@
1
- export { a as ASPECTS, b as ASPECT_BODIES, c as ASPECT_TYPES, d as AspectDefinition, A as AspectMotion, g as STATIONARY_RELATIVE_SPEED, h as aspectMotion, j as findAspects, m as matchAspect, n as normalizeLongitude, s as separation } from './internal-math-DJJ8BYex.js';
2
- export { A as AngleInput, H as HOUSE_SYSTEMS, P as PLACIDUS_POLAR_FALLBACK, a as POLAR_FALLBACK, b as POLAR_UNDEFINED_HOUSE_SYSTEMS, c as alcabitiusCusps, d as campanusCusps, e as computeAngles, f as computeHouses, g as eastPointOf, h as equalCusps, i as equalMcCusps, j as houseOf, k as isPolarUndefinedHouseSystem, l as kochCusps, m as meanObliquity, n as meridianCusps, o as morinusCusps, p as placidusCusps, q as porphyryCusps, r as ramcOf, s as regiomontanusCusps, t as topocentricCusps, v as vehlowCusps, u as vertexOf, w as wholeSignCusps } from './houses-CFERsAlK.js';
3
- export { A as Angles, n as Aspect, f as AspectType, B as BodyName, c as BodyPosition, d as Chart, g as ChartFlag, C as ChartInput, p as ENGINE_VERSION, b as HouseNumber, H as HouseSystem, a as Houses } from './types-B-yb_tGL.js';
1
+ export { a as ASPECTS, b as ASPECT_BODIES, c as ASPECT_TYPES, d as AspectDefinition, A as AspectMotion, g as STATIONARY_RELATIVE_SPEED, h as aspectMotion, j as findAspects, m as matchAspect, n as normalizeLongitude, s as separation } from './internal-math-CxenuGfm.js';
2
+ export { A as AngleInput, H as HOUSE_SYSTEMS, P as PLACIDUS_POLAR_FALLBACK, a as POLAR_FALLBACK, b as POLAR_UNDEFINED_HOUSE_SYSTEMS, c as alcabitiusCusps, d as campanusCusps, e as computeAngles, f as computeHouses, g as eastPointOf, h as equalCusps, i as equalMcCusps, j as houseOf, k as isPolarUndefinedHouseSystem, l as kochCusps, m as meanObliquity, n as meridianCusps, o as morinusCusps, p as placidusCusps, q as porphyryCusps, r as ramcOf, s as regiomontanusCusps, t as topocentricCusps, v as vehlowCusps, u as vertexOf, w as wholeSignCusps } from './houses-Bh7GCnPi.js';
3
+ export { A as Angles, o as Aspect, f as AspectType, B as BodyName, c as BodyPosition, d as Chart, g as ChartFlag, C as ChartInput, p as ENGINE_VERSION, b as HouseNumber, H as HouseSystem, a as Houses } from './types-DpPdtXgO.js';
4
4
  import './deltat.js';
5
+ import './time-scale-DIFNa0gz.js';
@@ -1,3 +1,14 @@
1
+ import {
2
+ ASPECTS,
3
+ ASPECT_BODIES,
4
+ ASPECT_TYPES,
5
+ ENGINE_VERSION,
6
+ STATIONARY_RELATIVE_SPEED,
7
+ aspectMotion,
8
+ findAspects,
9
+ matchAspect,
10
+ separation
11
+ } from "./chunk-B4M2Y7FT.js";
1
12
  import {
2
13
  HOUSE_SYSTEMS,
3
14
  PLACIDUS_POLAR_FALLBACK,
@@ -24,19 +35,10 @@ import {
24
35
  vehlowCusps,
25
36
  vertexOf,
26
37
  wholeSignCusps
27
- } from "./chunk-DMGHYCDI.js";
38
+ } from "./chunk-NNOSOOWS.js";
28
39
  import {
29
- ASPECTS,
30
- ASPECT_BODIES,
31
- ASPECT_TYPES,
32
- ENGINE_VERSION,
33
- STATIONARY_RELATIVE_SPEED,
34
- aspectMotion,
35
- findAspects,
36
- matchAspect,
37
- normalizeLongitude,
38
- separation
39
- } from "./chunk-OG4OYTJJ.js";
40
+ normalizeLongitude
41
+ } from "./chunk-RMBWKZI2.js";
40
42
  export {
41
43
  ASPECTS,
42
44
  ASPECT_BODIES,
@@ -1,10 +1,19 @@
1
- import { B as BodyName, c as BodyPosition, C as ChartInput, d as Chart } from './types-B-yb_tGL.js';
1
+ import { B as BodyName, D as DetailedResult } from './types-DpPdtXgO.js';
2
+ export { E as EphemerisFallback } from './types-DpPdtXgO.js';
3
+ export { b as bodyLongitude, c as computeBodies, a as computeChart, l as longitudeSpeed } from './ephemeris-exTSqBgb.js';
2
4
  import './deltat.js';
5
+ import './time-scale-DIFNa0gz.js';
3
6
 
4
- /** Apparent longitude at a UTC instant, on the engine's time basis. */
5
- declare function bodyLongitude(body: BodyName, date: Date): number;
6
- declare function longitudeSpeed(body: BodyName, date: Date): number;
7
- declare function computeBodies(date: Date): BodyPosition[];
8
- declare function computeChart(input: ChartInput): Chart;
7
+ /**
8
+ * `bodyLongitude`'s longitude as `value`, with the ephemeris it came from and
9
+ * the flag that says why that is astronomy-engine where the shipped DE440
10
+ * pack was the default (`DetailedResult`).
11
+ */
12
+ declare function bodyLongitudeDetailed(body: BodyName, date: Date): DetailedResult<number>;
13
+ /**
14
+ * `longitudeSpeed`'s speed as `value`, labelled as `bodyLongitudeDetailed`'s
15
+ * is: both samples are read on the source chosen at `date`.
16
+ */
17
+ declare function longitudeSpeedDetailed(body: BodyName, date: Date): DetailedResult<number>;
9
18
 
10
- export { bodyLongitude, computeBodies, computeChart, longitudeSpeed };
19
+ export { DetailedResult, bodyLongitudeDetailed, longitudeSpeedDetailed };
package/dist/internal.js CHANGED
@@ -2,15 +2,36 @@ import {
2
2
  bodyLongitude,
3
3
  computeBodies,
4
4
  computeChart,
5
+ ephemerisOver,
6
+ fallbacksAt,
5
7
  longitudeSpeed
6
- } from "./chunk-SRXBTP5H.js";
8
+ } from "./chunk-QLIEEICB.js";
9
+ import "./chunk-B4M2Y7FT.js";
10
+ import "./chunk-2PZYJQV5.js";
7
11
  import "./chunk-B5LKF437.js";
12
+ import "./chunk-767FTO7O.js";
13
+ import "./chunk-YPU3MDNI.js";
14
+ import "./chunk-Y4E3WJU5.js";
15
+ import "./chunk-NNOSOOWS.js";
16
+ import "./chunk-RMBWKZI2.js";
8
17
  import "./chunk-BHJXUY67.js";
9
- import "./chunk-DMGHYCDI.js";
10
- import "./chunk-OG4OYTJJ.js";
18
+
19
+ // src/internal.ts
20
+ function bodyLongitudeDetailed(body, date) {
21
+ return detailedAt(bodyLongitude(body, date), date);
22
+ }
23
+ function longitudeSpeedDetailed(body, date) {
24
+ return detailedAt(longitudeSpeed(body, date), date);
25
+ }
26
+ function detailedAt(value, date) {
27
+ const at = [date.getTime()];
28
+ return Object.freeze({ value, ephemeris: Object.freeze(ephemerisOver(at)), flags: Object.freeze(fallbacksAt(at)) });
29
+ }
11
30
  export {
12
31
  bodyLongitude,
32
+ bodyLongitudeDetailed,
13
33
  computeBodies,
14
34
  computeChart,
15
- longitudeSpeed
35
+ longitudeSpeed,
36
+ longitudeSpeedDetailed
16
37
  };
@@ -0,0 +1,114 @@
1
+ // src/aspects.ts
2
+ var ASPECTS = /* @__PURE__ */ Object.freeze([
3
+ /* @__PURE__ */ Object.freeze({ type: "conjunction", angle: 0, orb: 8, luminaryOrb: 10 }),
4
+ /* @__PURE__ */ Object.freeze({ type: "sextile", angle: 60, orb: 4, luminaryOrb: 5 }),
5
+ /* @__PURE__ */ Object.freeze({ type: "square", angle: 90, orb: 7, luminaryOrb: 8 }),
6
+ /* @__PURE__ */ Object.freeze({ type: "trine", angle: 120, orb: 7, luminaryOrb: 8 }),
7
+ /* @__PURE__ */ Object.freeze({ type: "opposition", angle: 180, orb: 8, luminaryOrb: 10 })
8
+ ]);
9
+ var LUMINARIES = /* @__PURE__ */ new Set(["Sun", "Moon"]);
10
+ var ASPECT_BODY_NAMES = /* @__PURE__ */ Object.freeze([
11
+ "Sun",
12
+ "Moon",
13
+ "Mercury",
14
+ "Venus",
15
+ "Mars",
16
+ "Jupiter",
17
+ "Saturn",
18
+ "Uranus",
19
+ "Neptune",
20
+ "Pluto"
21
+ ]);
22
+ var ASPECT_BODY_SET = /* @__PURE__ */ new Set(ASPECT_BODY_NAMES);
23
+ function separation(a, b) {
24
+ const difference = Math.abs(((a - b) % 360 + 360) % 360);
25
+ return difference > 180 ? 360 - difference : difference;
26
+ }
27
+ function matchAspect(aBody, aLongitude, bBody, bLongitude) {
28
+ const distance = separation(aLongitude, bLongitude);
29
+ const hasLuminary = LUMINARIES.has(aBody) || LUMINARIES.has(bBody);
30
+ let best = null;
31
+ for (const definition of ASPECTS) {
32
+ const orb = Math.abs(distance - definition.angle);
33
+ const maximum = hasLuminary ? definition.luminaryOrb : definition.orb;
34
+ if (orb <= maximum && (!best || orb < best.orb)) {
35
+ best = { definition, orb };
36
+ }
37
+ }
38
+ return best;
39
+ }
40
+
41
+ // src/signs.ts
42
+ function normalizeLongitude(lon) {
43
+ if (!Number.isFinite(lon)) throw new RangeError("Longitude must be finite.");
44
+ return (lon % 360 + 360) % 360;
45
+ }
46
+
47
+ // src/points.ts
48
+ var DEG = Math.PI / 180;
49
+ var RAD = 180 / Math.PI;
50
+ var ARCSEC = 1 / 3600;
51
+ function midpoint(first, second) {
52
+ const arc = normalizeLongitude(second - first);
53
+ return normalizeLongitude(first + (arc > 180 ? arc - 360 : arc) / 2);
54
+ }
55
+
56
+ // src/techniques/names.ts
57
+ var BODY_NAMES = [
58
+ "Sun",
59
+ "Moon",
60
+ "Mercury",
61
+ "Venus",
62
+ "Mars",
63
+ "Jupiter",
64
+ "Saturn",
65
+ "Uranus",
66
+ "Neptune",
67
+ "Pluto",
68
+ "North Node",
69
+ "South Node"
70
+ ];
71
+ function bodyName(value, label) {
72
+ if (typeof value === "string" && BODY_NAMES.includes(value)) return value;
73
+ throw new RangeError(`${label} must be a body name.`);
74
+ }
75
+ function finiteDegrees(value, label) {
76
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError(`${label} must be a finite number of degrees.`);
77
+ return value;
78
+ }
79
+
80
+ // src/techniques/composite.ts
81
+ function positions(list, label) {
82
+ if (!Array.isArray(list)) throw new RangeError(`${label} must be an array of { body, lon }.`);
83
+ const seen = /* @__PURE__ */ new Set();
84
+ return list.map((row) => {
85
+ const body = bodyName(row?.body, `${label}'s body`);
86
+ if (seen.has(body)) throw new RangeError(`${label} names ${body} twice.`);
87
+ seen.add(body);
88
+ return { body, lon: finiteDegrees(row?.lon, `${label}'s ${body}`) };
89
+ });
90
+ }
91
+ function compositeMidpoints(first, second) {
92
+ const b = new Map(positions(second, "second").map((row) => [row.body, row.lon]));
93
+ const out = [];
94
+ for (const row of positions(first, "first")) {
95
+ const other = b.get(row.body);
96
+ if (other !== void 0) out.push(Object.freeze({ body: row.body, lon: midpoint(row.lon, other) }));
97
+ }
98
+ return Object.freeze(out);
99
+ }
100
+ function compositeAspects(points) {
101
+ const list = positions(points, "points").filter((point) => ASPECT_BODY_SET.has(point.body));
102
+ const out = [];
103
+ list.forEach((a, i) => {
104
+ for (const b of list.slice(i + 1)) {
105
+ const match = matchAspect(a.body, a.lon, b.body, b.lon);
106
+ if (match) out.push(Object.freeze({ a: a.body, b: b.body, type: match.definition.type, orb: match.orb }));
107
+ }
108
+ });
109
+ return Object.freeze(out.sort((x, y) => x.orb - y.orb));
110
+ }
111
+ export {
112
+ compositeAspects,
113
+ compositeMidpoints
114
+ };
@@ -0,0 +1,253 @@
1
+ // src/body-label.ts
2
+ var MAX_BODY_LABEL_LENGTH = 80;
3
+ function checkedBodyLabel(value) {
4
+ if (typeof value !== "string" || value.length === 0 || value.length > MAX_BODY_LABEL_LENGTH || value.trim() !== value || /[\u0000-\u001f\u007f]/u.test(value)) {
5
+ throw new RangeError(
6
+ "Body labels must be nonempty, trimmed strings of at most 80 characters, without control characters."
7
+ );
8
+ }
9
+ return value;
10
+ }
11
+
12
+ // src/exact.ts
13
+ var SAFE_MAGNITUDE = 2 ** 1e3;
14
+ function add(partials, value) {
15
+ let x = value;
16
+ let kept = 0;
17
+ for (let index = 0; index < partials.length; index += 1) {
18
+ let y = partials[index];
19
+ if (Math.abs(x) < Math.abs(y)) {
20
+ const larger = y;
21
+ y = x;
22
+ x = larger;
23
+ }
24
+ const high = x + y;
25
+ const low = y - (high - x);
26
+ if (low !== 0) partials[kept++] = low;
27
+ x = high;
28
+ }
29
+ partials.length = kept;
30
+ if (x !== 0) partials.push(x);
31
+ }
32
+ function exactSum(...terms) {
33
+ const partials = [];
34
+ for (const term of terms) {
35
+ if (typeof term === "number") add(partials, term);
36
+ else for (const part of term) add(partials, part);
37
+ }
38
+ return partials;
39
+ }
40
+ function negated(sum) {
41
+ return sum.map((part) => -part);
42
+ }
43
+ function signOf(sum) {
44
+ const top = sum[sum.length - 1];
45
+ return top === void 0 ? 0 : top > 0 ? 1 : -1;
46
+ }
47
+ function compareExact(a, b) {
48
+ return signOf(exactSum(a, typeof b === "number" ? -b : negated(b)));
49
+ }
50
+ function absolute(sum) {
51
+ return signOf(sum) < 0 ? negated(sum) : sum;
52
+ }
53
+ function roundedValue(sum) {
54
+ let index = sum.length;
55
+ if (index === 0) return 0;
56
+ let high = sum[--index];
57
+ let low = 0;
58
+ while (index > 0) {
59
+ const x = high;
60
+ const y = sum[--index];
61
+ high = x + y;
62
+ low = y - (high - x);
63
+ if (low !== 0) break;
64
+ }
65
+ const below = index > 0 ? sum[index - 1] : 0;
66
+ if (low < 0 && below < 0 || low > 0 && below > 0) {
67
+ const twice = low * 2;
68
+ const moved = high + twice;
69
+ if (moved - high === twice) high = moved;
70
+ }
71
+ return high;
72
+ }
73
+
74
+ // src/declination.ts
75
+ var DEG = Math.PI / 180;
76
+ var RAD = 180 / Math.PI;
77
+ var DECLINATION_ORB = 1;
78
+ var DECLINATION_ORB_LUMINARY = 1.5;
79
+ var DEFAULT_DECLINATION_ORB_POLICY = /* @__PURE__ */ Object.freeze({
80
+ orb: DECLINATION_ORB,
81
+ luminaryOrb: DECLINATION_ORB_LUMINARY
82
+ });
83
+ var RA_POLE_TOLERANCE = 32 * Number.EPSILON;
84
+ var MAX_DECLINATION_BODIES = 256;
85
+ var SUN_BOUND_LATITUDE = 1e-3;
86
+ function finite(value, label) {
87
+ if (typeof value !== "number" || !Number.isFinite(value)) {
88
+ throw new RangeError(`${label} must be finite.`);
89
+ }
90
+ }
91
+ function obliquity(value) {
92
+ finite(value, "true obliquity");
93
+ if (value < 0 || value > 90) throw new RangeError("true obliquity must be in [0,90] degrees.");
94
+ }
95
+ function normalize(value) {
96
+ const remainder = value % 360;
97
+ if (remainder === 0) return 0;
98
+ return remainder > 0 ? remainder : Math.min(remainder + 360, 359.99999999999994);
99
+ }
100
+ function policyOf(policy) {
101
+ const fields = dataFields(policy, "declination orb policy");
102
+ if (Object.keys(fields).length !== 2 || !Object.hasOwn(fields, "orb") || !Object.hasOwn(fields, "luminaryOrb")) {
103
+ throw new RangeError("declination orb policy requires only orb and luminaryOrb.");
104
+ }
105
+ const checked = { orb: fields.orb.value, luminaryOrb: fields.luminaryOrb.value };
106
+ for (const key of ["orb", "luminaryOrb"]) {
107
+ finite(checked[key], `declination policy ${key}`);
108
+ if (checked[key] < 0 || checked[key] > 90) throw new RangeError("declination orbs must be in [0,90] degrees.");
109
+ }
110
+ return checked;
111
+ }
112
+ function dataFields(value, label) {
113
+ if (value === null || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
114
+ throw new RangeError(`${label} must be a plain data object.`);
115
+ }
116
+ const fields = Object.getOwnPropertyDescriptors(value);
117
+ if (Reflect.ownKeys(value).length !== Object.keys(fields).length || Object.values(fields).some((field) => !Object.hasOwn(field, "value") || !field.enumerable)) {
118
+ throw new RangeError(`${label} must contain only enumerable data properties.`);
119
+ }
120
+ return fields;
121
+ }
122
+ function bodyName(body) {
123
+ checkedBodyLabel(body);
124
+ }
125
+ function eclipticToEquatorial(longitudeDeg, latitudeDeg, trueObliquityDeg) {
126
+ finite(longitudeDeg, "ecliptic longitude");
127
+ finite(latitudeDeg, "ecliptic latitude");
128
+ if (latitudeDeg < -90 || latitudeDeg > 90) throw new RangeError("ecliptic latitude must be in [-90,90] degrees.");
129
+ obliquity(trueObliquityDeg);
130
+ const lon = normalize(longitudeDeg) * DEG;
131
+ const lat = latitudeDeg * DEG;
132
+ const tilt = trueObliquityDeg * DEG;
133
+ const cosLat = Math.cos(lat);
134
+ const x = cosLat * Math.cos(lon);
135
+ const y = cosLat * Math.sin(lon) * Math.cos(tilt) - Math.sin(lat) * Math.sin(tilt);
136
+ const z = cosLat * Math.sin(lon) * Math.sin(tilt) + Math.sin(lat) * Math.cos(tilt);
137
+ const horizontal = Math.hypot(x, y);
138
+ const raDefined = horizontal > RA_POLE_TOLERANCE;
139
+ let dec = trueObliquityDeg === 0 ? latitudeDeg : Math.atan2(z, horizontal) * RAD;
140
+ if (latitudeDeg === 0) dec = Math.max(-trueObliquityDeg, Math.min(trueObliquityDeg, dec));
141
+ return {
142
+ ra: raDefined ? trueObliquityDeg === 0 ? normalize(longitudeDeg) : normalize(Math.atan2(y, x) * RAD) : null,
143
+ dec: dec === 0 ? 0 : dec,
144
+ raDefined
145
+ };
146
+ }
147
+ function declinationOf(lon, lat, trueObliquity) {
148
+ return eclipticToEquatorial(lon, lat, trueObliquity).dec;
149
+ }
150
+ function declinationOrb(a, b, policy = DEFAULT_DECLINATION_ORB_POLICY) {
151
+ bodyName(a);
152
+ bodyName(b);
153
+ const checked = policyOf(policy);
154
+ return a === "Sun" || a === "Moon" || b === "Sun" || b === "Moon" ? checked.luminaryOrb : checked.orb;
155
+ }
156
+ function placeBodies(bodies, trueObliquity, chartSun = false) {
157
+ obliquity(trueObliquity);
158
+ if (!Array.isArray(bodies) || Object.getPrototypeOf(bodies) !== Array.prototype) {
159
+ throw new RangeError("declination bodies must be a standard array.");
160
+ }
161
+ const fields = Object.getOwnPropertyDescriptors(bodies);
162
+ const length = fields.length.value;
163
+ if (length > MAX_DECLINATION_BODIES || Reflect.ownKeys(bodies).length !== length + 1) {
164
+ throw new RangeError("declination bodies must be dense, undecorated, and contain at most 256 entries.");
165
+ }
166
+ const seen = /* @__PURE__ */ new Set();
167
+ const placed = [];
168
+ const longitudes = [];
169
+ for (let index = 0; index < length; index += 1) {
170
+ const field = fields[String(index)];
171
+ if (!field || !Object.hasOwn(field, "value") || !field.enumerable) {
172
+ throw new RangeError("declination bodies must contain only enumerable data entries.");
173
+ }
174
+ const source = dataFields(field.value, "declination body");
175
+ const body = { body: source.body?.value, lon: source.lon?.value, lat: source.lat?.value };
176
+ bodyName(body.body);
177
+ if (seen.has(body.body)) throw new RangeError("duplicate declination body identifier.");
178
+ seen.add(body.body);
179
+ const position = eclipticToEquatorial(body.lon, body.lat, trueObliquity);
180
+ const exemptSun = body.body === "Sun" && (chartSun || Math.abs(body.lat) <= SUN_BOUND_LATITUDE);
181
+ placed.push({
182
+ body: body.body,
183
+ lon: normalize(body.lon),
184
+ lat: body.lat,
185
+ ...position,
186
+ outOfBounds: !exemptSun && Math.abs(position.dec) > trueObliquity,
187
+ boundMarginArcsec: (Math.abs(position.dec) - trueObliquity) * 3600
188
+ });
189
+ longitudes.push(body.lon);
190
+ }
191
+ return { rows: placed, longitudes };
192
+ }
193
+ function longitudeSeparation(a, b) {
194
+ let difference = exactSum(a % 360, -(b % 360));
195
+ while (signOf(difference) < 0) difference = exactSum(difference, 360);
196
+ while (compareExact(difference, 360) >= 0) difference = exactSum(difference, -360);
197
+ return roundedValue(compareExact(difference, 180) > 0 ? exactSum(360, negated(difference)) : difference);
198
+ }
199
+ function aspectsFor({ rows, longitudes }, policy) {
200
+ const found = [];
201
+ for (let i = 0; i < rows.length; i += 1) {
202
+ for (let j = i + 1; j < rows.length; j += 1) {
203
+ const a = rows[i];
204
+ const b = rows[j];
205
+ const parallel = absolute(exactSum(a.dec, -b.dec));
206
+ const contraparallel = absolute(exactSum(a.dec, b.dec));
207
+ const isParallel = compareExact(parallel, contraparallel) <= 0;
208
+ const exactOrb = isParallel ? parallel : contraparallel;
209
+ const maximumOrb = declinationOrb(a.body, b.body, policy);
210
+ if (compareExact(exactOrb, maximumOrb) > 0) continue;
211
+ found.push({ exactOrb, aspect: {
212
+ a: a.body,
213
+ b: b.body,
214
+ type: isParallel ? "parallel" : "contraparallel",
215
+ orb: roundedValue(exactOrb),
216
+ maximumOrb,
217
+ decA: a.dec,
218
+ decB: b.dec,
219
+ separation: longitudeSeparation(longitudes[i], longitudes[j])
220
+ } });
221
+ }
222
+ }
223
+ return found.sort((x, y) => compareExact(x.exactOrb, y.exactOrb)).map((entry) => entry.aspect);
224
+ }
225
+ function findDeclinationAspects(bodies, trueObliquity, policy = DEFAULT_DECLINATION_ORB_POLICY) {
226
+ const checked = policyOf(policy);
227
+ return aspectsFor(placeBodies(bodies, trueObliquity), checked);
228
+ }
229
+ function declinations(bodies, trueObliquity, policy, chartSun) {
230
+ const checked = policyOf(policy);
231
+ const placed = placeBodies(bodies, trueObliquity, chartSun);
232
+ return {
233
+ trueObliquity,
234
+ rows: placed.rows,
235
+ aspects: aspectsFor(placed, checked),
236
+ orbPolicy: checked,
237
+ convention: "true-equator-and-equinox-of-date; full-ecliptic-longitude-and-latitude",
238
+ receiptScope: "not-included-in-natal-receipt"
239
+ };
240
+ }
241
+ function declinationsForBodies(bodies, trueObliquity, policy = DEFAULT_DECLINATION_ORB_POLICY) {
242
+ return declinations(bodies, trueObliquity, policy, false);
243
+ }
244
+ export {
245
+ DEFAULT_DECLINATION_ORB_POLICY,
246
+ RA_POLE_TOLERANCE,
247
+ SUN_BOUND_LATITUDE,
248
+ declinationOf,
249
+ declinationOrb,
250
+ declinationsForBodies,
251
+ eclipticToEquatorial,
252
+ findDeclinationAspects
253
+ };