@zodiacs/engine 0.1.1-rc.16 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +458 -0
  2. package/LICENSING.md +18 -5
  3. package/NOTICE +3 -2
  4. package/README.md +67 -33
  5. package/dist/{api-VOW6Umy5.d.ts → api-WbxJ4Wj-.d.ts} +12 -6
  6. package/dist/ayanamsa--YQ46fET.d.ts +134 -0
  7. package/dist/calc.d.ts +131 -20
  8. package/dist/calc.js +246 -60
  9. package/dist/chunk-47ERTK5X.js +27 -0
  10. package/dist/{chunk-O3NJRGJ2.js → chunk-7TRLIFFI.js} +1 -1
  11. package/dist/{chunk-KHBLFXFG.js → chunk-B5LKF437.js} +29 -28
  12. package/dist/{chunk-ONBZ4HK7.js → chunk-BHJXUY67.js} +4 -2
  13. package/dist/{chunk-I7O5EGFV.js → chunk-CHSYDKBL.js} +1 -1
  14. package/dist/{chunk-4NV4ZEFZ.js → chunk-DMGHYCDI.js} +4 -4
  15. package/dist/{chunk-L6ZHWJZ6.js → chunk-FTX3JDJA.js} +15 -12
  16. package/dist/{chunk-2OWGBT3O.js → chunk-OG4OYTJJ.js} +47 -42
  17. package/dist/{chunk-WOU7JVD3.js → chunk-SRXBTP5H.js} +7 -7
  18. package/dist/{chunk-AECKV73C.js → chunk-TSS2SZWQ.js} +8 -2
  19. package/dist/chunk-WS3TDSP3.js +474 -0
  20. package/dist/{chunk-N4B5JNMA.js → chunk-YIITY7Q7.js} +21 -11
  21. package/dist/crossings.d.ts +8 -7
  22. package/dist/crossings.js +1 -1
  23. package/dist/deltat.d.ts +28 -3
  24. package/dist/deltat.js +1 -1
  25. package/dist/geo.d.ts +33 -12
  26. package/dist/geo.js +3 -1
  27. package/dist/{houses-q1O2GGp4.d.ts → houses-CFERsAlK.d.ts} +12 -2
  28. package/dist/houses-extra.d.ts +19 -5
  29. package/dist/houses-extra.js +4 -2
  30. package/dist/index.d.ts +34 -49
  31. package/dist/index.js +21 -13
  32. package/dist/{internal-math-CmJ9xtaW.d.ts → internal-math-DJJ8BYex.d.ts} +41 -27
  33. package/dist/internal-math.d.ts +3 -3
  34. package/dist/internal-math.js +2 -2
  35. package/dist/internal.d.ts +1 -1
  36. package/dist/internal.js +5 -5
  37. package/dist/receipt.d.ts +2 -268
  38. package/dist/receipt.js +70 -35
  39. package/dist/reference-span-CILpclrz.d.ts +40 -0
  40. package/dist/{rulers-9wljfVaO.d.ts → rulers-Dla6h_Sm.d.ts} +7 -2
  41. package/dist/sky.d.ts +25 -10
  42. package/dist/sky.js +11 -9
  43. package/dist/techniques.d.ts +61 -18
  44. package/dist/techniques.js +39 -46
  45. package/dist/timing.d.ts +53 -16
  46. package/dist/timing.js +19 -38
  47. package/dist/{types-B4MCoCCS.d.ts → types-B-yb_tGL.d.ts} +23 -11
  48. package/dist/vedic.d.ts +42 -123
  49. package/dist/vedic.js +43 -440
  50. package/dist/window.d.ts +81 -79
  51. package/dist/window.js +26 -27
  52. package/dist/zone-history-ghdyO0Sc.d.ts +268 -0
  53. package/package.json +3 -1
