//>>built
define("dojox/math/BigInteger",["dojo","dojox"],function(n,s){function j(a,b,c){null!=a&&("number"==typeof a?this._fromNumber(a,b,c):!b&&"string"!=typeof a?this._fromString(a,256):this._fromString(a,b))}function k(){return new j(null)}function w(a,b,c,d,f,e){for(;0<=--e;){var g=b*this[a++]+c[d]+f,f=Math.floor(g/67108864);c[d++]=g&67108863}return f}function x(a,b,c,d,f,e){for(var g=b&32767,b=b>>15;0<=--e;){var h=this[a]&32767,j=this[a++]>>15,i=b*h+j*g,h=g*h+((i&32767)<<15)+c[d]+(f&1073741823),f=(h>>>
30)+(i>>>15)+b*j+(f>>>30);c[d++]=h&1073741823}return f}function y(a,b,c,d,f,e){for(var g=b&16383,b=b>>14;0<=--e;){var h=this[a]&16383,j=this[a++]>>14,i=b*h+j*g,h=g*h+((i&16383)<<14)+c[d]+f,f=(h>>28)+(i>>14)+b*j;c[d++]=h&268435455}return f}function t(a){var b=k();b._fromInt(a);return b}function r(a){var b=1,c;if(c=a>>>16)a=c,b+=16;if(c=a>>8)a=c,b+=8;if(c=a>>4)a=c,b+=4;if(c=a>>2)a=c,b+=2;a>>1&&(b+=1);return b}function v(a){this.m=a}function u(a){this.m=a;this.mp=a._invDigit();this.mpl=this.mp&32767;
this.mph=this.mp>>15;this.um=(1<<a._DB-15)-1;this.mt2=2*a.t}n.getObject("math.BigInteger",!0,s);n.experimental("dojox.math.BigInteger");var m;"Microsoft Internet Explorer"==navigator.appName?(j.prototype.am=x,m=30):"Netscape"!=navigator.appName?(j.prototype.am=w,m=26):(j.prototype.am=y,m=28);var o=[],l,i;l=48;for(i=0;9>=i;++i)o[l++]=i;l=97;for(i=10;36>i;++i)o[l++]=i;l=65;for(i=10;36>i;++i)o[l++]=i;n.extend(v,{convert:function(a){return 0>a.s||0<=a.compareTo(this.m)?a.mod(this.m):a},revert:function(a){return a},
reduce:function(a){a._divRemTo(this.m,null,a)},mulTo:function(a,b,c){a._multiplyTo(b,c);this.reduce(c)},sqrTo:function(a,b){a._squareTo(b);this.reduce(b)}});n.extend(u,{convert:function(a){var b=k();a.abs()._dlShiftTo(this.m.t,b);b._divRemTo(this.m,null,b);0>a.s&&0<b.compareTo(j.ZERO)&&this.m._subTo(b,b);return b},revert:function(a){var b=k();a._copyTo(b);this.reduce(b);return b},reduce:function(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=a[b]&32767,d=c*this.mpl+((c*this.mph+
(a[b]>>15)*this.mpl&this.um)<<15)&a._DM,c=b+this.m.t;for(a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a._DV;)a[c]-=a._DV,a[++c]++}a._clamp();a._drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a._subTo(this.m,a)},mulTo:function(a,b,c){a._multiplyTo(b,c);this.reduce(c)},sqrTo:function(a,b){a._squareTo(b);this.reduce(b)}});n.extend(j,{_DB:m,_DM:(1<<m)-1,_DV:1<<m,_FV:Math.pow(2,52),_F1:52-m,_F2:2*m-52,_copyTo:function(a){for(var b=this.t-1;0<=b;--b)a[b]=this[b];a.t=this.t;a.s=this.s},_fromInt:function(a){this.t=
1;this.s=0>a?-1:0;0<a?this[0]=a:-1>a?this[0]=a+_DV:this.t=0},_fromString:function(a,b){var c;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else if(4==b)c=2;else{this._fromRadix(a,b);return}this.s=this.t=0;for(var d=a.length,f=!1,e=0;0<=--d;){var g;8==c?g=a[d]&255:(g=o[a.charCodeAt(d)],g=null==g?-1:g);0>g?"-"==a.charAt(d)&&(f=!0):(f=!1,0==e?this[this.t++]=g:e+c>this._DB?(this[this.t-1]|=(g&(1<<this._DB-e)-1)<<e,this[this.t++]=g>>this._DB-e):this[this.t-1]|=g<<
e,e+=c,e>=this._DB&&(e-=this._DB))}if(8==c&&0!=(a[0]&128))this.s=-1,0<e&&(this[this.t-1]|=(1<<this._DB-e)-1<<e);this._clamp();f&&j.ZERO._subTo(this,this)},_clamp:function(){for(var a=this.s&this._DM;0<this.t&&this[this.t-1]==a;)--this.t},_dlShiftTo:function(a,b){var c;for(c=this.t-1;0<=c;--c)b[c+a]=this[c];for(c=a-1;0<=c;--c)b[c]=0;b.t=this.t+a;b.s=this.s},_drShiftTo:function(a,b){for(var c=a;c<this.t;++c)b[c-a]=this[c];b.t=Math.max(this.t-a,0);b.s=this.s},_lShiftTo:function(a,b){var c=a%this._DB,
d=this._DB-c,f=(1<<d)-1,e=Math.floor(a/this._DB),g=this.s<<c&this._DM,h;for(h=this.t-1;0<=h;--h)b[h+e+1]=this[h]>>d|g,g=(this[h]&f)<<c;for(h=e-1;0<=h;--h)b[h]=0;b[e]=g;b.t=this.t+e+1;b.s=this.s;b._clamp()},_rShiftTo:function(a,b){b.s=this.s;var c=Math.floor(a/this._DB);if(c>=this.t)b.t=0;else{var d=a%this._DB,f=this._DB-d,e=(1<<d)-1;b[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)b[g-c-1]|=(this[g]&e)<<f,b[g-c]=this[g]>>d;0<d&&(b[this.t-c-1]|=(this.s&e)<<f);b.t=this.t-c;b._clamp()}},_subTo:function(a,
b){for(var c=0,d=0,f=Math.min(a.t,this.t);c<f;)d+=this[c]-a[c],b[c++]=d&this._DM,d>>=this._DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this[c],b[c++]=d&this._DM,d>>=this._DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a[c],b[c++]=d&this._DM,d>>=this._DB;d-=a.s}b.s=0>d?-1:0;-1>d?b[c++]=this._DV+d:0<d&&(b[c++]=d);b.t=c;b._clamp()},_multiplyTo:function(a,b){var c=this.abs(),d=a.abs(),f=c.t;for(b.t=f+d.t;0<=--f;)b[f]=0;for(f=0;f<d.t;++f)b[f+c.t]=c.am(0,d[f],b,f,0,c.t);b.s=0;b._clamp();this.s!=a.s&&j.ZERO._subTo(b,
b)},_squareTo:function(a){for(var b=this.abs(),c=a.t=2*b.t;0<=--c;)a[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b[c],a,2*c,0,1);if((a[c+b.t]+=b.am(c+1,2*b[c],a,2*c+1,d,b.t-c-1))>=b._DV)a[c+b.t]-=b._DV,a[c+b.t+1]=1}0<a.t&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1));a.s=0;a._clamp()},_divRemTo:function(a,b,c){var d=a.abs();if(!(0>=d.t)){var f=this.abs();if(f.t<d.t)null!=b&&b._fromInt(0),null!=c&&this._copyTo(c);else{null==c&&(c=k());var e=k(),g=this.s,a=a.s,h=this._DB-r(d[d.t-1]);0<h?(d._lShiftTo(h,e),f._lShiftTo(h,
c)):(d._copyTo(e),f._copyTo(c));d=e.t;f=e[d-1];if(0!=f){var i=f*(1<<this._F1)+(1<d?e[d-2]>>this._F2:0),m=this._FV/i,i=(1<<this._F1)/i,n=1<<this._F2,q=c.t,l=q-d,p=null==b?k():b;e._dlShiftTo(l,p);0<=c.compareTo(p)&&(c[c.t++]=1,c._subTo(p,c));j.ONE._dlShiftTo(d,p);for(p._subTo(e,e);e.t<d;)e[e.t++]=0;for(;0<=--l;){var o=c[--q]==f?this._DM:Math.floor(c[q]*m+(c[q-1]+n)*i);if((c[q]+=e.am(0,o,c,l,0,d))<o){e._dlShiftTo(l,p);for(c._subTo(p,c);c[q]<--o;)c._subTo(p,c)}}null!=b&&(c._drShiftTo(d,b),g!=a&&j.ZERO._subTo(b,
b));c.t=d;c._clamp();0<h&&c._rShiftTo(h,c);0>g&&j.ZERO._subTo(c,c)}}}},_invDigit:function(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var b=a&3,b=b*(2-(a&15)*b)&15,b=b*(2-(a&255)*b)&255,b=b*(2-((a&65535)*b&65535))&65535,b=b*(2-a*b%this._DV)%this._DV;return 0<b?this._DV-b:-b},_isEven:function(){return 0==(0<this.t?this[0]&1:this.s)},_exp:function(a,b){if(4294967295<a||1>a)return j.ONE;var c=k(),d=k(),f=b.convert(this),e=r(a)-1;for(f._copyTo(c);0<=--e;)if(b.sqrTo(c,d),0<(a&1<<e))b.mulTo(d,
f,c);else var g=c,c=d,d=g;return b.revert(c)},toString:function(a){if(0>this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this._toRadix(a);var b=(1<<a)-1,c,d=!1,f="",e=this.t,g=this._DB-e*this._DB%a;if(0<e--){if(g<this._DB&&0<(c=this[e]>>g))d=!0,f="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c);for(;0<=e;)g<a?(c=(this[e]&(1<<g)-1)<<a-g,c|=this[--e]>>(g+=this._DB-a)):(c=this[e]>>(g-=a)&b,0>=g&&(g+=this._DB,--e)),
0<c&&(d=!0),d&&(f+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c))}return d?f:"0"},negate:function(){var a=k();j.ZERO._subTo(this,a);return a},abs:function(){return 0>this.s?this.negate():this},compareTo:function(a){var b=this.s-a.s;if(b)return b;var c=this.t;if(b=c-a.t)return b;for(;0<=--c;)if(b=this[c]-a[c])return b;return 0},bitLength:function(){return 0>=this.t?0:this._DB*(this.t-1)+r(this[this.t-1]^this.s&this._DM)},mod:function(a){var b=k();this.abs()._divRemTo(a,null,b);0>this.s&&0<b.compareTo(j.ZERO)&&
a._subTo(b,b);return b},modPowInt:function(a,b){var c;c=256>a||b._isEven()?new v(b):new u(b);return this._exp(a,c)}});n._mixin(j,{ZERO:t(0),ONE:t(1),_nbi:k,_nbv:t,_nbits:r,_Montgomery:u});s.math.BigInteger=j;return s.math.BigInteger});