kaabalah 5.3.0 → 5.4.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.
- package/dist/astrology/index.d.mts +194 -1
- package/dist/astrology/index.d.ts +194 -1
- package/dist/astrology/index.js +94 -22
- package/dist/astrology/index.mjs +1 -1
- package/dist/{chunk-AHUZONHJ.js → chunk-7FRU63L3.js} +648 -3
- package/dist/chunk-7FRU63L3.js.map +1 -0
- package/dist/{chunk-VSTGPXLM.mjs → chunk-EBLM443L.mjs} +631 -4
- package/dist/chunk-EBLM443L.mjs.map +1 -0
- package/dist/cli.js +1392 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +94 -22
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-AHUZONHJ.js.map +0 -1
- package/dist/chunk-VSTGPXLM.mjs.map +0 -1
|
@@ -585,6 +585,11 @@ async function getSwissEph(options = {}) {
|
|
|
585
585
|
throw error;
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
+
function calculateSinglePlanetPosition(date, planet) {
|
|
589
|
+
checkInitialization();
|
|
590
|
+
const julday = swissEph.getJulianDay(date);
|
|
591
|
+
return swissEph.calculatePlanetPosition(julday, planet, DEFAULT_FLAGS);
|
|
592
|
+
}
|
|
588
593
|
async function calculatePlanetaryPositions(date) {
|
|
589
594
|
try {
|
|
590
595
|
checkInitialization();
|
|
@@ -704,6 +709,9 @@ function getTimeZoneOffsetMs(instant, timeZone) {
|
|
|
704
709
|
return asUTC - instant.getTime();
|
|
705
710
|
}
|
|
706
711
|
async function localToUtcDate(local, latitude, longitude, opts = {}) {
|
|
712
|
+
if (opts.treatAsUTC === true) {
|
|
713
|
+
return local instanceof Date ? local : createUtcDateFromParts(buildLocalParts(local));
|
|
714
|
+
}
|
|
707
715
|
const parts = buildLocalParts(local);
|
|
708
716
|
const auto = opts.autoTimeZone !== false;
|
|
709
717
|
if (typeof opts.utcOffsetMinutes === "number" && Number.isFinite(opts.utcOffsetMinutes)) {
|
|
@@ -838,6 +846,308 @@ function computeMidpoints(planetsA, planetsB) {
|
|
|
838
846
|
}
|
|
839
847
|
return result;
|
|
840
848
|
}
|
|
849
|
+
var SLOW_PLANETS = /* @__PURE__ */ new Set([
|
|
850
|
+
"pluto",
|
|
851
|
+
"neptune",
|
|
852
|
+
"uranus",
|
|
853
|
+
"saturn",
|
|
854
|
+
"jupiter",
|
|
855
|
+
"chiron",
|
|
856
|
+
"mean node",
|
|
857
|
+
"true node",
|
|
858
|
+
"lilith true",
|
|
859
|
+
"lilith mean"
|
|
860
|
+
]);
|
|
861
|
+
function computeTransitAspects(transitPlanets, natalPlanets, specs = DEFAULT_ASPECT_SPECS) {
|
|
862
|
+
const keysT = Object.keys(transitPlanets);
|
|
863
|
+
const keysN = Object.keys(natalPlanets);
|
|
864
|
+
const edges = [];
|
|
865
|
+
for (const kT of keysT) {
|
|
866
|
+
const t = transitPlanets[kT];
|
|
867
|
+
for (const kN of keysN) {
|
|
868
|
+
const n = natalPlanets[kN];
|
|
869
|
+
const match = getAspectMatch(t.longitude, n.longitude, specs);
|
|
870
|
+
if (!match) continue;
|
|
871
|
+
const tSpeed = t.longitudeSpeed ?? 0;
|
|
872
|
+
const nSpeed = n.longitudeSpeed ?? 0;
|
|
873
|
+
const dt = 0.01;
|
|
874
|
+
const tLonFuture = t.longitude + tSpeed * dt;
|
|
875
|
+
const nLonFuture = n.longitude + nSpeed * dt;
|
|
876
|
+
const futureMatch = getAspectMatch(tLonFuture, nLonFuture, [match.spec]);
|
|
877
|
+
const applying = futureMatch != null ? futureMatch.orb < match.orb : false;
|
|
878
|
+
edges.push({
|
|
879
|
+
planetA: kT,
|
|
880
|
+
planetB: kN,
|
|
881
|
+
longitudeA: t.longitude,
|
|
882
|
+
longitudeB: n.longitude,
|
|
883
|
+
aspect: match.spec.name,
|
|
884
|
+
aspectAngle: match.spec.angle,
|
|
885
|
+
delta: match.delta,
|
|
886
|
+
orb: match.orb,
|
|
887
|
+
applying,
|
|
888
|
+
retrograde: tSpeed < 0,
|
|
889
|
+
category: SLOW_PLANETS.has(kT) ? "slow" : "fast"
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
return edges;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// src/astrology/dignity.ts
|
|
897
|
+
var DOMICILE_RULERS = {
|
|
898
|
+
Aries: "Mars",
|
|
899
|
+
Taurus: "Venus",
|
|
900
|
+
Gemini: "Mercury",
|
|
901
|
+
Cancer: "Moon",
|
|
902
|
+
Leo: "Sun",
|
|
903
|
+
Virgo: "Mercury",
|
|
904
|
+
Libra: "Venus",
|
|
905
|
+
Scorpio: "Mars",
|
|
906
|
+
Sagittarius: "Jupiter",
|
|
907
|
+
Capricorn: "Saturn",
|
|
908
|
+
Aquarius: "Saturn",
|
|
909
|
+
Pisces: "Jupiter"
|
|
910
|
+
};
|
|
911
|
+
var EXALTATIONS = {
|
|
912
|
+
Sun: { sign: "Aries", degree: 19 },
|
|
913
|
+
Moon: { sign: "Taurus", degree: 3 },
|
|
914
|
+
Mercury: { sign: "Virgo", degree: 15 },
|
|
915
|
+
Venus: { sign: "Pisces", degree: 27 },
|
|
916
|
+
Mars: { sign: "Capricorn", degree: 28 },
|
|
917
|
+
Jupiter: { sign: "Cancer", degree: 15 },
|
|
918
|
+
Saturn: { sign: "Libra", degree: 21 }
|
|
919
|
+
};
|
|
920
|
+
function getDomicileRuler(sign) {
|
|
921
|
+
return DOMICILE_RULERS[sign];
|
|
922
|
+
}
|
|
923
|
+
function getExaltation(planet) {
|
|
924
|
+
return EXALTATIONS[planet];
|
|
925
|
+
}
|
|
926
|
+
function getOppositeSign(sign) {
|
|
927
|
+
const idx = SIGNS.indexOf(sign);
|
|
928
|
+
return SIGNS[(idx + 6) % 12];
|
|
929
|
+
}
|
|
930
|
+
function getDetriment(planet) {
|
|
931
|
+
const signs = [];
|
|
932
|
+
for (const [sign, ruler] of Object.entries(DOMICILE_RULERS)) {
|
|
933
|
+
if (ruler === planet) {
|
|
934
|
+
signs.push(getOppositeSign(sign));
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return signs;
|
|
938
|
+
}
|
|
939
|
+
function getFall(planet) {
|
|
940
|
+
return getOppositeSign(EXALTATIONS[planet].sign);
|
|
941
|
+
}
|
|
942
|
+
function getEssentialDignity(planet, sign) {
|
|
943
|
+
const domicile = DOMICILE_RULERS[sign] === planet;
|
|
944
|
+
const exaltation = EXALTATIONS[planet].sign === sign;
|
|
945
|
+
const detrimentSigns = getDetriment(planet);
|
|
946
|
+
const detriment = detrimentSigns.includes(sign);
|
|
947
|
+
const fallSign = getFall(planet);
|
|
948
|
+
const fall = fallSign === sign;
|
|
949
|
+
const domicileRuler = DOMICILE_RULERS[sign];
|
|
950
|
+
const peregrine = !domicile && !exaltation && !detriment && !fall;
|
|
951
|
+
return { domicile, exaltation, detriment, fall, domicileRuler, peregrine };
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// src/astrology/decans.ts
|
|
955
|
+
var CHALDEAN_RULERS = [
|
|
956
|
+
"Mars",
|
|
957
|
+
"Sun",
|
|
958
|
+
"Venus",
|
|
959
|
+
"Mercury",
|
|
960
|
+
"Moon",
|
|
961
|
+
"Saturn",
|
|
962
|
+
"Jupiter"
|
|
963
|
+
];
|
|
964
|
+
var SIGN_SUITS = {
|
|
965
|
+
Aries: "Wands",
|
|
966
|
+
Taurus: "Pentacles",
|
|
967
|
+
Gemini: "Swords",
|
|
968
|
+
Cancer: "Cups",
|
|
969
|
+
Leo: "Wands",
|
|
970
|
+
Virgo: "Pentacles",
|
|
971
|
+
Libra: "Swords",
|
|
972
|
+
Scorpio: "Cups",
|
|
973
|
+
Sagittarius: "Wands",
|
|
974
|
+
Capricorn: "Pentacles",
|
|
975
|
+
Aquarius: "Swords",
|
|
976
|
+
Pisces: "Cups"
|
|
977
|
+
};
|
|
978
|
+
var RANK_NAMES = ["Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"];
|
|
979
|
+
function getDecan(longitude) {
|
|
980
|
+
const L = normalizeAngle(longitude);
|
|
981
|
+
const signIndex = Math.floor(L / 30) % 12;
|
|
982
|
+
const degreeWithinSign = L - signIndex * 30;
|
|
983
|
+
const decanIndex = Math.min(Math.floor(degreeWithinSign / 10), 2);
|
|
984
|
+
const globalDecanIndex = signIndex * 3 + decanIndex;
|
|
985
|
+
const sign = SIGNS[signIndex];
|
|
986
|
+
const ruler = CHALDEAN_RULERS[globalDecanIndex % 7];
|
|
987
|
+
const suit = SIGN_SUITS[sign];
|
|
988
|
+
const rank = RANK_NAMES[globalDecanIndex % 9];
|
|
989
|
+
const tarotCard = `${rank} of ${suit}`;
|
|
990
|
+
return {
|
|
991
|
+
sign,
|
|
992
|
+
decanNumber: decanIndex + 1,
|
|
993
|
+
ruler,
|
|
994
|
+
tarotCard,
|
|
995
|
+
startDegree: signIndex * 30 + decanIndex * 10,
|
|
996
|
+
endDegree: signIndex * 30 + (decanIndex + 1) * 10,
|
|
997
|
+
degreeWithinSign
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// src/astrology/dodecatemoria.ts
|
|
1002
|
+
function getDodecatemoria(longitude) {
|
|
1003
|
+
const L = normalizeAngle(longitude);
|
|
1004
|
+
const signIndex = Math.floor(L / 30) % 12;
|
|
1005
|
+
const degreeWithinSign = L - signIndex * 30;
|
|
1006
|
+
const index = Math.min(Math.floor(degreeWithinSign / 2.5), 11);
|
|
1007
|
+
const dodecatemoriaSignIndex = (signIndex + index) % 12;
|
|
1008
|
+
return {
|
|
1009
|
+
originalSign: SIGNS[signIndex],
|
|
1010
|
+
originalDegree: degreeWithinSign,
|
|
1011
|
+
dodecatemoriaSign: SIGNS[dodecatemoriaSignIndex],
|
|
1012
|
+
dodecatemoriaIndex: index
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/astrology/profections.ts
|
|
1017
|
+
function getAnnualProfection(natalChart, birthDate, targetYear) {
|
|
1018
|
+
const year = targetYear ?? (/* @__PURE__ */ new Date()).getFullYear();
|
|
1019
|
+
const birthYear = birthDate.getFullYear();
|
|
1020
|
+
const age = year - birthYear;
|
|
1021
|
+
if (age < 0) {
|
|
1022
|
+
throw new Error(`Target year (${year}) is before birth year (${birthYear}).`);
|
|
1023
|
+
}
|
|
1024
|
+
const house = age % 12 + 1;
|
|
1025
|
+
const sign = natalChart.houses.houses[house - 1].sign;
|
|
1026
|
+
const ruler = getDomicileRuler(sign);
|
|
1027
|
+
return { age, house, sign, ruler, targetYear: year };
|
|
1028
|
+
}
|
|
1029
|
+
function getMonthlyProfections(natalChart, birthDate, targetYear) {
|
|
1030
|
+
const annualProfection = getAnnualProfection(natalChart, birthDate, targetYear);
|
|
1031
|
+
const annualSignIndex = SIGNS.indexOf(annualProfection.sign);
|
|
1032
|
+
const bdMonth = birthDate.getMonth();
|
|
1033
|
+
const bdDay = birthDate.getDate();
|
|
1034
|
+
const year = annualProfection.targetYear;
|
|
1035
|
+
const months = [];
|
|
1036
|
+
for (let i = 0; i < 12; i++) {
|
|
1037
|
+
const monthDate = new Date(year, bdMonth + i, bdDay);
|
|
1038
|
+
if (monthDate.getDate() !== bdDay) {
|
|
1039
|
+
monthDate.setDate(0);
|
|
1040
|
+
}
|
|
1041
|
+
const signIndex = (annualSignIndex + i) % 12;
|
|
1042
|
+
const sign = SIGNS[signIndex];
|
|
1043
|
+
months.push({
|
|
1044
|
+
month: i + 1,
|
|
1045
|
+
startDate: monthDate,
|
|
1046
|
+
sign,
|
|
1047
|
+
ruler: getDomicileRuler(sign)
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
return { annualProfection, months };
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// src/astrology/firdaria.ts
|
|
1054
|
+
var DAY_SEQUENCE = [
|
|
1055
|
+
{ planet: "Sun", years: 10 },
|
|
1056
|
+
{ planet: "Venus", years: 8 },
|
|
1057
|
+
{ planet: "Mercury", years: 13 },
|
|
1058
|
+
{ planet: "Moon", years: 9 },
|
|
1059
|
+
{ planet: "Saturn", years: 11 },
|
|
1060
|
+
{ planet: "Jupiter", years: 12 },
|
|
1061
|
+
{ planet: "Mars", years: 7 },
|
|
1062
|
+
{ planet: "NorthNode", years: 3 },
|
|
1063
|
+
{ planet: "SouthNode", years: 2 }
|
|
1064
|
+
];
|
|
1065
|
+
var NIGHT_SEQUENCE = [
|
|
1066
|
+
{ planet: "Moon", years: 9 },
|
|
1067
|
+
{ planet: "Saturn", years: 11 },
|
|
1068
|
+
{ planet: "Jupiter", years: 12 },
|
|
1069
|
+
{ planet: "Mars", years: 7 },
|
|
1070
|
+
{ planet: "NorthNode", years: 3 },
|
|
1071
|
+
{ planet: "SouthNode", years: 2 },
|
|
1072
|
+
{ planet: "Sun", years: 10 },
|
|
1073
|
+
{ planet: "Venus", years: 8 },
|
|
1074
|
+
{ planet: "Mercury", years: 13 }
|
|
1075
|
+
];
|
|
1076
|
+
var CHALDEAN_ORDER = [
|
|
1077
|
+
"Saturn",
|
|
1078
|
+
"Jupiter",
|
|
1079
|
+
"Mars",
|
|
1080
|
+
"Sun",
|
|
1081
|
+
"Venus",
|
|
1082
|
+
"Mercury",
|
|
1083
|
+
"Moon"
|
|
1084
|
+
];
|
|
1085
|
+
function addYears(date, years) {
|
|
1086
|
+
const ms = years * 365.25 * 24 * 60 * 60 * 1e3;
|
|
1087
|
+
return new Date(date.getTime() + ms);
|
|
1088
|
+
}
|
|
1089
|
+
function getSubPeriodStart(planet, options) {
|
|
1090
|
+
const mode = options?.nodeSubPeriodStart ?? "jupiter-saturn";
|
|
1091
|
+
if (planet === "NorthNode") {
|
|
1092
|
+
if (mode === "sun-mars") {
|
|
1093
|
+
return CHALDEAN_ORDER.indexOf("Sun");
|
|
1094
|
+
}
|
|
1095
|
+
return CHALDEAN_ORDER.indexOf("Jupiter");
|
|
1096
|
+
}
|
|
1097
|
+
if (planet === "SouthNode") {
|
|
1098
|
+
if (mode === "sun-mars") {
|
|
1099
|
+
return CHALDEAN_ORDER.indexOf("Mars");
|
|
1100
|
+
}
|
|
1101
|
+
return CHALDEAN_ORDER.indexOf("Saturn");
|
|
1102
|
+
}
|
|
1103
|
+
return CHALDEAN_ORDER.indexOf(planet);
|
|
1104
|
+
}
|
|
1105
|
+
function buildSubPeriods(major, majorStart, majorEnd, options) {
|
|
1106
|
+
const startIdx = getSubPeriodStart(major.planet, options);
|
|
1107
|
+
const totalMs = majorEnd.getTime() - majorStart.getTime();
|
|
1108
|
+
const subMs = totalMs / 7;
|
|
1109
|
+
const subs = [];
|
|
1110
|
+
for (let i = 0; i < 7; i++) {
|
|
1111
|
+
const subPlanet = CHALDEAN_ORDER[(startIdx + i) % 7];
|
|
1112
|
+
const subStart = new Date(majorStart.getTime() + i * subMs);
|
|
1113
|
+
const subEnd = new Date(majorStart.getTime() + (i + 1) * subMs);
|
|
1114
|
+
subs.push({ planet: subPlanet, startDate: subStart, endDate: subEnd });
|
|
1115
|
+
}
|
|
1116
|
+
return subs;
|
|
1117
|
+
}
|
|
1118
|
+
function getFirdaria(birthDate, isDiurnal, targetDate, options) {
|
|
1119
|
+
const target = targetDate ?? /* @__PURE__ */ new Date();
|
|
1120
|
+
const sequence = isDiurnal ? DAY_SEQUENCE : NIGHT_SEQUENCE;
|
|
1121
|
+
const sect = isDiurnal ? "diurnal" : "nocturnal";
|
|
1122
|
+
const allPeriods = [];
|
|
1123
|
+
let cursor = new Date(birthDate.getTime());
|
|
1124
|
+
let foundCurrent = false;
|
|
1125
|
+
for (let cycle = 0; cycle < 3 && !foundCurrent; cycle++) {
|
|
1126
|
+
for (const entry of sequence) {
|
|
1127
|
+
const start = new Date(cursor.getTime());
|
|
1128
|
+
const end = addYears(start, entry.years);
|
|
1129
|
+
const subPeriods = buildSubPeriods(entry, start, end, options);
|
|
1130
|
+
allPeriods.push({
|
|
1131
|
+
planet: entry.planet,
|
|
1132
|
+
years: entry.years,
|
|
1133
|
+
startDate: start,
|
|
1134
|
+
endDate: end,
|
|
1135
|
+
subPeriods
|
|
1136
|
+
});
|
|
1137
|
+
cursor = end;
|
|
1138
|
+
if (target.getTime() >= start.getTime() && target.getTime() < end.getTime()) {
|
|
1139
|
+
foundCurrent = true;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const currentMajor = allPeriods.find(
|
|
1144
|
+
(p) => target.getTime() >= p.startDate.getTime() && target.getTime() < p.endDate.getTime()
|
|
1145
|
+
) ?? allPeriods[0];
|
|
1146
|
+
const currentSub = currentMajor.subPeriods.find(
|
|
1147
|
+
(s) => target.getTime() >= s.startDate.getTime() && target.getTime() < s.endDate.getTime()
|
|
1148
|
+
) ?? currentMajor.subPeriods[0];
|
|
1149
|
+
return { sect, currentMajor, currentSub, allPeriods };
|
|
1150
|
+
}
|
|
841
1151
|
|
|
842
1152
|
// src/astrology/index.ts
|
|
843
1153
|
function validateInputs(options) {
|
|
@@ -936,7 +1246,8 @@ async function getBirthChart(options) {
|
|
|
936
1246
|
planets,
|
|
937
1247
|
houses,
|
|
938
1248
|
nodes,
|
|
939
|
-
aspects
|
|
1249
|
+
aspects,
|
|
1250
|
+
sect: isDiurnal ? "diurnal" : "nocturnal"
|
|
940
1251
|
};
|
|
941
1252
|
} catch (error) {
|
|
942
1253
|
console.error("Error calculating birth chart:", error);
|
|
@@ -1042,7 +1353,323 @@ async function getCompositeChart(options) {
|
|
|
1042
1353
|
aspects
|
|
1043
1354
|
};
|
|
1044
1355
|
}
|
|
1356
|
+
function getTransitAspectPoints(planets) {
|
|
1357
|
+
const points = {};
|
|
1358
|
+
for (const [key, p] of Object.entries(planets)) {
|
|
1359
|
+
points[key] = { longitude: p.longitude, longitudeSpeed: p.longitudeSpeed };
|
|
1360
|
+
}
|
|
1361
|
+
return points;
|
|
1362
|
+
}
|
|
1363
|
+
function getNatalAspectPoints(planets, ascLon, mcLon) {
|
|
1364
|
+
const points = {};
|
|
1365
|
+
for (const [key, p] of Object.entries(planets)) {
|
|
1366
|
+
points[key] = { longitude: p.longitude, longitudeSpeed: 0 };
|
|
1367
|
+
}
|
|
1368
|
+
points.ascendant = { longitude: ascLon, longitudeSpeed: 0 };
|
|
1369
|
+
points.mc = { longitude: mcLon, longitudeSpeed: 0 };
|
|
1370
|
+
return points;
|
|
1371
|
+
}
|
|
1372
|
+
function filterByNames(points, names) {
|
|
1373
|
+
if (!names || names.length === 0) return points;
|
|
1374
|
+
const allowed = new Set(names.map((n) => n.toLowerCase()));
|
|
1375
|
+
const result = {};
|
|
1376
|
+
for (const [key, val] of Object.entries(points)) {
|
|
1377
|
+
if (allowed.has(key)) result[key] = val;
|
|
1378
|
+
}
|
|
1379
|
+
return result;
|
|
1380
|
+
}
|
|
1381
|
+
async function getTransitChart(options) {
|
|
1382
|
+
const natalChart = await getBirthChart(options.natal);
|
|
1383
|
+
const transitChart = await getBirthChart({
|
|
1384
|
+
date: options.transitDate,
|
|
1385
|
+
latitude: options.transitLatitude ?? options.natal.latitude,
|
|
1386
|
+
longitude: options.transitLongitude ?? options.natal.longitude,
|
|
1387
|
+
houseSystem: options.natal.houseSystem,
|
|
1388
|
+
timeZoneSettings: options.transitTimeZoneSettings ?? { autoTimeZone: true }
|
|
1389
|
+
});
|
|
1390
|
+
const natalCusps = natalChart.houses.houses.map((h) => h.longitude);
|
|
1391
|
+
const transitPlanets = {};
|
|
1392
|
+
for (const [key, planet] of Object.entries(transitChart.planets)) {
|
|
1393
|
+
const natalZodiac = getZodiacPosition(planet.longitude, natalCusps);
|
|
1394
|
+
transitPlanets[key] = {
|
|
1395
|
+
...planet,
|
|
1396
|
+
retrograde: (planet.longitudeSpeed ?? 0) < 0,
|
|
1397
|
+
natalHouse: natalZodiac.house,
|
|
1398
|
+
zodiacPosition: {
|
|
1399
|
+
...planet.zodiacPosition,
|
|
1400
|
+
house: natalZodiac.house
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
let tPoints = getTransitAspectPoints(transitChart.planets);
|
|
1405
|
+
let nPoints = getNatalAspectPoints(
|
|
1406
|
+
natalChart.planets,
|
|
1407
|
+
natalChart.houses.ascendant.longitude,
|
|
1408
|
+
natalChart.houses.mc.longitude
|
|
1409
|
+
);
|
|
1410
|
+
tPoints = filterByNames(tPoints, options.transitPlanets);
|
|
1411
|
+
nPoints = filterByNames(nPoints, options.natalPlanets);
|
|
1412
|
+
let aspects = computeTransitAspects(tPoints, nPoints, options.aspectSpecs);
|
|
1413
|
+
if (options.maxOrb != null) {
|
|
1414
|
+
aspects = aspects.filter((a) => a.orb <= options.maxOrb);
|
|
1415
|
+
}
|
|
1416
|
+
if (options.aspectFilter && options.aspectFilter.length > 0) {
|
|
1417
|
+
const allowed = new Set(options.aspectFilter);
|
|
1418
|
+
aspects = aspects.filter((a) => allowed.has(a.aspect));
|
|
1419
|
+
}
|
|
1420
|
+
return {
|
|
1421
|
+
natalChart,
|
|
1422
|
+
transitDateUtc: transitChart.dateUtc,
|
|
1423
|
+
transitPlanets,
|
|
1424
|
+
aspects
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
async function getTransitRange(options) {
|
|
1428
|
+
const natalChart = await getBirthChart(options.natal);
|
|
1429
|
+
natalChart.houses.houses.map((h) => h.longitude);
|
|
1430
|
+
const nPoints = filterByNames(
|
|
1431
|
+
getNatalAspectPoints(
|
|
1432
|
+
natalChart.planets,
|
|
1433
|
+
natalChart.houses.ascendant.longitude,
|
|
1434
|
+
natalChart.houses.mc.longitude
|
|
1435
|
+
),
|
|
1436
|
+
options.natalPlanets
|
|
1437
|
+
);
|
|
1438
|
+
const natalKeys = Object.keys(nPoints);
|
|
1439
|
+
const rawStep = options.stepDays ?? 1;
|
|
1440
|
+
if (rawStep <= 0) throw new Error("stepDays must be greater than 0");
|
|
1441
|
+
const fromMs = options.from.getTime();
|
|
1442
|
+
const toMs = options.to.getTime();
|
|
1443
|
+
const specs = options.aspectSpecs;
|
|
1444
|
+
const steps = [];
|
|
1445
|
+
const transitLat = options.transitLatitude ?? options.natal.latitude;
|
|
1446
|
+
const transitLon = options.transitLongitude ?? options.natal.longitude;
|
|
1447
|
+
const transitTz = options.transitTimeZoneSettings ?? { autoTimeZone: true };
|
|
1448
|
+
const FAST_PLANET_MAX_STEP = 0.25;
|
|
1449
|
+
let effectiveStepDays = rawStep;
|
|
1450
|
+
const requestedTransitPlanets = options.transitPlanets?.map((n) => n.toLowerCase());
|
|
1451
|
+
const hasFastPlanets = requestedTransitPlanets ? requestedTransitPlanets.some((n) => !SLOW_PLANETS.has(n)) : true;
|
|
1452
|
+
if (hasFastPlanets && effectiveStepDays > FAST_PLANET_MAX_STEP) {
|
|
1453
|
+
effectiveStepDays = FAST_PLANET_MAX_STEP;
|
|
1454
|
+
}
|
|
1455
|
+
const stepMs = effectiveStepDays * 864e5;
|
|
1456
|
+
const scanEndMs = toMs + stepMs;
|
|
1457
|
+
for (let ms = fromMs; ms <= scanEndMs; ms += stepMs) {
|
|
1458
|
+
const date = new Date(ms);
|
|
1459
|
+
const utcDate = await toUtcDate(date, transitLat, transitLon, transitTz ?? { autoTimeZone: true });
|
|
1460
|
+
const positions = await calculatePlanetaryPositions(utcDate);
|
|
1461
|
+
if (!positions) continue;
|
|
1462
|
+
const points = {};
|
|
1463
|
+
for (const [planetId, pos] of Object.entries(positions)) {
|
|
1464
|
+
const id = planetId;
|
|
1465
|
+
const name = PLANET_AND_NODE_NAMES[id].toLowerCase();
|
|
1466
|
+
points[name] = { longitude: pos.longitude, longitudeSpeed: pos.longitudeSpeed };
|
|
1467
|
+
}
|
|
1468
|
+
steps.push({ time: ms, positions: filterByNames(points, options.transitPlanets) });
|
|
1469
|
+
}
|
|
1470
|
+
const perfections = [];
|
|
1471
|
+
const transitKeys = steps.length > 0 ? Object.keys(steps[0].positions) : [];
|
|
1472
|
+
for (const tKey of transitKeys) {
|
|
1473
|
+
for (const nKey of natalKeys) {
|
|
1474
|
+
let prevOrb = null;
|
|
1475
|
+
let prevDecreasing = false;
|
|
1476
|
+
let prevStep = null;
|
|
1477
|
+
for (const step of steps) {
|
|
1478
|
+
const tPos = step.positions[tKey];
|
|
1479
|
+
const nPos = nPoints[nKey];
|
|
1480
|
+
if (!tPos || !nPos) continue;
|
|
1481
|
+
const match = specs ? findClosestAspectOrb(tPos.longitude, nPos.longitude, specs) : findClosestAspectOrb(tPos.longitude, nPos.longitude);
|
|
1482
|
+
if (!match) {
|
|
1483
|
+
prevOrb = null;
|
|
1484
|
+
prevStep = step;
|
|
1485
|
+
continue;
|
|
1486
|
+
}
|
|
1487
|
+
const currentOrb = match.orb;
|
|
1488
|
+
if (prevOrb != null && prevStep) {
|
|
1489
|
+
const wasDecreasing = prevOrb > currentOrb;
|
|
1490
|
+
if (prevDecreasing && !wasDecreasing && currentOrb <= match.spec.orb) {
|
|
1491
|
+
const exactResult = await binarySearchPerfection(
|
|
1492
|
+
tKey,
|
|
1493
|
+
nKey,
|
|
1494
|
+
match.spec,
|
|
1495
|
+
prevStep.time,
|
|
1496
|
+
step.time,
|
|
1497
|
+
nPos,
|
|
1498
|
+
transitLat,
|
|
1499
|
+
transitLon,
|
|
1500
|
+
transitTz
|
|
1501
|
+
);
|
|
1502
|
+
if (exactResult) perfections.push(exactResult);
|
|
1503
|
+
}
|
|
1504
|
+
prevDecreasing = wasDecreasing;
|
|
1505
|
+
} else {
|
|
1506
|
+
prevDecreasing = false;
|
|
1507
|
+
}
|
|
1508
|
+
prevOrb = currentOrb;
|
|
1509
|
+
prevStep = step;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
let filtered = perfections.filter((p) => {
|
|
1514
|
+
const t = p.exactDate.getTime();
|
|
1515
|
+
return t >= fromMs && t <= toMs;
|
|
1516
|
+
});
|
|
1517
|
+
if (options.maxOrb != null) {
|
|
1518
|
+
filtered = filtered.filter((p) => p.exactOrb <= options.maxOrb);
|
|
1519
|
+
}
|
|
1520
|
+
if (options.aspectFilter && options.aspectFilter.length > 0) {
|
|
1521
|
+
const allowed = new Set(options.aspectFilter);
|
|
1522
|
+
filtered = filtered.filter((p) => allowed.has(p.aspect));
|
|
1523
|
+
}
|
|
1524
|
+
filtered.sort((a, b) => a.exactDate.getTime() - b.exactDate.getTime());
|
|
1525
|
+
return {
|
|
1526
|
+
natalChart,
|
|
1527
|
+
from: options.from,
|
|
1528
|
+
to: options.to,
|
|
1529
|
+
perfections: filtered
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
function findClosestAspectOrb(lonA, lonB, specs = DEFAULT_ASPECT_SPECS) {
|
|
1533
|
+
const a = normalizeAngle(lonA);
|
|
1534
|
+
const b = normalizeAngle(lonB);
|
|
1535
|
+
const delta = Math.min(normalizeAngle(b - a), normalizeAngle(a - b));
|
|
1536
|
+
let best = null;
|
|
1537
|
+
for (const spec of specs) {
|
|
1538
|
+
const orb = Math.abs(delta - spec.angle);
|
|
1539
|
+
if (orb <= spec.orb + 2) {
|
|
1540
|
+
if (!best || orb < best.orb) {
|
|
1541
|
+
best = { spec, orb, delta };
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return best;
|
|
1546
|
+
}
|
|
1547
|
+
function computeOrbForAspect(transitLon, natalLon, aspectAngle) {
|
|
1548
|
+
const delta = Math.min(
|
|
1549
|
+
normalizeAngle(transitLon - natalLon),
|
|
1550
|
+
normalizeAngle(natalLon - transitLon)
|
|
1551
|
+
);
|
|
1552
|
+
return Math.abs(delta - aspectAngle);
|
|
1553
|
+
}
|
|
1554
|
+
var NAME_TO_PLANET = {};
|
|
1555
|
+
for (const [id, name] of Object.entries(PLANET_AND_NODE_NAMES)) {
|
|
1556
|
+
const numId = Number(id);
|
|
1557
|
+
if (!isNaN(numId)) NAME_TO_PLANET[name.toLowerCase()] = numId;
|
|
1558
|
+
}
|
|
1559
|
+
async function getTransitLongitudeAt(ms, transitKey, transitLat, transitLon, transitTz) {
|
|
1560
|
+
const date = new Date(ms);
|
|
1561
|
+
const utc = await toUtcDate(date, transitLat, transitLon, transitTz);
|
|
1562
|
+
const planetId = NAME_TO_PLANET[transitKey];
|
|
1563
|
+
if (planetId != null) {
|
|
1564
|
+
try {
|
|
1565
|
+
return calculateSinglePlanetPosition(utc, planetId);
|
|
1566
|
+
} catch {
|
|
1567
|
+
return null;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
const positions = await calculatePlanetaryPositions(utc);
|
|
1571
|
+
if (!positions) return null;
|
|
1572
|
+
return findPlanetByName(positions, transitKey) ?? null;
|
|
1573
|
+
}
|
|
1574
|
+
async function binarySearchPerfection(transitKey, natalKey, spec, startMs, endMs, natalPoint, transitLat, transitLon, transitTz) {
|
|
1575
|
+
const tz = transitTz ?? { autoTimeZone: true };
|
|
1576
|
+
const maxIterations = 30;
|
|
1577
|
+
let lo = startMs;
|
|
1578
|
+
let hi = endMs;
|
|
1579
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
1580
|
+
if (hi - lo < 6e4) break;
|
|
1581
|
+
const m1 = lo + Math.floor((hi - lo) / 3);
|
|
1582
|
+
const m2 = hi - Math.floor((hi - lo) / 3);
|
|
1583
|
+
const pos1 = await getTransitLongitudeAt(m1, transitKey, transitLat, transitLon, tz);
|
|
1584
|
+
const pos2 = await getTransitLongitudeAt(m2, transitKey, transitLat, transitLon, tz);
|
|
1585
|
+
if (!pos1 || !pos2) break;
|
|
1586
|
+
const orb1 = computeOrbForAspect(pos1.longitude, natalPoint.longitude, spec.angle);
|
|
1587
|
+
const orb2 = computeOrbForAspect(pos2.longitude, natalPoint.longitude, spec.angle);
|
|
1588
|
+
if (orb1 < orb2) {
|
|
1589
|
+
hi = m2;
|
|
1590
|
+
} else {
|
|
1591
|
+
lo = m1;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
const finalMs = Math.floor((lo + hi) / 2);
|
|
1595
|
+
const finalPos = await getTransitLongitudeAt(finalMs, transitKey, transitLat, transitLon, tz);
|
|
1596
|
+
if (!finalPos) return null;
|
|
1597
|
+
const finalOrb = computeOrbForAspect(finalPos.longitude, natalPoint.longitude, spec.angle);
|
|
1598
|
+
if (finalOrb > spec.orb) return null;
|
|
1599
|
+
return {
|
|
1600
|
+
transitPlanet: transitKey,
|
|
1601
|
+
natalPlanet: natalKey,
|
|
1602
|
+
aspect: spec.name,
|
|
1603
|
+
exactDate: new Date(finalMs),
|
|
1604
|
+
exactOrb: finalOrb,
|
|
1605
|
+
retrograde: (finalPos.longitudeSpeed ?? 0) < 0,
|
|
1606
|
+
category: SLOW_PLANETS.has(transitKey) ? "slow" : "fast"
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
function findPlanetByName(positions, name) {
|
|
1610
|
+
for (const [planetId, pos] of Object.entries(positions)) {
|
|
1611
|
+
const id = planetId;
|
|
1612
|
+
if (PLANET_AND_NODE_NAMES[id].toLowerCase() === name) return pos;
|
|
1613
|
+
}
|
|
1614
|
+
return void 0;
|
|
1615
|
+
}
|
|
1616
|
+
async function getSunLongitudeAtMs(ms) {
|
|
1617
|
+
const positions = await calculatePlanetaryPositions(new Date(ms));
|
|
1618
|
+
const sun = findPlanetByName(positions, "sun");
|
|
1619
|
+
if (!sun) throw new Error("Failed to compute Sun position");
|
|
1620
|
+
return sun.longitude;
|
|
1621
|
+
}
|
|
1622
|
+
function signedAngularDelta(current, target) {
|
|
1623
|
+
let d = normalizeAngle(current - target);
|
|
1624
|
+
if (d > 180) d -= 360;
|
|
1625
|
+
return d;
|
|
1626
|
+
}
|
|
1627
|
+
async function getSolarReturnChart(options) {
|
|
1628
|
+
const natalChart = await getBirthChart(options.natal);
|
|
1629
|
+
const natalSunLongitude = natalChart.planets.sun.longitude;
|
|
1630
|
+
const natalDate = options.natal.date;
|
|
1631
|
+
const approxReturn = new Date(Date.UTC(
|
|
1632
|
+
options.year,
|
|
1633
|
+
natalDate.getMonth(),
|
|
1634
|
+
natalDate.getDate(),
|
|
1635
|
+
12,
|
|
1636
|
+
0,
|
|
1637
|
+
0
|
|
1638
|
+
));
|
|
1639
|
+
let lo = approxReturn.getTime() - 2 * 864e5;
|
|
1640
|
+
let hi = approxReturn.getTime() + 2 * 864e5;
|
|
1641
|
+
for (let i = 0; i < 30; i++) {
|
|
1642
|
+
if (hi - lo < 6e4) break;
|
|
1643
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
1644
|
+
const sunLon = await getSunLongitudeAtMs(mid);
|
|
1645
|
+
const delta = signedAngularDelta(sunLon, natalSunLongitude);
|
|
1646
|
+
if (delta < 0) {
|
|
1647
|
+
lo = mid;
|
|
1648
|
+
} else {
|
|
1649
|
+
hi = mid;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
const exactMs = Math.floor((lo + hi) / 2);
|
|
1653
|
+
const exactReturnDate = new Date(exactMs);
|
|
1654
|
+
const solarReturnChart = await getBirthChart({
|
|
1655
|
+
date: exactReturnDate,
|
|
1656
|
+
latitude: options.solarReturnLatitude ?? options.natal.latitude,
|
|
1657
|
+
longitude: options.solarReturnLongitude ?? options.natal.longitude,
|
|
1658
|
+
houseSystem: options.solarReturnHouseSystem ?? options.natal.houseSystem,
|
|
1659
|
+
// Always treatAsUTC: the binary search converged on a UTC millisecond timestamp.
|
|
1660
|
+
// Passing a caller timezone here would re-interpret the already-UTC instant as local,
|
|
1661
|
+
// shifting planetary positions by hours.
|
|
1662
|
+
timeZoneSettings: { treatAsUTC: true }
|
|
1663
|
+
});
|
|
1664
|
+
return {
|
|
1665
|
+
natalChart,
|
|
1666
|
+
solarReturnChart,
|
|
1667
|
+
exactReturnDate,
|
|
1668
|
+
natalSunLongitude,
|
|
1669
|
+
year: options.year
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1045
1672
|
|
|
1046
|
-
export { CalcFlag, DEFAULT_ASPECT_SPECS, HouseSystem, PLANET_AND_NODE_NAMES, Planet, SIGNS, VirtualNodes, closeSwissEph, computeAspects, computeMidpoints, computeSynastryAspects, findHouseOf, formatDegreeMinutes, getAspectMatch, getBirthChart, getCompositeChart, getSwissEph, getSynastryChart, getZodiacPosition, normalizeAngle, shorterArcMidpoint };
|
|
1047
|
-
//# sourceMappingURL=chunk-
|
|
1048
|
-
//# sourceMappingURL=chunk-
|
|
1673
|
+
export { CalcFlag, DEFAULT_ASPECT_SPECS, DOMICILE_RULERS, EXALTATIONS, HouseSystem, PLANET_AND_NODE_NAMES, Planet, SIGNS, SLOW_PLANETS, VirtualNodes, closeSwissEph, computeAspects, computeMidpoints, computeSynastryAspects, computeTransitAspects, findHouseOf, formatDegreeMinutes, getAnnualProfection, getAspectMatch, getBirthChart, getCompositeChart, getDecan, getDetriment, getDodecatemoria, getDomicileRuler, getEssentialDignity, getExaltation, getFall, getFirdaria, getMonthlyProfections, getOppositeSign, getSolarReturnChart, getSwissEph, getSynastryChart, getTransitChart, getTransitRange, getZodiacPosition, normalizeAngle, shorterArcMidpoint };
|
|
1674
|
+
//# sourceMappingURL=chunk-EBLM443L.mjs.map
|
|
1675
|
+
//# sourceMappingURL=chunk-EBLM443L.mjs.map
|