@@ -0,0 +1,474 @@
1
+ import {
2
+ readOptions
3
+ } from "./chunk-47ERTK5X.js";
4
+ import {
5
+ dateFrom
6
+ } from "./chunk-CPALRSPC.js";
7
+ import {
8
+ eclipticFrame,
9
+ meanEcliptic,
10
+ onChartClock
11
+ } from "./chunk-SRXBTP5H.js";
12
+ import {
13
+ REFERENCE_SPAN,
14
+ TIME_SCALE_NAMES,
15
+ outsideReferenceSpan,
16
+ timeBasis
17
+ } from "./chunk-B5LKF437.js";
18
+
19
+ // src/vedic/ayanamsa.ts
20
+ import { BaryState, Body, HelioVector } from "astronomy-engine";
21
+ var DEG = Math.PI / 180;
22
+ var ARCSEC = DEG / 3600;
23
+ var MAS = ARCSEC / 1e3;
24
+ var J2000 = 2451545;
25
+ var DAY_MS = 864e5;
26
+ var UNIX_JD = 24405875e-1;
27
+ var JULIAN_YEAR = 365.25;
28
+ var AU_KM = 1495978707e-1;
29
+ var C_AU_PER_DAY = 299792.458 * 86400 / AU_KM;
30
+ var SUN_SCHWARZSCHILD_AU = 197412574336e-19;
31
+ var SPAN_FROM_JD = UNIX_JD + Date.parse(REFERENCE_SPAN.from) / DAY_MS;
32
+ var SPAN_TO_JD = UNIX_JD + Date.parse(REFERENCE_SPAN.to) / DAY_MS;
33
+ var DEFINITIONS = /* @__PURE__ */ new WeakSet();
34
+ function registered(definition) {
35
+ const frozen = Object.freeze(definition);
36
+ DEFINITIONS.add(frozen);
37
+ return frozen;
38
+ }
39
+ var HIPPARCOS_EPOCH = 24483490625e-4;
40
+ var HIP2007 = "Hipparcos 2007 (I/311)";
41
+ function star(name, ra, dec, pmRa, pmDec, parallax, radialVelocity, epochTT = HIPPARCOS_EPOCH) {
42
+ return Object.freeze({ name, ra, dec, epochTT, pmRa, pmDec, parallax, radialVelocity });
43
+ }
44
+ var AYANAMSAS = Object.freeze({
45
+ lahiri: registered({
46
+ kind: "epoch",
47
+ name: "lahiri",
48
+ label: "Lahiri (Chitrapaksha)",
49
+ // True 23°15′00.658″ less the IAU 1980 nutation in longitude at that instant, +16.768927″.
50
+ epochTT: 24355535e-1,
51
+ value: 23 + 15 / 60 + (0.658 - 16.768927) / 3600,
52
+ model: "iau1976",
53
+ source: "Indian Astronomical Ephemeris: 23\xB015\u203200.658\u2033 true at 1956-03-21 0h TT (1989, p. 556)"
54
+ }),
55
+ "fagan-bradley": registered({
56
+ kind: "epoch",
57
+ name: "fagan-bradley",
58
+ label: "Fagan\u2013Bradley",
59
+ epochTT: 243328242345905e-8,
60
+ value: 24 + 2 / 60 + 31.36 / 3600,
61
+ model: "newcomb",
62
+ source: "Synetic vernal point 335\xB057\u203228.64\u2033 at B1950.0 (Astro*Index)"
63
+ }),
64
+ krishnamurti: registered({
65
+ kind: "epoch",
66
+ name: "krishnamurti",
67
+ label: "Krishnamurti (KP)",
68
+ epochTT: 24150205e-1,
69
+ value: 22.363889,
70
+ model: "newcomb",
71
+ source: "22\xB021\u203250\u2033 at 1900-01-01, fitted to KP Reader 1's table (Hand, Dawson)"
72
+ }),
73
+ raman: registered({
74
+ kind: "linear",
75
+ name: "raman",
76
+ label: "Raman",
77
+ epochTT: J2000 + (397 - 2e3) * JULIAN_YEAR,
78
+ value: 0,
79
+ rate: 50 + 1 / 3,
80
+ source: "B. V. Raman, A Manual of Hindu Astrology (1935) \xA749"
81
+ }),
82
+ yukteswar: registered({
83
+ kind: "linear",
84
+ name: "yukteswar",
85
+ label: "Sri Yukteswar",
86
+ epochTT: 24129081244e-4,
87
+ value: 20 + 54 / 60 + 36 / 3600,
88
+ rate: 54,
89
+ source: "Sri Yukteswar, The Holy Science (1894), Introduction"
90
+ }),
91
+ "true-chitra": registered({
92
+ kind: "star",
93
+ name: "true-chitra",
94
+ label: "True Chitra (Spica at 180\xB0)",
95
+ longitude: 180,
96
+ star: star("Spica (\u03B1 Vir, HIP 65474)", 201.29835228, -11.16124494, -42.35, -30.67, 13.06, -3.31),
97
+ source: `Surya Siddhanta VIII; ${HIP2007}`
98
+ }),
99
+ "true-revati": registered({
100
+ kind: "star",
101
+ name: "true-revati",
102
+ label: "True Revati (\u03B6 Psc at 359\xB050\u2032)",
103
+ longitude: 359 + 50 / 60,
104
+ star: star("Revati (\u03B6 Psc A, HIP 5737)", 18.43250842, 7.57548938, 145, -55.69, 18.76, 15),
105
+ source: `Surya Siddhanta VIII; ${HIP2007}`
106
+ }),
107
+ "true-pushya": registered({
108
+ kind: "star",
109
+ name: "true-pushya",
110
+ label: "True Pushya (\u03B4 Cnc at 106\xB0)",
111
+ longitude: 106,
112
+ star: star("Pushya (\u03B4 Cnc, HIP 42911)", 131.17129191, 18.15486373, -17.67, -229.26, 24.98, 17.14),
113
+ source: `P. V. R. Narasimha Rao (2013); ${HIP2007}`
114
+ }),
115
+ "galactic-center": registered({
116
+ kind: "star",
117
+ name: "galactic-center",
118
+ label: "Galactic Center at 0\xB0 Sagittarius",
119
+ longitude: 240,
120
+ star: star("Sgr A*", 266.416816625, -(29 + 28.1699 / 3600), -3.151, -5.547, 0, 0, J2000),
121
+ source: "Sgr A*: SIMBAD ICRS position; Reid & Brunthaler 2004"
122
+ })
123
+ });
124
+ function requireFinite(value, low, high, label) {
125
+ if (typeof value !== "number" || !Number.isFinite(value) || value < low || value > high) {
126
+ throw new RangeError(`${label} must be a finite number in [${low}, ${high}].`);
127
+ }
128
+ return value;
129
+ }
130
+ var EPOCH_JD_LIMIT = 1e8;
131
+ function isUserAyanamsaName(name) {
132
+ return typeof name === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(name) && !Object.hasOwn(AYANAMSAS, name);
133
+ }
134
+ function userAyanamsa(input) {
135
+ if (!input || typeof input !== "object") throw new RangeError("userAyanamsa needs an input object.");
136
+ const read = readOptions(input, ["name", "epoch", "value", "rate", "model"], "userAyanamsa input");
137
+ const name = read.name ?? "user";
138
+ if (!isUserAyanamsaName(name)) {
139
+ throw new RangeError("Ayanamsa name must be a new lowercase identifier of at most 64 characters.");
140
+ }
141
+ const epoch = read.epoch;
142
+ let epochTT;
143
+ if (typeof epoch === "number") {
144
+ throw new RangeError("epoch must be { julianDateTT }, a Date or an ISO 8601 string: a bare number could be a Julian date or epoch milliseconds.");
145
+ } else if (epoch && typeof epoch === "object" && !(epoch instanceof Date)) {
146
+ const julian = readOptions(epoch, ["julianDateTT"], "epoch");
147
+ epochTT = requireFinite(julian.julianDateTT, UNIX_JD - EPOCH_JD_LIMIT, UNIX_JD + EPOCH_JD_LIMIT, "epoch.julianDateTT");
148
+ } else {
149
+ const at = dateFrom(epoch, "epoch");
150
+ epochTT = J2000 + timeBasis(at.getTime(), "utc").ttDays;
151
+ }
152
+ const value = requireFinite(read.value, -360, 360, "value");
153
+ const common = { name, label: `user: ${name}`, source: "caller-defined", epochTT, value };
154
+ if (read.rate !== void 0) {
155
+ if (read.model !== void 0) throw new RangeError("Give either a rate or a precession model, not both.");
156
+ return registered({ kind: "linear", ...common, rate: requireFinite(read.rate, -3600, 3600, "rate") });
157
+ }
158
+ const model = read.model ?? "engine";
159
+ if (model !== "engine" && model !== "newcomb" && model !== "iau1976") {
160
+ throw new RangeError("model must be engine, newcomb or iau1976.");
161
+ }
162
+ return registered({ kind: "epoch", ...common, model });
163
+ }
164
+ function definitionOf(definition) {
165
+ if (typeof definition === "string") {
166
+ if (!Object.hasOwn(AYANAMSAS, definition)) throw new RangeError(`Unknown ayanamsa: ${definition}.`);
167
+ return AYANAMSAS[definition];
168
+ }
169
+ if (!definition || typeof definition !== "object" || !DEFINITIONS.has(definition)) {
170
+ throw new RangeError("An ayanamsa must be a built-in name, an AYANAMSAS entry or a userAyanamsa result.");
171
+ }
172
+ return definition;
173
+ }
174
+ function longitudeIn(frame, x, y, z) {
175
+ const [ex, ey] = meanEcliptic(frame, x, y, z);
176
+ return Math.atan2(ey, ex);
177
+ }
178
+ function olderModelLongitude(model, jd) {
179
+ let zeta, z, theta, eps;
180
+ if (model === "newcomb") {
181
+ const B1850 = 239675820358095e-8;
182
+ const CENTURY = 36524.2198781;
183
+ const t = (J2000 - B1850) / CENTURY;
184
+ const h = (jd - J2000) / CENTURY;
185
+ const sum = (4607.1096 + t * (2.7944 + 118e-6 * t) + (1.3972 + 118e-6 * t + 0.03632 * h) * h) * h;
186
+ const diff = (0.79236 + 656e-6 * t + 328e-6 * h) * h * h;
187
+ zeta = (sum - diff) / 2;
188
+ z = (sum + diff) / 2;
189
+ theta = (2005.1125 - t * (0.85294 + 365e-6 * t) + (-0.42647 - 365e-6 * t - 0.041802 * h) * h) * h;
190
+ const e = (jd - B1850) / CENTURY;
191
+ eps = 84451.68 + e * (-46.837 + e * (-8752e-6 + 183e-5 * e));
192
+ } else {
193
+ const t = (jd - J2000) / 36525;
194
+ zeta = t * (2306.2181 + t * (0.30188 + 0.017998 * t));
195
+ z = t * (2306.2181 + t * (1.09468 + 0.018203 * t));
196
+ theta = t * (2004.3109 + t * (-0.42665 - 0.041833 * t));
197
+ eps = 84381.448 + t * (-46.815 + t * (-59e-5 + 1813e-6 * t));
198
+ }
199
+ [zeta, z, theta, eps] = [zeta * ARCSEC, z * ARCSEC, theta * ARCSEC, eps * ARCSEC];
200
+ const x = Math.cos(z) * Math.cos(zeta) * Math.cos(theta) - Math.sin(z) * Math.sin(zeta);
201
+ const y = Math.sin(z) * Math.cos(zeta) * Math.cos(theta) + Math.cos(z) * Math.sin(zeta);
202
+ const w = Math.cos(zeta) * Math.sin(theta);
203
+ return Math.atan2(Math.cos(eps) * y + Math.sin(eps) * w, x);
204
+ }
205
+ var FRAMES = /* @__PURE__ */ new WeakMap();
206
+ function epochFrame(definition) {
207
+ let epoch = FRAMES.get(definition);
208
+ if (epoch === void 0) {
209
+ const frame = eclipticFrame(definition.epochTT - J2000);
210
+ const correction = definition.model === "engine" ? 0 : longitudeIn(frame, 1, 0, 0) - olderModelLongitude(definition.model, definition.epochTT);
211
+ epoch = Object.freeze({ frame, correction });
212
+ FRAMES.set(definition, epoch);
213
+ }
214
+ return epoch;
215
+ }
216
+ var dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
217
+ var scale = (a, k) => [a[0] * k, a[1] * k, a[2] * k];
218
+ var unit = (a) => scale(a, 1 / Math.sqrt(dot(a, a)));
219
+ function bias(v) {
220
+ const [xi, eta, alpha] = [-16.617 * MAS, -6.8192 * MAS, -14.6 * MAS];
221
+ const x1 = v[0] + alpha * v[1];
222
+ const y1 = v[1] - alpha * v[0];
223
+ const x2 = x1 - xi * v[2];
224
+ const z2 = v[2] + xi * x1;
225
+ return [x2, y1 - eta * z2, z2 + eta * y1];
226
+ }
227
+ function apparentStar(s, time) {
228
+ const ra = s.ra * DEG;
229
+ const dec = s.dec * DEG;
230
+ const p0 = bias([Math.cos(dec) * Math.cos(ra), Math.cos(dec) * Math.sin(ra), Math.sin(dec)]);
231
+ const east = bias([-Math.sin(ra), Math.cos(ra), 0]);
232
+ const north = bias([-Math.sin(dec) * Math.cos(ra), -Math.sin(dec) * Math.sin(ra), Math.cos(dec)]);
233
+ const days = time.tt + J2000 - s.epochTT;
234
+ const pm = (k2) => k2 * MAS / JULIAN_YEAR;
235
+ const bary = BaryState(Body.Earth, time);
236
+ let q;
237
+ if (s.parallax > 0) {
238
+ const d = 1 / (s.parallax * MAS);
239
+ const rv = s.radialVelocity * 86400 / AU_KM;
240
+ q = [0, 1, 2].map((i) => d * p0[i] + days * (d * (pm(s.pmRa) * east[i] + pm(s.pmDec) * north[i]) + rv * p0[i]));
241
+ q = [q[0] - bary.x, q[1] - bary.y, q[2] - bary.z];
242
+ } else {
243
+ q = [0, 1, 2].map((i) => p0[i] + days * (pm(s.pmRa) * east[i] + pm(s.pmDec) * north[i]));
244
+ }
245
+ let p = unit(q);
246
+ const helio = HelioVector(Body.Earth, time);
247
+ const em = Math.hypot(helio.x, helio.y, helio.z);
248
+ const e = [helio.x / em, helio.y / em, helio.z / em];
249
+ const pe = dot(p, e);
250
+ const elongation = Math.acos(Math.min(1, Math.max(-1, -pe))) / DEG;
251
+ const w = SUN_SCHWARZSCHILD_AU / em / Math.max(1 + pe, 1e-6 / Math.max(em * em, 1));
252
+ p = unit([p[0] + w * (e[0] - pe * p[0]), p[1] + w * (e[1] - pe * p[1]), p[2] + w * (e[2] - pe * p[2])]);
253
+ const v = [bary.vx / C_AU_PER_DAY, bary.vy / C_AU_PER_DAY, bary.vz / C_AU_PER_DAY];
254
+ const root = Math.sqrt(1 - dot(v, v));
255
+ const k = 1 + dot(p, v) / (1 + root);
256
+ return { direction: unit([p[0] * root + k * v[0], p[1] * root + k * v[1], p[2] * root + k * v[2]]), elongation };
257
+ }
258
+ function meanAyanamsa(definition, time, frame) {
259
+ switch (definition.kind) {
260
+ case "epoch": {
261
+ const { frame: at, correction } = frame;
262
+ const [x, y, z] = eclipticFrame(time.tt).rows;
263
+ return { value: definition.value + (correction - longitudeIn(at, x, y, z)) / DEG, elongation: null };
264
+ }
265
+ case "linear": {
266
+ const perDay = definition.rate / JULIAN_YEAR / 3600;
267
+ const atJ2000 = definition.value - perDay * (definition.epochTT - J2000);
268
+ return { value: atJ2000 - 360 * Math.round(atJ2000 / 360) + perDay * time.tt, elongation: null };
269
+ }
270
+ case "star": {
271
+ const { direction: [x, y, z], elongation } = apparentStar(definition.star, time);
272
+ return { value: longitudeIn(eclipticFrame(time.tt), x, y, z) / DEG - definition.longitude, elongation };
273
+ }
274
+ }
275
+ }
276
+ function wrap(value) {
277
+ const r = value % 360;
278
+ return r > 180 ? r - 360 : r <= -180 ? r + 360 : r;
279
+ }
280
+ function ayanamsaAt(definition, time) {
281
+ const frame = definition.kind === "epoch" ? epochFrame(definition) : void 0;
282
+ const { value, elongation } = meanAyanamsa(definition, time, frame);
283
+ const mean = wrap(value);
284
+ const nutation = eclipticFrame(time.tt).tilt.dpsi / 3600;
285
+ return { mean, nutation, true: wrap(mean + nutation), elongation };
286
+ }
287
+ function outsideSpanEpoch(definition) {
288
+ return definition.kind === "epoch" && !(definition.epochTT >= SPAN_FROM_JD && definition.epochTT < SPAN_TO_JD);
289
+ }
290
+ var VALUES = /* @__PURE__ */ new WeakMap();
291
+ function isAyanamsaValue(value) {
292
+ return typeof value === "object" && value !== null && VALUES.has(value);
293
+ }
294
+ function utcInstantOf(value) {
295
+ const ms = VALUES.get(value);
296
+ if (ms === void 0) throw new RangeError("ayanamsa must be a value returned by ayanamsa().");
297
+ return new Date(Math.round(ms)).toISOString();
298
+ }
299
+ function ayanamsa(definition, at, options) {
300
+ const resolved = definitionOf(definition);
301
+ const date = dateFrom(at, "at");
302
+ const read = readOptions(options, ["deltaT", "timeScale"], "ayanamsa options");
303
+ const pin = read.deltaT;
304
+ if (pin !== void 0) requireFinite(pin, -1e10, 1e10, "deltaT");
305
+ const scale2 = read.timeScale;
306
+ if (scale2 !== void 0 && !TIME_SCALE_NAMES.includes(scale2)) {
307
+ throw new RangeError('timeScale must be "utc", "ut1" or "tt".');
308
+ }
309
+ if (resolved.kind === "epoch") epochFrame(resolved);
310
+ const outside = outsideReferenceSpan(date) || outsideSpanEpoch(resolved);
311
+ return onChartClock(date.getTime(), scale2 ?? "utc", pin, (time, basis) => {
312
+ const { mean, nutation, true: trueValue } = ayanamsaAt(resolved, time);
313
+ const { ut1MinusUtc, leapSeconds } = basis.timeScale;
314
+ const value = Object.freeze({
315
+ ayanamsa: resolved.name,
316
+ utc: date.toISOString(),
317
+ timeScale: Object.freeze({
318
+ ...basis.timeScale,
319
+ ut1MinusUtc: ut1MinusUtc && Object.freeze({ ...ut1MinusUtc }),
320
+ leapSeconds: leapSeconds && Object.freeze({ ...leapSeconds })
321
+ }),
322
+ julianDateTT: time.tt + J2000,
323
+ deltaT: Object.freeze({ ...basis.deltaT }),
324
+ mean,
325
+ nutation,
326
+ true: trueValue,
327
+ flags: Object.freeze(outside ? ["outside-reference-span"] : [])
328
+ });
329
+ VALUES.set(value, basis.utcMs);
330
+ return value;
331
+ });
332
+ }
333
+
334
+ // src/vedic/grid.ts
335
+ var TICKS_PER_DEGREE = 7560;
336
+ var SIGN_TICKS = 226800;
337
+ var NAKSHATRA_TICKS = 100800;
338
+ var PADA_TICKS = 25200;
339
+ var YEAR_TICKS = 840;
340
+ var SPLIT = 134217729;
341
+ function productError(a, b, p) {
342
+ let t = SPLIT * a;
343
+ const ah = t - (t - a);
344
+ const al = a - ah;
345
+ t = SPLIT * b;
346
+ const bh = t - (t - b);
347
+ const bl = b - bh;
348
+ return ah * bh - p + ah * bl + al * bh + al * bl;
349
+ }
350
+ function ticksOf(lon) {
351
+ const p = lon * TICKS_PER_DEGREE;
352
+ const f = Math.floor(p);
353
+ return f === p && productError(lon, TICKS_PER_DEGREE, p) < 0 ? f - 1 : f;
354
+ }
355
+
356
+ // src/vedic/sidereal.ts
357
+ var SIDEREAL = /* @__PURE__ */ new WeakSet();
358
+ function make(value) {
359
+ const frozen = Object.freeze(value);
360
+ SIDEREAL.add(frozen);
361
+ return frozen;
362
+ }
363
+ function requireSidereal(value) {
364
+ if (typeof value !== "object" || value === null || !SIDEREAL.has(value)) {
365
+ throw new RangeError("Expected a SiderealLongitude from siderealLongitude or declareSiderealLongitude.");
366
+ }
367
+ return value;
368
+ }
369
+ function wrap360(value) {
370
+ if (value >= 0 && value < 360) return value;
371
+ let r = value % 360;
372
+ if (r < 0) r += 360;
373
+ return r === 360 || r === 0 ? 0 : r;
374
+ }
375
+ function finiteLongitude(value, label) {
376
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError(`${label} must be a finite number.`);
377
+ return wrap360(value);
378
+ }
379
+ function siderealLongitude(tropicalLongitude, ayanamsa2) {
380
+ if (!isAyanamsaValue(ayanamsa2)) throw new RangeError("ayanamsa must be a value returned by ayanamsa().");
381
+ const tropical = finiteLongitude(tropicalLongitude, "tropicalLongitude");
382
+ return make({
383
+ frame: "sidereal",
384
+ lon: wrap360(tropical - ayanamsa2.true),
385
+ ayanamsa: ayanamsa2.ayanamsa,
386
+ trueAyanamsa: ayanamsa2.true,
387
+ tropical,
388
+ utc: utcInstantOf(ayanamsa2)
389
+ });
390
+ }
391
+ function declareSiderealLongitude(longitude, declaration) {
392
+ const read = readOptions(declaration, ["ayanamsa", "at"], "declaration");
393
+ const label = read.ayanamsa;
394
+ if (typeof label !== "string" || !label || label.length > 80 || label.trim() !== label || /[\u0000-\u001f\u007f]/.test(label)) {
395
+ throw new RangeError("declaration.ayanamsa must be a nonempty trimmed label of at most 80 characters.");
396
+ }
397
+ const at = read.at;
398
+ return make({
399
+ frame: "sidereal",
400
+ lon: finiteLongitude(longitude, "longitude"),
401
+ ayanamsa: label,
402
+ trueAyanamsa: null,
403
+ tropical: null,
404
+ utc: at === void 0 ? null : dateFrom(at, "declaration.at").toISOString()
405
+ });
406
+ }
407
+ function wholeSignCusps(ascendant) {
408
+ const first = Math.floor(ticksOf(ascendant) / SIGN_TICKS);
409
+ return Array.from({ length: 12 }, (_, k) => (first + k) % 12 * 30);
410
+ }
411
+ function siderealChartOf(chart, definition) {
412
+ const input = chart.input;
413
+ const value = ayanamsa(definition, input.utc, {
414
+ ...input.deltaT === void 0 ? {} : { deltaT: input.deltaT },
415
+ ...input.timeScale === void 0 ? {} : { timeScale: input.timeScale }
416
+ });
417
+ const of = (lon) => siderealLongitude(lon, value);
418
+ const bodies = chart.bodies.map((row) => {
419
+ const sidereal = of(row.lon);
420
+ SIDEREAL.delete(sidereal);
421
+ return make({ ...sidereal, body: row.body });
422
+ });
423
+ const ascendant = chart.angles ? of(chart.angles.asc) : null;
424
+ const houseSystem = chart.houses ? chart.houses.system : null;
425
+ let cusps = null;
426
+ if (chart.houses && houseSystem === "whole" && ascendant) {
427
+ cusps = wholeSignCusps(ascendant.lon).map(
428
+ (lon) => make({
429
+ frame: "sidereal",
430
+ lon,
431
+ ayanamsa: value.ayanamsa,
432
+ trueAyanamsa: value.true,
433
+ tropical: wrap360(lon + value.true),
434
+ utc: utcInstantOf(value)
435
+ })
436
+ );
437
+ } else if (chart.houses) {
438
+ cusps = chart.houses.cusps.map(of);
439
+ }
440
+ const flags = [...chart.flags];
441
+ for (const flag of value.flags) if (!flags.includes(flag)) flags.push(flag);
442
+ return Object.freeze({
443
+ ayanamsa: value.ayanamsa,
444
+ ayanamsaValue: value,
445
+ bodies: Object.freeze(bodies),
446
+ ascendant,
447
+ midheaven: chart.angles ? of(chart.angles.mc) : null,
448
+ houseSystem,
449
+ cusps: cusps && Object.freeze(cusps),
450
+ flags: Object.freeze(flags)
451
+ });
452
+ }
453
+
454
+ export {
455
+ AYANAMSAS,
456
+ isUserAyanamsaName,
457
+ userAyanamsa,
458
+ definitionOf,
459
+ ayanamsaAt,
460
+ outsideSpanEpoch,
461
+ ayanamsa,
462
+ TICKS_PER_DEGREE,
463
+ SIGN_TICKS,
464
+ NAKSHATRA_TICKS,
465
+ PADA_TICKS,
466
+ YEAR_TICKS,
467
+ ticksOf,
468
+ requireSidereal,
469
+ wrap360,
470
+ siderealLongitude,
471
+ declareSiderealLongitude,
472
+ wholeSignCusps,
473
+ siderealChartOf
474
+ };
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-PFGUCNOK.js";
10
10
 
