solar-time
Version:
This library provides functions to calculate local solar time, also known as local apparent time, based on a given location and date.
8 lines (7 loc) • 40.7 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fe={exports:{}};(function(e,n){(function(t,i){e.exports=i()})(Ae,function(){var t=1e3,i=6e4,r=36e5,s="millisecond",o="second",u="minute",c="hour",f="day",a="week",l="month",h="quarter",m="year",k="date",S="Invalid Date",Z=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,L=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var g=["th","st","nd","rd"],p=$%100;return"["+$+(g[(p-20)%10]||g[p]||g[0])+"]"}},_=function($,g,p){var N=String($);return!N||N.length>=g?$:""+Array(g+1-N.length).join(p)+$},I={s:_,z:function($){var g=-$.utcOffset(),p=Math.abs(g),N=Math.floor(p/60),w=p%60;return(g<=0?"+":"-")+_(N,2,"0")+":"+_(w,2,"0")},m:function $(g,p){if(g.date()<p.date())return-$(p,g);var N=12*(p.year()-g.year())+(p.month()-g.month()),w=g.clone().add(N,l),D=p-w<0,O=g.clone().add(N+(D?-1:1),l);return+(-(N+(p-w)/(D?w-O:O-w))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:l,y:m,w:a,d:f,D:k,h:c,m:u,s:o,ms:s,Q:h}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},X="en",H={};H[X]=y;var ae="$isDayjsObject",ee=function($){return $ instanceof z||!(!$||!$[ae])},Q=function $(g,p,N){var w;if(!g)return X;if(typeof g=="string"){var D=g.toLowerCase();H[D]&&(w=D),p&&(H[D]=p,w=D);var O=g.split("-");if(!w&&O.length>1)return $(O[0])}else{var T=g.name;H[T]=g,w=T}return!N&&w&&(X=w),w||!N&&X},P=function($,g){if(ee($))return $.clone();var p=typeof g=="object"?g:{};return p.date=$,p.args=arguments,new z(p)},C=I;C.l=Q,C.i=ee,C.w=function($,g){return P($,{locale:g.$L,utc:g.$u,x:g.$x,$offset:g.$offset})};var z=function(){function $(p){this.$L=Q(p.locale,null,!0),this.parse(p),this.$x=this.$x||p.x||{},this[ae]=!0}var g=$.prototype;return g.parse=function(p){this.$d=function(N){var w=N.date,D=N.utc;if(w===null)return new Date(NaN);if(C.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var O=w.match(Z);if(O){var T=O[2]-1||0,q=(O[7]||"0").substring(0,3);return D?new Date(Date.UTC(O[1],T,O[3]||1,O[4]||0,O[5]||0,O[6]||0,q)):new Date(O[1],T,O[3]||1,O[4]||0,O[5]||0,O[6]||0,q)}}return new Date(w)}(p),this.init()},g.init=function(){var p=this.$d;this.$y=p.getFullYear(),this.$M=p.getMonth(),this.$D=p.getDate(),this.$W=p.getDay(),this.$H=p.getHours(),this.$m=p.getMinutes(),this.$s=p.getSeconds(),this.$ms=p.getMilliseconds()},g.$utils=function(){return C},g.isValid=function(){return this.$d.toString()!==S},g.isSame=function(p,N){var w=P(p);return this.startOf(N)<=w&&w<=this.endOf(N)},g.isAfter=function(p,N){return P(p)<this.startOf(N)},g.isBefore=function(p,N){return this.endOf(N)<P(p)},g.$g=function(p,N,w){return C.u(p)?this[N]:this.set(w,p)},g.unix=function(){return Math.floor(this.valueOf()/1e3)},g.valueOf=function(){return this.$d.getTime()},g.startOf=function(p,N){var w=this,D=!!C.u(N)||N,O=C.p(p),T=function(fe,Y){var ne=C.w(w.$u?Date.UTC(w.$y,Y,fe):new Date(w.$y,Y,fe),w);return D?ne:ne.endOf(f)},q=function(fe,Y){return C.w(w.toDate()[fe].apply(w.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(Y)),w)},F=this.$W,R=this.$M,V=this.$D,le="set"+(this.$u?"UTC":"");switch(O){case m:return D?T(1,0):T(31,11);case l:return D?T(1,R):T(0,R+1);case a:var ue=this.$locale().weekStart||0,pe=(F<ue?F+7:F)-ue;return T(D?V-pe:V+(6-pe),R);case f:case k:return q(le+"Hours",0);case c:return q(le+"Minutes",1);case u:return q(le+"Seconds",2);case o:return q(le+"Milliseconds",3);default:return this.clone()}},g.endOf=function(p){return this.startOf(p,!1)},g.$set=function(p,N){var w,D=C.p(p),O="set"+(this.$u?"UTC":""),T=(w={},w[f]=O+"Date",w[k]=O+"Date",w[l]=O+"Month",w[m]=O+"FullYear",w[c]=O+"Hours",w[u]=O+"Minutes",w[o]=O+"Seconds",w[s]=O+"Milliseconds",w)[D],q=D===f?this.$D+(N-this.$W):N;if(D===l||D===m){var F=this.clone().set(k,1);F.$d[T](q),F.init(),this.$d=F.set(k,Math.min(this.$D,F.daysInMonth())).$d}else T&&this.$d[T](q);return this.init(),this},g.set=function(p,N){return this.clone().$set(p,N)},g.get=function(p){return this[C.p(p)]()},g.add=function(p,N){var w,D=this;p=Number(p);var O=C.p(N),T=function(R){var V=P(D);return C.w(V.date(V.date()+Math.round(R*p)),D)};if(O===l)return this.set(l,this.$M+p);if(O===m)return this.set(m,this.$y+p);if(O===f)return T(1);if(O===a)return T(7);var q=(w={},w[u]=i,w[c]=r,w[o]=t,w)[O]||1,F=this.$d.getTime()+p*q;return C.w(F,this)},g.subtract=function(p,N){return this.add(-1*p,N)},g.format=function(p){var N=this,w=this.$locale();if(!this.isValid())return w.invalidDate||S;var D=p||"YYYY-MM-DDTHH:mm:ssZ",O=C.z(this),T=this.$H,q=this.$m,F=this.$M,R=w.weekdays,V=w.months,le=w.meridiem,ue=function(Y,ne,ge,me){return Y&&(Y[ne]||Y(N,D))||ge[ne].slice(0,me)},pe=function(Y){return C.s(T%12||12,Y,"0")},fe=le||function(Y,ne,ge){var me=Y<12?"AM":"PM";return ge?me.toLowerCase():me};return D.replace(L,function(Y,ne){return ne||function(ge){switch(ge){case"YY":return String(N.$y).slice(-2);case"YYYY":return C.s(N.$y,4,"0");case"M":return F+1;case"MM":return C.s(F+1,2,"0");case"MMM":return ue(w.monthsShort,F,V,3);case"MMMM":return ue(V,F);case"D":return N.$D;case"DD":return C.s(N.$D,2,"0");case"d":return String(N.$W);case"dd":return ue(w.weekdaysMin,N.$W,R,2);case"ddd":return ue(w.weekdaysShort,N.$W,R,3);case"dddd":return R[N.$W];case"H":return String(T);case"HH":return C.s(T,2,"0");case"h":return pe(1);case"hh":return pe(2);case"a":return fe(T,q,!0);case"A":return fe(T,q,!1);case"m":return String(q);case"mm":return C.s(q,2,"0");case"s":return String(N.$s);case"ss":return C.s(N.$s,2,"0");case"SSS":return C.s(N.$ms,3,"0");case"Z":return O}return null}(Y)||O.replace(":","")})},g.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},g.diff=function(p,N,w){var D,O=this,T=C.p(N),q=P(p),F=(q.utcOffset()-this.utcOffset())*i,R=this-q,V=function(){return C.m(O,q)};switch(T){case m:D=V()/12;break;case l:D=V();break;case h:D=V()/3;break;case a:D=(R-F)/6048e5;break;case f:D=(R-F)/864e5;break;case c:D=R/r;break;case u:D=R/i;break;case o:D=R/t;break;default:D=R}return w?D:C.a(D)},g.daysInMonth=function(){return this.endOf(l).$D},g.$locale=function(){return H[this.$L]},g.locale=function(p,N){if(!p)return this.$L;var w=this.clone(),D=Q(p,N,!0);return D&&(w.$L=D),w},g.clone=function(){return C.w(this.$d,this)},g.toDate=function(){return new Date(this.valueOf())},g.toJSON=function(){return this.isValid()?this.toISOString():null},g.toISOString=function(){return this.$d.toISOString()},g.toString=function(){return this.$d.toUTCString()},$}(),oe=z.prototype;return P.prototype=oe,[["$ms",s],["$s",o],["$m",u],["$H",c],["$W",f],["$M",l],["$y",m],["$D",k]].forEach(function($){oe[$[1]]=function(g){return this.$g(g,$[0],$[1])}}),P.extend=function($,g){return $.$i||($(g,z,P),$.$i=!0),P},P.locale=Q,P.isDayjs=ee,P.unix=function($){return P(1e3*$)},P.en=H[X],P.Ls=H,P.p={},P})})(Fe);var Ke=Fe.exports;const ce=Ie(Ke);var Ze={exports:{}};(function(e,n){(function(t,i){e.exports=i()})(Ae,function(){return function(t,i,r){i.prototype.dayOfYear=function(s){var o=Math.round((r(this).startOf("day")-r(this).startOf("year"))/864e5)+1;return s==null?o:this.add(s-o,"day")}}})})(Ze);var ze=Ze.exports;const xe=Ie(ze);ce.extend(xe);const He=(e,n,t)=>{const i=(t==null?void 0:t.utc)??ce(e).utcOffset()/60,r=15*Math.abs(i),s=360/365*(ce(e).dayOfYear()-81),o=s*(Math.PI/180),u=9.87*Math.sin(2*o)-7.53*Math.cos(o)-1.5*Math.sin(o),c=4*(n-r)+u;return{LST:ce(e).add(c,"minute"),TC:c,EoT:u,B:s,LSTM:r}},en=(e,n)=>He(new Date,e,n);/*!
* decimal.js v10.4.3
* An arbitrary-precision Decimal type for JavaScript.
* https://github.com/MikeMcl/decimal.js
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
* MIT Licence
*/var he=9e15,se=1e9,Oe="0123456789abcdef",Ne="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Me="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ke={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-he,maxE:he,crypto:!1},Ue,x,E=!0,Se="[DecimalError] ",re=Se+"Invalid argument: ",Re=Se+"Precision limit exceeded",Be=Se+"crypto unavailable",Ye="[object Decimal]",B=Math.floor,A=Math.pow,nn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,tn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,rn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,We=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,G=1e7,M=7,sn=9007199254740991,on=Ne.length-1,Ce=Me.length-1,d={toStringTag:Ye};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),v(e)};d.ceil=function(){return v(new this.constructor(this),this.e+1,2)};d.clampedTo=d.clamp=function(e,n){var t,i=this,r=i.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error(re+n);return t=i.cmp(e),t<0?e:i.cmp(n)>0?n:new r(i)};d.comparedTo=d.cmp=function(e){var n,t,i,r,s=this,o=s.d,u=(e=new s.constructor(e)).d,c=s.s,f=e.s;if(!o||!u)return!c||!f?NaN:c!==f?c:o===u?0:!o^c<0?1:-1;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==e.e)return s.e>e.e^c<0?1:-1;for(i=o.length,r=u.length,n=0,t=i<r?i:r;n<t;++n)if(o[n]!==u[n])return o[n]>u[n]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};d.cosine=d.cos=function(){var e,n,t=this,i=t.constructor;return t.d?t.d[0]?(e=i.precision,n=i.rounding,i.precision=e+Math.max(t.e,t.sd())+M,i.rounding=1,t=un(i,Ge(i,t)),i.precision=e,i.rounding=n,v(x==2||x==3?t.neg():t,e,n,!0)):new i(1):new i(NaN)};d.cubeRoot=d.cbrt=function(){var e,n,t,i,r,s,o,u,c,f,a=this,l=a.constructor;if(!a.isFinite()||a.isZero())return new l(a);for(E=!1,s=a.s*A(a.s*a,1/3),!s||Math.abs(s)==1/0?(t=U(a.d),e=a.e,(s=(e-t.length+1)%3)&&(t+=s==1||s==-2?"0":"00"),s=A(t,1/3),e=B((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?t="5e"+e:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),i=new l(t),i.s=a.s):i=new l(s.toString()),o=(e=l.precision)+3;;)if(u=i,c=u.times(u).times(u),f=c.plus(a),i=b(f.plus(a).times(u),f.plus(c),o+2,1),U(u.d).slice(0,o)===(t=U(i.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!r&&t=="4999"){if(!r&&(v(u,e+1,0),u.times(u).times(u).eq(a))){i=u;break}o+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(v(i,e+1,1),n=!i.times(i).times(i).eq(a));break}return E=!0,v(i,e,l.rounding,n)};d.decimalPlaces=d.dp=function(){var e,n=this.d,t=NaN;if(n){if(e=n.length-1,t=(e-B(this.e/M))*M,e=n[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t};d.dividedBy=d.div=function(e){return b(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var n=this,t=n.constructor;return v(b(n,new t(e),0,1,1),t.precision,t.rounding)};d.equals=d.eq=function(e){return this.cmp(e)===0};d.floor=function(){return v(new this.constructor(this),this.e+1,3)};d.greaterThan=d.gt=function(e){return this.cmp(e)>0};d.greaterThanOrEqualTo=d.gte=function(e){var n=this.cmp(e);return n==1||n===0};d.hyperbolicCosine=d.cosh=function(){var e,n,t,i,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;t=o.precision,i=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,r=s.d.length,r<32?(e=Math.ceil(r/3),n=(1/De(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),s=de(o,1,s.times(n),new o(1),!0);for(var c,f=e,a=new o(8);f--;)c=s.times(s),s=u.minus(c.times(a.minus(c.times(a))));return v(s,o.precision=t,o.rounding=i,!0)};d.hyperbolicSine=d.sinh=function(){var e,n,t,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(n=s.precision,t=s.rounding,s.precision=n+Math.max(r.e,r.sd())+4,s.rounding=1,i=r.d.length,i<3)r=de(s,2,r,r,!0);else{e=1.4*Math.sqrt(i),e=e>16?16:e|0,r=r.times(1/De(5,e)),r=de(s,2,r,r,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);e--;)o=r.times(r),r=r.times(u.plus(o.times(c.times(o).plus(f))))}return s.precision=n,s.rounding=t,v(r,n,t,!0)};d.hyperbolicTangent=d.tanh=function(){var e,n,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(e=i.precision,n=i.rounding,i.precision=e+7,i.rounding=1,b(t.sinh(),t.cosh(),i.precision=e,i.rounding=n)):new i(t.s)};d.inverseCosine=d.acos=function(){var e,n=this,t=n.constructor,i=n.abs().cmp(1),r=t.precision,s=t.rounding;return i!==-1?i===0?n.isNeg()?J(t,r,s):new t(0):new t(NaN):n.isZero()?J(t,r+4,s).times(.5):(t.precision=r+6,t.rounding=1,n=n.asin(),e=J(t,r+4,s).times(.5),t.precision=r,t.rounding=s,e.minus(n))};d.inverseHyperbolicCosine=d.acosh=function(){var e,n,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(e=i.precision,n=i.rounding,i.precision=e+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,E=!1,t=t.times(t).minus(1).sqrt().plus(t),E=!0,i.precision=e,i.rounding=n,t.ln()):new i(t)};d.inverseHyperbolicSine=d.asinh=function(){var e,n,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(e=i.precision,n=i.rounding,i.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,E=!1,t=t.times(t).plus(1).sqrt().plus(t),E=!0,i.precision=e,i.rounding=n,t.ln())};d.inverseHyperbolicTangent=d.atanh=function(){var e,n,t,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=s.precision,n=s.rounding,i=r.sd(),Math.max(i,e)<2*-r.e-1?v(new s(r),e,n,!0):(s.precision=t=i-r.e,r=b(r.plus(1),new s(1).minus(r),t+e,1),s.precision=e+4,s.rounding=1,r=r.ln(),s.precision=e,s.rounding=n,r.times(.5))):new s(NaN)};d.inverseSine=d.asin=function(){var e,n,t,i,r=this,s=r.constructor;return r.isZero()?new s(r):(n=r.abs().cmp(1),t=s.precision,i=s.rounding,n!==-1?n===0?(e=J(s,t+4,i).times(.5),e.s=r.s,e):new s(NaN):(s.precision=t+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=i,r.times(2)))};d.inverseTangent=d.atan=function(){var e,n,t,i,r,s,o,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(f.isFinite()){if(f.isZero())return new a(f);if(f.abs().eq(1)&&l+4<=Ce)return o=J(a,l+4,h).times(.25),o.s=f.s,o}else{if(!f.s)return new a(NaN);if(l+4<=Ce)return o=J(a,l+4,h).times(.5),o.s=f.s,o}for(a.precision=u=l+10,a.rounding=1,t=Math.min(28,u/M+2|0),e=t;e;--e)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(E=!1,n=Math.ceil(u/M),i=1,c=f.times(f),o=new a(f),r=f;e!==-1;)if(r=r.times(c),s=o.minus(r.div(i+=2)),r=r.times(c),o=s.plus(r.div(i+=2)),o.d[n]!==void 0)for(e=n;o.d[e]===s.d[e]&&e--;);return t&&(o=o.times(2<<t-1)),E=!0,v(o,a.precision=l,a.rounding=h,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&B(this.e/M)>this.d.length-2};d.isNaN=function(){return!this.s};d.isNegative=d.isNeg=function(){return this.s<0};d.isPositive=d.isPos=function(){return this.s>0};d.isZero=function(){return!!this.d&&this.d[0]===0};d.lessThan=d.lt=function(e){return this.cmp(e)<0};d.lessThanOrEqualTo=d.lte=function(e){return this.cmp(e)<1};d.logarithm=d.log=function(e){var n,t,i,r,s,o,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding,m=5;if(e==null)e=new a(10),n=!0;else{if(e=new a(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new a(NaN);n=e.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new a(t&&!t[0]?-1/0:f.s!=1?NaN:t?0:1/0);if(n)if(t.length>1)s=!0;else{for(r=t[0];r%10===0;)r/=10;s=r!==1}if(E=!1,u=l+m,o=ie(f,u),i=n?$e(a,u+10):ie(e,u),c=b(o,i,u,1),we(c.d,r=l,h))do if(u+=10,o=ie(f,u),i=n?$e(a,u+10):ie(e,u),c=b(o,i,u,1),!s){+U(c.d).slice(r+1,r+15)+1==1e14&&(c=v(c,l+1,0));break}while(we(c.d,r+=10,h));return E=!0,v(c,l,h)};d.minus=d.sub=function(e){var n,t,i,r,s,o,u,c,f,a,l,h,m=this,k=m.constructor;if(e=new k(e),!m.d||!e.d)return!m.s||!e.s?e=new k(NaN):m.d?e.s=-e.s:e=new k(e.d||m.s!==e.s?m:NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(f=m.d,h=e.d,u=k.precision,c=k.rounding,!f[0]||!h[0]){if(h[0])e.s=-e.s;else if(f[0])e=new k(m);else return new k(c===3?-0:0);return E?v(e,u,c):e}if(t=B(e.e/M),a=B(m.e/M),f=f.slice(),s=a-t,s){for(l=s<0,l?(n=f,s=-s,o=h.length):(n=h,t=a,o=f.length),i=Math.max(Math.ceil(u/M),o)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=f.length,o=h.length,l=i<o,l&&(o=i),i=0;i<o;i++)if(f[i]!=h[i]){l=f[i]<h[i];break}s=0}for(l&&(n=f,f=h,h=n,e.s=-e.s),o=f.length,i=h.length-o;i>0;--i)f[o++]=0;for(i=h.length;i>s;){if(f[--i]<h[i]){for(r=i;r&&f[--r]===0;)f[r]=G-1;--f[r],f[i]+=G}f[i]-=h[i]}for(;f[--o]===0;)f.pop();for(;f[0]===0;f.shift())--t;return f[0]?(e.d=f,e.e=Ee(f,t),E?v(e,u,c):e):new k(c===3?-0:0)};d.modulo=d.mod=function(e){var n,t=this,i=t.constructor;return e=new i(e),!t.d||!e.s||e.d&&!e.d[0]?new i(NaN):!e.d||t.d&&!t.d[0]?v(new i(t),i.precision,i.rounding):(E=!1,i.modulo==9?(n=b(t,e.abs(),0,3,1),n.s*=e.s):n=b(t,e,0,i.modulo,1),n=n.times(e),E=!0,t.minus(n))};d.naturalExponential=d.exp=function(){return _e(this)};d.naturalLogarithm=d.ln=function(){return ie(this)};d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,v(e)};d.plus=d.add=function(e){var n,t,i,r,s,o,u,c,f,a,l=this,h=l.constructor;if(e=new h(e),!l.d||!e.d)return!l.s||!e.s?e=new h(NaN):l.d||(e=new h(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(f=l.d,a=e.d,u=h.precision,c=h.rounding,!f[0]||!a[0])return a[0]||(e=new h(l)),E?v(e,u,c):e;if(s=B(l.e/M),i=B(e.e/M),f=f.slice(),r=s-i,r){for(r<0?(t=f,r=-r,o=a.length):(t=a,i=s,o=f.length),s=Math.ceil(u/M),o=s>o?s+1:o+1,r>o&&(r=o,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(o=f.length,r=a.length,o-r<0&&(r=o,t=a,a=f,f=t),n=0;r;)n=(f[--r]=f[r]+a[r]+n)/G|0,f[r]%=G;for(n&&(f.unshift(n),++i),o=f.length;f[--o]==0;)f.pop();return e.d=f,e.e=Ee(f,i),E?v(e,u,c):e};d.precision=d.sd=function(e){var n,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(re+e);return t.d?(n=je(t.d),e&&t.e+1>n&&(n=t.e+1)):n=NaN,n};d.round=function(){var e=this,n=e.constructor;return v(new n(e),e.e+1,n.rounding)};d.sine=d.sin=function(){var e,n,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(e=i.precision,n=i.rounding,i.precision=e+Math.max(t.e,t.sd())+M,i.rounding=1,t=cn(i,Ge(i,t)),i.precision=e,i.rounding=n,v(x>2?t.neg():t,e,n,!0)):new i(NaN)};d.squareRoot=d.sqrt=function(){var e,n,t,i,r,s,o=this,u=o.d,c=o.e,f=o.s,a=o.constructor;if(f!==1||!u||!u[0])return new a(!f||f<0&&(!u||u[0])?NaN:u?o:1/0);for(E=!1,f=Math.sqrt(+o),f==0||f==1/0?(n=U(u),(n.length+c)%2==0&&(n+="0"),f=Math.sqrt(n),c=B((c+1)/2)-(c<0||c%2),f==1/0?n="5e"+c:(n=f.toExponential(),n=n.slice(0,n.indexOf("e")+1)+c),i=new a(n)):i=new a(f.toString()),t=(c=a.precision)+3;;)if(s=i,i=s.plus(b(o,s,t+2,1)).times(.5),U(s.d).slice(0,t)===(n=U(i.d)).slice(0,t))if(n=n.slice(t-3,t+1),n=="9999"||!r&&n=="4999"){if(!r&&(v(s,c+1,0),s.times(s).eq(o))){i=s;break}t+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(v(i,c+1,1),e=!i.times(i).eq(o));break}return E=!0,v(i,c,a.rounding,e)};d.tangent=d.tan=function(){var e,n,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(e=i.precision,n=i.rounding,i.precision=e+10,i.rounding=1,t=t.sin(),t.s=1,t=b(t,new i(1).minus(t.times(t)).sqrt(),e+10,0),i.precision=e,i.rounding=n,v(x==2||x==4?t.neg():t,e,n,!0)):new i(NaN)};d.times=d.mul=function(e){var n,t,i,r,s,o,u,c,f,a=this,l=a.constructor,h=a.d,m=(e=new l(e)).d;if(e.s*=a.s,!h||!h[0]||!m||!m[0])return new l(!e.s||h&&!h[0]&&!m||m&&!m[0]&&!h?NaN:!h||!m?e.s/0:e.s*0);for(t=B(a.e/M)+B(e.e/M),c=h.length,f=m.length,c<f&&(s=h,h=m,m=s,o=c,c=f,f=o),s=[],o=c+f,i=o;i--;)s.push(0);for(i=f;--i>=0;){for(n=0,r=c+i;r>i;)u=s[r]+m[i]*h[r-i-1]+n,s[r--]=u%G|0,n=u/G|0;s[r]=(s[r]+n)%G|0}for(;!s[--o];)s.pop();return n?++t:s.shift(),e.d=s,e.e=Ee(s,t),E?v(e,l.precision,l.rounding):e};d.toBinary=function(e,n){return Te(this,2,e,n)};d.toDecimalPlaces=d.toDP=function(e,n){var t=this,i=t.constructor;return t=new i(t),e===void 0?t:(j(e,0,se),n===void 0?n=i.rounding:j(n,0,8),v(t,e+t.e+1,n))};d.toExponential=function(e,n){var t,i=this,r=i.constructor;return e===void 0?t=K(i,!0):(j(e,0,se),n===void 0?n=r.rounding:j(n,0,8),i=v(new r(i),e+1,n),t=K(i,!0,e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};d.toFixed=function(e,n){var t,i,r=this,s=r.constructor;return e===void 0?t=K(r):(j(e,0,se),n===void 0?n=s.rounding:j(n,0,8),i=v(new s(r),e+r.e+1,n),t=K(i,!1,e+i.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};d.toFraction=function(e){var n,t,i,r,s,o,u,c,f,a,l,h,m=this,k=m.d,S=m.constructor;if(!k)return new S(m);if(f=t=new S(1),i=c=new S(0),n=new S(i),s=n.e=je(k)-m.e-1,o=s%M,n.d[0]=A(10,o<0?M+o:o),e==null)e=s>0?n:f;else{if(u=new S(e),!u.isInt()||u.lt(f))throw Error(re+u);e=u.gt(n)?s>0?n:f:u}for(E=!1,u=new S(U(k)),a=S.precision,S.precision=s=k.length*M*2;l=b(u,n,0,1,1),r=t.plus(l.times(i)),r.cmp(e)!=1;)t=i,i=r,r=f,f=c.plus(l.times(r)),c=r,r=n,n=u.minus(l.times(r)),u=r;return r=b(e.minus(t),i,0,1,1),c=c.plus(r.times(f)),t=t.plus(r.times(i)),c.s=f.s=m.s,h=b(f,i,s,1).minus(m).abs().cmp(b(c,t,s,1).minus(m).abs())<1?[f,i]:[c,t],S.precision=a,E=!0,h};d.toHexadecimal=d.toHex=function(e,n){return Te(this,16,e,n)};d.toNearest=function(e,n){var t=this,i=t.constructor;if(t=new i(t),e==null){if(!t.d)return t;e=new i(1),n=i.rounding}else{if(e=new i(e),n===void 0?n=i.rounding:j(n,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(E=!1,t=b(t,e,0,n,1).times(e),E=!0,v(t)):(e.s=t.s,t=e),t};d.toNumber=function(){return+this};d.toOctal=function(e,n){return Te(this,8,e,n)};d.toPower=d.pow=function(e){var n,t,i,r,s,o,u=this,c=u.constructor,f=+(e=new c(e));if(!u.d||!e.d||!u.d[0]||!e.d[0])return new c(A(+u,f));if(u=new c(u),u.eq(1))return u;if(i=c.precision,s=c.rounding,e.eq(1))return v(u,i,s);if(n=B(e.e/M),n>=e.d.length-1&&(t=f<0?-f:f)<=sn)return r=ye(c,u,t,i),e.s<0?new c(1).div(r):v(r,i,s);if(o=u.s,o<0){if(n<e.d.length-1)return new c(NaN);if(e.d[n]&1||(o=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=o,u}return t=A(+u,f),n=t==0||!isFinite(t)?B(f*(Math.log("0."+U(u.d))/Math.LN10+u.e+1)):new c(t+"").e,n>c.maxE+1||n<c.minE-1?new c(n>0?o/0:0):(E=!1,c.rounding=u.s=1,t=Math.min(12,(n+"").length),r=_e(e.times(ie(u,i+t)),i),r.d&&(r=v(r,i+5,1),we(r.d,i,s)&&(n=i+10,r=v(_e(e.times(ie(u,n+t)),n),n+5,1),+U(r.d).slice(i+1,i+15)+1==1e14&&(r=v(r,i+1,0)))),r.s=o,E=!0,c.rounding=s,v(r,i,s))};d.toPrecision=function(e,n){var t,i=this,r=i.constructor;return e===void 0?t=K(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(j(e,1,se),n===void 0?n=r.rounding:j(n,0,8),i=v(new r(i),e,n),t=K(i,e<=i.e||i.e<=r.toExpNeg,e)),i.isNeg()&&!i.isZero()?"-"+t:t};d.toSignificantDigits=d.toSD=function(e,n){var t=this,i=t.constructor;return e===void 0?(e=i.precision,n=i.rounding):(j(e,1,se),n===void 0?n=i.rounding:j(n,0,8)),v(new i(t),e,n)};d.toString=function(){var e=this,n=e.constructor,t=K(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t};d.truncated=d.trunc=function(){return v(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var e=this,n=e.constructor,t=K(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+t:t};function U(e){var n,t,i,r=e.length-1,s="",o=e[0];if(r>0){for(s+=o,n=1;n<r;n++)i=e[n]+"",t=M-i.length,t&&(s+=te(t)),s+=i;o=e[n],i=o+"",t=M-i.length,t&&(s+=te(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function j(e,n,t){if(e!==~~e||e<n||e>t)throw Error(re+e)}function we(e,n,t,i){var r,s,o,u;for(s=e[0];s>=10;s/=10)--n;return--n<0?(n+=M,r=0):(r=Math.ceil((n+1)/M),n%=M),s=A(10,M-n),u=e[r]%s|0,i==null?n<3?(n==0?u=u/100|0:n==1&&(u=u/10|0),o=t<4&&u==99999||t>3&&u==49999||u==5e4||u==0):o=(t<4&&u+1==s||t>3&&u+1==s/2)&&(e[r+1]/s/100|0)==A(10,n-2)-1||(u==s/2||u==0)&&(e[r+1]/s/100|0)==0:n<4?(n==0?u=u/1e3|0:n==1?u=u/100|0:n==2&&(u=u/10|0),o=(i||t<4)&&u==9999||!i&&t>3&&u==4999):o=((i||t<4)&&u+1==s||!i&&t>3&&u+1==s/2)&&(e[r+1]/s/1e3|0)==A(10,n-3)-1,o}function ve(e,n,t){for(var i,r=[0],s,o=0,u=e.length;o<u;){for(s=r.length;s--;)r[s]*=n;for(r[0]+=Oe.indexOf(e.charAt(o++)),i=0;i<r.length;i++)r[i]>t-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/t|0,r[i]%=t)}return r.reverse()}function un(e,n){var t,i,r;if(n.isZero())return n;i=n.d.length,i<32?(t=Math.ceil(i/3),r=(1/De(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),e.precision+=t,n=de(e,1,n.times(r),new e(1));for(var s=t;s--;){var o=n.times(n);n=o.times(o).minus(o).times(8).plus(1)}return e.precision-=t,n}var b=function(){function e(i,r,s){var o,u=0,c=i.length;for(i=i.slice();c--;)o=i[c]*r+u,i[c]=o%s|0,u=o/s|0;return u&&i.unshift(u),i}function n(i,r,s,o){var u,c;if(s!=o)c=s>o?1:-1;else for(u=c=0;u<s;u++)if(i[u]!=r[u]){c=i[u]>r[u]?1:-1;break}return c}function t(i,r,s,o){for(var u=0;s--;)i[s]-=u,u=i[s]<r[s]?1:0,i[s]=u*o+i[s]-r[s];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,s,o,u,c){var f,a,l,h,m,k,S,Z,L,y,_,I,X,H,ae,ee,Q,P,C,z,oe=i.constructor,$=i.s==r.s?1:-1,g=i.d,p=r.d;if(!g||!g[0]||!p||!p[0])return new oe(!i.s||!r.s||(g?p&&g[0]==p[0]:!p)?NaN:g&&g[0]==0||!p?$*0:$/0);for(c?(m=1,a=i.e-r.e):(c=G,m=M,a=B(i.e/m)-B(r.e/m)),C=p.length,Q=g.length,L=new oe($),y=L.d=[],l=0;p[l]==(g[l]||0);l++);if(p[l]>(g[l]||0)&&a--,s==null?(H=s=oe.precision,o=oe.rounding):u?H=s+(i.e-r.e)+1:H=s,H<0)y.push(1),k=!0;else{if(H=H/m+2|0,l=0,C==1){for(h=0,p=p[0],H++;(l<Q||h)&&H--;l++)ae=h*c+(g[l]||0),y[l]=ae/p|0,h=ae%p|0;k=h||l<Q}else{for(h=c/(p[0]+1)|0,h>1&&(p=e(p,h,c),g=e(g,h,c),C=p.length,Q=g.length),ee=C,_=g.slice(0,C),I=_.length;I<C;)_[I++]=0;z=p.slice(),z.unshift(0),P=p[0],p[1]>=c/2&&++P;do h=0,f=n(p,_,C,I),f<0?(X=_[0],C!=I&&(X=X*c+(_[1]||0)),h=X/P|0,h>1?(h>=c&&(h=c-1),S=e(p,h,c),Z=S.length,I=_.length,f=n(S,_,Z,I),f==1&&(h--,t(S,C<Z?z:p,Z,c))):(h==0&&(f=h=1),S=p.slice()),Z=S.length,Z<I&&S.unshift(0),t(_,S,I,c),f==-1&&(I=_.length,f=n(p,_,C,I),f<1&&(h++,t(_,C<I?z:p,I,c))),I=_.length):f===0&&(h++,_=[0]),y[l++]=h,f&&_[0]?_[I++]=g[ee]||0:(_=[g[ee]],I=1);while((ee++<Q||_[0]!==void 0)&&H--);k=_[0]!==void 0}y[0]||y.shift()}if(m==1)L.e=a,Ue=k;else{for(l=1,h=y[0];h>=10;h/=10)l++;L.e=l+a*m-1,v(L,u?s+L.e+1:s,o,k)}return L}}();function v(e,n,t,i){var r,s,o,u,c,f,a,l,h,m=e.constructor;e:if(n!=null){if(l=e.d,!l)return e;for(r=1,u=l[0];u>=10;u/=10)r++;if(s=n-r,s<0)s+=M,o=n,a=l[h=0],c=a/A(10,r-o-1)%10|0;else if(h=Math.ceil((s+1)/M),u=l.length,h>=u)if(i){for(;u++<=h;)l.push(0);a=c=0,r=1,s%=M,o=s-M+1}else break e;else{for(a=u=l[h],r=1;u>=10;u/=10)r++;s%=M,o=s-M+r,c=o<0?0:a/A(10,r-o-1)%10|0}if(i=i||n<0||l[h+1]!==void 0||(o<0?a:a%A(10,r-o-1)),f=t<4?(c||i)&&(t==0||t==(e.s<0?3:2)):c>5||c==5&&(t==4||i||t==6&&(s>0?o>0?a/A(10,r-o):0:l[h-1])%10&1||t==(e.s<0?8:7)),n<1||!l[0])return l.length=0,f?(n-=e.e+1,l[0]=A(10,(M-n%M)%M),e.e=-n||0):l[0]=e.e=0,e;if(s==0?(l.length=h,u=1,h--):(l.length=h+1,u=A(10,M-s),l[h]=o>0?(a/A(10,r-o)%A(10,o)|0)*u:0),f)for(;;)if(h==0){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(e.e++,l[0]==G&&(l[0]=1));break}else{if(l[h]+=u,l[h]!=G)break;l[h--]=0,u=1}for(s=l.length;l[--s]===0;)l.pop()}return E&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function K(e,n,t){if(!e.isFinite())return Je(e);var i,r=e.e,s=U(e.d),o=s.length;return n?(t&&(i=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+te(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):r<0?(s="0."+te(-r-1)+s,t&&(i=t-o)>0&&(s+=te(i))):r>=o?(s+=te(r+1-o),t&&(i=t-r-1)>0&&(s=s+"."+te(i))):((i=r+1)<o&&(s=s.slice(0,i)+"."+s.slice(i)),t&&(i=t-o)>0&&(r+1===o&&(s+="."),s+=te(i))),s}function Ee(e,n){var t=e[0];for(n*=M;t>=10;t/=10)n++;return n}function $e(e,n,t){if(n>on)throw E=!0,t&&(e.precision=t),Error(Re);return v(new e(Ne),n,1,!0)}function J(e,n,t){if(n>Ce)throw Error(Re);return v(new e(Me),n,t,!0)}function je(e){var n=e.length-1,t=n*M+1;if(n=e[n],n){for(;n%10==0;n/=10)t--;for(n=e[0];n>=10;n/=10)t++}return t}function te(e){for(var n="";e--;)n+="0";return n}function ye(e,n,t,i){var r,s=new e(1),o=Math.ceil(i/M+4);for(E=!1;;){if(t%2&&(s=s.times(n),Pe(s.d,o)&&(r=!0)),t=B(t/2),t===0){t=s.d.length-1,r&&s.d[t]===0&&++s.d[t];break}n=n.times(n),Pe(n.d,o)}return E=!0,s}function Le(e){return e.d[e.d.length-1]&1}function Ve(e,n,t){for(var i,r=new e(n[0]),s=0;++s<n.length;)if(i=new e(n[s]),i.s)r[t](i)&&(r=i);else{r=i;break}return r}function _e(e,n){var t,i,r,s,o,u,c,f=0,a=0,l=0,h=e.constructor,m=h.rounding,k=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?(E=!1,c=k):c=n,u=new h(.03125);e.e>-2;)e=e.times(u),l+=5;for(i=Math.log(A(2,l))/Math.LN10*2+5|0,c+=i,t=s=o=new h(1),h.precision=c;;){if(s=v(s.times(e),c,1),t=t.times(++a),u=o.plus(b(s,t,c,1)),U(u.d).slice(0,c)===U(o.d).slice(0,c)){for(r=l;r--;)o=v(o.times(o),c,1);if(n==null)if(f<3&&we(o.d,c-i,m,f))h.precision=c+=10,t=s=u=new h(1),a=0,f++;else return v(o,h.precision=k,m,E=!0);else return h.precision=k,o}o=u}}function ie(e,n){var t,i,r,s,o,u,c,f,a,l,h,m=1,k=10,S=e,Z=S.d,L=S.constructor,y=L.rounding,_=L.precision;if(S.s<0||!Z||!Z[0]||!S.e&&Z[0]==1&&Z.length==1)return new L(Z&&!Z[0]?-1/0:S.s!=1?NaN:Z?0:S);if(n==null?(E=!1,a=_):a=n,L.precision=a+=k,t=U(Z),i=t.charAt(0),Math.abs(s=S.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)S=S.times(e),t=U(S.d),i=t.charAt(0),m++;s=S.e,i>1?(S=new L("0."+t),s++):S=new L(i+"."+t.slice(1))}else return f=$e(L,a+2,_).times(s+""),S=ie(new L(i+"."+t.slice(1)),a-k).plus(f),L.precision=_,n==null?v(S,_,y,E=!0):S;for(l=S,c=o=S=b(S.minus(1),S.plus(1),a,1),h=v(S.times(S),a,1),r=3;;){if(o=v(o.times(h),a,1),f=c.plus(b(o,new L(r),a,1)),U(f.d).slice(0,a)===U(c.d).slice(0,a))if(c=c.times(2),s!==0&&(c=c.plus($e(L,a+2,_).times(s+""))),c=b(c,new L(m),a,1),n==null)if(we(c.d,a-k,y,u))L.precision=a+=k,f=o=S=b(l.minus(1),l.plus(1),a,1),h=v(S.times(S),a,1),r=u=1;else return v(c,L.precision=_,y,E=!0);else return L.precision=_,c;c=f,r+=2}}function Je(e){return String(e.s*e.s/0)}function be(e,n){var t,i,r;for((t=n.indexOf("."))>-1&&(n=n.replace(".","")),(i=n.search(/e/i))>0?(t<0&&(t=i),t+=+n.slice(i+1),n=n.substring(0,i)):t<0&&(t=n.length),i=0;n.charCodeAt(i)===48;i++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(i,r),n){if(r-=i,e.e=t=t-i-1,e.d=[],i=(t+1)%M,t<0&&(i+=M),i<r){for(i&&e.d.push(+n.slice(0,i)),r-=M;i<r;)e.d.push(+n.slice(i,i+=M));n=n.slice(i),i=M-n.length}else i-=r;for(;i--;)n+="0";e.d.push(+n),E&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function fn(e,n){var t,i,r,s,o,u,c,f,a;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),We.test(n))return be(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(tn.test(n))t=16,n=n.toLowerCase();else if(nn.test(n))t=2;else if(rn.test(n))t=8;else throw Error(re+n);for(s=n.search(/p/i),s>0?(c=+n.slice(s+1),n=n.substring(2,s)):n=n.slice(2),s=n.indexOf("."),o=s>=0,i=e.constructor,o&&(n=n.replace(".",""),u=n.length,s=u-s,r=ye(i,new i(t),s,s*2)),f=ve(n,t,G),a=f.length-1,s=a;f[s]===0;--s)f.pop();return s<0?new i(e.s*0):(e.e=Ee(f,a),e.d=f,E=!1,o&&(e=b(e,r,u*4)),c&&(e=e.times(Math.abs(c)<54?A(2,c):W.pow(2,c))),E=!0,e)}function cn(e,n){var t,i=n.d.length;if(i<3)return n.isZero()?n:de(e,2,n,n);t=1.4*Math.sqrt(i),t=t>16?16:t|0,n=n.times(1/De(5,t)),n=de(e,2,n,n);for(var r,s=new e(5),o=new e(16),u=new e(20);t--;)r=n.times(n),n=n.times(s.plus(r.times(o.times(r).minus(u))));return n}function de(e,n,t,i,r){var s,o,u,c,f=e.precision,a=Math.ceil(f/M);for(E=!1,c=t.times(t),u=new e(i);;){if(o=b(u.times(c),new e(n++*n++),f,1),u=r?i.plus(o):i.minus(o),i=b(o.times(c),new e(n++*n++),f,1),o=u.plus(i),o.d[a]!==void 0){for(s=a;o.d[s]===u.d[s]&&s--;);if(s==-1)break}s=u,u=i,i=o,o=s}return E=!0,o.d.length=a+1,o}function De(e,n){for(var t=e;--n;)t*=e;return t}function Ge(e,n){var t,i=n.s<0,r=J(e,e.precision,1),s=r.times(.5);if(n=n.abs(),n.lte(s))return x=i?4:1,n;if(t=n.divToInt(r),t.isZero())x=i?3:2;else{if(n=n.minus(t.times(r)),n.lte(s))return x=Le(t)?i?2:3:i?4:1,n;x=Le(t)?i?1:4:i?3:2}return n.minus(r).abs()}function Te(e,n,t,i){var r,s,o,u,c,f,a,l,h,m=e.constructor,k=t!==void 0;if(k?(j(t,1,se),i===void 0?i=m.rounding:j(i,0,8)):(t=m.precision,i=m.rounding),!e.isFinite())a=Je(e);else{for(a=K(e),o=a.indexOf("."),k?(r=2,n==16?t=t*4-3:n==8&&(t=t*3-2)):r=n,o>=0&&(a=a.replace(".",""),h=new m(1),h.e=a.length-o,h.d=ve(K(h),10,r),h.e=h.d.length),l=ve(a,10,r),s=c=l.length;l[--c]==0;)l.pop();if(!l[0])a=k?"0p+0":"0";else{if(o<0?s--:(e=new m(e),e.d=l,e.e=s,e=b(e,h,t,i,0,r),l=e.d,s=e.e,f=Ue),o=l[t],u=r/2,f=f||l[t+1]!==void 0,f=i<4?(o!==void 0||f)&&(i===0||i===(e.s<0?3:2)):o>u||o===u&&(i===4||f||i===6&&l[t-1]&1||i===(e.s<0?8:7)),l.length=t,f)for(;++l[--t]>r-1;)l[t]=0,t||(++s,l.unshift(1));for(c=l.length;!l[c-1];--c);for(o=0,a="";o<c;o++)a+=Oe.charAt(l[o]);if(k){if(c>1)if(n==16||n==8){for(o=n==16?4:3,--c;c%o;c++)a+="0";for(l=ve(a,r,n),c=l.length;!l[c-1];--c);for(o=1,a="1.";o<c;o++)a+=Oe.charAt(l[o])}else a=a.charAt(0)+"."+a.slice(1);a=a+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)a="0"+a;a="0."+a}else if(++s>c)for(s-=c;s--;)a+="0";else s<c&&(a=a.slice(0,s)+"."+a.slice(s))}a=(n==16?"0x":n==2?"0b":n==8?"0o":"")+a}return e.s<0?"-"+a:a}function Pe(e,n){if(e.length>n)return e.length=n,!0}function an(e){return new this(e).abs()}function ln(e){return new this(e).acos()}function hn(e){return new this(e).acosh()}function dn(e,n){return new this(e).plus(n)}function pn(e){return new this(e).asin()}function gn(e){return new this(e).asinh()}function wn(e){return new this(e).atan()}function mn(e){return new this(e).atanh()}function vn(e,n){e=new this(e),n=new this(n);var t,i=this.precision,r=this.rounding,s=i+4;return!e.s||!n.s?t=new this(NaN):!e.d&&!n.d?(t=J(this,s,1).times(n.s>0?.25:.75),t.s=e.s):!n.d||e.isZero()?(t=n.s<0?J(this,i,r):new this(0),t.s=e.s):!e.d||n.isZero()?(t=J(this,s,1).times(.5),t.s=e.s):n.s<0?(this.precision=s,this.rounding=1,t=this.atan(b(e,n,s,1)),n=J(this,s,1),this.precision=i,this.rounding=r,t=e.s<0?t.minus(n):t.plus(n)):t=this.atan(b(e,n,s,1)),t}function Nn(e){return new this(e).cbrt()}function Mn(e){return v(e=new this(e),e.e+1,2)}function $n(e,n,t){return new this(e).clamp(n,t)}function Sn(e){if(!e||typeof e!="object")throw Error(Se+"Object expected");var n,t,i,r=e.defaults===!0,s=["precision",1,se,"rounding",0,8,"toExpNeg",-he,0,"toExpPos",0,he,"maxE",0,he,"minE",-he,0,"modulo",0,9];for(n=0;n<s.length;n+=3)if(t=s[n],r&&(this[t]=ke[t]),(i=e[t])!==void 0)if(B(i)===i&&i>=s[n+1]&&i<=s[n+2])this[t]=i;else throw Error(re+t+": "+i);if(t="crypto",r&&(this[t]=ke[t]),(i=e[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Be);else this[t]=!1;else throw Error(re+t+": "+i);return this}function En(e){return new this(e).cos()}function Dn(e){return new this(e).cosh()}function Xe(e){var n,t,i;function r(s){var o,u,c,f=this;if(!(f instanceof r))return new r(s);if(f.constructor=r,qe(s)){f.s=s.s,E?!s.d||s.e>r.maxE?(f.e=NaN,f.d=null):s.e<r.minE?(f.e=0,f.d=[0]):(f.e=s.e,f.d=s.d.slice()):(f.e=s.e,f.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){f.s=1/s<0?-1:1,f.e=0,f.d=[0];return}if(s<0?(s=-s,f.s=-1):f.s=1,s===~~s&&s<1e7){for(o=0,u=s;u>=10;u/=10)o++;E?o>r.maxE?(f.e=NaN,f.d=null):o<r.minE?(f.e=0,f.d=[0]):(f.e=o,f.d=[s]):(f.e=o,f.d=[s]);return}else if(s*0!==0){s||(f.s=NaN),f.e=NaN,f.d=null;return}return be(f,s.toString())}else if(c!=="string")throw Error(re+s);return(u=s.charCodeAt(0))===45?(s=s.slice(1),f.s=-1):(u===43&&(s=s.slice(1)),f.s=1),We.test(s)?be(f,s):fn(f,s)}if(r.prototype=d,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Sn,r.clone=Xe,r.isDecimal=qe,r.abs=an,r.acos=ln,r.acosh=hn,r.add=dn,r.asin=pn,r.asinh=gn,r.atan=wn,r.atanh=mn,r.atan2=vn,r.cbrt=Nn,r.ceil=Mn,r.clamp=$n,r.cos=En,r.cosh=Dn,r.div=On,r.exp=kn,r.floor=Cn,r.hypot=_n,r.ln=bn,r.log=Tn,r.log10=Pn,r.log2=Ln,r.max=qn,r.min=An,r.mod=In,r.mul=Fn,r.pow=Zn,r.random=Hn,r.round=Un,r.sign=Rn,r.sin=Bn,r.sinh=Yn,r.sqrt=Wn,r.sub=jn,r.sum=yn,r.tan=Vn,r.tanh=Jn,r.trunc=Gn,e===void 0&&(e={}),e&&e.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<i.length;)e.hasOwnProperty(t=i[n++])||(e[t]=this[t]);return r.config(e),r}function On(e,n){return new this(e).div(n)}function kn(e){return new this(e).exp()}function Cn(e){return v(e=new this(e),e.e+1,3)}function _n(){var e,n,t=new this(0);for(E=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)t.d&&(t=t.plus(n.times(n)));else{if(n.s)return E=!0,new this(1/0);t=n}return E=!0,t.sqrt()}function qe(e){return e instanceof W||e&&e.toStringTag===Ye||!1}function bn(e){return new this(e).ln()}function Tn(e,n){return new this(e).log(n)}function Ln(e){return new this(e).log(2)}function Pn(e){return new this(e).log(10)}function qn(){return Ve(this,arguments,"lt")}function An(){return Ve(this,arguments,"gt")}function In(e,n){return new this(e).mod(n)}function Fn(e,n){return new this(e).mul(n)}function Zn(e,n){return new this(e).pow(n)}function Hn(e){var n,t,i,r,s=0,o=new this(1),u=[];if(e===void 0?e=this.precision:j(e,1,se),i=Math.ceil(e/M),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(i));s<i;)r=n[s],r>=429e7?n[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(i*=4);s<i;)r=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+((n[s+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(n,s):(u.push(r%1e7),s+=4);s=i/4}else throw Error(Be);else for(;s<i;)u[s++]=Math.random()*1e7|0;for(i=u[--s],e%=M,i&&e&&(r=A(10,M-e),u[s]=(i/r|0)*r);u[s]===0;s--)u.pop();if(s<0)t=0,u=[0];else{for(t=-1;u[0]===0;t-=M)u.shift();for(i=1,r=u[0];r>=10;r/=10)i++;i<M&&(t-=M-i)}return o.e=t,o.d=u,o}function Un(e){return v(e=new this(e),e.e+1,this.rounding)}function Rn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Bn(e){return new this(e).sin()}function Yn(e){return new this(e).sinh()}function Wn(e){return new this(e).sqrt()}function jn(e,n){return new this(e).sub(n)}function yn(){var e=0,n=arguments,t=new this(n[e]);for(E=!1;t.s&&++e<n.length;)t=t.plus(n[e]);return E=!0,v(t,this.precision,this.rounding)}function Vn(e){return new this(e).tan()}function Jn(e){return new this(e).tanh()}function Gn(e){return v(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var W=d.constructor=Xe(ke);Ne=new W(Ne);Me=new W(Me);const Qe=(e,n,t)=>{const i=(t==null?void 0:t.utc)??new W(ce(e).utcOffset()).div(60).toNumber(),r=new W(15).mul(new W(Math.abs(i))),s=new W(360).div(365).mul(new W(ce(e).dayOfYear()).minus(81)),o=s.mul(Math.PI).div(180),u=new W(9.87).mul(o.mul(2).sin()).minus(new W(7.53).mul(o.cos())).minus(new W(1.5).mul(o.sin())),c=new W(4).mul(new W(n).minus(r)).plus(u);return{LST:ce(e).add(c.toNumber(),"minute"),TC:c.toString(),EoT:u,B:s,LSTM:r}},Xn=(e,n)=>Qe(new Date,e,n);exports.Solar=He;exports.SolarNow=en;exports.SolarNowPrecise=Xn;exports.SolarPrecise=Qe;