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