11
11
  // src/geo/calendar.ts
12
- var GREGORIAN_ADOPTION_SOURCES = Object.freeze({
12
+ var GREGORIAN_ADOPTION_SOURCES = /* @__PURE__ */ Object.freeze({
13
13
  tzdb: "IANA tzdata 2025c, file calendars, quoting H. Grotefend, Taschenbuch der Zeitrechnung, ed. O. Grotefend (1941), pp. 26-28",
14
14
  "grotefend-1891": "H. Grotefend, Zeitrechnung des deutschen Mittelalters und der Neuzeit, vol. 1 (1891), pp. 133-134",
15
15
  "grotefend-1898": "H. Grotefend, Taschenbuch der Zeitrechnung des deutschen Mittelalters und der Neuzeit (1898), pp. 23-24"
@@ -33,8 +33,8 @@ PT|Portugal|-|1582-10-15|t18|
33
33
  RU|Russia|Soviet Russia|1918-02-14|t|Grotefend 1891, 1898: still Julian. Duchy of Prussia, now partly Kaliningrad, 1612-09-02 (Grotefend 1898: 1612-09-01).
34
34
  SE|Sweden|-|1753-03-01|t18|From 1 March 1700 to 30 February 1712 Swedish dates are one day ahead of the Julian (Grotefend 1898).`;
35
35
  var SOURCE_KEYS = { t: "tzdb", 1: "grotefend-1891", 8: "grotefend-1898" };
36
- var GREGORIAN_ADOPTION = Object.freeze(
37
- ROWS.split("\n").map((line) => {
36
+ var GREGORIAN_ADOPTION = /* @__PURE__ */ Object.freeze(
37
+ /* @__PURE__ */ ROWS.split("\n").map((line) => {
38
38
  const [code, country, region, firstGregorian, sources, note] = line.split("|");
39
39
  const day = julianDayNumber(parseCalendarDate(firstGregorian, "gregorian"), "gregorian");
40
40
  return Object.freeze({
@@ -52,15 +52,21 @@ function gregorianAdoption(country) {
52
52
  return GREGORIAN_ADOPTION.find((row) => row.code === country || row.country === country);
53
53
  }
54
54
  function calendarNote(gregorianDate, calendar, country) {
55
+ if (!parseCalendarDate(gregorianDate, "gregorian")) throw new RangeError("gregorianDate must be a valid Gregorian date, YYYY-MM-DD.");
56
+ if (calendar !== "gregorian" && calendar !== "julian") throw new RangeError('calendar must be "gregorian" or "julian".');
57
+ if (typeof country !== "string" || !country.trim()) throw new RangeError("country must be a nonempty string.");
58
+ return noteFor(gregorianDate, calendar, country);
59
+ }
60
+ function noteFor(gregorianDate, calendar, country) {
55
61
  const adoption = gregorianAdoption(country);
56
62
  if (!adoption) return null;
57
63
  const julian = calendar === "julian";
58
- if (gregorianDate >= adoption.firstGregorian) return julian ? { kind: "new-style", adoption } : null;
64
+ if (gregorianDate.length > 10 || gregorianDate >= adoption.firstGregorian) return julian ? { kind: "new-style", adoption } : null;
59
65
  return julian ? null : { kind: "old-style", adoption };
60
66
  }
61
67
 
62
68
  // src/tzdb/tzdb-2025c.ts
63
- var TZDB = Object.freeze({
69
+ var TZDB = /* @__PURE__ */ Object.freeze({
64
70
  version: "2025c",
65
71
  sha256: "4aa79e4effee53fc4029ffe5f6ebe97937282ebcdf386d5d2da91ce84142f957",
66
72
  form: "main+backzone"
@@ -318,7 +324,7 @@ function resolveLocalToUtc(date, time, timeZone, options) {
318
324
  wall.setUTCFullYear(civil.year, civil.month - 1, civil.day);
319
325
  const wallMs = wall.setUTCHours(Number(hhmm[1]), Number(hhmm[2]));
320
326
  const loaded = FIXED_ZONE.test(timeZone) ? null : loadedHistory(timeZone);
321
- if (loaded === void 0 && wallMs < DAY) throw notLoaded();
327
+ if (loaded === void 0 && wallMs < DAY) throw new ZoneHistoryNotLoadedError();
322
328
  const history = loaded ?? null;
323
329
  const zoneAt = zoneClock(timeZone, history);
324
330
  const place = longitude !== void 0 && history ? birthplaceClock(history, wallMs, longitude, zoneAt) : null;
@@ -375,7 +381,7 @@ function resolveLocalToUtc(date, time, timeZone, options) {
375
381
  localMeanTime,
376
382
  zone,
377
383
  intlOffsetMinutes: shipped ? offsetAt(timeZone, chosen.utcMs) : null,
378
- calendarNote: country === void 0 ? null : calendarNote(gregorianDate, calendar, country),
384
+ calendarNote: country === void 0 ? null : noteFor(gregorianDate, calendar, country),
379
385
  localResolution: {
380
386
  date: gregorianDate,
381
387
  time,
@@ -406,12 +412,15 @@ function zoneOffsetAt(timeZone, utcMilliseconds) {
406
412
  validateInstant(utcMilliseconds);
407
413
  offsetFormatter(timeZone);
408
414
  const loaded = FIXED_ZONE.test(timeZone) ? null : loadedHistory(timeZone);
409
- if (loaded === void 0 && utcMilliseconds < 0) throw notLoaded();
415
+ if (loaded === void 0 && utcMilliseconds < 0) throw new ZoneHistoryNotLoadedError();
410
416
  return zoneClock(timeZone, loaded ?? null)(utcMilliseconds) / 60;
411
417
  }
412
- function notLoaded() {
413
- return new Error("The zone's history before 1970 is not loaded: await prepareLocalTime(date, timeZone) first.");
414
- }
418
+ var ZoneHistoryNotLoadedError = class extends Error {
419
+ name = "ZoneHistoryNotLoadedError";
420
+ constructor() {
421
+ super("The zone's history before 1970 is not loaded: await prepareLocalTime(date, timeZone) first.");
422
+ }
423
+ };
415
424
  var LOCAL_BIRTH_KEYS = [
416
425
  "date",
417
426
  "time",
@@ -468,6 +477,7 @@ export {
468
477
  resolveLocalToUtc,
469
478
  prepareLocalTime,
470
479
  zoneOffsetAt,
480
+ ZoneHistoryNotLoadedError,
471
481
  resolveLocalBirth,
472
482
  resolveBirth
473
483
  };
@@ -1,4 +1,4 @@
1
- import { B as BodyName } from './types-B4MCoCCS.js';
1
+ import { B as BodyName } from './types-B-yb_tGL.js';
2
2
  import './deltat.js';
3
3
 
4
4
  /**
@@ -19,15 +19,16 @@ interface LongitudeCrossing {
19
19
  retrograde: boolean;
20
20
  }
21
21
  /** A longitude source: the ecliptic longitude of `body` at `date`, in degrees. */
22
- type BodyLongitudeAt = (body: BodyName, date: Date) => number;
22
+ type BodyLongitudeAt<B extends string = BodyName> = (body: B, date: Date) => number;
23
+ /** A key not named here is refused with a RangeError. */
23
24
  interface CrossingSearchOptions {
24
25
  /** Days between coarse samples. Defaults to 5. */
25
- stepDays?: number;
26
+ readonly stepDays?: number | undefined;
26
27
  /**
27
28
  * The most longitude evaluations the search may make, refinements
28
29
  * included: a positive integer, or `Infinity`. Defaults to no limit.
29
30
  */
30
- maxSamples?: number;
31
+ readonly maxSamples?: number | undefined;
31
32
  }
32
33
  /**
33
34
  * A search either completes, with every crossing it found, or is refused
@@ -77,7 +78,7 @@ type CrossingSearchResult = {
77
78
  * {@link searchLongitudeCrossingsWith} bounds it. Throws RangeError for an
78
79
  * invalid window, target or step, and for a non-finite longitude.
79
80
  */
80
- declare function findLongitudeCrossingsWith(longitudeAt: BodyLongitudeAt, body: BodyName, targetLongitude: number, from: Date, to: Date, stepDays?: number): LongitudeCrossing[];
81
+ declare function findLongitudeCrossingsWith<B extends string = BodyName>(longitudeAt: BodyLongitudeAt<B>, body: B, targetLongitude: number, from: Date, to: Date, stepDays?: number): LongitudeCrossing[];
81
82
  /**
82
83
  * The search {@link findLongitudeCrossingsWith} makes, with the step as
83
84
  * `options.stepDays` (default 5), under an optional budget of longitude
@@ -86,6 +87,6 @@ declare function findLongitudeCrossingsWith(longitudeAt: BodyLongitudeAt, body:
86
87
  * refinement would pass it; either way it returns a typed refusal with no
87
88
  * crossings rather than throwing. Invalid input still throws RangeError.
88
89
  */
89
- declare function searchLongitudeCrossingsWith(longitudeAt: BodyLongitudeAt, body: BodyName, targetLongitude: number, from: Date, to: Date, options?: CrossingSearchOptions): CrossingSearchResult;
90
+ declare function searchLongitudeCrossingsWith<B extends string = BodyName>(longitudeAt: BodyLongitudeAt<B>, body: B, targetLongitude: number, from: Date, to: Date, options?: CrossingSearchOptions): CrossingSearchResult;
90
91
 
91
- export { type BodyLongitudeAt, type CrossingSearchOptions, type CrossingSearchResult, type LongitudeCrossing, findLongitudeCrossingsWith, searchLongitudeCrossingsWith };
92
+ export { type BodyLongitudeAt, BodyName, type CrossingSearchOptions, type CrossingSearchResult, type LongitudeCrossing, findLongitudeCrossingsWith, searchLongitudeCrossingsWith };
package/dist/crossings.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  findLongitudeCrossingsWith,
3
3
  searchLongitudeCrossingsWith
4
- } from "./chunk-AECKV73C.js";
4
+ } from "./chunk-TSS2SZWQ.js";
5
5
  export {
6
6
  findLongitudeCrossingsWith,
7
7
  searchLongitudeCrossingsWith
package/dist/deltat.d.ts CHANGED
@@ -30,6 +30,14 @@
30
30
  * a calibrated 1-σ. Sources, licences and every number:
31
31
  * docs/platform/evidence/deltat-2026-09-25/ in the Zodiacs site repository.
32
32
  */
33
+ /**
34
+ * Where a ΔT came from: one of the model's segments above; "pinned", a
35
+ * caller's pin; or, on the IERS basis ("iers-utc/1", docs/time.md), the source
36
+ * of its UT1 − UTC, "observed" or "predicted". "fallback" is the IERS basis
37
+ * with UT1 − UTC taken as 0 ± 0.9 s past the table's ends, which rc.15's first
38
+ * cut recorded and receipts from it carry; later releases do not give it, and
39
+ * keep it so those records stay readable.
40
+ */
33
41
  type DeltaTSegment = "long-term" | "reconstructed" | "observed" | "predicted" | "extrapolated" | "pinned" | "fallback";
34
42
  /** ΔT with its band and provenance: this model, "iers-utc/1" (docs/time.md), or a caller's pin, whose sigma, table and tableDigest are null. */
35
43
  interface DeltaT {
@@ -43,7 +51,14 @@ interface DeltaT {
43
51
  tableDigest: string | null;
44
52
  segment: DeltaTSegment;
45
53
  }
46
- /** The part of the model refreshed from IERS. It changes only with an engine release. */
54
+ /**
55
+ * The part of the model refreshed from IERS. It changes only with an engine
56
+ * release. Its shape is the model's, "zodiacs-deltat/1": yearly knots to the
57
+ * last observed day, then four to the last predicted one, with `from` a year
58
+ * and the two ends MJDs. A refresh keeps that shape; a model that needs
59
+ * another would be a new model, with a new name and its own export beside
60
+ * this one. Each ΔT names the table it came from (`table`, `tableDigest`).
61
+ */
47
62
  interface DeltaTTable {
48
63
  /** Date of the last observed IERS day (YYYY-MM-DD). */
49
64
  readonly version: string;
@@ -65,9 +80,19 @@ interface DeltaTTable {
65
80
  declare const DELTA_T_MODEL = "zodiacs-deltat/1";
66
81
  /** This release's table: IERS files of 2026-09-24. Frozen. */
67
82
  declare const DELTA_T_TABLE: DeltaTTable;
68
- /** ΔT at astronomy-engine's UT (days since J2000.0), with its band and the part of the model that answered. */
83
+ /**
84
+ * ΔT of the model alone at astronomy-engine's UT, days since 2000-01-01T12:00
85
+ * on UT1 (not epoch milliseconds), with its band and the part of the model
86
+ * that answered. A chart from 1972 to the end of the IERS UT1 table uses IERS
87
+ * instead (`iers-utc/1`; docs/time.md), so its ΔT can differ from this.
88
+ * RangeError for a non-finite input.
89
+ */
69
90
  declare function deltaTAt(ut: number): DeltaT;
70
- /** For astronomy-engine's SetDeltaTFunction: UT days in, seconds out. Allocation-free. */
91
+ /**
92
+ * For astronomy-engine's SetDeltaTFunction: UT days since 2000-01-01T12:00
93
+ * in, the model's seconds out. Allocation-free. RangeError for a non-finite
94
+ * input.
95
+ */
71
96
  declare function deltaT(ut: number): number;
72
97
 
73
98
  export { DELTA_T_MODEL, DELTA_T_TABLE, type DeltaT, type DeltaTSegment, type DeltaTTable, deltaT, deltaTAt };
package/dist/deltat.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DELTA_T_TABLE,
4
4
  deltaT,
5
5
  deltaTAt
6
- } from "./chunk-ONBZ4HK7.js";
6
+ } from "./chunk-BHJXUY67.js";
7
7
  export {
8
8
  DELTA_T_MODEL,
9
9
  DELTA_T_TABLE,