UNPKG

sweph-wasm

Version:

High-precision Swiss Ephemeris WebAssembly bindings for TypeScript — comprehensive astronomical calculations including planetary positions, house systems, eclipses, fixed stars, and astrological computations with modern JS/TS support.

3 lines (2 loc) 35.9 kB
"use strict";var e="undefined"!=typeof document?document.currentScript:null;function t(e,t,s){const _=e.slice(0,t);for(;_.length<t;)_.push(s??null);return _}function s(e){return e<0?`${Math.abs(e)} BC`:0===e?"1 BC":`${e} AD`}const _=function(){const e=[];let t=-5401;const _=[{prefix:"pl",category:"SE Planetary Ephemeris"},{prefix:"mo",category:"SE Moon Ephemeris"},{prefix:"as",category:"SE Asteroid Ephemeris"}];for(;t<5400;){let r=t+599;t<=0&&r>=0&&(t+=1,r+=1);const a=String(Math.floor(Math.abs(t)/100)).padStart(2,"0"),i=r<0?"m":"_";for(const E of _)e.push({name:`se${E.prefix}${i}${a}.se1`,desc:`${s(t)} - ${s(r)}`,category:E.category});t+=600}return e.sort((e,t)=>{const s=e.category.localeCompare(t.category);return 0!==s?s:e.name.localeCompare(t.name)}),e}().concat([{name:"de200.eph",desc:"1599 AD - 2169 AD",category:"JPL Ephemeris"},{name:"de403.eph",desc:"3000 BC - 3000 AD",category:"JPL Ephemeris"},{name:"de404.eph",desc:"3000 BC - 3000 AD",category:"JPL Ephemeris"},{name:"de405.eph",desc:"1600 AD - 2200 AD",category:"JPL Ephemeris"},{name:"de406.eph",desc:"3000 BC - 3000 AD",category:"JPL Ephemeris"},{name:"de431.eph",desc:"13201 BC - 17191 AD",category:"JPL Ephemeris"}],[{name:"fixstars.cat",desc:"Static",category:"Fixed Stars Catalog"},{name:"sefstars.txt",desc:"Static",category:"Fixed Stars Names"},{name:"seasnam.txt",desc:"Static",category:"Asteroid Names"},{name:"seorbel.txt",desc:"Epoch-based (varies)",category:"Orbital Elements (Asteroids)"}]);class r extends Error{flag;error;constructor(e,t){super(e),this.error=e,this.name="SweError",this.flag=t,Object.setPrototypeOf(this,r.prototype)}}var a=Object.defineProperty,i=(e,t,s)=>((e,t,s)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);const E={i8:Int8Array.BYTES_PER_ELEMENT,i16:Int16Array.BYTES_PER_ELEMENT,i32:Int32Array.BYTES_PER_ELEMENT,i64:BigInt64Array.BYTES_PER_ELEMENT,float:Float32Array.BYTES_PER_ELEMENT,double:Float64Array.BYTES_PER_ELEMENT};class o{constructor(e,t){i(this,"_ptr",0),i(this,"wasm"),this.wasm=e,this._ptr=t}get ptr(){return this._ptr}get isValid(){return 0!==this._ptr}validatePointer(){if(!this.isValid)throw new Error("Cannot operate on freed or invalid pointer")}free(){0!==this._ptr&&(this.wasm._free(this._ptr),this._ptr=0)}readAndFree(){this.validatePointer();const e=this.read();return this.free(),e}toString(){return`${this.constructor.name}(ptr=${this._ptr}, valid=${this.isValid})`}}class h extends o{constructor(e,t,s,_){super(e,_??e._malloc(s*E[t])),i(this,"type"),i(this,"length"),this.type=t,this.length=s}static from(e,t,s,_=[]){const r=h.alloc(e,t,s);return r.write(_),r}static alloc(e,t,s){return new h(e,t,s)}add(e,t){if(this.validatePointer(),!(e>=0&&e<this.length))throw new Error(`Out-of-bounds access: tried to write at index ${e} in array of length ${this.length}`);this.wasm.setValue(this.ptr+e*E[this.type],t,this.type)}read(){this.validatePointer();const e=E[this.type];return function(e,t){const s=e.slice(0,t);for(;s.length<t;)s.push(null);return s}(Array.from({length:this.length},(t,s)=>this.wasm.getValue(this.ptr+s*e,this.type)),this.length)}write(e){if(this.validatePointer(),e.length>this.length)throw new Error(`Array length mismatch. Expected ${this.length}, got ${e.length}`);e.forEach((e,t)=>this.add(t,e))}}class n{static boolToC(e){return e?1:0}static boolFromC(e){return!!e}static charToC(e){if("string"!=typeof e||1!==e.length)throw new Error("Input must be exactly one character");const t=e.charCodeAt(0);if(t<0||t>255)throw new Error(`Character '${e}' is outside ASCII range (0-255)`);return t}static charFromC(e){if(!Number.isInteger(e)||e<0||e>255)throw new Error(`Invalid ASCII code: ${e}. Must be 0-255`);return String.fromCharCode(e)}static validateNumberType(e){if(!(e in E))throw new Error(`Unsupported number type: ${e}`);return!0}static getTypeSize(e){return this.validateNumberType(e),E[e]}}class S extends o{constructor(){super({},0)}read(){throw new Error("Cannot read from a NullPointer")}}class l extends o{constructor(e,t,s){super(e,s??e._malloc(E[t])),i(this,"type"),this.type=t}static from(e,t,s){const _=l.alloc(e,t);return _.write(s),_}write(e){this.validatePointer(),this.add(e)}static alloc(e,t){return new l(e,t)}add(e){this.validatePointer(),this.wasm.setValue(this.ptr,e,this.type)}read(){return this.validatePointer(),this.wasm.getValue(this.ptr,this.type)}}class A extends o{constructor(e,t,s){super(e,s??e._malloc(t*E.i8)),i(this,"length"),this.length=t}static from(e,t,s=""){const _=A.alloc(e,t+1);return _.write(s),_}static alloc(e,t){return new A(e,t)}write(e){if(this.validatePointer(),e.length+1>this.length)throw new Error("String length exceeds buffer size");this.wasm.stringToUTF8(e,this.ptr,this.length)}read(){return this.validatePointer(),this.wasm.UTF8ToString(this.ptr,this.length)}}class w{TRUE=1;FALSE=0;OK=0;ERR=-1;NOT_AVAILABLE=-2;BEYOND_EPH_LIMITS=-3;ODEGREE_STRING="°";HUGE=17e307;M_PI=Math.PI;AS_MAXCH=256;RADTODEG=180/this.M_PI;DEGTORAD=this.M_PI/180;DEG=36e4;DEG7_30=27e5;DEG15=15*this.DEG;DEG24=24*this.DEG;DEG30=30*this.DEG;DEG60=60*this.DEG;DEG90=90*this.DEG;DEG120=120*this.DEG;DEG150=150*this.DEG;DEG180=180*this.DEG;DEG270=270*this.DEG;DEG360=360*this.DEG;CSTORAD=this.DEGTORAD/36e4;RADTOCS=36e4*this.RADTODEG;CS2DEG=1/36e4;BFILE_R_ACCESS="rb";BFILE_RW_ACCESS="r+b";BFILE_W_CREATE="wb";BFILE_A_ACCESS="a+b";PATH_SEPARATOR=";";OPEN_MODE="0666";FILE_R_ACCESS="rt";FILE_RW_ACCESS="r+t";FILE_W_CREATE="wt";FILE_A_ACCESS="a+t";DIR_GLUE="\\";SE_AUNIT_TO_KM=149597870.7;SE_AUNIT_TO_LIGHTYEAR=1/63241.07708427;SE_AUNIT_TO_PARSEC=1/206264.8062471;SE_JUL_CAL=0;SE_GREG_CAL=1;SE_ECL_NUT=-1;SE_SUN=0;SE_MOON=1;SE_MERCURY=2;SE_VENUS=3;SE_MARS=4;SE_JUPITER=5;SE_SATURN=6;SE_URANUS=7;SE_NEPTUNE=8;SE_PLUTO=9;SE_MEAN_NODE=10;SE_TRUE_NODE=11;SE_MEAN_APOG=12;SE_OSCU_APOG=13;SE_EARTH=14;SE_CHIRON=15;SE_PHOLUS=16;SE_CERES=17;SE_PALLAS=18;SE_JUNO=19;SE_VESTA=20;SE_INTP_APOG=21;SE_INTP_PERG=22;SE_NPLANETS=23;SE_PLMOON_OFFSET=9e3;SE_AST_OFFSET=1e4;SE_VARUNA=this.SE_AST_OFFSET+2e4;SE_FICT_OFFSET=40;SE_FICT_OFFSET_1=39;SE_FICT_MAX=999;SE_NFICT_ELEM=15;SE_COMET_OFFSET=1e3;SE_NALL_NAT_POINTS=this.SE_NPLANETS+this.SE_NFICT_ELEM;SE_CUPIDO=40;SE_HADES=41;SE_ZEUS=42;SE_KRONOS=43;SE_APOLLON=44;SE_ADMETOS=45;SE_VULKANUS=46;SE_POSEIDON=47;SE_ISIS=48;SE_NIBIRU=49;SE_HARRINGTON=50;SE_NEPTUNE_LEVERRIER=51;SE_NEPTUNE_ADAMS=52;SE_PLUTO_LOWELL=53;SE_PLUTO_PICKERING=54;SE_VULCAN=55;SE_WHITE_MOON=56;SE_PROSERPINA=57;SE_WALDEMATH=58;SE_FIXSTAR=-10;SE_ASC=0;SE_MC=1;SE_ARMC=2;SE_VERTEX=3;SE_EQUASC=4;SE_COASC1=5;SE_COASC2=6;SE_POLASC=7;SE_NASCMC=8;SEFLG_JPLEPH=1;SEFLG_SWIEPH=2;SEFLG_MOSEPH=4;SEFLG_HELCTR=8;SEFLG_TRUEPOS=16;SEFLG_J2000=32;SEFLG_NONUT=64;SEFLG_SPEED3=128;SEFLG_SPEED=256;SEFLG_NOGDEFL=512;SEFLG_NOABERR=1024;SEFLG_ASTROMETRIC=this.SEFLG_NOABERR|this.SEFLG_NOGDEFL;SEFLG_EQUATORIAL=2048;SEFLG_XYZ=4096;SEFLG_RADIANS=8192;SEFLG_BARYCTR=16384;SEFLG_TOPOCTR=32768;SEFLG_ORBEL_AA=this.SEFLG_TOPOCTR;SEFLG_TROPICAL=0;SEFLG_SIDEREAL=65536;SEFLG_ICRS=131072;SEFLG_DPSIDEPS_1980=262144;SEFLG_JPLHOR=this.SEFLG_DPSIDEPS_1980;SEFLG_JPLHOR_APPROX=524288;SEFLG_CENTER_BODY=1048576;SEFLG_TEST_PLMOON=2097152|this.SEFLG_J2000|this.SEFLG_ICRS|this.SEFLG_HELCTR|this.SEFLG_TRUEPOS;SE_SIDBITS=256;SE_SIDBIT_ECL_T0=256;SE_SIDBIT_SSY_PLANE=512;SE_SIDBIT_USER_UT=1024;SE_SIDBIT_ECL_DATE=2048;SE_SIDBIT_NO_PREC_OFFSET=4096;SE_SIDBIT_PREC_ORIG=8192;SE_SIDM_FAGAN_BRADLEY=0;SE_SIDM_LAHIRI=1;SE_SIDM_DELUCE=2;SE_SIDM_RAMAN=3;SE_SIDM_USHASHASHI=4;SE_SIDM_KRISHNAMURTI=5;SE_SIDM_DJWHAL_KHUL=6;SE_SIDM_YUKTESHWAR=7;SE_SIDM_JN_BHASIN=8;SE_SIDM_BABYL_KUGLER1=9;SE_SIDM_BABYL_KUGLER2=10;SE_SIDM_BABYL_KUGLER3=11;SE_SIDM_BABYL_HUBER=12;SE_SIDM_BABYL_ETPSC=13;SE_SIDM_ALDEBARAN_15TAU=14;SE_SIDM_HIPPARCHOS=15;SE_SIDM_SASSANIAN=16;SE_SIDM_GALCENT_0SAG=17;SE_SIDM_J2000=18;SE_SIDM_J1900=19;SE_SIDM_B1950=20;SE_SIDM_SURYASIDDHANTA=21;SE_SIDM_SURYASIDDHANTA_MSUN=22;SE_SIDM_ARYABHATA=23;SE_SIDM_ARYABHATA_MSUN=24;SE_SIDM_SS_REVATI=25;SE_SIDM_SS_CITRA=26;SE_SIDM_TRUE_CITRA=27;SE_SIDM_TRUE_REVATI=28;SE_SIDM_TRUE_PUSHYA=29;SE_SIDM_GALCENT_RGILBRAND=30;SE_SIDM_GALEQU_IAU1958=31;SE_SIDM_GALEQU_TRUE=32;SE_SIDM_GALEQU_MULA=33;SE_SIDM_GALALIGN_MARDYKS=34;SE_SIDM_TRUE_MULA=35;SE_SIDM_GALCENT_MULA_WILHELM=36;SE_SIDM_ARYABHATA_522=37;SE_SIDM_BABYL_BRITTON=38;SE_SIDM_TRUE_SHEORAN=39;SE_SIDM_GALCENT_COCHRANE=40;SE_SIDM_GALEQU_FIORENZA=41;SE_SIDM_VALENS_MOON=42;SE_SIDM_LAHIRI_1940=43;SE_SIDM_LAHIRI_VP285=44;SE_SIDM_KRISHNAMURTI_VP291=45;SE_SIDM_LAHIRI_ICRC=46;SE_SIDM_USER=255;SE_NSIDM_PREDEF=47;SE_NODBIT_MEAN=1;SE_NODBIT_OSCU=2;SE_NODBIT_OSCU_BAR=4;SE_NODBIT_FOPOINT=256;SEFLG_DEFAULTEPH=this.SEFLG_SWIEPH;SE_MAX_STNAME=256;SE_ECL_CENTRAL=1;SE_ECL_NONCENTRAL=2;SE_ECL_TOTAL=4;SE_ECL_ANNULAR=8;SE_ECL_PARTIAL=16;SE_ECL_ANNULAR_TOTAL=32;SE_ECL_HYBRID=32;SE_ECL_PENUMBRAL=64;SE_ECL_ALLTYPES_SOLAR=this.SE_ECL_CENTRAL|this.SE_ECL_NONCENTRAL|this.SE_ECL_TOTAL|this.SE_ECL_ANNULAR|this.SE_ECL_PARTIAL|this.SE_ECL_ANNULAR_TOTAL;SE_ECL_ALLTYPES_LUNAR=this.SE_ECL_TOTAL|this.SE_ECL_PARTIAL|this.SE_ECL_PENUMBRAL;SE_ECL_VISIBLE=128;SE_ECL_MAX_VISIBLE=256;SE_ECL_1ST_VISIBLE=512;SE_ECL_PARTBEG_VISIBLE=512;SE_ECL_2ND_VISIBLE=1024;SE_ECL_TOTBEG_VISIBLE=1024;SE_ECL_3RD_VISIBLE=2048;SE_ECL_TOTEND_VISIBLE=2048;SE_ECL_4TH_VISIBLE=4096;SE_ECL_PARTEND_VISIBLE=4096;SE_ECL_PENUMBBEG_VISIBLE=8192;SE_ECL_PENUMBEND_VISIBLE=16384;SE_ECL_OCC_BEG_DAYLIGHT=8192;SE_ECL_OCC_END_DAYLIGHT=16384;SE_ECL_ONE_TRY=32768;SE_CALC_RISE=1;SE_CALC_SET=2;SE_CALC_MTRANSIT=4;SE_CALC_ITRANSIT=8;SE_BIT_DISC_CENTER=256;SE_BIT_DISC_BOTTOM=8192;SE_BIT_GEOCTR_NO_ECL_LAT=128;SE_BIT_NO_REFRACTION=512;SE_BIT_CIVIL_TWILIGHT=1024;SE_BIT_NAUTIC_TWILIGHT=2048;SE_BIT_ASTRO_TWILIGHT=4096;SE_BIT_FIXED_DISC_SIZE=16384;SE_BIT_FORCE_SLOW_METHOD=32768;SE_BIT_HINDU_RISING=this.SE_BIT_DISC_CENTER|this.SE_BIT_NO_REFRACTION|this.SE_BIT_GEOCTR_NO_ECL_LAT;SE_ECL2HOR=0;SE_EQU2HOR=1;SE_HOR2ECL=0;SE_HOR2EQU=1;SE_TRUE_TO_APP=0;SE_APP_TO_TRUE=1;SE_DE_NUMBER=431;SE_FNAME_DE200="de200.eph";SE_FNAME_DE403="de403.eph";SE_FNAME_DE404="de404.eph";SE_FNAME_DE405="de405.eph";SE_FNAME_DE406="de406.eph";SE_FNAME_DE431="de431.eph";SE_FNAME_DFT=this.SE_FNAME_DE431;SE_FNAME_DFT2=this.SE_FNAME_DE406;SE_STARFILE_OLD="fixstars.cat";SE_STARFILE="sefstars.txt";SE_ASTNAMFILE="seasnam.txt";SE_FICTFILE="seorbel.txt";SE_SPLIT_DEG_ROUND_SEC=1;SE_SPLIT_DEG_ROUND_MIN=2;SE_SPLIT_DEG_ROUND_DEG=4;SE_SPLIT_DEG_ZODIACAL=8;SE_SPLIT_DEG_NAKSHATRA=1024;SE_SPLIT_DEG_KEEP_SIGN=16;SE_SPLIT_DEG_KEEP_DEG=32;SE_HELIACAL_RISING=1;SE_HELIACAL_SETTING=2;SE_MORNING_FIRST=this.SE_HELIACAL_RISING;SE_EVENING_LAST=this.SE_HELIACAL_SETTING;SE_EVENING_FIRST=3;SE_MORNING_LAST=4;SE_ACRONYCHAL_RISING=5;SE_ACRONYCHAL_SETTING=6;SE_COSMICAL_SETTING=this.SE_ACRONYCHAL_SETTING;SE_HELFLAG_LONG_SEARCH=128;SE_HELFLAG_HIGH_PRECISION=256;SE_HELFLAG_OPTICAL_PARAMS=512;SE_HELFLAG_NO_DETAILS=1024;SE_HELFLAG_SEARCH_1_PERIOD=2048;SE_HELFLAG_VISLIM_DARK=4096;SE_HELFLAG_VISLIM_NOMOON=8192;SE_HELFLAG_VISLIM_PHOTOPIC=16384;SE_HELFLAG_VISLIM_SCOTOPIC=32768;SE_HELFLAG_AV=65536;SE_HELFLAG_AVKIND_VR=65536;SE_HELFLAG_AVKIND_PTO=1<<17;SE_HELFLAG_AVKIND_MIN7=1<<18;SE_HELFLAG_AVKIND_MIN9=1<<19;SE_HELFLAG_AVKIND=this.SE_HELFLAG_AVKIND_VR|this.SE_HELFLAG_AVKIND_PTO|this.SE_HELFLAG_AVKIND_MIN7|this.SE_HELFLAG_AVKIND_MIN9;TJD_INVALID=99999999;SIMULATE_VICTORVB=1;SE_HELIACAL_LONG_SEARCH=128;SE_HELIACAL_HIGH_PRECISION=256;SE_HELIACAL_OPTICAL_PARAMS=512;SE_HELIACAL_NO_DETAILS=1024;SE_HELIACAL_SEARCH_1_PERIOD=2048;SE_HELIACAL_VISLIM_DARK=4096;SE_HELIACAL_VISLIM_NOMOON=8192;SE_HELIACAL_VISLIM_PHOTOPIC=16384;SE_HELIACAL_AVKIND_VR=32768;SE_HELIACAL_AVKIND_PTO=65536;SE_HELIACAL_AVKIND_MIN7=1<<17;SE_HELIACAL_AVKIND_MIN9=1<<18;SE_HELIACAL_AVKIND=this.SE_HELFLAG_AVKIND_VR|this.SE_HELFLAG_AVKIND_PTO|this.SE_HELFLAG_AVKIND_MIN7|this.SE_HELFLAG_AVKIND_MIN9;SE_PHOTOPIC_FLAG=0;SE_SCOTOPIC_FLAG=1;SE_MIXEDOPIC_FLAG=2;SE_TIDAL_DE200=-23.8946;SE_TIDAL_DE403=-25.58;SE_TIDAL_DE404=-25.58;SE_TIDAL_DE405=-25.826;SE_TIDAL_DE406=-25.826;SE_TIDAL_DE421=-25.85;SE_TIDAL_DE422=-25.85;SE_TIDAL_DE430=-25.82;SE_TIDAL_DE431=-25.8;SE_TIDAL_DE441=-25.936;SE_TIDAL_26=-26;SE_TIDAL_STEPHENSON_2016=-25.85;SE_TIDAL_DEFAULT=this.SE_TIDAL_DE431;SE_TIDAL_AUTOMATIC=999999;SE_TIDAL_MOSEPH=this.SE_TIDAL_DE404;SE_TIDAL_SWIEPH=this.SE_TIDAL_DEFAULT;SE_TIDAL_JPLEPH=this.SE_TIDAL_DEFAULT;SE_DELTAT_AUTOMATIC=-1e-10;SE_MODEL_DELTAT=0;SE_MODEL_PREC_LONGTERM=1;SE_MODEL_PREC_SHORTTERM=2;SE_MODEL_NUT=3;SE_MODEL_BIAS=4;SE_MODEL_JPLHOR_MODE=5;SE_MODEL_JPLHORA_MODE=6;SE_MODEL_SIDT=7;NSE_MODELS=8;SEMOD_NPREC=11;SEMOD_PREC_IAU_1976=1;SEMOD_PREC_LASKAR_1986=2;SEMOD_PREC_WILL_EPS_LASK=3;SEMOD_PREC_WILLIAMS_1994=4;SEMOD_PREC_SIMON_1994=5;SEMOD_PREC_IAU_2000=6;SEMOD_PREC_BRETAGNON_2003=7;SEMOD_PREC_IAU_2006=8;SEMOD_PREC_VONDRAK_2011=9;SEMOD_PREC_OWEN_1990=10;SEMOD_PREC_NEWCOMB=11;SEMOD_PREC_DEFAULT=this.SEMOD_PREC_VONDRAK_2011;SEMOD_PREC_DEFAULT_SHORT=this.SEMOD_PREC_VONDRAK_2011;SEMOD_NNUT=5;SEMOD_NUT_IAU_1980=1;SEMOD_NUT_IAU_CORR_1987=2;SEMOD_NUT_IAU_2000A=3;SEMOD_NUT_IAU_2000B=4;SEMOD_NUT_WOOLARD=5;SEMOD_NUT_DEFAULT=this.SEMOD_NUT_IAU_2000B;SEMOD_NSIDT=4;SEMOD_SIDT_IAU_1976=1;SEMOD_SIDT_IAU_2006=2;SEMOD_SIDT_IERS_CONV_2010=3;SEMOD_SIDT_LONGTERM=4;SEMOD_SIDT_DEFAULT=this.SEMOD_SIDT_LONGTERM;SEMOD_NBIAS=3;SEMOD_BIAS_NONE=1;SEMOD_BIAS_IAU2000=2;SEMOD_BIAS_IAU2006=3;SEMOD_BIAS_DEFAULT=this.SEMOD_BIAS_IAU2006;SEMOD_NJPLHOR=2;SEMOD_JPLHOR_LONG_AGREEMENT=1;SEMOD_JPLHOR_DEFAULT=this.SEMOD_JPLHOR_LONG_AGREEMENT;SEMOD_NJPLHORA=3;SEMOD_JPLHORA_1=1;SEMOD_JPLHORA_2=2;SEMOD_JPLHORA_3=3;SEMOD_JPLHORA_DEFAULT=this.SEMOD_JPLHORA_3;SEMOD_NDELTAT=5;SEMOD_DELTAT_STEPHENSON_MORRISON_1984=1;SEMOD_DELTAT_STEPHENSON_1997=2;SEMOD_DELTAT_STEPHENSON_MORRISON_2004=3;SEMOD_DELTAT_ESPENAK_MEEUS_2006=4;SEMOD_DELTAT_STEPHENSON_ETC_2016=5;SEMOD_DELTAT_DEFAULT=this.SEMOD_DELTAT_STEPHENSON_ETC_2016;wasm;constructor(e){this.wasm=e}static async init(t){const{default:s}=await Promise.resolve().then(function(){return require("./wasm/swisseph.cjs")}),_=await s({locateFile:(s,_)=>s.endsWith("swisseph.wasm")?t||new URL("wasm/swisseph.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.cjs",document.baseURI).href).href:_+s});return new w(_)}swe_azalt_rev(e,t,s,_){const r=h.from(this.wasm,"double",3,s),a=h.from(this.wasm,"double",2,_),i=h.alloc(this.wasm,"double",2);return this.wasm._swe_azalt_rev(e,t,r.ptr,a.ptr,i.ptr),a.free(),r.free(),i.readAndFree()}swe_azalt(e,t,s,_,r,a){const i=h.from(this.wasm,"double",3,s),E=h.from(this.wasm,"double",3,a),o=h.alloc(this.wasm,"double",3);return this.wasm._swe_azalt(e,t,i.ptr,_,r,E.ptr,o.ptr),i.free(),E.free(),o.readAndFree()}swe_calc_pctr(e,t,s,_){const a=h.alloc(this.wasm,"double",6),i=A.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_calc_pctr(e,t,s,_,a.ptr,i.ptr),o=i.readAndFree();if(E<this.OK)throw new r(o,E);return a.readAndFree()}swe_calc_ut(e,t,s){const _=h.alloc(this.wasm,"double",6),a=A.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_calc_ut(e,t,s,_.ptr,a.ptr);if(i<this.OK)throw new r(a.readAndFree(),i);return _.readAndFree()}swe_calc(e,t,s){const _=h.alloc(this.wasm,"double",6),a=A.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_calc(e,t,s,_.ptr,a.ptr);if(i<this.OK)throw new r(a.readAndFree(),i);return _.readAndFree()}swe_close(){this.wasm._swe_close()}swe_cotrans_sp(e,t){const s=h.from(this.wasm,"double",6,e),_=h.alloc(this.wasm,"double",6);return this.wasm._swe_cotrans_sp(s.ptr,_.ptr,t),s.free(),_.readAndFree()}swe_cotrans(e,t){const s=h.from(this.wasm,"double",3,e),_=h.alloc(this.wasm,"double",3);return this.wasm._swe_cotrans(s.ptr,_.ptr,t),s.free(),_.readAndFree()}swe_cs2degstr(e){const t=A.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_cs2degstr(e,t.ptr),t.readAndFree()}swe_cs2lonlatstr(e,t,s){const _=A.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_cs2lonlatstr(e,n.charToC(t),n.charToC(s),_.ptr),_.readAndFree()}swe_cs2timestr(e,t,s){const _=A.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_cs2lonlatstr(e,n.charToC(t),n.boolToC(s),_.ptr),_.readAndFree()}swe_csnorm(e){return this.wasm._swe_csnorm(e)}swe_csroundsec(e){return this.wasm._swe_csroundsec(e)}swe_d2l(e){return this.wasm._swe_d2l(e)}swe_date_conversion(e,t,s,_,a="j"){const i=l.alloc(this.wasm,"double"),E=this.wasm._swe_date_conversion(e,t,s,_,n.charToC(a),i.ptr);if(E<this.OK)throw new r("illegal date",E);return i.readAndFree()}swe_day_of_week(e){return this.wasm._swe_day_of_week(e)}swe_degnorm(e){return this.wasm._swe_degnorm(e)}swe_deltat_ex(e,t){const s=A.alloc(this.wasm,this.AS_MAXCH),_=this.wasm._swe_deltat_ex(e,t,s.ptr),a=s.readAndFree();if(a.trim().length>1)throw new r(a,this.ERR);return _}swe_deltat(e){return this.wasm._swe_deltat(e)}swe_difcs2n(e,t){return this.wasm._swe_difcs2n(e,t)}swe_difcsn(e,t){return this.wasm._swe_difcsn(e,t)}swe_difdeg2n(e,t){return this.wasm._swe_difdeg2n(e,t)}swe_difdegn(e,t){return this.wasm._swe_difdegn(e,t)}swe_fixstar_mag(e){const t=l.alloc(this.wasm,"double"),s=A.alloc(this.wasm,this.AS_MAXCH),_=A.from(this.wasm,e.length,e),a=this.wasm._swe_fixstar_mag(_.ptr,t.ptr,s.ptr);if(a<this.OK)throw new r(s.read(),a);return s.free(),{star_name:_.readAndFree(),mag:t.readAndFree()}}swe_fixstar_ut(e,t,s){const _=h.alloc(this.wasm,"double",6),a=A.alloc(this.wasm,this.AS_MAXCH),i=A.from(this.wasm,e.length,e),E=this.wasm._swe_fixstar_ut(i.ptr,t,s,_.ptr,a.ptr);if(E<this.OK)throw new r(a.read(),E);return a.free(),{star_name:i.readAndFree(),data:_.readAndFree()}}swe_fixstar(e,t,s){const _=h.alloc(this.wasm,"double",6),a=A.alloc(this.wasm,this.AS_MAXCH),i=A.from(this.wasm,e.length,e),E=this.wasm._swe_fixstar(i.ptr,t,s,_.ptr,a.ptr);if(E<this.OK)throw new r(a.read(),E);return a.free(),{star_name:i.readAndFree(),data:_.readAndFree()}}swe_fixstar2_mag(e){const t=l.alloc(this.wasm,"double"),s=A.alloc(this.wasm,this.AS_MAXCH),_=A.from(this.wasm,e.length,e),a=this.wasm._swe_fixstar2_mag(_.ptr,t.ptr,s.ptr);if(a<this.OK)throw new r(s.read(),a);return s.free(),{star_name:_.readAndFree(),magnitude:t.readAndFree()}}swe_fixstar2_ut(e,t,s){const _=h.alloc(this.wasm,"double",6),a=A.alloc(this.wasm,this.AS_MAXCH),i=A.from(this.wasm,e.length,e),E=this.wasm._swe_fixstar2_ut(i.ptr,t,s,_.ptr,a.ptr);if(E<this.OK)throw new r(a.read(),E);return a.free(),{star_name:i.readAndFree(),data:_.readAndFree()}}swe_fixstar2(e,t,s){const _=h.alloc(this.wasm,"double",6),a=A.alloc(this.wasm,this.AS_MAXCH),i=A.from(this.wasm,e.length,e),E=this.wasm._swe_fixstar2(i.ptr,t,s,_.ptr,a.ptr);if(E<this.OK)throw new r(a.read(),E);return a.free(),{star_name:i.readAndFree(),data:_.readAndFree()}}swe_gauquelin_sector(e,t,s,_,a,i,E,o){const n=h.from(this.wasm,"double",3,i),w=A.alloc(this.wasm,this.AS_MAXCH),d=s?A.from(this.wasm,s.length,s):new S,c=l.alloc(this.wasm,"double"),m=this.wasm._swe_gauquelin_sector(e,t,d.ptr,_,a,n.ptr,E,o,c.ptr,w.ptr);if(d.free(),m<this.OK)throw new r(w.read(),m);return w.free(),c.readAndFree()}swe_get_ayanamsa_ex_ut(e,t){const s=l.alloc(this.wasm,"double"),_=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_get_ayanamsa_ex_ut(e,t,s.ptr,_.ptr);if(a<this.OK)throw new r(_.read(),a);return _.free(),s.readAndFree()}swe_get_ayanamsa_ex(e,t){const s=l.alloc(this.wasm,"double"),_=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_get_ayanamsa_ex_ut(e,t,s.ptr,_.ptr);if(a<this.OK)throw new r(_.read(),a);return _.free(),s.readAndFree()}swe_get_ayanamsa_name(e){return this.wasm.UTF8ToString(this.wasm._swe_get_ayanamsa_name(e))}swe_get_ayanamsa_ut(e){return this.wasm._swe_get_ayanamsa_ut(e)}swe_get_ayanamsa(e){return this.wasm._swe_get_ayanamsa(e)}swe_get_current_file_data(e){const t=l.alloc(this.wasm,"double"),s=l.alloc(this.wasm,"double"),_=l.alloc(this.wasm,"double");return{path:this.wasm.UTF8ToString(this.wasm._swe_get_current_file_data(e,t.ptr,s.ptr,_.ptr)),start:t.readAndFree(),end:s.readAndFree(),denum:_.readAndFree()}}swe_get_library_path(){const e=A.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_get_library_path(e.ptr),e.readAndFree()}swe_get_orbital_elements(e,s,_){const a=h.alloc(this.wasm,"double",50),i=A.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_get_orbital_elements(e,s,_,a.ptr,i.ptr);if(E<this.OK)throw new r(i.read(),E);return i.free(),t(a.readAndFree(),17)}swe_get_planet_name(e){const t=A.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_get_planet_name(e,t.ptr),t.readAndFree()}swe_get_tid_acc(){return this.wasm._swe_get_tid_acc()}swe_heliacal_pheno_ut(e,s,_,a,i,E,o){const n=h.from(this.wasm,"double",3,s),S=h.from(this.wasm,"double",4,_),l=h.from(this.wasm,"double",6,a),w=A.from(this.wasm,i.length,i),d=h.alloc(this.wasm,"double",50),c=A.alloc(this.wasm,this.AS_MAXCH),m=this.wasm._swe_heliacal_pheno_ut(e,n.ptr,S.ptr,l.ptr,w.ptr,E,o,d.ptr,c.ptr);if(m<this.OK)throw new r(c.read(),m);return c.free(),n.free(),S.free(),l.free(),w.free(),t(d.readAndFree(),30)}swe_heliacal_ut(e,s,_,a,i,E,o){const n=h.from(this.wasm,"double",3,s),S=h.from(this.wasm,"double",4,_),l=h.from(this.wasm,"double",6,a),w=A.from(this.wasm,i.length,i),d=h.alloc(this.wasm,"double",50),c=A.alloc(this.wasm,this.AS_MAXCH),m=this.wasm._swe_heliacal_ut(e,n.ptr,S.ptr,l.ptr,w.ptr,E,o,d.ptr,c.ptr);if(m<this.OK)throw new r(c.read(),m);return c.free(),n.free(),S.free(),l.free(),w.free(),t(d.readAndFree(),3)}swe_helio_cross_ut(e,t,s,_,a){const i=l.alloc(this.wasm,"double"),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_helio_cross_ut(e,t,s,_,a,i.ptr,E.ptr);if(o<this.OK)throw new r(E.readAndFree(),o);return E.free(),i.readAndFree()}swe_helio_cross(e,t,s,_,a){const i=l.alloc(this.wasm,"double"),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_helio_cross(e,t,s,_,a,i.ptr,E.ptr);if(o<this.OK)throw new r(E.read(),o);return E.free(),i.readAndFree()}swe_house_name(e){return this.wasm.UTF8ToString(this.wasm._swe_house_name(n.charToC(e)))}swe_house_pos(e,t,s,_,a){const i=h.from(this.wasm,"double",2,a),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_house_pos(e,t,s,n.charToC(_),i.ptr,E.ptr),S=E.readAndFree();if(S.trim().length>1)throw new r(S,this.ERR);return o}swe_houses_armc_ex2(e,s,_,a,i){const E="G"===a?37:13,o=h.alloc(this.wasm,"double",37),S=h.alloc(this.wasm,"double",37),l=h.alloc(this.wasm,"double",10),w=h.alloc(this.wasm,"double",10),d=A.alloc(this.wasm,this.AS_MAXCH);void 0===i||isNaN(i)||l.add(9,i);const c=this.wasm._swe_houses_armc_ex2(e,s,_,n.charToC(a),o.ptr,l.ptr,S.ptr,w.ptr,d.ptr);if(c<this.OK)throw new r(d.readAndFree(),c);d.free();const m={};return m.cusps=t(o.readAndFree(),E,0),m.ascmc=t(l.readAndFree(),8),m.cusp_speed=t(S.readAndFree(),E,0),m.ascmc_speed=t(w.readAndFree(),8),m}swe_houses_armc(e,s,_,a,i){const E="G"===a?37:13,o=h.alloc(this.wasm,"double",37),S=h.alloc(this.wasm,"double",10);void 0===i||isNaN(i)||S.add(9,i);const l=this.wasm._swe_houses_armc(e,s,_,n.charToC(a),o.ptr,S.ptr);if(l<this.OK)throw new r("swe_houses_armc",l);const A={};return A.cusps=t(o.readAndFree(),E,0),A.ascmc=t(S.readAndFree(),8),A}swe_houses_ex(e,s,_,a,i){const E="G"===i?37:13,o=h.alloc(this.wasm,"double",37),S=h.alloc(this.wasm,"double",10),l=this.wasm._swe_houses_ex(e,s,_,a,n.charToC(i),o.ptr,S.ptr);if(l<this.OK)throw new r("swe_houses_ex",l);const A={};return A.cusps=t(o.readAndFree(),E,0),A.ascmc=t(S.readAndFree(),8),A}swe_houses_ex2(e,s,_,a,i){const E="G"===i?37:13,o=h.alloc(this.wasm,"double",37),S=h.alloc(this.wasm,"double",10),l=h.alloc(this.wasm,"double",37),w=h.alloc(this.wasm,"double",10),d=A.alloc(this.wasm,this.AS_MAXCH),c=this.wasm._swe_houses_ex2(e,s,_,a,n.charToC(i),o.ptr,S.ptr,l.ptr,w.ptr,d.ptr);if(c<this.OK)throw new r(d.readAndFree(),c);d.free();const m={};return m.cusps=t(o.readAndFree(),E,0),m.ascmc=t(S.readAndFree(),8),m.cusp_speed=t(l.readAndFree(),E,0),m.ascmc_speed=t(w.readAndFree(),8),m}swe_houses(e,s,_,a){const i="G"===a?37:13,E=h.alloc(this.wasm,"double",37),o=h.alloc(this.wasm,"double",10),S=this.wasm._swe_houses(e,s,_,n.charToC(a),E.ptr,o.ptr);if(S<this.OK)throw new r("swe_houses",S);const l={};return l.cusps=t(E.readAndFree(),i,0),l.ascmc=t(o.readAndFree(),8),l}swe_jdet_to_utc(e,t){const s=l.alloc(this.wasm,"i32"),_=l.alloc(this.wasm,"i32"),r=l.alloc(this.wasm,"i32"),a=l.alloc(this.wasm,"i32"),i=l.alloc(this.wasm,"i32"),E=l.alloc(this.wasm,"double");return this.wasm._swe_jdet_to_utc(e,t,s.ptr,_.ptr,r.ptr,a.ptr,i.ptr,E.ptr),{year:s.readAndFree(),month:_.readAndFree(),day:r.readAndFree(),hour:a.readAndFree(),minute:i.readAndFree(),second:E.readAndFree()}}swe_jdut1_to_utc(e,t){const s=l.alloc(this.wasm,"i32"),_=l.alloc(this.wasm,"i32"),r=l.alloc(this.wasm,"i32"),a=l.alloc(this.wasm,"i32"),i=l.alloc(this.wasm,"i32"),E=l.alloc(this.wasm,"double");return this.wasm._swe_jdut1_to_utc(e,t,s.ptr,_.ptr,r.ptr,a.ptr,i.ptr,E.ptr),{year:s.readAndFree(),month:_.readAndFree(),day:r.readAndFree(),hour:a.readAndFree(),minute:i.readAndFree(),second:E.readAndFree()}}swe_julday(e,t,s,_,r){return this.wasm._swe_julday(e,t,s,_,r)}swe_lat_to_lmt(e,t){const s=l.alloc(this.wasm,"double"),_=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_lat_to_lmt(e,t,s.ptr,_.ptr);if(a<this.OK)throw new r(_.readAndFree(),a);return _.free(),s.readAndFree()}swe_lmt_to_lat(e,t){const s=l.alloc(this.wasm,"double"),_=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_lmt_to_lat(e,t,s.ptr,_.ptr);if(a<this.OK)throw new r(_.readAndFree(),a);return _.free(),s.readAndFree()}swe_lun_eclipse_how(e,s,_){const a=h.from(this.wasm,"double",3,_),i=h.alloc(this.wasm,"double",20),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_lun_eclipse_how(e,s,a.ptr,i.ptr,E.ptr);if(o<this.OK)throw new r(E.readAndFree(),o);return E.free(),t(i.readAndFree(),11)}swe_lun_eclipse_when_loc(e,s,_,a){const i=h.from(this.wasm,"double",3,_),E=h.alloc(this.wasm,"double",10),o=h.alloc(this.wasm,"double",20),S=A.alloc(this.wasm,this.AS_MAXCH),l=this.wasm._swe_lun_eclipse_when_loc(e,s,i.ptr,E.ptr,o.ptr,n.boolToC(a),S.ptr);if(i.free(),l<this.OK)throw new r(S.readAndFree(),l);return S.free(),{data:E.readAndFree(),Array:t(o.readAndFree(),11)}}swe_lun_eclipse_when(e,s,_,a){const i=h.alloc(this.wasm,"double",10),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_lun_eclipse_when(e,s,_,i.ptr,n.boolToC(a),E.ptr);if(o<this.OK)throw new r(E.read(),o);return E.free(),t(i.readAndFree(),8)}swe_lun_occult_when_glob(e,t,s,_,a,i){const E=s?A.from(this.wasm,s.length,s):new S,o=h.alloc(this.wasm,"double",10),l=A.alloc(this.wasm,this.AS_MAXCH),w=this.wasm._swe_lun_occult_when_glob(e,t,E.ptr,_,a,o.ptr,n.boolToC(i),l.ptr);if(E.free(),w<this.OK)throw new r(l.read(),w);return l.free(),o.readAndFree()}swe_lun_occult_when_loc(e,s,_,a,i,E){const o=h.from(this.wasm,"double",3,i),l=h.alloc(this.wasm,"double",10),w=h.alloc(this.wasm,"double",20),d=A.alloc(this.wasm,this.AS_MAXCH),c=_?A.from(this.wasm,_.length,_):new S,m=this.wasm._swe_lun_occult_when_loc(e,s,c.ptr,a,o.ptr,l.ptr,w.ptr,n.boolToC(E),d.ptr);if(o.free(),c.free(),m<this.OK)throw new r(d.read(),m);return d.free(),{data:t(l.readAndFree(),7),Array:t(w.readAndFree(),8)}}swe_lun_occult_where(e,s,_,a){const i=h.alloc(this.wasm,"double",10),E=h.alloc(this.wasm,"double",20),o=A.alloc(this.wasm,this.AS_MAXCH),n=_?A.from(this.wasm,_.length,_):new S,l=this.wasm._swe_lun_occult_where(e,s,n.ptr,a,i.ptr,E.ptr,o.ptr);if(n.free(),l<this.OK)throw new r(o.read(),l);return o.free(),{data:i.readAndFree(),Array:t(E.readAndFree(),8)}}swe_mooncross_node_ut(e,t){const s=A.alloc(this.wasm,this.AS_MAXCH),_=l.alloc(this.wasm,"double"),a=l.alloc(this.wasm,"double"),i=this.wasm._swe_mooncross_node_ut(e,t,_.ptr,a.ptr,s.ptr);if(t<this.OK)throw new r(s.readAndFree(),t);return s.free(),{jd:i,longitude:_.readAndFree(),latitude:a.readAndFree()}}swe_mooncross_node(e,t){const s=A.alloc(this.wasm,this.AS_MAXCH),_=l.alloc(this.wasm,"double"),a=l.alloc(this.wasm,"double"),i=this.wasm._swe_mooncross_node(e,t,_.ptr,a.ptr,s.ptr);if(t<this.OK)throw new r(s.readAndFree(),t);return s.free(),{jd:i,longitude:_.readAndFree(),latitude:a.readAndFree()}}swe_mooncross_ut(e,t,s){const _=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_mooncross_ut(e,t,s,_.ptr);if(s<this.OK)throw new r(_.readAndFree(),s);return _.free(),a}swe_mooncross(e,t,s){const _=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_mooncross(e,t,s,_.ptr);if(s<this.OK)throw new r(_.readAndFree(),s);return _.free(),a}swe_nod_aps_ut(e,t,s,_){const a=h.alloc(this.wasm,"double",6),i=h.alloc(this.wasm,"double",6),E=h.alloc(this.wasm,"double",6),o=h.alloc(this.wasm,"double",6),n=A.alloc(this.wasm,this.AS_MAXCH),S=this.wasm._swe_nod_aps_ut(e,t,s,_,a.ptr,i.ptr,E.ptr,o.ptr,n.ptr);if(S<this.OK)throw new r(n.readAndFree(),S);return n.free(),{ascending:a.readAndFree(),descending:i.readAndFree(),perihelion:E.readAndFree(),aphelion:o.readAndFree()}}swe_nod_aps(e,t,s,_){const a=h.alloc(this.wasm,"double",6),i=h.alloc(this.wasm,"double",6),E=h.alloc(this.wasm,"double",6),o=h.alloc(this.wasm,"double",6),n=A.alloc(this.wasm,this.AS_MAXCH),S=this.wasm._swe_nod_aps(e,t,s,_,a.ptr,i.ptr,E.ptr,o.ptr,n.ptr);if(S<this.OK)throw new r(n.readAndFree(),S);return n.free(),{ascending:a.readAndFree(),descending:i.readAndFree(),perihelion:E.readAndFree(),aphelion:o.readAndFree()}}swe_orbit_max_min_true_distance(e,t,s){const _=l.alloc(this.wasm,"double"),a=l.alloc(this.wasm,"double"),i=l.alloc(this.wasm,"double"),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_orbit_max_min_true_distance(e,t,s,_.ptr,a.ptr,i.ptr,E.ptr);if(o<this.OK)throw new r(E.readAndFree(),o);return E.free(),{max:_.readAndFree(),min:a.readAndFree(),true:i.readAndFree()}}swe_pheno_ut(e,s,_){const a=h.alloc(this.wasm,"double",20),i=A.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_pheno_ut(e,s,_,a.ptr,i.ptr);if(E<this.OK)throw new r(i.readAndFree(),E);return i.free(),t(a.readAndFree(),5)}swe_pheno(e,s,_){const a=h.alloc(this.wasm,"double",20),i=A.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_pheno(e,s,_,a.ptr,i.ptr);if(E<this.OK)throw new r(i.readAndFree(),E);return i.free(),t(a.readAndFree(),5)}swe_radnorm(e){return this.wasm._swe_radnorm(e)}swe_refrac_extended(e,s,_,r,a,i){const E=h.alloc(this.wasm,"double",20);return{altitude:this.wasm._swe_refrac_extended(e,s,_,r,a,i,E.ptr),extended:t(E.readAndFree(),4)}}swe_refrac(e,t,s,_){return this.wasm._swe_refrac(e,t,s,_)}swe_revjul(e,t){const s=l.alloc(this.wasm,"i32"),_=l.alloc(this.wasm,"i32"),r=l.alloc(this.wasm,"i32"),a=l.alloc(this.wasm,"double");return this.wasm._swe_revjul(e,t,s.ptr,_.ptr,r.ptr,a.ptr),{year:s.readAndFree(),month:_.readAndFree(),day:r.readAndFree(),hour:a.readAndFree()}}swe_rise_trans_true_hor(e,t,s,_,a,i,E,o,n){const w=h.from(this.wasm,"double",3,i),d=l.alloc(this.wasm,"double"),c=A.alloc(this.wasm,this.AS_MAXCH),m=s?A.from(this.wasm,s.length,s):new S,L=this.wasm._swe_rise_trans_true_hor(e,t,m.ptr,_,a,w.ptr,E,o,n,d.ptr,c.ptr);if(w.free(),m.free(),L<this.OK)throw new r(c.readAndFree(),L);return c.free(),d.readAndFree()}swe_rise_trans(e,t,s,_,a,i,E,o){const n=h.from(this.wasm,"double",3,i),w=l.alloc(this.wasm,"double"),d=A.alloc(this.wasm,this.AS_MAXCH),c=s?A.from(this.wasm,s.length,s):new S,m=this.wasm._swe_rise_trans(e,t,c.ptr,_,a,n.ptr,E,o,w.ptr,d.ptr);if(m<this.OK)throw new r(d.readAndFree(),m);return d.free(),w.readAndFree()}swe_set_delta_t_userdef(e){return this.wasm._swe_set_delta_t_userdef(e)}async swe_set_ephe_path(e="https://ptprashanttripathi.github.io/sweph-wasm/ephe/",t=["seas_18.se1","sepl_18.se1","semo_18.se1"]){const s="/ephe";this.wasm.FS.analyzePath(s,!0).exists||this.wasm.FS.mkdir(s);const a=function(e){let t=e.replace(/\/+$/,"");const s=t.split("/").pop();return s&&/\.[a-z0-9]+$/i.test(s)&&(t=t.substring(0,t.lastIndexOf("/"))),t}(e),i=_.filter(({name:e})=>!t||t.includes(e)),E=(await Promise.all(i.map(async({name:e,desc:t,category:_})=>{try{const r=await fetch(`${a}/${e}`);if(r.ok&&200===r.status){const a=await r.arrayBuffer(),i=new Uint8Array(a),E=`${s}/${e}`;return this.wasm.FS.analyzePath(E).exists&&this.wasm.FS.unlink(E),this.wasm.FS.createDataFile(s,e,i,!0,!0,!0),`${e.padEnd(14)}: ${_.padEnd(28)} [${t}]`}}catch(t){console.error(`Skipped ${e} due to error:`,t)}return null}))).filter(Boolean);if(0===E.length)throw new r(`No ephemeris files loaded from "${e}"`,this.ERR);console.log(E.join("\n")),console.log(`Total ephemeris files loaded: ${E.length}`);const o=A.from(this.wasm,5,s);this.wasm._swe_set_ephe_path(o.ptr),o.free()}swe_set_jpl_file(e){const t=A.from(this.wasm,e.length,e);this.wasm._swe_set_jpl_file(t.ptr),t.free()}swe_set_sid_mode(e,t,s){this.wasm._swe_set_sid_mode(e,t,s)}swe_set_tid_acc(e){this.wasm._swe_set_tid_acc(e)}swe_set_topo(e,t,s){this.wasm._swe_set_topo(e,t,s)}swe_sidtime(e){return this.wasm._swe_sidtime(e)}swe_sidtime0(e,t,s){return this.wasm._swe_sidtime0(e,t,s)}swe_sol_eclipse_how(e,s,_){const a=h.from(this.wasm,"double",3,_),i=h.alloc(this.wasm,"double",20),E=A.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_sol_eclipse_how(e,s,a.ptr,i.ptr,E.ptr);if(a.free(),o<this.OK)throw new r(E.readAndFree(),o);return E.free(),t(i.readAndFree(),11)}swe_sol_eclipse_when_glob(e,t,s,_){const a=h.alloc(this.wasm,"double",10),i=A.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_sol_eclipse_when_glob(e,t,s,a.ptr,n.boolToC(_),i.ptr);if(E<this.OK)throw new r(i.readAndFree(),E);return i.free(),a.readAndFree()}swe_sol_eclipse_when_loc(e,s,_,a){const i=h.from(this.wasm,"double",3,_),E=h.alloc(this.wasm,"double",10),o=h.alloc(this.wasm,"double",20),S=A.alloc(this.wasm,this.AS_MAXCH),l=this.wasm._swe_sol_eclipse_when_loc(e,s,i.ptr,E.ptr,o.ptr,n.boolToC(a),S.ptr);i.free();const w=S.readAndFree();if(l<this.OK)throw new r(w,l);return{eclipseContactTimes:t(E.readAndFree(),7),eclipseAttributes:t(o.readAndFree(),11)}}swe_sol_eclipse_where(e,s){const _=h.alloc(this.wasm,"double",10),a=h.alloc(this.wasm,"double",20),i=A.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_sol_eclipse_where(e,s,_.ptr,a.ptr,i.ptr);if(E<this.OK)throw new r(i.readAndFree(),E);return i.free(),{data:_.readAndFree(),Array:t(a.readAndFree(),11)}}swe_solcross_ut(e,t,s){const _=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_solcross_ut(e,t,s,_.ptr);if(s<this.OK)throw new r(_.readAndFree(),s);return _.free(),a}swe_solcross(e,t,s){const _=A.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_solcross(e,t,s,_.ptr);if(s<this.OK)throw new r(_.readAndFree(),s);return _.free(),a}swe_split_deg(e,t){const s=l.alloc(this.wasm,"i32"),_=l.alloc(this.wasm,"i32"),r=l.alloc(this.wasm,"i32"),a=l.alloc(this.wasm,"double"),i=l.alloc(this.wasm,"i32");return this.wasm._swe_split_deg(e,t,s.ptr,_.ptr,r.ptr,a.ptr,i.ptr),{degree:s.readAndFree(),minute:_.readAndFree(),second:r.readAndFree(),fraction:a.readAndFree(),sign:i.readAndFree()}}swe_time_equ(e){const t=l.alloc(this.wasm,"double"),s=A.alloc(this.wasm,this.AS_MAXCH),_=this.wasm._swe_time_equ(e,t.ptr,s.ptr);if(_<this.OK)throw new r(s.readAndFree(),_);return s.free(),t.readAndFree()}swe_utc_time_zone(e,t,s,_,r,a,i){const E=l.alloc(this.wasm,"i32"),o=l.alloc(this.wasm,"i32"),h=l.alloc(this.wasm,"i32"),n=l.alloc(this.wasm,"i32"),S=l.alloc(this.wasm,"i32"),A=l.alloc(this.wasm,"double");return this.wasm._swe_utc_time_zone(e,t,s,_,r,a,i,E.ptr,o.ptr,h.ptr,n.ptr,S.ptr,A.ptr),{year:E.readAndFree(),month:o.readAndFree(),day:h.readAndFree(),hour:n.readAndFree(),minute:S.readAndFree(),second:A.readAndFree()}}swe_utc_to_jd(e,t,s,_,a,i,E){const o=h.alloc(this.wasm,"double",2),n=A.alloc(this.wasm,this.AS_MAXCH),S=this.wasm._swe_utc_to_jd(e,t,s,_,a,i,E,o.ptr,n.ptr);if(S<this.OK)throw new r(n.readAndFree(),S);return n.free(),o.readAndFree()}swe_version(){const e=A.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_version(e.ptr),e.readAndFree()}swe_vis_limit_mag(e,t,s,_,a,i){const E=h.from(this.wasm,"double",3,t),o=h.from(this.wasm,"double",4,s),n=h.from(this.wasm,"double",6,_),S=h.alloc(this.wasm,"double",8),l=A.from(this.wasm,a.length,a),w=A.alloc(this.wasm,this.AS_MAXCH),d=this.wasm._swe_vis_limit_mag(e,E.ptr,o.ptr,n.ptr,l.ptr,i,S.ptr,w.ptr);if(E.free(),o.free(),n.free(),l.free(),d<this.OK)throw new r(w.readAndFree(),d);return w.free(),S.readAndFree()}}module.exports=w; //# sourceMappingURL=index.cjs.map