@omnity/ree-client-ts-sdk 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -79,4 +79,4 @@ PROCEED WITH CAUTION!
79
79
  * https://github.com/MikeMcl/decimal.js
80
80
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
81
81
  * MIT Licence
82
- */var as=9e15,fi=1e9,Gf="0123456789abcdef",_a="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Sa="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Df={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-as,maxE:as,crypto:!1},uw,gr,Te=!0,su="[DecimalError] ",oi=su+"Invalid argument: ",fw=su+"Precision limit exceeded",lw=su+"crypto unavailable",hw="[object Decimal]",Lt=Math.floor,bt=Math.pow,Hx=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Fx=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Mx=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,dw=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Fn=1e7,be=7,qx=9007199254740991,Vx=_a.length-1,Xf=Sa.length-1,ie={toStringTag:hw};ie.absoluteValue=ie.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),we(e)};ie.ceil=function(){return we(new this.constructor(this),this.e+1,2)};ie.clampedTo=ie.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(oi+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)};ie.comparedTo=ie.cmp=function(e){var t,n,r,i,s=this,o=s.d,c=(e=new s.constructor(e)).d,a=s.s,u=e.s;if(!o||!c)return!a||!u?NaN:a!==u?a:o===c?0:!o^a<0?1:-1;if(!o[0]||!c[0])return o[0]?a:c[0]?-u:0;if(a!==u)return a;if(s.e!==e.e)return s.e>e.e^a<0?1:-1;for(r=o.length,i=c.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==c[t])return o[t]>c[t]^a<0?1:-1;return r===i?0:r>i^a<0?1:-1};ie.cosine=ie.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+be,r.rounding=1,n=Lx(r,mw(r,n)),r.precision=e,r.rounding=t,we(gr==2||gr==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};ie.cubeRoot=ie.cbrt=function(){var e,t,n,r,i,s,o,c,a,u,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(Te=!1,s=f.s*bt(f.s*f,1/3),!s||Math.abs(s)==1/0?(n=Pt(f.d),e=f.e,(s=(e-n.length+1)%3)&&(n+=s==1||s==-2?"0":"00"),s=bt(n,1/3),e=Lt((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?n="5e"+e:(n=s.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new l(n),r.s=f.s):r=new l(s.toString()),o=(e=l.precision)+3;;)if(c=r,a=c.times(c).times(c),u=a.plus(f),r=De(u.plus(f).times(c),u.plus(a),o+2,1),Pt(c.d).slice(0,o)===(n=Pt(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n=="9999"||!i&&n=="4999"){if(!i&&(we(c,e+1,0),c.times(c).times(c).eq(f))){r=c;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(we(r,e+1,1),t=!r.times(r).times(r).eq(f));break}return Te=!0,we(r,e,l.rounding,t)};ie.decimalPlaces=ie.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Lt(this.e/be))*be,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};ie.dividedBy=ie.div=function(e){return De(this,new this.constructor(e))};ie.dividedToIntegerBy=ie.divToInt=function(e){var t=this,n=t.constructor;return we(De(t,new n(e),0,1,1),n.precision,n.rounding)};ie.equals=ie.eq=function(e){return this.cmp(e)===0};ie.floor=function(){return we(new this.constructor(this),this.e+1,3)};ie.greaterThan=ie.gt=function(e){return this.cmp(e)>0};ie.greaterThanOrEqualTo=ie.gte=function(e){var t=this.cmp(e);return t==1||t===0};ie.hyperbolicCosine=ie.cosh=function(){var e,t,n,r,i,s=this,o=s.constructor,c=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return c;n=o.precision,r=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(e=Math.ceil(i/3),t=(1/cu(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=As(o,1,s.times(t),new o(1),!0);for(var a,u=e,f=new o(8);u--;)a=s.times(s),s=c.minus(a.times(f.minus(a.times(f))));return we(s,o.precision=n,o.rounding=r,!0)};ie.hyperbolicSine=ie.sinh=function(){var e,t,n,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.precision,n=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length,r<3)i=As(s,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/cu(5,e)),i=As(s,2,i,i,!0);for(var o,c=new s(5),a=new s(16),u=new s(20);e--;)o=i.times(i),i=i.times(c.plus(o.times(a.times(o).plus(u))))}return s.precision=t,s.rounding=n,we(i,t,n,!0)};ie.hyperbolicTangent=ie.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,De(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};ie.inverseCosine=ie.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n!==-1?n===0?e.isNeg()?Xn(t,r,i):new t(0):new t(NaN):e.isZero()?Xn(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2))};ie.inverseHyperbolicCosine=ie.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,Te=!1,n=n.times(n).minus(1).sqrt().plus(n),Te=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)};ie.inverseHyperbolicSine=ie.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,Te=!1,n=n.times(n).plus(1).sqrt().plus(n),Te=!0,r.precision=e,r.rounding=t,n.ln())};ie.inverseHyperbolicTangent=ie.atanh=function(){var e,t,n,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?we(new s(i),e,t,!0):(s.precision=n=r-i.e,i=De(i.plus(1),new s(1).minus(i),n+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)};ie.inverseSine=ie.asin=function(){var e,t,n,r,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),n=s.precision,r=s.rounding,t!==-1?t===0?(e=Xn(s,n+4,r).times(.5),e.s=i.s,e):new s(NaN):(s.precision=n+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=r,i.times(2)))};ie.inverseTangent=ie.atan=function(){var e,t,n,r,i,s,o,c,a,u=this,f=u.constructor,l=f.precision,p=f.rounding;if(u.isFinite()){if(u.isZero())return new f(u);if(u.abs().eq(1)&&l+4<=Xf)return o=Xn(f,l+4,p).times(.25),o.s=u.s,o}else{if(!u.s)return new f(NaN);if(l+4<=Xf)return o=Xn(f,l+4,p).times(.5),o.s=u.s,o}for(f.precision=c=l+10,f.rounding=1,n=Math.min(28,c/be+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(Te=!1,t=Math.ceil(c/be),r=1,a=u.times(u),o=new f(u),i=u;e!==-1;)if(i=i.times(a),s=o.minus(i.div(r+=2)),i=i.times(a),o=s.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===s.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),Te=!0,we(o,f.precision=l,f.rounding=p,!0)};ie.isFinite=function(){return!!this.d};ie.isInteger=ie.isInt=function(){return!!this.d&&Lt(this.e/be)>this.d.length-2};ie.isNaN=function(){return!this.s};ie.isNegative=ie.isNeg=function(){return this.s<0};ie.isPositive=ie.isPos=function(){return this.s>0};ie.isZero=function(){return!!this.d&&this.d[0]===0};ie.lessThan=ie.lt=function(e){return this.cmp(e)<0};ie.lessThanOrEqualTo=ie.lte=function(e){return this.cmp(e)<1};ie.logarithm=ie.log=function(e){var t,n,r,i,s,o,c,a,u=this,f=u.constructor,l=f.precision,p=f.rounding,y=5;if(e==null)e=new f(10),t=!0;else{if(e=new f(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new f(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new f(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)s=!0;else{for(i=n[0];i%10===0;)i/=10;s=i!==1}if(Te=!1,c=l+y,o=Qr(u,c),r=t?Ta(f,c+10):Qr(e,c),a=De(o,r,c,1),Po(a.d,i=l,p))do if(c+=10,o=Qr(u,c),r=t?Ta(f,c+10):Qr(e,c),a=De(o,r,c,1),!s){+Pt(a.d).slice(i+1,i+15)+1==1e14&&(a=we(a,l+1,0));break}while(Po(a.d,i+=10,p));return Te=!0,we(a,l,p)};ie.minus=ie.sub=function(e){var t,n,r,i,s,o,c,a,u,f,l,p,y=this,g=y.constructor;if(e=new g(e),!y.d||!e.d)return!y.s||!e.s?e=new g(NaN):y.d?e.s=-e.s:e=new g(e.d||y.s!==e.s?y:NaN),e;if(y.s!=e.s)return e.s=-e.s,y.plus(e);if(u=y.d,p=e.d,c=g.precision,a=g.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else if(u[0])e=new g(y);else return new g(a===3?-0:0);return Te?we(e,c,a):e}if(n=Lt(e.e/be),f=Lt(y.e/be),u=u.slice(),s=f-n,s){for(l=s<0,l?(t=u,s=-s,o=p.length):(t=p,n=f,o=u.length),r=Math.max(Math.ceil(c/be),o)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=u.length,o=p.length,l=r<o,l&&(o=r),r=0;r<o;r++)if(u[r]!=p[r]){l=u[r]<p[r];break}s=0}for(l&&(t=u,u=p,p=t,e.s=-e.s),o=u.length,r=p.length-o;r>0;--r)u[o++]=0;for(r=p.length;r>s;){if(u[--r]<p[r]){for(i=r;i&&u[--i]===0;)u[i]=Fn-1;--u[i],u[r]+=Fn}u[r]-=p[r]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=ou(u,n),Te?we(e,c,a):e):new g(a===3?-0:0)};ie.modulo=ie.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?we(new r(n),r.precision,r.rounding):(Te=!1,r.modulo==9?(t=De(n,e.abs(),0,3,1),t.s*=e.s):t=De(n,e,0,r.modulo,1),t=t.times(e),Te=!0,n.minus(t))};ie.naturalExponential=ie.exp=function(){return zf(this)};ie.naturalLogarithm=ie.ln=function(){return Qr(this)};ie.negated=ie.neg=function(){var e=new this.constructor(this);return e.s=-e.s,we(e)};ie.plus=ie.add=function(e){var t,n,r,i,s,o,c,a,u,f,l=this,p=l.constructor;if(e=new p(e),!l.d||!e.d)return!l.s||!e.s?e=new p(NaN):l.d||(e=new p(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(u=l.d,f=e.d,c=p.precision,a=p.rounding,!u[0]||!f[0])return f[0]||(e=new p(l)),Te?we(e,c,a):e;if(s=Lt(l.e/be),r=Lt(e.e/be),u=u.slice(),i=s-r,i){for(i<0?(n=u,i=-i,o=f.length):(n=f,r=s,o=u.length),s=Math.ceil(c/be),o=s>o?s+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=u.length,i=f.length,o-i<0&&(i=o,n=f,f=u,u=n),t=0;i;)t=(u[--i]=u[i]+f[i]+t)/Fn|0,u[i]%=Fn;for(t&&(u.unshift(t),++r),o=u.length;u[--o]==0;)u.pop();return e.d=u,e.e=ou(u,r),Te?we(e,c,a):e};ie.precision=ie.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(oi+e);return n.d?(t=pw(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};ie.round=function(){var e=this,t=e.constructor;return we(new t(e),e.e+1,t.rounding)};ie.sine=ie.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+be,r.rounding=1,n=$x(r,mw(r,n)),r.precision=e,r.rounding=t,we(gr>2?n.neg():n,e,t,!0)):new r(NaN)};ie.squareRoot=ie.sqrt=function(){var e,t,n,r,i,s,o=this,c=o.d,a=o.e,u=o.s,f=o.constructor;if(u!==1||!c||!c[0])return new f(!u||u<0&&(!c||c[0])?NaN:c?o:1/0);for(Te=!1,u=Math.sqrt(+o),u==0||u==1/0?(t=Pt(c),(t.length+a)%2==0&&(t+="0"),u=Math.sqrt(t),a=Lt((a+1)/2)-(a<0||a%2),u==1/0?t="5e"+a:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+a),r=new f(t)):r=new f(u.toString()),n=(a=f.precision)+3;;)if(s=r,r=s.plus(De(o,s,n+2,1)).times(.5),Pt(s.d).slice(0,n)===(t=Pt(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!i&&t=="4999"){if(!i&&(we(s,a+1,0),s.times(s).eq(o))){r=s;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(we(r,a+1,1),e=!r.times(r).eq(o));break}return Te=!0,we(r,a,f.rounding,e)};ie.tangent=ie.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=De(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,we(gr==2||gr==4?n.neg():n,e,t,!0)):new r(NaN)};ie.times=ie.mul=function(e){var t,n,r,i,s,o,c,a,u,f=this,l=f.constructor,p=f.d,y=(e=new l(e)).d;if(e.s*=f.s,!p||!p[0]||!y||!y[0])return new l(!e.s||p&&!p[0]&&!y||y&&!y[0]&&!p?NaN:!p||!y?e.s/0:e.s*0);for(n=Lt(f.e/be)+Lt(e.e/be),a=p.length,u=y.length,a<u&&(s=p,p=y,y=s,o=a,a=u,u=o),s=[],o=a+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(t=0,i=a+r;i>r;)c=s[i]+y[r]*p[i-r-1]+t,s[i--]=c%Fn|0,t=c/Fn|0;s[i]=(s[i]+t)%Fn|0}for(;!s[--o];)s.pop();return t?++n:s.shift(),e.d=s,e.e=ou(s,n),Te?we(e,l.precision,l.rounding):e};ie.toBinary=function(e,t){return th(this,2,e,t)};ie.toDecimalPlaces=ie.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(fn(e,0,fi),t===void 0?t=r.rounding:fn(t,0,8),we(n,e+n.e+1,t))};ie.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Zn(r,!0):(fn(e,0,fi),t===void 0?t=i.rounding:fn(t,0,8),r=we(new i(r),e+1,t),n=Zn(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};ie.toFixed=function(e,t){var n,r,i=this,s=i.constructor;return e===void 0?n=Zn(i):(fn(e,0,fi),t===void 0?t=s.rounding:fn(t,0,8),r=we(new s(i),e+i.e+1,t),n=Zn(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};ie.toFraction=function(e){var t,n,r,i,s,o,c,a,u,f,l,p,y=this,g=y.d,w=y.constructor;if(!g)return new w(y);if(u=n=new w(1),r=a=new w(0),t=new w(r),s=t.e=pw(g)-y.e-1,o=s%be,t.d[0]=bt(10,o<0?be+o:o),e==null)e=s>0?t:u;else{if(c=new w(e),!c.isInt()||c.lt(u))throw Error(oi+c);e=c.gt(t)?s>0?t:u:c}for(Te=!1,c=new w(Pt(g)),f=w.precision,w.precision=s=g.length*be*2;l=De(c,t,0,1,1),i=n.plus(l.times(r)),i.cmp(e)!=1;)n=r,r=i,i=u,u=a.plus(l.times(i)),a=i,i=t,t=c.minus(l.times(i)),c=i;return i=De(e.minus(n),r,0,1,1),a=a.plus(i.times(u)),n=n.plus(i.times(r)),a.s=u.s=y.s,p=De(u,r,s,1).minus(y).abs().cmp(De(a,n,s,1).minus(y).abs())<1?[u,r]:[a,n],w.precision=f,Te=!0,p};ie.toHexadecimal=ie.toHex=function(e,t){return th(this,16,e,t)};ie.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:fn(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(Te=!1,n=De(n,e,0,t,1).times(e),Te=!0,we(n)):(e.s=n.s,n=e),n};ie.toNumber=function(){return+this};ie.toOctal=function(e,t){return th(this,8,e,t)};ie.toPower=ie.pow=function(e){var t,n,r,i,s,o,c=this,a=c.constructor,u=+(e=new a(e));if(!c.d||!e.d||!c.d[0]||!e.d[0])return new a(bt(+c,u));if(c=new a(c),c.eq(1))return c;if(r=a.precision,s=a.rounding,e.eq(1))return we(c,r,s);if(t=Lt(e.e/be),t>=e.d.length-1&&(n=u<0?-u:u)<=qx)return i=yw(a,c,n,r),e.s<0?new a(1).div(i):we(i,r,s);if(o=c.s,o<0){if(t<e.d.length-1)return new a(NaN);if((e.d[t]&1)==0&&(o=1),c.e==0&&c.d[0]==1&&c.d.length==1)return c.s=o,c}return n=bt(+c,u),t=n==0||!isFinite(n)?Lt(u*(Math.log("0."+Pt(c.d))/Math.LN10+c.e+1)):new a(n+"").e,t>a.maxE+1||t<a.minE-1?new a(t>0?o/0:0):(Te=!1,a.rounding=c.s=1,n=Math.min(12,(t+"").length),i=zf(e.times(Qr(c,r+n)),r),i.d&&(i=we(i,r+5,1),Po(i.d,r,s)&&(t=r+10,i=we(zf(e.times(Qr(c,t+n)),t),t+5,1),+Pt(i.d).slice(r+1,r+15)+1==1e14&&(i=we(i,r+1,0)))),i.s=o,Te=!0,a.rounding=s,we(i,r,s))};ie.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Zn(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(fn(e,1,fi),t===void 0?t=i.rounding:fn(t,0,8),r=we(new i(r),e,t),n=Zn(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n};ie.toSignificantDigits=ie.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(fn(e,1,fi),t===void 0?t=r.rounding:fn(t,0,8)),we(new r(n),e,t)};ie.toString=function(){var e=this,t=e.constructor,n=Zn(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};ie.truncated=ie.trunc=function(){return we(new this.constructor(this),this.e+1,1)};ie.valueOf=ie.toJSON=function(){var e=this,t=e.constructor,n=Zn(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function Pt(e){var t,n,r,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,t=1;t<i;t++)r=e[t]+"",n=be-r.length,n&&(s+=Yr(n)),s+=r;o=e[t],r=o+"",n=be-r.length,n&&(s+=Yr(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function fn(e,t,n){if(e!==~~e||e<t||e>n)throw Error(oi+e)}function Po(e,t,n,r){var i,s,o,c;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=be,i=0):(i=Math.ceil((t+1)/be),t%=be),s=bt(10,be-t),c=e[i]%s|0,r==null?t<3?(t==0?c=c/100|0:t==1&&(c=c/10|0),o=n<4&&c==99999||n>3&&c==49999||c==5e4||c==0):o=(n<4&&c+1==s||n>3&&c+1==s/2)&&(e[i+1]/s/100|0)==bt(10,t-2)-1||(c==s/2||c==0)&&(e[i+1]/s/100|0)==0:t<4?(t==0?c=c/1e3|0:t==1?c=c/100|0:t==2&&(c=c/10|0),o=(r||n<4)&&c==9999||!r&&n>3&&c==4999):o=((r||n<4)&&c+1==s||!r&&n>3&&c+1==s/2)&&(e[i+1]/s/1e3|0)==bt(10,t-3)-1,o}function Kc(e,t,n){for(var r,i=[0],s,o=0,c=e.length;o<c;){for(s=i.length;s--;)i[s]*=t;for(i[0]+=Gf.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Lx(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/cu(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),e.precision+=n,t=As(e,1,t.times(i),new e(1));for(var s=n;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var De=(function(){function e(r,i,s){var o,c=0,a=r.length;for(r=r.slice();a--;)o=r[a]*i+c,r[a]=o%s|0,c=o/s|0;return c&&r.unshift(c),r}function t(r,i,s,o){var c,a;if(s!=o)a=s>o?1:-1;else for(c=a=0;c<s;c++)if(r[c]!=i[c]){a=r[c]>i[c]?1:-1;break}return a}function n(r,i,s,o){for(var c=0;s--;)r[s]-=c,c=r[s]<i[s]?1:0,r[s]=c*o+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o,c,a){var u,f,l,p,y,g,w,E,_,S,m,T,I,A,U,M,v,R,V,W,H=r.constructor,K=r.s==i.s?1:-1,N=r.d,$=i.d;if(!N||!N[0]||!$||!$[0])return new H(!r.s||!i.s||(N?$&&N[0]==$[0]:!$)?NaN:N&&N[0]==0||!$?K*0:K/0);for(a?(y=1,f=r.e-i.e):(a=Fn,y=be,f=Lt(r.e/y)-Lt(i.e/y)),V=$.length,v=N.length,_=new H(K),S=_.d=[],l=0;$[l]==(N[l]||0);l++);if($[l]>(N[l]||0)&&f--,s==null?(A=s=H.precision,o=H.rounding):c?A=s+(r.e-i.e)+1:A=s,A<0)S.push(1),g=!0;else{if(A=A/y+2|0,l=0,V==1){for(p=0,$=$[0],A++;(l<v||p)&&A--;l++)U=p*a+(N[l]||0),S[l]=U/$|0,p=U%$|0;g=p||l<v}else{for(p=a/($[0]+1)|0,p>1&&($=e($,p,a),N=e(N,p,a),V=$.length,v=N.length),M=V,m=N.slice(0,V),T=m.length;T<V;)m[T++]=0;W=$.slice(),W.unshift(0),R=$[0],$[1]>=a/2&&++R;do p=0,u=t($,m,V,T),u<0?(I=m[0],V!=T&&(I=I*a+(m[1]||0)),p=I/R|0,p>1?(p>=a&&(p=a-1),w=e($,p,a),E=w.length,T=m.length,u=t(w,m,E,T),u==1&&(p--,n(w,V<E?W:$,E,a))):(p==0&&(u=p=1),w=$.slice()),E=w.length,E<T&&w.unshift(0),n(m,w,T,a),u==-1&&(T=m.length,u=t($,m,V,T),u<1&&(p++,n(m,V<T?W:$,T,a))),T=m.length):u===0&&(p++,m=[0]),S[l++]=p,u&&m[0]?m[T++]=N[M]||0:(m=[N[M]],T=1);while((M++<v||m[0]!==void 0)&&A--);g=m[0]!==void 0}S[0]||S.shift()}if(y==1)_.e=f,uw=g;else{for(l=1,p=S[0];p>=10;p/=10)l++;_.e=l+f*y-1,we(_,c?s+_.e+1:s,o,g)}return _}})();function we(e,t,n,r){var i,s,o,c,a,u,f,l,p,y=e.constructor;e:if(t!=null){if(l=e.d,!l)return e;for(i=1,c=l[0];c>=10;c/=10)i++;if(s=t-i,s<0)s+=be,o=t,f=l[p=0],a=f/bt(10,i-o-1)%10|0;else if(p=Math.ceil((s+1)/be),c=l.length,p>=c)if(r){for(;c++<=p;)l.push(0);f=a=0,i=1,s%=be,o=s-be+1}else break e;else{for(f=c=l[p],i=1;c>=10;c/=10)i++;s%=be,o=s-be+i,a=o<0?0:f/bt(10,i-o-1)%10|0}if(r=r||t<0||l[p+1]!==void 0||(o<0?f:f%bt(10,i-o-1)),u=n<4?(a||r)&&(n==0||n==(e.s<0?3:2)):a>5||a==5&&(n==4||r||n==6&&(s>0?o>0?f/bt(10,i-o):0:l[p-1])%10&1||n==(e.s<0?8:7)),t<1||!l[0])return l.length=0,u?(t-=e.e+1,l[0]=bt(10,(be-t%be)%be),e.e=-t||0):l[0]=e.e=0,e;if(s==0?(l.length=p,c=1,p--):(l.length=p+1,c=bt(10,be-s),l[p]=o>0?(f/bt(10,i-o)%bt(10,o)|0)*c:0),u)for(;;)if(p==0){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=c,c=1;o>=10;o/=10)c++;s!=c&&(e.e++,l[0]==Fn&&(l[0]=1));break}else{if(l[p]+=c,l[p]!=Fn)break;l[p--]=0,c=1}for(s=l.length;l[--s]===0;)l.pop()}return Te&&(e.e>y.maxE?(e.d=null,e.e=NaN):e.e<y.minE&&(e.e=0,e.d=[0])),e}function Zn(e,t,n){if(!e.isFinite())return ww(e);var r,i=e.e,s=Pt(e.d),o=s.length;return t?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+Yr(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+Yr(-i-1)+s,n&&(r=n-o)>0&&(s+=Yr(r))):i>=o?(s+=Yr(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+Yr(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=Yr(r))),s}function ou(e,t){var n=e[0];for(t*=be;n>=10;n/=10)t++;return t}function Ta(e,t,n){if(t>Vx)throw Te=!0,n&&(e.precision=n),Error(fw);return we(new e(_a),t,1,!0)}function Xn(e,t,n){if(t>Xf)throw Error(fw);return we(new e(Sa),t,n,!0)}function pw(e){var t=e.length-1,n=t*be+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function Yr(e){for(var t="";e--;)t+="0";return t}function yw(e,t,n,r){var i,s=new e(1),o=Math.ceil(r/be+4);for(Te=!1;;){if(n%2&&(s=s.times(t),Mp(s.d,o)&&(i=!0)),n=Lt(n/2),n===0){n=s.d.length-1,i&&s.d[n]===0&&++s.d[n];break}t=t.times(t),Mp(t.d,o)}return Te=!0,s}function Fp(e){return e.d[e.d.length-1]&1}function gw(e,t,n){for(var r,i,s=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){s=i;break}r=s.cmp(i),(r===n||r===0&&s.s===n)&&(s=i)}return s}function zf(e,t){var n,r,i,s,o,c,a,u=0,f=0,l=0,p=e.constructor,y=p.rounding,g=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(Te=!1,a=g):a=t,c=new p(.03125);e.e>-2;)e=e.times(c),l+=5;for(r=Math.log(bt(2,l))/Math.LN10*2+5|0,a+=r,n=s=o=new p(1),p.precision=a;;){if(s=we(s.times(e),a,1),n=n.times(++f),c=o.plus(De(s,n,a,1)),Pt(c.d).slice(0,a)===Pt(o.d).slice(0,a)){for(i=l;i--;)o=we(o.times(o),a,1);if(t==null)if(u<3&&Po(o.d,a-r,y,u))p.precision=a+=10,n=s=c=new p(1),f=0,u++;else return we(o,p.precision=g,y,Te=!0);else return p.precision=g,o}o=c}}function Qr(e,t){var n,r,i,s,o,c,a,u,f,l,p,y=1,g=10,w=e,E=w.d,_=w.constructor,S=_.rounding,m=_.precision;if(w.s<0||!E||!E[0]||!w.e&&E[0]==1&&E.length==1)return new _(E&&!E[0]?-1/0:w.s!=1?NaN:E?0:w);if(t==null?(Te=!1,f=m):f=t,_.precision=f+=g,n=Pt(E),r=n.charAt(0),Math.abs(s=w.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)w=w.times(e),n=Pt(w.d),r=n.charAt(0),y++;s=w.e,r>1?(w=new _("0."+n),s++):w=new _(r+"."+n.slice(1))}else return u=Ta(_,f+2,m).times(s+""),w=Qr(new _(r+"."+n.slice(1)),f-g).plus(u),_.precision=m,t==null?we(w,m,S,Te=!0):w;for(l=w,a=o=w=De(w.minus(1),w.plus(1),f,1),p=we(w.times(w),f,1),i=3;;){if(o=we(o.times(p),f,1),u=a.plus(De(o,new _(i),f,1)),Pt(u.d).slice(0,f)===Pt(a.d).slice(0,f))if(a=a.times(2),s!==0&&(a=a.plus(Ta(_,f+2,m).times(s+""))),a=De(a,new _(y),f,1),t==null)if(Po(a.d,f-g,S,c))_.precision=f+=g,u=o=w=De(l.minus(1),l.plus(1),f,1),p=we(w.times(w),f,1),i=c=1;else return we(a,_.precision=m,S,Te=!0);else return _.precision=m,a;a=u,i+=2}}function ww(e){return String(e.s*e.s/0)}function $c(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%be,n<0&&(r+=be),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=be;r<i;)e.d.push(+t.slice(r,r+=be));t=t.slice(r),r=be-t.length}else r-=i;for(;r--;)t+="0";e.d.push(+t),Te&&(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 Kx(e,t){var n,r,i,s,o,c,a,u,f;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),dw.test(t))return $c(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Fx.test(t))n=16,t=t.toLowerCase();else if(Hx.test(t))n=2;else if(Mx.test(t))n=8;else throw Error(oi+t);for(s=t.search(/p/i),s>0?(a=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),o=s>=0,r=e.constructor,o&&(t=t.replace(".",""),c=t.length,s=c-s,i=yw(r,new r(n),s,s*2)),u=Kc(t,n,Fn),f=u.length-1,s=f;u[s]===0;--s)u.pop();return s<0?new r(e.s*0):(e.e=ou(u,f),e.d=u,Te=!1,o&&(e=De(e,i,c*4)),a&&(e=e.times(Math.abs(a)<54?bt(2,a):ei.pow(2,a))),Te=!0,e)}function $x(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:As(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/cu(5,n)),t=As(e,2,t,t);for(var i,s=new e(5),o=new e(16),c=new e(20);n--;)i=t.times(t),t=t.times(s.plus(i.times(o.times(i).minus(c))));return t}function As(e,t,n,r,i){var s,o,c,a,u=e.precision,f=Math.ceil(u/be);for(Te=!1,a=n.times(n),c=new e(r);;){if(o=De(c.times(a),new e(t++*t++),u,1),c=i?r.plus(o):r.minus(o),r=De(o.times(a),new e(t++*t++),u,1),o=c.plus(r),o.d[f]!==void 0){for(s=f;o.d[s]===c.d[s]&&s--;);if(s==-1)break}s=c,c=r,r=o,o=s}return Te=!0,o.d.length=f+1,o}function cu(e,t){for(var n=e;--t;)n*=e;return n}function mw(e,t){var n,r=t.s<0,i=Xn(e,e.precision,1),s=i.times(.5);if(t=t.abs(),t.lte(s))return gr=r?4:1,t;if(n=t.divToInt(i),n.isZero())gr=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(s))return gr=Fp(n)?r?2:3:r?4:1,t;gr=Fp(n)?r?1:4:r?3:2}return t.minus(i).abs()}function th(e,t,n,r){var i,s,o,c,a,u,f,l,p,y=e.constructor,g=n!==void 0;if(g?(fn(n,1,fi),r===void 0?r=y.rounding:fn(r,0,8)):(n=y.precision,r=y.rounding),!e.isFinite())f=ww(e);else{for(f=Zn(e),o=f.indexOf("."),g?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(f=f.replace(".",""),p=new y(1),p.e=f.length-o,p.d=Kc(Zn(p),10,i),p.e=p.d.length),l=Kc(f,10,i),s=a=l.length;l[--a]==0;)l.pop();if(!l[0])f=g?"0p+0":"0";else{if(o<0?s--:(e=new y(e),e.d=l,e.e=s,e=De(e,p,n,r,0,i),l=e.d,s=e.e,u=uw),o=l[n],c=i/2,u=u||l[n+1]!==void 0,u=r<4?(o!==void 0||u)&&(r===0||r===(e.s<0?3:2)):o>c||o===c&&(r===4||u||r===6&&l[n-1]&1||r===(e.s<0?8:7)),l.length=n,u)for(;++l[--n]>i-1;)l[n]=0,n||(++s,l.unshift(1));for(a=l.length;!l[a-1];--a);for(o=0,f="";o<a;o++)f+=Gf.charAt(l[o]);if(g){if(a>1)if(t==16||t==8){for(o=t==16?4:3,--a;a%o;a++)f+="0";for(l=Kc(f,i,t),a=l.length;!l[a-1];--a);for(o=1,f="1.";o<a;o++)f+=Gf.charAt(l[o])}else f=f.charAt(0)+"."+f.slice(1);f=f+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)f="0"+f;f="0."+f}else if(++s>a)for(s-=a;s--;)f+="0";else s<a&&(f=f.slice(0,s)+"."+f.slice(s))}f=(t==16?"0x":t==2?"0b":t==8?"0o":"")+f}return e.s<0?"-"+f:f}function Mp(e,t){if(e.length>t)return e.length=t,!0}function jx(e){return new this(e).abs()}function Wx(e){return new this(e).acos()}function Gx(e){return new this(e).acosh()}function Dx(e,t){return new this(e).plus(t)}function Xx(e){return new this(e).asin()}function zx(e){return new this(e).asinh()}function Yx(e){return new this(e).atan()}function Zx(e){return new this(e).atanh()}function Jx(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,s=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Xn(this,s,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Xn(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Xn(this,s,1).times(.5),n.s=e.s):t.s<0?(this.precision=s,this.rounding=1,n=this.atan(De(e,t,s,1)),t=Xn(this,s,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(De(e,t,s,1)),n}function Qx(e){return new this(e).cbrt()}function e6(e){return we(e=new this(e),e.e+1,2)}function t6(e,t,n){return new this(e).clamp(t,n)}function n6(e){if(!e||typeof e!="object")throw Error(su+"Object expected");var t,n,r,i=e.defaults===!0,s=["precision",1,fi,"rounding",0,8,"toExpNeg",-as,0,"toExpPos",0,as,"maxE",0,as,"minE",-as,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(n=s[t],i&&(this[n]=Df[n]),(r=e[n])!==void 0)if(Lt(r)===r&&r>=s[t+1]&&r<=s[t+2])this[n]=r;else throw Error(oi+n+": "+r);if(n="crypto",i&&(this[n]=Df[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(lw);else this[n]=!1;else throw Error(oi+n+": "+r);return this}function r6(e){return new this(e).cos()}function i6(e){return new this(e).cosh()}function bw(e){var t,n,r;function i(s){var o,c,a,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,qp(s)){u.s=s.s,Te?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(a=typeof s,a==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,c=s;c>=10;c/=10)o++;Te?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return $c(u,s.toString())}if(a==="string")return(c=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(c===43&&(s=s.slice(1)),u.s=1),dw.test(s)?$c(u,s):Kx(u,s);if(a==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,$c(u,s.toString());throw Error(oi+s)}if(i.prototype=ie,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=n6,i.clone=bw,i.isDecimal=qp,i.abs=jx,i.acos=Wx,i.acosh=Gx,i.add=Dx,i.asin=Xx,i.asinh=zx,i.atan=Yx,i.atanh=Zx,i.atan2=Jx,i.cbrt=Qx,i.ceil=e6,i.clamp=t6,i.cos=r6,i.cosh=i6,i.div=s6,i.exp=o6,i.floor=c6,i.hypot=a6,i.ln=u6,i.log=f6,i.log10=h6,i.log2=l6,i.max=d6,i.min=p6,i.mod=y6,i.mul=g6,i.pow=w6,i.random=m6,i.round=b6,i.sign=E6,i.sin=_6,i.sinh=S6,i.sqrt=T6,i.sub=x6,i.sum=A6,i.tan=v6,i.tanh=B6,i.trunc=I6,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function s6(e,t){return new this(e).div(t)}function o6(e){return new this(e).exp()}function c6(e){return we(e=new this(e),e.e+1,3)}function a6(){var e,t,n=new this(0);for(Te=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return Te=!0,new this(1/0);n=t}return Te=!0,n.sqrt()}function qp(e){return e instanceof ei||e&&e.toStringTag===hw||!1}function u6(e){return new this(e).ln()}function f6(e,t){return new this(e).log(t)}function l6(e){return new this(e).log(2)}function h6(e){return new this(e).log(10)}function d6(){return gw(this,arguments,-1)}function p6(){return gw(this,arguments,1)}function y6(e,t){return new this(e).mod(t)}function g6(e,t){return new this(e).mul(t)}function w6(e,t){return new this(e).pow(t)}function m6(e){var t,n,r,i,s=0,o=new this(1),c=[];if(e===void 0?e=this.precision:fn(e,1,fi),r=Math.ceil(e/be),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)i=t[s],i>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:c[s++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)i=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,s):(c.push(i%1e7),s+=4);s=r/4}else throw Error(lw);else for(;s<r;)c[s++]=Math.random()*1e7|0;for(r=c[--s],e%=be,r&&e&&(i=bt(10,be-e),c[s]=(r/i|0)*i);c[s]===0;s--)c.pop();if(s<0)n=0,c=[0];else{for(n=-1;c[0]===0;n-=be)c.shift();for(r=1,i=c[0];i>=10;i/=10)r++;r<be&&(n-=be-r)}return o.e=n,o.d=c,o}function b6(e){return we(e=new this(e),e.e+1,this.rounding)}function E6(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function _6(e){return new this(e).sin()}function S6(e){return new this(e).sinh()}function T6(e){return new this(e).sqrt()}function x6(e,t){return new this(e).sub(t)}function A6(){var e=0,t=arguments,n=new this(t[e]);for(Te=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return Te=!0,we(n,this.precision,this.rounding)}function v6(e){return new this(e).tan()}function B6(e){return new this(e).tanh()}function I6(e){return we(e=new this(e),e.e+1,1)}ie[Symbol.for("nodejs.util.inspect.custom")]=ie.toString;ie[Symbol.toStringTag]="Decimal";var ei=ie.constructor=bw(Df);_a=new ei(_a);Sa=new ei(Sa);const O6=({IDL:e})=>{const t=e.Record({exchange_id:e.Text,reason:e.Text}),n=e.Variant({Ok:e.Null,Err:e.Text}),r=e.Variant({P2WPKH:e.Null,OpReturn:e.Nat64,P2SH:e.Null,P2TR:e.Null}),i=e.Record({input_types:e.Vec(r),pool_address:e.Vec(e.Text),output_types:e.Vec(r)}),s=e.Variant({Ok:e.Nat64,Err:e.Text}),o=e.Record({user_id:e.Principal}),c=e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal}),a=e.Variant({from_user:o,from_canister:c}),u=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),l=e.Record({mode:f,module_hash:e.Vec(e.Nat8)}),p=e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:e.Vec(e.Nat8)}),y=e.Variant({creation:u,code_deployment:l,load_snapshot:p,controllers_change:u,code_uninstall:e.Null}),g=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:a,details:y}),w=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(g),total_num_changes:e.Nat64}),E=e.Variant({Ok:w,Err:e.Text}),_=e.Record({exchange_id:e.Text,pool_address:e.Text,pool_key:e.Text}),S=e.Variant({All:e.Null,ByTxid:e.Text,ByStatusCode:e.Text,ByAddress:e.Text,BySecondsPassed:e.Nat64}),m=e.Variant({Ok:e.Text,Err:e.Text}),T=e.Record({result:m,exchange_id:e.Text,maybe_return_time:e.Opt(e.Text),calling_method:e.Text,calling_args:e.Text,pool_address:e.Text,calling_time:e.Text}),I=e.Record({rollback_results:e.Vec(e.Text),invoke_args:e.Text,invoke_time:e.Text,finalized_time:e.Opt(e.Text),confirmed_time:e.Opt(e.Text),execution_steps:e.Vec(T),processing_result:m,broadcasted_time:e.Opt(e.Text)}),A=e.Record({block_hash:e.Text,block_height:e.Nat32}),U=e.Record({processing_results:e.Vec(e.Text),block_basic:A,txids:e.Vec(e.Text),block_time:e.Text,received_time:e.Text}),M=e.Variant({Abandoned:e.Record({reason:e.Text}),Active:e.Null,Halted:e.Record({reason:e.Text})}),v=e.Record({status:M,exchange_id:e.Text,canister_id:e.Principal,utxo_proof_enabled:e.Bool,client_canisters:e.Vec(e.Principal)}),R=e.Record({rollback_results:e.Vec(e.Text),txid:e.Text,received_time:e.Text,reason:e.Text}),V=e.Variant({mainnet:e.Null,regtest:e.Null,testnet:e.Null}),W=e.Record({min_seconds_of_unconfirmed_tx_in_pool_for_raising_fee_rate:e.Nat32,exchange_registry_principal:e.Principal,max_input_count_of_psbt:e.Nat32,min_tx_confirmations:e.Nat32,mempool_connector_principal:e.Principal,max_unconfirmed_tx_count_in_pool:e.Nat32,min_btc_amount_for_utxo:e.Nat64,rune_indexer_principal:e.Principal,max_intentions_per_invoke:e.Nat32,mempool_connector_public_key:e.Text,max_received_blocks_count:e.Nat32,min_unconfirmed_tx_count_in_pool_for_raising_fee_rate:e.Nat32,bitcoin_network:V}),H=e.Record({low:e.Nat64,high:e.Nat64,update_time:e.Text,medium:e.Nat64}),K=e.Record({last_block:e.Opt(A),pending_tx_count:e.Nat64,mempool_tx_fee_rate:H,invoke_paused:e.Bool,concurrent_invoke_status:e.Text,last_block_time:e.Opt(e.Tuple(e.Nat64,e.Text)),failed_new_block_height:e.Opt(e.Tuple(e.Nat32,e.Text))}),N=e.Variant({Error:e.Null,AvailableUnconfirmed:e.Null,InvalidTxid:e.Null,InvalidVout:e.Null,SpentInMempool:e.Null,SpentOnChain:e.Null,AvailableConfirmed:e.Null}),$=e.Record({status:N,value:e.Opt(e.Text),txid:e.Text,vout:e.Nat32,ancestors:e.Opt(e.Nat32),address:e.Opt(e.Text)}),F=e.Record({id:e.Text,value:e.Nat}),x=e.Record({coins:e.Vec(F),sats:e.Nat64,txid:e.Text,vout:e.Nat32}),O=e.Record({status:e.Opt($),coins:e.Vec(F),utxo:x,is_signed:e.Bool,owner_pubkey:e.Opt(e.Text),owner_address:e.Text}),q=e.Record({coins_in_inputs:e.Vec(O),txid:e.Text,signed_address_coins:e.Vec(e.Tuple(e.Text,e.Vec(F))),address_coins:e.Vec(e.Tuple(e.Text,e.Vec(F)))}),P=e.Record({is_op_return:e.Bool,utxo:x,owner_address:e.Opt(e.Text)}),L=e.Record({burned_coins:e.Vec(F),coins_in_outputs:e.Vec(P),address_coins:e.Vec(e.Tuple(e.Text,e.Vec(F)))}),G=e.Record({coin:F,from:e.Text}),X=e.Record({to:e.Text,coin:F}),Y=e.Record({input_coins:e.Vec(G),output_coins:e.Vec(X),action:e.Text,exchange_id:e.Text,pool_utxo_spent:e.Vec(e.Text),action_params:e.Text,nonce:e.Nat64,pool_address:e.Text,pool_utxo_received:e.Vec(x)}),oe=e.Record({tx_fee_in_sats:e.Nat64,initiator_address:e.Text,intentions:e.Vec(Y)}),ae=e.Record({applied_fee_rate:e.Nat64,pool_addresses:e.Vec(e.Text),coins_in_inputs:q,txid:e.Text,estimated_min_tx_fee:e.Nat64,actual_tx_fee:e.Nat64,coins_in_outputs:L,tx_vsize:e.Nat64,intention_set:oe,user_coins_in_inputs:e.Vec(F),initially_signed_addresses:e.Vec(e.Text)}),ee=e.Variant({Confirmed:e.Nat32,Rejected:e.Text,Pending:e.Null}),Z=e.Record({status:e.Opt(ee),invoke_log:I,included_block:e.Opt(A),sent_tx_hex:e.Text}),ce=e.Variant({Failed:I,NotFound:e.Null,Succeeded:Z}),ge=e.Record({maybe_rune:e.Opt(F),value:e.Nat64,script_pubkey_hex:e.Text,outpoint:e.Text}),pe=e.Record({client_info:e.Opt(e.Text),intention_set:oe,initiator_utxo_proof:e.Vec(e.Nat8),psbt_hex:e.Text}),J=e.Record({block_hash:e.Text,block_timestamp:e.Nat64,tx_ids:e.Vec(e.Text),block_height:e.Nat32}),fe=e.Variant({Ok:e.Vec(e.Text),Err:e.Text}),Se=e.Record({exchange_canister:e.Principal,exchange_id:e.Text,utxo_proof_enabled:e.Bool,client_canisters:e.Vec(e.Principal)}),Ce=e.Record({txid:e.Text,reason_code:e.Text,reason:e.Text}),Ze=e.Record({txid:e.Text,timestamp:e.Nat64,block:A}),st=e.Record({low:e.Nat64,high:e.Nat64,medium:e.Nat64});return e.Service({abandon_exchange:e.Func([t],[n],[]),clear_exchange_pools:e.Func([],[n],[]),clear_failed_invoke_logs:e.Func([e.Opt(e.Nat64),e.Vec(e.Text)],[n],[]),clear_last_block:e.Func([],[n],[]),clear_rejected_txs:e.Func([],[n],[]),clear_txs_with_min_confirmations:e.Func([e.Nat32],[n],[]),delete_tx_detail:e.Func([e.Text],[n],[]),delete_used_outpoints:e.Func([e.Text],[n],[]),estimate_min_tx_fee:e.Func([i],[s],["query"]),get_canister_info:e.Func([e.Nat64],[E],[]),get_exchange_pools:e.Func([e.Opt(e.Text)],[e.Vec(_)],["query"]),get_failed_invoke_logs:e.Func([S],[e.Vec(e.Tuple(e.Text,I))],["query"]),get_last_sent_txs:e.Func([],[e.Vec(e.Tuple(e.Text,e.Text,e.Opt(e.Nat32)))],["query"]),get_received_blocks:e.Func([e.Opt(e.Bool)],[e.Vec(U)],["query"]),get_registered_exchanges:e.Func([e.Opt(M)],[e.Vec(v)],["query"]),get_rejected_txs:e.Func([],[e.Vec(R)],["query"]),get_settings:e.Func([],[W],["query"]),get_status:e.Func([],[K],["query"]),get_tx_execution_context_view:e.Func([e.Text],[e.Opt(ae)],["query"]),get_tx_execution_result:e.Func([e.Text],[ce],["query"]),get_tx_for_outpoint:e.Func([e.Text],[e.Opt(Z)],["query"]),get_tx_queue_of_pool:e.Func([e.Text],[e.Vec(e.Tuple(e.Text,e.Opt(e.Nat32)))],["query"]),get_tx_sent:e.Func([e.Text],[e.Opt(Z)],["query"]),get_used_outpoints:e.Func([e.Opt(e.Text)],[e.Vec(e.Tuple(e.Text,e.Text))],["query"]),get_zero_confirmed_tx_count_of_pool:e.Func([e.Text],[e.Nat32],["query"]),get_zero_confirmed_txs:e.Func([e.Opt(e.Text)],[e.Vec(e.Text)],["query"]),get_zero_confirmed_utxos_of_address:e.Func([e.Text],[e.Vec(ge)],["query"]),init_status_code_message:e.Func([],[n],[]),inspect_status_code:e.Func([e.Text],[e.Text],["query"]),invoke:e.Func([pe],[m],[]),new_block_detected:e.Func([J],[n],[]),notify_exchange_for_blocks_from_height:e.Func([e.Text,e.Nat32],[fe],[]),notify_exchanges_for_block:e.Func([e.Vec(e.Text),A,e.Nat64,e.Vec(e.Text)],[fe],[]),pause_invoke:e.Func([],[n],[]),reapply_tx:e.Func([e.Text],[n],[]),register_exchange:e.Func([Se],[n],[]),reject_tx:e.Func([Ce],[n],[]),resume_invoke:e.Func([],[n],[]),rollback_tx:e.Func([e.Text],[fe],[]),save_included_block_for_tx:e.Func([Ze],[n],[]),set_bitcoin_network:e.Func([V],[n],[]),set_exchange_registry_principal:e.Func([e.Principal],[n],[]),set_max_input_count_of_psbt:e.Func([e.Nat32],[n],[]),set_max_intentions_per_invoke:e.Func([e.Nat32],[n],[]),set_max_received_blocks_count:e.Func([e.Nat32],[n],[]),set_max_unconfirmed_tx_count_in_pool:e.Func([e.Nat32],[n],[]),set_mempool_connector_principal:e.Func([e.Principal],[n],[]),set_mempool_connector_public_key:e.Func([e.Text],[n],[]),set_min_btc_amount_for_utxo:e.Func([e.Nat64],[n],[]),set_min_tx_confirmations:e.Func([e.Nat32],[n],[]),set_rune_indexer_principal:e.Func([e.Principal],[n],[]),set_tx_fee_per_vbyte:e.Func([st],[n],[]),unhalt_exchange:e.Func([e.Text],[n],[]),version:e.Func([],[e.Text],["query"])})};class P6{xverse;config;exchange;orchestrator;constructor(t){this.config=t;const n=t.network===Yo.Testnet,r=n?"https://api-testnet4.secretkeylabs.io":"https://api.secretkeylabs.io";this.xverse=new XS({baseUrl:r,apiKey:t.xverseApiKey});const i="https://icp0.io";this.exchange=ma.createActor(t.exchangeIdlFactory,{agent:yr.createSync({host:i,retryTimes:50,verifyQuerySignatures:!1}),canisterId:t.exchangeCanisterId}),this.orchestrator=ma.createActor(O6,{agent:yr.createSync({host:i,retryTimes:50,verifyQuerySignatures:!1}),canisterId:n?Ux:Nx})}async filterSpentUtxos(t,n){const r=await this.orchestrator.get_used_outpoints([t]);return n.filter(({txid:i,vout:s})=>r.findIndex(([o])=>`${i}:${s}`===o)<0)}async getPendingBtcUtxos(t){const n=await this.orchestrator.get_zero_confirmed_utxos_of_address(t),r=Zr(t);return n.filter(({maybe_rune:i})=>!i.length).map(({value:i,script_pubkey_hex:s,outpoint:o})=>{const[c,a]=o.split(":");return{txid:c,vout:Number(a),satoshis:i.toString(),scriptPk:s,addressType:r,address:t,runes:[]}})}async getPendingRuneUtxos(t,n){const r=await this.orchestrator.get_zero_confirmed_utxos_of_address(t),i=Zr(t);return r.filter(({maybe_rune:s})=>s.length).map(({value:s,script_pubkey_hex:o,outpoint:c,maybe_rune:a})=>{const[u,f]=c.split(":"),l=a[0];return{txid:u,vout:Number(f),satoshis:s.toString(),scriptPk:o,addressType:i,address:t,runes:l?[{id:l.id,amount:l.value.toString()}]:[],pubkey:n}})}async getBtcUtxos(t){let n=0;const r=60,i=[],s=await this.getPendingBtcUtxos(t);let o=!0;for(;o;){const u=await this.xverse.utxosByAddress(t,n,r);i.push(...u.items),o=u.hasMore,n+=r}const c=Ea(t,this.config.network),a=i.map(({txid:u,vout:f,value:l})=>({txid:u,vout:f,address:t,runes:[],satoshis:l.toString(),scriptPk:ba(c)}));return this.filterSpentUtxos(t,a.concat(s))}async getRuneUtxos(t,n,r){let i=0;const s=60,o=[],c=await this.getPendingRuneUtxos(t,r);let a=!0;for(;a;){const l=await this.xverse.runeUtxosByAddress(t,n,i,s);o.push(...l.items),a=l.hasMore,i+=s}const u=Ea(t,this.config.network),f=o.map(({txid:l,vout:p,runes:y,amount:g})=>({txid:l,vout:p,address:t,runes:y.map(({runeId:w,amount:E,divisibility:_})=>{const S=new ei(E).mul(10**_).toFixed(0);return{id:w,amount:S}}),satoshis:g.toString(),scriptPk:ba(u),pubkey:r}));return this.filterSpentUtxos(t,f.concat(c))}async getBtcBalance(t){const r=(await this.getBtcUtxos(t)).reduce((i,s)=>i+BigInt(s.satoshis),BigInt(0));return new ei(r.toString()).div(1e8).toNumber()}async getRuneBalance(t,n,r){const i=await this.getRuneUtxos(t,n,r);if(!i)return;let s=new ei(0);for(const o of i)s=s.add(new ei(o.runes.find(c=>c.id===n)?.amount??0));return s.toNumber()}async getPoolList(){try{return await this.exchange.get_pool_list()??[]}catch(t){throw console.error("get pool list failed:",t),t}}async getPoolInfo(t){try{const n=await this.exchange.get_pool_info({pool_address:t});if(n.length===0)throw new Error("Pool not found");return n[0]}catch(n){throw console.error("get pool data failed:",n),n}}async createTransaction({address:t,paymentAddress:n,publicKey:r,feeRate:i,mergeSelfRuneBtcOutputs:s,clientInfo:o,manualBuild:c}){return new Jr({network:this.config.network,exchangeId:this.config.exchangeId,address:t,paymentAddress:n,publicKey:r,feeRate:i,mergeSelfRuneBtcOutputs:s,clientInfo:o,manualBuild:c},this)}async getRecommendedFeeRate(){const t=await this.orchestrator.get_status();return{min:Number(t.mempool_tx_fee_rate.medium),max:Number(t.mempool_tx_fee_rate.medium)*3}}}exports.Network=Yo;exports.ReeClient=P6;exports.Transaction=Jr;exports.utils=kx;
82
+ */var as=9e15,fi=1e9,Gf="0123456789abcdef",_a="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Sa="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Df={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-as,maxE:as,crypto:!1},uw,gr,Te=!0,su="[DecimalError] ",oi=su+"Invalid argument: ",fw=su+"Precision limit exceeded",lw=su+"crypto unavailable",hw="[object Decimal]",Lt=Math.floor,bt=Math.pow,Hx=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Fx=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Mx=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,dw=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Fn=1e7,be=7,qx=9007199254740991,Vx=_a.length-1,Xf=Sa.length-1,ie={toStringTag:hw};ie.absoluteValue=ie.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),we(e)};ie.ceil=function(){return we(new this.constructor(this),this.e+1,2)};ie.clampedTo=ie.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(oi+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)};ie.comparedTo=ie.cmp=function(e){var t,n,r,i,s=this,o=s.d,c=(e=new s.constructor(e)).d,a=s.s,u=e.s;if(!o||!c)return!a||!u?NaN:a!==u?a:o===c?0:!o^a<0?1:-1;if(!o[0]||!c[0])return o[0]?a:c[0]?-u:0;if(a!==u)return a;if(s.e!==e.e)return s.e>e.e^a<0?1:-1;for(r=o.length,i=c.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==c[t])return o[t]>c[t]^a<0?1:-1;return r===i?0:r>i^a<0?1:-1};ie.cosine=ie.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+be,r.rounding=1,n=Lx(r,mw(r,n)),r.precision=e,r.rounding=t,we(gr==2||gr==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};ie.cubeRoot=ie.cbrt=function(){var e,t,n,r,i,s,o,c,a,u,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(Te=!1,s=f.s*bt(f.s*f,1/3),!s||Math.abs(s)==1/0?(n=Pt(f.d),e=f.e,(s=(e-n.length+1)%3)&&(n+=s==1||s==-2?"0":"00"),s=bt(n,1/3),e=Lt((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?n="5e"+e:(n=s.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new l(n),r.s=f.s):r=new l(s.toString()),o=(e=l.precision)+3;;)if(c=r,a=c.times(c).times(c),u=a.plus(f),r=De(u.plus(f).times(c),u.plus(a),o+2,1),Pt(c.d).slice(0,o)===(n=Pt(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n=="9999"||!i&&n=="4999"){if(!i&&(we(c,e+1,0),c.times(c).times(c).eq(f))){r=c;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(we(r,e+1,1),t=!r.times(r).times(r).eq(f));break}return Te=!0,we(r,e,l.rounding,t)};ie.decimalPlaces=ie.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Lt(this.e/be))*be,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};ie.dividedBy=ie.div=function(e){return De(this,new this.constructor(e))};ie.dividedToIntegerBy=ie.divToInt=function(e){var t=this,n=t.constructor;return we(De(t,new n(e),0,1,1),n.precision,n.rounding)};ie.equals=ie.eq=function(e){return this.cmp(e)===0};ie.floor=function(){return we(new this.constructor(this),this.e+1,3)};ie.greaterThan=ie.gt=function(e){return this.cmp(e)>0};ie.greaterThanOrEqualTo=ie.gte=function(e){var t=this.cmp(e);return t==1||t===0};ie.hyperbolicCosine=ie.cosh=function(){var e,t,n,r,i,s=this,o=s.constructor,c=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return c;n=o.precision,r=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(e=Math.ceil(i/3),t=(1/cu(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=As(o,1,s.times(t),new o(1),!0);for(var a,u=e,f=new o(8);u--;)a=s.times(s),s=c.minus(a.times(f.minus(a.times(f))));return we(s,o.precision=n,o.rounding=r,!0)};ie.hyperbolicSine=ie.sinh=function(){var e,t,n,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.precision,n=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length,r<3)i=As(s,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/cu(5,e)),i=As(s,2,i,i,!0);for(var o,c=new s(5),a=new s(16),u=new s(20);e--;)o=i.times(i),i=i.times(c.plus(o.times(a.times(o).plus(u))))}return s.precision=t,s.rounding=n,we(i,t,n,!0)};ie.hyperbolicTangent=ie.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,De(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};ie.inverseCosine=ie.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n!==-1?n===0?e.isNeg()?Xn(t,r,i):new t(0):new t(NaN):e.isZero()?Xn(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2))};ie.inverseHyperbolicCosine=ie.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,Te=!1,n=n.times(n).minus(1).sqrt().plus(n),Te=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)};ie.inverseHyperbolicSine=ie.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,Te=!1,n=n.times(n).plus(1).sqrt().plus(n),Te=!0,r.precision=e,r.rounding=t,n.ln())};ie.inverseHyperbolicTangent=ie.atanh=function(){var e,t,n,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?we(new s(i),e,t,!0):(s.precision=n=r-i.e,i=De(i.plus(1),new s(1).minus(i),n+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)};ie.inverseSine=ie.asin=function(){var e,t,n,r,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),n=s.precision,r=s.rounding,t!==-1?t===0?(e=Xn(s,n+4,r).times(.5),e.s=i.s,e):new s(NaN):(s.precision=n+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=r,i.times(2)))};ie.inverseTangent=ie.atan=function(){var e,t,n,r,i,s,o,c,a,u=this,f=u.constructor,l=f.precision,p=f.rounding;if(u.isFinite()){if(u.isZero())return new f(u);if(u.abs().eq(1)&&l+4<=Xf)return o=Xn(f,l+4,p).times(.25),o.s=u.s,o}else{if(!u.s)return new f(NaN);if(l+4<=Xf)return o=Xn(f,l+4,p).times(.5),o.s=u.s,o}for(f.precision=c=l+10,f.rounding=1,n=Math.min(28,c/be+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(Te=!1,t=Math.ceil(c/be),r=1,a=u.times(u),o=new f(u),i=u;e!==-1;)if(i=i.times(a),s=o.minus(i.div(r+=2)),i=i.times(a),o=s.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===s.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),Te=!0,we(o,f.precision=l,f.rounding=p,!0)};ie.isFinite=function(){return!!this.d};ie.isInteger=ie.isInt=function(){return!!this.d&&Lt(this.e/be)>this.d.length-2};ie.isNaN=function(){return!this.s};ie.isNegative=ie.isNeg=function(){return this.s<0};ie.isPositive=ie.isPos=function(){return this.s>0};ie.isZero=function(){return!!this.d&&this.d[0]===0};ie.lessThan=ie.lt=function(e){return this.cmp(e)<0};ie.lessThanOrEqualTo=ie.lte=function(e){return this.cmp(e)<1};ie.logarithm=ie.log=function(e){var t,n,r,i,s,o,c,a,u=this,f=u.constructor,l=f.precision,p=f.rounding,y=5;if(e==null)e=new f(10),t=!0;else{if(e=new f(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new f(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new f(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)s=!0;else{for(i=n[0];i%10===0;)i/=10;s=i!==1}if(Te=!1,c=l+y,o=Qr(u,c),r=t?Ta(f,c+10):Qr(e,c),a=De(o,r,c,1),Po(a.d,i=l,p))do if(c+=10,o=Qr(u,c),r=t?Ta(f,c+10):Qr(e,c),a=De(o,r,c,1),!s){+Pt(a.d).slice(i+1,i+15)+1==1e14&&(a=we(a,l+1,0));break}while(Po(a.d,i+=10,p));return Te=!0,we(a,l,p)};ie.minus=ie.sub=function(e){var t,n,r,i,s,o,c,a,u,f,l,p,y=this,g=y.constructor;if(e=new g(e),!y.d||!e.d)return!y.s||!e.s?e=new g(NaN):y.d?e.s=-e.s:e=new g(e.d||y.s!==e.s?y:NaN),e;if(y.s!=e.s)return e.s=-e.s,y.plus(e);if(u=y.d,p=e.d,c=g.precision,a=g.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else if(u[0])e=new g(y);else return new g(a===3?-0:0);return Te?we(e,c,a):e}if(n=Lt(e.e/be),f=Lt(y.e/be),u=u.slice(),s=f-n,s){for(l=s<0,l?(t=u,s=-s,o=p.length):(t=p,n=f,o=u.length),r=Math.max(Math.ceil(c/be),o)+2,s>r&&(s=r,t.length=1),t.reverse(),r=s;r--;)t.push(0);t.reverse()}else{for(r=u.length,o=p.length,l=r<o,l&&(o=r),r=0;r<o;r++)if(u[r]!=p[r]){l=u[r]<p[r];break}s=0}for(l&&(t=u,u=p,p=t,e.s=-e.s),o=u.length,r=p.length-o;r>0;--r)u[o++]=0;for(r=p.length;r>s;){if(u[--r]<p[r]){for(i=r;i&&u[--i]===0;)u[i]=Fn-1;--u[i],u[r]+=Fn}u[r]-=p[r]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=ou(u,n),Te?we(e,c,a):e):new g(a===3?-0:0)};ie.modulo=ie.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?we(new r(n),r.precision,r.rounding):(Te=!1,r.modulo==9?(t=De(n,e.abs(),0,3,1),t.s*=e.s):t=De(n,e,0,r.modulo,1),t=t.times(e),Te=!0,n.minus(t))};ie.naturalExponential=ie.exp=function(){return zf(this)};ie.naturalLogarithm=ie.ln=function(){return Qr(this)};ie.negated=ie.neg=function(){var e=new this.constructor(this);return e.s=-e.s,we(e)};ie.plus=ie.add=function(e){var t,n,r,i,s,o,c,a,u,f,l=this,p=l.constructor;if(e=new p(e),!l.d||!e.d)return!l.s||!e.s?e=new p(NaN):l.d||(e=new p(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(u=l.d,f=e.d,c=p.precision,a=p.rounding,!u[0]||!f[0])return f[0]||(e=new p(l)),Te?we(e,c,a):e;if(s=Lt(l.e/be),r=Lt(e.e/be),u=u.slice(),i=s-r,i){for(i<0?(n=u,i=-i,o=f.length):(n=f,r=s,o=u.length),s=Math.ceil(c/be),o=s>o?s+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=u.length,i=f.length,o-i<0&&(i=o,n=f,f=u,u=n),t=0;i;)t=(u[--i]=u[i]+f[i]+t)/Fn|0,u[i]%=Fn;for(t&&(u.unshift(t),++r),o=u.length;u[--o]==0;)u.pop();return e.d=u,e.e=ou(u,r),Te?we(e,c,a):e};ie.precision=ie.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(oi+e);return n.d?(t=pw(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};ie.round=function(){var e=this,t=e.constructor;return we(new t(e),e.e+1,t.rounding)};ie.sine=ie.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+be,r.rounding=1,n=$x(r,mw(r,n)),r.precision=e,r.rounding=t,we(gr>2?n.neg():n,e,t,!0)):new r(NaN)};ie.squareRoot=ie.sqrt=function(){var e,t,n,r,i,s,o=this,c=o.d,a=o.e,u=o.s,f=o.constructor;if(u!==1||!c||!c[0])return new f(!u||u<0&&(!c||c[0])?NaN:c?o:1/0);for(Te=!1,u=Math.sqrt(+o),u==0||u==1/0?(t=Pt(c),(t.length+a)%2==0&&(t+="0"),u=Math.sqrt(t),a=Lt((a+1)/2)-(a<0||a%2),u==1/0?t="5e"+a:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+a),r=new f(t)):r=new f(u.toString()),n=(a=f.precision)+3;;)if(s=r,r=s.plus(De(o,s,n+2,1)).times(.5),Pt(s.d).slice(0,n)===(t=Pt(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!i&&t=="4999"){if(!i&&(we(s,a+1,0),s.times(s).eq(o))){r=s;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(we(r,a+1,1),e=!r.times(r).eq(o));break}return Te=!0,we(r,a,f.rounding,e)};ie.tangent=ie.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=De(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,we(gr==2||gr==4?n.neg():n,e,t,!0)):new r(NaN)};ie.times=ie.mul=function(e){var t,n,r,i,s,o,c,a,u,f=this,l=f.constructor,p=f.d,y=(e=new l(e)).d;if(e.s*=f.s,!p||!p[0]||!y||!y[0])return new l(!e.s||p&&!p[0]&&!y||y&&!y[0]&&!p?NaN:!p||!y?e.s/0:e.s*0);for(n=Lt(f.e/be)+Lt(e.e/be),a=p.length,u=y.length,a<u&&(s=p,p=y,y=s,o=a,a=u,u=o),s=[],o=a+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(t=0,i=a+r;i>r;)c=s[i]+y[r]*p[i-r-1]+t,s[i--]=c%Fn|0,t=c/Fn|0;s[i]=(s[i]+t)%Fn|0}for(;!s[--o];)s.pop();return t?++n:s.shift(),e.d=s,e.e=ou(s,n),Te?we(e,l.precision,l.rounding):e};ie.toBinary=function(e,t){return th(this,2,e,t)};ie.toDecimalPlaces=ie.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(fn(e,0,fi),t===void 0?t=r.rounding:fn(t,0,8),we(n,e+n.e+1,t))};ie.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Zn(r,!0):(fn(e,0,fi),t===void 0?t=i.rounding:fn(t,0,8),r=we(new i(r),e+1,t),n=Zn(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};ie.toFixed=function(e,t){var n,r,i=this,s=i.constructor;return e===void 0?n=Zn(i):(fn(e,0,fi),t===void 0?t=s.rounding:fn(t,0,8),r=we(new s(i),e+i.e+1,t),n=Zn(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};ie.toFraction=function(e){var t,n,r,i,s,o,c,a,u,f,l,p,y=this,g=y.d,w=y.constructor;if(!g)return new w(y);if(u=n=new w(1),r=a=new w(0),t=new w(r),s=t.e=pw(g)-y.e-1,o=s%be,t.d[0]=bt(10,o<0?be+o:o),e==null)e=s>0?t:u;else{if(c=new w(e),!c.isInt()||c.lt(u))throw Error(oi+c);e=c.gt(t)?s>0?t:u:c}for(Te=!1,c=new w(Pt(g)),f=w.precision,w.precision=s=g.length*be*2;l=De(c,t,0,1,1),i=n.plus(l.times(r)),i.cmp(e)!=1;)n=r,r=i,i=u,u=a.plus(l.times(i)),a=i,i=t,t=c.minus(l.times(i)),c=i;return i=De(e.minus(n),r,0,1,1),a=a.plus(i.times(u)),n=n.plus(i.times(r)),a.s=u.s=y.s,p=De(u,r,s,1).minus(y).abs().cmp(De(a,n,s,1).minus(y).abs())<1?[u,r]:[a,n],w.precision=f,Te=!0,p};ie.toHexadecimal=ie.toHex=function(e,t){return th(this,16,e,t)};ie.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:fn(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(Te=!1,n=De(n,e,0,t,1).times(e),Te=!0,we(n)):(e.s=n.s,n=e),n};ie.toNumber=function(){return+this};ie.toOctal=function(e,t){return th(this,8,e,t)};ie.toPower=ie.pow=function(e){var t,n,r,i,s,o,c=this,a=c.constructor,u=+(e=new a(e));if(!c.d||!e.d||!c.d[0]||!e.d[0])return new a(bt(+c,u));if(c=new a(c),c.eq(1))return c;if(r=a.precision,s=a.rounding,e.eq(1))return we(c,r,s);if(t=Lt(e.e/be),t>=e.d.length-1&&(n=u<0?-u:u)<=qx)return i=yw(a,c,n,r),e.s<0?new a(1).div(i):we(i,r,s);if(o=c.s,o<0){if(t<e.d.length-1)return new a(NaN);if((e.d[t]&1)==0&&(o=1),c.e==0&&c.d[0]==1&&c.d.length==1)return c.s=o,c}return n=bt(+c,u),t=n==0||!isFinite(n)?Lt(u*(Math.log("0."+Pt(c.d))/Math.LN10+c.e+1)):new a(n+"").e,t>a.maxE+1||t<a.minE-1?new a(t>0?o/0:0):(Te=!1,a.rounding=c.s=1,n=Math.min(12,(t+"").length),i=zf(e.times(Qr(c,r+n)),r),i.d&&(i=we(i,r+5,1),Po(i.d,r,s)&&(t=r+10,i=we(zf(e.times(Qr(c,t+n)),t),t+5,1),+Pt(i.d).slice(r+1,r+15)+1==1e14&&(i=we(i,r+1,0)))),i.s=o,Te=!0,a.rounding=s,we(i,r,s))};ie.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Zn(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(fn(e,1,fi),t===void 0?t=i.rounding:fn(t,0,8),r=we(new i(r),e,t),n=Zn(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n};ie.toSignificantDigits=ie.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(fn(e,1,fi),t===void 0?t=r.rounding:fn(t,0,8)),we(new r(n),e,t)};ie.toString=function(){var e=this,t=e.constructor,n=Zn(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};ie.truncated=ie.trunc=function(){return we(new this.constructor(this),this.e+1,1)};ie.valueOf=ie.toJSON=function(){var e=this,t=e.constructor,n=Zn(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function Pt(e){var t,n,r,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,t=1;t<i;t++)r=e[t]+"",n=be-r.length,n&&(s+=Yr(n)),s+=r;o=e[t],r=o+"",n=be-r.length,n&&(s+=Yr(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function fn(e,t,n){if(e!==~~e||e<t||e>n)throw Error(oi+e)}function Po(e,t,n,r){var i,s,o,c;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=be,i=0):(i=Math.ceil((t+1)/be),t%=be),s=bt(10,be-t),c=e[i]%s|0,r==null?t<3?(t==0?c=c/100|0:t==1&&(c=c/10|0),o=n<4&&c==99999||n>3&&c==49999||c==5e4||c==0):o=(n<4&&c+1==s||n>3&&c+1==s/2)&&(e[i+1]/s/100|0)==bt(10,t-2)-1||(c==s/2||c==0)&&(e[i+1]/s/100|0)==0:t<4?(t==0?c=c/1e3|0:t==1?c=c/100|0:t==2&&(c=c/10|0),o=(r||n<4)&&c==9999||!r&&n>3&&c==4999):o=((r||n<4)&&c+1==s||!r&&n>3&&c+1==s/2)&&(e[i+1]/s/1e3|0)==bt(10,t-3)-1,o}function Kc(e,t,n){for(var r,i=[0],s,o=0,c=e.length;o<c;){for(s=i.length;s--;)i[s]*=t;for(i[0]+=Gf.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Lx(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/cu(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),e.precision+=n,t=As(e,1,t.times(i),new e(1));for(var s=n;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var De=(function(){function e(r,i,s){var o,c=0,a=r.length;for(r=r.slice();a--;)o=r[a]*i+c,r[a]=o%s|0,c=o/s|0;return c&&r.unshift(c),r}function t(r,i,s,o){var c,a;if(s!=o)a=s>o?1:-1;else for(c=a=0;c<s;c++)if(r[c]!=i[c]){a=r[c]>i[c]?1:-1;break}return a}function n(r,i,s,o){for(var c=0;s--;)r[s]-=c,c=r[s]<i[s]?1:0,r[s]=c*o+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o,c,a){var u,f,l,p,y,g,w,E,_,S,m,T,I,A,U,M,v,R,V,W,H=r.constructor,K=r.s==i.s?1:-1,N=r.d,$=i.d;if(!N||!N[0]||!$||!$[0])return new H(!r.s||!i.s||(N?$&&N[0]==$[0]:!$)?NaN:N&&N[0]==0||!$?K*0:K/0);for(a?(y=1,f=r.e-i.e):(a=Fn,y=be,f=Lt(r.e/y)-Lt(i.e/y)),V=$.length,v=N.length,_=new H(K),S=_.d=[],l=0;$[l]==(N[l]||0);l++);if($[l]>(N[l]||0)&&f--,s==null?(A=s=H.precision,o=H.rounding):c?A=s+(r.e-i.e)+1:A=s,A<0)S.push(1),g=!0;else{if(A=A/y+2|0,l=0,V==1){for(p=0,$=$[0],A++;(l<v||p)&&A--;l++)U=p*a+(N[l]||0),S[l]=U/$|0,p=U%$|0;g=p||l<v}else{for(p=a/($[0]+1)|0,p>1&&($=e($,p,a),N=e(N,p,a),V=$.length,v=N.length),M=V,m=N.slice(0,V),T=m.length;T<V;)m[T++]=0;W=$.slice(),W.unshift(0),R=$[0],$[1]>=a/2&&++R;do p=0,u=t($,m,V,T),u<0?(I=m[0],V!=T&&(I=I*a+(m[1]||0)),p=I/R|0,p>1?(p>=a&&(p=a-1),w=e($,p,a),E=w.length,T=m.length,u=t(w,m,E,T),u==1&&(p--,n(w,V<E?W:$,E,a))):(p==0&&(u=p=1),w=$.slice()),E=w.length,E<T&&w.unshift(0),n(m,w,T,a),u==-1&&(T=m.length,u=t($,m,V,T),u<1&&(p++,n(m,V<T?W:$,T,a))),T=m.length):u===0&&(p++,m=[0]),S[l++]=p,u&&m[0]?m[T++]=N[M]||0:(m=[N[M]],T=1);while((M++<v||m[0]!==void 0)&&A--);g=m[0]!==void 0}S[0]||S.shift()}if(y==1)_.e=f,uw=g;else{for(l=1,p=S[0];p>=10;p/=10)l++;_.e=l+f*y-1,we(_,c?s+_.e+1:s,o,g)}return _}})();function we(e,t,n,r){var i,s,o,c,a,u,f,l,p,y=e.constructor;e:if(t!=null){if(l=e.d,!l)return e;for(i=1,c=l[0];c>=10;c/=10)i++;if(s=t-i,s<0)s+=be,o=t,f=l[p=0],a=f/bt(10,i-o-1)%10|0;else if(p=Math.ceil((s+1)/be),c=l.length,p>=c)if(r){for(;c++<=p;)l.push(0);f=a=0,i=1,s%=be,o=s-be+1}else break e;else{for(f=c=l[p],i=1;c>=10;c/=10)i++;s%=be,o=s-be+i,a=o<0?0:f/bt(10,i-o-1)%10|0}if(r=r||t<0||l[p+1]!==void 0||(o<0?f:f%bt(10,i-o-1)),u=n<4?(a||r)&&(n==0||n==(e.s<0?3:2)):a>5||a==5&&(n==4||r||n==6&&(s>0?o>0?f/bt(10,i-o):0:l[p-1])%10&1||n==(e.s<0?8:7)),t<1||!l[0])return l.length=0,u?(t-=e.e+1,l[0]=bt(10,(be-t%be)%be),e.e=-t||0):l[0]=e.e=0,e;if(s==0?(l.length=p,c=1,p--):(l.length=p+1,c=bt(10,be-s),l[p]=o>0?(f/bt(10,i-o)%bt(10,o)|0)*c:0),u)for(;;)if(p==0){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=c,c=1;o>=10;o/=10)c++;s!=c&&(e.e++,l[0]==Fn&&(l[0]=1));break}else{if(l[p]+=c,l[p]!=Fn)break;l[p--]=0,c=1}for(s=l.length;l[--s]===0;)l.pop()}return Te&&(e.e>y.maxE?(e.d=null,e.e=NaN):e.e<y.minE&&(e.e=0,e.d=[0])),e}function Zn(e,t,n){if(!e.isFinite())return ww(e);var r,i=e.e,s=Pt(e.d),o=s.length;return t?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+Yr(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+Yr(-i-1)+s,n&&(r=n-o)>0&&(s+=Yr(r))):i>=o?(s+=Yr(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+Yr(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=Yr(r))),s}function ou(e,t){var n=e[0];for(t*=be;n>=10;n/=10)t++;return t}function Ta(e,t,n){if(t>Vx)throw Te=!0,n&&(e.precision=n),Error(fw);return we(new e(_a),t,1,!0)}function Xn(e,t,n){if(t>Xf)throw Error(fw);return we(new e(Sa),t,n,!0)}function pw(e){var t=e.length-1,n=t*be+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function Yr(e){for(var t="";e--;)t+="0";return t}function yw(e,t,n,r){var i,s=new e(1),o=Math.ceil(r/be+4);for(Te=!1;;){if(n%2&&(s=s.times(t),Mp(s.d,o)&&(i=!0)),n=Lt(n/2),n===0){n=s.d.length-1,i&&s.d[n]===0&&++s.d[n];break}t=t.times(t),Mp(t.d,o)}return Te=!0,s}function Fp(e){return e.d[e.d.length-1]&1}function gw(e,t,n){for(var r,i,s=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){s=i;break}r=s.cmp(i),(r===n||r===0&&s.s===n)&&(s=i)}return s}function zf(e,t){var n,r,i,s,o,c,a,u=0,f=0,l=0,p=e.constructor,y=p.rounding,g=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(Te=!1,a=g):a=t,c=new p(.03125);e.e>-2;)e=e.times(c),l+=5;for(r=Math.log(bt(2,l))/Math.LN10*2+5|0,a+=r,n=s=o=new p(1),p.precision=a;;){if(s=we(s.times(e),a,1),n=n.times(++f),c=o.plus(De(s,n,a,1)),Pt(c.d).slice(0,a)===Pt(o.d).slice(0,a)){for(i=l;i--;)o=we(o.times(o),a,1);if(t==null)if(u<3&&Po(o.d,a-r,y,u))p.precision=a+=10,n=s=c=new p(1),f=0,u++;else return we(o,p.precision=g,y,Te=!0);else return p.precision=g,o}o=c}}function Qr(e,t){var n,r,i,s,o,c,a,u,f,l,p,y=1,g=10,w=e,E=w.d,_=w.constructor,S=_.rounding,m=_.precision;if(w.s<0||!E||!E[0]||!w.e&&E[0]==1&&E.length==1)return new _(E&&!E[0]?-1/0:w.s!=1?NaN:E?0:w);if(t==null?(Te=!1,f=m):f=t,_.precision=f+=g,n=Pt(E),r=n.charAt(0),Math.abs(s=w.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)w=w.times(e),n=Pt(w.d),r=n.charAt(0),y++;s=w.e,r>1?(w=new _("0."+n),s++):w=new _(r+"."+n.slice(1))}else return u=Ta(_,f+2,m).times(s+""),w=Qr(new _(r+"."+n.slice(1)),f-g).plus(u),_.precision=m,t==null?we(w,m,S,Te=!0):w;for(l=w,a=o=w=De(w.minus(1),w.plus(1),f,1),p=we(w.times(w),f,1),i=3;;){if(o=we(o.times(p),f,1),u=a.plus(De(o,new _(i),f,1)),Pt(u.d).slice(0,f)===Pt(a.d).slice(0,f))if(a=a.times(2),s!==0&&(a=a.plus(Ta(_,f+2,m).times(s+""))),a=De(a,new _(y),f,1),t==null)if(Po(a.d,f-g,S,c))_.precision=f+=g,u=o=w=De(l.minus(1),l.plus(1),f,1),p=we(w.times(w),f,1),i=c=1;else return we(a,_.precision=m,S,Te=!0);else return _.precision=m,a;a=u,i+=2}}function ww(e){return String(e.s*e.s/0)}function $c(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%be,n<0&&(r+=be),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=be;r<i;)e.d.push(+t.slice(r,r+=be));t=t.slice(r),r=be-t.length}else r-=i;for(;r--;)t+="0";e.d.push(+t),Te&&(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 Kx(e,t){var n,r,i,s,o,c,a,u,f;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),dw.test(t))return $c(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Fx.test(t))n=16,t=t.toLowerCase();else if(Hx.test(t))n=2;else if(Mx.test(t))n=8;else throw Error(oi+t);for(s=t.search(/p/i),s>0?(a=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),o=s>=0,r=e.constructor,o&&(t=t.replace(".",""),c=t.length,s=c-s,i=yw(r,new r(n),s,s*2)),u=Kc(t,n,Fn),f=u.length-1,s=f;u[s]===0;--s)u.pop();return s<0?new r(e.s*0):(e.e=ou(u,f),e.d=u,Te=!1,o&&(e=De(e,i,c*4)),a&&(e=e.times(Math.abs(a)<54?bt(2,a):ei.pow(2,a))),Te=!0,e)}function $x(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:As(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/cu(5,n)),t=As(e,2,t,t);for(var i,s=new e(5),o=new e(16),c=new e(20);n--;)i=t.times(t),t=t.times(s.plus(i.times(o.times(i).minus(c))));return t}function As(e,t,n,r,i){var s,o,c,a,u=e.precision,f=Math.ceil(u/be);for(Te=!1,a=n.times(n),c=new e(r);;){if(o=De(c.times(a),new e(t++*t++),u,1),c=i?r.plus(o):r.minus(o),r=De(o.times(a),new e(t++*t++),u,1),o=c.plus(r),o.d[f]!==void 0){for(s=f;o.d[s]===c.d[s]&&s--;);if(s==-1)break}s=c,c=r,r=o,o=s}return Te=!0,o.d.length=f+1,o}function cu(e,t){for(var n=e;--t;)n*=e;return n}function mw(e,t){var n,r=t.s<0,i=Xn(e,e.precision,1),s=i.times(.5);if(t=t.abs(),t.lte(s))return gr=r?4:1,t;if(n=t.divToInt(i),n.isZero())gr=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(s))return gr=Fp(n)?r?2:3:r?4:1,t;gr=Fp(n)?r?1:4:r?3:2}return t.minus(i).abs()}function th(e,t,n,r){var i,s,o,c,a,u,f,l,p,y=e.constructor,g=n!==void 0;if(g?(fn(n,1,fi),r===void 0?r=y.rounding:fn(r,0,8)):(n=y.precision,r=y.rounding),!e.isFinite())f=ww(e);else{for(f=Zn(e),o=f.indexOf("."),g?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(f=f.replace(".",""),p=new y(1),p.e=f.length-o,p.d=Kc(Zn(p),10,i),p.e=p.d.length),l=Kc(f,10,i),s=a=l.length;l[--a]==0;)l.pop();if(!l[0])f=g?"0p+0":"0";else{if(o<0?s--:(e=new y(e),e.d=l,e.e=s,e=De(e,p,n,r,0,i),l=e.d,s=e.e,u=uw),o=l[n],c=i/2,u=u||l[n+1]!==void 0,u=r<4?(o!==void 0||u)&&(r===0||r===(e.s<0?3:2)):o>c||o===c&&(r===4||u||r===6&&l[n-1]&1||r===(e.s<0?8:7)),l.length=n,u)for(;++l[--n]>i-1;)l[n]=0,n||(++s,l.unshift(1));for(a=l.length;!l[a-1];--a);for(o=0,f="";o<a;o++)f+=Gf.charAt(l[o]);if(g){if(a>1)if(t==16||t==8){for(o=t==16?4:3,--a;a%o;a++)f+="0";for(l=Kc(f,i,t),a=l.length;!l[a-1];--a);for(o=1,f="1.";o<a;o++)f+=Gf.charAt(l[o])}else f=f.charAt(0)+"."+f.slice(1);f=f+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)f="0"+f;f="0."+f}else if(++s>a)for(s-=a;s--;)f+="0";else s<a&&(f=f.slice(0,s)+"."+f.slice(s))}f=(t==16?"0x":t==2?"0b":t==8?"0o":"")+f}return e.s<0?"-"+f:f}function Mp(e,t){if(e.length>t)return e.length=t,!0}function jx(e){return new this(e).abs()}function Wx(e){return new this(e).acos()}function Gx(e){return new this(e).acosh()}function Dx(e,t){return new this(e).plus(t)}function Xx(e){return new this(e).asin()}function zx(e){return new this(e).asinh()}function Yx(e){return new this(e).atan()}function Zx(e){return new this(e).atanh()}function Jx(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,s=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Xn(this,s,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Xn(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Xn(this,s,1).times(.5),n.s=e.s):t.s<0?(this.precision=s,this.rounding=1,n=this.atan(De(e,t,s,1)),t=Xn(this,s,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(De(e,t,s,1)),n}function Qx(e){return new this(e).cbrt()}function e6(e){return we(e=new this(e),e.e+1,2)}function t6(e,t,n){return new this(e).clamp(t,n)}function n6(e){if(!e||typeof e!="object")throw Error(su+"Object expected");var t,n,r,i=e.defaults===!0,s=["precision",1,fi,"rounding",0,8,"toExpNeg",-as,0,"toExpPos",0,as,"maxE",0,as,"minE",-as,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(n=s[t],i&&(this[n]=Df[n]),(r=e[n])!==void 0)if(Lt(r)===r&&r>=s[t+1]&&r<=s[t+2])this[n]=r;else throw Error(oi+n+": "+r);if(n="crypto",i&&(this[n]=Df[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(lw);else this[n]=!1;else throw Error(oi+n+": "+r);return this}function r6(e){return new this(e).cos()}function i6(e){return new this(e).cosh()}function bw(e){var t,n,r;function i(s){var o,c,a,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,qp(s)){u.s=s.s,Te?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(a=typeof s,a==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,c=s;c>=10;c/=10)o++;Te?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return $c(u,s.toString())}if(a==="string")return(c=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(c===43&&(s=s.slice(1)),u.s=1),dw.test(s)?$c(u,s):Kx(u,s);if(a==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,$c(u,s.toString());throw Error(oi+s)}if(i.prototype=ie,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=n6,i.clone=bw,i.isDecimal=qp,i.abs=jx,i.acos=Wx,i.acosh=Gx,i.add=Dx,i.asin=Xx,i.asinh=zx,i.atan=Yx,i.atanh=Zx,i.atan2=Jx,i.cbrt=Qx,i.ceil=e6,i.clamp=t6,i.cos=r6,i.cosh=i6,i.div=s6,i.exp=o6,i.floor=c6,i.hypot=a6,i.ln=u6,i.log=f6,i.log10=h6,i.log2=l6,i.max=d6,i.min=p6,i.mod=y6,i.mul=g6,i.pow=w6,i.random=m6,i.round=b6,i.sign=E6,i.sin=_6,i.sinh=S6,i.sqrt=T6,i.sub=x6,i.sum=A6,i.tan=v6,i.tanh=B6,i.trunc=I6,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function s6(e,t){return new this(e).div(t)}function o6(e){return new this(e).exp()}function c6(e){return we(e=new this(e),e.e+1,3)}function a6(){var e,t,n=new this(0);for(Te=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return Te=!0,new this(1/0);n=t}return Te=!0,n.sqrt()}function qp(e){return e instanceof ei||e&&e.toStringTag===hw||!1}function u6(e){return new this(e).ln()}function f6(e,t){return new this(e).log(t)}function l6(e){return new this(e).log(2)}function h6(e){return new this(e).log(10)}function d6(){return gw(this,arguments,-1)}function p6(){return gw(this,arguments,1)}function y6(e,t){return new this(e).mod(t)}function g6(e,t){return new this(e).mul(t)}function w6(e,t){return new this(e).pow(t)}function m6(e){var t,n,r,i,s=0,o=new this(1),c=[];if(e===void 0?e=this.precision:fn(e,1,fi),r=Math.ceil(e/be),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));s<r;)i=t[s],i>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:c[s++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);s<r;)i=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,s):(c.push(i%1e7),s+=4);s=r/4}else throw Error(lw);else for(;s<r;)c[s++]=Math.random()*1e7|0;for(r=c[--s],e%=be,r&&e&&(i=bt(10,be-e),c[s]=(r/i|0)*i);c[s]===0;s--)c.pop();if(s<0)n=0,c=[0];else{for(n=-1;c[0]===0;n-=be)c.shift();for(r=1,i=c[0];i>=10;i/=10)r++;r<be&&(n-=be-r)}return o.e=n,o.d=c,o}function b6(e){return we(e=new this(e),e.e+1,this.rounding)}function E6(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function _6(e){return new this(e).sin()}function S6(e){return new this(e).sinh()}function T6(e){return new this(e).sqrt()}function x6(e,t){return new this(e).sub(t)}function A6(){var e=0,t=arguments,n=new this(t[e]);for(Te=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return Te=!0,we(n,this.precision,this.rounding)}function v6(e){return new this(e).tan()}function B6(e){return new this(e).tanh()}function I6(e){return we(e=new this(e),e.e+1,1)}ie[Symbol.for("nodejs.util.inspect.custom")]=ie.toString;ie[Symbol.toStringTag]="Decimal";var ei=ie.constructor=bw(Df);_a=new ei(_a);Sa=new ei(Sa);const O6=({IDL:e})=>{const t=e.Record({exchange_id:e.Text,reason:e.Text}),n=e.Variant({Ok:e.Null,Err:e.Text}),r=e.Variant({P2WPKH:e.Null,OpReturn:e.Nat64,P2SH:e.Null,P2TR:e.Null}),i=e.Record({input_types:e.Vec(r),pool_address:e.Vec(e.Text),output_types:e.Vec(r)}),s=e.Variant({Ok:e.Nat64,Err:e.Text}),o=e.Record({user_id:e.Principal}),c=e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal}),a=e.Variant({from_user:o,from_canister:c}),u=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),l=e.Record({mode:f,module_hash:e.Vec(e.Nat8)}),p=e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:e.Vec(e.Nat8)}),y=e.Variant({creation:u,code_deployment:l,load_snapshot:p,controllers_change:u,code_uninstall:e.Null}),g=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:a,details:y}),w=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(g),total_num_changes:e.Nat64}),E=e.Variant({Ok:w,Err:e.Text}),_=e.Record({exchange_id:e.Text,pool_address:e.Text,pool_key:e.Text}),S=e.Variant({All:e.Null,ByTxid:e.Text,ByStatusCode:e.Text,ByAddress:e.Text,BySecondsPassed:e.Nat64}),m=e.Variant({Ok:e.Text,Err:e.Text}),T=e.Record({result:m,exchange_id:e.Text,maybe_return_time:e.Opt(e.Text),calling_method:e.Text,calling_args:e.Text,pool_address:e.Text,calling_time:e.Text}),I=e.Record({rollback_results:e.Vec(e.Text),invoke_args:e.Text,invoke_time:e.Text,finalized_time:e.Opt(e.Text),confirmed_time:e.Opt(e.Text),execution_steps:e.Vec(T),processing_result:m,broadcasted_time:e.Opt(e.Text)}),A=e.Record({block_hash:e.Text,block_height:e.Nat32}),U=e.Record({processing_results:e.Vec(e.Text),block_basic:A,txids:e.Vec(e.Text),block_time:e.Text,received_time:e.Text}),M=e.Variant({Abandoned:e.Record({reason:e.Text}),Active:e.Null,Halted:e.Record({reason:e.Text})}),v=e.Record({status:M,exchange_id:e.Text,canister_id:e.Principal,utxo_proof_enabled:e.Bool,client_canisters:e.Vec(e.Principal)}),R=e.Record({rollback_results:e.Vec(e.Text),txid:e.Text,received_time:e.Text,reason:e.Text}),V=e.Variant({mainnet:e.Null,regtest:e.Null,testnet:e.Null}),W=e.Record({min_seconds_of_unconfirmed_tx_in_pool_for_raising_fee_rate:e.Nat32,exchange_registry_principal:e.Principal,max_input_count_of_psbt:e.Nat32,min_tx_confirmations:e.Nat32,mempool_connector_principal:e.Principal,max_unconfirmed_tx_count_in_pool:e.Nat32,min_btc_amount_for_utxo:e.Nat64,rune_indexer_principal:e.Principal,max_intentions_per_invoke:e.Nat32,mempool_connector_public_key:e.Text,max_received_blocks_count:e.Nat32,min_unconfirmed_tx_count_in_pool_for_raising_fee_rate:e.Nat32,bitcoin_network:V}),H=e.Record({low:e.Nat64,high:e.Nat64,update_time:e.Text,medium:e.Nat64}),K=e.Record({last_block:e.Opt(A),pending_tx_count:e.Nat64,mempool_tx_fee_rate:H,invoke_paused:e.Bool,concurrent_invoke_status:e.Text,last_block_time:e.Opt(e.Tuple(e.Nat64,e.Text)),failed_new_block_height:e.Opt(e.Tuple(e.Nat32,e.Text))}),N=e.Variant({Error:e.Null,AvailableUnconfirmed:e.Null,InvalidTxid:e.Null,InvalidVout:e.Null,SpentInMempool:e.Null,SpentOnChain:e.Null,AvailableConfirmed:e.Null}),$=e.Record({status:N,value:e.Opt(e.Text),txid:e.Text,vout:e.Nat32,ancestors:e.Opt(e.Nat32),address:e.Opt(e.Text)}),F=e.Record({id:e.Text,value:e.Nat}),x=e.Record({coins:e.Vec(F),sats:e.Nat64,txid:e.Text,vout:e.Nat32}),O=e.Record({status:e.Opt($),coins:e.Vec(F),utxo:x,is_signed:e.Bool,owner_pubkey:e.Opt(e.Text),owner_address:e.Text}),q=e.Record({coins_in_inputs:e.Vec(O),txid:e.Text,signed_address_coins:e.Vec(e.Tuple(e.Text,e.Vec(F))),address_coins:e.Vec(e.Tuple(e.Text,e.Vec(F)))}),P=e.Record({is_op_return:e.Bool,utxo:x,owner_address:e.Opt(e.Text)}),L=e.Record({burned_coins:e.Vec(F),coins_in_outputs:e.Vec(P),address_coins:e.Vec(e.Tuple(e.Text,e.Vec(F)))}),G=e.Record({coin:F,from:e.Text}),X=e.Record({to:e.Text,coin:F}),Y=e.Record({input_coins:e.Vec(G),output_coins:e.Vec(X),action:e.Text,exchange_id:e.Text,pool_utxo_spent:e.Vec(e.Text),action_params:e.Text,nonce:e.Nat64,pool_address:e.Text,pool_utxo_received:e.Vec(x)}),oe=e.Record({tx_fee_in_sats:e.Nat64,initiator_address:e.Text,intentions:e.Vec(Y)}),ae=e.Record({applied_fee_rate:e.Nat64,pool_addresses:e.Vec(e.Text),coins_in_inputs:q,txid:e.Text,estimated_min_tx_fee:e.Nat64,actual_tx_fee:e.Nat64,coins_in_outputs:L,tx_vsize:e.Nat64,intention_set:oe,user_coins_in_inputs:e.Vec(F),initially_signed_addresses:e.Vec(e.Text)}),ee=e.Variant({Confirmed:e.Nat32,Rejected:e.Text,Pending:e.Null}),Z=e.Record({status:e.Opt(ee),invoke_log:I,included_block:e.Opt(A),sent_tx_hex:e.Text}),ce=e.Variant({Failed:I,NotFound:e.Null,Succeeded:Z}),ge=e.Record({maybe_rune:e.Opt(F),value:e.Nat64,script_pubkey_hex:e.Text,outpoint:e.Text}),pe=e.Record({client_info:e.Opt(e.Text),intention_set:oe,initiator_utxo_proof:e.Vec(e.Nat8),psbt_hex:e.Text}),J=e.Record({block_hash:e.Text,block_timestamp:e.Nat64,tx_ids:e.Vec(e.Text),block_height:e.Nat32}),fe=e.Variant({Ok:e.Vec(e.Text),Err:e.Text}),Se=e.Record({exchange_canister:e.Principal,exchange_id:e.Text,utxo_proof_enabled:e.Bool,client_canisters:e.Vec(e.Principal)}),Ce=e.Record({txid:e.Text,reason_code:e.Text,reason:e.Text}),Ze=e.Record({txid:e.Text,timestamp:e.Nat64,block:A}),st=e.Record({low:e.Nat64,high:e.Nat64,medium:e.Nat64});return e.Service({abandon_exchange:e.Func([t],[n],[]),clear_exchange_pools:e.Func([],[n],[]),clear_failed_invoke_logs:e.Func([e.Opt(e.Nat64),e.Vec(e.Text)],[n],[]),clear_last_block:e.Func([],[n],[]),clear_rejected_txs:e.Func([],[n],[]),clear_txs_with_min_confirmations:e.Func([e.Nat32],[n],[]),delete_tx_detail:e.Func([e.Text],[n],[]),delete_used_outpoints:e.Func([e.Text],[n],[]),estimate_min_tx_fee:e.Func([i],[s],["query"]),get_canister_info:e.Func([e.Nat64],[E],[]),get_exchange_pools:e.Func([e.Opt(e.Text)],[e.Vec(_)],["query"]),get_failed_invoke_logs:e.Func([S],[e.Vec(e.Tuple(e.Text,I))],["query"]),get_last_sent_txs:e.Func([],[e.Vec(e.Tuple(e.Text,e.Text,e.Opt(e.Nat32)))],["query"]),get_received_blocks:e.Func([e.Opt(e.Bool)],[e.Vec(U)],["query"]),get_registered_exchanges:e.Func([e.Opt(M)],[e.Vec(v)],["query"]),get_rejected_txs:e.Func([],[e.Vec(R)],["query"]),get_settings:e.Func([],[W],["query"]),get_status:e.Func([],[K],["query"]),get_tx_execution_context_view:e.Func([e.Text],[e.Opt(ae)],["query"]),get_tx_execution_result:e.Func([e.Text],[ce],["query"]),get_tx_for_outpoint:e.Func([e.Text],[e.Opt(Z)],["query"]),get_tx_queue_of_pool:e.Func([e.Text],[e.Vec(e.Tuple(e.Text,e.Opt(e.Nat32)))],["query"]),get_tx_sent:e.Func([e.Text],[e.Opt(Z)],["query"]),get_used_outpoints:e.Func([e.Opt(e.Text)],[e.Vec(e.Tuple(e.Text,e.Text))],["query"]),get_zero_confirmed_tx_count_of_pool:e.Func([e.Text],[e.Nat32],["query"]),get_zero_confirmed_txs:e.Func([e.Opt(e.Text)],[e.Vec(e.Text)],["query"]),get_zero_confirmed_utxos_of_address:e.Func([e.Text],[e.Vec(ge)],["query"]),init_status_code_message:e.Func([],[n],[]),inspect_status_code:e.Func([e.Text],[e.Text],["query"]),invoke:e.Func([pe],[m],[]),new_block_detected:e.Func([J],[n],[]),notify_exchange_for_blocks_from_height:e.Func([e.Text,e.Nat32],[fe],[]),notify_exchanges_for_block:e.Func([e.Vec(e.Text),A,e.Nat64,e.Vec(e.Text)],[fe],[]),pause_invoke:e.Func([],[n],[]),reapply_tx:e.Func([e.Text],[n],[]),register_exchange:e.Func([Se],[n],[]),reject_tx:e.Func([Ce],[n],[]),resume_invoke:e.Func([],[n],[]),rollback_tx:e.Func([e.Text],[fe],[]),save_included_block_for_tx:e.Func([Ze],[n],[]),set_bitcoin_network:e.Func([V],[n],[]),set_exchange_registry_principal:e.Func([e.Principal],[n],[]),set_max_input_count_of_psbt:e.Func([e.Nat32],[n],[]),set_max_intentions_per_invoke:e.Func([e.Nat32],[n],[]),set_max_received_blocks_count:e.Func([e.Nat32],[n],[]),set_max_unconfirmed_tx_count_in_pool:e.Func([e.Nat32],[n],[]),set_mempool_connector_principal:e.Func([e.Principal],[n],[]),set_mempool_connector_public_key:e.Func([e.Text],[n],[]),set_min_btc_amount_for_utxo:e.Func([e.Nat64],[n],[]),set_min_tx_confirmations:e.Func([e.Nat32],[n],[]),set_rune_indexer_principal:e.Func([e.Principal],[n],[]),set_tx_fee_per_vbyte:e.Func([st],[n],[]),unhalt_exchange:e.Func([e.Text],[n],[]),version:e.Func([],[e.Text],["query"])})};class P6{xverse;config;exchange;orchestrator;constructor(t){this.config=t;const n=t.network===Yo.Testnet,r=n?"https://api-testnet4.secretkeylabs.io":"https://api.secretkeylabs.io";this.xverse=new XS({baseUrl:r,apiKey:t.xverseApiKey});const i="https://icp0.io";this.exchange=ma.createActor(t.exchangeIdlFactory,{agent:yr.createSync({host:i,retryTimes:50,verifyQuerySignatures:!1}),canisterId:t.exchangeCanisterId}),this.orchestrator=ma.createActor(O6,{agent:yr.createSync({host:i,retryTimes:50,verifyQuerySignatures:!1}),canisterId:n?Ux:Nx})}async filterSpentUtxos(t,n){const r=await this.orchestrator.get_used_outpoints([t]);return n.filter(({txid:i,vout:s})=>r.findIndex(([o])=>`${i}:${s}`===o)<0)}async getPendingBtcUtxos(t){const n=await this.orchestrator.get_zero_confirmed_utxos_of_address(t),r=Zr(t);return n.filter(({maybe_rune:i})=>!i.length).map(({value:i,script_pubkey_hex:s,outpoint:o})=>{const[c,a]=o.split(":");return{txid:c,vout:Number(a),satoshis:i.toString(),scriptPk:s,addressType:r,address:t,runes:[]}})}async getPendingRuneUtxos(t,n){const r=await this.orchestrator.get_zero_confirmed_utxos_of_address(t),i=Zr(t);return r.filter(({maybe_rune:s})=>s.length).map(({value:s,script_pubkey_hex:o,outpoint:c,maybe_rune:a})=>{const[u,f]=c.split(":"),l=a[0];return{txid:u,vout:Number(f),satoshis:s.toString(),scriptPk:o,addressType:i,address:t,runes:l?[{id:l.id,amount:l.value.toString()}]:[],pubkey:n}})}async getBtcUtxos(t){let n=0;const r=60,i=[],s=await this.getPendingBtcUtxos(t);let o=!0;for(;o;){const u=await this.xverse.utxosByAddress(t,n,r);i.push(...u.items),o=u.hasMore,n+=r}const c=Ea(t,this.config.network),a=i.map(({txid:u,vout:f,value:l})=>({txid:u,vout:f,address:t,runes:[],satoshis:l.toString(),scriptPk:ba(c)}));return this.filterSpentUtxos(t,a.concat(s))}async getRuneUtxos(t,n,r){let i=0;const s=60,o=[],c=await this.getPendingRuneUtxos(t,r);let a=!0;for(;a;){const l=await this.xverse.runeUtxosByAddress(t,n,i,s);o.push(...l.items),a=l.hasMore,i+=s}const u=Ea(t,this.config.network),f=o.map(({txid:l,vout:p,runes:y,amount:g})=>({txid:l,vout:p,address:t,runes:y.map(({runeId:w,amount:E,divisibility:_})=>{const S=new ei(E).mul(10**_).toFixed(0);return{id:w,amount:S}}),satoshis:g.toString(),scriptPk:ba(u),pubkey:r})).filter(l=>Number(l.satoshis)>546);return this.filterSpentUtxos(t,f.concat(c))}async getBtcBalance(t){const r=(await this.getBtcUtxos(t)).reduce((i,s)=>i+BigInt(s.satoshis),BigInt(0));return new ei(r.toString()).div(1e8).toNumber()}async getRuneBalance(t,n,r){const i=await this.getRuneUtxos(t,n,r);if(!i)return;let s=new ei(0);for(const o of i)s=s.add(new ei(o.runes.find(c=>c.id===n)?.amount??0));return s.toNumber()}async getPoolList(){try{return await this.exchange.get_pool_list()??[]}catch(t){throw console.error("get pool list failed:",t),t}}async getPoolInfo(t){try{const n=await this.exchange.get_pool_info({pool_address:t});if(n.length===0)throw new Error("Pool not found");return n[0]}catch(n){throw console.error("get pool data failed:",n),n}}async createTransaction({address:t,paymentAddress:n,publicKey:r,feeRate:i,mergeSelfRuneBtcOutputs:s,clientInfo:o,manualBuild:c}){return new Jr({network:this.config.network,exchangeId:this.config.exchangeId,address:t,paymentAddress:n,publicKey:r,feeRate:i,mergeSelfRuneBtcOutputs:s,clientInfo:o,manualBuild:c},this)}async getRecommendedFeeRate(){const t=await this.orchestrator.get_status();return{min:Number(t.mempool_tx_fee_rate.medium),max:Number(t.mempool_tx_fee_rate.medium)*3}}}exports.Network=Yo;exports.ReeClient=P6;exports.Transaction=Jr;exports.utils=kx;
package/dist/index.es.js CHANGED
@@ -29970,17 +29970,19 @@ class Z6 {
29970
29970
  txid: l,
29971
29971
  vout: p,
29972
29972
  address: t,
29973
- runes: y.map(({ runeId: w, amount: E, divisibility: _ }) => {
29974
- const S = new Qr(E).mul(10 ** _).toFixed(0);
29975
- return {
29976
- id: w,
29977
- amount: S
29978
- };
29979
- }),
29973
+ runes: y.map(
29974
+ ({ runeId: w, amount: E, divisibility: _ }) => {
29975
+ const S = new Qr(E).mul(10 ** _).toFixed(0);
29976
+ return {
29977
+ id: w,
29978
+ amount: S
29979
+ };
29980
+ }
29981
+ ),
29980
29982
  satoshis: g.toString(),
29981
29983
  scriptPk: ma(u),
29982
29984
  pubkey: r
29983
- }));
29985
+ })).filter((l) => Number(l.satoshis) > 546);
29984
29986
  return this.filterSpentUtxos(t, f.concat(c));
29985
29987
  }
29986
29988
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnity/ree-client-ts-sdk",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "A TypeScript SDK for interacting with the Ree protocol on Bitcoin",
5
5
  "keywords": [
6
6
  "bitcoin",