wowok_agent 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,(()=>(()=>{var e,t,r,s,i={22:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=t[e.charCodeAt(r)];if(255===u)return;for(var h=0,l=n-1;(0!==u||h<i)&&-1!==l;l--,h++)u+=a*c[l]>>>0,c[l]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");i=h,r++}for(var p=n-i;p!==n&&0===c[p];)p++;for(var m=new Uint8Array(s+(n-p)),b=s;p!==n;)m[b++]=c[p++];return m}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],l=0,p=d-1;(0!==h||l<s)&&-1!==p;p--,l++)h+=256*u[p]>>>0,u[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=l,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var b=o.repeat(r);m<d;++m)b+=e.charAt(u[m]);return b},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},211:()=>{},333:(e,t)=>{"use strict";t.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let e=0;e<32;e++){const t=r.charAt(e);s[t]=e}function i(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function n(e){let t=1;for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);if(s<33||s>126)return"Invalid prefix ("+e+")";t=i(t)^s>>5}t=i(t);for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);t=i(t)^31&s}return t}function a(e,t,r,s){let i=0,n=0;const a=(1<<r)-1,o=[];for(let s=0;s<e.length;++s)for(i=i<<t|e[s],n+=t;n>=r;)n-=r,o.push(i>>n&a);if(s)n>0&&o.push(i<<r-n&a);else{if(n>=t)return"Excess padding";if(i<<r-n&a)return"Non-zero padding"}return o}function o(e){return a(e,8,5,!0)}function d(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t}function c(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function u(e){let t;function a(e,r){if(r=r||90,e.length<8)return e+" too short";if(e.length>r)return"Exceeds length limit";const a=e.toLowerCase(),o=e.toUpperCase();if(e!==a&&e!==o)return"Mixed-case string "+e;const d=(e=a).lastIndexOf("1");if(-1===d)return"No separator character for "+e;if(0===d)return"Missing prefix for "+e;const c=e.slice(0,d),u=e.slice(d+1);if(u.length<6)return"Data too short";let h=n(c);if("string"==typeof h)return h;const l=[];for(let e=0;e<u.length;++e){const t=u.charAt(e),r=s[t];if(void 0===r)return"Unknown character "+t;h=i(h)^r,e+6>=u.length||l.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:c,words:l}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=a(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=a(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,s,a){if(a=a||90,e.length+7+s.length>a)throw new TypeError("Exceeds length limit");let o=n(e=e.toLowerCase());if("string"==typeof o)throw new Error(o);let d=e+"1";for(let e=0;e<s.length;++e){const t=s[e];if(t>>5)throw new Error("Non 5-bit word");o=i(o)^t,d+=r.charAt(t)}for(let e=0;e<6;++e)o=i(o);o^=t;for(let e=0;e<6;++e)d+=r.charAt(o>>5*(5-e)&31);return d},toWords:o,fromWordsUnsafe:d,fromWords:c}}t.I=u("bech32"),u("bech32m")},364:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=e.charCodeAt(r);if(u>255)return;var h=t[u];if(255===h)return;for(var l=0,p=n-1;(0!==h||l<i)&&-1!==p;p--,l++)h+=a*c[p]>>>0,c[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,r++}for(var m=n-i;m!==n&&0===c[m];)m++;for(var b=new Uint8Array(s+(n-m)),g=s;m!==n;)b[g++]=c[m++];return b}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],l=0,p=d-1;(0!==h||l<s)&&-1!==p;p--,l++)h+=256*u[p]>>>0,u[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=l,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var b=o.repeat(r);m<d;++m)b+=e.charAt(u[m]);return b},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},601:(e,t,r)=>{!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},s=function(){throw new Error("no PRNG")},i=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var a=t(),o=t([1]),d=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,t,r,s){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=s>>24&255,e[t+5]=s>>16&255,e[t+6]=s>>8&255,e[t+7]=255&s}function b(e,t,r,s,i){var n,a=0;for(n=0;n<i;n++)a|=e[t+n]^r[s+n];return(1&a-1>>>8)-1}function g(e,t,r,s){return b(e,t,r,s,16)}function _(e,t,r,s){return b(e,t,r,s,32)}function f(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,b=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,_=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,f=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,y=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=n,w=a,E=o,x=d,O=c,I=u,C=h,B=l,S=p,P=m,j=b,A=g,k=_,U=f,N=y,D=v,Y=0;Y<20;Y+=2)T^=(i=(k^=(i=(S^=(i=(O^=(i=T+k|0)<<7|i>>>25)+T|0)<<9|i>>>23)+O|0)<<13|i>>>19)+S|0)<<18|i>>>14,I^=(i=(w^=(i=(U^=(i=(P^=(i=I+w|0)<<7|i>>>25)+I|0)<<9|i>>>23)+P|0)<<13|i>>>19)+U|0)<<18|i>>>14,j^=(i=(C^=(i=(E^=(i=(N^=(i=j+C|0)<<7|i>>>25)+j|0)<<9|i>>>23)+N|0)<<13|i>>>19)+E|0)<<18|i>>>14,D^=(i=(A^=(i=(B^=(i=(x^=(i=D+A|0)<<7|i>>>25)+D|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,T^=(i=(x^=(i=(E^=(i=(w^=(i=T+x|0)<<7|i>>>25)+T|0)<<9|i>>>23)+w|0)<<13|i>>>19)+E|0)<<18|i>>>14,I^=(i=(O^=(i=(B^=(i=(C^=(i=I+O|0)<<7|i>>>25)+I|0)<<9|i>>>23)+C|0)<<13|i>>>19)+B|0)<<18|i>>>14,j^=(i=(P^=(i=(S^=(i=(A^=(i=j+P|0)<<7|i>>>25)+j|0)<<9|i>>>23)+A|0)<<13|i>>>19)+S|0)<<18|i>>>14,D^=(i=(N^=(i=(U^=(i=(k^=(i=D+N|0)<<7|i>>>25)+D|0)<<9|i>>>23)+k|0)<<13|i>>>19)+U|0)<<18|i>>>14;T=T+n|0,w=w+a|0,E=E+o|0,x=x+d|0,O=O+c|0,I=I+u|0,C=C+h|0,B=B+l|0,S=S+p|0,P=P+m|0,j=j+b|0,A=A+g|0,k=k+_|0,U=U+f|0,N=N+y|0,D=D+v|0,e[0]=T>>>0&255,e[1]=T>>>8&255,e[2]=T>>>16&255,e[3]=T>>>24&255,e[4]=w>>>0&255,e[5]=w>>>8&255,e[6]=w>>>16&255,e[7]=w>>>24&255,e[8]=E>>>0&255,e[9]=E>>>8&255,e[10]=E>>>16&255,e[11]=E>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=I>>>0&255,e[21]=I>>>8&255,e[22]=I>>>16&255,e[23]=I>>>24&255,e[24]=C>>>0&255,e[25]=C>>>8&255,e[26]=C>>>16&255,e[27]=C>>>24&255,e[28]=B>>>0&255,e[29]=B>>>8&255,e[30]=B>>>16&255,e[31]=B>>>24&255,e[32]=S>>>0&255,e[33]=S>>>8&255,e[34]=S>>>16&255,e[35]=S>>>24&255,e[36]=P>>>0&255,e[37]=P>>>8&255,e[38]=P>>>16&255,e[39]=P>>>24&255,e[40]=j>>>0&255,e[41]=j>>>8&255,e[42]=j>>>16&255,e[43]=j>>>24&255,e[44]=A>>>0&255,e[45]=A>>>8&255,e[46]=A>>>16&255,e[47]=A>>>24&255,e[48]=k>>>0&255,e[49]=k>>>8&255,e[50]=k>>>16&255,e[51]=k>>>24&255,e[52]=U>>>0&255,e[53]=U>>>8&255,e[54]=U>>>16&255,e[55]=U>>>24&255,e[56]=N>>>0&255,e[57]=N>>>8&255,e[58]=N>>>16&255,e[59]=N>>>24&255,e[60]=D>>>0&255,e[61]=D>>>8&255,e[62]=D>>>16&255,e[63]=D>>>24&255}(e,t,r,s)}function y(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,b=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,_=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,f=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,y=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=0;T<20;T+=2)n^=(i=(_^=(i=(p^=(i=(c^=(i=n+_|0)<<7|i>>>25)+n|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(a^=(i=(f^=(i=(m^=(i=u+a|0)<<7|i>>>25)+u|0)<<9|i>>>23)+m|0)<<13|i>>>19)+f|0)<<18|i>>>14,b^=(i=(h^=(i=(o^=(i=(y^=(i=b+h|0)<<7|i>>>25)+b|0)<<9|i>>>23)+y|0)<<13|i>>>19)+o|0)<<18|i>>>14,v^=(i=(g^=(i=(l^=(i=(d^=(i=v+g|0)<<7|i>>>25)+v|0)<<9|i>>>23)+d|0)<<13|i>>>19)+l|0)<<18|i>>>14,n^=(i=(d^=(i=(o^=(i=(a^=(i=n+d|0)<<7|i>>>25)+n|0)<<9|i>>>23)+a|0)<<13|i>>>19)+o|0)<<18|i>>>14,u^=(i=(c^=(i=(l^=(i=(h^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+h|0)<<13|i>>>19)+l|0)<<18|i>>>14,b^=(i=(m^=(i=(p^=(i=(g^=(i=b+m|0)<<7|i>>>25)+b|0)<<9|i>>>23)+g|0)<<13|i>>>19)+p|0)<<18|i>>>14,v^=(i=(y^=(i=(f^=(i=(_^=(i=v+y|0)<<7|i>>>25)+v|0)<<9|i>>>23)+_|0)<<13|i>>>19)+f|0)<<18|i>>>14;e[0]=n>>>0&255,e[1]=n>>>8&255,e[2]=n>>>16&255,e[3]=n>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=b>>>0&255,e[9]=b>>>8&255,e[10]=b>>>16&255,e[11]=b>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=l>>>0&255,e[21]=l>>>8&255,e[22]=l>>>16&255,e[23]=l>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=m>>>0&255,e[29]=m>>>8&255,e[30]=m>>>16&255,e[31]=m>>>24&255}(e,t,r,s)}var v=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function T(e,t,r,s,i,n,a){var o,d,c=new Uint8Array(16),u=new Uint8Array(64);for(d=0;d<16;d++)c[d]=0;for(d=0;d<8;d++)c[d]=n[d];for(;i>=64;){for(f(u,c,a,v),d=0;d<64;d++)e[t+d]=r[s+d]^u[d];for(o=1,d=8;d<16;d++)o=o+(255&c[d])|0,c[d]=255&o,o>>>=8;i-=64,t+=64,s+=64}if(i>0)for(f(u,c,a,v),d=0;d<i;d++)e[t+d]=r[s+d]^u[d];return 0}function w(e,t,r,s,i){var n,a,o=new Uint8Array(16),d=new Uint8Array(64);for(a=0;a<16;a++)o[a]=0;for(a=0;a<8;a++)o[a]=s[a];for(;r>=64;){for(f(d,o,i,v),a=0;a<64;a++)e[t+a]=d[a];for(n=1,a=8;a<16;a++)n=n+(255&o[a])|0,o[a]=255&n,n>>>=8;r-=64,t+=64}if(r>0)for(f(d,o,i,v),a=0;a<r;a++)e[t+a]=d[a];return 0}function E(e,t,r,s,i){var n=new Uint8Array(32);y(n,s,i,v);for(var a=new Uint8Array(8),o=0;o<8;o++)a[o]=s[o+16];return w(e,t,r,a,n)}function x(e,t,r,s,i,n,a){var o=new Uint8Array(32);y(o,n,a,v);for(var d=new Uint8Array(8),c=0;c<8;c++)d[c]=n[c+16];return T(e,t,r,s,i,d,o)}var O=function(e){var t,r,s,i,n,a,o,d;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),s=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|s<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(s>>>7|i<<9),n=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|n<<12),this.r[5]=n>>>1&8190,a=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(n>>>14|a<<2),o=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(a>>>11|o<<5),d=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(o>>>8|d<<8),this.r[9]=d>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function I(e,t,r,s,i,n){var a=new O(n);return a.update(r,s,i),a.finish(e,t),0}function C(e,t,r,s,i,n){var a=new Uint8Array(16);return I(a,0,r,s,i,n),g(e,t,a,0)}function B(e,t,r,s,i){var n;if(r<32)return-1;for(x(e,0,t,0,r,s,i),I(e,16,e,32,r-32,e),n=0;n<16;n++)e[n]=0;return 0}function S(e,t,r,s,i){var n,a=new Uint8Array(32);if(r<32)return-1;if(E(a,0,32,s,i),0!==C(t,16,t,32,r-32,a))return-1;for(x(e,0,t,0,r,s,i),n=0;n<32;n++)e[n]=0;return 0}function P(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function j(e){var t,r,s=1;for(t=0;t<16;t++)r=e[t]+s+65535,s=Math.floor(r/65536),e[t]=r-65536*s;e[0]+=s-1+37*(s-1)}function A(e,t,r){for(var s,i=~(r-1),n=0;n<16;n++)s=i&(e[n]^t[n]),e[n]^=s,t[n]^=s}function k(e,r){var s,i,n,a=t(),o=t();for(s=0;s<16;s++)o[s]=r[s];for(j(o),j(o),j(o),i=0;i<2;i++){for(a[0]=o[0]-65517,s=1;s<15;s++)a[s]=o[s]-65535-(a[s-1]>>16&1),a[s-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),n=a[15]>>16&1,a[14]&=65535,A(o,a,1-n)}for(s=0;s<16;s++)e[2*s]=255&o[s],e[2*s+1]=o[s]>>8}function U(e,t){var r=new Uint8Array(32),s=new Uint8Array(32);return k(r,e),k(s,t),_(r,0,s,0)}function N(e){var t=new Uint8Array(32);return k(t,e),1&t[0]}function D(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function Y(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]+r[s]}function R(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]-r[s]}function V(e,t,r){var s,i,n=0,a=0,o=0,d=0,c=0,u=0,h=0,l=0,p=0,m=0,b=0,g=0,_=0,f=0,y=0,v=0,T=0,w=0,E=0,x=0,O=0,I=0,C=0,B=0,S=0,P=0,j=0,A=0,k=0,U=0,N=0,D=r[0],Y=r[1],R=r[2],V=r[3],M=r[4],J=r[5],F=r[6],X=r[7],L=r[8],G=r[9],$=r[10],z=r[11],q=r[12],W=r[13],H=r[14],K=r[15];n+=(s=t[0])*D,a+=s*Y,o+=s*R,d+=s*V,c+=s*M,u+=s*J,h+=s*F,l+=s*X,p+=s*L,m+=s*G,b+=s*$,g+=s*z,_+=s*q,f+=s*W,y+=s*H,v+=s*K,a+=(s=t[1])*D,o+=s*Y,d+=s*R,c+=s*V,u+=s*M,h+=s*J,l+=s*F,p+=s*X,m+=s*L,b+=s*G,g+=s*$,_+=s*z,f+=s*q,y+=s*W,v+=s*H,T+=s*K,o+=(s=t[2])*D,d+=s*Y,c+=s*R,u+=s*V,h+=s*M,l+=s*J,p+=s*F,m+=s*X,b+=s*L,g+=s*G,_+=s*$,f+=s*z,y+=s*q,v+=s*W,T+=s*H,w+=s*K,d+=(s=t[3])*D,c+=s*Y,u+=s*R,h+=s*V,l+=s*M,p+=s*J,m+=s*F,b+=s*X,g+=s*L,_+=s*G,f+=s*$,y+=s*z,v+=s*q,T+=s*W,w+=s*H,E+=s*K,c+=(s=t[4])*D,u+=s*Y,h+=s*R,l+=s*V,p+=s*M,m+=s*J,b+=s*F,g+=s*X,_+=s*L,f+=s*G,y+=s*$,v+=s*z,T+=s*q,w+=s*W,E+=s*H,x+=s*K,u+=(s=t[5])*D,h+=s*Y,l+=s*R,p+=s*V,m+=s*M,b+=s*J,g+=s*F,_+=s*X,f+=s*L,y+=s*G,v+=s*$,T+=s*z,w+=s*q,E+=s*W,x+=s*H,O+=s*K,h+=(s=t[6])*D,l+=s*Y,p+=s*R,m+=s*V,b+=s*M,g+=s*J,_+=s*F,f+=s*X,y+=s*L,v+=s*G,T+=s*$,w+=s*z,E+=s*q,x+=s*W,O+=s*H,I+=s*K,l+=(s=t[7])*D,p+=s*Y,m+=s*R,b+=s*V,g+=s*M,_+=s*J,f+=s*F,y+=s*X,v+=s*L,T+=s*G,w+=s*$,E+=s*z,x+=s*q,O+=s*W,I+=s*H,C+=s*K,p+=(s=t[8])*D,m+=s*Y,b+=s*R,g+=s*V,_+=s*M,f+=s*J,y+=s*F,v+=s*X,T+=s*L,w+=s*G,E+=s*$,x+=s*z,O+=s*q,I+=s*W,C+=s*H,B+=s*K,m+=(s=t[9])*D,b+=s*Y,g+=s*R,_+=s*V,f+=s*M,y+=s*J,v+=s*F,T+=s*X,w+=s*L,E+=s*G,x+=s*$,O+=s*z,I+=s*q,C+=s*W,B+=s*H,S+=s*K,b+=(s=t[10])*D,g+=s*Y,_+=s*R,f+=s*V,y+=s*M,v+=s*J,T+=s*F,w+=s*X,E+=s*L,x+=s*G,O+=s*$,I+=s*z,C+=s*q,B+=s*W,S+=s*H,P+=s*K,g+=(s=t[11])*D,_+=s*Y,f+=s*R,y+=s*V,v+=s*M,T+=s*J,w+=s*F,E+=s*X,x+=s*L,O+=s*G,I+=s*$,C+=s*z,B+=s*q,S+=s*W,P+=s*H,j+=s*K,_+=(s=t[12])*D,f+=s*Y,y+=s*R,v+=s*V,T+=s*M,w+=s*J,E+=s*F,x+=s*X,O+=s*L,I+=s*G,C+=s*$,B+=s*z,S+=s*q,P+=s*W,j+=s*H,A+=s*K,f+=(s=t[13])*D,y+=s*Y,v+=s*R,T+=s*V,w+=s*M,E+=s*J,x+=s*F,O+=s*X,I+=s*L,C+=s*G,B+=s*$,S+=s*z,P+=s*q,j+=s*W,A+=s*H,k+=s*K,y+=(s=t[14])*D,v+=s*Y,T+=s*R,w+=s*V,E+=s*M,x+=s*J,O+=s*F,I+=s*X,C+=s*L,B+=s*G,S+=s*$,P+=s*z,j+=s*q,A+=s*W,k+=s*H,U+=s*K,v+=(s=t[15])*D,a+=38*(w+=s*R),o+=38*(E+=s*V),d+=38*(x+=s*M),c+=38*(O+=s*J),u+=38*(I+=s*F),h+=38*(C+=s*X),l+=38*(B+=s*L),p+=38*(S+=s*G),m+=38*(P+=s*$),b+=38*(j+=s*z),g+=38*(A+=s*q),_+=38*(k+=s*W),f+=38*(U+=s*H),y+=38*(N+=s*K),n=(s=(n+=38*(T+=s*Y))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n=(s=(n+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n+=i-1+37*(i-1),e[0]=n,e[1]=a,e[2]=o,e[3]=d,e[4]=c,e[5]=u,e[6]=h,e[7]=l,e[8]=p,e[9]=m,e[10]=b,e[11]=g,e[12]=_,e[13]=f,e[14]=y,e[15]=v}function M(e,t){V(e,t,t)}function J(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=253;s>=0;s--)M(i,i),2!==s&&4!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function F(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=250;s>=0;s--)M(i,i),1!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function X(e,r,s){var i,n,a=new Uint8Array(32),o=new Float64Array(80),c=t(),u=t(),h=t(),l=t(),p=t(),m=t();for(n=0;n<31;n++)a[n]=r[n];for(a[31]=127&r[31]|64,a[0]&=248,D(o,s),n=0;n<16;n++)u[n]=o[n],l[n]=c[n]=h[n]=0;for(c[0]=l[0]=1,n=254;n>=0;--n)A(c,u,i=a[n>>>3]>>>(7&n)&1),A(h,l,i),Y(p,c,h),R(c,c,h),Y(h,u,l),R(u,u,l),M(l,p),M(m,c),V(c,h,c),V(h,u,p),Y(p,c,h),R(c,c,h),M(u,c),R(h,l,m),V(c,h,d),Y(c,c,l),V(h,h,c),V(c,l,m),V(l,u,o),M(u,p),A(c,u,i),A(h,l,i);for(n=0;n<16;n++)o[n+16]=c[n],o[n+32]=h[n],o[n+48]=u[n],o[n+64]=l[n];var b=o.subarray(32),g=o.subarray(16);return J(b,b),V(g,g,b),k(e,g),0}function L(e,t){return X(e,t,n)}function G(e,t){return s(t,32),L(e,t)}function $(e,t,r){var s=new Uint8Array(32);return X(s,r,t),y(e,i,s,v)}O.prototype.blocks=function(e,t,r){for(var s,i,n,a,o,d,c,u,h,l,p,m,b,g,_,f,y,v,T,w=this.fin?0:2048,E=this.h[0],x=this.h[1],O=this.h[2],I=this.h[3],C=this.h[4],B=this.h[5],S=this.h[6],P=this.h[7],j=this.h[8],A=this.h[9],k=this.r[0],U=this.r[1],N=this.r[2],D=this.r[3],Y=this.r[4],R=this.r[5],V=this.r[6],M=this.r[7],J=this.r[8],F=this.r[9];r>=16;)l=h=0,l+=(E+=8191&(s=255&e[t+0]|(255&e[t+1])<<8))*k,l+=(x+=8191&(s>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),l+=(O+=8191&(i>>>10|(n=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*J),l+=(I+=8191&(n>>>7|(a=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*M),h=(l+=(C+=8191&(a>>>4|(o=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*V))>>>13,l&=8191,l+=(B+=o>>>1&8191)*(5*R),l+=(S+=8191&(o>>>14|(d=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*Y),l+=(P+=8191&(d>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*D),l+=(j+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*N),p=h+=(l+=(A+=u>>>5|w)*(5*U))>>>13,p+=E*U,p+=x*k,p+=O*(5*F),p+=I*(5*J),h=(p+=C*(5*M))>>>13,p&=8191,p+=B*(5*V),p+=S*(5*R),p+=P*(5*Y),p+=j*(5*D),h+=(p+=A*(5*N))>>>13,p&=8191,m=h,m+=E*N,m+=x*U,m+=O*k,m+=I*(5*F),h=(m+=C*(5*J))>>>13,m&=8191,m+=B*(5*M),m+=S*(5*V),m+=P*(5*R),m+=j*(5*Y),b=h+=(m+=A*(5*D))>>>13,b+=E*D,b+=x*N,b+=O*U,b+=I*k,h=(b+=C*(5*F))>>>13,b&=8191,b+=B*(5*J),b+=S*(5*M),b+=P*(5*V),b+=j*(5*R),g=h+=(b+=A*(5*Y))>>>13,g+=E*Y,g+=x*D,g+=O*N,g+=I*U,h=(g+=C*k)>>>13,g&=8191,g+=B*(5*F),g+=S*(5*J),g+=P*(5*M),g+=j*(5*V),_=h+=(g+=A*(5*R))>>>13,_+=E*R,_+=x*Y,_+=O*D,_+=I*N,h=(_+=C*U)>>>13,_&=8191,_+=B*k,_+=S*(5*F),_+=P*(5*J),_+=j*(5*M),f=h+=(_+=A*(5*V))>>>13,f+=E*V,f+=x*R,f+=O*Y,f+=I*D,h=(f+=C*N)>>>13,f&=8191,f+=B*U,f+=S*k,f+=P*(5*F),f+=j*(5*J),y=h+=(f+=A*(5*M))>>>13,y+=E*M,y+=x*V,y+=O*R,y+=I*Y,h=(y+=C*D)>>>13,y&=8191,y+=B*N,y+=S*U,y+=P*k,y+=j*(5*F),v=h+=(y+=A*(5*J))>>>13,v+=E*J,v+=x*M,v+=O*V,v+=I*R,h=(v+=C*Y)>>>13,v&=8191,v+=B*D,v+=S*N,v+=P*U,v+=j*k,T=h+=(v+=A*(5*F))>>>13,T+=E*F,T+=x*J,T+=O*M,T+=I*V,h=(T+=C*R)>>>13,T&=8191,T+=B*Y,T+=S*D,T+=P*N,T+=j*U,E=l=8191&(h=(h=((h+=(T+=A*k)>>>13)<<2)+h|0)+(l&=8191)|0),x=p+=h>>>=13,O=m&=8191,I=b&=8191,C=g&=8191,B=_&=8191,S=f&=8191,P=y&=8191,j=v&=8191,A=T&=8191,t+=16,r-=16;this.h[0]=E,this.h[1]=x,this.h[2]=O,this.h[3]=I,this.h[4]=C,this.h[5]=B,this.h[6]=S,this.h[7]=P,this.h[8]=j,this.h[9]=A},O.prototype.finish=function(e,t){var r,s,i,n,a=new Uint16Array(10);if(this.leftover){for(n=this.leftover,this.buffer[n++]=1;n<16;n++)this.buffer[n]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,n=2;n<10;n++)this.h[n]+=r,r=this.h[n]>>>13,this.h[n]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,a[0]=this.h[0]+5,r=a[0]>>>13,a[0]&=8191,n=1;n<10;n++)a[n]=this.h[n]+r,r=a[n]>>>13,a[n]&=8191;for(a[9]-=8192,s=(1^r)-1,n=0;n<10;n++)a[n]&=s;for(s=~s,n=0;n<10;n++)this.h[n]=this.h[n]&s|a[n];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,n=1;n<8;n++)i=(this.h[n]+this.pad[n]|0)+(i>>>16)|0,this.h[n]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,r){var s,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),s=0;s<i;s++)this.buffer[this.leftover+s]=e[t+s];if(r-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(s=0;s<r;s++)this.buffer[this.leftover+s]=e[t+s];this.leftover+=r}};var z=B,q=S,W=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function H(e,t,r,s){for(var i,n,a,o,d,c,u,h,l,p,m,b,g,_,f,y,v,T,w,E,x,O,I,C,B,S,P=new Int32Array(16),j=new Int32Array(16),A=e[0],k=e[1],U=e[2],N=e[3],D=e[4],Y=e[5],R=e[6],V=e[7],M=t[0],J=t[1],F=t[2],X=t[3],L=t[4],G=t[5],$=t[6],z=t[7],q=0;s>=128;){for(w=0;w<16;w++)E=8*w+q,P[w]=r[E+0]<<24|r[E+1]<<16|r[E+2]<<8|r[E+3],j[w]=r[E+4]<<24|r[E+5]<<16|r[E+6]<<8|r[E+7];for(w=0;w<80;w++)if(i=A,n=k,a=U,o=N,d=D,c=Y,u=R,l=M,p=J,m=F,b=X,g=L,_=G,f=$,I=65535&(O=z),C=O>>>16,B=65535&(x=V),S=x>>>16,I+=65535&(O=(L>>>14|D<<18)^(L>>>18|D<<14)^(D>>>9|L<<23)),C+=O>>>16,B+=65535&(x=(D>>>14|L<<18)^(D>>>18|L<<14)^(L>>>9|D<<23)),S+=x>>>16,I+=65535&(O=L&G^~L&$),C+=O>>>16,B+=65535&(x=D&Y^~D&R),S+=x>>>16,I+=65535&(O=W[2*w+1]),C+=O>>>16,B+=65535&(x=W[2*w]),S+=x>>>16,x=P[w%16],C+=(O=j[w%16])>>>16,B+=65535&x,S+=x>>>16,B+=(C+=(I+=65535&O)>>>16)>>>16,I=65535&(O=T=65535&I|C<<16),C=O>>>16,B=65535&(x=v=65535&B|(S+=B>>>16)<<16),S=x>>>16,I+=65535&(O=(M>>>28|A<<4)^(A>>>2|M<<30)^(A>>>7|M<<25)),C+=O>>>16,B+=65535&(x=(A>>>28|M<<4)^(M>>>2|A<<30)^(M>>>7|A<<25)),S+=x>>>16,C+=(O=M&J^M&F^J&F)>>>16,B+=65535&(x=A&k^A&U^k&U),S+=x>>>16,h=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,y=65535&I|C<<16,I=65535&(O=b),C=O>>>16,B=65535&(x=o),S=x>>>16,C+=(O=T)>>>16,B+=65535&(x=v),S+=x>>>16,k=i,U=n,N=a,D=o=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,Y=d,R=c,V=u,A=h,J=l,F=p,X=m,L=b=65535&I|C<<16,G=g,$=_,z=f,M=y,w%16==15)for(E=0;E<16;E++)x=P[E],I=65535&(O=j[E]),C=O>>>16,B=65535&x,S=x>>>16,x=P[(E+9)%16],I+=65535&(O=j[(E+9)%16]),C+=O>>>16,B+=65535&x,S+=x>>>16,v=P[(E+1)%16],I+=65535&(O=((T=j[(E+1)%16])>>>1|v<<31)^(T>>>8|v<<24)^(T>>>7|v<<25)),C+=O>>>16,B+=65535&(x=(v>>>1|T<<31)^(v>>>8|T<<24)^v>>>7),S+=x>>>16,v=P[(E+14)%16],C+=(O=((T=j[(E+14)%16])>>>19|v<<13)^(v>>>29|T<<3)^(T>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|T<<13)^(T>>>29|v<<3)^v>>>6),S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,P[E]=65535&B|S<<16,j[E]=65535&I|C<<16;I=65535&(O=M),C=O>>>16,B=65535&(x=A),S=x>>>16,x=e[0],C+=(O=t[0])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[0]=A=65535&B|S<<16,t[0]=M=65535&I|C<<16,I=65535&(O=J),C=O>>>16,B=65535&(x=k),S=x>>>16,x=e[1],C+=(O=t[1])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[1]=k=65535&B|S<<16,t[1]=J=65535&I|C<<16,I=65535&(O=F),C=O>>>16,B=65535&(x=U),S=x>>>16,x=e[2],C+=(O=t[2])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[2]=U=65535&B|S<<16,t[2]=F=65535&I|C<<16,I=65535&(O=X),C=O>>>16,B=65535&(x=N),S=x>>>16,x=e[3],C+=(O=t[3])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[3]=N=65535&B|S<<16,t[3]=X=65535&I|C<<16,I=65535&(O=L),C=O>>>16,B=65535&(x=D),S=x>>>16,x=e[4],C+=(O=t[4])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[4]=D=65535&B|S<<16,t[4]=L=65535&I|C<<16,I=65535&(O=G),C=O>>>16,B=65535&(x=Y),S=x>>>16,x=e[5],C+=(O=t[5])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[5]=Y=65535&B|S<<16,t[5]=G=65535&I|C<<16,I=65535&(O=$),C=O>>>16,B=65535&(x=R),S=x>>>16,x=e[6],C+=(O=t[6])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[6]=R=65535&B|S<<16,t[6]=$=65535&I|C<<16,I=65535&(O=z),C=O>>>16,B=65535&(x=V),S=x>>>16,x=e[7],C+=(O=t[7])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[7]=V=65535&B|S<<16,t[7]=z=65535&I|C<<16,q+=128,s-=128}return s}function K(e,t,r){var s,i=new Int32Array(8),n=new Int32Array(8),a=new Uint8Array(256),o=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,n[0]=4089235720,n[1]=2227873595,n[2]=4271175723,n[3]=1595750129,n[4]=2917565137,n[5]=725511199,n[6]=4215389547,n[7]=327033209,H(i,n,t,r),r%=128,s=0;s<r;s++)a[s]=t[o-r+s];for(a[r]=128,a[(r=256-128*(r<112?1:0))-9]=0,m(a,r-8,o/536870912|0,o<<3),H(i,n,a,r),s=0;s<8;s++)m(e,8*s,i[s],n[s]);return 0}function Q(e,r){var s=t(),i=t(),n=t(),a=t(),o=t(),d=t(),c=t(),h=t(),l=t();R(s,e[1],e[0]),R(l,r[1],r[0]),V(s,s,l),Y(i,e[0],e[1]),Y(l,r[0],r[1]),V(i,i,l),V(n,e[3],r[3]),V(n,n,u),V(a,e[2],r[2]),Y(a,a,a),R(o,i,s),R(d,a,n),Y(c,a,n),Y(h,i,s),V(e[0],o,d),V(e[1],h,c),V(e[2],c,d),V(e[3],o,h)}function Z(e,t,r){var s;for(s=0;s<4;s++)A(e[s],t[s],r)}function ee(e,r){var s=t(),i=t(),n=t();J(n,r[2]),V(s,r[0],n),V(i,r[1],n),k(e,i),e[31]^=N(s)<<7}function te(e,t,r){var s,i;for(P(e[0],a),P(e[1],o),P(e[2],o),P(e[3],a),i=255;i>=0;--i)Z(e,t,s=r[i/8|0]>>(7&i)&1),Q(t,e),Q(e,e),Z(e,t,s)}function re(e,r){var s=[t(),t(),t(),t()];P(s[0],h),P(s[1],l),P(s[2],o),V(s[3],h,l),te(e,s,r)}function se(e,r,i){var n,a=new Uint8Array(64),o=[t(),t(),t(),t()];for(i||s(r,32),K(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,re(o,a),ee(e,o),n=0;n<32;n++)r[n+32]=e[n];return 0}var ie=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ne(e,t){var r,s,i,n;for(s=63;s>=32;--s){for(r=0,i=s-32,n=s-12;i<n;++i)t[i]+=r-16*t[s]*ie[i-(s-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[s]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*ie[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ie[i];for(s=0;s<32;s++)t[s+1]+=t[s]>>8,e[s]=255&t[s]}function ae(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ne(e,r)}function oe(e,r,s,i){var n,a,o=new Uint8Array(64),d=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),h=[t(),t(),t(),t()];K(o,i,32),o[0]&=248,o[31]&=127,o[31]|=64;var l=s+64;for(n=0;n<s;n++)e[64+n]=r[n];for(n=0;n<32;n++)e[32+n]=o[32+n];for(K(c,e.subarray(32),s+32),ae(c),re(h,c),ee(e,h),n=32;n<64;n++)e[n]=i[n];for(K(d,e,s+64),ae(d),n=0;n<64;n++)u[n]=0;for(n=0;n<32;n++)u[n]=c[n];for(n=0;n<32;n++)for(a=0;a<32;a++)u[n+a]+=d[n]*o[a];return ne(e.subarray(32),u),l}function de(e,r,s,i){var n,d=new Uint8Array(32),u=new Uint8Array(64),h=[t(),t(),t(),t()],l=[t(),t(),t(),t()];if(s<64)return-1;if(function(e,r){var s=t(),i=t(),n=t(),d=t(),u=t(),h=t(),l=t();return P(e[2],o),D(e[1],r),M(n,e[1]),V(d,n,c),R(n,n,e[2]),Y(d,e[2],d),M(u,d),M(h,u),V(l,h,u),V(s,l,n),V(s,s,d),F(s,s),V(s,s,n),V(s,s,d),V(s,s,d),V(e[0],s,d),M(i,e[0]),V(i,i,d),U(i,n)&&V(e[0],e[0],p),M(i,e[0]),V(i,i,d),U(i,n)?-1:(N(e[0])===r[31]>>7&&R(e[0],a,e[0]),V(e[3],e[0],e[1]),0)}(l,i))return-1;for(n=0;n<s;n++)e[n]=r[n];for(n=0;n<32;n++)e[n+32]=i[n];if(K(u,e,s),ae(u),te(h,l,u),re(l,r.subarray(32)),Q(h,l),ee(d,h),s-=64,_(r,0,d,0)){for(n=0;n<s;n++)e[n]=0;return-1}for(n=0;n<s;n++)e[n]=r[n+64];return s}var ce,ue=64,he=32,le=64;function pe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function me(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function be(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:y,crypto_stream_xor:x,crypto_stream:E,crypto_stream_salsa20_xor:T,crypto_stream_salsa20:w,crypto_onetimeauth:I,crypto_onetimeauth_verify:C,crypto_verify_16:g,crypto_verify_32:_,crypto_secretbox:B,crypto_secretbox_open:S,crypto_scalarmult:X,crypto_scalarmult_base:L,crypto_box_beforenm:$,crypto_box_afternm:z,crypto_box:function(e,t,r,s,i,n){var a=new Uint8Array(32);return $(a,i,n),z(e,t,r,s,a)},crypto_box_open:function(e,t,r,s,i,n){var a=new Uint8Array(32);return $(a,i,n),q(e,t,r,s,a)},crypto_box_keypair:G,crypto_hash:K,crypto_sign:oe,crypto_sign_keypair:se,crypto_sign_open:de,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:he,crypto_sign_SECRETKEYBYTES:le,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:c,L:ie,pack25519:k,unpack25519:D,M:V,A:Y,S:M,Z:R,pow2523:F,add:Q,set25519:P,modL:ne,scalarmult:te,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return s(t,e),t},e.secretbox=function(e,t,r){me(e,t,r),pe(r,t);for(var s=new Uint8Array(32+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+32]=e[n];return B(i,s,s.length,t,r),i.subarray(16)},e.secretbox.open=function(e,t,r){me(e,t,r),pe(r,t);for(var s=new Uint8Array(16+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+16]=e[n];return s.length<32||0!==S(i,s,s.length,t,r)?null:i.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(me(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var r=new Uint8Array(32);return X(r,e,t),r},e.scalarMult.base=function(e){if(me(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return L(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox(t,r,n)},e.box.before=function(e,t){me(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var r=new Uint8Array(32);return $(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox.open(t,r,n)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return G(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(me(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return L(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(me(e,t),t.length!==le)throw new Error("bad secret key size");var r=new Uint8Array(ue+e.length);return oe(r,e,e.length,t),r},e.sign.open=function(e,t){if(me(e,t),t.length!==he)throw new Error("bad public key size");var r=new Uint8Array(e.length),s=de(r,e,e.length,t);if(s<0)return null;for(var i=new Uint8Array(s),n=0;n<i.length;n++)i[n]=r[n];return i},e.sign.detached=function(t,r){for(var s=e.sign(t,r),i=new Uint8Array(ue),n=0;n<i.length;n++)i[n]=s[n];return i},e.sign.detached.verify=function(e,t,r){if(me(e,t,r),t.length!==ue)throw new Error("bad signature size");if(r.length!==he)throw new Error("bad public key size");var s,i=new Uint8Array(ue+e.length),n=new Uint8Array(ue+e.length);for(s=0;s<ue;s++)i[s]=t[s];for(s=0;s<e.length;s++)i[s+ue]=e[s];return de(n,i,i.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(he),t=new Uint8Array(le);return se(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(me(e),e.length!==le)throw new Error("bad secret key size");for(var t=new Uint8Array(he),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(me(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(he),r=new Uint8Array(le),s=0;s<32;s++)r[s]=e[s];return se(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=he,e.sign.secretKeyLength=le,e.sign.seedLength=32,e.sign.signatureLength=ue,e.hash=function(e){me(e);var t=new Uint8Array(64);return K(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return me(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===b(e,0,t,0,e.length)},e.setPRNG=function(e){s=e},(ce="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&ce.getRandomValues?e.setPRNG((function(e,t){var r,s=new Uint8Array(t);for(r=0;r<t;r+=65536)ce.getRandomValues(s.subarray(r,r+Math.min(t-r,65536)));for(r=0;r<t;r++)e[r]=s[r];be(s)})):(ce=r(211))&&ce.randomBytes&&e.setPRNG((function(e,t){var r,s=ce.randomBytes(t);for(r=0;r<t;r++)e[r]=s[r];be(s)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},725:(e,t,r)=>{const s=r(22);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},763:(e,t,r)=>{const s=r(364);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var i=Object.create(null);a.r(i);var n={};e=e||[null,t({}),t([]),t(t)];for(var o=2&s&&r;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>n[e]=()=>r[e]));return n.default=()=>r,a.d(i,n),i},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".index.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},s="wowok_agent:",a.l=(e,t,i,n)=>{if(r[e])r[e].push(t);else{var o,d;if(void 0!==i)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var h=c[u];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==s+i){o=h;break}}o||(d=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,a.nc&&o.setAttribute("nonce",a.nc),o.setAttribute("data-webpack",s+i),o.src=e),r[e]=[t];var l=(t,s)=>{o.onerror=o.onload=null,clearTimeout(p);var i=r[e];if(delete r[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(s))),t)return t(s)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),d&&document.head.appendChild(o)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var s=r.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=r[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={792:0};a.f.j=(t,r)=>{var s=a.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{var i=new Promise(((r,i)=>s=e[t]=[r,i]));r.push(s[2]=i);var n=a.p+a.u(t),o=new Error;a.l(n,(r=>{if(a.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+i+": "+n+")",o.name="ChunkLoadError",o.type=i,o.request=n,s[1](o)}}),"chunk-"+t,t)}};var t=(t,r)=>{var s,i,[n,o,d]=r,c=0;if(n.some((t=>0!==e[t]))){for(s in o)a.o(o,s)&&(a.m[s]=o[s]);d&&d(a)}for(t&&t(r);c<n.length;c++)i=n[c],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkwowok_agent=this.webpackChunkwowok_agent||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var o={};return(()=>{"use strict";a.r(o),a.d(o,{Account:()=>ac,BCS:()=>Mp,CacheData:()=>Cd,CacheName:()=>Bd,CacheType:()=>kd,CallArbitration:()=>Fp,CallBase:()=>pp,CallDemand:()=>Gp,CallGuard:()=>Wp,CallMachine:()=>$p,CallObjectPermission:()=>Lp,CallPermission:()=>mp,CallPersonal:()=>Qp,CallRepository:()=>zp,CallService:()=>qp,CallTreasury:()=>Xp,EVENT_QUERY:()=>sc,LocalStorageCache:()=>jd,MemeryCache:()=>Pd,OBJECT_KEY:()=>Sd,ResponseData:()=>lp,WOWOK:()=>e,WowokCache:()=>Ad,call_object:()=>em,call_object_json:()=>Zp,data2object:()=>ec,getSuiMoveConfig:()=>Jp,queryTableItem_ArbVote:()=>Fd,queryTableItem_DemandPresenter:()=>Md,queryTableItem_PermissionEntity:()=>Jd,queryTableItem_Personal:()=>Rd,query_objects:()=>Yd,query_objects_json:()=>Ud,query_permission:()=>rc,query_permission_json:()=>tc,query_personal_json:()=>Dd,query_table:()=>Vd,query_table_json:()=>Nd,raw2type:()=>Zd,tableItemQuery_MachineNode:()=>Xd,tableItemQuery_MarkTag:()=>qd,tableItemQuery_ProgressHistory:()=>Gd,tableItemQuery_RepositoryData:()=>zd,tableItemQuery_ServiceSale:()=>Ld,tableItemQuery_TreasuryHistory:()=>$d});var e={};function t(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}a.r(e),a.d(e,{Arbitration:()=>Td,BCS:()=>Oa,Bcs:()=>Wa,BuyRequiredEnum:()=>od,ContextType:()=>Fo,Demand:()=>qo,ENTRYPOINT:()=>Lo,ERROR:()=>Ba,Ed25519Keypair:()=>Zn,Entity:()=>bd,Errors:()=>Ca,FirstLetterUppercase:()=>So,GUARD_QUERIES:()=>ed,Guard:()=>td,GuardMaker:()=>sd,GuardParser:()=>ld,IsNumberType:()=>Jo,IsValidAddress:()=>co,IsValidArgType:()=>_o,IsValidArray:()=>vo,IsValidBigint:()=>ho,IsValidCoinType:()=>uo,IsValidDesription:()=>io,IsValidEndpoint:()=>oo,IsValidGuardIdentifier:()=>rd,IsValidInt:()=>fo,IsValidName:()=>no,IsValidName_AllowEmpty:()=>ao,IsValidOperatorType:()=>Vo,IsValidPercent:()=>yo,IsValidTokenType:()=>go,IsValidU128:()=>mo,IsValidU256:()=>bo,IsValidU64:()=>po,IsValidU8:()=>lo,IsValidValueType:()=>Mo,LogicsInfo:()=>ko,MAX_DESCRIPTION_LENGTH:()=>eo,MAX_ENDPOINT_LENGTH:()=>ro,MAX_NAME_LENGTH:()=>to,MAX_U128:()=>ja,MAX_U256:()=>Aa,MAX_U64:()=>Pa,MAX_U8:()=>Sa,MODULES:()=>jo,Machine:()=>Qo,OPTION_NONE:()=>ka,OperatorType:()=>Ao,OperatorTypeArray:()=>Yo,PAYMENT_MAX_RECEIVER_COUNT:()=>yd,ParseType:()=>xo,Passport:()=>pd,Permission:()=>Ko,PermissionIndex:()=>Wo,PermissionInfo:()=>Ho,Progress:()=>Zo,Protocol:()=>$o,Repository:()=>hd,RepositoryValueType:()=>No,RepositoryValueTypeInfo:()=>Do,Repository_Policy_Mode:()=>id,Repository_Type:()=>nd,ResolveBalance:()=>Eo,ResolveU64:()=>To,Resource:()=>_d,RpcResultParser:()=>zo,SER_VALUE:()=>Xo,Service:()=>md,Service_Discount_Type:()=>ad,SuiClient:()=>ei,TagName:()=>dd,TransactionBlock:()=>_s,Treasury:()=>fd,Treasury_Operation:()=>ud,Treasury_WithdrawMode:()=>cd,ValueType:()=>Uo,ValueTypeArray:()=>Ro,ValueTypeConvert:()=>Ua,Wowok:()=>gd,array_equal:()=>Ga,array_unique:()=>$a,capitalize:()=>za,cb_U128:()=>Ja,cb_U256:()=>Fa,cb_U64:()=>Ma,cb_U8:()=>Va,concatenate:()=>Xa,create_payment:()=>vd,decodeSuiPrivateKey:()=>Un,deepClone:()=>Za,encodeSuiPrivateKey:()=>Nn,fromHEX:()=>ea,getFaucetHost:()=>Id,getSuiMoveConfig:()=>Ia,hasDuplicates:()=>Po,insertAtHead:()=>Oo,isArr:()=>Qa,isValidHttpUrl:()=>Co,normalizeSuiAddress:()=>de,numToUint8Array:()=>Ka,parseObjectType:()=>La,parse_object_type:()=>qa,query_object:()=>Bo,readOption:()=>Na,readOptionString:()=>Da,readVec:()=>Ra,requestSuiFromFaucetV0:()=>xd,requestSuiFromFaucetV1:()=>Od,stringToUint8Array:()=>Ha,toFixed:()=>Io,toHEX:()=>ta,ulebDecode:()=>Ya});const r=8192;function s(e){if(e.length<r)return btoa(String.fromCharCode(...e));let t="";for(var s=0;s<e.length;s+=r){const i=e.slice(s,s+r);t+=String.fromCharCode(...i)}return btoa(t)}const i=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;e[n];){let s=t[e.charCodeAt(n)];if(255===s)return;let i=0;for(let e=d-1;(0!==s||i<o)&&-1!==e;e--,i++)s+=r*c[e]>>>0,c[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw new Error("Non-zero carry");o=i,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let l=a;for(;u!==d;)h[l++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let l=s.repeat(i);for(;h<c;++h)l+=e.charAt(u[h]);return l},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),n=e=>i.encode(e),d=e=>i.decode(e);function c(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function u(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function h(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class l{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class p{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return m(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return m(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return m(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return h(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return n(e);case"base64":return s(e);case"hex":return u(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function m(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var b,g,_,f,y=e=>{throw TypeError(e)},v=(e,t,r)=>t.has(e)||y("Cannot "+r),T=(e,t,r)=>(v(e,t,"read from private field"),r?r.call(e):t.get(e)),w=(e,t,r)=>t.has(e)?y("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),E=(e,t,r,s)=>(v(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);b=new WeakMap,g=new WeakMap;let x=class e{constructor(e){w(this,b),w(this,g),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),E(this,b,e.write),E(this,g,e.serialize??((e,t)=>{const r=new p({initialSize:this.serializedSize(e)??void 0,...t});return T(this,b).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),T(this,b).call(this,e,t)}serialize(e,t){return this.validate(e),new C(this,T(this,g).call(this,e,t))}parse(e){const t=new l(e);return this.read(t)}fromHex(e){return this.parse(c(e))}fromBase58(e){return this.parse(d(e))}fromBase64(e){return this.parse(t(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>T(this,b).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>T(this,g).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const O=Symbol.for("@mysten/serialized-bcs");function I(e){return!!e&&"object"==typeof e&&!0===e[O]}class C{constructor(e,t){w(this,_),w(this,f),E(this,_,e),E(this,f,t)}get[O](){return!0}toBytes(){return T(this,f)}toHex(){return u(T(this,f))}toBase64(){return s(T(this,f))}toBase58(){return n(T(this,f))}parse(){return T(this,_).parse(T(this,f))}}function B({size:e,...t}){return new x({...t,serializedSize:()=>e})}function S({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function P({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function j(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function A(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??j(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function k(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}_=new WeakMap,f=new WeakMap;var U=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function N(e,t){return{kind:"validation",type:"check",reference:N,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"input",e,t),e}}}function D(e){return{kind:"validation",type:"integer",reference:D,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"integer",e,t),e}}}function Y(e){return{kind:"transformation",type:"transform",reference:Y,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function R(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function V(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function M(e,t){return{kind:"schema",type:"array",reference:M,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function J(e){return{kind:"schema",type:"bigint",reference:J,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function F(e){return{kind:"schema",type:"boolean",reference:F,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function X(e){return{kind:"schema",type:"lazy",reference:X,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function L(e,t){return{kind:"schema",type:"literal",reference:L,expects:j(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:A(this,"type",e,t),e}}}function G(e,...t){const r={kind:"schema",type:"nullable",reference:G,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=R(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function $(e,...t){const r={kind:"schema",type:"nullish",reference:$,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=R(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function z(e){return{kind:"schema",type:"number",reference:z,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?A(this,"type",e,t):e.typed=!0,e}}}function q(e,t){return{kind:"schema",type:"object",reference:q,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else A(this,"type",e,t);return e}}}function W(e,...t){const r={kind:"schema",type:"optional",reference:W,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=R(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function H(e,t,r){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(k(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else A(this,"type",e,t);return e}}}function K(e){return{kind:"schema",type:"string",reference:K,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function Q(e,t){return{kind:"schema",type:"tuple",reference:Q,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function Z(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ee(e,t){return{kind:"schema",type:"union",reference:ee,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];A(this,"type",e,t,{issues:Z(s)}),e.typed=!0}else{if(1===i?.length)return i[0];A(this,"type",e,t,{issues:Z(i)})}return e}}}function te(){return{kind:"schema",type:"unknown",reference:te,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function re(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new U(s.issues);return s.value}function se(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function ie(e){try{return 32===d(e).length}catch(e){return!1}}const ne=32;function ae(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)===ne}function oe(e){return ae(e)}function de(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(2*ne,"0")}`}function ce(e,t=!1){return de(e,t)}function ue(e){return se(ee(Object.entries(e).map((([e,t])=>q({[e]:t})))),Y((e=>({...e,$kind:Object.keys(e)[0]}))))}const he=se(K(),Y((e=>de(e))),N(ae)),le=he,pe=K(),me=se(ee([K(),se(z(),D())]),N((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),be=q({objectId:he,version:me,digest:K()}),ge=se(ee([q({GasCoin:L(!0)}),q({Input:se(z(),D()),type:W(L("pure"))}),q({Input:se(z(),D()),type:W(L("object"))}),q({Result:se(z(),D())}),q({NestedResult:Q([se(z(),D()),se(z(),D())])})]),Y((e=>({...e,$kind:Object.keys(e)[0]})))),_e=q({budget:G(me),price:G(me),owner:G(he),payment:G(M(be))}),fe=(q({address:K(),module:K(),name:K(),typeParams:M(K())}),ee([L("address"),L("bool"),L("u8"),L("u16"),L("u32"),L("u64"),L("u128"),L("u256"),q({vector:X((()=>fe))}),q({datatype:q({package:K(),module:K(),type:K(),typeParameters:M(X((()=>fe)))})}),q({typeParameter:se(z(),D())})])),ye=q({ref:G(ee([L("&"),L("&mut")])),body:fe}),ve=q({package:le,module:K(),function:K(),typeArguments:M(K()),arguments:M(ge),_argumentTypes:W(G(M(ye)))}),Te=q({name:K(),inputs:H(K(),ee([ge,M(ge)])),data:H(K(),te())}),we=ue({MoveCall:ve,TransferObjects:q({objects:M(ge),address:ge}),SplitCoins:q({coin:ge,amounts:M(ge)}),MergeCoins:q({destination:ge,sources:M(ge)}),Publish:q({modules:M(pe),dependencies:M(le)}),MakeMoveVec:q({type:G(K()),elements:M(ge)}),Upgrade:q({modules:M(pe),dependencies:M(le),package:le,ticket:ge}),$Intent:Te}),Ee=ue({ImmOrOwnedObject:be,SharedObject:q({objectId:le,initialSharedVersion:me,mutable:F()}),Receiving:be}),xe=ue({Object:Ee,Pure:q({bytes:pe}),UnresolvedPure:q({value:te()}),UnresolvedObject:q({objectId:le,version:W(G(me)),digest:W(G(K())),initialSharedVersion:W(G(me))})}),Oe=ue({Object:Ee,Pure:q({bytes:pe})}),Ie=ue({None:L(!0),Epoch:me}),Ce=q({version:L(2),sender:$(he),expiration:$(Ie),gasData:_e,inputs:M(xe),commands:M(we)}),Be={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>re(ge,e))),address:re(ge,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:re(ge,e),amounts:t.map((e=>re(ge,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:re(ge,e),sources:t.map((e=>re(ge,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:i})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e))),package:r,ticket:re(ge,i)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>re(ge,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>re(ge,e))):re(ge,t)]))),data:r}})},Se=/^vector<(.+)>$/,Pe=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class je{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(Se);if(r)return{vector:je.parseFromStr(r[1],t)};const s=e.match(Pe);if(s)return{struct:{address:t?de(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:je.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>je.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${je.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(je.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Ae=q({digest:K(),objectId:K(),version:ee([se(z(),D()),K(),J()])}),ke=ue({ImmOrOwned:Ae,Shared:q({objectId:le,initialSharedVersion:me,mutable:F()}),Receiving:Ae}),Ue=ue({Object:ke,Pure:M(se(z(),D()))}),Ne=ee([q({kind:L("Input"),index:se(z(),D()),value:te(),type:W(L("object"))}),q({kind:L("Input"),index:se(z(),D()),value:te(),type:L("pure")})]),De=ee([q({Epoch:se(z(),D())}),q({None:G(L(!0))})]),Ye=se(ee([z(),K(),J()]),N((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Re=ee([q({bool:G(L(!0))}),q({u8:G(L(!0))}),q({u64:G(L(!0))}),q({u128:G(L(!0))}),q({address:G(L(!0))}),q({signer:G(L(!0))}),q({vector:X((()=>Re))}),q({struct:X((()=>Ve))}),q({u16:G(L(!0))}),q({u32:G(L(!0))}),q({u256:G(L(!0))})]),Ve=q({address:K(),module:K(),name:K(),typeParams:M(Re)}),Me=q({budget:W(Ye),price:W(Ye),payment:W(M(Ae)),owner:W(K())}),Je=ee([Ne,q({kind:L("GasCoin")}),q({kind:L("Result"),index:se(z(),D())}),q({kind:L("NestedResult"),index:se(z(),D()),resultIndex:se(z(),D())})]),Fe=q({kind:L("MoveCall"),target:se(K(),N((e=>3===e.split("::").length))),typeArguments:M(K()),arguments:M(Je)}),Xe=q({kind:L("TransferObjects"),objects:M(Je),address:Je}),Le=q({kind:L("SplitCoins"),coin:Je,amounts:M(Je)}),Ge=q({kind:L("MergeCoins"),destination:Je,sources:M(Je)}),$e=q({kind:L("MakeMoveVec"),type:ee([q({Some:Re}),q({None:G(L(!0))})]),objects:M(Je)}),ze=ee([Fe,Xe,Le,Ge,q({kind:L("Publish"),modules:M(M(se(z(),D()))),dependencies:M(K())}),q({kind:L("Upgrade"),modules:M(M(se(z(),D()))),dependencies:M(K()),packageId:K(),ticket:Je}),$e]);function qe(e){const r=e.inputs.map(((e,r)=>{if(e.Object)return{kind:"Input",index:r,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:r,value:{Pure:Array.from(t(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:r,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:r,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:r,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:je.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>We(e,r)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:We(e.MergeCoins.destination,r),sources:e.MergeCoins.sources.map((e=>We(e,r)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>We(e,r)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(t(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:We(e.SplitCoins.coin,r),amounts:e.SplitCoins.amounts.map((e=>We(e,r)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>We(e,r))),address:We(e.TransferObjects.address,r)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(t(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:We(e.Upgrade.ticket,r)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function We(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function He(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Ke(e){return ee(Object.entries(e).map((([e,t])=>q({[e]:t}))))}q({version:L(1),sender:W(K()),expiration:$(De),gasConfig:Me,inputs:M(Ne),transactions:M(ze)});const Qe=Ke({GasCoin:L(!0),Input:se(z(),D()),Result:se(z(),D()),NestedResult:Q([se(z(),D()),se(z(),D())])}),Ze=q({budget:G(me),price:G(me),owner:G(he),payment:G(M(be))}),et=q({package:le,module:K(),function:K(),typeArguments:M(K()),arguments:M(Qe)}),tt=q({name:K(),inputs:H(K(),ee([Qe,M(Qe)])),data:H(K(),te())}),rt=Ke({MoveCall:et,TransferObjects:q({objects:M(Qe),address:Qe}),SplitCoins:q({coin:Qe,amounts:M(Qe)}),MergeCoins:q({destination:Qe,sources:M(Qe)}),Publish:q({modules:M(pe),dependencies:M(le)}),MakeMoveVec:q({type:G(K()),elements:M(Qe)}),Upgrade:q({modules:M(pe),dependencies:M(le),package:le,ticket:Qe}),$Intent:tt}),st=Ke({ImmOrOwnedObject:be,SharedObject:q({objectId:le,initialSharedVersion:me,mutable:F()}),Receiving:be}),it=Ke({Object:st,Pure:q({bytes:pe}),UnresolvedPure:q({value:te()}),UnresolvedObject:q({objectId:le,version:W(G(me)),digest:W(G(K())),initialSharedVersion:W(G(me))})}),nt=Ke({None:L(!0),Epoch:me}),at=q({version:L(2),sender:$(he),expiration:$(nt),gasData:Ze,inputs:M(it),commands:M(rt)}),ot=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?s(e):e.toBase64()}}},dt=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:de(e)}}}),ct=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:de(e)}}}),ut=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:de(e)}}}),ht={u8:e=>S({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>S({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>S({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>P({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>P({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>P({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>B({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new x({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(h(e)),...e}),bytes:(e,t)=>B({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new x({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=h(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new x({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>ht.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new x({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new x({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new x({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new x({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>ht.vector(ht.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new x({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},lt=ht.bytes(ne).transform({validate:e=>{const t="string"==typeof e?e:u(e);if(!t||!ae(de(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?c(de(e)):e,output:e=>de(u(e))}),pt=ht.vector(ht.u8()).transform({name:"ObjectDigest",input:e=>d(e),output:e=>n(new Uint8Array(e)),validate:e=>{if(32!==d(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),mt=ht.struct("SuiObjectRef",{objectId:lt,version:ht.u64(),digest:pt}),bt=ht.struct("SharedObjectRef",{objectId:lt,initialSharedVersion:ht.u64(),mutable:ht.bool()}),gt=ht.enum("ObjectArg",{ImmOrOwnedObject:mt,SharedObject:bt,Receiving:mt}),_t=ht.enum("CallArg",{Pure:ht.struct("Pure",{bytes:ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})}),Object:gt}),ft=ht.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:ht.lazy((()=>ft)),struct:ht.lazy((()=>It)),u16:null,u32:null,u256:null}),yt=ft.transform({input:e=>"string"==typeof e?je.parseFromStr(e,!0):e,output:e=>je.tagToString(e)}),vt=ht.enum("Argument",{GasCoin:null,Input:ht.u16(),Result:ht.u16(),NestedResult:ht.tuple([ht.u16(),ht.u16()])}),Tt=ht.struct("ProgrammableMoveCall",{package:lt,module:ht.string(),function:ht.string(),typeArguments:ht.vector(yt),arguments:ht.vector(vt)}),wt=ht.enum("Command",{MoveCall:Tt,TransferObjects:ht.struct("TransferObjects",{objects:ht.vector(vt),address:vt}),SplitCoins:ht.struct("SplitCoins",{coin:vt,amounts:ht.vector(vt)}),MergeCoins:ht.struct("MergeCoins",{destination:vt,sources:ht.vector(vt)}),Publish:ht.struct("Publish",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(lt)}),MakeMoveVec:ht.struct("MakeMoveVec",{type:function(e){return ht.enum("Option",{None:null,Some:e})}(yt).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:ht.vector(vt)}),Upgrade:ht.struct("Upgrade",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(lt),package:lt,ticket:vt})}),Et=ht.struct("ProgrammableTransaction",{inputs:ht.vector(_t),commands:ht.vector(wt)}),xt=ht.enum("TransactionKind",{ProgrammableTransaction:Et,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ot=ht.enum("TransactionExpiration",{None:null,Epoch:ht.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})});const It=ht.struct("StructTag",{address:lt,module:ht.string(),name:ht.string(),typeParams:ht.vector(ft)}),Ct=ht.struct("GasData",{payment:ht.vector(mt),owner:lt,price:ht.u64(),budget:ht.u64()}),Bt=ht.struct("TransactionDataV1",{kind:xt,sender:lt,gasData:Ct,expiration:Ot}),St=ht.enum("TransactionData",{V1:Bt}),Pt=ht.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),jt=ht.enum("IntentVersion",{V0:null}),At=ht.enum("AppId",{Sui:null}),kt=ht.struct("Intent",{scope:Pt,version:jt,appId:At});function Ut(e){return ht.struct(`IntentMessage<${e.name}>`,{intent:kt,value:e})}const Nt=ht.enum("CompressedSignature",{ED25519:ht.fixedArray(64,ht.u8()),Secp256k1:ht.fixedArray(64,ht.u8()),Secp256r1:ht.fixedArray(64,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Dt=ht.enum("PublicKey",{ED25519:ht.fixedArray(32,ht.u8()),Secp256k1:ht.fixedArray(33,ht.u8()),Secp256r1:ht.fixedArray(33,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Yt=ht.struct("MultiSigPkMap",{pubKey:Dt,weight:ht.u8()}),Rt=ht.struct("MultiSigPublicKey",{pk_map:ht.vector(Yt),threshold:ht.u16()}),Vt=ht.struct("MultiSig",{sigs:ht.vector(Nt),bitmap:ht.u16(),multisig_pk:Rt}),Mt=ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))}),Jt=ht.struct("SenderSignedTransaction",{intentMessage:Ut(St),txSignatures:ht.vector(Mt)}),Ft=ht.vector(Jt,{name:"SenderSignedData"}),Xt=ht.enum("PackageUpgradeError",{UnableToFetchPackage:ht.struct("UnableToFetchPackage",{packageId:lt}),NotAPackage:ht.struct("NotAPackage",{objectId:lt}),IncompatibleUpgrade:null,DigestDoesNotMatch:ht.struct("DigestDoesNotMatch",{digest:ht.vector(ht.u8())}),UnknownUpgradePolicy:ht.struct("UnknownUpgradePolicy",{policy:ht.u8()}),PackageIDDoesNotMatch:ht.struct("PackageIDDoesNotMatch",{packageId:lt,ticketId:lt})}),Lt=ht.struct("ModuleId",{address:lt,name:ht.string()}),Gt=ht.struct("MoveLocation",{module:Lt,function:ht.u16(),instruction:ht.u16(),functionName:ht.option(ht.string())}),$t=ht.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:ht.struct("IndexOutOfBounds",{idx:ht.u16()}),SecondaryIndexOutOfBounds:ht.struct("SecondaryIndexOutOfBounds",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidResultArity:ht.struct("InvalidResultArity",{resultIdx:ht.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),zt=ht.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),qt=ht.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:ht.struct("MoveObjectTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),MovePackageTooBig:ht.struct("MovePackageTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),CircularObjectOwnership:ht.struct("CircularObjectOwnership",{object:lt}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:ht.option(Gt),MoveAbort:ht.tuple([Gt,ht.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:ht.struct("CommandArgumentError",{argIdx:ht.u16(),kind:$t}),TypeArgumentError:ht.struct("TypeArgumentError",{argumentIdx:ht.u16(),kind:zt}),UnusedValueWithoutDrop:ht.struct("UnusedValueWithoutDrop",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidPublicFunctionReturnType:ht.struct("InvalidPublicFunctionReturnType",{idx:ht.u16()}),InvalidTransferObject:null,EffectsTooLarge:ht.struct("EffectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:ht.struct("PackageUpgradeError",{upgradeError:Xt}),WrittenObjectsTooLarge:ht.struct("WrittenObjectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Wt=ht.enum("ExecutionStatus",{Success:null,Failed:ht.struct("ExecutionFailed",{error:qt,command:ht.option(ht.u64())})}),Ht=ht.struct("GasCostSummary",{computationCost:ht.u64(),storageCost:ht.u64(),storageRebate:ht.u64(),nonRefundableStorageFee:ht.u64()}),Kt=ht.enum("Owner",{AddressOwner:lt,ObjectOwner:lt,Shared:ht.struct("Shared",{initialSharedVersion:ht.u64()}),Immutable:null}),Qt=ht.struct("TransactionEffectsV1",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,modifiedAtVersions:ht.vector(ht.tuple([lt,ht.u64()])),sharedObjects:ht.vector(mt),transactionDigest:pt,created:ht.vector(ht.tuple([mt,Kt])),mutated:ht.vector(ht.tuple([mt,Kt])),unwrapped:ht.vector(ht.tuple([mt,Kt])),deleted:ht.vector(mt),unwrappedThenDeleted:ht.vector(mt),wrapped:ht.vector(mt),gasObject:ht.tuple([mt,Kt]),eventsDigest:ht.option(pt),dependencies:ht.vector(pt)}),Zt=ht.tuple([ht.u64(),pt]),er=ht.enum("ObjectIn",{NotExist:null,Exist:ht.tuple([Zt,Kt])}),tr=ht.enum("ObjectOut",{NotExist:null,ObjectWrite:ht.tuple([pt,Kt]),PackageWrite:Zt}),rr=ht.enum("IDOperation",{None:null,Created:null,Deleted:null}),sr=ht.struct("EffectsObjectChange",{inputState:er,outputState:tr,idOperation:rr}),ir=ht.enum("UnchangedSharedKind",{ReadOnlyRoot:Zt,MutateDeleted:ht.u64(),ReadDeleted:ht.u64(),Cancelled:ht.u64(),PerEpochConfig:null}),nr=ht.struct("TransactionEffectsV2",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,transactionDigest:pt,gasObjectIndex:ht.option(ht.u32()),eventsDigest:ht.option(pt),dependencies:ht.vector(pt),lamportVersion:ht.u64(),changedObjects:ht.vector(ht.tuple([lt,sr])),unchangedSharedObjects:ht.vector(ht.tuple([lt,ir])),auxDataDigest:ht.option(pt)}),ar=ht.enum("TransactionEffects",{V1:Qt,V2:nr}),or={...ht,U8:ht.u8(),U16:ht.u16(),U32:ht.u32(),U64:ht.u64(),U128:ht.u128(),U256:ht.u256(),ULEB128:ht.uleb128(),Bool:ht.bool(),String:ht.string(),Address:lt,AppId:At,Argument:vt,CallArg:_t,CompressedSignature:Nt,GasData:Ct,Intent:kt,IntentMessage:Ut,IntentScope:Pt,IntentVersion:jt,MultiSig:Vt,MultiSigPkMap:Yt,MultiSigPublicKey:Rt,ObjectArg:gt,ObjectDigest:pt,ProgrammableMoveCall:Tt,ProgrammableTransaction:Et,PublicKey:Dt,SenderSignedData:Ft,SenderSignedTransaction:Jt,SharedObjectRef:bt,StructTag:It,SuiObjectRef:mt,Command:wt,TransactionData:St,TransactionDataV1:Bt,TransactionExpiration:Ot,TransactionKind:xt,TypeTag:yt,TransactionEffects:ar},dr=(BigInt(1e9),ce("0x6"),"0x2::sui::SUI");function cr(e){if("string"==typeof e)switch(e){case"address":return or.Address;case"bool":return or.Bool;case"u8":return or.U8;case"u16":return or.U16;case"u32":return or.U32;case"u64":return or.U64;case"u128":return or.U128;case"u256":return or.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return or.vector(or.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=cr(e.vector);return t?or.vector(t):null}if("datatype"in e){const t=de(e.datatype.package);if(t===de("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=cr(e.datatype.typeParameters[0]);return t?or.vector(t):null}}if(t===de("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return or.Address}return null}function ur(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:ur(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(ur)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}ce("0x5");async function hr(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{lr(t,or.U64,e)}));break;case"TransferObjects":lr(t.TransferObjects.address,or.Address,e)}}));const a=new Map;if(n.size>0){const e=br(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:ur(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:ur(e.MutableReference)}:{ref:null,body:ur(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&de(t.package)===de("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=cr(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=ot(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>ce(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>br(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=de(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=ct({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:pr(e,t)}):mr(e,t)&&(s=ut({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??dt({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await br(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await br(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await br(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:dr})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>re(be,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function lr(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=ot(t.serialize(s.UnresolvedPure.value)))}function pr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function mr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function br(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function gr(e){function t(t,r){if("string"==typeof t)return e(_r(t).serialize(r));if(t instanceof Uint8Array||I(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(or.U8.serialize(t)),t.u16=t=>e(or.U16.serialize(t)),t.u32=t=>e(or.U32.serialize(t)),t.u64=t=>e(or.U64.serialize(t)),t.u128=t=>e(or.U128.serialize(t)),t.u256=t=>e(or.U256.serialize(t)),t.bool=t=>e(or.Bool.serialize(t)),t.string=t=>e(or.String.serialize(t)),t.address=t=>e(or.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(or.vector(_r(t)).serialize(r)),t.option=(t,r)=>e(or.option(_r(t)).serialize(r)),t}function _r(e){switch(e){case"u8":return or.u8();case"u16":return or.u16();case"u32":return or.u32();case"u64":return or.u64();case"u128":return or.u128();case"u256":return or.u256();case"bool":return or.bool();case"string":return or.string();case"id":case"address":return or.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?or.vector(_r(r)):or.option(_r(r))}throw new Error(`Invalid Pure type name: ${e}`)}function fr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function yr(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function vr(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");fr(e.outputLen),fr(e.blockLen)}function Tr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wr(e,t){yr(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Er(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function xr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Or=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Ir(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Cr=Or?e=>e:e=>Ir(e);function Br(e){for(let t=0;t<e.length;t++)e[t]=Ir(e[t])}const Sr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Pr(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function jr(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),yr(e),e}class Ar{clone(){return this._cloneInto()}}function kr(e){const t=t=>e().update(jr(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ur(e){const t=(t,r)=>e(r).update(jr(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const Nr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Dr extends Ar{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,fr(e),fr(t),fr(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=Er(this.buffer)}update(e){Tr(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=jr(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Or||Br(s),this.compress(s,0,!1),Or||Br(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Or||Br(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Or||Br(e)}}return this}digestInto(e){Tr(this),wr(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Or||Br(r),this.compress(r,0,!0),Or||Br(r);const s=Er(e);this.get().forEach(((e,t)=>s[t]=Cr(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Yr=BigInt(2**32-1),Rr=BigInt(32);function Vr(e,t=!1){return t?{h:Number(e&Yr),l:Number(e>>Rr&Yr)}:{h:0|Number(e>>Rr&Yr),l:0|Number(e&Yr)}}const Mr={fromBig:Vr,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Vr(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Rr|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Jr=Mr,Fr=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Xr=new Uint32Array(32);function Lr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],l=Xr[2*r],p=Xr[2*r+1],m=Xr[2*s],b=Xr[2*s+1],g=Jr.add3L(d,u,a);c=Jr.add3H(g,c,h,o),d=0|g,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Jr.rotr32H(b,m),Dl:Jr.rotr32L(b,m)}),({h:p,l}=Jr.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Jr.rotrSH(h,u,24),Bl:Jr.rotrSL(h,u,24)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=l,Xr[2*r+1]=p,Xr[2*s]=m,Xr[2*s+1]=b}function Gr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],l=Xr[2*r],p=Xr[2*r+1],m=Xr[2*s],b=Xr[2*s+1],g=Jr.add3L(d,u,a);c=Jr.add3H(g,c,h,o),d=0|g,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Jr.rotrSH(b,m,16),Dl:Jr.rotrSL(b,m,16)}),({h:p,l}=Jr.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Jr.rotrBH(h,u,63),Bl:Jr.rotrBL(h,u,63)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=l,Xr[2*r+1]=p,Xr[2*s]=m,Xr[2*s+1]=b}class $r extends Dr{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Fr[0],this.v0h=0|Fr[1],this.v1l=0|Fr[2],this.v1h=0|Fr[3],this.v2l=0|Fr[4],this.v2h=0|Fr[5],this.v3l=0|Fr[6],this.v3h=0|Fr[7],this.v4l=0|Fr[8],this.v4h=0|Fr[9],this.v5l=0|Fr[10],this.v5h=0|Fr[11],this.v6l=0|Fr[12],this.v6h=0|Fr[13],this.v7l=0|Fr[14],this.v7h=0|Fr[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=Er(jr(e.salt));this.v4l^=Cr(t[0]),this.v4h^=Cr(t[1]),this.v5l^=Cr(t[2]),this.v5h^=Cr(t[3])}if(e.personalization){const t=Er(jr(e.personalization));this.v6l^=Cr(t[0]),this.v6h^=Cr(t[1]),this.v7l^=Cr(t[2]),this.v7h^=Cr(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(jr(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:l,v6h:p,v7l:m,v7h:b}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b]}set(e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|l,this.v6h=0|p,this.v7l=0|m,this.v7h=0|b}compress(e,t,r){this.get().forEach(((e,t)=>Xr[t]=e)),Xr.set(Fr,16);let{h:s,l:i}=Jr.fromBig(BigInt(this.length));Xr[24]=Fr[8]^i,Xr[25]=Fr[9]^s,r&&(Xr[28]=~Xr[28],Xr[29]=~Xr[29]);let n=0;const a=Nr;for(let r=0;r<12;r++)Lr(0,4,8,12,e,t+2*a[n++]),Gr(0,4,8,12,e,t+2*a[n++]),Lr(1,5,9,13,e,t+2*a[n++]),Gr(1,5,9,13,e,t+2*a[n++]),Lr(2,6,10,14,e,t+2*a[n++]),Gr(2,6,10,14,e,t+2*a[n++]),Lr(3,7,11,15,e,t+2*a[n++]),Gr(3,7,11,15,e,t+2*a[n++]),Lr(0,5,10,15,e,t+2*a[n++]),Gr(0,5,10,15,e,t+2*a[n++]),Lr(1,6,11,12,e,t+2*a[n++]),Gr(1,6,11,12,e,t+2*a[n++]),Lr(2,7,8,13,e,t+2*a[n++]),Gr(2,7,8,13,e,t+2*a[n++]),Lr(3,4,9,14,e,t+2*a[n++]),Gr(3,4,9,14,e,t+2*a[n++]);this.v0l^=Xr[0]^Xr[16],this.v0h^=Xr[1]^Xr[17],this.v1l^=Xr[2]^Xr[18],this.v1h^=Xr[3]^Xr[19],this.v2l^=Xr[4]^Xr[20],this.v2h^=Xr[5]^Xr[21],this.v3l^=Xr[6]^Xr[22],this.v3h^=Xr[7]^Xr[23],this.v4l^=Xr[8]^Xr[24],this.v4h^=Xr[9]^Xr[25],this.v5l^=Xr[10]^Xr[26],this.v5h^=Xr[11]^Xr[27],this.v6l^=Xr[12]^Xr[28],this.v6h^=Xr[13]^Xr[29],this.v7l^=Xr[14]^Xr[30],this.v7h^=Xr[15]^Xr[31],Xr.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const zr=Ur((e=>new $r(e)));function qr(e){return de(e).replace("0x","")}class Wr{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=or.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=or.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new Wr(re(Ce,e)):new Wr(re(Ce,function(e){return re(Ce,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(V(Ue,e.value)){const t=re(Ue,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:s(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?je.tagToString(e.type.Some):null,elements:e.objects.map((e=>He(e)))}};case"MergeCoins":return{MergeCoins:{destination:He(e.destination),sources:e.sources.map((e=>He(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>He(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:He(e.coin),amounts:e.amounts.map((e=>He(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>He(e))),address:He(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:He(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),zr(s,{dkLen:32})}(0,e);return n(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return or.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:qr(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:qr(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return or.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return Wr.getDigestFromBytes(e)}snapshot(){return re(Ce,this)}}function Hr(e){return"string"==typeof e?de(e):e.Object?e.Object.ImmOrOwnedObject?de(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?de(e.Object.Receiving.objectId):de(e.Object.SharedObject.objectId):e.UnresolvedObject?de(e.UnresolvedObject.objectId):void 0}var Kr,Qr,Zr,es,ts,rs,ss,is,ns,as=e=>{throw TypeError(e)},os=(e,t,r)=>t.has(e)||as("Cannot "+r),ds=(e,t,r)=>(os(e,t,"read from private field"),r?r.call(e):t.get(e)),cs=(e,t,r)=>t.has(e)?as("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),us=(e,t,r,s)=>(os(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),hs=(e,t,r)=>(os(e,t,"access private method"),r);const ls=Symbol.for("@mysten/transaction");function ps(e){return!!e&&"object"==typeof e&&!0===e[ls]}const ms={buildPlugins:[],serializationPlugins:[]},bs=Symbol.for("@mysten/transaction/registry");function gs(){try{const e=globalThis;return e[bs]||(e[bs]=ms),e[bs]}catch(e){return ms}}Kr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,es=new WeakMap,ts=new WeakSet,rs=function(e){return I(e)?this.pure(e):hs(this,ts,ss).call(this,e)},ss=function(e){return re(ge,"function"==typeof e?e(this):e)},is=async function(e){if(!e.onlyTransactionKind&&!ds(this,es).sender)throw new Error("Missing transaction sender");await hs(this,ts,ns).call(this,[...ds(this,Qr),hr],e)},ns=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(ds(this,es),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let _s=class e{constructor(){cs(this,ts),cs(this,Kr),cs(this,Qr),cs(this,Zr,new Map),cs(this,es),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&V(ge,e))return e;const t=Hr(e),r=ds(this,es).inputs.find((e=>t===Hr(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:ds(this,es).inputs.indexOf(r),type:"object"}:ds(this,es).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:de(e)}}:e)}));const e=gs();us(this,es,new Wr),us(this,Qr,[...e.buildPlugins]),us(this,Kr,[...e.serializationPlugins])}static fromKind(r){const s=new e;return us(s,es,Wr.fromKindBytes("string"==typeof r?t(r):r)),s}static from(r){const s=new e;return ps(r)?us(s,es,new Wr(r.getData())):"string"==typeof r&&r.startsWith("{")?us(s,es,Wr.restore(JSON.parse(r))):us(s,es,Wr.fromBytes("string"==typeof r?t(r):r)),s}static registerGlobalSerializationPlugin(e){gs().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){gs().buildPlugins.push(e)}addSerializationPlugin(e){ds(this,Kr).push(e)}addBuildPlugin(e){ds(this,Qr).push(e)}addIntentResolver(e,t){if(ds(this,Zr).has(e)&&ds(this,Zr).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);ds(this,Zr).set(e,t)}setSender(e){ds(this,es).sender=e}setSenderIfNotSet(e){ds(this,es).sender||(ds(this,es).sender=e)}setExpiration(e){ds(this,es).expiration=e?re(Ie,e):null}setGasPrice(e){ds(this,es).gasConfig.price=String(e)}setGasBudget(e){ds(this,es).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==ds(this,es).gasData.budget&&(ds(this,es).gasConfig.budget=String(e))}setGasOwner(e){ds(this,es).gasConfig.owner=e}setGasPayment(e){ds(this,es).gasConfig.payment=e.map((e=>re(be,e)))}get blockData(){return qe(ds(this,es).snapshot())}getData(){return ds(this,es).snapshot()}get[ls](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:gr((e=>I(e)?ds(this,es).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):ds(this,es).addInput("pure",V(Oe,e)?re(Oe,e):e instanceof Uint8Array?ot(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(dt(...e))}receivingRef(...e){return this.object(ut(...e))}sharedObjectRef(...e){return this.object(ct(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(ds(this,es).commands.push(e)-1)}splitCoins(e,t){return this.add(Be.SplitCoins("string"==typeof e?this.object(e):hs(this,ts,ss).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):hs(this,ts,rs).call(this,e)))))}mergeCoins(e,t){return this.add(Be.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Be.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Be.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Be.MoveCall({...t,arguments:e?.map((e=>hs(this,ts,rs).call(this,e)))}))}transferObjects(e,t){return this.add(Be.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):hs(this,ts,rs).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Be.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(qe(ds(this,es).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(re(at,ds(this,es).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await hs(this,ts,is).call(this,e),ds(this,es).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await hs(this,ts,is).call(this,e),ds(this,es).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of ds(this,es).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...ds(this,Kr)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!ds(this,Zr).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(ds(this,Zr).get(s))}await hs(this,ts,ns).call(this,r,e)}};const fs=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,ys=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,vs={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class Ts extends Error{}class ws extends Ts{constructor(e,t){super(e),this.code=t,this.type=vs[t]??"ServerError"}}class Es extends Ts{constructor(e,t,r){super(e),this.status=t,this.statusText=r}}var xs,Os,Is,Cs,Bs,Ss,Ps,js,As,ks=e=>{throw TypeError(e)},Us=(e,t,r)=>t.has(e)||ks("Cannot "+r),Ns=(e,t,r)=>(Us(e,t,"read from private field"),r?r.call(e):t.get(e)),Ds=(e,t,r)=>t.has(e)?ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ys=(e,t,r,s)=>(Us(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),Rs=(e,t,r)=>(Us(e,t,"access private method"),r);const Vs={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Ms{constructor(e,t={}){if(Ds(this,Ps),Ds(this,xs,0),Ds(this,Os,0),Ds(this,Is,null),Ds(this,Cs,null),Ds(this,Bs,new Set),Ds(this,Ss,new Map),this.endpoint=e,this.options={...Vs,...t},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}(this.endpoint))}async makeRequest(e,t){const r=await Rs(this,Ps,js).call(this);return new Promise(((s,i)=>{Ys(this,xs,Ns(this,xs)+1),Ns(this,Ss).set(Ns(this,xs),{resolve:s,reject:i,timeout:setTimeout((()=>{Ns(this,Ss).delete(Ns(this,xs)),i(new Error(`Request timeout: ${e}`))}),this.options.callTimeout)}),r.send(JSON.stringify({jsonrpc:"2.0",id:Ns(this,xs),method:e,params:t}))})).then((({error:e,result:t})=>{if(e)throw new ws(e.message,e.code);return t}))}async subscribe(e){const t=new Js(e);return Ns(this,Bs).add(t),await t.subscribe(this),()=>t.unsubscribe(this)}}xs=new WeakMap,Os=new WeakMap,Is=new WeakMap,Cs=new WeakMap,Bs=new WeakMap,Ss=new WeakMap,Ps=new WeakSet,js=function(){return Ns(this,Cs)||Ys(this,Cs,new Promise((e=>{Ns(this,Is)?.close(),Ys(this,Is,new this.options.WebSocketConstructor(this.endpoint)),Ns(this,Is).addEventListener("open",(()=>{Ys(this,Os,0),e(Ns(this,Is))})),Ns(this,Is).addEventListener("close",(()=>{var e,t;(e=this,t=Os,{set _(r){Ys(e,t,r,undefined)},get _(){return Ns(e,t,undefined)}})._++,Ns(this,Os)<=this.options.maxReconnects&&setTimeout((()=>{Rs(this,Ps,As).call(this)}),this.options.reconnectTimeout)})),Ns(this,Is).addEventListener("message",(({data:e})=>{let t;try{t=JSON.parse(e)}catch(t){return void console.error(new Error(`Failed to parse RPC message: ${e}`,{cause:t}))}if("id"in t&&null!=t.id&&Ns(this,Ss).has(t.id)){const{resolve:e,timeout:r}=Ns(this,Ss).get(t.id);clearTimeout(r),e(t)}else if("params"in t){const{params:e}=t;Ns(this,Bs).forEach((t=>{t.subscriptionId===e.subscription&&e.subscription===t.subscriptionId&&t.onMessage(e.result)}))}}))}))),Ns(this,Cs)},As=async function(){return Ns(this,Is)?.close(),Ys(this,Cs,null),Promise.allSettled([...Ns(this,Bs)].map((e=>e.subscribe(this))))};class Js{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:t}=this;return this.subscribed=!1,null!=t&&(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[t]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const t=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=t)}}var Fs,Xs,Ls,Gs,$s,zs=e=>{throw TypeError(e)},qs=(e,t,r)=>t.has(e)||zs("Cannot "+r),Ws=(e,t,r)=>(qs(e,t,"read from private field"),r?r.call(e):t.get(e)),Hs=(e,t,r)=>t.has(e)?zs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ks=(e,t,r,s)=>(qs(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Qs{constructor(e){Hs(this,Gs),Hs(this,Fs,0),Hs(this,Xs),Hs(this,Ls),Ks(this,Xs,e)}fetch(e,t){const r=Ws(this,Xs).fetch??fetch;if(!r)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return r(e,t)}async request(e){Ks(this,Fs,Ws(this,Fs)+1);const t=await this.fetch(Ws(this,Xs).rpc?.url??Ws(this,Xs).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":"1.7.0","Client-Target-Api-Version":"1.32.0",...Ws(this,Xs).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:Ws(this,Fs),method:e.method,params:e.params})});if(!t.ok)throw new Es(`Unexpected status code: ${t.status}`,t.status,t.statusText);const r=await t.json();if("error"in r&&null!=r.error)throw new ws(r.error.message,r.error.code);return r.result}async subscribe(e){const t=await(r=Gs,s=$s,qs(this,r,"access private method"),s).call(this).subscribe(e);var r,s;return async()=>!!await t()}}Fs=new WeakMap,Xs=new WeakMap,Ls=new WeakMap,Gs=new WeakSet,$s=function(){if(!Ws(this,Ls)){const e=Ws(this,Xs).WebSocketConstructor??WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");Ks(this,Ls,new Ms(Ws(this,Xs).websocket?.url??Ws(this,Xs).url,{WebSocketConstructor:e,...Ws(this,Xs).websocket}))}return Ws(this,Ls)};const Zs=Symbol.for("@mysten/SuiClient");class ei{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Qs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,t){return await this.transport.request({method:e,params:t})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!oe(ce(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Object id ${e}`)})),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,"descending"===(e.order||"descending")]})}async getTransactionBlock(e){if(!ie(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach((e=>{if(!ie(e))throw new Error(`Invalid Transaction digest ${e}`)})),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock({transactionBlock:e,signature:t,options:r,requestType:i}){const n=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof e?e:s(e),Array.isArray(t)?t:[t],r]});if("WaitForLocalExecution"===i)try{await this.waitForTransaction({digest:n.digest})}catch(e){}return n}async signAndExecuteTransaction({transaction:e,signer:t,...r}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(t.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:n}=await t.signTransaction(s);return this.executeTransactionBlock({transactionBlock:n,signature:i,...r})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Stake id ${e}`)})),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,"descending"===(e.order||"descending")]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){let t;if(ps(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),t=s(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof e.transactionBlock)t=e.transactionBlock;else{if(!(e.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");t=s(e.transactionBlock)}return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,t,e.gasPrice?.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof e.transactionBlock?e.transactionBlock:s(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!oe(ce(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e?.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e?.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e?.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"});return u(d(e.digest).slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames({format:e="dot",...t}){const{nextCursor:r,hasNextPage:s,data:i}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[t.address,t.cursor,t.limit]});return{hasNextPage:s,nextCursor:r,data:i.map((t=>function(e,t="at"){const r=e.toLowerCase();let s;if(r.includes("@")){if(!fs.test(r))throw new Error(`Invalid SuiNS name ${e}`);const[t,i]=r.split("@");s=[...t?t.split("."):[],i]}else{if(!ys.test(r))throw new Error(`Invalid SuiNS name ${e}`);s=r.split(".").slice(0,-1)}return"dot"===t?`${s.join(".")}.sui`:`${s.slice(0,-1).join(".")}@${s[s.length-1]}`}(t,e)))}}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e?.version]})}async waitForTransaction({signal:e,timeout:t=6e4,pollInterval:r=2e3,...s}){const i=AbortSignal.timeout(t),n=new Promise(((e,t)=>{i.addEventListener("abort",(()=>t(i.reason)))}));for(n.catch((()=>{}));!i.aborted;){e?.throwIfAborted();try{return await this.getTransactionBlock(s)}catch(e){await Promise.race([new Promise((e=>setTimeout(e,r))),n])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}var ti=a(601),ri=a(333);function si(e,t){return or.IntentMessage(or.fixedArray(t.length,or.u8())).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}const ii={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},ni={ED25519:32,Secp256k1:33,Secp256r1:33},ai={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function oi(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}class di{equals(e){return oi(this.toRawBytes(),e.toRawBytes())}toBase64(){return s(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return s(this.toSuiBytes())}verifyWithIntent(e,t,r){const s=si(r,e),i=zr(s,{dkLen:32});return this.verify(i,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(or.vector(or.u8()).serialize(e).toBytes(),t,"PersonalMessage")}verifyTransaction(e,t){return this.verifyWithIntent(e,t,"TransactionData")}toSuiBytes(){const e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return de(function(e){yr(e);let t="";for(let r=0;r<e.length;r++)t+=Sr[e[r]];return t}(zr(this.toSuiBytes(),{dkLen:32})).slice(0,2*ne))}}function ci(e){return 9===e||32===e}const ui=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function hi(e){return li[e.charCodeAt(0)]}const li=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];function pi(e,t){if(!Boolean(e))throw new Error(t)}function mi(e){return bi(e,[])}function bi(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const r=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:bi(t,r)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const r=Math.min(10,e.length),s=e.length-r,i=[];for(let s=0;s<r;++s)i.push(bi(e[s],t));return 1===s?i.push("... 1 more item"):s>1&&i.push(`... ${s} more items`),"["+i.join(", ")+"]"}(e,r);return function(e,t){const r=Object.entries(e);if(0===r.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const s=r.map((([e,r])=>e+": "+bi(r,t)));return"{ "+s.join(", ")+" }"}(e,r)}(e,t);default:return String(e)}}Symbol.toStringTag,Symbol.toStringTag;const gi={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},_i=new Set(Object.keys(gi));function fi(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&_i.has(t)}var yi,vi,Ti;!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(yi||(yi={})),(Ti=vi||(vi={})).NAME="Name",Ti.DOCUMENT="Document",Ti.OPERATION_DEFINITION="OperationDefinition",Ti.VARIABLE_DEFINITION="VariableDefinition",Ti.SELECTION_SET="SelectionSet",Ti.FIELD="Field",Ti.ARGUMENT="Argument",Ti.FRAGMENT_SPREAD="FragmentSpread",Ti.INLINE_FRAGMENT="InlineFragment",Ti.FRAGMENT_DEFINITION="FragmentDefinition",Ti.VARIABLE="Variable",Ti.INT="IntValue",Ti.FLOAT="FloatValue",Ti.STRING="StringValue",Ti.BOOLEAN="BooleanValue",Ti.NULL="NullValue",Ti.ENUM="EnumValue",Ti.LIST="ListValue",Ti.OBJECT="ObjectValue",Ti.OBJECT_FIELD="ObjectField",Ti.DIRECTIVE="Directive",Ti.NAMED_TYPE="NamedType",Ti.LIST_TYPE="ListType",Ti.NON_NULL_TYPE="NonNullType",Ti.SCHEMA_DEFINITION="SchemaDefinition",Ti.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",Ti.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",Ti.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",Ti.FIELD_DEFINITION="FieldDefinition",Ti.INPUT_VALUE_DEFINITION="InputValueDefinition",Ti.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",Ti.UNION_TYPE_DEFINITION="UnionTypeDefinition",Ti.ENUM_TYPE_DEFINITION="EnumTypeDefinition",Ti.ENUM_VALUE_DEFINITION="EnumValueDefinition",Ti.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",Ti.DIRECTIVE_DEFINITION="DirectiveDefinition",Ti.SCHEMA_EXTENSION="SchemaExtension",Ti.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",Ti.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",Ti.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",Ti.UNION_TYPE_EXTENSION="UnionTypeExtension",Ti.ENUM_TYPE_EXTENSION="EnumTypeExtension",Ti.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";const wi=Object.freeze({});function Ei(e,t){const r=e[t];return"object"==typeof r?r:"function"==typeof r?{enter:r,leave:void 0}:{enter:e.enter,leave:e.leave}}const xi={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>Oi(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Ci("(",Oi(e.variableDefinitions,", "),")"),r=Oi([e.operation,Oi([e.name,t]),Oi(e.directives," ")]," ");return("query"===r?"":r+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:r,directives:s})=>e+": "+t+Ci(" = ",r)+Ci(" ",Oi(s," "))},SelectionSet:{leave:({selections:e})=>Ii(e)},Field:{leave({alias:e,name:t,arguments:r,directives:s,selectionSet:i}){const n=Ci("",e,": ")+t;let a=n+Ci("(",Oi(r,", "),")");return a.length>80&&(a=n+Ci("(\n",Bi(Oi(r,"\n")),"\n)")),Oi([a,Oi(s," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Ci(" ",Oi(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:r})=>Oi(["...",Ci("on ",e),Oi(t," "),r]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:r,directives:s,selectionSet:i})=>`fragment ${e}${Ci("(",Oi(r,", "),")")} on ${t} ${Ci("",Oi(s," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e){const t=e.replace(/"""/g,'\\"""'),r=t.split(/\r\n|[\n\r]/g),s=1===r.length,i=r.length>1&&r.slice(1).every((e=>0===e.length||ci(e.charCodeAt(0)))),n=t.endsWith('\\"""'),a=e.endsWith('"')&&!n,o=e.endsWith("\\"),d=a||o,c=!s||e.length>70||d||i||n;let u="";const h=s&&ci(e.charCodeAt(0));return(c&&!h||i)&&(u+="\n"),u+=t,(c||d)&&(u+="\n"),'"""'+u+'"""'}(e):`"${e.replace(ui,hi)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+Oi(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+Oi(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Ci("(",Oi(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:r})=>Ci("",e,"\n")+Oi(["schema",Oi(t," "),Ii(r)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi(["scalar",t,Oi(r," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["type",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:r,type:s,directives:i})=>Ci("",e,"\n")+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+": "+s+Ci(" ",Oi(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:r,defaultValue:s,directives:i})=>Ci("",e,"\n")+Oi([t+": "+r,Ci("= ",s),Oi(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["interface",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:r,types:s})=>Ci("",e,"\n")+Oi(["union",t,Oi(r," "),Ci("= ",Oi(s," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:r,values:s})=>Ci("",e,"\n")+Oi(["enum",t,Oi(r," "),Ii(s)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi([t,Oi(r," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:r,fields:s})=>Ci("",e,"\n")+Oi(["input",t,Oi(r," "),Ii(s)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:r,repeatable:s,locations:i})=>Ci("",e,"\n")+"directive @"+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+(s?" repeatable":"")+" on "+Oi(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>Oi(["extend schema",Oi(e," "),Ii(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>Oi(["extend scalar",e,Oi(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend type",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend interface",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:r})=>Oi(["extend union",e,Oi(t," "),Ci("= ",Oi(r," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:r})=>Oi(["extend enum",e,Oi(t," "),Ii(r)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:r})=>Oi(["extend input",e,Oi(t," "),Ii(r)]," ")}};function Oi(e,t=""){var r;return null!==(r=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==r?r:""}function Ii(e){return Ci("{\n",Bi(Oi(e,"\n")),"\n}")}function Ci(e,t,r=""){return null!=t&&""!==t?e+t+r:""}function Bi(e){return Ci(" ",e.replace(/\n/g,"\n "))}function Si(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}var Pi,ji,Ai,ki,Ui=e=>{throw TypeError(e)},Ni=(e,t,r)=>t.has(e)||Ui("Cannot "+r),Di=(e,t,r)=>(Ni(e,t,"read from private field"),r?r.call(e):t.get(e)),Yi=(e,t,r)=>t.has(e)?Ui("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ri=(e,t,r,s)=>(Ni(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Vi extends Error{}class Mi{constructor({url:e,fetch:t=fetch,headers:r={},queries:s={}}){Yi(this,Pi),Yi(this,ji),Yi(this,Ai),Yi(this,ki),Ri(this,Pi,e),Ri(this,ji,s),Ri(this,Ai,r),Ri(this,ki,((...e)=>t(...e)))}async query(e){const t=await Di(this,ki).call(this,Di(this,Pi),{method:"POST",headers:{"Content-Type":"application/json",...Di(this,Ai)},body:JSON.stringify({query:"string"==typeof e.query?String(e.query):(r=e.query,function(e,t,r=gi){const s=new Map;for(const e of Object.values(vi))s.set(e,Ei(t,e));let i,n,a,o=Array.isArray(e),d=[e],c=-1,u=[],h=e;const l=[],p=[];do{c++;const e=c===d.length,_=e&&0!==u.length;if(e){if(n=0===p.length?void 0:l[l.length-1],h=a,a=p.pop(),_)if(o){h=h.slice();let e=0;for(const[t,r]of u){const s=t-e;null===r?(h.splice(s,1),e++):h[s]=r}}else{h=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));for(const[e,t]of u)h[e]=t}c=i.index,d=i.keys,u=i.edits,o=i.inArray,i=i.prev}else if(a){if(n=o?c:d[c],h=a[n],null==h)continue;l.push(n)}let f;if(!Array.isArray(h)){var m,b;fi(h)||pi(!1,`Invalid AST Node: ${mi(h)}.`);const r=e?null===(m=s.get(h.kind))||void 0===m?void 0:m.leave:null===(b=s.get(h.kind))||void 0===b?void 0:b.enter;if(f=null==r?void 0:r.call(t,h,n,a,l,p),f===wi)break;if(!1===f){if(!e){l.pop();continue}}else if(void 0!==f&&(u.push([n,f]),!e)){if(!fi(f)){l.pop();continue}h=f}}var g;void 0===f&&_&&u.push([n,h]),e?l.pop():(i={inArray:o,index:c,keys:d,edits:u,prev:i},o=Array.isArray(h),d=o?h:null!==(g=r[h.kind])&&void 0!==g?g:[],c=-1,u=[],a&&p.push(a),a=h)}while(void 0!==i);return 0!==u.length?u[u.length-1][1]:e}(r,xi)),variables:e.variables,extensions:e.extensions,operationName:e.operationName})});var r;if(!t.ok)throw new Vi(`GraphQL request failed: ${t.statusText} (${t.status})`);return await t.json()}async execute(e,t){return this.query({...t,query:Di(this,ji)[e]})}}Pi=new WeakMap,ji=new WeakMap,Ai=new WeakMap,ki=new WeakMap;var Ji,Fi,Xi="Document",Li="FragmentDefinition";class Gi extends Error{constructor(e,t,r,s,i,n,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),n&&(this.originalError=n);var o=a;if(!o&&n){var d=n.extensions;d&&"object"==typeof d&&(o=d)}this.extensions=o||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}function $i(e){return new Gi(`Syntax Error: Unexpected token at ${Fi} in ${e}`)}function zi(e){if(e.lastIndex=Fi,e.test(Ji))return Ji.slice(Fi,Fi=e.lastIndex)}var qi=/ +(?=[^\s])/y;function Wi(e){for(var t=e.split("\n"),r="",s=0,i=0,n=t.length-1,a=0;a<t.length;a++)qi.lastIndex=0,qi.test(t[a])&&(a&&(!s||qi.lastIndex<s)&&(s=qi.lastIndex),i=i||a,n=a);for(var o=i;o<=n;o++)o!==i&&(r+="\n"),r+=t[o].slice(s).replace(/\\"""/g,'"""');return r}function Hi(){for(var e=0|Ji.charCodeAt(Fi++);9===e||10===e||13===e||32===e||35===e||44===e||65279===e;e=0|Ji.charCodeAt(Fi++))if(35===e)for(;10!==(e=Ji.charCodeAt(Fi++))&&13!==e;);Fi--}function Ki(){for(var e=Fi,t=0|Ji.charCodeAt(Fi++);t>=48&&t<=57||t>=65&&t<=90||95===t||t>=97&&t<=122;t=0|Ji.charCodeAt(Fi++));if(e===Fi-1)throw $i("Name");var r=Ji.slice(e,--Fi);return Hi(),r}function Qi(){return{kind:"Name",value:Ki()}}var Zi=/(?:"""|(?:[\s\S]*?[^\\])""")/y,en=/(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;function tn(e){var t;switch(Ji.charCodeAt(Fi)){case 91:Fi++,Hi();for(var r=[];93!==Ji.charCodeAt(Fi);)r.push(tn(e));return Fi++,Hi(),{kind:"ListValue",values:r};case 123:Fi++,Hi();for(var s=[];125!==Ji.charCodeAt(Fi);){var i=Qi();if(58!==Ji.charCodeAt(Fi++))throw $i("ObjectField");Hi(),s.push({kind:"ObjectField",name:i,value:tn(e)})}return Fi++,Hi(),{kind:"ObjectValue",fields:s};case 36:if(e)throw $i("Variable");return Fi++,{kind:"Variable",name:Qi()};case 34:if(34===Ji.charCodeAt(Fi+1)&&34===Ji.charCodeAt(Fi+2)){if(Fi+=3,null==(t=zi(Zi)))throw $i("StringValue");return Hi(),{kind:"StringValue",value:Wi(t.slice(0,-3)),block:!0}}var n,a=Fi;Fi++;var o=!1;for(n=0|Ji.charCodeAt(Fi++);92===n&&(Fi++,o=!0)||10!==n&&13!==n&&34!==n&&n;n=0|Ji.charCodeAt(Fi++));if(34!==n)throw $i("StringValue");return t=Ji.slice(a,Fi),Hi(),{kind:"StringValue",value:o?JSON.parse(t):t.slice(1,-1),block:!1};case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:for(var d,c=Fi++;(d=0|Ji.charCodeAt(Fi++))>=48&&d<=57;);var u=Ji.slice(c,--Fi);if(46===(d=Ji.charCodeAt(Fi))||69===d||101===d){if(null==(t=zi(en)))throw $i("FloatValue");return Hi(),{kind:"FloatValue",value:u+t}}return Hi(),{kind:"IntValue",value:u};case 110:if(117===Ji.charCodeAt(Fi+1)&&108===Ji.charCodeAt(Fi+2)&&108===Ji.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"NullValue"};break;case 116:if(114===Ji.charCodeAt(Fi+1)&&117===Ji.charCodeAt(Fi+2)&&101===Ji.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"BooleanValue",value:!0};break;case 102:if(97===Ji.charCodeAt(Fi+1)&&108===Ji.charCodeAt(Fi+2)&&115===Ji.charCodeAt(Fi+3)&&101===Ji.charCodeAt(Fi+4))return Fi+=5,Hi(),{kind:"BooleanValue",value:!1}}return{kind:"EnumValue",value:Ki()}}function rn(e){if(40===Ji.charCodeAt(Fi)){var t=[];Fi++,Hi();do{var r=Qi();if(58!==Ji.charCodeAt(Fi++))throw $i("Argument");Hi(),t.push({kind:"Argument",name:r,value:tn(e)})}while(41!==Ji.charCodeAt(Fi));return Fi++,Hi(),t}}function sn(e){if(64===Ji.charCodeAt(Fi)){var t=[];do{Fi++,t.push({kind:"Directive",name:Qi(),arguments:rn(e)})}while(64===Ji.charCodeAt(Fi));return t}}function nn(){for(var e=0;91===Ji.charCodeAt(Fi);)e++,Fi++,Hi();var t={kind:"NamedType",name:Qi()};do{if(33===Ji.charCodeAt(Fi)&&(Fi++,Hi(),t={kind:"NonNullType",type:t}),e){if(93!==Ji.charCodeAt(Fi++))throw $i("NamedType");Hi(),t={kind:"ListType",type:t}}}while(e--);return t}function an(){if(123!==Ji.charCodeAt(Fi++))throw $i("SelectionSet");return Hi(),on()}function on(){var e=[];do{if(46===Ji.charCodeAt(Fi)){if(46!==Ji.charCodeAt(++Fi)||46!==Ji.charCodeAt(++Fi))throw $i("SelectionSet");switch(Fi++,Hi(),Ji.charCodeAt(Fi)){case 64:e.push({kind:"InlineFragment",typeCondition:void 0,directives:sn(!1),selectionSet:an()});break;case 111:110===Ji.charCodeAt(Fi+1)?(Fi+=2,Hi(),e.push({kind:"InlineFragment",typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()})):e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)});break;case 123:Fi++,Hi(),e.push({kind:"InlineFragment",typeCondition:void 0,directives:void 0,selectionSet:on()});break;default:e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)})}}else{var t=Qi(),r=void 0;58===Ji.charCodeAt(Fi)&&(Fi++,Hi(),r=t,t=Qi());var s=rn(!1),i=sn(!1),n=void 0;123===Ji.charCodeAt(Fi)&&(Fi++,Hi(),n=on()),e.push({kind:"Field",alias:r,name:t,arguments:s,directives:i,selectionSet:n})}}while(125!==Ji.charCodeAt(Fi));return Fi++,Hi(),{kind:"SelectionSet",selections:e}}function dn(){if(Hi(),40===Ji.charCodeAt(Fi)){var e=[];Fi++,Hi();do{if(36!==Ji.charCodeAt(Fi++))throw $i("Variable");var t=Qi();if(58!==Ji.charCodeAt(Fi++))throw $i("VariableDefinition");Hi();var r=nn(),s=void 0;61===Ji.charCodeAt(Fi)&&(Fi++,Hi(),s=tn(!0)),Hi(),e.push({kind:"VariableDefinition",variable:{kind:"Variable",name:t},type:r,defaultValue:s,directives:sn(!0)})}while(41!==Ji.charCodeAt(Fi));return Fi++,Hi(),e}}function cn(){var e=Qi();if(111!==Ji.charCodeAt(Fi++)||110!==Ji.charCodeAt(Fi++))throw $i("FragmentDefinition");return Hi(),{kind:"FragmentDefinition",name:e,typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()}}function un(){var e=[];do{if(123===Ji.charCodeAt(Fi))Fi++,Hi(),e.push({kind:"OperationDefinition",operation:"query",name:void 0,variableDefinitions:void 0,directives:void 0,selectionSet:on()});else{var t=Ki();switch(t){case"fragment":e.push(cn());break;case"query":case"mutation":case"subscription":var r,s=void 0;40!==(r=Ji.charCodeAt(Fi))&&64!==r&&123!==r&&(s=Qi()),e.push({kind:"OperationDefinition",operation:t,name:s,variableDefinitions:dn(),directives:sn(!1),selectionSet:an()});break;default:throw $i("Document")}}}while(Fi<Ji.length);return e}function hn(e,t){return Ji=e.body?e.body:e,Fi=0,Hi(),t&&t.noLocation?{kind:"Document",definitions:un()}:{kind:"Document",definitions:un(),loc:{start:0,end:Ji.length,startToken:void 0,endToken:void 0,source:{body:Ji,name:"graphql.web",locationOffset:{line:1,column:1}}}}}var ln=0,pn=new Set;function mn(){function e(e,t){var r,s,i=hn(e).definitions,n=new Set;for(var a of t||[])for(var o of a.definitions)o.kind!==Li||n.has(o)||(i.push(o),n.add(o));return(r=i[0].kind===Li)&&i[0].directives&&(i[0].directives=i[0].directives.filter((e=>"_unmask"!==e.name.value))),{kind:Xi,definitions:i,get loc(){if(!s&&r){var i=e+function(e){try{ln++;var t="";for(var r of e)if(!pn.has(r)){pn.add(r);var{loc:s}=r;s&&(t+=s.source.body)}return t}finally{0==--ln&&pn.clear()}}(t||[]);return{start:0,end:i.length,source:{body:i,name:"GraphQLTada",locationOffset:{line:1,column:1}}}}return s},set loc(e){s=e}}}return e.scalar=function(e,t){return t},e.persisted=function(e,t){return{kind:Xi,definitions:t?t.definitions:[],documentId:e}},e}mn();const bn=mn();function gn(e){if(1!==e.length)throw new Error("Invalid base64Url character: "+e);const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(e);if(-1===t)throw new Error("Invalid base64Url character: "+e);const r=t.toString(2).padStart(6,"0");return Array.from(r).map(Number)}function _n(e,t){const r=function(e,t){if(e.length<2)throw new Error(`Input (s = ${e}) is not tightly packed because s.length < 2`);let r=function(e){let t=[];for(let r=0;r<e.length;r++){const s=gn(e.charAt(r));t=t.concat(s)}return t}(e);const s=t%4;if(0===s);else if(1===s)r=r.slice(2);else{if(2!==s)throw new Error(`Input (s = ${e}) is not tightly packed because i%4 = 3 (i = ${t}))`);r=r.slice(4)}const i=(t+e.length-1)%4;if(3===i);else if(2===i)r=r.slice(0,r.length-2);else{if(1!==i)throw new Error(`Input (s = ${e}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${t}))`);r=r.slice(0,r.length-4)}if(r.length%8!=0)throw new Error("We should never reach here...");const n=new Uint8Array(Math.floor(r.length/8));let a=0;for(let e=0;e<r.length;e+=8){const t=r.slice(e,e+8),s=parseInt(t.join(""),2);n[a++]=s}return(new TextDecoder).decode(n)}(e.value,e.indexMod4),[s,i]=function(e){if("}"!==e.slice(-1)&&","!==e.slice(-1))throw new Error("Invalid claim");const t=JSON.parse("{"+e.slice(0,-1)+"}");if(1!==Object.keys(t).length)throw new Error("Invalid claim");const r=Object.keys(t)[0];return[r,t[r]]}(r);if(s!==t)throw new Error(`Invalid field name: found ${s} expected ${t}`);return i}const fn=ht.struct("ZkLoginSignature",{inputs:ht.struct("ZkLoginSignatureInputs",{proofPoints:ht.struct("ZkLoginSignatureInputsProofPoints",{a:ht.vector(ht.string()),b:ht.vector(ht.vector(ht.string())),c:ht.vector(ht.string())}),issBase64Details:ht.struct("ZkLoginSignatureInputsClaim",{value:ht.string(),indexMod4:ht.u8()}),headerBase64:ht.string(),addressSeed:ht.string()}),maxEpoch:ht.u64(),userSignature:ht.vector(ht.u8())});var yn,vn,Tn=e=>{throw TypeError(e)},wn=(e,t,r)=>t.has(e)||Tn("Cannot "+r),En=(e,t,r)=>(wn(e,t,"read from private field"),r?r.call(e):t.get(e)),xn=(e,t,r)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),On=(e,t,r,s)=>(wn(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);yn=new WeakMap,vn=new WeakMap;let In=class e extends di{constructor(e,{client:r}={}){super(),xn(this,yn),xn(this,vn),On(this,vn,r),"string"==typeof e?On(this,yn,t(e)):e instanceof Uint8Array?On(this,yn,e):On(this,yn,Uint8Array.from(e))}equals(e){return super.equals(e)}toRawBytes(){return En(this,yn)}flag(){return ii.ZkLogin}async verify(e,t){throw Error("does not support")}verifyPersonalMessage(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"PERSONAL_MESSAGE",client:En(this,vn)})}verifyTransaction(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"TRANSACTION_DATA",client:En(this,vn)})}};const Cn=bn("\n\tquery Zklogin(\n\t\t$bytes: Base64!\n\t\t$signature: Base64!\n\t\t$intentScope: ZkLoginIntentScope!\n\t\t$author: SuiAddress!\n\t) {\n\t\tverifyZkloginSignature(\n\t\t\tbytes: $bytes\n\t\t\tsignature: $signature\n\t\t\tintentScope: $intentScope\n\t\t\tauthor: $author\n\t\t) {\n\t\t\tsuccess\n\t\t\terrors\n\t\t}\n\t}\n");async function Bn({address:e,bytes:t,signature:r,intentScope:s,client:i=new Mi({url:"https://sui-mainnet.mystenlabs.com/graphql"})}){const n=await i.query({query:Cn,variables:{bytes:t,signature:r,intentScope:s,author:e}});return!0===n.data?.verifyZkloginSignature.success&&0===n.data?.verifyZkloginSignature.errors.length}function Sn(e){const r="string"==typeof e?t(e):e;if(r[0]!==ii.ZkLogin)throw new Error("Invalid signature scheme");const i=r.slice(1),{inputs:n,maxEpoch:a,userSignature:o}=function(e){return fn.parse("string"==typeof e?t(e):e)}(i),{issBase64Details:d,addressSeed:c}=n,u=_n(d,"iss"),h=function(e,t){const r=(n=32,function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=Pr(e.charCodeAt(i)),n=Pr(e.charCodeAt(i+1));if(void 0===r||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}s[t]=16*r+n}return s}(e.toString(16).padStart(2*n,"0").slice(2*-n))),s=(new TextEncoder).encode(t),i=new Uint8Array(1+s.length+r.length);var n;return i.set([s.length],0),i.set(s,1),i.set(r,1+s.length),new In(i,void 0)}(BigInt(c),u);return{serializedSignature:s(r),signatureScheme:"ZkLogin",zkLogin:{inputs:n,maxEpoch:a,userSignature:o,iss:u,addressSeed:BigInt(c)},signature:r,publicKey:h.toRawBytes()}}const Pn=32,jn="suiprivkey";class An{async signWithIntent(e,t){const r=si(t,e),i=zr(r,{dkLen:32});return{signature:function({signature:e,signatureScheme:t,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const i=r.toRawBytes(),n=new Uint8Array(1+e.length+i.length);return n.set([ii[t]]),n.set(e,1),n.set(i,1+e.length),s(n)}({signature:await this.sign(i),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:s(e)}}async signTransaction(e){return this.signWithIntent(e,"TransactionData")}async signPersonalMessage(e){const{signature:t}=await this.signWithIntent(ht.vector(ht.u8()).serialize(e).toBytes(),"PersonalMessage");return{bytes:s(e),signature:t}}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class kn extends An{}function Un(e){const{prefix:t,words:r}=ri.I.decode(e);if(t!==jn)throw new Error("invalid private key prefix");const s=new Uint8Array(ri.I.fromWords(r)),i=s.slice(1);return{schema:ai[s[0]],secretKey:i}}function Nn(e,t){if(e.length!==Pn)throw new Error("Invalid bytes length");const r=ii[t],s=new Uint8Array(e.length+1);return s.set([r]),s.set(e,1),ri.I.encode(jn,ri.I.toWords(s))}class Dn extends Ar{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,vr(e);const r=jr(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tr(this),this.iHash.update(e),this}digestInto(e){Tr(this),yr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:n,outputLen:a}=this;return e.finished=s,e.destroyed=i,e.blockLen=n,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Yn=(e,t,r)=>new Dn(e,t).update(r).digest();Yn.create=(e,t)=>new Dn(e,t);class Rn extends Ar{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=xr(this.buffer)}update(e){Tr(this);const{view:t,buffer:r,blockLen:s}=this,i=(e=jr(e)).length;for(let n=0;n<i;){const a=Math.min(s-this.pos,i-n);if(a!==s)r.set(e.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===s&&(this.process(t,0),this.pos=0);else{const t=xr(e);for(;s<=i-n;n+=s)this.process(t,n)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tr(this),wr(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let e=n;e<s;e++)t[e]=0;!function(e,t,r,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,s);const i=BigInt(32),n=BigInt(4294967295),a=Number(r>>i&n),o=Number(r&n),d=s?4:0,c=s?0:4;e.setUint32(t+d,a,s),e.setUint32(t+c,o,s)}(r,s-8,BigInt(8*this.length),i),this.process(r,0);const a=xr(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=o/4,c=this.get();if(d>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)a.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:n,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=n,s%t&&e.buffer.set(r),e}}const[Vn,Mn]=(()=>Jr.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Jn=new Uint32Array(80),Fn=new Uint32Array(80);class Xn extends Rn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:n,Dh:a,Dl:o,Eh:d,El:c,Fh:u,Fl:h,Gh:l,Gl:p,Hh:m,Hl:b}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b]}set(e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|s,this.Ch=0|i,this.Cl=0|n,this.Dh=0|a,this.Dl=0|o,this.Eh=0|d,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|l,this.Gl=0|p,this.Hh=0|m,this.Hl=0|b}process(e,t){for(let r=0;r<16;r++,t+=4)Jn[r]=e.getUint32(t),Fn[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Jn[e-15],r=0|Fn[e-15],s=Jr.rotrSH(t,r,1)^Jr.rotrSH(t,r,8)^Jr.shrSH(t,r,7),i=Jr.rotrSL(t,r,1)^Jr.rotrSL(t,r,8)^Jr.shrSL(t,r,7),n=0|Jn[e-2],a=0|Fn[e-2],o=Jr.rotrSH(n,a,19)^Jr.rotrBH(n,a,61)^Jr.shrSH(n,a,6),d=Jr.rotrSL(n,a,19)^Jr.rotrBL(n,a,61)^Jr.shrSL(n,a,6),c=Jr.add4L(i,d,Fn[e-7],Fn[e-16]),u=Jr.add4H(c,s,o,Jn[e-7],Jn[e-16]);Jn[e]=0|u,Fn[e]=0|c}let{Ah:r,Al:s,Bh:i,Bl:n,Ch:a,Cl:o,Dh:d,Dl:c,Eh:u,El:h,Fh:l,Fl:p,Gh:m,Gl:b,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){const t=Jr.rotrSH(u,h,14)^Jr.rotrSH(u,h,18)^Jr.rotrBH(u,h,41),f=Jr.rotrSL(u,h,14)^Jr.rotrSL(u,h,18)^Jr.rotrBL(u,h,41),y=u&l^~u&m,v=h&p^~h&b,T=Jr.add5L(_,f,v,Mn[e],Fn[e]),w=Jr.add5H(T,g,t,y,Vn[e],Jn[e]),E=0|T,x=Jr.rotrSH(r,s,28)^Jr.rotrBH(r,s,34)^Jr.rotrBH(r,s,39),O=Jr.rotrSL(r,s,28)^Jr.rotrBL(r,s,34)^Jr.rotrBL(r,s,39),I=r&i^r&a^i&a,C=s&n^s&o^n&o;g=0|m,_=0|b,m=0|l,b=0|p,l=0|u,p=0|h,({h:u,l:h}=Jr.add(0|d,0|c,0|w,0|E)),d=0|a,c=0|o,a=0|i,o=0|n,i=0|r,n=0|s;const B=Jr.add3L(E,O,C);r=Jr.add3H(B,w,x,I),s=0|B}({h:r,l:s}=Jr.add(0|this.Ah,0|this.Al,0|r,0|s)),({h:i,l:n}=Jr.add(0|this.Bh,0|this.Bl,0|i,0|n)),({h:a,l:o}=Jr.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:d,l:c}=Jr.add(0|this.Dh,0|this.Dl,0|d,0|c)),({h:u,l:h}=Jr.add(0|this.Eh,0|this.El,0|u,0|h)),({h:l,l:p}=Jr.add(0|this.Fh,0|this.Fl,0|l,0|p)),({h:m,l:b}=Jr.add(0|this.Gh,0|this.Gl,0|m,0|b)),({h:g,l:_}=Jr.add(0|this.Hh,0|this.Hl,0|g,0|_)),this.set(r,s,i,n,a,o,d,c,u,h,l,p,m,b,g,_)}roundClean(){Jn.fill(0),Fn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ln=kr((()=>new Xn));function Gn(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function $n(e,t=""){return function(e,t,r){const{c:s,dkLen:i,DK:n,PRF:a,PRFSalt:o}=function(e,t,r,s){vr(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("Options should be object or undefined");return Object.assign({dkLen:32,asyncTick:10},t)}(0,s),{c:n,dkLen:a,asyncTick:o}=i;if(fr(n),fr(a),fr(o),n<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const d=jr(t),c=jr(r),u=new Uint8Array(a),h=Yn.create(e,d),l=h._cloneInto().update(c);return{c:n,dkLen:a,asyncTick:o,DK:u,PRF:h,PRFSalt:l}}(e,t,r,{c:2048,dkLen:64});let d;const c=new Uint8Array(4),u=xr(c),h=new Uint8Array(a.outputLen);for(let e=1,t=0;t<i;e++,t+=a.outputLen){const r=n.subarray(t,t+a.outputLen);u.setInt32(0,e,!1),(d=o._cloneInto(d)).update(c).digestInto(h),r.set(h.subarray(0,r.length));for(let e=1;e<s;e++){a._cloneInto(d).update(h).digestInto(h);for(let e=0;e<r.length;e++)r[e]^=h[e]}}return function(e,t,r,s,i){return e.destroy(),t.destroy(),s&&s.destroy(),i.fill(0),r}(a,o,n,d,h)}(Ln,function(e){const t=Gn(e),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}(e).nfkd,(e=>Gn("mnemonic"+e))(t))}function zn(e){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(e)}const qn=new RegExp("^m(\\/[0-9]+')+$"),Wn=e=>e.replace("'",""),Hn=(e,t,r=2147483648)=>{if(!(e=>!!qn.test(e)&&!e.split("/").slice(1).map(Wn).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:s,chainCode:i}=(e=>{const t=Yn.create(Ln,"ed25519 seed").update(c(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(Wn).map((e=>parseInt(e,10))).reduce(((e,t)=>(({key:e,chainCode:t},r)=>{const s=new ArrayBuffer(4);new DataView(s).setUint32(0,r);const i=new Uint8Array(1+e.length+s.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(e,1),i.set(new Uint8Array(s,0,s.byteLength),e.length+1);const n=Yn.create(Ln,t).update(i).digest();return{key:n.slice(0,32),chainCode:n.slice(32)}})(e,t+r)),{key:s,chainCode:i})};class Kn extends di{constructor(e){if(super(),"string"==typeof e?this.data=t(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return ii.ED25519}async verify(e,r){let s;if("string"==typeof r){const e=function(e){const r=t(e),s=ai[r[0]];switch(s){case"MultiSig":return{serializedSignature:e,signatureScheme:s,multisig:or.MultiSig.parse(r.slice(1)),bytes:r};case"ZkLogin":return Sn(e);case"ED25519":case"Secp256k1":case"Secp256r1":const t=ni[s],i=r.slice(1,r.length-t);return{serializedSignature:e,signatureScheme:s,signature:i,publicKey:r.slice(1+i.length),bytes:r};default:throw new Error("Unsupported signature scheme")}}(r);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!oi(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");s=e.signature}else s=r;return ti.sign.detached.verify(e,s,this.toRawBytes())}}Kn.SIZE=32;const Qn="m/44'/784'/0'/0'/0'";class Zn extends kn{constructor(e){super(),this.keypair=e||ti.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Zn(ti.sign.keyPair())}static fromSecretKey(e,t){const r=e.length;if(r!==Pn)throw new Error(`Wrong secretKey size. Expected ${Pn} bytes, got ${r}.`);const s=ti.sign.keyPair.fromSeed(e);if(!t||!t.skipValidation){const e=(new TextEncoder).encode("sui validation"),t=ti.sign.detached(e,s.secretKey);if(!ti.sign.detached.verify(e,t,s.publicKey))throw new Error("provided secretKey is invalid")}return new Zn(s)}getPublicKey(){return new Kn(this.keypair.publicKey)}getSecretKey(){return Nn(this.keypair.secretKey.slice(0,Pn),this.getKeyScheme())}async sign(e){return ti.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=Qn),!zn(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,function(e){return u(function(e){return $n(e,"")}(e))}(e));return Zn.fromSecretKey(r)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=Qn),!zn(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,e);return Zn.fromSecretKey(r)}}function ea(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function ta(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}var ra=a(725);const sa=e=>ra.encode(e),ia=e=>ra.decode(e);function na(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const aa=8192;function oa(e){if(e.length<aa)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=aa){const s=e.slice(r,r+aa);t+=String.fromCharCode(...s)}return btoa(t)}class da{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class ca{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return ua(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return ua(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return ua(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return sa(e);case"base64":return oa(e);case"hex":return ta(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function ua(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var ha,la,pa,ma,ba=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},ga=(e,t,r)=>(ba(e,t,"read from private field"),r?r.call(e):t.get(e)),_a=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},fa=(e,t,r,s)=>(ba(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const ya=class{constructor(e){_a(this,ha,void 0),_a(this,la,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),fa(this,ha,e.write),fa(this,la,e.serialize??((e,t)=>{const r=new ca({size:this.serializedSize(e)??void 0,...t});return ga(this,ha).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),ga(this,ha).call(this,e,t)}serialize(e,t){return this.validate(e),new wa(this,ga(this,la).call(this,e,t))}parse(e){const t=new da(e);return this.read(t)}transform({name:e,input:t,output:r}){return new ya({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>ga(this,ha).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>ga(this,la).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let va=ya;ha=new WeakMap,la=new WeakMap;const Ta=Symbol.for("@mysten/serialized-bcs");class wa{constructor(e,t){_a(this,pa,void 0),_a(this,ma,void 0),fa(this,pa,e),fa(this,ma,t)}get[Ta](){return!0}toBytes(){return ga(this,ma)}toHex(){return ta(ga(this,ma))}toBase64(){return oa(ga(this,ma))}toBase58(){return sa(ga(this,ma))}parse(){return ga(this,pa).parse(ga(this,ma))}}pa=new WeakMap,ma=new WeakMap;const Ea=32,xa=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof xa)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(xa.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Oa.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Oa.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Oa.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Oa.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Oa.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Oa.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Oa.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Oa.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Oa.HEX,(function(e,t){return e.writeVec(Array.from(ea(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return ta(new Uint8Array(t))})),t.registerType(Oa.BASE58,(function(e,t){return e.writeVec(Array.from(ia(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return sa(new Uint8Array(t))})),t.registerType(Oa.BASE64,(function(e,t){return e.writeVec(Array.from(na(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return oa(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new xa(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return ia(e);case"base64":return na(e);case"hex":return ea(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new xa(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new ca(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new da(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new va({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new va({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return na(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return oa(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return ea(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return ta(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],l,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,l,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let l=n.indexOf(h),p=-1===l?h:a[l];{let{name:r,params:s}=this.parseTypeName(p);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Oa=xa;function Ia(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ea,addressEncoding:"hex"}}var Ca;Oa.U8="u8",Oa.U16="u16",Oa.U32="u32",Oa.U64="u64",Oa.U128="u128",Oa.U256="u256",Oa.BOOL="bool",Oa.VECTOR="vector",Oa.ADDRESS="address",Oa.STRING="string",Oa.HEX="hex-string",Oa.BASE58="base58-string",Oa.BASE64="base64-string",function(e){e.IsValidDesription="invalid description",e.IsValidName="invalid name",e.IsValidName_AllowEmpty="invalid name",e.IsValidEndpoint="invalid endpoint",e.IsValidAddress="invalid address",e.IsValidArgType="invalid argument type",e.IsValidTokenType="invalid token type",e.IsValidUint="invalid uint",e.IsValidInt="invalid int",e.IsValidU64="invalid u64",e.IsValidU8="invalid u8",e.IsValidPercent="invalid percent",e.IsValidArray="invalid array",e.IsValidObjects="invalid objects",e.AllInvalid="one valid at least",e.InvalidParam="invalid parameter",e.IsValidPermissionIndex="invalid permission index",e.IsValidKey="invalid key",e.Fail="fail",e.IsValidIndentifier="indentifier invalid",e.isValidHttpUrl="invalid url",e.IsValidBizPermissionIndex="invalid biz-permission index",e.bcsTypeInvalid="invalid bcs type",e.IsValidServiceItemName="invalid service item name",e.IsValidCoinType="not the coin type",e.IsValidGuardIdentifier="guard identifier invalid",e.noPermission="no permission"}(Ca||(Ca={}));const Ba=(e,t)=>{throw e.toString()+(t?" "+t:"")},Sa=BigInt("255"),Pa=BigInt("18446744073709551615"),ja=BigInt("340282366920938463463374607431768211455"),Aa=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),ka=0,Ua=e=>e===Uo.TYPE_U8||e===Uo.TYPE_U64||e===Uo.TYPE_U128||e===Uo.TYPE_U256?No.PositiveNumber:e===Uo.TYPE_VEC_U8||e===Uo.TYPE_VEC_U64||e===Uo.TYPE_VEC_U128||e===Uo.TYPE_VEC_U256||e===Uo.TYPE_VEC_BOOL?No.PositiveNumber_Vec:e===Uo.TYPE_ADDRESS?No.Address:e===Uo.TYPE_VEC_ADDRESS?No.Address_Vec:e===Uo.TYPE_STRING?No.String:e===Uo.TYPE_VEC_STRING?No.String_Vec:e===Uo.TYPE_BOOL?No.Bool:-1,Na=(e,t)=>{let r=e.splice(0,1);return 1==r[0]?{bNone:!1,value:Wa.getInstance().de(t,Uint8Array.from(e))}:(0==r[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka})},Da=e=>{let t=e.splice(0,1);if(1==t[0]){let t=Ya(Uint8Array.from(e)),r=Wa.getInstance().de(Uo.TYPE_STRING,Uint8Array.from(e));return e.splice(0,t.value+t.length),{bNone:!1,value:r}}return 0==t[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka}},Ya=e=>{let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}},Ra=(e,t)=>{let r=Ya(Uint8Array.from(e));e.splice(0,r.length);let s=[];for(let i=0;i<r.value;i++)s.push(t(e,i,r.value));return s},Va=(e,t,r)=>e.shift(),Ma=(e,t,r)=>e.splice(0,8),Ja=(e,t,r)=>e.splice(0,16),Fa=(e,t,r)=>e.splice(0,32),Xa=(e,...t)=>{let r=0;for(const e of t)r+=e.length;const s=new e(r);let i=0;for(const e of t)s.set(e,i),i+=e.length;return s},La=(e,t="payment::Payment<")=>{if(e){const r=e.indexOf(t);if(r>0)return e.slice(r+t.length,e.length-1)}return""},Ga=(e,t)=>e.length===t.length&&!e.some((e=>!t.includes(e))),$a=e=>{for(var t=[],r=0;r<e.length;r++)-1==t.indexOf(e[r])&&t.push(e[r]);return t};function za(e){return e&&e[0].toUpperCase()+e.slice(1)}function qa(e){var t=[];let r=e.indexOf("<");return r>=0&&(t=e.slice(r+1,e.length-1).split(",")),t}class Wa{bcs=new Oa(Ia());static _instance;constructor(){this.bcs.registerEnumType("Option<T>",{none:null,some:"T"}),this.bcs.registerStructType("EntStruct",{avatar:"vector<u8>",resource:"Option<address>",safer_name:"vector<string>",safer_value:"vector<string>",like:Oa.U32,dislike:Oa.U32}),this.bcs.registerStructType("TagStruct",{nick:"string",tags:"vector<string>"}),this.bcs.registerStructType("PersonalInfo",{name:"vector<u8>",description:"vector<u8>",avatar:Oa.STRING,twitter:Oa.STRING,discord:Oa.STRING,homepage:Oa.STRING}),this.bcs.registerStructType("OptionAddress",{address:"Option<address>"}),this.bcs.registerStructType("Guards",{guards:"vector<OptionAddress>"}),this.bcs.registerStructType("Perm",{index:Oa.U64,guard:"Option<address>"}),this.bcs.registerStructType("Perms",{perms:"vector<Perm>"})}static getInstance(){return Wa._instance||(Wa._instance=new Wa),Wa._instance}ser_option_u32(e){return this.bcs.ser("Option<u32>",{some:e}).toBytes()}ser(e,t){if("string"==typeof e)return this.bcs.ser(e,t).toBytes();switch(e){case Uo.TYPE_BOOL:return this.bcs.ser(Oa.BOOL,t).toBytes();case Uo.TYPE_ADDRESS:return this.bcs.ser(Oa.ADDRESS,t).toBytes();case Uo.TYPE_U64:return this.bcs.ser(Oa.U64,t).toBytes();case Uo.TYPE_U8:return this.bcs.ser(Oa.U8,t).toBytes();case Uo.TYPE_VEC_U8:return this.bcs.ser("vector<u8>",t).toBytes();case Uo.TYPE_U128:return this.bcs.ser(Oa.U128,t).toBytes();case Uo.TYPE_VEC_ADDRESS:return this.bcs.ser("vector<address>",t).toBytes();case Uo.TYPE_VEC_BOOL:return this.bcs.ser("vector<bool>",t).toBytes();case Uo.TYPE_VEC_VEC_U8:return this.bcs.ser("vector<vector<u8>>",t).toBytes();case Uo.TYPE_VEC_U64:return this.bcs.ser("vector<u64>",t).toBytes();case Uo.TYPE_VEC_U128:return this.bcs.ser("vector<u128>",t).toBytes();case Uo.TYPE_OPTION_ADDRESS:return this.bcs.ser("Option<address>",{some:t}).toBytes();case Uo.TYPE_OPTION_BOOL:return this.bcs.ser("Option<bool>",{some:t}).toBytes();case Uo.TYPE_OPTION_U8:return this.bcs.ser("Option<u8>",{some:t}).toBytes();case Uo.TYPE_OPTION_U64:return this.bcs.ser("Option<u64>",{some:t}).toBytes();case Uo.TYPE_OPTION_U128:return this.bcs.ser("Option<u128>",{some:t}).toBytes();case Uo.TYPE_OPTION_U256:return this.bcs.ser("Option<u256>",{some:t}).toBytes();case Uo.TYPE_OPTION_STRING:return this.bcs.ser("Option<string>",{some:t}).toBytes();case Uo.TYPE_VEC_U256:return this.bcs.ser("vector<u256>",t).toBytes();case Uo.TYPE_U256:return this.bcs.ser(Oa.U256,t).toBytes();case Uo.TYPE_STRING:const e=(new TextEncoder).encode(t);return this.bcs.ser("vector<u8>",e).toBytes();case Uo.TYPE_VEC_STRING:return this.bcs.ser("vector<vector<u8>>",t.map((e=>(new TextEncoder).encode(e)))).toBytes();default:Ba(Ca.bcsTypeInvalid,"ser")}return new Uint8Array}de(e,t){if("string"==typeof e)return this.bcs.de(e,t);switch(e){case Uo.TYPE_BOOL:return this.bcs.de(Oa.BOOL,t);case Uo.TYPE_ADDRESS:return this.bcs.de(Oa.ADDRESS,t);case Uo.TYPE_U64:return this.bcs.de(Oa.U64,t);case Uo.TYPE_U8:return this.bcs.de(Oa.U8,t);case Uo.TYPE_VEC_U8:return this.bcs.de("vector<u8>",t);case Uo.TYPE_U128:return this.bcs.de(Oa.U128,t);case Uo.TYPE_VEC_ADDRESS:return this.bcs.de("vector<address>",t);case Uo.TYPE_VEC_BOOL:return this.bcs.de("vector<bool>",t);case Uo.TYPE_VEC_VEC_U8:return this.bcs.de("vector<vector<u8>>",t);case Uo.TYPE_VEC_U64:return this.bcs.de("vector<u64>",t);case Uo.TYPE_VEC_U128:return this.bcs.de("vector<u128>",t);case Uo.TYPE_OPTION_ADDRESS:return this.bcs.de("Option<address>",t);case Uo.TYPE_OPTION_BOOL:return this.bcs.de("Option<bool>",t);case Uo.TYPE_OPTION_U8:return this.bcs.de("Option<u8>",t);case Uo.TYPE_OPTION_U64:return this.bcs.de("Option<u64>",t);case Uo.TYPE_OPTION_U128:return this.bcs.de("Option<u128>",t);case Uo.TYPE_OPTION_U256:return this.bcs.de("Option<u256>",t);case Uo.TYPE_OPTION_STRING:return this.bcs.de("Option<string>",t);case Uo.TYPE_VEC_U256:return this.bcs.de("vector<u256>",t);case Uo.TYPE_STRING:return(new TextDecoder).decode(Uint8Array.from(this.bcs.de("vector<u8>",t)));case Uo.TYPE_VEC_STRING:return this.bcs.de("vector<string>",t);case Uo.TYPE_U256:return this.bcs.de(Oa.U256,t);default:Ba(Ca.bcsTypeInvalid,"de")}}de_ent(e){if(!e||e.length<2)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("EntStruct",Uint8Array.from(t))}de_entInfo(e){if(!e||0===e.length)return;let t=this.bcs.de("PersonalInfo",e);return t.name=(new TextDecoder).decode(Uint8Array.from(t.name)),t.description=(new TextDecoder).decode(Uint8Array.from(t.description)),t}de_tags(e){if(!e||0===e.length)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("TagStruct",Uint8Array.from(t))}de_perms(e){return!e||e.length<1?"":this.bcs.de("Perms",e).perms.map((e=>({index:e?.index,guard:e?.guard?.none?void 0:"0x"+e?.guard?.some})))}}function Ha(e){const t=(new TextEncoder).encode(e);return new Uint8Array(t.buffer)}function Ka(e){if(!e)return new Uint8Array(0);const t=[];for(t.unshift(255&e);e>=256;)e>>>=8,t.unshift(255&e);return new Uint8Array(t)}const Qa=e=>"[object Array]"==Object.prototype.toString.call(e),Za=(e,t)=>{let r=t||{};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&("object"==typeof e[t]&&null!==e[t]?(r[t]=Qa(e[t])?[]:{},Za(e[t],r[t])):r[t]=e[t]);return r},eo=4e3,to=64,ro=1024,so=(e,t)=>Wa.getInstance().ser(Uo.TYPE_STRING,e).length<=t,io=e=>so(e,eo),no=e=>!(!e||0===e.length)&&so(e,to),ao=e=>so(e,to),oo=e=>e.length>0&&e.length<=ro&&Co(e),co=e=>!(!e||!ae(e)),uo=e=>!!e&&(e.startsWith("0x2::coin::Coin")||e.startsWith("0x0000000000000000000000000000000000000000000000000000000000000002")),ho=(e,t=Aa,r)=>{if(""===e||void 0===e)return!1;try{const s=BigInt(e);if(s<=t)return void 0===r||s>=r}catch(e){}return!1},lo=(e,t=0)=>ho(e,Sa,BigInt(t)),po=(e,t=0)=>ho(e,Pa,BigInt(t)),mo=(e,t=0)=>ho(e,ja,BigInt(t)),bo=(e,t=0)=>ho(e,Aa,BigInt(t)),go=e=>{if(!e||0===e.length)return!1;let t=e.split("::");return 3===t.length&&!(!co(t[0])&&"0x2"!=t[0]||0===t[1].length||0===t[2].length)},_o=e=>!(!e||0===e.length)&&!(e.split("::").length<3),fo=e=>("string"==typeof e&&(e=parseInt(e)),Number.isSafeInteger(e)),yo=e=>ho(e,BigInt(100),BigInt(0)),vo=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r]))return!1;return!0},To=e=>e>Pa?Pa:e;function wo(e){const t=e.trim();if(-1!==t.indexOf(".")){let e=t.length-1;for(;"0"===t[e];)e--;return"."===t[e]&&e--,t.slice(0,e+1)}return t}const Eo=(e,t)=>{if(!e)return"";if("0"===e)return"0";if(t<=0)return e;var r=t-e.length;return wo(0===r?"."+e:r<0?e.slice(0,Math.abs(r))+"."+e.slice(Math.abs(r)):"."+e.padStart(t,"0"))},xo=e=>{if(e){const t="0x2::coin::Coin<";let r=e.indexOf(t);if(r>=0){let s=e.slice(r+t.length,e.length-1);if(-1===s.indexOf("<")){for(;">"==s[s.length-1];)s=s.slice(0,-1);let e=s.lastIndexOf("::");return{isCoin:!0,coin:s,token:s.slice(e+2)}}}}return{isCoin:!1,coin:"",token:""}};function Oo(e,t){const r=e.length+1,s=new Uint8Array(r);return s.set([t],0),s.set(e,1),s}function Io(e){let t="";var r;return Math.abs(e)<1?(r=parseInt(e.toString().split("e-")[1]))&&(e*=Math.pow(10,r-1),t="0."+new Array(r).join("0")+e.toString().substring(2)):(r=parseInt(e.toString().split("+")[1]))>20&&(r-=20,t=(e/=Math.pow(10,r))+new Array(r+1).join("0")),t}function Co(e){let t;try{t=new URL(e)}catch(e){return!1}return"http:"===t.protocol||"https:"===t.protocol||"ipfs:"===t.protocol}const Bo=e=>{e.id&&(e?.onBegin&&e.onBegin(e.id),$o.Client().getObject({id:e.id,options:{showContent:!0,showType:!0,showOwner:!0}}).then((t=>{t.error?e?.onObjectErr&&e.onObjectErr(e.id,t.error):e?.onObjectRes&&e.onObjectRes(e.id,t)})).catch((t=>{console.log(t),e?.onObjectErr&&e.onObjectErr(e.id,t)})),$o.Client().getDynamicFields({parentId:e.id}).then((t=>{e?.onDynamicRes&&e.onDynamicRes(e.id,t),t.data.length>0&&$o.Client().multiGetObjects({ids:t.data.map((e=>e.objectId)),options:{showContent:!0}}).then((t=>{e?.onFieldsRes&&e.onFieldsRes(e.id,t)})).catch((t=>{console.log(t),e?.onFieldsErr&&e.onFieldsErr(e.id,t)}))})).catch((t=>{console.log(t),e?.onDynamicErr&&e.onDynamicErr(e.id,t)})))},So=e=>e?e.substring(0,1).toUpperCase()+e.substring(1):"";function Po(e){return e.some(((t,r)=>e.findIndex((e=>e===t))!==r))}var jo,Ao;!function(e){e.machine="machine",e.progress="progress",e.repository="repository",e.permission="permission",e.passport="passport",e.guard="guard",e.demand="demand",e.order="order",e.service="service",e.resource="resource",e.entity="entity",e.wowok="wowok",e.treasury="treasury",e.payment="payment",e.arbitration="arbitration",e.arb="arb"}(jo||(jo={})),function(e){e[e.TYPE_QUERY=1]="TYPE_QUERY",e[e.TYPE_NUMBER_ADD=2]="TYPE_NUMBER_ADD",e[e.TYPE_NUMBER_SUBTRACT=3]="TYPE_NUMBER_SUBTRACT",e[e.TYPE_NUMBER_MULTIPLY=4]="TYPE_NUMBER_MULTIPLY",e[e.TYPE_NUMBER_DEVIDE=5]="TYPE_NUMBER_DEVIDE",e[e.TYPE_NUMBER_MOD=6]="TYPE_NUMBER_MOD",e[e.TYPE_LOGIC_AS_U256_GREATER=11]="TYPE_LOGIC_AS_U256_GREATER",e[e.TYPE_LOGIC_AS_U256_GREATER_EQUAL=12]="TYPE_LOGIC_AS_U256_GREATER_EQUAL",e[e.TYPE_LOGIC_AS_U256_LESSER=13]="TYPE_LOGIC_AS_U256_LESSER",e[e.TYPE_LOGIC_AS_U256_LESSER_EQUAL=14]="TYPE_LOGIC_AS_U256_LESSER_EQUAL",e[e.TYPE_LOGIC_AS_U256_EQUAL=15]="TYPE_LOGIC_AS_U256_EQUAL",e[e.TYPE_LOGIC_EQUAL=16]="TYPE_LOGIC_EQUAL",e[e.TYPE_LOGIC_HAS_SUBSTRING=17]="TYPE_LOGIC_HAS_SUBSTRING",e[e.TYPE_LOGIC_NOT=18]="TYPE_LOGIC_NOT",e[e.TYPE_LOGIC_AND=19]="TYPE_LOGIC_AND",e[e.TYPE_LOGIC_OR=20]="TYPE_LOGIC_OR"}(Ao||(Ao={}));const ko=[[Ao.TYPE_LOGIC_AS_U256_GREATER,"Unsigned Integer >","The first item > anything that follows"],[Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL,"Unsigned Integer >=","The first item >= anything that follows"],[Ao.TYPE_LOGIC_AS_U256_LESSER,"Unsigned Integer <","The first item < anything that follows"],[Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL,"Unsigned Integer <=","The first item <= anything that follows"],[Ao.TYPE_LOGIC_AS_U256_EQUAL,"Unsigned Integer =","The first item = anything that follows"],[Ao.TYPE_LOGIC_EQUAL,"Equal","Data and type are exactly equal for all items"],[Ao.TYPE_LOGIC_HAS_SUBSTRING,"Has Sub String","The first item contains anything that follows"],[Ao.TYPE_LOGIC_NOT,"Not","Not operation"],[Ao.TYPE_LOGIC_AND,"And","All Items And operations"],[Ao.TYPE_LOGIC_OR,"Or","All Items Or operations"]];var Uo,No;!function(e){e[e.TYPE_BOOL=100]="TYPE_BOOL",e[e.TYPE_ADDRESS=101]="TYPE_ADDRESS",e[e.TYPE_U8=102]="TYPE_U8",e[e.TYPE_U64=103]="TYPE_U64",e[e.TYPE_VEC_U8=104]="TYPE_VEC_U8",e[e.TYPE_U128=105]="TYPE_U128",e[e.TYPE_VEC_ADDRESS=106]="TYPE_VEC_ADDRESS",e[e.TYPE_VEC_BOOL=107]="TYPE_VEC_BOOL",e[e.TYPE_VEC_VEC_U8=108]="TYPE_VEC_VEC_U8",e[e.TYPE_VEC_U64=109]="TYPE_VEC_U64",e[e.TYPE_VEC_U128=110]="TYPE_VEC_U128",e[e.TYPE_OPTION_ADDRESS=111]="TYPE_OPTION_ADDRESS",e[e.TYPE_OPTION_BOOL=112]="TYPE_OPTION_BOOL",e[e.TYPE_OPTION_U8=113]="TYPE_OPTION_U8",e[e.TYPE_OPTION_U64=114]="TYPE_OPTION_U64",e[e.TYPE_OPTION_U128=115]="TYPE_OPTION_U128",e[e.TYPE_OPTION_U256=116]="TYPE_OPTION_U256",e[e.TYPE_OPTION_STRING=117]="TYPE_OPTION_STRING",e[e.TYPE_OPTION_VEC_U8=118]="TYPE_OPTION_VEC_U8",e[e.TYPE_VEC_U256=119]="TYPE_VEC_U256",e[e.TYPE_STRING=120]="TYPE_STRING",e[e.TYPE_VEC_STRING=121]="TYPE_VEC_STRING",e[e.TYPE_U256=122]="TYPE_U256"}(Uo||(Uo={})),function(e){e[e.Address=200]="Address",e[e.Address_Vec=201]="Address_Vec",e[e.PositiveNumber=202]="PositiveNumber",e[e.PositiveNumber_Vec=203]="PositiveNumber_Vec",e[e.String=204]="String",e[e.String_Vec=205]="String_Vec",e[e.Bool=206]="Bool"}(No||(No={}));const Do=[{type:No.String,name:"string",description:"String."},{type:No.Address,name:"address",description:"Object id or Personal address."},{type:No.PositiveNumber,name:"unsigned integer",description:"Including u8, u16 ,..., u256"},{type:No.String_Vec,name:"string vector",description:"Vector of string."},{type:No.Address_Vec,name:"address vector",description:"Vector of address."},{type:No.PositiveNumber_Vec,name:"unsigned integer vector",description:"Vector of unsigned integer"},{type:No.Bool,name:"bool",description:"True or False."}],Yo=Object.values(Ao).filter((e=>"number"==typeof e)),Ro=Object.values(Uo).filter((e=>"number"==typeof e)),Vo=e=>Yo.includes(e),Mo=e=>Ro.includes(e),Jo=e=>e===Uo.TYPE_U128||e===Uo.TYPE_U256||e===Uo.TYPE_U64||e===Uo.TYPE_U8;var Fo;!function(e){e[e.TYPE_SIGNER=60]="TYPE_SIGNER",e[e.TYPE_CLOCK=61]="TYPE_CLOCK",e[e.TYPE_GUARD=62]="TYPE_GUARD",e[e.TYPE_CONSTANT=80]="TYPE_CONSTANT"}(Fo||(Fo={}));const Xo=[{type:Uo.TYPE_BOOL,name:"bool",description:"boolean. eg:true or false",validator:e=>!0===e||!1===e},{type:Uo.TYPE_ADDRESS,name:"address",description:"address or object-id. eg:0x6789af",validator:co},{type:Fo.TYPE_SIGNER,name:"txn signer",description:"signer address of the transaction"},{type:Fo.TYPE_GUARD,name:"guard address",description:"current guard address"},{type:Fo.TYPE_CLOCK,name:"txn time",description:"unsigned-64 number for the transaction time"},{type:Uo.TYPE_U64,name:"number",description:"unsigned-64 number. eg:23870233",validator:po},{type:Uo.TYPE_U8,name:"number",description:"unsigned-8 number. eg:255",validator:lo},{type:Uo.TYPE_VEC_U8,name:"string",description:'string or unsigned-8 number array. eg:"[1,2,3]"'},{type:Uo.TYPE_U128,name:"number",description:"unsigned-8 number. eg:12348900999",validator:mo},{type:Uo.TYPE_VEC_ADDRESS,name:"[address]",description:"address array. eg:[0x2277f2, 0x3344af]"},{type:Uo.TYPE_VEC_BOOL,name:"[bool]",description:"boolean array. eg:[true, false, true]"},{type:Uo.TYPE_VEC_VEC_U8,name:"[[number]]",description:'array of unsigned-8 number array. eg:["i", "like", "wowok"]'},{type:Uo.TYPE_VEC_U64,name:"[number]",description:"unsigned-64 number array. eg:[123, 778888, 42312]"},{type:Uo.TYPE_VEC_U128,name:"[number]",description:"unsigned-128 number array. eg:[123, 778888, 42312]"},{type:Uo.TYPE_OPTION_ADDRESS,name:"option",description:"option of address. eg:none or address"},{type:Uo.TYPE_OPTION_BOOL,name:"option",description:"option of bool. eg:none or boolean value"},{type:Uo.TYPE_OPTION_U8,name:"option",description:"option of u8. eg:none or u8 value"},{type:Uo.TYPE_OPTION_U64,name:"option",description:"option of u64. eg:none or u64 value"},{type:Uo.TYPE_OPTION_U128,name:"option",description:"option of u128. eg:none or u128 value"},{type:Uo.TYPE_OPTION_U256,name:"option",description:"option of u256. eg:none or u256 value"},{type:Uo.TYPE_VEC_U256,name:"[number]",description:"unsigned-256 number array. eg:[123, 778888, 42312]"},{type:Uo.TYPE_VEC_STRING,name:"[string]",description:'ascii string array. eg:["abc", "hi"]'},{type:Uo.TYPE_STRING,name:"string",description:'eg:"wowok"'},{type:Uo.TYPE_OPTION_STRING,name:"option",description:"option of string. eg:none or string value"},{type:Uo.TYPE_U256,name:"number",description:"unsigned-256 number. eg:12345678901233",validator:bo}];var Lo;!function(e){e.mainnet="mainnet",e.testnet="testnet",e.devnet="devnet",e.localnet="localnet"}(Lo||(Lo={}));const Go="0xdfb1985bea7c6be1764e1b9d57f6dcd2b94d2e8f5b2890f42944013ce21172e4";class $o{network="";packages=new Map;signer="";wowok_object="";entity_object="";treasury_cap="";oracle_object="";txb;static _instance;constructor(e=Lo.testnet){this.use_network(e),this.new_session()}static Instance(){return $o._instance||($o._instance=new $o),$o._instance}static Client(){return new ei({url:$o.Instance().networkUrl()})}client(){return new ei({url:this.networkUrl()})}use_network(e=Lo.testnet){switch(this.network=e,e){case Lo.localnet:case Lo.devnet:break;case Lo.testnet:this.packages.set("wowok","0x33fec6de2d8c1eb3940f691fb3b552e75ef4d99503b2b37233f2796f605651bb"),this.packages.set("base",Go),this.packages.set("wowok_origin","0x33fec6de2d8c1eb3940f691fb3b552e75ef4d99503b2b37233f2796f605651bb"),this.packages.set("base_origin","0xdfb1985bea7c6be1764e1b9d57f6dcd2b94d2e8f5b2890f42944013ce21172e4"),this.wowok_object="0xd76390f6bebcf2bf05d13984e4da0b8fa04df093e165e9ad4e68fe80bcced762",this.entity_object="0xed8ff6d066b2cf4011e3915d920fd7cf1b83e8e61cbb763a194683c67cee6f29",this.treasury_cap="0xb695974025c75cd53e185f307bb1de9a16a96f576b59537957cf7203a1b58bda",this.oracle_object="0x17cf5c6de4fe916a400a906756d76b9a092970d9b86430daf632ca0e9bba9fe1";break;case Lo.mainnet:this.packages.set("wowok",""),this.packages.set("base",""),this.packages.set("wowok_origin",""),this.packages.set("base_origin",""),this.wowok_object="",this.entity_object="",this.treasury_cap="",this.oracle_object=""}}package(e){return this.packages.get(e)??""}objectWowok(){return this.wowok_object}objectEntity(){return this.entity_object}objectOracle(){return this.oracle_object}objectTreasuryCap(){return this.treasury_cap}networkUrl(){switch(this.network){case Lo.localnet:return"http://127.0.0.1:9000";case Lo.devnet:return"https://fullnode.devnet.sui.io:443";case Lo.testnet:return"https://fullnode.testnet.sui.io:443";case Lo.mainnet:return"https://fullnode.mainnet.sui.io:443"}return""}machineFn=e=>`${this.packages.get("wowok")}::${jo.machine}::${e}`;progressFn=e=>`${this.packages.get("wowok")}::${jo.progress}::${e}`;repositoryFn=e=>`${this.packages.get("wowok")}::${jo.repository}::${e}`;permissionFn=e=>`${this.packages.get("wowok")}::${jo.permission}::${e}`;passportFn=e=>`${this.packages.get("wowok")}::${jo.passport}::${e}`;demandFn=e=>`${this.packages.get("wowok")}::${jo.demand}::${e}`;orderFn=e=>`${this.packages.get("wowok")}::${jo.order}::${e}`;serviceFn=e=>`${this.packages.get("wowok")}::${jo.service}::${e}`;resourceFn=e=>`${this.packages.get("wowok")}::${jo.resource}::${e}`;entityFn=e=>`${this.packages.get("wowok")}::${jo.entity}::${e}`;wowokFn=e=>`${this.packages.get("wowok")}::${jo.wowok}::${e}`;treasuryFn=e=>`${this.packages.get("wowok")}::${jo.treasury}::${e}`;paymentFn=e=>`${this.packages.get("wowok")}::${jo.payment}::${e}`;guardFn=e=>`${this.packages.get("base")}::${jo.guard}::${e}`;baseWowokFn=e=>`${this.packages.get("base")}::${jo.wowok}::${e}`;arbitrationFn=e=>`${this.packages.get("wowok")}::${jo.arbitration}::${e}`;arbFn=e=>`${this.packages.get("wowok")}::${jo.arb}::${e}`;query=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()}),s=e.map((e=>e.objectid)),i=await r.call("sui_multiGetObjects",[s,t]);for(let r=0;r<i.length;r++)e.forEach((e=>{e.callback(this,i[r],e,t)}));return i};query_raw=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()});return await r.call("sui_multiGetObjects",[e,t])};new_session=()=>(this.txb=new _s,this.txb);sessionCurrent=()=>this.txb?this.txb:this.new_session();sign_excute=async(e,t,r,s={showObjectChanges:!0})=>{const i=new ei({url:this.networkUrl()});e.forEach((e=>{e(this,r)}));const n=ea(t),a=Zn.fromSecretKey(n),o=await i.signAndExecuteTransaction({transaction:this.sessionCurrent(),signer:a,options:s});return this.txb=void 0,o};static SUI_TOKEN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";static SUI_COIN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<0x2::sui::SUI>";WOWOK_TOKEN_TYPE=()=>this.packages.get("base")+"::wowok::WOWOK";WOWOK_COIN_TYPE=()=>"0x2::coin::Coin<"+this.packages.get("base")+"::wowok::WOWOK>";COINS_TYPE=()=>{switch(this.network){case Lo.testnet:return this.CoinTypes_Testnet.filter((e=>!0!==e.alias));case Lo.mainnet:return this.CoinTypes_Mainnet.filter((e=>!0!==e.alias))}return[]};update_coinType=(e,t,r)=>{if(r&&e)switch(this.network){case Lo.testnet:(s=this.CoinTypes_Testnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Testnet=s;break;case Lo.mainnet:var s;(s=this.CoinTypes_Mainnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Mainnet=s}};explorerUrl=(e,t="object")=>this.network===Lo.testnet?"https://testnet.suivision.xyz/"+t+"/"+e:this.network===Lo.mainnet?"https://suivision.xyz/"+t+"/"+e:"";CoinTypes_Testnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:Go+"::wowok::WOWOK",decimals:9}];CoinTypes_Mainnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:Go+"::wowok::WOWOK",decimals:9},{symbol:"USDT",type:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",decimals:6},{symbol:"USDC",type:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",decimals:6},{symbol:"WETH",type:"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",decimals:8},{symbol:"WBNB",type:"0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN",decimals:8}];coinTypeInfo=(e,t)=>{if(!e)return"loading";return this.COINS_TYPE().find((t=>t?.type===e))||($o.Client().getCoinMetadata({coinType:e}).then((r=>{r?.decimals&&r?.symbol&&(this.update_coinType(e,r?.decimals,r?.symbol),t({symbol:r.symbol,decimals:r.decimals,type:e}))})).catch((e=>{console.log(e)})),"loading")};static CLOCK_OBJECT={objectId:"0x6",mutable:!1,initialSharedVersion:1};static TXB_OBJECT(e,t){return"string"==typeof t?e.object(t):t}static IsValidObjects=e=>vo(e,(e=>!(!e||"string"==typeof e&&!oe(e))));WOWOK_OBJECTS_TYPE=()=>Object.keys(jo).map((e=>(e===jo.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"+za(e)));WOWOK_OBJECTS_PREFIX_TYPE=()=>Object.keys(jo).map((e=>(e===jo.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"));hasPackage(e){for(let t of this.packages.values())if(e.includes(t))return!0;return!1}object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.lastIndexOf("::");if(r>0)return e.slice(r+2)}return""};module_object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.indexOf("::");if(r>0)return e.slice(r+2)}return""}}class zo{static Object_Type_Extra=()=>{let e=Object.keys(jo).map((e=>e+"::"+za(e)));return e.push("order::Discount"),e};static objectids_from_response=(e,t,r)=>{let s=new Map;return t?.objectChanges&&t.objectChanges.forEach((t=>{zo.Object_Type_Extra().forEach((r=>{"created"==t.type&&e.module_object_name_from_type_repr(t.objectType)===r&&(s.has(r)?s.get(r)?.push(t.objectId):s.set(r,[t.objectId]))}))})),r&&s.forEach(((e,t)=>{r.has(t)?r.set(t,r.get(t).concat(e)):r.set(t,e)})),s}}class qo{bounty_type;permission;object;txb;get_bounty_type(){return this.bounty_type}get_object(){return this.object}static From(e,t,r,s){let i=new qo(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}constructor(e,t,r){this.bounty_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i,n,a){io(n)||Ba(Ca.IsValidDesription),_o(t)||Ba(Ca.IsValidArgType,t),po(s)||Ba(Ca.IsValidUint,"time");let o=new qo(e,t,i);const d=e.sharedObjectRef($o.CLOCK_OBJECT);return o.object=a?e.moveCall({target:$o.Instance().demandFn("new_with_passport"),arguments:[a,e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),$o.TXB_OBJECT(e,i)],typeArguments:[t]}):e.moveCall({target:$o.Instance().demandFn("new"),arguments:[e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),$o.TXB_OBJECT(e,i)],typeArguments:[t]}),o}launch(){return this.txb.moveCall({target:$o.Instance().demandFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.bounty_type]})}refund(e){const t=this.txb.sharedObjectRef($o.CLOCK_OBJECT);e?this.txb.moveCall({target:$o.Instance().demandFn("refund_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("refund"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}expand_time(e,t,r){po(t)||Ba(Ca.IsValidUint,"time"),r?this.txb.moveCall({target:$o.Instance().demandFn("time_expand_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("time_expand"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_guard(e,t,r){e&&!$o.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"guard"),void 0===t||lo(t)||Ba(Ca.InvalidParam,"set_guard.service_identifier");let s=this.txb.pure.option("u8",void 0!==t?t:void 0);r?e?this.txb.moveCall({target:$o.Instance().demandFn("guard_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),s,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("guard_none_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):e?this.txb.moveCall({target:$o.Instance().demandFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),s,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().demandFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}yes(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:$o.Instance().demandFn("yes_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("yes"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}deposit(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().demandFn("deposit"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]})}present(e,t,r,s){io(r)||Ba(Ca.IsValidDesription,"present.tips"),t&&!_o(t)&&Ba(Ca.IsValidArgType,"service_pay_type"),"number"==typeof e?lo(e)&&s||Ba(Ca.IsValidU8,"present.service or present.passport"):$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"present.service"),s?"number"==typeof e?this.txb.moveCall({target:$o.Instance().demandFn("present_with_passport2"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(r)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("present_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]}):"number"!=typeof e&&this.txb.moveCall({target:$o.Instance().demandFn("present"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().demandFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]}),this.permission=e}static parseObjectType=e=>La(e,"demand::Demand<");static MAX_BOUNTY_COUNT=300;static MAX_PRESENTERS_COUNT=200}var Wo;!function(e){e[e.repository=100]="repository",e[e.repository_description=101]="repository_description",e[e.repository_mode=102]="repository_mode",e[e.repository_policies=103]="repository_policies",e[e.repository_reference=104]="repository_reference",e[e.service=200]="service",e[e.service_description=201]="service_description",e[e.service_sales=202]="service_sales",e[e.service_payee=203]="service_payee",e[e.service_repository=204]="service_repository",e[e.service_withdraw_guards=205]="service_withdraw_guards",e[e.service_refund_guards=206]="service_refund_guards",e[e.service_discount_transfer=207]="service_discount_transfer",e[e.service_withdraw=208]="service_withdraw",e[e.service_buyer_guard=209]="service_buyer_guard",e[e.service_machine=210]="service_machine",e[e.service_endpoint=211]="service_endpoint",e[e.service_publish=212]="service_publish",e[e.service_clone=213]="service_clone",e[e.service_customer_required=214]="service_customer_required",e[e.service_pause=215]="service_pause",e[e.service_treasury=216]="service_treasury",e[e.service_arbitration=217]="service_arbitration",e[e.demand=260]="demand",e[e.demand_refund=261]="demand_refund",e[e.demand_expand_time=262]="demand_expand_time",e[e.demand_guard=263]="demand_guard",e[e.demand_description=264]="demand_description",e[e.demand_yes=265]="demand_yes",e[e.machine=600]="machine",e[e.machine_description=601]="machine_description",e[e.machine_repository=602]="machine_repository",e[e.machine_clone=604]="machine_clone",e[e.machine_node=606]="machine_node",e[e.machine_endpoint=608]="machine_endpoint",e[e.machine_pause=609]="machine_pause",e[e.machine_publish=610]="machine_publish",e[e.progress=650]="progress",e[e.progress_namedOperator=651]="progress_namedOperator",e[e.progress_bind_task=652]="progress_bind_task",e[e.progress_context_repository=653]="progress_context_repository",e[e.progress_unhold=654]="progress_unhold",e[e.progress_parent=655]="progress_parent",e[e.treasury=700]="treasury",e[e.treasury_receive=701]="treasury_receive",e[e.treasury_deposit=702]="treasury_deposit",e[e.treasury_withdraw=703]="treasury_withdraw",e[e.treasury_descritption=704]="treasury_descritption",e[e.treasury_deposit_guard=705]="treasury_deposit_guard",e[e.treasury_withdraw_mode=706]="treasury_withdraw_mode",e[e.treasury_withdraw_guard=707]="treasury_withdraw_guard",e[e.arbitration=800]="arbitration",e[e.arbitration_description=801]="arbitration_description",e[e.arbitration_fee=802]="arbitration_fee",e[e.arbitration_voting_guard=803]="arbitration_voting_guard",e[e.arbitration_endpoint=804]="arbitration_endpoint",e[e.arbitration_guard=805]="arbitration_guard",e[e.arbitration_pause=806]="arbitration_pause",e[e.arbitration_vote=807]="arbitration_vote",e[e.arbitration_arbitration=808]="arbitration_arbitration",e[e.arbitration_withdraw=809]="arbitration_withdraw",e[e.arbitration_treasury=810]="arbitration_treasury",e[e.user_defined_start=1e3]="user_defined_start"}(Wo||(Wo={}));const Ho=[{index:Wo.repository,name:"Repository",description:"Launch new Repository",module:jo.repository},{index:Wo.repository_description,name:"Description",description:"Set Repository description",module:jo.repository},{index:Wo.repository_mode,name:"Policy mode",description:"Set Repository mode",module:jo.repository},{index:Wo.repository_policies,name:"Policy",description:"Set Repository policies",module:jo.repository},{index:Wo.repository_reference,name:"Reference",description:"Set Repository reference",module:jo.repository},{index:Wo.service,name:"Service",description:"Launch new Service",module:jo.service},{index:Wo.service_description,name:"Description",description:"Set Service description",module:jo.service},{index:Wo.service_sales,name:"Sales",description:"Set Service sales items",module:jo.service},{index:Wo.service_payee,name:"Payee",description:"Set Service payee",module:jo.service},{index:Wo.service_repository,name:"Repository",description:"Set Service repositories",module:jo.service},{index:Wo.service_withdraw_guards,name:"Withdraw Guard",description:"Set Service withdraw guards",module:jo.service},{index:Wo.service_refund_guards,name:"Refund Guard",description:"Set Service refund guards",module:jo.service},{index:Wo.service_discount_transfer,name:"Discount",description:"Launch discounts for Service",module:jo.service},{index:Wo.service_buyer_guard,name:"Buyer Guard",description:"Set Guard of buying for Service",module:jo.service},{index:Wo.service_machine,name:"Machine",description:"Set Machine for Service",module:jo.service},{index:Wo.service_endpoint,name:"Endpoint",description:"Set Service endpoint",module:jo.service},{index:Wo.service_publish,name:"Publish",description:"Allowing the creation of Order",module:jo.service},{index:Wo.service_clone,name:"Clone",description:"Clone Service",module:jo.service},{index:Wo.service_customer_required,name:"Buyer info",description:"Set Service buyer info required",module:jo.service},{index:Wo.service_pause,name:"Pause",description:"Pause/Unpause Service",module:jo.service},{index:Wo.service_treasury,name:"Treasury",description:"Externally withdrawable treasury for compensation or rewards",module:jo.service},{index:Wo.service_arbitration,name:"Arbitration",description:"Add/Remove arbitration that allows refunds from orders at any time based on arbitration results",module:jo.service},{index:Wo.demand,name:"Demand",description:"Launch new Demand",module:jo.demand},{index:Wo.demand_refund,name:"Refund",description:"Refund from Demand",module:jo.demand},{index:Wo.demand_expand_time,name:"Expand deadline",description:"Expand Demand deadline",module:jo.demand},{index:Wo.demand_guard,name:"Guard",description:"Set Demand guard",module:jo.demand},{index:Wo.demand_description,name:"Description",description:"Set Demand description",module:jo.demand},{index:Wo.demand_yes,name:"Yes",description:"Pick the Deamand serice",module:jo.demand},{index:Wo.machine,name:"Machine",description:"Launch new Machine",module:jo.machine},{index:Wo.machine_description,name:"Description",description:"Set Machine description",module:jo.machine},{index:Wo.machine_repository,name:"Repository",description:"Set Machine repository",module:jo.machine},{index:Wo.machine_clone,name:"Clone",description:"Clone Machine",module:jo.machine},{index:Wo.machine_node,name:"Node",description:"Set Machine nodes",module:jo.machine},{index:Wo.machine_endpoint,name:"Endpoint",description:"Set Machine endpoint",module:jo.machine},{index:Wo.machine_pause,name:"Pause",description:"Pause/Unpause Machine",module:jo.machine},{index:Wo.machine_publish,name:"Publish",description:"Allowing the creation of Progress",module:jo.machine},{index:Wo.progress,name:"Progress",description:"Launch new Progress",module:jo.progress},{index:Wo.progress_namedOperator,name:"Operator",description:"Set Progress operators",module:jo.progress},{index:Wo.progress_bind_task,name:"Bind",description:"Set Progress task",module:jo.progress},{index:Wo.progress_context_repository,name:"Repository",description:"Set Progress repository",module:jo.progress},{index:Wo.progress_unhold,name:"Unhold",description:"Release Progress holdings",module:jo.progress},{index:Wo.progress_parent,name:"Parent",description:"Set Progress parent",module:jo.progress},{index:Wo.treasury,name:"Treasury",description:"Launch new Treasury",module:jo.treasury},{index:Wo.treasury_deposit,name:"Deposit",description:"Deposit coins",module:jo.treasury},{index:Wo.treasury_receive,name:"Receive",description:"Receive coins from some address sent",module:jo.treasury},{index:Wo.treasury_withdraw,name:"Withdraw",description:"Withdraw coins",module:jo.treasury},{index:Wo.treasury_withdraw_guard,name:"Withdraw Guard",description:"Add/Remove Treasury withdraw guard",module:jo.treasury},{index:Wo.treasury_withdraw_mode,name:"Withdraw mode",description:"Set Treasury withdraw mode",module:jo.treasury},{index:Wo.treasury_deposit_guard,name:"Deposit Guard",description:"Set Treasury deposit guard",module:jo.treasury},{index:Wo.treasury_descritption,name:"Description",description:"Set Treasury description",module:jo.treasury},{index:Wo.arbitration,name:"Arbitration",description:"Launch new Arbitration",module:jo.arbitration},{index:Wo.arbitration_description,name:"Description",description:"Set Arbitration description",module:jo.arbitration},{index:Wo.arbitration_endpoint,name:"Endpoint",description:"Set Arbitration endpoint",module:jo.arbitration},{index:Wo.arbitration_fee,name:"Fee",description:"Set Arbitration fee",module:jo.arbitration},{index:Wo.arbitration_guard,name:"Guard",description:"Set Guard to apply for arbitration",module:jo.arbitration},{index:Wo.arbitration_arbitration,name:"Arbitrate",description:"Determine the outcome of arbitration",module:jo.arbitration},{index:Wo.arbitration_pause,name:"Pause",description:"Allowing/forbidding the creation of Arb",module:jo.arbitration},{index:Wo.arbitration_voting_guard,name:"Voting Guard",description:"Add/Remove voting Guard",module:jo.arbitration},{index:Wo.arbitration_vote,name:"Vote",description:"Vote on the application for arbitration",module:jo.arbitration},{index:Wo.arbitration_withdraw,name:"Withdraw",description:"Withdraw the arbitration fee",module:jo.arbitration},{index:Wo.arbitration_treasury,name:"Withdraw",description:"Set Treasury that fees was collected at the time of withdrawal",module:jo.arbitration}];class Ko{txb;object;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new Ko(e);return r.object=$o.TXB_OBJECT(e,t),r}static New(e,t){io(t)||Ba(Ca.IsValidDesription);let r=new Ko(e);return r.object=e.moveCall({target:$o.Instance().permissionFn("new"),arguments:[e.pure.string(t)]}),r}launch(){return this.txb.moveCall({target:$o.Instance().permissionFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}add_bizPermission(e,t){Ko.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"add_bizPermission"),no(t)||Ba(Ca.IsValidName,"add_bizPermission"),this.txb.moveCall({target:$o.Instance().permissionFn("user_define_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),this.txb.pure.string(t)]})}remove_bizPermission(e){Ko.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"remove_bizPermission"),this.txb.moveCall({target:$o.Instance().permissionFn("user_define_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e)]})}transfer_permission(e,t){co(e)&&co(t)||Ba(Ca.IsValidAddress,"transfer_permission"),this.txb.moveCall({target:$o.Instance().permissionFn("change_entity"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.address(t)]})}add_entity2(e,t){0!==e.length&&(vo(e,co)||Ba(Ca.IsValidArray,"add_entity2"),void 0!==t?this.txb.moveCall({target:$o.Instance().permissionFn("add_with_index"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(t),this.txb.pure.vector("address",$a(e))]}):this.txb.moveCall({target:$o.Instance().permissionFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}add_entity3(e){if(0===e.length)return;const t=[];e.forEach((e=>{e.entities.forEach((r=>{const s=t.find((e=>e.address===r.address));if(s){const t=s.permissions.find((t=>t.index===e.index));t?t.guard=r.guard:s.permissions.push({guard:r.guard,index:e.index})}else t.push({address:r.address,permissions:[{guard:r.guard,index:e.index}]})}))})),this.add_entity(t)}add_entity(e){if(0===e.length)return;let t=!0;e.forEach((e=>{co(e.address)||(t=!1),e.permissions.forEach((e=>{Ko.IsValidPermissionIndex(e.index)||(t=!1),e?.guard&&!$o.IsValidObjects([e.guard])&&(t=!1)}))})),t||Ba(Ca.InvalidParam,"add_entity.entities");let r=[];for(let t=0;t<e.length;t++){let s=e[t],i=[];for(let e=0;e<s.permissions.length;e++){let t=s.permissions[e];Ko.IsValidPermissionIndex(t.index)&&(i.includes(t.index)||(i.push(t.index),t?.guard&&r.push({address:s.address,index:t.index,guard:t.guard})))}i.length>0&&this.txb.moveCall({target:$o.Instance().permissionFn("add_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(s.address),this.txb.pure.vector("u64",i)]})}r.forEach((({address:e,index:t,guard:r})=>{this.txb.moveCall({target:$o.Instance().permissionFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,r)]})}))}set_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"address"),Ko.IsValidPermissionIndex(t)||Ko.IsValidBizPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex,"index"),r?this.txb.moveCall({target:$o.Instance().permissionFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,r)]}):this.txb.moveCall({target:$o.Instance().permissionFn("guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t)]})}remove_index(e,t){co(e)||Ba(Ca.IsValidAddress),0!==t.length&&(vo(t,Ko.IsValidPermissionIndex)||Ba(Ca.InvalidParam,"index"),this.txb.moveCall({target:$o.Instance().permissionFn("remove_index"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.vector("u64",$a(t))]}))}remove_entity(e){0!==e.length&&(vo(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:$o.Instance().permissionFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}set_description(e){io(e)||Ba(Ca.IsValidDesription),this.txb.moveCall({target:$o.Instance().permissionFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}add_admin(e){0!==e.length&&(vo(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:$o.Instance().permissionFn("admin_add_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}remove_admin(e,t){(t||0!==e.length)&&(vo(e,co)||Ba(Ca.IsValidArray,"admin"),t?this.txb.moveCall({target:$o.Instance().permissionFn("admins_clear"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]}):e&&this.txb.moveCall({target:$o.Instance().permissionFn("admin_remove_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}change_owner(e){co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:$o.Instance().permissionFn("builder_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}query_permissions_all(e){co(e)||Ba(Ca.InvalidParam,"query_permissions"),this.txb.moveCall({target:$o.Instance().permissionFn("query_permissions_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}QueryPermissions(e,t,r,s){this.query_permissions_all(t),$o.Client().devInspectTransactionBlock({sender:s??t,transactionBlock:this.txb}).then((s=>{if(s.results&&s.results[0].returnValues&&2!==s.results[0].returnValues.length)return void r({who:t,object:e});const i=Wa.getInstance().de(Oa.U8,Uint8Array.from(s.results[0].returnValues[0][0]));if(i===Ko.PERMISSION_ADMIN||i===Ko.PERMISSION_OWNER_AND_ADMIN)r({who:t,admin:!0,owner:i%2==1,items:[],object:e});else{const n=Wa.getInstance().de_perms(Uint8Array.from(s.results[0].returnValues[1][0]));r({who:t,admin:!1,owner:i%2==1,items:n.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e})}})).catch((s=>{console.log(s),r({who:t,object:e})}))}static HasPermission(e,t,r=!1){if(e){if(e.admin)return{has:!0,owner:e.owner};let r=e.items?.find((e=>e.query==t));return r?{has:r.permission,guard:r.guard,owner:e.owner}:{has:!1,guard:void 0,owner:e?.owner}}if(r)return{has:!1,guard:void 0,owner:!1}}static MAX_ADMIN_COUNT=64;static MAX_ENTITY_COUNT=2e3;static MAX_PERMISSION_INDEX_COUNT=200;static MAX_PERSONAL_PERMISSION_COUNT=200;static PERMISSION_NORMAL=0;static PERMISSION_OWNER=1;static PERMISSION_ADMIN=2;static PERMISSION_OWNER_AND_ADMIN=3;static BUSINESS_PERMISSIONS_START=Wo.user_defined_start;static IsValidBizPermissionIndex=e=>e>=Ko.BUSINESS_PERMISSIONS_START&&po(e);static IsValidPermissionIndex=e=>!!Object.values(Wo).includes(e)||Ko.IsValidBizPermissionIndex(e)}class Qo{txb;object;permission;get_object(){return this.object}static From(e,t,r){let s=new Qo(e,t);return s.object=$o.TXB_OBJECT(e,r),s}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static New(e,t,r,s,i){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription),s&&!oo(s)&&Ba(Ca.IsValidEndpoint);let n=new Qo(e,t),a=e.pure.option("string",s||void 0);return n.object=i?e.moveCall({target:$o.Instance().machineFn("new_with_passport"),arguments:[i,e.pure.string(r),a,$o.TXB_OBJECT(e,t)]}):e.moveCall({target:$o.Instance().machineFn("new"),arguments:[e.pure.string(r),a,$o.TXB_OBJECT(e,t)]}),n}add_node(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{no(e.name)||(r=!1),e.pairs.forEach((e=>{ao(e.prior_node)||(r=!1),e?.threshold&&!fo(e.threshold)&&(r=!1),e.forwards.forEach((e=>{""!==Qo.checkValidForward(e)&&(r=!1)}))}))})),r||Ba(Ca.InvalidParam,"add_node");let s=[];e.forEach((e=>{let t=this.txb.moveCall({target:$o.Instance().machineFn("node_new"),arguments:[this.txb.pure.string(e.name)]});e.pairs.forEach((e=>{let r=this.txb.pure.option("u32",e?.threshold);e.forwards.forEach((s=>{this.txb.moveCall({target:$o.Instance().machineFn("forward_add"),arguments:[t,this.txb.pure.string(e.prior_node),this.txb.pure.string(s.name),r,this.forward(s)]})})),0===e.forwards.length&&this.txb.moveCall({target:$o.Instance().machineFn("forward_add_none"),arguments:[t,this.txb.pure.string(e.prior_node),r]})})),s.push(t)})),this.add_node2(s,t)}forward(e){let t,r=e?.weight?e.weight:1;return e?.namedOperator&&no(e.namedOperator)?t=e?.guard?this.txb.moveCall({target:$o.Instance().machineFn("forward"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r),this.txb.object($o.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:$o.Instance().machineFn("forward2"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r)]}):void 0!==e?.permission&&po(e.permission)?t=e?.guard?this.txb.moveCall({target:$o.Instance().machineFn("forward3"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r),this.txb.object($o.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:$o.Instance().machineFn("forward4"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r)]}):Ba(Ca.InvalidParam,"forward"),e?.suppliers?.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"forward.suppliers:"+e.object),this.txb.moveCall({target:$o.Instance().serviceFn("add_to"),arguments:[this.txb.object(e.object),this.txb.pure.bool(e.bOptional),t],typeArguments:[e.pay_token_type]})})),t}add_node2(e,t){if(0===e.length)return;let r=e.map((e=>$o.TXB_OBJECT(this.txb,e)));t?this.txb.moveCall({target:$o.Instance().machineFn("node_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),$o.TXB_OBJECT(this.txb,this.permission)]})}fetch_node(e,t){return no(e)||Ba(Ca.IsValidName,"fetch_node"),t?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}rename_node(e,t,r){e!==t&&(no(e)||Ba(Ca.IsValidName,"rename_node"),no(t)||Ba(Ca.IsValidName,"rename_node"),r?this.txb.moveCall({target:$o.Instance().machineFn("node_rename_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_rename"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}))}remove_node(e,t=!1,r){0!==e.length&&(vo(e,no)||Ba(Ca.IsValidArray,"nodes_name"),r?this.txb.moveCall({target:$o.Instance().machineFn("node_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)]}))}launch(){return this.txb.moveCall({target:$o.Instance().machineFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().machineFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}add_repository(e,t){t?this.txb.moveCall({target:$o.Instance().machineFn("repository_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)]})}remove_repository(e,t,r){(t||0!==e.length)&&(vo(e,co)||Ba(Ca.IsValidArray,"remove_repository"),r?t?this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.object)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}clone(e,t){let r;return r=t?this.txb.moveCall({target:$o.Instance().machineFn("clone_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("clone"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}),e?this.txb.moveCall({target:$o.Instance().machineFn("create"),arguments:[$o.TXB_OBJECT(this.txb,r)]}):r}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:$o.Instance().machineFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().machineFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)]})}publish(e){e?this.txb.moveCall({target:$o.Instance().machineFn("publish_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("publish"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"new_permission"),this.txb.moveCall({target:$o.Instance().machineFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}add_forward(e,t,r,s,i,n){ao(e)||Ba(Ca.IsValidName_AllowEmpty,"add_forward"),no(t)||Ba(Ca.IsValidName,"add_forward");const a=Qo.checkValidForward(r);let o;a&&Ba(Ca.InvalidParam,a),o=n?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]});const d=this.forward(r),c=this.txb.pure.option("u32",s);this.txb.moveCall({target:$o.Instance().machineFn("forward_add"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(r.name),c,d]}),i&&i!==r.name&&this.txb.moveCall({target:$o.Instance().machineFn("forward_remove"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(i)]}),this.add_node2([o],n)}remove_pair(e,t,r){let s;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_pair"),no(t)||Ba(Ca.IsValidName,"remove_pair"),s=r?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:$o.Instance().machineFn("pair_remove"),arguments:[s,this.txb.pure.string(e)]}),this.add_node2([s],r)}remove_forward(e,t,r,s){let i;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_forward"),no(t)||Ba(Ca.IsValidName,"remove_forward"),i=s?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:$o.Instance().machineFn("forward_remove"),arguments:[i,this.txb.pure.string(e),this.txb.pure.string(r)]}),this.add_node2([i],s)}static rpc_de_nodes(e){const t=[];return e.forEach((e=>{t.push({name:e.data.content.fields.name,pairs:Qo.rpc_de_pair(e?.data.content.fields.value)})})),t}static rpc_de_pair(e){let t=[];return e.fields.value.fields.contents.forEach((e=>{let r=[];e.fields.value.fields.forwards.fields.contents.forEach((e=>{let t=e.fields.key,s=e.fields.value.fields.weight,i=e.fields.value.fields.guard,n=e.fields.value.fields.namedOperator,a=e.fields.value.fields.permission_index;r.push({name:t,namedOperator:n,permission:a,weight:s,guard:i||"",suppliers:e.fields.value.fields.suppliers.fields.contents.map((e=>({object:e.fields.key,bOptional:e.fields.value,pay_token_type:""})))})})),t.push({prior_node:e.fields.key,threshold:e.fields.value.fields.threshold,forwards:r})})),t}static namedOperators(e){let t=[];return e.forEach((e=>{e.pairs.forEach((e=>{e.forwards.forEach((e=>{e?.namedOperator&&!t.find((t=>t===e.namedOperator))&&t.push(e.namedOperator)}))}))})),t}static checkValidForward(e){return no(e.name)?e?.namedOperator&&!ao(e?.namedOperator)?"Progress Operator invalid":e?.permission&&!Ko.IsValidPermissionIndex(e?.permission)?"Permission index invalid":e?.permission||e?.namedOperator?e?.weight&&!po(e.weight)?"Weight invalid":"":"Business-Permissions invalid":"Forward name invalid"}static INITIAL_NODE_NAME="";static OPERATOR_ORDER_PAYER="OrderPayer"}class Zo{permission;machine;object;txb;get_object(){return this.object}constructor(e,t,r){this.permission=r,this.txb=e,this.machine=t,this.object=""}static From(e,t,r,s){let i=new Zo(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i){$o.IsValidObjects([t,r])||Ba(Ca.IsValidObjects,"machine & permission");let n=new Zo(e,t,r),a=e.pure.option("address",s||void 0);return n.object=i?e.moveCall({target:$o.Instance().progressFn("new_with_passport"),arguments:[i,a,$o.TXB_OBJECT(e,t),$o.TXB_OBJECT(e,r)]}):e.moveCall({target:$o.Instance().progressFn("new"),arguments:[a,$o.TXB_OBJECT(e,t),$o.TXB_OBJECT(e,r)]}),n}launch(){return this.txb.moveCall({target:$o.Instance().progressFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}set_namedOperator(e,t,r){no(e)||Ba(Ca.IsValidName,"name"),e===Qo.OPERATOR_ORDER_PAYER&&Ba(Ca.InvalidParam,"name cannot be "+Qo.OPERATOR_ORDER_PAYER),(t.length>Zo.MAX_NAMED_OPERATOR_COUNT||!vo(t,co))&&Ba(Ca.InvalidParam,"addresses"),r?this.txb.moveCall({target:$o.Instance().progressFn("namedOperator_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",$a(t)),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("namedOperator_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",$a(t)),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}bind_task(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:$o.Instance().progressFn("task_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("task_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}set_context_repository(e,t){e&&!$o.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"repository"),t?e?this.txb.moveCall({target:$o.Instance().progressFn("context_repository_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("context_repository_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):e?this.txb.moveCall({target:$o.Instance().progressFn("context_repository_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("context_repository_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}unhold(e,t){Zo.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"unhold");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?this.txb.moveCall({target:$o.Instance().progressFn("unhold_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]}):this.txb.moveCall({target:$o.Instance().progressFn("unhold"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}parent_none(e){e?this.txb.moveCall({target:$o.Instance().progressFn("parent_none_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("parent_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}parent(e,t){co(e.parent_id)&&fo(e.parent_session_id)||Ba(Ca.InvalidParam,"parent"),e.next_node&&e.forward||Ba(Ca.InvalidParam,"parent"),t?this.txb.moveCall({target:$o.Instance().progressFn("parent_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("parent_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission)]})}deliverable(e){io(e.msg)||Ba(Ca.IsValidDesription,"deliverable.msg"),e.orders.length>0&&!$o.IsValidObjects(e.orders.map((e=>e.object)))&&Ba(Ca.IsValidObjects,"deliverable.orders");const t=this.txb.moveCall({target:$o.Instance().progressFn("deliverable_new"),arguments:[this.txb.pure.string(e.msg)]});return e.orders.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"deliverable.orders:"+e.object),this.txb.moveCall({target:$o.Instance().orderFn("as_deliverable"),arguments:[this.txb.object(e.object),t],typeArguments:[e.pay_token_type]})})),t}next(e,t,r){Zo.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"next");const s=this.deliverable(t),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?this.txb.moveCall({target:$o.Instance().progressFn("next_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]}):this.txb.moveCall({target:$o.Instance().progressFn("next"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]})}hold(e,t){Zo.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"hold");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return this.txb.moveCall({target:$o.Instance().progressFn("hold"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}static QueryForwardGuard=async(e,t,r,s,i)=>{if(!(e&&t&&s&&i))return void Ba(Ca.InvalidParam,"QueryForwardGuard");const n=new _s;n.moveCall({target:$o.Instance().progressFn("query_guard"),arguments:[$o.TXB_OBJECT(n,e),$o.TXB_OBJECT(n,t),n.pure.string(s),n.pure.string(i)]});const a=await $o.Client().devInspectTransactionBlock({sender:r,transactionBlock:n});if(1===a.results?.length&&1===a.results[0].returnValues?.length){const e=Wa.getInstance().de("Option<address>",Uint8Array.from(a.results[0].returnValues[0][0]));return e?.some?"0x"+e?.some:void 0}};static DeSessions=e=>{let t=[];return e?.fields?.contents?.forEach((e=>{var r={next_node:e.fields.key,holders:[],weights:e.fields.value.fields.weights,threshold:e.fields.value.fields.threshold};e.fields.value.fields.forwards.fields.contents.forEach((e=>{r.holders.push({forward:e.fields.key,accomplished:e.fields.value.fields.accomplished,time:e.fields.value.fields.time,who:e.fields.value.fields.who,deliverable:{msg:e.fields.value.fields.msg,orders:e.fields.value.fields.orders??[]}})})),t.push(r)})),t};static DeHistories=e=>e?.map((e=>Zo.DeHistory(e?.data?.content?.fields)));static DeHistory=e=>({id:parseInt(e?.name),node:e?.value?.fields?.node,next_node:e?.value?.fields?.next_node,sessions:Zo.DeSessions(e?.value.fields?.session),time:e?.value?.fields?.time});static MAX_NAMED_OPERATOR_COUNT=20;static MAX_DELEVERABLE_ORDER_COUNT=20;static IsValidProgressNext=e=>no(e.forward)&&no(e.next_node_name)}const ed=[[jo.permission,"Owner",1,[],Uo.TYPE_ADDRESS,"Owner's address."],[jo.permission,"Is Admin",2,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is a certain address an administrator?",["address"]],[jo.permission,"Has Rights",3,[Uo.TYPE_ADDRESS,Uo.TYPE_U64],Uo.TYPE_BOOL,"Does an address have a certain permission(Admin always have permissions)?",["address","permission index"]],[jo.permission,"Contains Address",4,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether an address is included in the personnel permission table?",["address"]],[jo.permission,"Contains Permission",5,[Uo.TYPE_ADDRESS,Uo.TYPE_U64],Uo.TYPE_BOOL,"Whether a certain permission for a certain address is defined in the personnel permission table?",["address","permission index"]],[jo.permission,"Contains Permission Guard",6,[Uo.TYPE_ADDRESS,Uo.TYPE_U64],Uo.TYPE_BOOL,"Whether a permission guard for a certain address is defined in the personnel permission table?",["address","permission index"]],[jo.permission,"Permission Guard",7,[Uo.TYPE_ADDRESS,Uo.TYPE_U64],Uo.TYPE_ADDRESS,"Permission guard for a certain address.",["address","permission index"]],[jo.permission,"Number of Entities",8,[],Uo.TYPE_U64,"Number of entities in the personnel permission table.",[]],[jo.permission,"Number of Admin",9,[],Uo.TYPE_U64,"Number of administrators.",[]],[jo.repository,"Permission",100,[],Uo.TYPE_ADDRESS,"Permission object address.",[]],[jo.repository,"Contains Policy",101,[Uo.TYPE_STRING],Uo.TYPE_BOOL,"Is a consensus policy included?",["the filed name"]],[jo.repository,"Is Permission set of Policy",102,[Uo.TYPE_STRING],Uo.TYPE_BOOL,"Does a certain consensus policy set data operation permissions?",["the policy name"]],[jo.repository,"Permission of Policy",103,[Uo.TYPE_STRING],Uo.TYPE_U64,"The permission index of a certain consensus policy in the Permission object.",["the policy name"]],[jo.repository,"Value Type of Policy",104,[Uo.TYPE_STRING],Uo.TYPE_U8,"Data types defined by consensus policy.",["the policy name"]],[jo.repository,"Contains Data",105,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_BOOL,"Does it contain data for a certain field of an address?",["address","the field name"]],[jo.repository,"Raw data without Type",106,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_VEC_U8,"Data for a field at an address and does not contain data type information.",["address","the field name"]],[jo.repository,"Raw data",107,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_VEC_U8,"Data for a field at an address, and the first byte contains data type information.",["address","the field name"]],[jo.repository,"Type",108,[],Uo.TYPE_U8,"The repository Type. 0: Normal; 1: Wowok greenee.",[]],[jo.repository,"Policy Mode",109,[],Uo.TYPE_U8,"Policy Mode. 0: Free mode; 1: Strict mode.",[]],[jo.repository,"Reference Count",110,[],Uo.TYPE_U64,"The number of times it is referenced by other objects.",[]],[jo.repository,"Is Referenced by An Object",111,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is it referenced by an object?",["address"]],[jo.repository,"Number Data",112,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_U256,"Data for a field at an address and get unsigned integer type data.",["address","the field name"]],[jo.repository,"String Data",113,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_STRING,"Data for a field at an address and get string type data.",["address","the field name"]],[jo.repository,"Address Data",114,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_ADDRESS,"Data for a field at an address and get address type data.",["address","the field name"]],[jo.repository,"Bool Data",115,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_BOOL,"Data for a field at an address and get bool type data.",["address","the field name"]],[jo.repository,"Number Vector Data",116,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_VEC_U256,"Data for a field at an address and get unsigned integer vector type data.",["address","the field name"]],[jo.repository,"String Vector Data",117,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_VEC_STRING,"Data for a field at an address and get string vector type data.",["address","the field name"]],[jo.repository,"Address Vector Data",118,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_VEC_ADDRESS,"Data for a field at an address and get address vector type data.",["address","the field name"]],[jo.repository,"Bool Vector Data",119,[Uo.TYPE_ADDRESS,Uo.TYPE_STRING],Uo.TYPE_VEC_BOOL,"Data for a field at an address and get bool vector type data.",["address","the field name"]],[jo.entity,"Has Entity",200,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is an entity already registered?",["address"]],[jo.entity,"Likes",201,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The number of likes for an address by other addresses.",["address"]],[jo.entity,"Dislikes",202,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The number of dislikes for an address by other addresses.",["address"]],[jo.entity,"Entity Info",203,[Uo.TYPE_ADDRESS],Uo.TYPE_VEC_U8,"Public information about an entity.",["address"]],[jo.entity,"Has Resource by Entity?",204,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether an entity created a resource?",["address"]],[jo.entity,"Entity Resource",205,[Uo.TYPE_ADDRESS],Uo.TYPE_ADDRESS,"The address of a resource object created by an entity.",["address"]],[jo.demand,"Permission",300,[],Uo.TYPE_ADDRESS,"Permission object address.",[]],[jo.demand,"Deadline",302,[],Uo.TYPE_U64,"The expiration time of presenting.",[]],[jo.demand,"Bounty Count",303,[],Uo.TYPE_U64,"Number of Bounties.",[]],[jo.demand,"Has Guard",304,[],Uo.TYPE_BOOL,"Whether the present guard is set?",[]],[jo.demand,"Guard",305,[],Uo.TYPE_ADDRESS,"The present guard address.",[]],[jo.demand,"Has Service Picked",306,[],Uo.TYPE_BOOL,"Whether a service has been picked and bounties given?",[]],[jo.demand,"Service Picked",307,[],Uo.TYPE_ADDRESS,"Service address that has been picked.",[]],[jo.demand,"Presenter Count",308,[],Uo.TYPE_U64,"Number of presenters.",[]],[jo.demand,"Has Presenter",309,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is a certain address a presenter?",["address"]],[jo.demand,"Who Got Bounty",310,[Uo.TYPE_ADDRESS],Uo.TYPE_ADDRESS,"The address that bounties given.",["address"]],[jo.service,"Permission",400,[],Uo.TYPE_ADDRESS,"Permission object address.",[]],[jo.service,"Payee",401,[],Uo.TYPE_ADDRESS,"Payee address, that all order withdrawals will be collected to this address.",[]],[jo.service,"Has Buying Guard",402,[],Uo.TYPE_BOOL,"Is the guard condition of buying set?",[]],[jo.service,"Buying Guard",403,[],Uo.TYPE_ADDRESS,"Buying guard, that Purchase only if you meet the conditions of the guard.",[]],[jo.service,"Contains Repository",404,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is a certain repository one of the service's consensus repositories?",["address"]],[jo.service,"Has Withdrawing Guard",405,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether a certain guard is set when withdrawing money?",["address"]],[jo.service,"Withdrawing Guard Percent",406,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The percentage of withdrawals allowed by a certain withdrawal guard.",["address"]],[jo.service,"Has Refunding Guard",407,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether a certain guard is set when refunding money?",["address"]],[jo.service,"Refunding Guard Percent",408,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The percentage of refund allowed by a certain refund guard.",["address"]],[jo.service,"Has Sales Item",409,[Uo.TYPE_STRING],Uo.TYPE_BOOL,"Is there a sales item for the service?",["the item name"]],[jo.service,"Sale Item Price",410,[Uo.TYPE_STRING],Uo.TYPE_U64,"What is the price of a certain sale item?",["the item name"]],[jo.service,"Sale Item Inventory",411,[Uo.TYPE_STRING],Uo.TYPE_U64,"How much inventory is there for a certain sales item?",["the item name"]],[jo.service,"Has Machine",412,[],Uo.TYPE_BOOL,"Has the machine(progress generator) that serves the order been set up?",[]],[jo.service,"Machine",413,[],Uo.TYPE_ADDRESS,"Machine address, that generate progresses serving the execution process of order.",[]],[jo.service,"Paused",414,[],Uo.TYPE_BOOL,"Pause the creation of new order?"],[jo.service,"Published",415,[],Uo.TYPE_BOOL,"Is it allowed to create orders?"],[jo.service,"Has Required Info",416,[],Uo.TYPE_BOOL,"Whether the necessary information that needs to be provided by the customer is set?",[]],[jo.service,"Required Info of Service-Pubkey",417,[],Uo.TYPE_STRING,"The public key used to encrypt customer information, and only the service provider can decrypt and view customer information.",[]],[jo.service,"Required Info",418,[],Uo.TYPE_VEC_STRING,"Names of the required information item that needs to be provided by the customer.",[]],[jo.service,"Number of Treasuries",419,[],Uo.TYPE_U64,"The number of treasuries that can be externally withdrawn for purposes such as compensation or incentives.",[]],[jo.service,"Contains Treasury",420,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Does it contain externally withdrawable Treasury for purposes such as compensation or incentives?",["treasury address"]],[jo.service,"Number of Arbitrations",421,[],Uo.TYPE_U64,"The number of arbitrations that allows a refund to be made from the order at any time based on the arbitration result.",[]],[jo.service,"Contains Arbitration",422,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Does it contain an arbitration that allows a refund to be made from the order at any time based on the arbitration result.?",["arbitration address"]],[jo.order,"Amount",500,[],Uo.TYPE_U64,"Order amount.",[]],[jo.order,"Payer",501,[],Uo.TYPE_ADDRESS,"Order payer.",[]],[jo.order,"Service",502,[],Uo.TYPE_ADDRESS,"Service for creating orders.",[]],[jo.order,"Has Progress",503,[],Uo.TYPE_BOOL,"Is there a Progress for executing the order process?",[]],[jo.order,"Progress",504,[],Uo.TYPE_ADDRESS,"Progress address for executing the order process.",[]],[jo.order,"Required Info",505,[],Uo.TYPE_BOOL,"Is Required Info set?",[]],[jo.order,"Discount Used",506,[],Uo.TYPE_BOOL,"Discount coupon used for this order?",[]],[jo.order,"Discount",507,[],Uo.TYPE_ADDRESS,"Discount address that already used.",[]],[jo.order,"Balance",508,[],Uo.TYPE_U64,"The amount currently in the order.",[]],[jo.order,"Number of Agents",511,[],Uo.TYPE_U64,"The number of agents for the order.",[]],[jo.order,"Has Agent",512,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether an address is an order agent?",["agent address"]],[jo.order,"Number of Disputes",513,[],Uo.TYPE_U64,"Number of arbitrations for the order.",[]],[jo.order,"Has Arb",514,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Does the order contain an Arb for arbitration?",["arb address"]],[jo.machine,"Permission",700,[],Uo.TYPE_ADDRESS,"Permission object address.",[]],[jo.machine,"Paused",701,[],Uo.TYPE_BOOL,"Pause the creation of new Progress?",[]],[jo.machine,"Published",702,[],Uo.TYPE_BOOL,"Is it allowed to create Progress?",[]],[jo.machine,"Is Consensus Repository",703,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether an address is a consensus repository?",["adddress"]],[jo.machine,"Has Endpoint",704,[],Uo.TYPE_BOOL,"Is the endpoint set?",[]],[jo.machine,"Endpoint",705,[],Uo.TYPE_STRING,"Endpoint url/ipfs.",[]],[jo.progress,"Machine",800,[],Uo.TYPE_ADDRESS,"The Machine object that created this Progress.",[]],[jo.progress,"Current Node",801,[],Uo.TYPE_STRING,"The name of the currently running node.",[]],[jo.progress,"Has Parent",802,[],Uo.TYPE_BOOL,"Is the parent Progress defined?",[]],[jo.progress,"Parent",803,[],Uo.TYPE_ADDRESS,"The parent Progress, that contains some child Progress.",[]],[jo.progress,"Has Task",804,[],Uo.TYPE_BOOL,"Does it contain clear task(eg. an Order)?",[]],[jo.progress,"Task",805,[],Uo.TYPE_ADDRESS,"Task object address.",[]],[jo.progress,"Has Unique Permission",806,[Uo.TYPE_STRING],Uo.TYPE_BOOL,"Does Progress define a unique operation permission?",["operator name"]],[jo.progress,"Is Unique Permission Operator",807,[Uo.TYPE_STRING,Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is an address an operator with unique permissions?",["operator name","address"]],[jo.progress,"Has Context Repository",808,[],Uo.TYPE_BOOL,"Whether the repository reference for Progress is set?",[]],[jo.progress,"Context Repository",809,[],Uo.TYPE_ADDRESS,"Repository reference for Progress.",[]],[jo.progress,"Last Session Time",810,[],Uo.TYPE_U64,"Time when the previous session was completed.",[]],[jo.progress,"Last Session Node",811,[],Uo.TYPE_STRING,"The name of the last completed node.",[]],[jo.progress,"Current Session-id",812,[],Uo.TYPE_U64,"The session id of ongoing node.",[]],[jo.progress,"Parent Session-id",813,[],Uo.TYPE_U64,"The child process was started in the Session-id phase of the parent process.",[]],[jo.progress,"Parent Next Node",814,[],Uo.TYPE_STRING,"The child process is started at the next node stage of the parent process.",[]],[jo.progress,"Parent Forward",815,[],Uo.TYPE_STRING,"The child process is started in the Forward phase of the next node of the parent process.",[]],[jo.progress,"Parent Node",816,[],Uo.TYPE_STRING,"The node name of the parent process where the child process is located.",[]],[jo.progress,"Forward Accomplished",817,[Uo.TYPE_U64,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_BOOL,"Has the forward been accomplished?",["session-id","next node name","forward name"]],[jo.progress,"Forward Operator",818,[Uo.TYPE_U64,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_ADDRESS,"The forward operator.",["session-id","next node name","forward name"]],[jo.progress,"Forward Message",819,[Uo.TYPE_U64,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_STRING,"The forward message.",["session-id","next node name","forward name"]],[jo.progress,"Forward Order Count",820,[Uo.TYPE_U64,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_U64,"The forward Order count.",["session-id","next node name","forward name"]],[jo.progress,"Forward time",821,[Uo.TYPE_U64,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_U64,"The time when the forward was last triggered.",["session-id","next node name","forward name"]],[jo.progress,"Closest Session Time",822,[Uo.TYPE_STRING],Uo.TYPE_U64,"The time a node that closest time to the current node completes its session.",["node name"]],[jo.progress,"Closest Forward Accomplished",823,[Uo.TYPE_STRING,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_BOOL,"Has the forward been accomplished?",["node name","next node name","forward name"]],[jo.progress,"Closest Forward Operator",824,[Uo.TYPE_STRING,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_ADDRESS,"The operator of the forward that closest time to the current node.",["node name","next node name","forward name"]],[jo.progress,"Closest Forward Message",825,[Uo.TYPE_STRING,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_STRING,"The message of the forward that closest time to the current node.",["node name","next node name","forward name"]],[jo.progress,"Closest Forward Order Count",826,[Uo.TYPE_STRING,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_U64,"The Order count of the forward that closest time to the current node.",["node name","next node name","forward name"]],[jo.progress,"Closest Forward time",827,[Uo.TYPE_STRING,Uo.TYPE_STRING,Uo.TYPE_STRING],Uo.TYPE_U64,"The time when the forward that closest time to the current node was last triggered.",["node name","next node name","forward name"]],[jo.wowok,"Builder",900,[],Uo.TYPE_ADDRESS,"Builder address of Wowok.",[]],[jo.wowok,"Object of Entities",901,[],Uo.TYPE_ADDRESS,"The address of entity information object.",[]],[jo.wowok,"Grantor Count",902,[],Uo.TYPE_U64,"Number of registered grantors.",[]],[jo.wowok,"Has Grantor",903,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether an address has been registered as a grantor?",["address"]],[jo.wowok,"Grantor Name",904,[Uo.TYPE_ADDRESS],Uo.TYPE_STRING,"Name of a grantor.",["address"]],[jo.wowok,"Grantor Registration Time",905,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Registration time of a grantor.",["address"]],[jo.wowok,"Grantor Expired Time",906,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The expiration time of a grantor.",["address"]],[jo.wowok,"Grantee Object for Grantor",907,[Uo.TYPE_ADDRESS],Uo.TYPE_ADDRESS,"Grantee repository address of a grantor.",["address"]],[jo.payment,"Sender",1200,[],Uo.TYPE_ADDRESS,"Payment originator address.",[]],[jo.payment,"Total Amount",1201,[],Uo.TYPE_U128,"Payment amount.",[]],[jo.payment,"Remark",1202,[],Uo.TYPE_STRING,"Payment remark.",["address"]],[jo.payment,"Has Guard for Perpose",1203,[],Uo.TYPE_BOOL,"Whether the payment references a Guard?",[]],[jo.payment,"Has Object for Perpose",1204,[],Uo.TYPE_BOOL,"Whether the payment references an Object?",[]],[jo.payment,"Guard for Perpose",1205,[],Uo.TYPE_ADDRESS,"The Guard referenced by this payment.",[]],[jo.payment,"Object for Perpose",1206,[],Uo.TYPE_ADDRESS,"The Object referenced by this payment.",[]],[jo.payment,"Number of Recipients",1207,[],Uo.TYPE_U64,"Number of recipients to receive payment from.",[]],[jo.payment,"Is a Recipient",1208,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Is a recipient received the payment?",["address"]],[jo.payment,"Amount for a Recipient",1209,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The amount of payment received by an address.",["address"]],[jo.payment,"Time",1210,[],Uo.TYPE_U64,"Payment time",[]],[jo.payment,"Is from Treasury",1211,[],Uo.TYPE_BOOL,"Whether the payment comes from a Treasury?",[]],[jo.payment,"Treasury Address",1212,[],Uo.TYPE_ADDRESS,"The Treasury from which the payment comes.",[]],[jo.payment,"Biz-ID",1213,[],Uo.TYPE_U64,"Bisiness ID number of the payment.",[]],[jo.payment,"Check the purpose of payment",1214,[Uo.TYPE_ADDRESS,Uo.TYPE_ADDRESS,Uo.TYPE_U64],Uo.TYPE_BOOL,"Do Guard, Object Perpose, and Biz-ID match?",["guard address","object address","Biz-ID"]],[jo.payment,"Check & Amount for a Recipient",1215,[Uo.TYPE_ADDRESS,Uo.TYPE_ADDRESS,Uo.TYPE_U64,Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Check and get the amount of payment received by an address.",["guard address","object address","Biz-ID","recipient address"]],[jo.treasury,"Permission",1400,[],Uo.TYPE_ADDRESS,"Permission object address.",[]],[jo.treasury,"Balance",1401,[],Uo.TYPE_U64,"Treasury balance.",[]],[jo.treasury,"Number of Flow Records",1402,[],Uo.TYPE_U64,"Number of treasury transactions.",[]],[jo.treasury,"Inflow Amount",1403,[],Uo.TYPE_U128,"Treasury inflow amount.",[]],[jo.treasury,"Outflow Amount",1404,[],Uo.TYPE_U128,"Treasury outflow amount.",[]],[jo.treasury,"Has Deposit Guard",1405,[],Uo.TYPE_BOOL,"Whether the deposit Guard set?",[]],[jo.treasury,"Deposit Guard",1406,[],Uo.TYPE_ADDRESS,"Deposit Guard address.",[]],[jo.treasury,"Number of Withdraw Guards",1407,[],Uo.TYPE_U64,"Number of withdraw guards.",[]],[jo.treasury,"Has Withdraw Guard",1408,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Has a Withdraw Guard added?",["guard address"]],[jo.treasury,"Withdrawal Amount with Guard",1409,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"withdrawal amount corresponding the Guard.",["guard address"]],[jo.treasury,"Recent Time with Operation",1410,[Uo.TYPE_U8],Uo.TYPE_U64,"Time of the most recent fund operation.",["operation"]],[jo.treasury,"Recent Signer with Operation",1411,[Uo.TYPE_U8],Uo.TYPE_ADDRESS,"Signer address of the most recent fund operation.",["operation"]],[jo.treasury,"Recent Payment with Operation",1412,[Uo.TYPE_U8],Uo.TYPE_ADDRESS,"Payment address of the most recent fund operation.",["operation"]],[jo.treasury,"Recent Amount with Operation",1413,[Uo.TYPE_U8],Uo.TYPE_U64,"Amount of the most recent fund operation.",["operation"]],[jo.treasury,"Recent Time with Op/Pmt",1414,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Time of the most recent fund operation with payment specified.",["operation","payment address"]],[jo.treasury,"Recent Signer with Op&Pmt",1415,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_ADDRESS,"Signer of the most recent fund operationwith payment specified.",["operation","payment address"]],[jo.treasury,"Recent Amount with Op/Pmt",1416,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Amount of the most recent fund operation with payment specified.",["operation","payment address"]],[jo.treasury,"Recent Time with Op/Sgr",1417,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Time of the most recent fund operation with signer specified.",["operation","signer address"]],[jo.treasury,"Recent Payment with Op/Sgr",1418,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_ADDRESS,"Payment of the most recent fund operation with singner specified.",["operation","signer address"]],[jo.treasury,"Recent Amount with Op/Sgr",1419,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Amount of the most recent fund operation with singer specified.",["operation","signer address"]],[jo.treasury,"Recent Time with Op/Pmt/Sgr",1420,[Uo.TYPE_U8,Uo.TYPE_ADDRESS,Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Time of the most recent fund operation.",["operation","payment address","singer address"]],[jo.treasury,"Recent Amount with Op/Pmt/Sgr",1421,[Uo.TYPE_U8,Uo.TYPE_ADDRESS,Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Amount of the most recent fund operation.",["operation","payment address","singer address"]],[jo.treasury,"Has Operation",1422,[Uo.TYPE_U8],Uo.TYPE_BOOL,"Whether there was a fund operation?",["operation"]],[jo.treasury,"Has Operation with Pmt",1423,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether there was a fund operation with payment specified?",["operation","payment address"]],[jo.treasury,"Has Operation with Sgr",1424,[Uo.TYPE_U8,Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether there was a fund operation with singer specified?",["operation","singer address"]],[jo.treasury,"Has Operation with Pmt/Sgr",1425,[Uo.TYPE_U8,Uo.TYPE_ADDRESS,Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Whether there was a fund operation?",["operation","payment address","singer address"]],[jo.treasury,"Operation at Least Times",1426,[Uo.TYPE_U8,Uo.TYPE_U8],Uo.TYPE_BOOL,"Does it operate at least a certain number of times?",["operation","at least times"]],[jo.treasury,"Operation at Least Times by a Signer",1427,[Uo.TYPE_U8,Uo.TYPE_ADDRESS,Uo.TYPE_U8],Uo.TYPE_BOOL,"Does it operate at least a certain number of times by a signer?",["operation","signer address","at least times"]],[jo.arbitration,"Permission",1500,[],Uo.TYPE_ADDRESS,"Permission object address.",[]],[jo.arbitration,"Paused",1501,[],Uo.TYPE_BOOL,"Is it allowed to create Arb?",[]],[jo.arbitration,"Fee",1502,[],Uo.TYPE_U64,"Cost of arbitration.",[]],[jo.arbitration,"Has Endpoint",1503,[],Uo.TYPE_BOOL,"Is the endpoint set?",[]],[jo.arbitration,"Endpoint",1504,[],Uo.TYPE_STRING,"Endpoint url/ipfs.",[]],[jo.arbitration,"Has Customer Guard",1505,[],Uo.TYPE_BOOL,"Is there Guard set to apply for arbitration?",[]],[jo.arbitration,"Customer Guard",1506,[],Uo.TYPE_ADDRESS,"Guard to apply for arbitration.",[]],[jo.arbitration,"Number of Voting Guard",1507,[],Uo.TYPE_U64,"Number of voting guards.",[]],[jo.arbitration,"Has Voting Guard",1508,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Has the voting Guard added?",["guard address"]],[jo.arbitration,"Voting Weight",1509,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"Voting weight of the voting Guard.",["guard address"]],[jo.arbitration,"Treasury",1510,[],Uo.TYPE_ADDRESS,"The address of the Treasury where fees was collected at the time of withdrawal.",[]],[jo.arb,"Order",1600,[],Uo.TYPE_ADDRESS,"Order under arbitration.",[]],[jo.arb,"Arbitration",1601,[],Uo.TYPE_ADDRESS,"Arbitration object address.",[]],[jo.arb,"Feedback",1602,[],Uo.TYPE_STRING,"Arbitration feedback.",[]],[jo.arb,"Has Compensation",1603,[],Uo.TYPE_BOOL,"Whether there is an arbitration result?",[]],[jo.arb,"Compensation",1604,[],Uo.TYPE_U64,"Compensation should be given to the order payer.",[]],[jo.arb,"Unclaimed Arbitration Costs",1605,[],Uo.TYPE_U64,"Unclaimed arbitration costs.",[]],[jo.arb,"Turnout",1606,[],Uo.TYPE_U64,"The number of addresses have voted.",[]],[jo.arb,"Has voted",1607,[Uo.TYPE_ADDRESS],Uo.TYPE_BOOL,"Has someone voted?",["voter address"]],[jo.arb,"Voting weight",1608,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The weight of a complete vote for the address.",["voter address"]],[jo.arb,"Voting Time",1609,[Uo.TYPE_ADDRESS],Uo.TYPE_U64,"The time of a complete vote for the address.",["voter address"]],[jo.arb,"Voting Option",1610,[Uo.TYPE_ADDRESS,Uo.TYPE_U8],Uo.TYPE_BOOL,"Does an address complete voting for the option?",["voter address","option index"]],[jo.arb,"Number of Options",1611,[],Uo.TYPE_U64,"Number of voting options.",[]],[jo.arb,"Number of Votes",1612,[Uo.TYPE_U8],Uo.TYPE_U64,"The number of votes received for an option.",["option index"]]];class td{static MAX_INPUT_LENGTH=10240;txb;object;get_object(){return this.object}static From(e,t){let r=new td(e);return r.object=$o.TXB_OBJECT(e,t),r}constructor(e){this.txb=e,this.object=""}static New(e,t,r){r.IsReady()||Ba(Ca.InvalidParam,"launch maker"),io(t)||Ba(Ca.IsValidDesription);let s=r.get_input()[0],i=r.get_constant();(0==s.length||s.length>td.MAX_INPUT_LENGTH)&&Ba(Ca.InvalidParam,"launch input");let n=!0;i?.forEach(((e,t)=>{sd.IsValidIndentifier(t)||(n=!1),e.value&&e.bWitness&&(n=!1),void 0!==e.value||e.bWitness||(n=!1)})),n||Ba(Ca.InvalidParam,"launch constants");let a=new Uint8Array(s),o=new td(e);return o.object=e.moveCall({target:$o.Instance().guardFn("new"),arguments:[e.pure.string(t),e.pure.vector("u8",[].slice.call(a.reverse()))]}),i?.forEach(((t,r)=>{if(t.bWitness){const s=new Uint8Array(1);s.set([t.type],0),e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}else{const s=Oo(t.value,t.type);e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}})),o}launch(){return this.txb.moveCall({target:$o.Instance().guardFn("create"),arguments:[this.txb.object(this.object)]})}static everyone_guard(e){return e.moveCall({target:$o.Instance().guardFn("everyone_guard"),arguments:[]})}static QueryAddressIdentifiers(e,t,r){const s=new _s;s.moveCall({target:$o.Instance().guardFn("query_address_identifiers"),arguments:[s.object(e)]}),$o.Client().devInspectTransactionBlock({sender:r,transactionBlock:s}).then((e=>{if(e.results&&e.results[0]?.returnValues&&1!==e.results[0]?.returnValues?.length)return void t({err:"not match",txb:s,identifiers:[]});const r=Wa.getInstance().de("vector<u8>",Uint8Array.from(e.results[0].returnValues[0][0]));t({identifiers:r,txb:s})})).catch((e=>{console.log(e),t({err:e,txb:s,identifiers:[]})}))}static BoolCmd=ed.filter((e=>e[4]===Uo.TYPE_BOOL));static IsBoolCmd=e=>td.BoolCmd.includes((t=>t[2]==e));static CmdFilter=e=>ed.filter((t=>t[4]===e));static GetCmd=e=>ed.find((t=>t[2]==e));static GetCmdOption=e=>{const t=td.GetCmd(e);return t?{from:"query",name:t[1],value:t[2],group:So(t[0])}:t};static GetInputParams=e=>{const t=td.GetCmd(e);return t?t[3]:[]};static GetModuleName=e=>{let t=td.GetCmd(e);return t?So(t[0]):""};static NumberOptions=()=>[...td.CmdFilter(Uo.TYPE_U8),...td.CmdFilter(Uo.TYPE_U64),...td.CmdFilter(Uo.TYPE_U128),...td.CmdFilter(Uo.TYPE_U256)].map((e=>({from:"query",name:e[1],value:e[2],group:So(e[0])}))).concat(td.Crunchings);static Signer={from:"type",name:"Txn Signer",value:Fo.TYPE_SIGNER,group:"Txn Functions"};static Time={from:"type",name:"Txn Time",value:Fo.TYPE_CLOCK,group:"Txn Functions"};static Guard={from:"type",name:"Guard Address",value:Fo.TYPE_GUARD,group:"Txn Functions"};static Logics=()=>ko.map((e=>({from:"type",name:e[1],value:e[0],group:"Compare or Logic"})));static Crunchings=[{from:"type",name:"Txn Time",value:Fo.TYPE_CLOCK,group:"Txn Functions"},{from:"type",name:"PositiveNumber Add (+)",value:Ao.TYPE_NUMBER_ADD,group:"Number Crunching"},{from:"type",name:"PositiveNumber Subtract (-)",value:Ao.TYPE_NUMBER_SUBTRACT,group:"Number Crunching"},{from:"type",name:"PositiveNumber Multiply (*)",value:Ao.TYPE_NUMBER_MULTIPLY,group:"Number Crunching"},{from:"type",name:"PositiveNumber Devide (/)",value:Ao.TYPE_NUMBER_DEVIDE,group:"Number Crunching"},{from:"type",name:"PositiveNumber Mod (%)",value:Ao.TYPE_NUMBER_MOD,group:"Number Crunching"}];static CommonOptions=e=>td.CmdFilter(e).map((e=>({from:"query",name:e[1],value:e[2],group:So(e[0])})));static AllOptions=()=>[...ed.map((e=>({from:"query",name:e[1],value:e[2],group:So(e[0])}))),...td.Crunchings,...td.Logics(),td.Signer,td.Time,td.Guard];static StringOptions=()=>[...td.CmdFilter(Uo.TYPE_STRING)].map((e=>({from:"query",name:e[1],value:e[2],group:So(e[0])})));static BoolOptions=()=>[...td.BoolCmd.map((e=>({from:"query",name:e[1],value:e[2],group:So(e[0])}))),...td.Logics()];static AddressOptions=()=>{const e=ed.filter((e=>e[4]===Uo.TYPE_ADDRESS)).map((e=>({from:"query",name:e[1],value:e[2],group:So(e[0])})));return e.push(td.Signer),e.push(td.Guard),[...e]};static Options=e=>{if("number"===e)return td.NumberOptions();if("any"===e)return td.AllOptions();switch(e){case Uo.TYPE_BOOL:return td.BoolOptions();case Uo.TYPE_STRING:return td.StringOptions()}return td.CommonOptions(e)}}const rd=e=>lo(e)&&0!==e;class sd{data=[];type_validator=[];constant=new Map;static _witness_index=1;static _const_index=255;static GetWitnessIndex(){return this._witness_index>=this._const_index&&Ba(Ca.Fail,"too many witness"),sd._witness_index++}static getConstIndex(){return this._const_index<=this._witness_index&&Ba(Ca.Fail,"too many const"),sd._const_index--}static IsValidIndentifier=e=>!(!lo(e)||e<1);constructor(){}add_constant(e,t,r,s=!0){return void 0===r&&(r=void 0===t?sd.GetWitnessIndex():sd.getConstIndex()),this.constant.get(r)||(s&&void 0!==t&&(t=Wa.getInstance().ser(e,t)),this.constant.set(r,{type:e,value:void 0===t?void 0:t,bWitness:void 0===t})),r}add_param(e,t){switch(e){case Uo.TYPE_ADDRESS:case Uo.TYPE_BOOL:case Uo.TYPE_U8:case Uo.TYPE_U64:case Uo.TYPE_U128:case Uo.TYPE_U256:case Uo.TYPE_VEC_ADDRESS:case Uo.TYPE_VEC_BOOL:case Uo.TYPE_VEC_U128:case Uo.TYPE_VEC_U64:case Uo.TYPE_VEC_VEC_U8:case Uo.TYPE_OPTION_U64:case Uo.TYPE_OPTION_ADDRESS:case Uo.TYPE_OPTION_BOOL:case Uo.TYPE_OPTION_U128:case Uo.TYPE_OPTION_U256:case Uo.TYPE_OPTION_U8:case Uo.TYPE_VEC_U256:this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(e,t)),this.type_validator.push(e);break;case Uo.TYPE_STRING:case Uo.TYPE_VEC_U8:t||Ba(Ca.InvalidParam,"param: "+e),this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,e)),"string"==typeof t?this.data.push(Wa.getInstance().ser(Uo.TYPE_STRING,t)):this.data.push(Wa.getInstance().ser(Uo.TYPE_VEC_U8,t)),this.type_validator.push(e);break;case Fo.TYPE_SIGNER:case Fo.TYPE_GUARD:this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,e)),this.type_validator.push(Uo.TYPE_ADDRESS);break;case Fo.TYPE_CLOCK:this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,e)),this.type_validator.push(Uo.TYPE_U64);break;case Fo.TYPE_CONSTANT:rd(t)||Ba(Ca.IsValidGuardIdentifier,"add_param param:"+e);var r=this.constant.get(t);r||Ba(Ca.Fail,"identifier not in constant:"+t),this.type_validator.push(r.type),this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,t));break;default:Ba(Ca.InvalidParam,"add_param type:"+e)}return this}add_query(e,t,r){let s=ed.findIndex((r=>r[0]==e&&r[1]==t));-1==s&&Ba(Ca.InvalidParam,"query_name:"+t),"number"==typeof r?sd.IsValidIndentifier(r)||Ba(Ca.InvalidParam,"object_address_from:"+t):co(r)||Ba(Ca.InvalidParam,"object_address_from:"+t);let i=this.type_validator.length-ed[s][3].length;i<0&&Ba(Ca.InvalidParam,"offset:"+t);let n=this.type_validator.slice(i);if(Ga(n,ed[s][3])||Ba(Ca.Fail,"array_equal:"+t),this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,Ao.TYPE_QUERY)),"string"==typeof r)this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,Uo.TYPE_ADDRESS)),this.data.push(Wa.getInstance().ser(Uo.TYPE_ADDRESS,r));else{let e=this.constant.get(r);e||Ba(Ca.Fail,"object_address_from not in constant:"+t),e?.type==Uo.TYPE_ADDRESS?(this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,Fo.TYPE_CONSTANT)),this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,r))):Ba(Ca.Fail,"type bWitness not match:"+t)}return this.data.push(Wa.getInstance().ser("u16",ed[s][2])),this.type_validator.splice(i,ed[s][3].length),this.type_validator.push(ed[s][4]),this}add_logic(e,t=2){var r=ko.find((t=>t[0]===e));r&&(r=r[1]);let s,i=2,n=Uo.TYPE_BOOL;switch(e){case Ao.TYPE_LOGIC_AS_U256_GREATER:case Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_LESSER:case Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)sd.match_u256(this.type_validator[this.type_validator.length-e])||Ba(Ca.Fail,"type_validator check:"+r);break;case Ao.TYPE_LOGIC_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),s=this.type_validator[this.type_validator.length-1];for(let e=2;e<=i;++e)this.type_validator[this.type_validator.length-e]!==s&&Ba(Ca.Fail,"type_validator check:"+r);break;case Ao.TYPE_LOGIC_HAS_SUBSTRING:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!==Uo.TYPE_STRING&&Ba(Ca.Fail,"type_validator check:"+r);break;case Ao.TYPE_LOGIC_NOT:i=1,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),this.type_validator[this.type_validator.length-1]!=Uo.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case Ao.TYPE_LOGIC_AND:case Ao.TYPE_LOGIC_OR:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!=Uo.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case Ao.TYPE_NUMBER_ADD:case Ao.TYPE_NUMBER_DEVIDE:case Ao.TYPE_NUMBER_MULTIPLY:case Ao.TYPE_NUMBER_SUBTRACT:case Ao.TYPE_NUMBER_MOD:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)sd.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);n=Uo.TYPE_U256;break;default:Ba(Ca.InvalidParam,"add_logic type invalid:"+r)}return this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,e)),sd.is_multi_input_op(e)&&this.data.push(Wa.getInstance().ser(Uo.TYPE_U8,t)),this.type_validator.splice(this.type_validator.length-i),this.type_validator.push(n),this}hasIdentifier(e){return this.constant.has(e)}build(e=!1){return 1==this.type_validator.length&&this.type_validator[0]==Uo.TYPE_BOOL||Ba(Ca.Fail,"type_validator check"),e&&this.add_logic(Ao.TYPE_LOGIC_NOT),this.data.push(Xa(Uint8Array,...this.data)),this.data.splice(0,this.data.length-1),this}IsReady(){return 1==this.type_validator.length&&this.type_validator[0]==Uo.TYPE_BOOL&&1==this.data.length}combine(e,t=!0,r=!1){e.IsReady()&&this.IsReady()||Ba(Ca.Fail,"both should built yet");let s=new sd;this.constant.forEach(((e,t)=>{s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})})),e.constant.forEach(((e,t)=>{s.constant.has(t)&&!r&&Ba(Ca.Fail,"constant identifier exist"),s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})}));let i=t?Ao.TYPE_LOGIC_AND:Ao.TYPE_LOGIC_OR;return s.data.push(Xa(Uint8Array,...this.data,...e.data,Wa.getInstance().ser(Uo.TYPE_U8,i),Wa.getInstance().ser(Uo.TYPE_U8,2))),this.data.splice(0,this.data.length-1),s.type_validator=this.type_validator,s}get_constant(){return this.constant}get_input(){return this.data}static input_combine(e,t,r=!0){let s=r?Ao.TYPE_LOGIC_AND:Ao.TYPE_LOGIC_OR;return Xa(Uint8Array,e,t,Wa.getInstance().ser(Uo.TYPE_U8,s),Wa.getInstance().ser(Uo.TYPE_U8,2))}static input_not(e){return Xa(Uint8Array,e,Wa.getInstance().ser(Uo.TYPE_U8,Ao.TYPE_LOGIC_NOT))}static match_u256(e){return e==Uo.TYPE_U8||e==Uo.TYPE_U64||e==Uo.TYPE_U128||e==Uo.TYPE_U256}static is_multi_input_op(e){return e===Ao.TYPE_LOGIC_AS_U256_GREATER||e===Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL||e===Ao.TYPE_LOGIC_AS_U256_LESSER||e===Ao.TYPE_LOGIC_AS_U256_LESSER||e===Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL||e===Ao.TYPE_LOGIC_AS_U256_EQUAL||e===Ao.TYPE_LOGIC_EQUAL||e===Ao.TYPE_LOGIC_HAS_SUBSTRING||e===Ao.TYPE_LOGIC_AND||e===Ao.TYPE_LOGIC_OR||e===Ao.TYPE_NUMBER_ADD||e===Ao.TYPE_NUMBER_DEVIDE||e===Ao.TYPE_NUMBER_MULTIPLY||e===Ao.TYPE_NUMBER_SUBTRACT||e===Ao.TYPE_NUMBER_MOD}}var id,nd,ad,od,dd,cd,ud;!function(e){e[e.POLICY_MODE_FREE=0]="POLICY_MODE_FREE",e[e.POLICY_MODE_STRICT=1]="POLICY_MODE_STRICT"}(id||(id={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.WOWOK_GRANTEE=1]="WOWOK_GRANTEE",e[e.WOWOK_ORACLE=2]="WOWOK_ORACLE"}(nd||(nd={}));class hd{permission;object;txb;get_object(){return this.object}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static From(e,t,r){let s=new hd(e,t);return s.object=$o.TXB_OBJECT(e,r),s}static New(e,t,r,s=id.POLICY_MODE_FREE,i){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription);let n=new hd(e,t);return n.object=i?e.moveCall({target:$o.Instance().repositoryFn("new_with_passport"),arguments:[i,e.pure.string(r),e.pure.u8(s),$o.TXB_OBJECT(e,t)]}):e.moveCall({target:$o.Instance().repositoryFn("new"),arguments:[e.pure.string(r),e.pure.u8(s),$o.TXB_OBJECT(e,t)]}),n}launch(){return this.txb.moveCall({target:$o.Instance().repositoryFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}add_data(e){hd.IsValidName(e.key)||Ba(Ca.IsValidName,"add_data");let t=!0;e.data.forEach((e=>{co(e.address)||(t=!1),hd.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add_typed_data"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]})))}add_data2(e){co(e.address)||Ba(Ca.IsValidAddress,"add_data2");let t=!0;e.data.forEach((e=>{hd.IsValidName(e.key)||(t=!1),hd.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data2"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add_typed_data"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]})))}remove(e,t){hd.IsValidName(t)||Ba(Ca.IsValidName),co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:$o.Instance().repositoryFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}add_reference(e,t){0!==e.length&&(vo(e,co)||Ba(Ca.IsValidArray,"add_reference"),t?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}remove_reference(e,t,r){(0!==e.length||t)&&(vo(e,co)||Ba(Ca.IsValidArray,"remove_reference"),t?r?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):r?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}add_policies(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{io(e.description)&&hd.IsValidName(e.key)||(r=!1)})),r||Ba(Ca.InvalidParam,"policies"),e.forEach((e=>{let r=this.txb.pure.option("u64",e?.permissionIndex?e?.permissionIndex:void 0);t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),$o.TXB_OBJECT(this.txb,this.permission)]})}))}remove_policies(e,t,r){0!==e.length&&(vo(e,hd.IsValidName)||Ba(Ca.InvalidParam,"policy_keys"),r?t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}rename_policy(e,t,r){no(e)&&no(t)||Ba(Ca.IsValidName,"change_policy"),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_rename_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_rename"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().repositoryFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_mode(e,t){t?this.txb.moveCall({target:$o.Instance().repositoryFn("mode_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("mode_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_description(e,t,r){hd.IsValidName(e)||Ba(Ca.IsValidName,"policy"),io(t)||Ba(Ca.IsValidDesription),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_description_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_permission(e,t,r){hd.IsValidName(e)||Ba(Ca.IsValidName,"policy");let s=this.txb.pure.option("u64",void 0);void 0!==t&&(Ko.IsValidPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex),s=this.txb.pure.option("u64",t)),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_permission_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),s,$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),s,$o.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().repositoryFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}static MAX_POLICY_COUNT=120;static MAX_KEY_LENGTH=128;static MAX_VALUE_LENGTH=204800;static MAX_REFERENCE_COUNT=100;static IsValidName=e=>e.length<=hd.MAX_KEY_LENGTH&&0!=e.length;static IsValidValue=e=>e.length<hd.MAX_VALUE_LENGTH;static rpc_de_data(e){const t=e?.map((e=>{const t=new Uint8Array(e?.data?.content?.fields?.value),r=t?.length>0?t[0]:null;var s=t.length>0?t.slice(1):Uint8Array.from([]);return r===Uo.TYPE_STRING?(s=Wa.getInstance().de(Uo.TYPE_VEC_U8,s),s=(new TextDecoder).decode(Uint8Array.from(s))):r===Uo.TYPE_VEC_STRING?s=(s=Wa.getInstance().de(Uo.TYPE_VEC_VEC_U8,s)).map((e=>(new TextDecoder).decode(Uint8Array.from(e)))):(s=Wa.getInstance().de(t[0],s),r===Uo.TYPE_ADDRESS?s="0x"+s:r===Uo.TYPE_VEC_ADDRESS?s=s.map((e=>"0x"+e)):r===Uo.TYPE_BOOL&&(s=s?"True":"False")),{object:e?.data?.content?.fields?.id?.id,id:e?.data?.content?.fields?.name?.fields?.id,name:e?.data?.content?.fields?.name?.fields?.key,data:s,dataType:Ua(r)}}));return t}static DataType2ValueType(e){try{const t=BigInt(e);if(Uo.TYPE_U8,t<=Sa);else if(t<=Pa)Uo.TYPE_U64;else if(t<=ja)Uo.TYPE_U128;else{if(!(t<=Aa))return;Uo.TYPE_U256}}catch(e){console.log(e)}}static ResolveRepositoryData=(e,t)=>{if(e===No.String)return{type:Uo.TYPE_STRING,data:Wa.getInstance().ser(Uo.TYPE_VEC_U8,(new TextEncoder).encode(t.toString()))};if(e===No.PositiveNumber){const e=hd.DataType2ValueType(t);if(!e)return;return{type:e,data:Wa.getInstance().ser(e,t)}}if(e===No.Address){if(!co(t))return;return{type:Uo.TYPE_ADDRESS,data:Wa.getInstance().ser(Uo.TYPE_ADDRESS,t)}}if(e===No.Address_Vec){for(let e=0;e<t.length;++e)if(!co(t[e]))return;return{type:Uo.TYPE_VEC_ADDRESS,data:Wa.getInstance().ser(Uo.TYPE_VEC_ADDRESS,t)}}if(e===No.PositiveNumber_Vec){let e=Uo.TYPE_U8;for(let r=0;r<t.length;++r){const r=hd.DataType2ValueType(t);if(!r)return;r>e&&(e=r)}return e=e===Uo.TYPE_U8?Uo.TYPE_VEC_U8:e===Uo.TYPE_U64?Uo.TYPE_VEC_U64:e===Uo.TYPE_U128?Uo.TYPE_VEC_U128:Uo.TYPE_VEC_U256,{type:e,data:Wa.getInstance().ser(e,t)}}if(e===No.String_Vec){const e=t.map((e=>(new TextEncoder).encode(e)));return{type:Uo.TYPE_VEC_STRING,data:Wa.getInstance().ser(Uo.TYPE_VEC_VEC_U8,e)}}if(e===No.Bool){if("boolean"!=typeof t)return;return{type:Uo.TYPE_BOOL,data:Wa.getInstance().ser(Uo.TYPE_BOOL,t)}}}}class ld{guard_list=[];guards;constructor(e){this.guards=e}guardlist=()=>this.guard_list;static DeGuardObject_FromData=(e,t)=>{let r=ld.parse_constant(e),s=ld.parse_bcs(r,t);s&&0!=s.length||Ba(Ca.Fail,"GuardObject: data parsed error");let i=[];return s.forEach((e=>{ld.ResolveData(r,i,{...e,child:[]})})),1!=i.length&&Ba(Ca.Fail,"GuardObject: parse error"),{object:i.pop(),constant:r}};static DeGuardObject=async(e,t)=>{co(t)||Ba(Ca.IsValidAddress,"GuardObject guard");let r=await e.query_raw([t]);0!=r.length&&r[0].data&&r[0].data?.objectId==t||Ba(Ca.Fail,"GuardObject query error");let s=r[0].data.content;return s?.type!=e.package("base")+"::guard::Guard"&&Ba(Ca.Fail,"GuardObject object invalid"),ld.DeGuardObject_FromData(s.fields.constants,s.fields.input.fields.bytes)};static ResolveData=(e,t,r)=>{switch(r.type){case Ao.TYPE_LOGIC_NOT:r.ret_type=Uo.TYPE_BOOL,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT");let n=t.pop();return n.ret_type&&n.ret_type==Uo.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT type invalid"),r.child.push(n),void t.push(r);case Ao.TYPE_LOGIC_AS_U256_GREATER:case Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_LESSER:case Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_EQUAL:case Ao.TYPE_NUMBER_ADD:case Ao.TYPE_NUMBER_DEVIDE:case Ao.TYPE_NUMBER_MOD:case Ao.TYPE_NUMBER_MULTIPLY:case Ao.TYPE_NUMBER_SUBTRACT:r.type===Ao.TYPE_LOGIC_AS_U256_GREATER||r.type===Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL||r.type===Ao.TYPE_LOGIC_AS_U256_LESSER||r.type===Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL||r.type===Ao.TYPE_LOGIC_AS_U256_EQUAL?r.ret_type=Uo.TYPE_BOOL:r.ret_type=Uo.TYPE_U256,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(i=t.pop()).ret_type&&sd.match_u256(i.ret_type)||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(i);return void t.push(r);case Ao.TYPE_LOGIC_EQUAL:r.ret_type=Uo.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);var s=t.pop();r.child.push(s);for(let e=1;e<r.value;++e)(i=t.pop()).ret_type&&i.ret_type==s.ret_type||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(i);return void t.push(r);case Ao.TYPE_LOGIC_HAS_SUBSTRING:r.ret_type=Uo.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(i=t.pop()).ret_type&&i.ret_type==Uo.TYPE_STRING||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(i);return void t.push(r);case Ao.TYPE_LOGIC_AND:case Ao.TYPE_LOGIC_OR:r.ret_type=Uo.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e){var i;(i=t.pop()).ret_type&&i.ret_type==Uo.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(i)}return void t.push(r);case Ao.TYPE_QUERY:r?.cmd||Ba(Ca.Fail,"OperateParamCount: cmd invalid "+r.type);let a=td.GetCmd(r.cmd);return a||Ba(Ca.Fail,"OperateParamCount: cmd not supported "+r.type),r.ret_type=a[4],t.length<a[3].length&&Ba(Ca.Fail,"OperateParamCount: cmd param lost "+r.type),a[3].forEach((e=>{let s=t.pop();s?.ret_type&&s.ret_type==e||Ba(Ca.Fail,"OperateParamCount: cmd param not match "+r.type),r.child.push(s)})),void t.push(r);case Uo.TYPE_ADDRESS:case Uo.TYPE_BOOL:case Uo.TYPE_U128:case Uo.TYPE_U256:case Uo.TYPE_U64:case Uo.TYPE_U8:case Uo.TYPE_VEC_ADDRESS:case Uo.TYPE_VEC_BOOL:case Uo.TYPE_VEC_U128:case Uo.TYPE_VEC_U256:case Uo.TYPE_VEC_U64:case Uo.TYPE_VEC_U8:case Uo.TYPE_VEC_VEC_U8:case Uo.TYPE_OPTION_ADDRESS:case Uo.TYPE_OPTION_BOOL:case Uo.TYPE_OPTION_U128:case Uo.TYPE_OPTION_U256:case Uo.TYPE_OPTION_U64:case Uo.TYPE_OPTION_U8:case Uo.TYPE_STRING:return r.ret_type=r.type,void t.push(r);case Fo.TYPE_CLOCK:return r.ret_type=Uo.TYPE_U64,void t.push(r);case Fo.TYPE_SIGNER:case Fo.TYPE_GUARD:return r.ret_type=Uo.TYPE_ADDRESS,void t.push(r);case Fo.TYPE_CONSTANT:let o=e.find((e=>e.identifier==r?.identifier));return o||Ba(Ca.Fail,"OperateParamCount: identifier invalid "+r.type),r.ret_type=o?.type,void t.push(r)}Ba(Ca.Fail,"OperateParamCount: type invalid "+r.type)};static Parse_Guard_Helper(e,t){const r=$o.Instance(),s=new ld(e);return t.forEach((e=>{const t=e.data?.content;if(t||Ba(Ca.Fail,"Parse_Guard_Helper invalid content"),-1===r.WOWOK_OBJECTS_TYPE().findIndex((e=>e.includes("guard::Guard")&&e==t.type))&&Ba(Ca.Fail,"Parse_Guard_Helper invalid type: "+t.type),t.fields.input.type===r.package("base")+"::bcs::BCS"){const r=ld.parse_constant(t.fields.constants),i=ld.parse_bcs(r,Uint8Array.from(t.fields.input.fields.bytes));s.guard_list.push({id:t.fields.id.id,input:[...i],constant:[...r],digest:e.data?.digest??"",version:e.data?.version??""})}else Ba(Ca.Fail,"Parse_Guard_Helper invalid package: "+t.fields.input.type)})),s}static Create=async(e,t)=>{if(!vo(e,co))return void(t&&t(void 0));let r=$a(e);if(!t){const t=await $o.Instance().query_raw(r);return ld.Parse_Guard_Helper(e,t)}$o.Instance().query_raw(r).then((r=>{t(ld.Parse_Guard_Helper(e,r))})).catch((e=>{console.log(e),t(void 0)}))};future_fills=()=>{const e=[];return this.guard_list.forEach((t=>{t.constant.filter((e=>e.bWitness)).forEach((r=>{const s=t.input.filter((e=>e.identifier===r.identifier&&void 0!==e.cmd)).map((e=>e.cmd));let i=0;t.input.forEach((e=>{e.identifier===r.identifier&&i++})),e.push({guard:t.id,witness:void 0,identifier:r.identifier,type:r.type,cmd:s??[],cited:i})}))})),e};static parse_constant=e=>{let t=[];return e.forEach((e=>{let r=e?.fields??e;const s=Uint8Array.from(r.value),i=s.slice(0,1)[0];if(r.bWitness)t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:void 0});else{var n=s.slice(1);switch(i){case Uo.TYPE_ADDRESS:n="0x"+Wa.getInstance().de(Uo.TYPE_ADDRESS,Uint8Array.from(n)).toString();break;case Uo.TYPE_BOOL:case Uo.TYPE_U8:case Uo.TYPE_U64:case Uo.TYPE_U128:case Uo.TYPE_U256:case Uo.TYPE_VEC_U8:case Uo.TYPE_VEC_U64:case Uo.TYPE_VEC_U128:case Uo.TYPE_VEC_ADDRESS:case Uo.TYPE_VEC_BOOL:case Uo.TYPE_VEC_VEC_U8:case Uo.TYPE_OPTION_ADDRESS:case Uo.TYPE_OPTION_BOOL:case Uo.TYPE_OPTION_U128:case Uo.TYPE_OPTION_U8:case Uo.TYPE_OPTION_U64:case Uo.TYPE_OPTION_U256:case Uo.TYPE_VEC_U256:case Uo.TYPE_STRING:case Uo.TYPE_OPTION_STRING:case Uo.TYPE_OPTION_VEC_U8:case Uo.TYPE_VEC_STRING:Xo.find((e=>e.type==i))||Ba(Ca.Fail,"GuardObject de error"),n=Wa.getInstance().de(i,Uint8Array.from(n));break;default:Ba(Ca.Fail,"GuardObject constant type invalid:"+i)}t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:n})}})),t};static parse_bcs=(e,t)=>{let r=Uint8Array.from(t),s=[].slice.call(r.reverse()),i=[];for(;s.length>0;){let t,r,n,a=s.shift();switch(a){case Fo.TYPE_SIGNER:case Fo.TYPE_CLOCK:case Fo.TYPE_GUARD:case Ao.TYPE_LOGIC_NOT:break;case Ao.TYPE_LOGIC_AS_U256_GREATER:case Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_LESSER:case Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_EQUAL:case Ao.TYPE_LOGIC_EQUAL:case Ao.TYPE_LOGIC_HAS_SUBSTRING:case Ao.TYPE_NUMBER_ADD:case Ao.TYPE_NUMBER_DEVIDE:case Ao.TYPE_NUMBER_MOD:case Ao.TYPE_NUMBER_MULTIPLY:case Ao.TYPE_NUMBER_SUBTRACT:case Ao.TYPE_LOGIC_AND:case Ao.TYPE_LOGIC_OR:t=s.shift();break;case Fo.TYPE_CONSTANT:n=s.shift();break;case Uo.TYPE_ADDRESS:t="0x"+Wa.getInstance().de(Uo.TYPE_ADDRESS,Uint8Array.from(s)).toString(),s.splice(0,32);break;case Uo.TYPE_BOOL:case Uo.TYPE_U8:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.shift();break;case Uo.TYPE_U64:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8);break;case Uo.TYPE_U128:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16);break;case Uo.TYPE_U256:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32);break;case Uo.TYPE_VEC_U8:case Uo.TYPE_VEC_BOOL:case Uo.TYPE_STRING:let i=Ya(Uint8Array.from(s));t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,i.value+i.length);break;case Uo.TYPE_VEC_ADDRESS:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case Uo.TYPE_VEC_U128:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16*i.value+i.length);break;case Uo.TYPE_VEC_U256:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case Uo.TYPE_VEC_U64:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8*i.value+i.length);break;case Uo.TYPE_VEC_VEC_U8:case Uo.TYPE_VEC_STRING:i=Ya(Uint8Array.from(s)),s.splice(0,i.length);let o=[];for(let e=0;e<i.value;e++){let e=Ya(Uint8Array.from(s));o.push(Wa.getInstance().de(Uo.TYPE_VEC_U8,Uint8Array.from(s))),s.splice(0,e.length+e.value)}t=o;break;case Ao.TYPE_QUERY:let d=s.splice(0,1);if(d[0]==Uo.TYPE_ADDRESS){let e="0x"+Wa.getInstance().de(Uo.TYPE_ADDRESS,Uint8Array.from(s)).toString();s.splice(0,32),t=e,r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else if(d[0]==Fo.TYPE_CONSTANT){let t=s.splice(0,1);e.find((e=>e.identifier==t[0]&&e.type==Uo.TYPE_ADDRESS))||Ba(Ca.Fail,"GuardObject: indentifier not in constant"),n=t[0],r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else Ba(Ca.Fail,"GuardObject: constant type invalid");break;case Uo.TYPE_OPTION_ADDRESS:let c=Na(s,Uo.TYPE_ADDRESS);t=c.value,c.bNone||s.splice(0,32);break;case Uo.TYPE_OPTION_BOOL:c=Na(s,Uo.TYPE_BOOL),t=c.value,c.bNone||s.splice(0,1);break;case Uo.TYPE_OPTION_U8:c=Na(s,Uo.TYPE_U8),t=c.value,c.bNone||s.splice(0,1);break;case Uo.TYPE_OPTION_U128:c=Na(s,Uo.TYPE_U128),t=c.value,c.bNone||s.splice(0,16);break;case Uo.TYPE_OPTION_U256:c=Na(s,Uo.TYPE_U256),t=c.value,c.bNone||s.splice(0,32);break;case Uo.TYPE_OPTION_U64:c=Na(s,Uo.TYPE_U64),t=c.value,c.bNone||s.splice(0,8);break;case Uo.TYPE_OPTION_STRING:c=Da(s),t=c.value;break;default:Ba(Ca.Fail,"GuardObject: parse_bcs types "+a)}i.push({type:a,value:t,cmd:r,identifier:n})}return i};done=async(e,t)=>{let r=[];if(this.guard_list.forEach((t=>{t.constant.forEach((t=>{if(t.bWitness){const r=e?.find((e=>e.identifier===t.identifier));r?t.value=r.witness:Ba(Ca.Fail,"done: invalid witness "+t.identifier)}})),t.input.filter((e=>void 0!==e.cmd)).forEach((e=>{if(void 0!==e.identifier){const s=t.constant.find((t=>t.identifier===e.identifier&&t.type===Uo.TYPE_ADDRESS));s&&co(s.value)||Ba(Ca.Fail,"done: invalid identifier "+e.identifier),r.push(s.value)}else r.push(e.value)}))})),t)return 0===r.length?void t(this.done_helper([])):void $o.Instance().query_raw($a(r),{showType:!0}).then((e=>{t(this.done_helper(e))})).catch((e=>{console.log(e),t(void 0)}));{let e=[];return r.length>0&&(e=await $o.Instance().query_raw($a(r),{showType:!0})),this.done_helper(e)}};done_helper(e){let t=[],r=[];return this.guard_list.forEach((s=>{r.push(s.id),s.input.filter((e=>void 0!==e.cmd)).forEach((r=>{let i=r.value;i||void 0===r.identifier||(i=s.constant.find((e=>e.identifier==r.identifier))?.value);let n=e.find((e=>e.data?.objectId==i));n||Ba(Ca.Fail,"query object not match");let a=this.object_query(n.data);a||Ba(Ca.Fail,"query object fail"),t.push(a)}))})),{query:t,info:this.guard_list}}object_query=(e,t="guard_query")=>{for(let r=0;r<$o.Instance().WOWOK_OBJECTS_TYPE().length;r++)if(e.type.includes($o.Instance().WOWOK_OBJECTS_TYPE()[r]))return{target:$o.Instance().WOWOK_OBJECTS_PREFIX_TYPE()[r]+t,object:ct({objectId:e.objectId,mutable:!1,initialSharedVersion:e.version}),types:qa(e.type),id:e.objectId}}}class pd{static MAX_GUARD_COUNT=8;passport;txb;get_object(){return this.passport}constructor(e,t,r=!1){(0===t.info.length||t.info.length>pd.MAX_GUARD_COUNT)&&Ba(Ca.InvalidParam,"guards"),this.txb=e,this.passport=this.txb.moveCall({target:$o.Instance().passportFn("new"),arguments:[]}),t.info.forEach((t=>{const r=t.constant.filter((e=>e.bWitness)).map((e=>e.identifier)),s=t.constant.filter((e=>e.bWitness)).map((e=>{const t=Wa.getInstance().ser(e.type,e.value);let r=new Uint8Array(t.length+1);return r.set([e.type],0),r.set(t,1),[].slice.call(r)})),i=void 0!==t.version&&void 0!==t.digest?e.objectRef({objectId:t.id,version:t.version,digest:t.digest}):e.object(t.id);this.txb.moveCall({target:$o.Instance().passportFn("guard_add"),arguments:[this.passport,i,this.txb.pure.vector("u8",[].slice.call(r)),this.txb.pure(Wa.getInstance().ser("vector<vector<u8>>",[...s]))]})}));const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?.query.forEach((e=>{this.txb.moveCall({target:$o.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]}),this.txb.moveCall({target:e.target,arguments:[r?this.txb.object(e.object):this.txb.object(e.id),this.passport],typeArguments:e.types})})),this.txb.moveCall({target:$o.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]})}destroy(){this.txb.moveCall({target:$o.Instance().passportFn("destroy"),arguments:[this.passport]})}freeze(){this.txb.moveCall({target:$o.Instance().passportFn("freezen"),arguments:[this.passport]})}query_result(e,t){this.txb.moveCall({target:$o.Instance().passportFn("query_result"),arguments:[this.passport]}),$o.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb}).then((e=>{const r=pd.ResolveQueryRes(this.txb,e);r&&t(r)})).catch((e=>{console.log(e)}))}query_result_async=async e=>{this.txb.moveCall({target:$o.Instance().passportFn("query_result"),arguments:[this.passport]});const t=await $o.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb});return pd.ResolveQueryRes(this.txb,t)};static ResolveQueryRes(e,t){for(let r=0;r<t.results?.length;++r){const s=t.results[r];if(s?.returnValues&&2===s.returnValues.length&&"bool"===s.returnValues[0][1]&&"vector<address>"===s.returnValues[1][1])return{txb:e,result:Wa.getInstance().de("bool",Uint8Array.from(s.returnValues[0][0])),guards:Wa.getInstance().de("vector<address>",Uint8Array.from(s.returnValues[1][0])).map((e=>"0x"+e))}}}}!function(e){e[e.ratio=0]="ratio",e[e.minus=1]="minus"}(ad||(ad={})),function(e){e.address="address",e.phone="phone",e.name="name",e.postcode="postcode"}(od||(od={}));class md{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new md(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n){$o.IsValidObjects([r,i])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New: pay_token_type"),io(s)||Ba(Ca.IsValidDesription);let a=t,o=new md(e,a,r);return o.object=n?e.moveCall({target:$o.Instance().serviceFn("new_with_passport"),arguments:[n,e.pure.string(s),e.object(i),$o.TXB_OBJECT(e,r)],typeArguments:[a]}):e.moveCall({target:$o.Instance().serviceFn("new"),arguments:[e.pure.string(s),e.object(i),$o.TXB_OBJECT(e,r)],typeArguments:[a]}),o}launch(){return this.txb.moveCall({target:$o.Instance().serviceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().serviceFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_price(e,t,r=!0,s){po(t)||Ba(Ca.IsValidU64,"set_price price"),md.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_price item"),s?this.txb.moveCall({target:$o.Instance().serviceFn("price_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("price_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_stock(e,t,r=!0,s){md.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"item"),po(t)||Ba(Ca.IsValidU64,"stock"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_stock(e,t,r=!0,s){md.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"add_stock item"),po(t)||Ba(Ca.IsValidUint,"add_stock stock_add"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_add_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}reduce_stock(e,t,r=!0,s){md.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"reduce_stock item"),po(t)||Ba(Ca.IsValidUint,"reduce_stock stock_reduce"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_reduce_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_reduce"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_sale_endpoint(e,t,r=!0,s){md.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_sale_endpoint item"),t&&!oo(t)&&Ba(Ca.IsValidEndpoint,"set_sale_endpoint endpoint");let i=this.txb.pure.option("string",t||void 0);s?this.txb.moveCall({target:$o.Instance().serviceFn("sale_endpoint_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sale_endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_payee(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_payee"),t?this.txb.moveCall({target:$o.Instance().serviceFn("payee_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("payee_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_repository(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"repository_add"),t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_add_with_passport"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_repository(e,t,r){(t||0!==e.length)&&(vo(e,co)||Ba(Ca.IsValidArray,"repository_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_arbitration(e,t,r){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"add_arbitration.arbitraion"),go(t)||Ba(Ca.IsValidTokenType,"add_arbitration.arbitraion_token_type"),r?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]})}remove_arbitration(e,t,r){(t||0!==e.length)&&(vo(e,co)||Ba(Ca.IsValidArray,"remove_arbitration.address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_withdraw_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{$o.IsValidObjects([e.guard])||(r=!1),yo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_withdraw_guards(e,t,r){(t||0!==e.length)&&(vo(e,co)||Ba(Ca.IsValidArray,"guard_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_refund_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{$o.IsValidObjects([e.guard])||(r=!1),yo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_refund_guards(e,t,r){(0!==e.length||t)&&(vo(e,co)||Ba(Ca.InvalidParam,"guard_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}is_valid_sale(e){let t=!0,r=[];return e.forEach((e=>{md.IsValidItemName(e.item)||(t=!1),po(e.price)||(t=!1),po(e.stock)||(t=!1),r.includes(e.item)&&(t=!1),r.push(e.item)})),t}add_sales(e,t=!1,r){if(0===e.length)return;this.is_valid_sale(e)||Ba(Ca.InvalidParam,"add_sales");let s=[],i=[],n=[],a=[];e.forEach((e=>{e.endpoint&&!oo(e.endpoint)&&Ba(Ca.IsValidEndpoint,"add_sales"),s.push(e.item),i.push(e.price),n.push(e.stock),a.push(e.endpoint??"")})),r?this.txb.moveCall({target:$o.Instance().serviceFn("sales_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sales_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_sales(e,t){0!==e.length&&(vo(e,md.IsValidItemName)||Ba(Ca.IsValidArray,"remove_sales"),t?this.txb.moveCall({target:$o.Instance().serviceFn("sales_remove_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sales_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}discount_transfer(e,t){(!e||e.length>md.MAX_DISCOUNT_RECEIVER_COUNT)&&Ba(Ca.InvalidParam,"discount_dispatch");let r=!0;e.forEach((e=>{co(e.receiver)||(r=!1),(!po(e.count)||e.count>md.MAX_DISCOUNT_COUNT_ONCE)&&(r=!1),ao(e.discount.name)||(r=!1),e.discount.type!=ad.ratio||yo(e.discount.off)||(r=!1),po(e.discount.duration_minutes)||(r=!1),e.discount?.time_start&&!po(e.discount.time_start)&&(r=!1),e.discount?.price_greater&&!po(e.discount.price_greater)&&(r=!1)})),r||Ba(Ca.InvalidParam,"discount_dispatch");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);e.forEach((e=>{let r=this.txb.pure.option("u64",e.discount?.price_greater?e.discount?.price_greater:void 0),i=this.txb.pure.option("u64",e.discount?.time_start?e.discount?.time_start:void 0);t?this.txb.moveCall({target:$o.Instance().serviceFn("dicscount_create_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),$o.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("dicscount_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),$o.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]})}))}withdraw(e,t,r){$o.IsValidObjects([e,t.treasury,t.withdraw_guard,r])||Ba(Ca.IsValidObjects),t?.for_guard&&!$o.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),po(t.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return t.for_guard?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_forGuard_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_buy_guard(e,t){t?e?this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_machine(e,t){t?e?this.txb.moveCall({target:$o.Instance().serviceFn("machine_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("machine_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().serviceFn("machine_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("machine_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:$o.Instance().serviceFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}publish(e){e?this.txb.moveCall({target:$o.Instance().serviceFn("publish_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("publish"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}clone(e,t,r){let s;return s=r?this.txb.moveCall({target:$o.Instance().serviceFn("clone_withpassport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("clone"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}),t?this.txb.moveCall({target:$o.Instance().serviceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,s)],typeArguments:[e||this.pay_token_type]}):s}set_customer_required(e,t,r){t.length>0&&!e&&Ba(Ca.InvalidParam,"set_customer_required"),e.length>md.MAX_PUBKEY_SIZE&&Ba(Ca.InvalidParam,"set_customer_required.pubkey"),t.length>md.MAX_REQUIRES_COUNT&&Ba(Ca.InvalidParam,"set_customer_required.customer_required"),vo(t,no)||Ba(Ca.IsValidArray,"set_customer_required.customer_required");let s=$a(t);r?this.txb.moveCall({target:$o.Instance().serviceFn("required_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_customer_required(e){e?this.txb.moveCall({target:$o.Instance().serviceFn("required_none_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}change_required_pubkey(e,t){e||Ba(Ca.InvalidParam,"pubkey"),t?this.txb.moveCall({target:$o.Instance().serviceFn("required_pubkey_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_pubkey_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().serviceFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}refund_withArb(e,t,r){$o.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"refund_withArb.order or arb"),go(r)||Ba(Ca.IsValidTokenType,"refund_withArb.arb_type");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);this.txb.moveCall({target:$o.Instance().serviceFn("refund_with_arb"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t),this.txb.object(s)],typeArguments:[this.pay_token_type,r]})}refund(e,t,r){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"refund.order"),t&&!$o.IsValidObjects([t])&&Ba(Ca.IsValidObjects,"refund.refund_guard"),r&&!t&&Ba(Ca.InvalidParam,"refund.passport need refund_guard");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);r&&t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_with_passport"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t),r,this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}update_order_required_info(e,t){t.customer_pubkey&&0!==t.customer_info_crypt.length&&($o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"update_order_required_info.order"),this.txb.moveCall({target:$o.Instance().serviceFn("order_required_info_update"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(t.customer_pubkey),this.txb.pure.string(t.customer_info_crypt)],typeArguments:[this.pay_token_type]}))}order(e,t,r,s,i,n){0===e.length&&Ba(Ca.InvalidParam,"order.buy_items empty");let a=!0,o=[];e.forEach((e=>{md.IsValidItemName(e.item)||(a=!1),po(e.max_price)||(a=!1),po(e.count)||(a=!1),o.includes(e.item)&&(a=!1),o.push(e.item)})),a||Ba(Ca.InvalidParam,"buy_items invalid");let d,c=[],u=[],h=[];e.forEach((e=>{c.push(e.item),u.push(BigInt(e.max_price)),h.push(BigInt(e.count))}));const l=this.txb.sharedObjectRef($o.CLOCK_OBJECT);d=n?r?this.txb.moveCall({target:$o.Instance().serviceFn("dicount_buy_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t),$o.TXB_OBJECT(this.txb,r),this.txb.object(l)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}):r?this.txb.moveCall({target:$o.Instance().serviceFn("disoucnt_buy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t),$o.TXB_OBJECT(this.txb,r),this.txb.object(l)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}),i&&this.update_order_required_info(d,i);var p=void 0;return s&&(p=this.order_bind_machine(d,s)),{order:d,progress:p}}order_launch(e){var t;return e.progress&&(t=this.txb.moveCall({target:$o.Instance().progressFn("create"),arguments:[$o.TXB_OBJECT(this.txb,e.progress)]})),{order:this.txb.moveCall({target:$o.Instance().serviceFn("order_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.order)],typeArguments:[this.pay_token_type]}),progress:t}}buy(e,t,r,s,i,n){const a=this.order(e,t,r,s,i,n);return this.order_launch(a)}order_bind_machine(e,t){return $o.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"order & machine"),this.txb.moveCall({target:$o.Instance().serviceFn("order_bind_machine"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]})}add_treasury(e,t,r){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"add_treasury.treasury"),go(e)||Ba(Ca.IsValidTokenType,"add_treasury.treasury_token_type"),r?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]})}remove_treasury(e,t,r){(t||0!==e.length)&&(r?t?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().serviceFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}set_order_agent(e,t,r){md.SetOrderAgent(this.txb,this.pay_token_type,e,t,r)}change_order_payer(e,t,r){md.ChangeOrderPayer(this.txb,this.pay_token_type,e,t,r)}static MAX_DISCOUNT_COUNT_ONCE=200;static MAX_DISCOUNT_RECEIVER_COUNT=20;static MAX_GUARD_COUNT=16;static MAX_REPOSITORY_COUNT=32;static MAX_ITEM_NAME_LENGTH=256;static MAX_TREASURY_COUNT=8;static MAX_ORDER_AGENT_COUNT=8;static MAX_ORDER_ARBS_COUNT=8;static MAX_ARBITRATION_COUNT=8;static MAX_REQUIRES_COUNT=16;static MAX_PUBKEY_SIZE=3e3;static IsValidItemName(e){return!!e&&(new TextEncoder).encode(e).length<=md.MAX_ITEM_NAME_LENGTH}static parseObjectType=e=>La(e,"service::Service<");static parseOrderObjectType=e=>La(e,"order::Order<");static endpoint=(e,t,r)=>t||(e?e+"/sales/"+encodeURI(r):void 0);static DiscountObjects=(e,t)=>{$o.Client().getOwnedObjects({owner:e,filter:{MoveModule:{module:"order",package:$o.Instance().package("wowok")}},options:{showContent:!0,showType:!0}}).then((r=>{t(e,r.data.map((e=>e.data)))})).catch((e=>{console.log(e)}))};static SetOrderAgent=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"SetOrderAgent.order_token_type"),$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"SetOrderAgent.order"),vo(s,co)||Ba(Ca.IsValidArray,"SetOrderAgent.agent"),$a(s).length>md.MAX_ORDER_AGENT_COUNT&&Ba(Ca.Fail,"SetOrderAgent.agent count"),e.moveCall({target:$o.Instance().orderFn("agent_set"),arguments:[e.object(r),e.pure.vector("address",$a(s))],typeArguments:[t]}),i&&e.moveCall({target:$o.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})};static ChangeOrderPayer=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"ChangeOrderPayer.order_token_type"),$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"ChangeOrderPayer.order"),co(s)||Ba(Ca.IsValidAddress,"ChangeOrderPayer.new_addr"),e.moveCall({target:$o.Instance().orderFn("payer_change"),arguments:[e.object(r),e.pure.address(s)],typeArguments:[t]}),i&&e.moveCall({target:$o.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})}}class bd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new bd(e);return t.object=$o.TXB_OBJECT(e,$o.Instance().objectEntity()),t}mark(e,t,r){"string"!=typeof t||co(t)||Ba(Ca.IsValidAddress,r),this.txb.moveCall({target:$o.Instance().entityFn(r),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object()),"string"==typeof t?this.txb.pure.address(t):t]})}update(e){e?.name&&!no(e.name)&&Ba(Ca.IsValidName,"update"),e?.description&&!io(e.description)&&Ba(Ca.IsValidDesription,"update"),e?.avatar&&!Co(e.avatar)&&Ba(Ca.isValidHttpUrl,"update:avatar"),e?.twitter&&!no(e.twitter)&&Ba(Ca.IsValidName,"update:twitter"),e?.homepage&&!Co(e.homepage)&&Ba(Ca.isValidHttpUrl,"update:homepage"),e?.discord&&!no(e.discord)&&Ba(Ca.IsValidName,"update:discord");const t=Wa.getInstance().bcs.ser("PersonalInfo",{name:e.name?(new TextEncoder).encode(e.name):"",description:e?.description?(new TextEncoder).encode(e.description):"",avatar:e?.avatar??"",twitter:e?.twitter??"",discord:e?.discord??"",homepage:e?.homepage??""}).toBytes();this.txb.moveCall({target:$o.Instance().entityFn("avatar_update"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("u8",[].slice.call(t))]})}create_resource(){return this.txb.moveCall({target:$o.Instance().entityFn("resource_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}create_resource2(){return this.txb.moveCall({target:$o.Instance().entityFn("resource_create2"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}destroy_resource(e){return this.txb.moveCall({target:$o.Instance().entityFn("resource_destroy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object())]})}use_resource(e){return this.txb.moveCall({target:$o.Instance().entityFn("resource_use"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object())]})}transfer_resource(e,t){return co(t)||Ba(Ca.IsValidAddress,"transfer_resource"),this.txb.moveCall({target:$o.Instance().entityFn("resource_transfer"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object()),this.txb.pure.address(t)]})}query_ent(e){co(e)||Ba(Ca.InvalidParam,"query_ent"),this.txb.moveCall({target:$o.Instance().entityFn("QueryEnt"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}}class gd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new gd(e);return t.object=$o.TXB_OBJECT(e,$o.Instance().objectWowok()),t}register_grantor(e,t){no(e)||Ba(Ca.IsValidName,"register_grantor"),$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"register_grantor");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);this.txb.moveCall({target:$o.Instance().wowokFn("grantor_register"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.object(r),$o.TXB_OBJECT(this.txb,t)]})}grantor_time_expand_1year(e){co(e)||Ba(Ca.IsValidAddress,"grantor_time_expand_1year"),this.txb.moveCall({target:$o.Instance().wowokFn("grantor_time_expand_1year"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}grantor_rename(e){no(e)||Ba(Ca.IsValidName,"grantor_rename"),this.txb.moveCall({target:$o.Instance().wowokFn("grantor_time_expand_1year"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}mint(e,t){co(t)||Ba(Ca.IsValidAddress,"mint"),po(e)||Ba(Ca.IsValidU64,"mint"),this.txb.moveCall({target:$o.Instance().baseWowokFn("mint"),arguments:[$o.TXB_OBJECT(this.txb,$o.Instance().objectTreasuryCap()),this.txb.pure.u64(e),this.txb.pure.address(t)]})}oracle(e,t){return io(e)||Ba(Ca.IsValidDesription,"oracle.description"),$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"oracle.permission"),this.txb.moveCall({target:$o.Instance().wowokFn("oracle_repository"),arguments:[$o.TXB_OBJECT(this.txb,$o.Instance().objectOracle()),this.txb.pure.string(e),this.txb.object(t)]})}}!function(e){e.Like="like",e.Dislike="dislike",e.Launch="launch",e.Order="order",e.Payment="payment"}(dd||(dd={}));class _d{static MAX_ADDRESS_COUNT_FOR_TAG=1e3;static MAX_TAG_COUNT_FOR_ADDRESS=64;object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new _d(e);return r.object=$o.TXB_OBJECT(e,t),r}launch(){return this.object||Ba(Ca.Fail,"launch object Invalid"),this.txb.moveCall({target:$o.Instance().resourceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}resolve_add(e,t){return t.find((e=>e===dd.Like))&&bd.From(this.txb).mark(this,e,dd.Like),t.find((e=>e===dd.Dislike))&&bd.From(this.txb).mark(this,e,dd.Dislike),t.filter((e=>e!==dd.Like&&e!==dd.Dislike&&no(e)))}add(e,t,r){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: add.address");var s=this.resolve_add(e,t);(r||0!==s.length)&&(r&&!no(r)&&Ba(Ca.IsValidName,"Resource: add.name"),s.length>_d.MAX_TAG_COUNT_FOR_ADDRESS&&(s=s.slice(0,_d.MAX_TAG_COUNT_FOR_ADDRESS)),this.txb.moveCall({target:$o.Instance().resourceFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.option("string",r),this.txb.pure.vector("string",s)]}))}remove(e,t){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: remove.address"),this.txb.moveCall({target:$o.Instance().resourceFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.vector("string",t)]})}removeall(e){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: removeall.address"),this.txb.moveCall({target:$o.Instance().resourceFn("removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e]})}static TagData(e,t=!0){const r=[];return e.forEach((e=>{e.tags.forEach((t=>{const s=r.find((e=>e.tag===t));s?s.address.find((t=>t===e.address))||s.address.push(e.address):r.push({tag:t,address:[e.address]})}))})),t&&Object.keys(dd).forEach((e=>{r.find((t=>t.tag===dd[e]))||r.push({tag:dd[e],address:[]})})),r}static Tags(e){const t=[];return e.address.forEach((r=>{const s=t.find((e=>e.address===r));s?s.tags.find((t=>t===e.tag))||s.tags.push(e.tag):t.push({address:r,tags:[e.tag]})})),t}}!function(e){e[e.PERMISSION=0]="PERMISSION",e[e.GUARD_ONLY_AND_IMMUTABLE=1]="GUARD_ONLY_AND_IMMUTABLE",e[e.BOTH_PERMISSION_AND_GUARD=2]="BOTH_PERMISSION_AND_GUARD"}(cd||(cd={})),function(e){e[e.WITHDRAW=1]="WITHDRAW",e[e.DEPOSIT=2]="DEPOSIT",e[e.RECEIVE=4]="RECEIVE"}(ud||(ud={}));class fd{token_type;permission;object;txb;get_token_type(){return this.token_type}get_object(){return this.object}static From(e,t,r,s){let i=new fd(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}constructor(e,t,r){this.token_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i){$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"Treasury.New permission, bounty"),io(s)||Ba(Ca.IsValidDesription,"Treasury.New.description"),_o(t)||Ba(Ca.IsValidArgType,t);let n=new fd(e,t,r);return n.object=i?e.moveCall({target:$o.Instance().treasuryFn("new_with_passport"),arguments:[i,e.pure.string(s),$o.TXB_OBJECT(e,r)],typeArguments:[t]}):e.moveCall({target:$o.Instance().treasuryFn("new"),arguments:[e.pure.string(s),$o.TXB_OBJECT(e,r)],typeArguments:[t]}),n}launch(){return this.txb.moveCall({target:$o.Instance().treasuryFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.token_type]})}set_deposit_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_deposit_guard.guard"),t?e?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}deposit(e,t){$o.IsValidObjects([e.coin])||Ba(Ca.IsValidObjects,"deposit.param.coin"),io(e.remark)||Ba(Ca.IsValidDesription,"deposit.param.remark"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"deposit.param.for_object"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"deposit.param.for_guard"),void 0===e.index||po(e.index)||Ba(Ca.InvalidParam,"deposit.param.index");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_forGuard_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}receive(e,t,r){$o.IsValidObjects([e,t])||Ba(Ca.IsValidArray,"receive.payment&received");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?this.txb.moveCall({target:$o.Instance().treasuryFn("receive_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("receive"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}withdraw(e,t){if(0===e.items.length)return;vo(e.items,(e=>po(e.amount)&&co(e.address)))||Ba(Ca.IsValidArray,"withdraw.param.items"),io(e.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark"),po(e.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.for_guard"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),e?.withdraw_guard&&!co(e.withdraw_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard"),e?.withdraw_guard&&!t&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return e.withdraw_guard&&t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_useGuard_forGuard"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_useGuard"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_forGuard_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:$o.Instance().treasuryFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_withdraw_mode(e,t){t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_mode_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_mode_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}add_withdraw_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"add_withdraw_guard.guard"),po(t)||Ba(Ca.IsValidU64,"add_withdraw_guard.amount"),r?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}remove_withdraw_guard(e,t,r){(0!==e.length||t)&&(vo(e,co)||Ba(Ca.IsValidArray,"add_withdraw_guard.guard"),r?t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}))}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"change_permission.new_permission"),this.txb.moveCall({target:$o.Instance().treasuryFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.token_type]}),this.permission=e}static parseObjectType=e=>La(e,"treasury::Treasury<");static MAX_WITHDRAW_GUARD_COUNT=16}const yd=200;function vd(e,t,r){t||Ba(Ca.InvalidParam,"Payment.New.pay_token_type"),r.receiver.length>yd&&Ba(Ca.InvalidParam,"Payment.New.param.receiver"),vo(r.receiver,(e=>co(e.address)&&$o.IsValidObjects([e.coin])))||Ba(Ca.IsValidArray,"Payment.New.param.receiver"),r?.for_object&&!co(r.for_object)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_object"),r?.for_guard&&!co(r.for_guard)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_guard"),r?.business_remark&&!io(r?.business_remark)&&Ba(Ca.IsValidDesription,"Payment.New.param.business_remark");let s=e.pure.option("address",r.for_object?r.for_object:void 0);const i=e.sharedObjectRef($o.CLOCK_OBJECT);return r.for_guard?e.moveCall({target:$o.Instance().paymentFn("create_withGuard"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.object(r.for_guard),e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]}):e.moveCall({target:$o.Instance().paymentFn("create"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]})}class Td{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new Td(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n,a){$o.IsValidObjects([r,n])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New.token_type"),io(s)||Ba(Ca.IsValidDesription),po(i)||Ba(Ca.IsValidU64,"New.fee");let o=t,d=new Td(e,o,r);return d.object=a?e.moveCall({target:$o.Instance().arbitrationFn("new_with_passport"),arguments:[a,e.pure.string(s),e.pure.u64(i),e.object(n),$o.TXB_OBJECT(e,r)],typeArguments:[o]}):e.moveCall({target:$o.Instance().arbitrationFn("new"),arguments:[e.pure.string(s),e.pure.u64(i),e.object(n),$o.TXB_OBJECT(e,r)],typeArguments:[o]}),d}launch(){return this.txb.moveCall({target:$o.Instance().arbitrationFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_fee(e,t){po(e)||Ba(Ca.IsValidU64,"set_fee.fee"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("fee_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("fee_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint,"set_endpoint.endpoint"),t?e?this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_voting_guard(e,t){0!==e.length&&(vo(e,(e=>$o.IsValidObjects([e.guard])&&po(e.voting_weight)))||Ba(Ca.IsValidArray,"add_voting_guard.guard"),t?e.forEach((e=>{this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})):e.forEach((e=>{this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})))}remove_voting_guard(e,t,r){(t||0!==e.length)&&(vo(e,co)||Ba(Ca.IsValidArray,"remove_voting_guard.guard"),r?t?this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}set_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_guard.apply_guard"),t?e?this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().arbitrationFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}vote(e,t){e.voting_guard&&!$o.IsValidObjects([e.voting_guard])&&Ba(Ca.IsValidObjects,"vote.param.voting_guard"),vo(e.agrees,(e=>po(e)&&e<Td.MAX_PROPOSITION_COUNT))||Ba(Ca.IsValidArray,"vote.param.agrees"),$o.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"vote.param.arb");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?e.voting_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("vote_with_passport"),arguments:[t,this.txb.object(e.voting_guard),$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("vote2_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("vote"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arbitration(e,t){io(e.feedback)||Ba(Ca.IsValidDesription,"arbitration.param.feedback"),$o.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"arbitration.param.arb"),e.indemnity&&!po(e.indemnity)&&Ba(Ca.IsValidU64,"arbitration.param.indemnity");let r=this.txb.pure.option("u64",e.indemnity?e.indemnity:void 0);t?this.txb.moveCall({target:$o.Instance().arbitrationFn("arbitration_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("arbitration"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}withdraw_fee(e,t,r){$o.IsValidObjects([e,t.treasury])||Ba(Ca.IsValidObjects,"withdraw_fee.arb or treasury"),t?.for_guard&&!$o.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw_fee.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw_fee.param.for_object"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw_fee.param.remark"),po(t.index)||Ba(Ca.IsValidU64,"withdraw_fee.param.index");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?t.for_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_forGuard_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t.for_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_withdrawTreasury(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_withdrawTreasury.treasury"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_treasury_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_treasury_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arb(e,t){return $o.IsValidObjects([e.order])||Ba(Ca.IsValidObjects,"arb.param.order"),go(e.order_token_type)||Ba(Ca.IsValidTokenType,"arb.param.order_token_type"),io(e.description)||Ba(Ca.IsValidDesription,"arb.param.description"),vo(e.votable_proposition,no)||Ba(Ca.IsValidArray,"arb.param.votable_proposition"),t?e.fee?this.txb.moveCall({target:$o.Instance().arbitrationFn("dispute_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("free_dispute_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]}):e.fee?this.txb.moveCall({target:$o.Instance().arbitrationFn("dispute"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("free_dispute"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]})}arb_launch(e){return this.txb.moveCall({target:$o.Instance().arbFn("create"),arguments:[$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}dispute(e,t){const r=this.arb(e,t);return this.arb_launch(r)}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().arbitrationFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}static parseObjectType=e=>La(e,"arbitration::Arbitration<");static parseArbObjectType=e=>La(e,"arb::Arb<");static queryArbVoted=()=>{};static MAX_PROPOSITION_COUNT=16;static MAX_VOTING_GUARD_COUNT=16}class wd extends Error{}async function Ed({host:e,path:t,body:r,headers:s,method:i}){const n=new URL(t,e).toString(),a=await fetch(n,{method:i,body:r?JSON.stringify(r):void 0,headers:{"Content-Type":"application/json",...s||{}}});if(429===a.status)throw new wd("Too many requests from this client have been sent to the faucet. Please retry later");try{const e=await a.json();if(e.error)throw new Error(`Faucet returns error: ${e.error}`);return e}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${a.status}, response ${a}`)}}async function xd(e){return Ed({host:e.host,path:"/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}async function Od(e){return Ed({host:e.host,path:"/v1/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}function Id(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}class Cd{constructor(e){this.expire=e}expire_time(){return this.expire}expire}var Bd;!function(e){e.object="OBJECT",e.personal="PERSONAL",e.table="TABLE"}(Bd||(Bd={}));const Sd=(e,t)=>e+$o.Instance().package("wowok_origin")+t+"-V2";class Pd extends Cd{constructor(e=1e4){super(e)}data=new Map;load(e){return this.data.get(e)}save(e,t){this.data.set(e,t)}remove(e){this.data.delete(e)}}class jd extends Cd{constructor(e=1e4){super(e)}load(e){return localStorage.getItem(e)}save(e,t){return localStorage.setItem(e,t)}remove(e){return localStorage.removeItem(e)}}class Ad{static _instance;cache=new Map;constructor(){}static Instance(){return Ad._instance||(Ad._instance=new Ad),Ad._instance}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}}var kd;!function(e){e.localStorage="localStorage",e.memoryStorage="memoryStorage"}(kd||(kd={})),new Map;const Ud=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Yd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Nd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Vd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Dd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Rd(t)??""})}catch(e){return JSON.stringify({error:e?.toString()})}},Yd=async e=>{var t=[];const r=[],s=(new Date).getTime(),i=Ad.Instance().get(Bd.object);if(i)for(let n=0;n<e.objects.length;++n){try{let a=i.load(Sd(e.objects[n],Bd.object));if(a){const i=JSON.parse(a);if("INFINITE"!==i?.expire&&(e?.no_cache||i.expire<=s)&&(e.showOwner||e.showContent))r.push(e.objects[n]);else{const e=ec(JSON.parse(i.data));e.cache_expire=i.expire,t.push(e)}}}catch(e){console.log(e)}r.push(e.objects[n])}if(r.length>0){const s=await $o.Client().multiGetObjects({ids:[...r],options:{showContent:e.showContent,showType:e.showType,showOwner:e.showOwner}}),i=Ad.Instance().get(Bd.object);if(i){const e=(new Date).getTime();s.forEach((t=>{try{if(t?.data){const r=t.data?.type??t.data?.content?.type??void 0,s=r?$o.Instance().object_name_from_type_repr(r):void 0,n={expire:"Guard"===s||"Payment"===s?"INFINITE":i.expire_time()+e,data:JSON.stringify(t.data)};i.save(Sd(t.data.objectId,Bd.object),JSON.stringify(n))}}catch(e){console.log(e)}}))}t=t.concat(s.map((e=>ec(e?.data))))}return{objects:t}},Rd=async e=>{co(e.address)||Ba(Ca.IsValidAddress,"entity.address");const t=(new Date).getTime(),r=Ad.Instance().get(Bd.personal);if(r&&!e.no_cache)try{let s=r.load(Sd(e.address,Bd.personal));if(s){const e=JSON.parse(s);if("INFINITE"===e?.expire||e.expire<=t){const t=JSON.parse(e.data);return t.cache_expire=e.expire,t}}}catch(e){console.log(e)}const s=await Qd(Wd($o.Instance().objectEntity(),e.address));if("Personal"===s.type){if(r)try{const t=r.expire_time()+(new Date).getTime(),i={expire:t,data:JSON.stringify(s)};r.save(Sd(e.address,Bd.personal),JSON.stringify(i)),s.cache_expire=t}catch(e){console.log(e)}return s}},Vd=async e=>{const t=await $o.Client().getDynamicFields({parentId:e.parent,cursor:e.cursor,limit:e.limit});return{items:t?.data?.map((e=>({object:e.objectId,type:e.type,version:e.version,key:{type:e.name.type,value:e.name.value}}))),nextCursor:t.nextCursor,hasNextPage:t.hasNextPage}},Md=async(e,t)=>await Qd(Wd(e,t)),Jd=async(e,t)=>await Qd(Wd(e,t)),Fd=async(e,t)=>await Qd(Wd(e,t)),Xd=async(e,t)=>await Qd(Hd(e,t)),Ld=async(e,t)=>await Qd(Hd(e,t)),Gd=async(e,t)=>await Qd(Kd(e,t)),$d=async(e,t)=>await Qd(Kd(e,t)),zd=async(e,t,r)=>("string"!=typeof e&&(e=e.object),await Qd({parent:e,key:{type:$o.Instance().package("wowok")+"::repository::DataKey",value:{id:t,key:r}}})),qd=async(e,t)=>await Qd(Wd(e,t));function Wd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"address",value:t}}}function Hd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"0x1::string::String",value:t}}}function Kd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"u64",value:t}}}const Qd=async e=>{const t=await $o.Client().getDynamicFieldObject({parentId:e.parent,name:{type:e.key.type,value:e.key.value}});return ec(t?.data)};function Zd(e){if(!e)return;const t=$o.Instance().object_name_from_type_repr(e);if("Permission"===t||"Demand"===t||"Machine"===t||"Progress"===t||"Order"===t||"Service"===t||"Treasury"===t||"Arb"===t||"Repository"===t||"Payment"===t||"Discount"===t||"Guard"===t||"Arbitration"===t)return t;if("Resource"===t)return"PersonalMark";const r=e?.indexOf("0x2::dynamic_field::Field<");if(0===r){const t=e?.substring(26);if(t&&$o.Instance().hasPackage(t)){if(t.includes("::demand::Tips>"))return"TableItem_DemandPresenter";if(t.includes("::machine::NodePair>>>"))return"TableItem_MachineNode";if(t.includes("::progress::History>"))return"TableItem_ProgressHistory";if(t.includes("::service::Sale>"))return"TableItem_ServiceSale";if(t.includes("::treasury::Record>"))return"TableItem_TreasuryHistory";if(t.includes("::arb::Voted>"))return"TableItem_ArbVote";if(t.includes("::permission::Perm>>"))return"TableItem_PermissionEntity";if(t.includes("::repository::DataKey"))return"TableItem_RepositoryData";if(t.includes("::entity::Ent>"))return"Personal";if(t.includes("::resource::Tags>"))return"TableItem_PersonalMark"}}}function ec(e){const t=e?.content?.fields,r=e?.objectId??t?.id?.id??void 0,s=e?.type??e?.content?.type??void 0,i=e?.version??void 0,n=e?.owner??void 0,a=Zd(s);if(a)switch(a){case"Permission":return{object:r,type:a,type_raw:s,owner:n,version:i,builder:t?.builder??"",admin:t?.admin,description:t?.description??"",entity_count:parseInt(t?.table?.fields?.size),biz_permission:t?.user_define?.fields?.contents?.map((e=>({id:parseInt(e?.fields?.key),name:e?.fields?.value})))};case"Demand":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,guard:t?.guard?{object:t?.guard,service_id_in_guard:t?.service_identifier}:void 0,time_expire:t?.time_expire,yes:t?.yes,presenter_count:parseInt(t?.presenters?.fields?.size),bounty:t?.bounty?.map((e=>({type:e?.fields?.type,object:e?.fields?.id?.id,balance:e?.fields?.balance})))};case"Machine":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission??"",description:t?.description??"",bPaused:t?.bPaused,bPublished:t?.bPublished,endpoint:t?.endpoint,consensus_repository:t?.consensus_repositories,node_count:parseInt(t?.nodes?.fields?.size)};case"Progress":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,current:t?.current,task:t?.task,parent:t?.parent,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),namedOperator:t?.namedOperator?.fields?.contents?.map((e=>({name:e?.fields?.key,operator:e?.fields?.value}))),session:t?.session?.fields?.contents?.map((e=>({weights:e?.fields?.value?.fields?.weight,threshold:e?.fields?.value?.fields?.threshold,next_node:e?.fields?.key,forward:e?.fields?.value?.fields?.forwards?.fields?.contents?.map((e=>({forward_name:e?.fields?.key,accomplished:e?.fields?.value?.fields?.accomplished,msg:e?.fields?.value?.fields?.msg,orders:e?.fields?.value?.fields?.orders,time:e?.fields?.value?.fields?.time,holder:e?.fields?.value?.fields?.who})))})))};case"Order":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,amount:t?.amount,agent:t?.agent,arb:t?.dispute,payer:t?.payer,progress:t?.progress,discount:t?.discount,balance:t?.payed,required_info:t?.required_info?{pubkey:t?.required_info?.fields?.customer_pub,msg_encrypted:t?.required_info?.fields?.info}:void 0,item:t?.items?.map((e=>({name:e?.fields?.name,price:e?.fields?.price,stock:e?.fields?.stock,endpoint:e?.fields?.endpoint})))};case"Service":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,permission:t?.permission,description:t?.description,arbitration:t?.arbitrations,bPaused:t?.bPaused,bPublished:t?.bPublished,buy_guard:t?.buy_guard,endpoint:t?.endpoint,payee:t?.payee,repository:t?.repositories,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),refund_guard:t?.refund_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),sales_count:parseInt(t?.sales?.fields?.size),extern_withdraw_treasury:t?.extern_withdraw_treasuries,customer_required_info:t?.customer_required?{pubkey:t?.customer_required?.fields?.service_pubkey,required_info:t?.customer_required?.fields?.customer_required_info}:void 0};case"Treasury":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,withdraw_mode:t?.withdraw_mode,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),balance:t?.balance,deposit_guard:t?.deposit_guard,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value})))};case"Arbitration":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,fee:t?.fee,fee_treasury:t?.fee_treasury,usage_guard:t?.usage_guard,endpoint:t?.endpoint,bPaused:t?.bPaused,voting_guard:t?.voting_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,weights:e?.fields?.value})))};case"Arb":return{object:r,type:a,type_raw:s,owner:n,version:i,arbitration:t?.arbitration,description:t?.description,fee:t?.fee,feedback:t?.feedback,indemnity:t?.indemnity,order:t?.order,voted_count:parseInt(t?.voted?.fields?.size),proposition:t?.proposition?.fields?.contents?.map((e=>({proposition:e?.fields?.key,votes:e?.fields?.value})))};case"Repository":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,policy_mode:t?.policy_mode,data_count:parseInt(t?.data?.fields?.size),reference:t?.reference,rep_type:t?.type,policy:t?.policies?.fields?.contents?.map((e=>({key:e?.fields?.key,description:e?.fields?.value?.fields?.description,permissionIndex:e?.fields?.value?.fields?.permission_index,dataType:e?.fields?.value?.fields?.value_type})))};case"Payment":return{object:r,type:a,type_raw:s,owner:n,version:i,signer:t?.signer,time:t?.time,remark:t?.remark,from:t?.from,biz_id:t?.index,for_guard:t?.for_guard,for_object:t?.for_object,amount:t?.amount,record:t?.record?.map((e=>({recipient:e?.fields?.recipient,amount:e?.fields?.amount})))};case"Discount":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,time_start:t?.time_start,time_end:t?.time_end,price_greater:t?.price_greater,off_type:t?.type,off:t?.off,name:t?.name};case"Guard":return{object:r,type:a,type_raw:s,owner:n,version:i,description:t?.description,input:Uint8Array.from(t?.input?.fields?.bytes),identifier:t?.constants?.map((e=>({id:e?.fields?.identifier,bWitness:e?.fields?.bWitness,value:Uint8Array.from(e?.fields?.value)})))};case"PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,tag_count:parseInt(t?.tags?.fields?.size)};case"TableItem_DemandPresenter":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.name,presenter:t?.value?.fields?.who,recommendation:t?.value?.fields?.tips};case"TableItem_ProgressHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,history:Zo.DeHistory(t)};case"TableItem_ServiceSale":return{object:r,type:a,type_raw:s,owner:n,version:i,item:{item:t?.name,stock:t?.value?.fields?.stock,price:t?.value?.fields?.price,endpoint:t?.value?.fields?.endpoint}};case"TableItem_TreasuryHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,id:t?.name,payment:t?.value?.fields?.payment,signer:t?.value?.fields?.signer,operation:t?.value?.fields?.op,amount:t?.value?.fields?.amount,time:t?.value?.fields?.time};case"TableItem_ArbVote":return{object:r,type:a,type_raw:s,owner:n,version:i,singer:t?.name,vote:t?.value?.fields?.agrees,time:t?.value?.fields?.time,weight:t?.value?.fields?.weight};case"TableItem_PermissionEntity":return{object:r,type:a,type_raw:s,owner:n,version:i,entity:t?.name,permission:t?.value?.map((e=>({id:e?.fields.index,guard:e?.fields.guard})))};case"TableItem_RepositoryData":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name?.fields?.id,key:t?.name?.fields?.key,data:Uint8Array.from(t?.value)};case"Personal":const o=Wa.getInstance().de_entInfo(Uint8Array.from(t?.value?.fields?.avatar));return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,like:t?.value?.fields?.like,dislike:t?.value?.fields?.dislike,mark_object:t?.value?.fields?.resource,lastActive_digest:e?.previousTransaction,info:{homepage:o?.homepage,name:o?.name,avatar:o?.avatar,twitter:o?.twitter,discord:o?.discord,description:o?.description}};case"TableItem_PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,name:t?.value?.fields?.nick,tags:t?.value?.fields?.tags}}return{object:r,type:void 0,type_raw:s,owner:n,version:i}}const tc=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await rc(t)})}catch(e){return JSON.stringify({error:e})}},rc=async e=>{co(e.permission_object)||Ba(Ca.IsValidAddress,"permission.permission_object");const t=new _s;Ko.From(t,e.permission_object).query_permissions_all(e.address);const r=await $o.Client().devInspectTransactionBlock({sender:e.address,transactionBlock:t});r.results&&r.results[0].returnValues&&2!==r.results[0].returnValues.length&&Ba(Ca.Fail,"permission.retValues");const s=Wa.getInstance().de(Oa.U8,Uint8Array.from(r.results[0].returnValues[0][0]));if(s===Ko.PERMISSION_ADMIN||s===Ko.PERMISSION_OWNER_AND_ADMIN)return{who:e.address,admin:!0,owner:s%2==1,items:[],object:e.permission_object};{const t=Wa.getInstance().de_perms(Uint8Array.from(r.results[0].returnValues[1][0]));return{who:e.address,admin:!1,owner:s%2==1,items:t.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e.permission_object}}};var sc;!function(e){e.newArbEvents=async e=>await t($o.Instance().package("wowok")+"::arb::NewArbEvent",e),e.presentServiceEvents=async e=>await t($o.Instance().package("wowok")+"::demand::PresentEvent",e),e.newProgressEvents=async e=>await t($o.Instance().package("wowok")+"::progress::NewProgressEvent",e),e.newOrderEvents=async e=>await t($o.Instance().package("wowok")+"::order::NewOrderEvent",e);const t=async(e,t)=>{const r=await $o.Client().queryEvents({query:{MoveEventType:e},cursor:t?.cursor,limit:t?.limit,order:t?.order}),s=r?.data?.map((e=>{if(e?.packageId===$o.Instance().package("wowok")){if(e?.type?.includes("::order::NewOrderEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",order:e?.parsedJson?.object,service:e?.parsedJson?.service,progress:e?.parsedJson?.progress,amount:e?.parsedJson?.amount};if(e?.type?.includes("::demand::PresentEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",demand:e?.parsedJson?.object,service:e?.parsedJson?.service,recommendation:e?.parsedJson?.tips};if(e?.type?.includes("::progress::NewProgressEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",progress:e?.parsedJson?.object,machine:e?.parsedJson?.machine,task:e?.parsedJson?.task};if(e?.type?.includes("::arb::NewArbEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",arb:e?.parsedJson?.object,arbitration:e?.parsedJson?.arbitration,order:e?.parsedJson?.order};if(e?.type?.includes("::entity::NewEntityEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",resource:e?.parsedJson?.resource?.some,address:e?.parsedJson?.target}}return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:""}}));return{data:s,hasNextPage:r?.hasNextPage,nextCursor:r?.nextCursor}}}(sc||(sc={}));const ic="wowok.acc.dat",nc="wowok-acc-v1";class ac{constructor(e="File"){this.storage=e}static _instance;static Instance(){return ac._instance||(ac._instance=new ac),ac._instance}storage="File";_add(e,t,r){var s,i="0x"+ta(Un(Zn.generate().getSecretKey()).secretKey);try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));return e?e.default=r:(r&&s.forEach((e=>e.default=!1)),s.push({name:t,key:i,default:r})),s}}catch(e){}return[{name:t,key:i,default:r}]}_default(e){var t;try{if(e&&(t=JSON.parse(e))){const e=t.find((e=>e.default));if(e)return e}}catch(e){}}_get(e,t,r){var s;try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));if(e)return e;if(r)return s.find((e=>e.default))}}catch(e){}}_rename(e,t,r,s=!0){var i;try{if(e&&(i=JSON.parse(e)),i){const e=i.find((e=>e.name===t));if(!e)return;const n=i.find((e=>e.name===r));if(!n)return e.name=r,i;if(s)return e.name=r,n.name=t,i}}catch(e){}}set_storage(e="File"){this.storage=e}async gen(e,t){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),ic);r.readFile(n,"utf-8",((s,i)=>{const a=this._add(i,e,t);r.writeFileSync(n,JSON.stringify(a),"utf-8")}))}else if("Explorer"===this.storage){const r=this._add(localStorage.getItem(nc),e,t);localStorage.setItem(nc,JSON.stringify(r))}}catch(e){}}async default(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),ic);return this._default(e.readFileSync(s,"utf-8"))}if("Explorer"===this.storage)return this._default(localStorage.getItem(nc))}catch(e){}}async get(e,t=!0){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),ic);return this._get(r.readFileSync(n,"utf-8"),e,t)}if("Explorer"===this.storage)return this._get(localStorage.getItem(nc),e,t)}catch(e){}}async rename(e,t,r=!0){var s;try{if("File"===this.storage){const[i,n,o]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),d=o.join(n.homedir(),ic);(s=this._rename(i.readFileSync(d,"utf-8"),e,t,r))&&i.writeFileSync(d,JSON.stringify(s),"utf-8")}else"Explorer"===this.storage&&(s=this._rename(localStorage.getItem(nc),e,t,r))&&localStorage.setItem(nc,JSON.stringify(s))}catch(e){}return!!s}async get_address(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiAddress()}async get_pubkey(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiPublicKey()}async get_pair(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key))}async list(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),ic);return JSON.parse(e.readFileSync(s,"utf-8")).map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}if("Explorer"===this.storage)return JSON.parse(localStorage.getItem(nc)??"").map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}catch(e){}return[]}async faucet(e){const t=await this.get_address(e,!0);t&&await xd({host:Id("testnet"),recipient:t}).catch((e=>{}))}balance=async(e,t)=>{const r=await this.get_address(e);if(r)return await $o.Client().getBalance({owner:r,coinType:t})};coin=async(e,t)=>{const r=await this.get_address(e);if(r)return(await $o.Client().getCoins({owner:r,coinType:t})).data};get_coin_object=async(e,t,r,s)=>{const i=await this.get_address(r),n=BigInt(t);if(i&&n>BigInt(0)){if(s&&"0x2::sui::SUI"!==s&&"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"!==s){const t=await $o.Client().getCoins({owner:i,coinType:s}),r=[];var a=BigInt(0);for(let e=0;e<t.data.length&&(a+=BigInt(t.data[e].balance),r.push(t.data[e].coinObjectId),!(a>=n));++e);if(1===r.length)return e.splitCoins(r[0],[n]);{const t=r.pop();return e.mergeCoins(t,r),e.splitCoins(t,[n])}}return e.splitCoins(e.gas,[t])}};coin_with_balance=async(e,t,r)=>{const s=await this.get_pair(t,!0);s||Ba(Ca.Fail,"account invalid");const i=new _s,n=await ac.Instance().get_coin_object(i,e,t,r);if(n){i.transferObjects([n],s?.toSuiAddress());const e=await $o.Client().signAndExecuteTransaction({transaction:i,signer:s,options:{showObjectChanges:!0}}),t=r??"0x2::sui::SUI";return e?.objectChanges.find((e=>"created"===e?.type&&(e?.objectType).includes(t)))?.objectId}}}function oc(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const dc=8192;function cc(e){if(e.length<dc)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=dc){const s=e.slice(r,r+dc);t+=String.fromCharCode(...s)}return btoa(t)}const uc=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;n<e.length;){const s=e.charCodeAt(n);if(s>255)return;let i=t[s];if(255===i)return;let a=0;for(let e=d-1;(0!==i||a<o)&&-1!==e;e--,a++)i+=r*c[e]>>>0,c[e]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");o=a,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let l=a;for(;u!==d;)h[l++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let l=s.repeat(i);for(;h<c;++h)l+=e.charAt(u[h]);return l},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),hc=e=>uc.encode(e),lc=e=>uc.decode(e);function pc(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function mc(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function bc(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class gc{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class _c{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return fc(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return fc(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return fc(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return bc(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return hc(e);case"base64":return cc(e);case"hex":return mc(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function fc(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var yc,vc,Tc,wc,Ec=e=>{throw TypeError(e)},xc=(e,t,r)=>t.has(e)||Ec("Cannot "+r),Oc=(e,t,r)=>(xc(e,t,"read from private field"),r?r.call(e):t.get(e)),Ic=(e,t,r)=>t.has(e)?Ec("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Cc=(e,t,r,s)=>(xc(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);yc=new WeakMap,vc=new WeakMap;let Bc=class e{constructor(e){Ic(this,yc),Ic(this,vc),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Cc(this,yc,e.write),Cc(this,vc,e.serialize??((e,t)=>{const r=new _c({initialSize:this.serializedSize(e)??void 0,...t});return Oc(this,yc).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Oc(this,yc).call(this,e,t)}serialize(e,t){return this.validate(e),new jc(this,Oc(this,vc).call(this,e,t))}parse(e){const t=new gc(e);return this.read(t)}fromHex(e){return this.parse(pc(e))}fromBase58(e){return this.parse(lc(e))}fromBase64(e){return this.parse(oc(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>Oc(this,yc).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>Oc(this,vc).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const Sc=Symbol.for("@mysten/serialized-bcs");function Pc(e){return!!e&&"object"==typeof e&&!0===e[Sc]}class jc{constructor(e,t){Ic(this,Tc),Ic(this,wc),Cc(this,Tc,e),Cc(this,wc,t)}get[Sc](){return!0}toBytes(){return Oc(this,wc)}toHex(){return mc(Oc(this,wc))}toBase64(){return cc(Oc(this,wc))}toBase58(){return hc(Oc(this,wc))}parse(){return Oc(this,Tc).parse(Oc(this,wc))}}function Ac({size:e,...t}){return new Bc({...t,serializedSize:()=>e})}function kc({readMethod:e,writeMethod:t,...r}){return Ac({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function Uc({readMethod:e,writeMethod:t,...r}){return Ac({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function Nc(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function Dc(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??Nc(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function Yc(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}Tc=new WeakMap,wc=new WeakMap;var Rc=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Vc(e,t){return{kind:"validation",type:"check",reference:Vc,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&Dc(this,"input",e,t),e}}}function Mc(e){return{kind:"validation",type:"integer",reference:Mc,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&Dc(this,"integer",e,t),e}}}function Jc(e){return{kind:"transformation",type:"transform",reference:Jc,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Fc(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function Xc(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Lc(e,t){return{kind:"schema",type:"array",reference:Lc,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Dc(this,"type",e,t);return e}}}function Gc(e){return{kind:"schema",type:"bigint",reference:Gc,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:Dc(this,"type",e,t),e}}}function $c(e){return{kind:"schema",type:"boolean",reference:$c,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:Dc(this,"type",e,t),e}}}function zc(e){return{kind:"schema",type:"lazy",reference:zc,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function qc(e,t){return{kind:"schema",type:"literal",reference:qc,expects:Nc(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:Dc(this,"type",e,t),e}}}function Wc(e,...t){const r={kind:"schema",type:"nullable",reference:Wc,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Fc(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function Hc(e,...t){const r={kind:"schema",type:"nullish",reference:Hc,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Fc(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function Kc(e){return{kind:"schema",type:"number",reference:Kc,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?Dc(this,"type",e,t):e.typed=!0,e}}}function Qc(e,t){return{kind:"schema",type:"object",reference:Qc,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else Dc(this,"type",e,t);return e}}}function Zc(e,...t){const r={kind:"schema",type:"optional",reference:Zc,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Fc(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function eu(e,t,r){return{kind:"schema",type:"record",reference:eu,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(Yc(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else Dc(this,"type",e,t);return e}}}function tu(e){return{kind:"schema",type:"string",reference:tu,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:Dc(this,"type",e,t),e}}}function ru(e,t){return{kind:"schema",type:"tuple",reference:ru,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Dc(this,"type",e,t);return e}}}function su(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function iu(e,t){return{kind:"schema",type:"union",reference:iu,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];Dc(this,"type",e,t,{issues:su(s)}),e.typed=!0}else{if(1===i?.length)return i[0];Dc(this,"type",e,t,{issues:su(i)})}return e}}}function nu(){return{kind:"schema",type:"unknown",reference:nu,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function au(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new Rc(s.issues);return s.value}function ou(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function du(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&32===function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)}function cu(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(64,"0")}`}function uu(e,t=!1){return cu(e,t)}function hu(e){return ou(iu(Object.entries(e).map((([e,t])=>Qc({[e]:t})))),Jc((e=>({...e,$kind:Object.keys(e)[0]}))))}const lu=ou(tu(),Jc((e=>cu(e))),Vc(du)),pu=lu,mu=tu(),bu=ou(iu([tu(),ou(Kc(),Mc())]),Vc((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),gu=Qc({objectId:lu,version:bu,digest:tu()}),_u=ou(iu([Qc({GasCoin:qc(!0)}),Qc({Input:ou(Kc(),Mc()),type:Zc(qc("pure"))}),Qc({Input:ou(Kc(),Mc()),type:Zc(qc("object"))}),Qc({Result:ou(Kc(),Mc())}),Qc({NestedResult:ru([ou(Kc(),Mc()),ou(Kc(),Mc())])})]),Jc((e=>({...e,$kind:Object.keys(e)[0]})))),fu=Qc({budget:Wc(bu),price:Wc(bu),owner:Wc(lu),payment:Wc(Lc(gu))}),yu=(Qc({address:tu(),module:tu(),name:tu(),typeParams:Lc(tu())}),iu([qc("address"),qc("bool"),qc("u8"),qc("u16"),qc("u32"),qc("u64"),qc("u128"),qc("u256"),Qc({vector:zc((()=>yu))}),Qc({datatype:Qc({package:tu(),module:tu(),type:tu(),typeParameters:Lc(zc((()=>yu)))})}),Qc({typeParameter:ou(Kc(),Mc())})])),vu=Qc({ref:Wc(iu([qc("&"),qc("&mut")])),body:yu}),Tu=Qc({package:pu,module:tu(),function:tu(),typeArguments:Lc(tu()),arguments:Lc(_u),_argumentTypes:Zc(Wc(Lc(vu)))}),wu=Qc({name:tu(),inputs:eu(tu(),iu([_u,Lc(_u)])),data:eu(tu(),nu())}),Eu=hu({MoveCall:Tu,TransferObjects:Qc({objects:Lc(_u),address:_u}),SplitCoins:Qc({coin:_u,amounts:Lc(_u)}),MergeCoins:Qc({destination:_u,sources:Lc(_u)}),Publish:Qc({modules:Lc(mu),dependencies:Lc(pu)}),MakeMoveVec:Qc({type:Wc(tu()),elements:Lc(_u)}),Upgrade:Qc({modules:Lc(mu),dependencies:Lc(pu),package:pu,ticket:_u}),$Intent:wu}),xu=hu({ImmOrOwnedObject:gu,SharedObject:Qc({objectId:pu,initialSharedVersion:bu,mutable:$c()}),Receiving:gu}),Ou=hu({Object:xu,Pure:Qc({bytes:mu}),UnresolvedPure:Qc({value:nu()}),UnresolvedObject:Qc({objectId:pu,version:Zc(Wc(bu)),digest:Zc(Wc(tu())),initialSharedVersion:Zc(Wc(bu))})}),Iu=hu({Object:xu,Pure:Qc({bytes:mu})}),Cu=hu({None:qc(!0),Epoch:bu}),Bu=Qc({version:qc(2),sender:Hc(lu),expiration:Hc(Cu),gasData:fu,inputs:Lc(Ou),commands:Lc(Eu)}),Su={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>au(_u,e))),address:au(_u,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:au(_u,e),amounts:t.map((e=>au(_u,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:au(_u,e),sources:t.map((e=>au(_u,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:cc(new Uint8Array(e)))),dependencies:t.map((e=>uu(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:s})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:cc(new Uint8Array(e)))),dependencies:t.map((e=>uu(e))),package:r,ticket:au(_u,s)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>au(_u,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>au(_u,e))):au(_u,t)]))),data:r}})},Pu=/^vector<(.+)>$/,ju=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class Au{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(Pu);if(r)return{vector:Au.parseFromStr(r[1],t)};const s=e.match(ju);if(s)return{struct:{address:t?cu(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:Au.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>Au.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${Au.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(Au.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const ku=Qc({digest:tu(),objectId:tu(),version:iu([ou(Kc(),Mc()),tu(),Gc()])}),Uu=hu({ImmOrOwned:ku,Shared:Qc({objectId:pu,initialSharedVersion:bu,mutable:$c()}),Receiving:ku}),Nu=hu({Object:Uu,Pure:Lc(ou(Kc(),Mc()))}),Du=iu([Qc({kind:qc("Input"),index:ou(Kc(),Mc()),value:nu(),type:Zc(qc("object"))}),Qc({kind:qc("Input"),index:ou(Kc(),Mc()),value:nu(),type:qc("pure")})]),Yu=iu([Qc({Epoch:ou(Kc(),Mc())}),Qc({None:Wc(qc(!0))})]),Ru=ou(iu([Kc(),tu(),Gc()]),Vc((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Vu=iu([Qc({bool:Wc(qc(!0))}),Qc({u8:Wc(qc(!0))}),Qc({u64:Wc(qc(!0))}),Qc({u128:Wc(qc(!0))}),Qc({address:Wc(qc(!0))}),Qc({signer:Wc(qc(!0))}),Qc({vector:zc((()=>Vu))}),Qc({struct:zc((()=>Mu))}),Qc({u16:Wc(qc(!0))}),Qc({u32:Wc(qc(!0))}),Qc({u256:Wc(qc(!0))})]),Mu=Qc({address:tu(),module:tu(),name:tu(),typeParams:Lc(Vu)}),Ju=Qc({budget:Zc(Ru),price:Zc(Ru),payment:Zc(Lc(ku)),owner:Zc(tu())}),Fu=iu([Du,Qc({kind:qc("GasCoin")}),Qc({kind:qc("Result"),index:ou(Kc(),Mc())}),Qc({kind:qc("NestedResult"),index:ou(Kc(),Mc()),resultIndex:ou(Kc(),Mc())})]),Xu=Qc({kind:qc("MoveCall"),target:ou(tu(),Vc((e=>3===e.split("::").length))),typeArguments:Lc(tu()),arguments:Lc(Fu)}),Lu=Qc({kind:qc("TransferObjects"),objects:Lc(Fu),address:Fu}),Gu=Qc({kind:qc("SplitCoins"),coin:Fu,amounts:Lc(Fu)}),$u=Qc({kind:qc("MergeCoins"),destination:Fu,sources:Lc(Fu)}),zu=Qc({kind:qc("MakeMoveVec"),type:iu([Qc({Some:Vu}),Qc({None:Wc(qc(!0))})]),objects:Lc(Fu)}),qu=iu([Xu,Lu,Gu,$u,Qc({kind:qc("Publish"),modules:Lc(Lc(ou(Kc(),Mc()))),dependencies:Lc(tu())}),Qc({kind:qc("Upgrade"),modules:Lc(Lc(ou(Kc(),Mc()))),dependencies:Lc(tu()),packageId:tu(),ticket:Fu}),zu]);function Wu(e){const t=e.inputs.map(((e,t)=>{if(e.Object)return{kind:"Input",index:t,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:t,value:{Pure:Array.from(oc(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:t,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:t,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:t,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:Au.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>Hu(e,t)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:Hu(e.MergeCoins.destination,t),sources:e.MergeCoins.sources.map((e=>Hu(e,t)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>Hu(e,t)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(oc(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:Hu(e.SplitCoins.coin,t),amounts:e.SplitCoins.amounts.map((e=>Hu(e,t)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>Hu(e,t))),address:Hu(e.TransferObjects.address,t)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(oc(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:Hu(e.Upgrade.ticket,t)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function Hu(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function Ku(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Qu(e){return iu(Object.entries(e).map((([e,t])=>Qc({[e]:t}))))}Qc({version:qc(1),sender:Zc(tu()),expiration:Hc(Yu),gasConfig:Ju,inputs:Lc(Du),transactions:Lc(qu)});const Zu=Qu({GasCoin:qc(!0),Input:ou(Kc(),Mc()),Result:ou(Kc(),Mc()),NestedResult:ru([ou(Kc(),Mc()),ou(Kc(),Mc())])}),eh=Qc({budget:Wc(bu),price:Wc(bu),owner:Wc(lu),payment:Wc(Lc(gu))}),th=Qc({package:pu,module:tu(),function:tu(),typeArguments:Lc(tu()),arguments:Lc(Zu)}),rh=Qc({name:tu(),inputs:eu(tu(),iu([Zu,Lc(Zu)])),data:eu(tu(),nu())}),sh=Qu({MoveCall:th,TransferObjects:Qc({objects:Lc(Zu),address:Zu}),SplitCoins:Qc({coin:Zu,amounts:Lc(Zu)}),MergeCoins:Qc({destination:Zu,sources:Lc(Zu)}),Publish:Qc({modules:Lc(mu),dependencies:Lc(pu)}),MakeMoveVec:Qc({type:Wc(tu()),elements:Lc(Zu)}),Upgrade:Qc({modules:Lc(mu),dependencies:Lc(pu),package:pu,ticket:Zu}),$Intent:rh}),ih=Qu({ImmOrOwnedObject:gu,SharedObject:Qc({objectId:pu,initialSharedVersion:bu,mutable:$c()}),Receiving:gu}),nh=Qu({Object:ih,Pure:Qc({bytes:mu}),UnresolvedPure:Qc({value:nu()}),UnresolvedObject:Qc({objectId:pu,version:Zc(Wc(bu)),digest:Zc(Wc(tu())),initialSharedVersion:Zc(Wc(bu))})}),ah=Qu({None:qc(!0),Epoch:bu}),oh=Qc({version:qc(2),sender:Hc(lu),expiration:Hc(ah),gasData:eh,inputs:Lc(nh),commands:Lc(sh)}),dh=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?cc(e):e.toBase64()}}},ch=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:cu(e)}}}),uh=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:cu(e)}}}),hh=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:cu(e)}}}),lh={u8:e=>kc({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>kc({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>kc({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>Uc({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>Uc({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>Uc({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>Ac({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new Bc({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(bc(e)),...e}),bytes:(e,t)=>Ac({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new Bc({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=bc(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new Bc({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>lh.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new Bc({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new Bc({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new Bc({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new Bc({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>lh.vector(lh.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new Bc({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},ph=lh.bytes(32).transform({validate:e=>{const t="string"==typeof e?e:mc(e);if(!t||!du(cu(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?pc(cu(e)):e,output:e=>cu(mc(e))}),mh=lh.vector(lh.u8()).transform({name:"ObjectDigest",input:e=>lc(e),output:e=>hc(new Uint8Array(e)),validate:e=>{if(32!==lc(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),bh=lh.struct("SuiObjectRef",{objectId:ph,version:lh.u64(),digest:mh}),gh=lh.struct("SharedObjectRef",{objectId:ph,initialSharedVersion:lh.u64(),mutable:lh.bool()}),_h=lh.enum("ObjectArg",{ImmOrOwnedObject:bh,SharedObject:gh,Receiving:bh}),fh=lh.enum("CallArg",{Pure:lh.struct("Pure",{bytes:lh.vector(lh.u8()).transform({input:e=>"string"==typeof e?oc(e):e,output:e=>cc(new Uint8Array(e))})}),Object:_h}),yh=lh.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:lh.lazy((()=>yh)),struct:lh.lazy((()=>Ch)),u16:null,u32:null,u256:null}),vh=yh.transform({input:e=>"string"==typeof e?Au.parseFromStr(e,!0):e,output:e=>Au.tagToString(e)}),Th=lh.enum("Argument",{GasCoin:null,Input:lh.u16(),Result:lh.u16(),NestedResult:lh.tuple([lh.u16(),lh.u16()])}),wh=lh.struct("ProgrammableMoveCall",{package:ph,module:lh.string(),function:lh.string(),typeArguments:lh.vector(vh),arguments:lh.vector(Th)}),Eh=lh.enum("Command",{MoveCall:wh,TransferObjects:lh.struct("TransferObjects",{objects:lh.vector(Th),address:Th}),SplitCoins:lh.struct("SplitCoins",{coin:Th,amounts:lh.vector(Th)}),MergeCoins:lh.struct("MergeCoins",{destination:Th,sources:lh.vector(Th)}),Publish:lh.struct("Publish",{modules:lh.vector(lh.vector(lh.u8()).transform({input:e=>"string"==typeof e?oc(e):e,output:e=>cc(new Uint8Array(e))})),dependencies:lh.vector(ph)}),MakeMoveVec:lh.struct("MakeMoveVec",{type:function(e){return lh.enum("Option",{None:null,Some:e})}(vh).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:lh.vector(Th)}),Upgrade:lh.struct("Upgrade",{modules:lh.vector(lh.vector(lh.u8()).transform({input:e=>"string"==typeof e?oc(e):e,output:e=>cc(new Uint8Array(e))})),dependencies:lh.vector(ph),package:ph,ticket:Th})}),xh=lh.struct("ProgrammableTransaction",{inputs:lh.vector(fh),commands:lh.vector(Eh)}),Oh=lh.enum("TransactionKind",{ProgrammableTransaction:xh,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ih=lh.enum("TransactionExpiration",{None:null,Epoch:lh.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})}),Ch=lh.struct("StructTag",{address:ph,module:lh.string(),name:lh.string(),typeParams:lh.vector(yh)}),Bh=lh.struct("GasData",{payment:lh.vector(bh),owner:ph,price:lh.u64(),budget:lh.u64()}),Sh=lh.struct("TransactionDataV1",{kind:Oh,sender:ph,gasData:Bh,expiration:Ih}),Ph=lh.enum("TransactionData",{V1:Sh}),jh=lh.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Ah=lh.enum("IntentVersion",{V0:null}),kh=lh.enum("AppId",{Sui:null}),Uh=lh.struct("Intent",{scope:jh,version:Ah,appId:kh});function Nh(e){return lh.struct(`IntentMessage<${e.name}>`,{intent:Uh,value:e})}const Dh=lh.enum("CompressedSignature",{ED25519:lh.fixedArray(64,lh.u8()),Secp256k1:lh.fixedArray(64,lh.u8()),Secp256r1:lh.fixedArray(64,lh.u8()),ZkLogin:lh.vector(lh.u8())}),Yh=lh.enum("PublicKey",{ED25519:lh.fixedArray(32,lh.u8()),Secp256k1:lh.fixedArray(33,lh.u8()),Secp256r1:lh.fixedArray(33,lh.u8()),ZkLogin:lh.vector(lh.u8())}),Rh=lh.struct("MultiSigPkMap",{pubKey:Yh,weight:lh.u8()}),Vh=lh.struct("MultiSigPublicKey",{pk_map:lh.vector(Rh),threshold:lh.u16()}),Mh=lh.struct("MultiSig",{sigs:lh.vector(Dh),bitmap:lh.u16(),multisig_pk:Vh}),Jh=lh.vector(lh.u8()).transform({input:e=>"string"==typeof e?oc(e):e,output:e=>cc(new Uint8Array(e))}),Fh=lh.struct("SenderSignedTransaction",{intentMessage:Nh(Ph),txSignatures:lh.vector(Jh)}),Xh=lh.vector(Fh,{name:"SenderSignedData"}),Lh=lh.enum("PackageUpgradeError",{UnableToFetchPackage:lh.struct("UnableToFetchPackage",{packageId:ph}),NotAPackage:lh.struct("NotAPackage",{objectId:ph}),IncompatibleUpgrade:null,DigestDoesNotMatch:lh.struct("DigestDoesNotMatch",{digest:lh.vector(lh.u8())}),UnknownUpgradePolicy:lh.struct("UnknownUpgradePolicy",{policy:lh.u8()}),PackageIDDoesNotMatch:lh.struct("PackageIDDoesNotMatch",{packageId:ph,ticketId:ph})}),Gh=lh.struct("ModuleId",{address:ph,name:lh.string()}),$h=lh.struct("MoveLocation",{module:Gh,function:lh.u16(),instruction:lh.u16(),functionName:lh.option(lh.string())}),zh=lh.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:lh.struct("IndexOutOfBounds",{idx:lh.u16()}),SecondaryIndexOutOfBounds:lh.struct("SecondaryIndexOutOfBounds",{resultIdx:lh.u16(),secondaryIdx:lh.u16()}),InvalidResultArity:lh.struct("InvalidResultArity",{resultIdx:lh.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),qh=lh.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Wh=lh.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:lh.struct("MoveObjectTooBig",{objectSize:lh.u64(),maxObjectSize:lh.u64()}),MovePackageTooBig:lh.struct("MovePackageTooBig",{objectSize:lh.u64(),maxObjectSize:lh.u64()}),CircularObjectOwnership:lh.struct("CircularObjectOwnership",{object:ph}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:lh.option($h),MoveAbort:lh.tuple([$h,lh.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:lh.struct("CommandArgumentError",{argIdx:lh.u16(),kind:zh}),TypeArgumentError:lh.struct("TypeArgumentError",{argumentIdx:lh.u16(),kind:qh}),UnusedValueWithoutDrop:lh.struct("UnusedValueWithoutDrop",{resultIdx:lh.u16(),secondaryIdx:lh.u16()}),InvalidPublicFunctionReturnType:lh.struct("InvalidPublicFunctionReturnType",{idx:lh.u16()}),InvalidTransferObject:null,EffectsTooLarge:lh.struct("EffectsTooLarge",{currentSize:lh.u64(),maxSize:lh.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:lh.struct("PackageUpgradeError",{upgradeError:Lh}),WrittenObjectsTooLarge:lh.struct("WrittenObjectsTooLarge",{currentSize:lh.u64(),maxSize:lh.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Hh=lh.enum("ExecutionStatus",{Success:null,Failed:lh.struct("ExecutionFailed",{error:Wh,command:lh.option(lh.u64())})}),Kh=lh.struct("GasCostSummary",{computationCost:lh.u64(),storageCost:lh.u64(),storageRebate:lh.u64(),nonRefundableStorageFee:lh.u64()}),Qh=lh.enum("Owner",{AddressOwner:ph,ObjectOwner:ph,Shared:lh.struct("Shared",{initialSharedVersion:lh.u64()}),Immutable:null}),Zh=lh.struct("TransactionEffectsV1",{status:Hh,executedEpoch:lh.u64(),gasUsed:Kh,modifiedAtVersions:lh.vector(lh.tuple([ph,lh.u64()])),sharedObjects:lh.vector(bh),transactionDigest:mh,created:lh.vector(lh.tuple([bh,Qh])),mutated:lh.vector(lh.tuple([bh,Qh])),unwrapped:lh.vector(lh.tuple([bh,Qh])),deleted:lh.vector(bh),unwrappedThenDeleted:lh.vector(bh),wrapped:lh.vector(bh),gasObject:lh.tuple([bh,Qh]),eventsDigest:lh.option(mh),dependencies:lh.vector(mh)}),el=lh.tuple([lh.u64(),mh]),tl=lh.enum("ObjectIn",{NotExist:null,Exist:lh.tuple([el,Qh])}),rl=lh.enum("ObjectOut",{NotExist:null,ObjectWrite:lh.tuple([mh,Qh]),PackageWrite:el}),sl=lh.enum("IDOperation",{None:null,Created:null,Deleted:null}),il=lh.struct("EffectsObjectChange",{inputState:tl,outputState:rl,idOperation:sl}),nl=lh.enum("UnchangedSharedKind",{ReadOnlyRoot:el,MutateDeleted:lh.u64(),ReadDeleted:lh.u64(),Cancelled:lh.u64(),PerEpochConfig:null}),al=lh.struct("TransactionEffectsV2",{status:Hh,executedEpoch:lh.u64(),gasUsed:Kh,transactionDigest:mh,gasObjectIndex:lh.option(lh.u32()),eventsDigest:lh.option(mh),dependencies:lh.vector(mh),lamportVersion:lh.u64(),changedObjects:lh.vector(lh.tuple([ph,il])),unchangedSharedObjects:lh.vector(lh.tuple([ph,nl])),auxDataDigest:lh.option(mh)}),ol=lh.enum("TransactionEffects",{V1:Zh,V2:al}),dl={...lh,U8:lh.u8(),U16:lh.u16(),U32:lh.u32(),U64:lh.u64(),U128:lh.u128(),U256:lh.u256(),ULEB128:lh.uleb128(),Bool:lh.bool(),String:lh.string(),Address:ph,AppId:kh,Argument:Th,CallArg:fh,CompressedSignature:Dh,GasData:Bh,Intent:Uh,IntentMessage:Nh,IntentScope:jh,IntentVersion:Ah,MultiSig:Mh,MultiSigPkMap:Rh,MultiSigPublicKey:Vh,ObjectArg:_h,ObjectDigest:mh,ProgrammableMoveCall:wh,ProgrammableTransaction:xh,PublicKey:Yh,SenderSignedData:Xh,SenderSignedTransaction:Fh,SharedObjectRef:gh,StructTag:Ch,SuiObjectRef:bh,Command:Eh,TransactionData:Ph,TransactionDataV1:Sh,TransactionExpiration:Ih,TransactionKind:Oh,TypeTag:vh,TransactionEffects:ol},cl=(BigInt(1e9),uu("0x6"),"0x2::sui::SUI");function ul(e){if("string"==typeof e)switch(e){case"address":return dl.Address;case"bool":return dl.Bool;case"u8":return dl.U8;case"u16":return dl.U16;case"u32":return dl.U32;case"u64":return dl.U64;case"u128":return dl.U128;case"u256":return dl.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return dl.vector(dl.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=ul(e.vector);return t?dl.vector(t):null}if("datatype"in e){const t=cu(e.datatype.package);if(t===cu("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return dl.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return dl.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=ul(e.datatype.typeParameters[0]);return t?dl.vector(t):null}}if(t===cu("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return dl.Address}return null}function hl(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:hl(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(hl)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}uu("0x5");async function ll(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{pl(t,dl.U64,e)}));break;case"TransferObjects":pl(t.TransferObjects.address,dl.Address,e)}}));const a=new Map;if(n.size>0){const e=gl(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:hl(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:hl(e.MutableReference)}:{ref:null,body:hl(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&cu(t.package)===cu("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=ul(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=dh(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>uu(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>gl(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=cu(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=uh({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:ml(e,t)}):bl(e,t)&&(s=hh({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??ch({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await gl(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await gl(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await gl(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:cl})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>au(gu,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function pl(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=dh(t.serialize(s.UnresolvedPure.value)))}function ml(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function bl(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function gl(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function _l(e){function t(t,r){if("string"==typeof t)return e(fl(t).serialize(r));if(t instanceof Uint8Array||Pc(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(dl.U8.serialize(t)),t.u16=t=>e(dl.U16.serialize(t)),t.u32=t=>e(dl.U32.serialize(t)),t.u64=t=>e(dl.U64.serialize(t)),t.u128=t=>e(dl.U128.serialize(t)),t.u256=t=>e(dl.U256.serialize(t)),t.bool=t=>e(dl.Bool.serialize(t)),t.string=t=>e(dl.String.serialize(t)),t.address=t=>e(dl.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(dl.vector(fl(t)).serialize(r)),t.option=(t,r)=>e(dl.option(fl(t)).serialize(r)),t}function fl(e){switch(e){case"u8":return dl.u8();case"u16":return dl.u16();case"u32":return dl.u32();case"u64":return dl.u64();case"u128":return dl.u128();case"u256":return dl.u256();case"bool":return dl.bool();case"string":return dl.string();case"id":case"address":return dl.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?dl.vector(fl(r)):dl.option(fl(r))}throw new Error(`Invalid Pure type name: ${e}`)}function yl(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function vl(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Tl(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wl(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}const El=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function xl(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Ol=El?e=>e:e=>xl(e);function Il(e){for(let t=0;t<e.length;t++)e[t]=xl(e[t])}function Cl(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),vl(e),e}class Bl{clone(){return this._cloneInto()}}function Sl(e){const t=(t,r)=>e(r).update(Cl(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const Pl=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class jl extends Bl{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,yl(e),yl(t),yl(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=wl(this.buffer)}update(e){Tl(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=Cl(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(El||Il(s),this.compress(s,0,!1),El||Il(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));El||Il(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);El||Il(e)}}return this}digestInto(e){Tl(this),function(e,t){vl(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),El||Il(r),this.compress(r,0,!0),El||Il(r);const s=wl(e);this.get().forEach(((e,t)=>s[t]=Ol(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Al=BigInt(2**32-1),kl=BigInt(32);function Ul(e,t=!1){return t?{h:Number(e&Al),l:Number(e>>kl&Al)}:{h:0|Number(e>>kl&Al),l:0|Number(e&Al)}}const Nl={fromBig:Ul,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Ul(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<kl|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Dl=Nl,Yl=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Rl=new Uint32Array(32);function Vl(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Rl[2*e],c=Rl[2*e+1],u=Rl[2*t],h=Rl[2*t+1],l=Rl[2*r],p=Rl[2*r+1],m=Rl[2*s],b=Rl[2*s+1],g=Dl.add3L(d,u,a);c=Dl.add3H(g,c,h,o),d=0|g,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Dl.rotr32H(b,m),Dl:Dl.rotr32L(b,m)}),({h:p,l}=Dl.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Dl.rotrSH(h,u,24),Bl:Dl.rotrSL(h,u,24)}),Rl[2*e]=d,Rl[2*e+1]=c,Rl[2*t]=u,Rl[2*t+1]=h,Rl[2*r]=l,Rl[2*r+1]=p,Rl[2*s]=m,Rl[2*s+1]=b}function Ml(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Rl[2*e],c=Rl[2*e+1],u=Rl[2*t],h=Rl[2*t+1],l=Rl[2*r],p=Rl[2*r+1],m=Rl[2*s],b=Rl[2*s+1],g=Dl.add3L(d,u,a);c=Dl.add3H(g,c,h,o),d=0|g,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Dl.rotrSH(b,m,16),Dl:Dl.rotrSL(b,m,16)}),({h:p,l}=Dl.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Dl.rotrBH(h,u,63),Bl:Dl.rotrBL(h,u,63)}),Rl[2*e]=d,Rl[2*e+1]=c,Rl[2*t]=u,Rl[2*t+1]=h,Rl[2*r]=l,Rl[2*r+1]=p,Rl[2*s]=m,Rl[2*s+1]=b}class Jl extends jl{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Yl[0],this.v0h=0|Yl[1],this.v1l=0|Yl[2],this.v1h=0|Yl[3],this.v2l=0|Yl[4],this.v2h=0|Yl[5],this.v3l=0|Yl[6],this.v3h=0|Yl[7],this.v4l=0|Yl[8],this.v4h=0|Yl[9],this.v5l=0|Yl[10],this.v5h=0|Yl[11],this.v6l=0|Yl[12],this.v6h=0|Yl[13],this.v7l=0|Yl[14],this.v7h=0|Yl[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=wl(Cl(e.salt));this.v4l^=Ol(t[0]),this.v4h^=Ol(t[1]),this.v5l^=Ol(t[2]),this.v5h^=Ol(t[3])}if(e.personalization){const t=wl(Cl(e.personalization));this.v6l^=Ol(t[0]),this.v6h^=Ol(t[1]),this.v7l^=Ol(t[2]),this.v7h^=Ol(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(Cl(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:l,v6h:p,v7l:m,v7h:b}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b]}set(e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|l,this.v6h=0|p,this.v7l=0|m,this.v7h=0|b}compress(e,t,r){this.get().forEach(((e,t)=>Rl[t]=e)),Rl.set(Yl,16);let{h:s,l:i}=Dl.fromBig(BigInt(this.length));Rl[24]=Yl[8]^i,Rl[25]=Yl[9]^s,r&&(Rl[28]=~Rl[28],Rl[29]=~Rl[29]);let n=0;const a=Pl;for(let r=0;r<12;r++)Vl(0,4,8,12,e,t+2*a[n++]),Ml(0,4,8,12,e,t+2*a[n++]),Vl(1,5,9,13,e,t+2*a[n++]),Ml(1,5,9,13,e,t+2*a[n++]),Vl(2,6,10,14,e,t+2*a[n++]),Ml(2,6,10,14,e,t+2*a[n++]),Vl(3,7,11,15,e,t+2*a[n++]),Ml(3,7,11,15,e,t+2*a[n++]),Vl(0,5,10,15,e,t+2*a[n++]),Ml(0,5,10,15,e,t+2*a[n++]),Vl(1,6,11,12,e,t+2*a[n++]),Ml(1,6,11,12,e,t+2*a[n++]),Vl(2,7,8,13,e,t+2*a[n++]),Ml(2,7,8,13,e,t+2*a[n++]),Vl(3,4,9,14,e,t+2*a[n++]),Ml(3,4,9,14,e,t+2*a[n++]);this.v0l^=Rl[0]^Rl[16],this.v0h^=Rl[1]^Rl[17],this.v1l^=Rl[2]^Rl[18],this.v1h^=Rl[3]^Rl[19],this.v2l^=Rl[4]^Rl[20],this.v2h^=Rl[5]^Rl[21],this.v3l^=Rl[6]^Rl[22],this.v3h^=Rl[7]^Rl[23],this.v4l^=Rl[8]^Rl[24],this.v4h^=Rl[9]^Rl[25],this.v5l^=Rl[10]^Rl[26],this.v5h^=Rl[11]^Rl[27],this.v6l^=Rl[12]^Rl[28],this.v6h^=Rl[13]^Rl[29],this.v7l^=Rl[14]^Rl[30],this.v7h^=Rl[15]^Rl[31],Rl.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Fl=Sl((e=>new Jl(e)));function Xl(e){return cu(e).replace("0x","")}class Ll{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=dl.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Ll.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=dl.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return Ll.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new Ll(au(Bu,e)):new Ll(au(Bu,function(e){return au(Bu,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(Xc(Nu,e.value)){const t=au(Nu,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:cc(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?Au.tagToString(e.type.Some):null,elements:e.objects.map((e=>Ku(e)))}};case"MergeCoins":return{MergeCoins:{destination:Ku(e.destination),sources:e.sources.map((e=>Ku(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>Ku(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>cc(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:Ku(e.coin),amounts:e.amounts.map((e=>Ku(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>Ku(e))),address:Ku(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>cc(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:Ku(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),Fl(s,{dkLen:32})}(0,e);return hc(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return dl.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:Xl(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:Xl(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return dl.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return Ll.getDigestFromBytes(e)}snapshot(){return au(Bu,this)}}function Gl(e){return"string"==typeof e?cu(e):e.Object?e.Object.ImmOrOwnedObject?cu(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?cu(e.Object.Receiving.objectId):cu(e.Object.SharedObject.objectId):e.UnresolvedObject?cu(e.UnresolvedObject.objectId):void 0}var $l,zl,ql,Wl,Hl,Kl,Ql,Zl,ep,tp=e=>{throw TypeError(e)},rp=(e,t,r)=>t.has(e)||tp("Cannot "+r),sp=(e,t,r)=>(rp(e,t,"read from private field"),r?r.call(e):t.get(e)),ip=(e,t,r)=>t.has(e)?tp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),np=(e,t,r,s)=>(rp(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),ap=(e,t,r)=>(rp(e,t,"access private method"),r);const op=Symbol.for("@mysten/transaction"),dp={buildPlugins:[],serializationPlugins:[]},cp=Symbol.for("@mysten/transaction/registry");function up(){try{const e=globalThis;return e[cp]||(e[cp]=dp),e[cp]}catch(e){return dp}}$l=new WeakMap,zl=new WeakMap,ql=new WeakMap,Wl=new WeakMap,Hl=new WeakSet,Kl=function(e){return Pc(e)?this.pure(e):ap(this,Hl,Ql).call(this,e)},Ql=function(e){return au(_u,"function"==typeof e?e(this):e)},Zl=async function(e){if(!e.onlyTransactionKind&&!sp(this,Wl).sender)throw new Error("Missing transaction sender");await ap(this,Hl,ep).call(this,[...sp(this,zl),ll],e)},ep=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(sp(this,Wl),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let hp=class e{constructor(){ip(this,Hl),ip(this,$l),ip(this,zl),ip(this,ql,new Map),ip(this,Wl),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&Xc(_u,e))return e;const t=Gl(e),r=sp(this,Wl).inputs.find((e=>t===Gl(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:sp(this,Wl).inputs.indexOf(r),type:"object"}:sp(this,Wl).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:cu(e)}}:e)}));const e=up();np(this,Wl,new Ll),np(this,zl,[...e.buildPlugins]),np(this,$l,[...e.serializationPlugins])}static fromKind(t){const r=new e;return np(r,Wl,Ll.fromKindBytes("string"==typeof t?oc(t):t)),r}static from(t){const r=new e;var s;return(s=t)&&"object"==typeof s&&!0===s[op]?np(r,Wl,new Ll(t.getData())):"string"==typeof t&&t.startsWith("{")?np(r,Wl,Ll.restore(JSON.parse(t))):np(r,Wl,Ll.fromBytes("string"==typeof t?oc(t):t)),r}static registerGlobalSerializationPlugin(e){up().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){up().buildPlugins.push(e)}addSerializationPlugin(e){sp(this,$l).push(e)}addBuildPlugin(e){sp(this,zl).push(e)}addIntentResolver(e,t){if(sp(this,ql).has(e)&&sp(this,ql).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);sp(this,ql).set(e,t)}setSender(e){sp(this,Wl).sender=e}setSenderIfNotSet(e){sp(this,Wl).sender||(sp(this,Wl).sender=e)}setExpiration(e){sp(this,Wl).expiration=e?au(Cu,e):null}setGasPrice(e){sp(this,Wl).gasConfig.price=String(e)}setGasBudget(e){sp(this,Wl).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==sp(this,Wl).gasData.budget&&(sp(this,Wl).gasConfig.budget=String(e))}setGasOwner(e){sp(this,Wl).gasConfig.owner=e}setGasPayment(e){sp(this,Wl).gasConfig.payment=e.map((e=>au(gu,e)))}get blockData(){return Wu(sp(this,Wl).snapshot())}getData(){return sp(this,Wl).snapshot()}get[op](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:_l((e=>Pc(e)?sp(this,Wl).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):sp(this,Wl).addInput("pure",Xc(Iu,e)?au(Iu,e):e instanceof Uint8Array?dh(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(ch(...e))}receivingRef(...e){return this.object(hh(...e))}sharedObjectRef(...e){return this.object(uh(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(sp(this,Wl).commands.push(e)-1)}splitCoins(e,t){return this.add(Su.SplitCoins("string"==typeof e?this.object(e):ap(this,Hl,Ql).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):ap(this,Hl,Kl).call(this,e)))))}mergeCoins(e,t){return this.add(Su.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Su.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Su.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Su.MoveCall({...t,arguments:e?.map((e=>ap(this,Hl,Kl).call(this,e)))}))}transferObjects(e,t){return this.add(Su.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):ap(this,Hl,Kl).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Su.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(Wu(sp(this,Wl).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(au(oh,sp(this,Wl).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await ap(this,Hl,Zl).call(this,e),sp(this,Wl).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await ap(this,Hl,Zl).call(this,e),sp(this,Wl).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of sp(this,Wl).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...sp(this,$l)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!sp(this,ql).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(sp(this,ql).get(s))}await ap(this,Hl,ep).call(this,r,e)}};function lp(e){const t=[];return e?.objectChanges?.forEach((e=>{const r=e?.objectType,s=Zd(r);s&&t.push({type:s,type_raw:r,object:e?.objectId,version:e?.version,owner:e?.owner,change:e.type})})),t}class pp{resouceObject;async operate(e,t,r){}constructor(){}async call(e){}async call_with_witness(e,t){if(e.guard.length>0){const r=await ld.Create([...e.guard]);if(r){const s=await r.done(e.witness);if(s){const e=new hp,r=new pd(e,s);return await this.operate(new hp,r?.get_object(),t),r.destroy(),await this.sign_and_commit(e,t)}}else Ba(Ca.Fail,"guard verify")}}async check_permission_and_call(e,t,r,s,i,n){var a=[];if(t.length>0||s){const r=await ac.Instance().get_address(n);r||Ba(Ca.InvalidParam,"check_permission_and_call: account invalid");const o=await rc({permission_object:e,address:r});s&&!o.owner&&Ba(Ca.noPermission,"owner"),i&&!o.admin&&Ba(Ca.noPermission,"admin"),t.forEach((e=>{const t=Ko.HasPermission(o,e);t?.has||Ba(Ca.noPermission,e),t?.guard&&a.push(t.guard)}))}if(r.length>0&&(a=a.concat(r)),a.length>0){const e=await ld.Create([...a]),t=e?e.future_fills():[];if(e||Ba(Ca.Fail,"guard parse"),e&&0===t.length){const t=await e.done();if(t){const e=new hp,r=new pd(e,t);return await this.operate(new hp,r?.get_object(),n),r.destroy(),await this.sign_and_commit(e,n)}}return{guard:[...a],witness:e.future_fills()}}return await this.exec()}async exec(e){const t=new hp;return await this.operate(t,void 0,e),await this.sign_and_commit(t,e)}async new_with_mark(e,t,r,s,i=[dd.Launch]){const n=$a(r?.tags?[...r.tags,...i]:[...i]);if(this.resouceObject)_d.From(e,this.resouceObject).add(t,n,r?.name);else{const i=await ac.Instance().get_address(s);if(i){const s=await Rd({address:i});s?.mark_object?_d.From(e,s.mark_object).add(t,n,r?.name):(this.resouceObject=bd.From(e).create_resource2(),_d.From(e,this.resouceObject).add(t,n,r?.name))}else Ba(Ca.InvalidParam,"account - "+s)}}async sign_and_commit(e,t){const r=await ac.Instance().get_pair(t,!0);return r||Ba(Ca.Fail,"account invalid"),this.resouceObject&&(_d.From(e,this.resouceObject).launch(),this.resouceObject=void 0),await $o.Client().signAndExecuteTransaction({transaction:e,signer:r,options:{showObjectChanges:!0}})}}class mp extends pp{data;constructor(e){super(),this.data=e}async call(e){var t=!1,r=!1;const s=this.data?.object?.address;return s&&co(s)?(void 0===this.data?.builder&&void 0===this.data?.admin||(t=!0),void 0===this.data?.permission&&void 0===this.data?.biz_permission||(r=!0),void 0!==this.data?.description&&(r=!0),await this.check_permission_and_call(s,[],[],t,r,e)):await this.exec(e)}async operate(e,t,r){let s;const i=this.data?.object?.address;if(s=i&&co(i)?Ko.From(e,i):Ko.New(e,this.data?.description??""),s){if(void 0!==this.data?.description&&this.data.object&&s?.set_description(this.data.description),void 0!==this.data?.admin)switch(this.data.admin.op){case"add":s?.add_admin(this.data.admin.address);break;case"remove":s?.remove_admin(this.data.admin.address);break;case"set":s?.remove_admin([],!0),s?.add_admin(this.data.admin.address)}if(void 0!==this.data?.biz_permission)switch(this.data.biz_permission.op){case"add":this.data.biz_permission.data.forEach((e=>{s?.add_bizPermission(e.index,e.name)}));break;case"remove":this.data.biz_permission.permissions.forEach((e=>{s?.remove_bizPermission(e)}))}if(void 0!==this.data?.permission)switch(this.data.permission.op){case"add entity":s?.add_entity(this.data.permission.entities);break;case"add permission":s?.add_entity3(this.data.permission.permissions);break;case"remove entity":s?.remove_entity(this.data.permission.addresses);break;case"remove permission":s?.remove_index(this.data.permission.address,this.data.permission.index);break;case"transfer permission":s?.transfer_permission(this.data.permission.from_address,this.data.permission.to_address)}void 0!==this.data?.builder&&s?.change_owner(this.data.builder),i||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}var bp=a(763);const gp=e=>bp.encode(e),_p=e=>bp.decode(e);function fp(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const yp=8192;function vp(e){if(e.length<yp)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=yp){const s=e.slice(r,r+yp);t+=String.fromCharCode(...s)}return btoa(t)}function Tp(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function wp(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}class Ep{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class xp{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Op(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Op(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Op(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return gp(e);case"base64":return vp(e);case"hex":return wp(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Op(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Ip,Cp,Bp,Sp,Pp=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},jp=(e,t,r)=>(Pp(e,t,"read from private field"),r?r.call(e):t.get(e)),Ap=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},kp=(e,t,r,s)=>(Pp(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const Up=class{constructor(e){Ap(this,Ip,void 0),Ap(this,Cp,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),kp(this,Ip,e.write),kp(this,Cp,e.serialize??((e,t)=>{const r=new xp({size:this.serializedSize(e)??void 0,...t});return jp(this,Ip).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),jp(this,Ip).call(this,e,t)}serialize(e,t){return this.validate(e),new Yp(this,jp(this,Cp).call(this,e,t))}parse(e){const t=new Ep(e);return this.read(t)}transform({name:e,input:t,output:r}){return new Up({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>jp(this,Ip).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>jp(this,Cp).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let Np=Up;Ip=new WeakMap,Cp=new WeakMap;const Dp=Symbol.for("@mysten/serialized-bcs");class Yp{constructor(e,t){Ap(this,Bp,void 0),Ap(this,Sp,void 0),kp(this,Bp,e),kp(this,Sp,t)}get[Dp](){return!0}toBytes(){return jp(this,Sp)}toHex(){return wp(jp(this,Sp))}toBase64(){return vp(jp(this,Sp))}toBase58(){return gp(jp(this,Sp))}parse(){return jp(this,Bp).parse(jp(this,Sp))}}Bp=new WeakMap,Sp=new WeakMap;const Rp=32,Vp=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof Vp)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(Vp.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Mp.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Mp.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Mp.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Mp.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Mp.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Mp.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Mp.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Mp.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Mp.HEX,(function(e,t){return e.writeVec(Array.from(Tp(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return wp(new Uint8Array(t))})),t.registerType(Mp.BASE58,(function(e,t){return e.writeVec(Array.from(_p(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return gp(new Uint8Array(t))})),t.registerType(Mp.BASE64,(function(e,t){return e.writeVec(Array.from(fp(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return vp(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new Vp(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return _p(e);case"base64":return fp(e);case"hex":return Tp(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new Vp(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new xp(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new Ep(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new Np({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new Np({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return fp(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return vp(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return Tp(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return wp(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],l,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,l,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let l=n.indexOf(h),p=-1===l?h:a[l];{let{name:r,params:s}=this.parseTypeName(p);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Mp=Vp;function Jp(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Rp,addressEncoding:"hex"}}Mp.U8="u8",Mp.U16="u16",Mp.U32="u32",Mp.U64="u64",Mp.U128="u128",Mp.U256="u256",Mp.BOOL="bool",Mp.VECTOR="vector",Mp.ADDRESS="address",Mp.STRING="string",Mp.HEX="hex-string",Mp.BASE58="base58-string",Mp.BASE64="base64-string";class Fp extends pp{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&_o(this.data.type_parameter)||Ba(Ca.IsValidArgType,"arbitration.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.fee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Wo.arbitration),void 0!==this.data?.description&&n&&r.push(Wo.arbitration_description),void 0!==this.data?.bPaused&&r.push(Wo.arbitration_pause),null==this.data?.endpoint&&r.push(Wo.arbitration_endpoint),void 0!==this.data?.fee&&n&&r.push(Wo.arbitration_fee),void 0!==a&&n&&r.push(Wo.arbitration_treasury),void 0!==this.data?.usage_guard&&r.push(Wo.arbitration_guard),void 0!==this.data?.voting_guard&&r.push(Wo.arbitration_voting_guard),void 0!==this.data?.arb_arbitration&&r.push(Wo.arbitration_arbitration),void 0!==this.data?.arb_new?.guard)if(co(this.data.arb_new.guard))t.push(this.data.arb_new.guard);else if(n){if(!s){const e=await Yd({objects:[n],showContent:!0});e?.objects&&"Arbitration"===e.objects[0].type&&(s=e.objects[0])}s?.usage_guard&&t.push(s.usage_guard)}else this.data?.usage_guard&&co(this.data?.usage_guard)&&t.push(this.data.usage_guard);return void 0!==this.data?.arb_vote&&r.push(Wo.treasury_receive),"string"==typeof this.data?.arb_vote?.voting_guard&&co(this.data?.arb_vote?.voting_guard)&&t.push(this.data?.arb_vote?.voting_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.fee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a?s=Td.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Ko.New(e,t)}if(!d||!co(d)){const r=this.data?.fee_treasury?.description??"";n=fd.New(e,this.data?.type_parameter,i?i.get_object():a,r,i?void 0:t)}s=Td.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",BigInt(this.data?.fee??0),n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;var c;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.fee&&o&&s?.set_fee(BigInt(this.data.fee),a),void 0!==d&&o&&s?.set_withdrawTreasury(d,a),void 0!==this.data?.arb_new&&(c=s?.arb(this.data.arb_new.data,a)),void 0!==this.data?.arb_arbitration){const e=this.data.arb_arbitration.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_arbitration"),s?.arbitration({arb:e,feedback:this.data.arb_arbitration.feedback,indemnity:this.data.arb_arbitration.indemnity},a)}if(void 0!==this.data?.arb_vote){const e=this.data.arb_vote.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_vote"),s?.vote({arb:e,voting_guard:this.data.arb_vote.voting_guard,agrees:this.data.arb_vote.agrees},a)}if(void 0!==this.data?.arb_withdraw_fee){const e=this.data.arb_withdraw_fee.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_withdraw_fee"),s?.withdraw_fee(e,this.data.arb_withdraw_fee.data,a)}if(c&&await this.new_with_mark(e,s?.arb_launch(c),this.data?.arb_new?.namedNew,r),void 0!==this.data?.voting_guard)switch(this.data.voting_guard.op){case"add":s?.add_voting_guard(this.data.voting_guard.data,a);break;case"remove":s?.remove_voting_guard(this.data.voting_guard.guards,!1,a);break;case"set":s?.remove_voting_guard([],!0,a),s?.add_voting_guard(this.data.voting_guard.data,a);break;case"removeall":s?.remove_voting_guard([],!0,a)}void 0!==this.data.usage_guard&&s?.set_guard(this.data.usage_guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),n&&await this.new_with_mark(e,n.launch(),this.data?.fee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Xp extends pp{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&_o(this.data.type_parameter)||Ba(Ca.IsValidArgType,"treasury.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address;if(i&&co(i)){if(this.data?.object||r.push(Wo.treasury),void 0!==this.data?.description&&n&&r.push(Wo.treasury_descritption),void 0!==this.data?.withdraw_mode&&r.push(Wo.treasury_withdraw_mode),null==this.data?.withdraw_guard&&r.push(Wo.treasury_withdraw_guard),void 0!==this.data?.deposit_guard&&r.push(Wo.treasury_deposit_guard),void 0!==this.data?.deposit_guard&&r.push(Wo.treasury_deposit_guard),void 0!==this.data?.deposit?.guard)if(co(this.data.deposit.guard))t.push(this.data.deposit.guard);else if(this.data.object){if(!s){const e=await Yd({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}s?.deposit_guard&&t.push(s?.deposit_guard)}else this.data?.deposit_guard&&co(this.data?.deposit_guard)&&t.push(this.data.deposit_guard);if(void 0!==this.data?.receive&&r.push(Wo.treasury_receive),void 0!==this.data?.withdraw?.withdraw_guard){if("string"==typeof this.data.withdraw.withdraw_guard&&co(this.data.withdraw.withdraw_guard))t.push(this.data.withdraw.withdraw_guard);else if(this.data.object){if(!s){const e=await Yd({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}"string"==typeof s?.withdraw_guard&&t.push(s?.withdraw_guard)}}else r.push(Wo.treasury_withdraw);return await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&n&&co(n)?s=fd.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Ko.New(e,t)}s=fd.New(e,this.data.type_parameter,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data.deposit){const t=await ac.Instance().get_coin_object(e,this.data.deposit.data.balance,r,this.data.type_parameter);if(t){const e=this.data.deposit.data?.index??0;s?.deposit({coin:t,index:BigInt(e),remark:this.data.deposit.data.remark??"",for_guard:this.data.deposit.data?.for_guard,for_object:this.data.deposit.data?.for_object})}}if(void 0!==this.data?.receive&&s?.receive(this.data.receive.payment,this.data.receive.received_object,n),void 0!==this.data?.withdraw&&s?.withdraw(this.data.withdraw,n),void 0!==this.data?.deposit_guard&&s?.set_deposit_guard(this.data.deposit_guard,n),void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"remove":s?.remove_withdraw_guard(this.data.withdraw_guard.guards,!1,n);break;case"set":s?.remove_withdraw_guard([],!0,n),this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"removeall":s?.remove_withdraw_guard([],!0,n)}void 0!==this.data?.withdraw_mode&&s?.set_withdraw_mode(this.data.withdraw_mode,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Lp extends pp{data;constructor(e){super(),this.data=e}async call(e){if(co(this.data.new_permission)||Ba(Ca.InvalidParam,"CallObjectPermission_Data.new_permission"+this.data.new_permission),this.data?.objects.length>0)return await this.exec(e)}async operate(e,t){const r=await Yd({objects:this.data.objects,showContent:!0});r.objects?.forEach((t=>{switch(t.type){case"Demand":const r=t;qo.From(e,qo.parseObjectType(r.type_raw),r.permission,r.object).change_permission(this.data.new_permission);break;case"Machine":const s=t;Qo.From(e,s.permission,s.object).change_permission(this.data.new_permission);break;case"Service":const i=t;md.From(e,md.parseObjectType(i.type_raw),i.permission,i.object).change_permission(this.data.new_permission);break;case"Treasury":const n=t;fd.From(e,fd.parseObjectType(n.type_raw),n.permission,n.object).change_permission(this.data.new_permission);break;case"Arbitration":const a=t;Td.From(e,Td.parseObjectType(a.type_raw),a.permission,a.object).change_permission(this.data.new_permission);break;case"Repository":const o=t;hd.From(e,o.permission,o.object).change_permission(this.data.new_permission)}}))}}class Gp extends pp{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&_o(this.data.type_parameter)||Ba(Ca.IsValidArgType,"demand.type_parameter");const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Wo.demand),void 0!==this.data?.description&&i&&r.push(Wo.demand_description),void 0!==this.data?.time_expire&&i&&r.push(Wo.demand_expand_time),void 0!==this.data?.guard&&r.push(Wo.demand_guard),"reward"===this.data?.bounty?.op&&r.push(Wo.demand_yes),"refund"===this.data?.bounty?.op&&r.push(Wo.demand_refund),void 0!==this.data?.present?.guard)if(co(this.data.present.guard))t.push(this.data.present.guard);else if(i){const e=await Yd({objects:[i],showContent:!0});if(e?.objects&&"Demand"===e?.objects[0]?.type){const r=e?.objects[0];r?.guard&&t.push(r?.guard.object)}}else this.data?.guard?.address&&co(this.data?.guard.address)&&t.push(this.data.guard.address);return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&this.data.permission&&co(n)?s=qo.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Ko.New(e,t)}s=void 0!==this.data.time_expire?qo.New(e,this.data.type_parameter,"duration"===this.data.time_expire?.op,"duration"===this.data.time_expire?.op?this.data.time_expire.minutes:this.data.time_expire?.time,i?i.get_object():n,this.data?.description??"",i?void 0:t):qo.New(e,this.data.type_parameter,!0,43200,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.time_expire&&a&&s?.expand_time("duration"===this.data.time_expire.op,"duration"===this.data.time_expire.op?this.data.time_expire.minutes:this.data.time_expire.time,n),void 0!==this.data?.bounty)if("add"===this.data.bounty.op){if(co(this.data.bounty.object?.address))s.deposit(this.data.bounty.object?.address);else if(void 0!==this.data.bounty.object?.balance){uo(this.data.type_parameter)||Ba(Ca.IsValidCoinType,"demand bounty");const t=await ac.Instance().get_coin_object(e,this.data.bounty.object?.balance,r,this.data.type_parameter);t&&s.deposit(t)}}else"reward"===this.data.bounty.op?s?.yes(this.data.bounty.service,n):"refund"===this.data.bounty.op&&s?.refund(n);void 0!==this.data?.present&&s?.present(this.data.present.service,this.data.present.service_pay_type,this.data.present.recommend_words,n),void 0!==this.data?.guard&&s?.set_guard(this.data.guard.address,this.data.guard?.service_id_in_guard??void 0,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class $p extends pp{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Wo.machine),void 0!==this.data?.description&&i&&r.push(Wo.machine_description),void 0!==this.data?.endpoint&&i&&r.push(Wo.machine_endpoint),void 0!==this.data?.consensus_repository&&r.push(Wo.machine_repository),void 0!==this.data?.nodes&&r.push(Wo.machine_node),this.data?.bPublished&&r.push(Wo.machine_publish),void 0!==this.data?.progress_new&&r.push(Wo.progress),void 0!==this.data?.progress_context_repository&&r.push(Wo.progress_context_repository),void 0!==this.data?.progress_namedOperator&&r.push(Wo.progress_namedOperator),void 0!==this.data?.progress_parent&&r.push(Wo.progress_parent),void 0!==this.data?.progress_task&&r.push(Wo.progress_bind_task),void 0!==this.data?.progress_hold&&this.data.progress_hold.adminUnhold&&r.push(Wo.progress_unhold),void 0!==this.data?.bPaused&&r.push(Wo.machine_pause),void 0!==this.data?.progress_next?.guard)if(co(this.data?.progress_next?.guard))t.push(this.data?.progress_next?.guard);else if(this.data?.object&&co(i)){const e=await Zo.QueryForwardGuard(this.data?.progress_next.progress,i,await ac.Instance().get_address()??"0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f",this.data.progress_next.data.next_node_name,this.data.progress_next.data.forward);e&&t.push(e)}return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&n&&co(n)?s=Qo.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Ko.New(e,t)}s=Qo.New(e,i?i.get_object():n,this.data?.description??"",this.data?.endpoint??"",i?void 0:t)}if(s){const d=i?i.get_object():n,c=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,c),void 0!==this.data?.endpoint&&a&&s?.set_endpoint(this.data.endpoint,c),void 0!==this.data?.consensus_repository)switch(this.data.consensus_repository.op){case"add":this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)));break;case"remove":s?.remove_repository(this.data.consensus_repository.repositories,!1,c);break;case"removeall":s?.remove_repository([],!0,c);break;case"set":s?.remove_repository([],!0,c),this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)))}if(void 0!==this.data?.nodes)switch(this.data?.nodes?.op){case"add":s?.add_node(this.data.nodes.data,c);break;case"remove":s?.remove_node(this.data.nodes.names,this.data.nodes?.bTransferMyself,c);break;case"rename node":this.data.nodes.data.forEach((e=>s?.rename_node(e.old,e.new,c)));break;case"add from myself":s?.add_node2(this.data.nodes.addresses,c);break;case"add forward":this.data.nodes.data.forEach((e=>s?.add_forward(e.prior_node_name,e.node_name,e.forward,e.threshold,e.old_need_remove,c)));break;case"remove forward":this.data.nodes.data.forEach((e=>s?.remove_forward(e.prior_node_name,e.node_name,e.forward_name,c)))}var o;if(this.data?.bPublished&&s?.publish(t),void 0!==this.data?.progress_new&&(o=Zo?.New(e,s?.get_object(),d,this.data?.progress_new.task_address,c)),void 0!==this.data?.progress_context_repository){const t=this.data?.progress_context_repository.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_context_repository"),Zo.From(e,s?.get_object(),d,t).set_context_repository(this.data?.progress_context_repository.repository,c)}if(void 0!==this.data?.progress_namedOperator){const t=this.data?.progress_namedOperator.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_namedOperator");let r=Zo.From(e,s?.get_object(),d,t);this.data.progress_namedOperator.data.forEach((e=>r.set_namedOperator(e.name,e.operator,c)))}if(void 0!==this.data?.progress_parent){const t=this.data?.progress_parent.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_parent"),this.data.progress_parent.parent?Zo.From(e,s?.get_object(),d,t).parent(this.data.progress_parent.parent):Zo.From(e,s?.get_object(),d,t).parent_none()}if(void 0!==this.data?.progress_task){const t=this.data?.progress_task.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_task"),Zo.From(e,s?.get_object(),d,t).bind_task(this.data.progress_task.task,c)}if(void 0!==this.data?.progress_hold){const t=this.data?.progress_hold.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_hold"),this.data?.progress_hold.adminUnhold?Zo.From(e,s?.get_object(),d,t).unhold(this.data.progress_hold.data,c):Zo.From(e,s?.get_object(),d,t).hold(this.data.progress_hold.data,this.data.progress_hold.bHold)}const u=o?.launch();u&&await this.new_with_mark(e,u,this.data?.progress_new?.namedNew,r),void 0!==this.data?.progress_next&&Zo.From(e,s?.get_object(),d,this.data?.progress_next.progress).next(this.data.progress_next.data,this.data.progress_next.deliverable,c),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,c),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s?.clone(!0,c),this.data?.clone_new?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class zp extends pp{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=this.data?.permission?.address,s=this.data?.object?.address;return r&&co(r)?(this.data?.object||t.push(Wo.repository),void 0!==this.data?.description&&s&&t.push(Wo.repository_description),void 0!==this.data?.mode&&s&&t.push(Wo.repository_mode),void 0!==this.data?.reference&&t.push(Wo.repository_reference),void 0!==this.data?.policy&&t.push(Wo.repository_policies),await this.check_permission_and_call(r,t,[],!1,void 0,e)):await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.permission&&co(n)?s=hd.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Ko.New(e,t)}s=hd.New(e,i?i.get_object():n,this.data?.description??"",this.data?.mode,i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.reference)switch(this.data.reference.op){case"set":s?.remove_reference([],!0,n),s?.add_reference(this.data.reference.addresses,n);break;case"add":s?.add_reference(this.data.reference.addresses,n);break;case"remove":s?.remove_reference(this.data.reference.addresses,!1,n);break;case"removeall":s?.remove_reference([],!0,n)}if(void 0!==this.data?.mode&&a&&s?.set_policy_mode(this.data.mode,n),void 0!==this.data?.policy)switch(this.data.policy.op){case"set":s?.remove_policies([],!0,n),s?.add_policies(this.data.policy.data,n);break;case"add":s?.add_policies(this.data.policy.data,n);break;case"remove":s?.remove_policies(this.data.policy.data,!1,n);break;case"removeall":s?.remove_policies([],!0,n);break;case"rename":this.data.policy.data.forEach((e=>{s?.rename_policy(e.old,e.new,n)}))}if(void 0!==this.data?.data)switch(this.data.data.op){case"add":void 0!==this.data.data?.data?.key?s?.add_data(this.data.data.data):void 0!==this.data.data?.data?.address&&s?.add_data2(this.data.data.data);break;case"remove":s?.remove(this.data.data.data.address,this.data.data.data.key)}i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class qp extends pp{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&_o(this.data.type_parameter)||Ba(Ca.IsValidArgType,"service.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.payee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Wo.service),void 0!==this.data?.description&&n&&r.push(Wo.service_description),void 0!==this.data?.bPaused&&r.push(Wo.service_pause),this.data?.bPublished&&r.push(Wo.service_publish),void 0!==this.data?.endpoint&&r.push(Wo.service_endpoint),void 0!==this.data?.repository&&r.push(Wo.service_repository),void 0!==this.data?.clone_new&&r.push(Wo.service_clone),void 0!==this.data?.gen_discount&&r.push(Wo.service_discount_transfer),void 0!==this.data?.arbitration&&r.push(Wo.service_arbitration),void 0!==this.data?.buy_guard&&r.push(Wo.service_buyer_guard),void 0!==this.data?.endpoint&&r.push(Wo.service_endpoint),void 0!==this.data?.extern_withdraw_treasury&&r.push(Wo.service_treasury),void 0!==this.data?.machine&&r.push(Wo.service_machine),void 0!==a&&n&&r.push(Wo.service_payee),void 0!==this.data?.withdraw_guard&&r.push(Wo.service_withdraw_guards),void 0!==this.data?.refund_guard&&r.push(Wo.service_refund_guards),void 0!==this.data?.customer_required_info&&r.push(Wo.service_customer_required),void 0!==this.data?.sales&&r.push(Wo.service_sales),void 0!==this.data?.order_new?.guard)if(co(this.data.order_new.guard))t.push(this.data.order_new.guard);else if(this.data.object){if(!s){const e=await Yd({objects:[n],showContent:!0});e?.objects&&"Service"===e.objects[0].type&&(s=e.objects[0])}s?.buy_guard&&t.push(s?.buy_guard)}else this.data?.buy_guard&&co(this.data.buy_guard)&&t.push(this.data?.buy_guard);return co(this.data?.order_refund?.guard)&&t.push(this.data?.order_refund?.guard),void 0!==this.data.order_withdrawl&&r.push(Wo.service_withdraw),"string"==typeof this.data?.order_withdrawl?.data?.withdraw_guard&&co(this.data?.order_withdrawl?.data?.withdraw_guard)&&t.push(this.data?.order_withdrawl?.data?.withdraw_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.payee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a&&co(a)?s=md.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Ko.New(e,t)}if(!d||!co(d)){const r=this.data?.payee_treasury?.description??"";n=fd.New(e,this.data?.type_parameter,i??a,r,i?void 0:t)}s=md.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.payee_treasury&&o&&s?.set_payee(d,a),void 0!==this.data?.gen_discount&&s?.discount_transfer(this.data.gen_discount,a),void 0!==this.data?.repository)switch(this.data.repository.op){case"add":this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"remove":s?.remove_repository(this.data.repository.repositories,!1,a);break;case"set":s?.remove_repository([],!0,a),this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"removeall":s?.remove_repository([],!0,a)}if(void 0!==this.data?.extern_withdraw_treasury)switch(this.data.extern_withdraw_treasury.op){case"add":this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"set":s?.remove_treasury([],!0,a),this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"remove":s?.remove_treasury(this.data.extern_withdraw_treasury.addresses,!1,a);break;case"removeall":s?.remove_treasury([],!1,a)}if(void 0!==this.data?.machine&&s?.set_machine(this.data.machine,a),void 0!==this.data?.arbitration)switch(this.data.arbitration.op){case"add":this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.type_parameter,a)));break;case"set":s?.remove_arbitration([],!0,a),this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.type_parameter,a)));break;case"remove":s?.remove_arbitration(this.data.arbitration.addresses,!1,a);break;case"removeall":s?.remove_arbitration([],!1,a)}if(void 0!==this.data?.customer_required_info&&(this.data.customer_required_info.required_info&&this.data.customer_required_info.pubkey?s?.set_customer_required(this.data.customer_required_info.pubkey,this.data.customer_required_info.required_info,a):this.data.customer_required_info.pubkey&&s?.change_required_pubkey(this.data.customer_required_info.pubkey,a)),void 0!==this.data?.sales)switch(this.data.sales.op){case"add":s?.add_sales(this.data.sales.sales,!1,a);break;case"remove":s?.remove_sales(this.data.sales.sales_name,a)}if(void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"set":s?.remove_withdraw_guards([],!0,a),s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"remove":s?.remove_withdraw_guards(this.data.withdraw_guard.addresses,!1,a);break;case"removeall":s?.remove_withdraw_guards([],!0,a)}if(void 0!==this.data?.refund_guard)switch(this.data.refund_guard.op){case"add":s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"set":s?.remove_refund_guards([],!0,a),s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"remove":s?.remove_refund_guards(this.data.refund_guard.addresses,!1,a);break;case"removeall":s?.remove_refund_guards([],!0,a)}var c;if(this.data?.bPublished&&s?.publish(a),void 0!==this.data?.order_new){let t=BigInt(0);if(this.data.order_new.buy_items.forEach((e=>{t+=BigInt(e.max_price)*BigInt(e.count)})),t>BigInt(0)){const i=await ac.Instance().get_coin_object(e,t,r,this.data.type_parameter);i&&(c=s.order(this.data.order_new.buy_items,i,this.data.order_new.discount,this.data.order_new.machine,this.data.order_new.customer_info_crypto,a))}}if(void 0!==this.data?.order_agent){const e=this.data.order_agent.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_agent"),s?.set_order_agent(e,this.data.order_agent.agents,this.data.order_agent.progress)}if(void 0!==this.data?.order_required_info){const e=this.data.order_required_info.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_required_info"),s?.update_order_required_info(e,this.data.order_required_info.info)}if(void 0!==this.data?.order_refund){const e=this.data.order_refund.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_refund"),this.data?.order_refund?.arb&&this.data?.order_refund?.arb_token_type?s?.refund_withArb(e,this.data?.order_refund?.arb,this.data?.order_refund?.arb_token_type):s?.refund(e,this.data?.order_refund?.guard,a)}if(void 0!==this.data?.order_withdrawl&&a){const e=this.data.order_withdrawl.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_withdrawl"),s?.withdraw(e,this.data.order_withdrawl.data,a)}if(void 0!==this.data?.order_payer&&s){const e=this.data.order_payer.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_payer"),s?.change_order_payer(e,this.data.order_payer.payer_new,this.data.order_payer.progress)}if(c&&this?.data?.order_new){const t=s.order_launch(c);await this.new_with_mark(e,t.order,this.data?.order_new?.namedNewOrder,r,[dd.Launch,dd.Order]),t?.progress&&await this.new_with_mark(e,t.progress,this.data?.order_new?.namedNewProgress,r,[dd.Launch])}void 0!==this.data?.buy_guard&&s?.set_buy_guard(this.data.buy_guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s.clone(this.data.clone_new?.token_type_new,!0,a),this.data?.clone_new?.namedNew,r),n&&await this.new_with_mark(e,n.launch(),this.data?.payee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Wp extends pp{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){this.data?.root||Ba(Ca.InvalidParam,"guard root node invalid"),io(this.data?.description)||Ba(Ca.IsValidDesription,"build_guard - "+this.data.description),this.data?.table?.forEach((e=>{(!lo(e.identifier)||e.identifier<1)&&Ba(Ca.InvalidParam,"table.identifer invalid"),e.bWitness||void 0!==e.value||Ba(Ca.InvalidParam,"table.value")})),this.data?.table&&Po(this.data?.table?.map((e=>e.identifier)))&&Ba(Ca.InvalidParam,"table.identifer duplicates");var s=[];Hp(this.data.root,Uo.TYPE_BOOL,this.data?.table??[],s);const i=Xa(Uint8Array,...s),n=e.moveCall({target:$o.Instance().guardFn("new"),arguments:[e.pure.string(this.data.description),e.pure.vector("u8",[].slice.call(i.reverse()))]});this.data?.table?.forEach((t=>{if(t.bWitness){const r=new Uint8Array(1);r.set([t.value_type],0),e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}else{const r=Oo(Uint8Array.from(Wa.getInstance().ser(t.value_type,t.value)),t.value_type);e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}}));const a=e.moveCall({target:$o.Instance().guardFn("create"),arguments:[e.object(n)]});await this.new_with_mark(e,a,this.data?.namedNew,r)}}const Hp=(e,t,r,s)=>{const i=e;if(void 0!==i?.identifier){const e=r.find((e=>e.identifier===i.identifier));e?(Kp(e.value_type,t,i),s.push(Wa.getInstance().ser(Uo.TYPE_U8,Fo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.identifier))):Ba(Ca.InvalidParam,"node identifier - "+JSON.stringify(i))}else if(void 0!==i?.query){var n;if("string"==typeof i.query?n=ed.find((e=>e[1]===i.query)):"number"==typeof i.query&&(n=ed.find((e=>e[2]===i.query))),n||Ba(Ca.InvalidParam,"query invalid - "+i?.query),Kp(n[4],t,i),n[3].length===i.parameters.length)for(let e=i.parameters.length-1;e>=0;--e)Hp(i.parameters[e],n[3][e],r,s);else Ba(Ca.InvalidParam,"node query parameters length not match - "+JSON.stringify(i));if(s.push(Wa.getInstance().ser(Uo.TYPE_U8,Ao.TYPE_QUERY)),"string"==typeof i.object)co(i.object)||Ba(Ca.InvalidParam,"node object from address string - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,Uo.TYPE_ADDRESS)),s.push(Wa.getInstance().ser(Uo.TYPE_ADDRESS,i.object));else{const e=r.find((e=>e.identifier===i.object));e?(Kp(e.value_type,Uo.TYPE_ADDRESS,i),s.push(Wa.getInstance().ser(Uo.TYPE_U8,Fo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.object))):Ba(Ca.InvalidParam,"node object from identifier - "+JSON.stringify(i))}s.push(Wa.getInstance().ser("u16",n[2]))}else if(void 0!==i?.logic)switch(Kp(Uo.TYPE_BOOL,t,i),i?.logic){case Ao.TYPE_LOGIC_AND:case Ao.TYPE_LOGIC_OR:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Hp(e,Uo.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.parameters.length));break;case Ao.TYPE_LOGIC_NOT:1!==i.parameters.length&&Ba(Ca.InvalidParam,"node logic parameters length must be 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Hp(e,Uo.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.logic));break;case Ao.TYPE_LOGIC_AS_U256_GREATER:case Ao.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_LESSER:case Ao.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case Ao.TYPE_LOGIC_AS_U256_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Hp(e,"number",r,s))),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.parameters.length));break;case Ao.TYPE_LOGIC_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Hp(e,"variable",r,s))),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.parameters.length));break;case Ao.TYPE_LOGIC_HAS_SUBSTRING:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Hp(e,Uo.TYPE_STRING,r,s))),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.parameters.length))}else if(void 0!==i?.calc)Kp(Uo.TYPE_U256,t,i),i.parameters.length<2&&Ba(Ca.InvalidParam,"node calc parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Hp(e,"number",r,s))),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.calc)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.parameters.length));else if(void 0!==i?.value_type)Kp(i?.value_type,t,i),void 0===i?.value&&Ba(Ca.InvalidParam,"node value undefined - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.value_type)),i.value_type==Uo.TYPE_STRING||i.value_type===Uo.TYPE_VEC_U8?"string"==typeof i.value?s.push(Wa.getInstance().ser(Uo.TYPE_STRING,i.value)):s.push(Wa.getInstance().ser(Uo.TYPE_VEC_U8,i.value)):s.push(Wa.getInstance().ser(i?.value_type,i.value));else if(void 0!==i?.context)switch(s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.context)),i.context){case Fo.TYPE_CLOCK:Kp(Uo.TYPE_U64,t,i);break;case Fo.TYPE_GUARD:case Fo.TYPE_SIGNER:Kp(Uo.TYPE_ADDRESS,t,i)}else if(void 0!==i?.identifier){rd(i.identifier)||Ba(Ca.IsValidGuardIdentifier,"node - "+JSON.stringify(i));const e=r.find((e=>e.identifier===i.identifier));e||Ba(Ca.InvalidParam,"identifier not found. node - "+JSON.stringify(i)),Kp(e.value_type,t,i),s.push(Wa.getInstance().ser(Uo.TYPE_U8,Fo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(Uo.TYPE_U8,i.identifier))}else Ba(Ca.InvalidParam,"node - "+JSON.stringify(i))},Kp=(e,t,r)=>{if("variable"===t)t=e;else if("number"===t){if(e===Uo.TYPE_U128||e===Uo.TYPE_U256||e===Uo.TYPE_U8||e===Uo.TYPE_U64||e===Fo.TYPE_CLOCK)return}else if(t===Uo.TYPE_ADDRESS&&(e===Fo.TYPE_SIGNER||e===Fo.TYPE_GUARD))return;if(e!==t){var s="";r&&(s=" - "+JSON.stringify(r)),Ba(Ca.InvalidParam,"checkType: "+e+" require type: "+t+s)}};class Qp extends pp{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){let s,i=bd.From(e);const n=this.data?.object?.address;if(s=n&&co(n)?_d.From(e,n):_d.From(e,i.create_resource2()),"destroy"!==this.data?.mark?.op){if(void 0!==this.data?.information&&i.update(this.data.information),s&&s?.get_object()){if(void 0!==this.data?.mark)switch(this.data.mark.op){case"add":this.data.mark.data.forEach((e=>{s?.add(e.address,e.tags,e.name)}));break;case"remove":this.data.mark.data.forEach((e=>{s?.remove(e.address,e.tags)}));break;case"removeall":this.data.mark.address.forEach((e=>{s?.removeall(e)}))}"transfer"===this.data?.mark?.op&&s&&co(this.data.mark.address)&&i.transfer_resource(s,this.data.mark.address),"replace"===this.data?.mark?.op&&co(this.data.mark.address)&&i.use_resource(_d.From(e,this.data.mark.address)),!n&&s&&await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}else i.destroy_resource(s)}}const Zp=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await em(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},em=async e=>{var t=function(e){switch(e.type){case"Demand":return new Gp(e.data);case"Service":return new qp(e.data);case"Machine":return new $p(e.data);case"Treasury":return new Xp(e.data);case"Arbitration":return new Fp(e.data);case"Guard":return new Wp(e.data);case"Repository":return new zp(e.data);case"Personal":return new Qp(e.data);case"Permission":return new mp(e.data);case"ObjectPermission":return new Lp(e.data)}}(e);if(t)return e.witness?t.call_with_witness(e.witness,e.account):t.call(e.account)}})(),o})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,(()=>(()=>{var e,t,r,s,i={22:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=t[e.charCodeAt(r)];if(255===u)return;for(var h=0,l=n-1;(0!==u||h<i)&&-1!==l;l--,h++)u+=a*c[l]>>>0,c[l]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");i=h,r++}for(var p=n-i;p!==n&&0===c[p];)p++;for(var m=new Uint8Array(s+(n-p)),b=s;p!==n;)m[b++]=c[p++];return m}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],l=0,p=d-1;(0!==h||l<s)&&-1!==p;p--,l++)h+=256*u[p]>>>0,u[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=l,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var b=o.repeat(r);m<d;++m)b+=e.charAt(u[m]);return b},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},211:()=>{},333:(e,t)=>{"use strict";t.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let e=0;e<32;e++){const t=r.charAt(e);s[t]=e}function i(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function n(e){let t=1;for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);if(s<33||s>126)return"Invalid prefix ("+e+")";t=i(t)^s>>5}t=i(t);for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);t=i(t)^31&s}return t}function a(e,t,r,s){let i=0,n=0;const a=(1<<r)-1,o=[];for(let s=0;s<e.length;++s)for(i=i<<t|e[s],n+=t;n>=r;)n-=r,o.push(i>>n&a);if(s)n>0&&o.push(i<<r-n&a);else{if(n>=t)return"Excess padding";if(i<<r-n&a)return"Non-zero padding"}return o}function o(e){return a(e,8,5,!0)}function d(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t}function c(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function u(e){let t;function a(e,r){if(r=r||90,e.length<8)return e+" too short";if(e.length>r)return"Exceeds length limit";const a=e.toLowerCase(),o=e.toUpperCase();if(e!==a&&e!==o)return"Mixed-case string "+e;const d=(e=a).lastIndexOf("1");if(-1===d)return"No separator character for "+e;if(0===d)return"Missing prefix for "+e;const c=e.slice(0,d),u=e.slice(d+1);if(u.length<6)return"Data too short";let h=n(c);if("string"==typeof h)return h;const l=[];for(let e=0;e<u.length;++e){const t=u.charAt(e),r=s[t];if(void 0===r)return"Unknown character "+t;h=i(h)^r,e+6>=u.length||l.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:c,words:l}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=a(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=a(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,s,a){if(a=a||90,e.length+7+s.length>a)throw new TypeError("Exceeds length limit");let o=n(e=e.toLowerCase());if("string"==typeof o)throw new Error(o);let d=e+"1";for(let e=0;e<s.length;++e){const t=s[e];if(t>>5)throw new Error("Non 5-bit word");o=i(o)^t,d+=r.charAt(t)}for(let e=0;e<6;++e)o=i(o);o^=t;for(let e=0;e<6;++e)d+=r.charAt(o>>5*(5-e)&31);return d},toWords:o,fromWordsUnsafe:d,fromWords:c}}t.I=u("bech32"),u("bech32m")},364:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=e.charCodeAt(r);if(u>255)return;var h=t[u];if(255===h)return;for(var l=0,p=n-1;(0!==h||l<i)&&-1!==p;p--,l++)h+=a*c[p]>>>0,c[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,r++}for(var m=n-i;m!==n&&0===c[m];)m++;for(var b=new Uint8Array(s+(n-m)),_=s;m!==n;)b[_++]=c[m++];return b}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],l=0,p=d-1;(0!==h||l<s)&&-1!==p;p--,l++)h+=256*u[p]>>>0,u[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=l,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var b=o.repeat(r);m<d;++m)b+=e.charAt(u[m]);return b},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},601:(e,t,r)=>{!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},s=function(){throw new Error("no PRNG")},i=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var a=t(),o=t([1]),d=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,t,r,s){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=s>>24&255,e[t+5]=s>>16&255,e[t+6]=s>>8&255,e[t+7]=255&s}function b(e,t,r,s,i){var n,a=0;for(n=0;n<i;n++)a|=e[t+n]^r[s+n];return(1&a-1>>>8)-1}function _(e,t,r,s){return b(e,t,r,s,16)}function g(e,t,r,s){return b(e,t,r,s,32)}function f(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,b=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,_=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,f=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,y=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=n,E=a,w=o,x=d,O=c,I=u,C=h,B=l,S=p,P=m,j=b,A=_,k=g,U=f,N=y,D=v,Y=0;Y<20;Y+=2)T^=(i=(k^=(i=(S^=(i=(O^=(i=T+k|0)<<7|i>>>25)+T|0)<<9|i>>>23)+O|0)<<13|i>>>19)+S|0)<<18|i>>>14,I^=(i=(E^=(i=(U^=(i=(P^=(i=I+E|0)<<7|i>>>25)+I|0)<<9|i>>>23)+P|0)<<13|i>>>19)+U|0)<<18|i>>>14,j^=(i=(C^=(i=(w^=(i=(N^=(i=j+C|0)<<7|i>>>25)+j|0)<<9|i>>>23)+N|0)<<13|i>>>19)+w|0)<<18|i>>>14,D^=(i=(A^=(i=(B^=(i=(x^=(i=D+A|0)<<7|i>>>25)+D|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,T^=(i=(x^=(i=(w^=(i=(E^=(i=T+x|0)<<7|i>>>25)+T|0)<<9|i>>>23)+E|0)<<13|i>>>19)+w|0)<<18|i>>>14,I^=(i=(O^=(i=(B^=(i=(C^=(i=I+O|0)<<7|i>>>25)+I|0)<<9|i>>>23)+C|0)<<13|i>>>19)+B|0)<<18|i>>>14,j^=(i=(P^=(i=(S^=(i=(A^=(i=j+P|0)<<7|i>>>25)+j|0)<<9|i>>>23)+A|0)<<13|i>>>19)+S|0)<<18|i>>>14,D^=(i=(N^=(i=(U^=(i=(k^=(i=D+N|0)<<7|i>>>25)+D|0)<<9|i>>>23)+k|0)<<13|i>>>19)+U|0)<<18|i>>>14;T=T+n|0,E=E+a|0,w=w+o|0,x=x+d|0,O=O+c|0,I=I+u|0,C=C+h|0,B=B+l|0,S=S+p|0,P=P+m|0,j=j+b|0,A=A+_|0,k=k+g|0,U=U+f|0,N=N+y|0,D=D+v|0,e[0]=T>>>0&255,e[1]=T>>>8&255,e[2]=T>>>16&255,e[3]=T>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=w>>>0&255,e[9]=w>>>8&255,e[10]=w>>>16&255,e[11]=w>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=I>>>0&255,e[21]=I>>>8&255,e[22]=I>>>16&255,e[23]=I>>>24&255,e[24]=C>>>0&255,e[25]=C>>>8&255,e[26]=C>>>16&255,e[27]=C>>>24&255,e[28]=B>>>0&255,e[29]=B>>>8&255,e[30]=B>>>16&255,e[31]=B>>>24&255,e[32]=S>>>0&255,e[33]=S>>>8&255,e[34]=S>>>16&255,e[35]=S>>>24&255,e[36]=P>>>0&255,e[37]=P>>>8&255,e[38]=P>>>16&255,e[39]=P>>>24&255,e[40]=j>>>0&255,e[41]=j>>>8&255,e[42]=j>>>16&255,e[43]=j>>>24&255,e[44]=A>>>0&255,e[45]=A>>>8&255,e[46]=A>>>16&255,e[47]=A>>>24&255,e[48]=k>>>0&255,e[49]=k>>>8&255,e[50]=k>>>16&255,e[51]=k>>>24&255,e[52]=U>>>0&255,e[53]=U>>>8&255,e[54]=U>>>16&255,e[55]=U>>>24&255,e[56]=N>>>0&255,e[57]=N>>>8&255,e[58]=N>>>16&255,e[59]=N>>>24&255,e[60]=D>>>0&255,e[61]=D>>>8&255,e[62]=D>>>16&255,e[63]=D>>>24&255}(e,t,r,s)}function y(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,b=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,_=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,f=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,y=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=0;T<20;T+=2)n^=(i=(g^=(i=(p^=(i=(c^=(i=n+g|0)<<7|i>>>25)+n|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(a^=(i=(f^=(i=(m^=(i=u+a|0)<<7|i>>>25)+u|0)<<9|i>>>23)+m|0)<<13|i>>>19)+f|0)<<18|i>>>14,b^=(i=(h^=(i=(o^=(i=(y^=(i=b+h|0)<<7|i>>>25)+b|0)<<9|i>>>23)+y|0)<<13|i>>>19)+o|0)<<18|i>>>14,v^=(i=(_^=(i=(l^=(i=(d^=(i=v+_|0)<<7|i>>>25)+v|0)<<9|i>>>23)+d|0)<<13|i>>>19)+l|0)<<18|i>>>14,n^=(i=(d^=(i=(o^=(i=(a^=(i=n+d|0)<<7|i>>>25)+n|0)<<9|i>>>23)+a|0)<<13|i>>>19)+o|0)<<18|i>>>14,u^=(i=(c^=(i=(l^=(i=(h^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+h|0)<<13|i>>>19)+l|0)<<18|i>>>14,b^=(i=(m^=(i=(p^=(i=(_^=(i=b+m|0)<<7|i>>>25)+b|0)<<9|i>>>23)+_|0)<<13|i>>>19)+p|0)<<18|i>>>14,v^=(i=(y^=(i=(f^=(i=(g^=(i=v+y|0)<<7|i>>>25)+v|0)<<9|i>>>23)+g|0)<<13|i>>>19)+f|0)<<18|i>>>14;e[0]=n>>>0&255,e[1]=n>>>8&255,e[2]=n>>>16&255,e[3]=n>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=b>>>0&255,e[9]=b>>>8&255,e[10]=b>>>16&255,e[11]=b>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=l>>>0&255,e[21]=l>>>8&255,e[22]=l>>>16&255,e[23]=l>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=m>>>0&255,e[29]=m>>>8&255,e[30]=m>>>16&255,e[31]=m>>>24&255}(e,t,r,s)}var v=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function T(e,t,r,s,i,n,a){var o,d,c=new Uint8Array(16),u=new Uint8Array(64);for(d=0;d<16;d++)c[d]=0;for(d=0;d<8;d++)c[d]=n[d];for(;i>=64;){for(f(u,c,a,v),d=0;d<64;d++)e[t+d]=r[s+d]^u[d];for(o=1,d=8;d<16;d++)o=o+(255&c[d])|0,c[d]=255&o,o>>>=8;i-=64,t+=64,s+=64}if(i>0)for(f(u,c,a,v),d=0;d<i;d++)e[t+d]=r[s+d]^u[d];return 0}function E(e,t,r,s,i){var n,a,o=new Uint8Array(16),d=new Uint8Array(64);for(a=0;a<16;a++)o[a]=0;for(a=0;a<8;a++)o[a]=s[a];for(;r>=64;){for(f(d,o,i,v),a=0;a<64;a++)e[t+a]=d[a];for(n=1,a=8;a<16;a++)n=n+(255&o[a])|0,o[a]=255&n,n>>>=8;r-=64,t+=64}if(r>0)for(f(d,o,i,v),a=0;a<r;a++)e[t+a]=d[a];return 0}function w(e,t,r,s,i){var n=new Uint8Array(32);y(n,s,i,v);for(var a=new Uint8Array(8),o=0;o<8;o++)a[o]=s[o+16];return E(e,t,r,a,n)}function x(e,t,r,s,i,n,a){var o=new Uint8Array(32);y(o,n,a,v);for(var d=new Uint8Array(8),c=0;c<8;c++)d[c]=n[c+16];return T(e,t,r,s,i,d,o)}var O=function(e){var t,r,s,i,n,a,o,d;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),s=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|s<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(s>>>7|i<<9),n=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|n<<12),this.r[5]=n>>>1&8190,a=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(n>>>14|a<<2),o=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(a>>>11|o<<5),d=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(o>>>8|d<<8),this.r[9]=d>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function I(e,t,r,s,i,n){var a=new O(n);return a.update(r,s,i),a.finish(e,t),0}function C(e,t,r,s,i,n){var a=new Uint8Array(16);return I(a,0,r,s,i,n),_(e,t,a,0)}function B(e,t,r,s,i){var n;if(r<32)return-1;for(x(e,0,t,0,r,s,i),I(e,16,e,32,r-32,e),n=0;n<16;n++)e[n]=0;return 0}function S(e,t,r,s,i){var n,a=new Uint8Array(32);if(r<32)return-1;if(w(a,0,32,s,i),0!==C(t,16,t,32,r-32,a))return-1;for(x(e,0,t,0,r,s,i),n=0;n<32;n++)e[n]=0;return 0}function P(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function j(e){var t,r,s=1;for(t=0;t<16;t++)r=e[t]+s+65535,s=Math.floor(r/65536),e[t]=r-65536*s;e[0]+=s-1+37*(s-1)}function A(e,t,r){for(var s,i=~(r-1),n=0;n<16;n++)s=i&(e[n]^t[n]),e[n]^=s,t[n]^=s}function k(e,r){var s,i,n,a=t(),o=t();for(s=0;s<16;s++)o[s]=r[s];for(j(o),j(o),j(o),i=0;i<2;i++){for(a[0]=o[0]-65517,s=1;s<15;s++)a[s]=o[s]-65535-(a[s-1]>>16&1),a[s-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),n=a[15]>>16&1,a[14]&=65535,A(o,a,1-n)}for(s=0;s<16;s++)e[2*s]=255&o[s],e[2*s+1]=o[s]>>8}function U(e,t){var r=new Uint8Array(32),s=new Uint8Array(32);return k(r,e),k(s,t),g(r,0,s,0)}function N(e){var t=new Uint8Array(32);return k(t,e),1&t[0]}function D(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function Y(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]+r[s]}function R(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]-r[s]}function V(e,t,r){var s,i,n=0,a=0,o=0,d=0,c=0,u=0,h=0,l=0,p=0,m=0,b=0,_=0,g=0,f=0,y=0,v=0,T=0,E=0,w=0,x=0,O=0,I=0,C=0,B=0,S=0,P=0,j=0,A=0,k=0,U=0,N=0,D=r[0],Y=r[1],R=r[2],V=r[3],M=r[4],J=r[5],F=r[6],X=r[7],L=r[8],G=r[9],$=r[10],z=r[11],q=r[12],W=r[13],H=r[14],K=r[15];n+=(s=t[0])*D,a+=s*Y,o+=s*R,d+=s*V,c+=s*M,u+=s*J,h+=s*F,l+=s*X,p+=s*L,m+=s*G,b+=s*$,_+=s*z,g+=s*q,f+=s*W,y+=s*H,v+=s*K,a+=(s=t[1])*D,o+=s*Y,d+=s*R,c+=s*V,u+=s*M,h+=s*J,l+=s*F,p+=s*X,m+=s*L,b+=s*G,_+=s*$,g+=s*z,f+=s*q,y+=s*W,v+=s*H,T+=s*K,o+=(s=t[2])*D,d+=s*Y,c+=s*R,u+=s*V,h+=s*M,l+=s*J,p+=s*F,m+=s*X,b+=s*L,_+=s*G,g+=s*$,f+=s*z,y+=s*q,v+=s*W,T+=s*H,E+=s*K,d+=(s=t[3])*D,c+=s*Y,u+=s*R,h+=s*V,l+=s*M,p+=s*J,m+=s*F,b+=s*X,_+=s*L,g+=s*G,f+=s*$,y+=s*z,v+=s*q,T+=s*W,E+=s*H,w+=s*K,c+=(s=t[4])*D,u+=s*Y,h+=s*R,l+=s*V,p+=s*M,m+=s*J,b+=s*F,_+=s*X,g+=s*L,f+=s*G,y+=s*$,v+=s*z,T+=s*q,E+=s*W,w+=s*H,x+=s*K,u+=(s=t[5])*D,h+=s*Y,l+=s*R,p+=s*V,m+=s*M,b+=s*J,_+=s*F,g+=s*X,f+=s*L,y+=s*G,v+=s*$,T+=s*z,E+=s*q,w+=s*W,x+=s*H,O+=s*K,h+=(s=t[6])*D,l+=s*Y,p+=s*R,m+=s*V,b+=s*M,_+=s*J,g+=s*F,f+=s*X,y+=s*L,v+=s*G,T+=s*$,E+=s*z,w+=s*q,x+=s*W,O+=s*H,I+=s*K,l+=(s=t[7])*D,p+=s*Y,m+=s*R,b+=s*V,_+=s*M,g+=s*J,f+=s*F,y+=s*X,v+=s*L,T+=s*G,E+=s*$,w+=s*z,x+=s*q,O+=s*W,I+=s*H,C+=s*K,p+=(s=t[8])*D,m+=s*Y,b+=s*R,_+=s*V,g+=s*M,f+=s*J,y+=s*F,v+=s*X,T+=s*L,E+=s*G,w+=s*$,x+=s*z,O+=s*q,I+=s*W,C+=s*H,B+=s*K,m+=(s=t[9])*D,b+=s*Y,_+=s*R,g+=s*V,f+=s*M,y+=s*J,v+=s*F,T+=s*X,E+=s*L,w+=s*G,x+=s*$,O+=s*z,I+=s*q,C+=s*W,B+=s*H,S+=s*K,b+=(s=t[10])*D,_+=s*Y,g+=s*R,f+=s*V,y+=s*M,v+=s*J,T+=s*F,E+=s*X,w+=s*L,x+=s*G,O+=s*$,I+=s*z,C+=s*q,B+=s*W,S+=s*H,P+=s*K,_+=(s=t[11])*D,g+=s*Y,f+=s*R,y+=s*V,v+=s*M,T+=s*J,E+=s*F,w+=s*X,x+=s*L,O+=s*G,I+=s*$,C+=s*z,B+=s*q,S+=s*W,P+=s*H,j+=s*K,g+=(s=t[12])*D,f+=s*Y,y+=s*R,v+=s*V,T+=s*M,E+=s*J,w+=s*F,x+=s*X,O+=s*L,I+=s*G,C+=s*$,B+=s*z,S+=s*q,P+=s*W,j+=s*H,A+=s*K,f+=(s=t[13])*D,y+=s*Y,v+=s*R,T+=s*V,E+=s*M,w+=s*J,x+=s*F,O+=s*X,I+=s*L,C+=s*G,B+=s*$,S+=s*z,P+=s*q,j+=s*W,A+=s*H,k+=s*K,y+=(s=t[14])*D,v+=s*Y,T+=s*R,E+=s*V,w+=s*M,x+=s*J,O+=s*F,I+=s*X,C+=s*L,B+=s*G,S+=s*$,P+=s*z,j+=s*q,A+=s*W,k+=s*H,U+=s*K,v+=(s=t[15])*D,a+=38*(E+=s*R),o+=38*(w+=s*V),d+=38*(x+=s*M),c+=38*(O+=s*J),u+=38*(I+=s*F),h+=38*(C+=s*X),l+=38*(B+=s*L),p+=38*(S+=s*G),m+=38*(P+=s*$),b+=38*(j+=s*z),_+=38*(A+=s*q),g+=38*(k+=s*W),f+=38*(U+=s*H),y+=38*(N+=s*K),n=(s=(n+=38*(T+=s*Y))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n=(s=(n+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n+=i-1+37*(i-1),e[0]=n,e[1]=a,e[2]=o,e[3]=d,e[4]=c,e[5]=u,e[6]=h,e[7]=l,e[8]=p,e[9]=m,e[10]=b,e[11]=_,e[12]=g,e[13]=f,e[14]=y,e[15]=v}function M(e,t){V(e,t,t)}function J(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=253;s>=0;s--)M(i,i),2!==s&&4!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function F(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=250;s>=0;s--)M(i,i),1!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function X(e,r,s){var i,n,a=new Uint8Array(32),o=new Float64Array(80),c=t(),u=t(),h=t(),l=t(),p=t(),m=t();for(n=0;n<31;n++)a[n]=r[n];for(a[31]=127&r[31]|64,a[0]&=248,D(o,s),n=0;n<16;n++)u[n]=o[n],l[n]=c[n]=h[n]=0;for(c[0]=l[0]=1,n=254;n>=0;--n)A(c,u,i=a[n>>>3]>>>(7&n)&1),A(h,l,i),Y(p,c,h),R(c,c,h),Y(h,u,l),R(u,u,l),M(l,p),M(m,c),V(c,h,c),V(h,u,p),Y(p,c,h),R(c,c,h),M(u,c),R(h,l,m),V(c,h,d),Y(c,c,l),V(h,h,c),V(c,l,m),V(l,u,o),M(u,p),A(c,u,i),A(h,l,i);for(n=0;n<16;n++)o[n+16]=c[n],o[n+32]=h[n],o[n+48]=u[n],o[n+64]=l[n];var b=o.subarray(32),_=o.subarray(16);return J(b,b),V(_,_,b),k(e,_),0}function L(e,t){return X(e,t,n)}function G(e,t){return s(t,32),L(e,t)}function $(e,t,r){var s=new Uint8Array(32);return X(s,r,t),y(e,i,s,v)}O.prototype.blocks=function(e,t,r){for(var s,i,n,a,o,d,c,u,h,l,p,m,b,_,g,f,y,v,T,E=this.fin?0:2048,w=this.h[0],x=this.h[1],O=this.h[2],I=this.h[3],C=this.h[4],B=this.h[5],S=this.h[6],P=this.h[7],j=this.h[8],A=this.h[9],k=this.r[0],U=this.r[1],N=this.r[2],D=this.r[3],Y=this.r[4],R=this.r[5],V=this.r[6],M=this.r[7],J=this.r[8],F=this.r[9];r>=16;)l=h=0,l+=(w+=8191&(s=255&e[t+0]|(255&e[t+1])<<8))*k,l+=(x+=8191&(s>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),l+=(O+=8191&(i>>>10|(n=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*J),l+=(I+=8191&(n>>>7|(a=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*M),h=(l+=(C+=8191&(a>>>4|(o=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*V))>>>13,l&=8191,l+=(B+=o>>>1&8191)*(5*R),l+=(S+=8191&(o>>>14|(d=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*Y),l+=(P+=8191&(d>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*D),l+=(j+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*N),p=h+=(l+=(A+=u>>>5|E)*(5*U))>>>13,p+=w*U,p+=x*k,p+=O*(5*F),p+=I*(5*J),h=(p+=C*(5*M))>>>13,p&=8191,p+=B*(5*V),p+=S*(5*R),p+=P*(5*Y),p+=j*(5*D),h+=(p+=A*(5*N))>>>13,p&=8191,m=h,m+=w*N,m+=x*U,m+=O*k,m+=I*(5*F),h=(m+=C*(5*J))>>>13,m&=8191,m+=B*(5*M),m+=S*(5*V),m+=P*(5*R),m+=j*(5*Y),b=h+=(m+=A*(5*D))>>>13,b+=w*D,b+=x*N,b+=O*U,b+=I*k,h=(b+=C*(5*F))>>>13,b&=8191,b+=B*(5*J),b+=S*(5*M),b+=P*(5*V),b+=j*(5*R),_=h+=(b+=A*(5*Y))>>>13,_+=w*Y,_+=x*D,_+=O*N,_+=I*U,h=(_+=C*k)>>>13,_&=8191,_+=B*(5*F),_+=S*(5*J),_+=P*(5*M),_+=j*(5*V),g=h+=(_+=A*(5*R))>>>13,g+=w*R,g+=x*Y,g+=O*D,g+=I*N,h=(g+=C*U)>>>13,g&=8191,g+=B*k,g+=S*(5*F),g+=P*(5*J),g+=j*(5*M),f=h+=(g+=A*(5*V))>>>13,f+=w*V,f+=x*R,f+=O*Y,f+=I*D,h=(f+=C*N)>>>13,f&=8191,f+=B*U,f+=S*k,f+=P*(5*F),f+=j*(5*J),y=h+=(f+=A*(5*M))>>>13,y+=w*M,y+=x*V,y+=O*R,y+=I*Y,h=(y+=C*D)>>>13,y&=8191,y+=B*N,y+=S*U,y+=P*k,y+=j*(5*F),v=h+=(y+=A*(5*J))>>>13,v+=w*J,v+=x*M,v+=O*V,v+=I*R,h=(v+=C*Y)>>>13,v&=8191,v+=B*D,v+=S*N,v+=P*U,v+=j*k,T=h+=(v+=A*(5*F))>>>13,T+=w*F,T+=x*J,T+=O*M,T+=I*V,h=(T+=C*R)>>>13,T&=8191,T+=B*Y,T+=S*D,T+=P*N,T+=j*U,w=l=8191&(h=(h=((h+=(T+=A*k)>>>13)<<2)+h|0)+(l&=8191)|0),x=p+=h>>>=13,O=m&=8191,I=b&=8191,C=_&=8191,B=g&=8191,S=f&=8191,P=y&=8191,j=v&=8191,A=T&=8191,t+=16,r-=16;this.h[0]=w,this.h[1]=x,this.h[2]=O,this.h[3]=I,this.h[4]=C,this.h[5]=B,this.h[6]=S,this.h[7]=P,this.h[8]=j,this.h[9]=A},O.prototype.finish=function(e,t){var r,s,i,n,a=new Uint16Array(10);if(this.leftover){for(n=this.leftover,this.buffer[n++]=1;n<16;n++)this.buffer[n]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,n=2;n<10;n++)this.h[n]+=r,r=this.h[n]>>>13,this.h[n]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,a[0]=this.h[0]+5,r=a[0]>>>13,a[0]&=8191,n=1;n<10;n++)a[n]=this.h[n]+r,r=a[n]>>>13,a[n]&=8191;for(a[9]-=8192,s=(1^r)-1,n=0;n<10;n++)a[n]&=s;for(s=~s,n=0;n<10;n++)this.h[n]=this.h[n]&s|a[n];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,n=1;n<8;n++)i=(this.h[n]+this.pad[n]|0)+(i>>>16)|0,this.h[n]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,r){var s,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),s=0;s<i;s++)this.buffer[this.leftover+s]=e[t+s];if(r-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(s=0;s<r;s++)this.buffer[this.leftover+s]=e[t+s];this.leftover+=r}};var z=B,q=S,W=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function H(e,t,r,s){for(var i,n,a,o,d,c,u,h,l,p,m,b,_,g,f,y,v,T,E,w,x,O,I,C,B,S,P=new Int32Array(16),j=new Int32Array(16),A=e[0],k=e[1],U=e[2],N=e[3],D=e[4],Y=e[5],R=e[6],V=e[7],M=t[0],J=t[1],F=t[2],X=t[3],L=t[4],G=t[5],$=t[6],z=t[7],q=0;s>=128;){for(E=0;E<16;E++)w=8*E+q,P[E]=r[w+0]<<24|r[w+1]<<16|r[w+2]<<8|r[w+3],j[E]=r[w+4]<<24|r[w+5]<<16|r[w+6]<<8|r[w+7];for(E=0;E<80;E++)if(i=A,n=k,a=U,o=N,d=D,c=Y,u=R,l=M,p=J,m=F,b=X,_=L,g=G,f=$,I=65535&(O=z),C=O>>>16,B=65535&(x=V),S=x>>>16,I+=65535&(O=(L>>>14|D<<18)^(L>>>18|D<<14)^(D>>>9|L<<23)),C+=O>>>16,B+=65535&(x=(D>>>14|L<<18)^(D>>>18|L<<14)^(L>>>9|D<<23)),S+=x>>>16,I+=65535&(O=L&G^~L&$),C+=O>>>16,B+=65535&(x=D&Y^~D&R),S+=x>>>16,I+=65535&(O=W[2*E+1]),C+=O>>>16,B+=65535&(x=W[2*E]),S+=x>>>16,x=P[E%16],C+=(O=j[E%16])>>>16,B+=65535&x,S+=x>>>16,B+=(C+=(I+=65535&O)>>>16)>>>16,I=65535&(O=T=65535&I|C<<16),C=O>>>16,B=65535&(x=v=65535&B|(S+=B>>>16)<<16),S=x>>>16,I+=65535&(O=(M>>>28|A<<4)^(A>>>2|M<<30)^(A>>>7|M<<25)),C+=O>>>16,B+=65535&(x=(A>>>28|M<<4)^(M>>>2|A<<30)^(M>>>7|A<<25)),S+=x>>>16,C+=(O=M&J^M&F^J&F)>>>16,B+=65535&(x=A&k^A&U^k&U),S+=x>>>16,h=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,y=65535&I|C<<16,I=65535&(O=b),C=O>>>16,B=65535&(x=o),S=x>>>16,C+=(O=T)>>>16,B+=65535&(x=v),S+=x>>>16,k=i,U=n,N=a,D=o=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,Y=d,R=c,V=u,A=h,J=l,F=p,X=m,L=b=65535&I|C<<16,G=_,$=g,z=f,M=y,E%16==15)for(w=0;w<16;w++)x=P[w],I=65535&(O=j[w]),C=O>>>16,B=65535&x,S=x>>>16,x=P[(w+9)%16],I+=65535&(O=j[(w+9)%16]),C+=O>>>16,B+=65535&x,S+=x>>>16,v=P[(w+1)%16],I+=65535&(O=((T=j[(w+1)%16])>>>1|v<<31)^(T>>>8|v<<24)^(T>>>7|v<<25)),C+=O>>>16,B+=65535&(x=(v>>>1|T<<31)^(v>>>8|T<<24)^v>>>7),S+=x>>>16,v=P[(w+14)%16],C+=(O=((T=j[(w+14)%16])>>>19|v<<13)^(v>>>29|T<<3)^(T>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|T<<13)^(T>>>29|v<<3)^v>>>6),S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,P[w]=65535&B|S<<16,j[w]=65535&I|C<<16;I=65535&(O=M),C=O>>>16,B=65535&(x=A),S=x>>>16,x=e[0],C+=(O=t[0])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[0]=A=65535&B|S<<16,t[0]=M=65535&I|C<<16,I=65535&(O=J),C=O>>>16,B=65535&(x=k),S=x>>>16,x=e[1],C+=(O=t[1])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[1]=k=65535&B|S<<16,t[1]=J=65535&I|C<<16,I=65535&(O=F),C=O>>>16,B=65535&(x=U),S=x>>>16,x=e[2],C+=(O=t[2])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[2]=U=65535&B|S<<16,t[2]=F=65535&I|C<<16,I=65535&(O=X),C=O>>>16,B=65535&(x=N),S=x>>>16,x=e[3],C+=(O=t[3])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[3]=N=65535&B|S<<16,t[3]=X=65535&I|C<<16,I=65535&(O=L),C=O>>>16,B=65535&(x=D),S=x>>>16,x=e[4],C+=(O=t[4])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[4]=D=65535&B|S<<16,t[4]=L=65535&I|C<<16,I=65535&(O=G),C=O>>>16,B=65535&(x=Y),S=x>>>16,x=e[5],C+=(O=t[5])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[5]=Y=65535&B|S<<16,t[5]=G=65535&I|C<<16,I=65535&(O=$),C=O>>>16,B=65535&(x=R),S=x>>>16,x=e[6],C+=(O=t[6])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[6]=R=65535&B|S<<16,t[6]=$=65535&I|C<<16,I=65535&(O=z),C=O>>>16,B=65535&(x=V),S=x>>>16,x=e[7],C+=(O=t[7])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[7]=V=65535&B|S<<16,t[7]=z=65535&I|C<<16,q+=128,s-=128}return s}function K(e,t,r){var s,i=new Int32Array(8),n=new Int32Array(8),a=new Uint8Array(256),o=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,n[0]=4089235720,n[1]=2227873595,n[2]=4271175723,n[3]=1595750129,n[4]=2917565137,n[5]=725511199,n[6]=4215389547,n[7]=327033209,H(i,n,t,r),r%=128,s=0;s<r;s++)a[s]=t[o-r+s];for(a[r]=128,a[(r=256-128*(r<112?1:0))-9]=0,m(a,r-8,o/536870912|0,o<<3),H(i,n,a,r),s=0;s<8;s++)m(e,8*s,i[s],n[s]);return 0}function Q(e,r){var s=t(),i=t(),n=t(),a=t(),o=t(),d=t(),c=t(),h=t(),l=t();R(s,e[1],e[0]),R(l,r[1],r[0]),V(s,s,l),Y(i,e[0],e[1]),Y(l,r[0],r[1]),V(i,i,l),V(n,e[3],r[3]),V(n,n,u),V(a,e[2],r[2]),Y(a,a,a),R(o,i,s),R(d,a,n),Y(c,a,n),Y(h,i,s),V(e[0],o,d),V(e[1],h,c),V(e[2],c,d),V(e[3],o,h)}function Z(e,t,r){var s;for(s=0;s<4;s++)A(e[s],t[s],r)}function ee(e,r){var s=t(),i=t(),n=t();J(n,r[2]),V(s,r[0],n),V(i,r[1],n),k(e,i),e[31]^=N(s)<<7}function te(e,t,r){var s,i;for(P(e[0],a),P(e[1],o),P(e[2],o),P(e[3],a),i=255;i>=0;--i)Z(e,t,s=r[i/8|0]>>(7&i)&1),Q(t,e),Q(e,e),Z(e,t,s)}function re(e,r){var s=[t(),t(),t(),t()];P(s[0],h),P(s[1],l),P(s[2],o),V(s[3],h,l),te(e,s,r)}function se(e,r,i){var n,a=new Uint8Array(64),o=[t(),t(),t(),t()];for(i||s(r,32),K(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,re(o,a),ee(e,o),n=0;n<32;n++)r[n+32]=e[n];return 0}var ie=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ne(e,t){var r,s,i,n;for(s=63;s>=32;--s){for(r=0,i=s-32,n=s-12;i<n;++i)t[i]+=r-16*t[s]*ie[i-(s-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[s]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*ie[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ie[i];for(s=0;s<32;s++)t[s+1]+=t[s]>>8,e[s]=255&t[s]}function ae(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ne(e,r)}function oe(e,r,s,i){var n,a,o=new Uint8Array(64),d=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),h=[t(),t(),t(),t()];K(o,i,32),o[0]&=248,o[31]&=127,o[31]|=64;var l=s+64;for(n=0;n<s;n++)e[64+n]=r[n];for(n=0;n<32;n++)e[32+n]=o[32+n];for(K(c,e.subarray(32),s+32),ae(c),re(h,c),ee(e,h),n=32;n<64;n++)e[n]=i[n];for(K(d,e,s+64),ae(d),n=0;n<64;n++)u[n]=0;for(n=0;n<32;n++)u[n]=c[n];for(n=0;n<32;n++)for(a=0;a<32;a++)u[n+a]+=d[n]*o[a];return ne(e.subarray(32),u),l}function de(e,r,s,i){var n,d=new Uint8Array(32),u=new Uint8Array(64),h=[t(),t(),t(),t()],l=[t(),t(),t(),t()];if(s<64)return-1;if(function(e,r){var s=t(),i=t(),n=t(),d=t(),u=t(),h=t(),l=t();return P(e[2],o),D(e[1],r),M(n,e[1]),V(d,n,c),R(n,n,e[2]),Y(d,e[2],d),M(u,d),M(h,u),V(l,h,u),V(s,l,n),V(s,s,d),F(s,s),V(s,s,n),V(s,s,d),V(s,s,d),V(e[0],s,d),M(i,e[0]),V(i,i,d),U(i,n)&&V(e[0],e[0],p),M(i,e[0]),V(i,i,d),U(i,n)?-1:(N(e[0])===r[31]>>7&&R(e[0],a,e[0]),V(e[3],e[0],e[1]),0)}(l,i))return-1;for(n=0;n<s;n++)e[n]=r[n];for(n=0;n<32;n++)e[n+32]=i[n];if(K(u,e,s),ae(u),te(h,l,u),re(l,r.subarray(32)),Q(h,l),ee(d,h),s-=64,g(r,0,d,0)){for(n=0;n<s;n++)e[n]=0;return-1}for(n=0;n<s;n++)e[n]=r[n+64];return s}var ce,ue=64,he=32,le=64;function pe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function me(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function be(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:y,crypto_stream_xor:x,crypto_stream:w,crypto_stream_salsa20_xor:T,crypto_stream_salsa20:E,crypto_onetimeauth:I,crypto_onetimeauth_verify:C,crypto_verify_16:_,crypto_verify_32:g,crypto_secretbox:B,crypto_secretbox_open:S,crypto_scalarmult:X,crypto_scalarmult_base:L,crypto_box_beforenm:$,crypto_box_afternm:z,crypto_box:function(e,t,r,s,i,n){var a=new Uint8Array(32);return $(a,i,n),z(e,t,r,s,a)},crypto_box_open:function(e,t,r,s,i,n){var a=new Uint8Array(32);return $(a,i,n),q(e,t,r,s,a)},crypto_box_keypair:G,crypto_hash:K,crypto_sign:oe,crypto_sign_keypair:se,crypto_sign_open:de,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:he,crypto_sign_SECRETKEYBYTES:le,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:c,L:ie,pack25519:k,unpack25519:D,M:V,A:Y,S:M,Z:R,pow2523:F,add:Q,set25519:P,modL:ne,scalarmult:te,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return s(t,e),t},e.secretbox=function(e,t,r){me(e,t,r),pe(r,t);for(var s=new Uint8Array(32+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+32]=e[n];return B(i,s,s.length,t,r),i.subarray(16)},e.secretbox.open=function(e,t,r){me(e,t,r),pe(r,t);for(var s=new Uint8Array(16+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+16]=e[n];return s.length<32||0!==S(i,s,s.length,t,r)?null:i.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(me(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var r=new Uint8Array(32);return X(r,e,t),r},e.scalarMult.base=function(e){if(me(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return L(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox(t,r,n)},e.box.before=function(e,t){me(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var r=new Uint8Array(32);return $(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox.open(t,r,n)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return G(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(me(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return L(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(me(e,t),t.length!==le)throw new Error("bad secret key size");var r=new Uint8Array(ue+e.length);return oe(r,e,e.length,t),r},e.sign.open=function(e,t){if(me(e,t),t.length!==he)throw new Error("bad public key size");var r=new Uint8Array(e.length),s=de(r,e,e.length,t);if(s<0)return null;for(var i=new Uint8Array(s),n=0;n<i.length;n++)i[n]=r[n];return i},e.sign.detached=function(t,r){for(var s=e.sign(t,r),i=new Uint8Array(ue),n=0;n<i.length;n++)i[n]=s[n];return i},e.sign.detached.verify=function(e,t,r){if(me(e,t,r),t.length!==ue)throw new Error("bad signature size");if(r.length!==he)throw new Error("bad public key size");var s,i=new Uint8Array(ue+e.length),n=new Uint8Array(ue+e.length);for(s=0;s<ue;s++)i[s]=t[s];for(s=0;s<e.length;s++)i[s+ue]=e[s];return de(n,i,i.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(he),t=new Uint8Array(le);return se(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(me(e),e.length!==le)throw new Error("bad secret key size");for(var t=new Uint8Array(he),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(me(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(he),r=new Uint8Array(le),s=0;s<32;s++)r[s]=e[s];return se(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=he,e.sign.secretKeyLength=le,e.sign.seedLength=32,e.sign.signatureLength=ue,e.hash=function(e){me(e);var t=new Uint8Array(64);return K(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return me(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===b(e,0,t,0,e.length)},e.setPRNG=function(e){s=e},(ce="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&ce.getRandomValues?e.setPRNG((function(e,t){var r,s=new Uint8Array(t);for(r=0;r<t;r+=65536)ce.getRandomValues(s.subarray(r,r+Math.min(t-r,65536)));for(r=0;r<t;r++)e[r]=s[r];be(s)})):(ce=r(211))&&ce.randomBytes&&e.setPRNG((function(e,t){var r,s=ce.randomBytes(t);for(r=0;r<t;r++)e[r]=s[r];be(s)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},725:(e,t,r)=>{const s=r(22);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},763:(e,t,r)=>{const s=r(364);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var i=Object.create(null);a.r(i);var n={};e=e||[null,t({}),t([]),t(t)];for(var o=2&s&&r;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>n[e]=()=>r[e]));return n.default=()=>r,a.d(i,n),i},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".index.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},s="wowok_agent:",a.l=(e,t,i,n)=>{if(r[e])r[e].push(t);else{var o,d;if(void 0!==i)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var h=c[u];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==s+i){o=h;break}}o||(d=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,a.nc&&o.setAttribute("nonce",a.nc),o.setAttribute("data-webpack",s+i),o.src=e),r[e]=[t];var l=(t,s)=>{o.onerror=o.onload=null,clearTimeout(p);var i=r[e];if(delete r[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(s))),t)return t(s)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),d&&document.head.appendChild(o)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var s=r.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=r[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={792:0};a.f.j=(t,r)=>{var s=a.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{var i=new Promise(((r,i)=>s=e[t]=[r,i]));r.push(s[2]=i);var n=a.p+a.u(t),o=new Error;a.l(n,(r=>{if(a.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+i+": "+n+")",o.name="ChunkLoadError",o.type=i,o.request=n,s[1](o)}}),"chunk-"+t,t)}};var t=(t,r)=>{var s,i,[n,o,d]=r,c=0;if(n.some((t=>0!==e[t]))){for(s in o)a.o(o,s)&&(a.m[s]=o[s]);d&&d(a)}for(t&&t(r);c<n.length;c++)i=n[c],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkwowok_agent=this.webpackChunkwowok_agent||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var o={};return(()=>{"use strict";a.r(o),a.d(o,{Account:()=>cc,BCS:()=>Xp,CacheData:()=>Pd,CacheName:()=>jd,CacheType:()=>Dd,CallArbitration:()=>Gp,CallBase:()=>_p,CallDemand:()=>qp,CallGuard:()=>Qp,CallMachine:()=>Wp,CallObjectPermission:()=>zp,CallPermission:()=>gp,CallPersonal:()=>tm,CallRepository:()=>Hp,CallService:()=>Kp,CallTreasury:()=>$p,EVENT_QUERY:()=>ac,LocalStorageCache:()=>Ud,MemeryCache:()=>kd,OBJECT_KEY:()=>Ad,ResponseData:()=>bp,WOWOK:()=>e,WowokCache:()=>Nd,call_object:()=>sm,call_object_json:()=>rm,data2object:()=>sc,getSuiMoveConfig:()=>Lp,queryTableItem_ArbVote:()=>Gd,queryTableItem_DemandPresenter:()=>Xd,queryTableItem_PermissionEntity:()=>Ld,queryTableItem_Personal:()=>Jd,query_objects:()=>Md,query_objects_json:()=>Yd,query_permission:()=>nc,query_permission_json:()=>ic,query_personal_json:()=>Vd,query_table:()=>Fd,query_table_json:()=>Rd,raw2type:()=>rc,tableItemQuery_MachineNode:()=>$d,tableItemQuery_MarkTag:()=>Kd,tableItemQuery_ProgressHistory:()=>qd,tableItemQuery_RepositoryData:()=>Hd,tableItemQuery_ServiceSale:()=>zd,tableItemQuery_TreasuryHistory:()=>Wd});var e={};function t(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}a.r(e),a.d(e,{Arbitration:()=>xd,BCS:()=>Oa,Bcs:()=>Wa,BuyRequiredEnum:()=>ud,ContextType:()=>Xo,Demand:()=>Wo,ENTRYPOINT:()=>Go,ERROR:()=>Ba,Ed25519Keypair:()=>Zn,Entity:()=>fd,Errors:()=>Ca,FirstLetterUppercase:()=>Po,FunctionGroup:()=>rd,GUARD_QUERIES:()=>td,Guard:()=>id,GuardFunctions:()=>sd,GuardMaker:()=>ad,GuardParser:()=>bd,IsNumberType:()=>Fo,IsValidAddress:()=>co,IsValidArgType:()=>fo,IsValidArray:()=>To,IsValidBigint:()=>lo,IsValidCoinType:()=>uo,IsValidDesription:()=>io,IsValidEndpoint:()=>oo,IsValidGuardIdentifier:()=>nd,IsValidInt:()=>yo,IsValidName:()=>no,IsValidName_AllowEmpty:()=>ao,IsValidOperatorType:()=>Mo,IsValidPercent:()=>vo,IsValidTokenType:()=>go,IsValidU128:()=>bo,IsValidU256:()=>_o,IsValidU64:()=>mo,IsValidU8:()=>po,IsValidValueType:()=>Jo,LogicsInfo:()=>Uo,MAX_DESCRIPTION_LENGTH:()=>eo,MAX_ENDPOINT_LENGTH:()=>ro,MAX_NAME_LENGTH:()=>to,MAX_U128:()=>ja,MAX_U256:()=>Aa,MAX_U64:()=>Pa,MAX_U8:()=>Sa,MODULES:()=>Ao,Machine:()=>Zo,OPTION_NONE:()=>ka,OperatorType:()=>ko,OperatorTypeArray:()=>Ro,PAYMENT_MAX_RECEIVER_COUNT:()=>Ed,ParseType:()=>Oo,Passport:()=>_d,Permission:()=>Qo,PermissionIndex:()=>Ho,PermissionInfo:()=>Ko,Progress:()=>ed,Protocol:()=>zo,Repository:()=>md,RepositoryValueType:()=>Do,RepositoryValueTypeInfo:()=>Yo,Repository_Policy_Mode:()=>od,Repository_Type:()=>dd,ResolveBalance:()=>xo,ResolveU64:()=>Eo,Resource:()=>vd,RpcResultParser:()=>qo,SER_VALUE:()=>Lo,Service:()=>gd,Service_Discount_Type:()=>cd,SuiClient:()=>ei,TagName:()=>hd,TransactionBlock:()=>gs,Treasury:()=>Td,Treasury_Operation:()=>pd,Treasury_WithdrawMode:()=>ld,ValueType:()=>No,ValueTypeArray:()=>Vo,ValueTypeConvert:()=>Ua,Wowok:()=>yd,array_equal:()=>Ga,array_unique:()=>$a,capitalize:()=>za,cb_U128:()=>Ja,cb_U256:()=>Fa,cb_U64:()=>Ma,cb_U8:()=>Va,concatenate:()=>Xa,create_payment:()=>wd,decodeSuiPrivateKey:()=>Un,deepClone:()=>Za,encodeSuiPrivateKey:()=>Nn,fromHEX:()=>ea,getFaucetHost:()=>Sd,getSuiMoveConfig:()=>Ia,getUTCDayStartByDivision:()=>ho,hasDuplicates:()=>jo,insertAtHead:()=>Io,isArr:()=>Qa,isValidHttpUrl:()=>Bo,normalizeSuiAddress:()=>de,numToUint8Array:()=>Ka,parseObjectType:()=>La,parse_object_type:()=>qa,query_object:()=>So,readOption:()=>Na,readOptionString:()=>Da,readVec:()=>Ra,requestSuiFromFaucetV0:()=>Cd,requestSuiFromFaucetV1:()=>Bd,stringToUint8Array:()=>Ha,toFixed:()=>Co,toHEX:()=>ta,ulebDecode:()=>Ya});const r=8192;function s(e){if(e.length<r)return btoa(String.fromCharCode(...e));let t="";for(var s=0;s<e.length;s+=r){const i=e.slice(s,s+r);t+=String.fromCharCode(...i)}return btoa(t)}const i=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;e[n];){let s=t[e.charCodeAt(n)];if(255===s)return;let i=0;for(let e=d-1;(0!==s||i<o)&&-1!==e;e--,i++)s+=r*c[e]>>>0,c[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw new Error("Non-zero carry");o=i,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let l=a;for(;u!==d;)h[l++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let l=s.repeat(i);for(;h<c;++h)l+=e.charAt(u[h]);return l},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),n=e=>i.encode(e),d=e=>i.decode(e);function c(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function u(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function h(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class l{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class p{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return m(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return m(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return m(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return h(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return n(e);case"base64":return s(e);case"hex":return u(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function m(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var b,_,g,f,y=e=>{throw TypeError(e)},v=(e,t,r)=>t.has(e)||y("Cannot "+r),T=(e,t,r)=>(v(e,t,"read from private field"),r?r.call(e):t.get(e)),E=(e,t,r)=>t.has(e)?y("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),w=(e,t,r,s)=>(v(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);b=new WeakMap,_=new WeakMap;let x=class e{constructor(e){E(this,b),E(this,_),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),w(this,b,e.write),w(this,_,e.serialize??((e,t)=>{const r=new p({initialSize:this.serializedSize(e)??void 0,...t});return T(this,b).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),T(this,b).call(this,e,t)}serialize(e,t){return this.validate(e),new C(this,T(this,_).call(this,e,t))}parse(e){const t=new l(e);return this.read(t)}fromHex(e){return this.parse(c(e))}fromBase58(e){return this.parse(d(e))}fromBase64(e){return this.parse(t(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>T(this,b).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>T(this,_).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const O=Symbol.for("@mysten/serialized-bcs");function I(e){return!!e&&"object"==typeof e&&!0===e[O]}class C{constructor(e,t){E(this,g),E(this,f),w(this,g,e),w(this,f,t)}get[O](){return!0}toBytes(){return T(this,f)}toHex(){return u(T(this,f))}toBase64(){return s(T(this,f))}toBase58(){return n(T(this,f))}parse(){return T(this,g).parse(T(this,f))}}function B({size:e,...t}){return new x({...t,serializedSize:()=>e})}function S({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function P({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function j(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function A(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??j(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function k(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}g=new WeakMap,f=new WeakMap;var U=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function N(e,t){return{kind:"validation",type:"check",reference:N,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"input",e,t),e}}}function D(e){return{kind:"validation",type:"integer",reference:D,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"integer",e,t),e}}}function Y(e){return{kind:"transformation",type:"transform",reference:Y,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function R(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function V(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function M(e,t){return{kind:"schema",type:"array",reference:M,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function J(e){return{kind:"schema",type:"bigint",reference:J,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function F(e){return{kind:"schema",type:"boolean",reference:F,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function X(e){return{kind:"schema",type:"lazy",reference:X,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function L(e,t){return{kind:"schema",type:"literal",reference:L,expects:j(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:A(this,"type",e,t),e}}}function G(e,...t){const r={kind:"schema",type:"nullable",reference:G,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=R(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function $(e,...t){const r={kind:"schema",type:"nullish",reference:$,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=R(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function z(e){return{kind:"schema",type:"number",reference:z,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?A(this,"type",e,t):e.typed=!0,e}}}function q(e,t){return{kind:"schema",type:"object",reference:q,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else A(this,"type",e,t);return e}}}function W(e,...t){const r={kind:"schema",type:"optional",reference:W,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=R(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function H(e,t,r){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(k(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else A(this,"type",e,t);return e}}}function K(e){return{kind:"schema",type:"string",reference:K,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function Q(e,t){return{kind:"schema",type:"tuple",reference:Q,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function Z(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ee(e,t){return{kind:"schema",type:"union",reference:ee,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];A(this,"type",e,t,{issues:Z(s)}),e.typed=!0}else{if(1===i?.length)return i[0];A(this,"type",e,t,{issues:Z(i)})}return e}}}function te(){return{kind:"schema",type:"unknown",reference:te,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function re(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new U(s.issues);return s.value}function se(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function ie(e){try{return 32===d(e).length}catch(e){return!1}}const ne=32;function ae(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)===ne}function oe(e){return ae(e)}function de(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(2*ne,"0")}`}function ce(e,t=!1){return de(e,t)}function ue(e){return se(ee(Object.entries(e).map((([e,t])=>q({[e]:t})))),Y((e=>({...e,$kind:Object.keys(e)[0]}))))}const he=se(K(),Y((e=>de(e))),N(ae)),le=he,pe=K(),me=se(ee([K(),se(z(),D())]),N((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),be=q({objectId:he,version:me,digest:K()}),_e=se(ee([q({GasCoin:L(!0)}),q({Input:se(z(),D()),type:W(L("pure"))}),q({Input:se(z(),D()),type:W(L("object"))}),q({Result:se(z(),D())}),q({NestedResult:Q([se(z(),D()),se(z(),D())])})]),Y((e=>({...e,$kind:Object.keys(e)[0]})))),ge=q({budget:G(me),price:G(me),owner:G(he),payment:G(M(be))}),fe=(q({address:K(),module:K(),name:K(),typeParams:M(K())}),ee([L("address"),L("bool"),L("u8"),L("u16"),L("u32"),L("u64"),L("u128"),L("u256"),q({vector:X((()=>fe))}),q({datatype:q({package:K(),module:K(),type:K(),typeParameters:M(X((()=>fe)))})}),q({typeParameter:se(z(),D())})])),ye=q({ref:G(ee([L("&"),L("&mut")])),body:fe}),ve=q({package:le,module:K(),function:K(),typeArguments:M(K()),arguments:M(_e),_argumentTypes:W(G(M(ye)))}),Te=q({name:K(),inputs:H(K(),ee([_e,M(_e)])),data:H(K(),te())}),Ee=ue({MoveCall:ve,TransferObjects:q({objects:M(_e),address:_e}),SplitCoins:q({coin:_e,amounts:M(_e)}),MergeCoins:q({destination:_e,sources:M(_e)}),Publish:q({modules:M(pe),dependencies:M(le)}),MakeMoveVec:q({type:G(K()),elements:M(_e)}),Upgrade:q({modules:M(pe),dependencies:M(le),package:le,ticket:_e}),$Intent:Te}),we=ue({ImmOrOwnedObject:be,SharedObject:q({objectId:le,initialSharedVersion:me,mutable:F()}),Receiving:be}),xe=ue({Object:we,Pure:q({bytes:pe}),UnresolvedPure:q({value:te()}),UnresolvedObject:q({objectId:le,version:W(G(me)),digest:W(G(K())),initialSharedVersion:W(G(me))})}),Oe=ue({Object:we,Pure:q({bytes:pe})}),Ie=ue({None:L(!0),Epoch:me}),Ce=q({version:L(2),sender:$(he),expiration:$(Ie),gasData:ge,inputs:M(xe),commands:M(Ee)}),Be={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>re(_e,e))),address:re(_e,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:re(_e,e),amounts:t.map((e=>re(_e,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:re(_e,e),sources:t.map((e=>re(_e,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:i})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e))),package:r,ticket:re(_e,i)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>re(_e,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>re(_e,e))):re(_e,t)]))),data:r}})},Se=/^vector<(.+)>$/,Pe=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class je{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(Se);if(r)return{vector:je.parseFromStr(r[1],t)};const s=e.match(Pe);if(s)return{struct:{address:t?de(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:je.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>je.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${je.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(je.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Ae=q({digest:K(),objectId:K(),version:ee([se(z(),D()),K(),J()])}),ke=ue({ImmOrOwned:Ae,Shared:q({objectId:le,initialSharedVersion:me,mutable:F()}),Receiving:Ae}),Ue=ue({Object:ke,Pure:M(se(z(),D()))}),Ne=ee([q({kind:L("Input"),index:se(z(),D()),value:te(),type:W(L("object"))}),q({kind:L("Input"),index:se(z(),D()),value:te(),type:L("pure")})]),De=ee([q({Epoch:se(z(),D())}),q({None:G(L(!0))})]),Ye=se(ee([z(),K(),J()]),N((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Re=ee([q({bool:G(L(!0))}),q({u8:G(L(!0))}),q({u64:G(L(!0))}),q({u128:G(L(!0))}),q({address:G(L(!0))}),q({signer:G(L(!0))}),q({vector:X((()=>Re))}),q({struct:X((()=>Ve))}),q({u16:G(L(!0))}),q({u32:G(L(!0))}),q({u256:G(L(!0))})]),Ve=q({address:K(),module:K(),name:K(),typeParams:M(Re)}),Me=q({budget:W(Ye),price:W(Ye),payment:W(M(Ae)),owner:W(K())}),Je=ee([Ne,q({kind:L("GasCoin")}),q({kind:L("Result"),index:se(z(),D())}),q({kind:L("NestedResult"),index:se(z(),D()),resultIndex:se(z(),D())})]),Fe=q({kind:L("MoveCall"),target:se(K(),N((e=>3===e.split("::").length))),typeArguments:M(K()),arguments:M(Je)}),Xe=q({kind:L("TransferObjects"),objects:M(Je),address:Je}),Le=q({kind:L("SplitCoins"),coin:Je,amounts:M(Je)}),Ge=q({kind:L("MergeCoins"),destination:Je,sources:M(Je)}),$e=q({kind:L("MakeMoveVec"),type:ee([q({Some:Re}),q({None:G(L(!0))})]),objects:M(Je)}),ze=ee([Fe,Xe,Le,Ge,q({kind:L("Publish"),modules:M(M(se(z(),D()))),dependencies:M(K())}),q({kind:L("Upgrade"),modules:M(M(se(z(),D()))),dependencies:M(K()),packageId:K(),ticket:Je}),$e]);function qe(e){const r=e.inputs.map(((e,r)=>{if(e.Object)return{kind:"Input",index:r,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:r,value:{Pure:Array.from(t(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:r,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:r,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:r,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:je.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>We(e,r)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:We(e.MergeCoins.destination,r),sources:e.MergeCoins.sources.map((e=>We(e,r)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>We(e,r)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(t(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:We(e.SplitCoins.coin,r),amounts:e.SplitCoins.amounts.map((e=>We(e,r)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>We(e,r))),address:We(e.TransferObjects.address,r)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(t(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:We(e.Upgrade.ticket,r)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function We(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function He(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Ke(e){return ee(Object.entries(e).map((([e,t])=>q({[e]:t}))))}q({version:L(1),sender:W(K()),expiration:$(De),gasConfig:Me,inputs:M(Ne),transactions:M(ze)});const Qe=Ke({GasCoin:L(!0),Input:se(z(),D()),Result:se(z(),D()),NestedResult:Q([se(z(),D()),se(z(),D())])}),Ze=q({budget:G(me),price:G(me),owner:G(he),payment:G(M(be))}),et=q({package:le,module:K(),function:K(),typeArguments:M(K()),arguments:M(Qe)}),tt=q({name:K(),inputs:H(K(),ee([Qe,M(Qe)])),data:H(K(),te())}),rt=Ke({MoveCall:et,TransferObjects:q({objects:M(Qe),address:Qe}),SplitCoins:q({coin:Qe,amounts:M(Qe)}),MergeCoins:q({destination:Qe,sources:M(Qe)}),Publish:q({modules:M(pe),dependencies:M(le)}),MakeMoveVec:q({type:G(K()),elements:M(Qe)}),Upgrade:q({modules:M(pe),dependencies:M(le),package:le,ticket:Qe}),$Intent:tt}),st=Ke({ImmOrOwnedObject:be,SharedObject:q({objectId:le,initialSharedVersion:me,mutable:F()}),Receiving:be}),it=Ke({Object:st,Pure:q({bytes:pe}),UnresolvedPure:q({value:te()}),UnresolvedObject:q({objectId:le,version:W(G(me)),digest:W(G(K())),initialSharedVersion:W(G(me))})}),nt=Ke({None:L(!0),Epoch:me}),at=q({version:L(2),sender:$(he),expiration:$(nt),gasData:Ze,inputs:M(it),commands:M(rt)}),ot=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?s(e):e.toBase64()}}},dt=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:de(e)}}}),ct=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:de(e)}}}),ut=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:de(e)}}}),ht={u8:e=>S({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>S({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>S({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>P({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>P({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>P({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>B({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new x({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(h(e)),...e}),bytes:(e,t)=>B({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new x({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=h(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new x({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>ht.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new x({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new x({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new x({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new x({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>ht.vector(ht.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new x({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},lt=ht.bytes(ne).transform({validate:e=>{const t="string"==typeof e?e:u(e);if(!t||!ae(de(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?c(de(e)):e,output:e=>de(u(e))}),pt=ht.vector(ht.u8()).transform({name:"ObjectDigest",input:e=>d(e),output:e=>n(new Uint8Array(e)),validate:e=>{if(32!==d(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),mt=ht.struct("SuiObjectRef",{objectId:lt,version:ht.u64(),digest:pt}),bt=ht.struct("SharedObjectRef",{objectId:lt,initialSharedVersion:ht.u64(),mutable:ht.bool()}),_t=ht.enum("ObjectArg",{ImmOrOwnedObject:mt,SharedObject:bt,Receiving:mt}),gt=ht.enum("CallArg",{Pure:ht.struct("Pure",{bytes:ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})}),Object:_t}),ft=ht.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:ht.lazy((()=>ft)),struct:ht.lazy((()=>It)),u16:null,u32:null,u256:null}),yt=ft.transform({input:e=>"string"==typeof e?je.parseFromStr(e,!0):e,output:e=>je.tagToString(e)}),vt=ht.enum("Argument",{GasCoin:null,Input:ht.u16(),Result:ht.u16(),NestedResult:ht.tuple([ht.u16(),ht.u16()])}),Tt=ht.struct("ProgrammableMoveCall",{package:lt,module:ht.string(),function:ht.string(),typeArguments:ht.vector(yt),arguments:ht.vector(vt)}),Et=ht.enum("Command",{MoveCall:Tt,TransferObjects:ht.struct("TransferObjects",{objects:ht.vector(vt),address:vt}),SplitCoins:ht.struct("SplitCoins",{coin:vt,amounts:ht.vector(vt)}),MergeCoins:ht.struct("MergeCoins",{destination:vt,sources:ht.vector(vt)}),Publish:ht.struct("Publish",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(lt)}),MakeMoveVec:ht.struct("MakeMoveVec",{type:function(e){return ht.enum("Option",{None:null,Some:e})}(yt).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:ht.vector(vt)}),Upgrade:ht.struct("Upgrade",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(lt),package:lt,ticket:vt})}),wt=ht.struct("ProgrammableTransaction",{inputs:ht.vector(gt),commands:ht.vector(Et)}),xt=ht.enum("TransactionKind",{ProgrammableTransaction:wt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ot=ht.enum("TransactionExpiration",{None:null,Epoch:ht.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})});const It=ht.struct("StructTag",{address:lt,module:ht.string(),name:ht.string(),typeParams:ht.vector(ft)}),Ct=ht.struct("GasData",{payment:ht.vector(mt),owner:lt,price:ht.u64(),budget:ht.u64()}),Bt=ht.struct("TransactionDataV1",{kind:xt,sender:lt,gasData:Ct,expiration:Ot}),St=ht.enum("TransactionData",{V1:Bt}),Pt=ht.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),jt=ht.enum("IntentVersion",{V0:null}),At=ht.enum("AppId",{Sui:null}),kt=ht.struct("Intent",{scope:Pt,version:jt,appId:At});function Ut(e){return ht.struct(`IntentMessage<${e.name}>`,{intent:kt,value:e})}const Nt=ht.enum("CompressedSignature",{ED25519:ht.fixedArray(64,ht.u8()),Secp256k1:ht.fixedArray(64,ht.u8()),Secp256r1:ht.fixedArray(64,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Dt=ht.enum("PublicKey",{ED25519:ht.fixedArray(32,ht.u8()),Secp256k1:ht.fixedArray(33,ht.u8()),Secp256r1:ht.fixedArray(33,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Yt=ht.struct("MultiSigPkMap",{pubKey:Dt,weight:ht.u8()}),Rt=ht.struct("MultiSigPublicKey",{pk_map:ht.vector(Yt),threshold:ht.u16()}),Vt=ht.struct("MultiSig",{sigs:ht.vector(Nt),bitmap:ht.u16(),multisig_pk:Rt}),Mt=ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))}),Jt=ht.struct("SenderSignedTransaction",{intentMessage:Ut(St),txSignatures:ht.vector(Mt)}),Ft=ht.vector(Jt,{name:"SenderSignedData"}),Xt=ht.enum("PackageUpgradeError",{UnableToFetchPackage:ht.struct("UnableToFetchPackage",{packageId:lt}),NotAPackage:ht.struct("NotAPackage",{objectId:lt}),IncompatibleUpgrade:null,DigestDoesNotMatch:ht.struct("DigestDoesNotMatch",{digest:ht.vector(ht.u8())}),UnknownUpgradePolicy:ht.struct("UnknownUpgradePolicy",{policy:ht.u8()}),PackageIDDoesNotMatch:ht.struct("PackageIDDoesNotMatch",{packageId:lt,ticketId:lt})}),Lt=ht.struct("ModuleId",{address:lt,name:ht.string()}),Gt=ht.struct("MoveLocation",{module:Lt,function:ht.u16(),instruction:ht.u16(),functionName:ht.option(ht.string())}),$t=ht.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:ht.struct("IndexOutOfBounds",{idx:ht.u16()}),SecondaryIndexOutOfBounds:ht.struct("SecondaryIndexOutOfBounds",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidResultArity:ht.struct("InvalidResultArity",{resultIdx:ht.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),zt=ht.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),qt=ht.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:ht.struct("MoveObjectTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),MovePackageTooBig:ht.struct("MovePackageTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),CircularObjectOwnership:ht.struct("CircularObjectOwnership",{object:lt}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:ht.option(Gt),MoveAbort:ht.tuple([Gt,ht.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:ht.struct("CommandArgumentError",{argIdx:ht.u16(),kind:$t}),TypeArgumentError:ht.struct("TypeArgumentError",{argumentIdx:ht.u16(),kind:zt}),UnusedValueWithoutDrop:ht.struct("UnusedValueWithoutDrop",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidPublicFunctionReturnType:ht.struct("InvalidPublicFunctionReturnType",{idx:ht.u16()}),InvalidTransferObject:null,EffectsTooLarge:ht.struct("EffectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:ht.struct("PackageUpgradeError",{upgradeError:Xt}),WrittenObjectsTooLarge:ht.struct("WrittenObjectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Wt=ht.enum("ExecutionStatus",{Success:null,Failed:ht.struct("ExecutionFailed",{error:qt,command:ht.option(ht.u64())})}),Ht=ht.struct("GasCostSummary",{computationCost:ht.u64(),storageCost:ht.u64(),storageRebate:ht.u64(),nonRefundableStorageFee:ht.u64()}),Kt=ht.enum("Owner",{AddressOwner:lt,ObjectOwner:lt,Shared:ht.struct("Shared",{initialSharedVersion:ht.u64()}),Immutable:null}),Qt=ht.struct("TransactionEffectsV1",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,modifiedAtVersions:ht.vector(ht.tuple([lt,ht.u64()])),sharedObjects:ht.vector(mt),transactionDigest:pt,created:ht.vector(ht.tuple([mt,Kt])),mutated:ht.vector(ht.tuple([mt,Kt])),unwrapped:ht.vector(ht.tuple([mt,Kt])),deleted:ht.vector(mt),unwrappedThenDeleted:ht.vector(mt),wrapped:ht.vector(mt),gasObject:ht.tuple([mt,Kt]),eventsDigest:ht.option(pt),dependencies:ht.vector(pt)}),Zt=ht.tuple([ht.u64(),pt]),er=ht.enum("ObjectIn",{NotExist:null,Exist:ht.tuple([Zt,Kt])}),tr=ht.enum("ObjectOut",{NotExist:null,ObjectWrite:ht.tuple([pt,Kt]),PackageWrite:Zt}),rr=ht.enum("IDOperation",{None:null,Created:null,Deleted:null}),sr=ht.struct("EffectsObjectChange",{inputState:er,outputState:tr,idOperation:rr}),ir=ht.enum("UnchangedSharedKind",{ReadOnlyRoot:Zt,MutateDeleted:ht.u64(),ReadDeleted:ht.u64(),Cancelled:ht.u64(),PerEpochConfig:null}),nr=ht.struct("TransactionEffectsV2",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,transactionDigest:pt,gasObjectIndex:ht.option(ht.u32()),eventsDigest:ht.option(pt),dependencies:ht.vector(pt),lamportVersion:ht.u64(),changedObjects:ht.vector(ht.tuple([lt,sr])),unchangedSharedObjects:ht.vector(ht.tuple([lt,ir])),auxDataDigest:ht.option(pt)}),ar=ht.enum("TransactionEffects",{V1:Qt,V2:nr}),or={...ht,U8:ht.u8(),U16:ht.u16(),U32:ht.u32(),U64:ht.u64(),U128:ht.u128(),U256:ht.u256(),ULEB128:ht.uleb128(),Bool:ht.bool(),String:ht.string(),Address:lt,AppId:At,Argument:vt,CallArg:gt,CompressedSignature:Nt,GasData:Ct,Intent:kt,IntentMessage:Ut,IntentScope:Pt,IntentVersion:jt,MultiSig:Vt,MultiSigPkMap:Yt,MultiSigPublicKey:Rt,ObjectArg:_t,ObjectDigest:pt,ProgrammableMoveCall:Tt,ProgrammableTransaction:wt,PublicKey:Dt,SenderSignedData:Ft,SenderSignedTransaction:Jt,SharedObjectRef:bt,StructTag:It,SuiObjectRef:mt,Command:Et,TransactionData:St,TransactionDataV1:Bt,TransactionExpiration:Ot,TransactionKind:xt,TypeTag:yt,TransactionEffects:ar},dr=(BigInt(1e9),ce("0x6"),"0x2::sui::SUI");function cr(e){if("string"==typeof e)switch(e){case"address":return or.Address;case"bool":return or.Bool;case"u8":return or.U8;case"u16":return or.U16;case"u32":return or.U32;case"u64":return or.U64;case"u128":return or.U128;case"u256":return or.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return or.vector(or.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=cr(e.vector);return t?or.vector(t):null}if("datatype"in e){const t=de(e.datatype.package);if(t===de("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=cr(e.datatype.typeParameters[0]);return t?or.vector(t):null}}if(t===de("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return or.Address}return null}function ur(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:ur(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(ur)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}ce("0x5");async function hr(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{lr(t,or.U64,e)}));break;case"TransferObjects":lr(t.TransferObjects.address,or.Address,e)}}));const a=new Map;if(n.size>0){const e=br(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:ur(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:ur(e.MutableReference)}:{ref:null,body:ur(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&de(t.package)===de("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=cr(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=ot(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>ce(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>br(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=de(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=ct({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:pr(e,t)}):mr(e,t)&&(s=ut({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??dt({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await br(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await br(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await br(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:dr})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>re(be,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function lr(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=ot(t.serialize(s.UnresolvedPure.value)))}function pr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function mr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function br(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function _r(e){function t(t,r){if("string"==typeof t)return e(gr(t).serialize(r));if(t instanceof Uint8Array||I(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(or.U8.serialize(t)),t.u16=t=>e(or.U16.serialize(t)),t.u32=t=>e(or.U32.serialize(t)),t.u64=t=>e(or.U64.serialize(t)),t.u128=t=>e(or.U128.serialize(t)),t.u256=t=>e(or.U256.serialize(t)),t.bool=t=>e(or.Bool.serialize(t)),t.string=t=>e(or.String.serialize(t)),t.address=t=>e(or.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(or.vector(gr(t)).serialize(r)),t.option=(t,r)=>e(or.option(gr(t)).serialize(r)),t}function gr(e){switch(e){case"u8":return or.u8();case"u16":return or.u16();case"u32":return or.u32();case"u64":return or.u64();case"u128":return or.u128();case"u256":return or.u256();case"bool":return or.bool();case"string":return or.string();case"id":case"address":return or.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?or.vector(gr(r)):or.option(gr(r))}throw new Error(`Invalid Pure type name: ${e}`)}function fr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function yr(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function vr(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");fr(e.outputLen),fr(e.blockLen)}function Tr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Er(e,t){yr(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function wr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function xr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Or=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Ir(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Cr=Or?e=>e:e=>Ir(e);function Br(e){for(let t=0;t<e.length;t++)e[t]=Ir(e[t])}const Sr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Pr(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function jr(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),yr(e),e}class Ar{clone(){return this._cloneInto()}}function kr(e){const t=t=>e().update(jr(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ur(e){const t=(t,r)=>e(r).update(jr(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const Nr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Dr extends Ar{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,fr(e),fr(t),fr(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=wr(this.buffer)}update(e){Tr(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=jr(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Or||Br(s),this.compress(s,0,!1),Or||Br(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Or||Br(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Or||Br(e)}}return this}digestInto(e){Tr(this),Er(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Or||Br(r),this.compress(r,0,!0),Or||Br(r);const s=wr(e);this.get().forEach(((e,t)=>s[t]=Cr(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Yr=BigInt(2**32-1),Rr=BigInt(32);function Vr(e,t=!1){return t?{h:Number(e&Yr),l:Number(e>>Rr&Yr)}:{h:0|Number(e>>Rr&Yr),l:0|Number(e&Yr)}}const Mr={fromBig:Vr,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Vr(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Rr|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Jr=Mr,Fr=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Xr=new Uint32Array(32);function Lr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],l=Xr[2*r],p=Xr[2*r+1],m=Xr[2*s],b=Xr[2*s+1],_=Jr.add3L(d,u,a);c=Jr.add3H(_,c,h,o),d=0|_,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Jr.rotr32H(b,m),Dl:Jr.rotr32L(b,m)}),({h:p,l}=Jr.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Jr.rotrSH(h,u,24),Bl:Jr.rotrSL(h,u,24)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=l,Xr[2*r+1]=p,Xr[2*s]=m,Xr[2*s+1]=b}function Gr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],l=Xr[2*r],p=Xr[2*r+1],m=Xr[2*s],b=Xr[2*s+1],_=Jr.add3L(d,u,a);c=Jr.add3H(_,c,h,o),d=0|_,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Jr.rotrSH(b,m,16),Dl:Jr.rotrSL(b,m,16)}),({h:p,l}=Jr.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Jr.rotrBH(h,u,63),Bl:Jr.rotrBL(h,u,63)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=l,Xr[2*r+1]=p,Xr[2*s]=m,Xr[2*s+1]=b}class $r extends Dr{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Fr[0],this.v0h=0|Fr[1],this.v1l=0|Fr[2],this.v1h=0|Fr[3],this.v2l=0|Fr[4],this.v2h=0|Fr[5],this.v3l=0|Fr[6],this.v3h=0|Fr[7],this.v4l=0|Fr[8],this.v4h=0|Fr[9],this.v5l=0|Fr[10],this.v5h=0|Fr[11],this.v6l=0|Fr[12],this.v6h=0|Fr[13],this.v7l=0|Fr[14],this.v7h=0|Fr[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=wr(jr(e.salt));this.v4l^=Cr(t[0]),this.v4h^=Cr(t[1]),this.v5l^=Cr(t[2]),this.v5h^=Cr(t[3])}if(e.personalization){const t=wr(jr(e.personalization));this.v6l^=Cr(t[0]),this.v6h^=Cr(t[1]),this.v7l^=Cr(t[2]),this.v7h^=Cr(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(jr(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:l,v6h:p,v7l:m,v7h:b}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b]}set(e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|l,this.v6h=0|p,this.v7l=0|m,this.v7h=0|b}compress(e,t,r){this.get().forEach(((e,t)=>Xr[t]=e)),Xr.set(Fr,16);let{h:s,l:i}=Jr.fromBig(BigInt(this.length));Xr[24]=Fr[8]^i,Xr[25]=Fr[9]^s,r&&(Xr[28]=~Xr[28],Xr[29]=~Xr[29]);let n=0;const a=Nr;for(let r=0;r<12;r++)Lr(0,4,8,12,e,t+2*a[n++]),Gr(0,4,8,12,e,t+2*a[n++]),Lr(1,5,9,13,e,t+2*a[n++]),Gr(1,5,9,13,e,t+2*a[n++]),Lr(2,6,10,14,e,t+2*a[n++]),Gr(2,6,10,14,e,t+2*a[n++]),Lr(3,7,11,15,e,t+2*a[n++]),Gr(3,7,11,15,e,t+2*a[n++]),Lr(0,5,10,15,e,t+2*a[n++]),Gr(0,5,10,15,e,t+2*a[n++]),Lr(1,6,11,12,e,t+2*a[n++]),Gr(1,6,11,12,e,t+2*a[n++]),Lr(2,7,8,13,e,t+2*a[n++]),Gr(2,7,8,13,e,t+2*a[n++]),Lr(3,4,9,14,e,t+2*a[n++]),Gr(3,4,9,14,e,t+2*a[n++]);this.v0l^=Xr[0]^Xr[16],this.v0h^=Xr[1]^Xr[17],this.v1l^=Xr[2]^Xr[18],this.v1h^=Xr[3]^Xr[19],this.v2l^=Xr[4]^Xr[20],this.v2h^=Xr[5]^Xr[21],this.v3l^=Xr[6]^Xr[22],this.v3h^=Xr[7]^Xr[23],this.v4l^=Xr[8]^Xr[24],this.v4h^=Xr[9]^Xr[25],this.v5l^=Xr[10]^Xr[26],this.v5h^=Xr[11]^Xr[27],this.v6l^=Xr[12]^Xr[28],this.v6h^=Xr[13]^Xr[29],this.v7l^=Xr[14]^Xr[30],this.v7h^=Xr[15]^Xr[31],Xr.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const zr=Ur((e=>new $r(e)));function qr(e){return de(e).replace("0x","")}class Wr{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=or.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=or.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new Wr(re(Ce,e)):new Wr(re(Ce,function(e){return re(Ce,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(V(Ue,e.value)){const t=re(Ue,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:s(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?je.tagToString(e.type.Some):null,elements:e.objects.map((e=>He(e)))}};case"MergeCoins":return{MergeCoins:{destination:He(e.destination),sources:e.sources.map((e=>He(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>He(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:He(e.coin),amounts:e.amounts.map((e=>He(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>He(e))),address:He(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:He(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),zr(s,{dkLen:32})}(0,e);return n(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return or.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:qr(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:qr(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return or.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return Wr.getDigestFromBytes(e)}snapshot(){return re(Ce,this)}}function Hr(e){return"string"==typeof e?de(e):e.Object?e.Object.ImmOrOwnedObject?de(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?de(e.Object.Receiving.objectId):de(e.Object.SharedObject.objectId):e.UnresolvedObject?de(e.UnresolvedObject.objectId):void 0}var Kr,Qr,Zr,es,ts,rs,ss,is,ns,as=e=>{throw TypeError(e)},os=(e,t,r)=>t.has(e)||as("Cannot "+r),ds=(e,t,r)=>(os(e,t,"read from private field"),r?r.call(e):t.get(e)),cs=(e,t,r)=>t.has(e)?as("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),us=(e,t,r,s)=>(os(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),hs=(e,t,r)=>(os(e,t,"access private method"),r);const ls=Symbol.for("@mysten/transaction");function ps(e){return!!e&&"object"==typeof e&&!0===e[ls]}const ms={buildPlugins:[],serializationPlugins:[]},bs=Symbol.for("@mysten/transaction/registry");function _s(){try{const e=globalThis;return e[bs]||(e[bs]=ms),e[bs]}catch(e){return ms}}Kr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,es=new WeakMap,ts=new WeakSet,rs=function(e){return I(e)?this.pure(e):hs(this,ts,ss).call(this,e)},ss=function(e){return re(_e,"function"==typeof e?e(this):e)},is=async function(e){if(!e.onlyTransactionKind&&!ds(this,es).sender)throw new Error("Missing transaction sender");await hs(this,ts,ns).call(this,[...ds(this,Qr),hr],e)},ns=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(ds(this,es),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let gs=class e{constructor(){cs(this,ts),cs(this,Kr),cs(this,Qr),cs(this,Zr,new Map),cs(this,es),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&V(_e,e))return e;const t=Hr(e),r=ds(this,es).inputs.find((e=>t===Hr(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:ds(this,es).inputs.indexOf(r),type:"object"}:ds(this,es).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:de(e)}}:e)}));const e=_s();us(this,es,new Wr),us(this,Qr,[...e.buildPlugins]),us(this,Kr,[...e.serializationPlugins])}static fromKind(r){const s=new e;return us(s,es,Wr.fromKindBytes("string"==typeof r?t(r):r)),s}static from(r){const s=new e;return ps(r)?us(s,es,new Wr(r.getData())):"string"==typeof r&&r.startsWith("{")?us(s,es,Wr.restore(JSON.parse(r))):us(s,es,Wr.fromBytes("string"==typeof r?t(r):r)),s}static registerGlobalSerializationPlugin(e){_s().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){_s().buildPlugins.push(e)}addSerializationPlugin(e){ds(this,Kr).push(e)}addBuildPlugin(e){ds(this,Qr).push(e)}addIntentResolver(e,t){if(ds(this,Zr).has(e)&&ds(this,Zr).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);ds(this,Zr).set(e,t)}setSender(e){ds(this,es).sender=e}setSenderIfNotSet(e){ds(this,es).sender||(ds(this,es).sender=e)}setExpiration(e){ds(this,es).expiration=e?re(Ie,e):null}setGasPrice(e){ds(this,es).gasConfig.price=String(e)}setGasBudget(e){ds(this,es).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==ds(this,es).gasData.budget&&(ds(this,es).gasConfig.budget=String(e))}setGasOwner(e){ds(this,es).gasConfig.owner=e}setGasPayment(e){ds(this,es).gasConfig.payment=e.map((e=>re(be,e)))}get blockData(){return qe(ds(this,es).snapshot())}getData(){return ds(this,es).snapshot()}get[ls](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:_r((e=>I(e)?ds(this,es).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):ds(this,es).addInput("pure",V(Oe,e)?re(Oe,e):e instanceof Uint8Array?ot(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(dt(...e))}receivingRef(...e){return this.object(ut(...e))}sharedObjectRef(...e){return this.object(ct(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(ds(this,es).commands.push(e)-1)}splitCoins(e,t){return this.add(Be.SplitCoins("string"==typeof e?this.object(e):hs(this,ts,ss).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):hs(this,ts,rs).call(this,e)))))}mergeCoins(e,t){return this.add(Be.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Be.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Be.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Be.MoveCall({...t,arguments:e?.map((e=>hs(this,ts,rs).call(this,e)))}))}transferObjects(e,t){return this.add(Be.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):hs(this,ts,rs).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Be.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(qe(ds(this,es).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(re(at,ds(this,es).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await hs(this,ts,is).call(this,e),ds(this,es).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await hs(this,ts,is).call(this,e),ds(this,es).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of ds(this,es).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...ds(this,Kr)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!ds(this,Zr).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(ds(this,Zr).get(s))}await hs(this,ts,ns).call(this,r,e)}};const fs=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,ys=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,vs={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class Ts extends Error{}class Es extends Ts{constructor(e,t){super(e),this.code=t,this.type=vs[t]??"ServerError"}}class ws extends Ts{constructor(e,t,r){super(e),this.status=t,this.statusText=r}}var xs,Os,Is,Cs,Bs,Ss,Ps,js,As,ks=e=>{throw TypeError(e)},Us=(e,t,r)=>t.has(e)||ks("Cannot "+r),Ns=(e,t,r)=>(Us(e,t,"read from private field"),r?r.call(e):t.get(e)),Ds=(e,t,r)=>t.has(e)?ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ys=(e,t,r,s)=>(Us(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),Rs=(e,t,r)=>(Us(e,t,"access private method"),r);const Vs={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Ms{constructor(e,t={}){if(Ds(this,Ps),Ds(this,xs,0),Ds(this,Os,0),Ds(this,Is,null),Ds(this,Cs,null),Ds(this,Bs,new Set),Ds(this,Ss,new Map),this.endpoint=e,this.options={...Vs,...t},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}(this.endpoint))}async makeRequest(e,t){const r=await Rs(this,Ps,js).call(this);return new Promise(((s,i)=>{Ys(this,xs,Ns(this,xs)+1),Ns(this,Ss).set(Ns(this,xs),{resolve:s,reject:i,timeout:setTimeout((()=>{Ns(this,Ss).delete(Ns(this,xs)),i(new Error(`Request timeout: ${e}`))}),this.options.callTimeout)}),r.send(JSON.stringify({jsonrpc:"2.0",id:Ns(this,xs),method:e,params:t}))})).then((({error:e,result:t})=>{if(e)throw new Es(e.message,e.code);return t}))}async subscribe(e){const t=new Js(e);return Ns(this,Bs).add(t),await t.subscribe(this),()=>t.unsubscribe(this)}}xs=new WeakMap,Os=new WeakMap,Is=new WeakMap,Cs=new WeakMap,Bs=new WeakMap,Ss=new WeakMap,Ps=new WeakSet,js=function(){return Ns(this,Cs)||Ys(this,Cs,new Promise((e=>{Ns(this,Is)?.close(),Ys(this,Is,new this.options.WebSocketConstructor(this.endpoint)),Ns(this,Is).addEventListener("open",(()=>{Ys(this,Os,0),e(Ns(this,Is))})),Ns(this,Is).addEventListener("close",(()=>{var e,t;(e=this,t=Os,{set _(r){Ys(e,t,r,undefined)},get _(){return Ns(e,t,undefined)}})._++,Ns(this,Os)<=this.options.maxReconnects&&setTimeout((()=>{Rs(this,Ps,As).call(this)}),this.options.reconnectTimeout)})),Ns(this,Is).addEventListener("message",(({data:e})=>{let t;try{t=JSON.parse(e)}catch(t){return void console.error(new Error(`Failed to parse RPC message: ${e}`,{cause:t}))}if("id"in t&&null!=t.id&&Ns(this,Ss).has(t.id)){const{resolve:e,timeout:r}=Ns(this,Ss).get(t.id);clearTimeout(r),e(t)}else if("params"in t){const{params:e}=t;Ns(this,Bs).forEach((t=>{t.subscriptionId===e.subscription&&e.subscription===t.subscriptionId&&t.onMessage(e.result)}))}}))}))),Ns(this,Cs)},As=async function(){return Ns(this,Is)?.close(),Ys(this,Cs,null),Promise.allSettled([...Ns(this,Bs)].map((e=>e.subscribe(this))))};class Js{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:t}=this;return this.subscribed=!1,null!=t&&(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[t]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const t=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=t)}}var Fs,Xs,Ls,Gs,$s,zs=e=>{throw TypeError(e)},qs=(e,t,r)=>t.has(e)||zs("Cannot "+r),Ws=(e,t,r)=>(qs(e,t,"read from private field"),r?r.call(e):t.get(e)),Hs=(e,t,r)=>t.has(e)?zs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ks=(e,t,r,s)=>(qs(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Qs{constructor(e){Hs(this,Gs),Hs(this,Fs,0),Hs(this,Xs),Hs(this,Ls),Ks(this,Xs,e)}fetch(e,t){const r=Ws(this,Xs).fetch??fetch;if(!r)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return r(e,t)}async request(e){Ks(this,Fs,Ws(this,Fs)+1);const t=await this.fetch(Ws(this,Xs).rpc?.url??Ws(this,Xs).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":"1.7.0","Client-Target-Api-Version":"1.32.0",...Ws(this,Xs).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:Ws(this,Fs),method:e.method,params:e.params})});if(!t.ok)throw new ws(`Unexpected status code: ${t.status}`,t.status,t.statusText);const r=await t.json();if("error"in r&&null!=r.error)throw new Es(r.error.message,r.error.code);return r.result}async subscribe(e){const t=await(r=Gs,s=$s,qs(this,r,"access private method"),s).call(this).subscribe(e);var r,s;return async()=>!!await t()}}Fs=new WeakMap,Xs=new WeakMap,Ls=new WeakMap,Gs=new WeakSet,$s=function(){if(!Ws(this,Ls)){const e=Ws(this,Xs).WebSocketConstructor??WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");Ks(this,Ls,new Ms(Ws(this,Xs).websocket?.url??Ws(this,Xs).url,{WebSocketConstructor:e,...Ws(this,Xs).websocket}))}return Ws(this,Ls)};const Zs=Symbol.for("@mysten/SuiClient");class ei{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Qs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,t){return await this.transport.request({method:e,params:t})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!oe(ce(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Object id ${e}`)})),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,"descending"===(e.order||"descending")]})}async getTransactionBlock(e){if(!ie(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach((e=>{if(!ie(e))throw new Error(`Invalid Transaction digest ${e}`)})),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock({transactionBlock:e,signature:t,options:r,requestType:i}){const n=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof e?e:s(e),Array.isArray(t)?t:[t],r]});if("WaitForLocalExecution"===i)try{await this.waitForTransaction({digest:n.digest})}catch(e){}return n}async signAndExecuteTransaction({transaction:e,signer:t,...r}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(t.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:n}=await t.signTransaction(s);return this.executeTransactionBlock({transactionBlock:n,signature:i,...r})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Stake id ${e}`)})),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,"descending"===(e.order||"descending")]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){let t;if(ps(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),t=s(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof e.transactionBlock)t=e.transactionBlock;else{if(!(e.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");t=s(e.transactionBlock)}return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,t,e.gasPrice?.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof e.transactionBlock?e.transactionBlock:s(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!oe(ce(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e?.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e?.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e?.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"});return u(d(e.digest).slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames({format:e="dot",...t}){const{nextCursor:r,hasNextPage:s,data:i}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[t.address,t.cursor,t.limit]});return{hasNextPage:s,nextCursor:r,data:i.map((t=>function(e,t="at"){const r=e.toLowerCase();let s;if(r.includes("@")){if(!fs.test(r))throw new Error(`Invalid SuiNS name ${e}`);const[t,i]=r.split("@");s=[...t?t.split("."):[],i]}else{if(!ys.test(r))throw new Error(`Invalid SuiNS name ${e}`);s=r.split(".").slice(0,-1)}return"dot"===t?`${s.join(".")}.sui`:`${s.slice(0,-1).join(".")}@${s[s.length-1]}`}(t,e)))}}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e?.version]})}async waitForTransaction({signal:e,timeout:t=6e4,pollInterval:r=2e3,...s}){const i=AbortSignal.timeout(t),n=new Promise(((e,t)=>{i.addEventListener("abort",(()=>t(i.reason)))}));for(n.catch((()=>{}));!i.aborted;){e?.throwIfAborted();try{return await this.getTransactionBlock(s)}catch(e){await Promise.race([new Promise((e=>setTimeout(e,r))),n])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}var ti=a(601),ri=a(333);function si(e,t){return or.IntentMessage(or.fixedArray(t.length,or.u8())).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}const ii={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},ni={ED25519:32,Secp256k1:33,Secp256r1:33},ai={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function oi(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}class di{equals(e){return oi(this.toRawBytes(),e.toRawBytes())}toBase64(){return s(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return s(this.toSuiBytes())}verifyWithIntent(e,t,r){const s=si(r,e),i=zr(s,{dkLen:32});return this.verify(i,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(or.vector(or.u8()).serialize(e).toBytes(),t,"PersonalMessage")}verifyTransaction(e,t){return this.verifyWithIntent(e,t,"TransactionData")}toSuiBytes(){const e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return de(function(e){yr(e);let t="";for(let r=0;r<e.length;r++)t+=Sr[e[r]];return t}(zr(this.toSuiBytes(),{dkLen:32})).slice(0,2*ne))}}function ci(e){return 9===e||32===e}const ui=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function hi(e){return li[e.charCodeAt(0)]}const li=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];function pi(e,t){if(!Boolean(e))throw new Error(t)}function mi(e){return bi(e,[])}function bi(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const r=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:bi(t,r)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const r=Math.min(10,e.length),s=e.length-r,i=[];for(let s=0;s<r;++s)i.push(bi(e[s],t));return 1===s?i.push("... 1 more item"):s>1&&i.push(`... ${s} more items`),"["+i.join(", ")+"]"}(e,r);return function(e,t){const r=Object.entries(e);if(0===r.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const s=r.map((([e,r])=>e+": "+bi(r,t)));return"{ "+s.join(", ")+" }"}(e,r)}(e,t);default:return String(e)}}Symbol.toStringTag,Symbol.toStringTag;const _i={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},gi=new Set(Object.keys(_i));function fi(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&gi.has(t)}var yi,vi,Ti;!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(yi||(yi={})),(Ti=vi||(vi={})).NAME="Name",Ti.DOCUMENT="Document",Ti.OPERATION_DEFINITION="OperationDefinition",Ti.VARIABLE_DEFINITION="VariableDefinition",Ti.SELECTION_SET="SelectionSet",Ti.FIELD="Field",Ti.ARGUMENT="Argument",Ti.FRAGMENT_SPREAD="FragmentSpread",Ti.INLINE_FRAGMENT="InlineFragment",Ti.FRAGMENT_DEFINITION="FragmentDefinition",Ti.VARIABLE="Variable",Ti.INT="IntValue",Ti.FLOAT="FloatValue",Ti.STRING="StringValue",Ti.BOOLEAN="BooleanValue",Ti.NULL="NullValue",Ti.ENUM="EnumValue",Ti.LIST="ListValue",Ti.OBJECT="ObjectValue",Ti.OBJECT_FIELD="ObjectField",Ti.DIRECTIVE="Directive",Ti.NAMED_TYPE="NamedType",Ti.LIST_TYPE="ListType",Ti.NON_NULL_TYPE="NonNullType",Ti.SCHEMA_DEFINITION="SchemaDefinition",Ti.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",Ti.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",Ti.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",Ti.FIELD_DEFINITION="FieldDefinition",Ti.INPUT_VALUE_DEFINITION="InputValueDefinition",Ti.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",Ti.UNION_TYPE_DEFINITION="UnionTypeDefinition",Ti.ENUM_TYPE_DEFINITION="EnumTypeDefinition",Ti.ENUM_VALUE_DEFINITION="EnumValueDefinition",Ti.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",Ti.DIRECTIVE_DEFINITION="DirectiveDefinition",Ti.SCHEMA_EXTENSION="SchemaExtension",Ti.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",Ti.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",Ti.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",Ti.UNION_TYPE_EXTENSION="UnionTypeExtension",Ti.ENUM_TYPE_EXTENSION="EnumTypeExtension",Ti.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";const Ei=Object.freeze({});function wi(e,t){const r=e[t];return"object"==typeof r?r:"function"==typeof r?{enter:r,leave:void 0}:{enter:e.enter,leave:e.leave}}const xi={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>Oi(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Ci("(",Oi(e.variableDefinitions,", "),")"),r=Oi([e.operation,Oi([e.name,t]),Oi(e.directives," ")]," ");return("query"===r?"":r+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:r,directives:s})=>e+": "+t+Ci(" = ",r)+Ci(" ",Oi(s," "))},SelectionSet:{leave:({selections:e})=>Ii(e)},Field:{leave({alias:e,name:t,arguments:r,directives:s,selectionSet:i}){const n=Ci("",e,": ")+t;let a=n+Ci("(",Oi(r,", "),")");return a.length>80&&(a=n+Ci("(\n",Bi(Oi(r,"\n")),"\n)")),Oi([a,Oi(s," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Ci(" ",Oi(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:r})=>Oi(["...",Ci("on ",e),Oi(t," "),r]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:r,directives:s,selectionSet:i})=>`fragment ${e}${Ci("(",Oi(r,", "),")")} on ${t} ${Ci("",Oi(s," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e){const t=e.replace(/"""/g,'\\"""'),r=t.split(/\r\n|[\n\r]/g),s=1===r.length,i=r.length>1&&r.slice(1).every((e=>0===e.length||ci(e.charCodeAt(0)))),n=t.endsWith('\\"""'),a=e.endsWith('"')&&!n,o=e.endsWith("\\"),d=a||o,c=!s||e.length>70||d||i||n;let u="";const h=s&&ci(e.charCodeAt(0));return(c&&!h||i)&&(u+="\n"),u+=t,(c||d)&&(u+="\n"),'"""'+u+'"""'}(e):`"${e.replace(ui,hi)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+Oi(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+Oi(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Ci("(",Oi(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:r})=>Ci("",e,"\n")+Oi(["schema",Oi(t," "),Ii(r)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi(["scalar",t,Oi(r," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["type",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:r,type:s,directives:i})=>Ci("",e,"\n")+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+": "+s+Ci(" ",Oi(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:r,defaultValue:s,directives:i})=>Ci("",e,"\n")+Oi([t+": "+r,Ci("= ",s),Oi(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["interface",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:r,types:s})=>Ci("",e,"\n")+Oi(["union",t,Oi(r," "),Ci("= ",Oi(s," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:r,values:s})=>Ci("",e,"\n")+Oi(["enum",t,Oi(r," "),Ii(s)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi([t,Oi(r," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:r,fields:s})=>Ci("",e,"\n")+Oi(["input",t,Oi(r," "),Ii(s)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:r,repeatable:s,locations:i})=>Ci("",e,"\n")+"directive @"+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+(s?" repeatable":"")+" on "+Oi(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>Oi(["extend schema",Oi(e," "),Ii(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>Oi(["extend scalar",e,Oi(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend type",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend interface",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:r})=>Oi(["extend union",e,Oi(t," "),Ci("= ",Oi(r," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:r})=>Oi(["extend enum",e,Oi(t," "),Ii(r)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:r})=>Oi(["extend input",e,Oi(t," "),Ii(r)]," ")}};function Oi(e,t=""){var r;return null!==(r=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==r?r:""}function Ii(e){return Ci("{\n",Bi(Oi(e,"\n")),"\n}")}function Ci(e,t,r=""){return null!=t&&""!==t?e+t+r:""}function Bi(e){return Ci(" ",e.replace(/\n/g,"\n "))}function Si(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}var Pi,ji,Ai,ki,Ui=e=>{throw TypeError(e)},Ni=(e,t,r)=>t.has(e)||Ui("Cannot "+r),Di=(e,t,r)=>(Ni(e,t,"read from private field"),r?r.call(e):t.get(e)),Yi=(e,t,r)=>t.has(e)?Ui("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ri=(e,t,r,s)=>(Ni(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Vi extends Error{}class Mi{constructor({url:e,fetch:t=fetch,headers:r={},queries:s={}}){Yi(this,Pi),Yi(this,ji),Yi(this,Ai),Yi(this,ki),Ri(this,Pi,e),Ri(this,ji,s),Ri(this,Ai,r),Ri(this,ki,((...e)=>t(...e)))}async query(e){const t=await Di(this,ki).call(this,Di(this,Pi),{method:"POST",headers:{"Content-Type":"application/json",...Di(this,Ai)},body:JSON.stringify({query:"string"==typeof e.query?String(e.query):(r=e.query,function(e,t,r=_i){const s=new Map;for(const e of Object.values(vi))s.set(e,wi(t,e));let i,n,a,o=Array.isArray(e),d=[e],c=-1,u=[],h=e;const l=[],p=[];do{c++;const e=c===d.length,g=e&&0!==u.length;if(e){if(n=0===p.length?void 0:l[l.length-1],h=a,a=p.pop(),g)if(o){h=h.slice();let e=0;for(const[t,r]of u){const s=t-e;null===r?(h.splice(s,1),e++):h[s]=r}}else{h=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));for(const[e,t]of u)h[e]=t}c=i.index,d=i.keys,u=i.edits,o=i.inArray,i=i.prev}else if(a){if(n=o?c:d[c],h=a[n],null==h)continue;l.push(n)}let f;if(!Array.isArray(h)){var m,b;fi(h)||pi(!1,`Invalid AST Node: ${mi(h)}.`);const r=e?null===(m=s.get(h.kind))||void 0===m?void 0:m.leave:null===(b=s.get(h.kind))||void 0===b?void 0:b.enter;if(f=null==r?void 0:r.call(t,h,n,a,l,p),f===Ei)break;if(!1===f){if(!e){l.pop();continue}}else if(void 0!==f&&(u.push([n,f]),!e)){if(!fi(f)){l.pop();continue}h=f}}var _;void 0===f&&g&&u.push([n,h]),e?l.pop():(i={inArray:o,index:c,keys:d,edits:u,prev:i},o=Array.isArray(h),d=o?h:null!==(_=r[h.kind])&&void 0!==_?_:[],c=-1,u=[],a&&p.push(a),a=h)}while(void 0!==i);return 0!==u.length?u[u.length-1][1]:e}(r,xi)),variables:e.variables,extensions:e.extensions,operationName:e.operationName})});var r;if(!t.ok)throw new Vi(`GraphQL request failed: ${t.statusText} (${t.status})`);return await t.json()}async execute(e,t){return this.query({...t,query:Di(this,ji)[e]})}}Pi=new WeakMap,ji=new WeakMap,Ai=new WeakMap,ki=new WeakMap;var Ji,Fi,Xi="Document",Li="FragmentDefinition";class Gi extends Error{constructor(e,t,r,s,i,n,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),n&&(this.originalError=n);var o=a;if(!o&&n){var d=n.extensions;d&&"object"==typeof d&&(o=d)}this.extensions=o||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}function $i(e){return new Gi(`Syntax Error: Unexpected token at ${Fi} in ${e}`)}function zi(e){if(e.lastIndex=Fi,e.test(Ji))return Ji.slice(Fi,Fi=e.lastIndex)}var qi=/ +(?=[^\s])/y;function Wi(e){for(var t=e.split("\n"),r="",s=0,i=0,n=t.length-1,a=0;a<t.length;a++)qi.lastIndex=0,qi.test(t[a])&&(a&&(!s||qi.lastIndex<s)&&(s=qi.lastIndex),i=i||a,n=a);for(var o=i;o<=n;o++)o!==i&&(r+="\n"),r+=t[o].slice(s).replace(/\\"""/g,'"""');return r}function Hi(){for(var e=0|Ji.charCodeAt(Fi++);9===e||10===e||13===e||32===e||35===e||44===e||65279===e;e=0|Ji.charCodeAt(Fi++))if(35===e)for(;10!==(e=Ji.charCodeAt(Fi++))&&13!==e;);Fi--}function Ki(){for(var e=Fi,t=0|Ji.charCodeAt(Fi++);t>=48&&t<=57||t>=65&&t<=90||95===t||t>=97&&t<=122;t=0|Ji.charCodeAt(Fi++));if(e===Fi-1)throw $i("Name");var r=Ji.slice(e,--Fi);return Hi(),r}function Qi(){return{kind:"Name",value:Ki()}}var Zi=/(?:"""|(?:[\s\S]*?[^\\])""")/y,en=/(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;function tn(e){var t;switch(Ji.charCodeAt(Fi)){case 91:Fi++,Hi();for(var r=[];93!==Ji.charCodeAt(Fi);)r.push(tn(e));return Fi++,Hi(),{kind:"ListValue",values:r};case 123:Fi++,Hi();for(var s=[];125!==Ji.charCodeAt(Fi);){var i=Qi();if(58!==Ji.charCodeAt(Fi++))throw $i("ObjectField");Hi(),s.push({kind:"ObjectField",name:i,value:tn(e)})}return Fi++,Hi(),{kind:"ObjectValue",fields:s};case 36:if(e)throw $i("Variable");return Fi++,{kind:"Variable",name:Qi()};case 34:if(34===Ji.charCodeAt(Fi+1)&&34===Ji.charCodeAt(Fi+2)){if(Fi+=3,null==(t=zi(Zi)))throw $i("StringValue");return Hi(),{kind:"StringValue",value:Wi(t.slice(0,-3)),block:!0}}var n,a=Fi;Fi++;var o=!1;for(n=0|Ji.charCodeAt(Fi++);92===n&&(Fi++,o=!0)||10!==n&&13!==n&&34!==n&&n;n=0|Ji.charCodeAt(Fi++));if(34!==n)throw $i("StringValue");return t=Ji.slice(a,Fi),Hi(),{kind:"StringValue",value:o?JSON.parse(t):t.slice(1,-1),block:!1};case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:for(var d,c=Fi++;(d=0|Ji.charCodeAt(Fi++))>=48&&d<=57;);var u=Ji.slice(c,--Fi);if(46===(d=Ji.charCodeAt(Fi))||69===d||101===d){if(null==(t=zi(en)))throw $i("FloatValue");return Hi(),{kind:"FloatValue",value:u+t}}return Hi(),{kind:"IntValue",value:u};case 110:if(117===Ji.charCodeAt(Fi+1)&&108===Ji.charCodeAt(Fi+2)&&108===Ji.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"NullValue"};break;case 116:if(114===Ji.charCodeAt(Fi+1)&&117===Ji.charCodeAt(Fi+2)&&101===Ji.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"BooleanValue",value:!0};break;case 102:if(97===Ji.charCodeAt(Fi+1)&&108===Ji.charCodeAt(Fi+2)&&115===Ji.charCodeAt(Fi+3)&&101===Ji.charCodeAt(Fi+4))return Fi+=5,Hi(),{kind:"BooleanValue",value:!1}}return{kind:"EnumValue",value:Ki()}}function rn(e){if(40===Ji.charCodeAt(Fi)){var t=[];Fi++,Hi();do{var r=Qi();if(58!==Ji.charCodeAt(Fi++))throw $i("Argument");Hi(),t.push({kind:"Argument",name:r,value:tn(e)})}while(41!==Ji.charCodeAt(Fi));return Fi++,Hi(),t}}function sn(e){if(64===Ji.charCodeAt(Fi)){var t=[];do{Fi++,t.push({kind:"Directive",name:Qi(),arguments:rn(e)})}while(64===Ji.charCodeAt(Fi));return t}}function nn(){for(var e=0;91===Ji.charCodeAt(Fi);)e++,Fi++,Hi();var t={kind:"NamedType",name:Qi()};do{if(33===Ji.charCodeAt(Fi)&&(Fi++,Hi(),t={kind:"NonNullType",type:t}),e){if(93!==Ji.charCodeAt(Fi++))throw $i("NamedType");Hi(),t={kind:"ListType",type:t}}}while(e--);return t}function an(){if(123!==Ji.charCodeAt(Fi++))throw $i("SelectionSet");return Hi(),on()}function on(){var e=[];do{if(46===Ji.charCodeAt(Fi)){if(46!==Ji.charCodeAt(++Fi)||46!==Ji.charCodeAt(++Fi))throw $i("SelectionSet");switch(Fi++,Hi(),Ji.charCodeAt(Fi)){case 64:e.push({kind:"InlineFragment",typeCondition:void 0,directives:sn(!1),selectionSet:an()});break;case 111:110===Ji.charCodeAt(Fi+1)?(Fi+=2,Hi(),e.push({kind:"InlineFragment",typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()})):e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)});break;case 123:Fi++,Hi(),e.push({kind:"InlineFragment",typeCondition:void 0,directives:void 0,selectionSet:on()});break;default:e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)})}}else{var t=Qi(),r=void 0;58===Ji.charCodeAt(Fi)&&(Fi++,Hi(),r=t,t=Qi());var s=rn(!1),i=sn(!1),n=void 0;123===Ji.charCodeAt(Fi)&&(Fi++,Hi(),n=on()),e.push({kind:"Field",alias:r,name:t,arguments:s,directives:i,selectionSet:n})}}while(125!==Ji.charCodeAt(Fi));return Fi++,Hi(),{kind:"SelectionSet",selections:e}}function dn(){if(Hi(),40===Ji.charCodeAt(Fi)){var e=[];Fi++,Hi();do{if(36!==Ji.charCodeAt(Fi++))throw $i("Variable");var t=Qi();if(58!==Ji.charCodeAt(Fi++))throw $i("VariableDefinition");Hi();var r=nn(),s=void 0;61===Ji.charCodeAt(Fi)&&(Fi++,Hi(),s=tn(!0)),Hi(),e.push({kind:"VariableDefinition",variable:{kind:"Variable",name:t},type:r,defaultValue:s,directives:sn(!0)})}while(41!==Ji.charCodeAt(Fi));return Fi++,Hi(),e}}function cn(){var e=Qi();if(111!==Ji.charCodeAt(Fi++)||110!==Ji.charCodeAt(Fi++))throw $i("FragmentDefinition");return Hi(),{kind:"FragmentDefinition",name:e,typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()}}function un(){var e=[];do{if(123===Ji.charCodeAt(Fi))Fi++,Hi(),e.push({kind:"OperationDefinition",operation:"query",name:void 0,variableDefinitions:void 0,directives:void 0,selectionSet:on()});else{var t=Ki();switch(t){case"fragment":e.push(cn());break;case"query":case"mutation":case"subscription":var r,s=void 0;40!==(r=Ji.charCodeAt(Fi))&&64!==r&&123!==r&&(s=Qi()),e.push({kind:"OperationDefinition",operation:t,name:s,variableDefinitions:dn(),directives:sn(!1),selectionSet:an()});break;default:throw $i("Document")}}}while(Fi<Ji.length);return e}function hn(e,t){return Ji=e.body?e.body:e,Fi=0,Hi(),t&&t.noLocation?{kind:"Document",definitions:un()}:{kind:"Document",definitions:un(),loc:{start:0,end:Ji.length,startToken:void 0,endToken:void 0,source:{body:Ji,name:"graphql.web",locationOffset:{line:1,column:1}}}}}var ln=0,pn=new Set;function mn(){function e(e,t){var r,s,i=hn(e).definitions,n=new Set;for(var a of t||[])for(var o of a.definitions)o.kind!==Li||n.has(o)||(i.push(o),n.add(o));return(r=i[0].kind===Li)&&i[0].directives&&(i[0].directives=i[0].directives.filter((e=>"_unmask"!==e.name.value))),{kind:Xi,definitions:i,get loc(){if(!s&&r){var i=e+function(e){try{ln++;var t="";for(var r of e)if(!pn.has(r)){pn.add(r);var{loc:s}=r;s&&(t+=s.source.body)}return t}finally{0==--ln&&pn.clear()}}(t||[]);return{start:0,end:i.length,source:{body:i,name:"GraphQLTada",locationOffset:{line:1,column:1}}}}return s},set loc(e){s=e}}}return e.scalar=function(e,t){return t},e.persisted=function(e,t){return{kind:Xi,definitions:t?t.definitions:[],documentId:e}},e}mn();const bn=mn();function _n(e){if(1!==e.length)throw new Error("Invalid base64Url character: "+e);const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(e);if(-1===t)throw new Error("Invalid base64Url character: "+e);const r=t.toString(2).padStart(6,"0");return Array.from(r).map(Number)}function gn(e,t){const r=function(e,t){if(e.length<2)throw new Error(`Input (s = ${e}) is not tightly packed because s.length < 2`);let r=function(e){let t=[];for(let r=0;r<e.length;r++){const s=_n(e.charAt(r));t=t.concat(s)}return t}(e);const s=t%4;if(0===s);else if(1===s)r=r.slice(2);else{if(2!==s)throw new Error(`Input (s = ${e}) is not tightly packed because i%4 = 3 (i = ${t}))`);r=r.slice(4)}const i=(t+e.length-1)%4;if(3===i);else if(2===i)r=r.slice(0,r.length-2);else{if(1!==i)throw new Error(`Input (s = ${e}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${t}))`);r=r.slice(0,r.length-4)}if(r.length%8!=0)throw new Error("We should never reach here...");const n=new Uint8Array(Math.floor(r.length/8));let a=0;for(let e=0;e<r.length;e+=8){const t=r.slice(e,e+8),s=parseInt(t.join(""),2);n[a++]=s}return(new TextDecoder).decode(n)}(e.value,e.indexMod4),[s,i]=function(e){if("}"!==e.slice(-1)&&","!==e.slice(-1))throw new Error("Invalid claim");const t=JSON.parse("{"+e.slice(0,-1)+"}");if(1!==Object.keys(t).length)throw new Error("Invalid claim");const r=Object.keys(t)[0];return[r,t[r]]}(r);if(s!==t)throw new Error(`Invalid field name: found ${s} expected ${t}`);return i}const fn=ht.struct("ZkLoginSignature",{inputs:ht.struct("ZkLoginSignatureInputs",{proofPoints:ht.struct("ZkLoginSignatureInputsProofPoints",{a:ht.vector(ht.string()),b:ht.vector(ht.vector(ht.string())),c:ht.vector(ht.string())}),issBase64Details:ht.struct("ZkLoginSignatureInputsClaim",{value:ht.string(),indexMod4:ht.u8()}),headerBase64:ht.string(),addressSeed:ht.string()}),maxEpoch:ht.u64(),userSignature:ht.vector(ht.u8())});var yn,vn,Tn=e=>{throw TypeError(e)},En=(e,t,r)=>t.has(e)||Tn("Cannot "+r),wn=(e,t,r)=>(En(e,t,"read from private field"),r?r.call(e):t.get(e)),xn=(e,t,r)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),On=(e,t,r,s)=>(En(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);yn=new WeakMap,vn=new WeakMap;let In=class e extends di{constructor(e,{client:r}={}){super(),xn(this,yn),xn(this,vn),On(this,vn,r),"string"==typeof e?On(this,yn,t(e)):e instanceof Uint8Array?On(this,yn,e):On(this,yn,Uint8Array.from(e))}equals(e){return super.equals(e)}toRawBytes(){return wn(this,yn)}flag(){return ii.ZkLogin}async verify(e,t){throw Error("does not support")}verifyPersonalMessage(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"PERSONAL_MESSAGE",client:wn(this,vn)})}verifyTransaction(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"TRANSACTION_DATA",client:wn(this,vn)})}};const Cn=bn("\n\tquery Zklogin(\n\t\t$bytes: Base64!\n\t\t$signature: Base64!\n\t\t$intentScope: ZkLoginIntentScope!\n\t\t$author: SuiAddress!\n\t) {\n\t\tverifyZkloginSignature(\n\t\t\tbytes: $bytes\n\t\t\tsignature: $signature\n\t\t\tintentScope: $intentScope\n\t\t\tauthor: $author\n\t\t) {\n\t\t\tsuccess\n\t\t\terrors\n\t\t}\n\t}\n");async function Bn({address:e,bytes:t,signature:r,intentScope:s,client:i=new Mi({url:"https://sui-mainnet.mystenlabs.com/graphql"})}){const n=await i.query({query:Cn,variables:{bytes:t,signature:r,intentScope:s,author:e}});return!0===n.data?.verifyZkloginSignature.success&&0===n.data?.verifyZkloginSignature.errors.length}function Sn(e){const r="string"==typeof e?t(e):e;if(r[0]!==ii.ZkLogin)throw new Error("Invalid signature scheme");const i=r.slice(1),{inputs:n,maxEpoch:a,userSignature:o}=function(e){return fn.parse("string"==typeof e?t(e):e)}(i),{issBase64Details:d,addressSeed:c}=n,u=gn(d,"iss"),h=function(e,t){const r=(n=32,function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=Pr(e.charCodeAt(i)),n=Pr(e.charCodeAt(i+1));if(void 0===r||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}s[t]=16*r+n}return s}(e.toString(16).padStart(2*n,"0").slice(2*-n))),s=(new TextEncoder).encode(t),i=new Uint8Array(1+s.length+r.length);var n;return i.set([s.length],0),i.set(s,1),i.set(r,1+s.length),new In(i,void 0)}(BigInt(c),u);return{serializedSignature:s(r),signatureScheme:"ZkLogin",zkLogin:{inputs:n,maxEpoch:a,userSignature:o,iss:u,addressSeed:BigInt(c)},signature:r,publicKey:h.toRawBytes()}}const Pn=32,jn="suiprivkey";class An{async signWithIntent(e,t){const r=si(t,e),i=zr(r,{dkLen:32});return{signature:function({signature:e,signatureScheme:t,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const i=r.toRawBytes(),n=new Uint8Array(1+e.length+i.length);return n.set([ii[t]]),n.set(e,1),n.set(i,1+e.length),s(n)}({signature:await this.sign(i),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:s(e)}}async signTransaction(e){return this.signWithIntent(e,"TransactionData")}async signPersonalMessage(e){const{signature:t}=await this.signWithIntent(ht.vector(ht.u8()).serialize(e).toBytes(),"PersonalMessage");return{bytes:s(e),signature:t}}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class kn extends An{}function Un(e){const{prefix:t,words:r}=ri.I.decode(e);if(t!==jn)throw new Error("invalid private key prefix");const s=new Uint8Array(ri.I.fromWords(r)),i=s.slice(1);return{schema:ai[s[0]],secretKey:i}}function Nn(e,t){if(e.length!==Pn)throw new Error("Invalid bytes length");const r=ii[t],s=new Uint8Array(e.length+1);return s.set([r]),s.set(e,1),ri.I.encode(jn,ri.I.toWords(s))}class Dn extends Ar{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,vr(e);const r=jr(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tr(this),this.iHash.update(e),this}digestInto(e){Tr(this),yr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:n,outputLen:a}=this;return e.finished=s,e.destroyed=i,e.blockLen=n,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Yn=(e,t,r)=>new Dn(e,t).update(r).digest();Yn.create=(e,t)=>new Dn(e,t);class Rn extends Ar{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=xr(this.buffer)}update(e){Tr(this);const{view:t,buffer:r,blockLen:s}=this,i=(e=jr(e)).length;for(let n=0;n<i;){const a=Math.min(s-this.pos,i-n);if(a!==s)r.set(e.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===s&&(this.process(t,0),this.pos=0);else{const t=xr(e);for(;s<=i-n;n+=s)this.process(t,n)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tr(this),Er(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let e=n;e<s;e++)t[e]=0;!function(e,t,r,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,s);const i=BigInt(32),n=BigInt(4294967295),a=Number(r>>i&n),o=Number(r&n),d=s?4:0,c=s?0:4;e.setUint32(t+d,a,s),e.setUint32(t+c,o,s)}(r,s-8,BigInt(8*this.length),i),this.process(r,0);const a=xr(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=o/4,c=this.get();if(d>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)a.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:n,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=n,s%t&&e.buffer.set(r),e}}const[Vn,Mn]=(()=>Jr.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Jn=new Uint32Array(80),Fn=new Uint32Array(80);class Xn extends Rn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:n,Dh:a,Dl:o,Eh:d,El:c,Fh:u,Fl:h,Gh:l,Gl:p,Hh:m,Hl:b}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b]}set(e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|s,this.Ch=0|i,this.Cl=0|n,this.Dh=0|a,this.Dl=0|o,this.Eh=0|d,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|l,this.Gl=0|p,this.Hh=0|m,this.Hl=0|b}process(e,t){for(let r=0;r<16;r++,t+=4)Jn[r]=e.getUint32(t),Fn[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Jn[e-15],r=0|Fn[e-15],s=Jr.rotrSH(t,r,1)^Jr.rotrSH(t,r,8)^Jr.shrSH(t,r,7),i=Jr.rotrSL(t,r,1)^Jr.rotrSL(t,r,8)^Jr.shrSL(t,r,7),n=0|Jn[e-2],a=0|Fn[e-2],o=Jr.rotrSH(n,a,19)^Jr.rotrBH(n,a,61)^Jr.shrSH(n,a,6),d=Jr.rotrSL(n,a,19)^Jr.rotrBL(n,a,61)^Jr.shrSL(n,a,6),c=Jr.add4L(i,d,Fn[e-7],Fn[e-16]),u=Jr.add4H(c,s,o,Jn[e-7],Jn[e-16]);Jn[e]=0|u,Fn[e]=0|c}let{Ah:r,Al:s,Bh:i,Bl:n,Ch:a,Cl:o,Dh:d,Dl:c,Eh:u,El:h,Fh:l,Fl:p,Gh:m,Gl:b,Hh:_,Hl:g}=this;for(let e=0;e<80;e++){const t=Jr.rotrSH(u,h,14)^Jr.rotrSH(u,h,18)^Jr.rotrBH(u,h,41),f=Jr.rotrSL(u,h,14)^Jr.rotrSL(u,h,18)^Jr.rotrBL(u,h,41),y=u&l^~u&m,v=h&p^~h&b,T=Jr.add5L(g,f,v,Mn[e],Fn[e]),E=Jr.add5H(T,_,t,y,Vn[e],Jn[e]),w=0|T,x=Jr.rotrSH(r,s,28)^Jr.rotrBH(r,s,34)^Jr.rotrBH(r,s,39),O=Jr.rotrSL(r,s,28)^Jr.rotrBL(r,s,34)^Jr.rotrBL(r,s,39),I=r&i^r&a^i&a,C=s&n^s&o^n&o;_=0|m,g=0|b,m=0|l,b=0|p,l=0|u,p=0|h,({h:u,l:h}=Jr.add(0|d,0|c,0|E,0|w)),d=0|a,c=0|o,a=0|i,o=0|n,i=0|r,n=0|s;const B=Jr.add3L(w,O,C);r=Jr.add3H(B,E,x,I),s=0|B}({h:r,l:s}=Jr.add(0|this.Ah,0|this.Al,0|r,0|s)),({h:i,l:n}=Jr.add(0|this.Bh,0|this.Bl,0|i,0|n)),({h:a,l:o}=Jr.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:d,l:c}=Jr.add(0|this.Dh,0|this.Dl,0|d,0|c)),({h:u,l:h}=Jr.add(0|this.Eh,0|this.El,0|u,0|h)),({h:l,l:p}=Jr.add(0|this.Fh,0|this.Fl,0|l,0|p)),({h:m,l:b}=Jr.add(0|this.Gh,0|this.Gl,0|m,0|b)),({h:_,l:g}=Jr.add(0|this.Hh,0|this.Hl,0|_,0|g)),this.set(r,s,i,n,a,o,d,c,u,h,l,p,m,b,_,g)}roundClean(){Jn.fill(0),Fn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ln=kr((()=>new Xn));function Gn(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function $n(e,t=""){return function(e,t,r){const{c:s,dkLen:i,DK:n,PRF:a,PRFSalt:o}=function(e,t,r,s){vr(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("Options should be object or undefined");return Object.assign({dkLen:32,asyncTick:10},t)}(0,s),{c:n,dkLen:a,asyncTick:o}=i;if(fr(n),fr(a),fr(o),n<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const d=jr(t),c=jr(r),u=new Uint8Array(a),h=Yn.create(e,d),l=h._cloneInto().update(c);return{c:n,dkLen:a,asyncTick:o,DK:u,PRF:h,PRFSalt:l}}(e,t,r,{c:2048,dkLen:64});let d;const c=new Uint8Array(4),u=xr(c),h=new Uint8Array(a.outputLen);for(let e=1,t=0;t<i;e++,t+=a.outputLen){const r=n.subarray(t,t+a.outputLen);u.setInt32(0,e,!1),(d=o._cloneInto(d)).update(c).digestInto(h),r.set(h.subarray(0,r.length));for(let e=1;e<s;e++){a._cloneInto(d).update(h).digestInto(h);for(let e=0;e<r.length;e++)r[e]^=h[e]}}return function(e,t,r,s,i){return e.destroy(),t.destroy(),s&&s.destroy(),i.fill(0),r}(a,o,n,d,h)}(Ln,function(e){const t=Gn(e),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}(e).nfkd,(e=>Gn("mnemonic"+e))(t))}function zn(e){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(e)}const qn=new RegExp("^m(\\/[0-9]+')+$"),Wn=e=>e.replace("'",""),Hn=(e,t,r=2147483648)=>{if(!(e=>!!qn.test(e)&&!e.split("/").slice(1).map(Wn).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:s,chainCode:i}=(e=>{const t=Yn.create(Ln,"ed25519 seed").update(c(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(Wn).map((e=>parseInt(e,10))).reduce(((e,t)=>(({key:e,chainCode:t},r)=>{const s=new ArrayBuffer(4);new DataView(s).setUint32(0,r);const i=new Uint8Array(1+e.length+s.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(e,1),i.set(new Uint8Array(s,0,s.byteLength),e.length+1);const n=Yn.create(Ln,t).update(i).digest();return{key:n.slice(0,32),chainCode:n.slice(32)}})(e,t+r)),{key:s,chainCode:i})};class Kn extends di{constructor(e){if(super(),"string"==typeof e?this.data=t(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return ii.ED25519}async verify(e,r){let s;if("string"==typeof r){const e=function(e){const r=t(e),s=ai[r[0]];switch(s){case"MultiSig":return{serializedSignature:e,signatureScheme:s,multisig:or.MultiSig.parse(r.slice(1)),bytes:r};case"ZkLogin":return Sn(e);case"ED25519":case"Secp256k1":case"Secp256r1":const t=ni[s],i=r.slice(1,r.length-t);return{serializedSignature:e,signatureScheme:s,signature:i,publicKey:r.slice(1+i.length),bytes:r};default:throw new Error("Unsupported signature scheme")}}(r);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!oi(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");s=e.signature}else s=r;return ti.sign.detached.verify(e,s,this.toRawBytes())}}Kn.SIZE=32;const Qn="m/44'/784'/0'/0'/0'";class Zn extends kn{constructor(e){super(),this.keypair=e||ti.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Zn(ti.sign.keyPair())}static fromSecretKey(e,t){const r=e.length;if(r!==Pn)throw new Error(`Wrong secretKey size. Expected ${Pn} bytes, got ${r}.`);const s=ti.sign.keyPair.fromSeed(e);if(!t||!t.skipValidation){const e=(new TextEncoder).encode("sui validation"),t=ti.sign.detached(e,s.secretKey);if(!ti.sign.detached.verify(e,t,s.publicKey))throw new Error("provided secretKey is invalid")}return new Zn(s)}getPublicKey(){return new Kn(this.keypair.publicKey)}getSecretKey(){return Nn(this.keypair.secretKey.slice(0,Pn),this.getKeyScheme())}async sign(e){return ti.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=Qn),!zn(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,function(e){return u(function(e){return $n(e,"")}(e))}(e));return Zn.fromSecretKey(r)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=Qn),!zn(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,e);return Zn.fromSecretKey(r)}}function ea(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function ta(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}var ra=a(725);const sa=e=>ra.encode(e),ia=e=>ra.decode(e);function na(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const aa=8192;function oa(e){if(e.length<aa)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=aa){const s=e.slice(r,r+aa);t+=String.fromCharCode(...s)}return btoa(t)}class da{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class ca{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return ua(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return ua(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return ua(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return sa(e);case"base64":return oa(e);case"hex":return ta(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function ua(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var ha,la,pa,ma,ba=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},_a=(e,t,r)=>(ba(e,t,"read from private field"),r?r.call(e):t.get(e)),ga=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},fa=(e,t,r,s)=>(ba(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const ya=class{constructor(e){ga(this,ha,void 0),ga(this,la,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),fa(this,ha,e.write),fa(this,la,e.serialize??((e,t)=>{const r=new ca({size:this.serializedSize(e)??void 0,...t});return _a(this,ha).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),_a(this,ha).call(this,e,t)}serialize(e,t){return this.validate(e),new Ea(this,_a(this,la).call(this,e,t))}parse(e){const t=new da(e);return this.read(t)}transform({name:e,input:t,output:r}){return new ya({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>_a(this,ha).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>_a(this,la).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let va=ya;ha=new WeakMap,la=new WeakMap;const Ta=Symbol.for("@mysten/serialized-bcs");class Ea{constructor(e,t){ga(this,pa,void 0),ga(this,ma,void 0),fa(this,pa,e),fa(this,ma,t)}get[Ta](){return!0}toBytes(){return _a(this,ma)}toHex(){return ta(_a(this,ma))}toBase64(){return oa(_a(this,ma))}toBase58(){return sa(_a(this,ma))}parse(){return _a(this,pa).parse(_a(this,ma))}}pa=new WeakMap,ma=new WeakMap;const wa=32,xa=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof xa)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(xa.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Oa.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Oa.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Oa.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Oa.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Oa.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Oa.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Oa.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Oa.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Oa.HEX,(function(e,t){return e.writeVec(Array.from(ea(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return ta(new Uint8Array(t))})),t.registerType(Oa.BASE58,(function(e,t){return e.writeVec(Array.from(ia(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return sa(new Uint8Array(t))})),t.registerType(Oa.BASE64,(function(e,t){return e.writeVec(Array.from(na(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return oa(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new xa(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return ia(e);case"base64":return na(e);case"hex":return ea(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new xa(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new ca(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new da(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new va({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new va({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return na(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return oa(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return ea(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return ta(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],l,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,l,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let l=n.indexOf(h),p=-1===l?h:a[l];{let{name:r,params:s}=this.parseTypeName(p);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Oa=xa;function Ia(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:wa,addressEncoding:"hex"}}var Ca;Oa.U8="u8",Oa.U16="u16",Oa.U32="u32",Oa.U64="u64",Oa.U128="u128",Oa.U256="u256",Oa.BOOL="bool",Oa.VECTOR="vector",Oa.ADDRESS="address",Oa.STRING="string",Oa.HEX="hex-string",Oa.BASE58="base58-string",Oa.BASE64="base64-string",function(e){e.IsValidDesription="invalid description",e.IsValidName="invalid name",e.IsValidName_AllowEmpty="invalid name",e.IsValidEndpoint="invalid endpoint",e.IsValidAddress="invalid address",e.IsValidArgType="invalid argument type",e.IsValidTokenType="invalid token type",e.IsValidUint="invalid uint",e.IsValidInt="invalid int",e.IsValidU64="invalid u64",e.IsValidU8="invalid u8",e.IsValidPercent="invalid percent",e.IsValidArray="invalid array",e.IsValidObjects="invalid objects",e.AllInvalid="one valid at least",e.InvalidParam="invalid parameter",e.IsValidPermissionIndex="invalid permission index",e.IsValidKey="invalid key",e.Fail="fail",e.IsValidIndentifier="indentifier invalid",e.isValidHttpUrl="invalid url",e.IsValidBizPermissionIndex="invalid biz-permission index",e.bcsTypeInvalid="invalid bcs type",e.IsValidServiceItemName="invalid service item name",e.IsValidCoinType="not the coin type",e.IsValidGuardIdentifier="guard identifier invalid",e.noPermission="no permission"}(Ca||(Ca={}));const Ba=(e,t)=>{throw e.toString()+(t?" "+t:"")},Sa=BigInt("255"),Pa=BigInt("18446744073709551615"),ja=BigInt("340282366920938463463374607431768211455"),Aa=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),ka=0,Ua=e=>e===No.TYPE_U8||e===No.TYPE_U64||e===No.TYPE_U128||e===No.TYPE_U256?Do.PositiveNumber:e===No.TYPE_VEC_U8||e===No.TYPE_VEC_U64||e===No.TYPE_VEC_U128||e===No.TYPE_VEC_U256||e===No.TYPE_VEC_BOOL?Do.PositiveNumber_Vec:e===No.TYPE_ADDRESS?Do.Address:e===No.TYPE_VEC_ADDRESS?Do.Address_Vec:e===No.TYPE_STRING?Do.String:e===No.TYPE_VEC_STRING?Do.String_Vec:e===No.TYPE_BOOL?Do.Bool:-1,Na=(e,t)=>{let r=e.splice(0,1);return 1==r[0]?{bNone:!1,value:Wa.getInstance().de(t,Uint8Array.from(e))}:(0==r[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka})},Da=e=>{let t=e.splice(0,1);if(1==t[0]){let t=Ya(Uint8Array.from(e)),r=Wa.getInstance().de(No.TYPE_STRING,Uint8Array.from(e));return e.splice(0,t.value+t.length),{bNone:!1,value:r}}return 0==t[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka}},Ya=e=>{let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}},Ra=(e,t)=>{let r=Ya(Uint8Array.from(e));e.splice(0,r.length);let s=[];for(let i=0;i<r.value;i++)s.push(t(e,i,r.value));return s},Va=(e,t,r)=>e.shift(),Ma=(e,t,r)=>e.splice(0,8),Ja=(e,t,r)=>e.splice(0,16),Fa=(e,t,r)=>e.splice(0,32),Xa=(e,...t)=>{let r=0;for(const e of t)r+=e.length;const s=new e(r);let i=0;for(const e of t)s.set(e,i),i+=e.length;return s},La=(e,t="payment::Payment<")=>{if(e){const r=e.indexOf(t);if(r>0)return e.slice(r+t.length,e.length-1)}return""},Ga=(e,t)=>e.length===t.length&&!e.some((e=>!t.includes(e))),$a=e=>{for(var t=[],r=0;r<e.length;r++)-1==t.indexOf(e[r])&&t.push(e[r]);return t};function za(e){return e&&e[0].toUpperCase()+e.slice(1)}function qa(e){var t=[];let r=e.indexOf("<");return r>=0&&(t=e.slice(r+1,e.length-1).split(",")),t}class Wa{bcs=new Oa(Ia());static _instance;constructor(){this.bcs.registerEnumType("Option<T>",{none:null,some:"T"}),this.bcs.registerStructType("EntStruct",{avatar:"vector<u8>",resource:"Option<address>",safer_name:"vector<string>",safer_value:"vector<string>",like:Oa.U32,dislike:Oa.U32}),this.bcs.registerStructType("TagStruct",{nick:"string",tags:"vector<string>"}),this.bcs.registerStructType("PersonalInfo",{name:"vector<u8>",description:"vector<u8>",avatar:Oa.STRING,twitter:Oa.STRING,discord:Oa.STRING,homepage:Oa.STRING}),this.bcs.registerStructType("OptionAddress",{address:"Option<address>"}),this.bcs.registerStructType("Guards",{guards:"vector<OptionAddress>"}),this.bcs.registerStructType("Perm",{index:Oa.U64,guard:"Option<address>"}),this.bcs.registerStructType("Perms",{perms:"vector<Perm>"})}static getInstance(){return Wa._instance||(Wa._instance=new Wa),Wa._instance}ser_option_u32(e){return this.bcs.ser("Option<u32>",{some:e}).toBytes()}ser(e,t){if("string"==typeof e)return this.bcs.ser(e,t).toBytes();switch(e){case No.TYPE_BOOL:return this.bcs.ser(Oa.BOOL,t).toBytes();case No.TYPE_ADDRESS:return this.bcs.ser(Oa.ADDRESS,t).toBytes();case No.TYPE_U64:return this.bcs.ser(Oa.U64,t).toBytes();case No.TYPE_U8:return this.bcs.ser(Oa.U8,t).toBytes();case No.TYPE_VEC_U8:return this.bcs.ser("vector<u8>",t).toBytes();case No.TYPE_U128:return this.bcs.ser(Oa.U128,t).toBytes();case No.TYPE_VEC_ADDRESS:return this.bcs.ser("vector<address>",t).toBytes();case No.TYPE_VEC_BOOL:return this.bcs.ser("vector<bool>",t).toBytes();case No.TYPE_VEC_VEC_U8:return this.bcs.ser("vector<vector<u8>>",t).toBytes();case No.TYPE_VEC_U64:return this.bcs.ser("vector<u64>",t).toBytes();case No.TYPE_VEC_U128:return this.bcs.ser("vector<u128>",t).toBytes();case No.TYPE_OPTION_ADDRESS:return this.bcs.ser("Option<address>",{some:t}).toBytes();case No.TYPE_OPTION_BOOL:return this.bcs.ser("Option<bool>",{some:t}).toBytes();case No.TYPE_OPTION_U8:return this.bcs.ser("Option<u8>",{some:t}).toBytes();case No.TYPE_OPTION_U64:return this.bcs.ser("Option<u64>",{some:t}).toBytes();case No.TYPE_OPTION_U128:return this.bcs.ser("Option<u128>",{some:t}).toBytes();case No.TYPE_OPTION_U256:return this.bcs.ser("Option<u256>",{some:t}).toBytes();case No.TYPE_OPTION_STRING:return this.bcs.ser("Option<string>",{some:t}).toBytes();case No.TYPE_VEC_U256:return this.bcs.ser("vector<u256>",t).toBytes();case No.TYPE_U256:return this.bcs.ser(Oa.U256,t).toBytes();case No.TYPE_STRING:const e=(new TextEncoder).encode(t);return this.bcs.ser("vector<u8>",e).toBytes();case No.TYPE_VEC_STRING:return this.bcs.ser("vector<vector<u8>>",t.map((e=>(new TextEncoder).encode(e)))).toBytes();default:Ba(Ca.bcsTypeInvalid,"ser")}return new Uint8Array}de(e,t){if("string"==typeof e)return this.bcs.de(e,t);switch(e){case No.TYPE_BOOL:return this.bcs.de(Oa.BOOL,t);case No.TYPE_ADDRESS:return this.bcs.de(Oa.ADDRESS,t);case No.TYPE_U64:return this.bcs.de(Oa.U64,t);case No.TYPE_U8:return this.bcs.de(Oa.U8,t);case No.TYPE_VEC_U8:return this.bcs.de("vector<u8>",t);case No.TYPE_U128:return this.bcs.de(Oa.U128,t);case No.TYPE_VEC_ADDRESS:return this.bcs.de("vector<address>",t);case No.TYPE_VEC_BOOL:return this.bcs.de("vector<bool>",t);case No.TYPE_VEC_VEC_U8:return this.bcs.de("vector<vector<u8>>",t);case No.TYPE_VEC_U64:return this.bcs.de("vector<u64>",t);case No.TYPE_VEC_U128:return this.bcs.de("vector<u128>",t);case No.TYPE_OPTION_ADDRESS:return this.bcs.de("Option<address>",t);case No.TYPE_OPTION_BOOL:return this.bcs.de("Option<bool>",t);case No.TYPE_OPTION_U8:return this.bcs.de("Option<u8>",t);case No.TYPE_OPTION_U64:return this.bcs.de("Option<u64>",t);case No.TYPE_OPTION_U128:return this.bcs.de("Option<u128>",t);case No.TYPE_OPTION_U256:return this.bcs.de("Option<u256>",t);case No.TYPE_OPTION_STRING:return this.bcs.de("Option<string>",t);case No.TYPE_VEC_U256:return this.bcs.de("vector<u256>",t);case No.TYPE_STRING:return(new TextDecoder).decode(Uint8Array.from(this.bcs.de("vector<u8>",t)));case No.TYPE_VEC_STRING:return this.bcs.de("vector<string>",t);case No.TYPE_U256:return this.bcs.de(Oa.U256,t);default:Ba(Ca.bcsTypeInvalid,"de")}}de_ent(e){if(!e||e.length<2)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("EntStruct",Uint8Array.from(t))}de_entInfo(e){if(!e||0===e.length)return;let t=this.bcs.de("PersonalInfo",e);return t.name=(new TextDecoder).decode(Uint8Array.from(t.name)),t.description=(new TextDecoder).decode(Uint8Array.from(t.description)),t}de_tags(e){if(!e||0===e.length)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("TagStruct",Uint8Array.from(t))}de_perms(e){return!e||e.length<1?"":this.bcs.de("Perms",e).perms.map((e=>({index:e?.index,guard:e?.guard?.none?void 0:"0x"+e?.guard?.some})))}}function Ha(e){const t=(new TextEncoder).encode(e);return new Uint8Array(t.buffer)}function Ka(e){if(!e)return new Uint8Array(0);const t=[];for(t.unshift(255&e);e>=256;)e>>>=8,t.unshift(255&e);return new Uint8Array(t)}const Qa=e=>"[object Array]"==Object.prototype.toString.call(e),Za=(e,t)=>{let r=t||{};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&("object"==typeof e[t]&&null!==e[t]?(r[t]=Qa(e[t])?[]:{},Za(e[t],r[t])):r[t]=e[t]);return r},eo=4e3,to=64,ro=1024,so=(e,t)=>Wa.getInstance().ser(No.TYPE_STRING,e).length<=t,io=e=>so(e,eo),no=e=>!(!e||0===e.length)&&so(e,to),ao=e=>so(e,to),oo=e=>e.length>0&&e.length<=ro&&Bo(e),co=e=>!(!e||!ae(e)),uo=e=>!!e&&(e.startsWith("0x2::coin::Coin")||e.startsWith("0x0000000000000000000000000000000000000000000000000000000000000002")),ho=(e=864e5)=>{const t=Date.now();return Math.floor(t/e)*e},lo=(e,t=Aa,r)=>{if(""===e||void 0===e)return!1;try{const s=BigInt(e);if(s<=t)return void 0===r||s>=r}catch(e){}return!1},po=(e,t=0)=>lo(e,Sa,BigInt(t)),mo=(e,t=0)=>lo(e,Pa,BigInt(t)),bo=(e,t=0)=>lo(e,ja,BigInt(t)),_o=(e,t=0)=>lo(e,Aa,BigInt(t)),go=e=>{if(!e||0===e.length)return!1;let t=e.split("::");return 3===t.length&&!(!co(t[0])&&"0x2"!=t[0]||0===t[1].length||0===t[2].length)},fo=e=>!(!e||0===e.length)&&!(e.split("::").length<3),yo=e=>("string"==typeof e&&(e=parseInt(e)),Number.isSafeInteger(e)),vo=e=>lo(e,BigInt(100),BigInt(0)),To=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r]))return!1;return!0},Eo=e=>e>Pa?Pa:e;function wo(e){const t=e.trim();if(-1!==t.indexOf(".")){let e=t.length-1;for(;"0"===t[e];)e--;return"."===t[e]&&e--,t.slice(0,e+1)}return t}const xo=(e,t)=>{if(!e)return"";if("0"===e)return"0";if(t<=0)return e;var r=t-e.length;return wo(0===r?"."+e:r<0?e.slice(0,Math.abs(r))+"."+e.slice(Math.abs(r)):"."+e.padStart(t,"0"))},Oo=e=>{if(e){const t="0x2::coin::Coin<";let r=e.indexOf(t);if(r>=0){let s=e.slice(r+t.length,e.length-1);if(-1===s.indexOf("<")){for(;">"==s[s.length-1];)s=s.slice(0,-1);let e=s.lastIndexOf("::");return{isCoin:!0,coin:s,token:s.slice(e+2)}}}}return{isCoin:!1,coin:"",token:""}};function Io(e,t){const r=e.length+1,s=new Uint8Array(r);return s.set([t],0),s.set(e,1),s}function Co(e){let t="";var r;return Math.abs(e)<1?(r=parseInt(e.toString().split("e-")[1]))&&(e*=Math.pow(10,r-1),t="0."+new Array(r).join("0")+e.toString().substring(2)):(r=parseInt(e.toString().split("+")[1]))>20&&(r-=20,t=(e/=Math.pow(10,r))+new Array(r+1).join("0")),t}function Bo(e){let t;try{t=new URL(e)}catch(e){return!1}return"http:"===t.protocol||"https:"===t.protocol||"ipfs:"===t.protocol}const So=e=>{e.id&&(e?.onBegin&&e.onBegin(e.id),zo.Client().getObject({id:e.id,options:{showContent:!0,showType:!0,showOwner:!0}}).then((t=>{t.error?e?.onObjectErr&&e.onObjectErr(e.id,t.error):e?.onObjectRes&&e.onObjectRes(e.id,t)})).catch((t=>{console.log(t),e?.onObjectErr&&e.onObjectErr(e.id,t)})),zo.Client().getDynamicFields({parentId:e.id}).then((t=>{e?.onDynamicRes&&e.onDynamicRes(e.id,t),t.data.length>0&&zo.Client().multiGetObjects({ids:t.data.map((e=>e.objectId)),options:{showContent:!0}}).then((t=>{e?.onFieldsRes&&e.onFieldsRes(e.id,t)})).catch((t=>{console.log(t),e?.onFieldsErr&&e.onFieldsErr(e.id,t)}))})).catch((t=>{console.log(t),e?.onDynamicErr&&e.onDynamicErr(e.id,t)})))},Po=e=>e?e.substring(0,1).toUpperCase()+e.substring(1):"";function jo(e){return e.some(((t,r)=>e.findIndex((e=>e===t))!==r))}var Ao,ko;!function(e){e.machine="machine",e.progress="progress",e.repository="repository",e.permission="permission",e.passport="passport",e.guard="guard",e.demand="demand",e.order="order",e.service="service",e.resource="resource",e.entity="entity",e.wowok="wowok",e.treasury="treasury",e.payment="payment",e.arbitration="arbitration",e.arb="arb"}(Ao||(Ao={})),function(e){e[e.TYPE_QUERY=1]="TYPE_QUERY",e[e.TYPE_NUMBER_ADD=2]="TYPE_NUMBER_ADD",e[e.TYPE_NUMBER_SUBTRACT=3]="TYPE_NUMBER_SUBTRACT",e[e.TYPE_NUMBER_MULTIPLY=4]="TYPE_NUMBER_MULTIPLY",e[e.TYPE_NUMBER_DEVIDE=5]="TYPE_NUMBER_DEVIDE",e[e.TYPE_NUMBER_MOD=6]="TYPE_NUMBER_MOD",e[e.TYPE_NUMBER_ADDRESS=7]="TYPE_NUMBER_ADDRESS",e[e.TYPE_LOGIC_AS_U256_GREATER=11]="TYPE_LOGIC_AS_U256_GREATER",e[e.TYPE_LOGIC_AS_U256_GREATER_EQUAL=12]="TYPE_LOGIC_AS_U256_GREATER_EQUAL",e[e.TYPE_LOGIC_AS_U256_LESSER=13]="TYPE_LOGIC_AS_U256_LESSER",e[e.TYPE_LOGIC_AS_U256_LESSER_EQUAL=14]="TYPE_LOGIC_AS_U256_LESSER_EQUAL",e[e.TYPE_LOGIC_AS_U256_EQUAL=15]="TYPE_LOGIC_AS_U256_EQUAL",e[e.TYPE_LOGIC_EQUAL=16]="TYPE_LOGIC_EQUAL",e[e.TYPE_LOGIC_HAS_SUBSTRING=17]="TYPE_LOGIC_HAS_SUBSTRING",e[e.TYPE_LOGIC_NOT=18]="TYPE_LOGIC_NOT",e[e.TYPE_LOGIC_AND=19]="TYPE_LOGIC_AND",e[e.TYPE_LOGIC_OR=20]="TYPE_LOGIC_OR"}(ko||(ko={}));const Uo=[[ko.TYPE_LOGIC_AS_U256_GREATER,"Unsigned Integer >","The first item > anything that follows"],[ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL,"Unsigned Integer >=","The first item >= anything that follows"],[ko.TYPE_LOGIC_AS_U256_LESSER,"Unsigned Integer <","The first item < anything that follows"],[ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL,"Unsigned Integer <=","The first item <= anything that follows"],[ko.TYPE_LOGIC_AS_U256_EQUAL,"Unsigned Integer =","The first item = anything that follows"],[ko.TYPE_LOGIC_EQUAL,"Equal","Data and type are exactly equal for all items"],[ko.TYPE_LOGIC_HAS_SUBSTRING,"Has Sub String","The first item contains anything that follows"],[ko.TYPE_LOGIC_NOT,"Not","Not operation"],[ko.TYPE_LOGIC_AND,"And","All Items And operations"],[ko.TYPE_LOGIC_OR,"Or","All Items Or operations"]];var No,Do;!function(e){e[e.TYPE_BOOL=100]="TYPE_BOOL",e[e.TYPE_ADDRESS=101]="TYPE_ADDRESS",e[e.TYPE_U8=102]="TYPE_U8",e[e.TYPE_U64=103]="TYPE_U64",e[e.TYPE_VEC_U8=104]="TYPE_VEC_U8",e[e.TYPE_U128=105]="TYPE_U128",e[e.TYPE_VEC_ADDRESS=106]="TYPE_VEC_ADDRESS",e[e.TYPE_VEC_BOOL=107]="TYPE_VEC_BOOL",e[e.TYPE_VEC_VEC_U8=108]="TYPE_VEC_VEC_U8",e[e.TYPE_VEC_U64=109]="TYPE_VEC_U64",e[e.TYPE_VEC_U128=110]="TYPE_VEC_U128",e[e.TYPE_OPTION_ADDRESS=111]="TYPE_OPTION_ADDRESS",e[e.TYPE_OPTION_BOOL=112]="TYPE_OPTION_BOOL",e[e.TYPE_OPTION_U8=113]="TYPE_OPTION_U8",e[e.TYPE_OPTION_U64=114]="TYPE_OPTION_U64",e[e.TYPE_OPTION_U128=115]="TYPE_OPTION_U128",e[e.TYPE_OPTION_U256=116]="TYPE_OPTION_U256",e[e.TYPE_OPTION_STRING=117]="TYPE_OPTION_STRING",e[e.TYPE_OPTION_VEC_U8=118]="TYPE_OPTION_VEC_U8",e[e.TYPE_VEC_U256=119]="TYPE_VEC_U256",e[e.TYPE_STRING=120]="TYPE_STRING",e[e.TYPE_VEC_STRING=121]="TYPE_VEC_STRING",e[e.TYPE_U256=122]="TYPE_U256"}(No||(No={})),function(e){e[e.Address=200]="Address",e[e.Address_Vec=201]="Address_Vec",e[e.PositiveNumber=202]="PositiveNumber",e[e.PositiveNumber_Vec=203]="PositiveNumber_Vec",e[e.String=204]="String",e[e.String_Vec=205]="String_Vec",e[e.Bool=206]="Bool"}(Do||(Do={}));const Yo=[{type:Do.String,name:"string",description:"String."},{type:Do.Address,name:"address",description:"Object id or Personal address."},{type:Do.PositiveNumber,name:"unsigned integer",description:"Including u8, u16 ,..., u256"},{type:Do.String_Vec,name:"string vector",description:"Vector of string."},{type:Do.Address_Vec,name:"address vector",description:"Vector of address."},{type:Do.PositiveNumber_Vec,name:"unsigned integer vector",description:"Vector of unsigned integer"},{type:Do.Bool,name:"bool",description:"True or False."}],Ro=Object.values(ko).filter((e=>"number"==typeof e)),Vo=Object.values(No).filter((e=>"number"==typeof e)),Mo=e=>Ro.includes(e),Jo=e=>Vo.includes(e),Fo=e=>e===No.TYPE_U128||e===No.TYPE_U256||e===No.TYPE_U64||e===No.TYPE_U8;var Xo;!function(e){e[e.TYPE_SIGNER=60]="TYPE_SIGNER",e[e.TYPE_CLOCK=61]="TYPE_CLOCK",e[e.TYPE_GUARD=62]="TYPE_GUARD",e[e.TYPE_CONSTANT=80]="TYPE_CONSTANT"}(Xo||(Xo={}));const Lo=[{type:No.TYPE_BOOL,name:"bool",description:"boolean. eg:true or false",validator:e=>!0===e||!1===e},{type:No.TYPE_ADDRESS,name:"address",description:"address or object-id. eg:0x6789af",validator:co},{type:Xo.TYPE_SIGNER,name:"txn signer",description:"signer address of the transaction"},{type:Xo.TYPE_GUARD,name:"guard address",description:"current guard address"},{type:Xo.TYPE_CLOCK,name:"txn time",description:"unsigned-64 number for the transaction time"},{type:No.TYPE_U64,name:"number",description:"unsigned-64 number. eg:23870233",validator:mo},{type:No.TYPE_U8,name:"number",description:"unsigned-8 number. eg:255",validator:po},{type:No.TYPE_VEC_U8,name:"string",description:'string or unsigned-8 number array. eg:"[1,2,3]"'},{type:No.TYPE_U128,name:"number",description:"unsigned-8 number. eg:12348900999",validator:bo},{type:No.TYPE_VEC_ADDRESS,name:"[address]",description:"address array. eg:[0x2277f2, 0x3344af]"},{type:No.TYPE_VEC_BOOL,name:"[bool]",description:"boolean array. eg:[true, false, true]"},{type:No.TYPE_VEC_VEC_U8,name:"[[number]]",description:'array of unsigned-8 number array. eg:["i", "like", "wowok"]'},{type:No.TYPE_VEC_U64,name:"[number]",description:"unsigned-64 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_VEC_U128,name:"[number]",description:"unsigned-128 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_OPTION_ADDRESS,name:"option",description:"option of address. eg:none or address"},{type:No.TYPE_OPTION_BOOL,name:"option",description:"option of bool. eg:none or boolean value"},{type:No.TYPE_OPTION_U8,name:"option",description:"option of u8. eg:none or u8 value"},{type:No.TYPE_OPTION_U64,name:"option",description:"option of u64. eg:none or u64 value"},{type:No.TYPE_OPTION_U128,name:"option",description:"option of u128. eg:none or u128 value"},{type:No.TYPE_OPTION_U256,name:"option",description:"option of u256. eg:none or u256 value"},{type:No.TYPE_VEC_U256,name:"[number]",description:"unsigned-256 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_VEC_STRING,name:"[string]",description:'ascii string array. eg:["abc", "hi"]'},{type:No.TYPE_STRING,name:"string",description:'eg:"wowok"'},{type:No.TYPE_OPTION_STRING,name:"option",description:"option of string. eg:none or string value"},{type:No.TYPE_U256,name:"number",description:"unsigned-256 number. eg:12345678901233",validator:_o}];var Go;!function(e){e.mainnet="mainnet",e.testnet="testnet",e.devnet="devnet",e.localnet="localnet"}(Go||(Go={}));const $o="0x00b283ff2f3a0c706497faaa4e52536002c2a4908780d06582a98e2bc4a0a332";class zo{network="";packages=new Map;signer="";wowok_object="";entity_object="";treasury_cap="";oracle_object="";txb;static _instance;constructor(e=Go.testnet){this.use_network(e),this.new_session()}static Instance(){return zo._instance||(zo._instance=new zo),zo._instance}static Client(){return new ei({url:zo.Instance().networkUrl()})}client(){return new ei({url:this.networkUrl()})}use_network(e=Go.testnet){switch(this.network=e,e){case Go.localnet:case Go.devnet:break;case Go.testnet:this.packages.set("wowok","0x82b571c4476f1d7213906c3f76731256f5c9a55f28a74660cf54e8ad56d77a57"),this.packages.set("base",$o),this.packages.set("wowok_origin","0x82b571c4476f1d7213906c3f76731256f5c9a55f28a74660cf54e8ad56d77a57"),this.packages.set("base_origin","0x00b283ff2f3a0c706497faaa4e52536002c2a4908780d06582a98e2bc4a0a332"),this.wowok_object="0xe81643d04fcf6403adde4e9218de53fd66f2c7a715337b4710e573f6d272a4e5",this.entity_object="0x2b2ef38ef38459397a137d807f3f5a914c98e2c6ae9878849def71aea0cc8ca9",this.treasury_cap="0x176f957de5a0f8a5a47484a3dc8462c37df88a503781a0ac82cadd005aa80535",this.oracle_object="0x43d91c12ffc66111767f93cc49a5c87db23465996cfaee2c0b1cc072adc0b68e";break;case Go.mainnet:this.packages.set("wowok",""),this.packages.set("base",""),this.packages.set("wowok_origin",""),this.packages.set("base_origin",""),this.wowok_object="",this.entity_object="",this.treasury_cap="",this.oracle_object=""}}package(e){return this.packages.get(e)??""}objectWowok(){return this.wowok_object}objectEntity(){return this.entity_object}objectOracle(){return this.oracle_object}objectTreasuryCap(){return this.treasury_cap}networkUrl(){switch(this.network){case Go.localnet:return"http://127.0.0.1:9000";case Go.devnet:return"https://fullnode.devnet.sui.io:443";case Go.testnet:return"https://fullnode.testnet.sui.io:443";case Go.mainnet:return"https://fullnode.mainnet.sui.io:443"}return""}machineFn=e=>`${this.packages.get("wowok")}::${Ao.machine}::${e}`;progressFn=e=>`${this.packages.get("wowok")}::${Ao.progress}::${e}`;repositoryFn=e=>`${this.packages.get("wowok")}::${Ao.repository}::${e}`;permissionFn=e=>`${this.packages.get("wowok")}::${Ao.permission}::${e}`;passportFn=e=>`${this.packages.get("wowok")}::${Ao.passport}::${e}`;demandFn=e=>`${this.packages.get("wowok")}::${Ao.demand}::${e}`;orderFn=e=>`${this.packages.get("wowok")}::${Ao.order}::${e}`;serviceFn=e=>`${this.packages.get("wowok")}::${Ao.service}::${e}`;resourceFn=e=>`${this.packages.get("wowok")}::${Ao.resource}::${e}`;entityFn=e=>`${this.packages.get("wowok")}::${Ao.entity}::${e}`;wowokFn=e=>`${this.packages.get("wowok")}::${Ao.wowok}::${e}`;treasuryFn=e=>`${this.packages.get("wowok")}::${Ao.treasury}::${e}`;paymentFn=e=>`${this.packages.get("wowok")}::${Ao.payment}::${e}`;guardFn=e=>`${this.packages.get("base")}::${Ao.guard}::${e}`;baseWowokFn=e=>`${this.packages.get("base")}::${Ao.wowok}::${e}`;arbitrationFn=e=>`${this.packages.get("wowok")}::${Ao.arbitration}::${e}`;arbFn=e=>`${this.packages.get("wowok")}::${Ao.arb}::${e}`;query=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()}),s=e.map((e=>e.objectid)),i=await r.call("sui_multiGetObjects",[s,t]);for(let r=0;r<i.length;r++)e.forEach((e=>{e.callback(this,i[r],e,t)}));return i};query_raw=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()});return await r.call("sui_multiGetObjects",[e,t])};new_session=()=>(this.txb=new gs,this.txb);sessionCurrent=()=>this.txb?this.txb:this.new_session();sign_excute=async(e,t,r,s={showObjectChanges:!0})=>{const i=new ei({url:this.networkUrl()});e.forEach((e=>{e(this,r)}));const n=ea(t),a=Zn.fromSecretKey(n),o=await i.signAndExecuteTransaction({transaction:this.sessionCurrent(),signer:a,options:s});return this.txb=void 0,o};static SUI_TOKEN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";static SUI_COIN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<0x2::sui::SUI>";WOWOK_TOKEN_TYPE=()=>this.packages.get("base")+"::wowok::WOWOK";WOWOK_COIN_TYPE=()=>"0x2::coin::Coin<"+this.packages.get("base")+"::wowok::WOWOK>";COINS_TYPE=()=>{switch(this.network){case Go.testnet:return this.CoinTypes_Testnet.filter((e=>!0!==e.alias));case Go.mainnet:return this.CoinTypes_Mainnet.filter((e=>!0!==e.alias))}return[]};update_coinType=(e,t,r)=>{if(r&&e)switch(this.network){case Go.testnet:(s=this.CoinTypes_Testnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Testnet=s;break;case Go.mainnet:var s;(s=this.CoinTypes_Mainnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Mainnet=s}};explorerUrl=(e,t="object")=>this.network===Go.testnet?"https://testnet.suivision.xyz/"+t+"/"+e:this.network===Go.mainnet?"https://suivision.xyz/"+t+"/"+e:"";CoinTypes_Testnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:$o+"::wowok::WOWOK",decimals:9}];CoinTypes_Mainnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:$o+"::wowok::WOWOK",decimals:9},{symbol:"USDT",type:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",decimals:6},{symbol:"USDC",type:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",decimals:6},{symbol:"WETH",type:"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",decimals:8},{symbol:"WBNB",type:"0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN",decimals:8}];coinTypeInfo=(e,t)=>{if(!e)return"loading";return this.COINS_TYPE().find((t=>t?.type===e))||(zo.Client().getCoinMetadata({coinType:e}).then((r=>{r?.decimals&&r?.symbol&&(this.update_coinType(e,r?.decimals,r?.symbol),t({symbol:r.symbol,decimals:r.decimals,type:e}))})).catch((e=>{console.log(e)})),"loading")};static CLOCK_OBJECT={objectId:"0x6",mutable:!1,initialSharedVersion:1};static TXB_OBJECT(e,t){return"string"==typeof t?e.object(t):t}static IsValidObjects=e=>To(e,(e=>!(!e||"string"==typeof e&&!oe(e))));WOWOK_OBJECTS_TYPE=()=>Object.keys(Ao).map((e=>(e===Ao.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"+za(e)));WOWOK_OBJECTS_PREFIX_TYPE=()=>Object.keys(Ao).map((e=>(e===Ao.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"));hasPackage(e){for(let t of this.packages.values())if(e.includes(t))return!0;return!1}object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.lastIndexOf("::");if(r>0)return e.slice(r+2)}return""};module_object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.indexOf("::");if(r>0)return e.slice(r+2)}return""}}class qo{static Object_Type_Extra=()=>{let e=Object.keys(Ao).map((e=>e+"::"+za(e)));return e.push("order::Discount"),e};static objectids_from_response=(e,t,r)=>{let s=new Map;return t?.objectChanges&&t.objectChanges.forEach((t=>{qo.Object_Type_Extra().forEach((r=>{"created"==t.type&&e.module_object_name_from_type_repr(t.objectType)===r&&(s.has(r)?s.get(r)?.push(t.objectId):s.set(r,[t.objectId]))}))})),r&&s.forEach(((e,t)=>{r.has(t)?r.set(t,r.get(t).concat(e)):r.set(t,e)})),s}}class Wo{bounty_type;permission;object;txb;get_bounty_type(){return this.bounty_type}get_object(){return this.object}static From(e,t,r,s){let i=new Wo(e,t,r);return i.object=zo.TXB_OBJECT(e,s),i}constructor(e,t,r){this.bounty_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i,n,a){io(n)||Ba(Ca.IsValidDesription),fo(t)||Ba(Ca.IsValidArgType,t),mo(s)||Ba(Ca.IsValidUint,"time");let o=new Wo(e,t,i);const d=e.sharedObjectRef(zo.CLOCK_OBJECT);return o.object=a?e.moveCall({target:zo.Instance().demandFn("new_with_passport"),arguments:[a,e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),zo.TXB_OBJECT(e,i)],typeArguments:[t]}):e.moveCall({target:zo.Instance().demandFn("new"),arguments:[e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),zo.TXB_OBJECT(e,i)],typeArguments:[t]}),o}launch(){return this.txb.moveCall({target:zo.Instance().demandFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.bounty_type]})}refund(e){const t=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);e?this.txb.moveCall({target:zo.Instance().demandFn("refund_with_passport"),arguments:[e,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("refund"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}expand_time(e,t,r){mo(t)||Ba(Ca.IsValidUint,"time"),r?this.txb.moveCall({target:zo.Instance().demandFn("time_expand_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("time_expand"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_guard(e,t,r){e&&!zo.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"guard"),void 0===t||po(t)||Ba(Ca.InvalidParam,"set_guard.service_identifier");let s=this.txb.pure.option("u8",void 0!==t?t:void 0);r?e?this.txb.moveCall({target:zo.Instance().demandFn("guard_set_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),s,zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("guard_none_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):e?this.txb.moveCall({target:zo.Instance().demandFn("guard_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),s,zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("guard_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:zo.Instance().demandFn("description_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}yes(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:zo.Instance().demandFn("yes_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("yes"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}deposit(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:zo.Instance().demandFn("deposit"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]})}present(e,t,r,s){io(r)||Ba(Ca.IsValidDesription,"present.tips"),t&&!fo(t)&&Ba(Ca.IsValidArgType,"service_pay_type"),"number"==typeof e?po(e)&&s||Ba(Ca.IsValidU8,"present.service or present.passport"):zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"present.service"),s?"number"==typeof e?this.txb.moveCall({target:zo.Instance().demandFn("present_with_passport2"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(r)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:zo.Instance().demandFn("present_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]}):"number"!=typeof e&&this.txb.moveCall({target:zo.Instance().demandFn("present"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]})}change_permission(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:zo.Instance().demandFn("permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission),zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]}),this.permission=e}static parseObjectType=e=>La(e,"demand::Demand<");static MAX_BOUNTY_COUNT=300;static MAX_PRESENTERS_COUNT=200}var Ho;!function(e){e[e.repository=100]="repository",e[e.repository_description=101]="repository_description",e[e.repository_mode=102]="repository_mode",e[e.repository_policies=103]="repository_policies",e[e.repository_reference=104]="repository_reference",e[e.service=200]="service",e[e.service_description=201]="service_description",e[e.service_sales=202]="service_sales",e[e.service_payee=203]="service_payee",e[e.service_repository=204]="service_repository",e[e.service_withdraw_guards=205]="service_withdraw_guards",e[e.service_refund_guards=206]="service_refund_guards",e[e.service_discount_transfer=207]="service_discount_transfer",e[e.service_withdraw=208]="service_withdraw",e[e.service_buyer_guard=209]="service_buyer_guard",e[e.service_machine=210]="service_machine",e[e.service_endpoint=211]="service_endpoint",e[e.service_publish=212]="service_publish",e[e.service_clone=213]="service_clone",e[e.service_customer_required=214]="service_customer_required",e[e.service_pause=215]="service_pause",e[e.service_treasury=216]="service_treasury",e[e.service_arbitration=217]="service_arbitration",e[e.demand=260]="demand",e[e.demand_refund=261]="demand_refund",e[e.demand_expand_time=262]="demand_expand_time",e[e.demand_guard=263]="demand_guard",e[e.demand_description=264]="demand_description",e[e.demand_yes=265]="demand_yes",e[e.machine=600]="machine",e[e.machine_description=601]="machine_description",e[e.machine_repository=602]="machine_repository",e[e.machine_clone=604]="machine_clone",e[e.machine_node=606]="machine_node",e[e.machine_endpoint=608]="machine_endpoint",e[e.machine_pause=609]="machine_pause",e[e.machine_publish=610]="machine_publish",e[e.progress=650]="progress",e[e.progress_namedOperator=651]="progress_namedOperator",e[e.progress_bind_task=652]="progress_bind_task",e[e.progress_context_repository=653]="progress_context_repository",e[e.progress_unhold=654]="progress_unhold",e[e.progress_parent=655]="progress_parent",e[e.treasury=700]="treasury",e[e.treasury_receive=701]="treasury_receive",e[e.treasury_deposit=702]="treasury_deposit",e[e.treasury_withdraw=703]="treasury_withdraw",e[e.treasury_descritption=704]="treasury_descritption",e[e.treasury_deposit_guard=705]="treasury_deposit_guard",e[e.treasury_withdraw_mode=706]="treasury_withdraw_mode",e[e.treasury_withdraw_guard=707]="treasury_withdraw_guard",e[e.arbitration=800]="arbitration",e[e.arbitration_description=801]="arbitration_description",e[e.arbitration_fee=802]="arbitration_fee",e[e.arbitration_voting_guard=803]="arbitration_voting_guard",e[e.arbitration_endpoint=804]="arbitration_endpoint",e[e.arbitration_guard=805]="arbitration_guard",e[e.arbitration_pause=806]="arbitration_pause",e[e.arbitration_vote=807]="arbitration_vote",e[e.arbitration_arbitration=808]="arbitration_arbitration",e[e.arbitration_withdraw=809]="arbitration_withdraw",e[e.arbitration_treasury=810]="arbitration_treasury",e[e.user_defined_start=1e3]="user_defined_start"}(Ho||(Ho={}));const Ko=[{index:Ho.repository,name:"Repository",description:"Launch new Repository",module:Ao.repository},{index:Ho.repository_description,name:"Description",description:"Set Repository description",module:Ao.repository},{index:Ho.repository_mode,name:"Policy mode",description:"Set Repository mode",module:Ao.repository},{index:Ho.repository_policies,name:"Policy",description:"Set Repository policies",module:Ao.repository},{index:Ho.repository_reference,name:"Reference",description:"Set Repository reference",module:Ao.repository},{index:Ho.service,name:"Service",description:"Launch new Service",module:Ao.service},{index:Ho.service_description,name:"Description",description:"Set Service description",module:Ao.service},{index:Ho.service_sales,name:"Sales",description:"Set Service sales items",module:Ao.service},{index:Ho.service_payee,name:"Payee",description:"Set Service payee",module:Ao.service},{index:Ho.service_repository,name:"Repository",description:"Set Service repositories",module:Ao.service},{index:Ho.service_withdraw_guards,name:"Withdraw Guard",description:"Set Service withdraw guards",module:Ao.service},{index:Ho.service_refund_guards,name:"Refund Guard",description:"Set Service refund guards",module:Ao.service},{index:Ho.service_discount_transfer,name:"Discount",description:"Launch discounts for Service",module:Ao.service},{index:Ho.service_buyer_guard,name:"Buyer Guard",description:"Set Guard of buying for Service",module:Ao.service},{index:Ho.service_machine,name:"Machine",description:"Set Machine for Service",module:Ao.service},{index:Ho.service_endpoint,name:"Endpoint",description:"Set Service endpoint",module:Ao.service},{index:Ho.service_publish,name:"Publish",description:"Allowing the creation of Order",module:Ao.service},{index:Ho.service_clone,name:"Clone",description:"Clone Service",module:Ao.service},{index:Ho.service_customer_required,name:"Buyer info",description:"Set Service buyer info required",module:Ao.service},{index:Ho.service_pause,name:"Pause",description:"Pause/Unpause Service",module:Ao.service},{index:Ho.service_treasury,name:"Treasury",description:"Externally withdrawable treasury for compensation or rewards",module:Ao.service},{index:Ho.service_arbitration,name:"Arbitration",description:"Add/Remove arbitration that allows refunds from orders at any time based on arbitration results",module:Ao.service},{index:Ho.demand,name:"Demand",description:"Launch new Demand",module:Ao.demand},{index:Ho.demand_refund,name:"Refund",description:"Refund from Demand",module:Ao.demand},{index:Ho.demand_expand_time,name:"Expand deadline",description:"Expand Demand deadline",module:Ao.demand},{index:Ho.demand_guard,name:"Guard",description:"Set Demand guard",module:Ao.demand},{index:Ho.demand_description,name:"Description",description:"Set Demand description",module:Ao.demand},{index:Ho.demand_yes,name:"Yes",description:"Pick the Deamand serice",module:Ao.demand},{index:Ho.machine,name:"Machine",description:"Launch new Machine",module:Ao.machine},{index:Ho.machine_description,name:"Description",description:"Set Machine description",module:Ao.machine},{index:Ho.machine_repository,name:"Repository",description:"Set Machine repository",module:Ao.machine},{index:Ho.machine_clone,name:"Clone",description:"Clone Machine",module:Ao.machine},{index:Ho.machine_node,name:"Node",description:"Set Machine nodes",module:Ao.machine},{index:Ho.machine_endpoint,name:"Endpoint",description:"Set Machine endpoint",module:Ao.machine},{index:Ho.machine_pause,name:"Pause",description:"Pause/Unpause Machine",module:Ao.machine},{index:Ho.machine_publish,name:"Publish",description:"Allowing the creation of Progress",module:Ao.machine},{index:Ho.progress,name:"Progress",description:"Launch new Progress",module:Ao.progress},{index:Ho.progress_namedOperator,name:"Operator",description:"Set Progress operators",module:Ao.progress},{index:Ho.progress_bind_task,name:"Bind",description:"Set Progress task",module:Ao.progress},{index:Ho.progress_context_repository,name:"Repository",description:"Set Progress repository",module:Ao.progress},{index:Ho.progress_unhold,name:"Unhold",description:"Release Progress holdings",module:Ao.progress},{index:Ho.progress_parent,name:"Parent",description:"Set Progress parent",module:Ao.progress},{index:Ho.treasury,name:"Treasury",description:"Launch new Treasury",module:Ao.treasury},{index:Ho.treasury_deposit,name:"Deposit",description:"Deposit coins",module:Ao.treasury},{index:Ho.treasury_receive,name:"Receive",description:"Receive coins from some address sent",module:Ao.treasury},{index:Ho.treasury_withdraw,name:"Withdraw",description:"Withdraw coins",module:Ao.treasury},{index:Ho.treasury_withdraw_guard,name:"Withdraw Guard",description:"Add/Remove Treasury withdraw guard",module:Ao.treasury},{index:Ho.treasury_withdraw_mode,name:"Withdraw mode",description:"Set Treasury withdraw mode",module:Ao.treasury},{index:Ho.treasury_deposit_guard,name:"Deposit Guard",description:"Set Treasury deposit guard",module:Ao.treasury},{index:Ho.treasury_descritption,name:"Description",description:"Set Treasury description",module:Ao.treasury},{index:Ho.arbitration,name:"Arbitration",description:"Launch new Arbitration",module:Ao.arbitration},{index:Ho.arbitration_description,name:"Description",description:"Set Arbitration description",module:Ao.arbitration},{index:Ho.arbitration_endpoint,name:"Endpoint",description:"Set Arbitration endpoint",module:Ao.arbitration},{index:Ho.arbitration_fee,name:"Fee",description:"Set Arbitration fee",module:Ao.arbitration},{index:Ho.arbitration_guard,name:"Guard",description:"Set Guard to apply for arbitration",module:Ao.arbitration},{index:Ho.arbitration_arbitration,name:"Arbitrate",description:"Determine the outcome of arbitration",module:Ao.arbitration},{index:Ho.arbitration_pause,name:"Pause",description:"Allowing/forbidding the creation of Arb",module:Ao.arbitration},{index:Ho.arbitration_voting_guard,name:"Voting Guard",description:"Add/Remove voting Guard",module:Ao.arbitration},{index:Ho.arbitration_vote,name:"Vote",description:"Vote on the application for arbitration",module:Ao.arbitration},{index:Ho.arbitration_withdraw,name:"Withdraw",description:"Withdraw the arbitration fee",module:Ao.arbitration},{index:Ho.arbitration_treasury,name:"Withdraw",description:"Set Treasury that fees was collected at the time of withdrawal",module:Ao.arbitration}];class Qo{txb;object;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new Qo(e);return r.object=zo.TXB_OBJECT(e,t),r}static New(e,t){io(t)||Ba(Ca.IsValidDesription);let r=new Qo(e);return r.object=e.moveCall({target:zo.Instance().permissionFn("new"),arguments:[e.pure.string(t)]}),r}launch(){return this.txb.moveCall({target:zo.Instance().permissionFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}add_bizPermission(e,t){Qo.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"add_bizPermission"),no(t)||Ba(Ca.IsValidName,"add_bizPermission"),this.txb.moveCall({target:zo.Instance().permissionFn("user_define_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),this.txb.pure.string(t)]})}remove_bizPermission(e){Qo.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"remove_bizPermission"),this.txb.moveCall({target:zo.Instance().permissionFn("user_define_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e)]})}transfer_permission(e,t){co(e)&&co(t)||Ba(Ca.IsValidAddress,"transfer_permission"),this.txb.moveCall({target:zo.Instance().permissionFn("change_entity"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.address(t)]})}add_entity2(e,t){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray,"add_entity2"),void 0!==t?this.txb.moveCall({target:zo.Instance().permissionFn("add_with_index"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(t),this.txb.pure.vector("address",$a(e))]}):this.txb.moveCall({target:zo.Instance().permissionFn("add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}add_entity3(e){if(0===e.length)return;const t=[];e.forEach((e=>{e.entities.forEach((r=>{const s=t.find((e=>e.address===r.address));if(s){const t=s.permissions.find((t=>t.index===e.index));t?t.guard=r.guard:s.permissions.push({guard:r.guard,index:e.index})}else t.push({address:r.address,permissions:[{guard:r.guard,index:e.index}]})}))})),this.add_entity(t)}add_entity(e){if(0===e.length)return;let t=!0;e.forEach((e=>{co(e.address)||(t=!1),e.permissions.forEach((e=>{Qo.IsValidPermissionIndex(e.index)||(t=!1),e?.guard&&!zo.IsValidObjects([e.guard])&&(t=!1)}))})),t||Ba(Ca.InvalidParam,"add_entity.entities");let r=[];for(let t=0;t<e.length;t++){let s=e[t],i=[];for(let e=0;e<s.permissions.length;e++){let t=s.permissions[e];Qo.IsValidPermissionIndex(t.index)&&(i.includes(t.index)||(i.push(t.index),t?.guard&&r.push({address:s.address,index:t.index,guard:t.guard})))}i.length>0&&this.txb.moveCall({target:zo.Instance().permissionFn("add_batch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(s.address),this.txb.pure.vector("u64",i)]})}r.forEach((({address:e,index:t,guard:r})=>{this.txb.moveCall({target:zo.Instance().permissionFn("guard_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),zo.TXB_OBJECT(this.txb,r)]})}))}set_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"address"),Qo.IsValidPermissionIndex(t)||Qo.IsValidBizPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex,"index"),r?this.txb.moveCall({target:zo.Instance().permissionFn("guard_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),zo.TXB_OBJECT(this.txb,r)]}):this.txb.moveCall({target:zo.Instance().permissionFn("guard_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t)]})}remove_index(e,t){co(e)||Ba(Ca.IsValidAddress),0!==t.length&&(To(t,Qo.IsValidPermissionIndex)||Ba(Ca.InvalidParam,"index"),this.txb.moveCall({target:zo.Instance().permissionFn("remove_index"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.vector("u64",$a(t))]}))}remove_entity(e){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:zo.Instance().permissionFn("remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}set_description(e){io(e)||Ba(Ca.IsValidDesription),this.txb.moveCall({target:zo.Instance().permissionFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}add_admin(e){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:zo.Instance().permissionFn("admin_add_batch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}remove_admin(e,t){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"admin"),t?this.txb.moveCall({target:zo.Instance().permissionFn("admins_clear"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]}):e&&this.txb.moveCall({target:zo.Instance().permissionFn("admin_remove_batch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e))]}))}change_owner(e){co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:zo.Instance().permissionFn("builder_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}query_permissions_all(e){co(e)||Ba(Ca.InvalidParam,"query_permissions"),this.txb.moveCall({target:zo.Instance().permissionFn("query_permissions_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}QueryPermissions(e,t,r,s){this.query_permissions_all(t),zo.Client().devInspectTransactionBlock({sender:s??t,transactionBlock:this.txb}).then((s=>{if(s.results&&s.results[0].returnValues&&2!==s.results[0].returnValues.length)return void r({who:t,object:e});const i=Wa.getInstance().de(Oa.U8,Uint8Array.from(s.results[0].returnValues[0][0]));if(i===Qo.PERMISSION_ADMIN||i===Qo.PERMISSION_OWNER_AND_ADMIN)r({who:t,admin:!0,owner:i%2==1,items:[],object:e});else{const n=Wa.getInstance().de_perms(Uint8Array.from(s.results[0].returnValues[1][0]));r({who:t,admin:!1,owner:i%2==1,items:n.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e})}})).catch((s=>{console.log(s),r({who:t,object:e})}))}static HasPermission(e,t,r=!1){if(e){if(e.admin)return{has:!0,owner:e.owner};let r=e.items?.find((e=>e.query==t));return r?{has:r.permission,guard:r.guard,owner:e.owner}:{has:!1,guard:void 0,owner:e?.owner}}if(r)return{has:!1,guard:void 0,owner:!1}}static MAX_ADMIN_COUNT=64;static MAX_ENTITY_COUNT=2e3;static MAX_PERMISSION_INDEX_COUNT=200;static MAX_PERSONAL_PERMISSION_COUNT=200;static PERMISSION_NORMAL=0;static PERMISSION_OWNER=1;static PERMISSION_ADMIN=2;static PERMISSION_OWNER_AND_ADMIN=3;static BUSINESS_PERMISSIONS_START=Ho.user_defined_start;static IsValidBizPermissionIndex=e=>e>=Qo.BUSINESS_PERMISSIONS_START&&mo(e);static IsValidPermissionIndex=e=>!!Object.values(Ho).includes(e)||Qo.IsValidBizPermissionIndex(e)}class Zo{txb;object;permission;get_object(){return this.object}static From(e,t,r){let s=new Zo(e,t);return s.object=zo.TXB_OBJECT(e,r),s}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static New(e,t,r,s,i){zo.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription),s&&!oo(s)&&Ba(Ca.IsValidEndpoint);let n=new Zo(e,t),a=e.pure.option("string",s||void 0);return n.object=i?e.moveCall({target:zo.Instance().machineFn("new_with_passport"),arguments:[i,e.pure.string(r),a,zo.TXB_OBJECT(e,t)]}):e.moveCall({target:zo.Instance().machineFn("new"),arguments:[e.pure.string(r),a,zo.TXB_OBJECT(e,t)]}),n}add_node(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{no(e.name)||(r=!1),e.pairs.forEach((e=>{ao(e.prior_node)||(r=!1),e?.threshold&&!yo(e.threshold)&&(r=!1),e.forwards.forEach((e=>{""!==Zo.checkValidForward(e)&&(r=!1)}))}))})),r||Ba(Ca.InvalidParam,"add_node");let s=[];e.forEach((e=>{let t=this.txb.moveCall({target:zo.Instance().machineFn("node_new"),arguments:[this.txb.pure.string(e.name)]});e.pairs.forEach((e=>{let r=this.txb.pure.option("u32",e?.threshold);e.forwards.forEach((s=>{this.txb.moveCall({target:zo.Instance().machineFn("forward_add"),arguments:[t,this.txb.pure.string(e.prior_node),this.txb.pure.string(s.name),r,this.forward(s)]})})),0===e.forwards.length&&this.txb.moveCall({target:zo.Instance().machineFn("forward_add_none"),arguments:[t,this.txb.pure.string(e.prior_node),r]})})),s.push(t)})),this.add_node2(s,t)}forward(e){let t,r=e?.weight?e.weight:1;return e?.namedOperator&&no(e.namedOperator)?t=e?.guard?this.txb.moveCall({target:zo.Instance().machineFn("forward"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r),this.txb.object(zo.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:zo.Instance().machineFn("forward2"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r)]}):void 0!==e?.permission&&mo(e.permission)?t=e?.guard?this.txb.moveCall({target:zo.Instance().machineFn("forward3"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r),this.txb.object(zo.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:zo.Instance().machineFn("forward4"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r)]}):Ba(Ca.InvalidParam,"forward"),e?.suppliers?.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"forward.suppliers:"+e.object),this.txb.moveCall({target:zo.Instance().serviceFn("add_to"),arguments:[this.txb.object(e.object),this.txb.pure.bool(e.bOptional),t],typeArguments:[e.pay_token_type]})})),t}add_node2(e,t){if(0===e.length)return;let r=e.map((e=>zo.TXB_OBJECT(this.txb,e)));t?this.txb.moveCall({target:zo.Instance().machineFn("node_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),zo.TXB_OBJECT(this.txb,this.permission)]})}fetch_node(e,t){return no(e)||Ba(Ca.IsValidName,"fetch_node"),t?this.txb.moveCall({target:zo.Instance().machineFn("node_fetch_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_fetch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)]})}rename_node(e,t,r){e!==t&&(no(e)||Ba(Ca.IsValidName,"rename_node"),no(t)||Ba(Ca.IsValidName,"rename_node"),r?this.txb.moveCall({target:zo.Instance().machineFn("node_rename_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_rename"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}))}remove_node(e,t=!1,r){0!==e.length&&(To(e,no)||Ba(Ca.IsValidArray,"nodes_name"),r?this.txb.moveCall({target:zo.Instance().machineFn("node_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),zo.TXB_OBJECT(this.txb,this.permission)]}))}launch(){return this.txb.moveCall({target:zo.Instance().machineFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:zo.Instance().machineFn("description_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)]})}add_repository(e,t){t?this.txb.moveCall({target:zo.Instance().machineFn("repository_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("repository_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)]})}remove_repository(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_repository"),r?t?this.txb.moveCall({target:zo.Instance().machineFn("repository_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.object)]}):this.txb.moveCall({target:zo.Instance().machineFn("repository_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:zo.Instance().machineFn("repository_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("repository_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}))}clone(e,t){let r;return r=t?this.txb.moveCall({target:zo.Instance().machineFn("clone_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("clone"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}),e?this.txb.moveCall({target:zo.Instance().machineFn("create"),arguments:[zo.TXB_OBJECT(this.txb,r)]}):r}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:zo.Instance().machineFn("endpoint_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),r,zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("endpoint_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),r,zo.TXB_OBJECT(this.txb,this.permission)]})}pause(e,t){t?this.txb.moveCall({target:zo.Instance().machineFn("pause_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("pause"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),zo.TXB_OBJECT(this.txb,this.permission)]})}publish(e){e?this.txb.moveCall({target:zo.Instance().machineFn("publish_with_passport"),arguments:[e,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("publish"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"new_permission"),this.txb.moveCall({target:zo.Instance().machineFn("permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission),zo.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}add_forward(e,t,r,s,i,n){ao(e)||Ba(Ca.IsValidName_AllowEmpty,"add_forward"),no(t)||Ba(Ca.IsValidName,"add_forward");const a=Zo.checkValidForward(r);let o;a&&Ba(Ca.InvalidParam,a),o=n?this.txb.moveCall({target:zo.Instance().machineFn("node_fetch_with_passport"),arguments:[n,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_fetch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]});const d=this.forward(r),c=this.txb.pure.option("u32",s);this.txb.moveCall({target:zo.Instance().machineFn("forward_add"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(r.name),c,d]}),i&&i!==r.name&&this.txb.moveCall({target:zo.Instance().machineFn("forward_remove"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(i)]}),this.add_node2([o],n)}remove_pair(e,t,r){let s;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_pair"),no(t)||Ba(Ca.IsValidName,"remove_pair"),s=r?this.txb.moveCall({target:zo.Instance().machineFn("node_fetch_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_fetch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:zo.Instance().machineFn("pair_remove"),arguments:[s,this.txb.pure.string(e)]}),this.add_node2([s],r)}remove_forward(e,t,r,s){let i;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_forward"),no(t)||Ba(Ca.IsValidName,"remove_forward"),i=s?this.txb.moveCall({target:zo.Instance().machineFn("node_fetch_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().machineFn("node_fetch"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:zo.Instance().machineFn("forward_remove"),arguments:[i,this.txb.pure.string(e),this.txb.pure.string(r)]}),this.add_node2([i],s)}static rpc_de_nodes(e){const t=[];return e.forEach((e=>{t.push({name:e.data.content.fields.name,pairs:Zo.rpc_de_pair(e?.data.content.fields.value)})})),t}static rpc_de_pair(e){let t=[];return e.fields.value.fields.contents.forEach((e=>{let r=[];e.fields.value.fields.forwards.fields.contents.forEach((e=>{let t=e.fields.key,s=e.fields.value.fields.weight,i=e.fields.value.fields.guard,n=e.fields.value.fields.namedOperator,a=e.fields.value.fields.permission_index;r.push({name:t,namedOperator:n,permission:a,weight:s,guard:i||"",suppliers:e.fields.value.fields.suppliers.fields.contents.map((e=>({object:e.fields.key,bOptional:e.fields.value,pay_token_type:""})))})})),t.push({prior_node:e.fields.key,threshold:e.fields.value.fields.threshold,forwards:r})})),t}static namedOperators(e){let t=[];return e.forEach((e=>{e.pairs.forEach((e=>{e.forwards.forEach((e=>{e?.namedOperator&&!t.find((t=>t===e.namedOperator))&&t.push(e.namedOperator)}))}))})),t}static checkValidForward(e){return no(e.name)?e?.namedOperator&&!ao(e?.namedOperator)?"Progress Operator invalid":e?.permission&&!Qo.IsValidPermissionIndex(e?.permission)?"Permission index invalid":e?.permission||e?.namedOperator?e?.weight&&!mo(e.weight)?"Weight invalid":"":"Business-Permissions invalid":"Forward name invalid"}static INITIAL_NODE_NAME="";static OPERATOR_ORDER_PAYER="OrderPayer"}class ed{permission;machine;object;txb;get_object(){return this.object}constructor(e,t,r){this.permission=r,this.txb=e,this.machine=t,this.object=""}static From(e,t,r,s){let i=new ed(e,t,r);return i.object=zo.TXB_OBJECT(e,s),i}static New(e,t,r,s,i){zo.IsValidObjects([t,r])||Ba(Ca.IsValidObjects,"machine & permission");let n=new ed(e,t,r),a=e.pure.option("address",s||void 0);return n.object=i?e.moveCall({target:zo.Instance().progressFn("new_with_passport"),arguments:[i,a,zo.TXB_OBJECT(e,t),zo.TXB_OBJECT(e,r)]}):e.moveCall({target:zo.Instance().progressFn("new"),arguments:[a,zo.TXB_OBJECT(e,t),zo.TXB_OBJECT(e,r)]}),n}launch(){return this.txb.moveCall({target:zo.Instance().progressFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}set_namedOperator(e,t,r){no(e)||Ba(Ca.IsValidName,"name"),e===Zo.OPERATOR_ORDER_PAYER&&Ba(Ca.InvalidParam,"name cannot be "+Zo.OPERATOR_ORDER_PAYER),(t.length>ed.MAX_NAMED_OPERATOR_COUNT||!To(t,co))&&Ba(Ca.InvalidParam,"addresses"),r?this.txb.moveCall({target:zo.Instance().progressFn("namedOperator_set_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",$a(t)),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().progressFn("namedOperator_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",$a(t)),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]})}bind_task(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:zo.Instance().progressFn("task_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().progressFn("task_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]})}set_context_repository(e,t){e&&!zo.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"repository"),t?e?this.txb.moveCall({target:zo.Instance().progressFn("context_repository_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().progressFn("context_repository_none_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]}):e?this.txb.moveCall({target:zo.Instance().progressFn("context_repository_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().progressFn("context_repository_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]})}unhold(e,t){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"unhold");const r=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);t?this.txb.moveCall({target:zo.Instance().progressFn("unhold_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),zo.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]}):this.txb.moveCall({target:zo.Instance().progressFn("unhold"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),zo.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}parent_none(e){e?this.txb.moveCall({target:zo.Instance().progressFn("parent_none_with_passport"),arguments:[e,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().progressFn("parent_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),zo.TXB_OBJECT(this.txb,this.permission)]})}parent(e,t){co(e.parent_id)&&yo(e.parent_session_id)||Ba(Ca.InvalidParam,"parent"),e.next_node&&e.forward||Ba(Ca.InvalidParam,"parent"),t?this.txb.moveCall({target:zo.Instance().progressFn("parent_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().progressFn("parent_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),zo.TXB_OBJECT(this.txb,this.permission)]})}deliverable(e){io(e.msg)||Ba(Ca.IsValidDesription,"deliverable.msg"),e.orders.length>0&&!zo.IsValidObjects(e.orders.map((e=>e.object)))&&Ba(Ca.IsValidObjects,"deliverable.orders");const t=this.txb.moveCall({target:zo.Instance().progressFn("deliverable_new"),arguments:[this.txb.pure.string(e.msg)]});return e.orders.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"deliverable.orders:"+e.object),this.txb.moveCall({target:zo.Instance().orderFn("as_deliverable"),arguments:[this.txb.object(e.object),t],typeArguments:[e.pay_token_type]})})),t}next(e,t,r){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"next");const s=this.deliverable(t),i=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return r?this.txb.moveCall({target:zo.Instance().progressFn("next_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,zo.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]}):this.txb.moveCall({target:zo.Instance().progressFn("next"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,zo.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]})}hold(e,t){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"hold");const r=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return this.txb.moveCall({target:zo.Instance().progressFn("hold"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),this.txb.pure.bool(t),zo.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}static QueryForwardGuard=async(e,t,r,s,i)=>{if(!(e&&t&&s&&i))return void Ba(Ca.InvalidParam,"QueryForwardGuard");const n=new gs;n.moveCall({target:zo.Instance().progressFn("query_guard"),arguments:[zo.TXB_OBJECT(n,e),zo.TXB_OBJECT(n,t),n.pure.string(s),n.pure.string(i)]});const a=await zo.Client().devInspectTransactionBlock({sender:r,transactionBlock:n});if(1===a.results?.length&&1===a.results[0].returnValues?.length){const e=Wa.getInstance().de("Option<address>",Uint8Array.from(a.results[0].returnValues[0][0]));return e?.some?"0x"+e?.some:void 0}};static DeSessions=e=>{let t=[];return e?.fields?.contents?.forEach((e=>{var r={next_node:e.fields.key,holders:[],weights:e.fields.value.fields.weights,threshold:e.fields.value.fields.threshold};e.fields.value.fields.forwards.fields.contents.forEach((e=>{r.holders.push({forward:e.fields.key,accomplished:e.fields.value.fields.accomplished,time:e.fields.value.fields.time,who:e.fields.value.fields.who,deliverable:{msg:e.fields.value.fields.msg,orders:e.fields.value.fields.orders??[]}})})),t.push(r)})),t};static DeHistories=e=>e?.map((e=>ed.DeHistory(e?.data?.content?.fields)));static DeHistory=e=>({id:parseInt(e?.name),node:e?.value?.fields?.node,next_node:e?.value?.fields?.next_node,sessions:ed.DeSessions(e?.value.fields?.session),time:e?.value?.fields?.time});static MAX_NAMED_OPERATOR_COUNT=20;static MAX_DELEVERABLE_ORDER_COUNT=20;static IsValidProgressNext=e=>no(e.forward)&&no(e.next_node_name)}const td=[[Ao.permission,"Owner",1,[],No.TYPE_ADDRESS,"Owner's address."],[Ao.permission,"Is Admin",2,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Is a certain address an administrator?",["address"]],[Ao.permission,"Has Rights",3,[No.TYPE_ADDRESS,No.TYPE_U64],No.TYPE_BOOL,"Does an address have a certain permission(Admin always have permissions)?",["address","permission index"]],[Ao.permission,"Contains Address",4,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether an address is included in the personnel permission table?",["address"]],[Ao.permission,"Contains Permission",5,[No.TYPE_ADDRESS,No.TYPE_U64],No.TYPE_BOOL,"Whether a certain permission for a certain address is defined in the personnel permission table?",["address","permission index"]],[Ao.permission,"Contains Permission Guard",6,[No.TYPE_ADDRESS,No.TYPE_U64],No.TYPE_BOOL,"Whether a permission guard for a certain address is defined in the personnel permission table?",["address","permission index"]],[Ao.permission,"Permission Guard",7,[No.TYPE_ADDRESS,No.TYPE_U64],No.TYPE_ADDRESS,"Permission guard for a certain address.",["address","permission index"]],[Ao.permission,"Number of Entities",8,[],No.TYPE_U64,"Number of entities in the personnel permission table.",[]],[Ao.permission,"Number of Admin",9,[],No.TYPE_U64,"Number of administrators.",[]],[Ao.repository,"Permission",100,[],No.TYPE_ADDRESS,"Permission object address.",[]],[Ao.repository,"Contains Policy",101,[No.TYPE_STRING],No.TYPE_BOOL,"Is a consensus policy included?",["the filed name"]],[Ao.repository,"Is Permission set of Policy",102,[No.TYPE_STRING],No.TYPE_BOOL,"Does a certain consensus policy set data operation permissions?",["the policy name"]],[Ao.repository,"Permission of Policy",103,[No.TYPE_STRING],No.TYPE_U64,"The permission index of a certain consensus policy in the Permission object.",["the policy name"]],[Ao.repository,"Value Type of Policy",104,[No.TYPE_STRING],No.TYPE_U8,"Data types defined by consensus policy.",["the policy name"]],[Ao.repository,"Contains Data",105,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_BOOL,"Does it contain data for a certain field of an address?",["address","the field name"]],[Ao.repository,"Raw data without Type",106,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_VEC_U8,"Data for a field at an address and does not contain data type information.",["address","the field name"]],[Ao.repository,"Raw data",107,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_VEC_U8,"Data for a field at an address, and the first byte contains data type information.",["address","the field name"]],[Ao.repository,"Type",108,[],No.TYPE_U8,"The repository Type. 0: Normal; 1: Wowok greenee.",[]],[Ao.repository,"Policy Mode",109,[],No.TYPE_U8,"Policy Mode. 0: Free mode; 1: Strict mode.",[]],[Ao.repository,"Reference Count",110,[],No.TYPE_U64,"The number of times it is referenced by other objects.",[]],[Ao.repository,"Is Referenced by An Object",111,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Is it referenced by an object?",["address"]],[Ao.repository,"Number Data",112,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_U256,"Data for a field at an address and get unsigned integer type data.",["address","the field name"]],[Ao.repository,"String Data",113,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_STRING,"Data for a field at an address and get string type data.",["address","the field name"]],[Ao.repository,"Address Data",114,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_ADDRESS,"Data for a field at an address and get address type data.",["address","the field name"]],[Ao.repository,"Bool Data",115,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_BOOL,"Data for a field at an address and get bool type data.",["address","the field name"]],[Ao.repository,"Number Vector Data",116,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_VEC_U256,"Data for a field at an address and get unsigned integer vector type data.",["address","the field name"]],[Ao.repository,"String Vector Data",117,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_VEC_STRING,"Data for a field at an address and get string vector type data.",["address","the field name"]],[Ao.repository,"Address Vector Data",118,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_VEC_ADDRESS,"Data for a field at an address and get address vector type data.",["address","the field name"]],[Ao.repository,"Bool Vector Data",119,[No.TYPE_ADDRESS,No.TYPE_STRING],No.TYPE_VEC_BOOL,"Data for a field at an address and get bool vector type data.",["address","the field name"]],[Ao.entity,"Has Entity",200,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Is an entity already registered?",["address"]],[Ao.entity,"Likes",201,[No.TYPE_ADDRESS],No.TYPE_U64,"The number of likes for an address by other addresses.",["address"]],[Ao.entity,"Dislikes",202,[No.TYPE_ADDRESS],No.TYPE_U64,"The number of dislikes for an address by other addresses.",["address"]],[Ao.entity,"Entity Info",203,[No.TYPE_ADDRESS],No.TYPE_VEC_U8,"Public information about an entity.",["address"]],[Ao.entity,"Has Resource by Entity?",204,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether an entity created a resource?",["address"]],[Ao.entity,"Entity Resource",205,[No.TYPE_ADDRESS],No.TYPE_ADDRESS,"The address of a resource object created by an entity.",["address"]],[Ao.demand,"Permission",300,[],No.TYPE_ADDRESS,"Permission object address.",[]],[Ao.demand,"Deadline",302,[],No.TYPE_U64,"The expiration time of presenting.",[]],[Ao.demand,"Bounty Count",303,[],No.TYPE_U64,"Number of Bounties.",[]],[Ao.demand,"Has Guard",304,[],No.TYPE_BOOL,"Whether the present guard is set?",[]],[Ao.demand,"Guard",305,[],No.TYPE_ADDRESS,"The present guard address.",[]],[Ao.demand,"Has Service Picked",306,[],No.TYPE_BOOL,"Whether a service has been picked and bounties given?",[]],[Ao.demand,"Service Picked",307,[],No.TYPE_ADDRESS,"Service address that has been picked.",[]],[Ao.demand,"Presenter Count",308,[],No.TYPE_U64,"Number of presenters.",[]],[Ao.demand,"Has Presenter",309,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Is a certain address a presenter?",["address"]],[Ao.demand,"Who Got Bounty",310,[No.TYPE_ADDRESS],No.TYPE_ADDRESS,"The address that bounties given.",["address"]],[Ao.service,"Permission",400,[],No.TYPE_ADDRESS,"Permission object address.",[]],[Ao.service,"Payee",401,[],No.TYPE_ADDRESS,"Payee address, that all order withdrawals will be collected to this address.",[]],[Ao.service,"Has Buying Guard",402,[],No.TYPE_BOOL,"Is the guard condition of buying set?",[]],[Ao.service,"Buying Guard",403,[],No.TYPE_ADDRESS,"Buying guard, that Purchase only if you meet the conditions of the guard.",[]],[Ao.service,"Contains Repository",404,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Is a certain repository one of the service's consensus repositories?",["address"]],[Ao.service,"Has Withdrawing Guard",405,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether a certain guard is set when withdrawing money?",["address"]],[Ao.service,"Withdrawing Guard Percent",406,[No.TYPE_ADDRESS],No.TYPE_U64,"The percentage of withdrawals allowed by a certain withdrawal guard.",["address"]],[Ao.service,"Has Refunding Guard",407,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether a certain guard is set when refunding money?",["address"]],[Ao.service,"Refunding Guard Percent",408,[No.TYPE_ADDRESS],No.TYPE_U64,"The percentage of refund allowed by a certain refund guard.",["address"]],[Ao.service,"Has Sales Item",409,[No.TYPE_STRING],No.TYPE_BOOL,"Is there a sales item for the service?",["the item name"]],[Ao.service,"Sale Item Price",410,[No.TYPE_STRING],No.TYPE_U64,"What is the price of a certain sale item?",["the item name"]],[Ao.service,"Sale Item Inventory",411,[No.TYPE_STRING],No.TYPE_U64,"How much inventory is there for a certain sales item?",["the item name"]],[Ao.service,"Has Machine",412,[],No.TYPE_BOOL,"Has the machine(progress generator) that serves the order been set up?",[]],[Ao.service,"Machine",413,[],No.TYPE_ADDRESS,"Machine address, that generate progresses serving the execution process of order.",[]],[Ao.service,"Paused",414,[],No.TYPE_BOOL,"Pause the creation of new order?"],[Ao.service,"Published",415,[],No.TYPE_BOOL,"Is it allowed to create orders?"],[Ao.service,"Has Required Info",416,[],No.TYPE_BOOL,"Whether the necessary information that needs to be provided by the customer is set?",[]],[Ao.service,"Required Info of Service-Pubkey",417,[],No.TYPE_STRING,"The public key used to encrypt customer information, and only the service provider can decrypt and view customer information.",[]],[Ao.service,"Required Info",418,[],No.TYPE_VEC_STRING,"Names of the required information item that needs to be provided by the customer.",[]],[Ao.service,"Number of Treasuries",419,[],No.TYPE_U64,"The number of treasuries that can be externally withdrawn for purposes such as compensation or incentives.",[]],[Ao.service,"Contains Treasury",420,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Does it contain externally withdrawable Treasury for purposes such as compensation or incentives?",["treasury address"]],[Ao.service,"Number of Arbitrations",421,[],No.TYPE_U64,"The number of arbitrations that allows a refund to be made from the order at any time based on the arbitration result.",[]],[Ao.service,"Contains Arbitration",422,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Does it contain an arbitration that allows a refund to be made from the order at any time based on the arbitration result.?",["arbitration address"]],[Ao.order,"Amount",500,[],No.TYPE_U64,"Order amount.",[]],[Ao.order,"Payer",501,[],No.TYPE_ADDRESS,"Order payer.",[]],[Ao.order,"Service",502,[],No.TYPE_ADDRESS,"Service for creating orders.",[]],[Ao.order,"Has Progress",503,[],No.TYPE_BOOL,"Is there a Progress for executing the order process?",[]],[Ao.order,"Progress",504,[],No.TYPE_ADDRESS,"Progress address for executing the order process.",[]],[Ao.order,"Required Info",505,[],No.TYPE_BOOL,"Is Required Info set?",[]],[Ao.order,"Discount Used",506,[],No.TYPE_BOOL,"Discount coupon used for this order?",[]],[Ao.order,"Discount",507,[],No.TYPE_ADDRESS,"Discount address that already used.",[]],[Ao.order,"Balance",508,[],No.TYPE_U64,"The amount currently in the order.",[]],[Ao.order,"Number of Agents",511,[],No.TYPE_U64,"The number of agents for the order.",[]],[Ao.order,"Has Agent",512,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether an address is an order agent?",["agent address"]],[Ao.order,"Number of Disputes",513,[],No.TYPE_U64,"Number of arbitrations for the order.",[]],[Ao.order,"Has Arb",514,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Does the order contain an Arb for arbitration?",["arb address"]],[Ao.machine,"Permission",700,[],No.TYPE_ADDRESS,"Permission object address.",[]],[Ao.machine,"Paused",701,[],No.TYPE_BOOL,"Pause the creation of new Progress?",[]],[Ao.machine,"Published",702,[],No.TYPE_BOOL,"Is it allowed to create Progress?",[]],[Ao.machine,"Is Consensus Repository",703,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether an address is a consensus repository?",["adddress"]],[Ao.machine,"Has Endpoint",704,[],No.TYPE_BOOL,"Is the endpoint set?",[]],[Ao.machine,"Endpoint",705,[],No.TYPE_STRING,"Endpoint url/ipfs.",[]],[Ao.progress,"Machine",800,[],No.TYPE_ADDRESS,"The Machine object that created this Progress.",[]],[Ao.progress,"Current Node",801,[],No.TYPE_STRING,"The name of the currently running node.",[]],[Ao.progress,"Has Parent",802,[],No.TYPE_BOOL,"Is the parent Progress defined?",[]],[Ao.progress,"Parent",803,[],No.TYPE_ADDRESS,"The parent Progress, that contains some child Progress.",[]],[Ao.progress,"Has Task",804,[],No.TYPE_BOOL,"Does it contain clear task(eg. an Order)?",[]],[Ao.progress,"Task",805,[],No.TYPE_ADDRESS,"Task object address.",[]],[Ao.progress,"Has Unique Permission",806,[No.TYPE_STRING],No.TYPE_BOOL,"Does Progress define a unique operation permission?",["operator name"]],[Ao.progress,"Is Unique Permission Operator",807,[No.TYPE_STRING,No.TYPE_ADDRESS],No.TYPE_BOOL,"Is an address an operator with unique permissions?",["operator name","address"]],[Ao.progress,"Has Context Repository",808,[],No.TYPE_BOOL,"Whether the repository reference for Progress is set?",[]],[Ao.progress,"Context Repository",809,[],No.TYPE_ADDRESS,"Repository reference for Progress.",[]],[Ao.progress,"Last Session Time",810,[],No.TYPE_U64,"Time when the previous session was completed.",[]],[Ao.progress,"Last Session Node",811,[],No.TYPE_STRING,"The name of the last completed node.",[]],[Ao.progress,"Current Session-id",812,[],No.TYPE_U64,"The session id of ongoing node.",[]],[Ao.progress,"Parent Session-id",813,[],No.TYPE_U64,"The child process was started in the Session-id phase of the parent process.",[]],[Ao.progress,"Parent Next Node",814,[],No.TYPE_STRING,"The child process is started at the next node stage of the parent process.",[]],[Ao.progress,"Parent Forward",815,[],No.TYPE_STRING,"The child process is started in the Forward phase of the next node of the parent process.",[]],[Ao.progress,"Parent Node",816,[],No.TYPE_STRING,"The node name of the parent process where the child process is located.",[]],[Ao.progress,"Forward Accomplished",817,[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_BOOL,"Has the forward been accomplished?",["session-id","next node name","forward name"]],[Ao.progress,"Forward Operator",818,[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_ADDRESS,"The forward operator.",["session-id","next node name","forward name"]],[Ao.progress,"Forward Message",819,[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_STRING,"The forward message.",["session-id","next node name","forward name"]],[Ao.progress,"Forward Order Count",820,[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_U64,"The forward Order count.",["session-id","next node name","forward name"]],[Ao.progress,"Forward time",821,[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_U64,"The time when the forward was last triggered.",["session-id","next node name","forward name"]],[Ao.progress,"Closest Session Time",822,[No.TYPE_STRING],No.TYPE_U64,"The time a node that closest time to the current node completes its session.",["node name"]],[Ao.progress,"Closest Forward Accomplished",823,[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_BOOL,"Has the forward been accomplished?",["node name","next node name","forward name"]],[Ao.progress,"Closest Forward Operator",824,[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_ADDRESS,"The operator of the forward that closest time to the current node.",["node name","next node name","forward name"]],[Ao.progress,"Closest Forward Message",825,[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_STRING,"The message of the forward that closest time to the current node.",["node name","next node name","forward name"]],[Ao.progress,"Closest Forward Order Count",826,[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_U64,"The Order count of the forward that closest time to the current node.",["node name","next node name","forward name"]],[Ao.progress,"Closest Forward time",827,[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],No.TYPE_U64,"The time when the forward that closest time to the current node was last triggered.",["node name","next node name","forward name"]],[Ao.wowok,"Builder",900,[],No.TYPE_ADDRESS,"Builder address of Wowok.",[]],[Ao.wowok,"Object of Entities",901,[],No.TYPE_ADDRESS,"The address of entity information object.",[]],[Ao.wowok,"Grantor Count",902,[],No.TYPE_U64,"Number of registered grantors.",[]],[Ao.wowok,"Has Grantor",903,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether an address has been registered as a grantor?",["address"]],[Ao.wowok,"Grantor Name",904,[No.TYPE_ADDRESS],No.TYPE_STRING,"Name of a grantor.",["address"]],[Ao.wowok,"Grantor Registration Time",905,[No.TYPE_ADDRESS],No.TYPE_U64,"Registration time of a grantor.",["address"]],[Ao.wowok,"Grantor Expired Time",906,[No.TYPE_ADDRESS],No.TYPE_U64,"The expiration time of a grantor.",["address"]],[Ao.wowok,"Grantee Object for Grantor",907,[No.TYPE_ADDRESS],No.TYPE_ADDRESS,"Grantee repository address of a grantor.",["address"]],[Ao.payment,"Sender",1200,[],No.TYPE_ADDRESS,"Payment originator address.",[]],[Ao.payment,"Total Amount",1201,[],No.TYPE_U128,"Payment amount.",[]],[Ao.payment,"Remark",1202,[],No.TYPE_STRING,"Payment remark.",["address"]],[Ao.payment,"Has Guard for Perpose",1203,[],No.TYPE_BOOL,"Whether the payment references a Guard?",[]],[Ao.payment,"Has Object for Perpose",1204,[],No.TYPE_BOOL,"Whether the payment references an Object?",[]],[Ao.payment,"Guard for Perpose",1205,[],No.TYPE_ADDRESS,"The Guard referenced by this payment.",[]],[Ao.payment,"Object for Perpose",1206,[],No.TYPE_ADDRESS,"The Object referenced by this payment.",[]],[Ao.payment,"Number of Recipients",1207,[],No.TYPE_U64,"Number of recipients to receive payment from.",[]],[Ao.payment,"Is a Recipient",1208,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Is a recipient received the payment?",["address"]],[Ao.payment,"Amount for a Recipient",1209,[No.TYPE_ADDRESS],No.TYPE_U64,"The amount of payment received by an address.",["address"]],[Ao.payment,"Time",1210,[],No.TYPE_U64,"Payment time",[]],[Ao.payment,"Is from Treasury",1211,[],No.TYPE_BOOL,"Whether the payment comes from a Treasury?",[]],[Ao.payment,"Treasury Address",1212,[],No.TYPE_ADDRESS,"The Treasury from which the payment comes.",[]],[Ao.payment,"Biz-ID",1213,[],No.TYPE_U64,"Bisiness ID number of the payment.",[]],[Ao.payment,"Check the purpose of payment",1214,[No.TYPE_ADDRESS,No.TYPE_ADDRESS,No.TYPE_U64],No.TYPE_BOOL,"Do Guard, Object Perpose, and Biz-ID match?",["guard address","object address","Biz-ID"]],[Ao.payment,"Check & Amount for a Recipient",1215,[No.TYPE_ADDRESS,No.TYPE_ADDRESS,No.TYPE_U64,No.TYPE_ADDRESS],No.TYPE_BOOL,"Check and get the amount of payment received by an address.",["guard address","object address","Biz-ID","recipient address"]],[Ao.treasury,"Permission",1400,[],No.TYPE_ADDRESS,"Permission object address.",[]],[Ao.treasury,"Balance",1401,[],No.TYPE_U64,"Treasury balance.",[]],[Ao.treasury,"Number of Flow Records",1402,[],No.TYPE_U64,"Number of treasury transactions.",[]],[Ao.treasury,"Inflow Amount",1403,[],No.TYPE_U128,"Treasury inflow amount.",[]],[Ao.treasury,"Outflow Amount",1404,[],No.TYPE_U128,"Treasury outflow amount.",[]],[Ao.treasury,"Has Deposit Guard",1405,[],No.TYPE_BOOL,"Whether the deposit Guard set?",[]],[Ao.treasury,"Deposit Guard",1406,[],No.TYPE_ADDRESS,"Deposit Guard address.",[]],[Ao.treasury,"Number of Withdraw Guards",1407,[],No.TYPE_U64,"Number of withdraw guards.",[]],[Ao.treasury,"Has Withdraw Guard",1408,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Has a Withdraw Guard added?",["guard address"]],[Ao.treasury,"Withdrawal Amount with Guard",1409,[No.TYPE_ADDRESS],No.TYPE_U64,"withdrawal amount corresponding the Guard.",["guard address"]],[Ao.treasury,"Recent Time with Operation",1410,[No.TYPE_U8],No.TYPE_U64,"Time of the most recent fund operation.",["operation"]],[Ao.treasury,"Recent Signer with Operation",1411,[No.TYPE_U8],No.TYPE_ADDRESS,"Signer address of the most recent fund operation.",["operation"]],[Ao.treasury,"Recent Payment with Operation",1412,[No.TYPE_U8],No.TYPE_ADDRESS,"Payment address of the most recent fund operation.",["operation"]],[Ao.treasury,"Recent Amount with Operation",1413,[No.TYPE_U8],No.TYPE_U64,"Amount of the most recent fund operation.",["operation"]],[Ao.treasury,"Recent Time with Op/Pmt",1414,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_U64,"Time of the most recent fund operation with payment specified.",["operation","payment address"]],[Ao.treasury,"Recent Signer with Op&Pmt",1415,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_ADDRESS,"Signer of the most recent fund operationwith payment specified.",["operation","payment address"]],[Ao.treasury,"Recent Amount with Op/Pmt",1416,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_U64,"Amount of the most recent fund operation with payment specified.",["operation","payment address"]],[Ao.treasury,"Recent Time with Op/Sgr",1417,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_U64,"Time of the most recent fund operation with signer specified.",["operation","signer address"]],[Ao.treasury,"Recent Payment with Op/Sgr",1418,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_ADDRESS,"Payment of the most recent fund operation with singner specified.",["operation","signer address"]],[Ao.treasury,"Recent Amount with Op/Sgr",1419,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_U64,"Amount of the most recent fund operation with singer specified.",["operation","signer address"]],[Ao.treasury,"Recent Time with Op/Pmt/Sgr",1420,[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],No.TYPE_U64,"Time of the most recent fund operation.",["operation","payment address","singer address"]],[Ao.treasury,"Recent Amount with Op/Pmt/Sgr",1421,[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],No.TYPE_U64,"Amount of the most recent fund operation.",["operation","payment address","singer address"]],[Ao.treasury,"Has Operation",1422,[No.TYPE_U8],No.TYPE_BOOL,"Whether there was a fund operation?",["operation"]],[Ao.treasury,"Has Operation with Pmt",1423,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether there was a fund operation with payment specified?",["operation","payment address"]],[Ao.treasury,"Has Operation with Sgr",1424,[No.TYPE_U8,No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether there was a fund operation with singer specified?",["operation","singer address"]],[Ao.treasury,"Has Operation with Pmt/Sgr",1425,[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],No.TYPE_BOOL,"Whether there was a fund operation?",["operation","payment address","singer address"]],[Ao.treasury,"Operation at Least Times",1426,[No.TYPE_U8,No.TYPE_U8],No.TYPE_BOOL,"Does it operate at least a certain number of times?",["operation","at least times"]],[Ao.treasury,"Operation at Least Times by a Signer",1427,[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_U8],No.TYPE_BOOL,"Does it operate at least a certain number of times by a signer?",["operation","signer address","at least times"]],[Ao.arbitration,"Permission",1500,[],No.TYPE_ADDRESS,"Permission object address.",[]],[Ao.arbitration,"Paused",1501,[],No.TYPE_BOOL,"Is it allowed to create Arb?",[]],[Ao.arbitration,"Fee",1502,[],No.TYPE_U64,"Cost of arbitration.",[]],[Ao.arbitration,"Has Endpoint",1503,[],No.TYPE_BOOL,"Is the endpoint set?",[]],[Ao.arbitration,"Endpoint",1504,[],No.TYPE_STRING,"Endpoint url/ipfs.",[]],[Ao.arbitration,"Has Customer Guard",1505,[],No.TYPE_BOOL,"Is there Guard set to apply for arbitration?",[]],[Ao.arbitration,"Customer Guard",1506,[],No.TYPE_ADDRESS,"Guard to apply for arbitration.",[]],[Ao.arbitration,"Number of Voting Guard",1507,[],No.TYPE_U64,"Number of voting guards.",[]],[Ao.arbitration,"Has Voting Guard",1508,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Has the voting Guard added?",["guard address"]],[Ao.arbitration,"Voting Weight",1509,[No.TYPE_ADDRESS],No.TYPE_U64,"Voting weight of the voting Guard.",["guard address"]],[Ao.arbitration,"Treasury",1510,[],No.TYPE_ADDRESS,"The address of the Treasury where fees was collected at the time of withdrawal.",[]],[Ao.arb,"Order",1600,[],No.TYPE_ADDRESS,"Order under arbitration.",[]],[Ao.arb,"Arbitration",1601,[],No.TYPE_ADDRESS,"Arbitration object address.",[]],[Ao.arb,"Feedback",1602,[],No.TYPE_STRING,"Arbitration feedback.",[]],[Ao.arb,"Has Compensation",1603,[],No.TYPE_BOOL,"Whether there is an arbitration result?",[]],[Ao.arb,"Compensation",1604,[],No.TYPE_U64,"Compensation should be given to the order payer.",[]],[Ao.arb,"Unclaimed Arbitration Costs",1605,[],No.TYPE_U64,"Unclaimed arbitration costs.",[]],[Ao.arb,"Turnout",1606,[],No.TYPE_U64,"The number of addresses have voted.",[]],[Ao.arb,"Has voted",1607,[No.TYPE_ADDRESS],No.TYPE_BOOL,"Has someone voted?",["voter address"]],[Ao.arb,"Voting weight",1608,[No.TYPE_ADDRESS],No.TYPE_U64,"The weight of a complete vote for the address.",["voter address"]],[Ao.arb,"Voting Time",1609,[No.TYPE_ADDRESS],No.TYPE_U64,"The time of a complete vote for the address.",["voter address"]],[Ao.arb,"Voting Option",1610,[No.TYPE_ADDRESS,No.TYPE_U8],No.TYPE_BOOL,"Does an address complete voting for the option?",["voter address","option index"]],[Ao.arb,"Number of Options",1611,[],No.TYPE_U64,"Number of voting options.",[]],[Ao.arb,"Number of Votes",1612,[No.TYPE_U8],No.TYPE_U64,"The number of votes received for an option.",["option index"]]];var rd;!function(e){e.txn="Txn Functions",e.number="Number Crunching",e.logic="Compare or Logic"}(rd||(rd={}));const sd=[{from:"type",name:"Txn Signer",value:Xo.TYPE_SIGNER,group:rd.txn,return:No.TYPE_ADDRESS},{from:"type",name:"Txn Time",value:Xo.TYPE_CLOCK,group:rd.txn,return:No.TYPE_U64},{from:"type",name:"Guard Address",value:Xo.TYPE_GUARD,group:rd.txn,return:No.TYPE_ADDRESS},{from:"type",name:"PositiveNumber to Address",value:ko.TYPE_NUMBER_ADDRESS,group:rd.number,return:No.TYPE_ADDRESS},{from:"type",name:"PositiveNumber Add (+)",value:ko.TYPE_NUMBER_ADD,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Subtract (-)",value:ko.TYPE_NUMBER_SUBTRACT,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Multiply (*)",value:ko.TYPE_NUMBER_MULTIPLY,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Devide (/)",value:ko.TYPE_NUMBER_DEVIDE,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Mod (%)",value:ko.TYPE_NUMBER_MOD,group:rd.number,return:"number"}];class id{static MAX_INPUT_LENGTH=10240;txb;object;get_object(){return this.object}static From(e,t){let r=new id(e);return r.object=zo.TXB_OBJECT(e,t),r}constructor(e){this.txb=e,this.object=""}static New(e,t,r){r.IsReady()||Ba(Ca.InvalidParam,"launch maker"),io(t)||Ba(Ca.IsValidDesription);let s=r.get_input()[0],i=r.get_constant();(0==s.length||s.length>id.MAX_INPUT_LENGTH)&&Ba(Ca.InvalidParam,"launch input");let n=!0;i?.forEach(((e,t)=>{ad.IsValidIndentifier(t)||(n=!1),e.value&&e.bWitness&&(n=!1),void 0!==e.value||e.bWitness||(n=!1)})),n||Ba(Ca.InvalidParam,"launch constants");let a=new Uint8Array(s),o=new id(e);return o.object=e.moveCall({target:zo.Instance().guardFn("new"),arguments:[e.pure.string(t),e.pure.vector("u8",[].slice.call(a.reverse()))]}),i?.forEach(((t,r)=>{if(t.bWitness){const s=new Uint8Array(1);s.set([t.type],0),e.moveCall({target:zo.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}else{const s=Io(t.value,t.type);e.moveCall({target:zo.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}})),o}launch(){return this.txb.moveCall({target:zo.Instance().guardFn("create"),arguments:[this.txb.object(this.object)]})}static everyone_guard(e){return e.moveCall({target:zo.Instance().guardFn("everyone_guard"),arguments:[]})}static QueryAddressIdentifiers(e,t,r){const s=new gs;s.moveCall({target:zo.Instance().guardFn("query_address_identifiers"),arguments:[s.object(e)]}),zo.Client().devInspectTransactionBlock({sender:r,transactionBlock:s}).then((e=>{if(e.results&&e.results[0]?.returnValues&&1!==e.results[0]?.returnValues?.length)return void t({err:"not match",txb:s,identifiers:[]});const r=Wa.getInstance().de("vector<u8>",Uint8Array.from(e.results[0].returnValues[0][0]));t({identifiers:r,txb:s})})).catch((e=>{console.log(e),t({err:e,txb:s,identifiers:[]})}))}static BoolCmd=td.filter((e=>e[4]===No.TYPE_BOOL));static IsBoolCmd=e=>id.BoolCmd.includes((t=>t[2]==e));static CmdFilter=e=>td.filter((t=>t[4]===e));static GetCmd=e=>td.find((t=>t[2]==e));static GetCmdOption=e=>{const t=id.GetCmd(e);return t?{from:"query",name:t[1],value:t[2],group:Po(t[0]),return:t[4]}:t};static GetInputParams=e=>{const t=id.GetCmd(e);return t?t[3]:[]};static GetModuleName=e=>{let t=id.GetCmd(e);return t?Po(t[0]):""};static NumberOptions=()=>[...id.CmdFilter(No.TYPE_U8),...id.CmdFilter(No.TYPE_U64),...id.CmdFilter(No.TYPE_U128),...id.CmdFilter(No.TYPE_U256)].map((e=>({from:"query",name:e[1],value:e[2],group:Po(e[0]),return:e[4]}))).concat(id.Crunchings);static Signer=sd.find((e=>"Txn Signer"===e.name&&e.value===Xo.TYPE_SIGNER));static Time=sd.find((e=>"Txn Time"===e.name&&e.value===Xo.TYPE_CLOCK));static Guard=sd.find((e=>"Guard Address"===e.name&&e.value===Xo.TYPE_GUARD));static Logics=()=>Uo.map((e=>({from:"type",name:e[1],value:e[0],group:rd.logic,return:No.TYPE_BOOL})));static Crunchings=sd.filter((e=>e.value===ko.TYPE_NUMBER_ADD||e.value===ko.TYPE_NUMBER_SUBTRACT||e.value===ko.TYPE_NUMBER_MULTIPLY||e.value===ko.TYPE_NUMBER_DEVIDE||e.value===ko.TYPE_NUMBER_MOD||e.value===ko.TYPE_NUMBER_ADDRESS));static CommonOptions=e=>id.CmdFilter(e).map((e=>({from:"query",name:e[1],value:e[2],group:Po(e[0]),return:e[4]})));static AllOptions=()=>[...td.map((e=>({from:"query",name:e[1],value:e[2],group:Po(e[0]),return:e[4]}))),...sd];static StringOptions=()=>[...id.CmdFilter(No.TYPE_STRING)].map((e=>({from:"query",name:e[1],value:e[2],group:Po(e[0]),return:e[4]})));static BoolOptions=()=>[...id.BoolCmd.map((e=>({from:"query",name:e[1],value:e[2],group:Po(e[0]),return:e[4]}))),...id.Logics()];static AddressOptions=()=>[...td.filter((e=>e[4]===No.TYPE_ADDRESS)).map((e=>({from:"query",name:e[1],value:e[2],group:Po(e[0]),return:e[4]}))),...sd.filter((e=>e.return===No.TYPE_ADDRESS))];static Options=e=>{if("number"===e)return id.NumberOptions();if("any"===e)return id.AllOptions();switch(e){case No.TYPE_BOOL:return id.BoolOptions();case No.TYPE_STRING:return id.StringOptions()}return id.CommonOptions(e)}}const nd=e=>po(e)&&0!==e;class ad{data=[];type_validator=[];constant=new Map;static _witness_index=1;static _const_index=255;static GetWitnessIndex(){return this._witness_index>=this._const_index&&Ba(Ca.Fail,"too many witness"),ad._witness_index++}static getConstIndex(){return this._const_index<=this._witness_index&&Ba(Ca.Fail,"too many const"),ad._const_index--}static IsValidIndentifier=e=>!(!po(e)||e<1);constructor(){}add_constant(e,t,r,s=!0){return void 0===r&&(r=void 0===t?ad.GetWitnessIndex():ad.getConstIndex()),this.constant.get(r)||(s&&void 0!==t&&(t=Wa.getInstance().ser(e,t)),this.constant.set(r,{type:e,value:void 0===t?void 0:t,bWitness:void 0===t})),r}add_param(e,t){switch(e){case No.TYPE_ADDRESS:case No.TYPE_BOOL:case No.TYPE_U8:case No.TYPE_U64:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_U128:case No.TYPE_VEC_U64:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U256:case No.TYPE_OPTION_U8:case No.TYPE_VEC_U256:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(e,t)),this.type_validator.push(e);break;case No.TYPE_STRING:case No.TYPE_VEC_U8:t||Ba(Ca.InvalidParam,"param: "+e),this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),"string"==typeof t?this.data.push(Wa.getInstance().ser(No.TYPE_STRING,t)):this.data.push(Wa.getInstance().ser(No.TYPE_VEC_U8,t)),this.type_validator.push(e);break;case Xo.TYPE_SIGNER:case Xo.TYPE_GUARD:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.type_validator.push(No.TYPE_ADDRESS);break;case Xo.TYPE_CLOCK:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.type_validator.push(No.TYPE_U64);break;case Xo.TYPE_CONSTANT:nd(t)||Ba(Ca.IsValidGuardIdentifier,"add_param param:"+e);var r=this.constant.get(t);r||Ba(Ca.Fail,"identifier not in constant:"+t),this.type_validator.push(r.type),this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(No.TYPE_U8,t));break;default:Ba(Ca.InvalidParam,"add_param type:"+e)}return this}add_query(e,t,r){let s=td.findIndex((r=>r[0]==e&&r[1]==t));-1==s&&Ba(Ca.InvalidParam,"query_name:"+t),"number"==typeof r?ad.IsValidIndentifier(r)||Ba(Ca.InvalidParam,"object_address_from:"+t):co(r)||Ba(Ca.InvalidParam,"object_address_from:"+t);let i=this.type_validator.length-td[s][3].length;i<0&&Ba(Ca.InvalidParam,"offset:"+t);let n=this.type_validator.slice(i);if(Ga(n,td[s][3])||Ba(Ca.Fail,"array_equal:"+t),this.data.push(Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_QUERY)),"string"==typeof r)this.data.push(Wa.getInstance().ser(No.TYPE_U8,No.TYPE_ADDRESS)),this.data.push(Wa.getInstance().ser(No.TYPE_ADDRESS,r));else{let e=this.constant.get(r);e||Ba(Ca.Fail,"object_address_from not in constant:"+t),e?.type==No.TYPE_ADDRESS?(this.data.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),this.data.push(Wa.getInstance().ser(No.TYPE_U8,r))):Ba(Ca.Fail,"type bWitness not match:"+t)}return this.data.push(Wa.getInstance().ser("u16",td[s][2])),this.type_validator.splice(i,td[s][3].length),this.type_validator.push(td[s][4]),this}add_logic(e,t=2){var r=Uo.find((t=>t[0]===e));r&&(r=r[1]);let s,i=2,n=No.TYPE_BOOL;switch(e){case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)ad.match_u256(this.type_validator[this.type_validator.length-e])||Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),s=this.type_validator[this.type_validator.length-1];for(let e=2;e<=i;++e)this.type_validator[this.type_validator.length-e]!==s&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_HAS_SUBSTRING:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!==No.TYPE_STRING&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_NOT:i=1,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),this.type_validator[this.type_validator.length-1]!=No.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_NUMBER_ADDRESS:i=1,n=No.TYPE_ADDRESS,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),ad.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!=No.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:case ko.TYPE_NUMBER_MOD:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)ad.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);n=No.TYPE_U256;break;default:Ba(Ca.InvalidParam,"add_logic type invalid:"+r)}return this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),ad.is_multi_input_op(e)&&this.data.push(Wa.getInstance().ser(No.TYPE_U8,t)),this.type_validator.splice(this.type_validator.length-i),this.type_validator.push(n),this}hasIdentifier(e){return this.constant.has(e)}build(e=!1){return 1==this.type_validator.length&&this.type_validator[0]==No.TYPE_BOOL||Ba(Ca.Fail,"type_validator check"),e&&this.add_logic(ko.TYPE_LOGIC_NOT),this.data.push(Xa(Uint8Array,...this.data)),this.data.splice(0,this.data.length-1),this}IsReady(){return 1==this.type_validator.length&&this.type_validator[0]==No.TYPE_BOOL&&1==this.data.length}combine(e,t=!0,r=!1){e.IsReady()&&this.IsReady()||Ba(Ca.Fail,"both should built yet");let s=new ad;this.constant.forEach(((e,t)=>{s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})})),e.constant.forEach(((e,t)=>{s.constant.has(t)&&!r&&Ba(Ca.Fail,"constant identifier exist"),s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})}));let i=t?ko.TYPE_LOGIC_AND:ko.TYPE_LOGIC_OR;return s.data.push(Xa(Uint8Array,...this.data,...e.data,Wa.getInstance().ser(No.TYPE_U8,i),Wa.getInstance().ser(No.TYPE_U8,2))),this.data.splice(0,this.data.length-1),s.type_validator=this.type_validator,s}get_constant(){return this.constant}get_input(){return this.data}static input_combine(e,t,r=!0){let s=r?ko.TYPE_LOGIC_AND:ko.TYPE_LOGIC_OR;return Xa(Uint8Array,e,t,Wa.getInstance().ser(No.TYPE_U8,s),Wa.getInstance().ser(No.TYPE_U8,2))}static input_not(e){return Xa(Uint8Array,e,Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_LOGIC_NOT))}static match_u256(e){return e==No.TYPE_U8||e==No.TYPE_U64||e==No.TYPE_U128||e==No.TYPE_U256}static is_multi_input_op(e){return e===ko.TYPE_LOGIC_AS_U256_GREATER||e===ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL||e===ko.TYPE_LOGIC_AS_U256_LESSER||e===ko.TYPE_LOGIC_AS_U256_LESSER||e===ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL||e===ko.TYPE_LOGIC_AS_U256_EQUAL||e===ko.TYPE_LOGIC_EQUAL||e===ko.TYPE_LOGIC_HAS_SUBSTRING||e===ko.TYPE_LOGIC_AND||e===ko.TYPE_LOGIC_OR||e===ko.TYPE_NUMBER_ADD||e===ko.TYPE_NUMBER_DEVIDE||e===ko.TYPE_NUMBER_MULTIPLY||e===ko.TYPE_NUMBER_SUBTRACT||e===ko.TYPE_NUMBER_MOD}}var od,dd,cd,ud,hd,ld,pd;!function(e){e[e.POLICY_MODE_FREE=0]="POLICY_MODE_FREE",e[e.POLICY_MODE_STRICT=1]="POLICY_MODE_STRICT"}(od||(od={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.WOWOK_GRANTEE=1]="WOWOK_GRANTEE",e[e.WOWOK_ORACLE=2]="WOWOK_ORACLE"}(dd||(dd={}));class md{permission;object;txb;get_object(){return this.object}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static From(e,t,r){let s=new md(e,t);return s.object=zo.TXB_OBJECT(e,r),s}static New(e,t,r,s=od.POLICY_MODE_FREE,i){zo.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription);let n=new md(e,t);return n.object=i?e.moveCall({target:zo.Instance().repositoryFn("new_with_passport"),arguments:[i,e.pure.string(r),e.pure.u8(s),zo.TXB_OBJECT(e,t)]}):e.moveCall({target:zo.Instance().repositoryFn("new"),arguments:[e.pure.string(r),e.pure.u8(s),zo.TXB_OBJECT(e,t)]}),n}launch(){return this.txb.moveCall({target:zo.Instance().repositoryFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}add_data(e){md.IsValidName(e.key)||Ba(Ca.IsValidName,"add_data");let t=!0;e.data.forEach((e=>{co(e.address)||(t=!1),md.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:zo.Instance().repositoryFn("add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),zo.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:zo.Instance().repositoryFn("add_typed_data"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.vector("u8",[...t.bcsBytes]),zo.TXB_OBJECT(this.txb,this.permission)]})))}add_data2(e){co(e.address)||Ba(Ca.IsValidAddress,"add_data2");let t=!0;e.data.forEach((e=>{md.IsValidName(e.key)||(t=!1),md.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data2"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:zo.Instance().repositoryFn("add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),zo.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:zo.Instance().repositoryFn("add_typed_data"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.vector("u8",[...t.bcsBytes]),zo.TXB_OBJECT(this.txb,this.permission)]})))}remove(e,t){md.IsValidName(t)||Ba(Ca.IsValidName),co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:zo.Instance().repositoryFn("remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]})}add_reference(e,t){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray,"add_reference"),t?this.txb.moveCall({target:zo.Instance().repositoryFn("reference_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("reference_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}))}remove_reference(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_reference"),t?r?this.txb.moveCall({target:zo.Instance().repositoryFn("reference_removeall_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("reference_removeall"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):r?this.txb.moveCall({target:zo.Instance().repositoryFn("reference_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("reference_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}))}add_policies(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{io(e.description)&&md.IsValidName(e.key)||(r=!1)})),r||Ba(Ca.InvalidParam,"policies"),e.forEach((e=>{let r=this.txb.pure.option("u64",e?.permissionIndex?e?.permissionIndex:void 0);t?this.txb.moveCall({target:zo.Instance().repositoryFn("policy_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("policy_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),zo.TXB_OBJECT(this.txb,this.permission)]})}))}remove_policies(e,t,r){0!==e.length&&(To(e,md.IsValidName)||Ba(Ca.InvalidParam,"policy_keys"),r?t?this.txb.moveCall({target:zo.Instance().repositoryFn("policy_removeall_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("policy_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:zo.Instance().repositoryFn("policy_removeall"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("policy_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)]}))}rename_policy(e,t,r){no(e)&&no(t)||Ba(Ca.IsValidName,"change_policy"),r?this.txb.moveCall({target:zo.Instance().repositoryFn("policy_rename_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("policy_rename"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:zo.Instance().repositoryFn("description_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)]})}set_policy_mode(e,t){t?this.txb.moveCall({target:zo.Instance().repositoryFn("mode_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("mode_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),zo.TXB_OBJECT(this.txb,this.permission)]})}set_policy_description(e,t,r){md.IsValidName(e)||Ba(Ca.IsValidName,"policy"),io(t)||Ba(Ca.IsValidDesription),r?this.txb.moveCall({target:zo.Instance().repositoryFn("policy_description_set_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("policy_description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),zo.TXB_OBJECT(this.txb,this.permission)]})}set_policy_permission(e,t,r){md.IsValidName(e)||Ba(Ca.IsValidName,"policy");let s=this.txb.pure.option("u64",void 0);void 0!==t&&(Qo.IsValidPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex),s=this.txb.pure.option("u64",t)),r?this.txb.moveCall({target:zo.Instance().repositoryFn("policy_permission_set_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),s,zo.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:zo.Instance().repositoryFn("policy_permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),s,zo.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:zo.Instance().repositoryFn("permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission),zo.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}static MAX_POLICY_COUNT=120;static MAX_KEY_LENGTH=128;static MAX_VALUE_LENGTH=204800;static MAX_REFERENCE_COUNT=100;static IsValidName=e=>e.length<=md.MAX_KEY_LENGTH&&0!=e.length;static IsValidValue=e=>e.length<md.MAX_VALUE_LENGTH;static rpc_de_data(e){const t=e?.map((e=>{const t=new Uint8Array(e?.data?.content?.fields?.value),r=t?.length>0?t[0]:null;var s=t.length>0?t.slice(1):Uint8Array.from([]);return r===No.TYPE_STRING?(s=Wa.getInstance().de(No.TYPE_VEC_U8,s),s=(new TextDecoder).decode(Uint8Array.from(s))):r===No.TYPE_VEC_STRING?s=(s=Wa.getInstance().de(No.TYPE_VEC_VEC_U8,s)).map((e=>(new TextDecoder).decode(Uint8Array.from(e)))):(s=Wa.getInstance().de(t[0],s),r===No.TYPE_ADDRESS?s="0x"+s:r===No.TYPE_VEC_ADDRESS?s=s.map((e=>"0x"+e)):r===No.TYPE_BOOL&&(s=s?"True":"False")),{object:e?.data?.content?.fields?.id?.id,id:e?.data?.content?.fields?.name?.fields?.id,name:e?.data?.content?.fields?.name?.fields?.key,data:s,dataType:Ua(r)}}));return t}static DataType2ValueType(e){try{const t=BigInt(e);if(No.TYPE_U8,t<=Sa);else if(t<=Pa)No.TYPE_U64;else if(t<=ja)No.TYPE_U128;else{if(!(t<=Aa))return;No.TYPE_U256}}catch(e){console.log(e)}}static ResolveRepositoryData=(e,t)=>{if(e===Do.String)return{type:No.TYPE_STRING,data:Wa.getInstance().ser(No.TYPE_VEC_U8,(new TextEncoder).encode(t.toString()))};if(e===Do.PositiveNumber){const e=md.DataType2ValueType(t);if(!e)return;return{type:e,data:Wa.getInstance().ser(e,t)}}if(e===Do.Address){if(!co(t))return;return{type:No.TYPE_ADDRESS,data:Wa.getInstance().ser(No.TYPE_ADDRESS,t)}}if(e===Do.Address_Vec){for(let e=0;e<t.length;++e)if(!co(t[e]))return;return{type:No.TYPE_VEC_ADDRESS,data:Wa.getInstance().ser(No.TYPE_VEC_ADDRESS,t)}}if(e===Do.PositiveNumber_Vec){let e=No.TYPE_U8;for(let r=0;r<t.length;++r){const r=md.DataType2ValueType(t);if(!r)return;r>e&&(e=r)}return e=e===No.TYPE_U8?No.TYPE_VEC_U8:e===No.TYPE_U64?No.TYPE_VEC_U64:e===No.TYPE_U128?No.TYPE_VEC_U128:No.TYPE_VEC_U256,{type:e,data:Wa.getInstance().ser(e,t)}}if(e===Do.String_Vec){const e=t.map((e=>(new TextEncoder).encode(e)));return{type:No.TYPE_VEC_STRING,data:Wa.getInstance().ser(No.TYPE_VEC_VEC_U8,e)}}if(e===Do.Bool){if("boolean"!=typeof t)return;return{type:No.TYPE_BOOL,data:Wa.getInstance().ser(No.TYPE_BOOL,t)}}}}class bd{guard_list=[];guards;constructor(e){this.guards=e}guardlist=()=>this.guard_list;static DeGuardObject_FromData=(e,t)=>{let r=bd.parse_constant(e),s=bd.parse_bcs(r,t);s&&0!=s.length||Ba(Ca.Fail,"GuardObject: data parsed error");let i=[];return s.forEach((e=>{bd.ResolveData(r,i,{...e,child:[]})})),1!=i.length&&Ba(Ca.Fail,"GuardObject: parse error"),{object:i.pop(),constant:r}};static DeGuardObject=async(e,t)=>{co(t)||Ba(Ca.IsValidAddress,"GuardObject guard");let r=await e.query_raw([t]);0!=r.length&&r[0].data&&r[0].data?.objectId==t||Ba(Ca.Fail,"GuardObject query error");let s=r[0].data.content;return s?.type!=e.package("base")+"::guard::Guard"&&Ba(Ca.Fail,"GuardObject object invalid"),bd.DeGuardObject_FromData(s.fields.constants,s.fields.input.fields.bytes)};static ResolveData=(e,t,r)=>{switch(r.type){case ko.TYPE_LOGIC_NOT:return r.ret_type=No.TYPE_BOOL,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT"),(s=t.pop()).ret_type&&s.ret_type==No.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT type invalid"),r.child.push(s),void t.push(r);case ko.TYPE_NUMBER_ADDRESS:var s;return r.ret_type=No.TYPE_ADDRESS,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_NUMBER_ADDRESS"),(s=t.pop()).ret_type&&ad.match_u256(s.ret_type)||Ba(Ca.Fail,"ResolveData: TYPE_NUMBER_ADDRESS type invalid"),r.child.push(s),void t.push(r);case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MOD:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:r.type===ko.TYPE_LOGIC_AS_U256_GREATER||r.type===ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL||r.type===ko.TYPE_LOGIC_AS_U256_LESSER||r.type===ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL||r.type===ko.TYPE_LOGIC_AS_U256_EQUAL?r.ret_type=No.TYPE_BOOL:r.ret_type=No.TYPE_U256,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(n=t.pop()).ret_type&&ad.match_u256(n.ret_type)||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_EQUAL:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);var i=t.pop();r.child.push(i);for(let e=1;e<r.value;++e)(n=t.pop()).ret_type&&n.ret_type==i.ret_type||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_HAS_SUBSTRING:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(n=t.pop()).ret_type&&n.ret_type==No.TYPE_STRING||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e){var n;(n=t.pop()).ret_type&&n.ret_type==No.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n)}return void t.push(r);case ko.TYPE_QUERY:r?.cmd||Ba(Ca.Fail,"OperateParamCount: cmd invalid "+r.type);let a=id.GetCmd(r.cmd);return a||Ba(Ca.Fail,"OperateParamCount: cmd not supported "+r.type),r.ret_type=a[4],t.length<a[3].length&&Ba(Ca.Fail,"OperateParamCount: cmd param lost "+r.type),a[3].forEach((e=>{let s=t.pop();s?.ret_type&&s.ret_type==e||Ba(Ca.Fail,"OperateParamCount: cmd param not match "+r.type),r.child.push(s)})),void t.push(r);case No.TYPE_ADDRESS:case No.TYPE_BOOL:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_U64:case No.TYPE_U8:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_U128:case No.TYPE_VEC_U256:case No.TYPE_VEC_U64:case No.TYPE_VEC_U8:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U256:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_U8:case No.TYPE_STRING:return r.ret_type=r.type,void t.push(r);case Xo.TYPE_CLOCK:return r.ret_type=No.TYPE_U64,void t.push(r);case Xo.TYPE_SIGNER:case Xo.TYPE_GUARD:return r.ret_type=No.TYPE_ADDRESS,void t.push(r);case Xo.TYPE_CONSTANT:let o=e.find((e=>e.identifier==r?.identifier));return o||Ba(Ca.Fail,"OperateParamCount: identifier invalid "+r.type),r.ret_type=o?.type,void t.push(r)}Ba(Ca.Fail,"OperateParamCount: type invalid "+r.type)};static Parse_Guard_Helper(e,t){const r=zo.Instance(),s=new bd(e);return t.forEach((e=>{const t=e.data?.content;if(t||Ba(Ca.Fail,"Parse_Guard_Helper invalid content"),-1===r.WOWOK_OBJECTS_TYPE().findIndex((e=>e.includes("guard::Guard")&&e==t.type))&&Ba(Ca.Fail,"Parse_Guard_Helper invalid type: "+t.type),t.fields.input.type===r.package("base")+"::bcs::BCS"){const r=bd.parse_constant(t.fields.constants),i=bd.parse_bcs(r,Uint8Array.from(t.fields.input.fields.bytes));s.guard_list.push({id:t.fields.id.id,input:[...i],constant:[...r],digest:e.data?.digest??"",version:e.data?.version??""})}else Ba(Ca.Fail,"Parse_Guard_Helper invalid package: "+t.fields.input.type)})),s}static Create=async(e,t)=>{if(!To(e,co))return void(t&&t(void 0));let r=$a(e);if(!t){const t=await zo.Instance().query_raw(r);return bd.Parse_Guard_Helper(e,t)}zo.Instance().query_raw(r).then((r=>{t(bd.Parse_Guard_Helper(e,r))})).catch((e=>{console.log(e),t(void 0)}))};future_fills=()=>{const e=[];return this.guard_list.forEach((t=>{t.constant.filter((e=>e.bWitness)).forEach((r=>{const s=t.input.filter((e=>e.identifier===r.identifier&&void 0!==e.cmd)).map((e=>e.cmd));let i=0;t.input.forEach((e=>{e.identifier===r.identifier&&i++})),e.push({guard:t.id,witness:void 0,identifier:r.identifier,type:r.type,cmd:s??[],cited:i})}))})),e};static parse_constant=e=>{let t=[];return e.forEach((e=>{let r=e?.fields??e;const s=Uint8Array.from(r.value),i=s.slice(0,1)[0];if(r.bWitness)t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:void 0});else{var n=s.slice(1);switch(i){case No.TYPE_ADDRESS:n="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(n)).toString();break;case No.TYPE_BOOL:case No.TYPE_U8:case No.TYPE_U64:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_VEC_U8:case No.TYPE_VEC_U64:case No.TYPE_VEC_U128:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U8:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_U256:case No.TYPE_VEC_U256:case No.TYPE_STRING:case No.TYPE_OPTION_STRING:case No.TYPE_OPTION_VEC_U8:case No.TYPE_VEC_STRING:Lo.find((e=>e.type==i))||Ba(Ca.Fail,"GuardObject de error"),n=Wa.getInstance().de(i,Uint8Array.from(n));break;default:Ba(Ca.Fail,"GuardObject constant type invalid:"+i)}t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:n})}})),t};static parse_bcs=(e,t)=>{let r=Uint8Array.from(t),s=[].slice.call(r.reverse()),i=[];for(;s.length>0;){let t,r,n,a=s.shift();switch(a){case Xo.TYPE_SIGNER:case Xo.TYPE_CLOCK:case Xo.TYPE_GUARD:case ko.TYPE_LOGIC_NOT:case ko.TYPE_NUMBER_ADDRESS:break;case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:case ko.TYPE_LOGIC_EQUAL:case ko.TYPE_LOGIC_HAS_SUBSTRING:case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MOD:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:t=s.shift();break;case Xo.TYPE_CONSTANT:n=s.shift();break;case No.TYPE_ADDRESS:t="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(s)).toString(),s.splice(0,32);break;case No.TYPE_BOOL:case No.TYPE_U8:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.shift();break;case No.TYPE_U64:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8);break;case No.TYPE_U128:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16);break;case No.TYPE_U256:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32);break;case No.TYPE_VEC_U8:case No.TYPE_VEC_BOOL:case No.TYPE_STRING:let i=Ya(Uint8Array.from(s));t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,i.value+i.length);break;case No.TYPE_VEC_ADDRESS:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case No.TYPE_VEC_U128:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16*i.value+i.length);break;case No.TYPE_VEC_U256:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case No.TYPE_VEC_U64:i=Ya(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8*i.value+i.length);break;case No.TYPE_VEC_VEC_U8:case No.TYPE_VEC_STRING:i=Ya(Uint8Array.from(s)),s.splice(0,i.length);let o=[];for(let e=0;e<i.value;e++){let e=Ya(Uint8Array.from(s));o.push(Wa.getInstance().de(No.TYPE_VEC_U8,Uint8Array.from(s))),s.splice(0,e.length+e.value)}t=o;break;case ko.TYPE_QUERY:let d=s.splice(0,1);if(d[0]==No.TYPE_ADDRESS){let e="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(s)).toString();s.splice(0,32),t=e,r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else if(d[0]==Xo.TYPE_CONSTANT){let t=s.splice(0,1);e.find((e=>e.identifier==t[0]&&e.type==No.TYPE_ADDRESS))||Ba(Ca.Fail,"GuardObject: indentifier not in constant"),n=t[0],r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else Ba(Ca.Fail,"GuardObject: constant type invalid");break;case No.TYPE_OPTION_ADDRESS:let c=Na(s,No.TYPE_ADDRESS);t=c.value,c.bNone||s.splice(0,32);break;case No.TYPE_OPTION_BOOL:c=Na(s,No.TYPE_BOOL),t=c.value,c.bNone||s.splice(0,1);break;case No.TYPE_OPTION_U8:c=Na(s,No.TYPE_U8),t=c.value,c.bNone||s.splice(0,1);break;case No.TYPE_OPTION_U128:c=Na(s,No.TYPE_U128),t=c.value,c.bNone||s.splice(0,16);break;case No.TYPE_OPTION_U256:c=Na(s,No.TYPE_U256),t=c.value,c.bNone||s.splice(0,32);break;case No.TYPE_OPTION_U64:c=Na(s,No.TYPE_U64),t=c.value,c.bNone||s.splice(0,8);break;case No.TYPE_OPTION_STRING:c=Da(s),t=c.value;break;default:Ba(Ca.Fail,"GuardObject: parse_bcs types "+a)}i.push({type:a,value:t,cmd:r,identifier:n})}return i};done=async(e,t)=>{let r=[];if(this.guard_list.forEach((t=>{t.constant.forEach((t=>{if(t.bWitness){const r=e?.find((e=>e.identifier===t.identifier));r?t.value=r.witness:Ba(Ca.Fail,"done: invalid witness "+t.identifier)}})),t.input.filter((e=>void 0!==e.cmd)).forEach((e=>{if(void 0!==e.identifier){const s=t.constant.find((t=>t.identifier===e.identifier&&t.type===No.TYPE_ADDRESS));s&&co(s.value)||Ba(Ca.Fail,"done: invalid identifier "+e.identifier),r.push(s.value)}else r.push(e.value)}))})),t)return 0===r.length?void t(this.done_helper([])):void zo.Instance().query_raw($a(r),{showType:!0}).then((e=>{t(this.done_helper(e))})).catch((e=>{console.log(e),t(void 0)}));{let e=[];return r.length>0&&(e=await zo.Instance().query_raw($a(r),{showType:!0})),this.done_helper(e)}};done_helper(e){let t=[],r=[];return this.guard_list.forEach((s=>{r.push(s.id),s.input.filter((e=>void 0!==e.cmd)).forEach((r=>{let i=r.value;i||void 0===r.identifier||(i=s.constant.find((e=>e.identifier==r.identifier))?.value);let n=e.find((e=>e.data?.objectId==i));n||Ba(Ca.Fail,"query object not match");let a=this.object_query(n.data);a||Ba(Ca.Fail,"query object fail"),t.push(a)}))})),{query:t,info:this.guard_list}}object_query=(e,t="guard_query")=>{for(let r=0;r<zo.Instance().WOWOK_OBJECTS_TYPE().length;r++)if(e.type.includes(zo.Instance().WOWOK_OBJECTS_TYPE()[r]))return{target:zo.Instance().WOWOK_OBJECTS_PREFIX_TYPE()[r]+t,object:ct({objectId:e.objectId,mutable:!1,initialSharedVersion:e.version}),types:qa(e.type),id:e.objectId}}}class _d{static MAX_GUARD_COUNT=8;passport;txb;get_object(){return this.passport}constructor(e,t,r=!1){(0===t.info.length||t.info.length>_d.MAX_GUARD_COUNT)&&Ba(Ca.InvalidParam,"guards"),this.txb=e,this.passport=this.txb.moveCall({target:zo.Instance().passportFn("new"),arguments:[]}),t.info.forEach((t=>{const r=t.constant.filter((e=>e.bWitness)).map((e=>e.identifier)),s=t.constant.filter((e=>e.bWitness)).map((e=>{const t=Wa.getInstance().ser(e.type,e.value);let r=new Uint8Array(t.length+1);return r.set([e.type],0),r.set(t,1),[].slice.call(r)})),i=void 0!==t.version&&void 0!==t.digest?e.objectRef({objectId:t.id,version:t.version,digest:t.digest}):e.object(t.id);this.txb.moveCall({target:zo.Instance().passportFn("guard_add"),arguments:[this.passport,i,this.txb.pure.vector("u8",[].slice.call(r)),this.txb.pure(Wa.getInstance().ser("vector<vector<u8>>",[...s]))]})}));const s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);t?.query.forEach((e=>{this.txb.moveCall({target:zo.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]}),this.txb.moveCall({target:e.target,arguments:[r?this.txb.object(e.object):this.txb.object(e.id),this.passport],typeArguments:e.types})})),this.txb.moveCall({target:zo.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]})}destroy(){this.txb.moveCall({target:zo.Instance().passportFn("destroy"),arguments:[this.passport]})}freeze(){this.txb.moveCall({target:zo.Instance().passportFn("freezen"),arguments:[this.passport]})}query_result(e,t){this.txb.moveCall({target:zo.Instance().passportFn("query_result"),arguments:[this.passport]}),zo.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb}).then((e=>{const r=_d.ResolveQueryRes(this.txb,e);r&&t(r)})).catch((e=>{console.log(e)}))}query_result_async=async e=>{this.txb.moveCall({target:zo.Instance().passportFn("query_result"),arguments:[this.passport]});const t=await zo.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb});return _d.ResolveQueryRes(this.txb,t)};static ResolveQueryRes(e,t){for(let r=0;r<t.results?.length;++r){const s=t.results[r];if(s?.returnValues&&2===s.returnValues.length&&"bool"===s.returnValues[0][1]&&"vector<address>"===s.returnValues[1][1])return{txb:e,result:Wa.getInstance().de("bool",Uint8Array.from(s.returnValues[0][0])),guards:Wa.getInstance().de("vector<address>",Uint8Array.from(s.returnValues[1][0])).map((e=>"0x"+e))}}}}!function(e){e[e.ratio=0]="ratio",e[e.minus=1]="minus"}(cd||(cd={})),function(e){e.address="address",e.phone="phone",e.name="name",e.postcode="postcode"}(ud||(ud={}));class gd{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new gd(e,t,r);return i.object=zo.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n){zo.IsValidObjects([r,i])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New: pay_token_type"),io(s)||Ba(Ca.IsValidDesription);let a=t,o=new gd(e,a,r);return o.object=n?e.moveCall({target:zo.Instance().serviceFn("new_with_passport"),arguments:[n,e.pure.string(s),e.object(i),zo.TXB_OBJECT(e,r)],typeArguments:[a]}):e.moveCall({target:zo.Instance().serviceFn("new"),arguments:[e.pure.string(s),e.object(i),zo.TXB_OBJECT(e,r)],typeArguments:[a]}),o}launch(){return this.txb.moveCall({target:zo.Instance().serviceFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:zo.Instance().serviceFn("description_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_price(e,t,r=!0,s){mo(t)||Ba(Ca.IsValidU64,"set_price price"),gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_price item"),s?this.txb.moveCall({target:zo.Instance().serviceFn("price_set_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("price_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"item"),mo(t)||Ba(Ca.IsValidU64,"stock"),s?this.txb.moveCall({target:zo.Instance().serviceFn("stock_set_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("stock_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"add_stock item"),mo(t)||Ba(Ca.IsValidUint,"add_stock stock_add"),s?this.txb.moveCall({target:zo.Instance().serviceFn("stock_add_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("stock_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}reduce_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"reduce_stock item"),mo(t)||Ba(Ca.IsValidUint,"reduce_stock stock_reduce"),s?this.txb.moveCall({target:zo.Instance().serviceFn("stock_reduce_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("stock_reduce"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_sale_endpoint(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_sale_endpoint item"),t&&!oo(t)&&Ba(Ca.IsValidEndpoint,"set_sale_endpoint endpoint");let i=this.txb.pure.option("string",t||void 0);s?this.txb.moveCall({target:zo.Instance().serviceFn("sale_endpoint_set_with_passport"),arguments:[s,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("sale_endpoint_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_payee(e,t){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_payee"),t?this.txb.moveCall({target:zo.Instance().serviceFn("payee_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("payee_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_repository(e,t){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"repository_add"),t?this.txb.moveCall({target:zo.Instance().serviceFn("repository_add_with_passport"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("repository_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_repository(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"repository_address"),r?t?this.txb.moveCall({target:zo.Instance().serviceFn("repository_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("repository_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:zo.Instance().serviceFn("repository_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("repository_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_arbitration(e,t,r){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"add_arbitration.arbitraion"),go(t)||Ba(Ca.IsValidTokenType,"add_arbitration.arbitraion_token_type"),r?this.txb.moveCall({target:zo.Instance().serviceFn("arbitration_add_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]}):this.txb.moveCall({target:zo.Instance().serviceFn("arbitration_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]})}remove_arbitration(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_arbitration.address"),r?t?this.txb.moveCall({target:zo.Instance().serviceFn("arbitration_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("arbitration_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:zo.Instance().serviceFn("arbitration_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("arbitration_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_withdraw_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{zo.IsValidObjects([e.guard])||(r=!1),vo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_guard_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_guard_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_withdraw_guards(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"guard_address"),r?t?this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_guard_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_guard_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_guard_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_guard_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_refund_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{zo.IsValidObjects([e.guard])||(r=!1),vo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:zo.Instance().serviceFn("refund_guard_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("refund_guard_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_refund_guards(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.InvalidParam,"guard_address"),r?t?this.txb.moveCall({target:zo.Instance().serviceFn("refund_guard_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("refund_guard_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:zo.Instance().serviceFn("refund_guard_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("refund_guard_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}is_valid_sale(e){let t=!0,r=[];return e.forEach((e=>{gd.IsValidItemName(e.item)||(t=!1),mo(e.price)||(t=!1),mo(e.stock)||(t=!1),r.includes(e.item)&&(t=!1),r.push(e.item)})),t}add_sales(e,t=!1,r){if(0===e.length)return;this.is_valid_sale(e)||Ba(Ca.InvalidParam,"add_sales");let s=[],i=[],n=[],a=[];e.forEach((e=>{e.endpoint&&!oo(e.endpoint)&&Ba(Ca.IsValidEndpoint,"add_sales"),s.push(e.item),i.push(e.price),n.push(e.stock),a.push(e.endpoint??"")})),r?this.txb.moveCall({target:zo.Instance().serviceFn("sales_add_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("sales_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_sales(e,t){0!==e.length&&(To(e,gd.IsValidItemName)||Ba(Ca.IsValidArray,"remove_sales"),t?this.txb.moveCall({target:zo.Instance().serviceFn("sales_remove_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("sales_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",$a(e)),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}discount_transfer(e,t){(!e||e.length>gd.MAX_DISCOUNT_RECEIVER_COUNT)&&Ba(Ca.InvalidParam,"discount_dispatch");let r=!0;e.forEach((e=>{co(e.receiver)||(r=!1),(!mo(e.count)||e.count>gd.MAX_DISCOUNT_COUNT_ONCE)&&(r=!1),ao(e.discount.name)||(r=!1),e.discount.type!=cd.ratio||vo(e.discount.off)||(r=!1),mo(e.discount.duration_minutes)||(r=!1),e.discount?.time_start&&!mo(e.discount.time_start)&&(r=!1),e.discount?.price_greater&&!mo(e.discount.price_greater)&&(r=!1)})),r||Ba(Ca.InvalidParam,"discount_dispatch");const s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);e.forEach((e=>{let r=this.txb.pure.option("u64",e.discount?.price_greater?e.discount?.price_greater:void 0),i=this.txb.pure.option("u64",e.discount?.time_start?e.discount?.time_start:void 0);t?this.txb.moveCall({target:zo.Instance().serviceFn("dicscount_create_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),zo.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("dicscount_create"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),zo.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]})}))}withdraw(e,t,r){zo.IsValidObjects([e,t.treasury,t.withdraw_guard,r])||Ba(Ca.IsValidObjects),t?.for_guard&&!zo.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),mo(t.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return t.for_guard?this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_forGuard_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("withdraw_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_buy_guard(e,t){t?e?this.txb.moveCall({target:zo.Instance().serviceFn("buy_guard_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("buy_guard_none_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:zo.Instance().serviceFn("buy_guard_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("buy_guard_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_machine(e,t){t?e?this.txb.moveCall({target:zo.Instance().serviceFn("machine_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("machine_none_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:zo.Instance().serviceFn("machine_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("machine_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:zo.Instance().serviceFn("endpoint_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),r,zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("endpoint_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),r,zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}publish(e){e?this.txb.moveCall({target:zo.Instance().serviceFn("publish_with_passport"),arguments:[e,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("publish"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}clone(e,t,r){let s;return s=r?this.txb.moveCall({target:zo.Instance().serviceFn("clone_withpassport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("clone"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}),t?this.txb.moveCall({target:zo.Instance().serviceFn("create"),arguments:[zo.TXB_OBJECT(this.txb,s)],typeArguments:[e||this.pay_token_type]}):s}set_customer_required(e,t,r){t.length>0&&!e&&Ba(Ca.InvalidParam,"set_customer_required"),e.length>gd.MAX_PUBKEY_SIZE&&Ba(Ca.InvalidParam,"set_customer_required.pubkey"),t.length>gd.MAX_REQUIRES_COUNT&&Ba(Ca.InvalidParam,"set_customer_required.customer_required"),To(t,no)||Ba(Ca.IsValidArray,"set_customer_required.customer_required");let s=$a(t);r?this.txb.moveCall({target:zo.Instance().serviceFn("required_set_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("required_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_customer_required(e){e?this.txb.moveCall({target:zo.Instance().serviceFn("required_none_with_passport"),arguments:[e,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("required_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}change_required_pubkey(e,t){e||Ba(Ca.InvalidParam,"pubkey"),t?this.txb.moveCall({target:zo.Instance().serviceFn("required_pubkey_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("required_pubkey_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:zo.Instance().serviceFn("pause_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("pause"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}refund_withArb(e,t,r){zo.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"refund_withArb.order or arb"),go(r)||Ba(Ca.IsValidTokenType,"refund_withArb.arb_type");const s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);this.txb.moveCall({target:zo.Instance().serviceFn("refund_with_arb"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.object(t),this.txb.object(s)],typeArguments:[this.pay_token_type,r]})}refund(e,t,r){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"refund.order"),t&&!zo.IsValidObjects([t])&&Ba(Ca.IsValidObjects,"refund.refund_guard"),r&&!t&&Ba(Ca.InvalidParam,"refund.passport need refund_guard");const s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);r&&t?this.txb.moveCall({target:zo.Instance().serviceFn("refund_with_passport"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.object(t),r,this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("refund"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}update_order_required_info(e,t){t.customer_pubkey&&0!==t.customer_info_crypt.length&&(zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"update_order_required_info.order"),this.txb.moveCall({target:zo.Instance().serviceFn("order_required_info_update"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),this.txb.pure.string(t.customer_pubkey),this.txb.pure.string(t.customer_info_crypt)],typeArguments:[this.pay_token_type]}))}order(e,t,r,s,i,n){0===e.length&&Ba(Ca.InvalidParam,"order.buy_items empty");let a=!0,o=[];e.forEach((e=>{gd.IsValidItemName(e.item)||(a=!1),mo(e.max_price)||(a=!1),mo(e.count)||(a=!1),o.includes(e.item)&&(a=!1),o.push(e.item)})),a||Ba(Ca.InvalidParam,"buy_items invalid");let d,c=[],u=[],h=[];e.forEach((e=>{c.push(e.item),u.push(BigInt(e.max_price)),h.push(BigInt(e.count))}));const l=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);d=n?r?this.txb.moveCall({target:zo.Instance().serviceFn("dicount_buy_with_passport"),arguments:[n,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),zo.TXB_OBJECT(this.txb,t),zo.TXB_OBJECT(this.txb,r),this.txb.object(l)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("buy_with_passport"),arguments:[n,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),zo.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}):r?this.txb.moveCall({target:zo.Instance().serviceFn("disoucnt_buy"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),zo.TXB_OBJECT(this.txb,t),zo.TXB_OBJECT(this.txb,r),this.txb.object(l)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("buy"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),zo.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}),i&&this.update_order_required_info(d,i);var p=void 0;return s&&(p=this.order_bind_machine(d,s)),{order:d,progress:p}}order_launch(e){var t;return e.progress&&(t=this.txb.moveCall({target:zo.Instance().progressFn("create"),arguments:[zo.TXB_OBJECT(this.txb,e.progress)]})),{order:this.txb.moveCall({target:zo.Instance().serviceFn("order_create"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.order)],typeArguments:[this.pay_token_type]}),progress:t}}buy(e,t,r,s,i,n){const a=this.order(e,t,r,s,i,n);return this.order_launch(a)}order_bind_machine(e,t){return zo.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"order & machine"),this.txb.moveCall({target:zo.Instance().serviceFn("order_bind_machine"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e),zo.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]})}add_treasury(e,t,r){zo.IsValidObjects([t])||Ba(Ca.IsValidObjects,"add_treasury.treasury"),go(e)||Ba(Ca.IsValidTokenType,"add_treasury.treasury_token_type"),r?this.txb.moveCall({target:zo.Instance().serviceFn("treasury_add_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]}):this.txb.moveCall({target:zo.Instance().serviceFn("treasury_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]})}remove_treasury(e,t,r){(t||0!==e.length)&&(r?t?this.txb.moveCall({target:zo.Instance().serviceFn("treasury_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("treasury_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:zo.Instance().serviceFn("treasury_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().serviceFn("treasury_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}change_permission(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:zo.Instance().serviceFn("permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission),zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}set_order_agent(e,t,r){gd.SetOrderAgent(this.txb,this.pay_token_type,e,t,r)}change_order_payer(e,t,r){gd.ChangeOrderPayer(this.txb,this.pay_token_type,e,t,r)}static MAX_DISCOUNT_COUNT_ONCE=200;static MAX_DISCOUNT_RECEIVER_COUNT=20;static MAX_GUARD_COUNT=16;static MAX_REPOSITORY_COUNT=32;static MAX_ITEM_NAME_LENGTH=256;static MAX_TREASURY_COUNT=8;static MAX_ORDER_AGENT_COUNT=8;static MAX_ORDER_ARBS_COUNT=8;static MAX_ARBITRATION_COUNT=8;static MAX_REQUIRES_COUNT=16;static MAX_PUBKEY_SIZE=3e3;static IsValidItemName(e){return!!e&&(new TextEncoder).encode(e).length<=gd.MAX_ITEM_NAME_LENGTH}static parseObjectType=e=>La(e,"service::Service<");static parseOrderObjectType=e=>La(e,"order::Order<");static endpoint=(e,t,r)=>t||(e?e+"/sales/"+encodeURI(r):void 0);static DiscountObjects=(e,t)=>{zo.Client().getOwnedObjects({owner:e,filter:{MoveModule:{module:"order",package:zo.Instance().package("wowok")}},options:{showContent:!0,showType:!0}}).then((r=>{t(e,r.data.map((e=>e.data)))})).catch((e=>{console.log(e)}))};static SetOrderAgent=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"SetOrderAgent.order_token_type"),zo.IsValidObjects([r])||Ba(Ca.IsValidObjects,"SetOrderAgent.order"),To(s,co)||Ba(Ca.IsValidArray,"SetOrderAgent.agent"),$a(s).length>gd.MAX_ORDER_AGENT_COUNT&&Ba(Ca.Fail,"SetOrderAgent.agent count"),e.moveCall({target:zo.Instance().orderFn("agent_set"),arguments:[e.object(r),e.pure.vector("address",$a(s))],typeArguments:[t]}),i&&e.moveCall({target:zo.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})};static ChangeOrderPayer=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"ChangeOrderPayer.order_token_type"),zo.IsValidObjects([r])||Ba(Ca.IsValidObjects,"ChangeOrderPayer.order"),co(s)||Ba(Ca.IsValidAddress,"ChangeOrderPayer.new_addr"),e.moveCall({target:zo.Instance().orderFn("payer_change"),arguments:[e.object(r),e.pure.address(s)],typeArguments:[t]}),i&&e.moveCall({target:zo.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})}}class fd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new fd(e);return t.object=zo.TXB_OBJECT(e,zo.Instance().objectEntity()),t}mark(e,t,r){"string"!=typeof t||co(t)||Ba(Ca.IsValidAddress,r),this.txb.moveCall({target:zo.Instance().entityFn(r),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.get_object()),"string"==typeof t?this.txb.pure.address(t):t]})}update(e){e?.name&&!no(e.name)&&Ba(Ca.IsValidName,"update"),e?.description&&!io(e.description)&&Ba(Ca.IsValidDesription,"update"),e?.avatar&&!Bo(e.avatar)&&Ba(Ca.isValidHttpUrl,"update:avatar"),e?.twitter&&!no(e.twitter)&&Ba(Ca.IsValidName,"update:twitter"),e?.homepage&&!Bo(e.homepage)&&Ba(Ca.isValidHttpUrl,"update:homepage"),e?.discord&&!no(e.discord)&&Ba(Ca.IsValidName,"update:discord");const t=Wa.getInstance().bcs.ser("PersonalInfo",{name:e.name?(new TextEncoder).encode(e.name):"",description:e?.description?(new TextEncoder).encode(e.description):"",avatar:e?.avatar??"",twitter:e?.twitter??"",discord:e?.discord??"",homepage:e?.homepage??""}).toBytes();this.txb.moveCall({target:zo.Instance().entityFn("avatar_update"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("u8",[].slice.call(t))]})}create_resource(){return this.txb.moveCall({target:zo.Instance().entityFn("resource_create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}create_resource2(){return this.txb.moveCall({target:zo.Instance().entityFn("resource_create2"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}destroy_resource(e){return this.txb.moveCall({target:zo.Instance().entityFn("resource_destroy"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.get_object())]})}use_resource(e){return this.txb.moveCall({target:zo.Instance().entityFn("resource_use"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.get_object())]})}transfer_resource(e,t){return co(t)||Ba(Ca.IsValidAddress,"transfer_resource"),this.txb.moveCall({target:zo.Instance().entityFn("resource_transfer"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.get_object()),this.txb.pure.address(t)]})}query_ent(e){co(e)||Ba(Ca.InvalidParam,"query_ent"),this.txb.moveCall({target:zo.Instance().entityFn("QueryEnt"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}}class yd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new yd(e);return t.object=zo.TXB_OBJECT(e,zo.Instance().objectWowok()),t}register_grantor(e,t){no(e)||Ba(Ca.IsValidName,"register_grantor"),zo.IsValidObjects([t])||Ba(Ca.IsValidObjects,"register_grantor");const r=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);this.txb.moveCall({target:zo.Instance().wowokFn("grantor_register"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.object(r),zo.TXB_OBJECT(this.txb,t)]})}grantor_time_expand_1year(e){co(e)||Ba(Ca.IsValidAddress,"grantor_time_expand_1year"),this.txb.moveCall({target:zo.Instance().wowokFn("grantor_time_expand_1year"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}grantor_rename(e){no(e)||Ba(Ca.IsValidName,"grantor_rename"),this.txb.moveCall({target:zo.Instance().wowokFn("grantor_time_expand_1year"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}mint(e,t){co(t)||Ba(Ca.IsValidAddress,"mint"),mo(e)||Ba(Ca.IsValidU64,"mint"),this.txb.moveCall({target:zo.Instance().baseWowokFn("mint"),arguments:[zo.TXB_OBJECT(this.txb,zo.Instance().objectTreasuryCap()),this.txb.pure.u64(e),this.txb.pure.address(t)]})}oracle(e,t){return io(e)||Ba(Ca.IsValidDesription,"oracle.description"),zo.IsValidObjects([t])||Ba(Ca.IsValidObjects,"oracle.permission"),this.txb.moveCall({target:zo.Instance().wowokFn("oracle_repository"),arguments:[zo.TXB_OBJECT(this.txb,zo.Instance().objectOracle()),this.txb.pure.string(e),this.txb.object(t)]})}}!function(e){e.Like="like",e.Dislike="dislike",e.Launch="launch",e.Order="order",e.Payment="payment"}(hd||(hd={}));class vd{static MAX_ADDRESS_COUNT_FOR_TAG=1e3;static MAX_TAG_COUNT_FOR_ADDRESS=64;object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new vd(e);return r.object=zo.TXB_OBJECT(e,t),r}launch(){return this.object||Ba(Ca.Fail,"launch object Invalid"),this.txb.moveCall({target:zo.Instance().resourceFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)]})}resolve_add(e,t){return t.find((e=>e===hd.Like))&&fd.From(this.txb).mark(this,e,hd.Like),t.find((e=>e===hd.Dislike))&&fd.From(this.txb).mark(this,e,hd.Dislike),t.filter((e=>e!==hd.Like&&e!==hd.Dislike&&no(e)))}add(e,t,r){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: add.address");var s=this.resolve_add(e,t);(r||0!==s.length)&&(r&&!no(r)&&Ba(Ca.IsValidName,"Resource: add.name"),s.length>vd.MAX_TAG_COUNT_FOR_ADDRESS&&(s=s.slice(0,vd.MAX_TAG_COUNT_FOR_ADDRESS)),this.txb.moveCall({target:zo.Instance().resourceFn("add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.option("string",r),this.txb.pure.vector("string",s)]}))}remove(e,t){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: remove.address"),this.txb.moveCall({target:zo.Instance().resourceFn("remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.vector("string",t)]})}removeall(e){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: removeall.address"),this.txb.moveCall({target:zo.Instance().resourceFn("removeall"),arguments:[zo.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e]})}static TagData(e,t=!0){const r=[];return e.forEach((e=>{e.tags.forEach((t=>{const s=r.find((e=>e.tag===t));s?s.address.find((t=>t===e.address))||s.address.push(e.address):r.push({tag:t,address:[e.address]})}))})),t&&Object.keys(hd).forEach((e=>{r.find((t=>t.tag===hd[e]))||r.push({tag:hd[e],address:[]})})),r}static Tags(e){const t=[];return e.address.forEach((r=>{const s=t.find((e=>e.address===r));s?s.tags.find((t=>t===e.tag))||s.tags.push(e.tag):t.push({address:r,tags:[e.tag]})})),t}}!function(e){e[e.PERMISSION=0]="PERMISSION",e[e.GUARD_ONLY_AND_IMMUTABLE=1]="GUARD_ONLY_AND_IMMUTABLE",e[e.BOTH_PERMISSION_AND_GUARD=2]="BOTH_PERMISSION_AND_GUARD"}(ld||(ld={})),function(e){e[e.WITHDRAW=1]="WITHDRAW",e[e.DEPOSIT=2]="DEPOSIT",e[e.RECEIVE=4]="RECEIVE"}(pd||(pd={}));class Td{token_type;permission;object;txb;get_token_type(){return this.token_type}get_object(){return this.object}static From(e,t,r,s){let i=new Td(e,t,r);return i.object=zo.TXB_OBJECT(e,s),i}constructor(e,t,r){this.token_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i){zo.IsValidObjects([r])||Ba(Ca.IsValidObjects,"Treasury.New permission, bounty"),io(s)||Ba(Ca.IsValidDesription,"Treasury.New.description"),fo(t)||Ba(Ca.IsValidArgType,t);let n=new Td(e,t,r);return n.object=i?e.moveCall({target:zo.Instance().treasuryFn("new_with_passport"),arguments:[i,e.pure.string(s),zo.TXB_OBJECT(e,r)],typeArguments:[t]}):e.moveCall({target:zo.Instance().treasuryFn("new"),arguments:[e.pure.string(s),zo.TXB_OBJECT(e,r)],typeArguments:[t]}),n}launch(){return this.txb.moveCall({target:zo.Instance().treasuryFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.token_type]})}set_deposit_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_deposit_guard.guard"),t?e?this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_guard_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_guard_none_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e?this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_guard_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_guard_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}deposit(e,t){zo.IsValidObjects([e.coin])||Ba(Ca.IsValidObjects,"deposit.param.coin"),io(e.remark)||Ba(Ca.IsValidDesription,"deposit.param.remark"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"deposit.param.for_object"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"deposit.param.for_guard"),void 0===e.index||mo(e.index)||Ba(Ca.InvalidParam,"deposit.param.index");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return t?e.for_guard?this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_forGuard_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:zo.Instance().treasuryFn("deposit_forGuard"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("deposit"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}receive(e,t,r){zo.IsValidObjects([e,t])||Ba(Ca.IsValidArray,"receive.payment&received");const s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return r?this.txb.moveCall({target:zo.Instance().treasuryFn("receive_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("receive"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}withdraw(e,t){if(0===e.items.length)return;To(e.items,(e=>mo(e.amount)&&co(e.address)))||Ba(Ca.IsValidArray,"withdraw.param.items"),io(e.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark"),mo(e.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.for_guard"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),e?.withdraw_guard&&!co(e.withdraw_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard"),e?.withdraw_guard&&!t&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return e.withdraw_guard&&t?e.for_guard?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_useGuard_forGuard"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_useGuard"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):t?e.for_guard?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_forGuard_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_forGuard"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:zo.Instance().treasuryFn("description_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_withdraw_mode(e,t){t?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_mode_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_mode_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}add_withdraw_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"add_withdraw_guard.guard"),mo(t)||Ba(Ca.IsValidU64,"add_withdraw_guard.amount"),r?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_guard_add_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_guard_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}remove_withdraw_guard(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.IsValidArray,"add_withdraw_guard.guard"),r?t?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_guard_remove_all_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_guard_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):t?this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_guard_remove_all"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:zo.Instance().treasuryFn("withdraw_guard_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}))}change_permission(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"change_permission.new_permission"),this.txb.moveCall({target:zo.Instance().treasuryFn("permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission),zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.token_type]}),this.permission=e}static parseObjectType=e=>La(e,"treasury::Treasury<");static MAX_WITHDRAW_GUARD_COUNT=16}const Ed=200;function wd(e,t,r){t||Ba(Ca.InvalidParam,"Payment.New.pay_token_type"),r.receiver.length>Ed&&Ba(Ca.InvalidParam,"Payment.New.param.receiver"),To(r.receiver,(e=>co(e.address)&&zo.IsValidObjects([e.coin])))||Ba(Ca.IsValidArray,"Payment.New.param.receiver"),r?.for_object&&!co(r.for_object)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_object"),r?.for_guard&&!co(r.for_guard)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_guard"),r?.business_remark&&!io(r?.business_remark)&&Ba(Ca.IsValidDesription,"Payment.New.param.business_remark");let s=e.pure.option("address",r.for_object?r.for_object:void 0);const i=e.sharedObjectRef(zo.CLOCK_OBJECT);return r.for_guard?e.moveCall({target:zo.Instance().paymentFn("create_withGuard"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.object(r.for_guard),e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]}):e.moveCall({target:zo.Instance().paymentFn("create"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]})}class xd{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new xd(e,t,r);return i.object=zo.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n,a){zo.IsValidObjects([r,n])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New.token_type"),io(s)||Ba(Ca.IsValidDesription),mo(i)||Ba(Ca.IsValidU64,"New.fee");let o=t,d=new xd(e,o,r);return d.object=a?e.moveCall({target:zo.Instance().arbitrationFn("new_with_passport"),arguments:[a,e.pure.string(s),e.pure.u64(i),e.object(n),zo.TXB_OBJECT(e,r)],typeArguments:[o]}):e.moveCall({target:zo.Instance().arbitrationFn("new"),arguments:[e.pure.string(s),e.pure.u64(i),e.object(n),zo.TXB_OBJECT(e,r)],typeArguments:[o]}),d}launch(){return this.txb.moveCall({target:zo.Instance().arbitrationFn("create"),arguments:[zo.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:zo.Instance().arbitrationFn("description_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("description_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_fee(e,t){mo(e)||Ba(Ca.IsValidU64,"set_fee.fee"),t?this.txb.moveCall({target:zo.Instance().arbitrationFn("fee_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("fee_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint,"set_endpoint.endpoint"),t?e?this.txb.moveCall({target:zo.Instance().arbitrationFn("endpoint_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("endpoint_none_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:zo.Instance().arbitrationFn("endpoint_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("endpoint_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_voting_guard(e,t){0!==e.length&&(To(e,(e=>zo.IsValidObjects([e.guard])&&mo(e.voting_weight)))||Ba(Ca.IsValidArray,"add_voting_guard.guard"),t?e.forEach((e=>{this.txb.moveCall({target:zo.Instance().arbitrationFn("voting_guard_add_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})):e.forEach((e=>{this.txb.moveCall({target:zo.Instance().arbitrationFn("voting_guard_add"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})))}remove_voting_guard(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_voting_guard.guard"),r?t?this.txb.moveCall({target:zo.Instance().arbitrationFn("voting_guard_removeall_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("voting_guard_remove_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:zo.Instance().arbitrationFn("voting_guard_removeall"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("voting_guard_remove"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}set_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_guard.apply_guard"),t?e?this.txb.moveCall({target:zo.Instance().arbitrationFn("usage_guard_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("usage_guard_none_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:zo.Instance().arbitrationFn("usage_guard_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("usage_guard_none"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:zo.Instance().arbitrationFn("pause_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("pause"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}vote(e,t){e.voting_guard&&!zo.IsValidObjects([e.voting_guard])&&Ba(Ca.IsValidObjects,"vote.param.voting_guard"),To(e.agrees,(e=>mo(e)&&e<xd.MAX_PROPOSITION_COUNT))||Ba(Ca.IsValidArray,"vote.param.agrees"),zo.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"vote.param.arb");const r=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);t?e.voting_guard?this.txb.moveCall({target:zo.Instance().arbitrationFn("vote_with_passport"),arguments:[t,this.txb.object(e.voting_guard),zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("vote2_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("vote"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arbitration(e,t){io(e.feedback)||Ba(Ca.IsValidDesription,"arbitration.param.feedback"),zo.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"arbitration.param.arb"),e.indemnity&&!mo(e.indemnity)&&Ba(Ca.IsValidU64,"arbitration.param.indemnity");let r=this.txb.pure.option("u64",e.indemnity?e.indemnity:void 0);t?this.txb.moveCall({target:zo.Instance().arbitrationFn("arbitration_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("arbitration"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}withdraw_fee(e,t,r){zo.IsValidObjects([e,t.treasury])||Ba(Ca.IsValidObjects,"withdraw_fee.arb or treasury"),t?.for_guard&&!zo.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw_fee.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw_fee.param.for_object"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw_fee.param.remark"),mo(t.index)||Ba(Ca.IsValidU64,"withdraw_fee.param.index");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef(zo.CLOCK_OBJECT);return r?t.for_guard?this.txb.moveCall({target:zo.Instance().arbitrationFn("withdraw_forGuard_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("withdraw_with_passport"),arguments:[r,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t.for_guard?this.txb.moveCall({target:zo.Instance().arbitrationFn("withdraw_forGuard"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("withdraw"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_withdrawTreasury(e,t){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_withdrawTreasury.treasury"),t?this.txb.moveCall({target:zo.Instance().arbitrationFn("withdraw_treasury_set_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("withdraw_treasury_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e),zo.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arb(e,t){return zo.IsValidObjects([e.order])||Ba(Ca.IsValidObjects,"arb.param.order"),go(e.order_token_type)||Ba(Ca.IsValidTokenType,"arb.param.order_token_type"),io(e.description)||Ba(Ca.IsValidDesription,"arb.param.description"),To(e.votable_proposition,no)||Ba(Ca.IsValidArray,"arb.param.votable_proposition"),t?e.fee?this.txb.moveCall({target:zo.Instance().arbitrationFn("dispute_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("free_dispute_with_passport"),arguments:[t,zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]}):e.fee?this.txb.moveCall({target:zo.Instance().arbitrationFn("dispute"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:zo.Instance().arbitrationFn("free_dispute"),arguments:[zo.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",$a(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]})}arb_launch(e){return this.txb.moveCall({target:zo.Instance().arbFn("create"),arguments:[zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}dispute(e,t){const r=this.arb(e,t);return this.arb_launch(r)}change_permission(e){zo.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:zo.Instance().arbitrationFn("permission_set"),arguments:[zo.TXB_OBJECT(this.txb,this.object),zo.TXB_OBJECT(this.txb,this.permission),zo.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}static parseObjectType=e=>La(e,"arbitration::Arbitration<");static parseArbObjectType=e=>La(e,"arb::Arb<");static queryArbVoted=()=>{};static MAX_PROPOSITION_COUNT=16;static MAX_VOTING_GUARD_COUNT=16}class Od extends Error{}async function Id({host:e,path:t,body:r,headers:s,method:i}){const n=new URL(t,e).toString(),a=await fetch(n,{method:i,body:r?JSON.stringify(r):void 0,headers:{"Content-Type":"application/json",...s||{}}});if(429===a.status)throw new Od("Too many requests from this client have been sent to the faucet. Please retry later");try{const e=await a.json();if(e.error)throw new Error(`Faucet returns error: ${e.error}`);return e}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${a.status}, response ${a}`)}}async function Cd(e){return Id({host:e.host,path:"/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}async function Bd(e){return Id({host:e.host,path:"/v1/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}function Sd(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}class Pd{constructor(e){this.expire=e}expire_time(){return this.expire}expire}var jd;!function(e){e.object="OBJECT",e.personal="PERSONAL",e.table="TABLE"}(jd||(jd={}));const Ad=(e,t)=>e+zo.Instance().package("wowok_origin")+t+"-V2";class kd extends Pd{constructor(e=1e4){super(e)}data=new Map;load(e){return this.data.get(e)}save(e,t){this.data.set(e,t)}remove(e){this.data.delete(e)}}class Ud extends Pd{constructor(e=1e4){super(e)}load(e){return localStorage.getItem(e)}save(e,t){return localStorage.setItem(e,t)}remove(e){return localStorage.removeItem(e)}}class Nd{static _instance;cache=new Map;constructor(){}static Instance(){return Nd._instance||(Nd._instance=new Nd),Nd._instance}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}}var Dd;!function(e){e.localStorage="localStorage",e.memoryStorage="memoryStorage"}(Dd||(Dd={})),new Map;const Yd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Md(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Rd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Fd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Vd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Jd(t)??""})}catch(e){return JSON.stringify({error:e?.toString()})}},Md=async e=>{var t=[];const r=[],s=(new Date).getTime(),i=Nd.Instance().get(jd.object);if(i)for(let n=0;n<e.objects.length;++n){try{let a=i.load(Ad(e.objects[n],jd.object));if(a){const i=JSON.parse(a);if("INFINITE"!==i?.expire&&(e?.no_cache||i.expire<=s)&&(e.showOwner||e.showContent))r.push(e.objects[n]);else{const e=sc(JSON.parse(i.data));e.cache_expire=i.expire,t.push(e)}}}catch(e){console.log(e)}r.push(e.objects[n])}if(r.length>0){const s=await zo.Client().multiGetObjects({ids:[...r],options:{showContent:e.showContent,showType:e.showType,showOwner:e.showOwner}}),i=Nd.Instance().get(jd.object);if(i){const e=(new Date).getTime();s.forEach((t=>{try{if(t?.data){const r=t.data?.type??t.data?.content?.type??void 0,s=r?zo.Instance().object_name_from_type_repr(r):void 0,n={expire:"Guard"===s||"Payment"===s?"INFINITE":i.expire_time()+e,data:JSON.stringify(t.data)};i.save(Ad(t.data.objectId,jd.object),JSON.stringify(n))}}catch(e){console.log(e)}}))}t=t.concat(s.map((e=>sc(e?.data))))}return{objects:t}},Jd=async e=>{co(e.address)||Ba(Ca.IsValidAddress,"entity.address");const t=(new Date).getTime(),r=Nd.Instance().get(jd.personal);if(r&&!e.no_cache)try{let s=r.load(Ad(e.address,jd.personal));if(s){const e=JSON.parse(s);if("INFINITE"===e?.expire||e.expire<=t){const t=JSON.parse(e.data);return t.cache_expire=e.expire,t}}}catch(e){console.log(e)}const s=await tc(Qd(zo.Instance().objectEntity(),e.address));if("Personal"===s.type){if(r)try{const t=r.expire_time()+(new Date).getTime(),i={expire:t,data:JSON.stringify(s)};r.save(Ad(e.address,jd.personal),JSON.stringify(i)),s.cache_expire=t}catch(e){console.log(e)}return s}},Fd=async e=>{const t=await zo.Client().getDynamicFields({parentId:e.parent,cursor:e.cursor,limit:e.limit});return{items:t?.data?.map((e=>({object:e.objectId,type:e.type,version:e.version,key:{type:e.name.type,value:e.name.value}}))),nextCursor:t.nextCursor,hasNextPage:t.hasNextPage}},Xd=async(e,t)=>await tc(Qd(e,t)),Ld=async(e,t)=>await tc(Qd(e,t)),Gd=async(e,t)=>await tc(Qd(e,t)),$d=async(e,t)=>await tc(Zd(e,t)),zd=async(e,t)=>await tc(Zd(e,t)),qd=async(e,t)=>await tc(ec(e,t)),Wd=async(e,t)=>await tc(ec(e,t)),Hd=async(e,t,r)=>("string"!=typeof e&&(e=e.object),await tc({parent:e,key:{type:zo.Instance().package("wowok")+"::repository::DataKey",value:{id:t,key:r}}})),Kd=async(e,t)=>await tc(Qd(e,t));function Qd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"address",value:t}}}function Zd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"0x1::string::String",value:t}}}function ec(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"u64",value:t}}}const tc=async e=>{const t=await zo.Client().getDynamicFieldObject({parentId:e.parent,name:{type:e.key.type,value:e.key.value}});return sc(t?.data)};function rc(e){if(!e)return;const t=zo.Instance().object_name_from_type_repr(e);if("Permission"===t||"Demand"===t||"Machine"===t||"Progress"===t||"Order"===t||"Service"===t||"Treasury"===t||"Arb"===t||"Repository"===t||"Payment"===t||"Discount"===t||"Guard"===t||"Arbitration"===t)return t;if("Resource"===t)return"PersonalMark";const r=e?.indexOf("0x2::dynamic_field::Field<");if(0===r){const t=e?.substring(26);if(t&&zo.Instance().hasPackage(t)){if(t.includes("::demand::Tips>"))return"TableItem_DemandPresenter";if(t.includes("::machine::NodePair>>>"))return"TableItem_MachineNode";if(t.includes("::progress::History>"))return"TableItem_ProgressHistory";if(t.includes("::service::Sale>"))return"TableItem_ServiceSale";if(t.includes("::treasury::Record>"))return"TableItem_TreasuryHistory";if(t.includes("::arb::Voted>"))return"TableItem_ArbVote";if(t.includes("::permission::Perm>>"))return"TableItem_PermissionEntity";if(t.includes("::repository::DataKey"))return"TableItem_RepositoryData";if(t.includes("::entity::Ent>"))return"Personal";if(t.includes("::resource::Tags>"))return"TableItem_PersonalMark"}}}function sc(e){const t=e?.content?.fields,r=e?.objectId??t?.id?.id??void 0,s=e?.type??e?.content?.type??void 0,i=e?.version??void 0,n=e?.owner??void 0,a=rc(s);if(a)switch(a){case"Permission":return{object:r,type:a,type_raw:s,owner:n,version:i,builder:t?.builder??"",admin:t?.admin,description:t?.description??"",entity_count:parseInt(t?.table?.fields?.size),biz_permission:t?.user_define?.fields?.contents?.map((e=>({id:parseInt(e?.fields?.key),name:e?.fields?.value})))};case"Demand":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,guard:t?.guard?{object:t?.guard,service_id_in_guard:t?.service_identifier}:void 0,time_expire:t?.time_expire,yes:t?.yes,presenter_count:parseInt(t?.presenters?.fields?.size),bounty:t?.bounty?.map((e=>({type:e?.fields?.type,object:e?.fields?.id?.id,balance:e?.fields?.balance})))};case"Machine":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission??"",description:t?.description??"",bPaused:t?.bPaused,bPublished:t?.bPublished,endpoint:t?.endpoint,consensus_repository:t?.consensus_repositories,node_count:parseInt(t?.nodes?.fields?.size)};case"Progress":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,current:t?.current,task:t?.task,parent:t?.parent,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),namedOperator:t?.namedOperator?.fields?.contents?.map((e=>({name:e?.fields?.key,operator:e?.fields?.value}))),session:t?.session?.fields?.contents?.map((e=>({weights:e?.fields?.value?.fields?.weight,threshold:e?.fields?.value?.fields?.threshold,next_node:e?.fields?.key,forward:e?.fields?.value?.fields?.forwards?.fields?.contents?.map((e=>({forward_name:e?.fields?.key,accomplished:e?.fields?.value?.fields?.accomplished,msg:e?.fields?.value?.fields?.msg,orders:e?.fields?.value?.fields?.orders,time:e?.fields?.value?.fields?.time,holder:e?.fields?.value?.fields?.who})))})))};case"Order":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,amount:t?.amount,agent:t?.agent,arb:t?.dispute,payer:t?.payer,progress:t?.progress,discount:t?.discount,balance:t?.payed,required_info:t?.required_info?{pubkey:t?.required_info?.fields?.customer_pub,msg_encrypted:t?.required_info?.fields?.info}:void 0,item:t?.items?.map((e=>({name:e?.fields?.name,price:e?.fields?.price,stock:e?.fields?.stock,endpoint:e?.fields?.endpoint})))};case"Service":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,permission:t?.permission,description:t?.description,arbitration:t?.arbitrations,bPaused:t?.bPaused,bPublished:t?.bPublished,buy_guard:t?.buy_guard,endpoint:t?.endpoint,payee:t?.payee,repository:t?.repositories,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),refund_guard:t?.refund_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),sales_count:parseInt(t?.sales?.fields?.size),extern_withdraw_treasury:t?.extern_withdraw_treasuries,customer_required_info:t?.customer_required?{pubkey:t?.customer_required?.fields?.service_pubkey,required_info:t?.customer_required?.fields?.customer_required_info}:void 0};case"Treasury":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,withdraw_mode:t?.withdraw_mode,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),balance:t?.balance,deposit_guard:t?.deposit_guard,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value})))};case"Arbitration":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,fee:t?.fee,fee_treasury:t?.fee_treasury,usage_guard:t?.usage_guard,endpoint:t?.endpoint,bPaused:t?.bPaused,voting_guard:t?.voting_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,weights:e?.fields?.value})))};case"Arb":return{object:r,type:a,type_raw:s,owner:n,version:i,arbitration:t?.arbitration,description:t?.description,fee:t?.fee,feedback:t?.feedback,indemnity:t?.indemnity,order:t?.order,voted_count:parseInt(t?.voted?.fields?.size),proposition:t?.proposition?.fields?.contents?.map((e=>({proposition:e?.fields?.key,votes:e?.fields?.value})))};case"Repository":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,policy_mode:t?.policy_mode,data_count:parseInt(t?.data?.fields?.size),reference:t?.reference,rep_type:t?.type,policy:t?.policies?.fields?.contents?.map((e=>({key:e?.fields?.key,description:e?.fields?.value?.fields?.description,permissionIndex:e?.fields?.value?.fields?.permission_index,dataType:e?.fields?.value?.fields?.value_type})))};case"Payment":return{object:r,type:a,type_raw:s,owner:n,version:i,signer:t?.signer,time:t?.time,remark:t?.remark,from:t?.from,biz_id:t?.index,for_guard:t?.for_guard,for_object:t?.for_object,amount:t?.amount,record:t?.record?.map((e=>({recipient:e?.fields?.recipient,amount:e?.fields?.amount})))};case"Discount":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,time_start:t?.time_start,time_end:t?.time_end,price_greater:t?.price_greater,off_type:t?.type,off:t?.off,name:t?.name};case"Guard":return{object:r,type:a,type_raw:s,owner:n,version:i,description:t?.description,input:Uint8Array.from(t?.input?.fields?.bytes),identifier:t?.constants?.map((e=>({id:e?.fields?.identifier,bWitness:e?.fields?.bWitness,value:Uint8Array.from(e?.fields?.value)})))};case"PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,tag_count:parseInt(t?.tags?.fields?.size)};case"TableItem_DemandPresenter":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.name,presenter:t?.value?.fields?.who,recommendation:t?.value?.fields?.tips};case"TableItem_ProgressHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,history:ed.DeHistory(t)};case"TableItem_ServiceSale":return{object:r,type:a,type_raw:s,owner:n,version:i,item:{item:t?.name,stock:t?.value?.fields?.stock,price:t?.value?.fields?.price,endpoint:t?.value?.fields?.endpoint}};case"TableItem_TreasuryHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,id:t?.name,payment:t?.value?.fields?.payment,signer:t?.value?.fields?.signer,operation:t?.value?.fields?.op,amount:t?.value?.fields?.amount,time:t?.value?.fields?.time};case"TableItem_ArbVote":return{object:r,type:a,type_raw:s,owner:n,version:i,singer:t?.name,vote:t?.value?.fields?.agrees,time:t?.value?.fields?.time,weight:t?.value?.fields?.weight};case"TableItem_PermissionEntity":return{object:r,type:a,type_raw:s,owner:n,version:i,entity:t?.name,permission:t?.value?.map((e=>({id:e?.fields.index,guard:e?.fields.guard})))};case"TableItem_RepositoryData":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name?.fields?.id,key:t?.name?.fields?.key,data:Uint8Array.from(t?.value)};case"Personal":const o=Wa.getInstance().de_entInfo(Uint8Array.from(t?.value?.fields?.avatar));return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,like:t?.value?.fields?.like,dislike:t?.value?.fields?.dislike,mark_object:t?.value?.fields?.resource,lastActive_digest:e?.previousTransaction,info:{homepage:o?.homepage,name:o?.name,avatar:o?.avatar,twitter:o?.twitter,discord:o?.discord,description:o?.description}};case"TableItem_PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,name:t?.value?.fields?.nick,tags:t?.value?.fields?.tags}}return{object:r,type:void 0,type_raw:s,owner:n,version:i}}const ic=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await nc(t)})}catch(e){return JSON.stringify({error:e})}},nc=async e=>{co(e.permission_object)||Ba(Ca.IsValidAddress,"permission.permission_object");const t=new gs;Qo.From(t,e.permission_object).query_permissions_all(e.address);const r=await zo.Client().devInspectTransactionBlock({sender:e.address,transactionBlock:t});r.results&&r.results[0].returnValues&&2!==r.results[0].returnValues.length&&Ba(Ca.Fail,"permission.retValues");const s=Wa.getInstance().de(Oa.U8,Uint8Array.from(r.results[0].returnValues[0][0]));if(s===Qo.PERMISSION_ADMIN||s===Qo.PERMISSION_OWNER_AND_ADMIN)return{who:e.address,admin:!0,owner:s%2==1,items:[],object:e.permission_object};{const t=Wa.getInstance().de_perms(Uint8Array.from(r.results[0].returnValues[1][0]));return{who:e.address,admin:!1,owner:s%2==1,items:t.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e.permission_object}}};var ac;!function(e){e.newArbEvents=async e=>await t(zo.Instance().package("wowok")+"::arb::NewArbEvent",e),e.presentServiceEvents=async e=>await t(zo.Instance().package("wowok")+"::demand::PresentEvent",e),e.newProgressEvents=async e=>await t(zo.Instance().package("wowok")+"::progress::NewProgressEvent",e),e.newOrderEvents=async e=>await t(zo.Instance().package("wowok")+"::order::NewOrderEvent",e);const t=async(e,t)=>{const r=await zo.Client().queryEvents({query:{MoveEventType:e},cursor:t?.cursor,limit:t?.limit,order:t?.order}),s=r?.data?.map((e=>{if(e?.packageId===zo.Instance().package("wowok")){if(e?.type?.includes("::order::NewOrderEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",order:e?.parsedJson?.object,service:e?.parsedJson?.service,progress:e?.parsedJson?.progress,amount:e?.parsedJson?.amount};if(e?.type?.includes("::demand::PresentEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",demand:e?.parsedJson?.object,service:e?.parsedJson?.service,recommendation:e?.parsedJson?.tips};if(e?.type?.includes("::progress::NewProgressEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",progress:e?.parsedJson?.object,machine:e?.parsedJson?.machine,task:e?.parsedJson?.task};if(e?.type?.includes("::arb::NewArbEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",arb:e?.parsedJson?.object,arbitration:e?.parsedJson?.arbitration,order:e?.parsedJson?.order};if(e?.type?.includes("::entity::NewEntityEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",resource:e?.parsedJson?.resource?.some,address:e?.parsedJson?.target}}return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:""}}));return{data:s,hasNextPage:r?.hasNextPage,nextCursor:r?.nextCursor}}}(ac||(ac={}));const oc="wowok.acc.dat",dc="wowok-acc-v1";class cc{constructor(e="File"){this.storage=e}static _instance;static Instance(){return cc._instance||(cc._instance=new cc),cc._instance}storage="File";_add(e,t,r){var s,i="0x"+ta(Un(Zn.generate().getSecretKey()).secretKey);try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));return e?e.default=r:(r&&s.forEach((e=>e.default=!1)),s.push({name:t,key:i,default:r})),s}}catch(e){}return[{name:t,key:i,default:r}]}_default(e){var t;try{if(e&&(t=JSON.parse(e))){const e=t.find((e=>e.default));if(e)return e}}catch(e){}}_get(e,t,r){var s;try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));if(e)return e;if(r)return s.find((e=>e.default))}}catch(e){}}_rename(e,t,r,s=!0){var i;try{if(e&&(i=JSON.parse(e)),i){const e=i.find((e=>e.name===t));if(!e)return;const n=i.find((e=>e.name===r));if(!n)return e.name=r,i;if(s)return e.name=r,n.name=t,i}}catch(e){}}set_storage(e="File"){this.storage=e}async gen(e,t){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),oc);r.readFile(n,"utf-8",((s,i)=>{const a=this._add(i,e,t);r.writeFileSync(n,JSON.stringify(a),"utf-8")}))}else if("Explorer"===this.storage){const r=this._add(localStorage.getItem(dc),e,t);localStorage.setItem(dc,JSON.stringify(r))}}catch(e){}}async default(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),oc);return this._default(e.readFileSync(s,"utf-8"))}if("Explorer"===this.storage)return this._default(localStorage.getItem(dc))}catch(e){}}async get(e,t=!0){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),oc);return this._get(r.readFileSync(n,"utf-8"),e,t)}if("Explorer"===this.storage)return this._get(localStorage.getItem(dc),e,t)}catch(e){}}async rename(e,t,r=!0){var s;try{if("File"===this.storage){const[i,n,o]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),d=o.join(n.homedir(),oc);(s=this._rename(i.readFileSync(d,"utf-8"),e,t,r))&&i.writeFileSync(d,JSON.stringify(s),"utf-8")}else"Explorer"===this.storage&&(s=this._rename(localStorage.getItem(dc),e,t,r))&&localStorage.setItem(dc,JSON.stringify(s))}catch(e){}return!!s}async get_address(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiAddress()}async get_pubkey(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiPublicKey()}async get_pair(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key))}async list(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),oc);return JSON.parse(e.readFileSync(s,"utf-8")).map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}if("Explorer"===this.storage)return JSON.parse(localStorage.getItem(dc)??"").map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}catch(e){}return[]}async faucet(e){const t=await this.get_address(e,!0);t&&await Cd({host:Sd("testnet"),recipient:t}).catch((e=>{}))}balance=async(e,t)=>{const r=await this.get_address(e);if(r)return await zo.Client().getBalance({owner:r,coinType:t})};coin=async(e,t)=>{const r=await this.get_address(e);if(r)return(await zo.Client().getCoins({owner:r,coinType:t})).data};get_coin_object=async(e,t,r,s)=>{const i=await this.get_address(r),n=BigInt(t);if(i&&n>BigInt(0)){if(s&&"0x2::sui::SUI"!==s&&"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"!==s){const t=await zo.Client().getCoins({owner:i,coinType:s}),r=[];var a=BigInt(0);for(let e=0;e<t.data.length&&(a+=BigInt(t.data[e].balance),r.push(t.data[e].coinObjectId),!(a>=n));++e);if(1===r.length)return e.splitCoins(r[0],[n]);{const t=r.pop();return e.mergeCoins(t,r),e.splitCoins(t,[n])}}return e.splitCoins(e.gas,[t])}};coin_with_balance=async(e,t,r)=>{const s=await this.get_pair(t,!0);s||Ba(Ca.Fail,"account invalid");const i=new gs,n=await cc.Instance().get_coin_object(i,e,t,r);if(n){i.transferObjects([n],s?.toSuiAddress());const e=await zo.Client().signAndExecuteTransaction({transaction:i,signer:s,options:{showObjectChanges:!0}}),t=r??"0x2::sui::SUI";return e?.objectChanges.find((e=>"created"===e?.type&&(e?.objectType).includes(t)))?.objectId}}}function uc(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const hc=8192;function lc(e){if(e.length<hc)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=hc){const s=e.slice(r,r+hc);t+=String.fromCharCode(...s)}return btoa(t)}const pc=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;n<e.length;){const s=e.charCodeAt(n);if(s>255)return;let i=t[s];if(255===i)return;let a=0;for(let e=d-1;(0!==i||a<o)&&-1!==e;e--,a++)i+=r*c[e]>>>0,c[e]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");o=a,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let l=a;for(;u!==d;)h[l++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let l=s.repeat(i);for(;h<c;++h)l+=e.charAt(u[h]);return l},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),mc=e=>pc.encode(e),bc=e=>pc.decode(e);function _c(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function gc(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function fc(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class yc{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class vc{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Tc(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Tc(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Tc(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return fc(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return mc(e);case"base64":return lc(e);case"hex":return gc(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Tc(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Ec,wc,xc,Oc,Ic=e=>{throw TypeError(e)},Cc=(e,t,r)=>t.has(e)||Ic("Cannot "+r),Bc=(e,t,r)=>(Cc(e,t,"read from private field"),r?r.call(e):t.get(e)),Sc=(e,t,r)=>t.has(e)?Ic("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Pc=(e,t,r,s)=>(Cc(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);Ec=new WeakMap,wc=new WeakMap;let jc=class e{constructor(e){Sc(this,Ec),Sc(this,wc),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Pc(this,Ec,e.write),Pc(this,wc,e.serialize??((e,t)=>{const r=new vc({initialSize:this.serializedSize(e)??void 0,...t});return Bc(this,Ec).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Bc(this,Ec).call(this,e,t)}serialize(e,t){return this.validate(e),new Uc(this,Bc(this,wc).call(this,e,t))}parse(e){const t=new yc(e);return this.read(t)}fromHex(e){return this.parse(_c(e))}fromBase58(e){return this.parse(bc(e))}fromBase64(e){return this.parse(uc(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>Bc(this,Ec).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>Bc(this,wc).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const Ac=Symbol.for("@mysten/serialized-bcs");function kc(e){return!!e&&"object"==typeof e&&!0===e[Ac]}class Uc{constructor(e,t){Sc(this,xc),Sc(this,Oc),Pc(this,xc,e),Pc(this,Oc,t)}get[Ac](){return!0}toBytes(){return Bc(this,Oc)}toHex(){return gc(Bc(this,Oc))}toBase64(){return lc(Bc(this,Oc))}toBase58(){return mc(Bc(this,Oc))}parse(){return Bc(this,xc).parse(Bc(this,Oc))}}function Nc({size:e,...t}){return new jc({...t,serializedSize:()=>e})}function Dc({readMethod:e,writeMethod:t,...r}){return Nc({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function Yc({readMethod:e,writeMethod:t,...r}){return Nc({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function Rc(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function Vc(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??Rc(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function Mc(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}xc=new WeakMap,Oc=new WeakMap;var Jc=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Fc(e,t){return{kind:"validation",type:"check",reference:Fc,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&Vc(this,"input",e,t),e}}}function Xc(e){return{kind:"validation",type:"integer",reference:Xc,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&Vc(this,"integer",e,t),e}}}function Lc(e){return{kind:"transformation",type:"transform",reference:Lc,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Gc(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function $c(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function zc(e,t){return{kind:"schema",type:"array",reference:zc,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Vc(this,"type",e,t);return e}}}function qc(e){return{kind:"schema",type:"bigint",reference:qc,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function Wc(e){return{kind:"schema",type:"boolean",reference:Wc,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function Hc(e){return{kind:"schema",type:"lazy",reference:Hc,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function Kc(e,t){return{kind:"schema",type:"literal",reference:Kc,expects:Rc(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:Vc(this,"type",e,t),e}}}function Qc(e,...t){const r={kind:"schema",type:"nullable",reference:Qc,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Gc(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function Zc(e,...t){const r={kind:"schema",type:"nullish",reference:Zc,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Gc(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function eu(e){return{kind:"schema",type:"number",reference:eu,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?Vc(this,"type",e,t):e.typed=!0,e}}}function tu(e,t){return{kind:"schema",type:"object",reference:tu,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else Vc(this,"type",e,t);return e}}}function ru(e,...t){const r={kind:"schema",type:"optional",reference:ru,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Gc(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function su(e,t,r){return{kind:"schema",type:"record",reference:su,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(Mc(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else Vc(this,"type",e,t);return e}}}function iu(e){return{kind:"schema",type:"string",reference:iu,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function nu(e,t){return{kind:"schema",type:"tuple",reference:nu,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Vc(this,"type",e,t);return e}}}function au(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ou(e,t){return{kind:"schema",type:"union",reference:ou,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];Vc(this,"type",e,t,{issues:au(s)}),e.typed=!0}else{if(1===i?.length)return i[0];Vc(this,"type",e,t,{issues:au(i)})}return e}}}function du(){return{kind:"schema",type:"unknown",reference:du,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function cu(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new Jc(s.issues);return s.value}function uu(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function hu(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&32===function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)}function lu(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(64,"0")}`}function pu(e,t=!1){return lu(e,t)}function mu(e){return uu(ou(Object.entries(e).map((([e,t])=>tu({[e]:t})))),Lc((e=>({...e,$kind:Object.keys(e)[0]}))))}const bu=uu(iu(),Lc((e=>lu(e))),Fc(hu)),_u=bu,gu=iu(),fu=uu(ou([iu(),uu(eu(),Xc())]),Fc((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),yu=tu({objectId:bu,version:fu,digest:iu()}),vu=uu(ou([tu({GasCoin:Kc(!0)}),tu({Input:uu(eu(),Xc()),type:ru(Kc("pure"))}),tu({Input:uu(eu(),Xc()),type:ru(Kc("object"))}),tu({Result:uu(eu(),Xc())}),tu({NestedResult:nu([uu(eu(),Xc()),uu(eu(),Xc())])})]),Lc((e=>({...e,$kind:Object.keys(e)[0]})))),Tu=tu({budget:Qc(fu),price:Qc(fu),owner:Qc(bu),payment:Qc(zc(yu))}),Eu=(tu({address:iu(),module:iu(),name:iu(),typeParams:zc(iu())}),ou([Kc("address"),Kc("bool"),Kc("u8"),Kc("u16"),Kc("u32"),Kc("u64"),Kc("u128"),Kc("u256"),tu({vector:Hc((()=>Eu))}),tu({datatype:tu({package:iu(),module:iu(),type:iu(),typeParameters:zc(Hc((()=>Eu)))})}),tu({typeParameter:uu(eu(),Xc())})])),wu=tu({ref:Qc(ou([Kc("&"),Kc("&mut")])),body:Eu}),xu=tu({package:_u,module:iu(),function:iu(),typeArguments:zc(iu()),arguments:zc(vu),_argumentTypes:ru(Qc(zc(wu)))}),Ou=tu({name:iu(),inputs:su(iu(),ou([vu,zc(vu)])),data:su(iu(),du())}),Iu=mu({MoveCall:xu,TransferObjects:tu({objects:zc(vu),address:vu}),SplitCoins:tu({coin:vu,amounts:zc(vu)}),MergeCoins:tu({destination:vu,sources:zc(vu)}),Publish:tu({modules:zc(gu),dependencies:zc(_u)}),MakeMoveVec:tu({type:Qc(iu()),elements:zc(vu)}),Upgrade:tu({modules:zc(gu),dependencies:zc(_u),package:_u,ticket:vu}),$Intent:Ou}),Cu=mu({ImmOrOwnedObject:yu,SharedObject:tu({objectId:_u,initialSharedVersion:fu,mutable:Wc()}),Receiving:yu}),Bu=mu({Object:Cu,Pure:tu({bytes:gu}),UnresolvedPure:tu({value:du()}),UnresolvedObject:tu({objectId:_u,version:ru(Qc(fu)),digest:ru(Qc(iu())),initialSharedVersion:ru(Qc(fu))})}),Su=mu({Object:Cu,Pure:tu({bytes:gu})}),Pu=mu({None:Kc(!0),Epoch:fu}),ju=tu({version:Kc(2),sender:Zc(bu),expiration:Zc(Pu),gasData:Tu,inputs:zc(Bu),commands:zc(Iu)}),Au={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>cu(vu,e))),address:cu(vu,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:cu(vu,e),amounts:t.map((e=>cu(vu,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:cu(vu,e),sources:t.map((e=>cu(vu,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:lc(new Uint8Array(e)))),dependencies:t.map((e=>pu(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:s})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:lc(new Uint8Array(e)))),dependencies:t.map((e=>pu(e))),package:r,ticket:cu(vu,s)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>cu(vu,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>cu(vu,e))):cu(vu,t)]))),data:r}})},ku=/^vector<(.+)>$/,Uu=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class Nu{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(ku);if(r)return{vector:Nu.parseFromStr(r[1],t)};const s=e.match(Uu);if(s)return{struct:{address:t?lu(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:Nu.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>Nu.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${Nu.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(Nu.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Du=tu({digest:iu(),objectId:iu(),version:ou([uu(eu(),Xc()),iu(),qc()])}),Yu=mu({ImmOrOwned:Du,Shared:tu({objectId:_u,initialSharedVersion:fu,mutable:Wc()}),Receiving:Du}),Ru=mu({Object:Yu,Pure:zc(uu(eu(),Xc()))}),Vu=ou([tu({kind:Kc("Input"),index:uu(eu(),Xc()),value:du(),type:ru(Kc("object"))}),tu({kind:Kc("Input"),index:uu(eu(),Xc()),value:du(),type:Kc("pure")})]),Mu=ou([tu({Epoch:uu(eu(),Xc())}),tu({None:Qc(Kc(!0))})]),Ju=uu(ou([eu(),iu(),qc()]),Fc((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Fu=ou([tu({bool:Qc(Kc(!0))}),tu({u8:Qc(Kc(!0))}),tu({u64:Qc(Kc(!0))}),tu({u128:Qc(Kc(!0))}),tu({address:Qc(Kc(!0))}),tu({signer:Qc(Kc(!0))}),tu({vector:Hc((()=>Fu))}),tu({struct:Hc((()=>Xu))}),tu({u16:Qc(Kc(!0))}),tu({u32:Qc(Kc(!0))}),tu({u256:Qc(Kc(!0))})]),Xu=tu({address:iu(),module:iu(),name:iu(),typeParams:zc(Fu)}),Lu=tu({budget:ru(Ju),price:ru(Ju),payment:ru(zc(Du)),owner:ru(iu())}),Gu=ou([Vu,tu({kind:Kc("GasCoin")}),tu({kind:Kc("Result"),index:uu(eu(),Xc())}),tu({kind:Kc("NestedResult"),index:uu(eu(),Xc()),resultIndex:uu(eu(),Xc())})]),$u=tu({kind:Kc("MoveCall"),target:uu(iu(),Fc((e=>3===e.split("::").length))),typeArguments:zc(iu()),arguments:zc(Gu)}),zu=tu({kind:Kc("TransferObjects"),objects:zc(Gu),address:Gu}),qu=tu({kind:Kc("SplitCoins"),coin:Gu,amounts:zc(Gu)}),Wu=tu({kind:Kc("MergeCoins"),destination:Gu,sources:zc(Gu)}),Hu=tu({kind:Kc("MakeMoveVec"),type:ou([tu({Some:Fu}),tu({None:Qc(Kc(!0))})]),objects:zc(Gu)}),Ku=ou([$u,zu,qu,Wu,tu({kind:Kc("Publish"),modules:zc(zc(uu(eu(),Xc()))),dependencies:zc(iu())}),tu({kind:Kc("Upgrade"),modules:zc(zc(uu(eu(),Xc()))),dependencies:zc(iu()),packageId:iu(),ticket:Gu}),Hu]);function Qu(e){const t=e.inputs.map(((e,t)=>{if(e.Object)return{kind:"Input",index:t,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:t,value:{Pure:Array.from(uc(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:t,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:t,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:t,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:Nu.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>Zu(e,t)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:Zu(e.MergeCoins.destination,t),sources:e.MergeCoins.sources.map((e=>Zu(e,t)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>Zu(e,t)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(uc(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:Zu(e.SplitCoins.coin,t),amounts:e.SplitCoins.amounts.map((e=>Zu(e,t)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>Zu(e,t))),address:Zu(e.TransferObjects.address,t)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(uc(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:Zu(e.Upgrade.ticket,t)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function Zu(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function eh(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function th(e){return ou(Object.entries(e).map((([e,t])=>tu({[e]:t}))))}tu({version:Kc(1),sender:ru(iu()),expiration:Zc(Mu),gasConfig:Lu,inputs:zc(Vu),transactions:zc(Ku)});const rh=th({GasCoin:Kc(!0),Input:uu(eu(),Xc()),Result:uu(eu(),Xc()),NestedResult:nu([uu(eu(),Xc()),uu(eu(),Xc())])}),sh=tu({budget:Qc(fu),price:Qc(fu),owner:Qc(bu),payment:Qc(zc(yu))}),ih=tu({package:_u,module:iu(),function:iu(),typeArguments:zc(iu()),arguments:zc(rh)}),nh=tu({name:iu(),inputs:su(iu(),ou([rh,zc(rh)])),data:su(iu(),du())}),ah=th({MoveCall:ih,TransferObjects:tu({objects:zc(rh),address:rh}),SplitCoins:tu({coin:rh,amounts:zc(rh)}),MergeCoins:tu({destination:rh,sources:zc(rh)}),Publish:tu({modules:zc(gu),dependencies:zc(_u)}),MakeMoveVec:tu({type:Qc(iu()),elements:zc(rh)}),Upgrade:tu({modules:zc(gu),dependencies:zc(_u),package:_u,ticket:rh}),$Intent:nh}),oh=th({ImmOrOwnedObject:yu,SharedObject:tu({objectId:_u,initialSharedVersion:fu,mutable:Wc()}),Receiving:yu}),dh=th({Object:oh,Pure:tu({bytes:gu}),UnresolvedPure:tu({value:du()}),UnresolvedObject:tu({objectId:_u,version:ru(Qc(fu)),digest:ru(Qc(iu())),initialSharedVersion:ru(Qc(fu))})}),ch=th({None:Kc(!0),Epoch:fu}),uh=tu({version:Kc(2),sender:Zc(bu),expiration:Zc(ch),gasData:sh,inputs:zc(dh),commands:zc(ah)}),hh=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?lc(e):e.toBase64()}}},lh=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:lu(e)}}}),ph=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:lu(e)}}}),mh=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:lu(e)}}}),bh={u8:e=>Dc({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>Dc({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>Dc({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>Yc({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>Yc({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>Yc({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>Nc({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new jc({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(fc(e)),...e}),bytes:(e,t)=>Nc({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new jc({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=fc(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new jc({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>bh.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new jc({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new jc({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new jc({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new jc({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>bh.vector(bh.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new jc({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},_h=bh.bytes(32).transform({validate:e=>{const t="string"==typeof e?e:gc(e);if(!t||!hu(lu(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?_c(lu(e)):e,output:e=>lu(gc(e))}),gh=bh.vector(bh.u8()).transform({name:"ObjectDigest",input:e=>bc(e),output:e=>mc(new Uint8Array(e)),validate:e=>{if(32!==bc(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),fh=bh.struct("SuiObjectRef",{objectId:_h,version:bh.u64(),digest:gh}),yh=bh.struct("SharedObjectRef",{objectId:_h,initialSharedVersion:bh.u64(),mutable:bh.bool()}),vh=bh.enum("ObjectArg",{ImmOrOwnedObject:fh,SharedObject:yh,Receiving:fh}),Th=bh.enum("CallArg",{Pure:bh.struct("Pure",{bytes:bh.vector(bh.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>lc(new Uint8Array(e))})}),Object:vh}),Eh=bh.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:bh.lazy((()=>Eh)),struct:bh.lazy((()=>Ph)),u16:null,u32:null,u256:null}),wh=Eh.transform({input:e=>"string"==typeof e?Nu.parseFromStr(e,!0):e,output:e=>Nu.tagToString(e)}),xh=bh.enum("Argument",{GasCoin:null,Input:bh.u16(),Result:bh.u16(),NestedResult:bh.tuple([bh.u16(),bh.u16()])}),Oh=bh.struct("ProgrammableMoveCall",{package:_h,module:bh.string(),function:bh.string(),typeArguments:bh.vector(wh),arguments:bh.vector(xh)}),Ih=bh.enum("Command",{MoveCall:Oh,TransferObjects:bh.struct("TransferObjects",{objects:bh.vector(xh),address:xh}),SplitCoins:bh.struct("SplitCoins",{coin:xh,amounts:bh.vector(xh)}),MergeCoins:bh.struct("MergeCoins",{destination:xh,sources:bh.vector(xh)}),Publish:bh.struct("Publish",{modules:bh.vector(bh.vector(bh.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>lc(new Uint8Array(e))})),dependencies:bh.vector(_h)}),MakeMoveVec:bh.struct("MakeMoveVec",{type:function(e){return bh.enum("Option",{None:null,Some:e})}(wh).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:bh.vector(xh)}),Upgrade:bh.struct("Upgrade",{modules:bh.vector(bh.vector(bh.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>lc(new Uint8Array(e))})),dependencies:bh.vector(_h),package:_h,ticket:xh})}),Ch=bh.struct("ProgrammableTransaction",{inputs:bh.vector(Th),commands:bh.vector(Ih)}),Bh=bh.enum("TransactionKind",{ProgrammableTransaction:Ch,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Sh=bh.enum("TransactionExpiration",{None:null,Epoch:bh.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})}),Ph=bh.struct("StructTag",{address:_h,module:bh.string(),name:bh.string(),typeParams:bh.vector(Eh)}),jh=bh.struct("GasData",{payment:bh.vector(fh),owner:_h,price:bh.u64(),budget:bh.u64()}),Ah=bh.struct("TransactionDataV1",{kind:Bh,sender:_h,gasData:jh,expiration:Sh}),kh=bh.enum("TransactionData",{V1:Ah}),Uh=bh.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Nh=bh.enum("IntentVersion",{V0:null}),Dh=bh.enum("AppId",{Sui:null}),Yh=bh.struct("Intent",{scope:Uh,version:Nh,appId:Dh});function Rh(e){return bh.struct(`IntentMessage<${e.name}>`,{intent:Yh,value:e})}const Vh=bh.enum("CompressedSignature",{ED25519:bh.fixedArray(64,bh.u8()),Secp256k1:bh.fixedArray(64,bh.u8()),Secp256r1:bh.fixedArray(64,bh.u8()),ZkLogin:bh.vector(bh.u8())}),Mh=bh.enum("PublicKey",{ED25519:bh.fixedArray(32,bh.u8()),Secp256k1:bh.fixedArray(33,bh.u8()),Secp256r1:bh.fixedArray(33,bh.u8()),ZkLogin:bh.vector(bh.u8())}),Jh=bh.struct("MultiSigPkMap",{pubKey:Mh,weight:bh.u8()}),Fh=bh.struct("MultiSigPublicKey",{pk_map:bh.vector(Jh),threshold:bh.u16()}),Xh=bh.struct("MultiSig",{sigs:bh.vector(Vh),bitmap:bh.u16(),multisig_pk:Fh}),Lh=bh.vector(bh.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>lc(new Uint8Array(e))}),Gh=bh.struct("SenderSignedTransaction",{intentMessage:Rh(kh),txSignatures:bh.vector(Lh)}),$h=bh.vector(Gh,{name:"SenderSignedData"}),zh=bh.enum("PackageUpgradeError",{UnableToFetchPackage:bh.struct("UnableToFetchPackage",{packageId:_h}),NotAPackage:bh.struct("NotAPackage",{objectId:_h}),IncompatibleUpgrade:null,DigestDoesNotMatch:bh.struct("DigestDoesNotMatch",{digest:bh.vector(bh.u8())}),UnknownUpgradePolicy:bh.struct("UnknownUpgradePolicy",{policy:bh.u8()}),PackageIDDoesNotMatch:bh.struct("PackageIDDoesNotMatch",{packageId:_h,ticketId:_h})}),qh=bh.struct("ModuleId",{address:_h,name:bh.string()}),Wh=bh.struct("MoveLocation",{module:qh,function:bh.u16(),instruction:bh.u16(),functionName:bh.option(bh.string())}),Hh=bh.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:bh.struct("IndexOutOfBounds",{idx:bh.u16()}),SecondaryIndexOutOfBounds:bh.struct("SecondaryIndexOutOfBounds",{resultIdx:bh.u16(),secondaryIdx:bh.u16()}),InvalidResultArity:bh.struct("InvalidResultArity",{resultIdx:bh.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),Kh=bh.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Qh=bh.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:bh.struct("MoveObjectTooBig",{objectSize:bh.u64(),maxObjectSize:bh.u64()}),MovePackageTooBig:bh.struct("MovePackageTooBig",{objectSize:bh.u64(),maxObjectSize:bh.u64()}),CircularObjectOwnership:bh.struct("CircularObjectOwnership",{object:_h}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:bh.option(Wh),MoveAbort:bh.tuple([Wh,bh.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:bh.struct("CommandArgumentError",{argIdx:bh.u16(),kind:Hh}),TypeArgumentError:bh.struct("TypeArgumentError",{argumentIdx:bh.u16(),kind:Kh}),UnusedValueWithoutDrop:bh.struct("UnusedValueWithoutDrop",{resultIdx:bh.u16(),secondaryIdx:bh.u16()}),InvalidPublicFunctionReturnType:bh.struct("InvalidPublicFunctionReturnType",{idx:bh.u16()}),InvalidTransferObject:null,EffectsTooLarge:bh.struct("EffectsTooLarge",{currentSize:bh.u64(),maxSize:bh.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:bh.struct("PackageUpgradeError",{upgradeError:zh}),WrittenObjectsTooLarge:bh.struct("WrittenObjectsTooLarge",{currentSize:bh.u64(),maxSize:bh.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Zh=bh.enum("ExecutionStatus",{Success:null,Failed:bh.struct("ExecutionFailed",{error:Qh,command:bh.option(bh.u64())})}),el=bh.struct("GasCostSummary",{computationCost:bh.u64(),storageCost:bh.u64(),storageRebate:bh.u64(),nonRefundableStorageFee:bh.u64()}),tl=bh.enum("Owner",{AddressOwner:_h,ObjectOwner:_h,Shared:bh.struct("Shared",{initialSharedVersion:bh.u64()}),Immutable:null}),rl=bh.struct("TransactionEffectsV1",{status:Zh,executedEpoch:bh.u64(),gasUsed:el,modifiedAtVersions:bh.vector(bh.tuple([_h,bh.u64()])),sharedObjects:bh.vector(fh),transactionDigest:gh,created:bh.vector(bh.tuple([fh,tl])),mutated:bh.vector(bh.tuple([fh,tl])),unwrapped:bh.vector(bh.tuple([fh,tl])),deleted:bh.vector(fh),unwrappedThenDeleted:bh.vector(fh),wrapped:bh.vector(fh),gasObject:bh.tuple([fh,tl]),eventsDigest:bh.option(gh),dependencies:bh.vector(gh)}),sl=bh.tuple([bh.u64(),gh]),il=bh.enum("ObjectIn",{NotExist:null,Exist:bh.tuple([sl,tl])}),nl=bh.enum("ObjectOut",{NotExist:null,ObjectWrite:bh.tuple([gh,tl]),PackageWrite:sl}),al=bh.enum("IDOperation",{None:null,Created:null,Deleted:null}),ol=bh.struct("EffectsObjectChange",{inputState:il,outputState:nl,idOperation:al}),dl=bh.enum("UnchangedSharedKind",{ReadOnlyRoot:sl,MutateDeleted:bh.u64(),ReadDeleted:bh.u64(),Cancelled:bh.u64(),PerEpochConfig:null}),cl=bh.struct("TransactionEffectsV2",{status:Zh,executedEpoch:bh.u64(),gasUsed:el,transactionDigest:gh,gasObjectIndex:bh.option(bh.u32()),eventsDigest:bh.option(gh),dependencies:bh.vector(gh),lamportVersion:bh.u64(),changedObjects:bh.vector(bh.tuple([_h,ol])),unchangedSharedObjects:bh.vector(bh.tuple([_h,dl])),auxDataDigest:bh.option(gh)}),ul=bh.enum("TransactionEffects",{V1:rl,V2:cl}),hl={...bh,U8:bh.u8(),U16:bh.u16(),U32:bh.u32(),U64:bh.u64(),U128:bh.u128(),U256:bh.u256(),ULEB128:bh.uleb128(),Bool:bh.bool(),String:bh.string(),Address:_h,AppId:Dh,Argument:xh,CallArg:Th,CompressedSignature:Vh,GasData:jh,Intent:Yh,IntentMessage:Rh,IntentScope:Uh,IntentVersion:Nh,MultiSig:Xh,MultiSigPkMap:Jh,MultiSigPublicKey:Fh,ObjectArg:vh,ObjectDigest:gh,ProgrammableMoveCall:Oh,ProgrammableTransaction:Ch,PublicKey:Mh,SenderSignedData:$h,SenderSignedTransaction:Gh,SharedObjectRef:yh,StructTag:Ph,SuiObjectRef:fh,Command:Ih,TransactionData:kh,TransactionDataV1:Ah,TransactionExpiration:Sh,TransactionKind:Bh,TypeTag:wh,TransactionEffects:ul},ll=(BigInt(1e9),pu("0x6"),"0x2::sui::SUI");function pl(e){if("string"==typeof e)switch(e){case"address":return hl.Address;case"bool":return hl.Bool;case"u8":return hl.U8;case"u16":return hl.U16;case"u32":return hl.U32;case"u64":return hl.U64;case"u128":return hl.U128;case"u256":return hl.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return hl.vector(hl.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=pl(e.vector);return t?hl.vector(t):null}if("datatype"in e){const t=lu(e.datatype.package);if(t===lu("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return hl.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return hl.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=pl(e.datatype.typeParameters[0]);return t?hl.vector(t):null}}if(t===lu("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return hl.Address}return null}function ml(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:ml(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(ml)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}pu("0x5");async function bl(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{_l(t,hl.U64,e)}));break;case"TransferObjects":_l(t.TransferObjects.address,hl.Address,e)}}));const a=new Map;if(n.size>0){const e=yl(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:ml(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:ml(e.MutableReference)}:{ref:null,body:ml(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&lu(t.package)===lu("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=pl(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=hh(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>pu(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>yl(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=lu(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=ph({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:gl(e,t)}):fl(e,t)&&(s=mh({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??lh({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await yl(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await yl(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await yl(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:ll})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>cu(yu,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function _l(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=hh(t.serialize(s.UnresolvedPure.value)))}function gl(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function fl(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function yl(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function vl(e){function t(t,r){if("string"==typeof t)return e(Tl(t).serialize(r));if(t instanceof Uint8Array||kc(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(hl.U8.serialize(t)),t.u16=t=>e(hl.U16.serialize(t)),t.u32=t=>e(hl.U32.serialize(t)),t.u64=t=>e(hl.U64.serialize(t)),t.u128=t=>e(hl.U128.serialize(t)),t.u256=t=>e(hl.U256.serialize(t)),t.bool=t=>e(hl.Bool.serialize(t)),t.string=t=>e(hl.String.serialize(t)),t.address=t=>e(hl.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(hl.vector(Tl(t)).serialize(r)),t.option=(t,r)=>e(hl.option(Tl(t)).serialize(r)),t}function Tl(e){switch(e){case"u8":return hl.u8();case"u16":return hl.u16();case"u32":return hl.u32();case"u64":return hl.u64();case"u128":return hl.u128();case"u256":return hl.u256();case"bool":return hl.bool();case"string":return hl.string();case"id":case"address":return hl.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?hl.vector(Tl(r)):hl.option(Tl(r))}throw new Error(`Invalid Pure type name: ${e}`)}function El(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wl(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xl(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ol(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}const Il=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Cl(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Bl=Il?e=>e:e=>Cl(e);function Sl(e){for(let t=0;t<e.length;t++)e[t]=Cl(e[t])}function Pl(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),wl(e),e}class jl{clone(){return this._cloneInto()}}function Al(e){const t=(t,r)=>e(r).update(Pl(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const kl=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Ul extends jl{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,El(e),El(t),El(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=Ol(this.buffer)}update(e){xl(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=Pl(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Il||Sl(s),this.compress(s,0,!1),Il||Sl(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Il||Sl(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Il||Sl(e)}}return this}digestInto(e){xl(this),function(e,t){wl(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Il||Sl(r),this.compress(r,0,!0),Il||Sl(r);const s=Ol(e);this.get().forEach(((e,t)=>s[t]=Bl(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Nl=BigInt(2**32-1),Dl=BigInt(32);function Yl(e,t=!1){return t?{h:Number(e&Nl),l:Number(e>>Dl&Nl)}:{h:0|Number(e>>Dl&Nl),l:0|Number(e&Nl)}}const Rl={fromBig:Yl,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Yl(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Dl|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Vl=Rl,Ml=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Jl=new Uint32Array(32);function Fl(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Jl[2*e],c=Jl[2*e+1],u=Jl[2*t],h=Jl[2*t+1],l=Jl[2*r],p=Jl[2*r+1],m=Jl[2*s],b=Jl[2*s+1],_=Vl.add3L(d,u,a);c=Vl.add3H(_,c,h,o),d=0|_,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Vl.rotr32H(b,m),Dl:Vl.rotr32L(b,m)}),({h:p,l}=Vl.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Vl.rotrSH(h,u,24),Bl:Vl.rotrSL(h,u,24)}),Jl[2*e]=d,Jl[2*e+1]=c,Jl[2*t]=u,Jl[2*t+1]=h,Jl[2*r]=l,Jl[2*r+1]=p,Jl[2*s]=m,Jl[2*s+1]=b}function Xl(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Jl[2*e],c=Jl[2*e+1],u=Jl[2*t],h=Jl[2*t+1],l=Jl[2*r],p=Jl[2*r+1],m=Jl[2*s],b=Jl[2*s+1],_=Vl.add3L(d,u,a);c=Vl.add3H(_,c,h,o),d=0|_,({Dh:b,Dl:m}={Dh:b^c,Dl:m^d}),({Dh:b,Dl:m}={Dh:Vl.rotrSH(b,m,16),Dl:Vl.rotrSL(b,m,16)}),({h:p,l}=Vl.add(p,l,b,m)),({Bh:h,Bl:u}={Bh:h^p,Bl:u^l}),({Bh:h,Bl:u}={Bh:Vl.rotrBH(h,u,63),Bl:Vl.rotrBL(h,u,63)}),Jl[2*e]=d,Jl[2*e+1]=c,Jl[2*t]=u,Jl[2*t+1]=h,Jl[2*r]=l,Jl[2*r+1]=p,Jl[2*s]=m,Jl[2*s+1]=b}class Ll extends Ul{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Ml[0],this.v0h=0|Ml[1],this.v1l=0|Ml[2],this.v1h=0|Ml[3],this.v2l=0|Ml[4],this.v2h=0|Ml[5],this.v3l=0|Ml[6],this.v3h=0|Ml[7],this.v4l=0|Ml[8],this.v4h=0|Ml[9],this.v5l=0|Ml[10],this.v5h=0|Ml[11],this.v6l=0|Ml[12],this.v6h=0|Ml[13],this.v7l=0|Ml[14],this.v7h=0|Ml[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=Ol(Pl(e.salt));this.v4l^=Bl(t[0]),this.v4h^=Bl(t[1]),this.v5l^=Bl(t[2]),this.v5h^=Bl(t[3])}if(e.personalization){const t=Ol(Pl(e.personalization));this.v6l^=Bl(t[0]),this.v6h^=Bl(t[1]),this.v7l^=Bl(t[2]),this.v7h^=Bl(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(Pl(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:l,v6h:p,v7l:m,v7h:b}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b]}set(e,t,r,s,i,n,a,o,d,c,u,h,l,p,m,b){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|l,this.v6h=0|p,this.v7l=0|m,this.v7h=0|b}compress(e,t,r){this.get().forEach(((e,t)=>Jl[t]=e)),Jl.set(Ml,16);let{h:s,l:i}=Vl.fromBig(BigInt(this.length));Jl[24]=Ml[8]^i,Jl[25]=Ml[9]^s,r&&(Jl[28]=~Jl[28],Jl[29]=~Jl[29]);let n=0;const a=kl;for(let r=0;r<12;r++)Fl(0,4,8,12,e,t+2*a[n++]),Xl(0,4,8,12,e,t+2*a[n++]),Fl(1,5,9,13,e,t+2*a[n++]),Xl(1,5,9,13,e,t+2*a[n++]),Fl(2,6,10,14,e,t+2*a[n++]),Xl(2,6,10,14,e,t+2*a[n++]),Fl(3,7,11,15,e,t+2*a[n++]),Xl(3,7,11,15,e,t+2*a[n++]),Fl(0,5,10,15,e,t+2*a[n++]),Xl(0,5,10,15,e,t+2*a[n++]),Fl(1,6,11,12,e,t+2*a[n++]),Xl(1,6,11,12,e,t+2*a[n++]),Fl(2,7,8,13,e,t+2*a[n++]),Xl(2,7,8,13,e,t+2*a[n++]),Fl(3,4,9,14,e,t+2*a[n++]),Xl(3,4,9,14,e,t+2*a[n++]);this.v0l^=Jl[0]^Jl[16],this.v0h^=Jl[1]^Jl[17],this.v1l^=Jl[2]^Jl[18],this.v1h^=Jl[3]^Jl[19],this.v2l^=Jl[4]^Jl[20],this.v2h^=Jl[5]^Jl[21],this.v3l^=Jl[6]^Jl[22],this.v3h^=Jl[7]^Jl[23],this.v4l^=Jl[8]^Jl[24],this.v4h^=Jl[9]^Jl[25],this.v5l^=Jl[10]^Jl[26],this.v5h^=Jl[11]^Jl[27],this.v6l^=Jl[12]^Jl[28],this.v6h^=Jl[13]^Jl[29],this.v7l^=Jl[14]^Jl[30],this.v7h^=Jl[15]^Jl[31],Jl.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Gl=Al((e=>new Ll(e)));function $l(e){return lu(e).replace("0x","")}class zl{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=hl.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return zl.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=hl.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return zl.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new zl(cu(ju,e)):new zl(cu(ju,function(e){return cu(ju,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if($c(Ru,e.value)){const t=cu(Ru,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:lc(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?Nu.tagToString(e.type.Some):null,elements:e.objects.map((e=>eh(e)))}};case"MergeCoins":return{MergeCoins:{destination:eh(e.destination),sources:e.sources.map((e=>eh(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>eh(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>lc(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:eh(e.coin),amounts:e.amounts.map((e=>eh(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>eh(e))),address:eh(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>lc(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:eh(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),Gl(s,{dkLen:32})}(0,e);return mc(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return hl.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:$l(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:$l(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return hl.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return zl.getDigestFromBytes(e)}snapshot(){return cu(ju,this)}}function ql(e){return"string"==typeof e?lu(e):e.Object?e.Object.ImmOrOwnedObject?lu(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?lu(e.Object.Receiving.objectId):lu(e.Object.SharedObject.objectId):e.UnresolvedObject?lu(e.UnresolvedObject.objectId):void 0}var Wl,Hl,Kl,Ql,Zl,ep,tp,rp,sp,ip=e=>{throw TypeError(e)},np=(e,t,r)=>t.has(e)||ip("Cannot "+r),ap=(e,t,r)=>(np(e,t,"read from private field"),r?r.call(e):t.get(e)),op=(e,t,r)=>t.has(e)?ip("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),dp=(e,t,r,s)=>(np(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),cp=(e,t,r)=>(np(e,t,"access private method"),r);const up=Symbol.for("@mysten/transaction"),hp={buildPlugins:[],serializationPlugins:[]},lp=Symbol.for("@mysten/transaction/registry");function pp(){try{const e=globalThis;return e[lp]||(e[lp]=hp),e[lp]}catch(e){return hp}}Wl=new WeakMap,Hl=new WeakMap,Kl=new WeakMap,Ql=new WeakMap,Zl=new WeakSet,ep=function(e){return kc(e)?this.pure(e):cp(this,Zl,tp).call(this,e)},tp=function(e){return cu(vu,"function"==typeof e?e(this):e)},rp=async function(e){if(!e.onlyTransactionKind&&!ap(this,Ql).sender)throw new Error("Missing transaction sender");await cp(this,Zl,sp).call(this,[...ap(this,Hl),bl],e)},sp=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(ap(this,Ql),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let mp=class e{constructor(){op(this,Zl),op(this,Wl),op(this,Hl),op(this,Kl,new Map),op(this,Ql),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&$c(vu,e))return e;const t=ql(e),r=ap(this,Ql).inputs.find((e=>t===ql(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:ap(this,Ql).inputs.indexOf(r),type:"object"}:ap(this,Ql).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:lu(e)}}:e)}));const e=pp();dp(this,Ql,new zl),dp(this,Hl,[...e.buildPlugins]),dp(this,Wl,[...e.serializationPlugins])}static fromKind(t){const r=new e;return dp(r,Ql,zl.fromKindBytes("string"==typeof t?uc(t):t)),r}static from(t){const r=new e;var s;return(s=t)&&"object"==typeof s&&!0===s[up]?dp(r,Ql,new zl(t.getData())):"string"==typeof t&&t.startsWith("{")?dp(r,Ql,zl.restore(JSON.parse(t))):dp(r,Ql,zl.fromBytes("string"==typeof t?uc(t):t)),r}static registerGlobalSerializationPlugin(e){pp().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){pp().buildPlugins.push(e)}addSerializationPlugin(e){ap(this,Wl).push(e)}addBuildPlugin(e){ap(this,Hl).push(e)}addIntentResolver(e,t){if(ap(this,Kl).has(e)&&ap(this,Kl).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);ap(this,Kl).set(e,t)}setSender(e){ap(this,Ql).sender=e}setSenderIfNotSet(e){ap(this,Ql).sender||(ap(this,Ql).sender=e)}setExpiration(e){ap(this,Ql).expiration=e?cu(Pu,e):null}setGasPrice(e){ap(this,Ql).gasConfig.price=String(e)}setGasBudget(e){ap(this,Ql).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==ap(this,Ql).gasData.budget&&(ap(this,Ql).gasConfig.budget=String(e))}setGasOwner(e){ap(this,Ql).gasConfig.owner=e}setGasPayment(e){ap(this,Ql).gasConfig.payment=e.map((e=>cu(yu,e)))}get blockData(){return Qu(ap(this,Ql).snapshot())}getData(){return ap(this,Ql).snapshot()}get[up](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:vl((e=>kc(e)?ap(this,Ql).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):ap(this,Ql).addInput("pure",$c(Su,e)?cu(Su,e):e instanceof Uint8Array?hh(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(lh(...e))}receivingRef(...e){return this.object(mh(...e))}sharedObjectRef(...e){return this.object(ph(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(ap(this,Ql).commands.push(e)-1)}splitCoins(e,t){return this.add(Au.SplitCoins("string"==typeof e?this.object(e):cp(this,Zl,tp).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):cp(this,Zl,ep).call(this,e)))))}mergeCoins(e,t){return this.add(Au.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Au.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Au.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Au.MoveCall({...t,arguments:e?.map((e=>cp(this,Zl,ep).call(this,e)))}))}transferObjects(e,t){return this.add(Au.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):cp(this,Zl,ep).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Au.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(Qu(ap(this,Ql).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(cu(uh,ap(this,Ql).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await cp(this,Zl,rp).call(this,e),ap(this,Ql).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await cp(this,Zl,rp).call(this,e),ap(this,Ql).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of ap(this,Ql).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...ap(this,Wl)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!ap(this,Kl).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(ap(this,Kl).get(s))}await cp(this,Zl,sp).call(this,r,e)}};function bp(e){const t=[];return e?.objectChanges?.forEach((e=>{const r=e?.objectType,s=rc(r);s&&t.push({type:s,type_raw:r,object:e?.objectId,version:e?.version,owner:e?.owner,change:e.type})})),t}class _p{resouceObject;async operate(e,t,r){}constructor(){}async call(e){}async call_with_witness(e,t){if(e.guard.length>0){const r=await bd.Create([...e.guard]);if(r){const s=await r.done(e.witness);if(s){const e=new mp,r=new _d(e,s);return await this.operate(new mp,r?.get_object(),t),r.destroy(),await this.sign_and_commit(e,t)}}else Ba(Ca.Fail,"guard verify")}}async check_permission_and_call(e,t,r,s,i,n){var a=[];if(t.length>0||s){const r=await cc.Instance().get_address(n);r||Ba(Ca.InvalidParam,"check_permission_and_call: account invalid");const o=await nc({permission_object:e,address:r});s&&!o.owner&&Ba(Ca.noPermission,"owner"),i&&!o.admin&&Ba(Ca.noPermission,"admin"),t.forEach((e=>{const t=Qo.HasPermission(o,e);t?.has||Ba(Ca.noPermission,e),t?.guard&&a.push(t.guard)}))}if(r.length>0&&(a=a.concat(r)),a.length>0){const e=await bd.Create([...a]),t=e?e.future_fills():[];if(e||Ba(Ca.Fail,"guard parse"),e&&0===t.length){const t=await e.done();if(t){const e=new mp,r=new _d(e,t);return await this.operate(new mp,r?.get_object(),n),r.destroy(),await this.sign_and_commit(e,n)}}return{guard:[...a],witness:e.future_fills()}}return await this.exec()}async exec(e){const t=new mp;return await this.operate(t,void 0,e),await this.sign_and_commit(t,e)}async new_with_mark(e,t,r,s,i=[hd.Launch]){const n=$a(r?.tags?[...r.tags,...i]:[...i]);if(this.resouceObject)vd.From(e,this.resouceObject).add(t,n,r?.name);else{const i=await cc.Instance().get_address(s);if(i){const s=await Jd({address:i});s?.mark_object?vd.From(e,s.mark_object).add(t,n,r?.name):(this.resouceObject=fd.From(e).create_resource2(),vd.From(e,this.resouceObject).add(t,n,r?.name))}else Ba(Ca.InvalidParam,"account - "+s)}}async sign_and_commit(e,t){const r=await cc.Instance().get_pair(t,!0);return r||Ba(Ca.Fail,"account invalid"),this.resouceObject&&(vd.From(e,this.resouceObject).launch(),this.resouceObject=void 0),await zo.Client().signAndExecuteTransaction({transaction:e,signer:r,options:{showObjectChanges:!0}})}}class gp extends _p{data;constructor(e){super(),this.data=e}async call(e){var t=!1,r=!1;const s=this.data?.object?.address;return s&&co(s)?(void 0===this.data?.builder&&void 0===this.data?.admin||(t=!0),void 0===this.data?.permission&&void 0===this.data?.biz_permission||(r=!0),void 0!==this.data?.description&&(r=!0),await this.check_permission_and_call(s,[],[],t,r,e)):await this.exec(e)}async operate(e,t,r){let s;const i=this.data?.object?.address;if(s=i&&co(i)?Qo.From(e,i):Qo.New(e,this.data?.description??""),s){if(void 0!==this.data?.description&&this.data.object&&s?.set_description(this.data.description),void 0!==this.data?.admin)switch(this.data.admin.op){case"add":s?.add_admin(this.data.admin.address);break;case"remove":s?.remove_admin(this.data.admin.address);break;case"set":s?.remove_admin([],!0),s?.add_admin(this.data.admin.address)}if(void 0!==this.data?.biz_permission)switch(this.data.biz_permission.op){case"add":this.data.biz_permission.data.forEach((e=>{s?.add_bizPermission(e.index,e.name)}));break;case"remove":this.data.biz_permission.permissions.forEach((e=>{s?.remove_bizPermission(e)}))}if(void 0!==this.data?.permission)switch(this.data.permission.op){case"add entity":s?.add_entity(this.data.permission.entities);break;case"add permission":s?.add_entity3(this.data.permission.permissions);break;case"remove entity":s?.remove_entity(this.data.permission.addresses);break;case"remove permission":s?.remove_index(this.data.permission.address,this.data.permission.index);break;case"transfer permission":s?.transfer_permission(this.data.permission.from_address,this.data.permission.to_address)}void 0!==this.data?.builder&&s?.change_owner(this.data.builder),i||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}var fp=a(763);const yp=e=>fp.encode(e),vp=e=>fp.decode(e);function Tp(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const Ep=8192;function wp(e){if(e.length<Ep)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=Ep){const s=e.slice(r,r+Ep);t+=String.fromCharCode(...s)}return btoa(t)}function xp(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function Op(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}class Ip{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class Cp{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Bp(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Bp(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Bp(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return yp(e);case"base64":return wp(e);case"hex":return Op(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Bp(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Sp,Pp,jp,Ap,kp=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Up=(e,t,r)=>(kp(e,t,"read from private field"),r?r.call(e):t.get(e)),Np=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Dp=(e,t,r,s)=>(kp(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const Yp=class{constructor(e){Np(this,Sp,void 0),Np(this,Pp,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Dp(this,Sp,e.write),Dp(this,Pp,e.serialize??((e,t)=>{const r=new Cp({size:this.serializedSize(e)??void 0,...t});return Up(this,Sp).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Up(this,Sp).call(this,e,t)}serialize(e,t){return this.validate(e),new Mp(this,Up(this,Pp).call(this,e,t))}parse(e){const t=new Ip(e);return this.read(t)}transform({name:e,input:t,output:r}){return new Yp({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>Up(this,Sp).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>Up(this,Pp).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let Rp=Yp;Sp=new WeakMap,Pp=new WeakMap;const Vp=Symbol.for("@mysten/serialized-bcs");class Mp{constructor(e,t){Np(this,jp,void 0),Np(this,Ap,void 0),Dp(this,jp,e),Dp(this,Ap,t)}get[Vp](){return!0}toBytes(){return Up(this,Ap)}toHex(){return Op(Up(this,Ap))}toBase64(){return wp(Up(this,Ap))}toBase58(){return yp(Up(this,Ap))}parse(){return Up(this,jp).parse(Up(this,Ap))}}jp=new WeakMap,Ap=new WeakMap;const Jp=32,Fp=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof Fp)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(Fp.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Xp.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Xp.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Xp.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Xp.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Xp.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Xp.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Xp.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Xp.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Xp.HEX,(function(e,t){return e.writeVec(Array.from(xp(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return Op(new Uint8Array(t))})),t.registerType(Xp.BASE58,(function(e,t){return e.writeVec(Array.from(vp(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return yp(new Uint8Array(t))})),t.registerType(Xp.BASE64,(function(e,t){return e.writeVec(Array.from(Tp(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return wp(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new Fp(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return vp(e);case"base64":return Tp(e);case"hex":return xp(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new Fp(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new Cp(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new Ip(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new Rp({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new Rp({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return Tp(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return wp(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return xp(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return Op(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],l,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:l}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,l,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let l=n.indexOf(h),p=-1===l?h:a[l];{let{name:r,params:s}=this.parseTypeName(p);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Xp=Fp;function Lp(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Jp,addressEncoding:"hex"}}Xp.U8="u8",Xp.U16="u16",Xp.U32="u32",Xp.U64="u64",Xp.U128="u128",Xp.U256="u256",Xp.BOOL="bool",Xp.VECTOR="vector",Xp.ADDRESS="address",Xp.STRING="string",Xp.HEX="hex-string",Xp.BASE58="base58-string",Xp.BASE64="base64-string";class Gp extends _p{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&fo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"arbitration.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.fee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.arbitration),void 0!==this.data?.description&&n&&r.push(Ho.arbitration_description),void 0!==this.data?.bPaused&&r.push(Ho.arbitration_pause),null==this.data?.endpoint&&r.push(Ho.arbitration_endpoint),void 0!==this.data?.fee&&n&&r.push(Ho.arbitration_fee),void 0!==a&&n&&r.push(Ho.arbitration_treasury),void 0!==this.data?.usage_guard&&r.push(Ho.arbitration_guard),void 0!==this.data?.voting_guard&&r.push(Ho.arbitration_voting_guard),void 0!==this.data?.arb_arbitration&&r.push(Ho.arbitration_arbitration),void 0!==this.data?.arb_new?.guard)if(co(this.data.arb_new.guard))t.push(this.data.arb_new.guard);else if(n){if(!s){const e=await Md({objects:[n],showContent:!0});e?.objects&&"Arbitration"===e.objects[0].type&&(s=e.objects[0])}s?.usage_guard&&t.push(s.usage_guard)}else this.data?.usage_guard&&co(this.data?.usage_guard)&&t.push(this.data.usage_guard);return void 0!==this.data?.arb_vote&&r.push(Ho.treasury_receive),"string"==typeof this.data?.arb_vote?.voting_guard&&co(this.data?.arb_vote?.voting_guard)&&t.push(this.data?.arb_vote?.voting_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.fee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a?s=xd.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}if(!d||!co(d)){const r=this.data?.fee_treasury?.description??"";n=Td.New(e,this.data?.type_parameter,i?i.get_object():a,r,i?void 0:t)}s=xd.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",BigInt(this.data?.fee??0),n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;var c;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.fee&&o&&s?.set_fee(BigInt(this.data.fee),a),void 0!==d&&o&&s?.set_withdrawTreasury(d,a),void 0!==this.data?.arb_new&&(c=s?.arb(this.data.arb_new.data,a)),void 0!==this.data?.arb_arbitration){const e=this.data.arb_arbitration.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_arbitration"),s?.arbitration({arb:e,feedback:this.data.arb_arbitration.feedback,indemnity:this.data.arb_arbitration.indemnity},a)}if(void 0!==this.data?.arb_vote){const e=this.data.arb_vote.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_vote"),s?.vote({arb:e,voting_guard:this.data.arb_vote.voting_guard,agrees:this.data.arb_vote.agrees},a)}if(void 0!==this.data?.arb_withdraw_fee){const e=this.data.arb_withdraw_fee.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_withdraw_fee"),s?.withdraw_fee(e,this.data.arb_withdraw_fee.data,a)}if(c&&await this.new_with_mark(e,s?.arb_launch(c),this.data?.arb_new?.namedNew,r),void 0!==this.data?.voting_guard)switch(this.data.voting_guard.op){case"add":s?.add_voting_guard(this.data.voting_guard.data,a);break;case"remove":s?.remove_voting_guard(this.data.voting_guard.guards,!1,a);break;case"set":s?.remove_voting_guard([],!0,a),s?.add_voting_guard(this.data.voting_guard.data,a);break;case"removeall":s?.remove_voting_guard([],!0,a)}void 0!==this.data.usage_guard&&s?.set_guard(this.data.usage_guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),n&&await this.new_with_mark(e,n.launch(),this.data?.fee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class $p extends _p{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&fo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"treasury.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.treasury),void 0!==this.data?.description&&n&&r.push(Ho.treasury_descritption),void 0!==this.data?.withdraw_mode&&r.push(Ho.treasury_withdraw_mode),null==this.data?.withdraw_guard&&r.push(Ho.treasury_withdraw_guard),void 0!==this.data?.deposit_guard&&r.push(Ho.treasury_deposit_guard),void 0!==this.data?.deposit_guard&&r.push(Ho.treasury_deposit_guard),void 0!==this.data?.deposit?.guard)if(co(this.data.deposit.guard))t.push(this.data.deposit.guard);else if(this.data.object){if(!s){const e=await Md({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}s?.deposit_guard&&t.push(s?.deposit_guard)}else this.data?.deposit_guard&&co(this.data?.deposit_guard)&&t.push(this.data.deposit_guard);if(void 0!==this.data?.receive&&r.push(Ho.treasury_receive),void 0!==this.data?.withdraw?.withdraw_guard){if("string"==typeof this.data.withdraw.withdraw_guard&&co(this.data.withdraw.withdraw_guard))t.push(this.data.withdraw.withdraw_guard);else if(this.data.object){if(!s){const e=await Md({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}"string"==typeof s?.withdraw_guard&&t.push(s?.withdraw_guard)}}else r.push(Ho.treasury_withdraw);return await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&n&&co(n)?s=Td.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=Td.New(e,this.data.type_parameter,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data.deposit){const t=await cc.Instance().get_coin_object(e,this.data.deposit.data.balance,r,this.data.type_parameter);if(t){const e=this.data.deposit.data?.index??0;s?.deposit({coin:t,index:BigInt(e),remark:this.data.deposit.data.remark??"",for_guard:this.data.deposit.data?.for_guard,for_object:this.data.deposit.data?.for_object})}}if(void 0!==this.data?.receive&&s?.receive(this.data.receive.payment,this.data.receive.received_object,n),void 0!==this.data?.withdraw&&s?.withdraw(this.data.withdraw,n),void 0!==this.data?.deposit_guard&&s?.set_deposit_guard(this.data.deposit_guard,n),void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"remove":s?.remove_withdraw_guard(this.data.withdraw_guard.guards,!1,n);break;case"set":s?.remove_withdraw_guard([],!0,n),this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"removeall":s?.remove_withdraw_guard([],!0,n)}void 0!==this.data?.withdraw_mode&&s?.set_withdraw_mode(this.data.withdraw_mode,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class zp extends _p{data;constructor(e){super(),this.data=e}async call(e){if(co(this.data.new_permission)||Ba(Ca.InvalidParam,"CallObjectPermission_Data.new_permission"+this.data.new_permission),this.data?.objects.length>0)return await this.exec(e)}async operate(e,t){const r=await Md({objects:this.data.objects,showContent:!0});r.objects?.forEach((t=>{switch(t.type){case"Demand":const r=t;Wo.From(e,Wo.parseObjectType(r.type_raw),r.permission,r.object).change_permission(this.data.new_permission);break;case"Machine":const s=t;Zo.From(e,s.permission,s.object).change_permission(this.data.new_permission);break;case"Service":const i=t;gd.From(e,gd.parseObjectType(i.type_raw),i.permission,i.object).change_permission(this.data.new_permission);break;case"Treasury":const n=t;Td.From(e,Td.parseObjectType(n.type_raw),n.permission,n.object).change_permission(this.data.new_permission);break;case"Arbitration":const a=t;xd.From(e,xd.parseObjectType(a.type_raw),a.permission,a.object).change_permission(this.data.new_permission);break;case"Repository":const o=t;md.From(e,o.permission,o.object).change_permission(this.data.new_permission)}}))}}class qp extends _p{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&fo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"demand.type_parameter");const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Ho.demand),void 0!==this.data?.description&&i&&r.push(Ho.demand_description),void 0!==this.data?.time_expire&&i&&r.push(Ho.demand_expand_time),void 0!==this.data?.guard&&r.push(Ho.demand_guard),"reward"===this.data?.bounty?.op&&r.push(Ho.demand_yes),"refund"===this.data?.bounty?.op&&r.push(Ho.demand_refund),void 0!==this.data?.present?.guard)if(co(this.data.present.guard))t.push(this.data.present.guard);else if(i){const e=await Md({objects:[i],showContent:!0});if(e?.objects&&"Demand"===e?.objects[0]?.type){const r=e?.objects[0];r?.guard&&t.push(r?.guard.object)}}else this.data?.guard?.address&&co(this.data?.guard.address)&&t.push(this.data.guard.address);return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&this.data.permission&&co(n)?s=Wo.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=void 0!==this.data.time_expire?Wo.New(e,this.data.type_parameter,"duration"===this.data.time_expire?.op,"duration"===this.data.time_expire?.op?this.data.time_expire.minutes:this.data.time_expire?.time,i?i.get_object():n,this.data?.description??"",i?void 0:t):Wo.New(e,this.data.type_parameter,!0,43200,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.time_expire&&a&&s?.expand_time("duration"===this.data.time_expire.op,"duration"===this.data.time_expire.op?this.data.time_expire.minutes:this.data.time_expire.time,n),void 0!==this.data?.bounty)if("add"===this.data.bounty.op){if(co(this.data.bounty.object?.address))s.deposit(this.data.bounty.object?.address);else if(void 0!==this.data.bounty.object?.balance){uo(this.data.type_parameter)||Ba(Ca.IsValidCoinType,"demand bounty");const t=await cc.Instance().get_coin_object(e,this.data.bounty.object?.balance,r,this.data.type_parameter);t&&s.deposit(t)}}else"reward"===this.data.bounty.op?s?.yes(this.data.bounty.service,n):"refund"===this.data.bounty.op&&s?.refund(n);void 0!==this.data?.present&&s?.present(this.data.present.service,this.data.present.service_pay_type,this.data.present.recommend_words,n),void 0!==this.data?.guard&&s?.set_guard(this.data.guard.address,this.data.guard?.service_id_in_guard??void 0,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Wp extends _p{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Ho.machine),void 0!==this.data?.description&&i&&r.push(Ho.machine_description),void 0!==this.data?.endpoint&&i&&r.push(Ho.machine_endpoint),void 0!==this.data?.consensus_repository&&r.push(Ho.machine_repository),void 0!==this.data?.nodes&&r.push(Ho.machine_node),this.data?.bPublished&&r.push(Ho.machine_publish),void 0!==this.data?.progress_new&&r.push(Ho.progress),void 0!==this.data?.progress_context_repository&&r.push(Ho.progress_context_repository),void 0!==this.data?.progress_namedOperator&&r.push(Ho.progress_namedOperator),void 0!==this.data?.progress_parent&&r.push(Ho.progress_parent),void 0!==this.data?.progress_task&&r.push(Ho.progress_bind_task),void 0!==this.data?.progress_hold&&this.data.progress_hold.adminUnhold&&r.push(Ho.progress_unhold),void 0!==this.data?.bPaused&&r.push(Ho.machine_pause),void 0!==this.data?.progress_next?.guard)if(co(this.data?.progress_next?.guard))t.push(this.data?.progress_next?.guard);else if(this.data?.object&&co(i)){const e=await ed.QueryForwardGuard(this.data?.progress_next.progress,i,await cc.Instance().get_address()??"0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f",this.data.progress_next.data.next_node_name,this.data.progress_next.data.forward);e&&t.push(e)}return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&n&&co(n)?s=Zo.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=Zo.New(e,i?i.get_object():n,this.data?.description??"",this.data?.endpoint??"",i?void 0:t)}if(s){const d=i?i.get_object():n,c=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,c),void 0!==this.data?.endpoint&&a&&s?.set_endpoint(this.data.endpoint,c),void 0!==this.data?.consensus_repository)switch(this.data.consensus_repository.op){case"add":this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)));break;case"remove":s?.remove_repository(this.data.consensus_repository.repositories,!1,c);break;case"removeall":s?.remove_repository([],!0,c);break;case"set":s?.remove_repository([],!0,c),this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)))}if(void 0!==this.data?.nodes)switch(this.data?.nodes?.op){case"add":s?.add_node(this.data.nodes.data,c);break;case"remove":s?.remove_node(this.data.nodes.names,this.data.nodes?.bTransferMyself,c);break;case"rename node":this.data.nodes.data.forEach((e=>s?.rename_node(e.old,e.new,c)));break;case"add from myself":s?.add_node2(this.data.nodes.addresses,c);break;case"add forward":this.data.nodes.data.forEach((e=>s?.add_forward(e.prior_node_name,e.node_name,e.forward,e.threshold,e.old_need_remove,c)));break;case"remove forward":this.data.nodes.data.forEach((e=>s?.remove_forward(e.prior_node_name,e.node_name,e.forward_name,c)))}var o;if(this.data?.bPublished&&s?.publish(t),void 0!==this.data?.progress_new&&(o=ed?.New(e,s?.get_object(),d,this.data?.progress_new.task_address,c)),void 0!==this.data?.progress_context_repository){const t=this.data?.progress_context_repository.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_context_repository"),ed.From(e,s?.get_object(),d,t).set_context_repository(this.data?.progress_context_repository.repository,c)}if(void 0!==this.data?.progress_namedOperator){const t=this.data?.progress_namedOperator.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_namedOperator");let r=ed.From(e,s?.get_object(),d,t);this.data.progress_namedOperator.data.forEach((e=>r.set_namedOperator(e.name,e.operator,c)))}if(void 0!==this.data?.progress_parent){const t=this.data?.progress_parent.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_parent"),this.data.progress_parent.parent?ed.From(e,s?.get_object(),d,t).parent(this.data.progress_parent.parent):ed.From(e,s?.get_object(),d,t).parent_none()}if(void 0!==this.data?.progress_task){const t=this.data?.progress_task.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_task"),ed.From(e,s?.get_object(),d,t).bind_task(this.data.progress_task.task,c)}if(void 0!==this.data?.progress_hold){const t=this.data?.progress_hold.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_hold"),this.data?.progress_hold.adminUnhold?ed.From(e,s?.get_object(),d,t).unhold(this.data.progress_hold.data,c):ed.From(e,s?.get_object(),d,t).hold(this.data.progress_hold.data,this.data.progress_hold.bHold)}const u=o?.launch();u&&await this.new_with_mark(e,u,this.data?.progress_new?.namedNew,r),void 0!==this.data?.progress_next&&ed.From(e,s?.get_object(),d,this.data?.progress_next.progress).next(this.data.progress_next.data,this.data.progress_next.deliverable,c),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,c),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s?.clone(!0,c),this.data?.clone_new?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Hp extends _p{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=this.data?.permission?.address,s=this.data?.object?.address;return r&&co(r)?(this.data?.object||t.push(Ho.repository),void 0!==this.data?.description&&s&&t.push(Ho.repository_description),void 0!==this.data?.mode&&s&&t.push(Ho.repository_mode),void 0!==this.data?.reference&&t.push(Ho.repository_reference),void 0!==this.data?.policy&&t.push(Ho.repository_policies),await this.check_permission_and_call(r,t,[],!1,void 0,e)):await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.permission&&co(n)?s=md.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=md.New(e,i?i.get_object():n,this.data?.description??"",this.data?.mode,i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.reference)switch(this.data.reference.op){case"set":s?.remove_reference([],!0,n),s?.add_reference(this.data.reference.addresses,n);break;case"add":s?.add_reference(this.data.reference.addresses,n);break;case"remove":s?.remove_reference(this.data.reference.addresses,!1,n);break;case"removeall":s?.remove_reference([],!0,n)}if(void 0!==this.data?.mode&&a&&s?.set_policy_mode(this.data.mode,n),void 0!==this.data?.policy)switch(this.data.policy.op){case"set":s?.remove_policies([],!0,n),s?.add_policies(this.data.policy.data,n);break;case"add":s?.add_policies(this.data.policy.data,n);break;case"remove":s?.remove_policies(this.data.policy.data,!1,n);break;case"removeall":s?.remove_policies([],!0,n);break;case"rename":this.data.policy.data.forEach((e=>{s?.rename_policy(e.old,e.new,n)}))}if(void 0!==this.data?.data)switch(this.data.data.op){case"add":void 0!==this.data.data?.data?.key?s?.add_data(this.data.data.data):void 0!==this.data.data?.data?.address&&s?.add_data2(this.data.data.data);break;case"remove":s?.remove(this.data.data.data.address,this.data.data.data.key)}i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Kp extends _p{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&fo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"service.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.payee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.service),void 0!==this.data?.description&&n&&r.push(Ho.service_description),void 0!==this.data?.bPaused&&r.push(Ho.service_pause),this.data?.bPublished&&r.push(Ho.service_publish),void 0!==this.data?.endpoint&&r.push(Ho.service_endpoint),void 0!==this.data?.repository&&r.push(Ho.service_repository),void 0!==this.data?.clone_new&&r.push(Ho.service_clone),void 0!==this.data?.gen_discount&&r.push(Ho.service_discount_transfer),void 0!==this.data?.arbitration&&r.push(Ho.service_arbitration),void 0!==this.data?.buy_guard&&r.push(Ho.service_buyer_guard),void 0!==this.data?.endpoint&&r.push(Ho.service_endpoint),void 0!==this.data?.extern_withdraw_treasury&&r.push(Ho.service_treasury),void 0!==this.data?.machine&&r.push(Ho.service_machine),void 0!==a&&n&&r.push(Ho.service_payee),void 0!==this.data?.withdraw_guard&&r.push(Ho.service_withdraw_guards),void 0!==this.data?.refund_guard&&r.push(Ho.service_refund_guards),void 0!==this.data?.customer_required_info&&r.push(Ho.service_customer_required),void 0!==this.data?.sales&&r.push(Ho.service_sales),void 0!==this.data?.order_new?.guard)if(co(this.data.order_new.guard))t.push(this.data.order_new.guard);else if(this.data.object){if(!s){const e=await Md({objects:[n],showContent:!0});e?.objects&&"Service"===e.objects[0].type&&(s=e.objects[0])}s?.buy_guard&&t.push(s?.buy_guard)}else this.data?.buy_guard&&co(this.data.buy_guard)&&t.push(this.data?.buy_guard);return co(this.data?.order_refund?.guard)&&t.push(this.data?.order_refund?.guard),void 0!==this.data.order_withdrawl&&r.push(Ho.service_withdraw),"string"==typeof this.data?.order_withdrawl?.data?.withdraw_guard&&co(this.data?.order_withdrawl?.data?.withdraw_guard)&&t.push(this.data?.order_withdrawl?.data?.withdraw_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.payee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a&&co(a)?s=gd.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}if(!d||!co(d)){const r=this.data?.payee_treasury?.description??"";n=Td.New(e,this.data?.type_parameter,i??a,r,i?void 0:t)}s=gd.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.payee_treasury&&o&&s?.set_payee(d,a),void 0!==this.data?.gen_discount&&s?.discount_transfer(this.data.gen_discount,a),void 0!==this.data?.repository)switch(this.data.repository.op){case"add":this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"remove":s?.remove_repository(this.data.repository.repositories,!1,a);break;case"set":s?.remove_repository([],!0,a),this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"removeall":s?.remove_repository([],!0,a)}if(void 0!==this.data?.extern_withdraw_treasury)switch(this.data.extern_withdraw_treasury.op){case"add":this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"set":s?.remove_treasury([],!0,a),this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"remove":s?.remove_treasury(this.data.extern_withdraw_treasury.addresses,!1,a);break;case"removeall":s?.remove_treasury([],!1,a)}if(void 0!==this.data?.machine&&s?.set_machine(this.data.machine,a),void 0!==this.data?.arbitration)switch(this.data.arbitration.op){case"add":this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.type_parameter,a)));break;case"set":s?.remove_arbitration([],!0,a),this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.type_parameter,a)));break;case"remove":s?.remove_arbitration(this.data.arbitration.addresses,!1,a);break;case"removeall":s?.remove_arbitration([],!1,a)}if(void 0!==this.data?.customer_required_info&&(this.data.customer_required_info.required_info&&this.data.customer_required_info.pubkey?s?.set_customer_required(this.data.customer_required_info.pubkey,this.data.customer_required_info.required_info,a):this.data.customer_required_info.pubkey&&s?.change_required_pubkey(this.data.customer_required_info.pubkey,a)),void 0!==this.data?.sales)switch(this.data.sales.op){case"add":s?.add_sales(this.data.sales.sales,!1,a);break;case"remove":s?.remove_sales(this.data.sales.sales_name,a)}if(void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"set":s?.remove_withdraw_guards([],!0,a),s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"remove":s?.remove_withdraw_guards(this.data.withdraw_guard.addresses,!1,a);break;case"removeall":s?.remove_withdraw_guards([],!0,a)}if(void 0!==this.data?.refund_guard)switch(this.data.refund_guard.op){case"add":s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"set":s?.remove_refund_guards([],!0,a),s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"remove":s?.remove_refund_guards(this.data.refund_guard.addresses,!1,a);break;case"removeall":s?.remove_refund_guards([],!0,a)}var c;if(this.data?.bPublished&&s?.publish(a),void 0!==this.data?.order_new){let t=BigInt(0);if(this.data.order_new.buy_items.forEach((e=>{t+=BigInt(e.max_price)*BigInt(e.count)})),t>BigInt(0)){const i=await cc.Instance().get_coin_object(e,t,r,this.data.type_parameter);i&&(c=s.order(this.data.order_new.buy_items,i,this.data.order_new.discount,this.data.order_new.machine,this.data.order_new.customer_info_crypto,a))}}if(void 0!==this.data?.order_agent){const e=this.data.order_agent.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_agent"),s?.set_order_agent(e,this.data.order_agent.agents,this.data.order_agent.progress)}if(void 0!==this.data?.order_required_info){const e=this.data.order_required_info.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_required_info"),s?.update_order_required_info(e,this.data.order_required_info.info)}if(void 0!==this.data?.order_refund){const e=this.data.order_refund.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_refund"),this.data?.order_refund?.arb&&this.data?.order_refund?.arb_token_type?s?.refund_withArb(e,this.data?.order_refund?.arb,this.data?.order_refund?.arb_token_type):s?.refund(e,this.data?.order_refund?.guard,a)}if(void 0!==this.data?.order_withdrawl&&a){const e=this.data.order_withdrawl.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_withdrawl"),s?.withdraw(e,this.data.order_withdrawl.data,a)}if(void 0!==this.data?.order_payer&&s){const e=this.data.order_payer.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_payer"),s?.change_order_payer(e,this.data.order_payer.payer_new,this.data.order_payer.progress)}if(c&&this?.data?.order_new){const t=s.order_launch(c);await this.new_with_mark(e,t.order,this.data?.order_new?.namedNewOrder,r,[hd.Launch,hd.Order]),t?.progress&&await this.new_with_mark(e,t.progress,this.data?.order_new?.namedNewProgress,r,[hd.Launch])}void 0!==this.data?.buy_guard&&s?.set_buy_guard(this.data.buy_guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s.clone(this.data.clone_new?.token_type_new,!0,a),this.data?.clone_new?.namedNew,r),n&&await this.new_with_mark(e,n.launch(),this.data?.payee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Qp extends _p{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){this.data?.root||Ba(Ca.InvalidParam,"guard root node invalid"),io(this.data?.description)||Ba(Ca.IsValidDesription,"build_guard - "+this.data.description),this.data?.table?.forEach((e=>{(!po(e.identifier)||e.identifier<1)&&Ba(Ca.InvalidParam,"table.identifer invalid"),e.bWitness||void 0!==e.value||Ba(Ca.InvalidParam,"table.value")})),this.data?.table&&jo(this.data?.table?.map((e=>e.identifier)))&&Ba(Ca.InvalidParam,"table.identifer duplicates");var s=[];Zp(this.data.root,No.TYPE_BOOL,this.data?.table??[],s);const i=Xa(Uint8Array,...s),n=e.moveCall({target:zo.Instance().guardFn("new"),arguments:[e.pure.string(this.data.description),e.pure.vector("u8",[].slice.call(i.reverse()))]});this.data?.table?.forEach((t=>{if(t.bWitness){const r=new Uint8Array(1);r.set([t.value_type],0),e.moveCall({target:zo.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}else{const r=Io(Uint8Array.from(Wa.getInstance().ser(t.value_type,t.value)),t.value_type);e.moveCall({target:zo.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}}));const a=e.moveCall({target:zo.Instance().guardFn("create"),arguments:[e.object(n)]});await this.new_with_mark(e,a,this.data?.namedNew,r)}}const Zp=(e,t,r,s)=>{const i=e;if(void 0!==i?.identifier){const e=r.find((e=>e.identifier===i.identifier));e?(em(e.value_type,t,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.identifier))):Ba(Ca.InvalidParam,"node identifier - "+JSON.stringify(i))}else if(void 0!==i?.query){var n;if("string"==typeof i.query?n=td.find((e=>e[1]===i.query)):"number"==typeof i.query&&(n=td.find((e=>e[2]===i.query))),n||Ba(Ca.InvalidParam,"query invalid - "+i?.query),em(n[4],t,i),n[3].length===i.parameters.length)for(let e=i.parameters.length-1;e>=0;--e)Zp(i.parameters[e],n[3][e],r,s);else Ba(Ca.InvalidParam,"node query parameters length not match - "+JSON.stringify(i));if(s.push(Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_QUERY)),"string"==typeof i.object)co(i.object)||Ba(Ca.InvalidParam,"node object from address string - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(No.TYPE_U8,No.TYPE_ADDRESS)),s.push(Wa.getInstance().ser(No.TYPE_ADDRESS,i.object));else{const e=r.find((e=>e.identifier===i.object));e?(em(e.value_type,No.TYPE_ADDRESS,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.object))):Ba(Ca.InvalidParam,"node object from identifier - "+JSON.stringify(i))}s.push(Wa.getInstance().ser("u16",n[2]))}else if(void 0!==i?.logic)switch(em(No.TYPE_BOOL,t,i),i?.logic){case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,No.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_NOT:1!==i.parameters.length&&Ba(Ca.InvalidParam,"node logic parameters length must be 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,No.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic));break;case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,"variable",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_HAS_SUBSTRING:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,No.TYPE_STRING,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length))}else if(void 0!==i?.calc)i?.calc===ko.TYPE_NUMBER_ADDRESS?(em(No.TYPE_ADDRESS,t,i),1!==i.parameters.length&&Ba(Ca.InvalidParam,"node TYPE_NUMBER_ADDRESS parameters length must == 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.calc))):(em(No.TYPE_U256,t,i),i.parameters.length<2&&Ba(Ca.InvalidParam,"node calc parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zp(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.calc)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length)));else if(void 0!==i?.value_type)em(i?.value_type,t,i),void 0===i?.value&&Ba(Ca.InvalidParam,"node value undefined - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.value_type)),i.value_type==No.TYPE_STRING||i.value_type===No.TYPE_VEC_U8?"string"==typeof i.value?s.push(Wa.getInstance().ser(No.TYPE_STRING,i.value)):s.push(Wa.getInstance().ser(No.TYPE_VEC_U8,i.value)):s.push(Wa.getInstance().ser(i?.value_type,i.value));else if(void 0!==i?.context)switch(s.push(Wa.getInstance().ser(No.TYPE_U8,i.context)),i.context){case Xo.TYPE_CLOCK:em(No.TYPE_U64,t,i);break;case Xo.TYPE_GUARD:case Xo.TYPE_SIGNER:em(No.TYPE_ADDRESS,t,i)}else if(void 0!==i?.identifier){nd(i.identifier)||Ba(Ca.IsValidGuardIdentifier,"node - "+JSON.stringify(i));const e=r.find((e=>e.identifier===i.identifier));e||Ba(Ca.InvalidParam,"identifier not found. node - "+JSON.stringify(i)),em(e.value_type,t,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.identifier))}else Ba(Ca.InvalidParam,"node - "+JSON.stringify(i))},em=(e,t,r)=>{if("variable"===t)t=e;else if("number"===t){if(e===No.TYPE_U128||e===No.TYPE_U256||e===No.TYPE_U8||e===No.TYPE_U64||e===Xo.TYPE_CLOCK)return}else if(t===No.TYPE_ADDRESS&&(e===Xo.TYPE_SIGNER||e===Xo.TYPE_GUARD))return;if(e!==t){var s="";r&&(s=" - "+JSON.stringify(r)),Ba(Ca.InvalidParam,"checkType: "+e+" require type: "+t+s)}};class tm extends _p{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){let s,i=fd.From(e);const n=this.data?.object?.address;if(s=n&&co(n)?vd.From(e,n):vd.From(e,i.create_resource2()),"destroy"!==this.data?.mark?.op){if(void 0!==this.data?.information&&i.update(this.data.information),s&&s?.get_object()){if(void 0!==this.data?.mark)switch(this.data.mark.op){case"add":this.data.mark.data.forEach((e=>{s?.add(e.address,e.tags,e.name)}));break;case"remove":this.data.mark.data.forEach((e=>{s?.remove(e.address,e.tags)}));break;case"removeall":this.data.mark.address.forEach((e=>{s?.removeall(e)}))}"transfer"===this.data?.mark?.op&&s&&co(this.data.mark.address)&&i.transfer_resource(s,this.data.mark.address),"replace"===this.data?.mark?.op&&co(this.data.mark.address)&&i.use_resource(vd.From(e,this.data.mark.address)),!n&&s&&await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}else i.destroy_resource(s)}}const rm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await sm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},sm=async e=>{var t=function(e){switch(e.type){case"Demand":return new qp(e.data);case"Service":return new Kp(e.data);case"Machine":return new Wp(e.data);case"Treasury":return new $p(e.data);case"Arbitration":return new Gp(e.data);case"Guard":return new Qp(e.data);case"Repository":return new Hp(e.data);case"Personal":return new tm(e.data);case"Permission":return new gp(e.data);case"ObjectPermission":return new zp(e.data)}}(e);if(t)return e.witness?t.call_with_witness(e.witness,e.account):t.call(e.account)}})(),o})()));