@ultrade/shared 1.0.23 → 1.0.24

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.
Files changed (42) hide show
  1. package/dist/browser/common/auth.helper.js +1 -1
  2. package/dist/browser/common/index.js +1 -1
  3. package/dist/browser/helpers/Encoding.js +1 -1
  4. package/dist/browser/helpers/algo.helper.js +1 -1
  5. package/dist/browser/helpers/balance.helper.js +1 -1
  6. package/dist/browser/helpers/codex/common.helper.js +2 -2
  7. package/dist/browser/helpers/codex/index.js +2 -2
  8. package/dist/browser/helpers/codex/mbr.helper.js +1 -1
  9. package/dist/browser/helpers/codex/mna.helper.js +1 -1
  10. package/dist/browser/helpers/codex/order.helper.js +1 -1
  11. package/dist/browser/helpers/codex/setGlobal.helper.js +1 -1
  12. package/dist/browser/helpers/codex/transfer.helper.js +2 -2
  13. package/dist/browser/helpers/codex/txn.helper.js +1 -1
  14. package/dist/browser/helpers/codex.helper.js +6 -6
  15. package/dist/browser/helpers/eth.helper.js +2 -2
  16. package/dist/browser/helpers/index.js +1 -1
  17. package/dist/browser/helpers/pointSystem.helper.js +1 -1
  18. package/dist/browser/helpers/withdraw.helper.js +2 -2
  19. package/dist/browser/interfaces/index.js +1 -1
  20. package/dist/browser/types/index.js +1 -1
  21. package/dist/node/common/index.js +1 -1
  22. package/dist/node/helpers/Encoding.js +1 -1
  23. package/dist/node/helpers/algo.helper.js +1 -1
  24. package/dist/node/helpers/balance.helper.js +1 -1
  25. package/dist/node/helpers/codex/common.helper.js +2 -2
  26. package/dist/node/helpers/codex/index.js +2 -2
  27. package/dist/node/helpers/codex/mbr.helper.js +1 -1
  28. package/dist/node/helpers/codex/mna.helper.js +1 -1
  29. package/dist/node/helpers/codex/order.helper.js +1 -1
  30. package/dist/node/helpers/codex/setGlobal.helper.js +1 -1
  31. package/dist/node/helpers/codex/transfer.helper.js +2 -2
  32. package/dist/node/helpers/codex/txn.helper.js +1 -1
  33. package/dist/node/helpers/codex.helper.js +5 -5
  34. package/dist/node/helpers/eth.helper.js +2 -2
  35. package/dist/node/helpers/withdraw.helper.js +1 -1
  36. package/dist/node/types/index.js +1 -1
  37. package/dist/src/helpers/Encoding.d.ts +1 -0
  38. package/dist/src/interfaces/order.interface.d.ts +9 -1
  39. package/dist/src/interfaces/services/balances.interface.d.ts +1 -1
  40. package/dist/src/types/balance-result.types.d.ts +86 -0
  41. package/dist/src/types/index.d.ts +1 -0
  42. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- function Ne(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var j=Ne,Q=Se;typeof globalThis.setTimeout=="function"&&(j=setTimeout);typeof globalThis.clearTimeout=="function"&&(Q=clearTimeout);function Oe(t){if(j===setTimeout)return setTimeout(t,0);if((j===Ne||!j)&&setTimeout)return j=setTimeout,setTimeout(t,0);try{return j(t,0)}catch{try{return j.call(null,t,0)}catch{return j.call(this,t,0)}}}function tn(t){if(Q===clearTimeout)return clearTimeout(t);if((Q===Se||!Q)&&clearTimeout)return Q=clearTimeout,clearTimeout(t);try{return Q(t)}catch{try{return Q.call(null,t)}catch{return Q.call(this,t)}}}var z=[],dr=!1,or,Rr=-1;function nn(){!dr||!or||(dr=!1,or.length?z=or.concat(z):Rr=-1,z.length&&Be())}function Be(){if(!dr){var t=Oe(nn);dr=!0;for(var r=z.length;r;){for(or=z,z=[];++Rr<r;)or&&or[Rr].run();Rr=-1,r=z.length}or=null,dr=!1,tn(t)}}function on(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];z.push(new Ce(t,r)),z.length===1&&!dr&&Oe(Be)}function Ce(t,r){this.fun=t,this.array=r}Ce.prototype.run=function(){this.fun.apply(null,this.array)};var an="browser",sn="browser",cn=!0,un={},pn=[],ln="",mn={},dn={},fn={};function ir(){}var gn=ir,hn=ir,xn=ir,En=ir,bn=ir,An=ir,Tn=ir;function _n(t){throw new Error("process.binding is not supported")}function yn(){return"/"}function In(t){throw new Error("process.chdir is not supported")}function Rn(){return 0}var mr=globalThis.performance||{},wn=mr.now||mr.mozNow||mr.msNow||mr.oNow||mr.webkitNow||function(){return new Date().getTime()};function Nn(t){var r=wn.call(mr)*.001,e=Math.floor(r),n=Math.floor(r%1*1e9);return t&&(e=e-t[0],n=n-t[1],n<0&&(e--,n+=1e9)),[e,n]}var Sn=new Date;function On(){var t=new Date,r=t-Sn;return r/1e3}var f={nextTick:on,title:an,browser:cn,env:un,argv:pn,version:ln,versions:mn,on:gn,addListener:hn,once:xn,off:En,removeListener:bn,removeAllListeners:An,emit:Tn,binding:_n,cwd:yn,chdir:In,umask:Rn,hrtime:Nn,platform:sn,release:dn,config:fn,uptime:On},we={};Object.keys(we).forEach(t=>{let r=t.split("."),e=f;for(let n=0;n<r.length;n++){let o=r[n];n===r.length-1?e[o]=we[t]:e=e[o]||(e[o]={})}});var Y=[],P=[],Bn=typeof Uint8Array<"u"?Uint8Array:Array,qr=!1;function Ue(){qr=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)Y[r]=t[r],P[t.charCodeAt(r)]=r;P[45]=62,P[95]=63}function Cn(t){qr||Ue();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new Bn(c*3/4-i),n=i>0?c-4:c;var u=0;for(r=0,e=0;r<n;r+=4,e+=3)o=P[t.charCodeAt(r)]<<18|P[t.charCodeAt(r+1)]<<12|P[t.charCodeAt(r+2)]<<6|P[t.charCodeAt(r+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=o&255;return i===2?(o=P[t.charCodeAt(r)]<<2|P[t.charCodeAt(r+1)]>>4,a[u++]=o&255):i===1&&(o=P[t.charCodeAt(r)]<<10|P[t.charCodeAt(r+1)]<<4|P[t.charCodeAt(r+2)]>>2,a[u++]=o>>8&255,a[u++]=o&255),a}function Dn(t){return Y[t>>18&63]+Y[t>>12&63]+Y[t>>6&63]+Y[t&63]}function Pn(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(Dn(n));return o.join("")}function De(t){qr||Ue();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,u=e-n;c<u;c+=a)i.push(Pn(t,c,c+a>u?u:c+a));return n===1?(r=t[e-1],o+=Y[r>>2],o+=Y[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=Y[r>>10],o+=Y[r>>4&63],o+=Y[r<<2&63],o+="="),i.push(o),i.join("")}s.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function wr(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function q(t,r){if(wr()<r)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=s.prototype):(t===null&&(t=new s(r)),t.length=r),t}function s(t,r,e){if(!s.TYPED_ARRAY_SUPPORT&&!(this instanceof s))return new s(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return Jr(this,t)}return Le(this,t,r,e)}s.poolSize=8192;s._augment=function(t){return t.__proto__=s.prototype,t};function Le(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?Ln(t,r,e,n):typeof r=="string"?Un(t,r,e):Mn(t,r)}s.from=function(t,r,e){return Le(null,t,r,e)};s.kMaxLength=wr();s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&s[Symbol.species]);function Me(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function kn(t,r,e,n){return Me(r),r<=0?q(t,r):e!==void 0?typeof n=="string"?q(t,r).fill(e,n):q(t,r).fill(e):q(t,r)}s.alloc=function(t,r,e){return kn(null,t,r,e)};function Jr(t,r){if(Me(r),t=q(t,r<0?0:jr(r)|0),!s.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}s.allocUnsafe=function(t){return Jr(null,t)};s.allocUnsafeSlow=function(t){return Jr(null,t)};function Un(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=ve(r,e)|0;t=q(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function zr(t,r){var e=r.length<0?0:jr(r.length)|0;t=q(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Ln(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),s.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=s.prototype):t=zr(t,r),t}function Mn(t,r){if(G(r)){var e=jr(r.length)|0;return t=q(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||to(r.length)?q(t,0):zr(t,r);if(r.type==="Buffer"&&Array.isArray(r.data))return zr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function jr(t){if(t>=wr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+wr().toString(16)+" bytes");return t|0}s.isBuffer=no;function G(t){return!!(t!=null&&t._isBuffer)}s.compare=function(r,e){if(!G(r)||!G(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=s.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!G(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function ve(t,r){if(G(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Nr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ve(t).length;default:if(n)return Nr(t).length;r=(""+r).toLowerCase(),n=!0}}s.byteLength=ve;function vn(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return zn(this,r,e);case"utf8":case"utf-8":return Ge(this,r,e);case"ascii":return $n(this,r,e);case"latin1":case"binary":return Xn(this,r,e);case"base64":return Hn(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qn(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function ar(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}s.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)ar(this,e,e+1);return this};s.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)ar(this,e,e+3),ar(this,e+1,e+2);return this};s.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)ar(this,e,e+7),ar(this,e+1,e+6),ar(this,e+2,e+5),ar(this,e+3,e+4);return this};s.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?Ge(this,0,r):vn.apply(this,arguments)};s.prototype.equals=function(r){if(!G(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0};s.prototype.compare=function(r,e,n,o,i){if(!G(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,u=Math.min(a,c),p=this.slice(o,i),d=r.slice(e,n),m=0;m<u;++m)if(p[m]!==d[m]){a=p[m],c=d[m];break}return a<c?-1:c<a?1:0};function Fe(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=s.from(r,n)),G(r))return r.length===0?-1:Pe(t,r,e,n,o);if(typeof r=="number")return r=r&255,s.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Pe(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Pe(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function u(x,b){return i===1?x[b]:x.readUInt16BE(b*i)}var p;if(o){var d=-1;for(p=e;p<a;p++)if(u(t,p)===u(r,d===-1?0:p-d)){if(d===-1&&(d=p),p-d+1===c)return d*i}else d!==-1&&(p-=p-d),d=-1}else for(e+c>a&&(e=a-c),p=e;p>=0;p--){for(var m=!0,h=0;h<c;h++)if(u(t,p+h)!==u(r,h)){m=!1;break}if(m)return p}return-1}s.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};s.prototype.indexOf=function(r,e,n){return Fe(this,r,e,n,!0)};s.prototype.lastIndexOf=function(r,e,n){return Fe(this,r,e,n,!1)};function Fn(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function Yn(t,r,e,n){return Br(Nr(r,t.length-e),t,e,n)}function Ye(t,r,e,n){return Br(ro(r),t,e,n)}function Gn(t,r,e,n){return Ye(t,r,e,n)}function Kn(t,r,e,n){return Br(Ve(r),t,e,n)}function Wn(t,r,e,n){return Br(eo(r,t.length-e),t,e,n)}s.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return Fn(this,r,e,n);case"utf8":case"utf-8":return Yn(this,r,e,n);case"ascii":return Ye(this,r,e,n);case"latin1":case"binary":return Gn(this,r,e,n);case"base64":return Kn(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wn(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Hn(t,r,e){return r===0&&e===t.length?De(t):De(t.slice(r,e))}function Ge(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var u,p,d,m;switch(c){case 1:i<128&&(a=i);break;case 2:u=t[o+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(a=m));break;case 3:u=t[o+1],p=t[o+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(a=m));break;case 4:u=t[o+1],p=t[o+2],d=t[o+3],(u&192)===128&&(p&192)===128&&(d&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|d&63,m>65535&&m<1114112&&(a=m))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Vn(n)}var ke=4096;function Vn(t){var r=t.length;if(r<=ke)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=ke));return e}function $n(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function Xn(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function zn(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Zn(t[i]);return o}function qn(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}s.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(s.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=s.prototype;else{var i=e-r;o=new s(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function y(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};s.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};s.prototype.readUInt8=function(r,e){return e||y(r,1,this.length),this[r]};s.prototype.readUInt16LE=function(r,e){return e||y(r,2,this.length),this[r]|this[r+1]<<8};s.prototype.readUInt16BE=function(r,e){return e||y(r,2,this.length),this[r]<<8|this[r+1]};s.prototype.readUInt32LE=function(r,e){return e||y(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};s.prototype.readUInt32BE=function(r,e){return e||y(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};s.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};s.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};s.prototype.readInt8=function(r,e){return e||y(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};s.prototype.readInt16LE=function(r,e){e||y(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(r,e){e||y(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(r,e){return e||y(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};s.prototype.readInt32BE=function(r,e){return e||y(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};s.prototype.readFloatLE=function(r,e){return e||y(r,4,this.length),Cr(this,r,!0,23,4)};s.prototype.readFloatBE=function(r,e){return e||y(r,4,this.length),Cr(this,r,!1,23,4)};s.prototype.readDoubleLE=function(r,e){return e||y(r,8,this.length),Cr(this,r,!0,52,8)};s.prototype.readDoubleBE=function(r,e){return e||y(r,8,this.length),Cr(this,r,!1,52,8)};function O(t,r,e,n,o,i){if(!G(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}s.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;O(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};s.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;O(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};s.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function Sr(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}s.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Sr(this,r,e,!0),e+2};s.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Sr(this,r,e,!1),e+2};function Or(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}s.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Or(this,r,e,!0),e+4};s.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Or(this,r,e,!1),e+4};s.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);O(this,r,e,n,i-1,-i)}var a=0,c=1,u=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&u===0&&this[e+a-1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};s.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);O(this,r,e,n,i-1,-i)}var a=n-1,c=1,u=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&u===0&&this[e+a+1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};s.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};s.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Sr(this,r,e,!0),e+2};s.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Sr(this,r,e,!1),e+2};s.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Or(this,r,e,!0),e+4};s.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Or(this,r,e,!1),e+4};function Ke(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function We(t,r,e,n,o){return o||Ke(t,r,e,4,34028234663852886e22,-34028234663852886e22),Xe(t,r,e,n,23,4),e+4}s.prototype.writeFloatLE=function(r,e,n){return We(this,r,e,!0,n)};s.prototype.writeFloatBE=function(r,e,n){return We(this,r,e,!1,n)};function He(t,r,e,n,o){return o||Ke(t,r,e,8,17976931348623157e292,-17976931348623157e292),Xe(t,r,e,n,52,8),e+8}s.prototype.writeDoubleLE=function(r,e,n){return He(this,r,e,!0,n)};s.prototype.writeDoubleBE=function(r,e,n){return He(this,r,e,!1,n)};s.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};s.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=G(r)?r:Nr(new s(r,o).toString()),u=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%u]}return this};var Jn=/[^+\/0-9A-Za-z-_]/g;function jn(t){if(t=Qn(t).replace(Jn,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Qn(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Zn(t){return t<16?"0"+t.toString(16):t.toString(16)}function Nr(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function ro(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function eo(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function Ve(t){return Cn(jn(t))}function Br(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function to(t){return t!==t}function no(t){return t!=null&&(!!t._isBuffer||$e(t)||oo(t))}function $e(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function oo(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&$e(t.slice(0,0))}function Cr(t,r,e,n,o){var i,a,c=o*8-n-1,u=(1<<c)-1,p=u>>1,d=-7,m=e?o-1:0,h=e?-1:1,x=t[r+m];for(m+=h,i=x&(1<<-d)-1,x>>=-d,d+=c;d>0;i=i*256+t[r+m],m+=h,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[r+m],m+=h,d-=8);if(i===0)i=1-p;else{if(i===u)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(x?-1:1)*a*Math.pow(2,i-n)}function Xe(t,r,e,n,o,i){var a,c,u,p=i*8-o-1,d=(1<<p)-1,m=d>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,b=n?1:-1,_=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=d):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+m>=1?r+=h/u:r+=h*Math.pow(2,1-m),r*u>=2&&(a++,u/=2),a+m>=d?(c=0,a=d):a+m>=1?(c=(r*u-1)*Math.pow(2,o),a=a+m):(c=r*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;t[e+x]=c&255,x+=b,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;t[e+x]=a&255,x+=b,a/=256,p-=8);t[e+x-b]|=_*128}import E from"algosdk";import*as Wr from"bs58";import Qr from"bignumber.js";Qr.config({DECIMAL_PLACES:40,EXPONENTIAL_AT:45});function sr(t,r){return io(t,r,"/")}function io(t,r,e){switch(t=new Qr(String(t)),r=new Qr(String(r)),e.toLowerCase()){case"-":return t.minus(r).toString();case"+":return t.plus(r).toString();case"*":case"x":return t.multipliedBy(r).toString();case"\xF7":case"/":return t.dividedBy(r).toString();case">=":return t.isGreaterThanOrEqualTo(r);case">":return t.isGreaterThan(r);case"<=":return t.isLessThanOrEqualTo(r);case"<":return t.isLessThan(r);case"==":return t.isEqualTo(r);case"mod":return t.modulo(r);default:break}}var ze=t=>{let r=new Date(t),e=r.toLocaleDateString("default",{year:"numeric",month:"numeric",day:"numeric"}),n=r.toLocaleTimeString("en-US",{hour12:!0,hour:"2-digit",minute:"2-digit"});return e+" "+n};import $o from"algosdk";import*as ae from"bs58";import xt from"algosdk";import Oi,{decodeAddress as Bi,encodeAddress as Ci}from"algosdk";var K=[],k=[],ao=typeof Uint8Array<"u"?Uint8Array:Array,re=!1;function Qe(){re=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)K[r]=t[r],k[t.charCodeAt(r)]=r;k[45]=62,k[95]=63}function so(t){re||Qe();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new ao(c*3/4-i),n=i>0?c-4:c;var u=0;for(r=0,e=0;r<n;r+=4,e+=3)o=k[t.charCodeAt(r)]<<18|k[t.charCodeAt(r+1)]<<12|k[t.charCodeAt(r+2)]<<6|k[t.charCodeAt(r+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=o&255;return i===2?(o=k[t.charCodeAt(r)]<<2|k[t.charCodeAt(r+1)]>>4,a[u++]=o&255):i===1&&(o=k[t.charCodeAt(r)]<<10|k[t.charCodeAt(r+1)]<<4|k[t.charCodeAt(r+2)]>>2,a[u++]=o>>8&255,a[u++]=o&255),a}function co(t){return K[t>>18&63]+K[t>>12&63]+K[t>>6&63]+K[t&63]}function uo(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(co(n));return o.join("")}function qe(t){re||Qe();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,u=e-n;c<u;c+=a)i.push(uo(t,c,c+a>u?u:c+a));return n===1?(r=t[e-1],o+=K[r>>2],o+=K[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=K[r>>10],o+=K[r>>4&63],o+=K[r<<2&63],o+="="),i.push(o),i.join("")}function kr(t,r,e,n,o){var i,a,c=o*8-n-1,u=(1<<c)-1,p=u>>1,d=-7,m=e?o-1:0,h=e?-1:1,x=t[r+m];for(m+=h,i=x&(1<<-d)-1,x>>=-d,d+=c;d>0;i=i*256+t[r+m],m+=h,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[r+m],m+=h,d-=8);if(i===0)i=1-p;else{if(i===u)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(x?-1:1)*a*Math.pow(2,i-n)}function Ze(t,r,e,n,o,i){var a,c,u,p=i*8-o-1,d=(1<<p)-1,m=d>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,b=n?1:-1,_=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=d):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+m>=1?r+=h/u:r+=h*Math.pow(2,1-m),r*u>=2&&(a++,u/=2),a+m>=d?(c=0,a=d):a+m>=1?(c=(r*u-1)*Math.pow(2,o),a=a+m):(c=r*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;t[e+x]=c&255,x+=b,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;t[e+x]=a&255,x+=b,a/=256,p-=8);t[e+x-b]|=_*128}var po={}.toString,rt=Array.isArray||function(t){return po.call(t)=="[object Array]"};var lo=50;l.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;var Ii=Dr();function Dr(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function J(t,r){if(Dr()<r)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=l.prototype):(t===null&&(t=new l(r)),t.length=r),t}function l(t,r,e){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return ee(this,t)}return et(this,t,r,e)}l.poolSize=8192;l._augment=function(t){return t.__proto__=l.prototype,t};function et(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?go(t,r,e,n):typeof r=="string"?fo(t,r,e):ho(t,r)}l.from=function(t,r,e){return et(null,t,r,e)};l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array);function tt(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function mo(t,r,e,n){return tt(r),r<=0?J(t,r):e!==void 0?typeof n=="string"?J(t,r).fill(e,n):J(t,r).fill(e):J(t,r)}l.alloc=function(t,r,e){return mo(null,t,r,e)};function ee(t,r){if(tt(r),t=J(t,r<0?0:te(r)|0),!l.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}l.allocUnsafe=function(t){return ee(null,t)};l.allocUnsafeSlow=function(t){return ee(null,t)};function fo(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=nt(r,e)|0;t=J(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function Zr(t,r){var e=r.length<0?0:te(r.length)|0;t=J(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function go(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),l.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=l.prototype):t=Zr(t,r),t}function ho(t,r){if(W(r)){var e=te(r.length)|0;return t=J(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||Uo(r.length)?J(t,0):Zr(t,r);if(r.type==="Buffer"&&rt(r.data))return Zr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function te(t){if(t>=Dr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Dr().toString(16)+" bytes");return t|0}l.isBuffer=Lo;function W(t){return!!(t!=null&&t._isBuffer)}l.compare=function(r,e){if(!W(r)||!W(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};l.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(r,e){if(!rt(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return l.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=l.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!W(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function nt(t,r){if(W(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Pr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(t).length;default:if(n)return Pr(t).length;r=(""+r).toLowerCase(),n=!0}}l.byteLength=nt;function xo(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return No(this,r,e);case"utf8":case"utf-8":return at(this,r,e);case"ascii":return Ro(this,r,e);case"latin1":case"binary":return wo(this,r,e);case"base64":return yo(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return So(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function cr(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}l.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)cr(this,e,e+1);return this};l.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)cr(this,e,e+3),cr(this,e+1,e+2);return this};l.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)cr(this,e,e+7),cr(this,e+1,e+6),cr(this,e+2,e+5),cr(this,e+3,e+4);return this};l.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?at(this,0,r):xo.apply(this,arguments)};l.prototype.equals=function(r){if(!W(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:l.compare(this,r)===0};l.prototype.inspect=function(){var r="",e=lo;return this.length>0&&(r=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(r+=" ... ")),"<Buffer "+r+">"};l.prototype.compare=function(r,e,n,o,i){if(!W(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,u=Math.min(a,c),p=this.slice(o,i),d=r.slice(e,n),m=0;m<u;++m)if(p[m]!==d[m]){a=p[m],c=d[m];break}return a<c?-1:c<a?1:0};function ot(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=l.from(r,n)),W(r))return r.length===0?-1:Je(t,r,e,n,o);if(typeof r=="number")return r=r&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Je(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Je(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function u(x,b){return i===1?x[b]:x.readUInt16BE(b*i)}var p;if(o){var d=-1;for(p=e;p<a;p++)if(u(t,p)===u(r,d===-1?0:p-d)){if(d===-1&&(d=p),p-d+1===c)return d*i}else d!==-1&&(p-=p-d),d=-1}else for(e+c>a&&(e=a-c),p=e;p>=0;p--){for(var m=!0,h=0;h<c;h++)if(u(t,p+h)!==u(r,h)){m=!1;break}if(m)return p}return-1}l.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};l.prototype.indexOf=function(r,e,n){return ot(this,r,e,n,!0)};l.prototype.lastIndexOf=function(r,e,n){return ot(this,r,e,n,!1)};function Eo(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function bo(t,r,e,n){return Mr(Pr(r,t.length-e),t,e,n)}function it(t,r,e,n){return Mr(Po(r),t,e,n)}function Ao(t,r,e,n){return it(t,r,e,n)}function To(t,r,e,n){return Mr(pt(r),t,e,n)}function _o(t,r,e,n){return Mr(ko(r,t.length-e),t,e,n)}l.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return Eo(this,r,e,n);case"utf8":case"utf-8":return bo(this,r,e,n);case"ascii":return it(this,r,e,n);case"latin1":case"binary":return Ao(this,r,e,n);case"base64":return To(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _o(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yo(t,r,e){return r===0&&e===t.length?qe(t):qe(t.slice(r,e))}function at(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var u,p,d,m;switch(c){case 1:i<128&&(a=i);break;case 2:u=t[o+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(a=m));break;case 3:u=t[o+1],p=t[o+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(a=m));break;case 4:u=t[o+1],p=t[o+2],d=t[o+3],(u&192)===128&&(p&192)===128&&(d&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|d&63,m>65535&&m<1114112&&(a=m))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Io(n)}var je=4096;function Io(t){var r=t.length;if(r<=je)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=je));return e}function Ro(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function wo(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function No(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Do(t[i]);return o}function So(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}l.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(l.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=l.prototype;else{var i=e-r;o=new l(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function I(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};l.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};l.prototype.readUInt8=function(r,e){return e||I(r,1,this.length),this[r]};l.prototype.readUInt16LE=function(r,e){return e||I(r,2,this.length),this[r]|this[r+1]<<8};l.prototype.readUInt16BE=function(r,e){return e||I(r,2,this.length),this[r]<<8|this[r+1]};l.prototype.readUInt32LE=function(r,e){return e||I(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};l.prototype.readUInt32BE=function(r,e){return e||I(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};l.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};l.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};l.prototype.readInt8=function(r,e){return e||I(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};l.prototype.readInt16LE=function(r,e){e||I(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(r,e){e||I(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(r,e){return e||I(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};l.prototype.readInt32BE=function(r,e){return e||I(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};l.prototype.readFloatLE=function(r,e){return e||I(r,4,this.length),kr(this,r,!0,23,4)};l.prototype.readFloatBE=function(r,e){return e||I(r,4,this.length),kr(this,r,!1,23,4)};l.prototype.readDoubleLE=function(r,e){return e||I(r,8,this.length),kr(this,r,!0,52,8)};l.prototype.readDoubleBE=function(r,e){return e||I(r,8,this.length),kr(this,r,!1,52,8)};function B(t,r,e,n,o,i){if(!W(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;B(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};l.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;B(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};l.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,1,255,0),l.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function Ur(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}l.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Ur(this,r,e,!0),e+2};l.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Ur(this,r,e,!1),e+2};function Lr(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}l.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Lr(this,r,e,!0),e+4};l.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Lr(this,r,e,!1),e+4};l.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);B(this,r,e,n,i-1,-i)}var a=0,c=1,u=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&u===0&&this[e+a-1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};l.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);B(this,r,e,n,i-1,-i)}var a=n-1,c=1,u=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&u===0&&this[e+a+1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};l.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,1,127,-128),l.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};l.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Ur(this,r,e,!0),e+2};l.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Ur(this,r,e,!1),e+2};l.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Lr(this,r,e,!0),e+4};l.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Lr(this,r,e,!1),e+4};function st(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ct(t,r,e,n,o){return o||st(t,r,e,4),Ze(t,r,e,n,23,4),e+4}l.prototype.writeFloatLE=function(r,e,n){return ct(this,r,e,!0,n)};l.prototype.writeFloatBE=function(r,e,n){return ct(this,r,e,!1,n)};function ut(t,r,e,n,o){return o||st(t,r,e,8),Ze(t,r,e,n,52,8),e+8}l.prototype.writeDoubleLE=function(r,e,n){return ut(this,r,e,!0,n)};l.prototype.writeDoubleBE=function(r,e,n){return ut(this,r,e,!1,n)};l.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!l.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};l.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!l.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=W(r)?r:Pr(new l(r,o).toString()),u=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%u]}return this};var Oo=/[^+\/0-9A-Za-z-_]/g;function Bo(t){if(t=Co(t).replace(Oo,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Co(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Do(t){return t<16?"0"+t.toString(16):t.toString(16)}function Pr(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function Po(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function ko(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function pt(t){return so(Bo(t))}function Mr(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function Uo(t){return t!==t}function Lo(t){return t!=null&&(!!t._isBuffer||lt(t)||Mo(t))}function lt(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Mo(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&lt(t.slice(0,0))}import{encodeAddress as ft,decodeAddress as Mi}from"algosdk";function A(t){return t.reduce((r,e)=>Uint8Array.from([...r,...e]))}function Z(t){return new Uint8Array(l.from(t))}function mt(t){return l.from(t).toString("utf-8")}function dt(t){let r=l.alloc(8);for(let e=0;e<8;e++)r[7-e]=Number(BigInt(t)>>BigInt(e*8)&BigInt(255));return new Uint8Array(r)}function vr(t){return l.from(t).toString("base64")}function fr(t){return l.from(t,"base64")}var Qi=`{"theme1":{"value":"${f.env.FRONTEND_URL}/Theme%3DDark.svg","active":true},"theme2":{"value":"${f.env.FRONTEND_URL}/Theme%3DLight.svg","active":true},"theme3":{"value":"${f.env.FRONTEND_URL}/Theme%3DLight.svg","active":true}}`;var gt={V1_1:"v1_1",V2:"v2"},ta={[gt.V1_1]:{testnet:62368684,mainnet:552635992},[gt.V2]:{testnet:148607e3,mainnet:1002541853}};function ht(t){return Object.keys(t).sort().reduce((r,e)=>({...r,[e]:t[e]}),{})}function Fo(t){let r={};return t.forEach(e=>{let n=fr(e.key).toString(),o=e.value,i=o.type;i==2&&(o=o.uint),i==1&&(o=fr(o.bytes)),n=="gov"?r.gov=ft(o):r[n]=o}),ht(r)}var Et=t=>{let r={0:t.amount},e=t.assets;for(let n=0;n<e.length;n++){let o=e[n]["asset-id"],i=e[n].amount;r[o]=i}return console.log(`Account ${t.address} balances`,JSON.stringify(r)),r},bt=async(t,r)=>{let e=await t.getApplicationByID(r).do();return Fo(e.params["global-state"])};var H=async(t,r,e)=>{try{let{value:n}=await t.getApplicationBoxByName(r,e).do();return n}catch(n){if(n.message.includes("box not found"))return console.log(`Box not found '${s.from(e).toString("hex")}'`),null;throw n}},V=async(t,r=1)=>{let e=await t.getTransactionParams().do();return r>1&&(e.fee=xt.ALGORAND_MIN_TX_FEE*r,e.flatFee=!0),{...e}},At=(t,r)=>Object.keys(t).includes(r.toString()),Tt=t=>xt.decodeAddress(t.toUpperCase()).publicKey;import*as T from"ethereumjs-util";function U(t){let r=T.fromSigned(s.from(t));return BigInt(r.toString())}function Go(t){return T.toUnsigned(new T.BN(String(t)))}function ne(t){let r=Go(t);if(r.length>32)throw new Error("Invalid value. The buffer length of the value is more than 32");return new Uint8Array(T.setLengthLeft(r,32))}var oe=t=>{if(t.length!==32)throw new Error("Invalid address bytes. The address buffer length is not equel 32");let r=s.from(t).toString("hex");if(r.slice(0,24)!=="000000000000000000000000")throw console.log("normalizedAddress",r),new Error("Invalid normalized address");let e="0x"+r.slice(-40);if(!Wo(e))throw new Error("Invalid hex address");return e},_t=t=>new Uint8Array(T.setLengthLeft(Er(t),32)),Er=t=>s.from(Ko(t),"hex"),Ko=t=>t.startsWith("0x")?t.slice(2):t,Wo=t=>T.isValidAddress(t),yt=(t,r)=>{let e=T.keccak256(t),{r:n,s:o,v:i}=T.fromRpcSig(r);return T.ecrecover(e,i,n,o)};var C=t=>new Uint8Array(T.keccak256(s.from(t)));var Rt=(o=>(o.GLOBAL_PAIR_DELISTING="GLOBAL_PAIR_DELISTING",o.GLOBAL_NEW_PAIR_LISTING="GLOBAL_NEW_PAIR_LISTING",o.GLOBAL_SYSTEM_MAINTENANCE="GLOBAL_SYSTEM_MAINTENANCE",o.GLOBAL_SMART_CONTRACT_UPDATE="GLOBAL_SMART_CONTRACT_UPDATE",o))(Rt||{}),wt=(n=>(n.ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT="ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT",n.ACCOUNT_KYC_STATUS_CHANGED="ACCOUNT_KYC_STATUS_CHANGED",n.ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED="ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED",n))(wt||{}),Js={...Rt,...wt};var se=(t,r)=>A([g(r,"str"),C(t)]),ce=(t,r)=>A([g(r,"str"),s.from(t,"hex")]),N=(t,r)=>{let e=$o.ABIMethod.fromSignature(t),n=e.getSelector(),o={},i=r.map((a,c)=>{let u=e.args[c].type.encode(a);return o[`txnArgs${c}`]=Array.apply([],Array.from(u)).join(", "),u});return[n,...i]},br=(t,r,e)=>{let n=s.from(t,r),o=n.subarray(n.length-e),i=s.from(o).toString();return fr(i)},ur=(t,r,e,n,o="hex")=>[ie(t,o,n),Xo(r,n),zo(e,n,t,r,o)],Xo=(t,r)=>r===8?fr(t):r===1?ae.decode(t):Er(t),zo=(t,r,e,n,o)=>r===8||r===1?$(t,r):yt(ie(e,o,r),n),qo=(t,r)=>r===8?"MX":r===1?"":`Ethereum Signed Message:
2
- ${t.length}`,ie=(t,r,e)=>{let n=s.from(t,r);return s.concat([Z(qo(n,e)),n])};var $=(t,r)=>r===8?Tt(t):r===1?ae.decode(t):_t(t);import pu from"algosdk";import bu from"algosdk";import Rp from"algosdk";var Ar={"0x4343545055534443000000000000000000000000000000000000000000000000":65537};var Uu={SMALLESTUNIT:f.env.SMALLEST_UNIT},Lu={SMALLEST_UNITS:f.env.SMALLEST_UNIT};var Gu=["point-system.discordEnabled","point-system.telegramBotName","point-system.telegramBotId","point-system.telegramEnabled","point-system.telegramGroupId","point-system.telegramGroupName","point-system.twitterAccountId","point-system.twitterAccountName","point-system.twitterEnabled","point-system.twitterJobEnabled","point-system.guideLink"];var zu=f.env.REACT_APP_API_URL,qu=f.env.REACT_APP_SOCKET_URL,Ju=f.env.REACT_APP_ALGO_SERVER,ju=f.env.REACT_APP_ALGO_SERVER_PORT||"",Qu=f.env.REACT_APP_ALGOD_TOKEN||"",Zu=f.env.REACT_APP_DISPENSER_LINK,rp=f.env.REACT_APP_FRONTEND_LINK||"",ep=f.env.REACT_APP_ALGO_EXPLORER_LINK,tp=f.env.REACT_APP_ALGO_EXPLORER_ASSETS_URL,np=(f.env.REACT_APP_REQUIRE_ACCESS_CODE||"").toLowerCase()==="true",op=f.env.REACT_APP_USERBACK_ACCESS_TOKEN,ip=(f.env.REACT_APP_EXT_ORDER_TYPES||"").toLowerCase()==="true";var ap=.001*10**6,sp=.002*10**6;var cp=f.env.REACT_APP_MASTER_APP_ID||"406",up=f.env.REACT_APP_AGG_APP_ID||"408",Jo=Number(f.env.REACT_APP_CODEX_APP_ID||"467960617");console.log("CODEX_APP_ID",Jo);var jo=f.env.REACT_APP_ALGO_NETWORK||"";var pp=jo.toLowerCase()==="mainnet"?"mainnet":"testnet";var pe=(t,r="hex")=>br(t,r,328),Fr=(t,r)=>se(pe(t,r),"O_"),St=t=>ce(t,"O_");import Up from"algosdk";import me from"algosdk";var Yr=(t,r,e,n,o,i)=>{let a=N("dummy(uint64)void",[1]);return me.makeApplicationNoOpTxnFromObject({from:r,suggestedParams:{...e,fee:me.ALGORAND_MIN_TX_FEE,flatFee:!0},appArgs:a,appIndex:t,boxes:n,foreignApps:i,note:new Uint8Array(s.from(o))})},Ot=(t,r)=>{let{accounts:n,foreignAssets:o,foreignApps:i,boxes:a,appIndex:c,from:u,suggestedParams:p}=r;console.log("Total resources",[n,i,o,a]);let d=[n,i,o,a].reduce((R,M)=>R+(M?.length||0),0),m=a?.slice(0,8-d)||[],h=a?.slice(8-d)||[],x=8-(i?.length||0),b=me.makeApplicationNoOpTxnFromObject({...r,boxes:m}),_=1,S=[],w=[];for(let R=0;R<h.length;R++){let M=h[R];S.push(M),(S.length===x||R===h.length-1)&&(w.push(Yr(c,u,p,S,`${t}_${_}`,i)),S=[],_++)}return w.push(Yr(c,u,p,[],`${t}_${++_}`,i)),console.log("dummy count",w.length),[b,...w]};function de(t){switch(t){case"B":return"BUY";case"S":return"SELL";default:throw new Error("Unknown order side short type: "+t)}}function fe(t){switch(t){case"I":return"IOC";case"P":return"POST";case"M":return"Market";case"L":default:return"Limit"}}var _l=(t,r,e="address")=>({address:(e==="token"?ei:kt)(t,Number(r)),chainId:Number(r)}),kt=(t,r)=>{let e=s.from(t.startsWith("0x")?t.substring(2):t,"hex");return r===8?E.encodeAddress(e):r===1?Wr.encode(e):oe(e)};function ei(t,r){return Number(r)===8?String(Number(t)):Ar["0x"+t]?"0x"+t:kt(t,Number(r))}var g=(t,r,e)=>{switch(r){case"8B":return E.encodeUint64(Number(t));case"32B":return ne(t);case"str":return Z(String(t));case"address":return $(String(t),e);case"token":return Ae(String(t),e);case"float":{var n=s.alloc(8);return n.writeDoubleBE(Number(t),0),new Uint8Array(n)}case"bool":return new Uint8Array(s.from(E.encodeUint64(Number(t))).subarray(-1));case"2B":return new Uint8Array(s.from(E.encodeUint64(Number(t))).subarray(-2));case"4B":return new Uint8Array(s.from(E.encodeUint64(Number(t))).subarray(-4));default:return s.from(t.toString())}},D=(t,r,e)=>{switch(r){case"8B":return E.decodeUint64(t,"safe");case"32B":return U(t);case"str":return mt(t);case"address":return lr(t,e);case"token":return Ut(t,e);case"float":return s.from(t).readDoubleBE(0);case"bool":case"2B":return D(t,"8B");default:return s.from(t).toString()}},xe=(t,r,e)=>lr(t.subarray(r,r+32),e),Bt=(t,r,e)=>Ut(t.subarray(r,r+32),e),ti=(t,r=0)=>Number(D(t.subarray(r,r+8),"float")),Ct=(t,r,e)=>String(D(t.subarray(r,r+e),"str")),ge=(t,r=0)=>Number(D(t.subarray(r,r+2),"8B")),he=(t,r=0)=>Number(D(t.subarray(r,r+4),"8B")),Ee=(t,r=0)=>Number(D(t.subarray(r,r+8),"8B")),Dt=(t,r=0)=>String(D(t.subarray(r,r+32),"32B")),lr=(t,r)=>r===8?E.encodeAddress(t):r===1?Wr.encode(t):oe(t),Ut=(t,r)=>{let e=s.from(t).toString("hex");return e.startsWith("0x")||(e="0x"+e),Ar[e]?e:r===8?String(U(t)):r===1?Wr.encode(t):lr(t,r)},yl=(t,r,e=!1)=>{let n=s.from($(t,r)).toString("hex");return e&&!n.startsWith("0x")?`0x${n}`:n},Il=t=>t.startsWith("0x")?s.from(t.substring(2),"hex").length===32:s.from(t,"hex").length===32,Ae=(t,r)=>r===8?ne(+t):Ar[t]?new Uint8Array(Er(String(t))):$(String(t),r),Rl=async(t,r)=>{let e=await bt(t,r),n=e.MSG_PROCESSOR,o=e.UL_SUPERADMIN_APP,i=e.UL_SUPERADMIN_WALLET;i=i?.length?i:void 0;let a=i&&Number(D(i.subarray(32,40),"8B")),c={collectionWallet:i&&lr(i.subarray(0,32),a),collectionWalletChainId:a,msgProcId:n,superAppId:o};return console.log("CodexState parsed",c),c},wl=async(t,r)=>{let e=E.getApplicationAddress(r);console.log("appAddress",e);let n=await t.accountInformation(e).do();console.log("CODEX AccountInfo",n)},Nl=(t,r)=>{let e=L(t.address,t.chainId,r.address,r.chainId);return s.from(C(e)).toString("hex")},L=(t,r,e,n)=>{let o=$(t,r),i=E.encodeUint64(r),a=E.encodeUint64(n),c=Ae(e,n);return A([o,i,c,a])},Te=(t,r)=>{let e=A([Ae(t,r),E.encodeUint64(r)]);return C(e)},Sl=async(t,r,e,n)=>{let o=Te(e,n),i=await _e(t,r,o);return console.log("Box CCTP balance",e.substring(0,18),n,i),i},Ol=async(t,r,e,n=[1,6,10002,10003,10004,10005])=>{let o=await Promise.all(n.map(c=>_e(t,r,Te(e,c)))),i=(c,u=6)=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:u}).format(+sr(c,10**u)),a={};for(let c=0;c<n.length;c++){let u=n[c];a[u]=i(o[c])}return console.log("Box CCTP balance",a),a},Bl=t=>A([g("Rebalance_","str"),E.encodeUint64(t)]),be=t=>{let r=A([g("TokenManager","str"),E.encodeUint64(t)]);return C(r)},Cl=async(t,r,e)=>{let n=be(e),o=await H(t,r,n);if(!o)return;let i=lr(o,e);return console.log("Box TokenManager of chain",e,i),i},gr=(t,r)=>{let e=$(t,r),n=Z("TK_");return A([n,e])},Dl=async(t,r,e,n)=>{let o=C(gr(e,n)),i=await H(t,r,o);if(!i)return;let a=[];for(let c=0;c+32<=i.length;c+=32){let u=lr(i.subarray(c,c+32),8);a.push(u)}return console.log("Box account trading keys",e.substring(0,8),a,s.from(o).toString("hex")),a},Pl=async(t,r)=>{let e=E.getApplicationAddress(r);return await ni(t,e)},ni=async(t,r)=>{let e=await t.accountInformation(r).do();return Et(e)},kl=async(t,r)=>{let{boxes:e}=await t.getApplicationBoxes(r).do();console.log(`boxes of ${r}`,e.map(n=>n.name))},Ul=async(t,r,e,n)=>oi(t,r,e.address,e.chainId,n.address,n.chainId),oi=async(t,r,e,n,o,i)=>{let a=C(L(e,n,o,i)),c=await _e(t,r,a);return console.log("Box account value",e.substring(0,8),o,c,s.from(a).toString("hex")),String(c)},Ll=async(t,r,e)=>{let n=s.from(e,"hex"),o=await H(t,r,n),i=0n;return o&&(i=U(o)),console.log("Box account value",JSON.stringify({hash:e.substring(0,8),boxValue:String(i),box:`[${o?.toString()}]`})),i},_e=async(t,r,e)=>{let n=await H(t,r,e),o=0n;return n&&(o=U(n)),o},Tr=t=>g(t,"8B"),Ml=async(t,r,e)=>{let n=Tr(e),o=await H(t,r,n);if(!o)return;let i=Number(D(o.subarray(32,40),"8B")),a={collectionWallet:lr(o.subarray(0,32),i),collectionWalletChainId:i,takerFee:Number(D(o.subarray(40,48),"8B")),makerFee:o.length>48?Number(D(o.subarray(48,56),"8B")):0};return console.log(`Box company #${e} value`,a),a},vl=async(t,r,e,n)=>{let o=C(ye(e,n)),i=await H(t,r,o);if(!i)return;let a={minSize:U(i.subarray(0,32)),minPriceIncrement:U(i.subarray(32,64)),minSizeIncrement:U(i.subarray(64,96))};return console.log("Box pair value",i,a),a},Fl=async(t,r,e,n=!0)=>{let o=e.boxName||e.hash&&St(e.hash)||Fr(e.message,"hex"),i=await H(t,r,o);if(!i)return;let a={hash:s.from(o).toString("hex"),amount:U(i.subarray(0,32)),price:U(i.subarray(32,64)),expiredTime:U(i.subarray(64,72)),expiredDate:new Date(Number(U(i.subarray(64,72)))*1e3)};return n&&console.log("Box order value",JSON.stringify({expiredDate:a.expiredDate,expiredTime:String(a.expiredTime),hash:a.hash,price:String(a.price),amount:String(a.amount)})),a},Yl=async(t,r,e)=>{let n=C(er(e)),o=await H(t,r,n);if(!o)return;let i={decimal:Number(D(o.subarray(2,10),"8B")),name:String(D(o.subarray(12,o.length),"str"))};return console.log("Box token value",o,i),i},ii=(t,r,e,n,o,i)=>{if(i.chainId!==8)return;let a=Number(i.address);if(a===0||At(o,a))return;console.log("Make optin to codex for",a);let u=E.ABIMethod.fromSignature("asset_opt_in(asset)void").getSelector(),p={...n,fee:E.ALGORAND_MIN_TX_FEE*2,flatFee:!0};return E.makeApplicationNoOpTxnFromObject({appIndex:t,from:e,suggestedParams:p,appArgs:[u,dt(a)],foreignApps:[r],foreignAssets:[a]})},Gl=async(t,r,e,n,o,i,a,c)=>{console.log("makeDeposit args",{sender:e,loginAddress:n,loginChainId:o,tokenAmount:i,tokenIndex:a,appId:t});let u=[],p=await V(r,1),d=E.getApplicationAddress(t),m={suggestedParams:p,from:e,to:d,amount:i};u.push(a===0?E.makePaymentTxnWithSuggestedParamsFromObject(m):E.makeAssetTransferTxnWithSuggestedParamsFromObject({...m,assetIndex:a}));let h=E.ABIMethod.fromSignature("depositToCodex(byte[])uint64"),x=h.getSelector(),b=ai({loginAddress:n,loginChainId:o}),_=h.args[0].type.encode(b),S=C(L(n,o,a,c));return u.push(E.makeApplicationNoOpTxnFromObject({appIndex:t,from:e,suggestedParams:p,appArgs:[x,_],boxes:[{appIndex:t,name:S}]})),u},Lt=(t,r)=>{let e=$(t,r),n=E.encodeUint64(r),o=A([e,n]);return console.log("messageBytes",o,JSON.stringify(o),vr(o)),o},ai=({loginAddress:t,loginChainId:r})=>Lt(t,r),si=({loginAddress:t,loginChainId:r})=>Lt(t,r),Kl=t=>{try{let r=s.concat([s.from(g(t.version,"2B")),s.from(g(t.expiredTime,"4B")),s.from(g(t.orderSide,"str")),s.from(g(t.price,"32B")),s.from(g(t.amount,"32B")),s.from(g(t.orderType,"str")),s.from(g(t.address,"address",t.chainId)),s.from(g(t.chainId,"2B")),s.from(g(t.baseTokenAddress,"token",t.baseTokenChainId)),s.from(g(t.baseTokenChainId,"4B")),s.from(g(t.priceTokenAddress,"token",t.priceTokenChainId)),s.from(g(t.priceTokenChainId,"4B")),s.from(g(t.companyId,"2B")),s.from(g(t.random,"8B")),s.from(g(t.decimalPrice,"float")),s.alloc(50)]),e=new Uint8Array(s.from(vr(r))),n=new Uint8Array([...ci(t),...e]);return console.log(`Order data should be ${328} bytes`,e.length,e),n}catch(r){console.error(r)}},ci=t=>{let{amount:r,price:e,baseTokenAddress:n,baseChain:o,baseCurrency:i,baseDecimal:a,priceTokenAddress:c,priceChain:u,priceCurrency:p,priceDecimal:d}=t,m=i?.toUpperCase(),h=p?.toUpperCase(),x=sr(r,10**a),b=sr(e,10**d),_=de(t.orderSide),S=fe(t.orderType),w=(nr,v)=>`${nr}`+(v&&` (${v})`),R=t.orderType==="M"?`ESTIMATED TOTAL ${b} ${h}`:`LIMIT PRICE ${b} ${h} per ${m}`,tr=[`NEW ${S.toUpperCase()} ORDER ${w(m,o)} / ${w(h,u)}:`,`${_} ${x} ${m}, ${R}`,`${m} ID: ${n}`,`${h} ID: ${c}`,`Exp: ${30} Days`].join(`
1
+ function Ne(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var j=Ne,Q=Se;typeof globalThis.setTimeout=="function"&&(j=setTimeout);typeof globalThis.clearTimeout=="function"&&(Q=clearTimeout);function Be(t){if(j===setTimeout)return setTimeout(t,0);if((j===Ne||!j)&&setTimeout)return j=setTimeout,setTimeout(t,0);try{return j(t,0)}catch{try{return j.call(null,t,0)}catch{return j.call(this,t,0)}}}function tn(t){if(Q===clearTimeout)return clearTimeout(t);if((Q===Se||!Q)&&clearTimeout)return Q=clearTimeout,clearTimeout(t);try{return Q(t)}catch{try{return Q.call(null,t)}catch{return Q.call(this,t)}}}var z=[],dr=!1,or,Rr=-1;function nn(){!dr||!or||(dr=!1,or.length?z=or.concat(z):Rr=-1,z.length&&Oe())}function Oe(){if(!dr){var t=Be(nn);dr=!0;for(var r=z.length;r;){for(or=z,z=[];++Rr<r;)or&&or[Rr].run();Rr=-1,r=z.length}or=null,dr=!1,tn(t)}}function on(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];z.push(new Ce(t,r)),z.length===1&&!dr&&Be(Oe)}function Ce(t,r){this.fun=t,this.array=r}Ce.prototype.run=function(){this.fun.apply(null,this.array)};var an="browser",sn="browser",cn=!0,un={},pn=[],ln="",mn={},dn={},fn={};function ir(){}var gn=ir,hn=ir,xn=ir,En=ir,bn=ir,An=ir,Tn=ir;function _n(t){throw new Error("process.binding is not supported")}function yn(){return"/"}function In(t){throw new Error("process.chdir is not supported")}function Rn(){return 0}var mr=globalThis.performance||{},wn=mr.now||mr.mozNow||mr.msNow||mr.oNow||mr.webkitNow||function(){return new Date().getTime()};function Nn(t){var r=wn.call(mr)*.001,e=Math.floor(r),n=Math.floor(r%1*1e9);return t&&(e=e-t[0],n=n-t[1],n<0&&(e--,n+=1e9)),[e,n]}var Sn=new Date;function Bn(){var t=new Date,r=t-Sn;return r/1e3}var f={nextTick:on,title:an,browser:cn,env:un,argv:pn,version:ln,versions:mn,on:gn,addListener:hn,once:xn,off:En,removeListener:bn,removeAllListeners:An,emit:Tn,binding:_n,cwd:yn,chdir:In,umask:Rn,hrtime:Nn,platform:sn,release:dn,config:fn,uptime:Bn},we={};Object.keys(we).forEach(t=>{let r=t.split("."),e=f;for(let n=0;n<r.length;n++){let o=r[n];n===r.length-1?e[o]=we[t]:e=e[o]||(e[o]={})}});var Y=[],P=[],On=typeof Uint8Array<"u"?Uint8Array:Array,qr=!1;function Ue(){qr=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)Y[r]=t[r],P[t.charCodeAt(r)]=r;P[45]=62,P[95]=63}function Cn(t){qr||Ue();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new On(c*3/4-i),n=i>0?c-4:c;var u=0;for(r=0,e=0;r<n;r+=4,e+=3)o=P[t.charCodeAt(r)]<<18|P[t.charCodeAt(r+1)]<<12|P[t.charCodeAt(r+2)]<<6|P[t.charCodeAt(r+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=o&255;return i===2?(o=P[t.charCodeAt(r)]<<2|P[t.charCodeAt(r+1)]>>4,a[u++]=o&255):i===1&&(o=P[t.charCodeAt(r)]<<10|P[t.charCodeAt(r+1)]<<4|P[t.charCodeAt(r+2)]>>2,a[u++]=o>>8&255,a[u++]=o&255),a}function Dn(t){return Y[t>>18&63]+Y[t>>12&63]+Y[t>>6&63]+Y[t&63]}function Pn(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(Dn(n));return o.join("")}function De(t){qr||Ue();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,u=e-n;c<u;c+=a)i.push(Pn(t,c,c+a>u?u:c+a));return n===1?(r=t[e-1],o+=Y[r>>2],o+=Y[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=Y[r>>10],o+=Y[r>>4&63],o+=Y[r<<2&63],o+="="),i.push(o),i.join("")}s.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function wr(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function q(t,r){if(wr()<r)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=s.prototype):(t===null&&(t=new s(r)),t.length=r),t}function s(t,r,e){if(!s.TYPED_ARRAY_SUPPORT&&!(this instanceof s))return new s(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return Jr(this,t)}return Le(this,t,r,e)}s.poolSize=8192;s._augment=function(t){return t.__proto__=s.prototype,t};function Le(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?Ln(t,r,e,n):typeof r=="string"?Un(t,r,e):Mn(t,r)}s.from=function(t,r,e){return Le(null,t,r,e)};s.kMaxLength=wr();s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&s[Symbol.species]);function Me(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function kn(t,r,e,n){return Me(r),r<=0?q(t,r):e!==void 0?typeof n=="string"?q(t,r).fill(e,n):q(t,r).fill(e):q(t,r)}s.alloc=function(t,r,e){return kn(null,t,r,e)};function Jr(t,r){if(Me(r),t=q(t,r<0?0:jr(r)|0),!s.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}s.allocUnsafe=function(t){return Jr(null,t)};s.allocUnsafeSlow=function(t){return Jr(null,t)};function Un(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=ve(r,e)|0;t=q(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function zr(t,r){var e=r.length<0?0:jr(r.length)|0;t=q(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Ln(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),s.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=s.prototype):t=zr(t,r),t}function Mn(t,r){if(G(r)){var e=jr(r.length)|0;return t=q(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||to(r.length)?q(t,0):zr(t,r);if(r.type==="Buffer"&&Array.isArray(r.data))return zr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function jr(t){if(t>=wr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+wr().toString(16)+" bytes");return t|0}s.isBuffer=no;function G(t){return!!(t!=null&&t._isBuffer)}s.compare=function(r,e){if(!G(r)||!G(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return s.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=s.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!G(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function ve(t,r){if(G(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Nr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ve(t).length;default:if(n)return Nr(t).length;r=(""+r).toLowerCase(),n=!0}}s.byteLength=ve;function vn(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return zn(this,r,e);case"utf8":case"utf-8":return Ge(this,r,e);case"ascii":return $n(this,r,e);case"latin1":case"binary":return Xn(this,r,e);case"base64":return Hn(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qn(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function ar(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}s.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)ar(this,e,e+1);return this};s.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)ar(this,e,e+3),ar(this,e+1,e+2);return this};s.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)ar(this,e,e+7),ar(this,e+1,e+6),ar(this,e+2,e+5),ar(this,e+3,e+4);return this};s.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?Ge(this,0,r):vn.apply(this,arguments)};s.prototype.equals=function(r){if(!G(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:s.compare(this,r)===0};s.prototype.compare=function(r,e,n,o,i){if(!G(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,u=Math.min(a,c),p=this.slice(o,i),d=r.slice(e,n),m=0;m<u;++m)if(p[m]!==d[m]){a=p[m],c=d[m];break}return a<c?-1:c<a?1:0};function Fe(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=s.from(r,n)),G(r))return r.length===0?-1:Pe(t,r,e,n,o);if(typeof r=="number")return r=r&255,s.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Pe(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Pe(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function u(x,b){return i===1?x[b]:x.readUInt16BE(b*i)}var p;if(o){var d=-1;for(p=e;p<a;p++)if(u(t,p)===u(r,d===-1?0:p-d)){if(d===-1&&(d=p),p-d+1===c)return d*i}else d!==-1&&(p-=p-d),d=-1}else for(e+c>a&&(e=a-c),p=e;p>=0;p--){for(var m=!0,h=0;h<c;h++)if(u(t,p+h)!==u(r,h)){m=!1;break}if(m)return p}return-1}s.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};s.prototype.indexOf=function(r,e,n){return Fe(this,r,e,n,!0)};s.prototype.lastIndexOf=function(r,e,n){return Fe(this,r,e,n,!1)};function Fn(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function Yn(t,r,e,n){return Or(Nr(r,t.length-e),t,e,n)}function Ye(t,r,e,n){return Or(ro(r),t,e,n)}function Gn(t,r,e,n){return Ye(t,r,e,n)}function Kn(t,r,e,n){return Or(Ve(r),t,e,n)}function Wn(t,r,e,n){return Or(eo(r,t.length-e),t,e,n)}s.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return Fn(this,r,e,n);case"utf8":case"utf-8":return Yn(this,r,e,n);case"ascii":return Ye(this,r,e,n);case"latin1":case"binary":return Gn(this,r,e,n);case"base64":return Kn(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wn(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Hn(t,r,e){return r===0&&e===t.length?De(t):De(t.slice(r,e))}function Ge(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var u,p,d,m;switch(c){case 1:i<128&&(a=i);break;case 2:u=t[o+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(a=m));break;case 3:u=t[o+1],p=t[o+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(a=m));break;case 4:u=t[o+1],p=t[o+2],d=t[o+3],(u&192)===128&&(p&192)===128&&(d&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|d&63,m>65535&&m<1114112&&(a=m))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Vn(n)}var ke=4096;function Vn(t){var r=t.length;if(r<=ke)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=ke));return e}function $n(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function Xn(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function zn(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Zn(t[i]);return o}function qn(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}s.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(s.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=s.prototype;else{var i=e-r;o=new s(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function y(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};s.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};s.prototype.readUInt8=function(r,e){return e||y(r,1,this.length),this[r]};s.prototype.readUInt16LE=function(r,e){return e||y(r,2,this.length),this[r]|this[r+1]<<8};s.prototype.readUInt16BE=function(r,e){return e||y(r,2,this.length),this[r]<<8|this[r+1]};s.prototype.readUInt32LE=function(r,e){return e||y(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};s.prototype.readUInt32BE=function(r,e){return e||y(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};s.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};s.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||y(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};s.prototype.readInt8=function(r,e){return e||y(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};s.prototype.readInt16LE=function(r,e){e||y(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(r,e){e||y(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(r,e){return e||y(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};s.prototype.readInt32BE=function(r,e){return e||y(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};s.prototype.readFloatLE=function(r,e){return e||y(r,4,this.length),Cr(this,r,!0,23,4)};s.prototype.readFloatBE=function(r,e){return e||y(r,4,this.length),Cr(this,r,!1,23,4)};s.prototype.readDoubleLE=function(r,e){return e||y(r,8,this.length),Cr(this,r,!0,52,8)};s.prototype.readDoubleBE=function(r,e){return e||y(r,8,this.length),Cr(this,r,!1,52,8)};function B(t,r,e,n,o,i){if(!G(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}s.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;B(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};s.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;B(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};s.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function Sr(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}s.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Sr(this,r,e,!0),e+2};s.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Sr(this,r,e,!1),e+2};function Br(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}s.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Br(this,r,e,!0),e+4};s.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Br(this,r,e,!1),e+4};s.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);B(this,r,e,n,i-1,-i)}var a=0,c=1,u=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&u===0&&this[e+a-1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};s.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);B(this,r,e,n,i-1,-i)}var a=n-1,c=1,u=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&u===0&&this[e+a+1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};s.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};s.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Sr(this,r,e,!0),e+2};s.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Sr(this,r,e,!1),e+2};s.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Br(this,r,e,!0),e+4};s.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||B(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),s.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Br(this,r,e,!1),e+4};function Ke(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function We(t,r,e,n,o){return o||Ke(t,r,e,4,34028234663852886e22,-34028234663852886e22),Xe(t,r,e,n,23,4),e+4}s.prototype.writeFloatLE=function(r,e,n){return We(this,r,e,!0,n)};s.prototype.writeFloatBE=function(r,e,n){return We(this,r,e,!1,n)};function He(t,r,e,n,o){return o||Ke(t,r,e,8,17976931348623157e292,-17976931348623157e292),Xe(t,r,e,n,52,8),e+8}s.prototype.writeDoubleLE=function(r,e,n){return He(this,r,e,!0,n)};s.prototype.writeDoubleBE=function(r,e,n){return He(this,r,e,!1,n)};s.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};s.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=G(r)?r:Nr(new s(r,o).toString()),u=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%u]}return this};var Jn=/[^+\/0-9A-Za-z-_]/g;function jn(t){if(t=Qn(t).replace(Jn,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Qn(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Zn(t){return t<16?"0"+t.toString(16):t.toString(16)}function Nr(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function ro(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function eo(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function Ve(t){return Cn(jn(t))}function Or(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function to(t){return t!==t}function no(t){return t!=null&&(!!t._isBuffer||$e(t)||oo(t))}function $e(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function oo(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&$e(t.slice(0,0))}function Cr(t,r,e,n,o){var i,a,c=o*8-n-1,u=(1<<c)-1,p=u>>1,d=-7,m=e?o-1:0,h=e?-1:1,x=t[r+m];for(m+=h,i=x&(1<<-d)-1,x>>=-d,d+=c;d>0;i=i*256+t[r+m],m+=h,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[r+m],m+=h,d-=8);if(i===0)i=1-p;else{if(i===u)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(x?-1:1)*a*Math.pow(2,i-n)}function Xe(t,r,e,n,o,i){var a,c,u,p=i*8-o-1,d=(1<<p)-1,m=d>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,b=n?1:-1,_=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=d):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+m>=1?r+=h/u:r+=h*Math.pow(2,1-m),r*u>=2&&(a++,u/=2),a+m>=d?(c=0,a=d):a+m>=1?(c=(r*u-1)*Math.pow(2,o),a=a+m):(c=r*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;t[e+x]=c&255,x+=b,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;t[e+x]=a&255,x+=b,a/=256,p-=8);t[e+x-b]|=_*128}import E from"algosdk";import*as Wr from"bs58";import Qr from"bignumber.js";Qr.config({DECIMAL_PLACES:40,EXPONENTIAL_AT:45});function sr(t,r){return io(t,r,"/")}function io(t,r,e){switch(t=new Qr(String(t)),r=new Qr(String(r)),e.toLowerCase()){case"-":return t.minus(r).toString();case"+":return t.plus(r).toString();case"*":case"x":return t.multipliedBy(r).toString();case"\xF7":case"/":return t.dividedBy(r).toString();case">=":return t.isGreaterThanOrEqualTo(r);case">":return t.isGreaterThan(r);case"<=":return t.isLessThanOrEqualTo(r);case"<":return t.isLessThan(r);case"==":return t.isEqualTo(r);case"mod":return t.modulo(r);default:break}}var ze=t=>{let r=new Date(t),e=r.toLocaleDateString("default",{year:"numeric",month:"numeric",day:"numeric"}),n=r.toLocaleTimeString("en-US",{hour12:!0,hour:"2-digit",minute:"2-digit"});return e+" "+n};import $o from"algosdk";import*as ae from"bs58";import xt from"algosdk";import Bi,{decodeAddress as Oi,encodeAddress as Ci}from"algosdk";var K=[],k=[],ao=typeof Uint8Array<"u"?Uint8Array:Array,re=!1;function Qe(){re=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)K[r]=t[r],k[t.charCodeAt(r)]=r;k[45]=62,k[95]=63}function so(t){re||Qe();var r,e,n,o,i,a,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i=t[c-2]==="="?2:t[c-1]==="="?1:0,a=new ao(c*3/4-i),n=i>0?c-4:c;var u=0;for(r=0,e=0;r<n;r+=4,e+=3)o=k[t.charCodeAt(r)]<<18|k[t.charCodeAt(r+1)]<<12|k[t.charCodeAt(r+2)]<<6|k[t.charCodeAt(r+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=o&255;return i===2?(o=k[t.charCodeAt(r)]<<2|k[t.charCodeAt(r+1)]>>4,a[u++]=o&255):i===1&&(o=k[t.charCodeAt(r)]<<10|k[t.charCodeAt(r+1)]<<4|k[t.charCodeAt(r+2)]>>2,a[u++]=o>>8&255,a[u++]=o&255),a}function co(t){return K[t>>18&63]+K[t>>12&63]+K[t>>6&63]+K[t&63]}function uo(t,r,e){for(var n,o=[],i=r;i<e;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(co(n));return o.join("")}function qe(t){re||Qe();for(var r,e=t.length,n=e%3,o="",i=[],a=16383,c=0,u=e-n;c<u;c+=a)i.push(uo(t,c,c+a>u?u:c+a));return n===1?(r=t[e-1],o+=K[r>>2],o+=K[r<<4&63],o+="=="):n===2&&(r=(t[e-2]<<8)+t[e-1],o+=K[r>>10],o+=K[r>>4&63],o+=K[r<<2&63],o+="="),i.push(o),i.join("")}function kr(t,r,e,n,o){var i,a,c=o*8-n-1,u=(1<<c)-1,p=u>>1,d=-7,m=e?o-1:0,h=e?-1:1,x=t[r+m];for(m+=h,i=x&(1<<-d)-1,x>>=-d,d+=c;d>0;i=i*256+t[r+m],m+=h,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[r+m],m+=h,d-=8);if(i===0)i=1-p;else{if(i===u)return a?NaN:(x?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-p}return(x?-1:1)*a*Math.pow(2,i-n)}function Ze(t,r,e,n,o,i){var a,c,u,p=i*8-o-1,d=(1<<p)-1,m=d>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:i-1,b=n?1:-1,_=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,a=d):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+m>=1?r+=h/u:r+=h*Math.pow(2,1-m),r*u>=2&&(a++,u/=2),a+m>=d?(c=0,a=d):a+m>=1?(c=(r*u-1)*Math.pow(2,o),a=a+m):(c=r*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;t[e+x]=c&255,x+=b,c/=256,o-=8);for(a=a<<o|c,p+=o;p>0;t[e+x]=a&255,x+=b,a/=256,p-=8);t[e+x-b]|=_*128}var po={}.toString,rt=Array.isArray||function(t){return po.call(t)=="[object Array]"};var lo=50;l.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;var Ii=Dr();function Dr(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function J(t,r){if(Dr()<r)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=l.prototype):(t===null&&(t=new l(r)),t.length=r),t}function l(t,r,e){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(t,r,e);if(typeof t=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return ee(this,t)}return et(this,t,r,e)}l.poolSize=8192;l._augment=function(t){return t.__proto__=l.prototype,t};function et(t,r,e,n){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer?go(t,r,e,n):typeof r=="string"?fo(t,r,e):ho(t,r)}l.from=function(t,r,e){return et(null,t,r,e)};l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array);function tt(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function mo(t,r,e,n){return tt(r),r<=0?J(t,r):e!==void 0?typeof n=="string"?J(t,r).fill(e,n):J(t,r).fill(e):J(t,r)}l.alloc=function(t,r,e){return mo(null,t,r,e)};function ee(t,r){if(tt(r),t=J(t,r<0?0:te(r)|0),!l.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}l.allocUnsafe=function(t){return ee(null,t)};l.allocUnsafeSlow=function(t){return ee(null,t)};function fo(t,r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=nt(r,e)|0;t=J(t,n);var o=t.write(r,e);return o!==n&&(t=t.slice(0,o)),t}function Zr(t,r){var e=r.length<0?0:te(r.length)|0;t=J(t,e);for(var n=0;n<e;n+=1)t[n]=r[n]&255;return t}function go(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?r=new Uint8Array(r):n===void 0?r=new Uint8Array(r,e):r=new Uint8Array(r,e,n),l.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=l.prototype):t=Zr(t,r),t}function ho(t,r){if(W(r)){var e=te(r.length)|0;return t=J(t,e),t.length===0||r.copy(t,0,0,e),t}if(r){if(typeof ArrayBuffer<"u"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||Uo(r.length)?J(t,0):Zr(t,r);if(r.type==="Buffer"&&rt(r.data))return Zr(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function te(t){if(t>=Dr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Dr().toString(16)+" bytes");return t|0}l.isBuffer=Lo;function W(t){return!!(t!=null&&t._isBuffer)}l.compare=function(r,e){if(!W(r)||!W(e))throw new TypeError("Arguments must be Buffers");if(r===e)return 0;for(var n=r.length,o=e.length,i=0,a=Math.min(n,o);i<a;++i)if(r[i]!==e[i]){n=r[i],o=e[i];break}return n<o?-1:o<n?1:0};l.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(r,e){if(!rt(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return l.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var o=l.allocUnsafe(e),i=0;for(n=0;n<r.length;++n){var a=r[n];if(!W(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o};function nt(t,r){if(W(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var e=t.length;if(e===0)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Pr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(t).length;default:if(n)return Pr(t).length;r=(""+r).toLowerCase(),n=!0}}l.byteLength=nt;function xo(t,r,e){var n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(t||(t="utf8");;)switch(t){case"hex":return No(this,r,e);case"utf8":case"utf-8":return at(this,r,e);case"ascii":return Ro(this,r,e);case"latin1":case"binary":return wo(this,r,e);case"base64":return yo(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return So(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function cr(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}l.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)cr(this,e,e+1);return this};l.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)cr(this,e,e+3),cr(this,e+1,e+2);return this};l.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)cr(this,e,e+7),cr(this,e+1,e+6),cr(this,e+2,e+5),cr(this,e+3,e+4);return this};l.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?at(this,0,r):xo.apply(this,arguments)};l.prototype.equals=function(r){if(!W(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:l.compare(this,r)===0};l.prototype.inspect=function(){var r="",e=lo;return this.length>0&&(r=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(r+=" ... ")),"<Buffer "+r+">"};l.prototype.compare=function(r,e,n,o,i){if(!W(r))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=r?r.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>r.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===r)return 0;for(var a=i-o,c=n-e,u=Math.min(a,c),p=this.slice(o,i),d=r.slice(e,n),m=0;m<u;++m)if(p[m]!==d[m]){a=p[m],c=d[m];break}return a<c?-1:c<a?1:0};function ot(t,r,e,n,o){if(t.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof r=="string"&&(r=l.from(r,n)),W(r))return r.length===0?-1:Je(t,r,e,n,o);if(typeof r=="number")return r=r&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):Je(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Je(t,r,e,n,o){var i=1,a=t.length,c=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||r.length<2)return-1;i=2,a/=2,c/=2,e/=2}function u(x,b){return i===1?x[b]:x.readUInt16BE(b*i)}var p;if(o){var d=-1;for(p=e;p<a;p++)if(u(t,p)===u(r,d===-1?0:p-d)){if(d===-1&&(d=p),p-d+1===c)return d*i}else d!==-1&&(p-=p-d),d=-1}else for(e+c>a&&(e=a-c),p=e;p>=0;p--){for(var m=!0,h=0;h<c;h++)if(u(t,p+h)!==u(r,h)){m=!1;break}if(m)return p}return-1}l.prototype.includes=function(r,e,n){return this.indexOf(r,e,n)!==-1};l.prototype.indexOf=function(r,e,n){return ot(this,r,e,n,!0)};l.prototype.lastIndexOf=function(r,e,n){return ot(this,r,e,n,!1)};function Eo(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(r.substr(a*2,2),16);if(isNaN(c))return a;t[e+a]=c}return a}function bo(t,r,e,n){return Mr(Pr(r,t.length-e),t,e,n)}function it(t,r,e,n){return Mr(Po(r),t,e,n)}function Ao(t,r,e,n){return it(t,r,e,n)}function To(t,r,e,n){return Mr(pt(r),t,e,n)}function _o(t,r,e,n){return Mr(ko(r,t.length-e),t,e,n)}l.prototype.write=function(r,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-e;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var a=!1;;)switch(o){case"hex":return Eo(this,r,e,n);case"utf8":case"utf-8":return bo(this,r,e,n);case"ascii":return it(this,r,e,n);case"latin1":case"binary":return Ao(this,r,e,n);case"base64":return To(this,r,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _o(this,r,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yo(t,r,e){return r===0&&e===t.length?qe(t):qe(t.slice(r,e))}function at(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=e){var u,p,d,m;switch(c){case 1:i<128&&(a=i);break;case 2:u=t[o+1],(u&192)===128&&(m=(i&31)<<6|u&63,m>127&&(a=m));break;case 3:u=t[o+1],p=t[o+2],(u&192)===128&&(p&192)===128&&(m=(i&15)<<12|(u&63)<<6|p&63,m>2047&&(m<55296||m>57343)&&(a=m));break;case 4:u=t[o+1],p=t[o+2],d=t[o+3],(u&192)===128&&(p&192)===128&&(d&192)===128&&(m=(i&15)<<18|(u&63)<<12|(p&63)<<6|d&63,m>65535&&m<1114112&&(a=m))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Io(n)}var je=4096;function Io(t){var r=t.length;if(r<=je)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=je));return e}function Ro(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]&127);return n}function wo(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function No(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=Do(t[i]);return o}function So(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}l.prototype.slice=function(r,e){var n=this.length;r=~~r,e=e===void 0?n:~~e,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<r&&(e=r);var o;if(l.TYPED_ARRAY_SUPPORT)o=this.subarray(r,e),o.__proto__=l.prototype;else{var i=e-r;o=new l(i,void 0);for(var a=0;a<i;++a)o[a]=this[a+r]}return o};function I(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return o};l.prototype.readUIntBE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r+--e],i=1;e>0&&(i*=256);)o+=this[r+--e]*i;return o};l.prototype.readUInt8=function(r,e){return e||I(r,1,this.length),this[r]};l.prototype.readUInt16LE=function(r,e){return e||I(r,2,this.length),this[r]|this[r+1]<<8};l.prototype.readUInt16BE=function(r,e){return e||I(r,2,this.length),this[r]<<8|this[r+1]};l.prototype.readUInt32LE=function(r,e){return e||I(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};l.prototype.readUInt32BE=function(r,e){return e||I(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};l.prototype.readIntLE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=this[r],i=1,a=0;++a<e&&(i*=256);)o+=this[r+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};l.prototype.readIntBE=function(r,e,n){r=r|0,e=e|0,n||I(r,e,this.length);for(var o=e,i=1,a=this[r+--o];o>0&&(i*=256);)a+=this[r+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a};l.prototype.readInt8=function(r,e){return e||I(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};l.prototype.readInt16LE=function(r,e){e||I(r,2,this.length);var n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(r,e){e||I(r,2,this.length);var n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(r,e){return e||I(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};l.prototype.readInt32BE=function(r,e){return e||I(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};l.prototype.readFloatLE=function(r,e){return e||I(r,4,this.length),kr(this,r,!0,23,4)};l.prototype.readFloatBE=function(r,e){return e||I(r,4,this.length),kr(this,r,!1,23,4)};l.prototype.readDoubleLE=function(r,e){return e||I(r,8,this.length),kr(this,r,!0,52,8)};l.prototype.readDoubleBE=function(r,e){return e||I(r,8,this.length),kr(this,r,!1,52,8)};function O(t,r,e,n,o,i){if(!W(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;O(this,r,e,n,i,0)}var a=1,c=0;for(this[e]=r&255;++c<n&&(a*=256);)this[e+c]=r/a&255;return e+n};l.prototype.writeUIntBE=function(r,e,n,o){if(r=+r,e=e|0,n=n|0,!o){var i=Math.pow(2,8*n)-1;O(this,r,e,n,i,0)}var a=n-1,c=1;for(this[e+a]=r&255;--a>=0&&(c*=256);)this[e+a]=r/c&255;return e+n};l.prototype.writeUInt8=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,1,255,0),l.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[e]=r&255,e+1};function Ur(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>(n?o:1-o)*8}l.prototype.writeUInt16LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Ur(this,r,e,!0),e+2};l.prototype.writeUInt16BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Ur(this,r,e,!1),e+2};function Lr(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>(n?o:3-o)*8&255}l.prototype.writeUInt32LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255):Lr(this,r,e,!0),e+4};l.prototype.writeUInt32BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Lr(this,r,e,!1),e+4};l.prototype.writeIntLE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);O(this,r,e,n,i-1,-i)}var a=0,c=1,u=0;for(this[e]=r&255;++a<n&&(c*=256);)r<0&&u===0&&this[e+a-1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};l.prototype.writeIntBE=function(r,e,n,o){if(r=+r,e=e|0,!o){var i=Math.pow(2,8*n-1);O(this,r,e,n,i-1,-i)}var a=n-1,c=1,u=0;for(this[e+a]=r&255;--a>=0&&(c*=256);)r<0&&u===0&&this[e+a+1]!==0&&(u=1),this[e+a]=(r/c>>0)-u&255;return e+n};l.prototype.writeInt8=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,1,127,-128),l.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[e]=r&255,e+1};l.prototype.writeInt16LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8):Ur(this,r,e,!0),e+2};l.prototype.writeInt16BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>8,this[e+1]=r&255):Ur(this,r,e,!1),e+2};l.prototype.writeInt32LE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24):Lr(this,r,e,!0),e+4};l.prototype.writeInt32BE=function(r,e,n){return r=+r,e=e|0,n||O(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),l.TYPED_ARRAY_SUPPORT?(this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255):Lr(this,r,e,!1),e+4};function st(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ct(t,r,e,n,o){return o||st(t,r,e,4),Ze(t,r,e,n,23,4),e+4}l.prototype.writeFloatLE=function(r,e,n){return ct(this,r,e,!0,n)};l.prototype.writeFloatBE=function(r,e,n){return ct(this,r,e,!1,n)};function ut(t,r,e,n,o){return o||st(t,r,e,8),Ze(t,r,e,n,52,8),e+8}l.prototype.writeDoubleLE=function(r,e,n){return ut(this,r,e,!0,n)};l.prototype.writeDoubleBE=function(r,e,n){return ut(this,r,e,!1,n)};l.prototype.copy=function(r,e,n,o){if(n||(n=0),!o&&o!==0&&(o=this.length),e>=r.length&&(e=r.length),e||(e=0),o>0&&o<n&&(o=n),o===n||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),r.length-e<o-n&&(o=r.length-e+n);var i=o-n,a;if(this===r&&n<e&&e<o)for(a=i-1;a>=0;--a)r[a+e]=this[a+n];else if(i<1e3||!l.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,n+i),e);return i};l.prototype.fill=function(r,e,n,o){if(typeof r=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),r.length===1){var i=r.charCodeAt(0);i<256&&(r=i)}if(o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!l.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else typeof r=="number"&&(r=r&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<n;++a)this[a]=r;else{var c=W(r)?r:Pr(new l(r,o).toString()),u=c.length;for(a=0;a<n-e;++a)this[a+e]=c[a%u]}return this};var Bo=/[^+\/0-9A-Za-z-_]/g;function Oo(t){if(t=Co(t).replace(Bo,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Co(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Do(t){return t<16?"0"+t.toString(16):t.toString(16)}function Pr(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],a=0;a<n;++a){if(e=t.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function Po(t){for(var r=[],e=0;e<t.length;++e)r.push(t.charCodeAt(e)&255);return r}function ko(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function pt(t){return so(Oo(t))}function Mr(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function Uo(t){return t!==t}function Lo(t){return t!=null&&(!!t._isBuffer||lt(t)||Mo(t))}function lt(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Mo(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&lt(t.slice(0,0))}import{encodeAddress as ft,decodeAddress as Mi}from"algosdk";function A(t){return t.reduce((r,e)=>Uint8Array.from([...r,...e]))}function Z(t){return new Uint8Array(l.from(t))}function mt(t){return l.from(t).toString("utf-8")}function dt(t){let r=l.alloc(8);for(let e=0;e<8;e++)r[7-e]=Number(BigInt(t)>>BigInt(e*8)&BigInt(255));return new Uint8Array(r)}function vr(t){return l.from(t).toString("base64")}function fr(t){return l.from(t,"base64")}var ra=`{"theme1":{"value":"${f.env.FRONTEND_URL}/Theme%3DDark.svg","active":true},"theme2":{"value":"${f.env.FRONTEND_URL}/Theme%3DLight.svg","active":true},"theme3":{"value":"${f.env.FRONTEND_URL}/Theme%3DLight.svg","active":true}}`;var gt={V1_1:"v1_1",V2:"v2"},oa={[gt.V1_1]:{testnet:62368684,mainnet:552635992},[gt.V2]:{testnet:148607e3,mainnet:1002541853}};function ht(t){return Object.keys(t).sort().reduce((r,e)=>({...r,[e]:t[e]}),{})}function Fo(t){let r={};return t.forEach(e=>{let n=fr(e.key).toString(),o=e.value,i=o.type;i==2&&(o=o.uint),i==1&&(o=fr(o.bytes)),n=="gov"?r.gov=ft(o):r[n]=o}),ht(r)}var Et=t=>{let r={0:t.amount},e=t.assets;for(let n=0;n<e.length;n++){let o=e[n]["asset-id"],i=e[n].amount;r[o]=i}return console.log(`Account ${t.address} balances`,JSON.stringify(r)),r},bt=async(t,r)=>{let e=await t.getApplicationByID(r).do();return Fo(e.params["global-state"])};var H=async(t,r,e)=>{try{let{value:n}=await t.getApplicationBoxByName(r,e).do();return n}catch(n){if(n.message.includes("box not found"))return console.log(`Box not found '${s.from(e).toString("hex")}'`),null;throw n}},V=async(t,r=1)=>{let e=await t.getTransactionParams().do();return r>1&&(e.fee=xt.ALGORAND_MIN_TX_FEE*r,e.flatFee=!0),{...e}},At=(t,r)=>Object.keys(t).includes(r.toString()),Tt=t=>xt.decodeAddress(t.toUpperCase()).publicKey;import*as T from"ethereumjs-util";function U(t){let r=T.fromSigned(s.from(t));return BigInt(r.toString())}function Go(t){return T.toUnsigned(new T.BN(String(t)))}function ne(t){let r=Go(t);if(r.length>32)throw new Error("Invalid value. The buffer length of the value is more than 32");return new Uint8Array(T.setLengthLeft(r,32))}var oe=t=>{if(t.length!==32)throw new Error("Invalid address bytes. The address buffer length is not equel 32");let r=s.from(t).toString("hex");if(r.slice(0,24)!=="000000000000000000000000")throw console.log("normalizedAddress",r),new Error("Invalid normalized address");let e="0x"+r.slice(-40);if(!Wo(e))throw new Error("Invalid hex address");return e},_t=t=>new Uint8Array(T.setLengthLeft(Er(t),32)),Er=t=>s.from(Ko(t),"hex"),Ko=t=>t.startsWith("0x")?t.slice(2):t,Wo=t=>T.isValidAddress(t),yt=(t,r)=>{let e=T.keccak256(t),{r:n,s:o,v:i}=T.fromRpcSig(r);return T.ecrecover(e,i,n,o)};var C=t=>new Uint8Array(T.keccak256(s.from(t)));var Rt=(o=>(o.GLOBAL_PAIR_DELISTING="GLOBAL_PAIR_DELISTING",o.GLOBAL_NEW_PAIR_LISTING="GLOBAL_NEW_PAIR_LISTING",o.GLOBAL_SYSTEM_MAINTENANCE="GLOBAL_SYSTEM_MAINTENANCE",o.GLOBAL_SMART_CONTRACT_UPDATE="GLOBAL_SMART_CONTRACT_UPDATE",o))(Rt||{}),wt=(n=>(n.ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT="ACCOUNT_POINTS_UNLOCK_ACHIEVEMENT",n.ACCOUNT_KYC_STATUS_CHANGED="ACCOUNT_KYC_STATUS_CHANGED",n.ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED="ACCOUNT_AFFILIATE_DASHBOARD_UNLOCKED",n))(wt||{}),Zs={...Rt,...wt};var se=(t,r)=>A([g(r,"str"),C(t)]),ce=(t,r)=>A([g(r,"str"),s.from(t,"hex")]),N=(t,r)=>{let e=$o.ABIMethod.fromSignature(t),n=e.getSelector(),o={},i=r.map((a,c)=>{let u=e.args[c].type.encode(a);return o[`txnArgs${c}`]=Array.apply([],Array.from(u)).join(", "),u});return[n,...i]},br=(t,r,e)=>{let n=s.from(t,r),o=n.subarray(n.length-e),i=s.from(o).toString();return fr(i)},ur=(t,r,e,n,o="hex")=>[ie(t,o,n),Xo(r,n),zo(e,n,t,r,o)],Xo=(t,r)=>r===8?fr(t):r===1?ae.decode(t):Er(t),zo=(t,r,e,n,o)=>r===8||r===1?$(t,r):yt(ie(e,o,r),n),qo=(t,r)=>r===8?"MX":r===1?"":`Ethereum Signed Message:
2
+ ${t.length}`,ie=(t,r,e)=>{let n=s.from(t,r);return s.concat([Z(qo(n,e)),n])};var $=(t,r)=>r===8?Tt(t):r===1?ae.decode(t):_t(t);import du from"algosdk";import _u from"algosdk";import Sp from"algosdk";var Ar={"0x4343545055534443000000000000000000000000000000000000000000000000":65537};var vu={SMALLESTUNIT:f.env.SMALLEST_UNIT},Fu={SMALLEST_UNITS:f.env.SMALLEST_UNIT};var Hu=["point-system.discordEnabled","point-system.telegramBotName","point-system.telegramBotId","point-system.telegramEnabled","point-system.telegramGroupId","point-system.telegramGroupName","point-system.twitterAccountId","point-system.twitterAccountName","point-system.twitterEnabled","point-system.twitterJobEnabled","point-system.guideLink"];var ju=f.env.REACT_APP_API_URL,Qu=f.env.REACT_APP_SOCKET_URL,Zu=f.env.REACT_APP_ALGO_SERVER,rp=f.env.REACT_APP_ALGO_SERVER_PORT||"",ep=f.env.REACT_APP_ALGOD_TOKEN||"",tp=f.env.REACT_APP_DISPENSER_LINK,np=f.env.REACT_APP_FRONTEND_LINK||"",op=f.env.REACT_APP_ALGO_EXPLORER_LINK,ip=f.env.REACT_APP_ALGO_EXPLORER_ASSETS_URL,ap=(f.env.REACT_APP_REQUIRE_ACCESS_CODE||"").toLowerCase()==="true",sp=f.env.REACT_APP_USERBACK_ACCESS_TOKEN,cp=(f.env.REACT_APP_EXT_ORDER_TYPES||"").toLowerCase()==="true";var up=.001*10**6,pp=.002*10**6;var lp=f.env.REACT_APP_MASTER_APP_ID||"406",mp=f.env.REACT_APP_AGG_APP_ID||"408",Jo=Number(f.env.REACT_APP_CODEX_APP_ID||"467960617");console.log("CODEX_APP_ID",Jo);var jo=f.env.REACT_APP_ALGO_NETWORK||"";var dp=jo.toLowerCase()==="mainnet"?"mainnet":"testnet";var pe=(t,r="hex")=>br(t,r,328),Fr=(t,r)=>se(pe(t,r),"O_"),St=t=>ce(t,"O_");import vp from"algosdk";import me from"algosdk";var Yr=(t,r,e,n,o,i)=>{let a=N("dummy(uint64)void",[1]);return me.makeApplicationNoOpTxnFromObject({from:r,suggestedParams:{...e,fee:me.ALGORAND_MIN_TX_FEE,flatFee:!0},appArgs:a,appIndex:t,boxes:n,foreignApps:i,note:new Uint8Array(s.from(o))})},Bt=(t,r)=>{let{accounts:n,foreignAssets:o,foreignApps:i,boxes:a,appIndex:c,from:u,suggestedParams:p}=r;console.log("Total resources",[n,i,o,a]);let d=[n,i,o,a].reduce((R,M)=>R+(M?.length||0),0),m=a?.slice(0,8-d)||[],h=a?.slice(8-d)||[],x=8-(i?.length||0),b=me.makeApplicationNoOpTxnFromObject({...r,boxes:m}),_=1,S=[],w=[];for(let R=0;R<h.length;R++){let M=h[R];S.push(M),(S.length===x||R===h.length-1)&&(w.push(Yr(c,u,p,S,`${t}_${_}`,i)),S=[],_++)}return w.push(Yr(c,u,p,[],`${t}_${++_}`,i)),console.log("dummy count",w.length),[b,...w]};function de(t){switch(t){case"B":return"BUY";case"S":return"SELL";default:throw new Error("Unknown order side short type: "+t)}}function fe(t){switch(t){case"I":return"IOC";case"P":return"POST";case"M":return"Market";case"L":default:return"Limit"}}var Rl=(t,r,e="address")=>({address:(e==="token"?ei:kt)(t,Number(r)),chainId:Number(r)}),kt=(t,r)=>{let e=s.from(t.startsWith("0x")?t.substring(2):t,"hex");return r===8?E.encodeAddress(e):r===1?Wr.encode(e):oe(e)};function ei(t,r){return Number(r)===8?String(Number(t)):Ar["0x"+t]?"0x"+t:kt(t,Number(r))}var g=(t,r,e)=>{switch(r){case"8B":return E.encodeUint64(Number(t));case"32B":return ne(t);case"str":return Z(String(t));case"address":return $(String(t),e);case"token":return Ae(String(t),e);case"float":{var n=s.alloc(8);return n.writeDoubleBE(Number(t),0),new Uint8Array(n)}case"bool":return new Uint8Array(s.from(E.encodeUint64(Number(t))).subarray(-1));case"2B":return new Uint8Array(s.from(E.encodeUint64(Number(t))).subarray(-2));case"4B":return new Uint8Array(s.from(E.encodeUint64(Number(t))).subarray(-4));default:return s.from(t.toString())}},D=(t,r,e)=>{switch(r){case"8B":return E.decodeUint64(t,"safe");case"32B":return U(t);case"str":return mt(t);case"address":return lr(t,e);case"token":return Ut(t,e);case"float":return s.from(t).readDoubleBE(0);case"bool":case"2B":return D(t,"8B");default:return s.from(t).toString()}},xe=(t,r,e)=>lr(t.subarray(r,r+32),e),Ot=(t,r,e)=>Ut(t.subarray(r,r+32),e),ti=(t,r=0)=>Number(D(t.subarray(r,r+8),"float")),Ct=(t,r,e)=>String(D(t.subarray(r,r+e),"str")),ge=(t,r=0)=>Number(D(t.subarray(r,r+2),"8B")),he=(t,r=0)=>Number(D(t.subarray(r,r+4),"8B")),Ee=(t,r=0)=>Number(D(t.subarray(r,r+8),"8B")),Dt=(t,r=0)=>String(D(t.subarray(r,r+32),"32B")),lr=(t,r)=>r===8?E.encodeAddress(t):r===1?Wr.encode(t):oe(t),Ut=(t,r)=>{let e=s.from(t).toString("hex");return e.startsWith("0x")||(e="0x"+e),Ar[e]?e:r===8?String(U(t)):r===1?Wr.encode(t):lr(t,r)},wl=(t,r,e=!1)=>{let n=s.from($(t,r)).toString("hex");return e&&!n.startsWith("0x")?`0x${n}`:n},Nl=t=>t.startsWith("0x")?s.from(t.substring(2),"hex").length===32:s.from(t,"hex").length===32,Ae=(t,r)=>r===8?ne(+t):Ar[t]?new Uint8Array(Er(String(t))):$(String(t),r),Sl=async(t,r)=>{let e=await bt(t,r),n=e.MSG_PROCESSOR,o=e.UL_SUPERADMIN_APP,i=e.UL_SUPERADMIN_WALLET;i=i?.length?i:void 0;let a=i&&Number(D(i.subarray(32,40),"8B")),c={collectionWallet:i&&lr(i.subarray(0,32),a),collectionWalletChainId:a,msgProcId:n,superAppId:o};return console.log("CodexState parsed",c),c},Bl=async(t,r)=>{let e=E.getApplicationAddress(r);console.log("appAddress",e);let n=await t.accountInformation(e).do();console.log("CODEX AccountInfo",n)},Ol=(t,r)=>{let e=L(t.address,t.chainId,r.address,r.chainId);return s.from(C(e)).toString("hex")},L=(t,r,e,n)=>{let o=$(t,r),i=E.encodeUint64(r),a=E.encodeUint64(n),c=Ae(e,n);return A([o,i,c,a])},Te=(t,r)=>{let e=A([Ae(t,r),E.encodeUint64(r)]);return C(e)},Cl=async(t,r,e,n)=>{let o=Te(e,n),i=await _e(t,r,o);return console.log("Box CCTP balance",e.substring(0,18),n,i),i},Dl=async(t,r,e,n=[1,6,10002,10003,10004,10005])=>{let o=await Promise.all(n.map(c=>_e(t,r,Te(e,c)))),i=(c,u=6)=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:u}).format(+sr(c,10**u)),a={};for(let c=0;c<n.length;c++){let u=n[c];a[u]=i(o[c])}return console.log("Box CCTP balance",a),a},Pl=t=>A([g("Rebalance_","str"),E.encodeUint64(t)]),be=t=>{let r=A([g("TokenManager","str"),E.encodeUint64(t)]);return C(r)},kl=async(t,r,e)=>{let n=be(e),o=await H(t,r,n);if(!o)return;let i=lr(o,e);return console.log("Box TokenManager of chain",e,i),i},gr=(t,r)=>{let e=$(t,r),n=Z("TK_");return A([n,e])},Ul=async(t,r,e,n)=>{let o=C(gr(e,n)),i=await H(t,r,o);if(!i)return;let a=[];for(let c=0;c+32<=i.length;c+=32){let u=lr(i.subarray(c,c+32),8);a.push(u)}return console.log("Box account trading keys",e.substring(0,8),a,s.from(o).toString("hex")),a},Ll=async(t,r)=>{let e=E.getApplicationAddress(r);return await ni(t,e)},ni=async(t,r)=>{let e=await t.accountInformation(r).do();return Et(e)},Ml=async(t,r)=>{let{boxes:e}=await t.getApplicationBoxes(r).do();console.log(`boxes of ${r}`,e.map(n=>n.name))},vl=async(t,r,e,n)=>oi(t,r,e.address,e.chainId,n.address,n.chainId),oi=async(t,r,e,n,o,i)=>{let a=C(L(e,n,o,i)),c=await _e(t,r,a);return console.log("Box account value",e.substring(0,8),o,c,s.from(a).toString("hex")),String(c)},Fl=async(t,r,e)=>{let n=s.from(e,"hex"),o=await H(t,r,n),i=0n;return o&&(i=U(o)),console.log("Box account value",JSON.stringify({hash:e.substring(0,8),boxValue:String(i),box:`[${o?.toString()}]`})),i},_e=async(t,r,e)=>{let n=await H(t,r,e),o=0n;return n&&(o=U(n)),o},Tr=t=>g(t,"8B"),Yl=async(t,r,e)=>{let n=Tr(e),o=await H(t,r,n);if(!o)return;let i=Number(D(o.subarray(32,40),"8B")),a={collectionWallet:lr(o.subarray(0,32),i),collectionWalletChainId:i,takerFee:Number(D(o.subarray(40,48),"8B")),makerFee:o.length>48?Number(D(o.subarray(48,56),"8B")):0};return console.log(`Box company #${e} value`,a),a},Gl=async(t,r,e,n)=>{let o=C(ye(e,n)),i=await H(t,r,o);if(!i)return;let a={minSize:U(i.subarray(0,32)),minPriceIncrement:U(i.subarray(32,64)),minSizeIncrement:U(i.subarray(64,96))};return console.log("Box pair value",i,a),a},Kl=async(t,r,e,n=!0)=>{let o=e.boxName||e.hash&&St(e.hash)||Fr(e.message,"hex"),i=await H(t,r,o);if(!i)return;let a={hash:s.from(o).toString("hex"),amount:U(i.subarray(0,32)),price:U(i.subarray(32,64)),expiredTime:U(i.subarray(64,72)),expiredDate:new Date(Number(U(i.subarray(64,72)))*1e3)};return n&&console.log("Box order value",JSON.stringify({expiredDate:a.expiredDate,expiredTime:String(a.expiredTime),hash:a.hash,price:String(a.price),amount:String(a.amount)})),a},Wl=async(t,r,e)=>{let n=C(er(e)),o=await H(t,r,n);if(!o)return;let i={decimal:Number(D(o.subarray(2,10),"8B")),name:String(D(o.subarray(12,o.length),"str"))};return console.log("Box token value",o,i),i},ii=(t,r,e,n,o,i)=>{if(i.chainId!==8)return;let a=Number(i.address);if(a===0||At(o,a))return;console.log("Make optin to codex for",a);let u=E.ABIMethod.fromSignature("asset_opt_in(asset)void").getSelector(),p={...n,fee:E.ALGORAND_MIN_TX_FEE*2,flatFee:!0};return E.makeApplicationNoOpTxnFromObject({appIndex:t,from:e,suggestedParams:p,appArgs:[u,dt(a)],foreignApps:[r],foreignAssets:[a]})},Hl=async(t,r,e,n,o,i,a,c)=>{console.log("makeDeposit args",{sender:e,loginAddress:n,loginChainId:o,tokenAmount:i,tokenIndex:a,appId:t});let u=[],p=await V(r,1),d=E.getApplicationAddress(t),m={suggestedParams:p,from:e,to:d,amount:i};u.push(a===0?E.makePaymentTxnWithSuggestedParamsFromObject(m):E.makeAssetTransferTxnWithSuggestedParamsFromObject({...m,assetIndex:a}));let h=E.ABIMethod.fromSignature("depositToCodex(byte[])uint64"),x=h.getSelector(),b=ai({loginAddress:n,loginChainId:o}),_=h.args[0].type.encode(b),S=C(L(n,o,a,c));return u.push(E.makeApplicationNoOpTxnFromObject({appIndex:t,from:e,suggestedParams:p,appArgs:[x,_],boxes:[{appIndex:t,name:S}]})),u},Lt=(t,r)=>{let e=$(t,r),n=E.encodeUint64(r),o=A([e,n]);return console.log("messageBytes",o,JSON.stringify(o),vr(o)),o},ai=({loginAddress:t,loginChainId:r})=>Lt(t,r),si=({loginAddress:t,loginChainId:r})=>Lt(t,r),Vl=t=>{try{let r=s.concat([s.from(g(t.version,"2B")),s.from(g(t.expiredTime,"4B")),s.from(g(t.orderSide,"str")),s.from(g(t.price,"32B")),s.from(g(t.amount,"32B")),s.from(g(t.orderType,"str")),s.from(g(t.address,"address",t.chainId)),s.from(g(t.chainId,"2B")),s.from(g(t.baseTokenAddress,"token",t.baseTokenChainId)),s.from(g(t.baseTokenChainId,"4B")),s.from(g(t.priceTokenAddress,"token",t.priceTokenChainId)),s.from(g(t.priceTokenChainId,"4B")),s.from(g(t.companyId,"2B")),s.from(g(t.random,"8B")),s.from(g(t.decimalPrice,"float")),s.alloc(50)]),e=new Uint8Array(s.from(vr(r))),n=new Uint8Array([...ci(t),...e]);return console.log(`Order data should be ${328} bytes`,e.length,e),n}catch(r){console.error(r)}},ci=t=>{let{amount:r,price:e,baseTokenAddress:n,baseChain:o,baseCurrency:i,baseDecimal:a,priceTokenAddress:c,priceChain:u,priceCurrency:p,priceDecimal:d}=t,m=i?.toUpperCase(),h=p?.toUpperCase(),x=sr(r,10**a),b=sr(e,10**d),_=de(t.orderSide),S=fe(t.orderType),w=(nr,v)=>`${nr}`+(v&&` (${v})`),R=t.orderType==="M"?`ESTIMATED TOTAL ${b} ${h}`:`LIMIT PRICE ${b} ${h} per ${m}`,tr=[`NEW ${S.toUpperCase()} ORDER ${w(m,o)} / ${w(h,u)}:`,`${_} ${x} ${m}, ${R}`,`${m} ID: ${n}`,`${h} ID: ${c}`,`Exp: ${30} Days`].join(`
3
3
  `)+`
4
- `;return new Uint8Array(s.from(tr,"utf-8"))},Wl=t=>{let{orderId:r,amount:e,price:n,baseTokenAddress:o,baseChain:i,baseCurrency:a,baseDecimal:c,priceTokenAddress:u,priceChain:p,priceCurrency:d,priceDecimal:m}=t,h=a?.toUpperCase(),x=d?.toUpperCase(),b=(v,F)=>`${v}`+(F&&` (${F})`),_=sr(e,10**c),S=sr(n,10**m),w=de(t.orderSide),R=fe(t.orderType),M=t.orderType==="M"?`ESTIMATED TOTAL ${S} ${x}`:`LIMIT PRICE ${S} ${x} per ${h}`,nr=[`CANCEL ${R.toUpperCase()} ORDER ${b(h,i)} / ${b(x,p)}:`,`${w} ${_} ${h}, ${M}`,`Order ID: ${r}`,`${h} ID: ${o}`,`${x} ID: ${u}`].join(`
4
+ `;return new Uint8Array(s.from(tr,"utf-8"))},$l=t=>{let{orderId:r,amount:e,price:n,baseTokenAddress:o,baseChain:i,baseCurrency:a,baseDecimal:c,priceTokenAddress:u,priceChain:p,priceCurrency:d,priceDecimal:m}=t,h=a?.toUpperCase(),x=d?.toUpperCase(),b=(v,F)=>`${v}`+(F&&` (${F})`),_=sr(e,10**c),S=sr(n,10**m),w=de(t.orderSide),R=fe(t.orderType),M=t.orderType==="M"?`ESTIMATED TOTAL ${S} ${x}`:`LIMIT PRICE ${S} ${x} per ${h}`,nr=[`CANCEL ${R.toUpperCase()} ORDER ${b(h,i)} / ${b(x,p)}:`,`${w} ${_} ${h}, ${M}`,`Order ID: ${r}`,`${h} ID: ${o}`,`${x} ID: ${u}`].join(`
5
5
  `)+`
6
- `;return new Uint8Array(s.from(nr,"utf-8"))},Hl=(t,r="hex")=>{let e=pe(t,r),n=ge(e,104),o=he(e,138),i=he(e,174),a={version:ge(e),expiredTime:he(e,2),orderSide:Ct(e,6,1),price:Dt(e,7),amount:Dt(e,39),orderType:Ct(e,71,1),address:xe(e,72,n),chainId:n,baseTokenAddress:Bt(e,106,o),baseTokenChainId:o,priceTokenAddress:Bt(e,142,i),priceTokenChainId:i,companyId:ge(e,178),random:Ee(e,180),decimalPrice:ti(e,188)};return{...a,expiredDate:String(a.expiredTime).length>10?new Date(a.expiredTime):new Date(a.expiredTime*1e3)}},Pt=t=>{let{id:r,address:e,chain:n,message:o,encoding:i,signature:a,tradingKey:c}=t,u=c||e,p=c?8:n;return[...ur(o,a,u,p,i),r]},ye=(t,r)=>A([er(t),er(r)]),er=({address:t,chainId:r})=>A([g(t,"token",r),g(r,"8B")]),pr=(t,r,e=C)=>r.map(o=>({appIndex:t,name:e(o)})),Gr=t=>t?A([g(t.address,"address",t.chainId),g(t.chainId,"2B"),g(t.feeShare,"2B")]):s.alloc(36),rr=(t,r)=>{let e;return t?.address&&t?.chainId&&(e=L(t.address,t.chainId,r.address,r.chainId)),e},Kr=(t,r)=>{let e;return t.collectionWallet&&t.collectionWalletChainId&&(e=L(t.collectionWallet,t.collectionWalletChainId,r.address,r.chainId)),e},Vl=(t,r,e,n,o="hex")=>{let{id:i,amount:a,buy:c,sell:u,baseAsset:p,priceAsset:d,superCompany:m,superAppId:h,fee:x}=r,{b_share:b,s_share:_,tfee_tier:S,mfee_tier:w,mmfee_tier:R,mm_tfee:M,p_mfee:tr,p_tfee:nr,bdMaker:v,bdTaker:F,afMaker:hr,afTaker:xr}=x;if(!m)throw new Error("Collection wallet for super user was not provided");let Hr=A([g(b,"2B"),g(_,"2B"),g(w,"str"),g(S,"str"),g(R,"str"),g(M,"2B"),g(nr,"2B"),g(tr,"2B")]),_r=A([Gr(v),Gr(hr),Gr(F),Gr(xr)]),yr=[...Pt({...c,encoding:o}),...Pt({...u,encoding:o}),g(a,"32B"),Hr,g(i,"8B"),_r],Ir=N("match(byte[],byte[],byte[],uint64,byte[],byte[],byte[],uint64,byte[],byte[],byte[],byte[])uint64",yr),Ft=ye(p,d),Yt=Fr(c.message,o),Gt=Fr(u.message,o),Kt=er(p),Wt=er(d),Ht=L(c.address,c.chain,p.address,p.chainId),Vt=L(c.address,c.chain,d.address,d.chainId),$t=L(u.address,u.chain,p.address,p.chainId),Xt=L(u.address,u.chain,d.address,d.chainId),zt=Tr(c.companyId),qt=Tr(u.companyId),Jt=[...new Set([Ft,Kt,Wt,Ht,Vt,gr(c.address,c.chain),gr(u.address,u.chain),$t,Xt,Kr(m,p),Kr(m,d),Kr(c,p),Kr(u,d),rr(v,p),rr(v,d),rr(F,p),rr(F,d),rr(hr,p),rr(hr,d),rr(xr,p),rr(xr,d)].filter(Boolean).map(X=>s.from(X).toString("hex")))].map(X=>s.from(X,"hex")),Vr=[...pr(t,Jt),...pr(t,[Yt,Gt,zt,qt],X=>X)],jt=[...new Set(Vr.map(X=>s.from(X.name).toString("hex")))];console.log(`[TradeID: ${i}] All boxes`,JSON.stringify(jt));let $r=[h],Xr=8,Qt=Vr.slice(0,Xr-$r.length),Ie=Vr.slice(Xr-$r.length),Zt=E.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:e,appIndex:t,appArgs:Ir,boxes:Qt,foreignApps:$r,note:E.encodeUint64(i)}),rn={...e,fee:0,flatFee:!0},Re=[Zt],en=1;for(;Ie.length>0;){let X=Ie.splice(0,Xr);Re.push(Yr(t,n,rn,X,`${i}_${en++}`))}return Re},$l=(t,r)=>{let{address:e,technology:n}=t;return Mt(r||JSON.stringify({address:e,technology:n}))},Xl=({tkAddress:t,loginAddress:r,loginChainId:e,expiredDate:n,type:o},i=!0)=>{let a=`${i?"Add":"Revoke"} ${o} key: ${t}`,c=n?`Expires On: ${ze(n)}`:"No Expiration",u=a+(i?`
7
- `+c:""),p=A([g(t,"address",8),g(r,"address",e),g(e,"8B"),g(n||0,"8B")]);return pi(u,p)},ui=108,zl=(t,r="hex")=>{let e=br(t,r,ui),n=Ee(e,64),o={tkAddress:xe(e,0,8),address:xe(e,32,n),chainId:n,expiredTime:Ee(e,72)};return{...o,expiredDate:new Date(o.expiredTime)}},ql=async(t,r,e,n,{loginAddress:o,loginChainId:i},a,c)=>{let u=ur(a,c,o,i),p=N("manageTradingKey(byte[],byte[],byte[],byte[])uint64",[g("add","str"),...u]),d=gr(o,i),m=await V(t,5);return E.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:m,appIndex:r,appArgs:p,boxes:pr(r,[d]),foreignApps:[e]})},Jl=async(t,r,e,n,{loginAddress:o,loginChainId:i},a,c)=>{let u=ur(a,c,o,i),p=N("manageTradingKey(byte[],byte[],byte[],byte[])uint64",[g("delete","str"),...u]),d=gr(o,i);return E.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:await V(t,5),appIndex:r,appArgs:p,boxes:pr(r,[d]),foreignApps:[e]})},jl=t=>{let{loginAddress:r,loginChainId:e,companyId:n}=t,o=E.encodeUint64(n),i=$(r,e),a=E.encodeUint64(e),c=A([i,a,o]),u=new Uint8Array([...le(c)]);return console.log("MESSAGE LENGTH: ",u),u},pi=(t,r)=>A([Mt(t),le(r)]),Mt=t=>new Uint8Array(s.from(t+`
8
- `,"utf-8")),le=t=>new Uint8Array(s.from(vr(t))),Ql=async(t,{loginAddress:r,loginChainId:e,tokenIndex:n,recipient:o,recipientChainId:i},a,c,u,p)=>{let d=ur(a,c,r,e),m=N("withdraw(byte[],byte[],byte[])uint64",d),h=i===8,x=await V(t,h?6:2);x.fee=x.fee+E.ALGORAND_MIN_TX_FEE*5;let{appId:b,coreId:_,lsaAddress:S,msgProcessorId:w,unifiedChainId:R,cctpSupportedChains:M,superWallet:tr}=p,nr=C(L(r,e,n,R||i)),v=C(L(tr.address,tr.chainId,n,R||i)),F=[{appIndex:b,name:nr},{appIndex:b,name:v}];!h&&!R&&F.push({appIndex:w,name:be(i)}),R&&F.push(...M.map(Ir=>[{appIndex:w,name:Te(String(n),Ir)},{appIndex:w,name:be(Ir)}]).flat());let hr=h&&n!=0?[+n]:void 0,xr=h?[_]:[_,w],Hr=E.getApplicationAddress(_),_r=[S,Hr];h&&_r.push(o);let yr=Ot("withdraw",{appIndex:b,from:u,suggestedParams:x,appArgs:m,accounts:_r,foreignAssets:hr,foreignApps:xr,boxes:F,note:E.encodeUint64(Date.now())});return console.log("withdraw txns",yr),yr},Zl=async(t,r,{message:e,signature:n,signerAddress:o,signerChainId:i},a,c,u)=>{let p=ur(e,n,o,i),d=N("setCollectionWallet(byte[],byte[],byte[])void",p),m=await V(t,4),h=Tr(u),x=[c],b=E.makeApplicationNoOpTxnFromObject({appIndex:a,from:r,suggestedParams:m,appArgs:d,foreignApps:x,boxes:[{appIndex:a,name:h}]});return console.log("setCollectionWallet txn",b),b},rm=async(t,r,e,n,o,i)=>{let a=si({loginAddress:o,loginChainId:i});return vt(t,r,e,n,{key:"UL_SUPERADMIN_WALLET",type:"S",value:a})},em=async(t,r,e,n,o)=>{let i=g(o,"8B");return vt(t,r,e,n,{key:"UL_SUPERADMIN_APP",type:"N",value:i})},vt=async(t,r,e,n,o)=>{let{key:i,type:a,value:c}=o,u=N("setGlobal(byte[],byte[],byte[])void",[Z(i),c,Z(a)]),p=await V(t,6),d=[e];return E.makeApplicationNoOpTxnFromObject({appIndex:r,from:n,suggestedParams:p,appArgs:u,foreignApps:d})},tm=async(t,{fee:r,feeType:e,companyId:n},o,i,a)=>{let c=N("setCompanyFee(uint64,uint64,byte[])void",[r,n,Z(e)]),u=await V(t,1),p=Tr(n),d=[a],m=E.makeApplicationNoOpTxnFromObject({appIndex:i,from:o,suggestedParams:u,appArgs:c,boxes:[{appIndex:i,name:p}],foreignApps:d});return console.log("setCompanyFee txn",m),m},nm=(t,r,e,n,o,i)=>{let a=er(i),c=[g(i.address,"token",i.chainId),i.chainId,g(i.name,"str"),i.decimal],u=N("updateTokenInfo(byte[],uint64,byte[],uint64)uint64",c),d=[E.makeApplicationNoOpTxnFromObject({from:e,suggestedParams:n,appIndex:t,appArgs:u,boxes:pr(t,[a]),foreignApps:[r]})],m=ii(t,r,e,n,o,i);return m&&d.unshift(m),d},om=(t,r,e,n,o,i,a,c,u)=>{let p=er(o),d=er(i),m=ye(o,i),h=N("updatePairInfo(byte[],uint64,byte[],uint64,byte[],byte[],byte[])uint64",[g(o.address,"token",o.chainId),o.chainId,g(i.address,"token",i.chainId),i.chainId,g(a,"32B"),g(c,"32B"),g(u,"32B")]);return E.makeApplicationNoOpTxnFromObject({from:e,suggestedParams:n,appIndex:t,appArgs:h,boxes:pr(t,[m,p,d]),foreignApps:[r]})},im=(t,r)=>A([g("upgradee","str"),g(t,"8B"),$(r,t),g(0,"8B")]);export{Il as checkIfAddressIsNormalized,pr as createBoxes,D as decode,lr as decodeAddress,Hl as decodeCreateOrderMsg,Ut as decodeToken,zl as decodeTradingKeyMsg,g as encode,$ as encodeAddress,Ae as encodeToken,xe as extractAddress,ti as extractDouble,Ct as extractStr,Bt as extractToken,ge as extractUint16,Dt as extractUint256,he as extractUint32,Ee as extractUint64,L as getAccountBalanceBoxName,Nl as getAccountBalanceBoxNameHash,Ul as getAccountBalanceBoxValue,Ll as getAccountBoxByHash,oi as getAccountBoxValue,_l as getAddressChainFromNormalized,kt as getAddressFromNormalized,ni as getAssetBalancesByAppAddress,Pl as getAssetBalancesByAppIndex,le as getBase64EncodedData,kl as getBoxes,Te as getCCTPBalanceBoxName,Sl as getCCTPBalanceBoxValue,Ol as getCCTPBalancesBoxValue,Wl as getCancelOrderDataJsonBytes,wl as getCodexAccountInfo,Rl as getCodexStateValue,Tr as getCompanyBoxName,Ml as getCompanyBoxValue,Fl as getOrderBoxValue,ye as getPairBoxKey,vl as getPairBoxValue,Bl as getRebalanceBoxName,be as getTmcBoxName,Cl as getTmcBoxValue,er as getTokenBoxKey,Yl as getTokenBoxValue,ei as getTokenFromNormalized,gr as getTradingKeyBoxName,Dl as getTradingKeyBoxValue,im as getUpgradeImpMsg,Mt as getUtf8EncodedData,ql as makeAddTradingKeyTxn,ii as makeAssetOptInTxn,Kl as makeCreateOrderMsg,ai as makeDepositMsg,Gl as makeDepositTxns,$l as makeLoginMsg,Vl as makeMatchTxns,Jl as makeRevokeTradingKeyTxn,jl as makeSetCollectionWalletMsg,Zl as makeSetCollectionWalletTxn,tm as makeSetCompanyFeeTxn,em as makeSetSuperAppTxns,rm as makeSetSuperCollectionWalletTxns,pi as makeSigningMessage,Xl as makeTradingKeyMsg,om as makeUpdatePairInfoTxn,nm as makeUpdateTokenInfoTxns,Ql as makeWithdrawTxns,yl as normalizeAddress};
6
+ `;return new Uint8Array(s.from(nr,"utf-8"))},Xl=(t,r="hex")=>{let e=pe(t,r),n=ge(e,104),o=he(e,138),i=he(e,174),a={version:ge(e),expiredTime:he(e,2),orderSide:Ct(e,6,1),price:Dt(e,7),amount:Dt(e,39),orderType:Ct(e,71,1),address:xe(e,72,n),chainId:n,baseTokenAddress:Ot(e,106,o),baseTokenChainId:o,priceTokenAddress:Ot(e,142,i),priceTokenChainId:i,companyId:ge(e,178),random:Ee(e,180),decimalPrice:ti(e,188)};return{...a,expiredDate:String(a.expiredTime).length>10?new Date(a.expiredTime):new Date(a.expiredTime*1e3)}},Pt=t=>{let{id:r,address:e,chain:n,message:o,encoding:i,signature:a,tradingKey:c}=t,u=c||e,p=c?8:n;return[...ur(o,a,u,p,i),r]},ye=(t,r)=>A([er(t),er(r)]),er=({address:t,chainId:r})=>A([g(t,"token",r),g(r,"8B")]),pr=(t,r,e=C)=>r.map(o=>({appIndex:t,name:e(o)})),Gr=t=>t?A([g(t.address,"address",t.chainId),g(t.chainId,"2B"),g(t.feeShare,"2B")]):s.alloc(36),rr=(t,r)=>{let e;return t?.address&&t?.chainId&&(e=L(t.address,t.chainId,r.address,r.chainId)),e},Kr=(t,r)=>{let e;return t.collectionWallet&&t.collectionWalletChainId&&(e=L(t.collectionWallet,t.collectionWalletChainId,r.address,r.chainId)),e},zl=(t,r,e,n,o="hex")=>{let{id:i,amount:a,buy:c,sell:u,baseAsset:p,priceAsset:d,superCompany:m,superAppId:h,fee:x}=r,{b_share:b,s_share:_,tfee_tier:S,mfee_tier:w,mmfee_tier:R,mm_tfee:M,p_mfee:tr,p_tfee:nr,bdMaker:v,bdTaker:F,afMaker:hr,afTaker:xr}=x;if(!m)throw new Error("Collection wallet for super user was not provided");let Hr=A([g(b,"2B"),g(_,"2B"),g(w,"str"),g(S,"str"),g(R,"str"),g(M,"2B"),g(nr,"2B"),g(tr,"2B")]),_r=A([Gr(v),Gr(hr),Gr(F),Gr(xr)]),yr=[...Pt({...c,encoding:o}),...Pt({...u,encoding:o}),g(a,"32B"),Hr,g(i,"8B"),_r],Ir=N("match(byte[],byte[],byte[],uint64,byte[],byte[],byte[],uint64,byte[],byte[],byte[],byte[])uint64",yr),Ft=ye(p,d),Yt=Fr(c.message,o),Gt=Fr(u.message,o),Kt=er(p),Wt=er(d),Ht=L(c.address,c.chain,p.address,p.chainId),Vt=L(c.address,c.chain,d.address,d.chainId),$t=L(u.address,u.chain,p.address,p.chainId),Xt=L(u.address,u.chain,d.address,d.chainId),zt=Tr(c.companyId),qt=Tr(u.companyId),Jt=[...new Set([Ft,Kt,Wt,Ht,Vt,gr(c.address,c.chain),gr(u.address,u.chain),$t,Xt,Kr(m,p),Kr(m,d),Kr(c,p),Kr(u,d),rr(v,p),rr(v,d),rr(F,p),rr(F,d),rr(hr,p),rr(hr,d),rr(xr,p),rr(xr,d)].filter(Boolean).map(X=>s.from(X).toString("hex")))].map(X=>s.from(X,"hex")),Vr=[...pr(t,Jt),...pr(t,[Yt,Gt,zt,qt],X=>X)],jt=[...new Set(Vr.map(X=>s.from(X.name).toString("hex")))];console.log(`[TradeID: ${i}] All boxes`,JSON.stringify(jt));let $r=[h],Xr=8,Qt=Vr.slice(0,Xr-$r.length),Ie=Vr.slice(Xr-$r.length),Zt=E.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:e,appIndex:t,appArgs:Ir,boxes:Qt,foreignApps:$r,note:E.encodeUint64(i)}),rn={...e,fee:0,flatFee:!0},Re=[Zt],en=1;for(;Ie.length>0;){let X=Ie.splice(0,Xr);Re.push(Yr(t,n,rn,X,`${i}_${en++}`))}return Re},ql=(t,r)=>{let{address:e,technology:n}=t;return Mt(r||JSON.stringify({address:e,technology:n}))},Jl=({tkAddress:t,loginAddress:r,loginChainId:e,expiredDate:n,type:o},i=!0)=>{let a=`${i?"Add":"Revoke"} ${o} key: ${t}`,c=n?`Expires On: ${ze(n)}`:"No Expiration",u=a+(i?`
7
+ `+c:""),p=A([g(t,"address",8),g(r,"address",e),g(e,"8B"),g(n||0,"8B")]);return pi(u,p)},ui=108,jl=(t,r="hex")=>{let e=br(t,r,ui),n=Ee(e,64),o={tkAddress:xe(e,0,8),address:xe(e,32,n),chainId:n,expiredTime:Ee(e,72)};return{...o,expiredDate:new Date(o.expiredTime)}},Ql=async(t,r,e,n,{loginAddress:o,loginChainId:i},a,c)=>{let u=ur(a,c,o,i),p=N("manageTradingKey(byte[],byte[],byte[],byte[])uint64",[g("add","str"),...u]),d=gr(o,i),m=await V(t,5);return E.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:m,appIndex:r,appArgs:p,boxes:pr(r,[d]),foreignApps:[e]})},Zl=async(t,r,e,n,{loginAddress:o,loginChainId:i},a,c)=>{let u=ur(a,c,o,i),p=N("manageTradingKey(byte[],byte[],byte[],byte[])uint64",[g("delete","str"),...u]),d=gr(o,i);return E.makeApplicationNoOpTxnFromObject({from:n,suggestedParams:await V(t,5),appIndex:r,appArgs:p,boxes:pr(r,[d]),foreignApps:[e]})},rm=t=>{let{loginAddress:r,loginChainId:e,companyId:n}=t,o=E.encodeUint64(n),i=$(r,e),a=E.encodeUint64(e),c=A([i,a,o]),u=new Uint8Array([...le(c)]);return console.log("MESSAGE LENGTH: ",u),u},pi=(t,r)=>A([Mt(t),le(r)]),Mt=t=>new Uint8Array(s.from(t+`
8
+ `,"utf-8")),le=t=>new Uint8Array(s.from(vr(t))),em=async(t,{loginAddress:r,loginChainId:e,tokenIndex:n,recipient:o,recipientChainId:i},a,c,u,p)=>{let d=ur(a,c,r,e),m=N("withdraw(byte[],byte[],byte[])uint64",d),h=i===8,x=await V(t,h?6:2);x.fee=x.fee+E.ALGORAND_MIN_TX_FEE*5;let{appId:b,coreId:_,lsaAddress:S,msgProcessorId:w,unifiedChainId:R,cctpSupportedChains:M,superWallet:tr}=p,nr=C(L(r,e,n,R||i)),v=C(L(tr.address,tr.chainId,n,R||i)),F=[{appIndex:b,name:nr},{appIndex:b,name:v}];!h&&!R&&F.push({appIndex:w,name:be(i)}),R&&F.push(...M.map(Ir=>[{appIndex:w,name:Te(String(n),Ir)},{appIndex:w,name:be(Ir)}]).flat());let hr=h&&n!=0?[+n]:void 0,xr=h?[_]:[_,w],Hr=E.getApplicationAddress(_),_r=[S,Hr];h&&_r.push(o);let yr=Bt("withdraw",{appIndex:b,from:u,suggestedParams:x,appArgs:m,accounts:_r,foreignAssets:hr,foreignApps:xr,boxes:F,note:E.encodeUint64(Date.now())});return console.log("withdraw txns",yr),yr},tm=async(t,r,{message:e,signature:n,signerAddress:o,signerChainId:i},a,c,u)=>{let p=ur(e,n,o,i),d=N("setCollectionWallet(byte[],byte[],byte[])void",p),m=await V(t,4),h=Tr(u),x=[c],b=E.makeApplicationNoOpTxnFromObject({appIndex:a,from:r,suggestedParams:m,appArgs:d,foreignApps:x,boxes:[{appIndex:a,name:h}]});return console.log("setCollectionWallet txn",b),b},nm=async(t,r,e,n,o,i)=>{let a=si({loginAddress:o,loginChainId:i});return vt(t,r,e,n,{key:"UL_SUPERADMIN_WALLET",type:"S",value:a})},om=async(t,r,e,n,o)=>{let i=g(o,"8B");return vt(t,r,e,n,{key:"UL_SUPERADMIN_APP",type:"N",value:i})},vt=async(t,r,e,n,o)=>{let{key:i,type:a,value:c}=o,u=N("setGlobal(byte[],byte[],byte[])void",[Z(i),c,Z(a)]),p=await V(t,6),d=[e];return E.makeApplicationNoOpTxnFromObject({appIndex:r,from:n,suggestedParams:p,appArgs:u,foreignApps:d})},im=async(t,{fee:r,feeType:e,companyId:n},o,i,a)=>{let c=N("setCompanyFee(uint64,uint64,byte[])void",[r,n,Z(e)]),u=await V(t,1),p=Tr(n),d=[a],m=E.makeApplicationNoOpTxnFromObject({appIndex:i,from:o,suggestedParams:u,appArgs:c,boxes:[{appIndex:i,name:p}],foreignApps:d});return console.log("setCompanyFee txn",m),m},am=(t,r,e,n,o,i)=>{let a=er(i),c=[g(i.address,"token",i.chainId),i.chainId,g(i.name,"str"),i.decimal],u=N("updateTokenInfo(byte[],uint64,byte[],uint64)uint64",c),d=[E.makeApplicationNoOpTxnFromObject({from:e,suggestedParams:n,appIndex:t,appArgs:u,boxes:pr(t,[a]),foreignApps:[r]})],m=ii(t,r,e,n,o,i);return m&&d.unshift(m),d},sm=(t,r,e,n,o,i,a,c,u)=>{let p=er(o),d=er(i),m=ye(o,i),h=N("updatePairInfo(byte[],uint64,byte[],uint64,byte[],byte[],byte[])uint64",[g(o.address,"token",o.chainId),o.chainId,g(i.address,"token",i.chainId),i.chainId,g(a,"32B"),g(c,"32B"),g(u,"32B")]);return E.makeApplicationNoOpTxnFromObject({from:e,suggestedParams:n,appIndex:t,appArgs:h,boxes:pr(t,[m,p,d]),foreignApps:[r]})},cm=(t,r)=>A([g("upgradee","str"),g(t,"8B"),$(r,t),g(0,"8B")]);export{Nl as checkIfAddressIsNormalized,pr as createBoxes,D as decode,lr as decodeAddress,Xl as decodeCreateOrderMsg,Ut as decodeToken,jl as decodeTradingKeyMsg,g as encode,$ as encodeAddress,Ae as encodeToken,xe as extractAddress,ti as extractDouble,Ct as extractStr,Ot as extractToken,ge as extractUint16,Dt as extractUint256,he as extractUint32,Ee as extractUint64,L as getAccountBalanceBoxName,Ol as getAccountBalanceBoxNameHash,vl as getAccountBalanceBoxValue,Fl as getAccountBoxByHash,oi as getAccountBoxValue,Rl as getAddressChainFromNormalized,kt as getAddressFromNormalized,ni as getAssetBalancesByAppAddress,Ll as getAssetBalancesByAppIndex,le as getBase64EncodedData,Ml as getBoxes,Te as getCCTPBalanceBoxName,Cl as getCCTPBalanceBoxValue,Dl as getCCTPBalancesBoxValue,$l as getCancelOrderDataJsonBytes,Bl as getCodexAccountInfo,Sl as getCodexStateValue,Tr as getCompanyBoxName,Yl as getCompanyBoxValue,Kl as getOrderBoxValue,ye as getPairBoxKey,Gl as getPairBoxValue,Pl as getRebalanceBoxName,be as getTmcBoxName,kl as getTmcBoxValue,er as getTokenBoxKey,Wl as getTokenBoxValue,ei as getTokenFromNormalized,gr as getTradingKeyBoxName,Ul as getTradingKeyBoxValue,cm as getUpgradeImpMsg,Mt as getUtf8EncodedData,Ql as makeAddTradingKeyTxn,ii as makeAssetOptInTxn,Vl as makeCreateOrderMsg,ai as makeDepositMsg,Hl as makeDepositTxns,ql as makeLoginMsg,zl as makeMatchTxns,Zl as makeRevokeTradingKeyTxn,rm as makeSetCollectionWalletMsg,tm as makeSetCollectionWalletTxn,im as makeSetCompanyFeeTxn,om as makeSetSuperAppTxns,nm as makeSetSuperCollectionWalletTxns,pi as makeSigningMessage,Jl as makeTradingKeyMsg,sm as makeUpdatePairInfoTxn,am as makeUpdateTokenInfoTxns,em as makeWithdrawTxns,wl as normalizeAddress};
9
9
  /*!
10
10
  * The buffer module from node.js, for the browser.
11
11
  *