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.6 kB
JavaScript
function e(e,t,s){const _=e.slice(0,t);for(;_.length<t;)_.push(s??null);return _}function t(e){return e<0?`${Math.abs(e)} BC`:0===e?"1 BC":`${e} AD`}const s=function(){const e=[];let s=-5401;const _=[{prefix:"pl",category:"SE Planetary Ephemeris"},{prefix:"mo",category:"SE Moon Ephemeris"},{prefix:"as",category:"SE Asteroid Ephemeris"}];for(;s<5400;){let r=s+599;s<=0&&r>=0&&(s+=1,r+=1);const a=String(Math.floor(Math.abs(s)/100)).padStart(2,"0"),E=r<0?"m":"_";for(const i of _)e.push({name:`se${i.prefix}${E}${a}.se1`,desc:`${t(s)} - ${t(r)}`,category:i.category});s+=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 _ extends Error{flag;error;constructor(e,t){super(e),this.error=e,this.name="SweError",this.flag=t,Object.setPrototypeOf(this,_.prototype)}}var r=Object.defineProperty,a=(e,t,s)=>((e,t,s)=>t in e?r(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 i{constructor(e,t){a(this,"_ptr",0),a(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 o extends i{constructor(e,t,s,_){super(e,_??e._malloc(s*E[t])),a(this,"type"),a(this,"length"),this.type=t,this.length=s}static from(e,t,s,_=[]){const r=o.alloc(e,t,s);return r.write(_),r}static alloc(e,t,s){return new o(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 h{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 n extends i{constructor(){super({},0)}read(){throw new Error("Cannot read from a NullPointer")}}class S extends i{constructor(e,t,s){super(e,s??e._malloc(E[t])),a(this,"type"),this.type=t}static from(e,t,s){const _=S.alloc(e,t);return _.write(s),_}write(e){this.validatePointer(),this.add(e)}static alloc(e,t){return new S(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 l extends i{constructor(e,t,s){super(e,s??e._malloc(t*E.i8)),a(this,"length"),this.length=t}static from(e,t,s=""){const _=l.alloc(e,t+1);return _.write(s),_}static alloc(e,t){return new l(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 A{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(e){const{default:t}=await import("./wasm/swisseph.js"),s=await t({locateFile:(t,s)=>t.endsWith("swisseph.wasm")?e||new URL("wasm/swisseph.wasm",import.meta.url).href:s+t});return new A(s)}swe_azalt_rev(e,t,s,_){const r=o.from(this.wasm,"double",3,s),a=o.from(this.wasm,"double",2,_),E=o.alloc(this.wasm,"double",2);return this.wasm._swe_azalt_rev(e,t,r.ptr,a.ptr,E.ptr),a.free(),r.free(),E.readAndFree()}swe_azalt(e,t,s,_,r,a){const E=o.from(this.wasm,"double",3,s),i=o.from(this.wasm,"double",3,a),h=o.alloc(this.wasm,"double",3);return this.wasm._swe_azalt(e,t,E.ptr,_,r,i.ptr,h.ptr),E.free(),i.free(),h.readAndFree()}swe_calc_pctr(e,t,s,r){const a=o.alloc(this.wasm,"double",6),E=l.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_calc_pctr(e,t,s,r,a.ptr,E.ptr),h=E.readAndFree();if(i<this.OK)throw new _(h,i);return a.readAndFree()}swe_calc_ut(e,t,s){const r=o.alloc(this.wasm,"double",6),a=l.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_calc_ut(e,t,s,r.ptr,a.ptr);if(E<this.OK)throw new _(a.readAndFree(),E);return r.readAndFree()}swe_calc(e,t,s){const r=o.alloc(this.wasm,"double",6),a=l.alloc(this.wasm,this.AS_MAXCH),E=this.wasm._swe_calc(e,t,s,r.ptr,a.ptr);if(E<this.OK)throw new _(a.readAndFree(),E);return r.readAndFree()}swe_close(){this.wasm._swe_close()}swe_cotrans_sp(e,t){const s=o.from(this.wasm,"double",6,e),_=o.alloc(this.wasm,"double",6);return this.wasm._swe_cotrans_sp(s.ptr,_.ptr,t),s.free(),_.readAndFree()}swe_cotrans(e,t){const s=o.from(this.wasm,"double",3,e),_=o.alloc(this.wasm,"double",3);return this.wasm._swe_cotrans(s.ptr,_.ptr,t),s.free(),_.readAndFree()}swe_cs2degstr(e){const t=l.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_cs2degstr(e,t.ptr),t.readAndFree()}swe_cs2lonlatstr(e,t,s){const _=l.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_cs2lonlatstr(e,h.charToC(t),h.charToC(s),_.ptr),_.readAndFree()}swe_cs2timestr(e,t,s){const _=l.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_cs2lonlatstr(e,h.charToC(t),h.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,r,a="j"){const E=S.alloc(this.wasm,"double"),i=this.wasm._swe_date_conversion(e,t,s,r,h.charToC(a),E.ptr);if(i<this.OK)throw new _("illegal date",i);return E.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=l.alloc(this.wasm,this.AS_MAXCH),r=this.wasm._swe_deltat_ex(e,t,s.ptr),a=s.readAndFree();if(a.trim().length>1)throw new _(a,this.ERR);return r}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=S.alloc(this.wasm,"double"),s=l.alloc(this.wasm,this.AS_MAXCH),r=l.from(this.wasm,e.length,e),a=this.wasm._swe_fixstar_mag(r.ptr,t.ptr,s.ptr);if(a<this.OK)throw new _(s.read(),a);return s.free(),{star_name:r.readAndFree(),mag:t.readAndFree()}}swe_fixstar_ut(e,t,s){const r=o.alloc(this.wasm,"double",6),a=l.alloc(this.wasm,this.AS_MAXCH),E=l.from(this.wasm,e.length,e),i=this.wasm._swe_fixstar_ut(E.ptr,t,s,r.ptr,a.ptr);if(i<this.OK)throw new _(a.read(),i);return a.free(),{star_name:E.readAndFree(),data:r.readAndFree()}}swe_fixstar(e,t,s){const r=o.alloc(this.wasm,"double",6),a=l.alloc(this.wasm,this.AS_MAXCH),E=l.from(this.wasm,e.length,e),i=this.wasm._swe_fixstar(E.ptr,t,s,r.ptr,a.ptr);if(i<this.OK)throw new _(a.read(),i);return a.free(),{star_name:E.readAndFree(),data:r.readAndFree()}}swe_fixstar2_mag(e){const t=S.alloc(this.wasm,"double"),s=l.alloc(this.wasm,this.AS_MAXCH),r=l.from(this.wasm,e.length,e),a=this.wasm._swe_fixstar2_mag(r.ptr,t.ptr,s.ptr);if(a<this.OK)throw new _(s.read(),a);return s.free(),{star_name:r.readAndFree(),magnitude:t.readAndFree()}}swe_fixstar2_ut(e,t,s){const r=o.alloc(this.wasm,"double",6),a=l.alloc(this.wasm,this.AS_MAXCH),E=l.from(this.wasm,e.length,e),i=this.wasm._swe_fixstar2_ut(E.ptr,t,s,r.ptr,a.ptr);if(i<this.OK)throw new _(a.read(),i);return a.free(),{star_name:E.readAndFree(),data:r.readAndFree()}}swe_fixstar2(e,t,s){const r=o.alloc(this.wasm,"double",6),a=l.alloc(this.wasm,this.AS_MAXCH),E=l.from(this.wasm,e.length,e),i=this.wasm._swe_fixstar2(E.ptr,t,s,r.ptr,a.ptr);if(i<this.OK)throw new _(a.read(),i);return a.free(),{star_name:E.readAndFree(),data:r.readAndFree()}}swe_gauquelin_sector(e,t,s,r,a,E,i,h){const A=o.from(this.wasm,"double",3,E),w=l.alloc(this.wasm,this.AS_MAXCH),d=s?l.from(this.wasm,s.length,s):new n,c=S.alloc(this.wasm,"double"),m=this.wasm._swe_gauquelin_sector(e,t,d.ptr,r,a,A.ptr,i,h,c.ptr,w.ptr);if(d.free(),m<this.OK)throw new _(w.read(),m);return w.free(),c.readAndFree()}swe_get_ayanamsa_ex_ut(e,t){const s=S.alloc(this.wasm,"double"),r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_get_ayanamsa_ex_ut(e,t,s.ptr,r.ptr);if(a<this.OK)throw new _(r.read(),a);return r.free(),s.readAndFree()}swe_get_ayanamsa_ex(e,t){const s=S.alloc(this.wasm,"double"),r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_get_ayanamsa_ex_ut(e,t,s.ptr,r.ptr);if(a<this.OK)throw new _(r.read(),a);return r.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=S.alloc(this.wasm,"double"),s=S.alloc(this.wasm,"double"),_=S.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=l.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_get_library_path(e.ptr),e.readAndFree()}swe_get_orbital_elements(t,s,r){const a=o.alloc(this.wasm,"double",50),E=l.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_get_orbital_elements(t,s,r,a.ptr,E.ptr);if(i<this.OK)throw new _(E.read(),i);return E.free(),e(a.readAndFree(),17)}swe_get_planet_name(e){const t=l.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(t,s,r,a,E,i,h){const n=o.from(this.wasm,"double",3,s),S=o.from(this.wasm,"double",4,r),A=o.from(this.wasm,"double",6,a),w=l.from(this.wasm,E.length,E),d=o.alloc(this.wasm,"double",50),c=l.alloc(this.wasm,this.AS_MAXCH),m=this.wasm._swe_heliacal_pheno_ut(t,n.ptr,S.ptr,A.ptr,w.ptr,i,h,d.ptr,c.ptr);if(m<this.OK)throw new _(c.read(),m);return c.free(),n.free(),S.free(),A.free(),w.free(),e(d.readAndFree(),30)}swe_heliacal_ut(t,s,r,a,E,i,h){const n=o.from(this.wasm,"double",3,s),S=o.from(this.wasm,"double",4,r),A=o.from(this.wasm,"double",6,a),w=l.from(this.wasm,E.length,E),d=o.alloc(this.wasm,"double",50),c=l.alloc(this.wasm,this.AS_MAXCH),m=this.wasm._swe_heliacal_ut(t,n.ptr,S.ptr,A.ptr,w.ptr,i,h,d.ptr,c.ptr);if(m<this.OK)throw new _(c.read(),m);return c.free(),n.free(),S.free(),A.free(),w.free(),e(d.readAndFree(),3)}swe_helio_cross_ut(e,t,s,r,a){const E=S.alloc(this.wasm,"double"),i=l.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_helio_cross_ut(e,t,s,r,a,E.ptr,i.ptr);if(o<this.OK)throw new _(i.readAndFree(),o);return i.free(),E.readAndFree()}swe_helio_cross(e,t,s,r,a){const E=S.alloc(this.wasm,"double"),i=l.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_helio_cross(e,t,s,r,a,E.ptr,i.ptr);if(o<this.OK)throw new _(i.read(),o);return i.free(),E.readAndFree()}swe_house_name(e){return this.wasm.UTF8ToString(this.wasm._swe_house_name(h.charToC(e)))}swe_house_pos(e,t,s,r,a){const E=o.from(this.wasm,"double",2,a),i=l.alloc(this.wasm,this.AS_MAXCH),n=this.wasm._swe_house_pos(e,t,s,h.charToC(r),E.ptr,i.ptr),S=i.readAndFree();if(S.trim().length>1)throw new _(S,this.ERR);return n}swe_houses_armc_ex2(t,s,r,a,E){const i="G"===a?37:13,n=o.alloc(this.wasm,"double",37),S=o.alloc(this.wasm,"double",37),A=o.alloc(this.wasm,"double",10),w=o.alloc(this.wasm,"double",10),d=l.alloc(this.wasm,this.AS_MAXCH);void 0===E||isNaN(E)||A.add(9,E);const c=this.wasm._swe_houses_armc_ex2(t,s,r,h.charToC(a),n.ptr,A.ptr,S.ptr,w.ptr,d.ptr);if(c<this.OK)throw new _(d.readAndFree(),c);d.free();const m={};return m.cusps=e(n.readAndFree(),i,0),m.ascmc=e(A.readAndFree(),8),m.cusp_speed=e(S.readAndFree(),i,0),m.ascmc_speed=e(w.readAndFree(),8),m}swe_houses_armc(t,s,r,a,E){const i="G"===a?37:13,n=o.alloc(this.wasm,"double",37),S=o.alloc(this.wasm,"double",10);void 0===E||isNaN(E)||S.add(9,E);const l=this.wasm._swe_houses_armc(t,s,r,h.charToC(a),n.ptr,S.ptr);if(l<this.OK)throw new _("swe_houses_armc",l);const A={};return A.cusps=e(n.readAndFree(),i,0),A.ascmc=e(S.readAndFree(),8),A}swe_houses_ex(t,s,r,a,E){const i="G"===E?37:13,n=o.alloc(this.wasm,"double",37),S=o.alloc(this.wasm,"double",10),l=this.wasm._swe_houses_ex(t,s,r,a,h.charToC(E),n.ptr,S.ptr);if(l<this.OK)throw new _("swe_houses_ex",l);const A={};return A.cusps=e(n.readAndFree(),i,0),A.ascmc=e(S.readAndFree(),8),A}swe_houses_ex2(t,s,r,a,E){const i="G"===E?37:13,n=o.alloc(this.wasm,"double",37),S=o.alloc(this.wasm,"double",10),A=o.alloc(this.wasm,"double",37),w=o.alloc(this.wasm,"double",10),d=l.alloc(this.wasm,this.AS_MAXCH),c=this.wasm._swe_houses_ex2(t,s,r,a,h.charToC(E),n.ptr,S.ptr,A.ptr,w.ptr,d.ptr);if(c<this.OK)throw new _(d.readAndFree(),c);d.free();const m={};return m.cusps=e(n.readAndFree(),i,0),m.ascmc=e(S.readAndFree(),8),m.cusp_speed=e(A.readAndFree(),i,0),m.ascmc_speed=e(w.readAndFree(),8),m}swe_houses(t,s,r,a){const E="G"===a?37:13,i=o.alloc(this.wasm,"double",37),n=o.alloc(this.wasm,"double",10),S=this.wasm._swe_houses(t,s,r,h.charToC(a),i.ptr,n.ptr);if(S<this.OK)throw new _("swe_houses",S);const l={};return l.cusps=e(i.readAndFree(),E,0),l.ascmc=e(n.readAndFree(),8),l}swe_jdet_to_utc(e,t){const s=S.alloc(this.wasm,"i32"),_=S.alloc(this.wasm,"i32"),r=S.alloc(this.wasm,"i32"),a=S.alloc(this.wasm,"i32"),E=S.alloc(this.wasm,"i32"),i=S.alloc(this.wasm,"double");return this.wasm._swe_jdet_to_utc(e,t,s.ptr,_.ptr,r.ptr,a.ptr,E.ptr,i.ptr),{year:s.readAndFree(),month:_.readAndFree(),day:r.readAndFree(),hour:a.readAndFree(),minute:E.readAndFree(),second:i.readAndFree()}}swe_jdut1_to_utc(e,t){const s=S.alloc(this.wasm,"i32"),_=S.alloc(this.wasm,"i32"),r=S.alloc(this.wasm,"i32"),a=S.alloc(this.wasm,"i32"),E=S.alloc(this.wasm,"i32"),i=S.alloc(this.wasm,"double");return this.wasm._swe_jdut1_to_utc(e,t,s.ptr,_.ptr,r.ptr,a.ptr,E.ptr,i.ptr),{year:s.readAndFree(),month:_.readAndFree(),day:r.readAndFree(),hour:a.readAndFree(),minute:E.readAndFree(),second:i.readAndFree()}}swe_julday(e,t,s,_,r){return this.wasm._swe_julday(e,t,s,_,r)}swe_lat_to_lmt(e,t){const s=S.alloc(this.wasm,"double"),r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_lat_to_lmt(e,t,s.ptr,r.ptr);if(a<this.OK)throw new _(r.readAndFree(),a);return r.free(),s.readAndFree()}swe_lmt_to_lat(e,t){const s=S.alloc(this.wasm,"double"),r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_lmt_to_lat(e,t,s.ptr,r.ptr);if(a<this.OK)throw new _(r.readAndFree(),a);return r.free(),s.readAndFree()}swe_lun_eclipse_how(t,s,r){const a=o.from(this.wasm,"double",3,r),E=o.alloc(this.wasm,"double",20),i=l.alloc(this.wasm,this.AS_MAXCH),h=this.wasm._swe_lun_eclipse_how(t,s,a.ptr,E.ptr,i.ptr);if(h<this.OK)throw new _(i.readAndFree(),h);return i.free(),e(E.readAndFree(),11)}swe_lun_eclipse_when_loc(t,s,r,a){const E=o.from(this.wasm,"double",3,r),i=o.alloc(this.wasm,"double",10),n=o.alloc(this.wasm,"double",20),S=l.alloc(this.wasm,this.AS_MAXCH),A=this.wasm._swe_lun_eclipse_when_loc(t,s,E.ptr,i.ptr,n.ptr,h.boolToC(a),S.ptr);if(E.free(),A<this.OK)throw new _(S.readAndFree(),A);return S.free(),{data:i.readAndFree(),Array:e(n.readAndFree(),11)}}swe_lun_eclipse_when(t,s,r,a){const E=o.alloc(this.wasm,"double",10),i=l.alloc(this.wasm,this.AS_MAXCH),n=this.wasm._swe_lun_eclipse_when(t,s,r,E.ptr,h.boolToC(a),i.ptr);if(n<this.OK)throw new _(i.read(),n);return i.free(),e(E.readAndFree(),8)}swe_lun_occult_when_glob(e,t,s,r,a,E){const i=s?l.from(this.wasm,s.length,s):new n,S=o.alloc(this.wasm,"double",10),A=l.alloc(this.wasm,this.AS_MAXCH),w=this.wasm._swe_lun_occult_when_glob(e,t,i.ptr,r,a,S.ptr,h.boolToC(E),A.ptr);if(i.free(),w<this.OK)throw new _(A.read(),w);return A.free(),S.readAndFree()}swe_lun_occult_when_loc(t,s,r,a,E,i){const S=o.from(this.wasm,"double",3,E),A=o.alloc(this.wasm,"double",10),w=o.alloc(this.wasm,"double",20),d=l.alloc(this.wasm,this.AS_MAXCH),c=r?l.from(this.wasm,r.length,r):new n,m=this.wasm._swe_lun_occult_when_loc(t,s,c.ptr,a,S.ptr,A.ptr,w.ptr,h.boolToC(i),d.ptr);if(S.free(),c.free(),m<this.OK)throw new _(d.read(),m);return d.free(),{data:e(A.readAndFree(),7),Array:e(w.readAndFree(),8)}}swe_lun_occult_where(t,s,r,a){const E=o.alloc(this.wasm,"double",10),i=o.alloc(this.wasm,"double",20),h=l.alloc(this.wasm,this.AS_MAXCH),S=r?l.from(this.wasm,r.length,r):new n,A=this.wasm._swe_lun_occult_where(t,s,S.ptr,a,E.ptr,i.ptr,h.ptr);if(S.free(),A<this.OK)throw new _(h.read(),A);return h.free(),{data:E.readAndFree(),Array:e(i.readAndFree(),8)}}swe_mooncross_node_ut(e,t){const s=l.alloc(this.wasm,this.AS_MAXCH),r=S.alloc(this.wasm,"double"),a=S.alloc(this.wasm,"double"),E=this.wasm._swe_mooncross_node_ut(e,t,r.ptr,a.ptr,s.ptr);if(t<this.OK)throw new _(s.readAndFree(),t);return s.free(),{jd:E,longitude:r.readAndFree(),latitude:a.readAndFree()}}swe_mooncross_node(e,t){const s=l.alloc(this.wasm,this.AS_MAXCH),r=S.alloc(this.wasm,"double"),a=S.alloc(this.wasm,"double"),E=this.wasm._swe_mooncross_node(e,t,r.ptr,a.ptr,s.ptr);if(t<this.OK)throw new _(s.readAndFree(),t);return s.free(),{jd:E,longitude:r.readAndFree(),latitude:a.readAndFree()}}swe_mooncross_ut(e,t,s){const r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_mooncross_ut(e,t,s,r.ptr);if(s<this.OK)throw new _(r.readAndFree(),s);return r.free(),a}swe_mooncross(e,t,s){const r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_mooncross(e,t,s,r.ptr);if(s<this.OK)throw new _(r.readAndFree(),s);return r.free(),a}swe_nod_aps_ut(e,t,s,r){const a=o.alloc(this.wasm,"double",6),E=o.alloc(this.wasm,"double",6),i=o.alloc(this.wasm,"double",6),h=o.alloc(this.wasm,"double",6),n=l.alloc(this.wasm,this.AS_MAXCH),S=this.wasm._swe_nod_aps_ut(e,t,s,r,a.ptr,E.ptr,i.ptr,h.ptr,n.ptr);if(S<this.OK)throw new _(n.readAndFree(),S);return n.free(),{ascending:a.readAndFree(),descending:E.readAndFree(),perihelion:i.readAndFree(),aphelion:h.readAndFree()}}swe_nod_aps(e,t,s,r){const a=o.alloc(this.wasm,"double",6),E=o.alloc(this.wasm,"double",6),i=o.alloc(this.wasm,"double",6),h=o.alloc(this.wasm,"double",6),n=l.alloc(this.wasm,this.AS_MAXCH),S=this.wasm._swe_nod_aps(e,t,s,r,a.ptr,E.ptr,i.ptr,h.ptr,n.ptr);if(S<this.OK)throw new _(n.readAndFree(),S);return n.free(),{ascending:a.readAndFree(),descending:E.readAndFree(),perihelion:i.readAndFree(),aphelion:h.readAndFree()}}swe_orbit_max_min_true_distance(e,t,s){const r=S.alloc(this.wasm,"double"),a=S.alloc(this.wasm,"double"),E=S.alloc(this.wasm,"double"),i=l.alloc(this.wasm,this.AS_MAXCH),o=this.wasm._swe_orbit_max_min_true_distance(e,t,s,r.ptr,a.ptr,E.ptr,i.ptr);if(o<this.OK)throw new _(i.readAndFree(),o);return i.free(),{max:r.readAndFree(),min:a.readAndFree(),true:E.readAndFree()}}swe_pheno_ut(t,s,r){const a=o.alloc(this.wasm,"double",20),E=l.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_pheno_ut(t,s,r,a.ptr,E.ptr);if(i<this.OK)throw new _(E.readAndFree(),i);return E.free(),e(a.readAndFree(),5)}swe_pheno(t,s,r){const a=o.alloc(this.wasm,"double",20),E=l.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_pheno(t,s,r,a.ptr,E.ptr);if(i<this.OK)throw new _(E.readAndFree(),i);return E.free(),e(a.readAndFree(),5)}swe_radnorm(e){return this.wasm._swe_radnorm(e)}swe_refrac_extended(t,s,_,r,a,E){const i=o.alloc(this.wasm,"double",20);return{altitude:this.wasm._swe_refrac_extended(t,s,_,r,a,E,i.ptr),extended:e(i.readAndFree(),4)}}swe_refrac(e,t,s,_){return this.wasm._swe_refrac(e,t,s,_)}swe_revjul(e,t){const s=S.alloc(this.wasm,"i32"),_=S.alloc(this.wasm,"i32"),r=S.alloc(this.wasm,"i32"),a=S.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,r,a,E,i,h,A){const w=o.from(this.wasm,"double",3,E),d=S.alloc(this.wasm,"double"),c=l.alloc(this.wasm,this.AS_MAXCH),m=s?l.from(this.wasm,s.length,s):new n,L=this.wasm._swe_rise_trans_true_hor(e,t,m.ptr,r,a,w.ptr,i,h,A,d.ptr,c.ptr);if(w.free(),m.free(),L<this.OK)throw new _(c.readAndFree(),L);return c.free(),d.readAndFree()}swe_rise_trans(e,t,s,r,a,E,i,h){const A=o.from(this.wasm,"double",3,E),w=S.alloc(this.wasm,"double"),d=l.alloc(this.wasm,this.AS_MAXCH),c=s?l.from(this.wasm,s.length,s):new n,m=this.wasm._swe_rise_trans(e,t,c.ptr,r,a,A.ptr,i,h,w.ptr,d.ptr);if(m<this.OK)throw new _(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 r="/ephe";this.wasm.FS.analyzePath(r,!0).exists||this.wasm.FS.mkdir(r);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),E=s.filter(({name:e})=>!t||t.includes(e)),i=(await Promise.all(E.map(async({name:e,desc:t,category:s})=>{try{const _=await fetch(`${a}/${e}`);if(_.ok&&200===_.status){const a=await _.arrayBuffer(),E=new Uint8Array(a),i=`${r}/${e}`;return this.wasm.FS.analyzePath(i).exists&&this.wasm.FS.unlink(i),this.wasm.FS.createDataFile(r,e,E,!0,!0,!0),`${e.padEnd(14)}: ${s.padEnd(28)} [${t}]`}}catch(t){console.error(`Skipped ${e} due to error:`,t)}return null}))).filter(Boolean);if(0===i.length)throw new _(`No ephemeris files loaded from "${e}"`,this.ERR);console.log(i.join("\n")),console.log(`Total ephemeris files loaded: ${i.length}`);const o=l.from(this.wasm,5,r);this.wasm._swe_set_ephe_path(o.ptr),o.free()}swe_set_jpl_file(e){const t=l.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(t,s,r){const a=o.from(this.wasm,"double",3,r),E=o.alloc(this.wasm,"double",20),i=l.alloc(this.wasm,this.AS_MAXCH),h=this.wasm._swe_sol_eclipse_how(t,s,a.ptr,E.ptr,i.ptr);if(a.free(),h<this.OK)throw new _(i.readAndFree(),h);return i.free(),e(E.readAndFree(),11)}swe_sol_eclipse_when_glob(e,t,s,r){const a=o.alloc(this.wasm,"double",10),E=l.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_sol_eclipse_when_glob(e,t,s,a.ptr,h.boolToC(r),E.ptr);if(i<this.OK)throw new _(E.readAndFree(),i);return E.free(),a.readAndFree()}swe_sol_eclipse_when_loc(t,s,r,a){const E=o.from(this.wasm,"double",3,r),i=o.alloc(this.wasm,"double",10),n=o.alloc(this.wasm,"double",20),S=l.alloc(this.wasm,this.AS_MAXCH),A=this.wasm._swe_sol_eclipse_when_loc(t,s,E.ptr,i.ptr,n.ptr,h.boolToC(a),S.ptr);E.free();const w=S.readAndFree();if(A<this.OK)throw new _(w,A);return{eclipseContactTimes:e(i.readAndFree(),7),eclipseAttributes:e(n.readAndFree(),11)}}swe_sol_eclipse_where(t,s){const r=o.alloc(this.wasm,"double",10),a=o.alloc(this.wasm,"double",20),E=l.alloc(this.wasm,this.AS_MAXCH),i=this.wasm._swe_sol_eclipse_where(t,s,r.ptr,a.ptr,E.ptr);if(i<this.OK)throw new _(E.readAndFree(),i);return E.free(),{data:r.readAndFree(),Array:e(a.readAndFree(),11)}}swe_solcross_ut(e,t,s){const r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_solcross_ut(e,t,s,r.ptr);if(s<this.OK)throw new _(r.readAndFree(),s);return r.free(),a}swe_solcross(e,t,s){const r=l.alloc(this.wasm,this.AS_MAXCH),a=this.wasm._swe_solcross(e,t,s,r.ptr);if(s<this.OK)throw new _(r.readAndFree(),s);return r.free(),a}swe_split_deg(e,t){const s=S.alloc(this.wasm,"i32"),_=S.alloc(this.wasm,"i32"),r=S.alloc(this.wasm,"i32"),a=S.alloc(this.wasm,"double"),E=S.alloc(this.wasm,"i32");return this.wasm._swe_split_deg(e,t,s.ptr,_.ptr,r.ptr,a.ptr,E.ptr),{degree:s.readAndFree(),minute:_.readAndFree(),second:r.readAndFree(),fraction:a.readAndFree(),sign:E.readAndFree()}}swe_time_equ(e){const t=S.alloc(this.wasm,"double"),s=l.alloc(this.wasm,this.AS_MAXCH),r=this.wasm._swe_time_equ(e,t.ptr,s.ptr);if(r<this.OK)throw new _(s.readAndFree(),r);return s.free(),t.readAndFree()}swe_utc_time_zone(e,t,s,_,r,a,E){const i=S.alloc(this.wasm,"i32"),o=S.alloc(this.wasm,"i32"),h=S.alloc(this.wasm,"i32"),n=S.alloc(this.wasm,"i32"),l=S.alloc(this.wasm,"i32"),A=S.alloc(this.wasm,"double");return this.wasm._swe_utc_time_zone(e,t,s,_,r,a,E,i.ptr,o.ptr,h.ptr,n.ptr,l.ptr,A.ptr),{year:i.readAndFree(),month:o.readAndFree(),day:h.readAndFree(),hour:n.readAndFree(),minute:l.readAndFree(),second:A.readAndFree()}}swe_utc_to_jd(e,t,s,r,a,E,i){const h=o.alloc(this.wasm,"double",2),n=l.alloc(this.wasm,this.AS_MAXCH),S=this.wasm._swe_utc_to_jd(e,t,s,r,a,E,i,h.ptr,n.ptr);if(S<this.OK)throw new _(n.readAndFree(),S);return n.free(),h.readAndFree()}swe_version(){const e=l.alloc(this.wasm,this.AS_MAXCH);return this.wasm._swe_version(e.ptr),e.readAndFree()}swe_vis_limit_mag(e,t,s,r,a,E){const i=o.from(this.wasm,"double",3,t),h=o.from(this.wasm,"double",4,s),n=o.from(this.wasm,"double",6,r),S=o.alloc(this.wasm,"double",8),A=l.from(this.wasm,a.length,a),w=l.alloc(this.wasm,this.AS_MAXCH),d=this.wasm._swe_vis_limit_mag(e,i.ptr,h.ptr,n.ptr,A.ptr,E,S.ptr,w.ptr);if(i.free(),h.free(),n.free(),A.free(),d<this.OK)throw new _(w.readAndFree(),d);return w.free(),S.readAndFree()}}export{A as default};
//# sourceMappingURL=index.js.map