@zodiacs/engine 0.1.1-rc.14
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.
- package/CHANGELOG.md +502 -0
- package/LICENSE +21 -0
- package/LICENSING.md +99 -0
- package/NOTICE +58 -0
- package/README.md +785 -0
- package/dist/chunk-4OSOCZY2.js +340 -0
- package/dist/chunk-AECKV73C.js +231 -0
- package/dist/chunk-CPALRSPC.js +35 -0
- package/dist/chunk-GFT24GFR.js +25 -0
- package/dist/chunk-NAJ735VN.js +219 -0
- package/dist/chunk-ONBZ4HK7.js +285 -0
- package/dist/chunk-PFGUCNOK.js +87 -0
- package/dist/chunk-RETEVD4F.js +681 -0
- package/dist/crossings.d.ts +91 -0
- package/dist/crossings.js +8 -0
- package/dist/deltat.d.ts +73 -0
- package/dist/deltat.js +12 -0
- package/dist/geo.d.ts +58 -0
- package/dist/geo.js +312 -0
- package/dist/index.d.ts +478 -0
- package/dist/index.js +682 -0
- package/dist/internal-math-BE2hcSHd.d.ts +271 -0
- package/dist/internal-math.d.ts +3 -0
- package/dist/internal-math.js +76 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +16 -0
- package/dist/receipt.d.ts +224 -0
- package/dist/receipt.js +824 -0
- package/dist/types-CeafogFp.d.ts +197 -0
- package/package.json +94 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findLongitudeCrossingsWith,
|
|
3
|
+
searchLongitudeCrossingsWith
|
|
4
|
+
} from "./chunk-AECKV73C.js";
|
|
5
|
+
import {
|
|
6
|
+
assertDerivedFlags,
|
|
7
|
+
snapshotFlags,
|
|
8
|
+
timeFlags,
|
|
9
|
+
validateBirthSettings
|
|
10
|
+
} from "./chunk-PFGUCNOK.js";
|
|
11
|
+
import {
|
|
12
|
+
DECLINATION_ORB,
|
|
13
|
+
DECLINATION_ORB_LUMINARY,
|
|
14
|
+
DEFAULT_DECLINATION_ORB_POLICY,
|
|
15
|
+
LOTS,
|
|
16
|
+
MEAN_LUNAR_INCLINATION,
|
|
17
|
+
RA_POLE_TOLERANCE,
|
|
18
|
+
SPEED_STEP_DAYS,
|
|
19
|
+
SUN_BOUND_LATITUDE,
|
|
20
|
+
absolute,
|
|
21
|
+
antiscion,
|
|
22
|
+
bodyLongitude,
|
|
23
|
+
checkedBodyLabel,
|
|
24
|
+
compareExact,
|
|
25
|
+
computeBodies,
|
|
26
|
+
computeChart,
|
|
27
|
+
computeChartDeclinations,
|
|
28
|
+
computePoints,
|
|
29
|
+
contraAntiscion,
|
|
30
|
+
declinationOf,
|
|
31
|
+
declinationOrb,
|
|
32
|
+
declinationsForBodies,
|
|
33
|
+
eclipticToEquatorial,
|
|
34
|
+
exactSign,
|
|
35
|
+
exactSum,
|
|
36
|
+
findDeclinationAspects,
|
|
37
|
+
hellenisticLots,
|
|
38
|
+
longitudeSpeed,
|
|
39
|
+
lunarMeanArguments,
|
|
40
|
+
meanApogee,
|
|
41
|
+
meanNodeLongitude,
|
|
42
|
+
midpoint,
|
|
43
|
+
roundedValue,
|
|
44
|
+
sectOf,
|
|
45
|
+
signOf
|
|
46
|
+
} from "./chunk-RETEVD4F.js";
|
|
47
|
+
import {
|
|
48
|
+
HOUSE_SYSTEMS,
|
|
49
|
+
PLACIDUS_POLAR_FALLBACK,
|
|
50
|
+
POLAR_FALLBACK,
|
|
51
|
+
POLAR_UNDEFINED_HOUSE_SYSTEMS,
|
|
52
|
+
alcabitiusCusps,
|
|
53
|
+
campanusCusps,
|
|
54
|
+
computeAngles,
|
|
55
|
+
computeHouses,
|
|
56
|
+
eastPointOf,
|
|
57
|
+
equalCusps,
|
|
58
|
+
equalMcCusps,
|
|
59
|
+
houseOf,
|
|
60
|
+
isPolarUndefinedHouseSystem,
|
|
61
|
+
kochCusps,
|
|
62
|
+
meanObliquity,
|
|
63
|
+
meridianCusps,
|
|
64
|
+
morinusCusps,
|
|
65
|
+
placidusCusps,
|
|
66
|
+
porphyryCusps,
|
|
67
|
+
ramcOf,
|
|
68
|
+
regiomontanusCusps,
|
|
69
|
+
topocentricCusps,
|
|
70
|
+
vehlowCusps,
|
|
71
|
+
vertexOf,
|
|
72
|
+
wholeSignCusps
|
|
73
|
+
} from "./chunk-4OSOCZY2.js";
|
|
74
|
+
import {
|
|
75
|
+
dateFrom
|
|
76
|
+
} from "./chunk-CPALRSPC.js";
|
|
77
|
+
import {
|
|
78
|
+
EPHEMERIS_SPAN,
|
|
79
|
+
REFERENCE_SPAN,
|
|
80
|
+
outsideReferenceSpan
|
|
81
|
+
} from "./chunk-GFT24GFR.js";
|
|
82
|
+
import {
|
|
83
|
+
DELTA_T_MODEL,
|
|
84
|
+
DELTA_T_TABLE,
|
|
85
|
+
deltaT,
|
|
86
|
+
deltaTAt
|
|
87
|
+
} from "./chunk-ONBZ4HK7.js";
|
|
88
|
+
import {
|
|
89
|
+
ASPECTS,
|
|
90
|
+
ASPECT_BODIES,
|
|
91
|
+
ASPECT_TYPES,
|
|
92
|
+
ELEMENTS,
|
|
93
|
+
ENGINE_VERSION,
|
|
94
|
+
EPHEMERIS,
|
|
95
|
+
MODALITIES,
|
|
96
|
+
SIGNS,
|
|
97
|
+
SIGN_NAMES,
|
|
98
|
+
STATIONARY_RELATIVE_SPEED,
|
|
99
|
+
aspectMotion,
|
|
100
|
+
degreeInSign,
|
|
101
|
+
findAspects,
|
|
102
|
+
matchAspect,
|
|
103
|
+
normalizeLongitude,
|
|
104
|
+
separation,
|
|
105
|
+
signForLongitude,
|
|
106
|
+
signIndexForLongitude
|
|
107
|
+
} from "./chunk-NAJ735VN.js";
|
|
108
|
+
|
|
109
|
+
// src/returns.ts
|
|
110
|
+
var DAY = 864e5;
|
|
111
|
+
function validMilliseconds(date, label) {
|
|
112
|
+
if (!(date instanceof Date)) throw new RangeError(`${label} must be a valid Date.`);
|
|
113
|
+
const milliseconds = Date.prototype.getTime.call(date);
|
|
114
|
+
if (!Number.isFinite(milliseconds)) throw new RangeError(`${label} must be a valid Date.`);
|
|
115
|
+
return milliseconds;
|
|
116
|
+
}
|
|
117
|
+
function findLongitudeCrossings(body, targetLongitude, from, to, stepDays = 5) {
|
|
118
|
+
return findLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, from, to, stepDays);
|
|
119
|
+
}
|
|
120
|
+
function searchLongitudeCrossings(body, targetLongitude, from, to, options) {
|
|
121
|
+
return searchLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, from, to, options);
|
|
122
|
+
}
|
|
123
|
+
function groupIntoSeasons(crossings, gapDays = 400) {
|
|
124
|
+
if (!Number.isFinite(gapDays) || gapDays <= 0) {
|
|
125
|
+
throw new RangeError("gapDays must be positive.");
|
|
126
|
+
}
|
|
127
|
+
const seasons = [];
|
|
128
|
+
for (const crossing of crossings) {
|
|
129
|
+
const current = seasons.at(-1);
|
|
130
|
+
if (current && crossing.at.getTime() - current.last.getTime() <= gapDays * DAY) {
|
|
131
|
+
current.crossings.push(crossing);
|
|
132
|
+
current.last = crossing.at;
|
|
133
|
+
} else {
|
|
134
|
+
seasons.push({
|
|
135
|
+
index: seasons.length + 1,
|
|
136
|
+
crossings: [crossing],
|
|
137
|
+
first: crossing.at,
|
|
138
|
+
last: crossing.at
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return seasons;
|
|
143
|
+
}
|
|
144
|
+
function computeSaturnReturns(birthUtc) {
|
|
145
|
+
const birthTime = validMilliseconds(birthUtc, "Birth date");
|
|
146
|
+
const before = new Date(birthTime - SPEED_STEP_DAYS * DAY);
|
|
147
|
+
const after = new Date(birthTime + SPEED_STEP_DAYS * DAY);
|
|
148
|
+
const from = new Date(birthTime + 26 * 365.25 * DAY);
|
|
149
|
+
const to = new Date(birthTime + 92 * 365.25 * DAY);
|
|
150
|
+
validMilliseconds(before, "Natal speed window start");
|
|
151
|
+
validMilliseconds(after, "Natal speed window end");
|
|
152
|
+
validMilliseconds(from, "Saturn return window start");
|
|
153
|
+
validMilliseconds(to, "Saturn return window end");
|
|
154
|
+
const natalLon = bodyLongitude("Saturn", birthUtc);
|
|
155
|
+
const speed = longitudeSpeed("Saturn", birthUtc);
|
|
156
|
+
return {
|
|
157
|
+
natalLon,
|
|
158
|
+
natalRetrograde: speed < 0,
|
|
159
|
+
seasons: groupIntoSeasons(findLongitudeCrossings("Saturn", natalLon, from, to))
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/synastry.ts
|
|
164
|
+
function findInterAspects(first, second) {
|
|
165
|
+
const aBodies = first.filter((body) => ASPECT_BODIES.has(body.body));
|
|
166
|
+
const bBodies = second.filter((body) => ASPECT_BODIES.has(body.body));
|
|
167
|
+
const aspects = [];
|
|
168
|
+
for (const a of aBodies) {
|
|
169
|
+
for (const b of bBodies) {
|
|
170
|
+
const match = matchAspect(a.body, a.lon, b.body, b.lon);
|
|
171
|
+
if (!match) continue;
|
|
172
|
+
aspects.push({
|
|
173
|
+
a: a.body,
|
|
174
|
+
aLon: a.lon,
|
|
175
|
+
b: b.body,
|
|
176
|
+
bLon: b.lon,
|
|
177
|
+
type: match.definition.type,
|
|
178
|
+
orb: match.orb
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return aspects.sort((a, b) => a.orb - b.orb);
|
|
183
|
+
}
|
|
184
|
+
function elementBalance(bodies) {
|
|
185
|
+
const balance = {
|
|
186
|
+
fire: 0,
|
|
187
|
+
earth: 0,
|
|
188
|
+
air: 0,
|
|
189
|
+
water: 0
|
|
190
|
+
};
|
|
191
|
+
for (const body of bodies) {
|
|
192
|
+
if (!ASPECT_BODIES.has(body.body)) continue;
|
|
193
|
+
balance[signForLongitude(body.lon).element] += 1;
|
|
194
|
+
}
|
|
195
|
+
return balance;
|
|
196
|
+
}
|
|
197
|
+
function modalityBalance(bodies) {
|
|
198
|
+
const balance = {
|
|
199
|
+
cardinal: 0,
|
|
200
|
+
fixed: 0,
|
|
201
|
+
mutable: 0
|
|
202
|
+
};
|
|
203
|
+
for (const body of bodies) {
|
|
204
|
+
if (!ASPECT_BODIES.has(body.body)) continue;
|
|
205
|
+
balance[signForLongitude(body.lon).modality] += 1;
|
|
206
|
+
}
|
|
207
|
+
return balance;
|
|
208
|
+
}
|
|
209
|
+
function summarizePair(first, second, topCount = 8) {
|
|
210
|
+
if (!Number.isInteger(topCount) || topCount < 0) {
|
|
211
|
+
throw new RangeError("topCount must be a non-negative integer.");
|
|
212
|
+
}
|
|
213
|
+
const aspects = findInterAspects(first, second);
|
|
214
|
+
const counts = {
|
|
215
|
+
conjunction: 0,
|
|
216
|
+
sextile: 0,
|
|
217
|
+
square: 0,
|
|
218
|
+
trine: 0,
|
|
219
|
+
opposition: 0
|
|
220
|
+
};
|
|
221
|
+
for (const aspect of aspects) counts[aspect.type] += 1;
|
|
222
|
+
return {
|
|
223
|
+
aspects,
|
|
224
|
+
top: aspects.slice(0, topCount),
|
|
225
|
+
counts,
|
|
226
|
+
easeful: counts.trine + counts.sextile,
|
|
227
|
+
charged: counts.square + counts.opposition,
|
|
228
|
+
elements: {
|
|
229
|
+
a: elementBalance(first),
|
|
230
|
+
b: elementBalance(second)
|
|
231
|
+
},
|
|
232
|
+
modalities: {
|
|
233
|
+
a: modalityBalance(first),
|
|
234
|
+
b: modalityBalance(second)
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/api.ts
|
|
240
|
+
function isChart(value) {
|
|
241
|
+
if (!value || typeof value !== "object") return false;
|
|
242
|
+
const candidate = value;
|
|
243
|
+
return Array.isArray(candidate.bodies) && Array.isArray(candidate.aspects) && candidate.input?.utc instanceof Date;
|
|
244
|
+
}
|
|
245
|
+
function isBirth(value) {
|
|
246
|
+
return Boolean(value && typeof value === "object" && "utc" in value);
|
|
247
|
+
}
|
|
248
|
+
function resolvedChart(source) {
|
|
249
|
+
if (!isChart(source)) {
|
|
250
|
+
const chart = natalChart(source);
|
|
251
|
+
return { chart, utc: chart.input.utc };
|
|
252
|
+
}
|
|
253
|
+
const sourceInput = source.input;
|
|
254
|
+
const { input, flags: inputFlags } = validateBirth(sourceInput);
|
|
255
|
+
const resultFlags = snapshotFlags(source.flags);
|
|
256
|
+
const expected = timeFlags(inputFlags?.values ?? []);
|
|
257
|
+
const hasHouses = input.timeKnown && input.latitude !== void 0;
|
|
258
|
+
const houses = source.houses;
|
|
259
|
+
const angles = source.angles;
|
|
260
|
+
const actualHouseSystem = houses?.system;
|
|
261
|
+
if ((hasHouses ? !angles || typeof angles !== "object" || Array.isArray(angles) || !houses || typeof houses !== "object" || Array.isArray(houses) : angles !== null || houses !== null) || houses !== null && actualHouseSystem !== input.houseSystem && !(isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK)) {
|
|
262
|
+
throw new RangeError("chart flags must agree with its input and supplied house result.");
|
|
263
|
+
}
|
|
264
|
+
if (!input.timeKnown) expected.push("no-time");
|
|
265
|
+
if (isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK) {
|
|
266
|
+
expected.push("polar-fallback");
|
|
267
|
+
}
|
|
268
|
+
if (outsideReferenceSpan(input.utc)) expected.push("outside-reference-span");
|
|
269
|
+
assertDerivedFlags(inputFlags?.values ?? [], expected);
|
|
270
|
+
if (resultFlags.values.length !== expected.length || !expected.every((flag) => resultFlags.values.includes(flag))) {
|
|
271
|
+
throw new RangeError("chart flags must agree with its input and supplied house result.");
|
|
272
|
+
}
|
|
273
|
+
const canonicalInputFlags = input.flags ?? [];
|
|
274
|
+
const inputChanged = inputFlags !== void 0 && (inputFlags.hasDuplicates || inputFlags.values.length !== canonicalInputFlags.length);
|
|
275
|
+
const resultChanged = resultFlags.hasDuplicates || !expected.every((flag, index) => flag === resultFlags.values[index]);
|
|
276
|
+
if (!inputChanged && !resultChanged) return { chart: source, utc: input.utc };
|
|
277
|
+
return {
|
|
278
|
+
chart: {
|
|
279
|
+
...source,
|
|
280
|
+
input: inputChanged ? input : sourceInput,
|
|
281
|
+
flags: expected
|
|
282
|
+
},
|
|
283
|
+
utc: input.utc
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function validateBirth(birth) {
|
|
287
|
+
if (!birth || typeof birth !== "object" || Array.isArray(birth)) {
|
|
288
|
+
throw new RangeError("birth must be an object containing a resolved utc instant.");
|
|
289
|
+
}
|
|
290
|
+
const settings = validateBirthSettings(birth);
|
|
291
|
+
const supplied = birth.flags;
|
|
292
|
+
const flags = supplied === void 0 ? void 0 : snapshotFlags(supplied);
|
|
293
|
+
const utc = dateFrom(birth.utc, "birth.utc");
|
|
294
|
+
const pin = birth.deltaT;
|
|
295
|
+
if (pin !== void 0 && (typeof pin !== "number" || !Number.isFinite(pin) || Math.abs(pin) > 1e10)) {
|
|
296
|
+
throw new RangeError("deltaT must be a finite number of seconds, at most 1e10 in size.");
|
|
297
|
+
}
|
|
298
|
+
const possible = [];
|
|
299
|
+
if (settings.timeKnown === false) possible.push("no-time");
|
|
300
|
+
else if (settings.houseSystem !== void 0 && isPolarUndefinedHouseSystem(settings.houseSystem) && settings.latitude !== void 0) {
|
|
301
|
+
possible.push("polar-fallback");
|
|
302
|
+
}
|
|
303
|
+
if (outsideReferenceSpan(utc)) possible.push("outside-reference-span");
|
|
304
|
+
assertDerivedFlags(flags?.values ?? [], possible);
|
|
305
|
+
const input = {
|
|
306
|
+
utc,
|
|
307
|
+
houseSystem: settings.houseSystem ?? "whole",
|
|
308
|
+
timeKnown: settings.timeKnown ?? true,
|
|
309
|
+
...settings.latitude === void 0 ? {} : { latitude: settings.latitude, longitude: settings.longitude },
|
|
310
|
+
...flags === void 0 ? {} : { flags: timeFlags(flags.values) },
|
|
311
|
+
...pin === void 0 ? {} : { deltaT: pin }
|
|
312
|
+
};
|
|
313
|
+
return { input, flags };
|
|
314
|
+
}
|
|
315
|
+
function computedBirth({ input, flags }) {
|
|
316
|
+
const chart = computeChart(input);
|
|
317
|
+
assertDerivedFlags(flags?.values ?? [], chart.flags);
|
|
318
|
+
return chart;
|
|
319
|
+
}
|
|
320
|
+
function positions(date) {
|
|
321
|
+
return computeBodies(dateFrom(date, "date"));
|
|
322
|
+
}
|
|
323
|
+
function natalChart(birth) {
|
|
324
|
+
return computedBirth(validateBirth(birth));
|
|
325
|
+
}
|
|
326
|
+
function chartDeclinations(natal) {
|
|
327
|
+
return computeChartDeclinations(resolvedChart(natal).chart);
|
|
328
|
+
}
|
|
329
|
+
function chartPoints(natal) {
|
|
330
|
+
const { chart } = resolvedChart(natal);
|
|
331
|
+
return computePoints(chart);
|
|
332
|
+
}
|
|
333
|
+
function transits(natal, date) {
|
|
334
|
+
const { chart } = resolvedChart(natal);
|
|
335
|
+
const at = dateFrom(date, "date");
|
|
336
|
+
const current = computeBodies(at);
|
|
337
|
+
return {
|
|
338
|
+
natal: chart,
|
|
339
|
+
at,
|
|
340
|
+
positions: current,
|
|
341
|
+
aspects: findInterAspects(current, chart.bodies)
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function synastry(first, second) {
|
|
345
|
+
const { chart: a } = resolvedChart(first);
|
|
346
|
+
const { chart: b } = resolvedChart(second);
|
|
347
|
+
return { a, b, ...summarizePair(a.bodies, b.bodies) };
|
|
348
|
+
}
|
|
349
|
+
function phaseName(angle) {
|
|
350
|
+
if (angle < 22.5 || angle >= 337.5) return "New Moon";
|
|
351
|
+
if (angle < 67.5) return "Waxing Crescent";
|
|
352
|
+
if (angle < 112.5) return "First Quarter";
|
|
353
|
+
if (angle < 157.5) return "Waxing Gibbous";
|
|
354
|
+
if (angle < 202.5) return "Full Moon";
|
|
355
|
+
if (angle < 247.5) return "Waning Gibbous";
|
|
356
|
+
if (angle < 292.5) return "Last Quarter";
|
|
357
|
+
return "Waning Crescent";
|
|
358
|
+
}
|
|
359
|
+
function moonPhase(date) {
|
|
360
|
+
const at = dateFrom(date, "date");
|
|
361
|
+
const angle = normalizeLongitude(bodyLongitude("Moon", at) - bodyLongitude("Sun", at));
|
|
362
|
+
return {
|
|
363
|
+
at,
|
|
364
|
+
angle,
|
|
365
|
+
illumination: (1 - Math.cos(angle * Math.PI / 180)) / 2,
|
|
366
|
+
name: phaseName(angle),
|
|
367
|
+
waxing: angle < 180
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function saturnReturn(birth) {
|
|
371
|
+
let utc;
|
|
372
|
+
if (isChart(birth)) {
|
|
373
|
+
utc = resolvedChart(birth).utc;
|
|
374
|
+
} else if (isBirth(birth)) {
|
|
375
|
+
const validated = validateBirth(birth);
|
|
376
|
+
utc = validated.flags?.values.includes("polar-fallback") ? computedBirth(validated).input.utc : validated.input.utc;
|
|
377
|
+
} else utc = dateFrom(birth, "birth");
|
|
378
|
+
return computeSaturnReturns(utc);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/progressions.ts
|
|
382
|
+
var PROGRESSION_DAYS_PER_YEAR = 365.2422;
|
|
383
|
+
var DAY_MS = 864e5;
|
|
384
|
+
function progressedInstant(birthUtc, target) {
|
|
385
|
+
const birth = dateFrom(birthUtc, "birthUtc");
|
|
386
|
+
const at = dateFrom(target, "target");
|
|
387
|
+
const yearsLived = (at.getTime() - birth.getTime()) / (PROGRESSION_DAYS_PER_YEAR * DAY_MS);
|
|
388
|
+
return new Date(birth.getTime() + yearsLived * DAY_MS);
|
|
389
|
+
}
|
|
390
|
+
function progressedBodies(birthUtc, target) {
|
|
391
|
+
return computeBodies(progressedInstant(birthUtc, target));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/configured-aspects.ts
|
|
395
|
+
var CONFIGURED_ASPECT_ANGLES = Object.freeze({
|
|
396
|
+
conjunction: 0,
|
|
397
|
+
semisextile: 30,
|
|
398
|
+
semisquare: 45,
|
|
399
|
+
sextile: 60,
|
|
400
|
+
quintile: 72,
|
|
401
|
+
square: 90,
|
|
402
|
+
trine: 120,
|
|
403
|
+
sesquiquadrate: 135,
|
|
404
|
+
biquintile: 144,
|
|
405
|
+
quincunx: 150,
|
|
406
|
+
opposition: 180
|
|
407
|
+
});
|
|
408
|
+
var PHYSICAL_BODIES = ["Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"];
|
|
409
|
+
var DEFAULT_RULES = [
|
|
410
|
+
{ type: "conjunction", orb: 8, luminaryOrb: 10 },
|
|
411
|
+
{ type: "sextile", orb: 4, luminaryOrb: 5 },
|
|
412
|
+
{ type: "square", orb: 7, luminaryOrb: 8 },
|
|
413
|
+
{ type: "trine", orb: 7, luminaryOrb: 8 },
|
|
414
|
+
{ type: "opposition", orb: 8, luminaryOrb: 10 }
|
|
415
|
+
];
|
|
416
|
+
var POLICIES = /* @__PURE__ */ new WeakSet();
|
|
417
|
+
var CONVENTIONS = Object.freeze({
|
|
418
|
+
coordinates: "ecliptic-longitude-degrees-[0,360)",
|
|
419
|
+
speed: "longitude-degrees-per-day;same-time-basis",
|
|
420
|
+
motion: "instantaneous-orb-rate;right-derivative-at-circular-corners;exact-separating-unless-stationary",
|
|
421
|
+
orb: "inclusive;luminary-replaces-rule;minimum-of-rule-and-both-body-caps",
|
|
422
|
+
matching: "one-per-pair;smallest-absolute-orb;definition-order-on-tie",
|
|
423
|
+
ordering: "ascending-orb;input-pair-order-on-tie",
|
|
424
|
+
arithmetic: "exact-binary64;reported-orb-rounded-half-even"
|
|
425
|
+
});
|
|
426
|
+
function requireValue(condition, message) {
|
|
427
|
+
if (!condition) throw new RangeError(message);
|
|
428
|
+
}
|
|
429
|
+
function dataObject(value, allowed) {
|
|
430
|
+
requireValue(value !== null && typeof value === "object" && !Array.isArray(value), "Expected an ordinary data object.");
|
|
431
|
+
const proto = Object.getPrototypeOf(value);
|
|
432
|
+
requireValue(proto === Object.prototype || proto === null, "Expected an ordinary data object.");
|
|
433
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
434
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
435
|
+
requireValue(typeof key === "string" && (!allowed || allowed.includes(key)), "Unknown configuration field.");
|
|
436
|
+
const slot = Object.getOwnPropertyDescriptor(value, key);
|
|
437
|
+
requireValue(slot && "value" in slot && slot.enumerable, "Expected ordinary enumerable data slots.");
|
|
438
|
+
out[key] = slot.value;
|
|
439
|
+
}
|
|
440
|
+
return out;
|
|
441
|
+
}
|
|
442
|
+
function dataArray(value, maximum, label) {
|
|
443
|
+
requireValue(Array.isArray(value) && value.length <= maximum, `${label} must be an array with at most ${maximum} entries.`);
|
|
444
|
+
const out = [];
|
|
445
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
446
|
+
const slot = Object.getOwnPropertyDescriptor(value, String(i));
|
|
447
|
+
requireValue(slot && "value" in slot, `${label} must not contain holes or accessor slots.`);
|
|
448
|
+
out.push(slot.value);
|
|
449
|
+
}
|
|
450
|
+
return out;
|
|
451
|
+
}
|
|
452
|
+
function numberIn(value, low, high, label) {
|
|
453
|
+
requireValue(typeof value === "number" && Number.isFinite(value) && value >= low && value <= high, `${label} is outside its finite range.`);
|
|
454
|
+
return value === 0 ? 0 : value;
|
|
455
|
+
}
|
|
456
|
+
var bodyLabel = checkedBodyLabel;
|
|
457
|
+
function orbLimits(value) {
|
|
458
|
+
if (typeof value === "number") {
|
|
459
|
+
const limit = numberIn(value, 0, 180, "Orb");
|
|
460
|
+
return Object.freeze({ applying: limit, separating: limit, stationary: limit });
|
|
461
|
+
}
|
|
462
|
+
const object = dataObject(value, ["applying", "separating", "stationary"]);
|
|
463
|
+
return Object.freeze({
|
|
464
|
+
applying: numberIn(object.applying, 0, 180, "Applying orb"),
|
|
465
|
+
separating: numberIn(object.separating, 0, 180, "Separating orb"),
|
|
466
|
+
stationary: numberIn(object.stationary, 0, 180, "Stationary orb")
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function createAspectPolicy(input = {}) {
|
|
470
|
+
const options = dataObject(input, ["aspects", "bodies", "bodyOrbs", "stationaryRelativeSpeed"]);
|
|
471
|
+
const bodyValues = options.bodies === void 0 ? PHYSICAL_BODIES : options.bodies;
|
|
472
|
+
const bodies = dataArray(bodyValues, 256, "Bodies").map(bodyLabel);
|
|
473
|
+
requireValue(new Set(bodies).size === bodies.length, "Body selection contains duplicate labels.");
|
|
474
|
+
const rules = dataArray(options.aspects === void 0 ? DEFAULT_RULES : options.aspects, 64, "Aspects");
|
|
475
|
+
const seen = /* @__PURE__ */ new Set();
|
|
476
|
+
const aspects = rules.map((value) => {
|
|
477
|
+
const rule = dataObject(value, ["type", "angle", "orb", "luminaryOrb"]);
|
|
478
|
+
requireValue(typeof rule.type === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(rule.type), "Aspect type must be a lowercase identifier of at most 64 characters.");
|
|
479
|
+
const type = rule.type;
|
|
480
|
+
requireValue(!seen.has(type), "Aspect types must be unique.");
|
|
481
|
+
seen.add(type);
|
|
482
|
+
const named = Object.hasOwn(CONFIGURED_ASPECT_ANGLES, type) ? CONFIGURED_ASPECT_ANGLES[type] : void 0;
|
|
483
|
+
const angle = numberIn(rule.angle === void 0 ? named : rule.angle, 0, 180, "Aspect angle");
|
|
484
|
+
requireValue(named === void 0 || angle === named, "A named aspect must keep its named angle.");
|
|
485
|
+
return Object.freeze({
|
|
486
|
+
type,
|
|
487
|
+
angle,
|
|
488
|
+
orb: orbLimits(rule.orb),
|
|
489
|
+
...rule.luminaryOrb === void 0 ? {} : { luminaryOrb: orbLimits(rule.luminaryOrb) }
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
const caps = options.bodyOrbs === void 0 ? {} : dataObject(options.bodyOrbs);
|
|
493
|
+
const bodyOrbs = /* @__PURE__ */ Object.create(null);
|
|
494
|
+
for (const [name, value] of Object.entries(caps)) {
|
|
495
|
+
bodyLabel(name);
|
|
496
|
+
requireValue(bodies.includes(name), "A body orb cap must name a selected body.");
|
|
497
|
+
bodyOrbs[name] = orbLimits(value);
|
|
498
|
+
}
|
|
499
|
+
const stationaryRelativeSpeed = options.stationaryRelativeSpeed === void 0 ? 1e-9 : numberIn(options.stationaryRelativeSpeed, 0, Number.MAX_VALUE, "Stationary relative speed");
|
|
500
|
+
const policy = Object.freeze({
|
|
501
|
+
schema: "zodiacs.aspect-policy.v1",
|
|
502
|
+
aspects: Object.freeze(aspects),
|
|
503
|
+
bodies: Object.freeze(bodies),
|
|
504
|
+
bodyOrbs: Object.freeze(bodyOrbs),
|
|
505
|
+
stationaryRelativeSpeed,
|
|
506
|
+
conventions: CONVENTIONS
|
|
507
|
+
});
|
|
508
|
+
POLICIES.add(policy);
|
|
509
|
+
return policy;
|
|
510
|
+
}
|
|
511
|
+
var DEFAULT_ASPECT_POLICY = createAspectPolicy();
|
|
512
|
+
function signedSeparation(a, b) {
|
|
513
|
+
const difference = exactSum(a, -b);
|
|
514
|
+
if (compareExact(difference, 180) > 0) return exactSum(difference, -360);
|
|
515
|
+
if (compareExact(difference, -180) <= 0) return exactSum(difference, 360);
|
|
516
|
+
return difference;
|
|
517
|
+
}
|
|
518
|
+
function relativeSpeedSign(a, b, threshold) {
|
|
519
|
+
if (a === b) return 0;
|
|
520
|
+
const sign = a > b ? 1 : -1;
|
|
521
|
+
return exactSign([threshold, -sign * a, sign * b]) > 0 ? 0 : sign;
|
|
522
|
+
}
|
|
523
|
+
function distanceRateSign(signed, distance, relative) {
|
|
524
|
+
if (signOf(distance) === 0) return 1;
|
|
525
|
+
if (compareExact(distance, 180) === 0) return -1;
|
|
526
|
+
return signOf(signed) * relative > 0 ? 1 : -1;
|
|
527
|
+
}
|
|
528
|
+
function motionOf(deviation, rate) {
|
|
529
|
+
if (rate === null) return "stationary";
|
|
530
|
+
const deviationSign = signOf(deviation);
|
|
531
|
+
if (deviationSign === 0) return "separating";
|
|
532
|
+
return deviationSign * rate < 0 ? "applying" : "separating";
|
|
533
|
+
}
|
|
534
|
+
function findConfiguredAspects(positions2, policy) {
|
|
535
|
+
requireValue(policy !== null && typeof policy === "object" && POLICIES.has(policy), "Policy must be made by createAspectPolicy.");
|
|
536
|
+
const labels = /* @__PURE__ */ new Set();
|
|
537
|
+
const all = dataArray(positions2, 256, "Positions").map((value) => {
|
|
538
|
+
const row = dataObject(value);
|
|
539
|
+
const body = bodyLabel(row.body);
|
|
540
|
+
requireValue(!labels.has(body), "Positions contain duplicate body labels.");
|
|
541
|
+
labels.add(body);
|
|
542
|
+
const lon = numberIn(row.lon, 0, 360, "Longitude");
|
|
543
|
+
requireValue(lon < 360, "Longitude must be in [0,360).");
|
|
544
|
+
requireValue(typeof row.speed === "number" && Number.isFinite(row.speed), "Every position requires a finite longitude speed.");
|
|
545
|
+
return { body, lon, speed: row.speed };
|
|
546
|
+
});
|
|
547
|
+
const selected = new Set(policy.bodies);
|
|
548
|
+
const candidates = all.filter((row) => selected.has(row.body));
|
|
549
|
+
const found = [];
|
|
550
|
+
for (let i = 0; i < candidates.length; i += 1) {
|
|
551
|
+
for (let j = i + 1; j < candidates.length; j += 1) {
|
|
552
|
+
const a = candidates[i], b = candidates[j];
|
|
553
|
+
const signed = signedSeparation(a.lon, b.lon);
|
|
554
|
+
const distance = absolute(signed);
|
|
555
|
+
const relative = relativeSpeedSign(a.speed, b.speed, policy.stationaryRelativeSpeed);
|
|
556
|
+
const rate = relative === 0 ? null : distanceRateSign(signed, distance, relative);
|
|
557
|
+
const luminary = a.body === "Sun" || a.body === "Moon" || b.body === "Sun" || b.body === "Moon";
|
|
558
|
+
let best = null;
|
|
559
|
+
for (const definition of policy.aspects) {
|
|
560
|
+
const deviation = exactSum(distance, -definition.angle);
|
|
561
|
+
const exactOrb = absolute(deviation);
|
|
562
|
+
const motion = motionOf(deviation, rate);
|
|
563
|
+
const limits = luminary && definition.luminaryOrb ? definition.luminaryOrb : definition.orb;
|
|
564
|
+
const maximumOrb = Math.min(limits[motion], policy.bodyOrbs[a.body]?.[motion] ?? 180, policy.bodyOrbs[b.body]?.[motion] ?? 180);
|
|
565
|
+
if (compareExact(exactOrb, maximumOrb) <= 0 && (!best || compareExact(exactOrb, best.exactOrb) < 0)) {
|
|
566
|
+
best = { definition, exactOrb, maximumOrb, motion };
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (best) {
|
|
570
|
+
const { definition, exactOrb, maximumOrb, motion } = best;
|
|
571
|
+
found.push({ exactOrb, aspect: Object.freeze({
|
|
572
|
+
a: a.body,
|
|
573
|
+
b: b.body,
|
|
574
|
+
type: definition.type,
|
|
575
|
+
angle: definition.angle,
|
|
576
|
+
orb: roundedValue(exactOrb),
|
|
577
|
+
maximumOrb,
|
|
578
|
+
motion,
|
|
579
|
+
applying: motion === "applying"
|
|
580
|
+
}) });
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
found.sort((x, y) => compareExact(x.exactOrb, y.exactOrb));
|
|
585
|
+
return Object.freeze({ schema: "zodiacs.configured-aspects.v1", policy, aspects: Object.freeze(found.map((entry) => entry.aspect)) });
|
|
586
|
+
}
|
|
587
|
+
export {
|
|
588
|
+
ASPECTS,
|
|
589
|
+
ASPECT_BODIES,
|
|
590
|
+
ASPECT_TYPES,
|
|
591
|
+
CONFIGURED_ASPECT_ANGLES,
|
|
592
|
+
DECLINATION_ORB,
|
|
593
|
+
DECLINATION_ORB_LUMINARY,
|
|
594
|
+
DEFAULT_ASPECT_POLICY,
|
|
595
|
+
DEFAULT_DECLINATION_ORB_POLICY,
|
|
596
|
+
DELTA_T_MODEL,
|
|
597
|
+
DELTA_T_TABLE,
|
|
598
|
+
ELEMENTS,
|
|
599
|
+
ENGINE_VERSION,
|
|
600
|
+
EPHEMERIS,
|
|
601
|
+
EPHEMERIS_SPAN,
|
|
602
|
+
HOUSE_SYSTEMS,
|
|
603
|
+
LOTS,
|
|
604
|
+
MEAN_LUNAR_INCLINATION,
|
|
605
|
+
MODALITIES,
|
|
606
|
+
PLACIDUS_POLAR_FALLBACK,
|
|
607
|
+
POLAR_FALLBACK,
|
|
608
|
+
POLAR_UNDEFINED_HOUSE_SYSTEMS,
|
|
609
|
+
PROGRESSION_DAYS_PER_YEAR,
|
|
610
|
+
RA_POLE_TOLERANCE,
|
|
611
|
+
REFERENCE_SPAN,
|
|
612
|
+
SIGNS,
|
|
613
|
+
SIGN_NAMES,
|
|
614
|
+
STATIONARY_RELATIVE_SPEED,
|
|
615
|
+
SUN_BOUND_LATITUDE,
|
|
616
|
+
alcabitiusCusps,
|
|
617
|
+
antiscion,
|
|
618
|
+
aspectMotion,
|
|
619
|
+
campanusCusps,
|
|
620
|
+
chartDeclinations,
|
|
621
|
+
chartPoints,
|
|
622
|
+
computeAngles,
|
|
623
|
+
computeHouses,
|
|
624
|
+
contraAntiscion,
|
|
625
|
+
createAspectPolicy,
|
|
626
|
+
declinationOf,
|
|
627
|
+
declinationOrb,
|
|
628
|
+
declinationsForBodies,
|
|
629
|
+
degreeInSign,
|
|
630
|
+
deltaT,
|
|
631
|
+
deltaTAt,
|
|
632
|
+
eastPointOf,
|
|
633
|
+
eclipticToEquatorial,
|
|
634
|
+
elementBalance,
|
|
635
|
+
equalCusps,
|
|
636
|
+
equalMcCusps,
|
|
637
|
+
findAspects,
|
|
638
|
+
findConfiguredAspects,
|
|
639
|
+
findDeclinationAspects,
|
|
640
|
+
findInterAspects,
|
|
641
|
+
findLongitudeCrossings,
|
|
642
|
+
findLongitudeCrossingsWith,
|
|
643
|
+
groupIntoSeasons,
|
|
644
|
+
hellenisticLots,
|
|
645
|
+
houseOf,
|
|
646
|
+
isPolarUndefinedHouseSystem,
|
|
647
|
+
kochCusps,
|
|
648
|
+
lunarMeanArguments,
|
|
649
|
+
matchAspect,
|
|
650
|
+
meanApogee,
|
|
651
|
+
meanNodeLongitude,
|
|
652
|
+
meanObliquity,
|
|
653
|
+
meridianCusps,
|
|
654
|
+
midpoint,
|
|
655
|
+
modalityBalance,
|
|
656
|
+
moonPhase,
|
|
657
|
+
morinusCusps,
|
|
658
|
+
natalChart,
|
|
659
|
+
normalizeLongitude,
|
|
660
|
+
outsideReferenceSpan,
|
|
661
|
+
placidusCusps,
|
|
662
|
+
porphyryCusps,
|
|
663
|
+
positions,
|
|
664
|
+
progressedBodies,
|
|
665
|
+
progressedInstant,
|
|
666
|
+
ramcOf,
|
|
667
|
+
regiomontanusCusps,
|
|
668
|
+
saturnReturn,
|
|
669
|
+
searchLongitudeCrossings,
|
|
670
|
+
searchLongitudeCrossingsWith,
|
|
671
|
+
sectOf,
|
|
672
|
+
separation,
|
|
673
|
+
signForLongitude,
|
|
674
|
+
signIndexForLongitude,
|
|
675
|
+
summarizePair,
|
|
676
|
+
synastry,
|
|
677
|
+
topocentricCusps,
|
|
678
|
+
transits,
|
|
679
|
+
vehlowCusps,
|
|
680
|
+
vertexOf,
|
|
681
|
+
wholeSignCusps
|
|
682
|
+
};
|