@d13co/use-wallet-ui-react 1.0.2 → 1.0.4

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.
@@ -27,16 +27,16 @@
27
27
  `+i+F.join(`,
28
28
  `+i)+`
29
29
  `+v+"}":"{"+F.join(",")+"}",i=v,x}}typeof t.stringify!="function"&&(t.stringify=function(d,u,m){var h;if(i="",o="",typeof m=="number")for(h=0;h<m;h+=1)o+=" ";else typeof m=="string"&&(o=m);if(a=u,u&&typeof u!="function"&&(typeof u!="object"||typeof u.length!="number"))throw new Error("JSON.stringify");return c("",{"":d})})})()})(kh)),kh.exports}var Ch,Lm;function G1(){if(Lm)return Ch;Lm=1;var n=null;const e=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,t=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;var r=function(i){var o={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(i!=null){if(i.strict===!0&&(o.strict=!0),i.storeAsString===!0&&(o.storeAsString=!0),o.alwaysParseAsBig=i.alwaysParseAsBig===!0?i.alwaysParseAsBig:!1,o.useNativeBigInt=i.useNativeBigInt===!0?i.useNativeBigInt:!1,typeof i.constructorAction<"u")if(i.constructorAction==="error"||i.constructorAction==="ignore"||i.constructorAction==="preserve")o.constructorAction=i.constructorAction;else throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${i.constructorAction}`);if(typeof i.protoAction<"u")if(i.protoAction==="error"||i.protoAction==="ignore"||i.protoAction==="preserve")o.protoAction=i.protoAction;else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${i.protoAction}`)}var s,a,l={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
30
- `,r:"\r",t:" "},c,d=function(C){throw{name:"SyntaxError",message:C,at:s,text:c}},u=function(C){return C&&C!==a&&d("Expected '"+C+"' instead of '"+a+"'"),a=c.charAt(s),s+=1,a},m=function(){var C,M="";for(a==="-"&&(M="-",u("-"));a>="0"&&a<="9";)M+=a,u();if(a===".")for(M+=".";u()&&a>="0"&&a<="9";)M+=a;if(a==="e"||a==="E")for(M+=a,u(),(a==="-"||a==="+")&&(M+=a,u());a>="0"&&a<="9";)M+=a,u();if(C=+M,!isFinite(C))d("Bad number");else return n==null&&(n=O0()),M.length>15?o.storeAsString?M:o.useNativeBigInt?BigInt(M):new n(M):o.alwaysParseAsBig?o.useNativeBigInt?BigInt(C):new n(C):C},h=function(){var C,M,N="",b;if(a==='"')for(var j=s;u();){if(a==='"')return s-1>j&&(N+=c.substring(j,s-1)),u(),N;if(a==="\\"){if(s-1>j&&(N+=c.substring(j,s-1)),u(),a==="u"){for(b=0,M=0;M<4&&(C=parseInt(u(),16),!!isFinite(C));M+=1)b=b*16+C;N+=String.fromCharCode(b)}else if(typeof l[a]=="string")N+=l[a];else break;j=s}}d("Bad string")},x=function(){for(;a&&a<=" ";)u()},A=function(){switch(a){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}d("Unexpected '"+a+"'")},v,F=function(){var C=[];if(a==="["){if(u("["),x(),a==="]")return u("]"),C;for(;a;){if(C.push(v()),x(),a==="]")return u("]"),C;u(","),x()}}d("Bad array")},w=function(){var C,M=Object.create(null);if(a==="{"){if(u("{"),x(),a==="}")return u("}"),M;for(;a;){if(C=h(),x(),u(":"),o.strict===!0&&Object.hasOwnProperty.call(M,C)&&d('Duplicate key "'+C+'"'),e.test(C)===!0?o.protoAction==="error"?d("Object contains forbidden prototype property"):o.protoAction==="ignore"?v():M[C]=v():t.test(C)===!0?o.constructorAction==="error"?d("Object contains forbidden constructor property"):o.constructorAction==="ignore"?v():M[C]=v():M[C]=v(),x(),a==="}")return u("}"),M;u(","),x()}}d("Bad object")};return v=function(){switch(x(),a){case"{":return w();case"[":return F();case'"':return h();case"-":return m();default:return a>="0"&&a<="9"?m():A()}},function(C,M){var N;return c=C+"",s=0,a=" ",N=v(),x(),a&&d("Syntax error"),typeof M=="function"?(function b(j,p){var E,S=j[p];return S&&typeof S=="object"&&Object.keys(S).forEach(function($){E=b(S,$),E!==void 0?S[$]=E:delete S[$]}),M.call(j,p,S)})({"":N},""):N}};return Ch=r,Ch}var Vm;function W1(){if(Vm)return Lc.exports;Vm=1;var n=j1().stringify,e=G1();return Lc.exports=function(t){return{parse:e(t),stringify:n}},Lc.exports.parse=e(),Lc.exports.stringify=n,Lc.exports}var z1=W1();const H1=$d(z1);var an;(function(n){n.UNSAFE="unsafe",n.SAFE="safe",n.MIXED="mixed",n.BIGINT="bigint"})(an||(an={}));const L0=H1({useNativeBigInt:!0,strict:!0});function _d(n,{intDecoding:e}){if(e!==an.SAFE&&e!==an.UNSAFE&&e!==an.BIGINT&&e!==an.MIXED)throw new Error(`Invalid intDecoding option: ${e}`);return L0.parse(n,(t,r)=>{if(r!=null&&typeof r=="object"&&Object.getPrototypeOf(r)==null&&Object.setPrototypeOf(r,Object.prototype),typeof r=="bigint"){if(e===an.SAFE&&r>Number.MAX_SAFE_INTEGER)throw new Error(`Integer exceeds maximum safe integer: ${r.toString()}. Try parsing with a different intDecoding option.`);return e===an.BIGINT||e===an.MIXED&&r>Number.MAX_SAFE_INTEGER?r:Number(r)}return typeof r=="number"&&e===an.BIGINT&&Number.isInteger(r)?BigInt(r):r})}function yi(n,e,t){return L0.stringify(n,e,t)}function Kr(n,e){return n.length!==e.length?!1:Array.from(n).every((t,r)=>t===e[r])}function hn(...n){const e=n.reduce((i,o)=>i+o.length,0),t=new Uint8Array(e);let r=0;for(let i=0;i<n.length;i++)t.set(n[i],r),r+=n[i].length;return t}function Ud(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"}function Y1(){const{navigator:n}=globalThis;return typeof n=="object"&&n.product==="ReactNative"}function Le(n){if(typeof n>"u")throw new Error("Value is undefined");if(typeof n=="bigint"){if(n>BigInt(Number.MAX_SAFE_INTEGER)||n<BigInt(Number.MIN_SAFE_INTEGER))throw new Error(`BigInt value ${n} is not a safe integer`);return Number(n)}if(typeof n=="number"){if(Number.isSafeInteger(n))return n;throw new Error(`Value ${n} is not a safe integer`)}throw new Error(`Unexpected type ${typeof n}, ${n}`)}function An(n){const e=Le(n);if(e<0)throw new Error(`Value ${e} is negative`);return e}function ve(n){if(typeof n>"u")throw new Error("Value is undefined");if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new Error(`Value ${n} is not a safe integer`);return BigInt(n)}throw new Error(`Unexpected type ${typeof n}, ${n}`)}function Wt(n){const e=ve(n);if(e<0||e>BigInt("0xffffffffffffffff"))throw new Error(`Value ${e} is not a uint64`);return e}function wi(n){return _1.sha512_256.array(n)}function K1(n){return Y1()&&console.warn("It looks like you're running in react-native. In order to perform common crypto operations you will need to polyfill common operations such as crypto.getRandomValues"),bi.randomBytes(n)}function V0(n){return bi.sign.keyPair.fromSeed(n)}function q1(){const n=K1(bi.box.secretKeyLength);return V0(n)}function $0(n){return n===bi.sign.signatureLength}function jd(n){return bi.sign.keyPair.fromSecretKey(n)}function ll(n,e){return bi.sign.detached(n,e)}function _0(n,e){return bi.verify(n,e)}function Gd(n,e,t){return bi.sign.detached.verify(n,e,t)}const U0=bi.sign.publicKeyLength,$m=32,Lf=32;var Fh={exports:{}};/*
30
+ `,r:"\r",t:" "},c,d=function(C){throw{name:"SyntaxError",message:C,at:s,text:c}},u=function(C){return C&&C!==a&&d("Expected '"+C+"' instead of '"+a+"'"),a=c.charAt(s),s+=1,a},m=function(){var C,M="";for(a==="-"&&(M="-",u("-"));a>="0"&&a<="9";)M+=a,u();if(a===".")for(M+=".";u()&&a>="0"&&a<="9";)M+=a;if(a==="e"||a==="E")for(M+=a,u(),(a==="-"||a==="+")&&(M+=a,u());a>="0"&&a<="9";)M+=a,u();if(C=+M,!isFinite(C))d("Bad number");else return n==null&&(n=O0()),M.length>15?o.storeAsString?M:o.useNativeBigInt?BigInt(M):new n(M):o.alwaysParseAsBig?o.useNativeBigInt?BigInt(C):new n(C):C},h=function(){var C,M,N="",b;if(a==='"')for(var j=s;u();){if(a==='"')return s-1>j&&(N+=c.substring(j,s-1)),u(),N;if(a==="\\"){if(s-1>j&&(N+=c.substring(j,s-1)),u(),a==="u"){for(b=0,M=0;M<4&&(C=parseInt(u(),16),!!isFinite(C));M+=1)b=b*16+C;N+=String.fromCharCode(b)}else if(typeof l[a]=="string")N+=l[a];else break;j=s}}d("Bad string")},x=function(){for(;a&&a<=" ";)u()},A=function(){switch(a){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}d("Unexpected '"+a+"'")},v,F=function(){var C=[];if(a==="["){if(u("["),x(),a==="]")return u("]"),C;for(;a;){if(C.push(v()),x(),a==="]")return u("]"),C;u(","),x()}}d("Bad array")},w=function(){var C,M=Object.create(null);if(a==="{"){if(u("{"),x(),a==="}")return u("}"),M;for(;a;){if(C=h(),x(),u(":"),o.strict===!0&&Object.hasOwnProperty.call(M,C)&&d('Duplicate key "'+C+'"'),e.test(C)===!0?o.protoAction==="error"?d("Object contains forbidden prototype property"):o.protoAction==="ignore"?v():M[C]=v():t.test(C)===!0?o.constructorAction==="error"?d("Object contains forbidden constructor property"):o.constructorAction==="ignore"?v():M[C]=v():M[C]=v(),x(),a==="}")return u("}"),M;u(","),x()}}d("Bad object")};return v=function(){switch(x(),a){case"{":return w();case"[":return F();case'"':return h();case"-":return m();default:return a>="0"&&a<="9"?m():A()}},function(C,M){var N;return c=C+"",s=0,a=" ",N=v(),x(),a&&d("Syntax error"),typeof M=="function"?(function b(j,p){var E,S=j[p];return S&&typeof S=="object"&&Object.keys(S).forEach(function($){E=b(S,$),E!==void 0?S[$]=E:delete S[$]}),M.call(j,p,S)})({"":N},""):N}};return Ch=r,Ch}var Vm;function W1(){if(Vm)return Lc.exports;Vm=1;var n=j1().stringify,e=G1();return Lc.exports=function(t){return{parse:e(t),stringify:n}},Lc.exports.parse=e(),Lc.exports.stringify=n,Lc.exports}var z1=W1();const H1=$d(z1);var an;(function(n){n.UNSAFE="unsafe",n.SAFE="safe",n.MIXED="mixed",n.BIGINT="bigint"})(an||(an={}));const L0=H1({useNativeBigInt:!0,strict:!0});function _d(n,{intDecoding:e}){if(e!==an.SAFE&&e!==an.UNSAFE&&e!==an.BIGINT&&e!==an.MIXED)throw new Error(`Invalid intDecoding option: ${e}`);return L0.parse(n,(t,r)=>{if(r!=null&&typeof r=="object"&&Object.getPrototypeOf(r)==null&&Object.setPrototypeOf(r,Object.prototype),typeof r=="bigint"){if(e===an.SAFE&&r>Number.MAX_SAFE_INTEGER)throw new Error(`Integer exceeds maximum safe integer: ${r.toString()}. Try parsing with a different intDecoding option.`);return e===an.BIGINT||e===an.MIXED&&r>Number.MAX_SAFE_INTEGER?r:Number(r)}return typeof r=="number"&&e===an.BIGINT&&Number.isInteger(r)?BigInt(r):r})}function yi(n,e,t){return L0.stringify(n,e,t)}function Kr(n,e){return n.length!==e.length?!1:Array.from(n).every((t,r)=>t===e[r])}function hn(...n){const e=n.reduce((i,o)=>i+o.length,0),t=new Uint8Array(e);let r=0;for(let i=0;i<n.length;i++)t.set(n[i],r),r+=n[i].length;return t}function Ud(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"}function Y1(){const{navigator:n}=globalThis;return typeof n=="object"&&n.product==="ReactNative"}function Oe(n){if(typeof n>"u")throw new Error("Value is undefined");if(typeof n=="bigint"){if(n>BigInt(Number.MAX_SAFE_INTEGER)||n<BigInt(Number.MIN_SAFE_INTEGER))throw new Error(`BigInt value ${n} is not a safe integer`);return Number(n)}if(typeof n=="number"){if(Number.isSafeInteger(n))return n;throw new Error(`Value ${n} is not a safe integer`)}throw new Error(`Unexpected type ${typeof n}, ${n}`)}function An(n){const e=Oe(n);if(e<0)throw new Error(`Value ${e} is negative`);return e}function ve(n){if(typeof n>"u")throw new Error("Value is undefined");if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new Error(`Value ${n} is not a safe integer`);return BigInt(n)}throw new Error(`Unexpected type ${typeof n}, ${n}`)}function Wt(n){const e=ve(n);if(e<0||e>BigInt("0xffffffffffffffff"))throw new Error(`Value ${e} is not a uint64`);return e}function wi(n){return _1.sha512_256.array(n)}function K1(n){return Y1()&&console.warn("It looks like you're running in react-native. In order to perform common crypto operations you will need to polyfill common operations such as crypto.getRandomValues"),bi.randomBytes(n)}function V0(n){return bi.sign.keyPair.fromSeed(n)}function q1(){const n=K1(bi.box.secretKeyLength);return V0(n)}function $0(n){return n===bi.sign.signatureLength}function jd(n){return bi.sign.keyPair.fromSecretKey(n)}function ll(n,e){return bi.sign.detached(n,e)}function _0(n,e){return bi.verify(n,e)}function Gd(n,e,t){return bi.sign.detached.verify(n,e,t)}const U0=bi.sign.publicKeyLength,$m=32,Lf=32;var Fh={exports:{}};/*
31
31
  * [hi-base32]{@link https://github.com/emn178/hi-base32}
32
32
  *
33
33
  * @version 0.5.0
34
34
  * @author Chen, Yi-Cyuan [emn178@gmail.com]
35
35
  * @copyright Chen, Yi-Cyuan 2015-2018
36
36
  * @license MIT
37
- */var _m;function X1(){return _m||(_m=1,(function(n){(function(){var e=typeof window=="object"?window:{},t=!e.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;t&&(e=P0);var r=!e.HI_BASE32_NO_COMMON_JS&&!0&&n.exports,i="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),o={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},s=[0,0,0,0,0,0,0,0],a=function(v,F){F.length>10&&(F="..."+F.substr(-10));var w=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+v+" bytes: "+F+" <-");throw w.position=v,w},l=function(v){for(var F="",w=v.length,C=0,M=0,N,b;C<w;){if(N=v[C++],N<=127){F+=String.fromCharCode(N);continue}else N>191&&N<=223?(b=N&31,M=1):N<=239?(b=N&15,M=2):N<=247?(b=N&7,M=3):a(C,F);for(var j=0;j<M;++j)N=v[C++],(N<128||N>191)&&a(C,F),b<<=6,b+=N&63;b>=55296&&b<=57343&&a(C,F),b>1114111&&a(C,F),b<=65535?F+=String.fromCharCode(b):(b-=65536,F+=String.fromCharCode((b>>10)+55296),F+=String.fromCharCode((b&1023)+56320))}return F},c=function(v){if(v==="")return[];if(!/^[A-Z2-7=]+$/.test(v))throw new Error("Invalid base32 characters");v=v.replace(/=/g,"");for(var F,w,C,M,N,b,j,p,E=[],S=0,$=v.length,B=0,P=$>>3<<3;B<P;)F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],p=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255,E[S++]=(M<<4|N>>>1)&255,E[S++]=(N<<7|b<<2|j>>>3)&255,E[S++]=(j<<5|p)&255;var W=$-P;return W===2?(F=o[v.charAt(B++)],w=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255):W===4?(F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255):W===5?(F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255,E[S++]=(M<<4|N>>>1)&255):W===7&&(F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255,E[S++]=(M<<4|N>>>1)&255,E[S++]=(N<<7|b<<2|j>>>3)&255),E},d=function(v){for(var F,w,C,M,N,b="",j=v.length,p=0,E=parseInt(j/5)*5;p<E;)F=v.charCodeAt(p++),w=v.charCodeAt(p++),C=v.charCodeAt(p++),M=v.charCodeAt(p++),N=v.charCodeAt(p++),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[(M<<3|N>>>5)&31]+i[N&31];var S=j-E;return S===1?(F=v.charCodeAt(p),b+=i[F>>>3]+i[F<<2&31]+"======"):S===2?(F=v.charCodeAt(p++),w=v.charCodeAt(p),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[w<<4&31]+"===="):S===3?(F=v.charCodeAt(p++),w=v.charCodeAt(p++),C=v.charCodeAt(p),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[C<<1&31]+"==="):S===4&&(F=v.charCodeAt(p++),w=v.charCodeAt(p++),C=v.charCodeAt(p++),M=v.charCodeAt(p),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[M<<3&31]+"="),b},u=function(v){var F,w,C,M,N,b,j=!1,p="",E=0,S,$=0,B=v.length;if(v==="")return p;do{for(s[0]=s[5],s[1]=s[6],s[2]=s[7],S=$;E<B&&S<5;++E)b=v.charCodeAt(E),b<128?s[S++]=b:b<2048?(s[S++]=192|b>>6,s[S++]=128|b&63):b<55296||b>=57344?(s[S++]=224|b>>12,s[S++]=128|b>>6&63,s[S++]=128|b&63):(b=65536+((b&1023)<<10|v.charCodeAt(++E)&1023),s[S++]=240|b>>18,s[S++]=128|b>>12&63,s[S++]=128|b>>6&63,s[S++]=128|b&63);$=S-5,E===B&&++E,E>B&&S<6&&(j=!0),F=s[0],S>4?(w=s[1],C=s[2],M=s[3],N=s[4],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[(M<<3|N>>>5)&31]+i[N&31]):S===1?p+=i[F>>>3]+i[F<<2&31]+"======":S===2?(w=s[1],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[w<<4&31]+"===="):S===3?(w=s[1],C=s[2],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[C<<1&31]+"==="):(w=s[1],C=s[2],M=s[3],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[M<<3&31]+"=")}while(!j);return p},m=function(v){for(var F,w,C,M,N,b="",j=v.length,p=0,E=parseInt(j/5)*5;p<E;)F=v[p++],w=v[p++],C=v[p++],M=v[p++],N=v[p++],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[(M<<3|N>>>5)&31]+i[N&31];var S=j-E;return S===1?(F=v[p],b+=i[F>>>3]+i[F<<2&31]+"======"):S===2?(F=v[p++],w=v[p],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[w<<4&31]+"===="):S===3?(F=v[p++],w=v[p++],C=v[p],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[C<<1&31]+"==="):S===4&&(F=v[p++],w=v[p++],C=v[p++],M=v[p],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[M<<3&31]+"="),b},h=function(v,F){var w=typeof v!="string";return w&&v.constructor===ArrayBuffer&&(v=new Uint8Array(v)),w?m(v):F?d(v):u(v)},x=function(v,F){if(!F)return l(c(v));if(v==="")return"";if(!/^[A-Z2-7=]+$/.test(v))throw new Error("Invalid base32 characters");var w,C,M,N,b,j,p,E,S="",$=v.indexOf("=");$===-1&&($=v.length);for(var B=0,P=$>>3<<3;B<P;)w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],p=o[v.charAt(B++)],E=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)+String.fromCharCode((N<<4|b>>>1)&255)+String.fromCharCode((b<<7|j<<2|p>>>3)&255)+String.fromCharCode((p<<5|E)&255);var W=$-P;return W===2?(w=o[v.charAt(B++)],C=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)):W===4?(w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)):W===5?(w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)+String.fromCharCode((N<<4|b>>>1)&255)):W===7&&(w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],p=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)+String.fromCharCode((N<<4|b>>>1)&255)+String.fromCharCode((b<<7|j<<2|p>>>3)&255)),S},A={encode:h,decode:x};x.asBytes=c,r?n.exports=A:e.base32=A})()})(Fh)),Fh.exports}var Z1=X1();const ul=$d(Z1);function j0(n){if(!(typeof n=="bigint"||Number.isInteger(n))||n<0||n>BigInt("0xffffffffffffffff"))throw new Error("Input is not a 64-bit unsigned integer");const t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(n)),t}function G0(n,e="safe"){if(e!=="safe"&&e!=="mixed"&&e!=="bigint")throw new Error(`Unknown decodingMode option: ${e}`);if(n.byteLength===0||n.byteLength>8)throw new Error(`Data has unacceptable length. Expected length is between 1 and 8, got ${n.byteLength}`);const t=new Uint8Array(8-n.byteLength),r=hn(t,n),o=new DataView(r.buffer).getBigUint64(0),s=o>BigInt(Number.MAX_SAFE_INTEGER);if(e==="safe"){if(s)throw new Error(`Integer exceeds maximum safe integer: ${o.toString()}. Try decoding with "mixed" or "safe" decodingMode.`);return Number(o)}return e==="mixed"&&!s?Number(o):o}function Ge(n){if(Ud())return new Uint8Array(Buffer.from(n,"base64"));const e=atob(n);return Uint8Array.from(e,t=>t.codePointAt(0))}function In(n){if(Ud())return Buffer.from(n).toString("base64");const e=Array.from(n,t=>String.fromCodePoint(t)).join("");return btoa(e)}function Wd(n){return new TextDecoder().decode(n)}function qr(n){return typeof n=="string"?new TextEncoder().encode(n):n}function zd(n){return Ud()?Buffer.from(n).toString("hex"):Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}function J1(n){if(Ud())return Buffer.from(n,"hex");let e=n;n.length%2!==0&&(e=n.padStart(1,"0"));const t=new Uint8Array(e.length/2);for(let r=0;r<e.length/2;r++)t[r]=parseInt(e.slice(2*r,2*r+2),16);return t}const ko=36,Jc=4,Dh=58,Q1="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ",Vc="address seems to be malformed",eA="wrong checksum for address";function Um(n){return Uint8Array.from(wi(n).slice($m-Jc,$m))}class ze{constructor(e){if(!(e instanceof Uint8Array))throw new Error(`${Vc}: ${e} is not Uint8Array, type ${typeof e}`);if(e.length!==ko-Jc)throw new Error(`${Vc}: 0x${zd(e)}, length ${e.length}`);this.publicKey=e}equals(e){return e instanceof ze&&Kr(this.publicKey,e.publicKey)}checksum(){return Um(this.publicKey)}toString(){return ul.encode(hn(this.publicKey,this.checksum())).slice(0,Dh)}static fromString(e){if(typeof e!="string")throw new Error(`${Vc}: expected string, got ${typeof e}, ${e}`);if(e.length!==Dh)throw new Error(`${Vc}: expected length ${Dh}, got ${e.length}: ${e}`);const t=ul.decode.asBytes(e);if(t.length!==ko)throw new Error(`${Vc}: expected byte length ${ko}, got ${t.length}`);const r=new Uint8Array(t.slice(0,ko-Jc)),i=new Uint8Array(t.slice(U0,ko)),o=Um(r);if(!Kr(o,i))throw new Error(eA);return new ze(r)}static zeroAddress(){return new ze(new Uint8Array(ko-Jc))}}function W0(n){return ze.fromString(n)}function z0(n){try{ze.fromString(n)}catch{return!1}return!0}function H0(n){return new ze(n).toString()}const tA=new TextEncoder().encode("appID");function dd(n){const e=hn(tA,j0(n)),t=wi(e);return new ze(Uint8Array.from(t))}const Y0=1e6,ag="Microalgos should be positive and less than 2^53 - 1.";function nA(n){if(n<0||!Number.isSafeInteger(n))throw new Error(ag);return n/Y0}function rA(n){const e=n*Y0;return Math.round(e)}class iA extends Error{constructor(e,t){super(e),this.response=t,this.name="URLTokenBaseHTTPError",this.response=t}}class Ni{constructor(e,t,r,i={}){this.defaultHeaders=i;const o=t.endsWith("/")?t:`${t}/`,s=new URL(o);if(typeof r<"u"&&(s.port=r.toString()),s.protocol.length===0)throw new Error("Invalid base server URL, protocol must be defined.");this.baseURL=s,this.tokenHeader=e}getURL(e,t){let r;e.startsWith("./")?r=e:e.startsWith("/")?r=`.${e}`:r=`./${e}`;const i=new URL(r,this.baseURL);if(t)for(const[o,s]of Object.entries(t))i.searchParams.set(o,s.toString());return i.toString()}static formatFetchResponseHeaders(e){const t={};return e.forEach((r,i)=>{t[r]=i}),t}static async checkHttpError(e){if(e.ok)return;let t,r;try{t=new Uint8Array(await e.arrayBuffer());const o=JSON.parse(new TextDecoder().decode(t));o.message&&(r=o.message)}catch{}let i=`Network request error. Received status ${e.status} (${e.statusText})`;throw r&&(i+=`: ${r}`),new iA(i,{body:t??new Uint8Array,status:e.status,headers:Ni.formatFetchResponseHeaders(e.headers)})}static async formatFetchResponse(e){return await this.checkHttpError(e),{body:new Uint8Array(await e.arrayBuffer()),status:e.status,headers:Ni.formatFetchResponseHeaders(e.headers)}}async get(e,t,r,i){const o={...this.tokenHeader,...this.defaultHeaders,...r??{}},s=await fetch(this.getURL(e,t),{headers:o,...i??{}});return Ni.formatFetchResponse(s)}async post(e,t,r,i,o){const s={...this.tokenHeader,...this.defaultHeaders,...i??{}},a=await fetch(this.getURL(e,r),{method:"POST",body:t,headers:s,...o??{}});return Ni.formatFetchResponse(a)}async delete(e,t,r,i,o){const s={...this.tokenHeader,...this.defaultHeaders,...i??{}},a=await fetch(this.getURL(e,r),{method:"DELETE",body:t,headers:s,...o??{}});return Ni.formatFetchResponse(a)}}class oA{constructor(e){this.body=e.body,this.text=e.text,this.format=e.format,this.headers=e.headers,this.status=e.status,this.ok=e.ok}getJSONText(){if(this.text===void 0)throw new Error(`Response body does not contain JSON data. Format is ${this.format}`);return this.text}parseBodyAsJSON(e){if(this.text===void 0)throw new Error(`Response body does not contain JSON data. Format is ${this.format}`);return Jn.parseJSON(this.text,this.status,e)}}function sA(n){for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(!n[e]||n[e].length===0)&&delete n[e];return n}function jm(n){return Object.keys(n).reduce((e,t)=>(e[t.toLowerCase()]=n[t],e),{})}function aA(n){if(n!==void 0&&Object.prototype.hasOwnProperty.call(n,"format"))switch(n.format){case"msgpack":return"application/msgpack";case"json":default:return"application/json"}else return"application/json"}class Jn{constructor(e,t,r,i={}){t!==void 0?this.bc=new Ni(e,t,r,i):this.bc=e}static parseJSON(e,t,r){try{return e?_d(e,r):null}catch(i){const o=i;throw o.rawResponse=e||null,o.statusCode=t,o}}static serializeData(e,t){if(!e)return new Uint8Array(0);if(t["content-type"]==="application/json")return new TextEncoder().encode(yi(e));if(typeof e=="string")return new TextEncoder().encode(e);if(e instanceof Uint8Array)return e;throw new Error("provided data is neither a string nor a Uint8Array and content-type is not application/json")}static prepareResponse(e,t){const{body:r}=e;let i;return t!=="application/msgpack"&&(i=r&&new TextDecoder().decode(r)||""),new oA({...e,format:t,text:i,ok:Math.trunc(e.status/100)===2})}static prepareResponseError(e){return e.response&&(e.response=Jn.prepareResponse(e.response,"application/json"),e.status=e.response.status),e}async get({relativePath:e,query:t,requestHeaders:r,customOptions:i}){const o=aA(t),s={...r??{},accept:o};try{const a=await this.bc.get(e,t?sA(t):void 0,s,i);return Jn.prepareResponse(a,o)}catch(a){throw Jn.prepareResponseError(a)}}async post({relativePath:e,data:t,query:r,requestHeaders:i,customOptions:o}){const s={"content-type":"application/json",...jm(i??{})};try{const a=await this.bc.post(e,Jn.serializeData(t,s),r,s,o);return Jn.prepareResponse(a,"application/json")}catch(a){throw Jn.prepareResponseError(a)}}async delete({relativePath:e,data:t,requestHeaders:r,customOptions:i}){const o={"content-type":"application/json",...jm(r??{})};try{const s=await this.bc.delete(e,typeof t<"u"?Jn.serializeData(t,o):void 0,void 0,o,i);return Jn.prepareResponse(s,"application/json")}catch(s){throw Jn.prepareResponseError(s)}}}function cA(n,e=""){const t={};return e===""||(t[n]=e),t}function lA(n){return typeof n.get=="function"}class cg{constructor(e,t,r,i,o={}){if(lA(t))this.c=new Jn(t);else{let s;typeof t=="string"?s=cA(e,t):s=t,this.c=new Jn(s,r,i,o)}}}function uA(n){for(var e=n.length,t=0,r=0;r<e;){var i=n.charCodeAt(r++);if((i&4294967168)===0){t++;continue}else if((i&4294965248)===0)t+=2;else{if(i>=55296&&i<=56319&&r<e){var o=n.charCodeAt(r);(o&64512)===56320&&(++r,i=((i&1023)<<10)+(o&1023)+65536)}(i&4294901760)===0?t+=3:t+=4}}return t}function dA(n,e,t){for(var r=n.length,i=t,o=0;o<r;){var s=n.charCodeAt(o++);if((s&4294967168)===0){e[i++]=s;continue}else if((s&4294965248)===0)e[i++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<r){var a=n.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}(s&4294901760)===0?(e[i++]=s>>12&15|224,e[i++]=s>>6&63|128):(e[i++]=s>>18&7|240,e[i++]=s>>12&63|128,e[i++]=s>>6&63|128)}e[i++]=s&63|128}}var hA=new TextEncoder,fA=50;function pA(n,e,t){hA.encodeInto(n,e.subarray(t))}function gA(n,e,t){n.length>fA?pA(n,e,t):dA(n,e,t)}var mA=4096;function K0(n,e,t){for(var r=e,i=r+t,o=[],s="";r<i;){var a=n[r++];if((a&128)===0)o.push(a);else if((a&224)===192){var l=n[r++]&63;o.push((a&31)<<6|l)}else if((a&240)===224){var l=n[r++]&63,c=n[r++]&63;o.push((a&31)<<12|l<<6|c)}else if((a&248)===240){var l=n[r++]&63,c=n[r++]&63,d=n[r++]&63,u=(a&7)<<18|l<<12|c<<6|d;u>65535&&(u-=65536,o.push(u>>>10&1023|55296),u=56320|u&1023),o.push(u)}else o.push(a);o.length>=mA&&(s+=String.fromCharCode.apply(String,o),o.length=0)}return o.length>0&&(s+=String.fromCharCode.apply(String,o)),s}var yA=new TextDecoder,wA=200;function xA(n,e,t){var r=n.subarray(e,e+t);return yA.decode(r)}function vA(n,e,t){return t>wA?xA(n,e,t):K0(n,e,t)}var Iu=(function(){function n(e,t){this.type=e,this.data=t}return n})(),SA=(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},n(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),Nr=(function(n){SA(e,n);function e(t){var r=n.call(this,t)||this,i=Object.create(e.prototype);return Object.setPrototypeOf(r,i),Object.defineProperty(r,"name",{configurable:!0,enumerable:!1,value:e.name}),r}return e})(Error),un;(function(n){n[n.UNSAFE_NUMBER=0]="UNSAFE_NUMBER",n[n.SAFE_NUMBER=1]="SAFE_NUMBER",n[n.AS_ENCODED=2]="AS_ENCODED",n[n.MIXED=3]="MIXED",n[n.BIGINT=4]="BIGINT"})(un||(un={}));var $c=4294967295;function bA(n,e,t){var r=t/4294967296,i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function q0(n,e,t){var r=Math.floor(t/4294967296),i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function X0(n,e,t){if(t===un.UNSAFE_NUMBER||t===un.SAFE_NUMBER){var r=n.getInt32(e),i=n.getUint32(e+4);if(t===un.SAFE_NUMBER&&(r<Math.floor(Number.MIN_SAFE_INTEGER/4294967296)||r===Math.floor(Number.MIN_SAFE_INTEGER/4294967296)&&i===0||r>(Number.MAX_SAFE_INTEGER-i)/4294967296)){var o="".concat(r<0?"-":"","0x").concat(Math.abs(r).toString(16)).concat(i.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(o))}return r*4294967296+i}var s=n.getBigInt64(e);return t===un.MIXED&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}function EA(n,e,t){if(t===un.UNSAFE_NUMBER||t===un.SAFE_NUMBER){var r=n.getUint32(e),i=n.getUint32(e+4);if(t===un.SAFE_NUMBER&&r>(Number.MAX_SAFE_INTEGER-i)/4294967296){var o="0x".concat(r.toString(16)).concat(i.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(o))}return r*4294967296+i}var s=n.getBigUint64(e);return t===un.MIXED&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}function AA(n,e){return e===un.BIGINT?BigInt(n):Number(n)}var IA=-1,kA=4294967296-1,CA=17179869184-1;function FA(n){var e=n.sec,t=n.nsec;if(e>=0&&t>=0&&e<=CA)if(t===0&&e<=kA){var r=new Uint8Array(4),i=new DataView(r.buffer);return i.setUint32(0,e),r}else{var o=e/4294967296,s=e&4294967295,r=new Uint8Array(8),i=new DataView(r.buffer);return i.setUint32(0,t<<2|o&3),i.setUint32(4,s),r}else{var r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,t),q0(i,4,e),r}}function DA(n){var e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,i=Math.floor(r/1e9);return{sec:t+i,nsec:r-i*1e9}}function TA(n){if(n instanceof Date){var e=DA(n);return FA(e)}else return null}function MA(n){var e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:{var t=e.getUint32(0),r=0;return{sec:t,nsec:r}}case 8:{var i=e.getUint32(0),o=e.getUint32(4),t=(i&3)*4294967296+o,r=i>>>2;return{sec:t,nsec:r}}case 12:{var t=X0(e,4,un.UNSAFE_NUMBER),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new Nr("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(n.length))}}function RA(n){var e=MA(n);return new Date(e.sec*1e3+e.nsec/1e6)}var BA={type:IA,encode:TA,decode:RA},Z0=(function(){function n(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(BA)}return n.prototype.register=function(e){var t=e.type,r=e.encode,i=e.decode;if(t>=0)this.encoders[t]=r,this.decoders[t]=i;else{var o=1+t;this.builtInEncoders[o]=r,this.builtInDecoders[o]=i}},n.prototype.tryToEncode=function(e,t){for(var r=0;r<this.builtInEncoders.length;r++){var i=this.builtInEncoders[r];if(i!=null){var o=i(e,t);if(o!=null){var s=-1-r;return new Iu(s,o)}}}for(var r=0;r<this.encoders.length;r++){var i=this.encoders[r];if(i!=null){var o=i(e,t);if(o!=null){var s=r;return new Iu(s,o)}}}return e instanceof Iu?e:null},n.prototype.decode=function(e,t,r){var i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,r):new Iu(t,e)},n.defaultCodec=new n,n})();function Pi(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n instanceof ArrayBuffer?new Uint8Array(n):Uint8Array.from(n)}function NA(n){if(n instanceof ArrayBuffer)return new DataView(n);var e=Pi(n);return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Gm(n,e){for(var t=Math.min(n.length,e.length),r=0;r<t;r++){var i=n[r]-e[r];if(i!==0)return i}return n.length-e.length}var $n=(function(){function n(e){if(this.rawBinaryValue=e,!ArrayBuffer.isView(e))throw new TypeError("RawBinaryString: rawBinaryValue must be an ArrayBufferView")}return n})(),PA=100,OA=2048,LA=(function(){function n(e){var t,r,i,o,s,a,l,c;this.extensionCodec=(t=e==null?void 0:e.extensionCodec)!==null&&t!==void 0?t:Z0.defaultCodec,this.context=e==null?void 0:e.context,this.forceBigIntToInt64=(r=e==null?void 0:e.forceBigIntToInt64)!==null&&r!==void 0?r:!1,this.maxDepth=(i=e==null?void 0:e.maxDepth)!==null&&i!==void 0?i:PA,this.initialBufferSize=(o=e==null?void 0:e.initialBufferSize)!==null&&o!==void 0?o:OA,this.sortKeys=(s=e==null?void 0:e.sortKeys)!==null&&s!==void 0?s:!1,this.forceFloat32=(a=e==null?void 0:e.forceFloat32)!==null&&a!==void 0?a:!1,this.ignoreUndefined=(l=e==null?void 0:e.ignoreUndefined)!==null&&l!==void 0?l:!1,this.forceIntegerToFloat=(c=e==null?void 0:e.forceIntegerToFloat)!==null&&c!==void 0?c:!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return n.prototype.reinitializeState=function(){this.pos=0},n.prototype.encodeSharedRef=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)},n.prototype.encode=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)},n.prototype.doEncode=function(e,t){if(t>this.maxDepth)throw new Error("Too deep objects in depth ".concat(t));e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.encodeObject(e,t)},n.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)},n.prototype.resizeBuffer=function(e){var t=new ArrayBuffer(e),r=new Uint8Array(t),i=new DataView(t);r.set(this.bytes),this.view=i,this.bytes=r},n.prototype.encodeNil=function(){this.writeU8(192)},n.prototype.encodeBoolean=function(e){e===!1?this.writeU8(194):this.writeU8(195)},n.prototype.encodeNumber=function(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)},n.prototype.encodeNumberAsFloat=function(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},n.prototype.encodeBigInt=function(e){if(this.forceBigIntToInt64)this.encodeBigIntAsInt64(e);else if(e>=0)if(e<4294967296||this.forceIntegerToFloat)this.encodeNumber(Number(e));else if(e<BigInt("0x10000000000000000"))this.encodeBigIntAsInt64(e);else throw new Error("Bigint is too large for uint64: ".concat(e));else if(e>=-2147483648||this.forceIntegerToFloat)this.encodeNumber(Number(e));else if(e>=BigInt(-1)*BigInt("0x8000000000000000"))this.encodeBigIntAsInt64(e);else throw new Error("Bigint is too small for int64: ".concat(e))},n.prototype.encodeBigIntAsInt64=function(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))},n.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error("Too long string: ".concat(e," bytes in UTF-8"))},n.prototype.encodeString=function(e){var t=5,r=uA(e);this.ensureBufferSizeToWrite(t+r),this.writeStringHeader(r),gA(e,this.bytes,this.pos),this.pos+=r},n.prototype.encodeObject=function(e,t){var r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(e instanceof $n)this.encodeBinaryAsString(e);else if(typeof e=="bigint")this.encodeBigInt(e);else if(e instanceof Map)this.encodeMap(e,t);else if(typeof e=="object")this.encodeMapObject(e,t);else throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)))},n.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error("Too large binary: ".concat(t));var r=Pi(e);this.writeU8a(r)},n.prototype.encodeBinaryAsString=function(e){var t=e.rawBinaryValue;this.writeStringHeader(t.byteLength);var r=Pi(t);this.writeU8a(r)},n.prototype.encodeArray=function(e,t){var r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error("Too large array: ".concat(r));for(var i=0,o=e;i<o.length;i++){var s=o[i];this.doEncode(s,t+1)}},n.prototype.countWithoutUndefined=function(e,t){for(var r=0,i=0,o=t;i<o.length;i++){var s=o[i];e.get(s)!==void 0&&r++}return r},n.prototype.sortMapKeys=function(e){for(var t=[],r=[],i=[],o=[],s=0,a=e;s<a.length;s++){var l=a[s];if(typeof l=="number"){if(isNaN(l))throw new Error("Cannot sort map keys with NaN value");t.push(l)}else if(typeof l=="bigint")t.push(l);else if(typeof l=="string")r.push(l);else if(ArrayBuffer.isView(l))o.push(Pi(l));else if(l instanceof $n)i.push(l);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(l)))}return t.sort(function(c,d){return c<d?-1:c>d?1:0}),r.sort(),i.sort(function(c,d){return Gm(Pi(c.rawBinaryValue),Pi(d.rawBinaryValue))}),o.sort(Gm),[].concat(t,r,i,o)},n.prototype.encodeMapObject=function(e,t){this.encodeMap(new Map(Object.entries(e)),t)},n.prototype.encodeMap=function(e,t){var r=Array.from(e.keys());this.sortKeys&&(r=this.sortMapKeys(r));var i=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error("Too large map object: ".concat(i));for(var o=0,s=r;o<s.length;o++){var a=s[o],l=e.get(a);if(!(this.ignoreUndefined&&l===void 0)){if(typeof a=="string")this.encodeString(a);else if(typeof a=="number")this.encodeNumber(a);else if(typeof a=="bigint")this.encodeBigInt(a);else if(ArrayBuffer.isView(a))this.encodeBinary(a);else if(a instanceof $n)this.encodeBinaryAsString(a);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(a)));this.doEncode(l,t+1)}}},n.prototype.encodeExtension=function(e){var t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error("Too large extension object: ".concat(t));this.writeI8(e.type),this.writeU8a(e.data)},n.prototype.writeU8=function(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++},n.prototype.writeU8a=function(e){var t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t},n.prototype.writeI8=function(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++},n.prototype.writeU16=function(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2},n.prototype.writeI16=function(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2},n.prototype.writeU32=function(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4},n.prototype.writeI32=function(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4},n.prototype.writeF32=function(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4},n.prototype.writeF64=function(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8},n.prototype.writeU64=function(e){this.ensureBufferSizeToWrite(8),bA(this.view,this.pos,e),this.pos+=8},n.prototype.writeI64=function(e){this.ensureBufferSizeToWrite(8),q0(this.view,this.pos,e),this.pos+=8},n.prototype.writeBigUint64=function(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8},n.prototype.writeBigInt64=function(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8},n})();function VA(n,e){var t=new LA(e);return t.encodeSharedRef(n)}function Th(n){return"".concat(n<0?"-":"","0x").concat(Math.abs(n).toString(16).padStart(2,"0"))}var $A=16,_A=16,UA=(function(){function n(e,t){e===void 0&&(e=$A),t===void 0&&(t=_A),this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(var r=0;r<this.maxKeyLength;r++)this.caches.push([])}return n.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},n.prototype.find=function(e,t,r){var i=this.caches[r-1];e:for(var o=0,s=i;o<s.length;o++){for(var a=s[o],l=a.bytes,c=0;c<r;c++)if(l[c]!==e[t+c])continue e;return a.str}return null},n.prototype.store=function(e,t){var r=this.caches[e.length-1],i={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)},n.prototype.decode=function(e,t,r){var i=this.find(e,t,r);if(i!=null)return this.hit++,i;this.miss++;var o=K0(e,t,r),s=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(s,o),o},n})(),jA=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(d){try{c(r.next(d))}catch(u){s(u)}}function l(d){try{c(r.throw(d))}catch(u){s(u)}}function c(d){d.done?o(d.value):i(d.value).then(a,l)}c((r=r.apply(n,e||[])).next())})},Mh=function(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(d){return l([c,d])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(t=0)),t;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(d){c=[6,d],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Wm=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=n[o]&&function(s){return new Promise(function(a,l){s=n[o](s),i(a,l,s.done,s.value)})}}function i(o,s,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},s)}},Zs=function(n){return this instanceof Zs?(this.v=n,this):new Zs(n)},GA=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(m){r[m]&&(i[m]=function(h){return new Promise(function(x,A){o.push([m,h,x,A])>1||a(m,h)})})}function a(m,h){try{l(r[m](h))}catch(x){u(o[0][3],x)}}function l(m){m.value instanceof Zs?Promise.resolve(m.value.v).then(c,d):u(o[0][2],m)}function c(m){a("next",m)}function d(m){a("throw",m)}function u(m,h){m(h),o.shift(),o.length&&a(o[0][0],o[0][1])}},Vf="array",Qc="map_key",J0="map_value";function WA(n,e,t){return e?typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n instanceof Uint8Array||n instanceof $n:typeof n=="string"||t&&typeof n=="number"}var zA=(function(){function n(e){this.useMap=e,this.stack=[],this.stackHeadPosition=-1}return Object.defineProperty(n.prototype,"length",{get:function(){return this.stackHeadPosition+1},enumerable:!1,configurable:!0}),n.prototype.top=function(){return this.stack[this.stackHeadPosition]},n.prototype.pushArrayState=function(e){var t=this.getUninitializedStateFromPool();t.type=Vf,t.position=0,t.size=e,t.array=new Array(e)},n.prototype.pushMapState=function(e){var t=this.getUninitializedStateFromPool();t.type=Qc,t.readCount=0,t.size=e,t.map=this.useMap?new Map:{}},n.prototype.getUninitializedStateFromPool=function(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){var e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]},n.prototype.release=function(e){var t=this.stack[this.stackHeadPosition];if(t!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Vf){var r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===Qc||e.type===J0){var r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--},n.prototype.reset=function(){this.stack.length=0,this.stackHeadPosition=-1},n})(),_c=-1,lg=new DataView(new ArrayBuffer(0)),HA=new Uint8Array(lg.buffer);try{lg.getInt8(0)}catch(n){if(!(n instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var $f=RangeError,zm=new $f("Insufficient data"),YA=new UA,KA=(function(){function n(e){var t,r,i,o,s,a,l,c,d,u,m,h;if(this.totalPos=0,this.pos=0,this.view=lg,this.bytes=HA,this.headByte=_c,this.extensionCodec=(t=e==null?void 0:e.extensionCodec)!==null&&t!==void 0?t:Z0.defaultCodec,this.context=e==null?void 0:e.context,this.intMode=(r=e==null?void 0:e.intMode)!==null&&r!==void 0?r:e!=null&&e.useBigInt64?un.AS_ENCODED:un.UNSAFE_NUMBER,this.rawBinaryStringValues=(i=e==null?void 0:e.rawBinaryStringValues)!==null&&i!==void 0?i:!1,this.rawBinaryStringKeys=(o=e==null?void 0:e.rawBinaryStringKeys)!==null&&o!==void 0?o:!1,this.useRawBinaryStringClass=(s=e==null?void 0:e.useRawBinaryStringClass)!==null&&s!==void 0?s:!1,this.useMap=(a=e==null?void 0:e.useMap)!==null&&a!==void 0?a:!1,this.supportObjectNumberKeys=(l=e==null?void 0:e.supportObjectNumberKeys)!==null&&l!==void 0?l:!1,this.maxStrLength=(c=e==null?void 0:e.maxStrLength)!==null&&c!==void 0?c:$c,this.maxBinLength=(d=e==null?void 0:e.maxBinLength)!==null&&d!==void 0?d:$c,this.maxArrayLength=(u=e==null?void 0:e.maxArrayLength)!==null&&u!==void 0?u:$c,this.maxMapLength=(m=e==null?void 0:e.maxMapLength)!==null&&m!==void 0?m:$c,this.maxExtLength=(h=e==null?void 0:e.maxExtLength)!==null&&h!==void 0?h:$c,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:YA,this.rawBinaryStringKeys&&!this.useMap)throw new Error("rawBinaryStringKeys is only supported when useMap is true");this.stack=new zA(this.useMap)}return n.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=_c,this.stack.reset()},n.prototype.setBuffer=function(e){this.bytes=Pi(e),this.view=NA(this.bytes),this.pos=0},n.prototype.appendBuffer=function(e){if(this.headByte===_c&&!this.hasRemaining(1))this.setBuffer(e);else{var t=this.bytes.subarray(this.pos),r=Pi(e),i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),this.setBuffer(i)}},n.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},n.prototype.createExtraByteError=function(e){var t=this,r=t.view,i=t.pos;return new RangeError("Extra ".concat(r.byteLength-i," of ").concat(r.byteLength," byte(s) found at buffer[").concat(e,"]"))},n.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},n.prototype.decodeMulti=function(e){return Mh(this,function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}})},n.prototype.decodeAsync=function(e){var t,r,i,o,s,a,l;return jA(this,void 0,void 0,function(){var c,d,u,m,h,x,A,v;return Mh(this,function(F){switch(F.label){case 0:c=!1,F.label=1;case 1:F.trys.push([1,6,7,12]),t=!0,r=Wm(e),F.label=2;case 2:return[4,r.next()];case 3:if(i=F.sent(),o=i.done,!!o)return[3,5];if(l=i.value,t=!1,u=l,c)throw this.createExtraByteError(this.totalPos);this.appendBuffer(u);try{d=this.doDecodeSync(),c=!0}catch(w){if(!(w instanceof $f))throw w}this.totalPos+=this.pos,F.label=4;case 4:return t=!0,[3,2];case 5:return[3,12];case 6:return m=F.sent(),s={error:m},[3,12];case 7:return F.trys.push([7,,10,11]),!t&&!o&&(a=r.return)?[4,a.call(r)]:[3,9];case 8:F.sent(),F.label=9;case 9:return[3,11];case 10:if(s)throw s.error;return[7];case 11:return[7];case 12:if(c){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,d]}throw h=this,x=h.headByte,A=h.pos,v=h.totalPos,new RangeError("Insufficient data in parsing ".concat(Th(x)," at ").concat(v," (").concat(A," in the current buffer)"))}})})},n.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},n.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},n.prototype.decodeMultiAsync=function(e,t){return GA(this,arguments,function(){var i,o,s,a,l,c,d,u,m,h,x,A;return Mh(this,function(v){switch(v.label){case 0:i=t,o=-1,v.label=1;case 1:v.trys.push([1,13,14,19]),s=!0,a=Wm(e),v.label=2;case 2:return[4,Zs(a.next())];case 3:if(l=v.sent(),m=l.done,!!m)return[3,12];if(A=l.value,s=!1,c=A,t&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(c),i&&(o=this.readArraySize(),i=!1,this.complete()),v.label=4;case 4:v.trys.push([4,9,,10]),v.label=5;case 5:return[4,Zs(this.doDecodeSync())];case 6:return[4,v.sent()];case 7:return v.sent(),--o===0?[3,8]:[3,5];case 8:return[3,10];case 9:if(d=v.sent(),!(d instanceof $f))throw d;return[3,10];case 10:this.totalPos+=this.pos,v.label=11;case 11:return s=!0,[3,2];case 12:return[3,19];case 13:return u=v.sent(),h={error:u},[3,19];case 14:return v.trys.push([14,,17,18]),!s&&!m&&(x=a.return)?[4,Zs(x.call(a))]:[3,16];case 15:v.sent(),v.label=16;case 16:return[3,18];case 17:if(h)throw h.error;return[7];case 18:return[7];case 19:return[2]}})})},n.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=this.convertNumber(e-256);else if(e<192)if(e<128)t=this.convertNumber(e);else if(e<144){var r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t=this.useMap?new Map:{}}else if(e<160){var r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{var i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.convertNumber(this.readU8());else if(e===205)t=this.convertNumber(this.readU16());else if(e===206)t=this.convertNumber(this.readU32());else if(e===207)t=this.readU64();else if(e===208)t=this.convertNumber(this.readI8());else if(e===209)t=this.convertNumber(this.readI16());else if(e===210)t=this.convertNumber(this.readI32());else if(e===211)t=this.readI64();else if(e===217){var i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){var i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){var i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){var r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){var r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){var r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){var r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){var r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){var r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){var r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){var r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){var r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){var r=this.lookU32();t=this.decodeExtension(r,4)}else throw new Nr("Unrecognized type byte: ".concat(Th(e)));this.complete();for(var o=this.stack;o.length>0;){var s=o.top();if(s.type===Vf)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,o.release(s);else continue e;else if(s.type===Qc){if(!WA(t,this.useMap,this.supportObjectNumberKeys)){var a=this.useMap?"string, number, bigint, or Uint8Array":this.supportObjectNumberKeys?"string or number":"string";throw new Nr("The type of key must be ".concat(a," but got ").concat(typeof t))}if(!this.useMap&&t==="__proto__")throw new Nr("The key __proto__ is not allowed");s.key=t,s.type=J0;continue e}else if(this.useMap?s.map.set(s.key,t):s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,o.release(s);else{s.key=null,s.type=Qc;continue e}}return t}},n.prototype.readHeadByte=function(){return this.headByte===_c&&(this.headByte=this.readU8()),this.headByte},n.prototype.complete=function(){this.headByte=_c},n.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Nr("Unrecognized array type byte: ".concat(Th(e)))}}},n.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new Nr("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.pushMapState(e)},n.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new Nr("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.pushArrayState(e)},n.prototype.decodeString=function(e,t){if(this.stateIsMapKey()?this.rawBinaryStringKeys:this.rawBinaryStringValues){var r=this.decodeBinary(e,t);return this.useRawBinaryStringClass?new $n(r):r}return this.decodeUtf8String(e,t)},n.prototype.decodeUtf8String=function(e,t){var r;if(e>this.maxStrLength)throw new Nr("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+t+e)throw zm;var i=this.pos+t,o;return this.stateIsMapKey()&&(!((r=this.keyDecoder)===null||r===void 0)&&r.canBeCached(e))?o=this.keyDecoder.decode(this.bytes,i,e):o=vA(this.bytes,i,e),this.pos+=t+e,o},n.prototype.stateIsMapKey=function(){if(this.stack.length>0){var e=this.stack.top();return e.type===Qc}return!1},n.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new Nr("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw zm;var r=this.pos+t,i=this.bytes.subarray(r,r+e);return this.pos+=t+e,i},n.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new Nr("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var r=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,r,this.context)},n.prototype.convertNumber=function(e){return AA(e,this.intMode)},n.prototype.lookU8=function(){return this.view.getUint8(this.pos)},n.prototype.lookU16=function(){return this.view.getUint16(this.pos)},n.prototype.lookU32=function(){return this.view.getUint32(this.pos)},n.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},n.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},n.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},n.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},n.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},n.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},n.prototype.readU64=function(){var e=EA(this.view,this.pos,this.intMode);return this.pos+=8,e},n.prototype.readI64=function(){var e=X0(this.view,this.pos,this.intMode);return this.pos+=8,e},n.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},n.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},n})();function ug(n,e){var t=new KA(e);return t.decode(n)}const qA="The object contains empty or 0 values. First empty or 0 value encountered during encoding: ";function XA(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&(!n[e]||n[e].length===0))return{containsEmpty:!0,firstEmptyKey:e};return{containsEmpty:!1,firstEmptyKey:void 0}}function du(n){return VA(n,{sortKeys:!0})}function ZA(n){const e=XA(n);if(e.containsEmpty)throw new Error(qA+e.firstEmptyKey);return du(n)}function Q0(n){switch(n){case an.UNSAFE:return un.UNSAFE_NUMBER;case an.SAFE:return un.SAFE_NUMBER;case an.MIXED:return un.MIXED;case an.BIGINT:return un.BIGINT;default:throw new Error(`Invalid intDecoding: ${n}`)}}function ex(n,e){const t={intMode:e!=null&&e.intDecoding?Q0(e==null?void 0:e.intDecoding):un.BIGINT};return ug(n,t)}function JA(n){return ex(n,{intDecoding:an.MIXED})}function tx(n,e){const t={intMode:e!=null&&e.intDecoding?Q0(e==null?void 0:e.intDecoding):un.BIGINT,useMap:!0};return ug(n,t)}function QA(n,e){const t={intMode:un.BIGINT,useMap:!0,rawBinaryStringKeys:!0,rawBinaryStringValues:!0,useRawBinaryStringClass:!0};return ug(n,t)}function _f(n){if(n==null)return n;if(n instanceof Uint8Array)return In(n);if(Array.isArray(n))return n.map(_f);if(n instanceof Map){const e={};for(const[t,r]of n){if(typeof t!="string")throw new Error(`JSON map key must be a string: ${t}`);e[t]=_f(r)}return e}return n}function Uf(n){if(n==null||typeof n=="string"||typeof n=="number"||typeof n=="bigint"||typeof n=="boolean")return n;if(Array.isArray(n))return n.map(Uf);if(typeof n=="object"){const e=new Map;for(const[t,r]of Object.entries(n))e.set(t,Uf(r));return e}throw new Error(`Invalid JSON encoding data: ${n}`)}var Mi;(function(n){n[n.MAP_VALUE=0]="MAP_VALUE",n[n.ARRAY_ELEMENT=1]="ARRAY_ELEMENT"})(Mi||(Mi={}));class hd{constructor({parent:e,segment:t,baseObjectBytes:r}){this.resolvedCache=null,this.resolvedCachePresent=!1,this.parent=e,this.segment=t,this.baseObjectBytes=r}withMapValue(e){return new hd({parent:this,segment:{kind:Mi.MAP_VALUE,key:e}})}withArrayElement(e){return new hd({parent:this,segment:{kind:Mi.ARRAY_ELEMENT,key:e}})}getRawStringAtCurrentLocation(){const e=this.resolve();if(e instanceof $n)return e.rawBinaryValue;throw new Error(`Invalid type. Expected RawBinaryString, got ${e} (${typeof e})`)}getRawStringKeysAndValuesAtCurrentLocation(){const e=this.resolve();if(!(e instanceof Map))throw new Error(`Invalid type. Expected Map, got ${e} (${typeof e})`);const t=new Map;for(const[r,i]of e)if(r instanceof $n)t.set(r.rawBinaryValue,i);else throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${r} (${typeof r})`);return t}resolve(){if(this.resolvedCachePresent)return this.resolvedCache;let e;if(this.parent?e=this.parent.resolve():e=QA(this.baseObjectBytes),!this.segment)return this.resolvedCache=e,this.resolvedCachePresent=!0,e;if(this.segment.kind===Mi.MAP_VALUE){if(!(e instanceof Map))throw new Error(`Invalid type. Expected Map, got ${e} (${typeof e})`);if(typeof this.segment.key=="string"||this.segment.key instanceof Uint8Array||this.segment.key instanceof $n){const t=this.segment.key instanceof $n?this.segment.key.rawBinaryValue:qr(this.segment.key),r=typeof this.segment.key=="string"||this.segment.key instanceof $n;for(const[i,o]of e){let s;if(r?i instanceof $n&&(s=i.rawBinaryValue):i instanceof Uint8Array&&(s=i),s&&Kr(t,s)){this.resolvedCache=o;break}}}else this.resolvedCache=e.get(this.segment.key);return this.resolvedCachePresent=!0,this.resolvedCache}if(this.segment.kind===Mi.ARRAY_ELEMENT){if(!Array.isArray(e))throw new Error(`Invalid type. Expected Array, got ${e} (${typeof e})`);return this.resolvedCache=e[this.segment.key],this.resolvedCachePresent=!0,this.resolvedCache}throw new Error(`Invalid segment kind: ${this.segment.kind}`)}getPathString(){const e=this.parent?this.parent.getPathString():"root";return this.segment?this.segment.kind===Mi.MAP_VALUE?`${e} -> map key "${this.segment.key}" (${typeof this.segment.key})`:this.segment.kind===Mi.ARRAY_ELEMENT?`${e} -> array index ${this.segment.key} (${typeof this.segment.key})`:`${e} -> unknown segment kind ${this.segment.kind}`:e}}class Un{}function Xt(n,e){const t=tx(n),r=new hd({baseObjectBytes:n});return e.fromEncodingData(e.encodingSchema.fromPreparedMsgpack(t,r))}function Sr(n){return du(n.getEncodingSchema().prepareMsgpack(n.toEncodingData()))}function Et(n,e){const t=_d(n,{intDecoding:an.BIGINT});return e.fromEncodingData(e.encodingSchema.fromPreparedJSON(t))}function eI(n,e){const{space:t,...r}=e??{},i=n.getEncodingSchema().prepareJSON(n.toEncodingData(),r);return yi(i,void 0,t)}class gt extends Un{defaultValue(){return!1}isDefaultValue(e){return e===!1}prepareMsgpack(e){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}fromPreparedMsgpack(e,t){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}prepareJSON(e,t){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}fromPreparedJSON(e){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}}class Ce extends Un{defaultValue(){return""}isDefaultValue(e){return e===""}prepareMsgpack(e){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}prepareJSON(e,t){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}}class O extends Un{defaultValue(){return BigInt(0)}isDefaultValue(e){return typeof e=="bigint"?e===BigInt(0):typeof e=="number"?e===0:!1}prepareMsgpack(e){return Wt(e)}fromPreparedMsgpack(e,t){return Wt(e)}prepareJSON(e,t){return Wt(e)}fromPreparedJSON(e){return Wt(e)}}class _t extends Un{defaultValue(){return ze.zeroAddress()}isDefaultValue(e){return ze.zeroAddress().equals(e)}prepareMsgpack(e){if(e instanceof ze)return e.publicKey;throw new Error(`Invalid address: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){return new ze(e)}prepareJSON(e,t){if(e instanceof ze)return e.toString();throw new Error(`Invalid address: (${typeof e}) ${e}`)}fromPreparedJSON(e){return ze.fromString(e)}}class Pe extends Un{defaultValue(){return new Uint8Array}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===0}prepareMsgpack(e){if(e instanceof Uint8Array)return e;throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){if(e instanceof Uint8Array)return e;throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}prepareJSON(e,t){if(e instanceof Uint8Array)return In(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(e==null)return this.defaultValue();if(typeof e=="string")return Ge(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}}class Ht extends Un{constructor(e){super(),this.length=e}defaultValue(){return new Uint8Array(this.length)}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===this.length&&e.every(t=>t===0)}prepareMsgpack(e){if(e instanceof Uint8Array){if(e.byteLength===this.length)return e;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${e.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedMsgpack(e,t){if(e instanceof Uint8Array){if(e.byteLength===this.length)return e;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${e.byteLength}`)}throw new Error("Invalid byte array")}prepareJSON(e){if(e instanceof Uint8Array){if(e.byteLength===this.length)return In(e);throw new Error(`Invalid byte array length: wanted ${this.length}, got ${e.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedJSON(e){if(typeof e=="string"){const t=Ge(e);if(t.byteLength===this.length)return t;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid base64 byte array")}}const Uc=32,Hm=52;class tI extends Un{defaultValue(){return new Uint8Array(Uc)}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===Uc&&e.every(t=>t===0)}prepareMsgpack(e){if(e instanceof Uint8Array&&e.byteLength===Uc)return e;throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){if(e instanceof Uint8Array&&e.byteLength===Uc)return e;throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}prepareJSON(e,t){if(e instanceof Uint8Array&&e.byteLength===Uc)return`blk-${ul.encode(e).slice(0,Hm)}`;throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(typeof e=="string"&&e.length===Hm+4&&e.startsWith("blk-"))return Uint8Array.from(ul.decode.asBytes(e.slice(4)));throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}}class Js extends Un{defaultValue(){return new Uint8Array}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===0}prepareMsgpack(e){if(e instanceof Uint8Array)return new $n(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){return t.getRawStringAtCurrentLocation()}prepareJSON(e,t){if(e instanceof Uint8Array){const r=Wd(e);if(!t.lossyBinaryStringConversion&&!Kr(qr(r),e))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${In(e)}`);return r}throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(typeof e=="string")return qr(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}}class Me extends Un{constructor(e){super(),this.itemSchema=e}defaultValue(){return[]}isDefaultValue(e){return Array.isArray(e)&&e.length===0}prepareMsgpack(e){if(Array.isArray(e))return e.map(t=>this.itemSchema.prepareMsgpack(t));throw new Error("ArraySchema data must be an array")}fromPreparedMsgpack(e,t){if(Array.isArray(e))return e.map((r,i)=>this.itemSchema.fromPreparedMsgpack(r,t.withArrayElement(i)));throw new Error(`ArraySchema encoded data must be an array: ${e} (${typeof e})`)}prepareJSON(e,t){if(Array.isArray(e))return e.map(r=>this.itemSchema.prepareJSON(r,t));throw new Error("ArraySchema data must be an array")}fromPreparedJSON(e){if(Array.isArray(e))return e.map(t=>this.itemSchema.fromPreparedJSON(t));throw new Error(`ArraySchema encoded data must be an array: ${e} (${typeof e})`)}}function rt(n){return n.map(e=>({...e,omitEmpty:!0}))}class oe extends Un{constructor(e){super(),this.entries=e,this.checkEntries()}pushEntries(...e){this.entries.push(...e),this.checkEntries()}checkEntries(){for(const t of this.entries)if(t.embedded){if(t.key!=="")throw new Error("Embedded entries must have an empty key");if(!(t.valueSchema instanceof oe))throw new Error("Embedded entry valueSchema must be a NamedMapSchema")}const e=new Set;for(const t of this.getEntries()){if(e.has(t.key))throw new Error(`Duplicate key: ${t.key}`);e.add(t.key)}}getEntries(){const e=[];for(const t of this.entries)if(t.embedded){const r=t.valueSchema;e.push(...r.getEntries())}else e.push(t);return e}defaultValue(){const e=new Map;for(const t of this.getEntries())e.set(t.key,t.valueSchema.defaultValue());return e}isDefaultValue(e){if(!(e instanceof Map))return!1;for(const t of this.getEntries())if(!t.valueSchema.isDefaultValue(e.get(t.key)))return!1;return!0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`NamedMapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const r of this.getEntries()){const i=e.get(r.key);r.omitEmpty&&r.valueSchema.isDefaultValue(i)||t.set(r.key,r.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){if(!(e instanceof Map))throw new Error("NamedMapSchema data must be a Map");const r=new Map;for(const i of this.getEntries())if(e.has(i.key))r.set(i.key,i.valueSchema.fromPreparedMsgpack(e.get(i.key),t.withMapValue(i.key)));else if(i.omitEmpty)r.set(i.key,i.valueSchema.defaultValue());else throw new Error(`Missing key: ${i.key}`);return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error("NamedMapSchema data must be a Map");const r={};for(const i of this.getEntries()){const o=e.get(i.key);i.omitEmpty&&i.valueSchema.isDefaultValue(o)||(r[i.key]=i.valueSchema.prepareJSON(o,t))}return r}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("NamedMapSchema data must be an object");const t=new Map;for(const r of this.getEntries())if(Object.prototype.hasOwnProperty.call(e,r.key))t.set(r.key,r.valueSchema.fromPreparedJSON(e[r.key]));else if(r.omitEmpty)t.set(r.key,r.valueSchema.defaultValue());else throw new Error(`Missing key: ${r.key}`);return t}}function Dc(...n){const e=new Map;for(const t of n)for(const[r,i]of t){if(e.has(r))throw new Error(`Duplicate key: ${r}`);e.set(r,i)}return e}function dn(n,e){const t=new Map;for(const[r,i]of n){const[o,s]=e(r,i);t.set(o,s)}return t}class Hd extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){return new Map}isDefaultValue(e){return e instanceof Map&&e.size===0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const[r,i]of e){const o=Wt(r);if(t.has(o))throw new Error(`Duplicate key: ${o}`);t.set(o,this.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){if(!(e instanceof Map))throw new Error("Uint64MapSchema data must be a Map");const r=new Map;for(const[i,o]of e){const s=Wt(i);if(r.has(s))throw new Error(`Duplicate key: ${s}`);r.set(s,this.valueSchema.fromPreparedMsgpack(o,t.withMapValue(i)))}return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof e}) ${e}`);const r=new Map;for(const[o,s]of e){const a=Wt(o);if(r.has(a))throw new Error(`Duplicate key: ${a}`);r.set(a,this.valueSchema.prepareJSON(s,t))}const i={};for(const[o,s]of r)i[o.toString()]=s;return i}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("Uint64MapSchema data must be an object");const t=new Map;for(const[r,i]of Object.entries(e)){const o=BigInt(r);if(t.has(o))throw new Error(`Duplicate key: ${o}`);t.set(o,this.valueSchema.fromPreparedJSON(i))}return t}}class nI extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){return new Map}isDefaultValue(e){return e instanceof Map&&e.size===0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const[r,i]of e){if(!(r instanceof Uint8Array))throw new Error(`Invalid key: ${r} (${typeof r})`);t.set(r,this.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){if(!(e instanceof Map))throw new Error("ByteArrayMapSchema data must be a Map");const r=new Map;for(const[i,o]of e){if(!(i instanceof Uint8Array))throw new Error(`Invalid key: ${i} (${typeof i})`);r.set(i,this.valueSchema.fromPreparedMsgpack(o,t.withMapValue(i)))}return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof e}) ${e}`);const r=new Map;for(const[o,s]of e){if(!(o instanceof Uint8Array))throw new Error(`Invalid key: ${o} (${typeof o})`);const a=In(o);if(r.has(a))throw new Error(`Duplicate key (base64): ${a}`);r.set(a,this.valueSchema.prepareJSON(s,t))}const i={};for(const[o,s]of r)i[o]=s;return i}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("ByteArrayMapSchema data must be an object");const t=new Map;for(const[r,i]of Object.entries(e))t.set(Ge(r),this.valueSchema.fromPreparedJSON(i));return t}}function ju(n){if(n instanceof $n)return Wd(n.rawBinaryValue);if(n instanceof Map){const e=new Map;for(const[t,r]of n)e.set(ju(t),ju(r));return e}return Array.isArray(n)?n.map(ju):n}class dl extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){return new Map}isDefaultValue(e){return e instanceof Map&&e.size===0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const[r,i]of e){if(!(r instanceof Uint8Array))throw new Error(`Invalid key: ${r} (${typeof r})`);t.set(new $n(r),this.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){const r=new Map,i=t.getRawStringKeysAndValuesAtCurrentLocation();for(const[o,s]of i)r.set(o,this.valueSchema.fromPreparedMsgpack(ju(s),t.withMapValue(new $n(o))));return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof e}) ${e}`);const r=new Map;for(const[o,s]of e){if(!(o instanceof Uint8Array))throw new Error(`Invalid key: ${o}`);const a=Wd(o);if(!t.lossyBinaryStringConversion&&!Kr(qr(a),o))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${In(o)}`);r.set(a,this.valueSchema.prepareJSON(s,t))}const i={};for(const[o,s]of r)i[o]=s;return i}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("SpecialCaseBinaryStringMapSchema data must be an object");const t=new Map;for(const[r,i]of Object.entries(e))t.set(qr(r),this.valueSchema.fromPreparedJSON(i));return t}}class k extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){}isDefaultValue(e){return e===void 0||this.valueSchema.isDefaultValue(e)}prepareMsgpack(e){if(e!==void 0)return this.valueSchema.prepareMsgpack(e)}fromPreparedMsgpack(e,t){if(e!=null)return this.valueSchema.fromPreparedMsgpack(e,t)}prepareJSON(e,t){return e===void 0?null:this.valueSchema.prepareJSON(e,t)}fromPreparedJSON(e){if(e!=null)return this.valueSchema.fromPreparedJSON(e)}}class nx extends Un{defaultValue(){}isDefaultValue(e){return e===void 0}prepareMsgpack(e){return e}fromPreparedMsgpack(e,t){return e}prepareJSON(e,t){return _f(e)}fromPreparedJSON(e){return Uf(e)}}function rI(n,e,t){const r=BigInt(n.appIndex),i=n.name,o=r===BigInt(0)||r===t,s=e.indexOf(r)+1;if(s===0&&!o)throw new Error(`Box ref with appId ${r} not in foreign-apps`);return new Map([["i",s],["n",i]])}function iI(n,e,t){const r=BigInt(t),i=e.map(BigInt);return n.map(o=>rI(o,i,r))}function oI(n,e){const t=[];function r(o){for(let s=0;s<t.length;s++){const a=t[s],l=a.get("d");if((!o.address&&!l||o.address&&l&&o.address.equals(l))&&a.get("s")===o.assetIndex&&a.get("p")===o.appIndex)return s+1}return o.address&&t.push(new Map([["d",o.address]])),o.assetIndex&&t.push(new Map([["s",o.assetIndex]])),o.appIndex&&t.push(new Map([["p",o.appIndex]])),t.length}const i=ze.zeroAddress();for(const o of e){if(o.address||o.assetIndex||o.appIndex){r(o);continue}if(o.holding){const s=o.holding;let a=0;s.address&&!s.address.equals(i)&&(a=r({address:s.address}));const l=r({assetIndex:s.assetIndex});t.push(new Map([["h",new Map([["d",a],["s",l]])]]));continue}if(o.locals){const s=o.locals;let a=0;s.address&&!s.address.equals(i)&&(a=r({address:s.address}));let l=0;s.appIndex&&BigInt(s.appIndex)!==n&&(l=r({appIndex:s.appIndex})),t.push(new Map([["l",new Map([["d",a],["p",l]])]]));continue}if(o.box){const s=o.box;let a=0;s.appIndex&&BigInt(s.appIndex)!==n&&(a=r({appIndex:s.appIndex})),t.push(new Map([["b",new Map([["i",a],["n",s.name]])]]))}}return t}function sI(n){const e=[];for(const t of n){const r=t.get("d"),i=t.get("s"),o=t.get("p");if(r){e.push({address:r});continue}if(i){e.push({assetIndex:i});continue}if(o){e.push({appIndex:o});continue}const s=t.get("h");if(s){const c=An(s.get("d")??0),d=An(s.get("s"));if(!d)throw new Error(`Holding missing asset index: ${s}`);const u=c===0?ze.zeroAddress():e[c-1].address,m=e[d-1].assetIndex;e.push({holding:{address:u,assetIndex:m}});continue}const a=t.get("l");if(a){const c=An(a.get("d")??0),d=An(a.get("p")??0),u=c===0?ze.zeroAddress():e[c-1].address,m=d===0?BigInt(0):e[d-1].appIndex;e.push({locals:{address:u,appIndex:m}});continue}const l=t.get("b");if(l){const c=An(l.get("i")??0),d=l.get("n");if(!d)throw new Error(`Box missing name: ${l}`);const u=c===0?BigInt(0):e[c-1].appIndex;e.push({box:{appIndex:u,name:d}})}}return e}function aI({appIndex:n,accounts:e,foreignAssets:t,foreignApps:r,holdings:i,locals:o,boxes:s}){const a=[];function l(u){let m;if(typeof u=="string"){if(u==="")return;m=ze.fromString(u)}else m=u;if(m.equals(ze.zeroAddress()))return;let h=!1;for(const x of a){if(!x.address)continue;let A=x.address;if(typeof x.address=="string"&&(A=ze.fromString(x.address)),A.equals(m)){h=!0;break}}h||a.push({address:u})}function c(u){let m=!1;for(const h of a)if(h.assetIndex===u){m=!0;break}m||a.push({assetIndex:u})}function d(u){let m=!1;for(const h of a)if(h.appIndex===u){m=!0;break}m||a.push({appIndex:u})}for(const u of e??[])l(u);for(const u of t??[])c(u);for(const u of r??[])d(u);for(const u of i??[])u.address&&l(u.address),c(u.assetIndex),a.push({holding:u});for(const u of o??[])u.address&&l(u.address),u.appIndex&&BigInt(u.appIndex)!==n&&d(u.appIndex),a.push({locals:u});for(const u of s??[])u.appIndex&&BigInt(u.appIndex)!==n&&d(u.appIndex),a.push({box:u});return a}var Bt;(function(n){n.pay="pay",n.keyreg="keyreg",n.acfg="acfg",n.axfer="axfer",n.afrz="afrz",n.appl="appl",n.stpf="stpf",n.hb="hb"})(Bt||(Bt={}));function jf(n){return n===Bt.pay||n===Bt.keyreg||n===Bt.acfg||n===Bt.axfer||n===Bt.afrz||n===Bt.appl||n===Bt.stpf||n===Bt.hb}var kn;(function(n){n[n.NoOpOC=0]="NoOpOC",n[n.OptInOC=1]="OptInOC",n[n.CloseOutOC=2]="CloseOutOC",n[n.ClearStateOC=3]="ClearStateOC",n[n.UpdateApplicationOC=4]="UpdateApplicationOC",n[n.DeleteApplicationOC=5]="DeleteApplicationOC"})(kn||(kn={}));function rx(n){return n===kn.NoOpOC||n===kn.OptInOC||n===kn.CloseOutOC||n===kn.ClearStateOC||n===kn.UpdateApplicationOC||n===kn.DeleteApplicationOC}let Yd=class Gf{constructor(e){this.hashType=e.hashType}getEncodingSchema(){return Gf.encodingSchema}toEncodingData(){return new Map([["t",this.hashType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HashFactory: ${e}`);return new Gf({hashType:Number(e.get("t"))})}};Yd.encodingSchema=new oe(rt([{key:"t",valueSchema:new O}]));let to=class Wf{constructor(e){this.path=e.path,this.hashFactory=e.hashFactory,this.treeDepth=e.treeDepth}getEncodingSchema(){return Wf.encodingSchema}toEncodingData(){return new Map([["pth",this.path],["hsh",this.hashFactory.toEncodingData()],["td",this.treeDepth]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MerkleArrayProof: ${e}`);return new Wf({path:e.get("pth"),hashFactory:Yd.fromEncodingData(e.get("hsh")),treeDepth:Number(e.get("td"))})}};to.encodingSchema=new oe(rt([{key:"pth",valueSchema:new Me(new Pe)},{key:"hsh",valueSchema:Yd.encodingSchema},{key:"td",valueSchema:new O}]));class Xo{constructor(e){this.commitment=e.commitment,this.keyLifetime=e.keyLifetime}getEncodingSchema(){return Xo.encodingSchema}toEncodingData(){return new Map([["cmt",this.commitment],["lf",this.keyLifetime]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MerkleSignatureVerifier: ${e}`);return new Xo({commitment:e.get("cmt"),keyLifetime:e.get("lf")})}}Xo.encodingSchema=new oe(rt([{key:"cmt",valueSchema:new Ht(64)},{key:"lf",valueSchema:new O}]));class Zo{constructor(e){this.pk=e.pk,this.weight=e.weight}getEncodingSchema(){return Zo.encodingSchema}toEncodingData(){return new Map([["p",this.pk.toEncodingData()],["w",this.weight]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Participant: ${e}`);return new Zo({pk:Xo.fromEncodingData(e.get("p")),weight:e.get("w")})}}Zo.encodingSchema=new oe(rt([{key:"p",valueSchema:Xo.encodingSchema},{key:"w",valueSchema:new O}]));class Jo{constructor(e){this.publicKey=e.publicKey}getEncodingSchema(){return Jo.encodingSchema}toEncodingData(){return new Map([["k",this.publicKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded FalconVerifier: ${e}`);return new Jo({publicKey:e.get("k")})}}Jo.encodingSchema=new oe(rt([{key:"k",valueSchema:new Ht(1793)}]));class Qo{constructor(e){this.signature=e.signature,this.vectorCommitmentIndex=e.index,this.proof=e.proof,this.verifyingKey=e.verifyingKey}getEncodingSchema(){return Qo.encodingSchema}toEncodingData(){return new Map([["sig",this.signature],["idx",this.vectorCommitmentIndex],["prf",this.proof.toEncodingData()],["vkey",this.verifyingKey.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded FalconSignatureStruct: ${e}`);return new Qo({signature:e.get("sig"),index:e.get("idx"),proof:to.fromEncodingData(e.get("prf")),verifyingKey:Jo.fromEncodingData(e.get("vkey"))})}}Qo.encodingSchema=new oe(rt([{key:"sig",valueSchema:new Pe},{key:"idx",valueSchema:new O},{key:"prf",valueSchema:to.encodingSchema},{key:"vkey",valueSchema:Jo.encodingSchema}]));class es{constructor(e){this.sig=e.sig,this.l=e.l}getEncodingSchema(){return es.encodingSchema}toEncodingData(){return new Map([["s",this.sig.toEncodingData()],["l",this.l]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SigslotCommit: ${e}`);return new es({sig:Qo.fromEncodingData(e.get("s")),l:e.get("l")})}}es.encodingSchema=new oe(rt([{key:"s",valueSchema:Qo.encodingSchema},{key:"l",valueSchema:new O}]));class ts{constructor(e){this.sigslot=e.sigslot,this.participant=e.participant}getEncodingSchema(){return ts.encodingSchema}toEncodingData(){return new Map([["s",this.sigslot.toEncodingData()],["p",this.participant.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Reveal: ${e}`);return new ts({sigslot:es.fromEncodingData(e.get("s")),participant:Zo.fromEncodingData(e.get("p"))})}}ts.encodingSchema=new oe(rt([{key:"s",valueSchema:es.encodingSchema},{key:"p",valueSchema:Zo.encodingSchema}]));let Kd=class zf{constructor(e){this.sigCommit=e.sigCommit,this.signedWeight=e.signedWeight,this.sigProofs=e.sigProofs,this.partProofs=e.partProofs,this.merkleSignatureSaltVersion=e.merkleSignatureSaltVersion,this.reveals=e.reveals,this.positionsToReveal=e.positionsToReveal}getEncodingSchema(){return zf.encodingSchema}toEncodingData(){return new Map([["c",this.sigCommit],["w",this.signedWeight],["S",this.sigProofs.toEncodingData()],["P",this.partProofs.toEncodingData()],["v",this.merkleSignatureSaltVersion],["r",dn(this.reveals,(e,t)=>[e,t.toEncodingData()])],["pr",this.positionsToReveal]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProof: ${e}`);return new zf({sigCommit:e.get("c"),signedWeight:e.get("w"),sigProofs:to.fromEncodingData(e.get("S")),partProofs:to.fromEncodingData(e.get("P")),merkleSignatureSaltVersion:Number(e.get("v")),reveals:dn(e.get("r"),(t,r)=>[t,ts.fromEncodingData(r)]),positionsToReveal:e.get("pr")})}};Kd.encodingSchema=new oe(rt([{key:"c",valueSchema:new Pe},{key:"w",valueSchema:new O},{key:"S",valueSchema:to.encodingSchema},{key:"P",valueSchema:to.encodingSchema},{key:"v",valueSchema:new O},{key:"r",valueSchema:new Hd(ts.encodingSchema)},{key:"pr",valueSchema:new Me(new O)}]));let qd=class Gu{constructor(e){this.blockHeadersCommitment=e.blockHeadersCommitment,this.votersCommitment=e.votersCommitment,this.lnProvenWeight=e.lnProvenWeight,this.firstAttestedRound=e.firstAttestedRound,this.lastAttestedRound=e.lastAttestedRound}getEncodingSchema(){return Gu.encodingSchema}toEncodingData(){return new Map([["b",this.blockHeadersCommitment],["v",this.votersCommitment],["P",this.lnProvenWeight],["f",this.firstAttestedRound],["l",this.lastAttestedRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofMessage: ${e}`);return new Gu({blockHeadersCommitment:e.get("b"),votersCommitment:e.get("v"),lnProvenWeight:e.get("P"),firstAttestedRound:e.get("f"),lastAttestedRound:e.get("l")})}static fromMap(e){return new Gu({blockHeadersCommitment:e.get("b"),votersCommitment:e.get("v"),lnProvenWeight:e.get("P"),firstAttestedRound:e.get("f"),lastAttestedRound:e.get("l")})}};qd.encodingSchema=new oe(rt([{key:"b",valueSchema:new Pe},{key:"v",valueSchema:new Pe},{key:"P",valueSchema:new O},{key:"f",valueSchema:new O},{key:"l",valueSchema:new O}]));class ya{constructor(e){this.sig=e.sig,this.pk=e.pk,this.pk2=e.pk2,this.pk1Sig=e.pk1Sig,this.pk2Sig=e.pk2Sig}getEncodingSchema(){return ya.encodingSchema}toEncodingData(){return new Map([["s",this.sig],["p",this.pk],["p2",this.pk2],["p1s",this.pk1Sig],["p2s",this.pk2Sig]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HeartbeatProof: ${e}`);return new ya({sig:e.get("s"),pk:e.get("p"),pk2:e.get("p2"),pk1Sig:e.get("p1s"),pk2Sig:e.get("p2s")})}}ya.encodingSchema=new oe(rt([{key:"s",valueSchema:new Ht(64)},{key:"p",valueSchema:new Ht(32)},{key:"p2",valueSchema:new Ht(32)},{key:"p1s",valueSchema:new Ht(64)},{key:"p2s",valueSchema:new Ht(64)}]));class Ji{constructor(e){this.address=e.address,this.proof=e.proof,this.seed=e.seed,this.voteID=e.voteID,this.keyDilution=e.keyDilution}getEncodingSchema(){return Ji.encodingSchema}toEncodingData(){return new Map([["a",this.address],["prf",this.proof.toEncodingData()],["sd",this.seed],["vid",this.voteID],["kd",this.keyDilution]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Heartbeat: ${e}`);return new Ji({address:e.get("a"),proof:ya.fromEncodingData(e.get("prf")),seed:e.get("sd"),voteID:e.get("vid"),keyDilution:e.get("kd")})}}Ji.encodingSchema=new oe(rt([{key:"a",valueSchema:new _t},{key:"prf",valueSchema:ya.encodingSchema},{key:"sd",valueSchema:new Pe},{key:"vid",valueSchema:new Ht(32)},{key:"kd",valueSchema:new O}]));const cI=52,lI=32,uI=75,dI=32,hI=32,fI=32,pI=64,gI=32;function ix(n){return n.every(e=>e===0)}function Rh(n,e,t){if(n==null)return;let r;if(n instanceof Uint8Array&&(r=n),r==null||r.byteLength!==t)throw Error(`${e} must be a ${t} byte Uint8Array`);return r}function ai(n){if(n==null)throw new Error("Address must not be null or undefined");if(typeof n=="string")return ze.fromString(n);if(n instanceof ze)return n;throw new Error(`Not an address: ${n}`)}function Ci(n){if(n==null)return;let e;if(n instanceof ze)e=n;else if(typeof n=="string")e=ze.fromString(n);else throw new Error(`Not an address: ${n}`);if(ix(e.publicKey))throw new Error("Invalid use of the zero address. To omit this value, pass in undefined");return e}function ox(n){if(!(typeof n>"u")){if(n instanceof Uint8Array)return n;throw new Error(`Not a Uint8Array: ${n}`)}}function Co(n){if(n instanceof Uint8Array)return n;throw new Error(`Not a Uint8Array: ${n}`)}function Bh(n){if(!(typeof n>"u"))return Wt(n)}function ku(n){if(n===!0||n===!1)return n;throw new Error(`Not a boolean: ${n}`)}function Us(n){if(Array.isArray(n))return n.slice();throw new Error(`Not an array: ${n}`)}function Ym(n,e,t){const r=ox(n);if(!(typeof r>"u")){if(r.byteLength!==e)throw new Error(`${t} must be ${e} bytes long, was ${r.byteLength}`);if(!ix(r))return r}}function sx(n){if(n!=null&&typeof n=="object"){const{appIndex:e,name:t}=n;return{appIndex:Wt(e),name:Co(t)}}throw new Error(`Not a box reference: ${n}`)}function mI(n){if(n!=null&&typeof n=="object"){const{assetIndex:e,address:t}=n;return{assetIndex:Wt(e),address:ai(t)}}throw new Error(`Not a holding reference: ${n}`)}function yI(n){if(n!=null&&typeof n=="object"){const{appIndex:e,address:t}=n;return{appIndex:Wt(e),address:ai(t)}}throw new Error(`Not a locals reference: ${n}`)}function wI(n){if(n!=null&&typeof n=="object"){const{address:e,appIndex:t,assetIndex:r,holding:i,locals:o,box:s}=n;if(e!==void 0)return{address:ai(e)};if(t!==void 0)return{appIndex:Wt(t)};if(r!==void 0)return{assetIndex:Wt(r)};if(i!==void 0)return{holding:mI(i)};if(o!==void 0)return{locals:yI(o)};if(s!==void 0)return{box:sx(s)}}throw new Error(`Not a resource reference: ${n}`)}const Km=new TextEncoder().encode("TX");let br=class Wu{constructor(e){if(!jf(e.type))throw new Error(`Invalid transaction type: ${e.type}`);if(this.type=e.type,this.sender=ai(e.sender),this.note=Co(e.note??new Uint8Array),this.lease=Ym(e.lease,lI,"lease"),this.rekeyTo=Ci(e.rekeyTo),this.group=void 0,this.firstValid=Wt(e.suggestedParams.firstValid),this.lastValid=Wt(e.suggestedParams.lastValid),e.suggestedParams.genesisID){if(typeof e.suggestedParams.genesisID!="string")throw new Error("Genesis ID must be a string if present");this.genesisID=e.suggestedParams.genesisID}this.genesisHash=ox(e.suggestedParams.genesisHash);const t=[];if(e.paymentParams&&t.push(Bt.pay),e.keyregParams&&t.push(Bt.keyreg),e.assetConfigParams&&t.push(Bt.acfg),e.assetTransferParams&&t.push(Bt.axfer),e.assetFreezeParams&&t.push(Bt.afrz),e.appCallParams&&t.push(Bt.appl),e.stateProofParams&&t.push(Bt.stpf),e.heartbeatParams&&t.push(Bt.hb),t.length!==1)throw new Error(`Transaction has wrong number of type fields present (${t.length}): ${t}`);if(this.type!==t[0])throw new Error(`Transaction has type ${this.type} but fields present for ${t[0]}`);if(e.paymentParams&&(this.payment={receiver:ai(e.paymentParams.receiver),amount:Wt(e.paymentParams.amount),closeRemainderTo:Ci(e.paymentParams.closeRemainderTo)}),e.keyregParams){if(this.keyreg={voteKey:Rh(e.keyregParams.voteKey,"voteKey",hI),selectionKey:Rh(e.keyregParams.selectionKey,"selectionKey",fI),stateProofKey:Rh(e.keyregParams.stateProofKey,"stateProofKey",pI),voteFirst:Bh(e.keyregParams.voteFirst),voteLast:Bh(e.keyregParams.voteLast),voteKeyDilution:Bh(e.keyregParams.voteKeyDilution),nonParticipation:ku(e.keyregParams.nonParticipation??!1)},this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u"))throw new Error("nonParticipation is true but participation params are present.");if(!this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u")&&!(this.keyreg.voteKey&&this.keyreg.selectionKey&&typeof this.keyreg.voteFirst<"u"&&typeof this.keyreg.voteLast<"u"&&typeof this.keyreg.voteKeyDilution<"u"))throw new Error("Online key registration missing at least one of the following fields: voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution")}if(e.assetConfigParams&&(this.assetConfig={assetIndex:Wt(e.assetConfigParams.assetIndex??0),total:Wt(e.assetConfigParams.total??0),decimals:An(e.assetConfigParams.decimals??0),defaultFrozen:ku(e.assetConfigParams.defaultFrozen??!1),manager:Ci(e.assetConfigParams.manager),reserve:Ci(e.assetConfigParams.reserve),freeze:Ci(e.assetConfigParams.freeze),clawback:Ci(e.assetConfigParams.clawback),unitName:e.assetConfigParams.unitName,assetName:e.assetConfigParams.assetName,assetURL:e.assetConfigParams.assetURL,assetMetadataHash:Ym(e.assetConfigParams.assetMetadataHash,dI,"assetMetadataHash")}),e.assetTransferParams&&(this.assetTransfer={assetIndex:Wt(e.assetTransferParams.assetIndex),amount:Wt(e.assetTransferParams.amount),assetSender:Ci(e.assetTransferParams.assetSender),receiver:ai(e.assetTransferParams.receiver),closeRemainderTo:Ci(e.assetTransferParams.closeRemainderTo)}),e.assetFreezeParams&&(this.assetFreeze={assetIndex:Wt(e.assetFreezeParams.assetIndex),freezeAccount:ai(e.assetFreezeParams.freezeTarget),frozen:ku(e.assetFreezeParams.frozen)}),e.appCallParams){const{onComplete:i}=e.appCallParams;if(!rx(i))throw new Error(`Invalid onCompletion value: ${i}`);this.applicationCall={appIndex:Wt(e.appCallParams.appIndex),onComplete:i,numLocalInts:An(e.appCallParams.numLocalInts??0),numLocalByteSlices:An(e.appCallParams.numLocalByteSlices??0),numGlobalInts:An(e.appCallParams.numGlobalInts??0),numGlobalByteSlices:An(e.appCallParams.numGlobalByteSlices??0),extraPages:An(e.appCallParams.extraPages??0),approvalProgram:Co(e.appCallParams.approvalProgram??new Uint8Array),clearProgram:Co(e.appCallParams.clearProgram??new Uint8Array),appArgs:Us(e.appCallParams.appArgs??[]).map(Co),accounts:Us(e.appCallParams.accounts??[]).map(ai),foreignApps:Us(e.appCallParams.foreignApps??[]).map(Wt),foreignAssets:Us(e.appCallParams.foreignAssets??[]).map(Wt),boxes:Us(e.appCallParams.boxes??[]).map(sx),access:Us(e.appCallParams.access??[]).map(wI),rejectVersion:An(e.appCallParams.rejectVersion??0)}}if(e.stateProofParams&&(this.stateProof={stateProofType:An(e.stateProofParams.stateProofType??0),stateProof:e.stateProofParams.stateProof,message:e.stateProofParams.message}),e.heartbeatParams&&(this.heartbeat=new Ji({address:e.heartbeatParams.address,proof:e.heartbeatParams.proof,seed:e.heartbeatParams.seed,voteID:e.heartbeatParams.voteID,keyDilution:e.heartbeatParams.keyDilution})),this.fee=Wt(e.suggestedParams.fee),!ku(e.suggestedParams.flatFee??!1)){const i=Wt(e.suggestedParams.minFee);this.fee*=BigInt(this.estimateSize()),this.fee<i&&(this.fee=i)}}getEncodingSchema(){return Wu.encodingSchema}toEncodingData(){const e=new Map([["type",this.type],["fv",this.firstValid],["lv",this.lastValid],["snd",this.sender],["gen",this.genesisID],["gh",this.genesisHash],["fee",this.fee],["note",this.note],["lx",this.lease],["rekey",this.rekeyTo],["grp",this.group]]);if(this.payment)return e.set("amt",this.payment.amount),e.set("rcv",this.payment.receiver),e.set("close",this.payment.closeRemainderTo),e;if(this.keyreg)return e.set("votekey",this.keyreg.voteKey),e.set("selkey",this.keyreg.selectionKey),e.set("sprfkey",this.keyreg.stateProofKey),e.set("votefst",this.keyreg.voteFirst),e.set("votelst",this.keyreg.voteLast),e.set("votekd",this.keyreg.voteKeyDilution),e.set("nonpart",this.keyreg.nonParticipation),e;if(this.assetConfig){e.set("caid",this.assetConfig.assetIndex);const t=new Map([["t",this.assetConfig.total],["dc",this.assetConfig.decimals],["df",this.assetConfig.defaultFrozen],["m",this.assetConfig.manager],["r",this.assetConfig.reserve],["f",this.assetConfig.freeze],["c",this.assetConfig.clawback],["un",this.assetConfig.unitName],["an",this.assetConfig.assetName],["au",this.assetConfig.assetURL],["am",this.assetConfig.assetMetadataHash]]);return e.set("apar",t),e}if(this.assetTransfer)return e.set("xaid",this.assetTransfer.assetIndex),e.set("aamt",this.assetTransfer.amount),e.set("arcv",this.assetTransfer.receiver),e.set("aclose",this.assetTransfer.closeRemainderTo),e.set("asnd",this.assetTransfer.assetSender),e;if(this.assetFreeze)return e.set("faid",this.assetFreeze.assetIndex),e.set("afrz",this.assetFreeze.frozen),e.set("fadd",this.assetFreeze.freezeAccount),e;if(this.applicationCall)return e.set("apid",this.applicationCall.appIndex),e.set("apan",this.applicationCall.onComplete),e.set("apaa",this.applicationCall.appArgs),e.set("apat",this.applicationCall.accounts),e.set("apas",this.applicationCall.foreignAssets),e.set("apfa",this.applicationCall.foreignApps),e.set("apbx",iI(this.applicationCall.boxes,this.applicationCall.foreignApps,this.applicationCall.appIndex)),e.set("al",oI(this.applicationCall.appIndex,this.applicationCall.access)),e.set("apap",this.applicationCall.approvalProgram),e.set("apsu",this.applicationCall.clearProgram),e.set("apls",new Map([["nui",this.applicationCall.numLocalInts],["nbs",this.applicationCall.numLocalByteSlices]])),e.set("apgs",new Map([["nui",this.applicationCall.numGlobalInts],["nbs",this.applicationCall.numGlobalByteSlices]])),e.set("apep",this.applicationCall.extraPages),e.set("aprv",this.applicationCall.rejectVersion),e;if(this.stateProof)return e.set("sptype",this.stateProof.stateProofType),e.set("sp",this.stateProof.stateProof?this.stateProof.stateProof.toEncodingData():void 0),e.set("spmsg",this.stateProof.message?this.stateProof.message.toEncodingData():void 0),e;if(this.heartbeat){const t=new Ji({address:this.heartbeat.address,proof:this.heartbeat.proof,seed:this.heartbeat.seed,voteID:this.heartbeat.voteID,keyDilution:this.heartbeat.keyDilution});return e.set("hb",t.toEncodingData()),e}throw new Error(`Unexpected transaction type: ${this.type}`)}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded logic sig account: ${e}`);const t={minFee:BigInt(0),flatFee:!0,fee:e.get("fee")??0,firstValid:e.get("fv")??0,lastValid:e.get("lv")??0,genesisHash:e.get("gh"),genesisID:e.get("gen")},r=e.get("type");if(!jf(r))throw new Error(`Unrecognized transaction type: ${r}`);const i={type:r,sender:e.get("snd")??ze.zeroAddress(),note:e.get("note"),lease:e.get("lx"),suggestedParams:t};if(e.get("rekey")&&(i.rekeyTo=e.get("rekey")),i.type===Bt.pay){const s={amount:e.get("amt")??0,receiver:e.get("rcv")??ze.zeroAddress()};e.get("close")&&(s.closeRemainderTo=e.get("close")),i.paymentParams=s}else if(i.type===Bt.keyreg){const s={voteKey:e.get("votekey"),selectionKey:e.get("selkey"),stateProofKey:e.get("sprfkey"),voteFirst:e.get("votefst"),voteLast:e.get("votelst"),voteKeyDilution:e.get("votekd"),nonParticipation:e.get("nonpart")};i.keyregParams=s}else if(i.type===Bt.acfg){const s={assetIndex:e.get("caid")};if(e.get("apar")){const a=e.get("apar");s.total=a.get("t"),s.decimals=a.get("dc"),s.defaultFrozen=a.get("df"),s.unitName=a.get("un"),s.assetName=a.get("an"),s.assetURL=a.get("au"),s.assetMetadataHash=a.get("am"),a.get("m")&&(s.manager=a.get("m")),a.get("r")&&(s.reserve=a.get("r")),a.get("f")&&(s.freeze=a.get("f")),a.get("c")&&(s.clawback=a.get("c"))}i.assetConfigParams=s}else if(i.type===Bt.axfer){const s={assetIndex:e.get("xaid")??0,amount:e.get("aamt")??0,receiver:e.get("arcv")??ze.zeroAddress()};e.get("aclose")&&(s.closeRemainderTo=e.get("aclose")),e.get("asnd")&&(s.assetSender=e.get("asnd")),i.assetTransferParams=s}else if(i.type===Bt.afrz){const s={assetIndex:e.get("faid")??0,freezeTarget:e.get("fadd")??ze.zeroAddress(),frozen:e.get("afrz")??!1};i.assetFreezeParams=s}else if(i.type===Bt.appl){const s={appIndex:e.get("apid")??0,onComplete:An(e.get("apan")??0),appArgs:e.get("apaa"),accounts:e.get("apat"),foreignAssets:e.get("apas"),foreignApps:e.get("apfa"),approvalProgram:e.get("apap"),clearProgram:e.get("apsu"),extraPages:e.get("apep"),rejectVersion:e.get("aprv")??0},a=e.get("apls");a&&(s.numLocalInts=a.get("nui"),s.numLocalByteSlices=a.get("nbs"));const l=e.get("apgs");l&&(s.numGlobalInts=l.get("nui"),s.numGlobalByteSlices=l.get("nbs"));const c=e.get("apbx");c&&(s.boxes=c.map(u=>{const m=An(u.get("i")??0),h=Co(u.get("n")??new Uint8Array);if(m===0)return{appIndex:0,name:h};if(!s.foreignApps||m>s.foreignApps.length)throw new Error(`Cannot find foreign app index ${m} in ${s.foreignApps}`);return{appIndex:s.foreignApps[m-1],name:h}}));const d=e.get("al");d&&(s.access=sI(d)),i.appCallParams=s}else if(i.type===Bt.stpf){const s={stateProofType:e.get("sptype"),stateProof:e.get("sp")?Kd.fromEncodingData(e.get("sp")):void 0,message:e.get("spmsg")?qd.fromEncodingData(e.get("spmsg")):void 0};i.stateProofParams=s}else if(i.type===Bt.hb){const s=Ji.fromEncodingData(e.get("hb")),a={address:s.address,proof:s.proof,seed:s.seed,voteID:s.voteID,keyDilution:s.keyDilution};i.heartbeatParams=a}else{const s=i.type;throw new Error(`Unexpected transaction type: ${s}`)}const o=new Wu(i);if(e.get("grp")){const s=Co(e.get("grp"));if(s.byteLength!==gI)throw new Error(`Invalid group length: ${s.byteLength}`);o.group=s}return o}estimateSize(){return this.toByte().length+uI}bytesToSign(){const e=this.toByte();return hn(Km,e)}toByte(){return Sr(this)}rawSignTxn(e){const t=this.bytesToSign();return ll(t,e)}signTxn(e){const t=jd(e),r=new ze(t.publicKey),i=this.rawSignTxn(e);return this.attachSignature(r,i)}attachSignature(e,t){if(!$0(t.length))throw new Error("Invalid signature length");const r=new Map([["sig",t],["txn",this.toEncodingData()]]),i=ai(e);this.sender.equals(i)||r.set("sgnr",i);const o=new oe(rt([{key:"txn",valueSchema:Wu.encodingSchema},{key:"sig",valueSchema:new Ht(64)},{key:"sgnr",valueSchema:new k(new _t)}]));return du(o.prepareMsgpack(r))}rawTxID(){const e=this.toByte(),t=hn(Km,e);return Uint8Array.from(wi(t))}txID(){const e=this.rawTxID();return ul.encode(e).slice(0,cI)}};br.encodingSchema=new oe(rt([{key:"type",valueSchema:new Ce},{key:"snd",valueSchema:new _t},{key:"lv",valueSchema:new O},{key:"gen",valueSchema:new k(new Ce)},{key:"gh",valueSchema:new k(new Ht(32))},{key:"fee",valueSchema:new O},{key:"fv",valueSchema:new O},{key:"note",valueSchema:new Pe},{key:"lx",valueSchema:new k(new Ht(32))},{key:"rekey",valueSchema:new k(new _t)},{key:"grp",valueSchema:new k(new Ht(32))},{key:"amt",valueSchema:new k(new O)},{key:"rcv",valueSchema:new k(new _t)},{key:"close",valueSchema:new k(new _t)},{key:"votekey",valueSchema:new k(new Ht(32))},{key:"selkey",valueSchema:new k(new Ht(32))},{key:"sprfkey",valueSchema:new k(new Ht(64))},{key:"votefst",valueSchema:new k(new O)},{key:"votelst",valueSchema:new k(new O)},{key:"votekd",valueSchema:new k(new O)},{key:"nonpart",valueSchema:new k(new gt)},{key:"caid",valueSchema:new k(new O)},{key:"apar",valueSchema:new k(new oe(rt([{key:"t",valueSchema:new O},{key:"dc",valueSchema:new O},{key:"df",valueSchema:new gt},{key:"m",valueSchema:new k(new _t)},{key:"r",valueSchema:new k(new _t)},{key:"f",valueSchema:new k(new _t)},{key:"c",valueSchema:new k(new _t)},{key:"un",valueSchema:new k(new Ce)},{key:"an",valueSchema:new k(new Ce)},{key:"au",valueSchema:new k(new Ce)},{key:"am",valueSchema:new k(new Ht(32))}])))},{key:"xaid",valueSchema:new k(new O)},{key:"aamt",valueSchema:new k(new O)},{key:"arcv",valueSchema:new k(new _t)},{key:"aclose",valueSchema:new k(new _t)},{key:"asnd",valueSchema:new k(new _t)},{key:"faid",valueSchema:new k(new O)},{key:"afrz",valueSchema:new k(new gt)},{key:"fadd",valueSchema:new k(new _t)},{key:"apid",valueSchema:new k(new O)},{key:"apan",valueSchema:new k(new O)},{key:"apaa",valueSchema:new k(new Me(new Pe))},{key:"apat",valueSchema:new k(new Me(new _t))},{key:"apas",valueSchema:new k(new Me(new O))},{key:"apfa",valueSchema:new k(new Me(new O))},{key:"apbx",valueSchema:new k(new Me(new oe(rt([{key:"i",valueSchema:new O},{key:"n",valueSchema:new Pe}]))))},{key:"al",valueSchema:new k(new Me(new oe(rt([{key:"d",valueSchema:new k(new _t)},{key:"s",valueSchema:new k(new O)},{key:"p",valueSchema:new k(new O)},{key:"h",valueSchema:new k(new oe(rt([{key:"d",valueSchema:new O},{key:"s",valueSchema:new O}])))},{key:"l",valueSchema:new k(new oe(rt([{key:"d",valueSchema:new O},{key:"p",valueSchema:new O}])))},{key:"b",valueSchema:new k(new oe(rt([{key:"i",valueSchema:new O},{key:"n",valueSchema:new Pe}])))}]))))},{key:"apap",valueSchema:new k(new Pe)},{key:"apsu",valueSchema:new k(new Pe)},{key:"apls",valueSchema:new k(new oe(rt([{key:"nui",valueSchema:new O},{key:"nbs",valueSchema:new O}])))},{key:"apgs",valueSchema:new k(new oe(rt([{key:"nui",valueSchema:new O},{key:"nbs",valueSchema:new O}])))},{key:"apep",valueSchema:new k(new O)},{key:"aprv",valueSchema:new k(new O)},{key:"sptype",valueSchema:new k(new O)},{key:"sp",valueSchema:new k(Kd.encodingSchema)},{key:"spmsg",valueSchema:new k(qd.encodingSchema)},{key:"hb",valueSchema:new k(Ji.encodingSchema)}]));function xI(n){return Sr(n)}function vI(n){return Xt(n,br)}const jc=new Uint8Array([77,117,108,116,105,115,105,103,65,100,100,114]),SI="invalid multisig version",bI="bad multisig threshold",EI="bad multisig public key - wrong length",AI="nacl public key length is not 32 bytes";function Tc(n){return n.map(e=>typeof e=="string"?ze.fromString(e).publicKey:e.publicKey)}function xi({version:n,threshold:e,pks:t}){if(n!==1||n>255||n<0)throw new Error(SI);if(e===0||t.length===0||e>t.length||e>255)throw new Error(bI);const r=ko-Jc;if(r!==U0)throw new Error(AI);const i=new Uint8Array(jc.length+2+r*t.length);i.set(jc,0),i.set([n],jc.length),i.set([e],jc.length+1);for(let o=0;o<t.length;o++){if(t[o].length!==r)throw new Error(EI);i.set(t[o],jc.length+2+o*r)}return new ze(Uint8Array.from(wi(i)))}function II({version:n,threshold:e,addrs:t}){const r=Tc(t);return xi({version:n,threshold:e,pks:r})}function Hf(n,e,t){const r=e.v,i=e.thr,o=e.subsig,s=o.map(d=>d.pk);if(e.subsig.length<i)return!1;let a;try{a=xi({version:r,threshold:i,pks:s}).publicKey}catch{return!1}if(!Kr(a,t))return!1;let l=0;for(const d of o)d.s!==void 0&&(l+=1);if(l<i)return!1;let c=0;for(const d of o)d.s!==void 0&&Gd(n,d.s,d.pk)&&(c+=1);return!(c<i)}function kI({version:n,threshold:e,addrs:t}){return II({version:n,threshold:e,addrs:t})}const ax=new oe(rt([{key:"pk",valueSchema:new Ht(32)},{key:"s",valueSchema:new k(new Ht(64))}]));function cx(n){if(!(n instanceof Map))throw new Error(`Invalid decoded EncodedSubsig: ${n}`);const e={pk:n.get("pk")};return n.get("s")&&(e.s=n.get("s")),e}function lx(n){const e=new Map([["pk",n.pk]]);return n.s&&e.set("s",n.s),e}const fd=new oe(rt([{key:"v",valueSchema:new O},{key:"thr",valueSchema:new O},{key:"subsig",valueSchema:new Me(ax)}]));function pd(n){if(!(n instanceof Map))throw new Error(`Invalid decoded EncodedMultiSig: ${n}`);return{v:An(n.get("v")),thr:An(n.get("thr")),subsig:n.get("subsig").map(cx)}}function gd(n){return new Map([["v",n.v],["thr",n.thr],["subsig",n.subsig.map(lx)]])}const CI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;function qm(n){if(!n||n.length===0)throw new Error("empty program");const e=10,t=32,r=126,i=s=>t<=s&&s<=r;if(n.every(s=>s===e||i(s))){const s=new TextDecoder().decode(n);throw z0(s)?new Error("requesting program bytes, get Algorand address"):CI.test(s)?new Error("program should not be b64 encoded"):new Error("program bytes are all ASCII printable characters, not looking like Teal byte code")}}const Nh=new TextEncoder().encode("Program"),Xm=new TextEncoder().encode("MsigProgram");class rr{constructor(e,t){if(t&&(!Array.isArray(t)||!t.every(i=>i.constructor===Uint8Array)))throw new TypeError("Invalid arguments");let r=[];t!=null&&(r=t.map(i=>new Uint8Array(i))),qm(e),this.logic=e,this.args=r,this.sig=void 0,this.msig=void 0,this.lmsig=void 0}getEncodingSchema(){return rr.encodingSchema}toEncodingData(){const e=new Map([["l",this.logic],["arg",this.args],["sig",this.sig]]);return this.msig&&e.set("msig",gd(this.msig)),this.lmsig&&e.set("lmsig",gd(this.lmsig)),e}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded logic sig: ${e}`);const t=new rr(e.get("l"),e.get("arg"));return t.sig=e.get("sig"),e.get("msig")&&(t.msig=pd(e.get("msig"))),e.get("lmsig")&&(t.lmsig=pd(e.get("lmsig"))),t}verify(e){if([this.sig,this.msig,this.lmsig].filter(Boolean).length>1)return!1;try{qm(this.logic)}catch{return!1}const r=hn(Nh,this.logic);if(!this.sig&&!this.msig&&!this.lmsig){const i=wi(r);return Kr(i,e)}if(this.sig)return Gd(r,this.sig,e);if(this.lmsig){const i=xi({version:this.lmsig.v,threshold:this.lmsig.thr,pks:this.lmsig.subsig.map(s=>s.pk)}),o=hn(Xm,i.publicKey,this.logic);return Hf(o,this.lmsig,e)}return this.msig?Hf(r,this.msig,e):!1}address(){const e=hn(Nh,this.logic),t=wi(e);return new ze(Uint8Array.from(t))}sign(e,t){if(t==null)this.sig=this.signProgram(e);else{const r=Tc(t.addrs).map(s=>({pk:s}));this.lmsig={v:t.version,thr:t.threshold,subsig:r};const[i,o]=this.singleSignMultisig(e,this.lmsig);this.lmsig.subsig[o].s=i}}appendToMultisig(e){if(this.lmsig===void 0)throw new Error("no multisig present");const[t,r]=this.singleSignMultisig(e,this.lmsig);this.lmsig.subsig[r].s=t}signProgram(e){const t=hn(Nh,this.logic);return ll(t,e)}signProgramMultisig(e,t){const r=xi({version:t.v,threshold:t.thr,pks:t.subsig.map(s=>s.pk)}),i=hn(Xm,r.publicKey,this.logic);return ll(i,e)}singleSignMultisig(e,t){let r=-1;const i=jd(e).publicKey;for(let s=0;s<t.subsig.length;s++){const{pk:a}=t.subsig[s];if(Kr(a,i)){r=s;break}}if(r===-1)throw new Error("invalid secret key");return[this.signProgramMultisig(e,t),r]}toByte(){return Sr(this)}static fromByte(e){return Xt(e,rr)}}rr.encodingSchema=new oe(rt([{key:"l",valueSchema:new Pe},{key:"arg",valueSchema:new Me(new Pe)},{key:"sig",valueSchema:new k(new Ht(64))},{key:"msig",valueSchema:new k(fd)},{key:"lmsig",valueSchema:new k(fd)}]));let dg=class zu{constructor(e,t){this.lsig=new rr(e,t),this.sigkey=void 0}getEncodingSchema(){return zu.encodingSchema}toEncodingData(){return new Map([["lsig",this.lsig.toEncodingData()],["sigkey",this.sigkey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded logic sig account: ${e}`);const t=e,r=rr.fromEncodingData(t.get("lsig")),i=new zu(r.logic,r.args);return i.lsig=r,i.sigkey=t.get("sigkey"),i}toByte(){return Sr(this)}static fromByte(e){return Xt(e,zu)}isDelegated(){return!!(this.lsig.sig||this.lsig.msig||this.lsig.lmsig)}verify(){const e=this.address();return this.lsig.verify(e.publicKey)}address(){if([this.lsig.sig,this.lsig.msig,this.lsig.lmsig].filter(Boolean).length>1)throw new Error("LogicSig has too many signatures. At most one of sig, msig, or lmsig may be present");if(this.lsig.sig){if(!this.sigkey)throw new Error("Signing key for delegated account is missing");return new ze(this.sigkey)}const t=this.lsig.lmsig||this.lsig.msig;if(t){const r={version:t.v,threshold:t.thr,pks:t.subsig.map(i=>i.pk)};return xi(r)}return this.lsig.address()}signMultisig(e,t){this.lsig.sign(t,e)}appendToMultisig(e){this.lsig.appendToMultisig(e)}sign(e){this.lsig.sign(e),this.sigkey=jd(e).publicKey}};dg.encodingSchema=new oe(rt([{key:"lsig",valueSchema:rr.encodingSchema},{key:"sigkey",valueSchema:new k(new Ht(32))}]));function FI(n){return Xt(n,rr)}const ux=new TextEncoder().encode("ProgData");function dx(n,e,t){const r=typeof t=="string"?ze.fromString(t):t,i=hn(r.publicKey,e),o=hn(ux,i);return ll(o,n)}function DI(n,e,t,r){const i=typeof e=="string"?ze.fromString(e):e,o=hn(i.publicKey,n),s=hn(ux,o);return Gd(s,t,r)}function TI(n,e,t){const i=new rr(t).address();return dx(n,e,i)}class jt{constructor({txn:e,sig:t,msig:r,lsig:i,sgnr:o}){this.txn=e,this.sig=t,this.msig=r,this.lsig=i,this.sgnr=o;let s=0;if(t&&(s+=1),r&&(s+=1),i&&(s+=1),s>1)throw new Error(`SignedTransaction must not have more than 1 signature. Got ${s}`)}getEncodingSchema(){return jt.encodingSchema}toEncodingData(){return new Map([["txn",this.txn.toEncodingData()],["sig",this.sig],["msig",this.msig?gd(this.msig):void 0],["lsig",this.lsig?this.lsig.toEncodingData():void 0],["sgnr",this.sgnr]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SignedTransaction: ${e}`);return new jt({txn:br.fromEncodingData(e.get("txn")),sig:e.get("sig"),msig:e.get("msig")?pd(e.get("msig")):void 0,lsig:e.get("lsig")?rr.fromEncodingData(e.get("lsig")):void 0,sgnr:e.get("sgnr")})}}jt.encodingSchema=new oe(rt([{key:"txn",valueSchema:br.encodingSchema},{key:"sig",valueSchema:new k(new Ht(64))},{key:"msig",valueSchema:new k(fd)},{key:"lsig",valueSchema:new k(rr.encodingSchema)},{key:"sgnr",valueSchema:new k(new _t)}]));function MI(n){return Xt(n,jt)}function hx(n){const e=new jt({txn:n});return Sr(e)}class ns{constructor(e){this.stateProofVotersCommitment=e.stateProofVotersCommitment,this.stateProofOnlineTotalWeight=e.stateProofOnlineTotalWeight,this.stateProofNextRound=e.stateProofNextRound}getEncodingSchema(){return ns.encodingSchema}toEncodingData(){return new Map([["v",this.stateProofVotersCommitment],["t",this.stateProofOnlineTotalWeight],["n",this.stateProofNextRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofTrackingData: ${e}`);return new ns({stateProofVotersCommitment:e.get("v"),stateProofOnlineTotalWeight:e.get("t"),stateProofNextRound:e.get("n")})}}ns.encodingSchema=new oe(rt([{key:"v",valueSchema:new Pe},{key:"t",valueSchema:new O},{key:"n",valueSchema:new O}]));class rs{constructor(e){this.nativeSha512_256Commitment=e.nativeSha512_256Commitment,this.sha256Commitment=e.sha256Commitment}getEncodingSchema(){return rs.encodingSchema}toEncodingData(){return new Map([["txn",this.nativeSha512_256Commitment],["txn256",this.sha256Commitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TxnCommitments: ${e}`);return new rs({nativeSha512_256Commitment:e.get("txn"),sha256Commitment:e.get("txn256")})}}rs.encodingSchema=new oe(rt([{key:"txn",valueSchema:new Ht(32)},{key:"txn256",valueSchema:new Ht(32)}]));class is{constructor(e){this.feeSink=e.feeSink,this.rewardsPool=e.rewardsPool,this.rewardsLevel=e.rewardsLevel,this.rewardsRate=e.rewardsRate,this.rewardsResidue=e.rewardsResidue,this.rewardsRecalculationRound=e.rewardsRecalculationRound}getEncodingSchema(){return is.encodingSchema}toEncodingData(){return new Map([["fees",this.feeSink],["rwd",this.rewardsPool],["earn",this.rewardsLevel],["rate",this.rewardsRate],["frac",this.rewardsResidue],["rwcalr",this.rewardsRecalculationRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded RewardState: ${e}`);return new is({feeSink:e.get("fees"),rewardsPool:e.get("rwd"),rewardsLevel:e.get("earn"),rewardsRate:e.get("rate"),rewardsResidue:e.get("frac"),rewardsRecalculationRound:e.get("rwcalr")})}}is.encodingSchema=new oe(rt([{key:"fees",valueSchema:new _t},{key:"rwd",valueSchema:new _t},{key:"earn",valueSchema:new O},{key:"rate",valueSchema:new O},{key:"frac",valueSchema:new O},{key:"rwcalr",valueSchema:new O}]));class os{constructor(e){this.currentProtocol=e.currentProtocol,this.nextProtocol=e.nextProtocol,this.nextProtocolApprovals=e.nextProtocolApprovals,this.nextProtocolVoteBefore=e.nextProtocolVoteBefore,this.nextProtocolSwitchOn=e.nextProtocolSwitchOn}getEncodingSchema(){return os.encodingSchema}toEncodingData(){return new Map([["proto",this.currentProtocol],["nextproto",this.nextProtocol],["nextyes",this.nextProtocolApprovals],["nextbefore",this.nextProtocolVoteBefore],["nextswitch",this.nextProtocolSwitchOn]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded UpgradeState: ${e}`);return new os({currentProtocol:e.get("proto"),nextProtocol:e.get("nextproto"),nextProtocolApprovals:e.get("nextyes"),nextProtocolVoteBefore:e.get("nextbefore"),nextProtocolSwitchOn:e.get("nextswitch")})}}os.encodingSchema=new oe(rt([{key:"proto",valueSchema:new Ce},{key:"nextproto",valueSchema:new Ce},{key:"nextyes",valueSchema:new O},{key:"nextbefore",valueSchema:new O},{key:"nextswitch",valueSchema:new O}]));class ss{constructor(e){this.upgradePropose=e.upgradePropose,this.upgradeDelay=e.upgradeDelay,this.upgradeApprove=e.upgradeApprove}getEncodingSchema(){return ss.encodingSchema}toEncodingData(){return new Map([["upgradeprop",this.upgradePropose],["upgradedelay",this.upgradeDelay],["upgradeyes",this.upgradeApprove]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded UpgradeVote: ${e}`);return new ss({upgradePropose:e.get("upgradeprop"),upgradeDelay:e.get("upgradedelay"),upgradeApprove:e.get("upgradeyes")})}}ss.encodingSchema=new oe(rt([{key:"upgradeprop",valueSchema:new Ce},{key:"upgradedelay",valueSchema:new O},{key:"upgradeyes",valueSchema:new gt}]));let Xd=class Yf{constructor(e){this.expiredParticipationAccounts=e.expiredParticipationAccounts,this.absentParticipationAccounts=e.absentParticipationAccounts}getEncodingSchema(){return Yf.encodingSchema}toEncodingData(){return new Map([["partupdrmv",this.expiredParticipationAccounts],["partupdabs",this.absentParticipationAccounts]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ParticipationUpdates: ${e}`);return new Yf({expiredParticipationAccounts:e.get("partupdrmv"),absentParticipationAccounts:e.get("partupdabs")})}};Xd.encodingSchema=new oe(rt([{key:"partupdrmv",valueSchema:new Me(new _t)},{key:"partupdabs",valueSchema:new Me(new _t)}]));class vi{constructor(e){this.round=e.round,this.branch=e.branch,this.seed=e.seed,this.txnCommitments=e.txnCommitments,this.timestamp=e.timestamp,this.genesisID=e.genesisID,this.genesisHash=e.genesisHash,this.proposer=e.proposer,this.feesCollected=e.feesCollected,this.bonus=e.bonus,this.proposerPayout=e.proposerPayout,this.rewardState=e.rewardState,this.upgradeState=e.upgradeState,this.upgradeVote=e.upgradeVote,this.txnCounter=e.txnCounter,this.stateproofTracking=e.stateproofTracking,this.participationUpdates=e.participationUpdates}getEncodingSchema(){return vi.encodingSchema}toEncodingData(){const e=new Map([["rnd",this.round],["prev",this.branch],["seed",this.seed],["ts",this.timestamp],["gen",this.genesisID],["gh",this.genesisHash],["prp",this.proposer],["fc",this.feesCollected],["bi",this.bonus],["pp",this.proposerPayout],["tc",this.txnCounter],["spt",dn(this.stateproofTracking,(t,r)=>[t,r.toEncodingData()])]]);return Dc(e,this.txnCommitments.toEncodingData(),this.rewardState.toEncodingData(),this.upgradeState.toEncodingData(),this.upgradeVote.toEncodingData(),this.participationUpdates.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHeader: ${e}`);return new vi({round:e.get("rnd"),branch:e.get("prev"),seed:e.get("seed"),txnCommitments:rs.fromEncodingData(e),timestamp:e.get("ts"),genesisID:e.get("gen"),genesisHash:e.get("gh"),proposer:e.get("prp"),feesCollected:e.get("fc"),bonus:e.get("bi"),proposerPayout:e.get("pp"),rewardState:is.fromEncodingData(e),upgradeState:os.fromEncodingData(e),upgradeVote:ss.fromEncodingData(e),txnCounter:e.get("tc"),stateproofTracking:dn(e.get("spt"),(t,r)=>[Number(t),ns.fromEncodingData(r)]),participationUpdates:Xd.fromEncodingData(e)})}}vi.encodingSchema=new oe(rt([{key:"rnd",valueSchema:new O},{key:"prev",valueSchema:new tI},{key:"seed",valueSchema:new Pe},{key:"",valueSchema:rs.encodingSchema,embedded:!0},{key:"ts",valueSchema:new O},{key:"gen",valueSchema:new Ce},{key:"gh",valueSchema:new Ht(32)},{key:"prp",valueSchema:new _t},{key:"fc",valueSchema:new O},{key:"bi",valueSchema:new O},{key:"pp",valueSchema:new O},{key:"",valueSchema:is.encodingSchema,embedded:!0},{key:"",valueSchema:os.encodingSchema,embedded:!0},{key:"",valueSchema:ss.encodingSchema,embedded:!0},{key:"tc",valueSchema:new O},{key:"spt",valueSchema:new Hd(ns.encodingSchema)},{key:"",valueSchema:Xd.encodingSchema,embedded:!0}]));class di{constructor(e){this.action=e.action,this.bytes=e.bytes,this.uint=e.uint}getEncodingSchema(){return di.encodingSchema}toEncodingData(){return new Map([["at",this.action],["bs",this.bytes],["ui",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ValueDelta: ${e}`);return new di({action:Number(e.get("at")),bytes:e.get("bs"),uint:e.get("ui")})}}di.encodingSchema=new oe(rt([{key:"at",valueSchema:new O},{key:"bs",valueSchema:new Js},{key:"ui",valueSchema:new O}]));let Kf=class qf{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries(...rt([{key:"gd",valueSchema:new k(new dl(di.encodingSchema))},{key:"ld",valueSchema:new k(new Hd(new dl(di.encodingSchema)))},{key:"sa",valueSchema:new k(new Me(new _t))},{key:"lg",valueSchema:new k(new Me(new Js))},{key:"itx",valueSchema:new k(new Me(no.encodingSchema))}]))),this.encodingSchemaValue}constructor(e){this.globalDelta=e.globalDelta??new Map,this.localDeltas=e.localDeltas??new Map,this.sharedAccts=e.sharedAccts??[],this.logs=e.logs??[],this.innerTxns=e.innerTxns??[]}getEncodingSchema(){return qf.encodingSchema}toEncodingData(){return new Map([["gd",dn(this.globalDelta,(e,t)=>[e,t.toEncodingData()])],["ld",dn(this.localDeltas,(e,t)=>[e,dn(t,(r,i)=>[r,i.toEncodingData()])])],["sa",this.sharedAccts],["lg",this.logs],["itx",this.innerTxns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${e}`);return new qf({globalDelta:e.get("gd")?dn(e.get("gd"),(t,r)=>[t,di.fromEncodingData(r)]):void 0,localDeltas:e.get("ld")?dn(e.get("ld"),(t,r)=>[Number(t),dn(r,(i,o)=>[i,di.fromEncodingData(o)])]):void 0,sharedAccts:e.get("sa"),logs:e.get("lg"),innerTxns:(e.get("itx")??[]).map(no.fromEncodingData)})}};class wa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries(...rt([{key:"ca",valueSchema:new k(new O)},{key:"aca",valueSchema:new k(new O)},{key:"rs",valueSchema:new k(new O)},{key:"rr",valueSchema:new k(new O)},{key:"rc",valueSchema:new k(new O)},{key:"dt",valueSchema:new k(Kf.encodingSchema)},{key:"caid",valueSchema:new k(new O)},{key:"apid",valueSchema:new k(new O)}]))),this.encodingSchemaValue}constructor(e){this.closingAmount=e.closingAmount,this.assetClosingAmount=e.assetClosingAmount,this.senderRewards=e.senderRewards,this.receiverRewards=e.receiverRewards,this.closeRewards=e.closeRewards,this.evalDelta=e.evalDelta,this.configAsset=e.configAsset,this.applicationID=e.applicationID}getEncodingSchema(){return wa.encodingSchema}toEncodingData(){return new Map([["ca",this.closingAmount],["aca",this.assetClosingAmount],["rs",this.senderRewards],["rr",this.receiverRewards],["rc",this.closeRewards],["dt",this.evalDelta?this.evalDelta.toEncodingData():void 0],["caid",this.configAsset],["apid",this.applicationID]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplyData: ${e}`);return new wa({closingAmount:e.get("ca"),assetClosingAmount:e.get("aca"),senderRewards:e.get("rs"),receiverRewards:e.get("rr"),closeRewards:e.get("rc"),evalDelta:e.get("dt")?Kf.fromEncodingData(e.get("dt")):void 0,configAsset:e.get("caid"),applicationID:e.get("apid")})}}class no{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries(...rt([{key:"",valueSchema:jt.encodingSchema,embedded:!0},{key:"",valueSchema:wa.encodingSchema,embedded:!0}]))),this.encodingSchemaValue}constructor(e){this.signedTxn=e.signedTxn,this.applyData=e.applyData}getEncodingSchema(){return no.encodingSchema}toEncodingData(){return Dc(this.signedTxn.toEncodingData(),this.applyData.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SignedTxnWithAD: ${e}`);return new no({signedTxn:jt.fromEncodingData(e),applyData:wa.fromEncodingData(e)})}}class as{constructor(e){this.signedTxn=e.signedTxn,this.hasGenesisID=e.hasGenesisID,this.hasGenesisHash=e.hasGenesisHash}getEncodingSchema(){return as.encodingSchema}toEncodingData(){const e=new Map([["hgi",this.hasGenesisID],["hgh",this.hasGenesisHash]]);return Dc(e,this.signedTxn.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SignedTxnInBlock: ${e}`);return new as({signedTxn:no.fromEncodingData(e),hasGenesisID:e.get("hgi"),hasGenesisHash:e.get("hgh")})}}as.encodingSchema=new oe(rt([{key:"",valueSchema:no.encodingSchema,embedded:!0},{key:"hgi",valueSchema:new gt},{key:"hgh",valueSchema:new gt}]));let md=class Xf{constructor(e){this.header=e.header,this.payset=e.payset}getEncodingSchema(){return Xf.encodingSchema}toEncodingData(){const e=new Map([["txns",this.payset.map(t=>t.toEncodingData())]]);return Dc(e,this.header.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHeader: ${e}`);return new Xf({header:vi.fromEncodingData(e),payset:e.get("txns").map(as.fromEncodingData)})}};md.encodingSchema=new oe(rt([{key:"",valueSchema:vi.encodingSchema,embedded:!0},{key:"txns",valueSchema:new Me(as.encodingSchema)}]));class Sn{constructor(e){this.data=e}getEncodingSchema(){return Sn.encodingSchema}toEncodingData(){return this.data}static fromEncodingData(e){return new Sn(e)}}Sn.encodingSchema=new nx;let Mc=class Zf{constructor(e){this.type=e.type,this.bytes=e.bytes,this.uint=e.uint}getEncodingSchema(){return Zf.encodingSchema}toEncodingData(){return new Map([["tt",this.type],["tb",this.bytes],["ui",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealValue: ${e}`);return new Zf({type:Number(e.get("tt")),bytes:e.get("tb"),uint:e.get("ui")})}};Mc.encodingSchema=new oe(rt([{key:"tt",valueSchema:new O},{key:"tb",valueSchema:new k(new Js)},{key:"ui",valueSchema:new k(new O)}]));let Xr=class Jf{constructor(e){this.numUints=e.numUints,this.numByteSlices=e.numByteSlices}getEncodingSchema(){return Jf.encodingSchema}toEncodingData(){return new Map([["nui",this.numUints],["nbs",this.numByteSlices]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateSchema: ${e}`);return new Jf({numUints:Number(e.get("nui")),numByteSlices:Number(e.get("nbs"))})}};Xr.encodingSchema=new oe(rt([{key:"nui",valueSchema:new O},{key:"nbs",valueSchema:new O}]));class cs{constructor(e){this.approvalProgram=e.approvalProgram,this.clearStateProgram=e.clearStateProgram,this.globalState=e.globalState,this.localStateSchema=e.localStateSchema,this.globalStateSchema=e.globalStateSchema,this.extraProgramPages=e.extraProgramPages}getEncodingSchema(){return cs.encodingSchema}toEncodingData(){return new Map([["approv",this.approvalProgram],["clearp",this.clearStateProgram],["gs",dn(this.globalState,(e,t)=>[e,t.toEncodingData()])],["lsch",this.localStateSchema.toEncodingData()],["gsch",this.globalStateSchema.toEncodingData()],["epp",this.extraProgramPages]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppParams: ${e}`);return new cs({approvalProgram:e.get("approv"),clearStateProgram:e.get("clearp"),globalState:dn(e.get("gs"),(t,r)=>[t,Mc.fromEncodingData(r)]),localStateSchema:Xr.fromEncodingData(e.get("lsch")),globalStateSchema:Xr.fromEncodingData(e.get("gsch")),extraProgramPages:Number(e.get("epp"))})}}cs.encodingSchema=new oe(rt([{key:"approv",valueSchema:new Pe},{key:"clearp",valueSchema:new Pe},{key:"gs",valueSchema:new dl(Mc.encodingSchema)},{key:"lsch",valueSchema:Xr.encodingSchema},{key:"gsch",valueSchema:Xr.encodingSchema},{key:"epp",valueSchema:new O}]));class ls{constructor(e){this.schema=e.schema,this.keyValue=e.keyValue}getEncodingSchema(){return ls.encodingSchema}toEncodingData(){return new Map([["hsch",this.schema.toEncodingData()],["tkv",dn(this.keyValue,(e,t)=>[e,t.toEncodingData()])]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppLocalState: ${e}`);return new ls({schema:Xr.fromEncodingData(e.get("hsch")),keyValue:dn(e.get("tkv"),(t,r)=>[t,Mc.fromEncodingData(r)])})}}ls.encodingSchema=new oe(rt([{key:"hsch",valueSchema:Xr.encodingSchema},{key:"tkv",valueSchema:new dl(Mc.encodingSchema)}]));class us{constructor(e){this.localState=e.localState,this.deleted=e.deleted}getEncodingSchema(){return us.encodingSchema}toEncodingData(){return new Map([["LocalState",this.localState?this.localState.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppLocalStateDelta: ${e}`);return new us({localState:e.get("LocalState")?ls.fromEncodingData(e.get("LocalState")):void 0,deleted:e.get("Deleted")})}}us.encodingSchema=new oe(rt([{key:"LocalState",valueSchema:new k(ls.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));class ds{constructor(e){this.params=e.params,this.deleted=e.deleted}getEncodingSchema(){return ds.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppParamsDelta: ${e}`);return new ds({params:e.get("Params")?cs.fromEncodingData(e.get("Params")):void 0,deleted:e.get("Deleted")})}}ds.encodingSchema=new oe(rt([{key:"Params",valueSchema:new k(cs.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));class hs{constructor(e){this.id=e.id,this.address=e.address,this.params=e.params,this.state=e.state}getEncodingSchema(){return hs.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["State",this.state.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppResourceRecord: ${e}`);return new hs({id:e.get("Aidx"),address:e.get("Addr"),params:ds.fromEncodingData(e.get("Params")),state:us.fromEncodingData(e.get("State"))})}}hs.encodingSchema=new oe(rt([{key:"Aidx",valueSchema:new O},{key:"Addr",valueSchema:new _t},{key:"Params",valueSchema:ds.encodingSchema},{key:"State",valueSchema:us.encodingSchema}]));let Zd=class Qf{constructor(e){this.amount=e.amount,this.frozen=e.frozen}getEncodingSchema(){return Qf.encodingSchema}toEncodingData(){return new Map([["a",this.amount],["f",this.frozen]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${e}`);return new Qf({amount:e.get("a"),frozen:e.get("f")})}};Zd.encodingSchema=new oe(rt([{key:"a",valueSchema:new O},{key:"f",valueSchema:new gt}]));class fs{constructor(e){this.holding=e.holding,this.deleted=e.deleted}getEncodingSchema(){return fs.encodingSchema}toEncodingData(){return new Map([["Holding",this.holding?this.holding.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHoldingDelta: ${e}`);return new fs({holding:e.get("Holding")?Zd.fromEncodingData(e.get("Holding")):void 0,deleted:e.get("Deleted")})}}fs.encodingSchema=new oe(rt([{key:"Holding",valueSchema:new k(Zd.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));let Jd=class ep{constructor(e){this.total=e.total,this.decimals=e.decimals,this.defaultFrozen=e.defaultFrozen,this.unitName=e.unitName,this.assetName=e.assetName,this.url=e.url,this.metadataHash=e.metadataHash,this.manager=e.manager,this.reserve=e.reserve,this.freeze=e.freeze,this.clawback=e.clawback}getEncodingSchema(){return ep.encodingSchema}toEncodingData(){return new Map([["t",this.total],["dc",this.decimals],["df",this.defaultFrozen],["un",this.unitName],["an",this.assetName],["au",this.url],["am",this.metadataHash],["m",this.manager],["r",this.reserve],["f",this.freeze],["c",this.clawback]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParams: ${e}`);return new ep({total:e.get("t"),decimals:e.get("dc"),defaultFrozen:e.get("df"),unitName:e.get("un"),assetName:e.get("an"),url:e.get("au"),metadataHash:e.get("am"),manager:e.get("m"),reserve:e.get("r"),freeze:e.get("f"),clawback:e.get("c")})}};Jd.encodingSchema=new oe(rt([{key:"t",valueSchema:new O},{key:"dc",valueSchema:new O},{key:"df",valueSchema:new gt},{key:"un",valueSchema:new k(new Js)},{key:"an",valueSchema:new k(new Js)},{key:"au",valueSchema:new k(new Js)},{key:"am",valueSchema:new Ht(32)},{key:"m",valueSchema:new k(new _t)},{key:"r",valueSchema:new k(new _t)},{key:"f",valueSchema:new k(new _t)},{key:"c",valueSchema:new k(new _t)}]));class ps{constructor(e){this.params=e.params,this.deleted=e.deleted}getEncodingSchema(){return ps.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParamsDelta: ${e}`);return new ps({params:e.get("Params")?Jd.fromEncodingData(e.get("Params")):void 0,deleted:e.get("Deleted")})}}ps.encodingSchema=new oe(rt([{key:"Params",valueSchema:new k(Jd.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));class gs{constructor(e){this.id=e.id,this.address=e.address,this.params=e.params,this.holding=e.holding}getEncodingSchema(){return gs.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["Holding",this.holding.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetResourceRecord: ${e}`);return new gs({id:e.get("Aidx"),address:e.get("Addr"),params:ps.fromEncodingData(e.get("Params")),holding:fs.fromEncodingData(e.get("Holding"))})}}gs.encodingSchema=new oe(rt([{key:"Aidx",valueSchema:new O},{key:"Addr",valueSchema:new _t},{key:"Params",valueSchema:ps.encodingSchema},{key:"Holding",valueSchema:fs.encodingSchema}]));class ms{constructor(e){this.voteID=e.voteID,this.selectionID=e.selectionID,this.stateProofID=e.stateProofID,this.voteFirstValid=e.voteFirstValid,this.voteLastValid=e.voteLastValid,this.voteKeyDilution=e.voteKeyDilution}getEncodingSchema(){return ms.encodingSchema}toEncodingData(){return new Map([["VoteID",this.voteID],["SelectionID",this.selectionID],["StateProofID",this.stateProofID],["VoteFirstValid",this.voteFirstValid],["VoteLastValid",this.voteLastValid],["VoteKeyDilution",this.voteKeyDilution]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded VotingData: ${e}`);return new ms({voteID:e.get("VoteID"),selectionID:e.get("SelectionID"),stateProofID:e.get("StateProofID"),voteFirstValid:e.get("VoteFirstValid"),voteLastValid:e.get("VoteLastValid"),voteKeyDilution:e.get("VoteKeyDilution")})}}ms.encodingSchema=new oe(rt([{key:"VoteID",valueSchema:new Ht(32)},{key:"SelectionID",valueSchema:new Ht(32)},{key:"StateProofID",valueSchema:new Ht(64)},{key:"VoteFirstValid",valueSchema:new O},{key:"VoteLastValid",valueSchema:new O},{key:"VoteKeyDilution",valueSchema:new O}]));class ys{constructor(e){this.status=e.status,this.microAlgos=e.microAlgos,this.rewardsBase=e.rewardsBase,this.rewardedMicroAlgos=e.rewardedMicroAlgos,this.authAddr=e.authAddr,this.incentiveEligible=e.incentiveEligible,this.totalAppSchema=e.totalAppSchema,this.totalExtraAppPages=e.totalExtraAppPages,this.totalAppParams=e.totalAppParams,this.totalAppLocalStates=e.totalAppLocalStates,this.totalAssetParams=e.totalAssetParams,this.totalAssets=e.totalAssets,this.totalBoxes=e.totalBoxes,this.totalBoxBytes=e.totalBoxBytes,this.lastProposed=e.lastProposed,this.lastHeartbeat=e.lastHeartbeat}getEncodingSchema(){return ys.encodingSchema}toEncodingData(){return new Map([["Status",this.status],["MicroAlgos",this.microAlgos],["RewardsBase",this.rewardsBase],["RewardedMicroAlgos",this.rewardedMicroAlgos],["AuthAddr",this.authAddr],["IncentiveEligible",this.incentiveEligible],["TotalAppSchema",this.totalAppSchema.toEncodingData()],["TotalExtraAppPages",this.totalExtraAppPages],["TotalAppParams",this.totalAppParams],["TotalAppLocalStates",this.totalAppLocalStates],["TotalAssetParams",this.totalAssetParams],["TotalAssets",this.totalAssets],["TotalBoxes",this.totalBoxes],["TotalBoxBytes",this.totalBoxBytes],["LastProposed",this.lastProposed],["LastHeartbeat",this.lastHeartbeat]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountBaseData: ${e}`);return new ys({status:Number(e.get("Status")),microAlgos:e.get("MicroAlgos"),rewardsBase:e.get("RewardsBase"),rewardedMicroAlgos:e.get("RewardedMicroAlgos"),authAddr:e.get("AuthAddr"),incentiveEligible:e.get("IncentiveEligible"),totalAppSchema:Xr.fromEncodingData(e.get("TotalAppSchema")),totalExtraAppPages:Number(e.get("TotalExtraAppPages")),totalAppParams:e.get("TotalAppParams"),totalAppLocalStates:e.get("TotalAppLocalStates"),totalAssetParams:e.get("TotalAssetParams"),totalAssets:e.get("TotalAssets"),totalBoxes:e.get("TotalBoxes"),totalBoxBytes:e.get("TotalBoxBytes"),lastProposed:e.get("LastProposed"),lastHeartbeat:e.get("LastHeartbeat")})}}ys.encodingSchema=new oe(rt([{key:"Status",valueSchema:new O},{key:"MicroAlgos",valueSchema:new O},{key:"RewardsBase",valueSchema:new O},{key:"RewardedMicroAlgos",valueSchema:new O},{key:"AuthAddr",valueSchema:new _t},{key:"IncentiveEligible",valueSchema:new gt},{key:"TotalAppSchema",valueSchema:Xr.encodingSchema},{key:"TotalExtraAppPages",valueSchema:new O},{key:"TotalAppParams",valueSchema:new O},{key:"TotalAppLocalStates",valueSchema:new O},{key:"TotalAssetParams",valueSchema:new O},{key:"TotalAssets",valueSchema:new O},{key:"TotalBoxes",valueSchema:new O},{key:"TotalBoxBytes",valueSchema:new O},{key:"LastProposed",valueSchema:new O},{key:"LastHeartbeat",valueSchema:new O}]));class ws{constructor(e){this.accountBaseData=e.accountBaseData,this.votingData=e.votingData}getEncodingSchema(){return ws.encodingSchema}toEncodingData(){return Dc(this.accountBaseData.toEncodingData(),this.votingData.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountData: ${e}`);return new ws({accountBaseData:ys.fromEncodingData(e),votingData:ms.fromEncodingData(e)})}}ws.encodingSchema=new oe(rt([{key:"",valueSchema:ys.encodingSchema,embedded:!0},{key:"",valueSchema:ms.encodingSchema,embedded:!0}]));class xs{constructor(e){this.addr=e.addr,this.accountData=e.accountData}getEncodingSchema(){return xs.encodingSchema}toEncodingData(){return Dc(new Map([["Addr",this.addr]]),this.accountData.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BalanceRecord: ${e}`);return new xs({addr:e.get("Addr"),accountData:ws.fromEncodingData(e)})}}xs.encodingSchema=new oe(rt([{key:"Addr",valueSchema:new _t},{key:"",valueSchema:ws.encodingSchema,embedded:!0}]));class vs{constructor(e){this.accounts=e.accounts,this.appResources=e.appResources,this.assetResources=e.assetResources}getEncodingSchema(){return vs.encodingSchema}toEncodingData(){return new Map([["Accts",this.accounts.map(e=>e.toEncodingData())],["AppResources",this.appResources.length===0?void 0:this.appResources.map(e=>e.toEncodingData())],["AssetResources",this.assetResources.length===0?void 0:this.assetResources.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountDeltas: ${e}`);return new vs({accounts:(e.get("Accts")??[]).map(xs.fromEncodingData),appResources:(e.get("AppResources")??[]).map(hs.fromEncodingData),assetResources:(e.get("AssetResources")??[]).map(gs.fromEncodingData)})}}vs.encodingSchema=new oe(rt([{key:"Accts",valueSchema:new Me(xs.encodingSchema)},{key:"AppResources",valueSchema:new k(new Me(hs.encodingSchema))},{key:"AssetResources",valueSchema:new k(new Me(gs.encodingSchema))}]));class Ss{constructor(e){this.data=e.data,this.oldData=e.oldData}getEncodingSchema(){return Ss.encodingSchema}toEncodingData(){return new Map([["Data",this.data],["OldData",this.oldData]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded KvValueDelta: ${e}`);return new Ss({data:e.get("Data"),oldData:e.get("OldData")})}}Ss.encodingSchema=new oe(rt([{key:"Data",valueSchema:new k(new Pe)},{key:"OldData",valueSchema:new k(new Pe)}]));class bs{constructor(e){this.lastValid=e.lastValid,this.intra=e.intra}getEncodingSchema(){return bs.encodingSchema}toEncodingData(){return new Map([["LastValid",this.lastValid],["Intra",this.intra]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded IncludedTransactions: ${e}`);return new bs({lastValid:e.get("LastValid"),intra:Number(e.get("Intra"))})}}bs.encodingSchema=new oe(rt([{key:"LastValid",valueSchema:new O},{key:"Intra",valueSchema:new O}]));class Es{constructor(e){this.creatableType=e.creatableType,this.created=e.created,this.creator=e.creator,this.ndeltas=e.ndeltas}getEncodingSchema(){return Es.encodingSchema}toEncodingData(){return new Map([["Ctype",this.creatableType],["Created",this.created],["Creator",this.creator],["Ndeltas",this.ndeltas]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ModifiedCreatable: ${e}`);return new Es({creatableType:Number(e.get("Ctype")),created:e.get("Created"),creator:e.get("Creator"),ndeltas:Number(e.get("Ndeltas"))})}}Es.encodingSchema=new oe(rt([{key:"Ctype",valueSchema:new O},{key:"Created",valueSchema:new gt},{key:"Creator",valueSchema:new _t},{key:"Ndeltas",valueSchema:new O}]));class Tr{constructor(e){this.money=e.money,this.rewardUnits=e.rewardUnits}getEncodingSchema(){return Tr.encodingSchema}toEncodingData(){return new Map([["mon",this.money],["rwd",this.rewardUnits]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AlgoCount: ${e}`);return new Tr({money:e.get("mon"),rewardUnits:e.get("rwd")})}}Tr.encodingSchema=new oe(rt([{key:"mon",valueSchema:new O},{key:"rwd",valueSchema:new O}]));class As{constructor(e){this.online=e.online,this.offline=e.offline,this.notParticipating=e.notParticipating,this.rewardsLevel=e.rewardsLevel}getEncodingSchema(){return As.encodingSchema}toEncodingData(){return new Map([["online",this.online.toEncodingData()],["offline",this.offline.toEncodingData()],["notpart",this.notParticipating.toEncodingData()],["rwdlvl",this.rewardsLevel]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountTotals: ${e}`);return new As({online:Tr.fromEncodingData(e.get("online")),offline:Tr.fromEncodingData(e.get("offline")),notParticipating:Tr.fromEncodingData(e.get("notpart")),rewardsLevel:e.get("rwdlvl")})}}As.encodingSchema=new oe(rt([{key:"online",valueSchema:Tr.encodingSchema},{key:"offline",valueSchema:Tr.encodingSchema},{key:"notpart",valueSchema:Tr.encodingSchema},{key:"rwdlvl",valueSchema:new O}]));class Si{constructor(e){this.accounts=e.accounts,this.kvMods=e.kvMods,this.txids=e.txids,this.txleases=e.txleases,this.creatables=e.creatables,this.blockHeader=e.blockHeader,this.stateProofNext=e.stateProofNext,this.prevTimestamp=e.prevTimestamp,this.totals=e.totals}getEncodingSchema(){return Si.encodingSchema}toEncodingData(){return new Map([["Accts",this.accounts.toEncodingData()],["KvMods",this.kvMods.size===0?void 0:dn(this.kvMods,(e,t)=>[e,t.toEncodingData()])],["Txids",dn(this.txids,(e,t)=>[e,t.toEncodingData()])],["Txleases",this.txleases.toEncodingData()],["Creatables",this.creatables.size===0?void 0:dn(this.creatables,(e,t)=>[e,t.toEncodingData()])],["Hdr",this.blockHeader.toEncodingData()],["StateProofNext",this.stateProofNext],["PrevTimestamp",this.prevTimestamp],["Totals",this.totals.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LedgerStateDelta: ${e}`);return new Si({accounts:vs.fromEncodingData(e.get("Accts")),kvMods:dn(e.get("KvMods")??new Map,(t,r)=>[t,Ss.fromEncodingData(r)]),txids:dn(e.get("Txids"),(t,r)=>[t,bs.fromEncodingData(r)]),txleases:Sn.fromEncodingData(e.get("Txleases")),creatables:dn(e.get("Creatables")??new Map,(t,r)=>[t,Es.fromEncodingData(r)]),blockHeader:vi.fromEncodingData(e.get("Hdr")),stateProofNext:e.get("StateProofNext"),prevTimestamp:e.get("PrevTimestamp"),totals:As.fromEncodingData(e.get("Totals"))})}}Si.encodingSchema=new oe(rt([{key:"Accts",valueSchema:vs.encodingSchema},{key:"KvMods",valueSchema:new k(new dl(Ss.encodingSchema))},{key:"Txids",valueSchema:new nI(bs.encodingSchema)},{key:"Txleases",valueSchema:new k(new nx)},{key:"Creatables",valueSchema:new k(new Hd(Es.encodingSchema))},{key:"Hdr",valueSchema:vi.encodingSchema},{key:"StateProofNext",valueSchema:new O},{key:"PrevTimestamp",valueSchema:new O},{key:"Totals",valueSchema:As.encodingSchema}]));let yd=class tp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"amount",valueSchema:new O,omitEmpty:!0},{key:"amount-without-pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"min-balance",valueSchema:new O,omitEmpty:!0},{key:"pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"rewards",valueSchema:new O,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"status",valueSchema:new Ce,omitEmpty:!0},{key:"total-apps-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-assets-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-created-apps",valueSchema:new O,omitEmpty:!0},{key:"total-created-assets",valueSchema:new O,omitEmpty:!0},{key:"apps-local-state",valueSchema:new k(new Me(gl.encodingSchema)),omitEmpty:!0},{key:"apps-total-extra-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"apps-total-schema",valueSchema:new k(Dr.encodingSchema),omitEmpty:!0},{key:"assets",valueSchema:new k(new Me(ks.encodingSchema)),omitEmpty:!0},{key:"auth-addr",valueSchema:new k(new Ce),omitEmpty:!0},{key:"created-apps",valueSchema:new k(new Me(Is.encodingSchema)),omitEmpty:!0},{key:"created-assets",valueSchema:new k(new Me(xd.encodingSchema)),omitEmpty:!0},{key:"incentive-eligible",valueSchema:new k(new gt),omitEmpty:!0},{key:"last-heartbeat",valueSchema:new k(new O),omitEmpty:!0},{key:"last-proposed",valueSchema:new k(new O),omitEmpty:!0},{key:"participation",valueSchema:new k(np.encodingSchema),omitEmpty:!0},{key:"reward-base",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-type",valueSchema:new k(new Ce),omitEmpty:!0},{key:"total-box-bytes",valueSchema:new k(new O),omitEmpty:!0},{key:"total-boxes",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,amount:t,amountWithoutPendingRewards:r,minBalance:i,pendingRewards:o,rewards:s,round:a,status:l,totalAppsOptedIn:c,totalAssetsOptedIn:d,totalCreatedApps:u,totalCreatedAssets:m,appsLocalState:h,appsTotalExtraPages:x,appsTotalSchema:A,assets:v,authAddr:F,createdApps:w,createdAssets:C,incentiveEligible:M,lastHeartbeat:N,lastProposed:b,participation:j,rewardBase:p,sigType:E,totalBoxBytes:S,totalBoxes:$}){this.address=e,this.amount=ve(t),this.amountWithoutPendingRewards=ve(r),this.minBalance=ve(i),this.pendingRewards=ve(o),this.rewards=ve(s),this.round=ve(a),this.status=l,this.totalAppsOptedIn=Le(c),this.totalAssetsOptedIn=Le(d),this.totalCreatedApps=Le(u),this.totalCreatedAssets=Le(m),this.appsLocalState=h,this.appsTotalExtraPages=typeof x>"u"?void 0:Le(x),this.appsTotalSchema=A,this.assets=v,this.authAddr=typeof F=="string"?ze.fromString(F):F,this.createdApps=w,this.createdAssets=C,this.incentiveEligible=M,this.lastHeartbeat=typeof N>"u"?void 0:Le(N),this.lastProposed=typeof b>"u"?void 0:Le(b),this.participation=j,this.rewardBase=typeof p>"u"?void 0:ve(p),this.sigType=E,this.totalBoxBytes=typeof S>"u"?void 0:Le(S),this.totalBoxes=typeof $>"u"?void 0:Le($)}getEncodingSchema(){return tp.encodingSchema}toEncodingData(){return new Map([["address",this.address],["amount",this.amount],["amount-without-pending-rewards",this.amountWithoutPendingRewards],["min-balance",this.minBalance],["pending-rewards",this.pendingRewards],["rewards",this.rewards],["round",this.round],["status",this.status],["total-apps-opted-in",this.totalAppsOptedIn],["total-assets-opted-in",this.totalAssetsOptedIn],["total-created-apps",this.totalCreatedApps],["total-created-assets",this.totalCreatedAssets],["apps-local-state",typeof this.appsLocalState<"u"?this.appsLocalState.map(e=>e.toEncodingData()):void 0],["apps-total-extra-pages",this.appsTotalExtraPages],["apps-total-schema",typeof this.appsTotalSchema<"u"?this.appsTotalSchema.toEncodingData():void 0],["assets",typeof this.assets<"u"?this.assets.map(e=>e.toEncodingData()):void 0],["auth-addr",typeof this.authAddr<"u"?this.authAddr.toString():void 0],["created-apps",typeof this.createdApps<"u"?this.createdApps.map(e=>e.toEncodingData()):void 0],["created-assets",typeof this.createdAssets<"u"?this.createdAssets.map(e=>e.toEncodingData()):void 0],["incentive-eligible",this.incentiveEligible],["last-heartbeat",this.lastHeartbeat],["last-proposed",this.lastProposed],["participation",typeof this.participation<"u"?this.participation.toEncodingData():void 0],["reward-base",this.rewardBase],["sig-type",this.sigType],["total-box-bytes",this.totalBoxBytes],["total-boxes",this.totalBoxes]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Account: ${e}`);return new tp({address:e.get("address"),amount:e.get("amount"),amountWithoutPendingRewards:e.get("amount-without-pending-rewards"),minBalance:e.get("min-balance"),pendingRewards:e.get("pending-rewards"),rewards:e.get("rewards"),round:e.get("round"),status:e.get("status"),totalAppsOptedIn:e.get("total-apps-opted-in"),totalAssetsOptedIn:e.get("total-assets-opted-in"),totalCreatedApps:e.get("total-created-apps"),totalCreatedAssets:e.get("total-created-assets"),appsLocalState:typeof e.get("apps-local-state")<"u"?e.get("apps-local-state").map(t=>gl.fromEncodingData(t)):void 0,appsTotalExtraPages:e.get("apps-total-extra-pages"),appsTotalSchema:typeof e.get("apps-total-schema")<"u"?Dr.fromEncodingData(e.get("apps-total-schema")):void 0,assets:typeof e.get("assets")<"u"?e.get("assets").map(t=>ks.fromEncodingData(t)):void 0,authAddr:e.get("auth-addr"),createdApps:typeof e.get("created-apps")<"u"?e.get("created-apps").map(t=>Is.fromEncodingData(t)):void 0,createdAssets:typeof e.get("created-assets")<"u"?e.get("created-assets").map(t=>xd.fromEncodingData(t)):void 0,incentiveEligible:e.get("incentive-eligible"),lastHeartbeat:e.get("last-heartbeat"),lastProposed:e.get("last-proposed"),participation:typeof e.get("participation")<"u"?np.fromEncodingData(e.get("participation")):void 0,rewardBase:e.get("reward-base"),sigType:e.get("sig-type"),totalBoxBytes:e.get("total-box-bytes"),totalBoxes:e.get("total-boxes")})}};class hl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0},{key:"app-local-state",valueSchema:new k(gl.encodingSchema),omitEmpty:!0},{key:"created-app",valueSchema:new k(Ea.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e,appLocalState:t,createdApp:r}){this.round=ve(e),this.appLocalState=t,this.createdApp=r}getEncodingSchema(){return hl.encodingSchema}toEncodingData(){return new Map([["round",this.round],["app-local-state",typeof this.appLocalState<"u"?this.appLocalState.toEncodingData():void 0],["created-app",typeof this.createdApp<"u"?this.createdApp.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountApplicationResponse: ${e}`);return new hl({round:e.get("round"),appLocalState:typeof e.get("app-local-state")<"u"?gl.fromEncodingData(e.get("app-local-state")):void 0,createdApp:typeof e.get("created-app")<"u"?Ea.fromEncodingData(e.get("created-app")):void 0})}}class xa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"asset-holding",valueSchema:ks.encodingSchema,omitEmpty:!0},{key:"asset-params",valueSchema:new k(Cs.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({assetHolding:e,assetParams:t}){this.assetHolding=e,this.assetParams=t}getEncodingSchema(){return xa.encodingSchema}toEncodingData(){return new Map([["asset-holding",this.assetHolding.toEncodingData()],["asset-params",typeof this.assetParams<"u"?this.assetParams.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountAssetHolding: ${e}`);return new xa({assetHolding:ks.fromEncodingData(e.get("asset-holding")??new Map),assetParams:typeof e.get("asset-params")<"u"?Cs.fromEncodingData(e.get("asset-params")):void 0})}}class fl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0},{key:"asset-holding",valueSchema:new k(ks.encodingSchema),omitEmpty:!0},{key:"created-asset",valueSchema:new k(Cs.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e,assetHolding:t,createdAsset:r}){this.round=ve(e),this.assetHolding=t,this.createdAsset=r}getEncodingSchema(){return fl.encodingSchema}toEncodingData(){return new Map([["round",this.round],["asset-holding",typeof this.assetHolding<"u"?this.assetHolding.toEncodingData():void 0],["created-asset",typeof this.createdAsset<"u"?this.createdAsset.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountAssetResponse: ${e}`);return new fl({round:e.get("round"),assetHolding:typeof e.get("asset-holding")<"u"?ks.fromEncodingData(e.get("asset-holding")):void 0,createdAsset:typeof e.get("created-asset")<"u"?Cs.fromEncodingData(e.get("created-asset")):void 0})}}class wd{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0},{key:"asset-holdings",valueSchema:new k(new Me(xa.encodingSchema)),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e,assetHoldings:t,nextToken:r}){this.round=Le(e),this.assetHoldings=t,this.nextToken=r}getEncodingSchema(){return wd.encodingSchema}toEncodingData(){return new Map([["round",this.round],["asset-holdings",typeof this.assetHoldings<"u"?this.assetHoldings.map(e=>e.toEncodingData()):void 0],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountAssetsInformationResponse: ${e}`);return new wd({round:e.get("round"),assetHoldings:typeof e.get("asset-holdings")<"u"?e.get("asset-holdings").map(t=>xa.fromEncodingData(t)):void 0,nextToken:e.get("next-token")})}}let np=class rp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"selection-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"vote-first-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-key-dilution",valueSchema:new O,omitEmpty:!0},{key:"vote-last-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"state-proof-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({selectionParticipationKey:e,voteFirstValid:t,voteKeyDilution:r,voteLastValid:i,voteParticipationKey:o,stateProofKey:s}){this.selectionParticipationKey=typeof e=="string"?Ge(e):e,this.voteFirstValid=ve(t),this.voteKeyDilution=ve(r),this.voteLastValid=ve(i),this.voteParticipationKey=typeof o=="string"?Ge(o):o,this.stateProofKey=typeof s=="string"?Ge(s):s}getEncodingSchema(){return rp.encodingSchema}toEncodingData(){return new Map([["selection-participation-key",this.selectionParticipationKey],["vote-first-valid",this.voteFirstValid],["vote-key-dilution",this.voteKeyDilution],["vote-last-valid",this.voteLastValid],["vote-participation-key",this.voteParticipationKey],["state-proof-key",this.stateProofKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountParticipation: ${e}`);return new rp({selectionParticipationKey:e.get("selection-participation-key"),voteFirstValid:e.get("vote-first-valid"),voteKeyDilution:e.get("vote-key-dilution"),voteLastValid:e.get("vote-last-valid"),voteParticipationKey:e.get("vote-participation-key"),stateProofKey:e.get("state-proof-key")})}},pl=class ip{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"delta",valueSchema:new Me(Fs.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,delta:t}){this.address=e,this.delta=t}getEncodingSchema(){return ip.encodingSchema}toEncodingData(){return new Map([["address",this.address],["delta",this.delta.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountStateDelta: ${e}`);return new ip({address:e.get("address"),delta:(e.get("delta")??[]).map(t=>Fs.fromEncodingData(t))})}};class va{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-index",valueSchema:new O,omitEmpty:!0},{key:"logs",valueSchema:new Me(new Pe),omitEmpty:!0},{key:"txId",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationIndex:e,logs:t,txid:r}){this.applicationIndex=Le(e),this.logs=t,this.txid=r}getEncodingSchema(){return va.encodingSchema}toEncodingData(){return new Map([["application-index",this.applicationIndex],["logs",this.logs],["txId",this.txid]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppCallLogs: ${e}`);return new va({applicationIndex:e.get("application-index"),logs:e.get("logs"),txid:e.get("txId")})}}let Is=class op{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:Ea.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,params:t}){this.id=ve(e),this.params=t}getEncodingSchema(){return op.encodingSchema}toEncodingData(){return new Map([["id",this.id],["params",this.params.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Application: ${e}`);return new op({id:e.get("id"),params:Ea.fromEncodingData(e.get("params")??new Map)})}};class Sa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"app-boxes",valueSchema:new k(_r.encodingSchema),omitEmpty:!0},{key:"app-globals",valueSchema:new k(_r.encodingSchema),omitEmpty:!0},{key:"app-locals",valueSchema:new k(new Me(_r.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,appBoxes:t,appGlobals:r,appLocals:i}){this.id=ve(e),this.appBoxes=t,this.appGlobals=r,this.appLocals=i}getEncodingSchema(){return Sa.encodingSchema}toEncodingData(){return new Map([["id",this.id],["app-boxes",typeof this.appBoxes<"u"?this.appBoxes.toEncodingData():void 0],["app-globals",typeof this.appGlobals<"u"?this.appGlobals.toEncodingData():void 0],["app-locals",typeof this.appLocals<"u"?this.appLocals.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationInitialStates: ${e}`);return new Sa({id:e.get("id"),appBoxes:typeof e.get("app-boxes")<"u"?_r.fromEncodingData(e.get("app-boxes")):void 0,appGlobals:typeof e.get("app-globals")<"u"?_r.fromEncodingData(e.get("app-globals")):void 0,appLocals:typeof e.get("app-locals")<"u"?e.get("app-locals").map(t=>_r.fromEncodingData(t)):void 0})}}class _r{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"kvs",valueSchema:new Me(ka.encodingSchema),omitEmpty:!0},{key:"account",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({kvs:e,account:t}){this.kvs=e,this.account=typeof t=="string"?ze.fromString(t):t}getEncodingSchema(){return _r.encodingSchema}toEncodingData(){return new Map([["kvs",this.kvs.map(e=>e.toEncodingData())],["account",typeof this.account<"u"?this.account.toString():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationKVStorage: ${e}`);return new _r({kvs:(e.get("kvs")??[]).map(t=>ka.fromEncodingData(t)),account:e.get("account")})}}class ba{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"account",valueSchema:new Ce,omitEmpty:!0},{key:"app",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({account:e,app:t}){this.account=typeof e=="string"?ze.fromString(e):e,this.app=ve(t)}getEncodingSchema(){return ba.encodingSchema}toEncodingData(){return new Map([["account",this.account.toString()],["app",this.app]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalReference: ${e}`);return new ba({account:e.get("account"),app:e.get("app")})}}let gl=class sp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"schema",valueSchema:Dr.encodingSchema,omitEmpty:!0},{key:"key-value",valueSchema:new k(new Me(Fl.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,schema:t,keyValue:r}){this.id=ve(e),this.schema=t,this.keyValue=r}getEncodingSchema(){return sp.encodingSchema}toEncodingData(){return new Map([["id",this.id],["schema",this.schema.toEncodingData()],["key-value",typeof this.keyValue<"u"?this.keyValue.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalState: ${e}`);return new sp({id:e.get("id"),schema:Dr.fromEncodingData(e.get("schema")??new Map),keyValue:typeof e.get("key-value")<"u"?e.get("key-value").map(t=>Fl.fromEncodingData(t)):void 0})}},Ea=class ap{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"approval-program",valueSchema:new Pe,omitEmpty:!0},{key:"clear-state-program",valueSchema:new Pe,omitEmpty:!0},{key:"creator",valueSchema:new Ce,omitEmpty:!0},{key:"extra-program-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"global-state",valueSchema:new k(new Me(Fl.encodingSchema)),omitEmpty:!0},{key:"global-state-schema",valueSchema:new k(Dr.encodingSchema),omitEmpty:!0},{key:"local-state-schema",valueSchema:new k(Dr.encodingSchema),omitEmpty:!0},{key:"version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({approvalProgram:e,clearStateProgram:t,creator:r,extraProgramPages:i,globalState:o,globalStateSchema:s,localStateSchema:a,version:l}){this.approvalProgram=typeof e=="string"?Ge(e):e,this.clearStateProgram=typeof t=="string"?Ge(t):t,this.creator=typeof r=="string"?ze.fromString(r):r,this.extraProgramPages=typeof i>"u"?void 0:Le(i),this.globalState=o,this.globalStateSchema=s,this.localStateSchema=a,this.version=typeof l>"u"?void 0:Le(l)}getEncodingSchema(){return ap.encodingSchema}toEncodingData(){return new Map([["approval-program",this.approvalProgram],["clear-state-program",this.clearStateProgram],["creator",this.creator.toString()],["extra-program-pages",this.extraProgramPages],["global-state",typeof this.globalState<"u"?this.globalState.map(e=>e.toEncodingData()):void 0],["global-state-schema",typeof this.globalStateSchema<"u"?this.globalStateSchema.toEncodingData():void 0],["local-state-schema",typeof this.localStateSchema<"u"?this.localStateSchema.toEncodingData():void 0],["version",this.version]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationParams: ${e}`);return new ap({approvalProgram:e.get("approval-program"),clearStateProgram:e.get("clear-state-program"),creator:e.get("creator"),extraProgramPages:e.get("extra-program-pages"),globalState:typeof e.get("global-state")<"u"?e.get("global-state").map(t=>Fl.fromEncodingData(t)):void 0,globalStateSchema:typeof e.get("global-state-schema")<"u"?Dr.fromEncodingData(e.get("global-state-schema")):void 0,localStateSchema:typeof e.get("local-state-schema")<"u"?Dr.fromEncodingData(e.get("local-state-schema")):void 0,version:e.get("version")})}};class Aa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app-state-type",valueSchema:new Ce,omitEmpty:!0},{key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"operation",valueSchema:new Ce,omitEmpty:!0},{key:"account",valueSchema:new k(new Ce),omitEmpty:!0},{key:"new-value",valueSchema:new k(vr.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({appStateType:e,key:t,operation:r,account:i,newValue:o}){this.appStateType=e,this.key=typeof t=="string"?Ge(t):t,this.operation=r,this.account=typeof i=="string"?ze.fromString(i):i,this.newValue=o}getEncodingSchema(){return Aa.encodingSchema}toEncodingData(){return new Map([["app-state-type",this.appStateType],["key",this.key],["operation",this.operation],["account",typeof this.account<"u"?this.account.toString():void 0],["new-value",typeof this.newValue<"u"?this.newValue.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationStateOperation: ${e}`);return new Aa({appStateType:e.get("app-state-type"),key:e.get("key"),operation:e.get("operation"),account:e.get("account"),newValue:typeof e.get("new-value")<"u"?vr.fromEncodingData(e.get("new-value")):void 0})}}let Dr=class cp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"num-byte-slice",valueSchema:new O,omitEmpty:!0},{key:"num-uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({numByteSlice:e,numUint:t}){this.numByteSlice=Le(e),this.numUint=Le(t)}getEncodingSchema(){return cp.encodingSchema}toEncodingData(){return new Map([["num-byte-slice",this.numByteSlice],["num-uint",this.numUint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationStateSchema: ${e}`);return new cp({numByteSlice:e.get("num-byte-slice"),numUint:e.get("num-uint")})}},xd=class lp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"index",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:Cs.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({index:e,params:t}){this.index=ve(e),this.params=t}getEncodingSchema(){return lp.encodingSchema}toEncodingData(){return new Map([["index",this.index],["params",this.params.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Asset: ${e}`);return new lp({index:e.get("index"),params:Cs.fromEncodingData(e.get("params")??new Map)})}},ks=class up{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"is-frozen",valueSchema:new gt,omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,assetId:t,isFrozen:r}){this.amount=ve(e),this.assetId=ve(t),this.isFrozen=r}getEncodingSchema(){return up.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["asset-id",this.assetId],["is-frozen",this.isFrozen]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${e}`);return new up({amount:e.get("amount"),assetId:e.get("asset-id"),isFrozen:e.get("is-frozen")})}};class Ia{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"account",valueSchema:new Ce,omitEmpty:!0},{key:"asset",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({account:e,asset:t}){this.account=typeof e=="string"?ze.fromString(e):e,this.asset=ve(t)}getEncodingSchema(){return Ia.encodingSchema}toEncodingData(){return new Map([["account",this.account.toString()],["asset",this.asset]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHoldingReference: ${e}`);return new Ia({account:e.get("account"),asset:e.get("asset")})}}let Cs=class dp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"creator",valueSchema:new Ce,omitEmpty:!0},{key:"decimals",valueSchema:new O,omitEmpty:!0},{key:"total",valueSchema:new O,omitEmpty:!0},{key:"clawback",valueSchema:new k(new Ce),omitEmpty:!0},{key:"default-frozen",valueSchema:new k(new gt),omitEmpty:!0},{key:"freeze",valueSchema:new k(new Ce),omitEmpty:!0},{key:"manager",valueSchema:new k(new Ce),omitEmpty:!0},{key:"metadata-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"reserve",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"url",valueSchema:new k(new Ce),omitEmpty:!0},{key:"url-b64",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({creator:e,decimals:t,total:r,clawback:i,defaultFrozen:o,freeze:s,manager:a,metadataHash:l,name:c,nameB64:d,reserve:u,unitName:m,unitNameB64:h,url:x,urlB64:A}){this.creator=e,this.decimals=Le(t),this.total=ve(r),this.clawback=i,this.defaultFrozen=o,this.freeze=s,this.manager=a,this.metadataHash=typeof l=="string"?Ge(l):l,this.name=c,this.nameB64=typeof d=="string"?Ge(d):d,this.reserve=u,this.unitName=m,this.unitNameB64=typeof h=="string"?Ge(h):h,this.url=x,this.urlB64=typeof A=="string"?Ge(A):A}getEncodingSchema(){return dp.encodingSchema}toEncodingData(){return new Map([["creator",this.creator],["decimals",this.decimals],["total",this.total],["clawback",this.clawback],["default-frozen",this.defaultFrozen],["freeze",this.freeze],["manager",this.manager],["metadata-hash",this.metadataHash],["name",this.name],["name-b64",this.nameB64],["reserve",this.reserve],["unit-name",this.unitName],["unit-name-b64",this.unitNameB64],["url",this.url],["url-b64",this.urlB64]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParams: ${e}`);return new dp({creator:e.get("creator"),decimals:e.get("decimals"),total:e.get("total"),clawback:e.get("clawback"),defaultFrozen:e.get("default-frozen"),freeze:e.get("freeze"),manager:e.get("manager"),metadataHash:e.get("metadata-hash"),name:e.get("name"),nameB64:e.get("name-b64"),reserve:e.get("reserve"),unitName:e.get("unit-name"),unitNameB64:e.get("unit-name-b64"),url:e.get("url"),urlB64:e.get("url-b64")})}};class ka{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"value",valueSchema:vr.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=typeof e=="string"?Ge(e):e,this.value=t}getEncodingSchema(){return ka.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AvmKeyValue: ${e}`);return new ka({key:e.get("key"),value:vr.fromEncodingData(e.get("value")??new Map)})}}class vr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"type",valueSchema:new O,omitEmpty:!0},{key:"bytes",valueSchema:new k(new Pe),omitEmpty:!0},{key:"uint",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({type:e,bytes:t,uint:r}){this.type=Le(e),this.bytes=typeof t=="string"?Ge(t):t,this.uint=typeof r>"u"?void 0:ve(r)}getEncodingSchema(){return vr.encodingSchema}toEncodingData(){return new Map([["type",this.type],["bytes",this.bytes],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AvmValue: ${e}`);return new vr({type:e.get("type"),bytes:e.get("bytes"),uint:e.get("uint")})}}class ml{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"blockHash",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({blockhash:e}){this.blockhash=e}getEncodingSchema(){return ml.encodingSchema}toEncodingData(){return new Map([["blockHash",this.blockhash]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHashResponse: ${e}`);return new ml({blockhash:e.get("blockHash")})}}class vd{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logs",valueSchema:new Me(va.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({logs:e}){this.logs=e}getEncodingSchema(){return vd.encodingSchema}toEncodingData(){return new Map([["logs",this.logs.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockLogsResponse: ${e}`);return new vd({logs:(e.get("logs")??[]).map(t=>va.fromEncodingData(t))})}}class yl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"block",valueSchema:md.encodingSchema,omitEmpty:!0},{key:"cert",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({block:e,cert:t}){this.block=e,this.cert=t}getEncodingSchema(){return yl.encodingSchema}toEncodingData(){return new Map([["block",this.block.toEncodingData()],["cert",typeof this.cert<"u"?this.cert.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockResponse: ${e}`);return new yl({block:md.fromEncodingData(e.get("block")??new Map),cert:typeof e.get("cert")<"u"?Sn.fromEncodingData(e.get("cert")):void 0})}}class wl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"blockTxids",valueSchema:new Me(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({blocktxids:e}){this.blocktxids=e}getEncodingSchema(){return wl.encodingSchema}toEncodingData(){return new Map([["blockTxids",this.blocktxids]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockTxidsResponse: ${e}`);return new wl({blocktxids:e.get("blockTxids")})}}let fx=class hp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"value",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e,round:t,value:r}){this.name=typeof e=="string"?Ge(e):e,this.round=ve(t),this.value=typeof r=="string"?Ge(r):r}getEncodingSchema(){return hp.encodingSchema}toEncodingData(){return new Map([["name",this.name],["round",this.round],["value",this.value]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Box: ${e}`);return new hp({name:e.get("name"),round:e.get("round"),value:e.get("value")})}},fp=class pp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e}){this.name=typeof e=="string"?Ge(e):e}getEncodingSchema(){return pp.encodingSchema}toEncodingData(){return new Map([["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxDescriptor: ${e}`);return new pp({name:e.get("name")})}},gp=class mp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app",valueSchema:new O,omitEmpty:!0},{key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({app:e,name:t}){this.app=ve(e),this.name=typeof t=="string"?Ge(t):t}getEncodingSchema(){return mp.encodingSchema}toEncodingData(){return new Map([["app",this.app],["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxReference: ${e}`);return new mp({app:e.get("app"),name:e.get("name")})}},px=class yp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"boxes",valueSchema:new Me(fp.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({boxes:e}){this.boxes=e}getEncodingSchema(){return yp.encodingSchema}toEncodingData(){return new Map([["boxes",this.boxes.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxesResponse: ${e}`);return new yp({boxes:(e.get("boxes")??[]).map(t=>fp.fromEncodingData(t))})}};class Ca{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"branch",valueSchema:new Ce,omitEmpty:!0},{key:"build_number",valueSchema:new O,omitEmpty:!0},{key:"channel",valueSchema:new Ce,omitEmpty:!0},{key:"commit_hash",valueSchema:new Ce,omitEmpty:!0},{key:"major",valueSchema:new O,omitEmpty:!0},{key:"minor",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({branch:e,buildNumber:t,channel:r,commitHash:i,major:o,minor:s}){this.branch=e,this.buildNumber=Le(t),this.channel=r,this.commitHash=i,this.major=Le(o),this.minor=Le(s)}getEncodingSchema(){return Ca.encodingSchema}toEncodingData(){return new Map([["branch",this.branch],["build_number",this.buildNumber],["channel",this.channel],["commit_hash",this.commitHash],["major",this.major],["minor",this.minor]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BuildVersion: ${e}`);return new Ca({branch:e.get("branch"),buildNumber:e.get("build_number"),channel:e.get("channel"),commitHash:e.get("commit_hash"),major:e.get("major"),minor:e.get("minor")})}}class xl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hash",valueSchema:new Ce,omitEmpty:!0},{key:"result",valueSchema:new Ce,omitEmpty:!0},{key:"sourcemap",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({hash:e,result:t,sourcemap:r}){this.hash=e,this.result=t,this.sourcemap=r}getEncodingSchema(){return xl.encodingSchema}toEncodingData(){return new Map([["hash",this.hash],["result",this.result],["sourcemap",typeof this.sourcemap<"u"?this.sourcemap.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded CompileResponse: ${e}`);return new xl({hash:e.get("hash"),result:e.get("result"),sourcemap:typeof e.get("sourcemap")<"u"?Sn.fromEncodingData(e.get("sourcemap")):void 0})}}class vl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"result",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({result:e}){this.result=e}getEncodingSchema(){return vl.encodingSchema}toEncodingData(){return new Map([["result",this.result]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DisassembleResponse: ${e}`);return new vl({result:e.get("result")})}}class Sl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"accounts",valueSchema:new Me(yd.encodingSchema),omitEmpty:!0},{key:"apps",valueSchema:new Me(Is.encodingSchema),omitEmpty:!0},{key:"latest-timestamp",valueSchema:new O,omitEmpty:!0},{key:"protocol-version",valueSchema:new Ce,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"sources",valueSchema:new Me(Fa.encodingSchema),omitEmpty:!0},{key:"txns",valueSchema:new Me(jt.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({accounts:e,apps:t,latestTimestamp:r,protocolVersion:i,round:o,sources:s,txns:a}){this.accounts=e,this.apps=t,this.latestTimestamp=Le(r),this.protocolVersion=i,this.round=ve(o),this.sources=s,this.txns=a}getEncodingSchema(){return Sl.encodingSchema}toEncodingData(){return new Map([["accounts",this.accounts.map(e=>e.toEncodingData())],["apps",this.apps.map(e=>e.toEncodingData())],["latest-timestamp",this.latestTimestamp],["protocol-version",this.protocolVersion],["round",this.round],["sources",this.sources.map(e=>e.toEncodingData())],["txns",this.txns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunRequest: ${e}`);return new Sl({accounts:(e.get("accounts")??[]).map(t=>yd.fromEncodingData(t)),apps:(e.get("apps")??[]).map(t=>Is.fromEncodingData(t)),latestTimestamp:e.get("latest-timestamp"),protocolVersion:e.get("protocol-version"),round:e.get("round"),sources:(e.get("sources")??[]).map(t=>Fa.fromEncodingData(t)),txns:(e.get("txns")??[]).map(t=>jt.fromEncodingData(t))})}}class bl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"error",valueSchema:new Ce,omitEmpty:!0},{key:"protocol-version",valueSchema:new Ce,omitEmpty:!0},{key:"txns",valueSchema:new Me(Da.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({error:e,protocolVersion:t,txns:r}){this.error=e,this.protocolVersion=t,this.txns=r}getEncodingSchema(){return bl.encodingSchema}toEncodingData(){return new Map([["error",this.error],["protocol-version",this.protocolVersion],["txns",this.txns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunResponse: ${e}`);return new bl({error:e.get("error"),protocolVersion:e.get("protocol-version"),txns:(e.get("txns")??[]).map(t=>Da.fromEncodingData(t))})}}class Fa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app-index",valueSchema:new O,omitEmpty:!0},{key:"field-name",valueSchema:new Ce,omitEmpty:!0},{key:"source",valueSchema:new Ce,omitEmpty:!0},{key:"txn-index",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({appIndex:e,fieldName:t,source:r,txnIndex:i}){this.appIndex=ve(e),this.fieldName=t,this.source=r,this.txnIndex=Le(i)}getEncodingSchema(){return Fa.encodingSchema}toEncodingData(){return new Map([["app-index",this.appIndex],["field-name",this.fieldName],["source",this.source],["txn-index",this.txnIndex]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunSource: ${e}`);return new Fa({appIndex:e.get("app-index"),fieldName:e.get("field-name"),source:e.get("source"),txnIndex:e.get("txn-index")})}}class zi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"line",valueSchema:new O,omitEmpty:!0},{key:"pc",valueSchema:new O,omitEmpty:!0},{key:"stack",valueSchema:new Me(To.encodingSchema),omitEmpty:!0},{key:"error",valueSchema:new k(new Ce),omitEmpty:!0},{key:"scratch",valueSchema:new k(new Me(To.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({line:e,pc:t,stack:r,error:i,scratch:o}){this.line=Le(e),this.pc=Le(t),this.stack=r,this.error=i,this.scratch=o}getEncodingSchema(){return zi.encodingSchema}toEncodingData(){return new Map([["line",this.line],["pc",this.pc],["stack",this.stack.map(e=>e.toEncodingData())],["error",this.error],["scratch",typeof this.scratch<"u"?this.scratch.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunState: ${e}`);return new zi({line:e.get("line"),pc:e.get("pc"),stack:(e.get("stack")??[]).map(t=>To.fromEncodingData(t)),error:e.get("error"),scratch:typeof e.get("scratch")<"u"?e.get("scratch").map(t=>To.fromEncodingData(t)):void 0})}}class Da{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"disassembly",valueSchema:new Me(new Ce),omitEmpty:!0},{key:"app-call-messages",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"app-call-trace",valueSchema:new k(new Me(zi.encodingSchema)),omitEmpty:!0},{key:"budget-added",valueSchema:new k(new O),omitEmpty:!0},{key:"budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"global-delta",valueSchema:new k(new Me(Fs.encodingSchema)),omitEmpty:!0},{key:"local-deltas",valueSchema:new k(new Me(pl.encodingSchema)),omitEmpty:!0},{key:"logic-sig-disassembly",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"logic-sig-messages",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"logic-sig-trace",valueSchema:new k(new Me(zi.encodingSchema)),omitEmpty:!0},{key:"logs",valueSchema:new k(new Me(new Pe)),omitEmpty:!0})),this.encodingSchemaValue}constructor({disassembly:e,appCallMessages:t,appCallTrace:r,budgetAdded:i,budgetConsumed:o,globalDelta:s,localDeltas:a,logicSigDisassembly:l,logicSigMessages:c,logicSigTrace:d,logs:u}){this.disassembly=e,this.appCallMessages=t,this.appCallTrace=r,this.budgetAdded=typeof i>"u"?void 0:Le(i),this.budgetConsumed=typeof o>"u"?void 0:Le(o),this.globalDelta=s,this.localDeltas=a,this.logicSigDisassembly=l,this.logicSigMessages=c,this.logicSigTrace=d,this.logs=u}getEncodingSchema(){return Da.encodingSchema}toEncodingData(){return new Map([["disassembly",this.disassembly],["app-call-messages",this.appCallMessages],["app-call-trace",typeof this.appCallTrace<"u"?this.appCallTrace.map(e=>e.toEncodingData()):void 0],["budget-added",this.budgetAdded],["budget-consumed",this.budgetConsumed],["global-delta",typeof this.globalDelta<"u"?this.globalDelta.map(e=>e.toEncodingData()):void 0],["local-deltas",typeof this.localDeltas<"u"?this.localDeltas.map(e=>e.toEncodingData()):void 0],["logic-sig-disassembly",this.logicSigDisassembly],["logic-sig-messages",this.logicSigMessages],["logic-sig-trace",typeof this.logicSigTrace<"u"?this.logicSigTrace.map(e=>e.toEncodingData()):void 0],["logs",this.logs]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunTxnResult: ${e}`);return new Da({disassembly:e.get("disassembly"),appCallMessages:e.get("app-call-messages"),appCallTrace:typeof e.get("app-call-trace")<"u"?e.get("app-call-trace").map(t=>zi.fromEncodingData(t)):void 0,budgetAdded:e.get("budget-added"),budgetConsumed:e.get("budget-consumed"),globalDelta:typeof e.get("global-delta")<"u"?e.get("global-delta").map(t=>Fs.fromEncodingData(t)):void 0,localDeltas:typeof e.get("local-deltas")<"u"?e.get("local-deltas").map(t=>pl.fromEncodingData(t)):void 0,logicSigDisassembly:e.get("logic-sig-disassembly"),logicSigMessages:e.get("logic-sig-messages"),logicSigTrace:typeof e.get("logic-sig-trace")<"u"?e.get("logic-sig-trace").map(t=>zi.fromEncodingData(t)):void 0,logs:e.get("logs")})}}let RI=class wp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"message",valueSchema:new Ce,omitEmpty:!0},{key:"data",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,data:t}){this.message=e,this.data=t}getEncodingSchema(){return wp.encodingSchema}toEncodingData(){return new Map([["message",this.message],["data",typeof this.data<"u"?this.data.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ErrorResponse: ${e}`);return new wp({message:e.get("message"),data:typeof e.get("data")<"u"?Sn.fromEncodingData(e.get("data")):void 0})}},xp=class vp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"action",valueSchema:new O,omitEmpty:!0},{key:"bytes",valueSchema:new k(new Ce),omitEmpty:!0},{key:"uint",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({action:e,bytes:t,uint:r}){this.action=Le(e),this.bytes=t,this.uint=typeof r>"u"?void 0:ve(r)}getEncodingSchema(){return vp.encodingSchema}toEncodingData(){return new Map([["action",this.action],["bytes",this.bytes],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${e}`);return new vp({action:e.get("action"),bytes:e.get("bytes"),uint:e.get("uint")})}},Fs=class Sp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Ce,omitEmpty:!0},{key:"value",valueSchema:xp.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=e,this.value=t}getEncodingSchema(){return Sp.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDeltaKeyValue: ${e}`);return new Sp({key:e.get("key"),value:xp.fromEncodingData(e.get("value")??new Map)})}},BI=class bp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"alloc",valueSchema:new Me(Ta.encodingSchema),omitEmpty:!0},{key:"fees",valueSchema:new Ce,omitEmpty:!0},{key:"id",valueSchema:new Ce,omitEmpty:!0},{key:"network",valueSchema:new Ce,omitEmpty:!0},{key:"proto",valueSchema:new Ce,omitEmpty:!0},{key:"rwd",valueSchema:new Ce,omitEmpty:!0},{key:"timestamp",valueSchema:new O,omitEmpty:!0},{key:"comment",valueSchema:new k(new Ce),omitEmpty:!0},{key:"devmode",valueSchema:new k(new gt),omitEmpty:!0})),this.encodingSchemaValue}constructor({alloc:e,fees:t,id:r,network:i,proto:o,rwd:s,timestamp:a,comment:l,devmode:c}){this.alloc=e,this.fees=t,this.id=r,this.network=i,this.proto=o,this.rwd=s,this.timestamp=Le(a),this.comment=l,this.devmode=c}getEncodingSchema(){return bp.encodingSchema}toEncodingData(){return new Map([["alloc",this.alloc.map(e=>e.toEncodingData())],["fees",this.fees],["id",this.id],["network",this.network],["proto",this.proto],["rwd",this.rwd],["timestamp",this.timestamp],["comment",this.comment],["devmode",this.devmode]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Genesis: ${e}`);return new bp({alloc:(e.get("alloc")??[]).map(t=>Ta.fromEncodingData(t)),fees:e.get("fees"),id:e.get("id"),network:e.get("network"),proto:e.get("proto"),rwd:e.get("rwd"),timestamp:e.get("timestamp"),comment:e.get("comment"),devmode:e.get("devmode")})}};class Ta{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"addr",valueSchema:new Ce,omitEmpty:!0},{key:"comment",valueSchema:new Ce,omitEmpty:!0},{key:"state",valueSchema:Sn.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({addr:e,comment:t,state:r}){this.addr=e,this.comment=t,this.state=r}getEncodingSchema(){return Ta.encodingSchema}toEncodingData(){return new Map([["addr",this.addr],["comment",this.comment],["state",this.state.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded GenesisAllocation: ${e}`);return new Ta({addr:e.get("addr"),comment:e.get("comment"),state:Sn.fromEncodingData(e.get("state")??new Map)})}}class El{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"offset",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({offset:e}){this.offset=Le(e)}getEncodingSchema(){return El.encodingSchema}toEncodingData(){return new Map([["offset",this.offset]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded GetBlockTimeStampOffsetResponse: ${e}`);return new El({offset:e.get("offset")})}}class Al{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e}){this.round=ve(e)}getEncodingSchema(){return Al.encodingSchema}toEncodingData(){return new Map([["round",this.round]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded GetSyncRoundResponse: ${e}`);return new Al({round:e.get("round")})}}class Ma{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"Delta",valueSchema:Si.encodingSchema,omitEmpty:!0},{key:"Ids",valueSchema:new Me(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({delta:e,ids:t}){this.delta=e,this.ids=t}getEncodingSchema(){return Ma.encodingSchema}toEncodingData(){return new Map([["Delta",this.delta.toEncodingData()],["Ids",this.ids]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LedgerStateDeltaForTransactionGroup: ${e}`);return new Ma({delta:Si.fromEncodingData(e.get("Delta")??new Map),ids:e.get("Ids")})}}let gx=class Ep{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"index",valueSchema:new O,omitEmpty:!0},{key:"proof",valueSchema:new Pe,omitEmpty:!0},{key:"treedepth",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({index:e,proof:t,treedepth:r}){this.index=Le(e),this.proof=typeof t=="string"?Ge(t):t,this.treedepth=Le(r)}getEncodingSchema(){return Ep.encodingSchema}toEncodingData(){return new Map([["index",this.index],["proof",this.proof],["treedepth",this.treedepth]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LightBlockHeaderProof: ${e}`);return new Ep({index:e.get("index"),proof:e.get("proof"),treedepth:e.get("treedepth")})}};class Ra{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"catchup-time",valueSchema:new O,omitEmpty:!0},{key:"last-round",valueSchema:new O,omitEmpty:!0},{key:"last-version",valueSchema:new Ce,omitEmpty:!0},{key:"next-version",valueSchema:new Ce,omitEmpty:!0},{key:"next-version-round",valueSchema:new O,omitEmpty:!0},{key:"next-version-supported",valueSchema:new gt,omitEmpty:!0},{key:"stopped-at-unsupported-round",valueSchema:new gt,omitEmpty:!0},{key:"time-since-last-round",valueSchema:new O,omitEmpty:!0},{key:"catchpoint",valueSchema:new k(new Ce),omitEmpty:!0},{key:"catchpoint-acquired-blocks",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-processed-accounts",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-processed-kvs",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-total-accounts",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-total-blocks",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-total-kvs",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-verified-accounts",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-verified-kvs",valueSchema:new k(new O),omitEmpty:!0},{key:"last-catchpoint",valueSchema:new k(new Ce),omitEmpty:!0},{key:"upgrade-delay",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-next-protocol-vote-before",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-no-votes",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-node-vote",valueSchema:new k(new gt),omitEmpty:!0},{key:"upgrade-vote-rounds",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-votes",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-votes-required",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-yes-votes",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({catchupTime:e,lastRound:t,lastVersion:r,nextVersion:i,nextVersionRound:o,nextVersionSupported:s,stoppedAtUnsupportedRound:a,timeSinceLastRound:l,catchpoint:c,catchpointAcquiredBlocks:d,catchpointProcessedAccounts:u,catchpointProcessedKvs:m,catchpointTotalAccounts:h,catchpointTotalBlocks:x,catchpointTotalKvs:A,catchpointVerifiedAccounts:v,catchpointVerifiedKvs:F,lastCatchpoint:w,upgradeDelay:C,upgradeNextProtocolVoteBefore:M,upgradeNoVotes:N,upgradeNodeVote:b,upgradeVoteRounds:j,upgradeVotes:p,upgradeVotesRequired:E,upgradeYesVotes:S}){this.catchupTime=ve(e),this.lastRound=ve(t),this.lastVersion=r,this.nextVersion=i,this.nextVersionRound=ve(o),this.nextVersionSupported=s,this.stoppedAtUnsupportedRound=a,this.timeSinceLastRound=ve(l),this.catchpoint=c,this.catchpointAcquiredBlocks=typeof d>"u"?void 0:Le(d),this.catchpointProcessedAccounts=typeof u>"u"?void 0:Le(u),this.catchpointProcessedKvs=typeof m>"u"?void 0:Le(m),this.catchpointTotalAccounts=typeof h>"u"?void 0:Le(h),this.catchpointTotalBlocks=typeof x>"u"?void 0:Le(x),this.catchpointTotalKvs=typeof A>"u"?void 0:Le(A),this.catchpointVerifiedAccounts=typeof v>"u"?void 0:Le(v),this.catchpointVerifiedKvs=typeof F>"u"?void 0:Le(F),this.lastCatchpoint=w,this.upgradeDelay=typeof C>"u"?void 0:ve(C),this.upgradeNextProtocolVoteBefore=typeof M>"u"?void 0:ve(M),this.upgradeNoVotes=typeof N>"u"?void 0:Le(N),this.upgradeNodeVote=b,this.upgradeVoteRounds=typeof j>"u"?void 0:Le(j),this.upgradeVotes=typeof p>"u"?void 0:Le(p),this.upgradeVotesRequired=typeof E>"u"?void 0:Le(E),this.upgradeYesVotes=typeof S>"u"?void 0:Le(S)}getEncodingSchema(){return Ra.encodingSchema}toEncodingData(){return new Map([["catchup-time",this.catchupTime],["last-round",this.lastRound],["last-version",this.lastVersion],["next-version",this.nextVersion],["next-version-round",this.nextVersionRound],["next-version-supported",this.nextVersionSupported],["stopped-at-unsupported-round",this.stoppedAtUnsupportedRound],["time-since-last-round",this.timeSinceLastRound],["catchpoint",this.catchpoint],["catchpoint-acquired-blocks",this.catchpointAcquiredBlocks],["catchpoint-processed-accounts",this.catchpointProcessedAccounts],["catchpoint-processed-kvs",this.catchpointProcessedKvs],["catchpoint-total-accounts",this.catchpointTotalAccounts],["catchpoint-total-blocks",this.catchpointTotalBlocks],["catchpoint-total-kvs",this.catchpointTotalKvs],["catchpoint-verified-accounts",this.catchpointVerifiedAccounts],["catchpoint-verified-kvs",this.catchpointVerifiedKvs],["last-catchpoint",this.lastCatchpoint],["upgrade-delay",this.upgradeDelay],["upgrade-next-protocol-vote-before",this.upgradeNextProtocolVoteBefore],["upgrade-no-votes",this.upgradeNoVotes],["upgrade-node-vote",this.upgradeNodeVote],["upgrade-vote-rounds",this.upgradeVoteRounds],["upgrade-votes",this.upgradeVotes],["upgrade-votes-required",this.upgradeVotesRequired],["upgrade-yes-votes",this.upgradeYesVotes]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded NodeStatusResponse: ${e}`);return new Ra({catchupTime:e.get("catchup-time"),lastRound:e.get("last-round"),lastVersion:e.get("last-version"),nextVersion:e.get("next-version"),nextVersionRound:e.get("next-version-round"),nextVersionSupported:e.get("next-version-supported"),stoppedAtUnsupportedRound:e.get("stopped-at-unsupported-round"),timeSinceLastRound:e.get("time-since-last-round"),catchpoint:e.get("catchpoint"),catchpointAcquiredBlocks:e.get("catchpoint-acquired-blocks"),catchpointProcessedAccounts:e.get("catchpoint-processed-accounts"),catchpointProcessedKvs:e.get("catchpoint-processed-kvs"),catchpointTotalAccounts:e.get("catchpoint-total-accounts"),catchpointTotalBlocks:e.get("catchpoint-total-blocks"),catchpointTotalKvs:e.get("catchpoint-total-kvs"),catchpointVerifiedAccounts:e.get("catchpoint-verified-accounts"),catchpointVerifiedKvs:e.get("catchpoint-verified-kvs"),lastCatchpoint:e.get("last-catchpoint"),upgradeDelay:e.get("upgrade-delay"),upgradeNextProtocolVoteBefore:e.get("upgrade-next-protocol-vote-before"),upgradeNoVotes:e.get("upgrade-no-votes"),upgradeNodeVote:e.get("upgrade-node-vote"),upgradeVoteRounds:e.get("upgrade-vote-rounds"),upgradeVotes:e.get("upgrade-votes"),upgradeVotesRequired:e.get("upgrade-votes-required"),upgradeYesVotes:e.get("upgrade-yes-votes")})}}class hi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"pool-error",valueSchema:new Ce,omitEmpty:!0},{key:"txn",valueSchema:jt.encodingSchema,omitEmpty:!0},{key:"application-index",valueSchema:new k(new O),omitEmpty:!0},{key:"asset-closing-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"asset-index",valueSchema:new k(new O),omitEmpty:!0},{key:"close-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"closing-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"confirmed-round",valueSchema:new k(new O),omitEmpty:!0},{key:"global-state-delta",valueSchema:new k(new Me(Fs.encodingSchema)),omitEmpty:!0},{key:"inner-txns",valueSchema:new k(new Me(hi.encodingSchema)),omitEmpty:!0},{key:"local-state-delta",valueSchema:new k(new Me(pl.encodingSchema)),omitEmpty:!0},{key:"logs",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"receiver-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"sender-rewards",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({poolError:e,txn:t,applicationIndex:r,assetClosingAmount:i,assetIndex:o,closeRewards:s,closingAmount:a,confirmedRound:l,globalStateDelta:c,innerTxns:d,localStateDelta:u,logs:m,receiverRewards:h,senderRewards:x}){this.poolError=e,this.txn=t,this.applicationIndex=typeof r>"u"?void 0:ve(r),this.assetClosingAmount=typeof i>"u"?void 0:ve(i),this.assetIndex=typeof o>"u"?void 0:ve(o),this.closeRewards=typeof s>"u"?void 0:ve(s),this.closingAmount=typeof a>"u"?void 0:ve(a),this.confirmedRound=typeof l>"u"?void 0:ve(l),this.globalStateDelta=c,this.innerTxns=d,this.localStateDelta=u,this.logs=m,this.receiverRewards=typeof h>"u"?void 0:ve(h),this.senderRewards=typeof x>"u"?void 0:ve(x)}getEncodingSchema(){return hi.encodingSchema}toEncodingData(){return new Map([["pool-error",this.poolError],["txn",this.txn.toEncodingData()],["application-index",this.applicationIndex],["asset-closing-amount",this.assetClosingAmount],["asset-index",this.assetIndex],["close-rewards",this.closeRewards],["closing-amount",this.closingAmount],["confirmed-round",this.confirmedRound],["global-state-delta",typeof this.globalStateDelta<"u"?this.globalStateDelta.map(e=>e.toEncodingData()):void 0],["inner-txns",typeof this.innerTxns<"u"?this.innerTxns.map(e=>e.toEncodingData()):void 0],["local-state-delta",typeof this.localStateDelta<"u"?this.localStateDelta.map(e=>e.toEncodingData()):void 0],["logs",this.logs],["receiver-rewards",this.receiverRewards],["sender-rewards",this.senderRewards]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded PendingTransactionResponse: ${e}`);return new hi({poolError:e.get("pool-error"),txn:jt.fromEncodingData(e.get("txn")??new Map),applicationIndex:e.get("application-index"),assetClosingAmount:e.get("asset-closing-amount"),assetIndex:e.get("asset-index"),closeRewards:e.get("close-rewards"),closingAmount:e.get("closing-amount"),confirmedRound:e.get("confirmed-round"),globalStateDelta:typeof e.get("global-state-delta")<"u"?e.get("global-state-delta").map(t=>Fs.fromEncodingData(t)):void 0,innerTxns:typeof e.get("inner-txns")<"u"?e.get("inner-txns").map(t=>hi.fromEncodingData(t)):void 0,localStateDelta:typeof e.get("local-state-delta")<"u"?e.get("local-state-delta").map(t=>pl.fromEncodingData(t)):void 0,logs:e.get("logs"),receiverRewards:e.get("receiver-rewards"),senderRewards:e.get("sender-rewards")})}}class Ba{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"top-transactions",valueSchema:new Me(jt.encodingSchema),omitEmpty:!0},{key:"total-transactions",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({topTransactions:e,totalTransactions:t}){this.topTransactions=e,this.totalTransactions=Le(t)}getEncodingSchema(){return Ba.encodingSchema}toEncodingData(){return new Map([["top-transactions",this.topTransactions.map(e=>e.toEncodingData())],["total-transactions",this.totalTransactions]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded PendingTransactionsResponse: ${e}`);return new Ba({topTransactions:(e.get("top-transactions")??[]).map(t=>jt.fromEncodingData(t)),totalTransactions:e.get("total-transactions")})}}class Il{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txId",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({txid:e}){this.txid=e}getEncodingSchema(){return Il.encodingSchema}toEncodingData(){return new Map([["txId",this.txid]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded PostTransactionsResponse: ${e}`);return new Il({txid:e.get("txId")})}}class Na{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"new-value",valueSchema:vr.encodingSchema,omitEmpty:!0},{key:"slot",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({newValue:e,slot:t}){this.newValue=e,this.slot=Le(t)}getEncodingSchema(){return Na.encodingSchema}toEncodingData(){return new Map([["new-value",this.newValue.toEncodingData()],["slot",this.slot]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ScratchChange: ${e}`);return new Na({newValue:vr.fromEncodingData(e.get("new-value")??new Map),slot:e.get("slot")})}}class Pa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app-initial-states",valueSchema:new k(new Me(Sa.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({appInitialStates:e}){this.appInitialStates=e}getEncodingSchema(){return Pa.encodingSchema}toEncodingData(){return new Map([["app-initial-states",typeof this.appInitialStates<"u"?this.appInitialStates.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateInitialStates: ${e}`);return new Pa({appInitialStates:typeof e.get("app-initial-states")<"u"?e.get("app-initial-states").map(t=>Sa.fromEncodingData(t)):void 0})}}class Oa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txn-groups",valueSchema:new Me(ro.encodingSchema),omitEmpty:!0},{key:"allow-empty-signatures",valueSchema:new k(new gt),omitEmpty:!0},{key:"allow-more-logging",valueSchema:new k(new gt),omitEmpty:!0},{key:"allow-unnamed-resources",valueSchema:new k(new gt),omitEmpty:!0},{key:"exec-trace-config",valueSchema:new k(io.encodingSchema),omitEmpty:!0},{key:"extra-opcode-budget",valueSchema:new k(new O),omitEmpty:!0},{key:"fix-signers",valueSchema:new k(new gt),omitEmpty:!0},{key:"round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({txnGroups:e,allowEmptySignatures:t,allowMoreLogging:r,allowUnnamedResources:i,execTraceConfig:o,extraOpcodeBudget:s,fixSigners:a,round:l}){this.txnGroups=e,this.allowEmptySignatures=t,this.allowMoreLogging=r,this.allowUnnamedResources=i,this.execTraceConfig=o,this.extraOpcodeBudget=typeof s>"u"?void 0:Le(s),this.fixSigners=a,this.round=typeof l>"u"?void 0:ve(l)}getEncodingSchema(){return Oa.encodingSchema}toEncodingData(){return new Map([["txn-groups",this.txnGroups.map(e=>e.toEncodingData())],["allow-empty-signatures",this.allowEmptySignatures],["allow-more-logging",this.allowMoreLogging],["allow-unnamed-resources",this.allowUnnamedResources],["exec-trace-config",typeof this.execTraceConfig<"u"?this.execTraceConfig.toEncodingData():void 0],["extra-opcode-budget",this.extraOpcodeBudget],["fix-signers",this.fixSigners],["round",this.round]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateRequest: ${e}`);return new Oa({txnGroups:(e.get("txn-groups")??[]).map(t=>ro.fromEncodingData(t)),allowEmptySignatures:e.get("allow-empty-signatures"),allowMoreLogging:e.get("allow-more-logging"),allowUnnamedResources:e.get("allow-unnamed-resources"),execTraceConfig:typeof e.get("exec-trace-config")<"u"?io.fromEncodingData(e.get("exec-trace-config")):void 0,extraOpcodeBudget:e.get("extra-opcode-budget"),fixSigners:e.get("fix-signers"),round:e.get("round")})}}class ro{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txns",valueSchema:new Me(jt.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({txns:e}){this.txns=e}getEncodingSchema(){return ro.encodingSchema}toEncodingData(){return new Map([["txns",this.txns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateRequestTransactionGroup: ${e}`);return new ro({txns:(e.get("txns")??[]).map(t=>jt.fromEncodingData(t))})}}class kl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"last-round",valueSchema:new O,omitEmpty:!0},{key:"txn-groups",valueSchema:new Me(La.encodingSchema),omitEmpty:!0},{key:"version",valueSchema:new O,omitEmpty:!0},{key:"eval-overrides",valueSchema:new k($a.encodingSchema),omitEmpty:!0},{key:"exec-trace-config",valueSchema:new k(io.encodingSchema),omitEmpty:!0},{key:"initial-states",valueSchema:new k(Pa.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({lastRound:e,txnGroups:t,version:r,evalOverrides:i,execTraceConfig:o,initialStates:s}){this.lastRound=ve(e),this.txnGroups=t,this.version=Le(r),this.evalOverrides=i,this.execTraceConfig=o,this.initialStates=s}getEncodingSchema(){return kl.encodingSchema}toEncodingData(){return new Map([["last-round",this.lastRound],["txn-groups",this.txnGroups.map(e=>e.toEncodingData())],["version",this.version],["eval-overrides",typeof this.evalOverrides<"u"?this.evalOverrides.toEncodingData():void 0],["exec-trace-config",typeof this.execTraceConfig<"u"?this.execTraceConfig.toEncodingData():void 0],["initial-states",typeof this.initialStates<"u"?this.initialStates.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateResponse: ${e}`);return new kl({lastRound:e.get("last-round"),txnGroups:(e.get("txn-groups")??[]).map(t=>La.fromEncodingData(t)),version:e.get("version"),evalOverrides:typeof e.get("eval-overrides")<"u"?$a.fromEncodingData(e.get("eval-overrides")):void 0,execTraceConfig:typeof e.get("exec-trace-config")<"u"?io.fromEncodingData(e.get("exec-trace-config")):void 0,initialStates:typeof e.get("initial-states")<"u"?Pa.fromEncodingData(e.get("initial-states")):void 0})}}class io{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"enable",valueSchema:new k(new gt),omitEmpty:!0},{key:"scratch-change",valueSchema:new k(new gt),omitEmpty:!0},{key:"stack-change",valueSchema:new k(new gt),omitEmpty:!0},{key:"state-change",valueSchema:new k(new gt),omitEmpty:!0})),this.encodingSchemaValue}constructor({enable:e,scratchChange:t,stackChange:r,stateChange:i}){this.enable=e,this.scratchChange=t,this.stackChange=r,this.stateChange=i}getEncodingSchema(){return io.encodingSchema}toEncodingData(){return new Map([["enable",this.enable],["scratch-change",this.scratchChange],["stack-change",this.stackChange],["state-change",this.stateChange]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateTraceConfig: ${e}`);return new io({enable:e.get("enable"),scratchChange:e.get("scratch-change"),stackChange:e.get("stack-change"),stateChange:e.get("state-change")})}}class La{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txn-results",valueSchema:new Me(Va.encodingSchema),omitEmpty:!0},{key:"app-budget-added",valueSchema:new k(new O),omitEmpty:!0},{key:"app-budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"failed-at",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"failure-message",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unnamed-resources-accessed",valueSchema:new k(oo.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({txnResults:e,appBudgetAdded:t,appBudgetConsumed:r,failedAt:i,failureMessage:o,unnamedResourcesAccessed:s}){this.txnResults=e,this.appBudgetAdded=typeof t>"u"?void 0:Le(t),this.appBudgetConsumed=typeof r>"u"?void 0:Le(r),this.failedAt=typeof i>"u"?void 0:i.map(Le),this.failureMessage=o,this.unnamedResourcesAccessed=s}getEncodingSchema(){return La.encodingSchema}toEncodingData(){return new Map([["txn-results",this.txnResults.map(e=>e.toEncodingData())],["app-budget-added",this.appBudgetAdded],["app-budget-consumed",this.appBudgetConsumed],["failed-at",this.failedAt],["failure-message",this.failureMessage],["unnamed-resources-accessed",typeof this.unnamedResourcesAccessed<"u"?this.unnamedResourcesAccessed.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateTransactionGroupResult: ${e}`);return new La({txnResults:(e.get("txn-results")??[]).map(t=>Va.fromEncodingData(t)),appBudgetAdded:e.get("app-budget-added"),appBudgetConsumed:e.get("app-budget-consumed"),failedAt:e.get("failed-at"),failureMessage:e.get("failure-message"),unnamedResourcesAccessed:typeof e.get("unnamed-resources-accessed")<"u"?oo.fromEncodingData(e.get("unnamed-resources-accessed")):void 0})}}class Va{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txn-result",valueSchema:hi.encodingSchema,omitEmpty:!0},{key:"app-budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"exec-trace",valueSchema:new k(Hi.encodingSchema),omitEmpty:!0},{key:"fixed-signer",valueSchema:new k(new Ce),omitEmpty:!0},{key:"logic-sig-budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"unnamed-resources-accessed",valueSchema:new k(oo.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({txnResult:e,appBudgetConsumed:t,execTrace:r,fixedSigner:i,logicSigBudgetConsumed:o,unnamedResourcesAccessed:s}){this.txnResult=e,this.appBudgetConsumed=typeof t>"u"?void 0:Le(t),this.execTrace=r,this.fixedSigner=typeof i=="string"?ze.fromString(i):i,this.logicSigBudgetConsumed=typeof o>"u"?void 0:Le(o),this.unnamedResourcesAccessed=s}getEncodingSchema(){return Va.encodingSchema}toEncodingData(){return new Map([["txn-result",this.txnResult.toEncodingData()],["app-budget-consumed",this.appBudgetConsumed],["exec-trace",typeof this.execTrace<"u"?this.execTrace.toEncodingData():void 0],["fixed-signer",typeof this.fixedSigner<"u"?this.fixedSigner.toString():void 0],["logic-sig-budget-consumed",this.logicSigBudgetConsumed],["unnamed-resources-accessed",typeof this.unnamedResourcesAccessed<"u"?this.unnamedResourcesAccessed.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateTransactionResult: ${e}`);return new Va({txnResult:hi.fromEncodingData(e.get("txn-result")??new Map),appBudgetConsumed:e.get("app-budget-consumed"),execTrace:typeof e.get("exec-trace")<"u"?Hi.fromEncodingData(e.get("exec-trace")):void 0,fixedSigner:e.get("fixed-signer"),logicSigBudgetConsumed:e.get("logic-sig-budget-consumed"),unnamedResourcesAccessed:typeof e.get("unnamed-resources-accessed")<"u"?oo.fromEncodingData(e.get("unnamed-resources-accessed")):void 0})}}class oo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"app-locals",valueSchema:new k(new Me(ba.encodingSchema)),omitEmpty:!0},{key:"apps",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"asset-holdings",valueSchema:new k(new Me(Ia.encodingSchema)),omitEmpty:!0},{key:"assets",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"boxes",valueSchema:new k(new Me(gp.encodingSchema)),omitEmpty:!0},{key:"extra-box-refs",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({accounts:e,appLocals:t,apps:r,assetHoldings:i,assets:o,boxes:s,extraBoxRefs:a}){this.accounts=typeof e<"u"?e.map(l=>typeof l=="string"?ze.fromString(l):l):void 0,this.appLocals=t,this.apps=typeof r>"u"?void 0:r.map(ve),this.assetHoldings=i,this.assets=typeof o>"u"?void 0:o.map(ve),this.boxes=s,this.extraBoxRefs=typeof a>"u"?void 0:Le(a)}getEncodingSchema(){return oo.encodingSchema}toEncodingData(){return new Map([["accounts",typeof this.accounts<"u"?this.accounts.map(e=>e.toString()):void 0],["app-locals",typeof this.appLocals<"u"?this.appLocals.map(e=>e.toEncodingData()):void 0],["apps",this.apps],["asset-holdings",typeof this.assetHoldings<"u"?this.assetHoldings.map(e=>e.toEncodingData()):void 0],["assets",this.assets],["boxes",typeof this.boxes<"u"?this.boxes.map(e=>e.toEncodingData()):void 0],["extra-box-refs",this.extraBoxRefs]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateUnnamedResourcesAccessed: ${e}`);return new oo({accounts:e.get("accounts"),appLocals:typeof e.get("app-locals")<"u"?e.get("app-locals").map(t=>ba.fromEncodingData(t)):void 0,apps:e.get("apps"),assetHoldings:typeof e.get("asset-holdings")<"u"?e.get("asset-holdings").map(t=>Ia.fromEncodingData(t)):void 0,assets:e.get("assets"),boxes:typeof e.get("boxes")<"u"?e.get("boxes").map(t=>gp.fromEncodingData(t)):void 0,extraBoxRefs:e.get("extra-box-refs")})}}class $a{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"allow-empty-signatures",valueSchema:new k(new gt),omitEmpty:!0},{key:"allow-unnamed-resources",valueSchema:new k(new gt),omitEmpty:!0},{key:"extra-opcode-budget",valueSchema:new k(new O),omitEmpty:!0},{key:"fix-signers",valueSchema:new k(new gt),omitEmpty:!0},{key:"max-log-calls",valueSchema:new k(new O),omitEmpty:!0},{key:"max-log-size",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({allowEmptySignatures:e,allowUnnamedResources:t,extraOpcodeBudget:r,fixSigners:i,maxLogCalls:o,maxLogSize:s}){this.allowEmptySignatures=e,this.allowUnnamedResources=t,this.extraOpcodeBudget=typeof r>"u"?void 0:Le(r),this.fixSigners=i,this.maxLogCalls=typeof o>"u"?void 0:Le(o),this.maxLogSize=typeof s>"u"?void 0:Le(s)}getEncodingSchema(){return $a.encodingSchema}toEncodingData(){return new Map([["allow-empty-signatures",this.allowEmptySignatures],["allow-unnamed-resources",this.allowUnnamedResources],["extra-opcode-budget",this.extraOpcodeBudget],["fix-signers",this.fixSigners],["max-log-calls",this.maxLogCalls],["max-log-size",this.maxLogSize]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulationEvalOverrides: ${e}`);return new $a({allowEmptySignatures:e.get("allow-empty-signatures"),allowUnnamedResources:e.get("allow-unnamed-resources"),extraOpcodeBudget:e.get("extra-opcode-budget"),fixSigners:e.get("fix-signers"),maxLogCalls:e.get("max-log-calls"),maxLogSize:e.get("max-log-size")})}}class Ur{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"pc",valueSchema:new O,omitEmpty:!0},{key:"scratch-changes",valueSchema:new k(new Me(Na.encodingSchema)),omitEmpty:!0},{key:"spawned-inners",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"stack-additions",valueSchema:new k(new Me(vr.encodingSchema)),omitEmpty:!0},{key:"stack-pop-count",valueSchema:new k(new O),omitEmpty:!0},{key:"state-changes",valueSchema:new k(new Me(Aa.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({pc:e,scratchChanges:t,spawnedInners:r,stackAdditions:i,stackPopCount:o,stateChanges:s}){this.pc=Le(e),this.scratchChanges=t,this.spawnedInners=typeof r>"u"?void 0:r.map(Le),this.stackAdditions=i,this.stackPopCount=typeof o>"u"?void 0:Le(o),this.stateChanges=s}getEncodingSchema(){return Ur.encodingSchema}toEncodingData(){return new Map([["pc",this.pc],["scratch-changes",typeof this.scratchChanges<"u"?this.scratchChanges.map(e=>e.toEncodingData()):void 0],["spawned-inners",this.spawnedInners],["stack-additions",typeof this.stackAdditions<"u"?this.stackAdditions.map(e=>e.toEncodingData()):void 0],["stack-pop-count",this.stackPopCount],["state-changes",typeof this.stateChanges<"u"?this.stateChanges.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulationOpcodeTraceUnit: ${e}`);return new Ur({pc:e.get("pc"),scratchChanges:typeof e.get("scratch-changes")<"u"?e.get("scratch-changes").map(t=>Na.fromEncodingData(t)):void 0,spawnedInners:e.get("spawned-inners"),stackAdditions:typeof e.get("stack-additions")<"u"?e.get("stack-additions").map(t=>vr.fromEncodingData(t)):void 0,stackPopCount:e.get("stack-pop-count"),stateChanges:typeof e.get("state-changes")<"u"?e.get("state-changes").map(t=>Aa.fromEncodingData(t)):void 0})}}class Hi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"approval-program-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"approval-program-trace",valueSchema:new k(new Me(Ur.encodingSchema)),omitEmpty:!0},{key:"clear-state-program-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"clear-state-program-trace",valueSchema:new k(new Me(Ur.encodingSchema)),omitEmpty:!0},{key:"clear-state-rollback",valueSchema:new k(new gt),omitEmpty:!0},{key:"clear-state-rollback-error",valueSchema:new k(new Ce),omitEmpty:!0},{key:"inner-trace",valueSchema:new k(new Me(Hi.encodingSchema)),omitEmpty:!0},{key:"logic-sig-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"logic-sig-trace",valueSchema:new k(new Me(Ur.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({approvalProgramHash:e,approvalProgramTrace:t,clearStateProgramHash:r,clearStateProgramTrace:i,clearStateRollback:o,clearStateRollbackError:s,innerTrace:a,logicSigHash:l,logicSigTrace:c}){this.approvalProgramHash=typeof e=="string"?Ge(e):e,this.approvalProgramTrace=t,this.clearStateProgramHash=typeof r=="string"?Ge(r):r,this.clearStateProgramTrace=i,this.clearStateRollback=o,this.clearStateRollbackError=s,this.innerTrace=a,this.logicSigHash=typeof l=="string"?Ge(l):l,this.logicSigTrace=c}getEncodingSchema(){return Hi.encodingSchema}toEncodingData(){return new Map([["approval-program-hash",this.approvalProgramHash],["approval-program-trace",typeof this.approvalProgramTrace<"u"?this.approvalProgramTrace.map(e=>e.toEncodingData()):void 0],["clear-state-program-hash",this.clearStateProgramHash],["clear-state-program-trace",typeof this.clearStateProgramTrace<"u"?this.clearStateProgramTrace.map(e=>e.toEncodingData()):void 0],["clear-state-rollback",this.clearStateRollback],["clear-state-rollback-error",this.clearStateRollbackError],["inner-trace",typeof this.innerTrace<"u"?this.innerTrace.map(e=>e.toEncodingData()):void 0],["logic-sig-hash",this.logicSigHash],["logic-sig-trace",typeof this.logicSigTrace<"u"?this.logicSigTrace.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulationTransactionExecTrace: ${e}`);return new Hi({approvalProgramHash:e.get("approval-program-hash"),approvalProgramTrace:typeof e.get("approval-program-trace")<"u"?e.get("approval-program-trace").map(t=>Ur.fromEncodingData(t)):void 0,clearStateProgramHash:e.get("clear-state-program-hash"),clearStateProgramTrace:typeof e.get("clear-state-program-trace")<"u"?e.get("clear-state-program-trace").map(t=>Ur.fromEncodingData(t)):void 0,clearStateRollback:e.get("clear-state-rollback"),clearStateRollbackError:e.get("clear-state-rollback-error"),innerTrace:typeof e.get("inner-trace")<"u"?e.get("inner-trace").map(t=>Hi.fromEncodingData(t)):void 0,logicSigHash:e.get("logic-sig-hash"),logicSigTrace:typeof e.get("logic-sig-trace")<"u"?e.get("logic-sig-trace").map(t=>Ur.fromEncodingData(t)):void 0})}}let mx=class Ap{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"Message",valueSchema:_a.encodingSchema,omitEmpty:!0},{key:"StateProof",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,stateproof:t}){this.message=e,this.stateproof=typeof t=="string"?Ge(t):t}getEncodingSchema(){return Ap.encodingSchema}toEncodingData(){return new Map([["Message",this.message.toEncodingData()],["StateProof",this.stateproof]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProof: ${e}`);return new Ap({message:_a.fromEncodingData(e.get("Message")??new Map),stateproof:e.get("StateProof")})}};class _a{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"BlockHeadersCommitment",valueSchema:new Pe,omitEmpty:!0},{key:"FirstAttestedRound",valueSchema:new O,omitEmpty:!0},{key:"LastAttestedRound",valueSchema:new O,omitEmpty:!0},{key:"LnProvenWeight",valueSchema:new O,omitEmpty:!0},{key:"VotersCommitment",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({blockheaderscommitment:e,firstattestedround:t,lastattestedround:r,lnprovenweight:i,voterscommitment:o}){this.blockheaderscommitment=typeof e=="string"?Ge(e):e,this.firstattestedround=ve(t),this.lastattestedround=ve(r),this.lnprovenweight=ve(i),this.voterscommitment=typeof o=="string"?Ge(o):o}getEncodingSchema(){return _a.encodingSchema}toEncodingData(){return new Map([["BlockHeadersCommitment",this.blockheaderscommitment],["FirstAttestedRound",this.firstattestedround],["LastAttestedRound",this.lastattestedround],["LnProvenWeight",this.lnprovenweight],["VotersCommitment",this.voterscommitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofMessage: ${e}`);return new _a({blockheaderscommitment:e.get("BlockHeadersCommitment"),firstattestedround:e.get("FirstAttestedRound"),lastattestedround:e.get("LastAttestedRound"),lnprovenweight:e.get("LnProvenWeight"),voterscommitment:e.get("VotersCommitment")})}}class Cl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current_round",valueSchema:new O,omitEmpty:!0},{key:"online-money",valueSchema:new O,omitEmpty:!0},{key:"total-money",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,onlineMoney:t,totalMoney:r}){this.currentRound=ve(e),this.onlineMoney=ve(t),this.totalMoney=ve(r)}getEncodingSchema(){return Cl.encodingSchema}toEncodingData(){return new Map([["current_round",this.currentRound],["online-money",this.onlineMoney],["total-money",this.totalMoney]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SupplyResponse: ${e}`);return new Cl({currentRound:e.get("current_round"),onlineMoney:e.get("online-money"),totalMoney:e.get("total-money")})}}let Fl=class Ip{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"value",valueSchema:To.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=typeof e=="string"?Ge(e):e,this.value=t}getEncodingSchema(){return Ip.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealKeyValue: ${e}`);return new Ip({key:e.get("key"),value:To.fromEncodingData(e.get("value")??new Map)})}},To=class kp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"bytes",valueSchema:new Pe,omitEmpty:!0},{key:"type",valueSchema:new O,omitEmpty:!0},{key:"uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({bytes:e,type:t,uint:r}){this.bytes=typeof e=="string"?Ge(e):e,this.type=Le(t),this.uint=ve(r)}getEncodingSchema(){return kp.encodingSchema}toEncodingData(){return new Map([["bytes",this.bytes],["type",this.type],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealValue: ${e}`);return new kp({bytes:e.get("bytes"),type:e.get("type"),uint:e.get("uint")})}};class Dl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"Deltas",valueSchema:new Me(Ma.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({deltas:e}){this.deltas=e}getEncodingSchema(){return Dl.encodingSchema}toEncodingData(){return new Map([["Deltas",this.deltas.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionGroupLedgerStateDeltasForRoundResponse: ${e}`);return new Dl({deltas:(e.get("Deltas")??[]).map(t=>Ma.fromEncodingData(t))})}}class Tl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"consensus-version",valueSchema:new Ce,omitEmpty:!0},{key:"fee",valueSchema:new O,omitEmpty:!0},{key:"genesis-hash",valueSchema:new Pe,omitEmpty:!0},{key:"genesis-id",valueSchema:new Ce,omitEmpty:!0},{key:"last-round",valueSchema:new O,omitEmpty:!0},{key:"min-fee",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({consensusVersion:e,fee:t,genesisHash:r,genesisId:i,lastRound:o,minFee:s}){this.consensusVersion=e,this.fee=ve(t),this.genesisHash=typeof r=="string"?Ge(r):r,this.genesisId=i,this.lastRound=ve(o),this.minFee=ve(s)}getEncodingSchema(){return Tl.encodingSchema}toEncodingData(){return new Map([["consensus-version",this.consensusVersion],["fee",this.fee],["genesis-hash",this.genesisHash],["genesis-id",this.genesisId],["last-round",this.lastRound],["min-fee",this.minFee]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionParametersResponse: ${e}`);return new Tl({consensusVersion:e.get("consensus-version"),fee:e.get("fee"),genesisHash:e.get("genesis-hash"),genesisId:e.get("genesis-id"),lastRound:e.get("last-round"),minFee:e.get("min-fee")})}}class Ml{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"idx",valueSchema:new O,omitEmpty:!0},{key:"proof",valueSchema:new Pe,omitEmpty:!0},{key:"stibhash",valueSchema:new Pe,omitEmpty:!0},{key:"treedepth",valueSchema:new O,omitEmpty:!0},{key:"hashtype",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({idx:e,proof:t,stibhash:r,treedepth:i,hashtype:o}){this.idx=Le(e),this.proof=typeof t=="string"?Ge(t):t,this.stibhash=typeof r=="string"?Ge(r):r,this.treedepth=Le(i),this.hashtype=o}getEncodingSchema(){return Ml.encodingSchema}toEncodingData(){return new Map([["idx",this.idx],["proof",this.proof],["stibhash",this.stibhash],["treedepth",this.treedepth],["hashtype",this.hashtype]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionProof: ${e}`);return new Ml({idx:e.get("idx"),proof:e.get("proof"),stibhash:e.get("stibhash"),treedepth:e.get("treedepth"),hashtype:e.get("hashtype")})}}class Rl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"build",valueSchema:Ca.encodingSchema,omitEmpty:!0},{key:"genesis_hash_b64",valueSchema:new Pe,omitEmpty:!0},{key:"genesis_id",valueSchema:new Ce,omitEmpty:!0},{key:"versions",valueSchema:new Me(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({build:e,genesisHashB64:t,genesisId:r,versions:i}){this.build=e,this.genesisHashB64=typeof t=="string"?Ge(t):t,this.genesisId=r,this.versions=i}getEncodingSchema(){return Rl.encodingSchema}toEncodingData(){return new Map([["build",this.build.toEncodingData()],["genesis_hash_b64",this.genesisHashB64],["genesis_id",this.genesisId],["versions",this.versions]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Version: ${e}`);return new Rl({build:Ca.fromEncodingData(e.get("build")??new Map),genesisHashB64:e.get("genesis_hash_b64"),genesisId:e.get("genesis_id"),versions:e.get("versions")})}}const NI=Object.freeze(Object.defineProperty({__proto__:null,Account:yd,AccountApplicationResponse:hl,AccountAssetHolding:xa,AccountAssetResponse:fl,AccountAssetsInformationResponse:wd,AccountParticipation:np,AccountStateDelta:pl,AppCallLogs:va,Application:Is,ApplicationInitialStates:Sa,ApplicationKVStorage:_r,ApplicationLocalReference:ba,ApplicationLocalState:gl,ApplicationParams:Ea,ApplicationStateOperation:Aa,ApplicationStateSchema:Dr,Asset:xd,AssetHolding:ks,AssetHoldingReference:Ia,AssetParams:Cs,AvmKeyValue:ka,AvmValue:vr,BlockHashResponse:ml,BlockLogsResponse:vd,BlockResponse:yl,BlockTxidsResponse:wl,Box:fx,BoxDescriptor:fp,BoxReference:gp,BoxesResponse:px,BuildVersion:Ca,CompileResponse:xl,DisassembleResponse:vl,DryrunRequest:Sl,DryrunResponse:bl,DryrunSource:Fa,DryrunState:zi,DryrunTxnResult:Da,ErrorResponse:RI,EvalDelta:xp,EvalDeltaKeyValue:Fs,Genesis:BI,GenesisAllocation:Ta,GetBlockTimeStampOffsetResponse:El,GetSyncRoundResponse:Al,LedgerStateDeltaForTransactionGroup:Ma,LightBlockHeaderProof:gx,NodeStatusResponse:Ra,PendingTransactionResponse:hi,PendingTransactionsResponse:Ba,PostTransactionsResponse:Il,ScratchChange:Na,SimulateInitialStates:Pa,SimulateRequest:Oa,SimulateRequestTransactionGroup:ro,SimulateResponse:kl,SimulateTraceConfig:io,SimulateTransactionGroupResult:La,SimulateTransactionResult:Va,SimulateUnnamedResourcesAccessed:oo,SimulationEvalOverrides:$a,SimulationOpcodeTraceUnit:Ur,SimulationTransactionExecTrace:Hi,StateProof:mx,StateProofMessage:_a,SupplyResponse:Cl,TealKeyValue:Fl,TealValue:To,TransactionGroupLedgerStateDeltasForRoundResponse:Dl,TransactionParametersResponse:Tl,TransactionProof:Ml,Version:Rl},Symbol.toStringTag,{value:"Module"}));class lt{constructor(e){this.c=e,this.query={}}executeRequest(e,t){return this.c.get({relativePath:this.path(),query:this.query,requestHeaders:e,customOptions:t})}async do(e,t){const r=await this.executeRequest(e,t);return this.prepare(r)}async doRaw(e,t){return(await this.executeRequest(e,t)).body}}class PI extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}`}exclude(e){return this.query.exclude=e,this}prepare(e){return Et(e.getJSONText(),yd)}}class OI extends lt{constructor(e,t,r){super(e),this.account=t.toString(),this.assetID=BigInt(r)}path(){return`/v2/accounts/${this.account}/assets/${this.assetID}`}prepare(e){return Et(e.getJSONText(),fl)}}class LI extends lt{constructor(e,t,r){super(e),this.account=t.toString(),this.applicationID=BigInt(r)}path(){return`/v2/accounts/${this.account}/applications/${this.applicationID}`}prepare(e){return Et(e.getJSONText(),hl)}}let VI=class extends lt{constructor(e,t){super(e),this.round=BigInt(t),this.query={format:"msgpack"}}path(){return`/v2/blocks/${this.round}`}headerOnly(e){return this.query["header-only"]=e,this}prepare(e){return Xt(e.body,yl)}};function yx(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="text/plain"),e}class $I extends lt{constructor(e,t){super(e),this.source=t}path(){return"/v2/teal/compile"}sourcemap(e=!0){return this.query.sourcemap=e,this}executeRequest(e,t){const r=yx(e);return this.c.post({relativePath:this.path(),data:qr(this.source),query:this.query,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),xl)}}class _I extends lt{constructor(e,t){super(e),this.blob=Sr(t)}path(){return"/v2/teal/dryrun"}executeRequest(e,t){const r=yx(e);return this.c.post({relativePath:this.path(),data:this.blob,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),bl)}}class UI extends lt{path(){return"/genesis"}prepare(e){return e.getJSONText()}}class jI extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}`}prepare(e){return Et(e.getJSONText(),xd)}}class GI extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/applications/${this.index}`}prepare(e){return Et(e.getJSONText(),Is)}}class WI extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/hash`}prepare(e){return Et(e.getJSONText(),ml)}}class zI extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/txids`}prepare(e){return Et(e.getJSONText(),wl)}}class HI extends lt{constructor(e,t,r){super(e),this.index=BigInt(t);const i=In(r);this.query.name=encodeURI(`b64:${i}`)}path(){return`/v2/applications/${this.index}/box`}prepare(e){return Et(e.getJSONText(),fx)}}class YI extends lt{constructor(e,t){super(e),this.index=BigInt(t),this.query.max=0}path(){return`/v2/applications/${this.index}/boxes`}max(e){return this.query.max=e,this}prepare(e){return Et(e.getJSONText(),px)}}let KI=class extends lt{path(){return"/health"}prepare(e){}};class qI extends lt{constructor(e,t){super(e),this.txid=t,this.query.format="msgpack"}prepare(e){return Xt(e.body,hi)}path(){return`/v2/transactions/pending/${this.txid}`}max(e){return this.query.max=e,this}}class XI extends lt{constructor(e){super(e),this.query.format="msgpack"}path(){return"/v2/transactions/pending"}prepare(e){return Xt(e.body,Ba)}max(e){return this.query.max=e,this}}class ZI extends lt{constructor(e,t){super(e),this.address=t.toString(),this.query.format="msgpack"}prepare(e){return Xt(e.body,Ba)}path(){return`/v2/accounts/${this.address}/transactions/pending`}max(e){return this.query.max=e,this}}class JI extends lt{constructor(e,t,r){super(e),this.txID=r,this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/transactions/${this.txID}/proof`}hashType(e){return this.query.hashtype=e,this}prepare(e){return Et(e.getJSONText(),Ml)}}function QI(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="application/x-binary"),e}function Zm(n){return n&&n.byteLength!==void 0}class ek extends lt{constructor(e,t){super(e);let r=t;if(Array.isArray(t)){if(!t.every(Zm))throw new TypeError("Array elements must be byte arrays");r=hn(...t)}else if(!Zm(r))throw new TypeError("Argument must be byte array");this.txnBytesToPost=r}path(){return"/v2/transactions"}executeRequest(e,t){const r=QI(e);return this.c.post({relativePath:this.path(),data:this.txnBytesToPost,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),Il)}}class tk extends lt{path(){return"/v2/status"}prepare(e){return Et(e.getJSONText(),Ra)}}class nk extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/status/wait-for-block-after/${this.round}`}prepare(e){return Et(e.getJSONText(),Ra)}}class rk extends lt{path(){return"/v2/transactions/params"}prepare(e){const t=Et(e.getJSONText(),Tl);return{flatFee:!1,fee:t.fee,firstValid:t.lastRound,lastValid:t.lastRound+BigInt(1e3),genesisID:t.genesisId,genesisHash:t.genesisHash,minFee:t.minFee,consensusVersion:t.consensusVersion}}}class ik extends lt{path(){return"/v2/ledger/supply"}prepare(e){return Et(e.getJSONText(),Cl)}}class ok extends lt{path(){return"/versions"}prepare(e){return Et(e.getJSONText(),Rl)}}class sk extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/lightheader/proof`}prepare(e){return Et(e.getJSONText(),gx)}}class ak extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/stateproofs/${this.round}`}prepare(e){return Et(e.getJSONText(),mx)}}class ck extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/ledger/sync/${this.round}`}executeRequest(e,t){return this.c.post({relativePath:this.path(),data:null,requestHeaders:e,customOptions:t})}prepare(e){}}class lk extends lt{path(){return"/v2/ledger/sync"}prepare(e){return Et(e.getJSONText(),Al)}}class uk extends lt{constructor(e,t){super(e),this.offset=BigInt(t)}path(){return`/v2/devmode/blocks/offset/${this.offset}`}executeRequest(e,t){return this.c.post({relativePath:this.path(),data:null,requestHeaders:e,customOptions:t})}prepare(e){}}class dk extends lt{path(){return"/v2/devmode/blocks/offset"}prepare(e){return Et(e.getJSONText(),El)}}function hk(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="text/plain"),e}class fk extends lt{constructor(e,t){super(e),this.source=t}path(){return"/v2/teal/disassemble"}executeRequest(e,t){const r=hk(e);return this.c.post({relativePath:this.path(),data:qr(this.source),query:this.query,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),vl)}}function pk(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="application/msgpack"),e}class gk extends lt{constructor(e,t){super(e),this.query.format="msgpack",this.requestBytes=Sr(t)}path(){return"/v2/transactions/simulate"}executeRequest(e,t){const r=pk(e);return this.c.post({relativePath:this.path(),data:this.requestBytes,query:this.query,requestHeaders:r,customOptions:t})}prepare(e){return Xt(e.body,kl)}}class mk extends lt{path(){return"/ready"}prepare(e){}}class yk extends lt{path(){return"/v2/ledger/sync"}executeRequest(e,t){return this.c.delete({relativePath:this.path(),data:void 0,requestHeaders:e,customOptions:t})}prepare(e){}}class wk extends lt{constructor(e,t){super(e),this.id=t,this.query={format:"msgpack"}}path(){return`/v2/deltas/txn/group/${this.id}`}prepare(e){return Xt(e.body,Si)}}class xk extends lt{constructor(e,t){super(e),this.round=BigInt(t),this.query={format:"msgpack"}}path(){return`/v2/deltas/${this.round}`}prepare(e){return Xt(e.body,Si)}}class vk extends lt{constructor(e,t){super(e),this.round=BigInt(t),this.query={format:"msgpack"}}path(){return`/v2/deltas/${this.round}/txn/group`}prepare(e){return Xt(e.body,Dl)}}class Sk extends cg{constructor(e,t,r,i={}){super("X-Algo-API-Token",e,t,r,i)}healthCheck(){return new KI(this.c)}versionsCheck(){return new ok(this.c)}sendRawTransaction(e){return new ek(this.c,e)}accountInformation(e){return new PI(this.c,e)}accountAssetInformation(e,t){return new OI(this.c,e,t)}accountApplicationInformation(e,t){return new LI(this.c,e,t)}block(e){return new VI(this.c,e)}getBlockHash(e){return new WI(this.c,e)}getBlockTxids(e){return new zI(this.c,e)}pendingTransactionInformation(e){return new qI(this.c,e)}pendingTransactionsInformation(){return new XI(this.c)}pendingTransactionByAddress(e){return new ZI(this.c,e)}status(){return new tk(this.c)}statusAfterBlock(e){return new nk(this.c,e)}getTransactionParams(){return new rk(this.c)}supply(){return new ik(this.c)}compile(e){return new $I(this.c,e)}disassemble(e){return new fk(this.c,e)}dryrun(e){return new _I(this.c,e)}getAssetByID(e){return new jI(this.c,e)}getApplicationByID(e){return new GI(this.c,e)}getApplicationBoxByName(e,t){return new HI(this.c,e,t)}getApplicationBoxes(e){return new YI(this.c,e)}genesis(){return new UI(this.c)}getTransactionProof(e,t){return new JI(this.c,e,t)}getLightBlockHeaderProof(e){return new sk(this.c,e)}getStateProof(e){return new ak(this.c,e)}simulateRawTransactions(e){const t=[];if(Array.isArray(e))for(const i of e)t.push(Xt(i,jt));else t.push(Xt(e,jt));const r=new Oa({txnGroups:[new ro({txns:t})]});return this.simulateTransactions(r)}simulateTransactions(e){return new gk(this.c,e)}setBlockOffsetTimestamp(e){return new uk(this.c,e)}getBlockOffsetTimestamp(){return new dk(this.c)}setSyncRound(e){return new ck(this.c,e)}unsetSyncRound(){return new yk(this.c)}getSyncRound(){return new lk(this.c)}ready(){return new mk(this.c)}getLedgerStateDeltaForTransactionGroup(e){return new wk(this.c,e)}getLedgerStateDelta(e){return new xk(this.c,e)}getTransactionGroupLedgerStateDeltasForRound(e){return new vk(this.c,e)}}class bk extends cg{constructor(e,t="http://127.0.0.1",r=7833,i={}){super("X-KMD-API-Token",e,t,r,i)}async get(e){return(await this.c.get({relativePath:e})).parseBodyAsJSON({intDecoding:an.SAFE})}async delete(e,t){return(await this.c.delete({relativePath:e,data:t})).parseBodyAsJSON({intDecoding:an.SAFE})}async post(e,t){return(await this.c.post({relativePath:e,data:t})).parseBodyAsJSON({intDecoding:an.SAFE})}async versions(){return this.get("/versions")}async listWallets(){return this.get("/v1/wallets")}async createWallet(e,t,r=new Uint8Array,i="sqlite"){const o={wallet_name:e,wallet_driver_name:i,wallet_password:t,master_derivation_key:In(r)};return this.post("/v1/wallet",o)}async initWalletHandle(e,t){const r={wallet_id:e,wallet_password:t};return this.post("/v1/wallet/init",r)}async releaseWalletHandle(e){const t={wallet_handle_token:e};return this.post("/v1/wallet/release",t)}async renewWalletHandle(e){const t={wallet_handle_token:e};return this.post("/v1/wallet/renew",t)}async renameWallet(e,t,r){const i={wallet_id:e,wallet_password:t,wallet_name:r};return this.post("/v1/wallet/rename",i)}async getWallet(e){const t={wallet_handle_token:e};return this.post("/v1/wallet/info",t)}async exportMasterDerivationKey(e,t){const r={wallet_handle_token:e,wallet_password:t},i=await this.post("/v1/master-key/export",r);return{master_derivation_key:Ge(i.master_derivation_key)}}async importKey(e,t){const r={wallet_handle_token:e,private_key:In(t)};return this.post("/v1/key/import",r)}async exportKey(e,t,r){const i={wallet_handle_token:e,address:r,wallet_password:t},o=await this.post("/v1/key/export",i);return{private_key:Ge(o.private_key)}}async generateKey(e){const t={wallet_handle_token:e,display_mnemonic:!1};return this.post("/v1/key",t)}async deleteKey(e,t,r){const i={wallet_handle_token:e,address:r,wallet_password:t};return this.delete("/v1/key",i)}async listKeys(e){const t={wallet_handle_token:e};return this.post("/v1/key/list",t)}async signTransaction(e,t,r){const i={wallet_handle_token:e,wallet_password:t,transaction:In(r.toByte())},o=await this.post("/v1/transaction/sign",i);return Ge(o.signed_transaction)}async signTransactionWithSpecificPublicKey(e,t,r,i){const o=qr(i),s={wallet_handle_token:e,wallet_password:t,transaction:In(r.toByte()),public_key:In(o)},a=await this.post("/v1/transaction/sign",s);return Ge(a.signed_transaction)}async listMultisig(e){const t={wallet_handle_token:e};return this.post("/v1/multisig/list",t)}async importMultisig(e,t,r,i){const o={wallet_handle_token:e,multisig_version:t,threshold:r,pks:i};return this.post("/v1/multisig/import",o)}async exportMultisig(e,t){const r={wallet_handle_token:e,address:t};return this.post("/v1/multisig/export",r)}async signMultisigTransaction(e,t,r,i,o){const s=qr(i),a={wallet_handle_token:e,transaction:In(r.toByte()),public_key:In(s),partial_multisig:o,wallet_password:t};return this.post("/v1/multisig/sign",a)}async deleteMultisig(e,t,r){const i={wallet_handle_token:e,address:r,wallet_password:t};return this.delete("/v1/multisig",i)}}class so{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"amount",valueSchema:new O,omitEmpty:!0},{key:"amount-without-pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"min-balance",valueSchema:new O,omitEmpty:!0},{key:"pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"rewards",valueSchema:new O,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"status",valueSchema:new Ce,omitEmpty:!0},{key:"total-apps-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-assets-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-box-bytes",valueSchema:new O,omitEmpty:!0},{key:"total-boxes",valueSchema:new O,omitEmpty:!0},{key:"total-created-apps",valueSchema:new O,omitEmpty:!0},{key:"total-created-assets",valueSchema:new O,omitEmpty:!0},{key:"apps-local-state",valueSchema:new k(new Me(ao.encodingSchema)),omitEmpty:!0},{key:"apps-total-extra-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"apps-total-schema",valueSchema:new k(yr.encodingSchema),omitEmpty:!0},{key:"assets",valueSchema:new k(new Me(co.encodingSchema)),omitEmpty:!0},{key:"auth-addr",valueSchema:new k(new Ce),omitEmpty:!0},{key:"closed-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"created-apps",valueSchema:new k(new Me(Zr.encodingSchema)),omitEmpty:!0},{key:"created-assets",valueSchema:new k(new Me(Jr.encodingSchema)),omitEmpty:!0},{key:"created-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"incentive-eligible",valueSchema:new k(new gt),omitEmpty:!0},{key:"last-heartbeat",valueSchema:new k(new O),omitEmpty:!0},{key:"last-proposed",valueSchema:new k(new O),omitEmpty:!0},{key:"participation",valueSchema:new k(Ua.encodingSchema),omitEmpty:!0},{key:"reward-base",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-type",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,amount:t,amountWithoutPendingRewards:r,minBalance:i,pendingRewards:o,rewards:s,round:a,status:l,totalAppsOptedIn:c,totalAssetsOptedIn:d,totalBoxBytes:u,totalBoxes:m,totalCreatedApps:h,totalCreatedAssets:x,appsLocalState:A,appsTotalExtraPages:v,appsTotalSchema:F,assets:w,authAddr:C,closedAtRound:M,createdApps:N,createdAssets:b,createdAtRound:j,deleted:p,incentiveEligible:E,lastHeartbeat:S,lastProposed:$,participation:B,rewardBase:P,sigType:W}){this.address=e,this.amount=ve(t),this.amountWithoutPendingRewards=ve(r),this.minBalance=Le(i),this.pendingRewards=ve(o),this.rewards=ve(s),this.round=ve(a),this.status=l,this.totalAppsOptedIn=Le(c),this.totalAssetsOptedIn=Le(d),this.totalBoxBytes=Le(u),this.totalBoxes=Le(m),this.totalCreatedApps=Le(h),this.totalCreatedAssets=Le(x),this.appsLocalState=A,this.appsTotalExtraPages=typeof v>"u"?void 0:Le(v),this.appsTotalSchema=F,this.assets=w,this.authAddr=typeof C=="string"?ze.fromString(C):C,this.closedAtRound=typeof M>"u"?void 0:ve(M),this.createdApps=N,this.createdAssets=b,this.createdAtRound=typeof j>"u"?void 0:ve(j),this.deleted=p,this.incentiveEligible=E,this.lastHeartbeat=typeof S>"u"?void 0:Le(S),this.lastProposed=typeof $>"u"?void 0:Le($),this.participation=B,this.rewardBase=typeof P>"u"?void 0:ve(P),this.sigType=W}getEncodingSchema(){return so.encodingSchema}toEncodingData(){return new Map([["address",this.address],["amount",this.amount],["amount-without-pending-rewards",this.amountWithoutPendingRewards],["min-balance",this.minBalance],["pending-rewards",this.pendingRewards],["rewards",this.rewards],["round",this.round],["status",this.status],["total-apps-opted-in",this.totalAppsOptedIn],["total-assets-opted-in",this.totalAssetsOptedIn],["total-box-bytes",this.totalBoxBytes],["total-boxes",this.totalBoxes],["total-created-apps",this.totalCreatedApps],["total-created-assets",this.totalCreatedAssets],["apps-local-state",typeof this.appsLocalState<"u"?this.appsLocalState.map(e=>e.toEncodingData()):void 0],["apps-total-extra-pages",this.appsTotalExtraPages],["apps-total-schema",typeof this.appsTotalSchema<"u"?this.appsTotalSchema.toEncodingData():void 0],["assets",typeof this.assets<"u"?this.assets.map(e=>e.toEncodingData()):void 0],["auth-addr",typeof this.authAddr<"u"?this.authAddr.toString():void 0],["closed-at-round",this.closedAtRound],["created-apps",typeof this.createdApps<"u"?this.createdApps.map(e=>e.toEncodingData()):void 0],["created-assets",typeof this.createdAssets<"u"?this.createdAssets.map(e=>e.toEncodingData()):void 0],["created-at-round",this.createdAtRound],["deleted",this.deleted],["incentive-eligible",this.incentiveEligible],["last-heartbeat",this.lastHeartbeat],["last-proposed",this.lastProposed],["participation",typeof this.participation<"u"?this.participation.toEncodingData():void 0],["reward-base",this.rewardBase],["sig-type",this.sigType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Account: ${e}`);return new so({address:e.get("address"),amount:e.get("amount"),amountWithoutPendingRewards:e.get("amount-without-pending-rewards"),minBalance:e.get("min-balance"),pendingRewards:e.get("pending-rewards"),rewards:e.get("rewards"),round:e.get("round"),status:e.get("status"),totalAppsOptedIn:e.get("total-apps-opted-in"),totalAssetsOptedIn:e.get("total-assets-opted-in"),totalBoxBytes:e.get("total-box-bytes"),totalBoxes:e.get("total-boxes"),totalCreatedApps:e.get("total-created-apps"),totalCreatedAssets:e.get("total-created-assets"),appsLocalState:typeof e.get("apps-local-state")<"u"?e.get("apps-local-state").map(t=>ao.fromEncodingData(t)):void 0,appsTotalExtraPages:e.get("apps-total-extra-pages"),appsTotalSchema:typeof e.get("apps-total-schema")<"u"?yr.fromEncodingData(e.get("apps-total-schema")):void 0,assets:typeof e.get("assets")<"u"?e.get("assets").map(t=>co.fromEncodingData(t)):void 0,authAddr:e.get("auth-addr"),closedAtRound:e.get("closed-at-round"),createdApps:typeof e.get("created-apps")<"u"?e.get("created-apps").map(t=>Zr.fromEncodingData(t)):void 0,createdAssets:typeof e.get("created-assets")<"u"?e.get("created-assets").map(t=>Jr.fromEncodingData(t)):void 0,createdAtRound:e.get("created-at-round"),deleted:e.get("deleted"),incentiveEligible:e.get("incentive-eligible"),lastHeartbeat:e.get("last-heartbeat"),lastProposed:e.get("last-proposed"),participation:typeof e.get("participation")<"u"?Ua.fromEncodingData(e.get("participation")):void 0,rewardBase:e.get("reward-base"),sigType:e.get("sig-type")})}}class Ua{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"selection-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"vote-first-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-key-dilution",valueSchema:new O,omitEmpty:!0},{key:"vote-last-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"state-proof-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({selectionParticipationKey:e,voteFirstValid:t,voteKeyDilution:r,voteLastValid:i,voteParticipationKey:o,stateProofKey:s}){this.selectionParticipationKey=typeof e=="string"?Ge(e):e,this.voteFirstValid=ve(t),this.voteKeyDilution=ve(r),this.voteLastValid=ve(i),this.voteParticipationKey=typeof o=="string"?Ge(o):o,this.stateProofKey=typeof s=="string"?Ge(s):s}getEncodingSchema(){return Ua.encodingSchema}toEncodingData(){return new Map([["selection-participation-key",this.selectionParticipationKey],["vote-first-valid",this.voteFirstValid],["vote-key-dilution",this.voteKeyDilution],["vote-last-valid",this.voteLastValid],["vote-participation-key",this.voteParticipationKey],["state-proof-key",this.stateProofKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountParticipation: ${e}`);return new Ua({selectionParticipationKey:e.get("selection-participation-key"),voteFirstValid:e.get("vote-first-valid"),voteKeyDilution:e.get("vote-key-dilution"),voteLastValid:e.get("vote-last-valid"),voteParticipationKey:e.get("vote-participation-key"),stateProofKey:e.get("state-proof-key")})}}class Bl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"account",valueSchema:so.encodingSchema,omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({account:e,currentRound:t}){this.account=e,this.currentRound=ve(t)}getEncodingSchema(){return Bl.encodingSchema}toEncodingData(){return new Map([["account",this.account.toEncodingData()],["current-round",this.currentRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountResponse: ${e}`);return new Bl({account:so.fromEncodingData(e.get("account")??new Map),currentRound:e.get("current-round")})}}class ja{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"delta",valueSchema:new Me(ho.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,delta:t}){this.address=e,this.delta=t}getEncodingSchema(){return ja.encodingSchema}toEncodingData(){return new Map([["address",this.address],["delta",this.delta.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountStateDelta: ${e}`);return new ja({address:e.get("address"),delta:(e.get("delta")??[]).map(t=>ho.fromEncodingData(t))})}}class Nl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"accounts",valueSchema:new Me(so.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({accounts:e,currentRound:t,nextToken:r}){this.accounts=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Nl.encodingSchema}toEncodingData(){return new Map([["accounts",this.accounts.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountsResponse: ${e}`);return new Nl({accounts:(e.get("accounts")??[]).map(t=>so.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Zr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:Wa.encodingSchema,omitEmpty:!0},{key:"created-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"deleted-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,params:t,createdAtRound:r,deleted:i,deletedAtRound:o}){this.id=ve(e),this.params=t,this.createdAtRound=typeof r>"u"?void 0:ve(r),this.deleted=i,this.deletedAtRound=typeof o>"u"?void 0:ve(o)}getEncodingSchema(){return Zr.encodingSchema}toEncodingData(){return new Map([["id",this.id],["params",this.params.toEncodingData()],["created-at-round",this.createdAtRound],["deleted",this.deleted],["deleted-at-round",this.deletedAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Application: ${e}`);return new Zr({id:e.get("id"),params:Wa.fromEncodingData(e.get("params")??new Map),createdAtRound:e.get("created-at-round"),deleted:e.get("deleted"),deletedAtRound:e.get("deleted-at-round")})}}class ao{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"schema",valueSchema:yr.encodingSchema,omitEmpty:!0},{key:"closed-out-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"key-value",valueSchema:new k(new Me(fo.encodingSchema)),omitEmpty:!0},{key:"opted-in-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,schema:t,closedOutAtRound:r,deleted:i,keyValue:o,optedInAtRound:s}){this.id=ve(e),this.schema=t,this.closedOutAtRound=typeof r>"u"?void 0:ve(r),this.deleted=i,this.keyValue=o,this.optedInAtRound=typeof s>"u"?void 0:ve(s)}getEncodingSchema(){return ao.encodingSchema}toEncodingData(){return new Map([["id",this.id],["schema",this.schema.toEncodingData()],["closed-out-at-round",this.closedOutAtRound],["deleted",this.deleted],["key-value",typeof this.keyValue<"u"?this.keyValue.map(e=>e.toEncodingData()):void 0],["opted-in-at-round",this.optedInAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalState: ${e}`);return new ao({id:e.get("id"),schema:yr.fromEncodingData(e.get("schema")??new Map),closedOutAtRound:e.get("closed-out-at-round"),deleted:e.get("deleted"),keyValue:typeof e.get("key-value")<"u"?e.get("key-value").map(t=>fo.fromEncodingData(t)):void 0,optedInAtRound:e.get("opted-in-at-round")})}}class Pl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"apps-local-states",valueSchema:new Me(ao.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({appsLocalStates:e,currentRound:t,nextToken:r}){this.appsLocalStates=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Pl.encodingSchema}toEncodingData(){return new Map([["apps-local-states",this.appsLocalStates.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalStatesResponse: ${e}`);return new Pl({appsLocalStates:(e.get("apps-local-states")??[]).map(t=>ao.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Ga{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logs",valueSchema:new Me(new Pe),omitEmpty:!0},{key:"txid",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({logs:e,txid:t}){this.logs=e,this.txid=t}getEncodingSchema(){return Ga.encodingSchema}toEncodingData(){return new Map([["logs",this.logs],["txid",this.txid]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLogData: ${e}`);return new Ga({logs:e.get("logs"),txid:e.get("txid")})}}class Ol{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-id",valueSchema:new O,omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"log-data",valueSchema:new k(new Me(Ga.encodingSchema)),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationId:e,currentRound:t,logData:r,nextToken:i}){this.applicationId=ve(e),this.currentRound=ve(t),this.logData=r,this.nextToken=i}getEncodingSchema(){return Ol.encodingSchema}toEncodingData(){return new Map([["application-id",this.applicationId],["current-round",this.currentRound],["log-data",typeof this.logData<"u"?this.logData.map(e=>e.toEncodingData()):void 0],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLogsResponse: ${e}`);return new Ol({applicationId:e.get("application-id"),currentRound:e.get("current-round"),logData:typeof e.get("log-data")<"u"?e.get("log-data").map(t=>Ga.fromEncodingData(t)):void 0,nextToken:e.get("next-token")})}}class Wa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"approval-program",valueSchema:new Pe,omitEmpty:!0},{key:"clear-state-program",valueSchema:new Pe,omitEmpty:!0},{key:"creator",valueSchema:new k(new Ce),omitEmpty:!0},{key:"extra-program-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"global-state",valueSchema:new k(new Me(fo.encodingSchema)),omitEmpty:!0},{key:"global-state-schema",valueSchema:new k(yr.encodingSchema),omitEmpty:!0},{key:"local-state-schema",valueSchema:new k(yr.encodingSchema),omitEmpty:!0},{key:"version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({approvalProgram:e,clearStateProgram:t,creator:r,extraProgramPages:i,globalState:o,globalStateSchema:s,localStateSchema:a,version:l}){this.approvalProgram=typeof e=="string"?Ge(e):e,this.clearStateProgram=typeof t=="string"?Ge(t):t,this.creator=typeof r=="string"?ze.fromString(r):r,this.extraProgramPages=typeof i>"u"?void 0:Le(i),this.globalState=o,this.globalStateSchema=s,this.localStateSchema=a,this.version=typeof l>"u"?void 0:Le(l)}getEncodingSchema(){return Wa.encodingSchema}toEncodingData(){return new Map([["approval-program",this.approvalProgram],["clear-state-program",this.clearStateProgram],["creator",typeof this.creator<"u"?this.creator.toString():void 0],["extra-program-pages",this.extraProgramPages],["global-state",typeof this.globalState<"u"?this.globalState.map(e=>e.toEncodingData()):void 0],["global-state-schema",typeof this.globalStateSchema<"u"?this.globalStateSchema.toEncodingData():void 0],["local-state-schema",typeof this.localStateSchema<"u"?this.localStateSchema.toEncodingData():void 0],["version",this.version]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationParams: ${e}`);return new Wa({approvalProgram:e.get("approval-program"),clearStateProgram:e.get("clear-state-program"),creator:e.get("creator"),extraProgramPages:e.get("extra-program-pages"),globalState:typeof e.get("global-state")<"u"?e.get("global-state").map(t=>fo.fromEncodingData(t)):void 0,globalStateSchema:typeof e.get("global-state-schema")<"u"?yr.fromEncodingData(e.get("global-state-schema")):void 0,localStateSchema:typeof e.get("local-state-schema")<"u"?yr.fromEncodingData(e.get("local-state-schema")):void 0,version:e.get("version")})}}class Ll{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"application",valueSchema:new k(Zr.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,application:t}){this.currentRound=ve(e),this.application=t}getEncodingSchema(){return Ll.encodingSchema}toEncodingData(){return new Map([["current-round",this.currentRound],["application",typeof this.application<"u"?this.application.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationResponse: ${e}`);return new Ll({currentRound:e.get("current-round"),application:typeof e.get("application")<"u"?Zr.fromEncodingData(e.get("application")):void 0})}}class yr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"num-byte-slice",valueSchema:new O,omitEmpty:!0},{key:"num-uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({numByteSlice:e,numUint:t}){this.numByteSlice=Le(e),this.numUint=Le(t)}getEncodingSchema(){return yr.encodingSchema}toEncodingData(){return new Map([["num-byte-slice",this.numByteSlice],["num-uint",this.numUint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationStateSchema: ${e}`);return new yr({numByteSlice:e.get("num-byte-slice"),numUint:e.get("num-uint")})}}class za{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"applications",valueSchema:new Me(Zr.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({applications:e,currentRound:t,nextToken:r}){this.applications=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return za.encodingSchema}toEncodingData(){return new Map([["applications",this.applications.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationsResponse: ${e}`);return new za({applications:(e.get("applications")??[]).map(t=>Zr.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Jr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"index",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:lo.encodingSchema,omitEmpty:!0},{key:"created-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"destroyed-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({index:e,params:t,createdAtRound:r,deleted:i,destroyedAtRound:o}){this.index=ve(e),this.params=t,this.createdAtRound=typeof r>"u"?void 0:ve(r),this.deleted=i,this.destroyedAtRound=typeof o>"u"?void 0:ve(o)}getEncodingSchema(){return Jr.encodingSchema}toEncodingData(){return new Map([["index",this.index],["params",this.params.toEncodingData()],["created-at-round",this.createdAtRound],["deleted",this.deleted],["destroyed-at-round",this.destroyedAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Asset: ${e}`);return new Jr({index:e.get("index"),params:lo.fromEncodingData(e.get("params")??new Map),createdAtRound:e.get("created-at-round"),deleted:e.get("deleted"),destroyedAtRound:e.get("destroyed-at-round")})}}class Vl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"balances",valueSchema:new Me(rc.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({balances:e,currentRound:t,nextToken:r}){this.balances=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Vl.encodingSchema}toEncodingData(){return new Map([["balances",this.balances.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetBalancesResponse: ${e}`);return new Vl({balances:(e.get("balances")??[]).map(t=>rc.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class co{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"is-frozen",valueSchema:new gt,omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"opted-in-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"opted-out-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,assetId:t,isFrozen:r,deleted:i,optedInAtRound:o,optedOutAtRound:s}){this.amount=ve(e),this.assetId=ve(t),this.isFrozen=r,this.deleted=i,this.optedInAtRound=typeof o>"u"?void 0:ve(o),this.optedOutAtRound=typeof s>"u"?void 0:ve(s)}getEncodingSchema(){return co.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["asset-id",this.assetId],["is-frozen",this.isFrozen],["deleted",this.deleted],["opted-in-at-round",this.optedInAtRound],["opted-out-at-round",this.optedOutAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${e}`);return new co({amount:e.get("amount"),assetId:e.get("asset-id"),isFrozen:e.get("is-frozen"),deleted:e.get("deleted"),optedInAtRound:e.get("opted-in-at-round"),optedOutAtRound:e.get("opted-out-at-round")})}}class $l{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"assets",valueSchema:new Me(co.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({assets:e,currentRound:t,nextToken:r}){this.assets=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return $l.encodingSchema}toEncodingData(){return new Map([["assets",this.assets.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHoldingsResponse: ${e}`);return new $l({assets:(e.get("assets")??[]).map(t=>co.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class lo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"creator",valueSchema:new Ce,omitEmpty:!0},{key:"decimals",valueSchema:new O,omitEmpty:!0},{key:"total",valueSchema:new O,omitEmpty:!0},{key:"clawback",valueSchema:new k(new Ce),omitEmpty:!0},{key:"default-frozen",valueSchema:new k(new gt),omitEmpty:!0},{key:"freeze",valueSchema:new k(new Ce),omitEmpty:!0},{key:"manager",valueSchema:new k(new Ce),omitEmpty:!0},{key:"metadata-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"reserve",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"url",valueSchema:new k(new Ce),omitEmpty:!0},{key:"url-b64",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({creator:e,decimals:t,total:r,clawback:i,defaultFrozen:o,freeze:s,manager:a,metadataHash:l,name:c,nameB64:d,reserve:u,unitName:m,unitNameB64:h,url:x,urlB64:A}){this.creator=e,this.decimals=Le(t),this.total=ve(r),this.clawback=i,this.defaultFrozen=o,this.freeze=s,this.manager=a,this.metadataHash=typeof l=="string"?Ge(l):l,this.name=c,this.nameB64=typeof d=="string"?Ge(d):d,this.reserve=u,this.unitName=m,this.unitNameB64=typeof h=="string"?Ge(h):h,this.url=x,this.urlB64=typeof A=="string"?Ge(A):A}getEncodingSchema(){return lo.encodingSchema}toEncodingData(){return new Map([["creator",this.creator],["decimals",this.decimals],["total",this.total],["clawback",this.clawback],["default-frozen",this.defaultFrozen],["freeze",this.freeze],["manager",this.manager],["metadata-hash",this.metadataHash],["name",this.name],["name-b64",this.nameB64],["reserve",this.reserve],["unit-name",this.unitName],["unit-name-b64",this.unitNameB64],["url",this.url],["url-b64",this.urlB64]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParams: ${e}`);return new lo({creator:e.get("creator"),decimals:e.get("decimals"),total:e.get("total"),clawback:e.get("clawback"),defaultFrozen:e.get("default-frozen"),freeze:e.get("freeze"),manager:e.get("manager"),metadataHash:e.get("metadata-hash"),name:e.get("name"),nameB64:e.get("name-b64"),reserve:e.get("reserve"),unitName:e.get("unit-name"),unitNameB64:e.get("unit-name-b64"),url:e.get("url"),urlB64:e.get("url-b64")})}}class _l{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"asset",valueSchema:Jr.encodingSchema,omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({asset:e,currentRound:t}){this.asset=e,this.currentRound=ve(t)}getEncodingSchema(){return _l.encodingSchema}toEncodingData(){return new Map([["asset",this.asset.toEncodingData()],["current-round",this.currentRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetResponse: ${e}`);return new _l({asset:Jr.fromEncodingData(e.get("asset")??new Map),currentRound:e.get("current-round")})}}class Ha{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"assets",valueSchema:new Me(Jr.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({assets:e,currentRound:t,nextToken:r}){this.assets=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Ha.encodingSchema}toEncodingData(){return new Map([["assets",this.assets.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetsResponse: ${e}`);return new Ha({assets:(e.get("assets")??[]).map(t=>Jr.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Ds{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"genesis-hash",valueSchema:new Pe,omitEmpty:!0},{key:"genesis-id",valueSchema:new Ce,omitEmpty:!0},{key:"previous-block-hash",valueSchema:new Pe,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"seed",valueSchema:new Pe,omitEmpty:!0},{key:"timestamp",valueSchema:new O,omitEmpty:!0},{key:"transactions-root",valueSchema:new Pe,omitEmpty:!0},{key:"transactions-root-sha256",valueSchema:new Pe,omitEmpty:!0},{key:"bonus",valueSchema:new k(new O),omitEmpty:!0},{key:"fees-collected",valueSchema:new k(new O),omitEmpty:!0},{key:"participation-updates",valueSchema:new k(ic.encodingSchema),omitEmpty:!0},{key:"previous-block-hash-512",valueSchema:new k(new Pe),omitEmpty:!0},{key:"proposer",valueSchema:new k(new Ce),omitEmpty:!0},{key:"proposer-payout",valueSchema:new k(new O),omitEmpty:!0},{key:"rewards",valueSchema:new k(Ya.encodingSchema),omitEmpty:!0},{key:"state-proof-tracking",valueSchema:new k(new Me(dc.encodingSchema)),omitEmpty:!0},{key:"transactions",valueSchema:new k(new Me(wr.encodingSchema)),omitEmpty:!0},{key:"transactions-root-sha512",valueSchema:new k(new Pe),omitEmpty:!0},{key:"txn-counter",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-state",valueSchema:new k(Ka.encodingSchema),omitEmpty:!0},{key:"upgrade-vote",valueSchema:new k(qa.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({genesisHash:e,genesisId:t,previousBlockHash:r,round:i,seed:o,timestamp:s,transactionsRoot:a,transactionsRootSha256:l,bonus:c,feesCollected:d,participationUpdates:u,previousBlockHash512:m,proposer:h,proposerPayout:x,rewards:A,stateProofTracking:v,transactions:F,transactionsRootSha512:w,txnCounter:C,upgradeState:M,upgradeVote:N}){this.genesisHash=typeof e=="string"?Ge(e):e,this.genesisId=t,this.previousBlockHash=typeof r=="string"?Ge(r):r,this.round=ve(i),this.seed=typeof o=="string"?Ge(o):o,this.timestamp=Le(s),this.transactionsRoot=typeof a=="string"?Ge(a):a,this.transactionsRootSha256=typeof l=="string"?Ge(l):l,this.bonus=typeof c>"u"?void 0:Le(c),this.feesCollected=typeof d>"u"?void 0:Le(d),this.participationUpdates=u,this.previousBlockHash512=typeof m=="string"?Ge(m):m,this.proposer=typeof h=="string"?ze.fromString(h):h,this.proposerPayout=typeof x>"u"?void 0:Le(x),this.rewards=A,this.stateProofTracking=v,this.transactions=F,this.transactionsRootSha512=typeof w=="string"?Ge(w):w,this.txnCounter=typeof C>"u"?void 0:Le(C),this.upgradeState=M,this.upgradeVote=N}getEncodingSchema(){return Ds.encodingSchema}toEncodingData(){return new Map([["genesis-hash",this.genesisHash],["genesis-id",this.genesisId],["previous-block-hash",this.previousBlockHash],["round",this.round],["seed",this.seed],["timestamp",this.timestamp],["transactions-root",this.transactionsRoot],["transactions-root-sha256",this.transactionsRootSha256],["bonus",this.bonus],["fees-collected",this.feesCollected],["participation-updates",typeof this.participationUpdates<"u"?this.participationUpdates.toEncodingData():void 0],["previous-block-hash-512",this.previousBlockHash512],["proposer",typeof this.proposer<"u"?this.proposer.toString():void 0],["proposer-payout",this.proposerPayout],["rewards",typeof this.rewards<"u"?this.rewards.toEncodingData():void 0],["state-proof-tracking",typeof this.stateProofTracking<"u"?this.stateProofTracking.map(e=>e.toEncodingData()):void 0],["transactions",typeof this.transactions<"u"?this.transactions.map(e=>e.toEncodingData()):void 0],["transactions-root-sha512",this.transactionsRootSha512],["txn-counter",this.txnCounter],["upgrade-state",typeof this.upgradeState<"u"?this.upgradeState.toEncodingData():void 0],["upgrade-vote",typeof this.upgradeVote<"u"?this.upgradeVote.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Block: ${e}`);return new Ds({genesisHash:e.get("genesis-hash"),genesisId:e.get("genesis-id"),previousBlockHash:e.get("previous-block-hash"),round:e.get("round"),seed:e.get("seed"),timestamp:e.get("timestamp"),transactionsRoot:e.get("transactions-root"),transactionsRootSha256:e.get("transactions-root-sha256"),bonus:e.get("bonus"),feesCollected:e.get("fees-collected"),participationUpdates:typeof e.get("participation-updates")<"u"?ic.fromEncodingData(e.get("participation-updates")):void 0,previousBlockHash512:e.get("previous-block-hash-512"),proposer:e.get("proposer"),proposerPayout:e.get("proposer-payout"),rewards:typeof e.get("rewards")<"u"?Ya.fromEncodingData(e.get("rewards")):void 0,stateProofTracking:typeof e.get("state-proof-tracking")<"u"?e.get("state-proof-tracking").map(t=>dc.fromEncodingData(t)):void 0,transactions:typeof e.get("transactions")<"u"?e.get("transactions").map(t=>wr.fromEncodingData(t)):void 0,transactionsRootSha512:e.get("transactions-root-sha512"),txnCounter:e.get("txn-counter"),upgradeState:typeof e.get("upgrade-state")<"u"?Ka.fromEncodingData(e.get("upgrade-state")):void 0,upgradeVote:typeof e.get("upgrade-vote")<"u"?qa.fromEncodingData(e.get("upgrade-vote")):void 0})}}class Ul{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"blocks",valueSchema:new Me(Ds.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({blocks:e,currentRound:t,nextToken:r}){this.blocks=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Ul.encodingSchema}toEncodingData(){return new Map([["blocks",this.blocks.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHeadersResponse: ${e}`);return new Ul({blocks:(e.get("blocks")??[]).map(t=>Ds.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Ya{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"fee-sink",valueSchema:new Ce,omitEmpty:!0},{key:"rewards-calculation-round",valueSchema:new O,omitEmpty:!0},{key:"rewards-level",valueSchema:new O,omitEmpty:!0},{key:"rewards-pool",valueSchema:new Ce,omitEmpty:!0},{key:"rewards-rate",valueSchema:new O,omitEmpty:!0},{key:"rewards-residue",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({feeSink:e,rewardsCalculationRound:t,rewardsLevel:r,rewardsPool:i,rewardsRate:o,rewardsResidue:s}){this.feeSink=e,this.rewardsCalculationRound=ve(t),this.rewardsLevel=ve(r),this.rewardsPool=i,this.rewardsRate=ve(o),this.rewardsResidue=ve(s)}getEncodingSchema(){return Ya.encodingSchema}toEncodingData(){return new Map([["fee-sink",this.feeSink],["rewards-calculation-round",this.rewardsCalculationRound],["rewards-level",this.rewardsLevel],["rewards-pool",this.rewardsPool],["rewards-rate",this.rewardsRate],["rewards-residue",this.rewardsResidue]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockRewards: ${e}`);return new Ya({feeSink:e.get("fee-sink"),rewardsCalculationRound:e.get("rewards-calculation-round"),rewardsLevel:e.get("rewards-level"),rewardsPool:e.get("rewards-pool"),rewardsRate:e.get("rewards-rate"),rewardsResidue:e.get("rewards-residue")})}}class Ka{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-protocol",valueSchema:new Ce,omitEmpty:!0},{key:"next-protocol",valueSchema:new k(new Ce),omitEmpty:!0},{key:"next-protocol-approvals",valueSchema:new k(new O),omitEmpty:!0},{key:"next-protocol-switch-on",valueSchema:new k(new O),omitEmpty:!0},{key:"next-protocol-vote-before",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({currentProtocol:e,nextProtocol:t,nextProtocolApprovals:r,nextProtocolSwitchOn:i,nextProtocolVoteBefore:o}){this.currentProtocol=e,this.nextProtocol=t,this.nextProtocolApprovals=typeof r>"u"?void 0:Le(r),this.nextProtocolSwitchOn=typeof i>"u"?void 0:ve(i),this.nextProtocolVoteBefore=typeof o>"u"?void 0:ve(o)}getEncodingSchema(){return Ka.encodingSchema}toEncodingData(){return new Map([["current-protocol",this.currentProtocol],["next-protocol",this.nextProtocol],["next-protocol-approvals",this.nextProtocolApprovals],["next-protocol-switch-on",this.nextProtocolSwitchOn],["next-protocol-vote-before",this.nextProtocolVoteBefore]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockUpgradeState: ${e}`);return new Ka({currentProtocol:e.get("current-protocol"),nextProtocol:e.get("next-protocol"),nextProtocolApprovals:e.get("next-protocol-approvals"),nextProtocolSwitchOn:e.get("next-protocol-switch-on"),nextProtocolVoteBefore:e.get("next-protocol-vote-before")})}}class qa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"upgrade-approve",valueSchema:new k(new gt),omitEmpty:!0},{key:"upgrade-delay",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-propose",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({upgradeApprove:e,upgradeDelay:t,upgradePropose:r}){this.upgradeApprove=e,this.upgradeDelay=typeof t>"u"?void 0:ve(t),this.upgradePropose=r}getEncodingSchema(){return qa.encodingSchema}toEncodingData(){return new Map([["upgrade-approve",this.upgradeApprove],["upgrade-delay",this.upgradeDelay],["upgrade-propose",this.upgradePropose]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockUpgradeVote: ${e}`);return new qa({upgradeApprove:e.get("upgrade-approve"),upgradeDelay:e.get("upgrade-delay"),upgradePropose:e.get("upgrade-propose")})}}class jl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"value",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e,round:t,value:r}){this.name=typeof e=="string"?Ge(e):e,this.round=ve(t),this.value=typeof r=="string"?Ge(r):r}getEncodingSchema(){return jl.encodingSchema}toEncodingData(){return new Map([["name",this.name],["round",this.round],["value",this.value]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Box: ${e}`);return new jl({name:e.get("name"),round:e.get("round"),value:e.get("value")})}}class Xa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e}){this.name=typeof e=="string"?Ge(e):e}getEncodingSchema(){return Xa.encodingSchema}toEncodingData(){return new Map([["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxDescriptor: ${e}`);return new Xa({name:e.get("name")})}}class uo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app",valueSchema:new O,omitEmpty:!0},{key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({app:e,name:t}){this.app=Le(e),this.name=typeof t=="string"?Ge(t):t}getEncodingSchema(){return uo.encodingSchema}toEncodingData(){return new Map([["app",this.app],["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxReference: ${e}`);return new uo({app:e.get("app"),name:e.get("name")})}}class Gl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-id",valueSchema:new O,omitEmpty:!0},{key:"boxes",valueSchema:new Me(Xa.encodingSchema),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationId:e,boxes:t,nextToken:r}){this.applicationId=ve(e),this.boxes=t,this.nextToken=r}getEncodingSchema(){return Gl.encodingSchema}toEncodingData(){return new Map([["application-id",this.applicationId],["boxes",this.boxes.map(e=>e.toEncodingData())],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxesResponse: ${e}`);return new Gl({applicationId:e.get("application-id"),boxes:(e.get("boxes")??[]).map(t=>Xa.fromEncodingData(t)),nextToken:e.get("next-token")})}}class Sd{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"message",valueSchema:new Ce,omitEmpty:!0},{key:"data",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,data:t}){this.message=e,this.data=t}getEncodingSchema(){return Sd.encodingSchema}toEncodingData(){return new Map([["message",this.message],["data",typeof this.data<"u"?this.data.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ErrorResponse: ${e}`);return new Sd({message:e.get("message"),data:typeof e.get("data")<"u"?Sn.fromEncodingData(e.get("data")):void 0})}}class Za{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"action",valueSchema:new O,omitEmpty:!0},{key:"bytes",valueSchema:new k(new Ce),omitEmpty:!0},{key:"uint",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({action:e,bytes:t,uint:r}){this.action=Le(e),this.bytes=t,this.uint=typeof r>"u"?void 0:ve(r)}getEncodingSchema(){return Za.encodingSchema}toEncodingData(){return new Map([["action",this.action],["bytes",this.bytes],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${e}`);return new Za({action:e.get("action"),bytes:e.get("bytes"),uint:e.get("uint")})}}class ho{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Ce,omitEmpty:!0},{key:"value",valueSchema:Za.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=e,this.value=t}getEncodingSchema(){return ho.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDeltaKeyValue: ${e}`);return new ho({key:e.get("key"),value:Za.fromEncodingData(e.get("value")??new Map)})}}class Ja{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hash-type",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({hashType:e}){this.hashType=typeof e>"u"?void 0:Le(e)}getEncodingSchema(){return Ja.encodingSchema}toEncodingData(){return new Map([["hash-type",this.hashType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HashFactory: ${e}`);return new Ja({hashType:e.get("hash-type")})}}class Qa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hb-pk",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-pk1sig",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-pk2",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-pk2sig",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-sig",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({hbPk:e,hbPk1sig:t,hbPk2:r,hbPk2sig:i,hbSig:o}){this.hbPk=typeof e=="string"?Ge(e):e,this.hbPk1sig=typeof t=="string"?Ge(t):t,this.hbPk2=typeof r=="string"?Ge(r):r,this.hbPk2sig=typeof i=="string"?Ge(i):i,this.hbSig=typeof o=="string"?Ge(o):o}getEncodingSchema(){return Qa.encodingSchema}toEncodingData(){return new Map([["hb-pk",this.hbPk],["hb-pk1sig",this.hbPk1sig],["hb-pk2",this.hbPk2],["hb-pk2sig",this.hbPk2sig],["hb-sig",this.hbSig]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HbProofFields: ${e}`);return new Qa({hbPk:e.get("hb-pk"),hbPk1sig:e.get("hb-pk1sig"),hbPk2:e.get("hb-pk2"),hbPk2sig:e.get("hb-pk2sig"),hbSig:e.get("hb-sig")})}}class Wl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"db-available",valueSchema:new gt,omitEmpty:!0},{key:"is-migrating",valueSchema:new gt,omitEmpty:!0},{key:"message",valueSchema:new Ce,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"version",valueSchema:new Ce,omitEmpty:!0},{key:"data",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0},{key:"errors",valueSchema:new k(new Me(new Ce)),omitEmpty:!0})),this.encodingSchemaValue}constructor({dbAvailable:e,isMigrating:t,message:r,round:i,version:o,data:s,errors:a}){this.dbAvailable=e,this.isMigrating=t,this.message=r,this.round=ve(i),this.version=o,this.data=s,this.errors=a}getEncodingSchema(){return Wl.encodingSchema}toEncodingData(){return new Map([["db-available",this.dbAvailable],["is-migrating",this.isMigrating],["message",this.message],["round",this.round],["version",this.version],["data",typeof this.data<"u"?this.data.toEncodingData():void 0],["errors",this.errors]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HealthCheck: ${e}`);return new Wl({dbAvailable:e.get("db-available"),isMigrating:e.get("is-migrating"),message:e.get("message"),round:e.get("round"),version:e.get("version"),data:typeof e.get("data")<"u"?Sn.fromEncodingData(e.get("data")):void 0,errors:e.get("errors")})}}class ec{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"asset",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,asset:t}){this.address=typeof e=="string"?ze.fromString(e):e,this.asset=Le(t)}getEncodingSchema(){return ec.encodingSchema}toEncodingData(){return new Map([["address",this.address.toString()],["asset",this.asset]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HoldingRef: ${e}`);return new ec({address:e.get("address"),asset:e.get("asset")})}}class tc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"block-headers-commitment",valueSchema:new k(new Pe),omitEmpty:!0},{key:"first-attested-round",valueSchema:new k(new O),omitEmpty:!0},{key:"latest-attested-round",valueSchema:new k(new O),omitEmpty:!0},{key:"ln-proven-weight",valueSchema:new k(new O),omitEmpty:!0},{key:"voters-commitment",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({blockHeadersCommitment:e,firstAttestedRound:t,latestAttestedRound:r,lnProvenWeight:i,votersCommitment:o}){this.blockHeadersCommitment=typeof e=="string"?Ge(e):e,this.firstAttestedRound=typeof t>"u"?void 0:ve(t),this.latestAttestedRound=typeof r>"u"?void 0:ve(r),this.lnProvenWeight=typeof i>"u"?void 0:ve(i),this.votersCommitment=typeof o=="string"?Ge(o):o}getEncodingSchema(){return tc.encodingSchema}toEncodingData(){return new Map([["block-headers-commitment",this.blockHeadersCommitment],["first-attested-round",this.firstAttestedRound],["latest-attested-round",this.latestAttestedRound],["ln-proven-weight",this.lnProvenWeight],["voters-commitment",this.votersCommitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded IndexerStateProofMessage: ${e}`);return new tc({blockHeadersCommitment:e.get("block-headers-commitment"),firstAttestedRound:e.get("first-attested-round"),latestAttestedRound:e.get("latest-attested-round"),lnProvenWeight:e.get("ln-proven-weight"),votersCommitment:e.get("voters-commitment")})}}class nc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"app",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,app:t}){this.address=typeof e=="string"?ze.fromString(e):e,this.app=Le(t)}getEncodingSchema(){return nc.encodingSchema}toEncodingData(){return new Map([["address",this.address.toString()],["app",this.app]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LocalsRef: ${e}`);return new nc({address:e.get("address"),app:e.get("app")})}}class Gr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hash-factory",valueSchema:new k(Ja.encodingSchema),omitEmpty:!0},{key:"path",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"tree-depth",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({hashFactory:e,path:t,treeDepth:r}){this.hashFactory=e,this.path=t,this.treeDepth=typeof r>"u"?void 0:Le(r)}getEncodingSchema(){return Gr.encodingSchema}toEncodingData(){return new Map([["hash-factory",typeof this.hashFactory<"u"?this.hashFactory.toEncodingData():void 0],["path",this.path],["tree-depth",this.treeDepth]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MerkleArrayProof: ${e}`);return new Gr({hashFactory:typeof e.get("hash-factory")<"u"?Ja.fromEncodingData(e.get("hash-factory")):void 0,path:e.get("path"),treeDepth:e.get("tree-depth")})}}class rc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"amount",valueSchema:new O,omitEmpty:!0},{key:"is-frozen",valueSchema:new gt,omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"opted-in-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"opted-out-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,amount:t,isFrozen:r,deleted:i,optedInAtRound:o,optedOutAtRound:s}){this.address=e,this.amount=ve(t),this.isFrozen=r,this.deleted=i,this.optedInAtRound=typeof o>"u"?void 0:ve(o),this.optedOutAtRound=typeof s>"u"?void 0:ve(s)}getEncodingSchema(){return rc.encodingSchema}toEncodingData(){return new Map([["address",this.address],["amount",this.amount],["is-frozen",this.isFrozen],["deleted",this.deleted],["opted-in-at-round",this.optedInAtRound],["opted-out-at-round",this.optedOutAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MiniAssetHolding: ${e}`);return new rc({address:e.get("address"),amount:e.get("amount"),isFrozen:e.get("is-frozen"),deleted:e.get("deleted"),optedInAtRound:e.get("opted-in-at-round"),optedOutAtRound:e.get("opted-out-at-round")})}}class ic{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"absent-participation-accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"expired-participation-accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0})),this.encodingSchemaValue}constructor({absentParticipationAccounts:e,expiredParticipationAccounts:t}){this.absentParticipationAccounts=e,this.expiredParticipationAccounts=t}getEncodingSchema(){return ic.encodingSchema}toEncodingData(){return new Map([["absent-participation-accounts",this.absentParticipationAccounts],["expired-participation-accounts",this.expiredParticipationAccounts]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ParticipationUpdates: ${e}`);return new ic({absentParticipationAccounts:e.get("absent-participation-accounts"),expiredParticipationAccounts:e.get("expired-participation-accounts")})}}class oc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new k(new Ce),omitEmpty:!0},{key:"application-id",valueSchema:new k(new O),omitEmpty:!0},{key:"asset-id",valueSchema:new k(new O),omitEmpty:!0},{key:"box",valueSchema:new k(uo.encodingSchema),omitEmpty:!0},{key:"holding",valueSchema:new k(ec.encodingSchema),omitEmpty:!0},{key:"local",valueSchema:new k(nc.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,applicationId:t,assetId:r,box:i,holding:o,local:s}){this.address=typeof e=="string"?ze.fromString(e):e,this.applicationId=typeof t>"u"?void 0:Le(t),this.assetId=typeof r>"u"?void 0:Le(r),this.box=i,this.holding=o,this.local=s}getEncodingSchema(){return oc.encodingSchema}toEncodingData(){return new Map([["address",typeof this.address<"u"?this.address.toString():void 0],["application-id",this.applicationId],["asset-id",this.assetId],["box",typeof this.box<"u"?this.box.toEncodingData():void 0],["holding",typeof this.holding<"u"?this.holding.toEncodingData():void 0],["local",typeof this.local<"u"?this.local.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ResourceRef: ${e}`);return new oc({address:e.get("address"),applicationId:e.get("application-id"),assetId:e.get("asset-id"),box:typeof e.get("box")<"u"?uo.fromEncodingData(e.get("box")):void 0,holding:typeof e.get("holding")<"u"?ec.fromEncodingData(e.get("holding")):void 0,local:typeof e.get("local")<"u"?nc.fromEncodingData(e.get("local")):void 0})}}class sc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"part-proofs",valueSchema:new k(Gr.encodingSchema),omitEmpty:!0},{key:"positions-to-reveal",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"reveals",valueSchema:new k(new Me(cc.encodingSchema)),omitEmpty:!0},{key:"salt-version",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-commit",valueSchema:new k(new Pe),omitEmpty:!0},{key:"sig-proofs",valueSchema:new k(Gr.encodingSchema),omitEmpty:!0},{key:"signed-weight",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({partProofs:e,positionsToReveal:t,reveals:r,saltVersion:i,sigCommit:o,sigProofs:s,signedWeight:a}){this.partProofs=e,this.positionsToReveal=typeof t>"u"?void 0:t.map(ve),this.reveals=r,this.saltVersion=typeof i>"u"?void 0:Le(i),this.sigCommit=typeof o=="string"?Ge(o):o,this.sigProofs=s,this.signedWeight=typeof a>"u"?void 0:ve(a)}getEncodingSchema(){return sc.encodingSchema}toEncodingData(){return new Map([["part-proofs",typeof this.partProofs<"u"?this.partProofs.toEncodingData():void 0],["positions-to-reveal",this.positionsToReveal],["reveals",typeof this.reveals<"u"?this.reveals.map(e=>e.toEncodingData()):void 0],["salt-version",this.saltVersion],["sig-commit",this.sigCommit],["sig-proofs",typeof this.sigProofs<"u"?this.sigProofs.toEncodingData():void 0],["signed-weight",this.signedWeight]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofFields: ${e}`);return new sc({partProofs:typeof e.get("part-proofs")<"u"?Gr.fromEncodingData(e.get("part-proofs")):void 0,positionsToReveal:e.get("positions-to-reveal"),reveals:typeof e.get("reveals")<"u"?e.get("reveals").map(t=>cc.fromEncodingData(t)):void 0,saltVersion:e.get("salt-version"),sigCommit:e.get("sig-commit"),sigProofs:typeof e.get("sig-proofs")<"u"?Gr.fromEncodingData(e.get("sig-proofs")):void 0,signedWeight:e.get("signed-weight")})}}class ac{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"verifier",valueSchema:new k(hc.encodingSchema),omitEmpty:!0},{key:"weight",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({verifier:e,weight:t}){this.verifier=e,this.weight=typeof t>"u"?void 0:ve(t)}getEncodingSchema(){return ac.encodingSchema}toEncodingData(){return new Map([["verifier",typeof this.verifier<"u"?this.verifier.toEncodingData():void 0],["weight",this.weight]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofParticipant: ${e}`);return new ac({verifier:typeof e.get("verifier")<"u"?hc.fromEncodingData(e.get("verifier")):void 0,weight:e.get("weight")})}}class cc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"participant",valueSchema:new k(ac.encodingSchema),omitEmpty:!0},{key:"position",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-slot",valueSchema:new k(lc.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({participant:e,position:t,sigSlot:r}){this.participant=e,this.position=typeof t>"u"?void 0:ve(t),this.sigSlot=r}getEncodingSchema(){return cc.encodingSchema}toEncodingData(){return new Map([["participant",typeof this.participant<"u"?this.participant.toEncodingData():void 0],["position",this.position],["sig-slot",typeof this.sigSlot<"u"?this.sigSlot.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofReveal: ${e}`);return new cc({participant:typeof e.get("participant")<"u"?ac.fromEncodingData(e.get("participant")):void 0,position:e.get("position"),sigSlot:typeof e.get("sig-slot")<"u"?lc.fromEncodingData(e.get("sig-slot")):void 0})}}class lc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"lower-sig-weight",valueSchema:new k(new O),omitEmpty:!0},{key:"signature",valueSchema:new k(uc.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({lowerSigWeight:e,signature:t}){this.lowerSigWeight=typeof e>"u"?void 0:ve(e),this.signature=t}getEncodingSchema(){return lc.encodingSchema}toEncodingData(){return new Map([["lower-sig-weight",this.lowerSigWeight],["signature",typeof this.signature<"u"?this.signature.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofSigSlot: ${e}`);return new lc({lowerSigWeight:e.get("lower-sig-weight"),signature:typeof e.get("signature")<"u"?uc.fromEncodingData(e.get("signature")):void 0})}}class uc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"falcon-signature",valueSchema:new k(new Pe),omitEmpty:!0},{key:"merkle-array-index",valueSchema:new k(new O),omitEmpty:!0},{key:"proof",valueSchema:new k(Gr.encodingSchema),omitEmpty:!0},{key:"verifying-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({falconSignature:e,merkleArrayIndex:t,proof:r,verifyingKey:i}){this.falconSignature=typeof e=="string"?Ge(e):e,this.merkleArrayIndex=typeof t>"u"?void 0:Le(t),this.proof=r,this.verifyingKey=typeof i=="string"?Ge(i):i}getEncodingSchema(){return uc.encodingSchema}toEncodingData(){return new Map([["falcon-signature",this.falconSignature],["merkle-array-index",this.merkleArrayIndex],["proof",typeof this.proof<"u"?this.proof.toEncodingData():void 0],["verifying-key",this.verifyingKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofSignature: ${e}`);return new uc({falconSignature:e.get("falcon-signature"),merkleArrayIndex:e.get("merkle-array-index"),proof:typeof e.get("proof")<"u"?Gr.fromEncodingData(e.get("proof")):void 0,verifyingKey:e.get("verifying-key")})}}class dc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"next-round",valueSchema:new k(new O),omitEmpty:!0},{key:"online-total-weight",valueSchema:new k(new O),omitEmpty:!0},{key:"type",valueSchema:new k(new O),omitEmpty:!0},{key:"voters-commitment",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({nextRound:e,onlineTotalWeight:t,type:r,votersCommitment:i}){this.nextRound=typeof e>"u"?void 0:ve(e),this.onlineTotalWeight=typeof t>"u"?void 0:ve(t),this.type=typeof r>"u"?void 0:Le(r),this.votersCommitment=typeof i=="string"?Ge(i):i}getEncodingSchema(){return dc.encodingSchema}toEncodingData(){return new Map([["next-round",this.nextRound],["online-total-weight",this.onlineTotalWeight],["type",this.type],["voters-commitment",this.votersCommitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofTracking: ${e}`);return new dc({nextRound:e.get("next-round"),onlineTotalWeight:e.get("online-total-weight"),type:e.get("type"),votersCommitment:e.get("voters-commitment")})}}class hc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"commitment",valueSchema:new k(new Pe),omitEmpty:!0},{key:"key-lifetime",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({commitment:e,keyLifetime:t}){this.commitment=typeof e=="string"?Ge(e):e,this.keyLifetime=typeof t>"u"?void 0:ve(t)}getEncodingSchema(){return hc.encodingSchema}toEncodingData(){return new Map([["commitment",this.commitment],["key-lifetime",this.keyLifetime]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofVerifier: ${e}`);return new hc({commitment:e.get("commitment"),keyLifetime:e.get("key-lifetime")})}}class Yi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"num-byte-slice",valueSchema:new O,omitEmpty:!0},{key:"num-uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({numByteSlice:e,numUint:t}){this.numByteSlice=Le(e),this.numUint=Le(t)}getEncodingSchema(){return Yi.encodingSchema}toEncodingData(){return new Map([["num-byte-slice",this.numByteSlice],["num-uint",this.numUint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateSchema: ${e}`);return new Yi({numByteSlice:e.get("num-byte-slice"),numUint:e.get("num-uint")})}}class fo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"value",valueSchema:fc.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=typeof e=="string"?Ge(e):e,this.value=t}getEncodingSchema(){return fo.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealKeyValue: ${e}`);return new fo({key:e.get("key"),value:fc.fromEncodingData(e.get("value")??new Map)})}}class fc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"bytes",valueSchema:new Pe,omitEmpty:!0},{key:"type",valueSchema:new O,omitEmpty:!0},{key:"uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({bytes:e,type:t,uint:r}){this.bytes=typeof e=="string"?Ge(e):e,this.type=Le(t),this.uint=ve(r)}getEncodingSchema(){return fc.encodingSchema}toEncodingData(){return new Map([["bytes",this.bytes],["type",this.type],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealValue: ${e}`);return new fc({bytes:e.get("bytes"),type:e.get("type"),uint:e.get("uint")})}}class wr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"fee",valueSchema:new O,omitEmpty:!0},{key:"first-valid",valueSchema:new O,omitEmpty:!0},{key:"last-valid",valueSchema:new O,omitEmpty:!0},{key:"sender",valueSchema:new Ce,omitEmpty:!0},{key:"application-transaction",valueSchema:new k(pc.encodingSchema),omitEmpty:!0},{key:"asset-config-transaction",valueSchema:new k(gc.encodingSchema),omitEmpty:!0},{key:"asset-freeze-transaction",valueSchema:new k(mc.encodingSchema),omitEmpty:!0},{key:"asset-transfer-transaction",valueSchema:new k(yc.encodingSchema),omitEmpty:!0},{key:"auth-addr",valueSchema:new k(new Ce),omitEmpty:!0},{key:"close-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"closing-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"confirmed-round",valueSchema:new k(new O),omitEmpty:!0},{key:"created-application-index",valueSchema:new k(new O),omitEmpty:!0},{key:"created-asset-index",valueSchema:new k(new O),omitEmpty:!0},{key:"genesis-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"genesis-id",valueSchema:new k(new Ce),omitEmpty:!0},{key:"global-state-delta",valueSchema:new k(new Me(ho.encodingSchema)),omitEmpty:!0},{key:"group",valueSchema:new k(new Pe),omitEmpty:!0},{key:"heartbeat-transaction",valueSchema:new k(wc.encodingSchema),omitEmpty:!0},{key:"id",valueSchema:new k(new Ce),omitEmpty:!0},{key:"inner-txns",valueSchema:new k(new Me(wr.encodingSchema)),omitEmpty:!0},{key:"intra-round-offset",valueSchema:new k(new O),omitEmpty:!0},{key:"keyreg-transaction",valueSchema:new k(xc.encodingSchema),omitEmpty:!0},{key:"lease",valueSchema:new k(new Pe),omitEmpty:!0},{key:"local-state-delta",valueSchema:new k(new Me(ja.encodingSchema)),omitEmpty:!0},{key:"logs",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"note",valueSchema:new k(new Pe),omitEmpty:!0},{key:"payment-transaction",valueSchema:new k(vc.encodingSchema),omitEmpty:!0},{key:"receiver-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"rekey-to",valueSchema:new k(new Ce),omitEmpty:!0},{key:"round-time",valueSchema:new k(new O),omitEmpty:!0},{key:"sender-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"signature",valueSchema:new k(Sc.encodingSchema),omitEmpty:!0},{key:"state-proof-transaction",valueSchema:new k(Ac.encodingSchema),omitEmpty:!0},{key:"tx-type",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({fee:e,firstValid:t,lastValid:r,sender:i,applicationTransaction:o,assetConfigTransaction:s,assetFreezeTransaction:a,assetTransferTransaction:l,authAddr:c,closeRewards:d,closingAmount:u,confirmedRound:m,createdApplicationIndex:h,createdAssetIndex:x,genesisHash:A,genesisId:v,globalStateDelta:F,group:w,heartbeatTransaction:C,id:M,innerTxns:N,intraRoundOffset:b,keyregTransaction:j,lease:p,localStateDelta:E,logs:S,note:$,paymentTransaction:B,receiverRewards:P,rekeyTo:W,roundTime:L,senderRewards:q,signature:J,stateProofTransaction:U,txType:ne}){this.fee=ve(e),this.firstValid=ve(t),this.lastValid=ve(r),this.sender=i,this.applicationTransaction=o,this.assetConfigTransaction=s,this.assetFreezeTransaction=a,this.assetTransferTransaction=l,this.authAddr=typeof c=="string"?ze.fromString(c):c,this.closeRewards=typeof d>"u"?void 0:ve(d),this.closingAmount=typeof u>"u"?void 0:ve(u),this.confirmedRound=typeof m>"u"?void 0:ve(m),this.createdApplicationIndex=typeof h>"u"?void 0:ve(h),this.createdAssetIndex=typeof x>"u"?void 0:ve(x),this.genesisHash=typeof A=="string"?Ge(A):A,this.genesisId=v,this.globalStateDelta=F,this.group=typeof w=="string"?Ge(w):w,this.heartbeatTransaction=C,this.id=M,this.innerTxns=N,this.intraRoundOffset=typeof b>"u"?void 0:Le(b),this.keyregTransaction=j,this.lease=typeof p=="string"?Ge(p):p,this.localStateDelta=E,this.logs=S,this.note=typeof $=="string"?Ge($):$,this.paymentTransaction=B,this.receiverRewards=typeof P>"u"?void 0:ve(P),this.rekeyTo=typeof W=="string"?ze.fromString(W):W,this.roundTime=typeof L>"u"?void 0:Le(L),this.senderRewards=typeof q>"u"?void 0:ve(q),this.signature=J,this.stateProofTransaction=U,this.txType=ne}getEncodingSchema(){return wr.encodingSchema}toEncodingData(){return new Map([["fee",this.fee],["first-valid",this.firstValid],["last-valid",this.lastValid],["sender",this.sender],["application-transaction",typeof this.applicationTransaction<"u"?this.applicationTransaction.toEncodingData():void 0],["asset-config-transaction",typeof this.assetConfigTransaction<"u"?this.assetConfigTransaction.toEncodingData():void 0],["asset-freeze-transaction",typeof this.assetFreezeTransaction<"u"?this.assetFreezeTransaction.toEncodingData():void 0],["asset-transfer-transaction",typeof this.assetTransferTransaction<"u"?this.assetTransferTransaction.toEncodingData():void 0],["auth-addr",typeof this.authAddr<"u"?this.authAddr.toString():void 0],["close-rewards",this.closeRewards],["closing-amount",this.closingAmount],["confirmed-round",this.confirmedRound],["created-application-index",this.createdApplicationIndex],["created-asset-index",this.createdAssetIndex],["genesis-hash",this.genesisHash],["genesis-id",this.genesisId],["global-state-delta",typeof this.globalStateDelta<"u"?this.globalStateDelta.map(e=>e.toEncodingData()):void 0],["group",this.group],["heartbeat-transaction",typeof this.heartbeatTransaction<"u"?this.heartbeatTransaction.toEncodingData():void 0],["id",this.id],["inner-txns",typeof this.innerTxns<"u"?this.innerTxns.map(e=>e.toEncodingData()):void 0],["intra-round-offset",this.intraRoundOffset],["keyreg-transaction",typeof this.keyregTransaction<"u"?this.keyregTransaction.toEncodingData():void 0],["lease",this.lease],["local-state-delta",typeof this.localStateDelta<"u"?this.localStateDelta.map(e=>e.toEncodingData()):void 0],["logs",this.logs],["note",this.note],["payment-transaction",typeof this.paymentTransaction<"u"?this.paymentTransaction.toEncodingData():void 0],["receiver-rewards",this.receiverRewards],["rekey-to",typeof this.rekeyTo<"u"?this.rekeyTo.toString():void 0],["round-time",this.roundTime],["sender-rewards",this.senderRewards],["signature",typeof this.signature<"u"?this.signature.toEncodingData():void 0],["state-proof-transaction",typeof this.stateProofTransaction<"u"?this.stateProofTransaction.toEncodingData():void 0],["tx-type",this.txType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Transaction: ${e}`);return new wr({fee:e.get("fee"),firstValid:e.get("first-valid"),lastValid:e.get("last-valid"),sender:e.get("sender"),applicationTransaction:typeof e.get("application-transaction")<"u"?pc.fromEncodingData(e.get("application-transaction")):void 0,assetConfigTransaction:typeof e.get("asset-config-transaction")<"u"?gc.fromEncodingData(e.get("asset-config-transaction")):void 0,assetFreezeTransaction:typeof e.get("asset-freeze-transaction")<"u"?mc.fromEncodingData(e.get("asset-freeze-transaction")):void 0,assetTransferTransaction:typeof e.get("asset-transfer-transaction")<"u"?yc.fromEncodingData(e.get("asset-transfer-transaction")):void 0,authAddr:e.get("auth-addr"),closeRewards:e.get("close-rewards"),closingAmount:e.get("closing-amount"),confirmedRound:e.get("confirmed-round"),createdApplicationIndex:e.get("created-application-index"),createdAssetIndex:e.get("created-asset-index"),genesisHash:e.get("genesis-hash"),genesisId:e.get("genesis-id"),globalStateDelta:typeof e.get("global-state-delta")<"u"?e.get("global-state-delta").map(t=>ho.fromEncodingData(t)):void 0,group:e.get("group"),heartbeatTransaction:typeof e.get("heartbeat-transaction")<"u"?wc.fromEncodingData(e.get("heartbeat-transaction")):void 0,id:e.get("id"),innerTxns:typeof e.get("inner-txns")<"u"?e.get("inner-txns").map(t=>wr.fromEncodingData(t)):void 0,intraRoundOffset:e.get("intra-round-offset"),keyregTransaction:typeof e.get("keyreg-transaction")<"u"?xc.fromEncodingData(e.get("keyreg-transaction")):void 0,lease:e.get("lease"),localStateDelta:typeof e.get("local-state-delta")<"u"?e.get("local-state-delta").map(t=>ja.fromEncodingData(t)):void 0,logs:e.get("logs"),note:e.get("note"),paymentTransaction:typeof e.get("payment-transaction")<"u"?vc.fromEncodingData(e.get("payment-transaction")):void 0,receiverRewards:e.get("receiver-rewards"),rekeyTo:e.get("rekey-to"),roundTime:e.get("round-time"),senderRewards:e.get("sender-rewards"),signature:typeof e.get("signature")<"u"?Sc.fromEncodingData(e.get("signature")):void 0,stateProofTransaction:typeof e.get("state-proof-transaction")<"u"?Ac.fromEncodingData(e.get("state-proof-transaction")):void 0,txType:e.get("tx-type")})}}class pc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-id",valueSchema:new O,omitEmpty:!0},{key:"access",valueSchema:new k(new Me(oc.encodingSchema)),omitEmpty:!0},{key:"accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"application-args",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"approval-program",valueSchema:new k(new Pe),omitEmpty:!0},{key:"box-references",valueSchema:new k(new Me(uo.encodingSchema)),omitEmpty:!0},{key:"clear-state-program",valueSchema:new k(new Pe),omitEmpty:!0},{key:"extra-program-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"foreign-apps",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"foreign-assets",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"global-state-schema",valueSchema:new k(Yi.encodingSchema),omitEmpty:!0},{key:"local-state-schema",valueSchema:new k(Yi.encodingSchema),omitEmpty:!0},{key:"on-completion",valueSchema:new k(new Ce),omitEmpty:!0},{key:"reject-version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationId:e,access:t,accounts:r,applicationArgs:i,approvalProgram:o,boxReferences:s,clearStateProgram:a,extraProgramPages:l,foreignApps:c,foreignAssets:d,globalStateSchema:u,localStateSchema:m,onCompletion:h,rejectVersion:x}){this.applicationId=ve(e),this.access=t,this.accounts=typeof r<"u"?r.map(A=>typeof A=="string"?ze.fromString(A):A):void 0,this.applicationArgs=i,this.approvalProgram=typeof o=="string"?Ge(o):o,this.boxReferences=s,this.clearStateProgram=typeof a=="string"?Ge(a):a,this.extraProgramPages=typeof l>"u"?void 0:Le(l),this.foreignApps=typeof c>"u"?void 0:c.map(ve),this.foreignAssets=typeof d>"u"?void 0:d.map(ve),this.globalStateSchema=u,this.localStateSchema=m,this.onCompletion=h,this.rejectVersion=typeof x>"u"?void 0:Le(x)}getEncodingSchema(){return pc.encodingSchema}toEncodingData(){return new Map([["application-id",this.applicationId],["access",typeof this.access<"u"?this.access.map(e=>e.toEncodingData()):void 0],["accounts",typeof this.accounts<"u"?this.accounts.map(e=>e.toString()):void 0],["application-args",this.applicationArgs],["approval-program",this.approvalProgram],["box-references",typeof this.boxReferences<"u"?this.boxReferences.map(e=>e.toEncodingData()):void 0],["clear-state-program",this.clearStateProgram],["extra-program-pages",this.extraProgramPages],["foreign-apps",this.foreignApps],["foreign-assets",this.foreignAssets],["global-state-schema",typeof this.globalStateSchema<"u"?this.globalStateSchema.toEncodingData():void 0],["local-state-schema",typeof this.localStateSchema<"u"?this.localStateSchema.toEncodingData():void 0],["on-completion",this.onCompletion],["reject-version",this.rejectVersion]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionApplication: ${e}`);return new pc({applicationId:e.get("application-id"),access:typeof e.get("access")<"u"?e.get("access").map(t=>oc.fromEncodingData(t)):void 0,accounts:e.get("accounts"),applicationArgs:e.get("application-args"),approvalProgram:e.get("approval-program"),boxReferences:typeof e.get("box-references")<"u"?e.get("box-references").map(t=>uo.fromEncodingData(t)):void 0,clearStateProgram:e.get("clear-state-program"),extraProgramPages:e.get("extra-program-pages"),foreignApps:e.get("foreign-apps"),foreignAssets:e.get("foreign-assets"),globalStateSchema:typeof e.get("global-state-schema")<"u"?Yi.fromEncodingData(e.get("global-state-schema")):void 0,localStateSchema:typeof e.get("local-state-schema")<"u"?Yi.fromEncodingData(e.get("local-state-schema")):void 0,onCompletion:e.get("on-completion"),rejectVersion:e.get("reject-version")})}}class gc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"asset-id",valueSchema:new k(new O),omitEmpty:!0},{key:"params",valueSchema:new k(lo.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({assetId:e,params:t}){this.assetId=typeof e>"u"?void 0:ve(e),this.params=t}getEncodingSchema(){return gc.encodingSchema}toEncodingData(){return new Map([["asset-id",this.assetId],["params",typeof this.params<"u"?this.params.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionAssetConfig: ${e}`);return new gc({assetId:e.get("asset-id"),params:typeof e.get("params")<"u"?lo.fromEncodingData(e.get("params")):void 0})}}class mc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"new-freeze-status",valueSchema:new gt,omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,assetId:t,newFreezeStatus:r}){this.address=e,this.assetId=ve(t),this.newFreezeStatus=r}getEncodingSchema(){return mc.encodingSchema}toEncodingData(){return new Map([["address",this.address],["asset-id",this.assetId],["new-freeze-status",this.newFreezeStatus]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionAssetFreeze: ${e}`);return new mc({address:e.get("address"),assetId:e.get("asset-id"),newFreezeStatus:e.get("new-freeze-status")})}}class yc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"receiver",valueSchema:new Ce,omitEmpty:!0},{key:"close-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"close-to",valueSchema:new k(new Ce),omitEmpty:!0},{key:"sender",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,assetId:t,receiver:r,closeAmount:i,closeTo:o,sender:s}){this.amount=ve(e),this.assetId=ve(t),this.receiver=r,this.closeAmount=typeof i>"u"?void 0:ve(i),this.closeTo=o,this.sender=s}getEncodingSchema(){return yc.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["asset-id",this.assetId],["receiver",this.receiver],["close-amount",this.closeAmount],["close-to",this.closeTo],["sender",this.sender]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionAssetTransfer: ${e}`);return new yc({amount:e.get("amount"),assetId:e.get("asset-id"),receiver:e.get("receiver"),closeAmount:e.get("close-amount"),closeTo:e.get("close-to"),sender:e.get("sender")})}}class wc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hb-address",valueSchema:new Ce,omitEmpty:!0},{key:"hb-key-dilution",valueSchema:new O,omitEmpty:!0},{key:"hb-proof",valueSchema:Qa.encodingSchema,omitEmpty:!0},{key:"hb-seed",valueSchema:new Pe,omitEmpty:!0},{key:"hb-vote-id",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({hbAddress:e,hbKeyDilution:t,hbProof:r,hbSeed:i,hbVoteId:o}){this.hbAddress=e,this.hbKeyDilution=ve(t),this.hbProof=r,this.hbSeed=typeof i=="string"?Ge(i):i,this.hbVoteId=typeof o=="string"?Ge(o):o}getEncodingSchema(){return wc.encodingSchema}toEncodingData(){return new Map([["hb-address",this.hbAddress],["hb-key-dilution",this.hbKeyDilution],["hb-proof",this.hbProof.toEncodingData()],["hb-seed",this.hbSeed],["hb-vote-id",this.hbVoteId]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionHeartbeat: ${e}`);return new wc({hbAddress:e.get("hb-address"),hbKeyDilution:e.get("hb-key-dilution"),hbProof:Qa.fromEncodingData(e.get("hb-proof")??new Map),hbSeed:e.get("hb-seed"),hbVoteId:e.get("hb-vote-id")})}}class xc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"non-participation",valueSchema:new k(new gt),omitEmpty:!0},{key:"selection-participation-key",valueSchema:new k(new Pe),omitEmpty:!0},{key:"state-proof-key",valueSchema:new k(new Pe),omitEmpty:!0},{key:"vote-first-valid",valueSchema:new k(new O),omitEmpty:!0},{key:"vote-key-dilution",valueSchema:new k(new O),omitEmpty:!0},{key:"vote-last-valid",valueSchema:new k(new O),omitEmpty:!0},{key:"vote-participation-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({nonParticipation:e,selectionParticipationKey:t,stateProofKey:r,voteFirstValid:i,voteKeyDilution:o,voteLastValid:s,voteParticipationKey:a}){this.nonParticipation=e,this.selectionParticipationKey=typeof t=="string"?Ge(t):t,this.stateProofKey=typeof r=="string"?Ge(r):r,this.voteFirstValid=typeof i>"u"?void 0:ve(i),this.voteKeyDilution=typeof o>"u"?void 0:ve(o),this.voteLastValid=typeof s>"u"?void 0:ve(s),this.voteParticipationKey=typeof a=="string"?Ge(a):a}getEncodingSchema(){return xc.encodingSchema}toEncodingData(){return new Map([["non-participation",this.nonParticipation],["selection-participation-key",this.selectionParticipationKey],["state-proof-key",this.stateProofKey],["vote-first-valid",this.voteFirstValid],["vote-key-dilution",this.voteKeyDilution],["vote-last-valid",this.voteLastValid],["vote-participation-key",this.voteParticipationKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionKeyreg: ${e}`);return new xc({nonParticipation:e.get("non-participation"),selectionParticipationKey:e.get("selection-participation-key"),stateProofKey:e.get("state-proof-key"),voteFirstValid:e.get("vote-first-valid"),voteKeyDilution:e.get("vote-key-dilution"),voteLastValid:e.get("vote-last-valid"),voteParticipationKey:e.get("vote-participation-key")})}}class vc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"receiver",valueSchema:new Ce,omitEmpty:!0},{key:"close-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"close-remainder-to",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,receiver:t,closeAmount:r,closeRemainderTo:i}){this.amount=ve(e),this.receiver=t,this.closeAmount=typeof r>"u"?void 0:ve(r),this.closeRemainderTo=i}getEncodingSchema(){return vc.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["receiver",this.receiver],["close-amount",this.closeAmount],["close-remainder-to",this.closeRemainderTo]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionPayment: ${e}`);return new vc({amount:e.get("amount"),receiver:e.get("receiver"),closeAmount:e.get("close-amount"),closeRemainderTo:e.get("close-remainder-to")})}}class zl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"transaction",valueSchema:wr.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,transaction:t}){this.currentRound=ve(e),this.transaction=t}getEncodingSchema(){return zl.encodingSchema}toEncodingData(){return new Map([["current-round",this.currentRound],["transaction",this.transaction.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionResponse: ${e}`);return new zl({currentRound:e.get("current-round"),transaction:wr.fromEncodingData(e.get("transaction")??new Map)})}}class Sc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logicsig",valueSchema:new k(bc.encodingSchema),omitEmpty:!0},{key:"multisig",valueSchema:new k(Wr.encodingSchema),omitEmpty:!0},{key:"sig",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({logicsig:e,multisig:t,sig:r}){this.logicsig=e,this.multisig=t,this.sig=typeof r=="string"?Ge(r):r}getEncodingSchema(){return Sc.encodingSchema}toEncodingData(){return new Map([["logicsig",typeof this.logicsig<"u"?this.logicsig.toEncodingData():void 0],["multisig",typeof this.multisig<"u"?this.multisig.toEncodingData():void 0],["sig",this.sig]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignature: ${e}`);return new Sc({logicsig:typeof e.get("logicsig")<"u"?bc.fromEncodingData(e.get("logicsig")):void 0,multisig:typeof e.get("multisig")<"u"?Wr.fromEncodingData(e.get("multisig")):void 0,sig:e.get("sig")})}}class bc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logic",valueSchema:new Pe,omitEmpty:!0},{key:"args",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"logic-multisig-signature",valueSchema:new k(Wr.encodingSchema),omitEmpty:!0},{key:"multisig-signature",valueSchema:new k(Wr.encodingSchema),omitEmpty:!0},{key:"signature",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({logic:e,args:t,logicMultisigSignature:r,multisigSignature:i,signature:o}){this.logic=typeof e=="string"?Ge(e):e,this.args=t,this.logicMultisigSignature=r,this.multisigSignature=i,this.signature=typeof o=="string"?Ge(o):o}getEncodingSchema(){return bc.encodingSchema}toEncodingData(){return new Map([["logic",this.logic],["args",this.args],["logic-multisig-signature",typeof this.logicMultisigSignature<"u"?this.logicMultisigSignature.toEncodingData():void 0],["multisig-signature",typeof this.multisigSignature<"u"?this.multisigSignature.toEncodingData():void 0],["signature",this.signature]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignatureLogicsig: ${e}`);return new bc({logic:e.get("logic"),args:e.get("args"),logicMultisigSignature:typeof e.get("logic-multisig-signature")<"u"?Wr.fromEncodingData(e.get("logic-multisig-signature")):void 0,multisigSignature:typeof e.get("multisig-signature")<"u"?Wr.fromEncodingData(e.get("multisig-signature")):void 0,signature:e.get("signature")})}}class Wr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"subsignature",valueSchema:new k(new Me(Ec.encodingSchema)),omitEmpty:!0},{key:"threshold",valueSchema:new k(new O),omitEmpty:!0},{key:"version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({subsignature:e,threshold:t,version:r}){this.subsignature=e,this.threshold=typeof t>"u"?void 0:Le(t),this.version=typeof r>"u"?void 0:Le(r)}getEncodingSchema(){return Wr.encodingSchema}toEncodingData(){return new Map([["subsignature",typeof this.subsignature<"u"?this.subsignature.map(e=>e.toEncodingData()):void 0],["threshold",this.threshold],["version",this.version]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignatureMultisig: ${e}`);return new Wr({subsignature:typeof e.get("subsignature")<"u"?e.get("subsignature").map(t=>Ec.fromEncodingData(t)):void 0,threshold:e.get("threshold"),version:e.get("version")})}}class Ec{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"public-key",valueSchema:new k(new Pe),omitEmpty:!0},{key:"signature",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({publicKey:e,signature:t}){this.publicKey=typeof e=="string"?Ge(e):e,this.signature=typeof t=="string"?Ge(t):t}getEncodingSchema(){return Ec.encodingSchema}toEncodingData(){return new Map([["public-key",this.publicKey],["signature",this.signature]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignatureMultisigSubsignature: ${e}`);return new Ec({publicKey:e.get("public-key"),signature:e.get("signature")})}}class Ac{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"message",valueSchema:new k(tc.encodingSchema),omitEmpty:!0},{key:"state-proof",valueSchema:new k(sc.encodingSchema),omitEmpty:!0},{key:"state-proof-type",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,stateProof:t,stateProofType:r}){this.message=e,this.stateProof=t,this.stateProofType=typeof r>"u"?void 0:Le(r)}getEncodingSchema(){return Ac.encodingSchema}toEncodingData(){return new Map([["message",typeof this.message<"u"?this.message.toEncodingData():void 0],["state-proof",typeof this.stateProof<"u"?this.stateProof.toEncodingData():void 0],["state-proof-type",this.stateProofType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionStateProof: ${e}`);return new Ac({message:typeof e.get("message")<"u"?tc.fromEncodingData(e.get("message")):void 0,stateProof:typeof e.get("state-proof")<"u"?sc.fromEncodingData(e.get("state-proof")):void 0,stateProofType:e.get("state-proof-type")})}}class Ts{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"transactions",valueSchema:new Me(wr.encodingSchema),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,transactions:t,nextToken:r}){this.currentRound=ve(e),this.transactions=t,this.nextToken=r}getEncodingSchema(){return Ts.encodingSchema}toEncodingData(){return new Map([["current-round",this.currentRound],["transactions",this.transactions.map(e=>e.toEncodingData())],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionsResponse: ${e}`);return new Ts({currentRound:e.get("current-round"),transactions:(e.get("transactions")??[]).map(t=>wr.fromEncodingData(t)),nextToken:e.get("next-token")})}}const Ek=Object.freeze(Object.defineProperty({__proto__:null,Account:so,AccountParticipation:Ua,AccountResponse:Bl,AccountStateDelta:ja,AccountsResponse:Nl,Application:Zr,ApplicationLocalState:ao,ApplicationLocalStatesResponse:Pl,ApplicationLogData:Ga,ApplicationLogsResponse:Ol,ApplicationParams:Wa,ApplicationResponse:Ll,ApplicationStateSchema:yr,ApplicationsResponse:za,Asset:Jr,AssetBalancesResponse:Vl,AssetHolding:co,AssetHoldingsResponse:$l,AssetParams:lo,AssetResponse:_l,AssetsResponse:Ha,Block:Ds,BlockHeadersResponse:Ul,BlockRewards:Ya,BlockUpgradeState:Ka,BlockUpgradeVote:qa,Box:jl,BoxDescriptor:Xa,BoxReference:uo,BoxesResponse:Gl,ErrorResponse:Sd,EvalDelta:Za,EvalDeltaKeyValue:ho,HashFactory:Ja,HbProofFields:Qa,HealthCheck:Wl,HoldingRef:ec,IndexerStateProofMessage:tc,LocalsRef:nc,MerkleArrayProof:Gr,MiniAssetHolding:rc,ParticipationUpdates:ic,ResourceRef:oc,StateProofFields:sc,StateProofParticipant:ac,StateProofReveal:cc,StateProofSigSlot:lc,StateProofSignature:uc,StateProofTracking:dc,StateProofVerifier:hc,StateSchema:Yi,TealKeyValue:fo,TealValue:fc,Transaction:wr,TransactionApplication:pc,TransactionAssetConfig:gc,TransactionAssetFreeze:mc,TransactionAssetTransfer:yc,TransactionHeartbeat:wc,TransactionKeyreg:xc,TransactionPayment:vc,TransactionResponse:zl,TransactionSignature:Sc,TransactionSignatureLogicsig:bc,TransactionSignatureMultisig:Wr,TransactionSignatureMultisigSubsignature:Ec,TransactionStateProof:Ac,TransactionsResponse:Ts},Symbol.toStringTag,{value:"Module"}));class Ak extends lt{path(){return"/health"}prepare(e){return Et(e.getJSONText(),Wl)}}class Ik extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}/balances`}limit(e){return this.query.limit=e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),Vl)}}function bd(n){return typeof n=="string"?n:In(n)}class kk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/transactions`}notePrefix(e){return this.query["note-prefix"]=bd(e),this}txType(e){return this.query["tx-type"]=e,this}sigType(e){return this.query["sig-type"]=e,this}txid(e){return this.query.txid=e,this}round(e){return this.query.round=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}assetID(e){return this.query["asset-id"]=e,this}limit(e){return this.query.limit=e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}nextToken(e){return this.query.next=e,this}rekeyTo(e){return this.query["rekey-to"]=e,this}prepare(e){return Et(e.getJSONText(),Ts)}}class Ck extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}/transactions`}notePrefix(e){return this.query["note-prefix"]=bd(e),this}txType(e){return this.query["tx-type"]=e,this}sigType(e){return this.query["sig-type"]=e,this}txid(e){return this.query.txid=e,this}round(e){return this.query.round=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}limit(e){return this.query.limit=e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}addressRole(e){return this.query["address-role"]=e,this}address(e){return this.query.address=e.toString(),this}excludeCloseTo(e){return this.query["exclude-close-to"]=e,this}nextToken(e){return this.query.next=e,this}rekeyTo(e){return this.query["rekey-to"]=e,this}prepare(e){return Et(e.getJSONText(),Ts)}}class Fk extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}`}headerOnly(e){return this.query["header-only"]=e,this}prepare(e){return Et(e.getJSONText(),Ds)}}class Dk extends lt{constructor(e,t){super(e),this.txID=t}path(){return`/v2/transactions/${this.txID}`}prepare(e){return Et(e.getJSONText(),zl)}}class Tk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}`}round(e){return this.query.round=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}exclude(e){return this.query.exclude=e,this}prepare(e){return Et(e.getJSONText(),Bl)}}class Mk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/assets`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}assetId(e){return this.query["asset-id"]=e,this}prepare(e){return Et(e.getJSONText(),$l)}}class Rk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/created-assets`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}assetID(e){return this.query["asset-id"]=e,this}prepare(e){return Et(e.getJSONText(),Ha)}}class Bk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/apps-local-state`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}applicationID(e){return this.query["application-id"]=e,this}prepare(e){return Et(e.getJSONText(),Pl)}}class Nk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/created-applications`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}applicationID(e){return this.query["application-id"]=e,this}prepare(e){return Et(e.getJSONText(),za)}}class Pk extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}`}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),_l)}}class Ok extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/applications/${this.index}`}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),Ll)}}class Lk extends lt{constructor(e,t){super(e),this.appID=BigInt(t)}path(){return`/v2/applications/${this.appID}/logs`}limit(e){return this.query.limit=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}nextToken(e){return this.query.next=e,this}sender(e){return this.query["sender-address"]=e,this}txid(e){return this.query.txid=e,this}prepare(e){return Et(e.getJSONText(),Ol)}}class Vk extends lt{constructor(e,t,r){super(e),this.index=BigInt(t);const i=In(r);this.query.name=encodeURI(`b64:${i}`)}path(){return`/v2/applications/${this.index}/box`}prepare(e){return Et(e.getJSONText(),jl)}}class $k extends lt{path(){return"/v2/accounts"}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}limit(e){return this.query.limit=e,this}assetID(e){return this.query["asset-id"]=e,this}nextToken(e){return this.query.next=e,this}round(e){return this.query.round=e,this}authAddr(e){return this.query["auth-addr"]=e.toString(),this}applicationID(e){return this.query["application-id"]=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}exclude(e){return this.query.exclude=e,this}onlineOnly(e){return this.query["online-only"]=e,this}prepare(e){return Et(e.getJSONText(),Nl)}}class _k extends lt{path(){return"/v2/block-headers"}absent(e){return this.query.absent=e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}expired(e){return this.query.expired=e,this}limit(e){return this.query.limit=e,this}maxRound(e){return this.query["max-round"]=e,this}minRound(e){return this.query["min-round"]=e,this}nextToken(e){return this.query.next=e,this}proposers(e){return this.query.proposers=e,this}prepare(e){return Et(e.getJSONText(),Ul)}}class Uk extends lt{path(){return"/v2/transactions"}notePrefix(e){return this.query["note-prefix"]=bd(e),this}txType(e){return this.query["tx-type"]=e,this}sigType(e){return this.query["sig-type"]=e,this}txid(e){return this.query.txid=e,this}groupid(e){return this.query["group-id"]=bd(e),this}round(e){return this.query.round=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}assetID(e){return this.query["asset-id"]=e,this}limit(e){return this.query.limit=e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}addressRole(e){return this.query["address-role"]=e,this}address(e){return this.query.address=e.toString(),this}excludeCloseTo(e){return this.query["exclude-close-to"]=e,this}nextToken(e){return this.query.next=e,this}rekeyTo(e){return this.query["rekey-to"]=e,this}applicationID(e){return this.query["application-id"]=e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}prepare(e){return Et(e.getJSONText(),Ts)}}class jk extends lt{path(){return"/v2/assets"}limit(e){return this.query.limit=e,this}creator(e){return this.query.creator=e.toString(),this}name(e){return this.query.name=e,this}unit(e){return this.query.unit=e,this}index(e){return this.query["asset-id"]=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),Ha)}}class Gk extends lt{path(){return"/v2/applications"}index(e){return this.query["application-id"]=e,this}creator(e){return this.query.creator=e.toString(),this}nextToken(e){return this.query.next=e,this}limit(e){return this.query.limit=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),za)}}class Wk extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/applications/${this.index}/boxes`}nextToken(e){return this.query.next=e,this}limit(e){return this.query.limit=e,this}prepare(e){return Et(e.getJSONText(),Gl)}}class zk extends cg{constructor(e,t="http://127.0.0.1",r=8080,i={}){super("X-Indexer-API-Token",e,t,r,i)}makeHealthCheck(){return new Ak(this.c)}lookupAssetBalances(e){return new Ik(this.c,e)}lookupAssetTransactions(e){return new Ck(this.c,e)}lookupAccountTransactions(e){return new kk(this.c,e)}lookupBlock(e){return new Fk(this.c,e)}lookupTransactionByID(e){return new Dk(this.c,e)}lookupAccountByID(e){return new Tk(this.c,e)}lookupAccountAssets(e){return new Mk(this.c,e)}lookupAccountCreatedAssets(e){return new Rk(this.c,e)}lookupAccountAppLocalStates(e){return new Bk(this.c,e)}lookupAccountCreatedApplications(e){return new Nk(this.c,e)}lookupAssetByID(e){return new Pk(this.c,e)}lookupApplications(e){return new Ok(this.c,e)}lookupApplicationLogs(e){return new Lk(this.c,e)}searchAccounts(){return new $k(this.c)}searchForBlockHeaders(){return new _k(this.c)}searchForTransactions(){return new Uk(this.c)}searchForAssets(){return new jk(this.c)}searchForApplications(){return new Gk(this.c)}searchForApplicationBoxes(e){return new Wk(this.c,e)}lookupApplicationBoxByIDandName(e,t){return new Vk(this.c,e,t)}}async function wx(n,e,t){const r=await n.status().do();if(typeof r>"u")throw new Error("Unable to get node status");const i=r.lastRound+BigInt(1),o=i+BigInt(t);let s=i;for(;s<o;){let a=!1;try{const l=await n.pendingTransactionInformation(e).do();if(l.confirmedRound)return l;if(l.poolError)throw a=!0,new Error(`Transaction Rejected: ${l.poolError}`)}catch(l){if(a)throw l}await n.statusAfterBlock(s).do(),s+=BigInt(1)}throw new Error(`Transaction not confirmed after ${t} rounds`)}function Ms(n,e){let t=n.toString(16);t.length!==e*2&&(t=t.padStart(e*2,"0"));const r=new Uint8Array(t.length/2);for(let i=0,o=0;i<t.length/2;i++,o+=2)r[i]=parseInt(t.slice(o,o+2),16);return r}function hg(n){let e=BigInt(0);const t=new DataView(n.buffer,n.byteOffset);for(let r=0;r<n.length;r++)e=BigInt(Number(t.getUint8(r)))+e*BigInt(256);return e}function Hk(){const n=q1();return{addr:new ze(n.publicKey),sk:n.secretKey}}const Cp=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"],Ph="failed to decode mnemonic",Yk="the mnemonic contains a word that is not in the wordlist";function xx(n){const e=[];let t=0,r=0;function i(s){t|=s<<r,r+=8,r>=11&&(e.push(t&2047),t>>=11,r-=11)}function o(){r&&e.push(t)}return n.forEach(i),o(),e}function vx(n){return n.map(e=>Cp[e])}function Sx(n){const e=wi(n),t=xx(e);return vx(t)[0]}function fg(n){if(n.length!==Lf)throw new RangeError(`Seed length must be ${Lf}`);const e=xx(n),t=vx(e),r=Sx(n);return`${t.join(" ")} ${r}`}function Kk(n){const e=[];let t=0,r=0;function i(s){for(t|=s<<r,r+=11;r>=8;)e.push(t&255),t>>=8,r-=8}function o(){r&&e.push(t)}return n.forEach(i),o(),new Uint8Array(e)}function pg(n){const e=n.split(" "),t=e.slice(0,24);for(const a of t)if(Cp.indexOf(a)===-1)throw new Error(Yk);const r=e[e.length-1],i=t.map(a=>Cp.indexOf(a));let o=Kk(i);if(o.length!==33)throw new Error(Ph);if(o[o.length-1]!==0)throw new Error(Ph);if(o=o.slice(0,o.length-1),Sx(o)===r)return o;throw new Error(Ph)}function qk(n){const e=pg(n),t=V0(e);return{addr:new ze(t.publicKey),sk:t.secretKey}}function Xk(n){const e=n.slice(0,Lf);return fg(e)}function Zk(n){return pg(n)}function Jk(n){return fg(n)}const Jm=16,Qk=new TextEncoder().encode("TG");function eC(n){if(n.length>Jm)throw new Error(`${n.length} transactions grouped together but max group size is ${Jm}`);if(n.length===0)throw new Error("Cannot compute group ID of zero transactions");const e=du({txlist:n});return hn(Qk,e)}function bx(n){const e=[];for(const i of n)e.push(i.rawTxID());const t=eC(e),r=wi(t);return Uint8Array.from(r)}function Ex(n){const e=bx(n);for(const t of n)t.group=e;return n}function tC(n,e,t){if(!e.verify(t.publicKey))throw new Error("Logic signature verification failed. Ensure the program and signature are valid.");let r;_0(t.publicKey,n.sender.publicKey)||(r=t);const i=new jt({lsig:e,txn:n,sgnr:r});return{txID:n.txID(),blob:Sr(i)}}function gg(n,e){let t,r;if(e instanceof dg)t=e.lsig,r=e.address();else if(t=e,t.sig)r=new ze(n.sender.publicKey);else if(t.lmsig){const i={version:t.lmsig.v,threshold:t.lmsig.thr,pks:t.lmsig.subsig.map(o=>o.pk)};r=xi(i)}else r=t.address();return tC(n,t,r)}function nC(n,e){return gg(n,e)}const rC="Not enough multisig transactions to merge. Need at least two",iC="Cannot merge txs. txIDs differ",oC="Cannot merge txs. Auth addrs differ",Qm="Cannot merge txs. Multisig preimages differ",sC="Cannot merge txs. subsigs are mismatched.",aC="Cannot add multisig signature. Signature is not of the correct length.",cC="Key does not exist";function Ax(n,{version:e,threshold:t,addrs:r}){const i=Tc(r),o=i.map(d=>({pk:d})),s={v:e,thr:t,subsig:o},a=xi({version:e,threshold:t,pks:i});let l;n.sender.equals(a)||(l=a);const c=new jt({txn:n,msig:s,sgnr:l});return Sr(c)}function Ix(n,{rawSig:e,myPk:t},{version:r,threshold:i,pks:o}){const s=Ax(n,{version:r,threshold:i,addrs:o.map(c=>new ze(c))}),a=Xt(s,jt);let l=!1;if(a.msig.subsig.forEach((c,d)=>{_0(c.pk,t)&&(l=!0,a.msig.subsig[d].s=e)}),!l)throw new Error(cC);return Sr(a)}function kx(n,{version:e,threshold:t,pks:r},i){const o=jd(i).publicKey;return Ix(n,{rawSig:n.rawSignTxn(i),myPk:o},{version:e,threshold:t,pks:r})}function lC(n,e,t,r){if(!$0(r.length))throw new Error(aC);const i=typeof t=="string"?ze.fromString(t):t;return Ix(n,{rawSig:r,myPk:i.publicKey},e)}function Qd(n){if(n.length<2)throw new Error(rC);const e=Xt(n[0],jt);if(!e.msig)throw new Error("Invalid multisig transaction, multisig structure missing at index 0");const t=e.txn.txID(),r=e.sgnr?e.sgnr.toString():void 0,i={version:e.msig.v,threshold:e.msig.thr,pks:e.msig.subsig.map(d=>d.pk)},o=xi(i),s=e.msig.subsig.map(d=>({...d}));for(let d=1;d<n.length;d++){const u=Xt(n[d],jt);if(!u.msig)throw new Error(`Invalid multisig transaction, multisig structure missing at index ${d}`);if(u.txn.txID()!==t)throw new Error(iC);const m=u.sgnr?u.sgnr.toString():void 0;if(r!==m)throw new Error(oC);if(u.msig.subsig.length!==e.msig.subsig.length)throw new Error(Qm);const h={version:u.msig.v,threshold:u.msig.thr,pks:u.msig.subsig.map(A=>A.pk)},x=xi(h);if(!o.equals(x))throw new Error(Qm);u.msig.subsig.forEach((A,v)=>{if(!A.s)return;const F=s[v];if(F.s&&!Kr(A.s,F.s))throw new Error(sC);F.s=A.s})}const a={v:e.msig.v,thr:e.msig.thr,subsig:s},l=typeof r<"u"?e.sgnr:void 0,c=new jt({msig:a,txn:e.txn,sgnr:l});return Sr(c)}function Cx(n,{version:e,threshold:t,addrs:r},i){const o=Tc(r),s=kx(n,{version:e,threshold:t,pks:o},i);return{txID:n.txID(),blob:s}}function uC(n,{version:e,threshold:t,addrs:r},i){const o=Tc(r),s=Xt(n,jt),a=kx(s.txn,{version:e,threshold:t,pks:o},i);return{txID:s.txn.txID(),blob:Qd([n,a])}}function dC(n,{version:e,threshold:t,addrs:r},i,o){const s=Tc(r),a=Xt(n,jt),l=lC(a.txn,{version:e,threshold:t,pks:s},i,o);return{txID:a.txn.txID(),blob:Qd([n,l])}}let Fx={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(n,e){Fx[n]=e});function hC(n){let e=[],t=0,r=0;for(let i=0;i<n.length;i+=1){let o=Fx[n[i]];if(o===void 0)throw new Error("Invalid character ("+n[i]+")");const s=o&32;if(o&=31,r+=o<<t,s)t+=5;else{const a=r&1;r>>>=1,a?e.push(r===0?-2147483648:-r):e.push(r),r=t=0}}return e}class Dx{constructor({version:e,sources:t,names:r,mappings:i}){if(this.version=e,this.sources=t,this.names=r,this.mappings=i,this.version!==3)throw new Error(`Only version 3 is supported, got ${this.version}`);if(this.mappings===void 0)throw new Error("mapping undefined, cannot build source map without `mapping`");const o=this.mappings.split(";").map(hC);this.pcToLocation=new Map,this.sourceAndLineToPc=new Map;const s={line:0,column:0,sourceIndex:0,nameIndex:0};for(const[a,l]of o.entries()){if(l.length<4)continue;const c=l.length>4?l[4]:void 0,[,d,u,m]=l;s.sourceIndex+=d,s.line+=u,s.column+=m,typeof c<"u"&&(s.nameIndex+=c);const h=`${s.sourceIndex}:${s.line}`;let x=this.sourceAndLineToPc.get(h);x===void 0&&(x=[],this.sourceAndLineToPc.set(h,x));const A={pc:a,column:s.column},v={line:s.line,column:s.column,sourceIndex:s.sourceIndex};typeof c<"u"&&(A.nameIndex=s.nameIndex,v.nameIndex=s.nameIndex),x.push(A),this.pcToLocation.set(a,v)}}getPcs(){return Array.from(this.pcToLocation.keys())}getLocationForPc(e){return this.pcToLocation.get(e)}getPcsOnSourceLine(e,t){const r=this.sourceAndLineToPc.get(`${e}:${t}`);return r===void 0?[]:r}}const fC=1380011588,mg=30;async function pC({client:n,txns:e,protocolVersion:t,latestTimestamp:r,round:i,sources:o}){const s=[],a=[],l=[],c=[],d=[];for(const x of e)if(x.txn.type===Bt.appl)if(d.push(x.txn.sender.toString()),d.push(...x.txn.applicationCall.accounts.map(A=>A.toString())),l.push(...x.txn.applicationCall.foreignApps),d.push(...x.txn.applicationCall.foreignApps.map(dd).map(A=>A.toString())),c.push(...x.txn.applicationCall.foreignAssets),x.txn.applicationCall.appIndex===BigInt(0))s.push(new Is({id:fC,params:new Ea({creator:x.txn.sender.toString(),approvalProgram:x.txn.applicationCall.approvalProgram,clearStateProgram:x.txn.applicationCall.clearProgram,localStateSchema:new Dr({numUint:x.txn.applicationCall.numLocalInts,numByteSlice:x.txn.applicationCall.numLocalByteSlices}),globalStateSchema:new Dr({numUint:x.txn.applicationCall.numGlobalInts,numByteSlice:x.txn.applicationCall.numGlobalByteSlices})})}));else{const{appIndex:A}=x.txn.applicationCall;l.push(A),d.push(dd(A).toString())}const u=[];for(const x of new Set(c))u.push(n.getAssetByID(x).do().then(A=>{d.push(A.params.creator)}));await Promise.all(u);const m=[];for(const x of new Set(l))m.push(n.getApplicationByID(x).do().then(A=>{s.push(A),d.push(A.params.creator.toString())}));await Promise.all(m);const h=[];for(const x of new Set(d))h.push(n.accountInformation(x).do().then(A=>{a.push(A)}));return await Promise.all(h),new Sl({txns:e.slice(),accounts:a,apps:s,latestTimestamp:r??0,round:i??0,protocolVersion:t??"",sources:o??[]})}function Oh(n,e){return n.length>e&&e>0?`${n.slice(0,e)}...`:n}function gC(n,e){if(e.length===0)return"";let t=null;for(let i=0;i<e.length;i++){if(i>n.length){t=i;continue}yi(n[i])!==yi(e[i])&&(t=i)}if(t==null)return"";const r=e[t];return r.bytes.length>0?`${t} = 0x${zd(r.bytes)}`:`${t} = ${r.uint.toString()}`}function mC(n,e){return`[${(e?n.reverse():n).map(r=>{switch(r.type){case 1:return`0x${zd(r.bytes)}`;case 2:return r.uint.toString();default:return""}}).join(", ")}]`}function Tx(n,e,t){const r=t.maxValueWidth||mg,i=[["pc#","ln#","source","scratch","stack"]];for(let s=0;s<n.length;s++){const{line:a,error:l,pc:c,scratch:d,stack:u}=n[s],m=d!==void 0?d:[],h=s>0&&n[s-1].scratch!==void 0?n[s-1].scratch:[],x=l?`!! ${l} !!`:e[a];i.push([c.toString().padEnd(3," "),a.toString().padEnd(3," "),Oh(x,r),Oh(gC(h,m),r),Oh(mC(u,t.topOfStackFirst),r)])}const o=i.reduce((s,a)=>{const l=new Array(i[0].length).fill(0);for(let c=0;c<s.length;c++)l[c]=a[c].length>s[c]?a[c].length:s[c];return l},new Array(i[0].length).fill(0));return`${i.map(s=>s.map((a,l)=>a.padEnd(o[l]+1," ")).join("|").trim()).join(`
37
+ */var _m;function X1(){return _m||(_m=1,(function(n){(function(){var e=typeof window=="object"?window:{},t=!e.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;t&&(e=P0);var r=!e.HI_BASE32_NO_COMMON_JS&&!0&&n.exports,i="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),o={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},s=[0,0,0,0,0,0,0,0],a=function(v,F){F.length>10&&(F="..."+F.substr(-10));var w=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+v+" bytes: "+F+" <-");throw w.position=v,w},l=function(v){for(var F="",w=v.length,C=0,M=0,N,b;C<w;){if(N=v[C++],N<=127){F+=String.fromCharCode(N);continue}else N>191&&N<=223?(b=N&31,M=1):N<=239?(b=N&15,M=2):N<=247?(b=N&7,M=3):a(C,F);for(var j=0;j<M;++j)N=v[C++],(N<128||N>191)&&a(C,F),b<<=6,b+=N&63;b>=55296&&b<=57343&&a(C,F),b>1114111&&a(C,F),b<=65535?F+=String.fromCharCode(b):(b-=65536,F+=String.fromCharCode((b>>10)+55296),F+=String.fromCharCode((b&1023)+56320))}return F},c=function(v){if(v==="")return[];if(!/^[A-Z2-7=]+$/.test(v))throw new Error("Invalid base32 characters");v=v.replace(/=/g,"");for(var F,w,C,M,N,b,j,p,E=[],S=0,$=v.length,B=0,P=$>>3<<3;B<P;)F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],p=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255,E[S++]=(M<<4|N>>>1)&255,E[S++]=(N<<7|b<<2|j>>>3)&255,E[S++]=(j<<5|p)&255;var W=$-P;return W===2?(F=o[v.charAt(B++)],w=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255):W===4?(F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255):W===5?(F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255,E[S++]=(M<<4|N>>>1)&255):W===7&&(F=o[v.charAt(B++)],w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],E[S++]=(F<<3|w>>>2)&255,E[S++]=(w<<6|C<<1|M>>>4)&255,E[S++]=(M<<4|N>>>1)&255,E[S++]=(N<<7|b<<2|j>>>3)&255),E},d=function(v){for(var F,w,C,M,N,b="",j=v.length,p=0,E=parseInt(j/5)*5;p<E;)F=v.charCodeAt(p++),w=v.charCodeAt(p++),C=v.charCodeAt(p++),M=v.charCodeAt(p++),N=v.charCodeAt(p++),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[(M<<3|N>>>5)&31]+i[N&31];var S=j-E;return S===1?(F=v.charCodeAt(p),b+=i[F>>>3]+i[F<<2&31]+"======"):S===2?(F=v.charCodeAt(p++),w=v.charCodeAt(p),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[w<<4&31]+"===="):S===3?(F=v.charCodeAt(p++),w=v.charCodeAt(p++),C=v.charCodeAt(p),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[C<<1&31]+"==="):S===4&&(F=v.charCodeAt(p++),w=v.charCodeAt(p++),C=v.charCodeAt(p++),M=v.charCodeAt(p),b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[M<<3&31]+"="),b},u=function(v){var F,w,C,M,N,b,j=!1,p="",E=0,S,$=0,B=v.length;if(v==="")return p;do{for(s[0]=s[5],s[1]=s[6],s[2]=s[7],S=$;E<B&&S<5;++E)b=v.charCodeAt(E),b<128?s[S++]=b:b<2048?(s[S++]=192|b>>6,s[S++]=128|b&63):b<55296||b>=57344?(s[S++]=224|b>>12,s[S++]=128|b>>6&63,s[S++]=128|b&63):(b=65536+((b&1023)<<10|v.charCodeAt(++E)&1023),s[S++]=240|b>>18,s[S++]=128|b>>12&63,s[S++]=128|b>>6&63,s[S++]=128|b&63);$=S-5,E===B&&++E,E>B&&S<6&&(j=!0),F=s[0],S>4?(w=s[1],C=s[2],M=s[3],N=s[4],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[(M<<3|N>>>5)&31]+i[N&31]):S===1?p+=i[F>>>3]+i[F<<2&31]+"======":S===2?(w=s[1],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[w<<4&31]+"===="):S===3?(w=s[1],C=s[2],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[C<<1&31]+"==="):(w=s[1],C=s[2],M=s[3],p+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[M<<3&31]+"=")}while(!j);return p},m=function(v){for(var F,w,C,M,N,b="",j=v.length,p=0,E=parseInt(j/5)*5;p<E;)F=v[p++],w=v[p++],C=v[p++],M=v[p++],N=v[p++],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[(M<<3|N>>>5)&31]+i[N&31];var S=j-E;return S===1?(F=v[p],b+=i[F>>>3]+i[F<<2&31]+"======"):S===2?(F=v[p++],w=v[p],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[w<<4&31]+"===="):S===3?(F=v[p++],w=v[p++],C=v[p],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[C<<1&31]+"==="):S===4&&(F=v[p++],w=v[p++],C=v[p++],M=v[p],b+=i[F>>>3]+i[(F<<2|w>>>6)&31]+i[w>>>1&31]+i[(w<<4|C>>>4)&31]+i[(C<<1|M>>>7)&31]+i[M>>>2&31]+i[M<<3&31]+"="),b},h=function(v,F){var w=typeof v!="string";return w&&v.constructor===ArrayBuffer&&(v=new Uint8Array(v)),w?m(v):F?d(v):u(v)},x=function(v,F){if(!F)return l(c(v));if(v==="")return"";if(!/^[A-Z2-7=]+$/.test(v))throw new Error("Invalid base32 characters");var w,C,M,N,b,j,p,E,S="",$=v.indexOf("=");$===-1&&($=v.length);for(var B=0,P=$>>3<<3;B<P;)w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],p=o[v.charAt(B++)],E=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)+String.fromCharCode((N<<4|b>>>1)&255)+String.fromCharCode((b<<7|j<<2|p>>>3)&255)+String.fromCharCode((p<<5|E)&255);var W=$-P;return W===2?(w=o[v.charAt(B++)],C=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)):W===4?(w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)):W===5?(w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)+String.fromCharCode((N<<4|b>>>1)&255)):W===7&&(w=o[v.charAt(B++)],C=o[v.charAt(B++)],M=o[v.charAt(B++)],N=o[v.charAt(B++)],b=o[v.charAt(B++)],j=o[v.charAt(B++)],p=o[v.charAt(B++)],S+=String.fromCharCode((w<<3|C>>>2)&255)+String.fromCharCode((C<<6|M<<1|N>>>4)&255)+String.fromCharCode((N<<4|b>>>1)&255)+String.fromCharCode((b<<7|j<<2|p>>>3)&255)),S},A={encode:h,decode:x};x.asBytes=c,r?n.exports=A:e.base32=A})()})(Fh)),Fh.exports}var Z1=X1();const ul=$d(Z1);function j0(n){if(!(typeof n=="bigint"||Number.isInteger(n))||n<0||n>BigInt("0xffffffffffffffff"))throw new Error("Input is not a 64-bit unsigned integer");const t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(n)),t}function G0(n,e="safe"){if(e!=="safe"&&e!=="mixed"&&e!=="bigint")throw new Error(`Unknown decodingMode option: ${e}`);if(n.byteLength===0||n.byteLength>8)throw new Error(`Data has unacceptable length. Expected length is between 1 and 8, got ${n.byteLength}`);const t=new Uint8Array(8-n.byteLength),r=hn(t,n),o=new DataView(r.buffer).getBigUint64(0),s=o>BigInt(Number.MAX_SAFE_INTEGER);if(e==="safe"){if(s)throw new Error(`Integer exceeds maximum safe integer: ${o.toString()}. Try decoding with "mixed" or "safe" decodingMode.`);return Number(o)}return e==="mixed"&&!s?Number(o):o}function Ge(n){if(Ud())return new Uint8Array(Buffer.from(n,"base64"));const e=atob(n);return Uint8Array.from(e,t=>t.codePointAt(0))}function In(n){if(Ud())return Buffer.from(n).toString("base64");const e=Array.from(n,t=>String.fromCodePoint(t)).join("");return btoa(e)}function Wd(n){return new TextDecoder().decode(n)}function qr(n){return typeof n=="string"?new TextEncoder().encode(n):n}function zd(n){return Ud()?Buffer.from(n).toString("hex"):Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}function J1(n){if(Ud())return Buffer.from(n,"hex");let e=n;n.length%2!==0&&(e=n.padStart(1,"0"));const t=new Uint8Array(e.length/2);for(let r=0;r<e.length/2;r++)t[r]=parseInt(e.slice(2*r,2*r+2),16);return t}const ko=36,Jc=4,Dh=58,Q1="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ",Vc="address seems to be malformed",eA="wrong checksum for address";function Um(n){return Uint8Array.from(wi(n).slice($m-Jc,$m))}class ze{constructor(e){if(!(e instanceof Uint8Array))throw new Error(`${Vc}: ${e} is not Uint8Array, type ${typeof e}`);if(e.length!==ko-Jc)throw new Error(`${Vc}: 0x${zd(e)}, length ${e.length}`);this.publicKey=e}equals(e){return e instanceof ze&&Kr(this.publicKey,e.publicKey)}checksum(){return Um(this.publicKey)}toString(){return ul.encode(hn(this.publicKey,this.checksum())).slice(0,Dh)}static fromString(e){if(typeof e!="string")throw new Error(`${Vc}: expected string, got ${typeof e}, ${e}`);if(e.length!==Dh)throw new Error(`${Vc}: expected length ${Dh}, got ${e.length}: ${e}`);const t=ul.decode.asBytes(e);if(t.length!==ko)throw new Error(`${Vc}: expected byte length ${ko}, got ${t.length}`);const r=new Uint8Array(t.slice(0,ko-Jc)),i=new Uint8Array(t.slice(U0,ko)),o=Um(r);if(!Kr(o,i))throw new Error(eA);return new ze(r)}static zeroAddress(){return new ze(new Uint8Array(ko-Jc))}}function W0(n){return ze.fromString(n)}function z0(n){try{ze.fromString(n)}catch{return!1}return!0}function H0(n){return new ze(n).toString()}const tA=new TextEncoder().encode("appID");function dd(n){const e=hn(tA,j0(n)),t=wi(e);return new ze(Uint8Array.from(t))}const Y0=1e6,ag="Microalgos should be positive and less than 2^53 - 1.";function nA(n){if(n<0||!Number.isSafeInteger(n))throw new Error(ag);return n/Y0}function rA(n){const e=n*Y0;return Math.round(e)}class iA extends Error{constructor(e,t){super(e),this.response=t,this.name="URLTokenBaseHTTPError",this.response=t}}class Ni{constructor(e,t,r,i={}){this.defaultHeaders=i;const o=t.endsWith("/")?t:`${t}/`,s=new URL(o);if(typeof r<"u"&&(s.port=r.toString()),s.protocol.length===0)throw new Error("Invalid base server URL, protocol must be defined.");this.baseURL=s,this.tokenHeader=e}getURL(e,t){let r;e.startsWith("./")?r=e:e.startsWith("/")?r=`.${e}`:r=`./${e}`;const i=new URL(r,this.baseURL);if(t)for(const[o,s]of Object.entries(t))i.searchParams.set(o,s.toString());return i.toString()}static formatFetchResponseHeaders(e){const t={};return e.forEach((r,i)=>{t[r]=i}),t}static async checkHttpError(e){if(e.ok)return;let t,r;try{t=new Uint8Array(await e.arrayBuffer());const o=JSON.parse(new TextDecoder().decode(t));o.message&&(r=o.message)}catch{}let i=`Network request error. Received status ${e.status} (${e.statusText})`;throw r&&(i+=`: ${r}`),new iA(i,{body:t??new Uint8Array,status:e.status,headers:Ni.formatFetchResponseHeaders(e.headers)})}static async formatFetchResponse(e){return await this.checkHttpError(e),{body:new Uint8Array(await e.arrayBuffer()),status:e.status,headers:Ni.formatFetchResponseHeaders(e.headers)}}async get(e,t,r,i){const o={...this.tokenHeader,...this.defaultHeaders,...r??{}},s=await fetch(this.getURL(e,t),{headers:o,...i??{}});return Ni.formatFetchResponse(s)}async post(e,t,r,i,o){const s={...this.tokenHeader,...this.defaultHeaders,...i??{}},a=await fetch(this.getURL(e,r),{method:"POST",body:t,headers:s,...o??{}});return Ni.formatFetchResponse(a)}async delete(e,t,r,i,o){const s={...this.tokenHeader,...this.defaultHeaders,...i??{}},a=await fetch(this.getURL(e,r),{method:"DELETE",body:t,headers:s,...o??{}});return Ni.formatFetchResponse(a)}}class oA{constructor(e){this.body=e.body,this.text=e.text,this.format=e.format,this.headers=e.headers,this.status=e.status,this.ok=e.ok}getJSONText(){if(this.text===void 0)throw new Error(`Response body does not contain JSON data. Format is ${this.format}`);return this.text}parseBodyAsJSON(e){if(this.text===void 0)throw new Error(`Response body does not contain JSON data. Format is ${this.format}`);return Jn.parseJSON(this.text,this.status,e)}}function sA(n){for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(!n[e]||n[e].length===0)&&delete n[e];return n}function jm(n){return Object.keys(n).reduce((e,t)=>(e[t.toLowerCase()]=n[t],e),{})}function aA(n){if(n!==void 0&&Object.prototype.hasOwnProperty.call(n,"format"))switch(n.format){case"msgpack":return"application/msgpack";case"json":default:return"application/json"}else return"application/json"}class Jn{constructor(e,t,r,i={}){t!==void 0?this.bc=new Ni(e,t,r,i):this.bc=e}static parseJSON(e,t,r){try{return e?_d(e,r):null}catch(i){const o=i;throw o.rawResponse=e||null,o.statusCode=t,o}}static serializeData(e,t){if(!e)return new Uint8Array(0);if(t["content-type"]==="application/json")return new TextEncoder().encode(yi(e));if(typeof e=="string")return new TextEncoder().encode(e);if(e instanceof Uint8Array)return e;throw new Error("provided data is neither a string nor a Uint8Array and content-type is not application/json")}static prepareResponse(e,t){const{body:r}=e;let i;return t!=="application/msgpack"&&(i=r&&new TextDecoder().decode(r)||""),new oA({...e,format:t,text:i,ok:Math.trunc(e.status/100)===2})}static prepareResponseError(e){return e.response&&(e.response=Jn.prepareResponse(e.response,"application/json"),e.status=e.response.status),e}async get({relativePath:e,query:t,requestHeaders:r,customOptions:i}){const o=aA(t),s={...r??{},accept:o};try{const a=await this.bc.get(e,t?sA(t):void 0,s,i);return Jn.prepareResponse(a,o)}catch(a){throw Jn.prepareResponseError(a)}}async post({relativePath:e,data:t,query:r,requestHeaders:i,customOptions:o}){const s={"content-type":"application/json",...jm(i??{})};try{const a=await this.bc.post(e,Jn.serializeData(t,s),r,s,o);return Jn.prepareResponse(a,"application/json")}catch(a){throw Jn.prepareResponseError(a)}}async delete({relativePath:e,data:t,requestHeaders:r,customOptions:i}){const o={"content-type":"application/json",...jm(r??{})};try{const s=await this.bc.delete(e,typeof t<"u"?Jn.serializeData(t,o):void 0,void 0,o,i);return Jn.prepareResponse(s,"application/json")}catch(s){throw Jn.prepareResponseError(s)}}}function cA(n,e=""){const t={};return e===""||(t[n]=e),t}function lA(n){return typeof n.get=="function"}class cg{constructor(e,t,r,i,o={}){if(lA(t))this.c=new Jn(t);else{let s;typeof t=="string"?s=cA(e,t):s=t,this.c=new Jn(s,r,i,o)}}}function uA(n){for(var e=n.length,t=0,r=0;r<e;){var i=n.charCodeAt(r++);if((i&4294967168)===0){t++;continue}else if((i&4294965248)===0)t+=2;else{if(i>=55296&&i<=56319&&r<e){var o=n.charCodeAt(r);(o&64512)===56320&&(++r,i=((i&1023)<<10)+(o&1023)+65536)}(i&4294901760)===0?t+=3:t+=4}}return t}function dA(n,e,t){for(var r=n.length,i=t,o=0;o<r;){var s=n.charCodeAt(o++);if((s&4294967168)===0){e[i++]=s;continue}else if((s&4294965248)===0)e[i++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<r){var a=n.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}(s&4294901760)===0?(e[i++]=s>>12&15|224,e[i++]=s>>6&63|128):(e[i++]=s>>18&7|240,e[i++]=s>>12&63|128,e[i++]=s>>6&63|128)}e[i++]=s&63|128}}var hA=new TextEncoder,fA=50;function pA(n,e,t){hA.encodeInto(n,e.subarray(t))}function gA(n,e,t){n.length>fA?pA(n,e,t):dA(n,e,t)}var mA=4096;function K0(n,e,t){for(var r=e,i=r+t,o=[],s="";r<i;){var a=n[r++];if((a&128)===0)o.push(a);else if((a&224)===192){var l=n[r++]&63;o.push((a&31)<<6|l)}else if((a&240)===224){var l=n[r++]&63,c=n[r++]&63;o.push((a&31)<<12|l<<6|c)}else if((a&248)===240){var l=n[r++]&63,c=n[r++]&63,d=n[r++]&63,u=(a&7)<<18|l<<12|c<<6|d;u>65535&&(u-=65536,o.push(u>>>10&1023|55296),u=56320|u&1023),o.push(u)}else o.push(a);o.length>=mA&&(s+=String.fromCharCode.apply(String,o),o.length=0)}return o.length>0&&(s+=String.fromCharCode.apply(String,o)),s}var yA=new TextDecoder,wA=200;function xA(n,e,t){var r=n.subarray(e,e+t);return yA.decode(r)}function vA(n,e,t){return t>wA?xA(n,e,t):K0(n,e,t)}var Iu=(function(){function n(e,t){this.type=e,this.data=t}return n})(),SA=(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},n(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),Nr=(function(n){SA(e,n);function e(t){var r=n.call(this,t)||this,i=Object.create(e.prototype);return Object.setPrototypeOf(r,i),Object.defineProperty(r,"name",{configurable:!0,enumerable:!1,value:e.name}),r}return e})(Error),un;(function(n){n[n.UNSAFE_NUMBER=0]="UNSAFE_NUMBER",n[n.SAFE_NUMBER=1]="SAFE_NUMBER",n[n.AS_ENCODED=2]="AS_ENCODED",n[n.MIXED=3]="MIXED",n[n.BIGINT=4]="BIGINT"})(un||(un={}));var $c=4294967295;function bA(n,e,t){var r=t/4294967296,i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function q0(n,e,t){var r=Math.floor(t/4294967296),i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function X0(n,e,t){if(t===un.UNSAFE_NUMBER||t===un.SAFE_NUMBER){var r=n.getInt32(e),i=n.getUint32(e+4);if(t===un.SAFE_NUMBER&&(r<Math.floor(Number.MIN_SAFE_INTEGER/4294967296)||r===Math.floor(Number.MIN_SAFE_INTEGER/4294967296)&&i===0||r>(Number.MAX_SAFE_INTEGER-i)/4294967296)){var o="".concat(r<0?"-":"","0x").concat(Math.abs(r).toString(16)).concat(i.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(o))}return r*4294967296+i}var s=n.getBigInt64(e);return t===un.MIXED&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}function EA(n,e,t){if(t===un.UNSAFE_NUMBER||t===un.SAFE_NUMBER){var r=n.getUint32(e),i=n.getUint32(e+4);if(t===un.SAFE_NUMBER&&r>(Number.MAX_SAFE_INTEGER-i)/4294967296){var o="0x".concat(r.toString(16)).concat(i.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(o))}return r*4294967296+i}var s=n.getBigUint64(e);return t===un.MIXED&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}function AA(n,e){return e===un.BIGINT?BigInt(n):Number(n)}var IA=-1,kA=4294967296-1,CA=17179869184-1;function FA(n){var e=n.sec,t=n.nsec;if(e>=0&&t>=0&&e<=CA)if(t===0&&e<=kA){var r=new Uint8Array(4),i=new DataView(r.buffer);return i.setUint32(0,e),r}else{var o=e/4294967296,s=e&4294967295,r=new Uint8Array(8),i=new DataView(r.buffer);return i.setUint32(0,t<<2|o&3),i.setUint32(4,s),r}else{var r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,t),q0(i,4,e),r}}function DA(n){var e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,i=Math.floor(r/1e9);return{sec:t+i,nsec:r-i*1e9}}function TA(n){if(n instanceof Date){var e=DA(n);return FA(e)}else return null}function MA(n){var e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:{var t=e.getUint32(0),r=0;return{sec:t,nsec:r}}case 8:{var i=e.getUint32(0),o=e.getUint32(4),t=(i&3)*4294967296+o,r=i>>>2;return{sec:t,nsec:r}}case 12:{var t=X0(e,4,un.UNSAFE_NUMBER),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new Nr("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(n.length))}}function RA(n){var e=MA(n);return new Date(e.sec*1e3+e.nsec/1e6)}var BA={type:IA,encode:TA,decode:RA},Z0=(function(){function n(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(BA)}return n.prototype.register=function(e){var t=e.type,r=e.encode,i=e.decode;if(t>=0)this.encoders[t]=r,this.decoders[t]=i;else{var o=1+t;this.builtInEncoders[o]=r,this.builtInDecoders[o]=i}},n.prototype.tryToEncode=function(e,t){for(var r=0;r<this.builtInEncoders.length;r++){var i=this.builtInEncoders[r];if(i!=null){var o=i(e,t);if(o!=null){var s=-1-r;return new Iu(s,o)}}}for(var r=0;r<this.encoders.length;r++){var i=this.encoders[r];if(i!=null){var o=i(e,t);if(o!=null){var s=r;return new Iu(s,o)}}}return e instanceof Iu?e:null},n.prototype.decode=function(e,t,r){var i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,r):new Iu(t,e)},n.defaultCodec=new n,n})();function Pi(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n instanceof ArrayBuffer?new Uint8Array(n):Uint8Array.from(n)}function NA(n){if(n instanceof ArrayBuffer)return new DataView(n);var e=Pi(n);return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Gm(n,e){for(var t=Math.min(n.length,e.length),r=0;r<t;r++){var i=n[r]-e[r];if(i!==0)return i}return n.length-e.length}var $n=(function(){function n(e){if(this.rawBinaryValue=e,!ArrayBuffer.isView(e))throw new TypeError("RawBinaryString: rawBinaryValue must be an ArrayBufferView")}return n})(),PA=100,OA=2048,LA=(function(){function n(e){var t,r,i,o,s,a,l,c;this.extensionCodec=(t=e==null?void 0:e.extensionCodec)!==null&&t!==void 0?t:Z0.defaultCodec,this.context=e==null?void 0:e.context,this.forceBigIntToInt64=(r=e==null?void 0:e.forceBigIntToInt64)!==null&&r!==void 0?r:!1,this.maxDepth=(i=e==null?void 0:e.maxDepth)!==null&&i!==void 0?i:PA,this.initialBufferSize=(o=e==null?void 0:e.initialBufferSize)!==null&&o!==void 0?o:OA,this.sortKeys=(s=e==null?void 0:e.sortKeys)!==null&&s!==void 0?s:!1,this.forceFloat32=(a=e==null?void 0:e.forceFloat32)!==null&&a!==void 0?a:!1,this.ignoreUndefined=(l=e==null?void 0:e.ignoreUndefined)!==null&&l!==void 0?l:!1,this.forceIntegerToFloat=(c=e==null?void 0:e.forceIntegerToFloat)!==null&&c!==void 0?c:!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return n.prototype.reinitializeState=function(){this.pos=0},n.prototype.encodeSharedRef=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)},n.prototype.encode=function(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)},n.prototype.doEncode=function(e,t){if(t>this.maxDepth)throw new Error("Too deep objects in depth ".concat(t));e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.encodeObject(e,t)},n.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)},n.prototype.resizeBuffer=function(e){var t=new ArrayBuffer(e),r=new Uint8Array(t),i=new DataView(t);r.set(this.bytes),this.view=i,this.bytes=r},n.prototype.encodeNil=function(){this.writeU8(192)},n.prototype.encodeBoolean=function(e){e===!1?this.writeU8(194):this.writeU8(195)},n.prototype.encodeNumber=function(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)},n.prototype.encodeNumberAsFloat=function(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},n.prototype.encodeBigInt=function(e){if(this.forceBigIntToInt64)this.encodeBigIntAsInt64(e);else if(e>=0)if(e<4294967296||this.forceIntegerToFloat)this.encodeNumber(Number(e));else if(e<BigInt("0x10000000000000000"))this.encodeBigIntAsInt64(e);else throw new Error("Bigint is too large for uint64: ".concat(e));else if(e>=-2147483648||this.forceIntegerToFloat)this.encodeNumber(Number(e));else if(e>=BigInt(-1)*BigInt("0x8000000000000000"))this.encodeBigIntAsInt64(e);else throw new Error("Bigint is too small for int64: ".concat(e))},n.prototype.encodeBigIntAsInt64=function(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))},n.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error("Too long string: ".concat(e," bytes in UTF-8"))},n.prototype.encodeString=function(e){var t=5,r=uA(e);this.ensureBufferSizeToWrite(t+r),this.writeStringHeader(r),gA(e,this.bytes,this.pos),this.pos+=r},n.prototype.encodeObject=function(e,t){var r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(e instanceof $n)this.encodeBinaryAsString(e);else if(typeof e=="bigint")this.encodeBigInt(e);else if(e instanceof Map)this.encodeMap(e,t);else if(typeof e=="object")this.encodeMapObject(e,t);else throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)))},n.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error("Too large binary: ".concat(t));var r=Pi(e);this.writeU8a(r)},n.prototype.encodeBinaryAsString=function(e){var t=e.rawBinaryValue;this.writeStringHeader(t.byteLength);var r=Pi(t);this.writeU8a(r)},n.prototype.encodeArray=function(e,t){var r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error("Too large array: ".concat(r));for(var i=0,o=e;i<o.length;i++){var s=o[i];this.doEncode(s,t+1)}},n.prototype.countWithoutUndefined=function(e,t){for(var r=0,i=0,o=t;i<o.length;i++){var s=o[i];e.get(s)!==void 0&&r++}return r},n.prototype.sortMapKeys=function(e){for(var t=[],r=[],i=[],o=[],s=0,a=e;s<a.length;s++){var l=a[s];if(typeof l=="number"){if(isNaN(l))throw new Error("Cannot sort map keys with NaN value");t.push(l)}else if(typeof l=="bigint")t.push(l);else if(typeof l=="string")r.push(l);else if(ArrayBuffer.isView(l))o.push(Pi(l));else if(l instanceof $n)i.push(l);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(l)))}return t.sort(function(c,d){return c<d?-1:c>d?1:0}),r.sort(),i.sort(function(c,d){return Gm(Pi(c.rawBinaryValue),Pi(d.rawBinaryValue))}),o.sort(Gm),[].concat(t,r,i,o)},n.prototype.encodeMapObject=function(e,t){this.encodeMap(new Map(Object.entries(e)),t)},n.prototype.encodeMap=function(e,t){var r=Array.from(e.keys());this.sortKeys&&(r=this.sortMapKeys(r));var i=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error("Too large map object: ".concat(i));for(var o=0,s=r;o<s.length;o++){var a=s[o],l=e.get(a);if(!(this.ignoreUndefined&&l===void 0)){if(typeof a=="string")this.encodeString(a);else if(typeof a=="number")this.encodeNumber(a);else if(typeof a=="bigint")this.encodeBigInt(a);else if(ArrayBuffer.isView(a))this.encodeBinary(a);else if(a instanceof $n)this.encodeBinaryAsString(a);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(a)));this.doEncode(l,t+1)}}},n.prototype.encodeExtension=function(e){var t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error("Too large extension object: ".concat(t));this.writeI8(e.type),this.writeU8a(e.data)},n.prototype.writeU8=function(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++},n.prototype.writeU8a=function(e){var t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t},n.prototype.writeI8=function(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++},n.prototype.writeU16=function(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2},n.prototype.writeI16=function(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2},n.prototype.writeU32=function(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4},n.prototype.writeI32=function(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4},n.prototype.writeF32=function(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4},n.prototype.writeF64=function(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8},n.prototype.writeU64=function(e){this.ensureBufferSizeToWrite(8),bA(this.view,this.pos,e),this.pos+=8},n.prototype.writeI64=function(e){this.ensureBufferSizeToWrite(8),q0(this.view,this.pos,e),this.pos+=8},n.prototype.writeBigUint64=function(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8},n.prototype.writeBigInt64=function(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8},n})();function VA(n,e){var t=new LA(e);return t.encodeSharedRef(n)}function Th(n){return"".concat(n<0?"-":"","0x").concat(Math.abs(n).toString(16).padStart(2,"0"))}var $A=16,_A=16,UA=(function(){function n(e,t){e===void 0&&(e=$A),t===void 0&&(t=_A),this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(var r=0;r<this.maxKeyLength;r++)this.caches.push([])}return n.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},n.prototype.find=function(e,t,r){var i=this.caches[r-1];e:for(var o=0,s=i;o<s.length;o++){for(var a=s[o],l=a.bytes,c=0;c<r;c++)if(l[c]!==e[t+c])continue e;return a.str}return null},n.prototype.store=function(e,t){var r=this.caches[e.length-1],i={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)},n.prototype.decode=function(e,t,r){var i=this.find(e,t,r);if(i!=null)return this.hit++,i;this.miss++;var o=K0(e,t,r),s=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(s,o),o},n})(),jA=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(d){try{c(r.next(d))}catch(u){s(u)}}function l(d){try{c(r.throw(d))}catch(u){s(u)}}function c(d){d.done?o(d.value):i(d.value).then(a,l)}c((r=r.apply(n,e||[])).next())})},Mh=function(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(d){return l([c,d])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(t=0)),t;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(d){c=[6,d],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Wm=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=n[o]&&function(s){return new Promise(function(a,l){s=n[o](s),i(a,l,s.done,s.value)})}}function i(o,s,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},s)}},Zs=function(n){return this instanceof Zs?(this.v=n,this):new Zs(n)},GA=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(m){r[m]&&(i[m]=function(h){return new Promise(function(x,A){o.push([m,h,x,A])>1||a(m,h)})})}function a(m,h){try{l(r[m](h))}catch(x){u(o[0][3],x)}}function l(m){m.value instanceof Zs?Promise.resolve(m.value.v).then(c,d):u(o[0][2],m)}function c(m){a("next",m)}function d(m){a("throw",m)}function u(m,h){m(h),o.shift(),o.length&&a(o[0][0],o[0][1])}},Vf="array",Qc="map_key",J0="map_value";function WA(n,e,t){return e?typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n instanceof Uint8Array||n instanceof $n:typeof n=="string"||t&&typeof n=="number"}var zA=(function(){function n(e){this.useMap=e,this.stack=[],this.stackHeadPosition=-1}return Object.defineProperty(n.prototype,"length",{get:function(){return this.stackHeadPosition+1},enumerable:!1,configurable:!0}),n.prototype.top=function(){return this.stack[this.stackHeadPosition]},n.prototype.pushArrayState=function(e){var t=this.getUninitializedStateFromPool();t.type=Vf,t.position=0,t.size=e,t.array=new Array(e)},n.prototype.pushMapState=function(e){var t=this.getUninitializedStateFromPool();t.type=Qc,t.readCount=0,t.size=e,t.map=this.useMap?new Map:{}},n.prototype.getUninitializedStateFromPool=function(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){var e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]},n.prototype.release=function(e){var t=this.stack[this.stackHeadPosition];if(t!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Vf){var r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===Qc||e.type===J0){var r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--},n.prototype.reset=function(){this.stack.length=0,this.stackHeadPosition=-1},n})(),_c=-1,lg=new DataView(new ArrayBuffer(0)),HA=new Uint8Array(lg.buffer);try{lg.getInt8(0)}catch(n){if(!(n instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var $f=RangeError,zm=new $f("Insufficient data"),YA=new UA,KA=(function(){function n(e){var t,r,i,o,s,a,l,c,d,u,m,h;if(this.totalPos=0,this.pos=0,this.view=lg,this.bytes=HA,this.headByte=_c,this.extensionCodec=(t=e==null?void 0:e.extensionCodec)!==null&&t!==void 0?t:Z0.defaultCodec,this.context=e==null?void 0:e.context,this.intMode=(r=e==null?void 0:e.intMode)!==null&&r!==void 0?r:e!=null&&e.useBigInt64?un.AS_ENCODED:un.UNSAFE_NUMBER,this.rawBinaryStringValues=(i=e==null?void 0:e.rawBinaryStringValues)!==null&&i!==void 0?i:!1,this.rawBinaryStringKeys=(o=e==null?void 0:e.rawBinaryStringKeys)!==null&&o!==void 0?o:!1,this.useRawBinaryStringClass=(s=e==null?void 0:e.useRawBinaryStringClass)!==null&&s!==void 0?s:!1,this.useMap=(a=e==null?void 0:e.useMap)!==null&&a!==void 0?a:!1,this.supportObjectNumberKeys=(l=e==null?void 0:e.supportObjectNumberKeys)!==null&&l!==void 0?l:!1,this.maxStrLength=(c=e==null?void 0:e.maxStrLength)!==null&&c!==void 0?c:$c,this.maxBinLength=(d=e==null?void 0:e.maxBinLength)!==null&&d!==void 0?d:$c,this.maxArrayLength=(u=e==null?void 0:e.maxArrayLength)!==null&&u!==void 0?u:$c,this.maxMapLength=(m=e==null?void 0:e.maxMapLength)!==null&&m!==void 0?m:$c,this.maxExtLength=(h=e==null?void 0:e.maxExtLength)!==null&&h!==void 0?h:$c,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:YA,this.rawBinaryStringKeys&&!this.useMap)throw new Error("rawBinaryStringKeys is only supported when useMap is true");this.stack=new zA(this.useMap)}return n.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=_c,this.stack.reset()},n.prototype.setBuffer=function(e){this.bytes=Pi(e),this.view=NA(this.bytes),this.pos=0},n.prototype.appendBuffer=function(e){if(this.headByte===_c&&!this.hasRemaining(1))this.setBuffer(e);else{var t=this.bytes.subarray(this.pos),r=Pi(e),i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),this.setBuffer(i)}},n.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},n.prototype.createExtraByteError=function(e){var t=this,r=t.view,i=t.pos;return new RangeError("Extra ".concat(r.byteLength-i," of ").concat(r.byteLength," byte(s) found at buffer[").concat(e,"]"))},n.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},n.prototype.decodeMulti=function(e){return Mh(this,function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}})},n.prototype.decodeAsync=function(e){var t,r,i,o,s,a,l;return jA(this,void 0,void 0,function(){var c,d,u,m,h,x,A,v;return Mh(this,function(F){switch(F.label){case 0:c=!1,F.label=1;case 1:F.trys.push([1,6,7,12]),t=!0,r=Wm(e),F.label=2;case 2:return[4,r.next()];case 3:if(i=F.sent(),o=i.done,!!o)return[3,5];if(l=i.value,t=!1,u=l,c)throw this.createExtraByteError(this.totalPos);this.appendBuffer(u);try{d=this.doDecodeSync(),c=!0}catch(w){if(!(w instanceof $f))throw w}this.totalPos+=this.pos,F.label=4;case 4:return t=!0,[3,2];case 5:return[3,12];case 6:return m=F.sent(),s={error:m},[3,12];case 7:return F.trys.push([7,,10,11]),!t&&!o&&(a=r.return)?[4,a.call(r)]:[3,9];case 8:F.sent(),F.label=9;case 9:return[3,11];case 10:if(s)throw s.error;return[7];case 11:return[7];case 12:if(c){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,d]}throw h=this,x=h.headByte,A=h.pos,v=h.totalPos,new RangeError("Insufficient data in parsing ".concat(Th(x)," at ").concat(v," (").concat(A," in the current buffer)"))}})})},n.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},n.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},n.prototype.decodeMultiAsync=function(e,t){return GA(this,arguments,function(){var i,o,s,a,l,c,d,u,m,h,x,A;return Mh(this,function(v){switch(v.label){case 0:i=t,o=-1,v.label=1;case 1:v.trys.push([1,13,14,19]),s=!0,a=Wm(e),v.label=2;case 2:return[4,Zs(a.next())];case 3:if(l=v.sent(),m=l.done,!!m)return[3,12];if(A=l.value,s=!1,c=A,t&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(c),i&&(o=this.readArraySize(),i=!1,this.complete()),v.label=4;case 4:v.trys.push([4,9,,10]),v.label=5;case 5:return[4,Zs(this.doDecodeSync())];case 6:return[4,v.sent()];case 7:return v.sent(),--o===0?[3,8]:[3,5];case 8:return[3,10];case 9:if(d=v.sent(),!(d instanceof $f))throw d;return[3,10];case 10:this.totalPos+=this.pos,v.label=11;case 11:return s=!0,[3,2];case 12:return[3,19];case 13:return u=v.sent(),h={error:u},[3,19];case 14:return v.trys.push([14,,17,18]),!s&&!m&&(x=a.return)?[4,Zs(x.call(a))]:[3,16];case 15:v.sent(),v.label=16;case 16:return[3,18];case 17:if(h)throw h.error;return[7];case 18:return[7];case 19:return[2]}})})},n.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=this.convertNumber(e-256);else if(e<192)if(e<128)t=this.convertNumber(e);else if(e<144){var r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t=this.useMap?new Map:{}}else if(e<160){var r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{var i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.convertNumber(this.readU8());else if(e===205)t=this.convertNumber(this.readU16());else if(e===206)t=this.convertNumber(this.readU32());else if(e===207)t=this.readU64();else if(e===208)t=this.convertNumber(this.readI8());else if(e===209)t=this.convertNumber(this.readI16());else if(e===210)t=this.convertNumber(this.readI32());else if(e===211)t=this.readI64();else if(e===217){var i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){var i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){var i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){var r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){var r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){var r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){var r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){var r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){var r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){var r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){var r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){var r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){var r=this.lookU32();t=this.decodeExtension(r,4)}else throw new Nr("Unrecognized type byte: ".concat(Th(e)));this.complete();for(var o=this.stack;o.length>0;){var s=o.top();if(s.type===Vf)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,o.release(s);else continue e;else if(s.type===Qc){if(!WA(t,this.useMap,this.supportObjectNumberKeys)){var a=this.useMap?"string, number, bigint, or Uint8Array":this.supportObjectNumberKeys?"string or number":"string";throw new Nr("The type of key must be ".concat(a," but got ").concat(typeof t))}if(!this.useMap&&t==="__proto__")throw new Nr("The key __proto__ is not allowed");s.key=t,s.type=J0;continue e}else if(this.useMap?s.map.set(s.key,t):s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,o.release(s);else{s.key=null,s.type=Qc;continue e}}return t}},n.prototype.readHeadByte=function(){return this.headByte===_c&&(this.headByte=this.readU8()),this.headByte},n.prototype.complete=function(){this.headByte=_c},n.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Nr("Unrecognized array type byte: ".concat(Th(e)))}}},n.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new Nr("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.pushMapState(e)},n.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new Nr("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.pushArrayState(e)},n.prototype.decodeString=function(e,t){if(this.stateIsMapKey()?this.rawBinaryStringKeys:this.rawBinaryStringValues){var r=this.decodeBinary(e,t);return this.useRawBinaryStringClass?new $n(r):r}return this.decodeUtf8String(e,t)},n.prototype.decodeUtf8String=function(e,t){var r;if(e>this.maxStrLength)throw new Nr("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+t+e)throw zm;var i=this.pos+t,o;return this.stateIsMapKey()&&(!((r=this.keyDecoder)===null||r===void 0)&&r.canBeCached(e))?o=this.keyDecoder.decode(this.bytes,i,e):o=vA(this.bytes,i,e),this.pos+=t+e,o},n.prototype.stateIsMapKey=function(){if(this.stack.length>0){var e=this.stack.top();return e.type===Qc}return!1},n.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new Nr("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw zm;var r=this.pos+t,i=this.bytes.subarray(r,r+e);return this.pos+=t+e,i},n.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new Nr("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var r=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,r,this.context)},n.prototype.convertNumber=function(e){return AA(e,this.intMode)},n.prototype.lookU8=function(){return this.view.getUint8(this.pos)},n.prototype.lookU16=function(){return this.view.getUint16(this.pos)},n.prototype.lookU32=function(){return this.view.getUint32(this.pos)},n.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},n.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},n.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},n.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},n.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},n.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},n.prototype.readU64=function(){var e=EA(this.view,this.pos,this.intMode);return this.pos+=8,e},n.prototype.readI64=function(){var e=X0(this.view,this.pos,this.intMode);return this.pos+=8,e},n.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},n.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},n})();function ug(n,e){var t=new KA(e);return t.decode(n)}const qA="The object contains empty or 0 values. First empty or 0 value encountered during encoding: ";function XA(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&(!n[e]||n[e].length===0))return{containsEmpty:!0,firstEmptyKey:e};return{containsEmpty:!1,firstEmptyKey:void 0}}function du(n){return VA(n,{sortKeys:!0})}function ZA(n){const e=XA(n);if(e.containsEmpty)throw new Error(qA+e.firstEmptyKey);return du(n)}function Q0(n){switch(n){case an.UNSAFE:return un.UNSAFE_NUMBER;case an.SAFE:return un.SAFE_NUMBER;case an.MIXED:return un.MIXED;case an.BIGINT:return un.BIGINT;default:throw new Error(`Invalid intDecoding: ${n}`)}}function ex(n,e){const t={intMode:e!=null&&e.intDecoding?Q0(e==null?void 0:e.intDecoding):un.BIGINT};return ug(n,t)}function JA(n){return ex(n,{intDecoding:an.MIXED})}function tx(n,e){const t={intMode:e!=null&&e.intDecoding?Q0(e==null?void 0:e.intDecoding):un.BIGINT,useMap:!0};return ug(n,t)}function QA(n,e){const t={intMode:un.BIGINT,useMap:!0,rawBinaryStringKeys:!0,rawBinaryStringValues:!0,useRawBinaryStringClass:!0};return ug(n,t)}function _f(n){if(n==null)return n;if(n instanceof Uint8Array)return In(n);if(Array.isArray(n))return n.map(_f);if(n instanceof Map){const e={};for(const[t,r]of n){if(typeof t!="string")throw new Error(`JSON map key must be a string: ${t}`);e[t]=_f(r)}return e}return n}function Uf(n){if(n==null||typeof n=="string"||typeof n=="number"||typeof n=="bigint"||typeof n=="boolean")return n;if(Array.isArray(n))return n.map(Uf);if(typeof n=="object"){const e=new Map;for(const[t,r]of Object.entries(n))e.set(t,Uf(r));return e}throw new Error(`Invalid JSON encoding data: ${n}`)}var Mi;(function(n){n[n.MAP_VALUE=0]="MAP_VALUE",n[n.ARRAY_ELEMENT=1]="ARRAY_ELEMENT"})(Mi||(Mi={}));class hd{constructor({parent:e,segment:t,baseObjectBytes:r}){this.resolvedCache=null,this.resolvedCachePresent=!1,this.parent=e,this.segment=t,this.baseObjectBytes=r}withMapValue(e){return new hd({parent:this,segment:{kind:Mi.MAP_VALUE,key:e}})}withArrayElement(e){return new hd({parent:this,segment:{kind:Mi.ARRAY_ELEMENT,key:e}})}getRawStringAtCurrentLocation(){const e=this.resolve();if(e instanceof $n)return e.rawBinaryValue;throw new Error(`Invalid type. Expected RawBinaryString, got ${e} (${typeof e})`)}getRawStringKeysAndValuesAtCurrentLocation(){const e=this.resolve();if(!(e instanceof Map))throw new Error(`Invalid type. Expected Map, got ${e} (${typeof e})`);const t=new Map;for(const[r,i]of e)if(r instanceof $n)t.set(r.rawBinaryValue,i);else throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${r} (${typeof r})`);return t}resolve(){if(this.resolvedCachePresent)return this.resolvedCache;let e;if(this.parent?e=this.parent.resolve():e=QA(this.baseObjectBytes),!this.segment)return this.resolvedCache=e,this.resolvedCachePresent=!0,e;if(this.segment.kind===Mi.MAP_VALUE){if(!(e instanceof Map))throw new Error(`Invalid type. Expected Map, got ${e} (${typeof e})`);if(typeof this.segment.key=="string"||this.segment.key instanceof Uint8Array||this.segment.key instanceof $n){const t=this.segment.key instanceof $n?this.segment.key.rawBinaryValue:qr(this.segment.key),r=typeof this.segment.key=="string"||this.segment.key instanceof $n;for(const[i,o]of e){let s;if(r?i instanceof $n&&(s=i.rawBinaryValue):i instanceof Uint8Array&&(s=i),s&&Kr(t,s)){this.resolvedCache=o;break}}}else this.resolvedCache=e.get(this.segment.key);return this.resolvedCachePresent=!0,this.resolvedCache}if(this.segment.kind===Mi.ARRAY_ELEMENT){if(!Array.isArray(e))throw new Error(`Invalid type. Expected Array, got ${e} (${typeof e})`);return this.resolvedCache=e[this.segment.key],this.resolvedCachePresent=!0,this.resolvedCache}throw new Error(`Invalid segment kind: ${this.segment.kind}`)}getPathString(){const e=this.parent?this.parent.getPathString():"root";return this.segment?this.segment.kind===Mi.MAP_VALUE?`${e} -> map key "${this.segment.key}" (${typeof this.segment.key})`:this.segment.kind===Mi.ARRAY_ELEMENT?`${e} -> array index ${this.segment.key} (${typeof this.segment.key})`:`${e} -> unknown segment kind ${this.segment.kind}`:e}}class Un{}function Xt(n,e){const t=tx(n),r=new hd({baseObjectBytes:n});return e.fromEncodingData(e.encodingSchema.fromPreparedMsgpack(t,r))}function Sr(n){return du(n.getEncodingSchema().prepareMsgpack(n.toEncodingData()))}function Et(n,e){const t=_d(n,{intDecoding:an.BIGINT});return e.fromEncodingData(e.encodingSchema.fromPreparedJSON(t))}function eI(n,e){const{space:t,...r}=e??{},i=n.getEncodingSchema().prepareJSON(n.toEncodingData(),r);return yi(i,void 0,t)}class gt extends Un{defaultValue(){return!1}isDefaultValue(e){return e===!1}prepareMsgpack(e){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}fromPreparedMsgpack(e,t){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}prepareJSON(e,t){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}fromPreparedJSON(e){if(typeof e=="boolean")return e;throw new Error("Invalid boolean")}}class Ce extends Un{defaultValue(){return""}isDefaultValue(e){return e===""}prepareMsgpack(e){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}prepareJSON(e,t){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(typeof e=="string")return e;throw new Error(`Invalid string: (${typeof e}) ${e}`)}}class O extends Un{defaultValue(){return BigInt(0)}isDefaultValue(e){return typeof e=="bigint"?e===BigInt(0):typeof e=="number"?e===0:!1}prepareMsgpack(e){return Wt(e)}fromPreparedMsgpack(e,t){return Wt(e)}prepareJSON(e,t){return Wt(e)}fromPreparedJSON(e){return Wt(e)}}class _t extends Un{defaultValue(){return ze.zeroAddress()}isDefaultValue(e){return ze.zeroAddress().equals(e)}prepareMsgpack(e){if(e instanceof ze)return e.publicKey;throw new Error(`Invalid address: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){return new ze(e)}prepareJSON(e,t){if(e instanceof ze)return e.toString();throw new Error(`Invalid address: (${typeof e}) ${e}`)}fromPreparedJSON(e){return ze.fromString(e)}}class Pe extends Un{defaultValue(){return new Uint8Array}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===0}prepareMsgpack(e){if(e instanceof Uint8Array)return e;throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){if(e instanceof Uint8Array)return e;throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}prepareJSON(e,t){if(e instanceof Uint8Array)return In(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(e==null)return this.defaultValue();if(typeof e=="string")return Ge(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}}class Ht extends Un{constructor(e){super(),this.length=e}defaultValue(){return new Uint8Array(this.length)}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===this.length&&e.every(t=>t===0)}prepareMsgpack(e){if(e instanceof Uint8Array){if(e.byteLength===this.length)return e;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${e.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedMsgpack(e,t){if(e instanceof Uint8Array){if(e.byteLength===this.length)return e;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${e.byteLength}`)}throw new Error("Invalid byte array")}prepareJSON(e){if(e instanceof Uint8Array){if(e.byteLength===this.length)return In(e);throw new Error(`Invalid byte array length: wanted ${this.length}, got ${e.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedJSON(e){if(typeof e=="string"){const t=Ge(e);if(t.byteLength===this.length)return t;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid base64 byte array")}}const Uc=32,Hm=52;class tI extends Un{defaultValue(){return new Uint8Array(Uc)}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===Uc&&e.every(t=>t===0)}prepareMsgpack(e){if(e instanceof Uint8Array&&e.byteLength===Uc)return e;throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){if(e instanceof Uint8Array&&e.byteLength===Uc)return e;throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}prepareJSON(e,t){if(e instanceof Uint8Array&&e.byteLength===Uc)return`blk-${ul.encode(e).slice(0,Hm)}`;throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(typeof e=="string"&&e.length===Hm+4&&e.startsWith("blk-"))return Uint8Array.from(ul.decode.asBytes(e.slice(4)));throw new Error(`Invalid block hash: (${typeof e}) ${e}`)}}class Js extends Un{defaultValue(){return new Uint8Array}isDefaultValue(e){return e instanceof Uint8Array&&e.byteLength===0}prepareMsgpack(e){if(e instanceof Uint8Array)return new $n(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedMsgpack(e,t){return t.getRawStringAtCurrentLocation()}prepareJSON(e,t){if(e instanceof Uint8Array){const r=Wd(e);if(!t.lossyBinaryStringConversion&&!Kr(qr(r),e))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${In(e)}`);return r}throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}fromPreparedJSON(e){if(typeof e=="string")return qr(e);throw new Error(`Invalid byte array: (${typeof e}) ${e}`)}}class Me extends Un{constructor(e){super(),this.itemSchema=e}defaultValue(){return[]}isDefaultValue(e){return Array.isArray(e)&&e.length===0}prepareMsgpack(e){if(Array.isArray(e))return e.map(t=>this.itemSchema.prepareMsgpack(t));throw new Error("ArraySchema data must be an array")}fromPreparedMsgpack(e,t){if(Array.isArray(e))return e.map((r,i)=>this.itemSchema.fromPreparedMsgpack(r,t.withArrayElement(i)));throw new Error(`ArraySchema encoded data must be an array: ${e} (${typeof e})`)}prepareJSON(e,t){if(Array.isArray(e))return e.map(r=>this.itemSchema.prepareJSON(r,t));throw new Error("ArraySchema data must be an array")}fromPreparedJSON(e){if(Array.isArray(e))return e.map(t=>this.itemSchema.fromPreparedJSON(t));throw new Error(`ArraySchema encoded data must be an array: ${e} (${typeof e})`)}}function rt(n){return n.map(e=>({...e,omitEmpty:!0}))}class oe extends Un{constructor(e){super(),this.entries=e,this.checkEntries()}pushEntries(...e){this.entries.push(...e),this.checkEntries()}checkEntries(){for(const t of this.entries)if(t.embedded){if(t.key!=="")throw new Error("Embedded entries must have an empty key");if(!(t.valueSchema instanceof oe))throw new Error("Embedded entry valueSchema must be a NamedMapSchema")}const e=new Set;for(const t of this.getEntries()){if(e.has(t.key))throw new Error(`Duplicate key: ${t.key}`);e.add(t.key)}}getEntries(){const e=[];for(const t of this.entries)if(t.embedded){const r=t.valueSchema;e.push(...r.getEntries())}else e.push(t);return e}defaultValue(){const e=new Map;for(const t of this.getEntries())e.set(t.key,t.valueSchema.defaultValue());return e}isDefaultValue(e){if(!(e instanceof Map))return!1;for(const t of this.getEntries())if(!t.valueSchema.isDefaultValue(e.get(t.key)))return!1;return!0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`NamedMapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const r of this.getEntries()){const i=e.get(r.key);r.omitEmpty&&r.valueSchema.isDefaultValue(i)||t.set(r.key,r.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){if(!(e instanceof Map))throw new Error("NamedMapSchema data must be a Map");const r=new Map;for(const i of this.getEntries())if(e.has(i.key))r.set(i.key,i.valueSchema.fromPreparedMsgpack(e.get(i.key),t.withMapValue(i.key)));else if(i.omitEmpty)r.set(i.key,i.valueSchema.defaultValue());else throw new Error(`Missing key: ${i.key}`);return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error("NamedMapSchema data must be a Map");const r={};for(const i of this.getEntries()){const o=e.get(i.key);i.omitEmpty&&i.valueSchema.isDefaultValue(o)||(r[i.key]=i.valueSchema.prepareJSON(o,t))}return r}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("NamedMapSchema data must be an object");const t=new Map;for(const r of this.getEntries())if(Object.prototype.hasOwnProperty.call(e,r.key))t.set(r.key,r.valueSchema.fromPreparedJSON(e[r.key]));else if(r.omitEmpty)t.set(r.key,r.valueSchema.defaultValue());else throw new Error(`Missing key: ${r.key}`);return t}}function Dc(...n){const e=new Map;for(const t of n)for(const[r,i]of t){if(e.has(r))throw new Error(`Duplicate key: ${r}`);e.set(r,i)}return e}function dn(n,e){const t=new Map;for(const[r,i]of n){const[o,s]=e(r,i);t.set(o,s)}return t}class Hd extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){return new Map}isDefaultValue(e){return e instanceof Map&&e.size===0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const[r,i]of e){const o=Wt(r);if(t.has(o))throw new Error(`Duplicate key: ${o}`);t.set(o,this.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){if(!(e instanceof Map))throw new Error("Uint64MapSchema data must be a Map");const r=new Map;for(const[i,o]of e){const s=Wt(i);if(r.has(s))throw new Error(`Duplicate key: ${s}`);r.set(s,this.valueSchema.fromPreparedMsgpack(o,t.withMapValue(i)))}return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof e}) ${e}`);const r=new Map;for(const[o,s]of e){const a=Wt(o);if(r.has(a))throw new Error(`Duplicate key: ${a}`);r.set(a,this.valueSchema.prepareJSON(s,t))}const i={};for(const[o,s]of r)i[o.toString()]=s;return i}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("Uint64MapSchema data must be an object");const t=new Map;for(const[r,i]of Object.entries(e)){const o=BigInt(r);if(t.has(o))throw new Error(`Duplicate key: ${o}`);t.set(o,this.valueSchema.fromPreparedJSON(i))}return t}}class nI extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){return new Map}isDefaultValue(e){return e instanceof Map&&e.size===0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const[r,i]of e){if(!(r instanceof Uint8Array))throw new Error(`Invalid key: ${r} (${typeof r})`);t.set(r,this.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){if(!(e instanceof Map))throw new Error("ByteArrayMapSchema data must be a Map");const r=new Map;for(const[i,o]of e){if(!(i instanceof Uint8Array))throw new Error(`Invalid key: ${i} (${typeof i})`);r.set(i,this.valueSchema.fromPreparedMsgpack(o,t.withMapValue(i)))}return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof e}) ${e}`);const r=new Map;for(const[o,s]of e){if(!(o instanceof Uint8Array))throw new Error(`Invalid key: ${o} (${typeof o})`);const a=In(o);if(r.has(a))throw new Error(`Duplicate key (base64): ${a}`);r.set(a,this.valueSchema.prepareJSON(s,t))}const i={};for(const[o,s]of r)i[o]=s;return i}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("ByteArrayMapSchema data must be an object");const t=new Map;for(const[r,i]of Object.entries(e))t.set(Ge(r),this.valueSchema.fromPreparedJSON(i));return t}}function ju(n){if(n instanceof $n)return Wd(n.rawBinaryValue);if(n instanceof Map){const e=new Map;for(const[t,r]of n)e.set(ju(t),ju(r));return e}return Array.isArray(n)?n.map(ju):n}class dl extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){return new Map}isDefaultValue(e){return e instanceof Map&&e.size===0}prepareMsgpack(e){if(!(e instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof e}) ${e}`);const t=new Map;for(const[r,i]of e){if(!(r instanceof Uint8Array))throw new Error(`Invalid key: ${r} (${typeof r})`);t.set(new $n(r),this.valueSchema.prepareMsgpack(i))}return t}fromPreparedMsgpack(e,t){const r=new Map,i=t.getRawStringKeysAndValuesAtCurrentLocation();for(const[o,s]of i)r.set(o,this.valueSchema.fromPreparedMsgpack(ju(s),t.withMapValue(new $n(o))));return r}prepareJSON(e,t){if(!(e instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof e}) ${e}`);const r=new Map;for(const[o,s]of e){if(!(o instanceof Uint8Array))throw new Error(`Invalid key: ${o}`);const a=Wd(o);if(!t.lossyBinaryStringConversion&&!Kr(qr(a),o))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${In(o)}`);r.set(a,this.valueSchema.prepareJSON(s,t))}const i={};for(const[o,s]of r)i[o]=s;return i}fromPreparedJSON(e){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error("SpecialCaseBinaryStringMapSchema data must be an object");const t=new Map;for(const[r,i]of Object.entries(e))t.set(qr(r),this.valueSchema.fromPreparedJSON(i));return t}}class k extends Un{constructor(e){super(),this.valueSchema=e}defaultValue(){}isDefaultValue(e){return e===void 0||this.valueSchema.isDefaultValue(e)}prepareMsgpack(e){if(e!==void 0)return this.valueSchema.prepareMsgpack(e)}fromPreparedMsgpack(e,t){if(e!=null)return this.valueSchema.fromPreparedMsgpack(e,t)}prepareJSON(e,t){return e===void 0?null:this.valueSchema.prepareJSON(e,t)}fromPreparedJSON(e){if(e!=null)return this.valueSchema.fromPreparedJSON(e)}}class nx extends Un{defaultValue(){}isDefaultValue(e){return e===void 0}prepareMsgpack(e){return e}fromPreparedMsgpack(e,t){return e}prepareJSON(e,t){return _f(e)}fromPreparedJSON(e){return Uf(e)}}function rI(n,e,t){const r=BigInt(n.appIndex),i=n.name,o=r===BigInt(0)||r===t,s=e.indexOf(r)+1;if(s===0&&!o)throw new Error(`Box ref with appId ${r} not in foreign-apps`);return new Map([["i",s],["n",i]])}function iI(n,e,t){const r=BigInt(t),i=e.map(BigInt);return n.map(o=>rI(o,i,r))}function oI(n,e){const t=[];function r(o){for(let s=0;s<t.length;s++){const a=t[s],l=a.get("d");if((!o.address&&!l||o.address&&l&&o.address.equals(l))&&a.get("s")===o.assetIndex&&a.get("p")===o.appIndex)return s+1}return o.address&&t.push(new Map([["d",o.address]])),o.assetIndex&&t.push(new Map([["s",o.assetIndex]])),o.appIndex&&t.push(new Map([["p",o.appIndex]])),t.length}const i=ze.zeroAddress();for(const o of e){if(o.address||o.assetIndex||o.appIndex){r(o);continue}if(o.holding){const s=o.holding;let a=0;s.address&&!s.address.equals(i)&&(a=r({address:s.address}));const l=r({assetIndex:s.assetIndex});t.push(new Map([["h",new Map([["d",a],["s",l]])]]));continue}if(o.locals){const s=o.locals;let a=0;s.address&&!s.address.equals(i)&&(a=r({address:s.address}));let l=0;s.appIndex&&BigInt(s.appIndex)!==n&&(l=r({appIndex:s.appIndex})),t.push(new Map([["l",new Map([["d",a],["p",l]])]]));continue}if(o.box){const s=o.box;let a=0;s.appIndex&&BigInt(s.appIndex)!==n&&(a=r({appIndex:s.appIndex})),t.push(new Map([["b",new Map([["i",a],["n",s.name]])]]))}}return t}function sI(n){const e=[];for(const t of n){const r=t.get("d"),i=t.get("s"),o=t.get("p");if(r){e.push({address:r});continue}if(i){e.push({assetIndex:i});continue}if(o){e.push({appIndex:o});continue}const s=t.get("h");if(s){const c=An(s.get("d")??0),d=An(s.get("s"));if(!d)throw new Error(`Holding missing asset index: ${s}`);const u=c===0?ze.zeroAddress():e[c-1].address,m=e[d-1].assetIndex;e.push({holding:{address:u,assetIndex:m}});continue}const a=t.get("l");if(a){const c=An(a.get("d")??0),d=An(a.get("p")??0),u=c===0?ze.zeroAddress():e[c-1].address,m=d===0?BigInt(0):e[d-1].appIndex;e.push({locals:{address:u,appIndex:m}});continue}const l=t.get("b");if(l){const c=An(l.get("i")??0),d=l.get("n");if(!d)throw new Error(`Box missing name: ${l}`);const u=c===0?BigInt(0):e[c-1].appIndex;e.push({box:{appIndex:u,name:d}})}}return e}function aI({appIndex:n,accounts:e,foreignAssets:t,foreignApps:r,holdings:i,locals:o,boxes:s}){const a=[];function l(u){let m;if(typeof u=="string"){if(u==="")return;m=ze.fromString(u)}else m=u;if(m.equals(ze.zeroAddress()))return;let h=!1;for(const x of a){if(!x.address)continue;let A=x.address;if(typeof x.address=="string"&&(A=ze.fromString(x.address)),A.equals(m)){h=!0;break}}h||a.push({address:u})}function c(u){let m=!1;for(const h of a)if(h.assetIndex===u){m=!0;break}m||a.push({assetIndex:u})}function d(u){let m=!1;for(const h of a)if(h.appIndex===u){m=!0;break}m||a.push({appIndex:u})}for(const u of e??[])l(u);for(const u of t??[])c(u);for(const u of r??[])d(u);for(const u of i??[])u.address&&l(u.address),c(u.assetIndex),a.push({holding:u});for(const u of o??[])u.address&&l(u.address),u.appIndex&&BigInt(u.appIndex)!==n&&d(u.appIndex),a.push({locals:u});for(const u of s??[])u.appIndex&&BigInt(u.appIndex)!==n&&d(u.appIndex),a.push({box:u});return a}var Bt;(function(n){n.pay="pay",n.keyreg="keyreg",n.acfg="acfg",n.axfer="axfer",n.afrz="afrz",n.appl="appl",n.stpf="stpf",n.hb="hb"})(Bt||(Bt={}));function jf(n){return n===Bt.pay||n===Bt.keyreg||n===Bt.acfg||n===Bt.axfer||n===Bt.afrz||n===Bt.appl||n===Bt.stpf||n===Bt.hb}var kn;(function(n){n[n.NoOpOC=0]="NoOpOC",n[n.OptInOC=1]="OptInOC",n[n.CloseOutOC=2]="CloseOutOC",n[n.ClearStateOC=3]="ClearStateOC",n[n.UpdateApplicationOC=4]="UpdateApplicationOC",n[n.DeleteApplicationOC=5]="DeleteApplicationOC"})(kn||(kn={}));function rx(n){return n===kn.NoOpOC||n===kn.OptInOC||n===kn.CloseOutOC||n===kn.ClearStateOC||n===kn.UpdateApplicationOC||n===kn.DeleteApplicationOC}let Yd=class Gf{constructor(e){this.hashType=e.hashType}getEncodingSchema(){return Gf.encodingSchema}toEncodingData(){return new Map([["t",this.hashType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HashFactory: ${e}`);return new Gf({hashType:Number(e.get("t"))})}};Yd.encodingSchema=new oe(rt([{key:"t",valueSchema:new O}]));let to=class Wf{constructor(e){this.path=e.path,this.hashFactory=e.hashFactory,this.treeDepth=e.treeDepth}getEncodingSchema(){return Wf.encodingSchema}toEncodingData(){return new Map([["pth",this.path],["hsh",this.hashFactory.toEncodingData()],["td",this.treeDepth]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MerkleArrayProof: ${e}`);return new Wf({path:e.get("pth"),hashFactory:Yd.fromEncodingData(e.get("hsh")),treeDepth:Number(e.get("td"))})}};to.encodingSchema=new oe(rt([{key:"pth",valueSchema:new Me(new Pe)},{key:"hsh",valueSchema:Yd.encodingSchema},{key:"td",valueSchema:new O}]));class Xo{constructor(e){this.commitment=e.commitment,this.keyLifetime=e.keyLifetime}getEncodingSchema(){return Xo.encodingSchema}toEncodingData(){return new Map([["cmt",this.commitment],["lf",this.keyLifetime]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MerkleSignatureVerifier: ${e}`);return new Xo({commitment:e.get("cmt"),keyLifetime:e.get("lf")})}}Xo.encodingSchema=new oe(rt([{key:"cmt",valueSchema:new Ht(64)},{key:"lf",valueSchema:new O}]));class Zo{constructor(e){this.pk=e.pk,this.weight=e.weight}getEncodingSchema(){return Zo.encodingSchema}toEncodingData(){return new Map([["p",this.pk.toEncodingData()],["w",this.weight]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Participant: ${e}`);return new Zo({pk:Xo.fromEncodingData(e.get("p")),weight:e.get("w")})}}Zo.encodingSchema=new oe(rt([{key:"p",valueSchema:Xo.encodingSchema},{key:"w",valueSchema:new O}]));class Jo{constructor(e){this.publicKey=e.publicKey}getEncodingSchema(){return Jo.encodingSchema}toEncodingData(){return new Map([["k",this.publicKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded FalconVerifier: ${e}`);return new Jo({publicKey:e.get("k")})}}Jo.encodingSchema=new oe(rt([{key:"k",valueSchema:new Ht(1793)}]));class Qo{constructor(e){this.signature=e.signature,this.vectorCommitmentIndex=e.index,this.proof=e.proof,this.verifyingKey=e.verifyingKey}getEncodingSchema(){return Qo.encodingSchema}toEncodingData(){return new Map([["sig",this.signature],["idx",this.vectorCommitmentIndex],["prf",this.proof.toEncodingData()],["vkey",this.verifyingKey.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded FalconSignatureStruct: ${e}`);return new Qo({signature:e.get("sig"),index:e.get("idx"),proof:to.fromEncodingData(e.get("prf")),verifyingKey:Jo.fromEncodingData(e.get("vkey"))})}}Qo.encodingSchema=new oe(rt([{key:"sig",valueSchema:new Pe},{key:"idx",valueSchema:new O},{key:"prf",valueSchema:to.encodingSchema},{key:"vkey",valueSchema:Jo.encodingSchema}]));class es{constructor(e){this.sig=e.sig,this.l=e.l}getEncodingSchema(){return es.encodingSchema}toEncodingData(){return new Map([["s",this.sig.toEncodingData()],["l",this.l]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SigslotCommit: ${e}`);return new es({sig:Qo.fromEncodingData(e.get("s")),l:e.get("l")})}}es.encodingSchema=new oe(rt([{key:"s",valueSchema:Qo.encodingSchema},{key:"l",valueSchema:new O}]));class ts{constructor(e){this.sigslot=e.sigslot,this.participant=e.participant}getEncodingSchema(){return ts.encodingSchema}toEncodingData(){return new Map([["s",this.sigslot.toEncodingData()],["p",this.participant.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Reveal: ${e}`);return new ts({sigslot:es.fromEncodingData(e.get("s")),participant:Zo.fromEncodingData(e.get("p"))})}}ts.encodingSchema=new oe(rt([{key:"s",valueSchema:es.encodingSchema},{key:"p",valueSchema:Zo.encodingSchema}]));let Kd=class zf{constructor(e){this.sigCommit=e.sigCommit,this.signedWeight=e.signedWeight,this.sigProofs=e.sigProofs,this.partProofs=e.partProofs,this.merkleSignatureSaltVersion=e.merkleSignatureSaltVersion,this.reveals=e.reveals,this.positionsToReveal=e.positionsToReveal}getEncodingSchema(){return zf.encodingSchema}toEncodingData(){return new Map([["c",this.sigCommit],["w",this.signedWeight],["S",this.sigProofs.toEncodingData()],["P",this.partProofs.toEncodingData()],["v",this.merkleSignatureSaltVersion],["r",dn(this.reveals,(e,t)=>[e,t.toEncodingData()])],["pr",this.positionsToReveal]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProof: ${e}`);return new zf({sigCommit:e.get("c"),signedWeight:e.get("w"),sigProofs:to.fromEncodingData(e.get("S")),partProofs:to.fromEncodingData(e.get("P")),merkleSignatureSaltVersion:Number(e.get("v")),reveals:dn(e.get("r"),(t,r)=>[t,ts.fromEncodingData(r)]),positionsToReveal:e.get("pr")})}};Kd.encodingSchema=new oe(rt([{key:"c",valueSchema:new Pe},{key:"w",valueSchema:new O},{key:"S",valueSchema:to.encodingSchema},{key:"P",valueSchema:to.encodingSchema},{key:"v",valueSchema:new O},{key:"r",valueSchema:new Hd(ts.encodingSchema)},{key:"pr",valueSchema:new Me(new O)}]));let qd=class Gu{constructor(e){this.blockHeadersCommitment=e.blockHeadersCommitment,this.votersCommitment=e.votersCommitment,this.lnProvenWeight=e.lnProvenWeight,this.firstAttestedRound=e.firstAttestedRound,this.lastAttestedRound=e.lastAttestedRound}getEncodingSchema(){return Gu.encodingSchema}toEncodingData(){return new Map([["b",this.blockHeadersCommitment],["v",this.votersCommitment],["P",this.lnProvenWeight],["f",this.firstAttestedRound],["l",this.lastAttestedRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofMessage: ${e}`);return new Gu({blockHeadersCommitment:e.get("b"),votersCommitment:e.get("v"),lnProvenWeight:e.get("P"),firstAttestedRound:e.get("f"),lastAttestedRound:e.get("l")})}static fromMap(e){return new Gu({blockHeadersCommitment:e.get("b"),votersCommitment:e.get("v"),lnProvenWeight:e.get("P"),firstAttestedRound:e.get("f"),lastAttestedRound:e.get("l")})}};qd.encodingSchema=new oe(rt([{key:"b",valueSchema:new Pe},{key:"v",valueSchema:new Pe},{key:"P",valueSchema:new O},{key:"f",valueSchema:new O},{key:"l",valueSchema:new O}]));class ya{constructor(e){this.sig=e.sig,this.pk=e.pk,this.pk2=e.pk2,this.pk1Sig=e.pk1Sig,this.pk2Sig=e.pk2Sig}getEncodingSchema(){return ya.encodingSchema}toEncodingData(){return new Map([["s",this.sig],["p",this.pk],["p2",this.pk2],["p1s",this.pk1Sig],["p2s",this.pk2Sig]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HeartbeatProof: ${e}`);return new ya({sig:e.get("s"),pk:e.get("p"),pk2:e.get("p2"),pk1Sig:e.get("p1s"),pk2Sig:e.get("p2s")})}}ya.encodingSchema=new oe(rt([{key:"s",valueSchema:new Ht(64)},{key:"p",valueSchema:new Ht(32)},{key:"p2",valueSchema:new Ht(32)},{key:"p1s",valueSchema:new Ht(64)},{key:"p2s",valueSchema:new Ht(64)}]));class Ji{constructor(e){this.address=e.address,this.proof=e.proof,this.seed=e.seed,this.voteID=e.voteID,this.keyDilution=e.keyDilution}getEncodingSchema(){return Ji.encodingSchema}toEncodingData(){return new Map([["a",this.address],["prf",this.proof.toEncodingData()],["sd",this.seed],["vid",this.voteID],["kd",this.keyDilution]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Heartbeat: ${e}`);return new Ji({address:e.get("a"),proof:ya.fromEncodingData(e.get("prf")),seed:e.get("sd"),voteID:e.get("vid"),keyDilution:e.get("kd")})}}Ji.encodingSchema=new oe(rt([{key:"a",valueSchema:new _t},{key:"prf",valueSchema:ya.encodingSchema},{key:"sd",valueSchema:new Pe},{key:"vid",valueSchema:new Ht(32)},{key:"kd",valueSchema:new O}]));const cI=52,lI=32,uI=75,dI=32,hI=32,fI=32,pI=64,gI=32;function ix(n){return n.every(e=>e===0)}function Rh(n,e,t){if(n==null)return;let r;if(n instanceof Uint8Array&&(r=n),r==null||r.byteLength!==t)throw Error(`${e} must be a ${t} byte Uint8Array`);return r}function ai(n){if(n==null)throw new Error("Address must not be null or undefined");if(typeof n=="string")return ze.fromString(n);if(n instanceof ze)return n;throw new Error(`Not an address: ${n}`)}function Ci(n){if(n==null)return;let e;if(n instanceof ze)e=n;else if(typeof n=="string")e=ze.fromString(n);else throw new Error(`Not an address: ${n}`);if(ix(e.publicKey))throw new Error("Invalid use of the zero address. To omit this value, pass in undefined");return e}function ox(n){if(!(typeof n>"u")){if(n instanceof Uint8Array)return n;throw new Error(`Not a Uint8Array: ${n}`)}}function Co(n){if(n instanceof Uint8Array)return n;throw new Error(`Not a Uint8Array: ${n}`)}function Bh(n){if(!(typeof n>"u"))return Wt(n)}function ku(n){if(n===!0||n===!1)return n;throw new Error(`Not a boolean: ${n}`)}function Us(n){if(Array.isArray(n))return n.slice();throw new Error(`Not an array: ${n}`)}function Ym(n,e,t){const r=ox(n);if(!(typeof r>"u")){if(r.byteLength!==e)throw new Error(`${t} must be ${e} bytes long, was ${r.byteLength}`);if(!ix(r))return r}}function sx(n){if(n!=null&&typeof n=="object"){const{appIndex:e,name:t}=n;return{appIndex:Wt(e),name:Co(t)}}throw new Error(`Not a box reference: ${n}`)}function mI(n){if(n!=null&&typeof n=="object"){const{assetIndex:e,address:t}=n;return{assetIndex:Wt(e),address:ai(t)}}throw new Error(`Not a holding reference: ${n}`)}function yI(n){if(n!=null&&typeof n=="object"){const{appIndex:e,address:t}=n;return{appIndex:Wt(e),address:ai(t)}}throw new Error(`Not a locals reference: ${n}`)}function wI(n){if(n!=null&&typeof n=="object"){const{address:e,appIndex:t,assetIndex:r,holding:i,locals:o,box:s}=n;if(e!==void 0)return{address:ai(e)};if(t!==void 0)return{appIndex:Wt(t)};if(r!==void 0)return{assetIndex:Wt(r)};if(i!==void 0)return{holding:mI(i)};if(o!==void 0)return{locals:yI(o)};if(s!==void 0)return{box:sx(s)}}throw new Error(`Not a resource reference: ${n}`)}const Km=new TextEncoder().encode("TX");let br=class Wu{constructor(e){if(!jf(e.type))throw new Error(`Invalid transaction type: ${e.type}`);if(this.type=e.type,this.sender=ai(e.sender),this.note=Co(e.note??new Uint8Array),this.lease=Ym(e.lease,lI,"lease"),this.rekeyTo=Ci(e.rekeyTo),this.group=void 0,this.firstValid=Wt(e.suggestedParams.firstValid),this.lastValid=Wt(e.suggestedParams.lastValid),e.suggestedParams.genesisID){if(typeof e.suggestedParams.genesisID!="string")throw new Error("Genesis ID must be a string if present");this.genesisID=e.suggestedParams.genesisID}this.genesisHash=ox(e.suggestedParams.genesisHash);const t=[];if(e.paymentParams&&t.push(Bt.pay),e.keyregParams&&t.push(Bt.keyreg),e.assetConfigParams&&t.push(Bt.acfg),e.assetTransferParams&&t.push(Bt.axfer),e.assetFreezeParams&&t.push(Bt.afrz),e.appCallParams&&t.push(Bt.appl),e.stateProofParams&&t.push(Bt.stpf),e.heartbeatParams&&t.push(Bt.hb),t.length!==1)throw new Error(`Transaction has wrong number of type fields present (${t.length}): ${t}`);if(this.type!==t[0])throw new Error(`Transaction has type ${this.type} but fields present for ${t[0]}`);if(e.paymentParams&&(this.payment={receiver:ai(e.paymentParams.receiver),amount:Wt(e.paymentParams.amount),closeRemainderTo:Ci(e.paymentParams.closeRemainderTo)}),e.keyregParams){if(this.keyreg={voteKey:Rh(e.keyregParams.voteKey,"voteKey",hI),selectionKey:Rh(e.keyregParams.selectionKey,"selectionKey",fI),stateProofKey:Rh(e.keyregParams.stateProofKey,"stateProofKey",pI),voteFirst:Bh(e.keyregParams.voteFirst),voteLast:Bh(e.keyregParams.voteLast),voteKeyDilution:Bh(e.keyregParams.voteKeyDilution),nonParticipation:ku(e.keyregParams.nonParticipation??!1)},this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u"))throw new Error("nonParticipation is true but participation params are present.");if(!this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u")&&!(this.keyreg.voteKey&&this.keyreg.selectionKey&&typeof this.keyreg.voteFirst<"u"&&typeof this.keyreg.voteLast<"u"&&typeof this.keyreg.voteKeyDilution<"u"))throw new Error("Online key registration missing at least one of the following fields: voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution")}if(e.assetConfigParams&&(this.assetConfig={assetIndex:Wt(e.assetConfigParams.assetIndex??0),total:Wt(e.assetConfigParams.total??0),decimals:An(e.assetConfigParams.decimals??0),defaultFrozen:ku(e.assetConfigParams.defaultFrozen??!1),manager:Ci(e.assetConfigParams.manager),reserve:Ci(e.assetConfigParams.reserve),freeze:Ci(e.assetConfigParams.freeze),clawback:Ci(e.assetConfigParams.clawback),unitName:e.assetConfigParams.unitName,assetName:e.assetConfigParams.assetName,assetURL:e.assetConfigParams.assetURL,assetMetadataHash:Ym(e.assetConfigParams.assetMetadataHash,dI,"assetMetadataHash")}),e.assetTransferParams&&(this.assetTransfer={assetIndex:Wt(e.assetTransferParams.assetIndex),amount:Wt(e.assetTransferParams.amount),assetSender:Ci(e.assetTransferParams.assetSender),receiver:ai(e.assetTransferParams.receiver),closeRemainderTo:Ci(e.assetTransferParams.closeRemainderTo)}),e.assetFreezeParams&&(this.assetFreeze={assetIndex:Wt(e.assetFreezeParams.assetIndex),freezeAccount:ai(e.assetFreezeParams.freezeTarget),frozen:ku(e.assetFreezeParams.frozen)}),e.appCallParams){const{onComplete:i}=e.appCallParams;if(!rx(i))throw new Error(`Invalid onCompletion value: ${i}`);this.applicationCall={appIndex:Wt(e.appCallParams.appIndex),onComplete:i,numLocalInts:An(e.appCallParams.numLocalInts??0),numLocalByteSlices:An(e.appCallParams.numLocalByteSlices??0),numGlobalInts:An(e.appCallParams.numGlobalInts??0),numGlobalByteSlices:An(e.appCallParams.numGlobalByteSlices??0),extraPages:An(e.appCallParams.extraPages??0),approvalProgram:Co(e.appCallParams.approvalProgram??new Uint8Array),clearProgram:Co(e.appCallParams.clearProgram??new Uint8Array),appArgs:Us(e.appCallParams.appArgs??[]).map(Co),accounts:Us(e.appCallParams.accounts??[]).map(ai),foreignApps:Us(e.appCallParams.foreignApps??[]).map(Wt),foreignAssets:Us(e.appCallParams.foreignAssets??[]).map(Wt),boxes:Us(e.appCallParams.boxes??[]).map(sx),access:Us(e.appCallParams.access??[]).map(wI),rejectVersion:An(e.appCallParams.rejectVersion??0)}}if(e.stateProofParams&&(this.stateProof={stateProofType:An(e.stateProofParams.stateProofType??0),stateProof:e.stateProofParams.stateProof,message:e.stateProofParams.message}),e.heartbeatParams&&(this.heartbeat=new Ji({address:e.heartbeatParams.address,proof:e.heartbeatParams.proof,seed:e.heartbeatParams.seed,voteID:e.heartbeatParams.voteID,keyDilution:e.heartbeatParams.keyDilution})),this.fee=Wt(e.suggestedParams.fee),!ku(e.suggestedParams.flatFee??!1)){const i=Wt(e.suggestedParams.minFee);this.fee*=BigInt(this.estimateSize()),this.fee<i&&(this.fee=i)}}getEncodingSchema(){return Wu.encodingSchema}toEncodingData(){const e=new Map([["type",this.type],["fv",this.firstValid],["lv",this.lastValid],["snd",this.sender],["gen",this.genesisID],["gh",this.genesisHash],["fee",this.fee],["note",this.note],["lx",this.lease],["rekey",this.rekeyTo],["grp",this.group]]);if(this.payment)return e.set("amt",this.payment.amount),e.set("rcv",this.payment.receiver),e.set("close",this.payment.closeRemainderTo),e;if(this.keyreg)return e.set("votekey",this.keyreg.voteKey),e.set("selkey",this.keyreg.selectionKey),e.set("sprfkey",this.keyreg.stateProofKey),e.set("votefst",this.keyreg.voteFirst),e.set("votelst",this.keyreg.voteLast),e.set("votekd",this.keyreg.voteKeyDilution),e.set("nonpart",this.keyreg.nonParticipation),e;if(this.assetConfig){e.set("caid",this.assetConfig.assetIndex);const t=new Map([["t",this.assetConfig.total],["dc",this.assetConfig.decimals],["df",this.assetConfig.defaultFrozen],["m",this.assetConfig.manager],["r",this.assetConfig.reserve],["f",this.assetConfig.freeze],["c",this.assetConfig.clawback],["un",this.assetConfig.unitName],["an",this.assetConfig.assetName],["au",this.assetConfig.assetURL],["am",this.assetConfig.assetMetadataHash]]);return e.set("apar",t),e}if(this.assetTransfer)return e.set("xaid",this.assetTransfer.assetIndex),e.set("aamt",this.assetTransfer.amount),e.set("arcv",this.assetTransfer.receiver),e.set("aclose",this.assetTransfer.closeRemainderTo),e.set("asnd",this.assetTransfer.assetSender),e;if(this.assetFreeze)return e.set("faid",this.assetFreeze.assetIndex),e.set("afrz",this.assetFreeze.frozen),e.set("fadd",this.assetFreeze.freezeAccount),e;if(this.applicationCall)return e.set("apid",this.applicationCall.appIndex),e.set("apan",this.applicationCall.onComplete),e.set("apaa",this.applicationCall.appArgs),e.set("apat",this.applicationCall.accounts),e.set("apas",this.applicationCall.foreignAssets),e.set("apfa",this.applicationCall.foreignApps),e.set("apbx",iI(this.applicationCall.boxes,this.applicationCall.foreignApps,this.applicationCall.appIndex)),e.set("al",oI(this.applicationCall.appIndex,this.applicationCall.access)),e.set("apap",this.applicationCall.approvalProgram),e.set("apsu",this.applicationCall.clearProgram),e.set("apls",new Map([["nui",this.applicationCall.numLocalInts],["nbs",this.applicationCall.numLocalByteSlices]])),e.set("apgs",new Map([["nui",this.applicationCall.numGlobalInts],["nbs",this.applicationCall.numGlobalByteSlices]])),e.set("apep",this.applicationCall.extraPages),e.set("aprv",this.applicationCall.rejectVersion),e;if(this.stateProof)return e.set("sptype",this.stateProof.stateProofType),e.set("sp",this.stateProof.stateProof?this.stateProof.stateProof.toEncodingData():void 0),e.set("spmsg",this.stateProof.message?this.stateProof.message.toEncodingData():void 0),e;if(this.heartbeat){const t=new Ji({address:this.heartbeat.address,proof:this.heartbeat.proof,seed:this.heartbeat.seed,voteID:this.heartbeat.voteID,keyDilution:this.heartbeat.keyDilution});return e.set("hb",t.toEncodingData()),e}throw new Error(`Unexpected transaction type: ${this.type}`)}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded logic sig account: ${e}`);const t={minFee:BigInt(0),flatFee:!0,fee:e.get("fee")??0,firstValid:e.get("fv")??0,lastValid:e.get("lv")??0,genesisHash:e.get("gh"),genesisID:e.get("gen")},r=e.get("type");if(!jf(r))throw new Error(`Unrecognized transaction type: ${r}`);const i={type:r,sender:e.get("snd")??ze.zeroAddress(),note:e.get("note"),lease:e.get("lx"),suggestedParams:t};if(e.get("rekey")&&(i.rekeyTo=e.get("rekey")),i.type===Bt.pay){const s={amount:e.get("amt")??0,receiver:e.get("rcv")??ze.zeroAddress()};e.get("close")&&(s.closeRemainderTo=e.get("close")),i.paymentParams=s}else if(i.type===Bt.keyreg){const s={voteKey:e.get("votekey"),selectionKey:e.get("selkey"),stateProofKey:e.get("sprfkey"),voteFirst:e.get("votefst"),voteLast:e.get("votelst"),voteKeyDilution:e.get("votekd"),nonParticipation:e.get("nonpart")};i.keyregParams=s}else if(i.type===Bt.acfg){const s={assetIndex:e.get("caid")};if(e.get("apar")){const a=e.get("apar");s.total=a.get("t"),s.decimals=a.get("dc"),s.defaultFrozen=a.get("df"),s.unitName=a.get("un"),s.assetName=a.get("an"),s.assetURL=a.get("au"),s.assetMetadataHash=a.get("am"),a.get("m")&&(s.manager=a.get("m")),a.get("r")&&(s.reserve=a.get("r")),a.get("f")&&(s.freeze=a.get("f")),a.get("c")&&(s.clawback=a.get("c"))}i.assetConfigParams=s}else if(i.type===Bt.axfer){const s={assetIndex:e.get("xaid")??0,amount:e.get("aamt")??0,receiver:e.get("arcv")??ze.zeroAddress()};e.get("aclose")&&(s.closeRemainderTo=e.get("aclose")),e.get("asnd")&&(s.assetSender=e.get("asnd")),i.assetTransferParams=s}else if(i.type===Bt.afrz){const s={assetIndex:e.get("faid")??0,freezeTarget:e.get("fadd")??ze.zeroAddress(),frozen:e.get("afrz")??!1};i.assetFreezeParams=s}else if(i.type===Bt.appl){const s={appIndex:e.get("apid")??0,onComplete:An(e.get("apan")??0),appArgs:e.get("apaa"),accounts:e.get("apat"),foreignAssets:e.get("apas"),foreignApps:e.get("apfa"),approvalProgram:e.get("apap"),clearProgram:e.get("apsu"),extraPages:e.get("apep"),rejectVersion:e.get("aprv")??0},a=e.get("apls");a&&(s.numLocalInts=a.get("nui"),s.numLocalByteSlices=a.get("nbs"));const l=e.get("apgs");l&&(s.numGlobalInts=l.get("nui"),s.numGlobalByteSlices=l.get("nbs"));const c=e.get("apbx");c&&(s.boxes=c.map(u=>{const m=An(u.get("i")??0),h=Co(u.get("n")??new Uint8Array);if(m===0)return{appIndex:0,name:h};if(!s.foreignApps||m>s.foreignApps.length)throw new Error(`Cannot find foreign app index ${m} in ${s.foreignApps}`);return{appIndex:s.foreignApps[m-1],name:h}}));const d=e.get("al");d&&(s.access=sI(d)),i.appCallParams=s}else if(i.type===Bt.stpf){const s={stateProofType:e.get("sptype"),stateProof:e.get("sp")?Kd.fromEncodingData(e.get("sp")):void 0,message:e.get("spmsg")?qd.fromEncodingData(e.get("spmsg")):void 0};i.stateProofParams=s}else if(i.type===Bt.hb){const s=Ji.fromEncodingData(e.get("hb")),a={address:s.address,proof:s.proof,seed:s.seed,voteID:s.voteID,keyDilution:s.keyDilution};i.heartbeatParams=a}else{const s=i.type;throw new Error(`Unexpected transaction type: ${s}`)}const o=new Wu(i);if(e.get("grp")){const s=Co(e.get("grp"));if(s.byteLength!==gI)throw new Error(`Invalid group length: ${s.byteLength}`);o.group=s}return o}estimateSize(){return this.toByte().length+uI}bytesToSign(){const e=this.toByte();return hn(Km,e)}toByte(){return Sr(this)}rawSignTxn(e){const t=this.bytesToSign();return ll(t,e)}signTxn(e){const t=jd(e),r=new ze(t.publicKey),i=this.rawSignTxn(e);return this.attachSignature(r,i)}attachSignature(e,t){if(!$0(t.length))throw new Error("Invalid signature length");const r=new Map([["sig",t],["txn",this.toEncodingData()]]),i=ai(e);this.sender.equals(i)||r.set("sgnr",i);const o=new oe(rt([{key:"txn",valueSchema:Wu.encodingSchema},{key:"sig",valueSchema:new Ht(64)},{key:"sgnr",valueSchema:new k(new _t)}]));return du(o.prepareMsgpack(r))}rawTxID(){const e=this.toByte(),t=hn(Km,e);return Uint8Array.from(wi(t))}txID(){const e=this.rawTxID();return ul.encode(e).slice(0,cI)}};br.encodingSchema=new oe(rt([{key:"type",valueSchema:new Ce},{key:"snd",valueSchema:new _t},{key:"lv",valueSchema:new O},{key:"gen",valueSchema:new k(new Ce)},{key:"gh",valueSchema:new k(new Ht(32))},{key:"fee",valueSchema:new O},{key:"fv",valueSchema:new O},{key:"note",valueSchema:new Pe},{key:"lx",valueSchema:new k(new Ht(32))},{key:"rekey",valueSchema:new k(new _t)},{key:"grp",valueSchema:new k(new Ht(32))},{key:"amt",valueSchema:new k(new O)},{key:"rcv",valueSchema:new k(new _t)},{key:"close",valueSchema:new k(new _t)},{key:"votekey",valueSchema:new k(new Ht(32))},{key:"selkey",valueSchema:new k(new Ht(32))},{key:"sprfkey",valueSchema:new k(new Ht(64))},{key:"votefst",valueSchema:new k(new O)},{key:"votelst",valueSchema:new k(new O)},{key:"votekd",valueSchema:new k(new O)},{key:"nonpart",valueSchema:new k(new gt)},{key:"caid",valueSchema:new k(new O)},{key:"apar",valueSchema:new k(new oe(rt([{key:"t",valueSchema:new O},{key:"dc",valueSchema:new O},{key:"df",valueSchema:new gt},{key:"m",valueSchema:new k(new _t)},{key:"r",valueSchema:new k(new _t)},{key:"f",valueSchema:new k(new _t)},{key:"c",valueSchema:new k(new _t)},{key:"un",valueSchema:new k(new Ce)},{key:"an",valueSchema:new k(new Ce)},{key:"au",valueSchema:new k(new Ce)},{key:"am",valueSchema:new k(new Ht(32))}])))},{key:"xaid",valueSchema:new k(new O)},{key:"aamt",valueSchema:new k(new O)},{key:"arcv",valueSchema:new k(new _t)},{key:"aclose",valueSchema:new k(new _t)},{key:"asnd",valueSchema:new k(new _t)},{key:"faid",valueSchema:new k(new O)},{key:"afrz",valueSchema:new k(new gt)},{key:"fadd",valueSchema:new k(new _t)},{key:"apid",valueSchema:new k(new O)},{key:"apan",valueSchema:new k(new O)},{key:"apaa",valueSchema:new k(new Me(new Pe))},{key:"apat",valueSchema:new k(new Me(new _t))},{key:"apas",valueSchema:new k(new Me(new O))},{key:"apfa",valueSchema:new k(new Me(new O))},{key:"apbx",valueSchema:new k(new Me(new oe(rt([{key:"i",valueSchema:new O},{key:"n",valueSchema:new Pe}]))))},{key:"al",valueSchema:new k(new Me(new oe(rt([{key:"d",valueSchema:new k(new _t)},{key:"s",valueSchema:new k(new O)},{key:"p",valueSchema:new k(new O)},{key:"h",valueSchema:new k(new oe(rt([{key:"d",valueSchema:new O},{key:"s",valueSchema:new O}])))},{key:"l",valueSchema:new k(new oe(rt([{key:"d",valueSchema:new O},{key:"p",valueSchema:new O}])))},{key:"b",valueSchema:new k(new oe(rt([{key:"i",valueSchema:new O},{key:"n",valueSchema:new Pe}])))}]))))},{key:"apap",valueSchema:new k(new Pe)},{key:"apsu",valueSchema:new k(new Pe)},{key:"apls",valueSchema:new k(new oe(rt([{key:"nui",valueSchema:new O},{key:"nbs",valueSchema:new O}])))},{key:"apgs",valueSchema:new k(new oe(rt([{key:"nui",valueSchema:new O},{key:"nbs",valueSchema:new O}])))},{key:"apep",valueSchema:new k(new O)},{key:"aprv",valueSchema:new k(new O)},{key:"sptype",valueSchema:new k(new O)},{key:"sp",valueSchema:new k(Kd.encodingSchema)},{key:"spmsg",valueSchema:new k(qd.encodingSchema)},{key:"hb",valueSchema:new k(Ji.encodingSchema)}]));function xI(n){return Sr(n)}function vI(n){return Xt(n,br)}const jc=new Uint8Array([77,117,108,116,105,115,105,103,65,100,100,114]),SI="invalid multisig version",bI="bad multisig threshold",EI="bad multisig public key - wrong length",AI="nacl public key length is not 32 bytes";function Tc(n){return n.map(e=>typeof e=="string"?ze.fromString(e).publicKey:e.publicKey)}function xi({version:n,threshold:e,pks:t}){if(n!==1||n>255||n<0)throw new Error(SI);if(e===0||t.length===0||e>t.length||e>255)throw new Error(bI);const r=ko-Jc;if(r!==U0)throw new Error(AI);const i=new Uint8Array(jc.length+2+r*t.length);i.set(jc,0),i.set([n],jc.length),i.set([e],jc.length+1);for(let o=0;o<t.length;o++){if(t[o].length!==r)throw new Error(EI);i.set(t[o],jc.length+2+o*r)}return new ze(Uint8Array.from(wi(i)))}function II({version:n,threshold:e,addrs:t}){const r=Tc(t);return xi({version:n,threshold:e,pks:r})}function Hf(n,e,t){const r=e.v,i=e.thr,o=e.subsig,s=o.map(d=>d.pk);if(e.subsig.length<i)return!1;let a;try{a=xi({version:r,threshold:i,pks:s}).publicKey}catch{return!1}if(!Kr(a,t))return!1;let l=0;for(const d of o)d.s!==void 0&&(l+=1);if(l<i)return!1;let c=0;for(const d of o)d.s!==void 0&&Gd(n,d.s,d.pk)&&(c+=1);return!(c<i)}function kI({version:n,threshold:e,addrs:t}){return II({version:n,threshold:e,addrs:t})}const ax=new oe(rt([{key:"pk",valueSchema:new Ht(32)},{key:"s",valueSchema:new k(new Ht(64))}]));function cx(n){if(!(n instanceof Map))throw new Error(`Invalid decoded EncodedSubsig: ${n}`);const e={pk:n.get("pk")};return n.get("s")&&(e.s=n.get("s")),e}function lx(n){const e=new Map([["pk",n.pk]]);return n.s&&e.set("s",n.s),e}const fd=new oe(rt([{key:"v",valueSchema:new O},{key:"thr",valueSchema:new O},{key:"subsig",valueSchema:new Me(ax)}]));function pd(n){if(!(n instanceof Map))throw new Error(`Invalid decoded EncodedMultiSig: ${n}`);return{v:An(n.get("v")),thr:An(n.get("thr")),subsig:n.get("subsig").map(cx)}}function gd(n){return new Map([["v",n.v],["thr",n.thr],["subsig",n.subsig.map(lx)]])}const CI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;function qm(n){if(!n||n.length===0)throw new Error("empty program");const e=10,t=32,r=126,i=s=>t<=s&&s<=r;if(n.every(s=>s===e||i(s))){const s=new TextDecoder().decode(n);throw z0(s)?new Error("requesting program bytes, get Algorand address"):CI.test(s)?new Error("program should not be b64 encoded"):new Error("program bytes are all ASCII printable characters, not looking like Teal byte code")}}const Nh=new TextEncoder().encode("Program"),Xm=new TextEncoder().encode("MsigProgram");class rr{constructor(e,t){if(t&&(!Array.isArray(t)||!t.every(i=>i.constructor===Uint8Array)))throw new TypeError("Invalid arguments");let r=[];t!=null&&(r=t.map(i=>new Uint8Array(i))),qm(e),this.logic=e,this.args=r,this.sig=void 0,this.msig=void 0,this.lmsig=void 0}getEncodingSchema(){return rr.encodingSchema}toEncodingData(){const e=new Map([["l",this.logic],["arg",this.args],["sig",this.sig]]);return this.msig&&e.set("msig",gd(this.msig)),this.lmsig&&e.set("lmsig",gd(this.lmsig)),e}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded logic sig: ${e}`);const t=new rr(e.get("l"),e.get("arg"));return t.sig=e.get("sig"),e.get("msig")&&(t.msig=pd(e.get("msig"))),e.get("lmsig")&&(t.lmsig=pd(e.get("lmsig"))),t}verify(e){if([this.sig,this.msig,this.lmsig].filter(Boolean).length>1)return!1;try{qm(this.logic)}catch{return!1}const r=hn(Nh,this.logic);if(!this.sig&&!this.msig&&!this.lmsig){const i=wi(r);return Kr(i,e)}if(this.sig)return Gd(r,this.sig,e);if(this.lmsig){const i=xi({version:this.lmsig.v,threshold:this.lmsig.thr,pks:this.lmsig.subsig.map(s=>s.pk)}),o=hn(Xm,i.publicKey,this.logic);return Hf(o,this.lmsig,e)}return this.msig?Hf(r,this.msig,e):!1}address(){const e=hn(Nh,this.logic),t=wi(e);return new ze(Uint8Array.from(t))}sign(e,t){if(t==null)this.sig=this.signProgram(e);else{const r=Tc(t.addrs).map(s=>({pk:s}));this.lmsig={v:t.version,thr:t.threshold,subsig:r};const[i,o]=this.singleSignMultisig(e,this.lmsig);this.lmsig.subsig[o].s=i}}appendToMultisig(e){if(this.lmsig===void 0)throw new Error("no multisig present");const[t,r]=this.singleSignMultisig(e,this.lmsig);this.lmsig.subsig[r].s=t}signProgram(e){const t=hn(Nh,this.logic);return ll(t,e)}signProgramMultisig(e,t){const r=xi({version:t.v,threshold:t.thr,pks:t.subsig.map(s=>s.pk)}),i=hn(Xm,r.publicKey,this.logic);return ll(i,e)}singleSignMultisig(e,t){let r=-1;const i=jd(e).publicKey;for(let s=0;s<t.subsig.length;s++){const{pk:a}=t.subsig[s];if(Kr(a,i)){r=s;break}}if(r===-1)throw new Error("invalid secret key");return[this.signProgramMultisig(e,t),r]}toByte(){return Sr(this)}static fromByte(e){return Xt(e,rr)}}rr.encodingSchema=new oe(rt([{key:"l",valueSchema:new Pe},{key:"arg",valueSchema:new Me(new Pe)},{key:"sig",valueSchema:new k(new Ht(64))},{key:"msig",valueSchema:new k(fd)},{key:"lmsig",valueSchema:new k(fd)}]));let dg=class zu{constructor(e,t){this.lsig=new rr(e,t),this.sigkey=void 0}getEncodingSchema(){return zu.encodingSchema}toEncodingData(){return new Map([["lsig",this.lsig.toEncodingData()],["sigkey",this.sigkey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded logic sig account: ${e}`);const t=e,r=rr.fromEncodingData(t.get("lsig")),i=new zu(r.logic,r.args);return i.lsig=r,i.sigkey=t.get("sigkey"),i}toByte(){return Sr(this)}static fromByte(e){return Xt(e,zu)}isDelegated(){return!!(this.lsig.sig||this.lsig.msig||this.lsig.lmsig)}verify(){const e=this.address();return this.lsig.verify(e.publicKey)}address(){if([this.lsig.sig,this.lsig.msig,this.lsig.lmsig].filter(Boolean).length>1)throw new Error("LogicSig has too many signatures. At most one of sig, msig, or lmsig may be present");if(this.lsig.sig){if(!this.sigkey)throw new Error("Signing key for delegated account is missing");return new ze(this.sigkey)}const t=this.lsig.lmsig||this.lsig.msig;if(t){const r={version:t.v,threshold:t.thr,pks:t.subsig.map(i=>i.pk)};return xi(r)}return this.lsig.address()}signMultisig(e,t){this.lsig.sign(t,e)}appendToMultisig(e){this.lsig.appendToMultisig(e)}sign(e){this.lsig.sign(e),this.sigkey=jd(e).publicKey}};dg.encodingSchema=new oe(rt([{key:"lsig",valueSchema:rr.encodingSchema},{key:"sigkey",valueSchema:new k(new Ht(32))}]));function FI(n){return Xt(n,rr)}const ux=new TextEncoder().encode("ProgData");function dx(n,e,t){const r=typeof t=="string"?ze.fromString(t):t,i=hn(r.publicKey,e),o=hn(ux,i);return ll(o,n)}function DI(n,e,t,r){const i=typeof e=="string"?ze.fromString(e):e,o=hn(i.publicKey,n),s=hn(ux,o);return Gd(s,t,r)}function TI(n,e,t){const i=new rr(t).address();return dx(n,e,i)}class jt{constructor({txn:e,sig:t,msig:r,lsig:i,sgnr:o}){this.txn=e,this.sig=t,this.msig=r,this.lsig=i,this.sgnr=o;let s=0;if(t&&(s+=1),r&&(s+=1),i&&(s+=1),s>1)throw new Error(`SignedTransaction must not have more than 1 signature. Got ${s}`)}getEncodingSchema(){return jt.encodingSchema}toEncodingData(){return new Map([["txn",this.txn.toEncodingData()],["sig",this.sig],["msig",this.msig?gd(this.msig):void 0],["lsig",this.lsig?this.lsig.toEncodingData():void 0],["sgnr",this.sgnr]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SignedTransaction: ${e}`);return new jt({txn:br.fromEncodingData(e.get("txn")),sig:e.get("sig"),msig:e.get("msig")?pd(e.get("msig")):void 0,lsig:e.get("lsig")?rr.fromEncodingData(e.get("lsig")):void 0,sgnr:e.get("sgnr")})}}jt.encodingSchema=new oe(rt([{key:"txn",valueSchema:br.encodingSchema},{key:"sig",valueSchema:new k(new Ht(64))},{key:"msig",valueSchema:new k(fd)},{key:"lsig",valueSchema:new k(rr.encodingSchema)},{key:"sgnr",valueSchema:new k(new _t)}]));function MI(n){return Xt(n,jt)}function hx(n){const e=new jt({txn:n});return Sr(e)}class ns{constructor(e){this.stateProofVotersCommitment=e.stateProofVotersCommitment,this.stateProofOnlineTotalWeight=e.stateProofOnlineTotalWeight,this.stateProofNextRound=e.stateProofNextRound}getEncodingSchema(){return ns.encodingSchema}toEncodingData(){return new Map([["v",this.stateProofVotersCommitment],["t",this.stateProofOnlineTotalWeight],["n",this.stateProofNextRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofTrackingData: ${e}`);return new ns({stateProofVotersCommitment:e.get("v"),stateProofOnlineTotalWeight:e.get("t"),stateProofNextRound:e.get("n")})}}ns.encodingSchema=new oe(rt([{key:"v",valueSchema:new Pe},{key:"t",valueSchema:new O},{key:"n",valueSchema:new O}]));class rs{constructor(e){this.nativeSha512_256Commitment=e.nativeSha512_256Commitment,this.sha256Commitment=e.sha256Commitment}getEncodingSchema(){return rs.encodingSchema}toEncodingData(){return new Map([["txn",this.nativeSha512_256Commitment],["txn256",this.sha256Commitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TxnCommitments: ${e}`);return new rs({nativeSha512_256Commitment:e.get("txn"),sha256Commitment:e.get("txn256")})}}rs.encodingSchema=new oe(rt([{key:"txn",valueSchema:new Ht(32)},{key:"txn256",valueSchema:new Ht(32)}]));class is{constructor(e){this.feeSink=e.feeSink,this.rewardsPool=e.rewardsPool,this.rewardsLevel=e.rewardsLevel,this.rewardsRate=e.rewardsRate,this.rewardsResidue=e.rewardsResidue,this.rewardsRecalculationRound=e.rewardsRecalculationRound}getEncodingSchema(){return is.encodingSchema}toEncodingData(){return new Map([["fees",this.feeSink],["rwd",this.rewardsPool],["earn",this.rewardsLevel],["rate",this.rewardsRate],["frac",this.rewardsResidue],["rwcalr",this.rewardsRecalculationRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded RewardState: ${e}`);return new is({feeSink:e.get("fees"),rewardsPool:e.get("rwd"),rewardsLevel:e.get("earn"),rewardsRate:e.get("rate"),rewardsResidue:e.get("frac"),rewardsRecalculationRound:e.get("rwcalr")})}}is.encodingSchema=new oe(rt([{key:"fees",valueSchema:new _t},{key:"rwd",valueSchema:new _t},{key:"earn",valueSchema:new O},{key:"rate",valueSchema:new O},{key:"frac",valueSchema:new O},{key:"rwcalr",valueSchema:new O}]));class os{constructor(e){this.currentProtocol=e.currentProtocol,this.nextProtocol=e.nextProtocol,this.nextProtocolApprovals=e.nextProtocolApprovals,this.nextProtocolVoteBefore=e.nextProtocolVoteBefore,this.nextProtocolSwitchOn=e.nextProtocolSwitchOn}getEncodingSchema(){return os.encodingSchema}toEncodingData(){return new Map([["proto",this.currentProtocol],["nextproto",this.nextProtocol],["nextyes",this.nextProtocolApprovals],["nextbefore",this.nextProtocolVoteBefore],["nextswitch",this.nextProtocolSwitchOn]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded UpgradeState: ${e}`);return new os({currentProtocol:e.get("proto"),nextProtocol:e.get("nextproto"),nextProtocolApprovals:e.get("nextyes"),nextProtocolVoteBefore:e.get("nextbefore"),nextProtocolSwitchOn:e.get("nextswitch")})}}os.encodingSchema=new oe(rt([{key:"proto",valueSchema:new Ce},{key:"nextproto",valueSchema:new Ce},{key:"nextyes",valueSchema:new O},{key:"nextbefore",valueSchema:new O},{key:"nextswitch",valueSchema:new O}]));class ss{constructor(e){this.upgradePropose=e.upgradePropose,this.upgradeDelay=e.upgradeDelay,this.upgradeApprove=e.upgradeApprove}getEncodingSchema(){return ss.encodingSchema}toEncodingData(){return new Map([["upgradeprop",this.upgradePropose],["upgradedelay",this.upgradeDelay],["upgradeyes",this.upgradeApprove]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded UpgradeVote: ${e}`);return new ss({upgradePropose:e.get("upgradeprop"),upgradeDelay:e.get("upgradedelay"),upgradeApprove:e.get("upgradeyes")})}}ss.encodingSchema=new oe(rt([{key:"upgradeprop",valueSchema:new Ce},{key:"upgradedelay",valueSchema:new O},{key:"upgradeyes",valueSchema:new gt}]));let Xd=class Yf{constructor(e){this.expiredParticipationAccounts=e.expiredParticipationAccounts,this.absentParticipationAccounts=e.absentParticipationAccounts}getEncodingSchema(){return Yf.encodingSchema}toEncodingData(){return new Map([["partupdrmv",this.expiredParticipationAccounts],["partupdabs",this.absentParticipationAccounts]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ParticipationUpdates: ${e}`);return new Yf({expiredParticipationAccounts:e.get("partupdrmv"),absentParticipationAccounts:e.get("partupdabs")})}};Xd.encodingSchema=new oe(rt([{key:"partupdrmv",valueSchema:new Me(new _t)},{key:"partupdabs",valueSchema:new Me(new _t)}]));class vi{constructor(e){this.round=e.round,this.branch=e.branch,this.seed=e.seed,this.txnCommitments=e.txnCommitments,this.timestamp=e.timestamp,this.genesisID=e.genesisID,this.genesisHash=e.genesisHash,this.proposer=e.proposer,this.feesCollected=e.feesCollected,this.bonus=e.bonus,this.proposerPayout=e.proposerPayout,this.rewardState=e.rewardState,this.upgradeState=e.upgradeState,this.upgradeVote=e.upgradeVote,this.txnCounter=e.txnCounter,this.stateproofTracking=e.stateproofTracking,this.participationUpdates=e.participationUpdates}getEncodingSchema(){return vi.encodingSchema}toEncodingData(){const e=new Map([["rnd",this.round],["prev",this.branch],["seed",this.seed],["ts",this.timestamp],["gen",this.genesisID],["gh",this.genesisHash],["prp",this.proposer],["fc",this.feesCollected],["bi",this.bonus],["pp",this.proposerPayout],["tc",this.txnCounter],["spt",dn(this.stateproofTracking,(t,r)=>[t,r.toEncodingData()])]]);return Dc(e,this.txnCommitments.toEncodingData(),this.rewardState.toEncodingData(),this.upgradeState.toEncodingData(),this.upgradeVote.toEncodingData(),this.participationUpdates.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHeader: ${e}`);return new vi({round:e.get("rnd"),branch:e.get("prev"),seed:e.get("seed"),txnCommitments:rs.fromEncodingData(e),timestamp:e.get("ts"),genesisID:e.get("gen"),genesisHash:e.get("gh"),proposer:e.get("prp"),feesCollected:e.get("fc"),bonus:e.get("bi"),proposerPayout:e.get("pp"),rewardState:is.fromEncodingData(e),upgradeState:os.fromEncodingData(e),upgradeVote:ss.fromEncodingData(e),txnCounter:e.get("tc"),stateproofTracking:dn(e.get("spt"),(t,r)=>[Number(t),ns.fromEncodingData(r)]),participationUpdates:Xd.fromEncodingData(e)})}}vi.encodingSchema=new oe(rt([{key:"rnd",valueSchema:new O},{key:"prev",valueSchema:new tI},{key:"seed",valueSchema:new Pe},{key:"",valueSchema:rs.encodingSchema,embedded:!0},{key:"ts",valueSchema:new O},{key:"gen",valueSchema:new Ce},{key:"gh",valueSchema:new Ht(32)},{key:"prp",valueSchema:new _t},{key:"fc",valueSchema:new O},{key:"bi",valueSchema:new O},{key:"pp",valueSchema:new O},{key:"",valueSchema:is.encodingSchema,embedded:!0},{key:"",valueSchema:os.encodingSchema,embedded:!0},{key:"",valueSchema:ss.encodingSchema,embedded:!0},{key:"tc",valueSchema:new O},{key:"spt",valueSchema:new Hd(ns.encodingSchema)},{key:"",valueSchema:Xd.encodingSchema,embedded:!0}]));class di{constructor(e){this.action=e.action,this.bytes=e.bytes,this.uint=e.uint}getEncodingSchema(){return di.encodingSchema}toEncodingData(){return new Map([["at",this.action],["bs",this.bytes],["ui",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ValueDelta: ${e}`);return new di({action:Number(e.get("at")),bytes:e.get("bs"),uint:e.get("ui")})}}di.encodingSchema=new oe(rt([{key:"at",valueSchema:new O},{key:"bs",valueSchema:new Js},{key:"ui",valueSchema:new O}]));let Kf=class qf{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries(...rt([{key:"gd",valueSchema:new k(new dl(di.encodingSchema))},{key:"ld",valueSchema:new k(new Hd(new dl(di.encodingSchema)))},{key:"sa",valueSchema:new k(new Me(new _t))},{key:"lg",valueSchema:new k(new Me(new Js))},{key:"itx",valueSchema:new k(new Me(no.encodingSchema))}]))),this.encodingSchemaValue}constructor(e){this.globalDelta=e.globalDelta??new Map,this.localDeltas=e.localDeltas??new Map,this.sharedAccts=e.sharedAccts??[],this.logs=e.logs??[],this.innerTxns=e.innerTxns??[]}getEncodingSchema(){return qf.encodingSchema}toEncodingData(){return new Map([["gd",dn(this.globalDelta,(e,t)=>[e,t.toEncodingData()])],["ld",dn(this.localDeltas,(e,t)=>[e,dn(t,(r,i)=>[r,i.toEncodingData()])])],["sa",this.sharedAccts],["lg",this.logs],["itx",this.innerTxns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${e}`);return new qf({globalDelta:e.get("gd")?dn(e.get("gd"),(t,r)=>[t,di.fromEncodingData(r)]):void 0,localDeltas:e.get("ld")?dn(e.get("ld"),(t,r)=>[Number(t),dn(r,(i,o)=>[i,di.fromEncodingData(o)])]):void 0,sharedAccts:e.get("sa"),logs:e.get("lg"),innerTxns:(e.get("itx")??[]).map(no.fromEncodingData)})}};class wa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries(...rt([{key:"ca",valueSchema:new k(new O)},{key:"aca",valueSchema:new k(new O)},{key:"rs",valueSchema:new k(new O)},{key:"rr",valueSchema:new k(new O)},{key:"rc",valueSchema:new k(new O)},{key:"dt",valueSchema:new k(Kf.encodingSchema)},{key:"caid",valueSchema:new k(new O)},{key:"apid",valueSchema:new k(new O)}]))),this.encodingSchemaValue}constructor(e){this.closingAmount=e.closingAmount,this.assetClosingAmount=e.assetClosingAmount,this.senderRewards=e.senderRewards,this.receiverRewards=e.receiverRewards,this.closeRewards=e.closeRewards,this.evalDelta=e.evalDelta,this.configAsset=e.configAsset,this.applicationID=e.applicationID}getEncodingSchema(){return wa.encodingSchema}toEncodingData(){return new Map([["ca",this.closingAmount],["aca",this.assetClosingAmount],["rs",this.senderRewards],["rr",this.receiverRewards],["rc",this.closeRewards],["dt",this.evalDelta?this.evalDelta.toEncodingData():void 0],["caid",this.configAsset],["apid",this.applicationID]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplyData: ${e}`);return new wa({closingAmount:e.get("ca"),assetClosingAmount:e.get("aca"),senderRewards:e.get("rs"),receiverRewards:e.get("rr"),closeRewards:e.get("rc"),evalDelta:e.get("dt")?Kf.fromEncodingData(e.get("dt")):void 0,configAsset:e.get("caid"),applicationID:e.get("apid")})}}class no{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries(...rt([{key:"",valueSchema:jt.encodingSchema,embedded:!0},{key:"",valueSchema:wa.encodingSchema,embedded:!0}]))),this.encodingSchemaValue}constructor(e){this.signedTxn=e.signedTxn,this.applyData=e.applyData}getEncodingSchema(){return no.encodingSchema}toEncodingData(){return Dc(this.signedTxn.toEncodingData(),this.applyData.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SignedTxnWithAD: ${e}`);return new no({signedTxn:jt.fromEncodingData(e),applyData:wa.fromEncodingData(e)})}}class as{constructor(e){this.signedTxn=e.signedTxn,this.hasGenesisID=e.hasGenesisID,this.hasGenesisHash=e.hasGenesisHash}getEncodingSchema(){return as.encodingSchema}toEncodingData(){const e=new Map([["hgi",this.hasGenesisID],["hgh",this.hasGenesisHash]]);return Dc(e,this.signedTxn.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SignedTxnInBlock: ${e}`);return new as({signedTxn:no.fromEncodingData(e),hasGenesisID:e.get("hgi"),hasGenesisHash:e.get("hgh")})}}as.encodingSchema=new oe(rt([{key:"",valueSchema:no.encodingSchema,embedded:!0},{key:"hgi",valueSchema:new gt},{key:"hgh",valueSchema:new gt}]));let md=class Xf{constructor(e){this.header=e.header,this.payset=e.payset}getEncodingSchema(){return Xf.encodingSchema}toEncodingData(){const e=new Map([["txns",this.payset.map(t=>t.toEncodingData())]]);return Dc(e,this.header.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHeader: ${e}`);return new Xf({header:vi.fromEncodingData(e),payset:e.get("txns").map(as.fromEncodingData)})}};md.encodingSchema=new oe(rt([{key:"",valueSchema:vi.encodingSchema,embedded:!0},{key:"txns",valueSchema:new Me(as.encodingSchema)}]));class Sn{constructor(e){this.data=e}getEncodingSchema(){return Sn.encodingSchema}toEncodingData(){return this.data}static fromEncodingData(e){return new Sn(e)}}Sn.encodingSchema=new nx;let Mc=class Zf{constructor(e){this.type=e.type,this.bytes=e.bytes,this.uint=e.uint}getEncodingSchema(){return Zf.encodingSchema}toEncodingData(){return new Map([["tt",this.type],["tb",this.bytes],["ui",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealValue: ${e}`);return new Zf({type:Number(e.get("tt")),bytes:e.get("tb"),uint:e.get("ui")})}};Mc.encodingSchema=new oe(rt([{key:"tt",valueSchema:new O},{key:"tb",valueSchema:new k(new Js)},{key:"ui",valueSchema:new k(new O)}]));let Xr=class Jf{constructor(e){this.numUints=e.numUints,this.numByteSlices=e.numByteSlices}getEncodingSchema(){return Jf.encodingSchema}toEncodingData(){return new Map([["nui",this.numUints],["nbs",this.numByteSlices]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateSchema: ${e}`);return new Jf({numUints:Number(e.get("nui")),numByteSlices:Number(e.get("nbs"))})}};Xr.encodingSchema=new oe(rt([{key:"nui",valueSchema:new O},{key:"nbs",valueSchema:new O}]));class cs{constructor(e){this.approvalProgram=e.approvalProgram,this.clearStateProgram=e.clearStateProgram,this.globalState=e.globalState,this.localStateSchema=e.localStateSchema,this.globalStateSchema=e.globalStateSchema,this.extraProgramPages=e.extraProgramPages}getEncodingSchema(){return cs.encodingSchema}toEncodingData(){return new Map([["approv",this.approvalProgram],["clearp",this.clearStateProgram],["gs",dn(this.globalState,(e,t)=>[e,t.toEncodingData()])],["lsch",this.localStateSchema.toEncodingData()],["gsch",this.globalStateSchema.toEncodingData()],["epp",this.extraProgramPages]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppParams: ${e}`);return new cs({approvalProgram:e.get("approv"),clearStateProgram:e.get("clearp"),globalState:dn(e.get("gs"),(t,r)=>[t,Mc.fromEncodingData(r)]),localStateSchema:Xr.fromEncodingData(e.get("lsch")),globalStateSchema:Xr.fromEncodingData(e.get("gsch")),extraProgramPages:Number(e.get("epp"))})}}cs.encodingSchema=new oe(rt([{key:"approv",valueSchema:new Pe},{key:"clearp",valueSchema:new Pe},{key:"gs",valueSchema:new dl(Mc.encodingSchema)},{key:"lsch",valueSchema:Xr.encodingSchema},{key:"gsch",valueSchema:Xr.encodingSchema},{key:"epp",valueSchema:new O}]));class ls{constructor(e){this.schema=e.schema,this.keyValue=e.keyValue}getEncodingSchema(){return ls.encodingSchema}toEncodingData(){return new Map([["hsch",this.schema.toEncodingData()],["tkv",dn(this.keyValue,(e,t)=>[e,t.toEncodingData()])]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppLocalState: ${e}`);return new ls({schema:Xr.fromEncodingData(e.get("hsch")),keyValue:dn(e.get("tkv"),(t,r)=>[t,Mc.fromEncodingData(r)])})}}ls.encodingSchema=new oe(rt([{key:"hsch",valueSchema:Xr.encodingSchema},{key:"tkv",valueSchema:new dl(Mc.encodingSchema)}]));class us{constructor(e){this.localState=e.localState,this.deleted=e.deleted}getEncodingSchema(){return us.encodingSchema}toEncodingData(){return new Map([["LocalState",this.localState?this.localState.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppLocalStateDelta: ${e}`);return new us({localState:e.get("LocalState")?ls.fromEncodingData(e.get("LocalState")):void 0,deleted:e.get("Deleted")})}}us.encodingSchema=new oe(rt([{key:"LocalState",valueSchema:new k(ls.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));class ds{constructor(e){this.params=e.params,this.deleted=e.deleted}getEncodingSchema(){return ds.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppParamsDelta: ${e}`);return new ds({params:e.get("Params")?cs.fromEncodingData(e.get("Params")):void 0,deleted:e.get("Deleted")})}}ds.encodingSchema=new oe(rt([{key:"Params",valueSchema:new k(cs.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));class hs{constructor(e){this.id=e.id,this.address=e.address,this.params=e.params,this.state=e.state}getEncodingSchema(){return hs.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["State",this.state.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppResourceRecord: ${e}`);return new hs({id:e.get("Aidx"),address:e.get("Addr"),params:ds.fromEncodingData(e.get("Params")),state:us.fromEncodingData(e.get("State"))})}}hs.encodingSchema=new oe(rt([{key:"Aidx",valueSchema:new O},{key:"Addr",valueSchema:new _t},{key:"Params",valueSchema:ds.encodingSchema},{key:"State",valueSchema:us.encodingSchema}]));let Zd=class Qf{constructor(e){this.amount=e.amount,this.frozen=e.frozen}getEncodingSchema(){return Qf.encodingSchema}toEncodingData(){return new Map([["a",this.amount],["f",this.frozen]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${e}`);return new Qf({amount:e.get("a"),frozen:e.get("f")})}};Zd.encodingSchema=new oe(rt([{key:"a",valueSchema:new O},{key:"f",valueSchema:new gt}]));class fs{constructor(e){this.holding=e.holding,this.deleted=e.deleted}getEncodingSchema(){return fs.encodingSchema}toEncodingData(){return new Map([["Holding",this.holding?this.holding.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHoldingDelta: ${e}`);return new fs({holding:e.get("Holding")?Zd.fromEncodingData(e.get("Holding")):void 0,deleted:e.get("Deleted")})}}fs.encodingSchema=new oe(rt([{key:"Holding",valueSchema:new k(Zd.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));let Jd=class ep{constructor(e){this.total=e.total,this.decimals=e.decimals,this.defaultFrozen=e.defaultFrozen,this.unitName=e.unitName,this.assetName=e.assetName,this.url=e.url,this.metadataHash=e.metadataHash,this.manager=e.manager,this.reserve=e.reserve,this.freeze=e.freeze,this.clawback=e.clawback}getEncodingSchema(){return ep.encodingSchema}toEncodingData(){return new Map([["t",this.total],["dc",this.decimals],["df",this.defaultFrozen],["un",this.unitName],["an",this.assetName],["au",this.url],["am",this.metadataHash],["m",this.manager],["r",this.reserve],["f",this.freeze],["c",this.clawback]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParams: ${e}`);return new ep({total:e.get("t"),decimals:e.get("dc"),defaultFrozen:e.get("df"),unitName:e.get("un"),assetName:e.get("an"),url:e.get("au"),metadataHash:e.get("am"),manager:e.get("m"),reserve:e.get("r"),freeze:e.get("f"),clawback:e.get("c")})}};Jd.encodingSchema=new oe(rt([{key:"t",valueSchema:new O},{key:"dc",valueSchema:new O},{key:"df",valueSchema:new gt},{key:"un",valueSchema:new k(new Js)},{key:"an",valueSchema:new k(new Js)},{key:"au",valueSchema:new k(new Js)},{key:"am",valueSchema:new Ht(32)},{key:"m",valueSchema:new k(new _t)},{key:"r",valueSchema:new k(new _t)},{key:"f",valueSchema:new k(new _t)},{key:"c",valueSchema:new k(new _t)}]));class ps{constructor(e){this.params=e.params,this.deleted=e.deleted}getEncodingSchema(){return ps.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParamsDelta: ${e}`);return new ps({params:e.get("Params")?Jd.fromEncodingData(e.get("Params")):void 0,deleted:e.get("Deleted")})}}ps.encodingSchema=new oe(rt([{key:"Params",valueSchema:new k(Jd.encodingSchema)},{key:"Deleted",valueSchema:new gt}]));class gs{constructor(e){this.id=e.id,this.address=e.address,this.params=e.params,this.holding=e.holding}getEncodingSchema(){return gs.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["Holding",this.holding.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetResourceRecord: ${e}`);return new gs({id:e.get("Aidx"),address:e.get("Addr"),params:ps.fromEncodingData(e.get("Params")),holding:fs.fromEncodingData(e.get("Holding"))})}}gs.encodingSchema=new oe(rt([{key:"Aidx",valueSchema:new O},{key:"Addr",valueSchema:new _t},{key:"Params",valueSchema:ps.encodingSchema},{key:"Holding",valueSchema:fs.encodingSchema}]));class ms{constructor(e){this.voteID=e.voteID,this.selectionID=e.selectionID,this.stateProofID=e.stateProofID,this.voteFirstValid=e.voteFirstValid,this.voteLastValid=e.voteLastValid,this.voteKeyDilution=e.voteKeyDilution}getEncodingSchema(){return ms.encodingSchema}toEncodingData(){return new Map([["VoteID",this.voteID],["SelectionID",this.selectionID],["StateProofID",this.stateProofID],["VoteFirstValid",this.voteFirstValid],["VoteLastValid",this.voteLastValid],["VoteKeyDilution",this.voteKeyDilution]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded VotingData: ${e}`);return new ms({voteID:e.get("VoteID"),selectionID:e.get("SelectionID"),stateProofID:e.get("StateProofID"),voteFirstValid:e.get("VoteFirstValid"),voteLastValid:e.get("VoteLastValid"),voteKeyDilution:e.get("VoteKeyDilution")})}}ms.encodingSchema=new oe(rt([{key:"VoteID",valueSchema:new Ht(32)},{key:"SelectionID",valueSchema:new Ht(32)},{key:"StateProofID",valueSchema:new Ht(64)},{key:"VoteFirstValid",valueSchema:new O},{key:"VoteLastValid",valueSchema:new O},{key:"VoteKeyDilution",valueSchema:new O}]));class ys{constructor(e){this.status=e.status,this.microAlgos=e.microAlgos,this.rewardsBase=e.rewardsBase,this.rewardedMicroAlgos=e.rewardedMicroAlgos,this.authAddr=e.authAddr,this.incentiveEligible=e.incentiveEligible,this.totalAppSchema=e.totalAppSchema,this.totalExtraAppPages=e.totalExtraAppPages,this.totalAppParams=e.totalAppParams,this.totalAppLocalStates=e.totalAppLocalStates,this.totalAssetParams=e.totalAssetParams,this.totalAssets=e.totalAssets,this.totalBoxes=e.totalBoxes,this.totalBoxBytes=e.totalBoxBytes,this.lastProposed=e.lastProposed,this.lastHeartbeat=e.lastHeartbeat}getEncodingSchema(){return ys.encodingSchema}toEncodingData(){return new Map([["Status",this.status],["MicroAlgos",this.microAlgos],["RewardsBase",this.rewardsBase],["RewardedMicroAlgos",this.rewardedMicroAlgos],["AuthAddr",this.authAddr],["IncentiveEligible",this.incentiveEligible],["TotalAppSchema",this.totalAppSchema.toEncodingData()],["TotalExtraAppPages",this.totalExtraAppPages],["TotalAppParams",this.totalAppParams],["TotalAppLocalStates",this.totalAppLocalStates],["TotalAssetParams",this.totalAssetParams],["TotalAssets",this.totalAssets],["TotalBoxes",this.totalBoxes],["TotalBoxBytes",this.totalBoxBytes],["LastProposed",this.lastProposed],["LastHeartbeat",this.lastHeartbeat]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountBaseData: ${e}`);return new ys({status:Number(e.get("Status")),microAlgos:e.get("MicroAlgos"),rewardsBase:e.get("RewardsBase"),rewardedMicroAlgos:e.get("RewardedMicroAlgos"),authAddr:e.get("AuthAddr"),incentiveEligible:e.get("IncentiveEligible"),totalAppSchema:Xr.fromEncodingData(e.get("TotalAppSchema")),totalExtraAppPages:Number(e.get("TotalExtraAppPages")),totalAppParams:e.get("TotalAppParams"),totalAppLocalStates:e.get("TotalAppLocalStates"),totalAssetParams:e.get("TotalAssetParams"),totalAssets:e.get("TotalAssets"),totalBoxes:e.get("TotalBoxes"),totalBoxBytes:e.get("TotalBoxBytes"),lastProposed:e.get("LastProposed"),lastHeartbeat:e.get("LastHeartbeat")})}}ys.encodingSchema=new oe(rt([{key:"Status",valueSchema:new O},{key:"MicroAlgos",valueSchema:new O},{key:"RewardsBase",valueSchema:new O},{key:"RewardedMicroAlgos",valueSchema:new O},{key:"AuthAddr",valueSchema:new _t},{key:"IncentiveEligible",valueSchema:new gt},{key:"TotalAppSchema",valueSchema:Xr.encodingSchema},{key:"TotalExtraAppPages",valueSchema:new O},{key:"TotalAppParams",valueSchema:new O},{key:"TotalAppLocalStates",valueSchema:new O},{key:"TotalAssetParams",valueSchema:new O},{key:"TotalAssets",valueSchema:new O},{key:"TotalBoxes",valueSchema:new O},{key:"TotalBoxBytes",valueSchema:new O},{key:"LastProposed",valueSchema:new O},{key:"LastHeartbeat",valueSchema:new O}]));class ws{constructor(e){this.accountBaseData=e.accountBaseData,this.votingData=e.votingData}getEncodingSchema(){return ws.encodingSchema}toEncodingData(){return Dc(this.accountBaseData.toEncodingData(),this.votingData.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountData: ${e}`);return new ws({accountBaseData:ys.fromEncodingData(e),votingData:ms.fromEncodingData(e)})}}ws.encodingSchema=new oe(rt([{key:"",valueSchema:ys.encodingSchema,embedded:!0},{key:"",valueSchema:ms.encodingSchema,embedded:!0}]));class xs{constructor(e){this.addr=e.addr,this.accountData=e.accountData}getEncodingSchema(){return xs.encodingSchema}toEncodingData(){return Dc(new Map([["Addr",this.addr]]),this.accountData.toEncodingData())}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BalanceRecord: ${e}`);return new xs({addr:e.get("Addr"),accountData:ws.fromEncodingData(e)})}}xs.encodingSchema=new oe(rt([{key:"Addr",valueSchema:new _t},{key:"",valueSchema:ws.encodingSchema,embedded:!0}]));class vs{constructor(e){this.accounts=e.accounts,this.appResources=e.appResources,this.assetResources=e.assetResources}getEncodingSchema(){return vs.encodingSchema}toEncodingData(){return new Map([["Accts",this.accounts.map(e=>e.toEncodingData())],["AppResources",this.appResources.length===0?void 0:this.appResources.map(e=>e.toEncodingData())],["AssetResources",this.assetResources.length===0?void 0:this.assetResources.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountDeltas: ${e}`);return new vs({accounts:(e.get("Accts")??[]).map(xs.fromEncodingData),appResources:(e.get("AppResources")??[]).map(hs.fromEncodingData),assetResources:(e.get("AssetResources")??[]).map(gs.fromEncodingData)})}}vs.encodingSchema=new oe(rt([{key:"Accts",valueSchema:new Me(xs.encodingSchema)},{key:"AppResources",valueSchema:new k(new Me(hs.encodingSchema))},{key:"AssetResources",valueSchema:new k(new Me(gs.encodingSchema))}]));class Ss{constructor(e){this.data=e.data,this.oldData=e.oldData}getEncodingSchema(){return Ss.encodingSchema}toEncodingData(){return new Map([["Data",this.data],["OldData",this.oldData]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded KvValueDelta: ${e}`);return new Ss({data:e.get("Data"),oldData:e.get("OldData")})}}Ss.encodingSchema=new oe(rt([{key:"Data",valueSchema:new k(new Pe)},{key:"OldData",valueSchema:new k(new Pe)}]));class bs{constructor(e){this.lastValid=e.lastValid,this.intra=e.intra}getEncodingSchema(){return bs.encodingSchema}toEncodingData(){return new Map([["LastValid",this.lastValid],["Intra",this.intra]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded IncludedTransactions: ${e}`);return new bs({lastValid:e.get("LastValid"),intra:Number(e.get("Intra"))})}}bs.encodingSchema=new oe(rt([{key:"LastValid",valueSchema:new O},{key:"Intra",valueSchema:new O}]));class Es{constructor(e){this.creatableType=e.creatableType,this.created=e.created,this.creator=e.creator,this.ndeltas=e.ndeltas}getEncodingSchema(){return Es.encodingSchema}toEncodingData(){return new Map([["Ctype",this.creatableType],["Created",this.created],["Creator",this.creator],["Ndeltas",this.ndeltas]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ModifiedCreatable: ${e}`);return new Es({creatableType:Number(e.get("Ctype")),created:e.get("Created"),creator:e.get("Creator"),ndeltas:Number(e.get("Ndeltas"))})}}Es.encodingSchema=new oe(rt([{key:"Ctype",valueSchema:new O},{key:"Created",valueSchema:new gt},{key:"Creator",valueSchema:new _t},{key:"Ndeltas",valueSchema:new O}]));class Tr{constructor(e){this.money=e.money,this.rewardUnits=e.rewardUnits}getEncodingSchema(){return Tr.encodingSchema}toEncodingData(){return new Map([["mon",this.money],["rwd",this.rewardUnits]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AlgoCount: ${e}`);return new Tr({money:e.get("mon"),rewardUnits:e.get("rwd")})}}Tr.encodingSchema=new oe(rt([{key:"mon",valueSchema:new O},{key:"rwd",valueSchema:new O}]));class As{constructor(e){this.online=e.online,this.offline=e.offline,this.notParticipating=e.notParticipating,this.rewardsLevel=e.rewardsLevel}getEncodingSchema(){return As.encodingSchema}toEncodingData(){return new Map([["online",this.online.toEncodingData()],["offline",this.offline.toEncodingData()],["notpart",this.notParticipating.toEncodingData()],["rwdlvl",this.rewardsLevel]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountTotals: ${e}`);return new As({online:Tr.fromEncodingData(e.get("online")),offline:Tr.fromEncodingData(e.get("offline")),notParticipating:Tr.fromEncodingData(e.get("notpart")),rewardsLevel:e.get("rwdlvl")})}}As.encodingSchema=new oe(rt([{key:"online",valueSchema:Tr.encodingSchema},{key:"offline",valueSchema:Tr.encodingSchema},{key:"notpart",valueSchema:Tr.encodingSchema},{key:"rwdlvl",valueSchema:new O}]));class Si{constructor(e){this.accounts=e.accounts,this.kvMods=e.kvMods,this.txids=e.txids,this.txleases=e.txleases,this.creatables=e.creatables,this.blockHeader=e.blockHeader,this.stateProofNext=e.stateProofNext,this.prevTimestamp=e.prevTimestamp,this.totals=e.totals}getEncodingSchema(){return Si.encodingSchema}toEncodingData(){return new Map([["Accts",this.accounts.toEncodingData()],["KvMods",this.kvMods.size===0?void 0:dn(this.kvMods,(e,t)=>[e,t.toEncodingData()])],["Txids",dn(this.txids,(e,t)=>[e,t.toEncodingData()])],["Txleases",this.txleases.toEncodingData()],["Creatables",this.creatables.size===0?void 0:dn(this.creatables,(e,t)=>[e,t.toEncodingData()])],["Hdr",this.blockHeader.toEncodingData()],["StateProofNext",this.stateProofNext],["PrevTimestamp",this.prevTimestamp],["Totals",this.totals.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LedgerStateDelta: ${e}`);return new Si({accounts:vs.fromEncodingData(e.get("Accts")),kvMods:dn(e.get("KvMods")??new Map,(t,r)=>[t,Ss.fromEncodingData(r)]),txids:dn(e.get("Txids"),(t,r)=>[t,bs.fromEncodingData(r)]),txleases:Sn.fromEncodingData(e.get("Txleases")),creatables:dn(e.get("Creatables")??new Map,(t,r)=>[t,Es.fromEncodingData(r)]),blockHeader:vi.fromEncodingData(e.get("Hdr")),stateProofNext:e.get("StateProofNext"),prevTimestamp:e.get("PrevTimestamp"),totals:As.fromEncodingData(e.get("Totals"))})}}Si.encodingSchema=new oe(rt([{key:"Accts",valueSchema:vs.encodingSchema},{key:"KvMods",valueSchema:new k(new dl(Ss.encodingSchema))},{key:"Txids",valueSchema:new nI(bs.encodingSchema)},{key:"Txleases",valueSchema:new k(new nx)},{key:"Creatables",valueSchema:new k(new Hd(Es.encodingSchema))},{key:"Hdr",valueSchema:vi.encodingSchema},{key:"StateProofNext",valueSchema:new O},{key:"PrevTimestamp",valueSchema:new O},{key:"Totals",valueSchema:As.encodingSchema}]));let yd=class tp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"amount",valueSchema:new O,omitEmpty:!0},{key:"amount-without-pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"min-balance",valueSchema:new O,omitEmpty:!0},{key:"pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"rewards",valueSchema:new O,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"status",valueSchema:new Ce,omitEmpty:!0},{key:"total-apps-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-assets-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-created-apps",valueSchema:new O,omitEmpty:!0},{key:"total-created-assets",valueSchema:new O,omitEmpty:!0},{key:"apps-local-state",valueSchema:new k(new Me(gl.encodingSchema)),omitEmpty:!0},{key:"apps-total-extra-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"apps-total-schema",valueSchema:new k(Dr.encodingSchema),omitEmpty:!0},{key:"assets",valueSchema:new k(new Me(ks.encodingSchema)),omitEmpty:!0},{key:"auth-addr",valueSchema:new k(new Ce),omitEmpty:!0},{key:"created-apps",valueSchema:new k(new Me(Is.encodingSchema)),omitEmpty:!0},{key:"created-assets",valueSchema:new k(new Me(xd.encodingSchema)),omitEmpty:!0},{key:"incentive-eligible",valueSchema:new k(new gt),omitEmpty:!0},{key:"last-heartbeat",valueSchema:new k(new O),omitEmpty:!0},{key:"last-proposed",valueSchema:new k(new O),omitEmpty:!0},{key:"participation",valueSchema:new k(np.encodingSchema),omitEmpty:!0},{key:"reward-base",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-type",valueSchema:new k(new Ce),omitEmpty:!0},{key:"total-box-bytes",valueSchema:new k(new O),omitEmpty:!0},{key:"total-boxes",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,amount:t,amountWithoutPendingRewards:r,minBalance:i,pendingRewards:o,rewards:s,round:a,status:l,totalAppsOptedIn:c,totalAssetsOptedIn:d,totalCreatedApps:u,totalCreatedAssets:m,appsLocalState:h,appsTotalExtraPages:x,appsTotalSchema:A,assets:v,authAddr:F,createdApps:w,createdAssets:C,incentiveEligible:M,lastHeartbeat:N,lastProposed:b,participation:j,rewardBase:p,sigType:E,totalBoxBytes:S,totalBoxes:$}){this.address=e,this.amount=ve(t),this.amountWithoutPendingRewards=ve(r),this.minBalance=ve(i),this.pendingRewards=ve(o),this.rewards=ve(s),this.round=ve(a),this.status=l,this.totalAppsOptedIn=Oe(c),this.totalAssetsOptedIn=Oe(d),this.totalCreatedApps=Oe(u),this.totalCreatedAssets=Oe(m),this.appsLocalState=h,this.appsTotalExtraPages=typeof x>"u"?void 0:Oe(x),this.appsTotalSchema=A,this.assets=v,this.authAddr=typeof F=="string"?ze.fromString(F):F,this.createdApps=w,this.createdAssets=C,this.incentiveEligible=M,this.lastHeartbeat=typeof N>"u"?void 0:Oe(N),this.lastProposed=typeof b>"u"?void 0:Oe(b),this.participation=j,this.rewardBase=typeof p>"u"?void 0:ve(p),this.sigType=E,this.totalBoxBytes=typeof S>"u"?void 0:Oe(S),this.totalBoxes=typeof $>"u"?void 0:Oe($)}getEncodingSchema(){return tp.encodingSchema}toEncodingData(){return new Map([["address",this.address],["amount",this.amount],["amount-without-pending-rewards",this.amountWithoutPendingRewards],["min-balance",this.minBalance],["pending-rewards",this.pendingRewards],["rewards",this.rewards],["round",this.round],["status",this.status],["total-apps-opted-in",this.totalAppsOptedIn],["total-assets-opted-in",this.totalAssetsOptedIn],["total-created-apps",this.totalCreatedApps],["total-created-assets",this.totalCreatedAssets],["apps-local-state",typeof this.appsLocalState<"u"?this.appsLocalState.map(e=>e.toEncodingData()):void 0],["apps-total-extra-pages",this.appsTotalExtraPages],["apps-total-schema",typeof this.appsTotalSchema<"u"?this.appsTotalSchema.toEncodingData():void 0],["assets",typeof this.assets<"u"?this.assets.map(e=>e.toEncodingData()):void 0],["auth-addr",typeof this.authAddr<"u"?this.authAddr.toString():void 0],["created-apps",typeof this.createdApps<"u"?this.createdApps.map(e=>e.toEncodingData()):void 0],["created-assets",typeof this.createdAssets<"u"?this.createdAssets.map(e=>e.toEncodingData()):void 0],["incentive-eligible",this.incentiveEligible],["last-heartbeat",this.lastHeartbeat],["last-proposed",this.lastProposed],["participation",typeof this.participation<"u"?this.participation.toEncodingData():void 0],["reward-base",this.rewardBase],["sig-type",this.sigType],["total-box-bytes",this.totalBoxBytes],["total-boxes",this.totalBoxes]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Account: ${e}`);return new tp({address:e.get("address"),amount:e.get("amount"),amountWithoutPendingRewards:e.get("amount-without-pending-rewards"),minBalance:e.get("min-balance"),pendingRewards:e.get("pending-rewards"),rewards:e.get("rewards"),round:e.get("round"),status:e.get("status"),totalAppsOptedIn:e.get("total-apps-opted-in"),totalAssetsOptedIn:e.get("total-assets-opted-in"),totalCreatedApps:e.get("total-created-apps"),totalCreatedAssets:e.get("total-created-assets"),appsLocalState:typeof e.get("apps-local-state")<"u"?e.get("apps-local-state").map(t=>gl.fromEncodingData(t)):void 0,appsTotalExtraPages:e.get("apps-total-extra-pages"),appsTotalSchema:typeof e.get("apps-total-schema")<"u"?Dr.fromEncodingData(e.get("apps-total-schema")):void 0,assets:typeof e.get("assets")<"u"?e.get("assets").map(t=>ks.fromEncodingData(t)):void 0,authAddr:e.get("auth-addr"),createdApps:typeof e.get("created-apps")<"u"?e.get("created-apps").map(t=>Is.fromEncodingData(t)):void 0,createdAssets:typeof e.get("created-assets")<"u"?e.get("created-assets").map(t=>xd.fromEncodingData(t)):void 0,incentiveEligible:e.get("incentive-eligible"),lastHeartbeat:e.get("last-heartbeat"),lastProposed:e.get("last-proposed"),participation:typeof e.get("participation")<"u"?np.fromEncodingData(e.get("participation")):void 0,rewardBase:e.get("reward-base"),sigType:e.get("sig-type"),totalBoxBytes:e.get("total-box-bytes"),totalBoxes:e.get("total-boxes")})}};class hl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0},{key:"app-local-state",valueSchema:new k(gl.encodingSchema),omitEmpty:!0},{key:"created-app",valueSchema:new k(Ea.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e,appLocalState:t,createdApp:r}){this.round=ve(e),this.appLocalState=t,this.createdApp=r}getEncodingSchema(){return hl.encodingSchema}toEncodingData(){return new Map([["round",this.round],["app-local-state",typeof this.appLocalState<"u"?this.appLocalState.toEncodingData():void 0],["created-app",typeof this.createdApp<"u"?this.createdApp.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountApplicationResponse: ${e}`);return new hl({round:e.get("round"),appLocalState:typeof e.get("app-local-state")<"u"?gl.fromEncodingData(e.get("app-local-state")):void 0,createdApp:typeof e.get("created-app")<"u"?Ea.fromEncodingData(e.get("created-app")):void 0})}}class xa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"asset-holding",valueSchema:ks.encodingSchema,omitEmpty:!0},{key:"asset-params",valueSchema:new k(Cs.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({assetHolding:e,assetParams:t}){this.assetHolding=e,this.assetParams=t}getEncodingSchema(){return xa.encodingSchema}toEncodingData(){return new Map([["asset-holding",this.assetHolding.toEncodingData()],["asset-params",typeof this.assetParams<"u"?this.assetParams.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountAssetHolding: ${e}`);return new xa({assetHolding:ks.fromEncodingData(e.get("asset-holding")??new Map),assetParams:typeof e.get("asset-params")<"u"?Cs.fromEncodingData(e.get("asset-params")):void 0})}}class fl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0},{key:"asset-holding",valueSchema:new k(ks.encodingSchema),omitEmpty:!0},{key:"created-asset",valueSchema:new k(Cs.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e,assetHolding:t,createdAsset:r}){this.round=ve(e),this.assetHolding=t,this.createdAsset=r}getEncodingSchema(){return fl.encodingSchema}toEncodingData(){return new Map([["round",this.round],["asset-holding",typeof this.assetHolding<"u"?this.assetHolding.toEncodingData():void 0],["created-asset",typeof this.createdAsset<"u"?this.createdAsset.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountAssetResponse: ${e}`);return new fl({round:e.get("round"),assetHolding:typeof e.get("asset-holding")<"u"?ks.fromEncodingData(e.get("asset-holding")):void 0,createdAsset:typeof e.get("created-asset")<"u"?Cs.fromEncodingData(e.get("created-asset")):void 0})}}class wd{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0},{key:"asset-holdings",valueSchema:new k(new Me(xa.encodingSchema)),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e,assetHoldings:t,nextToken:r}){this.round=Oe(e),this.assetHoldings=t,this.nextToken=r}getEncodingSchema(){return wd.encodingSchema}toEncodingData(){return new Map([["round",this.round],["asset-holdings",typeof this.assetHoldings<"u"?this.assetHoldings.map(e=>e.toEncodingData()):void 0],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountAssetsInformationResponse: ${e}`);return new wd({round:e.get("round"),assetHoldings:typeof e.get("asset-holdings")<"u"?e.get("asset-holdings").map(t=>xa.fromEncodingData(t)):void 0,nextToken:e.get("next-token")})}}let np=class rp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"selection-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"vote-first-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-key-dilution",valueSchema:new O,omitEmpty:!0},{key:"vote-last-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"state-proof-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({selectionParticipationKey:e,voteFirstValid:t,voteKeyDilution:r,voteLastValid:i,voteParticipationKey:o,stateProofKey:s}){this.selectionParticipationKey=typeof e=="string"?Ge(e):e,this.voteFirstValid=ve(t),this.voteKeyDilution=ve(r),this.voteLastValid=ve(i),this.voteParticipationKey=typeof o=="string"?Ge(o):o,this.stateProofKey=typeof s=="string"?Ge(s):s}getEncodingSchema(){return rp.encodingSchema}toEncodingData(){return new Map([["selection-participation-key",this.selectionParticipationKey],["vote-first-valid",this.voteFirstValid],["vote-key-dilution",this.voteKeyDilution],["vote-last-valid",this.voteLastValid],["vote-participation-key",this.voteParticipationKey],["state-proof-key",this.stateProofKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountParticipation: ${e}`);return new rp({selectionParticipationKey:e.get("selection-participation-key"),voteFirstValid:e.get("vote-first-valid"),voteKeyDilution:e.get("vote-key-dilution"),voteLastValid:e.get("vote-last-valid"),voteParticipationKey:e.get("vote-participation-key"),stateProofKey:e.get("state-proof-key")})}},pl=class ip{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"delta",valueSchema:new Me(Fs.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,delta:t}){this.address=e,this.delta=t}getEncodingSchema(){return ip.encodingSchema}toEncodingData(){return new Map([["address",this.address],["delta",this.delta.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountStateDelta: ${e}`);return new ip({address:e.get("address"),delta:(e.get("delta")??[]).map(t=>Fs.fromEncodingData(t))})}};class va{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-index",valueSchema:new O,omitEmpty:!0},{key:"logs",valueSchema:new Me(new Pe),omitEmpty:!0},{key:"txId",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationIndex:e,logs:t,txid:r}){this.applicationIndex=Oe(e),this.logs=t,this.txid=r}getEncodingSchema(){return va.encodingSchema}toEncodingData(){return new Map([["application-index",this.applicationIndex],["logs",this.logs],["txId",this.txid]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AppCallLogs: ${e}`);return new va({applicationIndex:e.get("application-index"),logs:e.get("logs"),txid:e.get("txId")})}}let Is=class op{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:Ea.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,params:t}){this.id=ve(e),this.params=t}getEncodingSchema(){return op.encodingSchema}toEncodingData(){return new Map([["id",this.id],["params",this.params.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Application: ${e}`);return new op({id:e.get("id"),params:Ea.fromEncodingData(e.get("params")??new Map)})}};class Sa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"app-boxes",valueSchema:new k(_r.encodingSchema),omitEmpty:!0},{key:"app-globals",valueSchema:new k(_r.encodingSchema),omitEmpty:!0},{key:"app-locals",valueSchema:new k(new Me(_r.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,appBoxes:t,appGlobals:r,appLocals:i}){this.id=ve(e),this.appBoxes=t,this.appGlobals=r,this.appLocals=i}getEncodingSchema(){return Sa.encodingSchema}toEncodingData(){return new Map([["id",this.id],["app-boxes",typeof this.appBoxes<"u"?this.appBoxes.toEncodingData():void 0],["app-globals",typeof this.appGlobals<"u"?this.appGlobals.toEncodingData():void 0],["app-locals",typeof this.appLocals<"u"?this.appLocals.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationInitialStates: ${e}`);return new Sa({id:e.get("id"),appBoxes:typeof e.get("app-boxes")<"u"?_r.fromEncodingData(e.get("app-boxes")):void 0,appGlobals:typeof e.get("app-globals")<"u"?_r.fromEncodingData(e.get("app-globals")):void 0,appLocals:typeof e.get("app-locals")<"u"?e.get("app-locals").map(t=>_r.fromEncodingData(t)):void 0})}}class _r{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"kvs",valueSchema:new Me(ka.encodingSchema),omitEmpty:!0},{key:"account",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({kvs:e,account:t}){this.kvs=e,this.account=typeof t=="string"?ze.fromString(t):t}getEncodingSchema(){return _r.encodingSchema}toEncodingData(){return new Map([["kvs",this.kvs.map(e=>e.toEncodingData())],["account",typeof this.account<"u"?this.account.toString():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationKVStorage: ${e}`);return new _r({kvs:(e.get("kvs")??[]).map(t=>ka.fromEncodingData(t)),account:e.get("account")})}}class ba{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"account",valueSchema:new Ce,omitEmpty:!0},{key:"app",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({account:e,app:t}){this.account=typeof e=="string"?ze.fromString(e):e,this.app=ve(t)}getEncodingSchema(){return ba.encodingSchema}toEncodingData(){return new Map([["account",this.account.toString()],["app",this.app]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalReference: ${e}`);return new ba({account:e.get("account"),app:e.get("app")})}}let gl=class sp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"schema",valueSchema:Dr.encodingSchema,omitEmpty:!0},{key:"key-value",valueSchema:new k(new Me(Fl.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,schema:t,keyValue:r}){this.id=ve(e),this.schema=t,this.keyValue=r}getEncodingSchema(){return sp.encodingSchema}toEncodingData(){return new Map([["id",this.id],["schema",this.schema.toEncodingData()],["key-value",typeof this.keyValue<"u"?this.keyValue.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalState: ${e}`);return new sp({id:e.get("id"),schema:Dr.fromEncodingData(e.get("schema")??new Map),keyValue:typeof e.get("key-value")<"u"?e.get("key-value").map(t=>Fl.fromEncodingData(t)):void 0})}},Ea=class ap{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"approval-program",valueSchema:new Pe,omitEmpty:!0},{key:"clear-state-program",valueSchema:new Pe,omitEmpty:!0},{key:"creator",valueSchema:new Ce,omitEmpty:!0},{key:"extra-program-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"global-state",valueSchema:new k(new Me(Fl.encodingSchema)),omitEmpty:!0},{key:"global-state-schema",valueSchema:new k(Dr.encodingSchema),omitEmpty:!0},{key:"local-state-schema",valueSchema:new k(Dr.encodingSchema),omitEmpty:!0},{key:"version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({approvalProgram:e,clearStateProgram:t,creator:r,extraProgramPages:i,globalState:o,globalStateSchema:s,localStateSchema:a,version:l}){this.approvalProgram=typeof e=="string"?Ge(e):e,this.clearStateProgram=typeof t=="string"?Ge(t):t,this.creator=typeof r=="string"?ze.fromString(r):r,this.extraProgramPages=typeof i>"u"?void 0:Oe(i),this.globalState=o,this.globalStateSchema=s,this.localStateSchema=a,this.version=typeof l>"u"?void 0:Oe(l)}getEncodingSchema(){return ap.encodingSchema}toEncodingData(){return new Map([["approval-program",this.approvalProgram],["clear-state-program",this.clearStateProgram],["creator",this.creator.toString()],["extra-program-pages",this.extraProgramPages],["global-state",typeof this.globalState<"u"?this.globalState.map(e=>e.toEncodingData()):void 0],["global-state-schema",typeof this.globalStateSchema<"u"?this.globalStateSchema.toEncodingData():void 0],["local-state-schema",typeof this.localStateSchema<"u"?this.localStateSchema.toEncodingData():void 0],["version",this.version]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationParams: ${e}`);return new ap({approvalProgram:e.get("approval-program"),clearStateProgram:e.get("clear-state-program"),creator:e.get("creator"),extraProgramPages:e.get("extra-program-pages"),globalState:typeof e.get("global-state")<"u"?e.get("global-state").map(t=>Fl.fromEncodingData(t)):void 0,globalStateSchema:typeof e.get("global-state-schema")<"u"?Dr.fromEncodingData(e.get("global-state-schema")):void 0,localStateSchema:typeof e.get("local-state-schema")<"u"?Dr.fromEncodingData(e.get("local-state-schema")):void 0,version:e.get("version")})}};class Aa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app-state-type",valueSchema:new Ce,omitEmpty:!0},{key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"operation",valueSchema:new Ce,omitEmpty:!0},{key:"account",valueSchema:new k(new Ce),omitEmpty:!0},{key:"new-value",valueSchema:new k(vr.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({appStateType:e,key:t,operation:r,account:i,newValue:o}){this.appStateType=e,this.key=typeof t=="string"?Ge(t):t,this.operation=r,this.account=typeof i=="string"?ze.fromString(i):i,this.newValue=o}getEncodingSchema(){return Aa.encodingSchema}toEncodingData(){return new Map([["app-state-type",this.appStateType],["key",this.key],["operation",this.operation],["account",typeof this.account<"u"?this.account.toString():void 0],["new-value",typeof this.newValue<"u"?this.newValue.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationStateOperation: ${e}`);return new Aa({appStateType:e.get("app-state-type"),key:e.get("key"),operation:e.get("operation"),account:e.get("account"),newValue:typeof e.get("new-value")<"u"?vr.fromEncodingData(e.get("new-value")):void 0})}}let Dr=class cp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"num-byte-slice",valueSchema:new O,omitEmpty:!0},{key:"num-uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({numByteSlice:e,numUint:t}){this.numByteSlice=Oe(e),this.numUint=Oe(t)}getEncodingSchema(){return cp.encodingSchema}toEncodingData(){return new Map([["num-byte-slice",this.numByteSlice],["num-uint",this.numUint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationStateSchema: ${e}`);return new cp({numByteSlice:e.get("num-byte-slice"),numUint:e.get("num-uint")})}},xd=class lp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"index",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:Cs.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({index:e,params:t}){this.index=ve(e),this.params=t}getEncodingSchema(){return lp.encodingSchema}toEncodingData(){return new Map([["index",this.index],["params",this.params.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Asset: ${e}`);return new lp({index:e.get("index"),params:Cs.fromEncodingData(e.get("params")??new Map)})}},ks=class up{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"is-frozen",valueSchema:new gt,omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,assetId:t,isFrozen:r}){this.amount=ve(e),this.assetId=ve(t),this.isFrozen=r}getEncodingSchema(){return up.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["asset-id",this.assetId],["is-frozen",this.isFrozen]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${e}`);return new up({amount:e.get("amount"),assetId:e.get("asset-id"),isFrozen:e.get("is-frozen")})}};class Ia{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"account",valueSchema:new Ce,omitEmpty:!0},{key:"asset",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({account:e,asset:t}){this.account=typeof e=="string"?ze.fromString(e):e,this.asset=ve(t)}getEncodingSchema(){return Ia.encodingSchema}toEncodingData(){return new Map([["account",this.account.toString()],["asset",this.asset]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHoldingReference: ${e}`);return new Ia({account:e.get("account"),asset:e.get("asset")})}}let Cs=class dp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"creator",valueSchema:new Ce,omitEmpty:!0},{key:"decimals",valueSchema:new O,omitEmpty:!0},{key:"total",valueSchema:new O,omitEmpty:!0},{key:"clawback",valueSchema:new k(new Ce),omitEmpty:!0},{key:"default-frozen",valueSchema:new k(new gt),omitEmpty:!0},{key:"freeze",valueSchema:new k(new Ce),omitEmpty:!0},{key:"manager",valueSchema:new k(new Ce),omitEmpty:!0},{key:"metadata-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"reserve",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"url",valueSchema:new k(new Ce),omitEmpty:!0},{key:"url-b64",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({creator:e,decimals:t,total:r,clawback:i,defaultFrozen:o,freeze:s,manager:a,metadataHash:l,name:c,nameB64:d,reserve:u,unitName:m,unitNameB64:h,url:x,urlB64:A}){this.creator=e,this.decimals=Oe(t),this.total=ve(r),this.clawback=i,this.defaultFrozen=o,this.freeze=s,this.manager=a,this.metadataHash=typeof l=="string"?Ge(l):l,this.name=c,this.nameB64=typeof d=="string"?Ge(d):d,this.reserve=u,this.unitName=m,this.unitNameB64=typeof h=="string"?Ge(h):h,this.url=x,this.urlB64=typeof A=="string"?Ge(A):A}getEncodingSchema(){return dp.encodingSchema}toEncodingData(){return new Map([["creator",this.creator],["decimals",this.decimals],["total",this.total],["clawback",this.clawback],["default-frozen",this.defaultFrozen],["freeze",this.freeze],["manager",this.manager],["metadata-hash",this.metadataHash],["name",this.name],["name-b64",this.nameB64],["reserve",this.reserve],["unit-name",this.unitName],["unit-name-b64",this.unitNameB64],["url",this.url],["url-b64",this.urlB64]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParams: ${e}`);return new dp({creator:e.get("creator"),decimals:e.get("decimals"),total:e.get("total"),clawback:e.get("clawback"),defaultFrozen:e.get("default-frozen"),freeze:e.get("freeze"),manager:e.get("manager"),metadataHash:e.get("metadata-hash"),name:e.get("name"),nameB64:e.get("name-b64"),reserve:e.get("reserve"),unitName:e.get("unit-name"),unitNameB64:e.get("unit-name-b64"),url:e.get("url"),urlB64:e.get("url-b64")})}};class ka{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"value",valueSchema:vr.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=typeof e=="string"?Ge(e):e,this.value=t}getEncodingSchema(){return ka.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AvmKeyValue: ${e}`);return new ka({key:e.get("key"),value:vr.fromEncodingData(e.get("value")??new Map)})}}class vr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"type",valueSchema:new O,omitEmpty:!0},{key:"bytes",valueSchema:new k(new Pe),omitEmpty:!0},{key:"uint",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({type:e,bytes:t,uint:r}){this.type=Oe(e),this.bytes=typeof t=="string"?Ge(t):t,this.uint=typeof r>"u"?void 0:ve(r)}getEncodingSchema(){return vr.encodingSchema}toEncodingData(){return new Map([["type",this.type],["bytes",this.bytes],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AvmValue: ${e}`);return new vr({type:e.get("type"),bytes:e.get("bytes"),uint:e.get("uint")})}}class ml{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"blockHash",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({blockhash:e}){this.blockhash=e}getEncodingSchema(){return ml.encodingSchema}toEncodingData(){return new Map([["blockHash",this.blockhash]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHashResponse: ${e}`);return new ml({blockhash:e.get("blockHash")})}}class vd{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logs",valueSchema:new Me(va.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({logs:e}){this.logs=e}getEncodingSchema(){return vd.encodingSchema}toEncodingData(){return new Map([["logs",this.logs.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockLogsResponse: ${e}`);return new vd({logs:(e.get("logs")??[]).map(t=>va.fromEncodingData(t))})}}class yl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"block",valueSchema:md.encodingSchema,omitEmpty:!0},{key:"cert",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({block:e,cert:t}){this.block=e,this.cert=t}getEncodingSchema(){return yl.encodingSchema}toEncodingData(){return new Map([["block",this.block.toEncodingData()],["cert",typeof this.cert<"u"?this.cert.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockResponse: ${e}`);return new yl({block:md.fromEncodingData(e.get("block")??new Map),cert:typeof e.get("cert")<"u"?Sn.fromEncodingData(e.get("cert")):void 0})}}class wl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"blockTxids",valueSchema:new Me(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({blocktxids:e}){this.blocktxids=e}getEncodingSchema(){return wl.encodingSchema}toEncodingData(){return new Map([["blockTxids",this.blocktxids]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockTxidsResponse: ${e}`);return new wl({blocktxids:e.get("blockTxids")})}}let fx=class hp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"value",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e,round:t,value:r}){this.name=typeof e=="string"?Ge(e):e,this.round=ve(t),this.value=typeof r=="string"?Ge(r):r}getEncodingSchema(){return hp.encodingSchema}toEncodingData(){return new Map([["name",this.name],["round",this.round],["value",this.value]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Box: ${e}`);return new hp({name:e.get("name"),round:e.get("round"),value:e.get("value")})}},fp=class pp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e}){this.name=typeof e=="string"?Ge(e):e}getEncodingSchema(){return pp.encodingSchema}toEncodingData(){return new Map([["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxDescriptor: ${e}`);return new pp({name:e.get("name")})}},gp=class mp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app",valueSchema:new O,omitEmpty:!0},{key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({app:e,name:t}){this.app=ve(e),this.name=typeof t=="string"?Ge(t):t}getEncodingSchema(){return mp.encodingSchema}toEncodingData(){return new Map([["app",this.app],["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxReference: ${e}`);return new mp({app:e.get("app"),name:e.get("name")})}},px=class yp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"boxes",valueSchema:new Me(fp.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({boxes:e}){this.boxes=e}getEncodingSchema(){return yp.encodingSchema}toEncodingData(){return new Map([["boxes",this.boxes.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxesResponse: ${e}`);return new yp({boxes:(e.get("boxes")??[]).map(t=>fp.fromEncodingData(t))})}};class Ca{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"branch",valueSchema:new Ce,omitEmpty:!0},{key:"build_number",valueSchema:new O,omitEmpty:!0},{key:"channel",valueSchema:new Ce,omitEmpty:!0},{key:"commit_hash",valueSchema:new Ce,omitEmpty:!0},{key:"major",valueSchema:new O,omitEmpty:!0},{key:"minor",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({branch:e,buildNumber:t,channel:r,commitHash:i,major:o,minor:s}){this.branch=e,this.buildNumber=Oe(t),this.channel=r,this.commitHash=i,this.major=Oe(o),this.minor=Oe(s)}getEncodingSchema(){return Ca.encodingSchema}toEncodingData(){return new Map([["branch",this.branch],["build_number",this.buildNumber],["channel",this.channel],["commit_hash",this.commitHash],["major",this.major],["minor",this.minor]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BuildVersion: ${e}`);return new Ca({branch:e.get("branch"),buildNumber:e.get("build_number"),channel:e.get("channel"),commitHash:e.get("commit_hash"),major:e.get("major"),minor:e.get("minor")})}}class xl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hash",valueSchema:new Ce,omitEmpty:!0},{key:"result",valueSchema:new Ce,omitEmpty:!0},{key:"sourcemap",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({hash:e,result:t,sourcemap:r}){this.hash=e,this.result=t,this.sourcemap=r}getEncodingSchema(){return xl.encodingSchema}toEncodingData(){return new Map([["hash",this.hash],["result",this.result],["sourcemap",typeof this.sourcemap<"u"?this.sourcemap.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded CompileResponse: ${e}`);return new xl({hash:e.get("hash"),result:e.get("result"),sourcemap:typeof e.get("sourcemap")<"u"?Sn.fromEncodingData(e.get("sourcemap")):void 0})}}class vl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"result",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({result:e}){this.result=e}getEncodingSchema(){return vl.encodingSchema}toEncodingData(){return new Map([["result",this.result]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DisassembleResponse: ${e}`);return new vl({result:e.get("result")})}}class Sl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"accounts",valueSchema:new Me(yd.encodingSchema),omitEmpty:!0},{key:"apps",valueSchema:new Me(Is.encodingSchema),omitEmpty:!0},{key:"latest-timestamp",valueSchema:new O,omitEmpty:!0},{key:"protocol-version",valueSchema:new Ce,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"sources",valueSchema:new Me(Fa.encodingSchema),omitEmpty:!0},{key:"txns",valueSchema:new Me(jt.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({accounts:e,apps:t,latestTimestamp:r,protocolVersion:i,round:o,sources:s,txns:a}){this.accounts=e,this.apps=t,this.latestTimestamp=Oe(r),this.protocolVersion=i,this.round=ve(o),this.sources=s,this.txns=a}getEncodingSchema(){return Sl.encodingSchema}toEncodingData(){return new Map([["accounts",this.accounts.map(e=>e.toEncodingData())],["apps",this.apps.map(e=>e.toEncodingData())],["latest-timestamp",this.latestTimestamp],["protocol-version",this.protocolVersion],["round",this.round],["sources",this.sources.map(e=>e.toEncodingData())],["txns",this.txns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunRequest: ${e}`);return new Sl({accounts:(e.get("accounts")??[]).map(t=>yd.fromEncodingData(t)),apps:(e.get("apps")??[]).map(t=>Is.fromEncodingData(t)),latestTimestamp:e.get("latest-timestamp"),protocolVersion:e.get("protocol-version"),round:e.get("round"),sources:(e.get("sources")??[]).map(t=>Fa.fromEncodingData(t)),txns:(e.get("txns")??[]).map(t=>jt.fromEncodingData(t))})}}class bl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"error",valueSchema:new Ce,omitEmpty:!0},{key:"protocol-version",valueSchema:new Ce,omitEmpty:!0},{key:"txns",valueSchema:new Me(Da.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({error:e,protocolVersion:t,txns:r}){this.error=e,this.protocolVersion=t,this.txns=r}getEncodingSchema(){return bl.encodingSchema}toEncodingData(){return new Map([["error",this.error],["protocol-version",this.protocolVersion],["txns",this.txns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunResponse: ${e}`);return new bl({error:e.get("error"),protocolVersion:e.get("protocol-version"),txns:(e.get("txns")??[]).map(t=>Da.fromEncodingData(t))})}}class Fa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app-index",valueSchema:new O,omitEmpty:!0},{key:"field-name",valueSchema:new Ce,omitEmpty:!0},{key:"source",valueSchema:new Ce,omitEmpty:!0},{key:"txn-index",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({appIndex:e,fieldName:t,source:r,txnIndex:i}){this.appIndex=ve(e),this.fieldName=t,this.source=r,this.txnIndex=Oe(i)}getEncodingSchema(){return Fa.encodingSchema}toEncodingData(){return new Map([["app-index",this.appIndex],["field-name",this.fieldName],["source",this.source],["txn-index",this.txnIndex]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunSource: ${e}`);return new Fa({appIndex:e.get("app-index"),fieldName:e.get("field-name"),source:e.get("source"),txnIndex:e.get("txn-index")})}}class zi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"line",valueSchema:new O,omitEmpty:!0},{key:"pc",valueSchema:new O,omitEmpty:!0},{key:"stack",valueSchema:new Me(To.encodingSchema),omitEmpty:!0},{key:"error",valueSchema:new k(new Ce),omitEmpty:!0},{key:"scratch",valueSchema:new k(new Me(To.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({line:e,pc:t,stack:r,error:i,scratch:o}){this.line=Oe(e),this.pc=Oe(t),this.stack=r,this.error=i,this.scratch=o}getEncodingSchema(){return zi.encodingSchema}toEncodingData(){return new Map([["line",this.line],["pc",this.pc],["stack",this.stack.map(e=>e.toEncodingData())],["error",this.error],["scratch",typeof this.scratch<"u"?this.scratch.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunState: ${e}`);return new zi({line:e.get("line"),pc:e.get("pc"),stack:(e.get("stack")??[]).map(t=>To.fromEncodingData(t)),error:e.get("error"),scratch:typeof e.get("scratch")<"u"?e.get("scratch").map(t=>To.fromEncodingData(t)):void 0})}}class Da{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"disassembly",valueSchema:new Me(new Ce),omitEmpty:!0},{key:"app-call-messages",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"app-call-trace",valueSchema:new k(new Me(zi.encodingSchema)),omitEmpty:!0},{key:"budget-added",valueSchema:new k(new O),omitEmpty:!0},{key:"budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"global-delta",valueSchema:new k(new Me(Fs.encodingSchema)),omitEmpty:!0},{key:"local-deltas",valueSchema:new k(new Me(pl.encodingSchema)),omitEmpty:!0},{key:"logic-sig-disassembly",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"logic-sig-messages",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"logic-sig-trace",valueSchema:new k(new Me(zi.encodingSchema)),omitEmpty:!0},{key:"logs",valueSchema:new k(new Me(new Pe)),omitEmpty:!0})),this.encodingSchemaValue}constructor({disassembly:e,appCallMessages:t,appCallTrace:r,budgetAdded:i,budgetConsumed:o,globalDelta:s,localDeltas:a,logicSigDisassembly:l,logicSigMessages:c,logicSigTrace:d,logs:u}){this.disassembly=e,this.appCallMessages=t,this.appCallTrace=r,this.budgetAdded=typeof i>"u"?void 0:Oe(i),this.budgetConsumed=typeof o>"u"?void 0:Oe(o),this.globalDelta=s,this.localDeltas=a,this.logicSigDisassembly=l,this.logicSigMessages=c,this.logicSigTrace=d,this.logs=u}getEncodingSchema(){return Da.encodingSchema}toEncodingData(){return new Map([["disassembly",this.disassembly],["app-call-messages",this.appCallMessages],["app-call-trace",typeof this.appCallTrace<"u"?this.appCallTrace.map(e=>e.toEncodingData()):void 0],["budget-added",this.budgetAdded],["budget-consumed",this.budgetConsumed],["global-delta",typeof this.globalDelta<"u"?this.globalDelta.map(e=>e.toEncodingData()):void 0],["local-deltas",typeof this.localDeltas<"u"?this.localDeltas.map(e=>e.toEncodingData()):void 0],["logic-sig-disassembly",this.logicSigDisassembly],["logic-sig-messages",this.logicSigMessages],["logic-sig-trace",typeof this.logicSigTrace<"u"?this.logicSigTrace.map(e=>e.toEncodingData()):void 0],["logs",this.logs]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded DryrunTxnResult: ${e}`);return new Da({disassembly:e.get("disassembly"),appCallMessages:e.get("app-call-messages"),appCallTrace:typeof e.get("app-call-trace")<"u"?e.get("app-call-trace").map(t=>zi.fromEncodingData(t)):void 0,budgetAdded:e.get("budget-added"),budgetConsumed:e.get("budget-consumed"),globalDelta:typeof e.get("global-delta")<"u"?e.get("global-delta").map(t=>Fs.fromEncodingData(t)):void 0,localDeltas:typeof e.get("local-deltas")<"u"?e.get("local-deltas").map(t=>pl.fromEncodingData(t)):void 0,logicSigDisassembly:e.get("logic-sig-disassembly"),logicSigMessages:e.get("logic-sig-messages"),logicSigTrace:typeof e.get("logic-sig-trace")<"u"?e.get("logic-sig-trace").map(t=>zi.fromEncodingData(t)):void 0,logs:e.get("logs")})}}let RI=class wp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"message",valueSchema:new Ce,omitEmpty:!0},{key:"data",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,data:t}){this.message=e,this.data=t}getEncodingSchema(){return wp.encodingSchema}toEncodingData(){return new Map([["message",this.message],["data",typeof this.data<"u"?this.data.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ErrorResponse: ${e}`);return new wp({message:e.get("message"),data:typeof e.get("data")<"u"?Sn.fromEncodingData(e.get("data")):void 0})}},xp=class vp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"action",valueSchema:new O,omitEmpty:!0},{key:"bytes",valueSchema:new k(new Ce),omitEmpty:!0},{key:"uint",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({action:e,bytes:t,uint:r}){this.action=Oe(e),this.bytes=t,this.uint=typeof r>"u"?void 0:ve(r)}getEncodingSchema(){return vp.encodingSchema}toEncodingData(){return new Map([["action",this.action],["bytes",this.bytes],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${e}`);return new vp({action:e.get("action"),bytes:e.get("bytes"),uint:e.get("uint")})}},Fs=class Sp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Ce,omitEmpty:!0},{key:"value",valueSchema:xp.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=e,this.value=t}getEncodingSchema(){return Sp.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDeltaKeyValue: ${e}`);return new Sp({key:e.get("key"),value:xp.fromEncodingData(e.get("value")??new Map)})}},BI=class bp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"alloc",valueSchema:new Me(Ta.encodingSchema),omitEmpty:!0},{key:"fees",valueSchema:new Ce,omitEmpty:!0},{key:"id",valueSchema:new Ce,omitEmpty:!0},{key:"network",valueSchema:new Ce,omitEmpty:!0},{key:"proto",valueSchema:new Ce,omitEmpty:!0},{key:"rwd",valueSchema:new Ce,omitEmpty:!0},{key:"timestamp",valueSchema:new O,omitEmpty:!0},{key:"comment",valueSchema:new k(new Ce),omitEmpty:!0},{key:"devmode",valueSchema:new k(new gt),omitEmpty:!0})),this.encodingSchemaValue}constructor({alloc:e,fees:t,id:r,network:i,proto:o,rwd:s,timestamp:a,comment:l,devmode:c}){this.alloc=e,this.fees=t,this.id=r,this.network=i,this.proto=o,this.rwd=s,this.timestamp=Oe(a),this.comment=l,this.devmode=c}getEncodingSchema(){return bp.encodingSchema}toEncodingData(){return new Map([["alloc",this.alloc.map(e=>e.toEncodingData())],["fees",this.fees],["id",this.id],["network",this.network],["proto",this.proto],["rwd",this.rwd],["timestamp",this.timestamp],["comment",this.comment],["devmode",this.devmode]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Genesis: ${e}`);return new bp({alloc:(e.get("alloc")??[]).map(t=>Ta.fromEncodingData(t)),fees:e.get("fees"),id:e.get("id"),network:e.get("network"),proto:e.get("proto"),rwd:e.get("rwd"),timestamp:e.get("timestamp"),comment:e.get("comment"),devmode:e.get("devmode")})}};class Ta{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"addr",valueSchema:new Ce,omitEmpty:!0},{key:"comment",valueSchema:new Ce,omitEmpty:!0},{key:"state",valueSchema:Sn.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({addr:e,comment:t,state:r}){this.addr=e,this.comment=t,this.state=r}getEncodingSchema(){return Ta.encodingSchema}toEncodingData(){return new Map([["addr",this.addr],["comment",this.comment],["state",this.state.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded GenesisAllocation: ${e}`);return new Ta({addr:e.get("addr"),comment:e.get("comment"),state:Sn.fromEncodingData(e.get("state")??new Map)})}}class El{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"offset",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({offset:e}){this.offset=Oe(e)}getEncodingSchema(){return El.encodingSchema}toEncodingData(){return new Map([["offset",this.offset]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded GetBlockTimeStampOffsetResponse: ${e}`);return new El({offset:e.get("offset")})}}class Al{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"round",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({round:e}){this.round=ve(e)}getEncodingSchema(){return Al.encodingSchema}toEncodingData(){return new Map([["round",this.round]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded GetSyncRoundResponse: ${e}`);return new Al({round:e.get("round")})}}class Ma{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"Delta",valueSchema:Si.encodingSchema,omitEmpty:!0},{key:"Ids",valueSchema:new Me(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({delta:e,ids:t}){this.delta=e,this.ids=t}getEncodingSchema(){return Ma.encodingSchema}toEncodingData(){return new Map([["Delta",this.delta.toEncodingData()],["Ids",this.ids]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LedgerStateDeltaForTransactionGroup: ${e}`);return new Ma({delta:Si.fromEncodingData(e.get("Delta")??new Map),ids:e.get("Ids")})}}let gx=class Ep{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"index",valueSchema:new O,omitEmpty:!0},{key:"proof",valueSchema:new Pe,omitEmpty:!0},{key:"treedepth",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({index:e,proof:t,treedepth:r}){this.index=Oe(e),this.proof=typeof t=="string"?Ge(t):t,this.treedepth=Oe(r)}getEncodingSchema(){return Ep.encodingSchema}toEncodingData(){return new Map([["index",this.index],["proof",this.proof],["treedepth",this.treedepth]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LightBlockHeaderProof: ${e}`);return new Ep({index:e.get("index"),proof:e.get("proof"),treedepth:e.get("treedepth")})}};class Ra{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"catchup-time",valueSchema:new O,omitEmpty:!0},{key:"last-round",valueSchema:new O,omitEmpty:!0},{key:"last-version",valueSchema:new Ce,omitEmpty:!0},{key:"next-version",valueSchema:new Ce,omitEmpty:!0},{key:"next-version-round",valueSchema:new O,omitEmpty:!0},{key:"next-version-supported",valueSchema:new gt,omitEmpty:!0},{key:"stopped-at-unsupported-round",valueSchema:new gt,omitEmpty:!0},{key:"time-since-last-round",valueSchema:new O,omitEmpty:!0},{key:"catchpoint",valueSchema:new k(new Ce),omitEmpty:!0},{key:"catchpoint-acquired-blocks",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-processed-accounts",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-processed-kvs",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-total-accounts",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-total-blocks",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-total-kvs",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-verified-accounts",valueSchema:new k(new O),omitEmpty:!0},{key:"catchpoint-verified-kvs",valueSchema:new k(new O),omitEmpty:!0},{key:"last-catchpoint",valueSchema:new k(new Ce),omitEmpty:!0},{key:"upgrade-delay",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-next-protocol-vote-before",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-no-votes",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-node-vote",valueSchema:new k(new gt),omitEmpty:!0},{key:"upgrade-vote-rounds",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-votes",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-votes-required",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-yes-votes",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({catchupTime:e,lastRound:t,lastVersion:r,nextVersion:i,nextVersionRound:o,nextVersionSupported:s,stoppedAtUnsupportedRound:a,timeSinceLastRound:l,catchpoint:c,catchpointAcquiredBlocks:d,catchpointProcessedAccounts:u,catchpointProcessedKvs:m,catchpointTotalAccounts:h,catchpointTotalBlocks:x,catchpointTotalKvs:A,catchpointVerifiedAccounts:v,catchpointVerifiedKvs:F,lastCatchpoint:w,upgradeDelay:C,upgradeNextProtocolVoteBefore:M,upgradeNoVotes:N,upgradeNodeVote:b,upgradeVoteRounds:j,upgradeVotes:p,upgradeVotesRequired:E,upgradeYesVotes:S}){this.catchupTime=ve(e),this.lastRound=ve(t),this.lastVersion=r,this.nextVersion=i,this.nextVersionRound=ve(o),this.nextVersionSupported=s,this.stoppedAtUnsupportedRound=a,this.timeSinceLastRound=ve(l),this.catchpoint=c,this.catchpointAcquiredBlocks=typeof d>"u"?void 0:Oe(d),this.catchpointProcessedAccounts=typeof u>"u"?void 0:Oe(u),this.catchpointProcessedKvs=typeof m>"u"?void 0:Oe(m),this.catchpointTotalAccounts=typeof h>"u"?void 0:Oe(h),this.catchpointTotalBlocks=typeof x>"u"?void 0:Oe(x),this.catchpointTotalKvs=typeof A>"u"?void 0:Oe(A),this.catchpointVerifiedAccounts=typeof v>"u"?void 0:Oe(v),this.catchpointVerifiedKvs=typeof F>"u"?void 0:Oe(F),this.lastCatchpoint=w,this.upgradeDelay=typeof C>"u"?void 0:ve(C),this.upgradeNextProtocolVoteBefore=typeof M>"u"?void 0:ve(M),this.upgradeNoVotes=typeof N>"u"?void 0:Oe(N),this.upgradeNodeVote=b,this.upgradeVoteRounds=typeof j>"u"?void 0:Oe(j),this.upgradeVotes=typeof p>"u"?void 0:Oe(p),this.upgradeVotesRequired=typeof E>"u"?void 0:Oe(E),this.upgradeYesVotes=typeof S>"u"?void 0:Oe(S)}getEncodingSchema(){return Ra.encodingSchema}toEncodingData(){return new Map([["catchup-time",this.catchupTime],["last-round",this.lastRound],["last-version",this.lastVersion],["next-version",this.nextVersion],["next-version-round",this.nextVersionRound],["next-version-supported",this.nextVersionSupported],["stopped-at-unsupported-round",this.stoppedAtUnsupportedRound],["time-since-last-round",this.timeSinceLastRound],["catchpoint",this.catchpoint],["catchpoint-acquired-blocks",this.catchpointAcquiredBlocks],["catchpoint-processed-accounts",this.catchpointProcessedAccounts],["catchpoint-processed-kvs",this.catchpointProcessedKvs],["catchpoint-total-accounts",this.catchpointTotalAccounts],["catchpoint-total-blocks",this.catchpointTotalBlocks],["catchpoint-total-kvs",this.catchpointTotalKvs],["catchpoint-verified-accounts",this.catchpointVerifiedAccounts],["catchpoint-verified-kvs",this.catchpointVerifiedKvs],["last-catchpoint",this.lastCatchpoint],["upgrade-delay",this.upgradeDelay],["upgrade-next-protocol-vote-before",this.upgradeNextProtocolVoteBefore],["upgrade-no-votes",this.upgradeNoVotes],["upgrade-node-vote",this.upgradeNodeVote],["upgrade-vote-rounds",this.upgradeVoteRounds],["upgrade-votes",this.upgradeVotes],["upgrade-votes-required",this.upgradeVotesRequired],["upgrade-yes-votes",this.upgradeYesVotes]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded NodeStatusResponse: ${e}`);return new Ra({catchupTime:e.get("catchup-time"),lastRound:e.get("last-round"),lastVersion:e.get("last-version"),nextVersion:e.get("next-version"),nextVersionRound:e.get("next-version-round"),nextVersionSupported:e.get("next-version-supported"),stoppedAtUnsupportedRound:e.get("stopped-at-unsupported-round"),timeSinceLastRound:e.get("time-since-last-round"),catchpoint:e.get("catchpoint"),catchpointAcquiredBlocks:e.get("catchpoint-acquired-blocks"),catchpointProcessedAccounts:e.get("catchpoint-processed-accounts"),catchpointProcessedKvs:e.get("catchpoint-processed-kvs"),catchpointTotalAccounts:e.get("catchpoint-total-accounts"),catchpointTotalBlocks:e.get("catchpoint-total-blocks"),catchpointTotalKvs:e.get("catchpoint-total-kvs"),catchpointVerifiedAccounts:e.get("catchpoint-verified-accounts"),catchpointVerifiedKvs:e.get("catchpoint-verified-kvs"),lastCatchpoint:e.get("last-catchpoint"),upgradeDelay:e.get("upgrade-delay"),upgradeNextProtocolVoteBefore:e.get("upgrade-next-protocol-vote-before"),upgradeNoVotes:e.get("upgrade-no-votes"),upgradeNodeVote:e.get("upgrade-node-vote"),upgradeVoteRounds:e.get("upgrade-vote-rounds"),upgradeVotes:e.get("upgrade-votes"),upgradeVotesRequired:e.get("upgrade-votes-required"),upgradeYesVotes:e.get("upgrade-yes-votes")})}}class hi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"pool-error",valueSchema:new Ce,omitEmpty:!0},{key:"txn",valueSchema:jt.encodingSchema,omitEmpty:!0},{key:"application-index",valueSchema:new k(new O),omitEmpty:!0},{key:"asset-closing-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"asset-index",valueSchema:new k(new O),omitEmpty:!0},{key:"close-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"closing-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"confirmed-round",valueSchema:new k(new O),omitEmpty:!0},{key:"global-state-delta",valueSchema:new k(new Me(Fs.encodingSchema)),omitEmpty:!0},{key:"inner-txns",valueSchema:new k(new Me(hi.encodingSchema)),omitEmpty:!0},{key:"local-state-delta",valueSchema:new k(new Me(pl.encodingSchema)),omitEmpty:!0},{key:"logs",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"receiver-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"sender-rewards",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({poolError:e,txn:t,applicationIndex:r,assetClosingAmount:i,assetIndex:o,closeRewards:s,closingAmount:a,confirmedRound:l,globalStateDelta:c,innerTxns:d,localStateDelta:u,logs:m,receiverRewards:h,senderRewards:x}){this.poolError=e,this.txn=t,this.applicationIndex=typeof r>"u"?void 0:ve(r),this.assetClosingAmount=typeof i>"u"?void 0:ve(i),this.assetIndex=typeof o>"u"?void 0:ve(o),this.closeRewards=typeof s>"u"?void 0:ve(s),this.closingAmount=typeof a>"u"?void 0:ve(a),this.confirmedRound=typeof l>"u"?void 0:ve(l),this.globalStateDelta=c,this.innerTxns=d,this.localStateDelta=u,this.logs=m,this.receiverRewards=typeof h>"u"?void 0:ve(h),this.senderRewards=typeof x>"u"?void 0:ve(x)}getEncodingSchema(){return hi.encodingSchema}toEncodingData(){return new Map([["pool-error",this.poolError],["txn",this.txn.toEncodingData()],["application-index",this.applicationIndex],["asset-closing-amount",this.assetClosingAmount],["asset-index",this.assetIndex],["close-rewards",this.closeRewards],["closing-amount",this.closingAmount],["confirmed-round",this.confirmedRound],["global-state-delta",typeof this.globalStateDelta<"u"?this.globalStateDelta.map(e=>e.toEncodingData()):void 0],["inner-txns",typeof this.innerTxns<"u"?this.innerTxns.map(e=>e.toEncodingData()):void 0],["local-state-delta",typeof this.localStateDelta<"u"?this.localStateDelta.map(e=>e.toEncodingData()):void 0],["logs",this.logs],["receiver-rewards",this.receiverRewards],["sender-rewards",this.senderRewards]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded PendingTransactionResponse: ${e}`);return new hi({poolError:e.get("pool-error"),txn:jt.fromEncodingData(e.get("txn")??new Map),applicationIndex:e.get("application-index"),assetClosingAmount:e.get("asset-closing-amount"),assetIndex:e.get("asset-index"),closeRewards:e.get("close-rewards"),closingAmount:e.get("closing-amount"),confirmedRound:e.get("confirmed-round"),globalStateDelta:typeof e.get("global-state-delta")<"u"?e.get("global-state-delta").map(t=>Fs.fromEncodingData(t)):void 0,innerTxns:typeof e.get("inner-txns")<"u"?e.get("inner-txns").map(t=>hi.fromEncodingData(t)):void 0,localStateDelta:typeof e.get("local-state-delta")<"u"?e.get("local-state-delta").map(t=>pl.fromEncodingData(t)):void 0,logs:e.get("logs"),receiverRewards:e.get("receiver-rewards"),senderRewards:e.get("sender-rewards")})}}class Ba{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"top-transactions",valueSchema:new Me(jt.encodingSchema),omitEmpty:!0},{key:"total-transactions",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({topTransactions:e,totalTransactions:t}){this.topTransactions=e,this.totalTransactions=Oe(t)}getEncodingSchema(){return Ba.encodingSchema}toEncodingData(){return new Map([["top-transactions",this.topTransactions.map(e=>e.toEncodingData())],["total-transactions",this.totalTransactions]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded PendingTransactionsResponse: ${e}`);return new Ba({topTransactions:(e.get("top-transactions")??[]).map(t=>jt.fromEncodingData(t)),totalTransactions:e.get("total-transactions")})}}class Il{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txId",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({txid:e}){this.txid=e}getEncodingSchema(){return Il.encodingSchema}toEncodingData(){return new Map([["txId",this.txid]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded PostTransactionsResponse: ${e}`);return new Il({txid:e.get("txId")})}}class Na{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"new-value",valueSchema:vr.encodingSchema,omitEmpty:!0},{key:"slot",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({newValue:e,slot:t}){this.newValue=e,this.slot=Oe(t)}getEncodingSchema(){return Na.encodingSchema}toEncodingData(){return new Map([["new-value",this.newValue.toEncodingData()],["slot",this.slot]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ScratchChange: ${e}`);return new Na({newValue:vr.fromEncodingData(e.get("new-value")??new Map),slot:e.get("slot")})}}class Pa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app-initial-states",valueSchema:new k(new Me(Sa.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({appInitialStates:e}){this.appInitialStates=e}getEncodingSchema(){return Pa.encodingSchema}toEncodingData(){return new Map([["app-initial-states",typeof this.appInitialStates<"u"?this.appInitialStates.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateInitialStates: ${e}`);return new Pa({appInitialStates:typeof e.get("app-initial-states")<"u"?e.get("app-initial-states").map(t=>Sa.fromEncodingData(t)):void 0})}}class Oa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txn-groups",valueSchema:new Me(ro.encodingSchema),omitEmpty:!0},{key:"allow-empty-signatures",valueSchema:new k(new gt),omitEmpty:!0},{key:"allow-more-logging",valueSchema:new k(new gt),omitEmpty:!0},{key:"allow-unnamed-resources",valueSchema:new k(new gt),omitEmpty:!0},{key:"exec-trace-config",valueSchema:new k(io.encodingSchema),omitEmpty:!0},{key:"extra-opcode-budget",valueSchema:new k(new O),omitEmpty:!0},{key:"fix-signers",valueSchema:new k(new gt),omitEmpty:!0},{key:"round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({txnGroups:e,allowEmptySignatures:t,allowMoreLogging:r,allowUnnamedResources:i,execTraceConfig:o,extraOpcodeBudget:s,fixSigners:a,round:l}){this.txnGroups=e,this.allowEmptySignatures=t,this.allowMoreLogging=r,this.allowUnnamedResources=i,this.execTraceConfig=o,this.extraOpcodeBudget=typeof s>"u"?void 0:Oe(s),this.fixSigners=a,this.round=typeof l>"u"?void 0:ve(l)}getEncodingSchema(){return Oa.encodingSchema}toEncodingData(){return new Map([["txn-groups",this.txnGroups.map(e=>e.toEncodingData())],["allow-empty-signatures",this.allowEmptySignatures],["allow-more-logging",this.allowMoreLogging],["allow-unnamed-resources",this.allowUnnamedResources],["exec-trace-config",typeof this.execTraceConfig<"u"?this.execTraceConfig.toEncodingData():void 0],["extra-opcode-budget",this.extraOpcodeBudget],["fix-signers",this.fixSigners],["round",this.round]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateRequest: ${e}`);return new Oa({txnGroups:(e.get("txn-groups")??[]).map(t=>ro.fromEncodingData(t)),allowEmptySignatures:e.get("allow-empty-signatures"),allowMoreLogging:e.get("allow-more-logging"),allowUnnamedResources:e.get("allow-unnamed-resources"),execTraceConfig:typeof e.get("exec-trace-config")<"u"?io.fromEncodingData(e.get("exec-trace-config")):void 0,extraOpcodeBudget:e.get("extra-opcode-budget"),fixSigners:e.get("fix-signers"),round:e.get("round")})}}class ro{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txns",valueSchema:new Me(jt.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({txns:e}){this.txns=e}getEncodingSchema(){return ro.encodingSchema}toEncodingData(){return new Map([["txns",this.txns.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateRequestTransactionGroup: ${e}`);return new ro({txns:(e.get("txns")??[]).map(t=>jt.fromEncodingData(t))})}}class kl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"last-round",valueSchema:new O,omitEmpty:!0},{key:"txn-groups",valueSchema:new Me(La.encodingSchema),omitEmpty:!0},{key:"version",valueSchema:new O,omitEmpty:!0},{key:"eval-overrides",valueSchema:new k($a.encodingSchema),omitEmpty:!0},{key:"exec-trace-config",valueSchema:new k(io.encodingSchema),omitEmpty:!0},{key:"initial-states",valueSchema:new k(Pa.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({lastRound:e,txnGroups:t,version:r,evalOverrides:i,execTraceConfig:o,initialStates:s}){this.lastRound=ve(e),this.txnGroups=t,this.version=Oe(r),this.evalOverrides=i,this.execTraceConfig=o,this.initialStates=s}getEncodingSchema(){return kl.encodingSchema}toEncodingData(){return new Map([["last-round",this.lastRound],["txn-groups",this.txnGroups.map(e=>e.toEncodingData())],["version",this.version],["eval-overrides",typeof this.evalOverrides<"u"?this.evalOverrides.toEncodingData():void 0],["exec-trace-config",typeof this.execTraceConfig<"u"?this.execTraceConfig.toEncodingData():void 0],["initial-states",typeof this.initialStates<"u"?this.initialStates.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateResponse: ${e}`);return new kl({lastRound:e.get("last-round"),txnGroups:(e.get("txn-groups")??[]).map(t=>La.fromEncodingData(t)),version:e.get("version"),evalOverrides:typeof e.get("eval-overrides")<"u"?$a.fromEncodingData(e.get("eval-overrides")):void 0,execTraceConfig:typeof e.get("exec-trace-config")<"u"?io.fromEncodingData(e.get("exec-trace-config")):void 0,initialStates:typeof e.get("initial-states")<"u"?Pa.fromEncodingData(e.get("initial-states")):void 0})}}class io{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"enable",valueSchema:new k(new gt),omitEmpty:!0},{key:"scratch-change",valueSchema:new k(new gt),omitEmpty:!0},{key:"stack-change",valueSchema:new k(new gt),omitEmpty:!0},{key:"state-change",valueSchema:new k(new gt),omitEmpty:!0})),this.encodingSchemaValue}constructor({enable:e,scratchChange:t,stackChange:r,stateChange:i}){this.enable=e,this.scratchChange=t,this.stackChange=r,this.stateChange=i}getEncodingSchema(){return io.encodingSchema}toEncodingData(){return new Map([["enable",this.enable],["scratch-change",this.scratchChange],["stack-change",this.stackChange],["state-change",this.stateChange]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateTraceConfig: ${e}`);return new io({enable:e.get("enable"),scratchChange:e.get("scratch-change"),stackChange:e.get("stack-change"),stateChange:e.get("state-change")})}}class La{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txn-results",valueSchema:new Me(Va.encodingSchema),omitEmpty:!0},{key:"app-budget-added",valueSchema:new k(new O),omitEmpty:!0},{key:"app-budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"failed-at",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"failure-message",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unnamed-resources-accessed",valueSchema:new k(oo.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({txnResults:e,appBudgetAdded:t,appBudgetConsumed:r,failedAt:i,failureMessage:o,unnamedResourcesAccessed:s}){this.txnResults=e,this.appBudgetAdded=typeof t>"u"?void 0:Oe(t),this.appBudgetConsumed=typeof r>"u"?void 0:Oe(r),this.failedAt=typeof i>"u"?void 0:i.map(Oe),this.failureMessage=o,this.unnamedResourcesAccessed=s}getEncodingSchema(){return La.encodingSchema}toEncodingData(){return new Map([["txn-results",this.txnResults.map(e=>e.toEncodingData())],["app-budget-added",this.appBudgetAdded],["app-budget-consumed",this.appBudgetConsumed],["failed-at",this.failedAt],["failure-message",this.failureMessage],["unnamed-resources-accessed",typeof this.unnamedResourcesAccessed<"u"?this.unnamedResourcesAccessed.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateTransactionGroupResult: ${e}`);return new La({txnResults:(e.get("txn-results")??[]).map(t=>Va.fromEncodingData(t)),appBudgetAdded:e.get("app-budget-added"),appBudgetConsumed:e.get("app-budget-consumed"),failedAt:e.get("failed-at"),failureMessage:e.get("failure-message"),unnamedResourcesAccessed:typeof e.get("unnamed-resources-accessed")<"u"?oo.fromEncodingData(e.get("unnamed-resources-accessed")):void 0})}}class Va{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"txn-result",valueSchema:hi.encodingSchema,omitEmpty:!0},{key:"app-budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"exec-trace",valueSchema:new k(Hi.encodingSchema),omitEmpty:!0},{key:"fixed-signer",valueSchema:new k(new Ce),omitEmpty:!0},{key:"logic-sig-budget-consumed",valueSchema:new k(new O),omitEmpty:!0},{key:"unnamed-resources-accessed",valueSchema:new k(oo.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({txnResult:e,appBudgetConsumed:t,execTrace:r,fixedSigner:i,logicSigBudgetConsumed:o,unnamedResourcesAccessed:s}){this.txnResult=e,this.appBudgetConsumed=typeof t>"u"?void 0:Oe(t),this.execTrace=r,this.fixedSigner=typeof i=="string"?ze.fromString(i):i,this.logicSigBudgetConsumed=typeof o>"u"?void 0:Oe(o),this.unnamedResourcesAccessed=s}getEncodingSchema(){return Va.encodingSchema}toEncodingData(){return new Map([["txn-result",this.txnResult.toEncodingData()],["app-budget-consumed",this.appBudgetConsumed],["exec-trace",typeof this.execTrace<"u"?this.execTrace.toEncodingData():void 0],["fixed-signer",typeof this.fixedSigner<"u"?this.fixedSigner.toString():void 0],["logic-sig-budget-consumed",this.logicSigBudgetConsumed],["unnamed-resources-accessed",typeof this.unnamedResourcesAccessed<"u"?this.unnamedResourcesAccessed.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateTransactionResult: ${e}`);return new Va({txnResult:hi.fromEncodingData(e.get("txn-result")??new Map),appBudgetConsumed:e.get("app-budget-consumed"),execTrace:typeof e.get("exec-trace")<"u"?Hi.fromEncodingData(e.get("exec-trace")):void 0,fixedSigner:e.get("fixed-signer"),logicSigBudgetConsumed:e.get("logic-sig-budget-consumed"),unnamedResourcesAccessed:typeof e.get("unnamed-resources-accessed")<"u"?oo.fromEncodingData(e.get("unnamed-resources-accessed")):void 0})}}class oo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"app-locals",valueSchema:new k(new Me(ba.encodingSchema)),omitEmpty:!0},{key:"apps",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"asset-holdings",valueSchema:new k(new Me(Ia.encodingSchema)),omitEmpty:!0},{key:"assets",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"boxes",valueSchema:new k(new Me(gp.encodingSchema)),omitEmpty:!0},{key:"extra-box-refs",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({accounts:e,appLocals:t,apps:r,assetHoldings:i,assets:o,boxes:s,extraBoxRefs:a}){this.accounts=typeof e<"u"?e.map(l=>typeof l=="string"?ze.fromString(l):l):void 0,this.appLocals=t,this.apps=typeof r>"u"?void 0:r.map(ve),this.assetHoldings=i,this.assets=typeof o>"u"?void 0:o.map(ve),this.boxes=s,this.extraBoxRefs=typeof a>"u"?void 0:Oe(a)}getEncodingSchema(){return oo.encodingSchema}toEncodingData(){return new Map([["accounts",typeof this.accounts<"u"?this.accounts.map(e=>e.toString()):void 0],["app-locals",typeof this.appLocals<"u"?this.appLocals.map(e=>e.toEncodingData()):void 0],["apps",this.apps],["asset-holdings",typeof this.assetHoldings<"u"?this.assetHoldings.map(e=>e.toEncodingData()):void 0],["assets",this.assets],["boxes",typeof this.boxes<"u"?this.boxes.map(e=>e.toEncodingData()):void 0],["extra-box-refs",this.extraBoxRefs]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulateUnnamedResourcesAccessed: ${e}`);return new oo({accounts:e.get("accounts"),appLocals:typeof e.get("app-locals")<"u"?e.get("app-locals").map(t=>ba.fromEncodingData(t)):void 0,apps:e.get("apps"),assetHoldings:typeof e.get("asset-holdings")<"u"?e.get("asset-holdings").map(t=>Ia.fromEncodingData(t)):void 0,assets:e.get("assets"),boxes:typeof e.get("boxes")<"u"?e.get("boxes").map(t=>gp.fromEncodingData(t)):void 0,extraBoxRefs:e.get("extra-box-refs")})}}class $a{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"allow-empty-signatures",valueSchema:new k(new gt),omitEmpty:!0},{key:"allow-unnamed-resources",valueSchema:new k(new gt),omitEmpty:!0},{key:"extra-opcode-budget",valueSchema:new k(new O),omitEmpty:!0},{key:"fix-signers",valueSchema:new k(new gt),omitEmpty:!0},{key:"max-log-calls",valueSchema:new k(new O),omitEmpty:!0},{key:"max-log-size",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({allowEmptySignatures:e,allowUnnamedResources:t,extraOpcodeBudget:r,fixSigners:i,maxLogCalls:o,maxLogSize:s}){this.allowEmptySignatures=e,this.allowUnnamedResources=t,this.extraOpcodeBudget=typeof r>"u"?void 0:Oe(r),this.fixSigners=i,this.maxLogCalls=typeof o>"u"?void 0:Oe(o),this.maxLogSize=typeof s>"u"?void 0:Oe(s)}getEncodingSchema(){return $a.encodingSchema}toEncodingData(){return new Map([["allow-empty-signatures",this.allowEmptySignatures],["allow-unnamed-resources",this.allowUnnamedResources],["extra-opcode-budget",this.extraOpcodeBudget],["fix-signers",this.fixSigners],["max-log-calls",this.maxLogCalls],["max-log-size",this.maxLogSize]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulationEvalOverrides: ${e}`);return new $a({allowEmptySignatures:e.get("allow-empty-signatures"),allowUnnamedResources:e.get("allow-unnamed-resources"),extraOpcodeBudget:e.get("extra-opcode-budget"),fixSigners:e.get("fix-signers"),maxLogCalls:e.get("max-log-calls"),maxLogSize:e.get("max-log-size")})}}class Ur{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"pc",valueSchema:new O,omitEmpty:!0},{key:"scratch-changes",valueSchema:new k(new Me(Na.encodingSchema)),omitEmpty:!0},{key:"spawned-inners",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"stack-additions",valueSchema:new k(new Me(vr.encodingSchema)),omitEmpty:!0},{key:"stack-pop-count",valueSchema:new k(new O),omitEmpty:!0},{key:"state-changes",valueSchema:new k(new Me(Aa.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({pc:e,scratchChanges:t,spawnedInners:r,stackAdditions:i,stackPopCount:o,stateChanges:s}){this.pc=Oe(e),this.scratchChanges=t,this.spawnedInners=typeof r>"u"?void 0:r.map(Oe),this.stackAdditions=i,this.stackPopCount=typeof o>"u"?void 0:Oe(o),this.stateChanges=s}getEncodingSchema(){return Ur.encodingSchema}toEncodingData(){return new Map([["pc",this.pc],["scratch-changes",typeof this.scratchChanges<"u"?this.scratchChanges.map(e=>e.toEncodingData()):void 0],["spawned-inners",this.spawnedInners],["stack-additions",typeof this.stackAdditions<"u"?this.stackAdditions.map(e=>e.toEncodingData()):void 0],["stack-pop-count",this.stackPopCount],["state-changes",typeof this.stateChanges<"u"?this.stateChanges.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulationOpcodeTraceUnit: ${e}`);return new Ur({pc:e.get("pc"),scratchChanges:typeof e.get("scratch-changes")<"u"?e.get("scratch-changes").map(t=>Na.fromEncodingData(t)):void 0,spawnedInners:e.get("spawned-inners"),stackAdditions:typeof e.get("stack-additions")<"u"?e.get("stack-additions").map(t=>vr.fromEncodingData(t)):void 0,stackPopCount:e.get("stack-pop-count"),stateChanges:typeof e.get("state-changes")<"u"?e.get("state-changes").map(t=>Aa.fromEncodingData(t)):void 0})}}class Hi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"approval-program-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"approval-program-trace",valueSchema:new k(new Me(Ur.encodingSchema)),omitEmpty:!0},{key:"clear-state-program-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"clear-state-program-trace",valueSchema:new k(new Me(Ur.encodingSchema)),omitEmpty:!0},{key:"clear-state-rollback",valueSchema:new k(new gt),omitEmpty:!0},{key:"clear-state-rollback-error",valueSchema:new k(new Ce),omitEmpty:!0},{key:"inner-trace",valueSchema:new k(new Me(Hi.encodingSchema)),omitEmpty:!0},{key:"logic-sig-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"logic-sig-trace",valueSchema:new k(new Me(Ur.encodingSchema)),omitEmpty:!0})),this.encodingSchemaValue}constructor({approvalProgramHash:e,approvalProgramTrace:t,clearStateProgramHash:r,clearStateProgramTrace:i,clearStateRollback:o,clearStateRollbackError:s,innerTrace:a,logicSigHash:l,logicSigTrace:c}){this.approvalProgramHash=typeof e=="string"?Ge(e):e,this.approvalProgramTrace=t,this.clearStateProgramHash=typeof r=="string"?Ge(r):r,this.clearStateProgramTrace=i,this.clearStateRollback=o,this.clearStateRollbackError=s,this.innerTrace=a,this.logicSigHash=typeof l=="string"?Ge(l):l,this.logicSigTrace=c}getEncodingSchema(){return Hi.encodingSchema}toEncodingData(){return new Map([["approval-program-hash",this.approvalProgramHash],["approval-program-trace",typeof this.approvalProgramTrace<"u"?this.approvalProgramTrace.map(e=>e.toEncodingData()):void 0],["clear-state-program-hash",this.clearStateProgramHash],["clear-state-program-trace",typeof this.clearStateProgramTrace<"u"?this.clearStateProgramTrace.map(e=>e.toEncodingData()):void 0],["clear-state-rollback",this.clearStateRollback],["clear-state-rollback-error",this.clearStateRollbackError],["inner-trace",typeof this.innerTrace<"u"?this.innerTrace.map(e=>e.toEncodingData()):void 0],["logic-sig-hash",this.logicSigHash],["logic-sig-trace",typeof this.logicSigTrace<"u"?this.logicSigTrace.map(e=>e.toEncodingData()):void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SimulationTransactionExecTrace: ${e}`);return new Hi({approvalProgramHash:e.get("approval-program-hash"),approvalProgramTrace:typeof e.get("approval-program-trace")<"u"?e.get("approval-program-trace").map(t=>Ur.fromEncodingData(t)):void 0,clearStateProgramHash:e.get("clear-state-program-hash"),clearStateProgramTrace:typeof e.get("clear-state-program-trace")<"u"?e.get("clear-state-program-trace").map(t=>Ur.fromEncodingData(t)):void 0,clearStateRollback:e.get("clear-state-rollback"),clearStateRollbackError:e.get("clear-state-rollback-error"),innerTrace:typeof e.get("inner-trace")<"u"?e.get("inner-trace").map(t=>Hi.fromEncodingData(t)):void 0,logicSigHash:e.get("logic-sig-hash"),logicSigTrace:typeof e.get("logic-sig-trace")<"u"?e.get("logic-sig-trace").map(t=>Ur.fromEncodingData(t)):void 0})}}let mx=class Ap{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"Message",valueSchema:_a.encodingSchema,omitEmpty:!0},{key:"StateProof",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,stateproof:t}){this.message=e,this.stateproof=typeof t=="string"?Ge(t):t}getEncodingSchema(){return Ap.encodingSchema}toEncodingData(){return new Map([["Message",this.message.toEncodingData()],["StateProof",this.stateproof]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProof: ${e}`);return new Ap({message:_a.fromEncodingData(e.get("Message")??new Map),stateproof:e.get("StateProof")})}};class _a{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"BlockHeadersCommitment",valueSchema:new Pe,omitEmpty:!0},{key:"FirstAttestedRound",valueSchema:new O,omitEmpty:!0},{key:"LastAttestedRound",valueSchema:new O,omitEmpty:!0},{key:"LnProvenWeight",valueSchema:new O,omitEmpty:!0},{key:"VotersCommitment",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({blockheaderscommitment:e,firstattestedround:t,lastattestedround:r,lnprovenweight:i,voterscommitment:o}){this.blockheaderscommitment=typeof e=="string"?Ge(e):e,this.firstattestedround=ve(t),this.lastattestedround=ve(r),this.lnprovenweight=ve(i),this.voterscommitment=typeof o=="string"?Ge(o):o}getEncodingSchema(){return _a.encodingSchema}toEncodingData(){return new Map([["BlockHeadersCommitment",this.blockheaderscommitment],["FirstAttestedRound",this.firstattestedround],["LastAttestedRound",this.lastattestedround],["LnProvenWeight",this.lnprovenweight],["VotersCommitment",this.voterscommitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofMessage: ${e}`);return new _a({blockheaderscommitment:e.get("BlockHeadersCommitment"),firstattestedround:e.get("FirstAttestedRound"),lastattestedround:e.get("LastAttestedRound"),lnprovenweight:e.get("LnProvenWeight"),voterscommitment:e.get("VotersCommitment")})}}class Cl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current_round",valueSchema:new O,omitEmpty:!0},{key:"online-money",valueSchema:new O,omitEmpty:!0},{key:"total-money",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,onlineMoney:t,totalMoney:r}){this.currentRound=ve(e),this.onlineMoney=ve(t),this.totalMoney=ve(r)}getEncodingSchema(){return Cl.encodingSchema}toEncodingData(){return new Map([["current_round",this.currentRound],["online-money",this.onlineMoney],["total-money",this.totalMoney]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded SupplyResponse: ${e}`);return new Cl({currentRound:e.get("current_round"),onlineMoney:e.get("online-money"),totalMoney:e.get("total-money")})}}let Fl=class Ip{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"value",valueSchema:To.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=typeof e=="string"?Ge(e):e,this.value=t}getEncodingSchema(){return Ip.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealKeyValue: ${e}`);return new Ip({key:e.get("key"),value:To.fromEncodingData(e.get("value")??new Map)})}},To=class kp{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"bytes",valueSchema:new Pe,omitEmpty:!0},{key:"type",valueSchema:new O,omitEmpty:!0},{key:"uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({bytes:e,type:t,uint:r}){this.bytes=typeof e=="string"?Ge(e):e,this.type=Oe(t),this.uint=ve(r)}getEncodingSchema(){return kp.encodingSchema}toEncodingData(){return new Map([["bytes",this.bytes],["type",this.type],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealValue: ${e}`);return new kp({bytes:e.get("bytes"),type:e.get("type"),uint:e.get("uint")})}};class Dl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"Deltas",valueSchema:new Me(Ma.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({deltas:e}){this.deltas=e}getEncodingSchema(){return Dl.encodingSchema}toEncodingData(){return new Map([["Deltas",this.deltas.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionGroupLedgerStateDeltasForRoundResponse: ${e}`);return new Dl({deltas:(e.get("Deltas")??[]).map(t=>Ma.fromEncodingData(t))})}}class Tl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"consensus-version",valueSchema:new Ce,omitEmpty:!0},{key:"fee",valueSchema:new O,omitEmpty:!0},{key:"genesis-hash",valueSchema:new Pe,omitEmpty:!0},{key:"genesis-id",valueSchema:new Ce,omitEmpty:!0},{key:"last-round",valueSchema:new O,omitEmpty:!0},{key:"min-fee",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({consensusVersion:e,fee:t,genesisHash:r,genesisId:i,lastRound:o,minFee:s}){this.consensusVersion=e,this.fee=ve(t),this.genesisHash=typeof r=="string"?Ge(r):r,this.genesisId=i,this.lastRound=ve(o),this.minFee=ve(s)}getEncodingSchema(){return Tl.encodingSchema}toEncodingData(){return new Map([["consensus-version",this.consensusVersion],["fee",this.fee],["genesis-hash",this.genesisHash],["genesis-id",this.genesisId],["last-round",this.lastRound],["min-fee",this.minFee]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionParametersResponse: ${e}`);return new Tl({consensusVersion:e.get("consensus-version"),fee:e.get("fee"),genesisHash:e.get("genesis-hash"),genesisId:e.get("genesis-id"),lastRound:e.get("last-round"),minFee:e.get("min-fee")})}}class Ml{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"idx",valueSchema:new O,omitEmpty:!0},{key:"proof",valueSchema:new Pe,omitEmpty:!0},{key:"stibhash",valueSchema:new Pe,omitEmpty:!0},{key:"treedepth",valueSchema:new O,omitEmpty:!0},{key:"hashtype",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({idx:e,proof:t,stibhash:r,treedepth:i,hashtype:o}){this.idx=Oe(e),this.proof=typeof t=="string"?Ge(t):t,this.stibhash=typeof r=="string"?Ge(r):r,this.treedepth=Oe(i),this.hashtype=o}getEncodingSchema(){return Ml.encodingSchema}toEncodingData(){return new Map([["idx",this.idx],["proof",this.proof],["stibhash",this.stibhash],["treedepth",this.treedepth],["hashtype",this.hashtype]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionProof: ${e}`);return new Ml({idx:e.get("idx"),proof:e.get("proof"),stibhash:e.get("stibhash"),treedepth:e.get("treedepth"),hashtype:e.get("hashtype")})}}class Rl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"build",valueSchema:Ca.encodingSchema,omitEmpty:!0},{key:"genesis_hash_b64",valueSchema:new Pe,omitEmpty:!0},{key:"genesis_id",valueSchema:new Ce,omitEmpty:!0},{key:"versions",valueSchema:new Me(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({build:e,genesisHashB64:t,genesisId:r,versions:i}){this.build=e,this.genesisHashB64=typeof t=="string"?Ge(t):t,this.genesisId=r,this.versions=i}getEncodingSchema(){return Rl.encodingSchema}toEncodingData(){return new Map([["build",this.build.toEncodingData()],["genesis_hash_b64",this.genesisHashB64],["genesis_id",this.genesisId],["versions",this.versions]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Version: ${e}`);return new Rl({build:Ca.fromEncodingData(e.get("build")??new Map),genesisHashB64:e.get("genesis_hash_b64"),genesisId:e.get("genesis_id"),versions:e.get("versions")})}}const NI=Object.freeze(Object.defineProperty({__proto__:null,Account:yd,AccountApplicationResponse:hl,AccountAssetHolding:xa,AccountAssetResponse:fl,AccountAssetsInformationResponse:wd,AccountParticipation:np,AccountStateDelta:pl,AppCallLogs:va,Application:Is,ApplicationInitialStates:Sa,ApplicationKVStorage:_r,ApplicationLocalReference:ba,ApplicationLocalState:gl,ApplicationParams:Ea,ApplicationStateOperation:Aa,ApplicationStateSchema:Dr,Asset:xd,AssetHolding:ks,AssetHoldingReference:Ia,AssetParams:Cs,AvmKeyValue:ka,AvmValue:vr,BlockHashResponse:ml,BlockLogsResponse:vd,BlockResponse:yl,BlockTxidsResponse:wl,Box:fx,BoxDescriptor:fp,BoxReference:gp,BoxesResponse:px,BuildVersion:Ca,CompileResponse:xl,DisassembleResponse:vl,DryrunRequest:Sl,DryrunResponse:bl,DryrunSource:Fa,DryrunState:zi,DryrunTxnResult:Da,ErrorResponse:RI,EvalDelta:xp,EvalDeltaKeyValue:Fs,Genesis:BI,GenesisAllocation:Ta,GetBlockTimeStampOffsetResponse:El,GetSyncRoundResponse:Al,LedgerStateDeltaForTransactionGroup:Ma,LightBlockHeaderProof:gx,NodeStatusResponse:Ra,PendingTransactionResponse:hi,PendingTransactionsResponse:Ba,PostTransactionsResponse:Il,ScratchChange:Na,SimulateInitialStates:Pa,SimulateRequest:Oa,SimulateRequestTransactionGroup:ro,SimulateResponse:kl,SimulateTraceConfig:io,SimulateTransactionGroupResult:La,SimulateTransactionResult:Va,SimulateUnnamedResourcesAccessed:oo,SimulationEvalOverrides:$a,SimulationOpcodeTraceUnit:Ur,SimulationTransactionExecTrace:Hi,StateProof:mx,StateProofMessage:_a,SupplyResponse:Cl,TealKeyValue:Fl,TealValue:To,TransactionGroupLedgerStateDeltasForRoundResponse:Dl,TransactionParametersResponse:Tl,TransactionProof:Ml,Version:Rl},Symbol.toStringTag,{value:"Module"}));class lt{constructor(e){this.c=e,this.query={}}executeRequest(e,t){return this.c.get({relativePath:this.path(),query:this.query,requestHeaders:e,customOptions:t})}async do(e,t){const r=await this.executeRequest(e,t);return this.prepare(r)}async doRaw(e,t){return(await this.executeRequest(e,t)).body}}class PI extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}`}exclude(e){return this.query.exclude=e,this}prepare(e){return Et(e.getJSONText(),yd)}}class OI extends lt{constructor(e,t,r){super(e),this.account=t.toString(),this.assetID=BigInt(r)}path(){return`/v2/accounts/${this.account}/assets/${this.assetID}`}prepare(e){return Et(e.getJSONText(),fl)}}class LI extends lt{constructor(e,t,r){super(e),this.account=t.toString(),this.applicationID=BigInt(r)}path(){return`/v2/accounts/${this.account}/applications/${this.applicationID}`}prepare(e){return Et(e.getJSONText(),hl)}}let VI=class extends lt{constructor(e,t){super(e),this.round=BigInt(t),this.query={format:"msgpack"}}path(){return`/v2/blocks/${this.round}`}headerOnly(e){return this.query["header-only"]=e,this}prepare(e){return Xt(e.body,yl)}};function yx(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="text/plain"),e}class $I extends lt{constructor(e,t){super(e),this.source=t}path(){return"/v2/teal/compile"}sourcemap(e=!0){return this.query.sourcemap=e,this}executeRequest(e,t){const r=yx(e);return this.c.post({relativePath:this.path(),data:qr(this.source),query:this.query,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),xl)}}class _I extends lt{constructor(e,t){super(e),this.blob=Sr(t)}path(){return"/v2/teal/dryrun"}executeRequest(e,t){const r=yx(e);return this.c.post({relativePath:this.path(),data:this.blob,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),bl)}}class UI extends lt{path(){return"/genesis"}prepare(e){return e.getJSONText()}}class jI extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}`}prepare(e){return Et(e.getJSONText(),xd)}}class GI extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/applications/${this.index}`}prepare(e){return Et(e.getJSONText(),Is)}}class WI extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/hash`}prepare(e){return Et(e.getJSONText(),ml)}}class zI extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/txids`}prepare(e){return Et(e.getJSONText(),wl)}}class HI extends lt{constructor(e,t,r){super(e),this.index=BigInt(t);const i=In(r);this.query.name=encodeURI(`b64:${i}`)}path(){return`/v2/applications/${this.index}/box`}prepare(e){return Et(e.getJSONText(),fx)}}class YI extends lt{constructor(e,t){super(e),this.index=BigInt(t),this.query.max=0}path(){return`/v2/applications/${this.index}/boxes`}max(e){return this.query.max=e,this}prepare(e){return Et(e.getJSONText(),px)}}let KI=class extends lt{path(){return"/health"}prepare(e){}};class qI extends lt{constructor(e,t){super(e),this.txid=t,this.query.format="msgpack"}prepare(e){return Xt(e.body,hi)}path(){return`/v2/transactions/pending/${this.txid}`}max(e){return this.query.max=e,this}}class XI extends lt{constructor(e){super(e),this.query.format="msgpack"}path(){return"/v2/transactions/pending"}prepare(e){return Xt(e.body,Ba)}max(e){return this.query.max=e,this}}class ZI extends lt{constructor(e,t){super(e),this.address=t.toString(),this.query.format="msgpack"}prepare(e){return Xt(e.body,Ba)}path(){return`/v2/accounts/${this.address}/transactions/pending`}max(e){return this.query.max=e,this}}class JI extends lt{constructor(e,t,r){super(e),this.txID=r,this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/transactions/${this.txID}/proof`}hashType(e){return this.query.hashtype=e,this}prepare(e){return Et(e.getJSONText(),Ml)}}function QI(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="application/x-binary"),e}function Zm(n){return n&&n.byteLength!==void 0}class ek extends lt{constructor(e,t){super(e);let r=t;if(Array.isArray(t)){if(!t.every(Zm))throw new TypeError("Array elements must be byte arrays");r=hn(...t)}else if(!Zm(r))throw new TypeError("Argument must be byte array");this.txnBytesToPost=r}path(){return"/v2/transactions"}executeRequest(e,t){const r=QI(e);return this.c.post({relativePath:this.path(),data:this.txnBytesToPost,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),Il)}}class tk extends lt{path(){return"/v2/status"}prepare(e){return Et(e.getJSONText(),Ra)}}class nk extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/status/wait-for-block-after/${this.round}`}prepare(e){return Et(e.getJSONText(),Ra)}}class rk extends lt{path(){return"/v2/transactions/params"}prepare(e){const t=Et(e.getJSONText(),Tl);return{flatFee:!1,fee:t.fee,firstValid:t.lastRound,lastValid:t.lastRound+BigInt(1e3),genesisID:t.genesisId,genesisHash:t.genesisHash,minFee:t.minFee,consensusVersion:t.consensusVersion}}}class ik extends lt{path(){return"/v2/ledger/supply"}prepare(e){return Et(e.getJSONText(),Cl)}}class ok extends lt{path(){return"/versions"}prepare(e){return Et(e.getJSONText(),Rl)}}class sk extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}/lightheader/proof`}prepare(e){return Et(e.getJSONText(),gx)}}class ak extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/stateproofs/${this.round}`}prepare(e){return Et(e.getJSONText(),mx)}}class ck extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/ledger/sync/${this.round}`}executeRequest(e,t){return this.c.post({relativePath:this.path(),data:null,requestHeaders:e,customOptions:t})}prepare(e){}}class lk extends lt{path(){return"/v2/ledger/sync"}prepare(e){return Et(e.getJSONText(),Al)}}class uk extends lt{constructor(e,t){super(e),this.offset=BigInt(t)}path(){return`/v2/devmode/blocks/offset/${this.offset}`}executeRequest(e,t){return this.c.post({relativePath:this.path(),data:null,requestHeaders:e,customOptions:t})}prepare(e){}}class dk extends lt{path(){return"/v2/devmode/blocks/offset"}prepare(e){return Et(e.getJSONText(),El)}}function hk(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="text/plain"),e}class fk extends lt{constructor(e,t){super(e),this.source=t}path(){return"/v2/teal/disassemble"}executeRequest(e,t){const r=hk(e);return this.c.post({relativePath:this.path(),data:qr(this.source),query:this.query,requestHeaders:r,customOptions:t})}prepare(e){return Et(e.getJSONText(),vl)}}function pk(n={}){let e=n;return Object.keys(e).every(t=>t.toLowerCase()!=="content-type")&&(e={...n},e["Content-Type"]="application/msgpack"),e}class gk extends lt{constructor(e,t){super(e),this.query.format="msgpack",this.requestBytes=Sr(t)}path(){return"/v2/transactions/simulate"}executeRequest(e,t){const r=pk(e);return this.c.post({relativePath:this.path(),data:this.requestBytes,query:this.query,requestHeaders:r,customOptions:t})}prepare(e){return Xt(e.body,kl)}}class mk extends lt{path(){return"/ready"}prepare(e){}}class yk extends lt{path(){return"/v2/ledger/sync"}executeRequest(e,t){return this.c.delete({relativePath:this.path(),data:void 0,requestHeaders:e,customOptions:t})}prepare(e){}}class wk extends lt{constructor(e,t){super(e),this.id=t,this.query={format:"msgpack"}}path(){return`/v2/deltas/txn/group/${this.id}`}prepare(e){return Xt(e.body,Si)}}class xk extends lt{constructor(e,t){super(e),this.round=BigInt(t),this.query={format:"msgpack"}}path(){return`/v2/deltas/${this.round}`}prepare(e){return Xt(e.body,Si)}}class vk extends lt{constructor(e,t){super(e),this.round=BigInt(t),this.query={format:"msgpack"}}path(){return`/v2/deltas/${this.round}/txn/group`}prepare(e){return Xt(e.body,Dl)}}class Sk extends cg{constructor(e,t,r,i={}){super("X-Algo-API-Token",e,t,r,i)}healthCheck(){return new KI(this.c)}versionsCheck(){return new ok(this.c)}sendRawTransaction(e){return new ek(this.c,e)}accountInformation(e){return new PI(this.c,e)}accountAssetInformation(e,t){return new OI(this.c,e,t)}accountApplicationInformation(e,t){return new LI(this.c,e,t)}block(e){return new VI(this.c,e)}getBlockHash(e){return new WI(this.c,e)}getBlockTxids(e){return new zI(this.c,e)}pendingTransactionInformation(e){return new qI(this.c,e)}pendingTransactionsInformation(){return new XI(this.c)}pendingTransactionByAddress(e){return new ZI(this.c,e)}status(){return new tk(this.c)}statusAfterBlock(e){return new nk(this.c,e)}getTransactionParams(){return new rk(this.c)}supply(){return new ik(this.c)}compile(e){return new $I(this.c,e)}disassemble(e){return new fk(this.c,e)}dryrun(e){return new _I(this.c,e)}getAssetByID(e){return new jI(this.c,e)}getApplicationByID(e){return new GI(this.c,e)}getApplicationBoxByName(e,t){return new HI(this.c,e,t)}getApplicationBoxes(e){return new YI(this.c,e)}genesis(){return new UI(this.c)}getTransactionProof(e,t){return new JI(this.c,e,t)}getLightBlockHeaderProof(e){return new sk(this.c,e)}getStateProof(e){return new ak(this.c,e)}simulateRawTransactions(e){const t=[];if(Array.isArray(e))for(const i of e)t.push(Xt(i,jt));else t.push(Xt(e,jt));const r=new Oa({txnGroups:[new ro({txns:t})]});return this.simulateTransactions(r)}simulateTransactions(e){return new gk(this.c,e)}setBlockOffsetTimestamp(e){return new uk(this.c,e)}getBlockOffsetTimestamp(){return new dk(this.c)}setSyncRound(e){return new ck(this.c,e)}unsetSyncRound(){return new yk(this.c)}getSyncRound(){return new lk(this.c)}ready(){return new mk(this.c)}getLedgerStateDeltaForTransactionGroup(e){return new wk(this.c,e)}getLedgerStateDelta(e){return new xk(this.c,e)}getTransactionGroupLedgerStateDeltasForRound(e){return new vk(this.c,e)}}class bk extends cg{constructor(e,t="http://127.0.0.1",r=7833,i={}){super("X-KMD-API-Token",e,t,r,i)}async get(e){return(await this.c.get({relativePath:e})).parseBodyAsJSON({intDecoding:an.SAFE})}async delete(e,t){return(await this.c.delete({relativePath:e,data:t})).parseBodyAsJSON({intDecoding:an.SAFE})}async post(e,t){return(await this.c.post({relativePath:e,data:t})).parseBodyAsJSON({intDecoding:an.SAFE})}async versions(){return this.get("/versions")}async listWallets(){return this.get("/v1/wallets")}async createWallet(e,t,r=new Uint8Array,i="sqlite"){const o={wallet_name:e,wallet_driver_name:i,wallet_password:t,master_derivation_key:In(r)};return this.post("/v1/wallet",o)}async initWalletHandle(e,t){const r={wallet_id:e,wallet_password:t};return this.post("/v1/wallet/init",r)}async releaseWalletHandle(e){const t={wallet_handle_token:e};return this.post("/v1/wallet/release",t)}async renewWalletHandle(e){const t={wallet_handle_token:e};return this.post("/v1/wallet/renew",t)}async renameWallet(e,t,r){const i={wallet_id:e,wallet_password:t,wallet_name:r};return this.post("/v1/wallet/rename",i)}async getWallet(e){const t={wallet_handle_token:e};return this.post("/v1/wallet/info",t)}async exportMasterDerivationKey(e,t){const r={wallet_handle_token:e,wallet_password:t},i=await this.post("/v1/master-key/export",r);return{master_derivation_key:Ge(i.master_derivation_key)}}async importKey(e,t){const r={wallet_handle_token:e,private_key:In(t)};return this.post("/v1/key/import",r)}async exportKey(e,t,r){const i={wallet_handle_token:e,address:r,wallet_password:t},o=await this.post("/v1/key/export",i);return{private_key:Ge(o.private_key)}}async generateKey(e){const t={wallet_handle_token:e,display_mnemonic:!1};return this.post("/v1/key",t)}async deleteKey(e,t,r){const i={wallet_handle_token:e,address:r,wallet_password:t};return this.delete("/v1/key",i)}async listKeys(e){const t={wallet_handle_token:e};return this.post("/v1/key/list",t)}async signTransaction(e,t,r){const i={wallet_handle_token:e,wallet_password:t,transaction:In(r.toByte())},o=await this.post("/v1/transaction/sign",i);return Ge(o.signed_transaction)}async signTransactionWithSpecificPublicKey(e,t,r,i){const o=qr(i),s={wallet_handle_token:e,wallet_password:t,transaction:In(r.toByte()),public_key:In(o)},a=await this.post("/v1/transaction/sign",s);return Ge(a.signed_transaction)}async listMultisig(e){const t={wallet_handle_token:e};return this.post("/v1/multisig/list",t)}async importMultisig(e,t,r,i){const o={wallet_handle_token:e,multisig_version:t,threshold:r,pks:i};return this.post("/v1/multisig/import",o)}async exportMultisig(e,t){const r={wallet_handle_token:e,address:t};return this.post("/v1/multisig/export",r)}async signMultisigTransaction(e,t,r,i,o){const s=qr(i),a={wallet_handle_token:e,transaction:In(r.toByte()),public_key:In(s),partial_multisig:o,wallet_password:t};return this.post("/v1/multisig/sign",a)}async deleteMultisig(e,t,r){const i={wallet_handle_token:e,address:r,wallet_password:t};return this.delete("/v1/multisig",i)}}class so{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"amount",valueSchema:new O,omitEmpty:!0},{key:"amount-without-pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"min-balance",valueSchema:new O,omitEmpty:!0},{key:"pending-rewards",valueSchema:new O,omitEmpty:!0},{key:"rewards",valueSchema:new O,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"status",valueSchema:new Ce,omitEmpty:!0},{key:"total-apps-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-assets-opted-in",valueSchema:new O,omitEmpty:!0},{key:"total-box-bytes",valueSchema:new O,omitEmpty:!0},{key:"total-boxes",valueSchema:new O,omitEmpty:!0},{key:"total-created-apps",valueSchema:new O,omitEmpty:!0},{key:"total-created-assets",valueSchema:new O,omitEmpty:!0},{key:"apps-local-state",valueSchema:new k(new Me(ao.encodingSchema)),omitEmpty:!0},{key:"apps-total-extra-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"apps-total-schema",valueSchema:new k(yr.encodingSchema),omitEmpty:!0},{key:"assets",valueSchema:new k(new Me(co.encodingSchema)),omitEmpty:!0},{key:"auth-addr",valueSchema:new k(new Ce),omitEmpty:!0},{key:"closed-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"created-apps",valueSchema:new k(new Me(Zr.encodingSchema)),omitEmpty:!0},{key:"created-assets",valueSchema:new k(new Me(Jr.encodingSchema)),omitEmpty:!0},{key:"created-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"incentive-eligible",valueSchema:new k(new gt),omitEmpty:!0},{key:"last-heartbeat",valueSchema:new k(new O),omitEmpty:!0},{key:"last-proposed",valueSchema:new k(new O),omitEmpty:!0},{key:"participation",valueSchema:new k(Ua.encodingSchema),omitEmpty:!0},{key:"reward-base",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-type",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,amount:t,amountWithoutPendingRewards:r,minBalance:i,pendingRewards:o,rewards:s,round:a,status:l,totalAppsOptedIn:c,totalAssetsOptedIn:d,totalBoxBytes:u,totalBoxes:m,totalCreatedApps:h,totalCreatedAssets:x,appsLocalState:A,appsTotalExtraPages:v,appsTotalSchema:F,assets:w,authAddr:C,closedAtRound:M,createdApps:N,createdAssets:b,createdAtRound:j,deleted:p,incentiveEligible:E,lastHeartbeat:S,lastProposed:$,participation:B,rewardBase:P,sigType:W}){this.address=e,this.amount=ve(t),this.amountWithoutPendingRewards=ve(r),this.minBalance=Oe(i),this.pendingRewards=ve(o),this.rewards=ve(s),this.round=ve(a),this.status=l,this.totalAppsOptedIn=Oe(c),this.totalAssetsOptedIn=Oe(d),this.totalBoxBytes=Oe(u),this.totalBoxes=Oe(m),this.totalCreatedApps=Oe(h),this.totalCreatedAssets=Oe(x),this.appsLocalState=A,this.appsTotalExtraPages=typeof v>"u"?void 0:Oe(v),this.appsTotalSchema=F,this.assets=w,this.authAddr=typeof C=="string"?ze.fromString(C):C,this.closedAtRound=typeof M>"u"?void 0:ve(M),this.createdApps=N,this.createdAssets=b,this.createdAtRound=typeof j>"u"?void 0:ve(j),this.deleted=p,this.incentiveEligible=E,this.lastHeartbeat=typeof S>"u"?void 0:Oe(S),this.lastProposed=typeof $>"u"?void 0:Oe($),this.participation=B,this.rewardBase=typeof P>"u"?void 0:ve(P),this.sigType=W}getEncodingSchema(){return so.encodingSchema}toEncodingData(){return new Map([["address",this.address],["amount",this.amount],["amount-without-pending-rewards",this.amountWithoutPendingRewards],["min-balance",this.minBalance],["pending-rewards",this.pendingRewards],["rewards",this.rewards],["round",this.round],["status",this.status],["total-apps-opted-in",this.totalAppsOptedIn],["total-assets-opted-in",this.totalAssetsOptedIn],["total-box-bytes",this.totalBoxBytes],["total-boxes",this.totalBoxes],["total-created-apps",this.totalCreatedApps],["total-created-assets",this.totalCreatedAssets],["apps-local-state",typeof this.appsLocalState<"u"?this.appsLocalState.map(e=>e.toEncodingData()):void 0],["apps-total-extra-pages",this.appsTotalExtraPages],["apps-total-schema",typeof this.appsTotalSchema<"u"?this.appsTotalSchema.toEncodingData():void 0],["assets",typeof this.assets<"u"?this.assets.map(e=>e.toEncodingData()):void 0],["auth-addr",typeof this.authAddr<"u"?this.authAddr.toString():void 0],["closed-at-round",this.closedAtRound],["created-apps",typeof this.createdApps<"u"?this.createdApps.map(e=>e.toEncodingData()):void 0],["created-assets",typeof this.createdAssets<"u"?this.createdAssets.map(e=>e.toEncodingData()):void 0],["created-at-round",this.createdAtRound],["deleted",this.deleted],["incentive-eligible",this.incentiveEligible],["last-heartbeat",this.lastHeartbeat],["last-proposed",this.lastProposed],["participation",typeof this.participation<"u"?this.participation.toEncodingData():void 0],["reward-base",this.rewardBase],["sig-type",this.sigType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Account: ${e}`);return new so({address:e.get("address"),amount:e.get("amount"),amountWithoutPendingRewards:e.get("amount-without-pending-rewards"),minBalance:e.get("min-balance"),pendingRewards:e.get("pending-rewards"),rewards:e.get("rewards"),round:e.get("round"),status:e.get("status"),totalAppsOptedIn:e.get("total-apps-opted-in"),totalAssetsOptedIn:e.get("total-assets-opted-in"),totalBoxBytes:e.get("total-box-bytes"),totalBoxes:e.get("total-boxes"),totalCreatedApps:e.get("total-created-apps"),totalCreatedAssets:e.get("total-created-assets"),appsLocalState:typeof e.get("apps-local-state")<"u"?e.get("apps-local-state").map(t=>ao.fromEncodingData(t)):void 0,appsTotalExtraPages:e.get("apps-total-extra-pages"),appsTotalSchema:typeof e.get("apps-total-schema")<"u"?yr.fromEncodingData(e.get("apps-total-schema")):void 0,assets:typeof e.get("assets")<"u"?e.get("assets").map(t=>co.fromEncodingData(t)):void 0,authAddr:e.get("auth-addr"),closedAtRound:e.get("closed-at-round"),createdApps:typeof e.get("created-apps")<"u"?e.get("created-apps").map(t=>Zr.fromEncodingData(t)):void 0,createdAssets:typeof e.get("created-assets")<"u"?e.get("created-assets").map(t=>Jr.fromEncodingData(t)):void 0,createdAtRound:e.get("created-at-round"),deleted:e.get("deleted"),incentiveEligible:e.get("incentive-eligible"),lastHeartbeat:e.get("last-heartbeat"),lastProposed:e.get("last-proposed"),participation:typeof e.get("participation")<"u"?Ua.fromEncodingData(e.get("participation")):void 0,rewardBase:e.get("reward-base"),sigType:e.get("sig-type")})}}class Ua{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"selection-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"vote-first-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-key-dilution",valueSchema:new O,omitEmpty:!0},{key:"vote-last-valid",valueSchema:new O,omitEmpty:!0},{key:"vote-participation-key",valueSchema:new Pe,omitEmpty:!0},{key:"state-proof-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({selectionParticipationKey:e,voteFirstValid:t,voteKeyDilution:r,voteLastValid:i,voteParticipationKey:o,stateProofKey:s}){this.selectionParticipationKey=typeof e=="string"?Ge(e):e,this.voteFirstValid=ve(t),this.voteKeyDilution=ve(r),this.voteLastValid=ve(i),this.voteParticipationKey=typeof o=="string"?Ge(o):o,this.stateProofKey=typeof s=="string"?Ge(s):s}getEncodingSchema(){return Ua.encodingSchema}toEncodingData(){return new Map([["selection-participation-key",this.selectionParticipationKey],["vote-first-valid",this.voteFirstValid],["vote-key-dilution",this.voteKeyDilution],["vote-last-valid",this.voteLastValid],["vote-participation-key",this.voteParticipationKey],["state-proof-key",this.stateProofKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountParticipation: ${e}`);return new Ua({selectionParticipationKey:e.get("selection-participation-key"),voteFirstValid:e.get("vote-first-valid"),voteKeyDilution:e.get("vote-key-dilution"),voteLastValid:e.get("vote-last-valid"),voteParticipationKey:e.get("vote-participation-key"),stateProofKey:e.get("state-proof-key")})}}class Bl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"account",valueSchema:so.encodingSchema,omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({account:e,currentRound:t}){this.account=e,this.currentRound=ve(t)}getEncodingSchema(){return Bl.encodingSchema}toEncodingData(){return new Map([["account",this.account.toEncodingData()],["current-round",this.currentRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountResponse: ${e}`);return new Bl({account:so.fromEncodingData(e.get("account")??new Map),currentRound:e.get("current-round")})}}class ja{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"delta",valueSchema:new Me(ho.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,delta:t}){this.address=e,this.delta=t}getEncodingSchema(){return ja.encodingSchema}toEncodingData(){return new Map([["address",this.address],["delta",this.delta.map(e=>e.toEncodingData())]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountStateDelta: ${e}`);return new ja({address:e.get("address"),delta:(e.get("delta")??[]).map(t=>ho.fromEncodingData(t))})}}class Nl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"accounts",valueSchema:new Me(so.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({accounts:e,currentRound:t,nextToken:r}){this.accounts=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Nl.encodingSchema}toEncodingData(){return new Map([["accounts",this.accounts.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AccountsResponse: ${e}`);return new Nl({accounts:(e.get("accounts")??[]).map(t=>so.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Zr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:Wa.encodingSchema,omitEmpty:!0},{key:"created-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"deleted-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,params:t,createdAtRound:r,deleted:i,deletedAtRound:o}){this.id=ve(e),this.params=t,this.createdAtRound=typeof r>"u"?void 0:ve(r),this.deleted=i,this.deletedAtRound=typeof o>"u"?void 0:ve(o)}getEncodingSchema(){return Zr.encodingSchema}toEncodingData(){return new Map([["id",this.id],["params",this.params.toEncodingData()],["created-at-round",this.createdAtRound],["deleted",this.deleted],["deleted-at-round",this.deletedAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Application: ${e}`);return new Zr({id:e.get("id"),params:Wa.fromEncodingData(e.get("params")??new Map),createdAtRound:e.get("created-at-round"),deleted:e.get("deleted"),deletedAtRound:e.get("deleted-at-round")})}}class ao{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"id",valueSchema:new O,omitEmpty:!0},{key:"schema",valueSchema:yr.encodingSchema,omitEmpty:!0},{key:"closed-out-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"key-value",valueSchema:new k(new Me(fo.encodingSchema)),omitEmpty:!0},{key:"opted-in-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({id:e,schema:t,closedOutAtRound:r,deleted:i,keyValue:o,optedInAtRound:s}){this.id=ve(e),this.schema=t,this.closedOutAtRound=typeof r>"u"?void 0:ve(r),this.deleted=i,this.keyValue=o,this.optedInAtRound=typeof s>"u"?void 0:ve(s)}getEncodingSchema(){return ao.encodingSchema}toEncodingData(){return new Map([["id",this.id],["schema",this.schema.toEncodingData()],["closed-out-at-round",this.closedOutAtRound],["deleted",this.deleted],["key-value",typeof this.keyValue<"u"?this.keyValue.map(e=>e.toEncodingData()):void 0],["opted-in-at-round",this.optedInAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalState: ${e}`);return new ao({id:e.get("id"),schema:yr.fromEncodingData(e.get("schema")??new Map),closedOutAtRound:e.get("closed-out-at-round"),deleted:e.get("deleted"),keyValue:typeof e.get("key-value")<"u"?e.get("key-value").map(t=>fo.fromEncodingData(t)):void 0,optedInAtRound:e.get("opted-in-at-round")})}}class Pl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"apps-local-states",valueSchema:new Me(ao.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({appsLocalStates:e,currentRound:t,nextToken:r}){this.appsLocalStates=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Pl.encodingSchema}toEncodingData(){return new Map([["apps-local-states",this.appsLocalStates.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLocalStatesResponse: ${e}`);return new Pl({appsLocalStates:(e.get("apps-local-states")??[]).map(t=>ao.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Ga{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logs",valueSchema:new Me(new Pe),omitEmpty:!0},{key:"txid",valueSchema:new Ce,omitEmpty:!0})),this.encodingSchemaValue}constructor({logs:e,txid:t}){this.logs=e,this.txid=t}getEncodingSchema(){return Ga.encodingSchema}toEncodingData(){return new Map([["logs",this.logs],["txid",this.txid]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLogData: ${e}`);return new Ga({logs:e.get("logs"),txid:e.get("txid")})}}class Ol{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-id",valueSchema:new O,omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"log-data",valueSchema:new k(new Me(Ga.encodingSchema)),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationId:e,currentRound:t,logData:r,nextToken:i}){this.applicationId=ve(e),this.currentRound=ve(t),this.logData=r,this.nextToken=i}getEncodingSchema(){return Ol.encodingSchema}toEncodingData(){return new Map([["application-id",this.applicationId],["current-round",this.currentRound],["log-data",typeof this.logData<"u"?this.logData.map(e=>e.toEncodingData()):void 0],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationLogsResponse: ${e}`);return new Ol({applicationId:e.get("application-id"),currentRound:e.get("current-round"),logData:typeof e.get("log-data")<"u"?e.get("log-data").map(t=>Ga.fromEncodingData(t)):void 0,nextToken:e.get("next-token")})}}class Wa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"approval-program",valueSchema:new Pe,omitEmpty:!0},{key:"clear-state-program",valueSchema:new Pe,omitEmpty:!0},{key:"creator",valueSchema:new k(new Ce),omitEmpty:!0},{key:"extra-program-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"global-state",valueSchema:new k(new Me(fo.encodingSchema)),omitEmpty:!0},{key:"global-state-schema",valueSchema:new k(yr.encodingSchema),omitEmpty:!0},{key:"local-state-schema",valueSchema:new k(yr.encodingSchema),omitEmpty:!0},{key:"version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({approvalProgram:e,clearStateProgram:t,creator:r,extraProgramPages:i,globalState:o,globalStateSchema:s,localStateSchema:a,version:l}){this.approvalProgram=typeof e=="string"?Ge(e):e,this.clearStateProgram=typeof t=="string"?Ge(t):t,this.creator=typeof r=="string"?ze.fromString(r):r,this.extraProgramPages=typeof i>"u"?void 0:Oe(i),this.globalState=o,this.globalStateSchema=s,this.localStateSchema=a,this.version=typeof l>"u"?void 0:Oe(l)}getEncodingSchema(){return Wa.encodingSchema}toEncodingData(){return new Map([["approval-program",this.approvalProgram],["clear-state-program",this.clearStateProgram],["creator",typeof this.creator<"u"?this.creator.toString():void 0],["extra-program-pages",this.extraProgramPages],["global-state",typeof this.globalState<"u"?this.globalState.map(e=>e.toEncodingData()):void 0],["global-state-schema",typeof this.globalStateSchema<"u"?this.globalStateSchema.toEncodingData():void 0],["local-state-schema",typeof this.localStateSchema<"u"?this.localStateSchema.toEncodingData():void 0],["version",this.version]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationParams: ${e}`);return new Wa({approvalProgram:e.get("approval-program"),clearStateProgram:e.get("clear-state-program"),creator:e.get("creator"),extraProgramPages:e.get("extra-program-pages"),globalState:typeof e.get("global-state")<"u"?e.get("global-state").map(t=>fo.fromEncodingData(t)):void 0,globalStateSchema:typeof e.get("global-state-schema")<"u"?yr.fromEncodingData(e.get("global-state-schema")):void 0,localStateSchema:typeof e.get("local-state-schema")<"u"?yr.fromEncodingData(e.get("local-state-schema")):void 0,version:e.get("version")})}}class Ll{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"application",valueSchema:new k(Zr.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,application:t}){this.currentRound=ve(e),this.application=t}getEncodingSchema(){return Ll.encodingSchema}toEncodingData(){return new Map([["current-round",this.currentRound],["application",typeof this.application<"u"?this.application.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationResponse: ${e}`);return new Ll({currentRound:e.get("current-round"),application:typeof e.get("application")<"u"?Zr.fromEncodingData(e.get("application")):void 0})}}class yr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"num-byte-slice",valueSchema:new O,omitEmpty:!0},{key:"num-uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({numByteSlice:e,numUint:t}){this.numByteSlice=Oe(e),this.numUint=Oe(t)}getEncodingSchema(){return yr.encodingSchema}toEncodingData(){return new Map([["num-byte-slice",this.numByteSlice],["num-uint",this.numUint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationStateSchema: ${e}`);return new yr({numByteSlice:e.get("num-byte-slice"),numUint:e.get("num-uint")})}}class za{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"applications",valueSchema:new Me(Zr.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({applications:e,currentRound:t,nextToken:r}){this.applications=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return za.encodingSchema}toEncodingData(){return new Map([["applications",this.applications.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ApplicationsResponse: ${e}`);return new za({applications:(e.get("applications")??[]).map(t=>Zr.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Jr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"index",valueSchema:new O,omitEmpty:!0},{key:"params",valueSchema:lo.encodingSchema,omitEmpty:!0},{key:"created-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"destroyed-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({index:e,params:t,createdAtRound:r,deleted:i,destroyedAtRound:o}){this.index=ve(e),this.params=t,this.createdAtRound=typeof r>"u"?void 0:ve(r),this.deleted=i,this.destroyedAtRound=typeof o>"u"?void 0:ve(o)}getEncodingSchema(){return Jr.encodingSchema}toEncodingData(){return new Map([["index",this.index],["params",this.params.toEncodingData()],["created-at-round",this.createdAtRound],["deleted",this.deleted],["destroyed-at-round",this.destroyedAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Asset: ${e}`);return new Jr({index:e.get("index"),params:lo.fromEncodingData(e.get("params")??new Map),createdAtRound:e.get("created-at-round"),deleted:e.get("deleted"),destroyedAtRound:e.get("destroyed-at-round")})}}class Vl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"balances",valueSchema:new Me(rc.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({balances:e,currentRound:t,nextToken:r}){this.balances=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Vl.encodingSchema}toEncodingData(){return new Map([["balances",this.balances.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetBalancesResponse: ${e}`);return new Vl({balances:(e.get("balances")??[]).map(t=>rc.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class co{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"is-frozen",valueSchema:new gt,omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"opted-in-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"opted-out-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,assetId:t,isFrozen:r,deleted:i,optedInAtRound:o,optedOutAtRound:s}){this.amount=ve(e),this.assetId=ve(t),this.isFrozen=r,this.deleted=i,this.optedInAtRound=typeof o>"u"?void 0:ve(o),this.optedOutAtRound=typeof s>"u"?void 0:ve(s)}getEncodingSchema(){return co.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["asset-id",this.assetId],["is-frozen",this.isFrozen],["deleted",this.deleted],["opted-in-at-round",this.optedInAtRound],["opted-out-at-round",this.optedOutAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${e}`);return new co({amount:e.get("amount"),assetId:e.get("asset-id"),isFrozen:e.get("is-frozen"),deleted:e.get("deleted"),optedInAtRound:e.get("opted-in-at-round"),optedOutAtRound:e.get("opted-out-at-round")})}}class $l{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"assets",valueSchema:new Me(co.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({assets:e,currentRound:t,nextToken:r}){this.assets=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return $l.encodingSchema}toEncodingData(){return new Map([["assets",this.assets.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetHoldingsResponse: ${e}`);return new $l({assets:(e.get("assets")??[]).map(t=>co.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class lo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"creator",valueSchema:new Ce,omitEmpty:!0},{key:"decimals",valueSchema:new O,omitEmpty:!0},{key:"total",valueSchema:new O,omitEmpty:!0},{key:"clawback",valueSchema:new k(new Ce),omitEmpty:!0},{key:"default-frozen",valueSchema:new k(new gt),omitEmpty:!0},{key:"freeze",valueSchema:new k(new Ce),omitEmpty:!0},{key:"manager",valueSchema:new k(new Ce),omitEmpty:!0},{key:"metadata-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"reserve",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name",valueSchema:new k(new Ce),omitEmpty:!0},{key:"unit-name-b64",valueSchema:new k(new Pe),omitEmpty:!0},{key:"url",valueSchema:new k(new Ce),omitEmpty:!0},{key:"url-b64",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({creator:e,decimals:t,total:r,clawback:i,defaultFrozen:o,freeze:s,manager:a,metadataHash:l,name:c,nameB64:d,reserve:u,unitName:m,unitNameB64:h,url:x,urlB64:A}){this.creator=e,this.decimals=Oe(t),this.total=ve(r),this.clawback=i,this.defaultFrozen=o,this.freeze=s,this.manager=a,this.metadataHash=typeof l=="string"?Ge(l):l,this.name=c,this.nameB64=typeof d=="string"?Ge(d):d,this.reserve=u,this.unitName=m,this.unitNameB64=typeof h=="string"?Ge(h):h,this.url=x,this.urlB64=typeof A=="string"?Ge(A):A}getEncodingSchema(){return lo.encodingSchema}toEncodingData(){return new Map([["creator",this.creator],["decimals",this.decimals],["total",this.total],["clawback",this.clawback],["default-frozen",this.defaultFrozen],["freeze",this.freeze],["manager",this.manager],["metadata-hash",this.metadataHash],["name",this.name],["name-b64",this.nameB64],["reserve",this.reserve],["unit-name",this.unitName],["unit-name-b64",this.unitNameB64],["url",this.url],["url-b64",this.urlB64]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetParams: ${e}`);return new lo({creator:e.get("creator"),decimals:e.get("decimals"),total:e.get("total"),clawback:e.get("clawback"),defaultFrozen:e.get("default-frozen"),freeze:e.get("freeze"),manager:e.get("manager"),metadataHash:e.get("metadata-hash"),name:e.get("name"),nameB64:e.get("name-b64"),reserve:e.get("reserve"),unitName:e.get("unit-name"),unitNameB64:e.get("unit-name-b64"),url:e.get("url"),urlB64:e.get("url-b64")})}}class _l{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"asset",valueSchema:Jr.encodingSchema,omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({asset:e,currentRound:t}){this.asset=e,this.currentRound=ve(t)}getEncodingSchema(){return _l.encodingSchema}toEncodingData(){return new Map([["asset",this.asset.toEncodingData()],["current-round",this.currentRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetResponse: ${e}`);return new _l({asset:Jr.fromEncodingData(e.get("asset")??new Map),currentRound:e.get("current-round")})}}class Ha{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"assets",valueSchema:new Me(Jr.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({assets:e,currentRound:t,nextToken:r}){this.assets=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Ha.encodingSchema}toEncodingData(){return new Map([["assets",this.assets.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded AssetsResponse: ${e}`);return new Ha({assets:(e.get("assets")??[]).map(t=>Jr.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Ds{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"genesis-hash",valueSchema:new Pe,omitEmpty:!0},{key:"genesis-id",valueSchema:new Ce,omitEmpty:!0},{key:"previous-block-hash",valueSchema:new Pe,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"seed",valueSchema:new Pe,omitEmpty:!0},{key:"timestamp",valueSchema:new O,omitEmpty:!0},{key:"transactions-root",valueSchema:new Pe,omitEmpty:!0},{key:"transactions-root-sha256",valueSchema:new Pe,omitEmpty:!0},{key:"bonus",valueSchema:new k(new O),omitEmpty:!0},{key:"fees-collected",valueSchema:new k(new O),omitEmpty:!0},{key:"participation-updates",valueSchema:new k(ic.encodingSchema),omitEmpty:!0},{key:"previous-block-hash-512",valueSchema:new k(new Pe),omitEmpty:!0},{key:"proposer",valueSchema:new k(new Ce),omitEmpty:!0},{key:"proposer-payout",valueSchema:new k(new O),omitEmpty:!0},{key:"rewards",valueSchema:new k(Ya.encodingSchema),omitEmpty:!0},{key:"state-proof-tracking",valueSchema:new k(new Me(dc.encodingSchema)),omitEmpty:!0},{key:"transactions",valueSchema:new k(new Me(wr.encodingSchema)),omitEmpty:!0},{key:"transactions-root-sha512",valueSchema:new k(new Pe),omitEmpty:!0},{key:"txn-counter",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-state",valueSchema:new k(Ka.encodingSchema),omitEmpty:!0},{key:"upgrade-vote",valueSchema:new k(qa.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({genesisHash:e,genesisId:t,previousBlockHash:r,round:i,seed:o,timestamp:s,transactionsRoot:a,transactionsRootSha256:l,bonus:c,feesCollected:d,participationUpdates:u,previousBlockHash512:m,proposer:h,proposerPayout:x,rewards:A,stateProofTracking:v,transactions:F,transactionsRootSha512:w,txnCounter:C,upgradeState:M,upgradeVote:N}){this.genesisHash=typeof e=="string"?Ge(e):e,this.genesisId=t,this.previousBlockHash=typeof r=="string"?Ge(r):r,this.round=ve(i),this.seed=typeof o=="string"?Ge(o):o,this.timestamp=Oe(s),this.transactionsRoot=typeof a=="string"?Ge(a):a,this.transactionsRootSha256=typeof l=="string"?Ge(l):l,this.bonus=typeof c>"u"?void 0:Oe(c),this.feesCollected=typeof d>"u"?void 0:Oe(d),this.participationUpdates=u,this.previousBlockHash512=typeof m=="string"?Ge(m):m,this.proposer=typeof h=="string"?ze.fromString(h):h,this.proposerPayout=typeof x>"u"?void 0:Oe(x),this.rewards=A,this.stateProofTracking=v,this.transactions=F,this.transactionsRootSha512=typeof w=="string"?Ge(w):w,this.txnCounter=typeof C>"u"?void 0:Oe(C),this.upgradeState=M,this.upgradeVote=N}getEncodingSchema(){return Ds.encodingSchema}toEncodingData(){return new Map([["genesis-hash",this.genesisHash],["genesis-id",this.genesisId],["previous-block-hash",this.previousBlockHash],["round",this.round],["seed",this.seed],["timestamp",this.timestamp],["transactions-root",this.transactionsRoot],["transactions-root-sha256",this.transactionsRootSha256],["bonus",this.bonus],["fees-collected",this.feesCollected],["participation-updates",typeof this.participationUpdates<"u"?this.participationUpdates.toEncodingData():void 0],["previous-block-hash-512",this.previousBlockHash512],["proposer",typeof this.proposer<"u"?this.proposer.toString():void 0],["proposer-payout",this.proposerPayout],["rewards",typeof this.rewards<"u"?this.rewards.toEncodingData():void 0],["state-proof-tracking",typeof this.stateProofTracking<"u"?this.stateProofTracking.map(e=>e.toEncodingData()):void 0],["transactions",typeof this.transactions<"u"?this.transactions.map(e=>e.toEncodingData()):void 0],["transactions-root-sha512",this.transactionsRootSha512],["txn-counter",this.txnCounter],["upgrade-state",typeof this.upgradeState<"u"?this.upgradeState.toEncodingData():void 0],["upgrade-vote",typeof this.upgradeVote<"u"?this.upgradeVote.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Block: ${e}`);return new Ds({genesisHash:e.get("genesis-hash"),genesisId:e.get("genesis-id"),previousBlockHash:e.get("previous-block-hash"),round:e.get("round"),seed:e.get("seed"),timestamp:e.get("timestamp"),transactionsRoot:e.get("transactions-root"),transactionsRootSha256:e.get("transactions-root-sha256"),bonus:e.get("bonus"),feesCollected:e.get("fees-collected"),participationUpdates:typeof e.get("participation-updates")<"u"?ic.fromEncodingData(e.get("participation-updates")):void 0,previousBlockHash512:e.get("previous-block-hash-512"),proposer:e.get("proposer"),proposerPayout:e.get("proposer-payout"),rewards:typeof e.get("rewards")<"u"?Ya.fromEncodingData(e.get("rewards")):void 0,stateProofTracking:typeof e.get("state-proof-tracking")<"u"?e.get("state-proof-tracking").map(t=>dc.fromEncodingData(t)):void 0,transactions:typeof e.get("transactions")<"u"?e.get("transactions").map(t=>wr.fromEncodingData(t)):void 0,transactionsRootSha512:e.get("transactions-root-sha512"),txnCounter:e.get("txn-counter"),upgradeState:typeof e.get("upgrade-state")<"u"?Ka.fromEncodingData(e.get("upgrade-state")):void 0,upgradeVote:typeof e.get("upgrade-vote")<"u"?qa.fromEncodingData(e.get("upgrade-vote")):void 0})}}class Ul{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"blocks",valueSchema:new Me(Ds.encodingSchema),omitEmpty:!0},{key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({blocks:e,currentRound:t,nextToken:r}){this.blocks=e,this.currentRound=ve(t),this.nextToken=r}getEncodingSchema(){return Ul.encodingSchema}toEncodingData(){return new Map([["blocks",this.blocks.map(e=>e.toEncodingData())],["current-round",this.currentRound],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockHeadersResponse: ${e}`);return new Ul({blocks:(e.get("blocks")??[]).map(t=>Ds.fromEncodingData(t)),currentRound:e.get("current-round"),nextToken:e.get("next-token")})}}class Ya{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"fee-sink",valueSchema:new Ce,omitEmpty:!0},{key:"rewards-calculation-round",valueSchema:new O,omitEmpty:!0},{key:"rewards-level",valueSchema:new O,omitEmpty:!0},{key:"rewards-pool",valueSchema:new Ce,omitEmpty:!0},{key:"rewards-rate",valueSchema:new O,omitEmpty:!0},{key:"rewards-residue",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({feeSink:e,rewardsCalculationRound:t,rewardsLevel:r,rewardsPool:i,rewardsRate:o,rewardsResidue:s}){this.feeSink=e,this.rewardsCalculationRound=ve(t),this.rewardsLevel=ve(r),this.rewardsPool=i,this.rewardsRate=ve(o),this.rewardsResidue=ve(s)}getEncodingSchema(){return Ya.encodingSchema}toEncodingData(){return new Map([["fee-sink",this.feeSink],["rewards-calculation-round",this.rewardsCalculationRound],["rewards-level",this.rewardsLevel],["rewards-pool",this.rewardsPool],["rewards-rate",this.rewardsRate],["rewards-residue",this.rewardsResidue]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockRewards: ${e}`);return new Ya({feeSink:e.get("fee-sink"),rewardsCalculationRound:e.get("rewards-calculation-round"),rewardsLevel:e.get("rewards-level"),rewardsPool:e.get("rewards-pool"),rewardsRate:e.get("rewards-rate"),rewardsResidue:e.get("rewards-residue")})}}class Ka{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-protocol",valueSchema:new Ce,omitEmpty:!0},{key:"next-protocol",valueSchema:new k(new Ce),omitEmpty:!0},{key:"next-protocol-approvals",valueSchema:new k(new O),omitEmpty:!0},{key:"next-protocol-switch-on",valueSchema:new k(new O),omitEmpty:!0},{key:"next-protocol-vote-before",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({currentProtocol:e,nextProtocol:t,nextProtocolApprovals:r,nextProtocolSwitchOn:i,nextProtocolVoteBefore:o}){this.currentProtocol=e,this.nextProtocol=t,this.nextProtocolApprovals=typeof r>"u"?void 0:Oe(r),this.nextProtocolSwitchOn=typeof i>"u"?void 0:ve(i),this.nextProtocolVoteBefore=typeof o>"u"?void 0:ve(o)}getEncodingSchema(){return Ka.encodingSchema}toEncodingData(){return new Map([["current-protocol",this.currentProtocol],["next-protocol",this.nextProtocol],["next-protocol-approvals",this.nextProtocolApprovals],["next-protocol-switch-on",this.nextProtocolSwitchOn],["next-protocol-vote-before",this.nextProtocolVoteBefore]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockUpgradeState: ${e}`);return new Ka({currentProtocol:e.get("current-protocol"),nextProtocol:e.get("next-protocol"),nextProtocolApprovals:e.get("next-protocol-approvals"),nextProtocolSwitchOn:e.get("next-protocol-switch-on"),nextProtocolVoteBefore:e.get("next-protocol-vote-before")})}}class qa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"upgrade-approve",valueSchema:new k(new gt),omitEmpty:!0},{key:"upgrade-delay",valueSchema:new k(new O),omitEmpty:!0},{key:"upgrade-propose",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({upgradeApprove:e,upgradeDelay:t,upgradePropose:r}){this.upgradeApprove=e,this.upgradeDelay=typeof t>"u"?void 0:ve(t),this.upgradePropose=r}getEncodingSchema(){return qa.encodingSchema}toEncodingData(){return new Map([["upgrade-approve",this.upgradeApprove],["upgrade-delay",this.upgradeDelay],["upgrade-propose",this.upgradePropose]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BlockUpgradeVote: ${e}`);return new qa({upgradeApprove:e.get("upgrade-approve"),upgradeDelay:e.get("upgrade-delay"),upgradePropose:e.get("upgrade-propose")})}}class jl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"value",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e,round:t,value:r}){this.name=typeof e=="string"?Ge(e):e,this.round=ve(t),this.value=typeof r=="string"?Ge(r):r}getEncodingSchema(){return jl.encodingSchema}toEncodingData(){return new Map([["name",this.name],["round",this.round],["value",this.value]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Box: ${e}`);return new jl({name:e.get("name"),round:e.get("round"),value:e.get("value")})}}class Xa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({name:e}){this.name=typeof e=="string"?Ge(e):e}getEncodingSchema(){return Xa.encodingSchema}toEncodingData(){return new Map([["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxDescriptor: ${e}`);return new Xa({name:e.get("name")})}}class uo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"app",valueSchema:new O,omitEmpty:!0},{key:"name",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({app:e,name:t}){this.app=Oe(e),this.name=typeof t=="string"?Ge(t):t}getEncodingSchema(){return uo.encodingSchema}toEncodingData(){return new Map([["app",this.app],["name",this.name]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxReference: ${e}`);return new uo({app:e.get("app"),name:e.get("name")})}}class Gl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-id",valueSchema:new O,omitEmpty:!0},{key:"boxes",valueSchema:new Me(Xa.encodingSchema),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationId:e,boxes:t,nextToken:r}){this.applicationId=ve(e),this.boxes=t,this.nextToken=r}getEncodingSchema(){return Gl.encodingSchema}toEncodingData(){return new Map([["application-id",this.applicationId],["boxes",this.boxes.map(e=>e.toEncodingData())],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded BoxesResponse: ${e}`);return new Gl({applicationId:e.get("application-id"),boxes:(e.get("boxes")??[]).map(t=>Xa.fromEncodingData(t)),nextToken:e.get("next-token")})}}class Sd{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"message",valueSchema:new Ce,omitEmpty:!0},{key:"data",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,data:t}){this.message=e,this.data=t}getEncodingSchema(){return Sd.encodingSchema}toEncodingData(){return new Map([["message",this.message],["data",typeof this.data<"u"?this.data.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ErrorResponse: ${e}`);return new Sd({message:e.get("message"),data:typeof e.get("data")<"u"?Sn.fromEncodingData(e.get("data")):void 0})}}class Za{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"action",valueSchema:new O,omitEmpty:!0},{key:"bytes",valueSchema:new k(new Ce),omitEmpty:!0},{key:"uint",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({action:e,bytes:t,uint:r}){this.action=Oe(e),this.bytes=t,this.uint=typeof r>"u"?void 0:ve(r)}getEncodingSchema(){return Za.encodingSchema}toEncodingData(){return new Map([["action",this.action],["bytes",this.bytes],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${e}`);return new Za({action:e.get("action"),bytes:e.get("bytes"),uint:e.get("uint")})}}class ho{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Ce,omitEmpty:!0},{key:"value",valueSchema:Za.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=e,this.value=t}getEncodingSchema(){return ho.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EvalDeltaKeyValue: ${e}`);return new ho({key:e.get("key"),value:Za.fromEncodingData(e.get("value")??new Map)})}}class Ja{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hash-type",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({hashType:e}){this.hashType=typeof e>"u"?void 0:Oe(e)}getEncodingSchema(){return Ja.encodingSchema}toEncodingData(){return new Map([["hash-type",this.hashType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HashFactory: ${e}`);return new Ja({hashType:e.get("hash-type")})}}class Qa{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hb-pk",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-pk1sig",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-pk2",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-pk2sig",valueSchema:new k(new Pe),omitEmpty:!0},{key:"hb-sig",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({hbPk:e,hbPk1sig:t,hbPk2:r,hbPk2sig:i,hbSig:o}){this.hbPk=typeof e=="string"?Ge(e):e,this.hbPk1sig=typeof t=="string"?Ge(t):t,this.hbPk2=typeof r=="string"?Ge(r):r,this.hbPk2sig=typeof i=="string"?Ge(i):i,this.hbSig=typeof o=="string"?Ge(o):o}getEncodingSchema(){return Qa.encodingSchema}toEncodingData(){return new Map([["hb-pk",this.hbPk],["hb-pk1sig",this.hbPk1sig],["hb-pk2",this.hbPk2],["hb-pk2sig",this.hbPk2sig],["hb-sig",this.hbSig]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HbProofFields: ${e}`);return new Qa({hbPk:e.get("hb-pk"),hbPk1sig:e.get("hb-pk1sig"),hbPk2:e.get("hb-pk2"),hbPk2sig:e.get("hb-pk2sig"),hbSig:e.get("hb-sig")})}}class Wl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"db-available",valueSchema:new gt,omitEmpty:!0},{key:"is-migrating",valueSchema:new gt,omitEmpty:!0},{key:"message",valueSchema:new Ce,omitEmpty:!0},{key:"round",valueSchema:new O,omitEmpty:!0},{key:"version",valueSchema:new Ce,omitEmpty:!0},{key:"data",valueSchema:new k(Sn.encodingSchema),omitEmpty:!0},{key:"errors",valueSchema:new k(new Me(new Ce)),omitEmpty:!0})),this.encodingSchemaValue}constructor({dbAvailable:e,isMigrating:t,message:r,round:i,version:o,data:s,errors:a}){this.dbAvailable=e,this.isMigrating=t,this.message=r,this.round=ve(i),this.version=o,this.data=s,this.errors=a}getEncodingSchema(){return Wl.encodingSchema}toEncodingData(){return new Map([["db-available",this.dbAvailable],["is-migrating",this.isMigrating],["message",this.message],["round",this.round],["version",this.version],["data",typeof this.data<"u"?this.data.toEncodingData():void 0],["errors",this.errors]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HealthCheck: ${e}`);return new Wl({dbAvailable:e.get("db-available"),isMigrating:e.get("is-migrating"),message:e.get("message"),round:e.get("round"),version:e.get("version"),data:typeof e.get("data")<"u"?Sn.fromEncodingData(e.get("data")):void 0,errors:e.get("errors")})}}class ec{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"asset",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,asset:t}){this.address=typeof e=="string"?ze.fromString(e):e,this.asset=Oe(t)}getEncodingSchema(){return ec.encodingSchema}toEncodingData(){return new Map([["address",this.address.toString()],["asset",this.asset]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded HoldingRef: ${e}`);return new ec({address:e.get("address"),asset:e.get("asset")})}}class tc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"block-headers-commitment",valueSchema:new k(new Pe),omitEmpty:!0},{key:"first-attested-round",valueSchema:new k(new O),omitEmpty:!0},{key:"latest-attested-round",valueSchema:new k(new O),omitEmpty:!0},{key:"ln-proven-weight",valueSchema:new k(new O),omitEmpty:!0},{key:"voters-commitment",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({blockHeadersCommitment:e,firstAttestedRound:t,latestAttestedRound:r,lnProvenWeight:i,votersCommitment:o}){this.blockHeadersCommitment=typeof e=="string"?Ge(e):e,this.firstAttestedRound=typeof t>"u"?void 0:ve(t),this.latestAttestedRound=typeof r>"u"?void 0:ve(r),this.lnProvenWeight=typeof i>"u"?void 0:ve(i),this.votersCommitment=typeof o=="string"?Ge(o):o}getEncodingSchema(){return tc.encodingSchema}toEncodingData(){return new Map([["block-headers-commitment",this.blockHeadersCommitment],["first-attested-round",this.firstAttestedRound],["latest-attested-round",this.latestAttestedRound],["ln-proven-weight",this.lnProvenWeight],["voters-commitment",this.votersCommitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded IndexerStateProofMessage: ${e}`);return new tc({blockHeadersCommitment:e.get("block-headers-commitment"),firstAttestedRound:e.get("first-attested-round"),latestAttestedRound:e.get("latest-attested-round"),lnProvenWeight:e.get("ln-proven-weight"),votersCommitment:e.get("voters-commitment")})}}class nc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"app",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,app:t}){this.address=typeof e=="string"?ze.fromString(e):e,this.app=Oe(t)}getEncodingSchema(){return nc.encodingSchema}toEncodingData(){return new Map([["address",this.address.toString()],["app",this.app]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded LocalsRef: ${e}`);return new nc({address:e.get("address"),app:e.get("app")})}}class Gr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hash-factory",valueSchema:new k(Ja.encodingSchema),omitEmpty:!0},{key:"path",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"tree-depth",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({hashFactory:e,path:t,treeDepth:r}){this.hashFactory=e,this.path=t,this.treeDepth=typeof r>"u"?void 0:Oe(r)}getEncodingSchema(){return Gr.encodingSchema}toEncodingData(){return new Map([["hash-factory",typeof this.hashFactory<"u"?this.hashFactory.toEncodingData():void 0],["path",this.path],["tree-depth",this.treeDepth]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MerkleArrayProof: ${e}`);return new Gr({hashFactory:typeof e.get("hash-factory")<"u"?Ja.fromEncodingData(e.get("hash-factory")):void 0,path:e.get("path"),treeDepth:e.get("tree-depth")})}}class rc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"amount",valueSchema:new O,omitEmpty:!0},{key:"is-frozen",valueSchema:new gt,omitEmpty:!0},{key:"deleted",valueSchema:new k(new gt),omitEmpty:!0},{key:"opted-in-at-round",valueSchema:new k(new O),omitEmpty:!0},{key:"opted-out-at-round",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,amount:t,isFrozen:r,deleted:i,optedInAtRound:o,optedOutAtRound:s}){this.address=e,this.amount=ve(t),this.isFrozen=r,this.deleted=i,this.optedInAtRound=typeof o>"u"?void 0:ve(o),this.optedOutAtRound=typeof s>"u"?void 0:ve(s)}getEncodingSchema(){return rc.encodingSchema}toEncodingData(){return new Map([["address",this.address],["amount",this.amount],["is-frozen",this.isFrozen],["deleted",this.deleted],["opted-in-at-round",this.optedInAtRound],["opted-out-at-round",this.optedOutAtRound]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded MiniAssetHolding: ${e}`);return new rc({address:e.get("address"),amount:e.get("amount"),isFrozen:e.get("is-frozen"),deleted:e.get("deleted"),optedInAtRound:e.get("opted-in-at-round"),optedOutAtRound:e.get("opted-out-at-round")})}}class ic{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"absent-participation-accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"expired-participation-accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0})),this.encodingSchemaValue}constructor({absentParticipationAccounts:e,expiredParticipationAccounts:t}){this.absentParticipationAccounts=e,this.expiredParticipationAccounts=t}getEncodingSchema(){return ic.encodingSchema}toEncodingData(){return new Map([["absent-participation-accounts",this.absentParticipationAccounts],["expired-participation-accounts",this.expiredParticipationAccounts]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ParticipationUpdates: ${e}`);return new ic({absentParticipationAccounts:e.get("absent-participation-accounts"),expiredParticipationAccounts:e.get("expired-participation-accounts")})}}class oc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new k(new Ce),omitEmpty:!0},{key:"application-id",valueSchema:new k(new O),omitEmpty:!0},{key:"asset-id",valueSchema:new k(new O),omitEmpty:!0},{key:"box",valueSchema:new k(uo.encodingSchema),omitEmpty:!0},{key:"holding",valueSchema:new k(ec.encodingSchema),omitEmpty:!0},{key:"local",valueSchema:new k(nc.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,applicationId:t,assetId:r,box:i,holding:o,local:s}){this.address=typeof e=="string"?ze.fromString(e):e,this.applicationId=typeof t>"u"?void 0:Oe(t),this.assetId=typeof r>"u"?void 0:Oe(r),this.box=i,this.holding=o,this.local=s}getEncodingSchema(){return oc.encodingSchema}toEncodingData(){return new Map([["address",typeof this.address<"u"?this.address.toString():void 0],["application-id",this.applicationId],["asset-id",this.assetId],["box",typeof this.box<"u"?this.box.toEncodingData():void 0],["holding",typeof this.holding<"u"?this.holding.toEncodingData():void 0],["local",typeof this.local<"u"?this.local.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded ResourceRef: ${e}`);return new oc({address:e.get("address"),applicationId:e.get("application-id"),assetId:e.get("asset-id"),box:typeof e.get("box")<"u"?uo.fromEncodingData(e.get("box")):void 0,holding:typeof e.get("holding")<"u"?ec.fromEncodingData(e.get("holding")):void 0,local:typeof e.get("local")<"u"?nc.fromEncodingData(e.get("local")):void 0})}}class sc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"part-proofs",valueSchema:new k(Gr.encodingSchema),omitEmpty:!0},{key:"positions-to-reveal",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"reveals",valueSchema:new k(new Me(cc.encodingSchema)),omitEmpty:!0},{key:"salt-version",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-commit",valueSchema:new k(new Pe),omitEmpty:!0},{key:"sig-proofs",valueSchema:new k(Gr.encodingSchema),omitEmpty:!0},{key:"signed-weight",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({partProofs:e,positionsToReveal:t,reveals:r,saltVersion:i,sigCommit:o,sigProofs:s,signedWeight:a}){this.partProofs=e,this.positionsToReveal=typeof t>"u"?void 0:t.map(ve),this.reveals=r,this.saltVersion=typeof i>"u"?void 0:Oe(i),this.sigCommit=typeof o=="string"?Ge(o):o,this.sigProofs=s,this.signedWeight=typeof a>"u"?void 0:ve(a)}getEncodingSchema(){return sc.encodingSchema}toEncodingData(){return new Map([["part-proofs",typeof this.partProofs<"u"?this.partProofs.toEncodingData():void 0],["positions-to-reveal",this.positionsToReveal],["reveals",typeof this.reveals<"u"?this.reveals.map(e=>e.toEncodingData()):void 0],["salt-version",this.saltVersion],["sig-commit",this.sigCommit],["sig-proofs",typeof this.sigProofs<"u"?this.sigProofs.toEncodingData():void 0],["signed-weight",this.signedWeight]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofFields: ${e}`);return new sc({partProofs:typeof e.get("part-proofs")<"u"?Gr.fromEncodingData(e.get("part-proofs")):void 0,positionsToReveal:e.get("positions-to-reveal"),reveals:typeof e.get("reveals")<"u"?e.get("reveals").map(t=>cc.fromEncodingData(t)):void 0,saltVersion:e.get("salt-version"),sigCommit:e.get("sig-commit"),sigProofs:typeof e.get("sig-proofs")<"u"?Gr.fromEncodingData(e.get("sig-proofs")):void 0,signedWeight:e.get("signed-weight")})}}class ac{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"verifier",valueSchema:new k(hc.encodingSchema),omitEmpty:!0},{key:"weight",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({verifier:e,weight:t}){this.verifier=e,this.weight=typeof t>"u"?void 0:ve(t)}getEncodingSchema(){return ac.encodingSchema}toEncodingData(){return new Map([["verifier",typeof this.verifier<"u"?this.verifier.toEncodingData():void 0],["weight",this.weight]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofParticipant: ${e}`);return new ac({verifier:typeof e.get("verifier")<"u"?hc.fromEncodingData(e.get("verifier")):void 0,weight:e.get("weight")})}}class cc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"participant",valueSchema:new k(ac.encodingSchema),omitEmpty:!0},{key:"position",valueSchema:new k(new O),omitEmpty:!0},{key:"sig-slot",valueSchema:new k(lc.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({participant:e,position:t,sigSlot:r}){this.participant=e,this.position=typeof t>"u"?void 0:ve(t),this.sigSlot=r}getEncodingSchema(){return cc.encodingSchema}toEncodingData(){return new Map([["participant",typeof this.participant<"u"?this.participant.toEncodingData():void 0],["position",this.position],["sig-slot",typeof this.sigSlot<"u"?this.sigSlot.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofReveal: ${e}`);return new cc({participant:typeof e.get("participant")<"u"?ac.fromEncodingData(e.get("participant")):void 0,position:e.get("position"),sigSlot:typeof e.get("sig-slot")<"u"?lc.fromEncodingData(e.get("sig-slot")):void 0})}}class lc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"lower-sig-weight",valueSchema:new k(new O),omitEmpty:!0},{key:"signature",valueSchema:new k(uc.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({lowerSigWeight:e,signature:t}){this.lowerSigWeight=typeof e>"u"?void 0:ve(e),this.signature=t}getEncodingSchema(){return lc.encodingSchema}toEncodingData(){return new Map([["lower-sig-weight",this.lowerSigWeight],["signature",typeof this.signature<"u"?this.signature.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofSigSlot: ${e}`);return new lc({lowerSigWeight:e.get("lower-sig-weight"),signature:typeof e.get("signature")<"u"?uc.fromEncodingData(e.get("signature")):void 0})}}class uc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"falcon-signature",valueSchema:new k(new Pe),omitEmpty:!0},{key:"merkle-array-index",valueSchema:new k(new O),omitEmpty:!0},{key:"proof",valueSchema:new k(Gr.encodingSchema),omitEmpty:!0},{key:"verifying-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({falconSignature:e,merkleArrayIndex:t,proof:r,verifyingKey:i}){this.falconSignature=typeof e=="string"?Ge(e):e,this.merkleArrayIndex=typeof t>"u"?void 0:Oe(t),this.proof=r,this.verifyingKey=typeof i=="string"?Ge(i):i}getEncodingSchema(){return uc.encodingSchema}toEncodingData(){return new Map([["falcon-signature",this.falconSignature],["merkle-array-index",this.merkleArrayIndex],["proof",typeof this.proof<"u"?this.proof.toEncodingData():void 0],["verifying-key",this.verifyingKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofSignature: ${e}`);return new uc({falconSignature:e.get("falcon-signature"),merkleArrayIndex:e.get("merkle-array-index"),proof:typeof e.get("proof")<"u"?Gr.fromEncodingData(e.get("proof")):void 0,verifyingKey:e.get("verifying-key")})}}class dc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"next-round",valueSchema:new k(new O),omitEmpty:!0},{key:"online-total-weight",valueSchema:new k(new O),omitEmpty:!0},{key:"type",valueSchema:new k(new O),omitEmpty:!0},{key:"voters-commitment",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({nextRound:e,onlineTotalWeight:t,type:r,votersCommitment:i}){this.nextRound=typeof e>"u"?void 0:ve(e),this.onlineTotalWeight=typeof t>"u"?void 0:ve(t),this.type=typeof r>"u"?void 0:Oe(r),this.votersCommitment=typeof i=="string"?Ge(i):i}getEncodingSchema(){return dc.encodingSchema}toEncodingData(){return new Map([["next-round",this.nextRound],["online-total-weight",this.onlineTotalWeight],["type",this.type],["voters-commitment",this.votersCommitment]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofTracking: ${e}`);return new dc({nextRound:e.get("next-round"),onlineTotalWeight:e.get("online-total-weight"),type:e.get("type"),votersCommitment:e.get("voters-commitment")})}}class hc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"commitment",valueSchema:new k(new Pe),omitEmpty:!0},{key:"key-lifetime",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({commitment:e,keyLifetime:t}){this.commitment=typeof e=="string"?Ge(e):e,this.keyLifetime=typeof t>"u"?void 0:ve(t)}getEncodingSchema(){return hc.encodingSchema}toEncodingData(){return new Map([["commitment",this.commitment],["key-lifetime",this.keyLifetime]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateProofVerifier: ${e}`);return new hc({commitment:e.get("commitment"),keyLifetime:e.get("key-lifetime")})}}class Yi{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"num-byte-slice",valueSchema:new O,omitEmpty:!0},{key:"num-uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({numByteSlice:e,numUint:t}){this.numByteSlice=Oe(e),this.numUint=Oe(t)}getEncodingSchema(){return Yi.encodingSchema}toEncodingData(){return new Map([["num-byte-slice",this.numByteSlice],["num-uint",this.numUint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded StateSchema: ${e}`);return new Yi({numByteSlice:e.get("num-byte-slice"),numUint:e.get("num-uint")})}}class fo{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"key",valueSchema:new Pe,omitEmpty:!0},{key:"value",valueSchema:fc.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({key:e,value:t}){this.key=typeof e=="string"?Ge(e):e,this.value=t}getEncodingSchema(){return fo.encodingSchema}toEncodingData(){return new Map([["key",this.key],["value",this.value.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealKeyValue: ${e}`);return new fo({key:e.get("key"),value:fc.fromEncodingData(e.get("value")??new Map)})}}class fc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"bytes",valueSchema:new Pe,omitEmpty:!0},{key:"type",valueSchema:new O,omitEmpty:!0},{key:"uint",valueSchema:new O,omitEmpty:!0})),this.encodingSchemaValue}constructor({bytes:e,type:t,uint:r}){this.bytes=typeof e=="string"?Ge(e):e,this.type=Oe(t),this.uint=ve(r)}getEncodingSchema(){return fc.encodingSchema}toEncodingData(){return new Map([["bytes",this.bytes],["type",this.type],["uint",this.uint]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TealValue: ${e}`);return new fc({bytes:e.get("bytes"),type:e.get("type"),uint:e.get("uint")})}}class wr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"fee",valueSchema:new O,omitEmpty:!0},{key:"first-valid",valueSchema:new O,omitEmpty:!0},{key:"last-valid",valueSchema:new O,omitEmpty:!0},{key:"sender",valueSchema:new Ce,omitEmpty:!0},{key:"application-transaction",valueSchema:new k(pc.encodingSchema),omitEmpty:!0},{key:"asset-config-transaction",valueSchema:new k(gc.encodingSchema),omitEmpty:!0},{key:"asset-freeze-transaction",valueSchema:new k(mc.encodingSchema),omitEmpty:!0},{key:"asset-transfer-transaction",valueSchema:new k(yc.encodingSchema),omitEmpty:!0},{key:"auth-addr",valueSchema:new k(new Ce),omitEmpty:!0},{key:"close-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"closing-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"confirmed-round",valueSchema:new k(new O),omitEmpty:!0},{key:"created-application-index",valueSchema:new k(new O),omitEmpty:!0},{key:"created-asset-index",valueSchema:new k(new O),omitEmpty:!0},{key:"genesis-hash",valueSchema:new k(new Pe),omitEmpty:!0},{key:"genesis-id",valueSchema:new k(new Ce),omitEmpty:!0},{key:"global-state-delta",valueSchema:new k(new Me(ho.encodingSchema)),omitEmpty:!0},{key:"group",valueSchema:new k(new Pe),omitEmpty:!0},{key:"heartbeat-transaction",valueSchema:new k(wc.encodingSchema),omitEmpty:!0},{key:"id",valueSchema:new k(new Ce),omitEmpty:!0},{key:"inner-txns",valueSchema:new k(new Me(wr.encodingSchema)),omitEmpty:!0},{key:"intra-round-offset",valueSchema:new k(new O),omitEmpty:!0},{key:"keyreg-transaction",valueSchema:new k(xc.encodingSchema),omitEmpty:!0},{key:"lease",valueSchema:new k(new Pe),omitEmpty:!0},{key:"local-state-delta",valueSchema:new k(new Me(ja.encodingSchema)),omitEmpty:!0},{key:"logs",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"note",valueSchema:new k(new Pe),omitEmpty:!0},{key:"payment-transaction",valueSchema:new k(vc.encodingSchema),omitEmpty:!0},{key:"receiver-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"rekey-to",valueSchema:new k(new Ce),omitEmpty:!0},{key:"round-time",valueSchema:new k(new O),omitEmpty:!0},{key:"sender-rewards",valueSchema:new k(new O),omitEmpty:!0},{key:"signature",valueSchema:new k(Sc.encodingSchema),omitEmpty:!0},{key:"state-proof-transaction",valueSchema:new k(Ac.encodingSchema),omitEmpty:!0},{key:"tx-type",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({fee:e,firstValid:t,lastValid:r,sender:i,applicationTransaction:o,assetConfigTransaction:s,assetFreezeTransaction:a,assetTransferTransaction:l,authAddr:c,closeRewards:d,closingAmount:u,confirmedRound:m,createdApplicationIndex:h,createdAssetIndex:x,genesisHash:A,genesisId:v,globalStateDelta:F,group:w,heartbeatTransaction:C,id:M,innerTxns:N,intraRoundOffset:b,keyregTransaction:j,lease:p,localStateDelta:E,logs:S,note:$,paymentTransaction:B,receiverRewards:P,rekeyTo:W,roundTime:L,senderRewards:q,signature:J,stateProofTransaction:U,txType:ne}){this.fee=ve(e),this.firstValid=ve(t),this.lastValid=ve(r),this.sender=i,this.applicationTransaction=o,this.assetConfigTransaction=s,this.assetFreezeTransaction=a,this.assetTransferTransaction=l,this.authAddr=typeof c=="string"?ze.fromString(c):c,this.closeRewards=typeof d>"u"?void 0:ve(d),this.closingAmount=typeof u>"u"?void 0:ve(u),this.confirmedRound=typeof m>"u"?void 0:ve(m),this.createdApplicationIndex=typeof h>"u"?void 0:ve(h),this.createdAssetIndex=typeof x>"u"?void 0:ve(x),this.genesisHash=typeof A=="string"?Ge(A):A,this.genesisId=v,this.globalStateDelta=F,this.group=typeof w=="string"?Ge(w):w,this.heartbeatTransaction=C,this.id=M,this.innerTxns=N,this.intraRoundOffset=typeof b>"u"?void 0:Oe(b),this.keyregTransaction=j,this.lease=typeof p=="string"?Ge(p):p,this.localStateDelta=E,this.logs=S,this.note=typeof $=="string"?Ge($):$,this.paymentTransaction=B,this.receiverRewards=typeof P>"u"?void 0:ve(P),this.rekeyTo=typeof W=="string"?ze.fromString(W):W,this.roundTime=typeof L>"u"?void 0:Oe(L),this.senderRewards=typeof q>"u"?void 0:ve(q),this.signature=J,this.stateProofTransaction=U,this.txType=ne}getEncodingSchema(){return wr.encodingSchema}toEncodingData(){return new Map([["fee",this.fee],["first-valid",this.firstValid],["last-valid",this.lastValid],["sender",this.sender],["application-transaction",typeof this.applicationTransaction<"u"?this.applicationTransaction.toEncodingData():void 0],["asset-config-transaction",typeof this.assetConfigTransaction<"u"?this.assetConfigTransaction.toEncodingData():void 0],["asset-freeze-transaction",typeof this.assetFreezeTransaction<"u"?this.assetFreezeTransaction.toEncodingData():void 0],["asset-transfer-transaction",typeof this.assetTransferTransaction<"u"?this.assetTransferTransaction.toEncodingData():void 0],["auth-addr",typeof this.authAddr<"u"?this.authAddr.toString():void 0],["close-rewards",this.closeRewards],["closing-amount",this.closingAmount],["confirmed-round",this.confirmedRound],["created-application-index",this.createdApplicationIndex],["created-asset-index",this.createdAssetIndex],["genesis-hash",this.genesisHash],["genesis-id",this.genesisId],["global-state-delta",typeof this.globalStateDelta<"u"?this.globalStateDelta.map(e=>e.toEncodingData()):void 0],["group",this.group],["heartbeat-transaction",typeof this.heartbeatTransaction<"u"?this.heartbeatTransaction.toEncodingData():void 0],["id",this.id],["inner-txns",typeof this.innerTxns<"u"?this.innerTxns.map(e=>e.toEncodingData()):void 0],["intra-round-offset",this.intraRoundOffset],["keyreg-transaction",typeof this.keyregTransaction<"u"?this.keyregTransaction.toEncodingData():void 0],["lease",this.lease],["local-state-delta",typeof this.localStateDelta<"u"?this.localStateDelta.map(e=>e.toEncodingData()):void 0],["logs",this.logs],["note",this.note],["payment-transaction",typeof this.paymentTransaction<"u"?this.paymentTransaction.toEncodingData():void 0],["receiver-rewards",this.receiverRewards],["rekey-to",typeof this.rekeyTo<"u"?this.rekeyTo.toString():void 0],["round-time",this.roundTime],["sender-rewards",this.senderRewards],["signature",typeof this.signature<"u"?this.signature.toEncodingData():void 0],["state-proof-transaction",typeof this.stateProofTransaction<"u"?this.stateProofTransaction.toEncodingData():void 0],["tx-type",this.txType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded Transaction: ${e}`);return new wr({fee:e.get("fee"),firstValid:e.get("first-valid"),lastValid:e.get("last-valid"),sender:e.get("sender"),applicationTransaction:typeof e.get("application-transaction")<"u"?pc.fromEncodingData(e.get("application-transaction")):void 0,assetConfigTransaction:typeof e.get("asset-config-transaction")<"u"?gc.fromEncodingData(e.get("asset-config-transaction")):void 0,assetFreezeTransaction:typeof e.get("asset-freeze-transaction")<"u"?mc.fromEncodingData(e.get("asset-freeze-transaction")):void 0,assetTransferTransaction:typeof e.get("asset-transfer-transaction")<"u"?yc.fromEncodingData(e.get("asset-transfer-transaction")):void 0,authAddr:e.get("auth-addr"),closeRewards:e.get("close-rewards"),closingAmount:e.get("closing-amount"),confirmedRound:e.get("confirmed-round"),createdApplicationIndex:e.get("created-application-index"),createdAssetIndex:e.get("created-asset-index"),genesisHash:e.get("genesis-hash"),genesisId:e.get("genesis-id"),globalStateDelta:typeof e.get("global-state-delta")<"u"?e.get("global-state-delta").map(t=>ho.fromEncodingData(t)):void 0,group:e.get("group"),heartbeatTransaction:typeof e.get("heartbeat-transaction")<"u"?wc.fromEncodingData(e.get("heartbeat-transaction")):void 0,id:e.get("id"),innerTxns:typeof e.get("inner-txns")<"u"?e.get("inner-txns").map(t=>wr.fromEncodingData(t)):void 0,intraRoundOffset:e.get("intra-round-offset"),keyregTransaction:typeof e.get("keyreg-transaction")<"u"?xc.fromEncodingData(e.get("keyreg-transaction")):void 0,lease:e.get("lease"),localStateDelta:typeof e.get("local-state-delta")<"u"?e.get("local-state-delta").map(t=>ja.fromEncodingData(t)):void 0,logs:e.get("logs"),note:e.get("note"),paymentTransaction:typeof e.get("payment-transaction")<"u"?vc.fromEncodingData(e.get("payment-transaction")):void 0,receiverRewards:e.get("receiver-rewards"),rekeyTo:e.get("rekey-to"),roundTime:e.get("round-time"),senderRewards:e.get("sender-rewards"),signature:typeof e.get("signature")<"u"?Sc.fromEncodingData(e.get("signature")):void 0,stateProofTransaction:typeof e.get("state-proof-transaction")<"u"?Ac.fromEncodingData(e.get("state-proof-transaction")):void 0,txType:e.get("tx-type")})}}class pc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"application-id",valueSchema:new O,omitEmpty:!0},{key:"access",valueSchema:new k(new Me(oc.encodingSchema)),omitEmpty:!0},{key:"accounts",valueSchema:new k(new Me(new Ce)),omitEmpty:!0},{key:"application-args",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"approval-program",valueSchema:new k(new Pe),omitEmpty:!0},{key:"box-references",valueSchema:new k(new Me(uo.encodingSchema)),omitEmpty:!0},{key:"clear-state-program",valueSchema:new k(new Pe),omitEmpty:!0},{key:"extra-program-pages",valueSchema:new k(new O),omitEmpty:!0},{key:"foreign-apps",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"foreign-assets",valueSchema:new k(new Me(new O)),omitEmpty:!0},{key:"global-state-schema",valueSchema:new k(Yi.encodingSchema),omitEmpty:!0},{key:"local-state-schema",valueSchema:new k(Yi.encodingSchema),omitEmpty:!0},{key:"on-completion",valueSchema:new k(new Ce),omitEmpty:!0},{key:"reject-version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({applicationId:e,access:t,accounts:r,applicationArgs:i,approvalProgram:o,boxReferences:s,clearStateProgram:a,extraProgramPages:l,foreignApps:c,foreignAssets:d,globalStateSchema:u,localStateSchema:m,onCompletion:h,rejectVersion:x}){this.applicationId=ve(e),this.access=t,this.accounts=typeof r<"u"?r.map(A=>typeof A=="string"?ze.fromString(A):A):void 0,this.applicationArgs=i,this.approvalProgram=typeof o=="string"?Ge(o):o,this.boxReferences=s,this.clearStateProgram=typeof a=="string"?Ge(a):a,this.extraProgramPages=typeof l>"u"?void 0:Oe(l),this.foreignApps=typeof c>"u"?void 0:c.map(ve),this.foreignAssets=typeof d>"u"?void 0:d.map(ve),this.globalStateSchema=u,this.localStateSchema=m,this.onCompletion=h,this.rejectVersion=typeof x>"u"?void 0:Oe(x)}getEncodingSchema(){return pc.encodingSchema}toEncodingData(){return new Map([["application-id",this.applicationId],["access",typeof this.access<"u"?this.access.map(e=>e.toEncodingData()):void 0],["accounts",typeof this.accounts<"u"?this.accounts.map(e=>e.toString()):void 0],["application-args",this.applicationArgs],["approval-program",this.approvalProgram],["box-references",typeof this.boxReferences<"u"?this.boxReferences.map(e=>e.toEncodingData()):void 0],["clear-state-program",this.clearStateProgram],["extra-program-pages",this.extraProgramPages],["foreign-apps",this.foreignApps],["foreign-assets",this.foreignAssets],["global-state-schema",typeof this.globalStateSchema<"u"?this.globalStateSchema.toEncodingData():void 0],["local-state-schema",typeof this.localStateSchema<"u"?this.localStateSchema.toEncodingData():void 0],["on-completion",this.onCompletion],["reject-version",this.rejectVersion]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionApplication: ${e}`);return new pc({applicationId:e.get("application-id"),access:typeof e.get("access")<"u"?e.get("access").map(t=>oc.fromEncodingData(t)):void 0,accounts:e.get("accounts"),applicationArgs:e.get("application-args"),approvalProgram:e.get("approval-program"),boxReferences:typeof e.get("box-references")<"u"?e.get("box-references").map(t=>uo.fromEncodingData(t)):void 0,clearStateProgram:e.get("clear-state-program"),extraProgramPages:e.get("extra-program-pages"),foreignApps:e.get("foreign-apps"),foreignAssets:e.get("foreign-assets"),globalStateSchema:typeof e.get("global-state-schema")<"u"?Yi.fromEncodingData(e.get("global-state-schema")):void 0,localStateSchema:typeof e.get("local-state-schema")<"u"?Yi.fromEncodingData(e.get("local-state-schema")):void 0,onCompletion:e.get("on-completion"),rejectVersion:e.get("reject-version")})}}class gc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"asset-id",valueSchema:new k(new O),omitEmpty:!0},{key:"params",valueSchema:new k(lo.encodingSchema),omitEmpty:!0})),this.encodingSchemaValue}constructor({assetId:e,params:t}){this.assetId=typeof e>"u"?void 0:ve(e),this.params=t}getEncodingSchema(){return gc.encodingSchema}toEncodingData(){return new Map([["asset-id",this.assetId],["params",typeof this.params<"u"?this.params.toEncodingData():void 0]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionAssetConfig: ${e}`);return new gc({assetId:e.get("asset-id"),params:typeof e.get("params")<"u"?lo.fromEncodingData(e.get("params")):void 0})}}class mc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"address",valueSchema:new Ce,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"new-freeze-status",valueSchema:new gt,omitEmpty:!0})),this.encodingSchemaValue}constructor({address:e,assetId:t,newFreezeStatus:r}){this.address=e,this.assetId=ve(t),this.newFreezeStatus=r}getEncodingSchema(){return mc.encodingSchema}toEncodingData(){return new Map([["address",this.address],["asset-id",this.assetId],["new-freeze-status",this.newFreezeStatus]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionAssetFreeze: ${e}`);return new mc({address:e.get("address"),assetId:e.get("asset-id"),newFreezeStatus:e.get("new-freeze-status")})}}class yc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"asset-id",valueSchema:new O,omitEmpty:!0},{key:"receiver",valueSchema:new Ce,omitEmpty:!0},{key:"close-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"close-to",valueSchema:new k(new Ce),omitEmpty:!0},{key:"sender",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,assetId:t,receiver:r,closeAmount:i,closeTo:o,sender:s}){this.amount=ve(e),this.assetId=ve(t),this.receiver=r,this.closeAmount=typeof i>"u"?void 0:ve(i),this.closeTo=o,this.sender=s}getEncodingSchema(){return yc.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["asset-id",this.assetId],["receiver",this.receiver],["close-amount",this.closeAmount],["close-to",this.closeTo],["sender",this.sender]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionAssetTransfer: ${e}`);return new yc({amount:e.get("amount"),assetId:e.get("asset-id"),receiver:e.get("receiver"),closeAmount:e.get("close-amount"),closeTo:e.get("close-to"),sender:e.get("sender")})}}class wc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"hb-address",valueSchema:new Ce,omitEmpty:!0},{key:"hb-key-dilution",valueSchema:new O,omitEmpty:!0},{key:"hb-proof",valueSchema:Qa.encodingSchema,omitEmpty:!0},{key:"hb-seed",valueSchema:new Pe,omitEmpty:!0},{key:"hb-vote-id",valueSchema:new Pe,omitEmpty:!0})),this.encodingSchemaValue}constructor({hbAddress:e,hbKeyDilution:t,hbProof:r,hbSeed:i,hbVoteId:o}){this.hbAddress=e,this.hbKeyDilution=ve(t),this.hbProof=r,this.hbSeed=typeof i=="string"?Ge(i):i,this.hbVoteId=typeof o=="string"?Ge(o):o}getEncodingSchema(){return wc.encodingSchema}toEncodingData(){return new Map([["hb-address",this.hbAddress],["hb-key-dilution",this.hbKeyDilution],["hb-proof",this.hbProof.toEncodingData()],["hb-seed",this.hbSeed],["hb-vote-id",this.hbVoteId]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionHeartbeat: ${e}`);return new wc({hbAddress:e.get("hb-address"),hbKeyDilution:e.get("hb-key-dilution"),hbProof:Qa.fromEncodingData(e.get("hb-proof")??new Map),hbSeed:e.get("hb-seed"),hbVoteId:e.get("hb-vote-id")})}}class xc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"non-participation",valueSchema:new k(new gt),omitEmpty:!0},{key:"selection-participation-key",valueSchema:new k(new Pe),omitEmpty:!0},{key:"state-proof-key",valueSchema:new k(new Pe),omitEmpty:!0},{key:"vote-first-valid",valueSchema:new k(new O),omitEmpty:!0},{key:"vote-key-dilution",valueSchema:new k(new O),omitEmpty:!0},{key:"vote-last-valid",valueSchema:new k(new O),omitEmpty:!0},{key:"vote-participation-key",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({nonParticipation:e,selectionParticipationKey:t,stateProofKey:r,voteFirstValid:i,voteKeyDilution:o,voteLastValid:s,voteParticipationKey:a}){this.nonParticipation=e,this.selectionParticipationKey=typeof t=="string"?Ge(t):t,this.stateProofKey=typeof r=="string"?Ge(r):r,this.voteFirstValid=typeof i>"u"?void 0:ve(i),this.voteKeyDilution=typeof o>"u"?void 0:ve(o),this.voteLastValid=typeof s>"u"?void 0:ve(s),this.voteParticipationKey=typeof a=="string"?Ge(a):a}getEncodingSchema(){return xc.encodingSchema}toEncodingData(){return new Map([["non-participation",this.nonParticipation],["selection-participation-key",this.selectionParticipationKey],["state-proof-key",this.stateProofKey],["vote-first-valid",this.voteFirstValid],["vote-key-dilution",this.voteKeyDilution],["vote-last-valid",this.voteLastValid],["vote-participation-key",this.voteParticipationKey]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionKeyreg: ${e}`);return new xc({nonParticipation:e.get("non-participation"),selectionParticipationKey:e.get("selection-participation-key"),stateProofKey:e.get("state-proof-key"),voteFirstValid:e.get("vote-first-valid"),voteKeyDilution:e.get("vote-key-dilution"),voteLastValid:e.get("vote-last-valid"),voteParticipationKey:e.get("vote-participation-key")})}}class vc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"amount",valueSchema:new O,omitEmpty:!0},{key:"receiver",valueSchema:new Ce,omitEmpty:!0},{key:"close-amount",valueSchema:new k(new O),omitEmpty:!0},{key:"close-remainder-to",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({amount:e,receiver:t,closeAmount:r,closeRemainderTo:i}){this.amount=ve(e),this.receiver=t,this.closeAmount=typeof r>"u"?void 0:ve(r),this.closeRemainderTo=i}getEncodingSchema(){return vc.encodingSchema}toEncodingData(){return new Map([["amount",this.amount],["receiver",this.receiver],["close-amount",this.closeAmount],["close-remainder-to",this.closeRemainderTo]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionPayment: ${e}`);return new vc({amount:e.get("amount"),receiver:e.get("receiver"),closeAmount:e.get("close-amount"),closeRemainderTo:e.get("close-remainder-to")})}}class zl{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"transaction",valueSchema:wr.encodingSchema,omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,transaction:t}){this.currentRound=ve(e),this.transaction=t}getEncodingSchema(){return zl.encodingSchema}toEncodingData(){return new Map([["current-round",this.currentRound],["transaction",this.transaction.toEncodingData()]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionResponse: ${e}`);return new zl({currentRound:e.get("current-round"),transaction:wr.fromEncodingData(e.get("transaction")??new Map)})}}class Sc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logicsig",valueSchema:new k(bc.encodingSchema),omitEmpty:!0},{key:"multisig",valueSchema:new k(Wr.encodingSchema),omitEmpty:!0},{key:"sig",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({logicsig:e,multisig:t,sig:r}){this.logicsig=e,this.multisig=t,this.sig=typeof r=="string"?Ge(r):r}getEncodingSchema(){return Sc.encodingSchema}toEncodingData(){return new Map([["logicsig",typeof this.logicsig<"u"?this.logicsig.toEncodingData():void 0],["multisig",typeof this.multisig<"u"?this.multisig.toEncodingData():void 0],["sig",this.sig]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignature: ${e}`);return new Sc({logicsig:typeof e.get("logicsig")<"u"?bc.fromEncodingData(e.get("logicsig")):void 0,multisig:typeof e.get("multisig")<"u"?Wr.fromEncodingData(e.get("multisig")):void 0,sig:e.get("sig")})}}class bc{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"logic",valueSchema:new Pe,omitEmpty:!0},{key:"args",valueSchema:new k(new Me(new Pe)),omitEmpty:!0},{key:"logic-multisig-signature",valueSchema:new k(Wr.encodingSchema),omitEmpty:!0},{key:"multisig-signature",valueSchema:new k(Wr.encodingSchema),omitEmpty:!0},{key:"signature",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({logic:e,args:t,logicMultisigSignature:r,multisigSignature:i,signature:o}){this.logic=typeof e=="string"?Ge(e):e,this.args=t,this.logicMultisigSignature=r,this.multisigSignature=i,this.signature=typeof o=="string"?Ge(o):o}getEncodingSchema(){return bc.encodingSchema}toEncodingData(){return new Map([["logic",this.logic],["args",this.args],["logic-multisig-signature",typeof this.logicMultisigSignature<"u"?this.logicMultisigSignature.toEncodingData():void 0],["multisig-signature",typeof this.multisigSignature<"u"?this.multisigSignature.toEncodingData():void 0],["signature",this.signature]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignatureLogicsig: ${e}`);return new bc({logic:e.get("logic"),args:e.get("args"),logicMultisigSignature:typeof e.get("logic-multisig-signature")<"u"?Wr.fromEncodingData(e.get("logic-multisig-signature")):void 0,multisigSignature:typeof e.get("multisig-signature")<"u"?Wr.fromEncodingData(e.get("multisig-signature")):void 0,signature:e.get("signature")})}}class Wr{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"subsignature",valueSchema:new k(new Me(Ec.encodingSchema)),omitEmpty:!0},{key:"threshold",valueSchema:new k(new O),omitEmpty:!0},{key:"version",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({subsignature:e,threshold:t,version:r}){this.subsignature=e,this.threshold=typeof t>"u"?void 0:Oe(t),this.version=typeof r>"u"?void 0:Oe(r)}getEncodingSchema(){return Wr.encodingSchema}toEncodingData(){return new Map([["subsignature",typeof this.subsignature<"u"?this.subsignature.map(e=>e.toEncodingData()):void 0],["threshold",this.threshold],["version",this.version]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignatureMultisig: ${e}`);return new Wr({subsignature:typeof e.get("subsignature")<"u"?e.get("subsignature").map(t=>Ec.fromEncodingData(t)):void 0,threshold:e.get("threshold"),version:e.get("version")})}}class Ec{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"public-key",valueSchema:new k(new Pe),omitEmpty:!0},{key:"signature",valueSchema:new k(new Pe),omitEmpty:!0})),this.encodingSchemaValue}constructor({publicKey:e,signature:t}){this.publicKey=typeof e=="string"?Ge(e):e,this.signature=typeof t=="string"?Ge(t):t}getEncodingSchema(){return Ec.encodingSchema}toEncodingData(){return new Map([["public-key",this.publicKey],["signature",this.signature]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionSignatureMultisigSubsignature: ${e}`);return new Ec({publicKey:e.get("public-key"),signature:e.get("signature")})}}class Ac{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"message",valueSchema:new k(tc.encodingSchema),omitEmpty:!0},{key:"state-proof",valueSchema:new k(sc.encodingSchema),omitEmpty:!0},{key:"state-proof-type",valueSchema:new k(new O),omitEmpty:!0})),this.encodingSchemaValue}constructor({message:e,stateProof:t,stateProofType:r}){this.message=e,this.stateProof=t,this.stateProofType=typeof r>"u"?void 0:Oe(r)}getEncodingSchema(){return Ac.encodingSchema}toEncodingData(){return new Map([["message",typeof this.message<"u"?this.message.toEncodingData():void 0],["state-proof",typeof this.stateProof<"u"?this.stateProof.toEncodingData():void 0],["state-proof-type",this.stateProofType]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionStateProof: ${e}`);return new Ac({message:typeof e.get("message")<"u"?tc.fromEncodingData(e.get("message")):void 0,stateProof:typeof e.get("state-proof")<"u"?sc.fromEncodingData(e.get("state-proof")):void 0,stateProofType:e.get("state-proof-type")})}}class Ts{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new oe([]),this.encodingSchemaValue.pushEntries({key:"current-round",valueSchema:new O,omitEmpty:!0},{key:"transactions",valueSchema:new Me(wr.encodingSchema),omitEmpty:!0},{key:"next-token",valueSchema:new k(new Ce),omitEmpty:!0})),this.encodingSchemaValue}constructor({currentRound:e,transactions:t,nextToken:r}){this.currentRound=ve(e),this.transactions=t,this.nextToken=r}getEncodingSchema(){return Ts.encodingSchema}toEncodingData(){return new Map([["current-round",this.currentRound],["transactions",this.transactions.map(e=>e.toEncodingData())],["next-token",this.nextToken]])}static fromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded TransactionsResponse: ${e}`);return new Ts({currentRound:e.get("current-round"),transactions:(e.get("transactions")??[]).map(t=>wr.fromEncodingData(t)),nextToken:e.get("next-token")})}}const Ek=Object.freeze(Object.defineProperty({__proto__:null,Account:so,AccountParticipation:Ua,AccountResponse:Bl,AccountStateDelta:ja,AccountsResponse:Nl,Application:Zr,ApplicationLocalState:ao,ApplicationLocalStatesResponse:Pl,ApplicationLogData:Ga,ApplicationLogsResponse:Ol,ApplicationParams:Wa,ApplicationResponse:Ll,ApplicationStateSchema:yr,ApplicationsResponse:za,Asset:Jr,AssetBalancesResponse:Vl,AssetHolding:co,AssetHoldingsResponse:$l,AssetParams:lo,AssetResponse:_l,AssetsResponse:Ha,Block:Ds,BlockHeadersResponse:Ul,BlockRewards:Ya,BlockUpgradeState:Ka,BlockUpgradeVote:qa,Box:jl,BoxDescriptor:Xa,BoxReference:uo,BoxesResponse:Gl,ErrorResponse:Sd,EvalDelta:Za,EvalDeltaKeyValue:ho,HashFactory:Ja,HbProofFields:Qa,HealthCheck:Wl,HoldingRef:ec,IndexerStateProofMessage:tc,LocalsRef:nc,MerkleArrayProof:Gr,MiniAssetHolding:rc,ParticipationUpdates:ic,ResourceRef:oc,StateProofFields:sc,StateProofParticipant:ac,StateProofReveal:cc,StateProofSigSlot:lc,StateProofSignature:uc,StateProofTracking:dc,StateProofVerifier:hc,StateSchema:Yi,TealKeyValue:fo,TealValue:fc,Transaction:wr,TransactionApplication:pc,TransactionAssetConfig:gc,TransactionAssetFreeze:mc,TransactionAssetTransfer:yc,TransactionHeartbeat:wc,TransactionKeyreg:xc,TransactionPayment:vc,TransactionResponse:zl,TransactionSignature:Sc,TransactionSignatureLogicsig:bc,TransactionSignatureMultisig:Wr,TransactionSignatureMultisigSubsignature:Ec,TransactionStateProof:Ac,TransactionsResponse:Ts},Symbol.toStringTag,{value:"Module"}));class Ak extends lt{path(){return"/health"}prepare(e){return Et(e.getJSONText(),Wl)}}class Ik extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}/balances`}limit(e){return this.query.limit=e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),Vl)}}function bd(n){return typeof n=="string"?n:In(n)}class kk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/transactions`}notePrefix(e){return this.query["note-prefix"]=bd(e),this}txType(e){return this.query["tx-type"]=e,this}sigType(e){return this.query["sig-type"]=e,this}txid(e){return this.query.txid=e,this}round(e){return this.query.round=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}assetID(e){return this.query["asset-id"]=e,this}limit(e){return this.query.limit=e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}nextToken(e){return this.query.next=e,this}rekeyTo(e){return this.query["rekey-to"]=e,this}prepare(e){return Et(e.getJSONText(),Ts)}}class Ck extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}/transactions`}notePrefix(e){return this.query["note-prefix"]=bd(e),this}txType(e){return this.query["tx-type"]=e,this}sigType(e){return this.query["sig-type"]=e,this}txid(e){return this.query.txid=e,this}round(e){return this.query.round=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}limit(e){return this.query.limit=e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}addressRole(e){return this.query["address-role"]=e,this}address(e){return this.query.address=e.toString(),this}excludeCloseTo(e){return this.query["exclude-close-to"]=e,this}nextToken(e){return this.query.next=e,this}rekeyTo(e){return this.query["rekey-to"]=e,this}prepare(e){return Et(e.getJSONText(),Ts)}}class Fk extends lt{constructor(e,t){super(e),this.round=BigInt(t)}path(){return`/v2/blocks/${this.round}`}headerOnly(e){return this.query["header-only"]=e,this}prepare(e){return Et(e.getJSONText(),Ds)}}class Dk extends lt{constructor(e,t){super(e),this.txID=t}path(){return`/v2/transactions/${this.txID}`}prepare(e){return Et(e.getJSONText(),zl)}}class Tk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}`}round(e){return this.query.round=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}exclude(e){return this.query.exclude=e,this}prepare(e){return Et(e.getJSONText(),Bl)}}class Mk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/assets`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}assetId(e){return this.query["asset-id"]=e,this}prepare(e){return Et(e.getJSONText(),$l)}}class Rk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/created-assets`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}assetID(e){return this.query["asset-id"]=e,this}prepare(e){return Et(e.getJSONText(),Ha)}}class Bk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/apps-local-state`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}applicationID(e){return this.query["application-id"]=e,this}prepare(e){return Et(e.getJSONText(),Pl)}}class Nk extends lt{constructor(e,t){super(e),this.account=t.toString()}path(){return`/v2/accounts/${this.account}/created-applications`}limit(e){return this.query.limit=e,this}round(e){return this.query.round=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}applicationID(e){return this.query["application-id"]=e,this}prepare(e){return Et(e.getJSONText(),za)}}class Pk extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/assets/${this.index}`}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),_l)}}class Ok extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/applications/${this.index}`}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),Ll)}}class Lk extends lt{constructor(e,t){super(e),this.appID=BigInt(t)}path(){return`/v2/applications/${this.appID}/logs`}limit(e){return this.query.limit=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}nextToken(e){return this.query.next=e,this}sender(e){return this.query["sender-address"]=e,this}txid(e){return this.query.txid=e,this}prepare(e){return Et(e.getJSONText(),Ol)}}class Vk extends lt{constructor(e,t,r){super(e),this.index=BigInt(t);const i=In(r);this.query.name=encodeURI(`b64:${i}`)}path(){return`/v2/applications/${this.index}/box`}prepare(e){return Et(e.getJSONText(),jl)}}class $k extends lt{path(){return"/v2/accounts"}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}limit(e){return this.query.limit=e,this}assetID(e){return this.query["asset-id"]=e,this}nextToken(e){return this.query.next=e,this}round(e){return this.query.round=e,this}authAddr(e){return this.query["auth-addr"]=e.toString(),this}applicationID(e){return this.query["application-id"]=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}exclude(e){return this.query.exclude=e,this}onlineOnly(e){return this.query["online-only"]=e,this}prepare(e){return Et(e.getJSONText(),Nl)}}class _k extends lt{path(){return"/v2/block-headers"}absent(e){return this.query.absent=e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}expired(e){return this.query.expired=e,this}limit(e){return this.query.limit=e,this}maxRound(e){return this.query["max-round"]=e,this}minRound(e){return this.query["min-round"]=e,this}nextToken(e){return this.query.next=e,this}proposers(e){return this.query.proposers=e,this}prepare(e){return Et(e.getJSONText(),Ul)}}class Uk extends lt{path(){return"/v2/transactions"}notePrefix(e){return this.query["note-prefix"]=bd(e),this}txType(e){return this.query["tx-type"]=e,this}sigType(e){return this.query["sig-type"]=e,this}txid(e){return this.query.txid=e,this}groupid(e){return this.query["group-id"]=bd(e),this}round(e){return this.query.round=e,this}minRound(e){return this.query["min-round"]=e,this}maxRound(e){return this.query["max-round"]=e,this}assetID(e){return this.query["asset-id"]=e,this}limit(e){return this.query.limit=e,this}beforeTime(e){return this.query["before-time"]=e instanceof Date?e.toISOString():e,this}afterTime(e){return this.query["after-time"]=e instanceof Date?e.toISOString():e,this}addressRole(e){return this.query["address-role"]=e,this}address(e){return this.query.address=e.toString(),this}excludeCloseTo(e){return this.query["exclude-close-to"]=e,this}nextToken(e){return this.query.next=e,this}rekeyTo(e){return this.query["rekey-to"]=e,this}applicationID(e){return this.query["application-id"]=e,this}currencyGreaterThan(e){return this.query["currency-greater-than"]=e.toString(),this}currencyLessThan(e){return this.query["currency-less-than"]=e,this}prepare(e){return Et(e.getJSONText(),Ts)}}class jk extends lt{path(){return"/v2/assets"}limit(e){return this.query.limit=e,this}creator(e){return this.query.creator=e.toString(),this}name(e){return this.query.name=e,this}unit(e){return this.query.unit=e,this}index(e){return this.query["asset-id"]=e,this}nextToken(e){return this.query.next=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),Ha)}}class Gk extends lt{path(){return"/v2/applications"}index(e){return this.query["application-id"]=e,this}creator(e){return this.query.creator=e.toString(),this}nextToken(e){return this.query.next=e,this}limit(e){return this.query.limit=e,this}includeAll(e=!0){return this.query["include-all"]=e,this}prepare(e){return Et(e.getJSONText(),za)}}class Wk extends lt{constructor(e,t){super(e),this.index=BigInt(t)}path(){return`/v2/applications/${this.index}/boxes`}nextToken(e){return this.query.next=e,this}limit(e){return this.query.limit=e,this}prepare(e){return Et(e.getJSONText(),Gl)}}class zk extends cg{constructor(e,t="http://127.0.0.1",r=8080,i={}){super("X-Indexer-API-Token",e,t,r,i)}makeHealthCheck(){return new Ak(this.c)}lookupAssetBalances(e){return new Ik(this.c,e)}lookupAssetTransactions(e){return new Ck(this.c,e)}lookupAccountTransactions(e){return new kk(this.c,e)}lookupBlock(e){return new Fk(this.c,e)}lookupTransactionByID(e){return new Dk(this.c,e)}lookupAccountByID(e){return new Tk(this.c,e)}lookupAccountAssets(e){return new Mk(this.c,e)}lookupAccountCreatedAssets(e){return new Rk(this.c,e)}lookupAccountAppLocalStates(e){return new Bk(this.c,e)}lookupAccountCreatedApplications(e){return new Nk(this.c,e)}lookupAssetByID(e){return new Pk(this.c,e)}lookupApplications(e){return new Ok(this.c,e)}lookupApplicationLogs(e){return new Lk(this.c,e)}searchAccounts(){return new $k(this.c)}searchForBlockHeaders(){return new _k(this.c)}searchForTransactions(){return new Uk(this.c)}searchForAssets(){return new jk(this.c)}searchForApplications(){return new Gk(this.c)}searchForApplicationBoxes(e){return new Wk(this.c,e)}lookupApplicationBoxByIDandName(e,t){return new Vk(this.c,e,t)}}async function wx(n,e,t){const r=await n.status().do();if(typeof r>"u")throw new Error("Unable to get node status");const i=r.lastRound+BigInt(1),o=i+BigInt(t);let s=i;for(;s<o;){let a=!1;try{const l=await n.pendingTransactionInformation(e).do();if(l.confirmedRound)return l;if(l.poolError)throw a=!0,new Error(`Transaction Rejected: ${l.poolError}`)}catch(l){if(a)throw l}await n.statusAfterBlock(s).do(),s+=BigInt(1)}throw new Error(`Transaction not confirmed after ${t} rounds`)}function Ms(n,e){let t=n.toString(16);t.length!==e*2&&(t=t.padStart(e*2,"0"));const r=new Uint8Array(t.length/2);for(let i=0,o=0;i<t.length/2;i++,o+=2)r[i]=parseInt(t.slice(o,o+2),16);return r}function hg(n){let e=BigInt(0);const t=new DataView(n.buffer,n.byteOffset);for(let r=0;r<n.length;r++)e=BigInt(Number(t.getUint8(r)))+e*BigInt(256);return e}function Hk(){const n=q1();return{addr:new ze(n.publicKey),sk:n.secretKey}}const Cp=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"],Ph="failed to decode mnemonic",Yk="the mnemonic contains a word that is not in the wordlist";function xx(n){const e=[];let t=0,r=0;function i(s){t|=s<<r,r+=8,r>=11&&(e.push(t&2047),t>>=11,r-=11)}function o(){r&&e.push(t)}return n.forEach(i),o(),e}function vx(n){return n.map(e=>Cp[e])}function Sx(n){const e=wi(n),t=xx(e);return vx(t)[0]}function fg(n){if(n.length!==Lf)throw new RangeError(`Seed length must be ${Lf}`);const e=xx(n),t=vx(e),r=Sx(n);return`${t.join(" ")} ${r}`}function Kk(n){const e=[];let t=0,r=0;function i(s){for(t|=s<<r,r+=11;r>=8;)e.push(t&255),t>>=8,r-=8}function o(){r&&e.push(t)}return n.forEach(i),o(),new Uint8Array(e)}function pg(n){const e=n.split(" "),t=e.slice(0,24);for(const a of t)if(Cp.indexOf(a)===-1)throw new Error(Yk);const r=e[e.length-1],i=t.map(a=>Cp.indexOf(a));let o=Kk(i);if(o.length!==33)throw new Error(Ph);if(o[o.length-1]!==0)throw new Error(Ph);if(o=o.slice(0,o.length-1),Sx(o)===r)return o;throw new Error(Ph)}function qk(n){const e=pg(n),t=V0(e);return{addr:new ze(t.publicKey),sk:t.secretKey}}function Xk(n){const e=n.slice(0,Lf);return fg(e)}function Zk(n){return pg(n)}function Jk(n){return fg(n)}const Jm=16,Qk=new TextEncoder().encode("TG");function eC(n){if(n.length>Jm)throw new Error(`${n.length} transactions grouped together but max group size is ${Jm}`);if(n.length===0)throw new Error("Cannot compute group ID of zero transactions");const e=du({txlist:n});return hn(Qk,e)}function bx(n){const e=[];for(const i of n)e.push(i.rawTxID());const t=eC(e),r=wi(t);return Uint8Array.from(r)}function Ex(n){const e=bx(n);for(const t of n)t.group=e;return n}function tC(n,e,t){if(!e.verify(t.publicKey))throw new Error("Logic signature verification failed. Ensure the program and signature are valid.");let r;_0(t.publicKey,n.sender.publicKey)||(r=t);const i=new jt({lsig:e,txn:n,sgnr:r});return{txID:n.txID(),blob:Sr(i)}}function gg(n,e){let t,r;if(e instanceof dg)t=e.lsig,r=e.address();else if(t=e,t.sig)r=new ze(n.sender.publicKey);else if(t.lmsig){const i={version:t.lmsig.v,threshold:t.lmsig.thr,pks:t.lmsig.subsig.map(o=>o.pk)};r=xi(i)}else r=t.address();return tC(n,t,r)}function nC(n,e){return gg(n,e)}const rC="Not enough multisig transactions to merge. Need at least two",iC="Cannot merge txs. txIDs differ",oC="Cannot merge txs. Auth addrs differ",Qm="Cannot merge txs. Multisig preimages differ",sC="Cannot merge txs. subsigs are mismatched.",aC="Cannot add multisig signature. Signature is not of the correct length.",cC="Key does not exist";function Ax(n,{version:e,threshold:t,addrs:r}){const i=Tc(r),o=i.map(d=>({pk:d})),s={v:e,thr:t,subsig:o},a=xi({version:e,threshold:t,pks:i});let l;n.sender.equals(a)||(l=a);const c=new jt({txn:n,msig:s,sgnr:l});return Sr(c)}function Ix(n,{rawSig:e,myPk:t},{version:r,threshold:i,pks:o}){const s=Ax(n,{version:r,threshold:i,addrs:o.map(c=>new ze(c))}),a=Xt(s,jt);let l=!1;if(a.msig.subsig.forEach((c,d)=>{_0(c.pk,t)&&(l=!0,a.msig.subsig[d].s=e)}),!l)throw new Error(cC);return Sr(a)}function kx(n,{version:e,threshold:t,pks:r},i){const o=jd(i).publicKey;return Ix(n,{rawSig:n.rawSignTxn(i),myPk:o},{version:e,threshold:t,pks:r})}function lC(n,e,t,r){if(!$0(r.length))throw new Error(aC);const i=typeof t=="string"?ze.fromString(t):t;return Ix(n,{rawSig:r,myPk:i.publicKey},e)}function Qd(n){if(n.length<2)throw new Error(rC);const e=Xt(n[0],jt);if(!e.msig)throw new Error("Invalid multisig transaction, multisig structure missing at index 0");const t=e.txn.txID(),r=e.sgnr?e.sgnr.toString():void 0,i={version:e.msig.v,threshold:e.msig.thr,pks:e.msig.subsig.map(d=>d.pk)},o=xi(i),s=e.msig.subsig.map(d=>({...d}));for(let d=1;d<n.length;d++){const u=Xt(n[d],jt);if(!u.msig)throw new Error(`Invalid multisig transaction, multisig structure missing at index ${d}`);if(u.txn.txID()!==t)throw new Error(iC);const m=u.sgnr?u.sgnr.toString():void 0;if(r!==m)throw new Error(oC);if(u.msig.subsig.length!==e.msig.subsig.length)throw new Error(Qm);const h={version:u.msig.v,threshold:u.msig.thr,pks:u.msig.subsig.map(A=>A.pk)},x=xi(h);if(!o.equals(x))throw new Error(Qm);u.msig.subsig.forEach((A,v)=>{if(!A.s)return;const F=s[v];if(F.s&&!Kr(A.s,F.s))throw new Error(sC);F.s=A.s})}const a={v:e.msig.v,thr:e.msig.thr,subsig:s},l=typeof r<"u"?e.sgnr:void 0,c=new jt({msig:a,txn:e.txn,sgnr:l});return Sr(c)}function Cx(n,{version:e,threshold:t,addrs:r},i){const o=Tc(r),s=kx(n,{version:e,threshold:t,pks:o},i);return{txID:n.txID(),blob:s}}function uC(n,{version:e,threshold:t,addrs:r},i){const o=Tc(r),s=Xt(n,jt),a=kx(s.txn,{version:e,threshold:t,pks:o},i);return{txID:s.txn.txID(),blob:Qd([n,a])}}function dC(n,{version:e,threshold:t,addrs:r},i,o){const s=Tc(r),a=Xt(n,jt),l=lC(a.txn,{version:e,threshold:t,pks:s},i,o);return{txID:a.txn.txID(),blob:Qd([n,l])}}let Fx={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(n,e){Fx[n]=e});function hC(n){let e=[],t=0,r=0;for(let i=0;i<n.length;i+=1){let o=Fx[n[i]];if(o===void 0)throw new Error("Invalid character ("+n[i]+")");const s=o&32;if(o&=31,r+=o<<t,s)t+=5;else{const a=r&1;r>>>=1,a?e.push(r===0?-2147483648:-r):e.push(r),r=t=0}}return e}class Dx{constructor({version:e,sources:t,names:r,mappings:i}){if(this.version=e,this.sources=t,this.names=r,this.mappings=i,this.version!==3)throw new Error(`Only version 3 is supported, got ${this.version}`);if(this.mappings===void 0)throw new Error("mapping undefined, cannot build source map without `mapping`");const o=this.mappings.split(";").map(hC);this.pcToLocation=new Map,this.sourceAndLineToPc=new Map;const s={line:0,column:0,sourceIndex:0,nameIndex:0};for(const[a,l]of o.entries()){if(l.length<4)continue;const c=l.length>4?l[4]:void 0,[,d,u,m]=l;s.sourceIndex+=d,s.line+=u,s.column+=m,typeof c<"u"&&(s.nameIndex+=c);const h=`${s.sourceIndex}:${s.line}`;let x=this.sourceAndLineToPc.get(h);x===void 0&&(x=[],this.sourceAndLineToPc.set(h,x));const A={pc:a,column:s.column},v={line:s.line,column:s.column,sourceIndex:s.sourceIndex};typeof c<"u"&&(A.nameIndex=s.nameIndex,v.nameIndex=s.nameIndex),x.push(A),this.pcToLocation.set(a,v)}}getPcs(){return Array.from(this.pcToLocation.keys())}getLocationForPc(e){return this.pcToLocation.get(e)}getPcsOnSourceLine(e,t){const r=this.sourceAndLineToPc.get(`${e}:${t}`);return r===void 0?[]:r}}const fC=1380011588,mg=30;async function pC({client:n,txns:e,protocolVersion:t,latestTimestamp:r,round:i,sources:o}){const s=[],a=[],l=[],c=[],d=[];for(const x of e)if(x.txn.type===Bt.appl)if(d.push(x.txn.sender.toString()),d.push(...x.txn.applicationCall.accounts.map(A=>A.toString())),l.push(...x.txn.applicationCall.foreignApps),d.push(...x.txn.applicationCall.foreignApps.map(dd).map(A=>A.toString())),c.push(...x.txn.applicationCall.foreignAssets),x.txn.applicationCall.appIndex===BigInt(0))s.push(new Is({id:fC,params:new Ea({creator:x.txn.sender.toString(),approvalProgram:x.txn.applicationCall.approvalProgram,clearStateProgram:x.txn.applicationCall.clearProgram,localStateSchema:new Dr({numUint:x.txn.applicationCall.numLocalInts,numByteSlice:x.txn.applicationCall.numLocalByteSlices}),globalStateSchema:new Dr({numUint:x.txn.applicationCall.numGlobalInts,numByteSlice:x.txn.applicationCall.numGlobalByteSlices})})}));else{const{appIndex:A}=x.txn.applicationCall;l.push(A),d.push(dd(A).toString())}const u=[];for(const x of new Set(c))u.push(n.getAssetByID(x).do().then(A=>{d.push(A.params.creator)}));await Promise.all(u);const m=[];for(const x of new Set(l))m.push(n.getApplicationByID(x).do().then(A=>{s.push(A),d.push(A.params.creator.toString())}));await Promise.all(m);const h=[];for(const x of new Set(d))h.push(n.accountInformation(x).do().then(A=>{a.push(A)}));return await Promise.all(h),new Sl({txns:e.slice(),accounts:a,apps:s,latestTimestamp:r??0,round:i??0,protocolVersion:t??"",sources:o??[]})}function Oh(n,e){return n.length>e&&e>0?`${n.slice(0,e)}...`:n}function gC(n,e){if(e.length===0)return"";let t=null;for(let i=0;i<e.length;i++){if(i>n.length){t=i;continue}yi(n[i])!==yi(e[i])&&(t=i)}if(t==null)return"";const r=e[t];return r.bytes.length>0?`${t} = 0x${zd(r.bytes)}`:`${t} = ${r.uint.toString()}`}function mC(n,e){return`[${(e?n.reverse():n).map(r=>{switch(r.type){case 1:return`0x${zd(r.bytes)}`;case 2:return r.uint.toString();default:return""}}).join(", ")}]`}function Tx(n,e,t){const r=t.maxValueWidth||mg,i=[["pc#","ln#","source","scratch","stack"]];for(let s=0;s<n.length;s++){const{line:a,error:l,pc:c,scratch:d,stack:u}=n[s],m=d!==void 0?d:[],h=s>0&&n[s-1].scratch!==void 0?n[s-1].scratch:[],x=l?`!! ${l} !!`:e[a];i.push([c.toString().padEnd(3," "),a.toString().padEnd(3," "),Oh(x,r),Oh(gC(h,m),r),Oh(mC(u,t.topOfStackFirst),r)])}const o=i.reduce((s,a)=>{const l=new Array(i[0].length).fill(0);for(let c=0;c<s.length;c++)l[c]=a[c].length>s[c]?a[c].length:s[c];return l},new Array(i[0].length).fill(0));return`${i.map(s=>s.map((a,l)=>a.padEnd(o[l]+1," ")).join("|").trim()).join(`
38
38
  `)}
39
- `}function yC(n,e){if(!n.appCallTrace||!n.disassembly)return"";let t=e;return e!==void 0?t=e:t={maxValueWidth:mg,topOfStackFirst:!1},Tx(n.appCallTrace,n.disassembly,t)}function wC(n,e){if(!n.logicSigTrace||!n.logicSigDisassembly)return"";let t;return e!==void 0?t=e:t={maxValueWidth:mg,topOfStackFirst:!0},Tx(n.logicSigTrace,n.logicSigDisassembly,t)}function xC({sender:n,receiver:e,amount:t,closeRemainderTo:r,suggestedParams:i,note:o,lease:s,rekeyTo:a}){return new br({type:Bt.pay,sender:n,note:o,lease:s,rekeyTo:a,suggestedParams:i,paymentParams:{receiver:e,amount:t,closeRemainderTo:r}})}function vC({sender:n,voteKey:e,selectionKey:t,stateProofKey:r,voteFirst:i,voteLast:o,voteKeyDilution:s,nonParticipation:a,suggestedParams:l,note:c,lease:d,rekeyTo:u}){return new br({type:Bt.keyreg,sender:n,note:c,lease:d,rekeyTo:u,suggestedParams:l,keyregParams:{voteKey:e,selectionKey:t,stateProofKey:r,voteFirst:i,voteLast:o,voteKeyDilution:s,nonParticipation:a}})}function eh({sender:n,assetIndex:e,total:t,decimals:r,defaultFrozen:i,manager:o,reserve:s,freeze:a,clawback:l,unitName:c,assetName:d,assetURL:u,assetMetadataHash:m,note:h,lease:x,rekeyTo:A,suggestedParams:v}){return new br({type:Bt.acfg,sender:n,note:h,lease:x,rekeyTo:A,suggestedParams:v,assetConfigParams:{assetIndex:e,total:t,decimals:r,defaultFrozen:i,manager:o,reserve:s,freeze:a,clawback:l,unitName:c,assetName:d,assetURL:u,assetMetadataHash:m}})}function SC({sender:n,total:e,decimals:t,defaultFrozen:r,manager:i,reserve:o,freeze:s,clawback:a,unitName:l,assetName:c,assetURL:d,assetMetadataHash:u,note:m,lease:h,rekeyTo:x,suggestedParams:A}){return eh({sender:n,total:e,decimals:t,defaultFrozen:r,manager:i,reserve:o,freeze:s,clawback:a,unitName:l,assetName:c,assetURL:d,assetMetadataHash:u,note:m,lease:h,rekeyTo:x,suggestedParams:A})}function bC({sender:n,assetIndex:e,manager:t,reserve:r,freeze:i,clawback:o,strictEmptyAddressChecking:s,note:a,lease:l,rekeyTo:c,suggestedParams:d}){if(!e)throw Error("assetIndex must be provided");if((s??!0)&&(t==null||r==null||i==null||o==null))throw Error("strictEmptyAddressChecking is enabled, but an address is empty. If this is intentional, set strictEmptyAddressChecking to false.");return eh({sender:n,assetIndex:e,manager:t,reserve:r,freeze:i,clawback:o,note:a,lease:l,rekeyTo:c,suggestedParams:d})}function EC({sender:n,assetIndex:e,note:t,lease:r,rekeyTo:i,suggestedParams:o}){if(!e)throw Error("assetIndex must be provided");return eh({sender:n,assetIndex:e,note:t,lease:r,rekeyTo:i,suggestedParams:o})}function AC({sender:n,assetIndex:e,freezeTarget:t,frozen:r,suggestedParams:i,note:o,lease:s,rekeyTo:a}){return new br({type:Bt.afrz,sender:n,note:o,lease:s,rekeyTo:a,suggestedParams:i,assetFreezeParams:{assetIndex:e,freezeTarget:t,frozen:r}})}function IC({sender:n,receiver:e,amount:t,closeRemainderTo:r,assetSender:i,note:o,assetIndex:s,suggestedParams:a,rekeyTo:l,lease:c}){if(!s)throw Error("assetIndex must be provided");return new br({type:Bt.axfer,sender:n,note:o,lease:c,rekeyTo:l,suggestedParams:a,assetTransferParams:{assetIndex:s,receiver:e,amount:t,assetSender:i,closeRemainderTo:r}})}function Ei({sender:n,appIndex:e,onComplete:t,appArgs:r,accounts:i,foreignApps:o,foreignAssets:s,boxes:a,convertToAccess:l,holdings:c,locals:d,access:u,approvalProgram:m,clearProgram:h,numLocalInts:x,numLocalByteSlices:A,numGlobalInts:v,numGlobalByteSlices:F,extraPages:w,rejectVersion:C,note:M,lease:N,rekeyTo:b,suggestedParams:j}){if(t==null)throw Error("onComplete must be provided");if(u&&(i||o||s||a||c||d))throw Error("cannot specify both access and other access fields");let p=u;return l&&(p=aI({appIndex:e,accounts:i,foreignApps:o,foreignAssets:s,holdings:c,locals:d,boxes:a})),new br({type:Bt.appl,sender:n,note:M,lease:N,rekeyTo:b,suggestedParams:j,appCallParams:{appIndex:e,onComplete:t,appArgs:r,accounts:p?void 0:i,foreignAssets:p?void 0:s,foreignApps:p?void 0:o,boxes:p?void 0:a,access:p,approvalProgram:m,clearProgram:h,numLocalInts:x,numLocalByteSlices:A,numGlobalInts:v,numGlobalByteSlices:F,extraPages:w,rejectVersion:C}})}function kC({sender:n,onComplete:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,numLocalInts:h,numLocalByteSlices:x,numGlobalInts:A,numGlobalByteSlices:v,extraPages:F,note:w,lease:C,rekeyTo:M,suggestedParams:N}){if(!u||!m)throw Error("approvalProgram and clearProgram must be provided");if(e==null)throw Error("onComplete must be provided");return Ei({sender:n,appIndex:0,onComplete:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,numLocalInts:h,numLocalByteSlices:x,numGlobalInts:A,numGlobalByteSlices:v,extraPages:F,note:w,lease:C,rekeyTo:M,suggestedParams:N})}function CC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,note:h,lease:x,rekeyTo:A,suggestedParams:v}){if(!e)throw Error("appIndex must be provided");if(!u||!m)throw Error("approvalProgram and clearProgram must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.UpdateApplicationOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,note:h,lease:x,rekeyTo:A,suggestedParams:v})}function FC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.DeleteApplicationOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function DC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.OptInOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,note:u,convertToAccess:a,holdings:l,locals:c,access:d,lease:m,rekeyTo:h,suggestedParams:x})}function TC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.CloseOutOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function MC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.ClearStateOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function RC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.NoOpOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function BC(n){return(e,t)=>{const r=[];for(const i of t)r.push(e[i].signTxn(n.sk));return Promise.resolve(r)}}function NC(n){return(e,t)=>{const r=[];for(const i of t){const{blob:o}=gg(e[i],n);r.push(o)}return Promise.resolve(r)}}function PC(n,e){return(t,r)=>{const i=[];for(const o of r){const s=t[o],a=[];for(const l of e){const{blob:c}=Cx(s,n,l);a.push(c)}a.length>1?i.push(Qd(a)):i.push(a[0])}return Promise.resolve(i)}}function Mx(){return(n,e)=>{const t=[];for(const r of e)t.push(hx(n[r]));return Promise.resolve(t)}}function Fp(n){return typeof n=="object"&&Object.keys(n).length===2&&typeof n.txn=="object"&&typeof n.signer=="function"}const Wo=2**16-1,Rx=32,Bx=1,Nx=1,zn=2,OC=/^([a-z\d[\](),]+)\[(0|[1-9][\d]*)]$/,LC=/^ufixed([1-9][\d]*)x([1-9][\d]*)$/;class On{static from(e){if(e.endsWith("[]")){const t=On.from(e.slice(0,e.length-2));return new Bs(t)}if(e.endsWith("]")){const t=e.match(OC);if(!t||t.length!==3)throw new Error(`malformed static array string: ${e}`);const r=t[2],i=parseInt(r,10);if(i>Wo)throw new Error(`array length exceeds limit ${Wo}`);const o=On.from(t[1]);return new Rs(o,i)}if(e.startsWith("uint")){const t=o=>[...o].every(s=>"0123456789".includes(s)),r=e.slice(4,e.length);if(!t(r))throw new Error(`malformed uint string: ${r}`);const i=parseInt(r,10);if(i>Wo)throw new Error(`malformed uint string: ${i}`);return new Qi(i)}if(e==="byte")return new fu;if(e.startsWith("ufixed")){const t=e.match(LC);if(!t||t.length!==3)throw new Error(`malformed ufixed type: ${e}`);const r=parseInt(t[1],10),i=parseInt(t[2],10);return new th(r,i)}if(e==="bool")return new pi;if(e==="address")return new hu;if(e==="string")return new nh;if(e.length>=2&&e[0]==="("&&e[e.length-1]===")"){const t=Mr.parseTupleContent(e.slice(1,e.length-1)),r=[];for(let i=0;i<t.length;i++){const o=On.from(t[i]);r.push(o)}return new Mr(r)}throw new Error(`cannot convert a string ${e} to an ABI type`)}}class Qi extends On{constructor(e){if(super(),e%8!==0||e<8||e>512)throw new Error(`unsupported uint type bitSize: ${e}`);this.bitSize=e}toString(){return`uint${this.bitSize}`}equals(e){return e instanceof Qi&&this.bitSize===e.bitSize}isDynamic(){return!1}byteLen(){return this.bitSize/8}encode(e){if(typeof e!="bigint"&&typeof e!="number")throw new Error(`Cannot encode value as uint${this.bitSize}: ${e}`);if(e>=BigInt(2**this.bitSize)||e<BigInt(0))throw new Error(`${e} is not a non-negative int or too big to fit in size uint${this.bitSize}`);if(typeof e=="number"&&!Number.isSafeInteger(e))throw new Error(`${e} should be converted into a BigInt before it is encoded`);return Ms(e,this.bitSize/8)}decode(e){if(e.length!==this.bitSize/8)throw new Error(`byte string must correspond to a uint${this.bitSize}`);return hg(e)}}class th extends On{constructor(e,t){if(super(),e%8!==0||e<8||e>512)throw new Error(`unsupported ufixed type bitSize: ${e}`);if(t>160||t<1)throw new Error(`unsupported ufixed type precision: ${t}`);this.bitSize=e,this.precision=t}toString(){return`ufixed${this.bitSize}x${this.precision}`}equals(e){return e instanceof th&&this.bitSize===e.bitSize&&this.precision===e.precision}isDynamic(){return!1}byteLen(){return this.bitSize/8}encode(e){if(typeof e!="bigint"&&typeof e!="number")throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);if(e>=BigInt(2**this.bitSize)||e<BigInt(0))throw new Error(`${e} is not a non-negative int or too big to fit in size ${this.toString()}`);if(typeof e=="number"&&!Number.isSafeInteger(e))throw new Error(`${e} should be converted into a BigInt before it is encoded`);return Ms(e,this.bitSize/8)}decode(e){if(e.length!==this.bitSize/8)throw new Error(`byte string must correspond to a ${this.toString()}`);return hg(e)}}class hu extends On{toString(){return"address"}equals(e){return e instanceof hu}isDynamic(){return!1}byteLen(){return Rx}encode(e){if(typeof e=="string")return W0(e).publicKey;if(e instanceof ze)return e.publicKey;if(e instanceof Uint8Array){if(e.byteLength!==32)throw new Error("byte string must be 32 bytes long for an address");return e}throw new Error(`Cannot encode value as ${this.toString()}: ${e}`)}decode(e){if(e.byteLength!==32)throw new Error("byte string must be 32 bytes long for an address");return H0(e)}}class pi extends On{toString(){return"bool"}equals(e){return e instanceof pi}isDynamic(){return!1}byteLen(){return Nx}encode(e){if(typeof e!="boolean")throw new Error(`Cannot encode value as bool: ${e}`);return e?new Uint8Array([128]):new Uint8Array([0])}decode(e){if(e.byteLength!==1)throw new Error("bool string must be 1 byte long");const t=e[0];if(t===128)return!0;if(t===0)return!1;throw new Error("boolean could not be decoded from the byte string")}}class fu extends On{toString(){return"byte"}equals(e){return e instanceof fu}isDynamic(){return!1}byteLen(){return Bx}encode(e){if(typeof e!="number"&&typeof e!="bigint")throw new Error(`Cannot encode value as byte: ${e}`);if(typeof e=="bigint"&&(e=Number(e)),e<0||e>255)throw new Error(`${e} cannot be encoded into a byte`);return new Uint8Array([e])}decode(e){if(e.byteLength!==1)throw new Error("byte string must be 1 byte long");return e[0]}}class nh extends On{toString(){return"string"}equals(e){return e instanceof nh}isDynamic(){return!0}byteLen(){throw new Error(`${this.toString()} is a dynamic type`)}encode(e){if(typeof e!="string"&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as string: ${e}`);let t;typeof e=="string"?t=new TextEncoder().encode(e):t=e;const r=Ms(t.length,zn),i=new Uint8Array(t.length+zn);return i.set(r),i.set(t,zn),i}decode(e){if(e.length<zn)throw new Error(`byte string is too short to be decoded. Actual length is ${e.length}, but expected at least ${zn}`);const r=new DataView(e.buffer,e.byteOffset,zn).getUint16(0),i=e.slice(zn,e.length);if(r!==i.length)throw new Error(`string length bytes do not match the actual length of string. Expected ${r}, got ${i.length}`);return new TextDecoder("utf-8").decode(i)}}class Rs extends On{constructor(e,t){if(super(),t<0)throw new Error(`static array must have a non negative length: ${t}`);this.childType=e,this.staticLength=t}toString(){return`${this.childType.toString()}[${this.staticLength}]`}equals(e){return e instanceof Rs&&this.staticLength===e.staticLength&&this.childType.equals(e.childType)}isDynamic(){return this.childType.isDynamic()}byteLen(){return this.childType.constructor===pi?Math.ceil(this.staticLength/8):this.staticLength*this.childType.byteLen()}encode(e){if(!Array.isArray(e)&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);if(e.length!==this.staticLength)throw new Error(`Value array does not match static array length. Expected ${this.staticLength}, got ${e.length}`);return this.toABITupleType().encode(e)}decode(e){return this.toABITupleType().decode(e)}toABITupleType(){return new Mr(Array(this.staticLength).fill(this.childType))}}class Bs extends On{constructor(e){super(),this.childType=e}toString(){return`${this.childType.toString()}[]`}equals(e){return e instanceof Bs&&this.childType.equals(e.childType)}isDynamic(){return!0}byteLen(){throw new Error(`${this.toString()} is a dynamic type`)}encode(e){if(!Array.isArray(e)&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);const t=this.toABITupleType(e.length),r=t.encode(e),i=Ms(t.childTypes.length,zn);return hn(i,r)}decode(e){const r=new DataView(e.buffer,0,zn).getUint16(0);return this.toABITupleType(r).decode(e.slice(zn,e.length))}toABITupleType(e){return new Mr(Array(e).fill(this.childType))}}class Mr extends On{constructor(e){if(super(),e.length>=Wo)throw new Error("tuple type child type number larger than maximum uint16 error");this.childTypes=e}toString(){const e=[];for(let t=0;t<this.childTypes.length;t++)e[t]=this.childTypes[t].toString();return`(${e.join(",")})`}equals(e){return e instanceof Mr&&this.childTypes.length===e.childTypes.length&&this.childTypes.every((t,r)=>t.equals(e.childTypes[r]))}isDynamic(){const e=t=>t.isDynamic();return this.childTypes.some(e)}byteLen(){let e=0;for(let t=0;t<this.childTypes.length;t++)if(this.childTypes[t].constructor===pi){const r=Gc(this.childTypes,t,1),i=r+1;t+=r,e+=Math.trunc((i+7)/8)}else{const r=this.childTypes[t].byteLen();e+=r}return e}encode(e){if(!Array.isArray(e)&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);const t=Array.from(e);if(e.length>Wo)throw new Error("length of tuple array should not exceed a uint16");const r=this.childTypes,i=[],o=[],s=new Map;let a=0;for(;a<r.length;){const d=r[a];if(d.isDynamic())s.set(i.length,!0),i.push(new Uint8Array([0,0])),o.push(d.encode(t[a]));else{if(d.constructor===pi){const u=Gc(r,a,-1);let m=Gc(r,a,1);if(u%8!==0)throw new Error("expected before index should have number of bool mod 8 equal 0");m=Math.min(7,m);const h=VC(t.slice(a,a+m+1));i.push(Ms(h,1)),a+=m}else{const u=d.encode(t[a]);i.push(u)}s.set(a,!1),o.push(new Uint8Array)}a+=1}let l=0;for(const d of i)l+=d.length;let c=0;for(let d=0;d<i.length;d++){if(s.get(d)){const u=l+c;if(u>Wo)throw new Error(`byte length of ${u} should not exceed a uint16`);i[d]=Ms(u,zn)}c+=o[d].length}return hn(...i,...o)}decode(e){const t=this.childTypes,r=[],i=[];let o=0,s=0;const a=new DataView(e.buffer);for(;o<t.length;){const d=t[o];if(d.isDynamic()){if(e.slice(s,e.length).length<zn)throw new Error("dynamic type in tuple is too short to be decoded");const u=a.getUint16(s);if(r.length>0&&(r[r.length-1].right=u,u<r[r.length-1].left))throw new Error("dynamic index segment miscalculation: left is greater than right index");const m={left:u,right:-1};r.push(m),i.push(null),s+=zn}else if(d.constructor===pi){const u=Gc(this.childTypes,o,-1);let m=Gc(this.childTypes,o,1);if(u%8!==0)throw new Error("expected before bool number mod 8 === 0");m=Math.min(7,m);for(let h=0;h<=m;h++){const x=128>>h;(e[s]&x)>0?i.push(new Uint8Array([128])):i.push(new Uint8Array([0]))}o+=m,s+=1}else{const u=d.byteLen();i.push(e.slice(s,s+u)),s+=u}if(o!==t.length-1&&s>=e.length)throw new Error("input byte not enough to decode");o+=1}if(r.length>0&&(r[r.length-1].right=e.length,s=e.length),s<e.length)throw new Error("input byte not fully consumed");for(let d=0;d<r.length;d++){const u=r[d];if(u.left>u.right)throw new Error("dynamic segment should display a [l, r] space with l <= r");if(d!==r.length-1&&u.right!==r[d+1].left)throw new Error("dynamic segment should be consecutive")}let l=0;for(let d=0;d<t.length;d++)t[d].isDynamic()&&(i[d]=e.slice(r[l].left,r[l].right),l+=1);const c=[];for(let d=0;d<t.length;d++){const u=t[d].decode(i[d]);c.push(u)}return c}static parseTupleContent(e){if(e.length===0)return[];if(e.endsWith(",")||e.startsWith(","))throw new Error("tuple string should not start with comma");if(e.includes(",,"))throw new Error("tuple string should not have consecutive commas");const t=[];let r=0,i="";for(const o of e)i+=o,o==="("?r+=1:o===")"?r-=1:o===","&&r===0&&(t.push(i.slice(0,i.length-1)),i="");if(i.length!==0&&t.push(i),r!==0)throw new Error("tuple string has mismatched parentheses");return t}}function VC(n){let e=0;if(n.length>8)throw new Error("value list passed in should be no greater than length 8");for(let t=0;t<n.length;t++){const r=n[t];if(typeof r!="boolean")throw new Error("non-boolean values cannot be compressed into a byte");r&&(e|=1<<7-t)}return e}function Gc(n,e,t){let r=0;for(;;){const i=e+t*r;if(n[i].constructor===pi)if(i!==n.length-1&&t===1)r+=1;else if(i>0&&t===-1)r+=1;else break;else{r-=1;break}}return r}var kr;(function(n){n.any="txn",n.pay="pay",n.keyreg="keyreg",n.acfg="acfg",n.axfer="axfer",n.afrz="afrz",n.appl="appl"})(kr||(kr={}));function Ed(n){return n===kr.any||n===kr.pay||n===kr.keyreg||n===kr.acfg||n===kr.axfer||n===kr.afrz||n===kr.appl}function Px(n,e){return n===kr.any?!0:e.type?e.type.toString()===n.toString():!1}var gi;(function(n){n.account="account",n.application="application",n.asset="asset"})(gi||(gi={}));function yg(n){return n===gi.account||n===gi.application||n===gi.asset}function $C(n){const e=n.indexOf("(");if(e===-1)throw new Error(`Invalid method signature: ${n}`);let t=-1,r=0;for(let i=e;i<n.length;i++){const o=n[i];if(o==="(")r+=1;else if(o===")"){if(r===0)break;if(r-=1,r===0){t=i;break}}}if(t===-1)throw new Error(`Invalid method signature: ${n}`);return{name:n.slice(0,e),args:Mr.parseTupleContent(n.slice(e+1,t)),returns:n.slice(t+1)}}let rh=class Ox{constructor(e){if(typeof e.name!="string"||typeof e.returns!="object"||!Array.isArray(e.args))throw new Error("Invalid ABIMethod parameters");this.name=e.name,this.description=e.desc,this.args=e.args.map(({type:t,name:r,desc:i})=>Ed(t)||yg(t)?{type:t,name:r,description:i}:{type:On.from(t),name:r,description:i}),this.returns={type:e.returns.type==="void"?e.returns.type:On.from(e.returns.type),description:e.returns.desc},this.events=e.events,this.readonly=e.readonly}getSignature(){const e=this.args.map(r=>r.type.toString()).join(","),t=this.returns.type.toString();return`${this.name}(${e})${t}`}getSelector(){const e=wi(this.getSignature());return new Uint8Array(e.slice(0,4))}txnCount(){let e=1;for(const t of this.args)typeof t.type=="string"&&Ed(t.type)&&(e+=1);return e}toJSON(){return{name:this.name,desc:this.description,args:this.args.map(({type:e,name:t,description:r})=>({type:e.toString(),name:t,desc:r})),returns:{type:this.returns.type.toString(),desc:this.returns.description},events:this.events,readonly:this.readonly}}static fromSignature(e){const{name:t,args:r,returns:i}=$C(e);return new Ox({name:t,args:r.map(o=>({type:o})),returns:{type:i}})}};function wg(n,e){if(n===null||!Array.isArray(n)||!n.every(r=>r instanceof rh))throw new Error("Methods list provided is null or not the correct type");const t=n.filter(r=>r.name===e);if(t.length>1)throw new Error(`found ${t.length} methods with the same name ${t.map(r=>r.getSignature()).join(",")}`);if(t.length===0)throw new Error(`found 0 methods with the name ${e}`);return t[0]}class _C{constructor(e){if(typeof e.name!="string"||!Array.isArray(e.methods)||e.networks&&typeof e.networks!="object")throw new Error("Invalid ABIContract parameters");this.name=e.name,this.description=e.desc,this.networks=e.networks?{...e.networks}:{},this.methods=e.methods.map(t=>new rh(t)),this.events=e.events}toJSON(){return{name:this.name,desc:this.description,networks:this.networks,methods:this.methods.map(e=>e.toJSON()),events:this.events}}getMethodByName(e){return wg(this.methods,e)}}class UC{constructor(e){if(typeof e.name!="string"||!Array.isArray(e.methods))throw new Error("Invalid ABIInterface parameters");this.name=e.name,this.description=e.desc,this.methods=e.methods.map(t=>new rh(t))}toJSON(){return{name:this.name,desc:this.description,methods:this.methods.map(e=>e.toJSON())}}getMethodByName(e){return wg(this.methods,e)}}const jC=new Uint8Array([21,31,124,117]),Wc=16;var Mn;(function(n){n[n.BUILDING=0]="BUILDING",n[n.BUILT=1]="BUILT",n[n.SIGNED=2]="SIGNED",n[n.SUBMITTED=3]="SUBMITTED",n[n.COMMITTED=4]="COMMITTED"})(Mn||(Mn={}));function Lh(n,e,t){if(t!=null&&n===t)return 0;const r=t==null?0:1;for(let i=0;i<e.length;i++)if(n===e[i])return i+r;return e.push(n),e.length-1+r}let Lx=class Ti{constructor(){this.status=Mn.BUILDING,this.transactions=[],this.methodCalls=new Map,this.signedTxns=[],this.txIDs=[]}getStatus(){return this.status}count(){return this.transactions.length}clone(){const e=new Ti;return e.transactions=this.transactions.map(({txn:t,signer:r})=>{const i=t.toEncodingData();return i.delete("grp"),{txn:br.fromEncodingData(i),signer:r}}),e.methodCalls=new Map(this.methodCalls),e}addTransaction(e){if(this.status!==Mn.BUILDING)throw new Error("Cannot add transactions when composer status is not BUILDING");if(this.transactions.length===Ti.MAX_GROUP_SIZE)throw new Error(`Adding an additional transaction exceeds the maximum atomic group size of ${Ti.MAX_GROUP_SIZE}`);if(e.txn.group&&e.txn.group.some(t=>t!==0))throw new Error("Cannot add a transaction with nonzero group ID");this.transactions.push(e)}addMethodCall({appID:e,method:t,methodArgs:r,sender:i,suggestedParams:o,onComplete:s,approvalProgram:a,clearProgram:l,numGlobalInts:c,numGlobalByteSlices:d,numLocalInts:u,numLocalByteSlices:m,extraPages:h,appAccounts:x,appForeignApps:A,appForeignAssets:v,boxes:F,access:w,note:C,lease:M,rekeyTo:N,rejectVersion:b,signer:j}){if(this.status!==Mn.BUILDING)throw new Error("Cannot add transactions when composer status is not BUILDING");if(this.transactions.length+t.txnCount()>Ti.MAX_GROUP_SIZE)throw new Error(`Adding additional transactions exceeds the maximum atomic group size of ${Ti.MAX_GROUP_SIZE}`);if(BigInt(e)===BigInt(0)){if(a==null||l==null||c==null||d==null||u==null||m==null)throw new Error("One of the following required parameters for application creation is missing: approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices")}else if(s===kn.UpdateApplicationOC){if(a==null||l==null)throw new Error("One of the following required parameters for OnApplicationComplete.UpdateApplicationOC is missing: approvalProgram, clearProgram");if(c!=null||d!=null||u!=null||m!=null||h!=null)throw new Error("One of the following application creation parameters were set on a non-creation call: numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages")}else if(a!=null||l!=null||c!=null||d!=null||u!=null||m!=null||h!=null)throw new Error("One of the following application creation parameters were set on a non-creation call: approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages");if(w&&(x||A||v||F))throw new Error("Cannot specify both access and legacy foreign arrays (appAccounts, appForeignApps, appForeignAssets, boxes)");if(r==null&&(r=[]),r.length!==t.args.length)throw new Error(`Incorrect number of method arguments. Expected ${t.args.length}, got ${r.length}`);let p=[],E=[];const S=[],$=[],B=[],P=new Map,W=F||[];for(let le=0;le<r.length;le++){let ye=t.args[le].type;const he=r[le];if(Ed(ye)){if(!Fp(he)||!Px(ye,he.txn))throw new Error(`Expected ${ye} TransactionWithSigner for argument at index ${le}`);if(he.txn.group&&he.txn.group.some(de=>de!==0))throw new Error("Cannot add a transaction with nonzero group ID");S.push(he);continue}if(Fp(he))throw new Error(`Expected non-transaction value for argument at index ${le}`);if(yg(ye)&&(P.set($.length,p.length),$.push(ye),B.push(he),ye=new Qi(8)),typeof ye=="string")throw new Error(`Unknown ABI type: ${ye}`);p.push(ye),E.push(he)}const L=[],q=x==null?[]:x.map(le=>le.toString()),J=A==null?[]:A.map(Wt),U=v==null?[]:v.map(Wt);for(let le=0;le<$.length;le++){const ye=$[le],he=B[le];let de=0;switch(ye){case gi.account:{const be=new hu,Ae=be.decode(be.encode(he));de=Lh(Ae,q,i.toString());break}case gi.application:{const be=new Qi(64),Ae=be.decode(be.encode(he));if(Ae>Number.MAX_SAFE_INTEGER)throw new Error(`Expected safe integer for application value, got ${Ae}`);de=Lh(Ae,J,Wt(e));break}case gi.asset:{const be=new Qi(64),Ae=be.decode(be.encode(he));if(Ae>Number.MAX_SAFE_INTEGER)throw new Error(`Expected safe integer for asset value, got ${Ae}`);de=Lh(Ae,U);break}default:throw new Error(`Unknown reference type: ${ye}`)}L.push(de)}for(let le=0;le<L.length;le++){const ye=P.get(le);E[ye]=L[le]}if(p.length>Wc-1){const le=p.slice(Wc-2),ye=E.slice(Wc-2);p=p.slice(0,Wc-2),E=E.slice(0,Wc-2),p.push(new Mr(le)),E.push(ye)}const ne=[t.getSelector()];for(let le=0;le<p.length;le++)ne.push(p[le].encode(E[le]));const fe={txn:Ei({sender:i,appIndex:e,appArgs:ne,accounts:w?void 0:q,foreignApps:w?void 0:J,foreignAssets:w?void 0:U,boxes:w?void 0:W,access:w,onComplete:s??kn.NoOpOC,approvalProgram:a,clearProgram:l,numGlobalInts:c,numGlobalByteSlices:d,numLocalInts:u,numLocalByteSlices:m,extraPages:h,rejectVersion:b,lease:M,note:C,rekeyTo:N,suggestedParams:o}),signer:j};this.transactions.push(...S,fe),this.methodCalls.set(this.transactions.length-1,t)}buildGroup(){if(this.status===Mn.BUILDING){if(this.transactions.length===0)throw new Error("Cannot build a group with 0 transactions");this.transactions.length>1&&Ex(this.transactions.map(e=>e.txn)),this.status=Mn.BUILT}return this.transactions}async gatherSignatures(){if(this.status>=Mn.SIGNED)return this.signedTxns;const e=this.buildGroup(),t=e.map(c=>c.txn),r=new Map;for(let c=0;c<e.length;c++){const{signer:d}=e[c];r.has(d)||r.set(d,[]),r.get(d).push(c)}const i=Array.from(r),o=await Promise.all(i.map(([c,d])=>c(t,d))),s=e.map(()=>null);for(let c=0;c<i.length;c++){const d=i[c][1],u=o[c];for(let m=0;m<d.length;m++)s[d[m]]=u[m]}function a(c){return c.every(d=>d!=null)}if(!a(s))throw new Error(`Missing signatures. Got ${s}`);const l=s.map((c,d)=>{try{return Xt(c,jt).txn.txID()}catch(u){throw new Error(`Cannot decode signed transaction at index ${d}. ${u}`)}});return this.signedTxns=s,this.txIDs=l,this.status=Mn.SIGNED,s}async submit(e){if(this.status>Mn.SUBMITTED)throw new Error("Transaction group cannot be resubmitted");const t=await this.gatherSignatures();return await e.sendRawTransaction(t).do(),this.status=Mn.SUBMITTED,this.txIDs}async simulate(e,t){if(this.status>Mn.SUBMITTED)throw new Error("Simulated Transaction group has already been submitted to the network");const i=(await this.gatherSignatures()).map(l=>Xt(l,jt)),o=t??new Oa({txnGroups:[]});o.txnGroups=[new ro({txns:i})];const s=await e.simulateTransactions(o).do(),a=[];for(const[l,c]of this.methodCalls){const d=this.txIDs[l],u=s.txnGroups[0].txnResults[l].txnResult,m={txID:d,rawReturnValue:new Uint8Array,method:c};a.push(Ti.parseMethodResponse(c,m,u))}return{methodResults:a,simulateResponse:s}}async execute(e,t){if(this.status===Mn.COMMITTED)throw new Error("Transaction group has already been executed successfully");const r=await this.submit(e);this.status=Mn.SUBMITTED;const i=this.transactions.findIndex((c,d)=>this.methodCalls.has(d)),s=await wx(e,r[i===-1?0:i],t);this.status=Mn.COMMITTED;const a=s.confirmedRound,l=[];for(const[c,d]of this.methodCalls){const u=r[c];let m={txID:u,rawReturnValue:new Uint8Array,method:d};try{const h=c===i?s:await e.pendingTransactionInformation(u).do();m=Ti.parseMethodResponse(d,m,h)}catch(h){m.decodeError=h}l.push(m)}return{confirmedRound:a,txIDs:r,methodResults:l}}static parseMethodResponse(e,t,r){const i=t;try{if(i.txInfo=r,e.returns.type!=="void"){const o=r.logs||[];if(o.length===0)throw new Error(`App call transaction did not log a return value ${yi(r)}`);const s=o[o.length-1];if(s.byteLength<4||!Kr(s.slice(0,4),jC))throw new Error(`App call transaction did not log a ABI return value ${yi(r)}`);i.rawReturnValue=new Uint8Array(s.slice(4)),i.returnValue=e.returns.type.decode(t.rawReturnValue)}}catch(o){i.decodeError=o}return i}};Lx.MAX_GROUP_SIZE=16;const Vx=Uint8Array.from([77,88]),$x="The transaction sender address and multisig preimage do not match.";function GC(n,e){return{txID:n.txID(),blob:n.signTxn(e)}}function WC(n,e){const t=hn(Vx,n);return ll(t,e)}function zC(n,e,t){const r=hn(Vx,n),i=typeof t=="string"?ze.fromString(t):t;return Gd(r,e,i.publicKey)}const HC=new Error($x),YC=new Error(ag),Oe=Object.freeze(Object.defineProperty({__proto__:null,ABIAddressType:hu,ABIArrayDynamicType:Bs,ABIArrayStaticType:Rs,ABIBoolType:pi,ABIByteType:fu,ABIContract:_C,ABIInterface:UC,ABIMethod:rh,get ABIReferenceType(){return gi},ABIStringType:nh,get ABITransactionType(){return kr},ABITupleType:Mr,ABIType:On,ABIUfixedType:th,ABIUintType:Qi,ADDR_BYTE_SIZE:Rx,ALGORAND_ZERO_ADDRESS_STRING:Q1,AccountBaseData:ys,AccountData:ws,AccountDeltas:vs,AccountTotals:As,Address:ze,AlgoCount:Tr,Algodv2:Sk,AppLocalState:ls,AppLocalStateDelta:us,AppParams:cs,AppParamsDelta:ds,AppResourceRecord:hs,ApplyData:wa,AssetHolding:Zd,AssetHoldingDelta:fs,AssetParams:Jd,AssetParamsDelta:ps,AssetResourceRecord:gs,AtomicTransactionComposer:Lx,get AtomicTransactionComposerStatus(){return Mn},BalanceRecord:xs,Block:md,BlockHeader:vi,ENCODED_MULTISIG_SCHEMA:fd,ENCODED_SUBSIG_SCHEMA:ax,ERROR_INVALID_MICROALGOS:YC,ERROR_MULTISIG_BAD_SENDER:HC,EvalDelta:Kf,FalconSignatureStruct:Qo,FalconVerifier:Jo,HashFactory:Yd,INVALID_MICROALGOS_ERROR_MSG:ag,IncludedTransactions:bs,Indexer:zk,IntDecoding:an,Kmd:bk,KvValueDelta:Ss,LENGTH_ENCODE_BYTE_SIZE:zn,LedgerStateDelta:Si,LogicSig:rr,LogicSigAccount:dg,MAX_LEN:Wo,MULTISIG_BAD_SENDER_ERROR_MSG:$x,MerkleArrayProof:to,MerkleSignatureVerifier:Xo,ModifiedCreatable:Es,get OnApplicationComplete(){return kn},Participant:Zo,ParticipationUpdates:Xd,ProgramSourceMap:Dx,Reveal:ts,RewardState:is,SINGLE_BOOL_SIZE:Nx,SINGLE_BYTE_SIZE:Bx,SignedTransaction:jt,SignedTxnInBlock:as,SignedTxnWithAD:no,SigslotCommit:es,StateProof:Kd,StateProofMessage:qd,StateProofTrackingData:ns,StateSchema:Xr,TealValue:Mc,Transaction:br,get TransactionType(){return Bt},TxnCommitments:rs,UntypedValue:Sn,UpgradeState:os,UpgradeVote:ss,ValueDelta:di,VotingData:ms,abiCheckTransactionType:Px,abiTypeIsReference:yg,abiTypeIsTransaction:Ed,algosToMicroalgos:rA,appendSignMultisigTransaction:uC,appendSignRawMultisigSignature:dC,assignGroupID:Ex,base64ToBytes:Ge,bigIntToBytes:Ms,bytesToBase64:In,bytesToBigInt:hg,bytesToHex:zd,bytesToString:Wd,coerceToBytes:qr,computeGroupID:bx,createDryrun:pC,createMultisigTransaction:Ax,decodeAddress:W0,decodeJSON:Et,decodeMsgpack:Xt,decodeObj:JA,decodeSignedTransaction:MI,decodeUint64:G0,decodeUnsignedTransaction:vI,dryrunTxnResultAppTrace:yC,dryrunTxnResultLogicSigTrace:wC,encodeAddress:H0,encodeJSON:eI,encodeMsgpack:Sr,encodeObj:ZA,encodeUint64:j0,encodeUnsignedSimulateTransaction:hx,encodeUnsignedTransaction:xI,encodedMultiSigFromEncodingData:pd,encodedMultiSigToEncodingData:gd,encodedSubsigFromEncodingData:cx,encodedSubsigToEncodingData:lx,generateAccount:Hk,getApplicationAddress:dd,getMethodByName:wg,hexToBytes:J1,indexerModels:Ek,isOnApplicationComplete:rx,isTransactionType:jf,isTransactionWithSigner:Fp,isValidAddress:z0,logicSigFromByte:FI,makeApplicationCallTxnFromObject:Ei,makeApplicationClearStateTxnFromObject:MC,makeApplicationCloseOutTxnFromObject:TC,makeApplicationCreateTxnFromObject:kC,makeApplicationDeleteTxnFromObject:FC,makeApplicationNoOpTxnFromObject:RC,makeApplicationOptInTxnFromObject:DC,makeApplicationUpdateTxnFromObject:CC,makeAssetConfigTxnWithSuggestedParamsFromObject:bC,makeAssetCreateTxnWithSuggestedParamsFromObject:SC,makeAssetDestroyTxnWithSuggestedParamsFromObject:EC,makeAssetFreezeTxnWithSuggestedParamsFromObject:AC,makeAssetTransferTxnWithSuggestedParamsFromObject:IC,makeBaseAssetConfigTxn:eh,makeBasicAccountTransactionSigner:BC,makeEmptyTransactionSigner:Mx,makeKeyRegistrationTxnWithSuggestedParamsFromObject:vC,makeLogicSigAccountTransactionSigner:NC,makeMultiSigAccountTransactionSigner:PC,makePaymentTxnWithSuggestedParamsFromObject:xC,masterDerivationKeyToMnemonic:Jk,mergeMultisigTransactions:Qd,microalgosToAlgos:nA,mnemonicFromSeed:fg,mnemonicToMasterDerivationKey:Zk,mnemonicToSecretKey:qk,modelsv2:NI,msgpackRawDecode:ex,msgpackRawDecodeAsMap:tx,msgpackRawEncode:du,multisigAddress:kI,parseJSON:_d,secretKeyToMnemonic:Xk,seedFromMnemonic:pg,signBytes:WC,signLogicSigTransaction:nC,signLogicSigTransactionObject:gg,signMultisigTransaction:Cx,signTransaction:GC,stringifyJSON:yi,tealSign:dx,tealSignFromProgram:TI,verifyBytes:zC,verifyMultisig:Hf,verifyTealSign:DI,waitForConfirmation:wx},Symbol.toStringTag,{value:"Module"}));function KC(n,e){if(n===void 0)return`0 ${e.unitName}`;const t=typeof n=="bigint"?n:BigInt(n);if(e.decimals===0)return`${t} ${e.unitName}`;const r=10n**BigInt(e.decimals),i=t/r,o=t%r;if(o===0n)return`${i} ${e.unitName}`;const s=o.toString().padStart(e.decimals,"0").replace(/0+$/,"");return`${i}.${s} ${e.unitName}`}function Vh(n,e){return e!=null&&e.unitName?e.unitName:n.assetIndex?`ASA#${n.assetIndex}`:"ASA"}function qC({txn:n,assetInfo:e,appEscrows:t={}}){const r=(a,l)=>a&&t[a]||l,i=(a,l,c,d=!1,u=!1)=>D.jsxs("div",{className:`grid grid-cols-[1fr_auto_1fr] w-full items-center font-mono text-xs ${u?"mt-1":""}`,children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] text-left",children:a}),D.jsxs("span",{className:"flex items-center justify-center gap-1 px-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"--["}),D.jsx("span",{className:d?"text-[var(--wui-color-danger-text)] font-bold":"text-[var(--wui-color-primary)] font-medium",children:l}),D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"]-->"})]}),D.jsx("span",{className:`text-right ${d?"text-[var(--wui-color-danger-text)] font-bold":"text-[var(--wui-color-text-secondary)]"}`,children:c})]}),o=a=>D.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center font-mono text-xs mt-1",children:[D.jsx("span",{}),D.jsxs("span",{className:"flex items-center justify-center gap-1 px-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"--["}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold",children:"remainder"}),D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"]-->"})]}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold text-right",children:a})]}),s=(a,l)=>D.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center font-mono text-xs mt-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] text-left",children:a}),D.jsxs("span",{className:"flex items-center justify-center gap-1 px-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"--["}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold",children:"REKEY"}),D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"]-->"})]}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold text-right",children:l})]});return D.jsxs("div",{className:"space-y-0",children:[n.type==="pay"&&n.receiverShort&&D.jsxs(D.Fragment,{children:[i(n.senderShort,n.amount||"0 ALGO",r(n.receiver,n.receiverShort)),n.closeRemainderToShort&&o(n.closeRemainderToShort)]}),n.type==="axfer"&&n.receiverShort&&D.jsxs(D.Fragment,{children:[i(n.senderShort,e?KC(n.rawAmount,e):`${n.amount||"0"} ${Vh(n)}`,r(n.receiver,n.receiverShort)),n.closeRemainderToShort&&o(n.closeRemainderToShort)]}),n.type==="afrz"&&n.freezeTargetShort&&D.jsx(D.Fragment,{children:i(n.senderShort,`${n.isFreezing?"Freeze":"Unfreeze"} ${Vh(n,e)}`,n.freezeTargetShort)}),n.type==="acfg"&&D.jsx(D.Fragment,{children:i(n.senderShort,`Configure ${n.assetIndex?Vh(n,e):"NEW"}`,n.senderShort)}),n.type==="appl"&&D.jsx(D.Fragment,{children:i(n.senderShort,"APP CALL",`App ${n.appIndex||"NEW"}`)}),n.type==="keyreg"&&D.jsx(D.Fragment,{children:i(n.senderShort,"KEY REG",n.senderShort)}),n.rekeyToShort&&s(n.senderShort,n.rekeyToShort)]})}function _x(n,e){const t=F1({queries:n.map(o=>({queryKey:["asset",o],queryFn:async()=>{const s=await e.getAssetByID(Number(o)).do();return{decimals:s.params.decimals,name:s.params.name||"",unitName:s.params.unitName||""}},retries:0,enabled:!!e,staleTime:1/0,gcTime:1/0}))}),r=t.some(o=>o.isLoading),i=Y.useMemo(()=>{var s;const o={};for(let a=0;a<n.length;a++){const l=(s=t[a])==null?void 0:s.data;l&&(o[n[a]]=l)}return o},[n,t]);return{loading:r,assets:i}}function XC(n,e){const t=e==null?void 0:e.algodClient,r=e==null?void 0:e.getApplicationAddress,i=Y.useMemo(()=>{const l=new Set;for(const c of n)c.assetIndex&&l.add(c.assetIndex.toString());return Array.from(l)},[n]),{loading:o,assets:s}=_x(i,t),a=Y.useMemo(()=>{if(!r)return{};const l={};for(const c of n)if(c.type==="appl"&&c.appIndex){const d=r(c.appIndex);l[d.toString()]=`App ${c.appIndex}`}return l},[n,r]);return{loading:o,assets:s,appEscrows:a}}function ZC({transactions:n,message:e,dangerous:t,algodClient:r,getApplicationAddress:i,onApprove:o,onReject:s,signing:a,walletName:l,origin:c,headerAction:d,payloadVerified:u}){const{loading:m,assets:h,appEscrows:x}=XC(n,{algodClient:r,getApplicationAddress:i});return D.jsxs("div",{className:"flex flex-col",children:[D.jsxs("div",{className:"flex items-center justify-between px-6 pt-5 pb-1",children:[D.jsxs("h2",{className:`text-lg font-bold ${t?"text-[var(--wui-color-danger-text)]":"text-[var(--wui-color-text)]"}`,children:[t?"Review Dangerous ":"Review ","Transaction",n.length>1?"s":""]}),d]}),c&&D.jsx("div",{className:"px-6 text-xs text-[var(--wui-color-text-tertiary)] truncate",children:c}),t?D.jsx("div",{className:"px-6 pb-3 text-sm font-bold text-[var(--wui-color-danger-text)]",children:t==="rekey"?"This transaction will rekey your account, transferring signing authority to a different address. You will no longer be able to sign transactions with your current key.":"This transaction will close your account and transfer all remaining funds to another address. This action is irreversible."}):D.jsx("div",{className:"px-6 pb-3 text-sm text-[var(--wui-color-text-secondary)]",children:n.length===1?"You are about to sign the following transaction:":`You are about to sign ${n.length} transactions:`}),D.jsx("div",{className:"px-4 pb-4 max-h-80 overflow-y-auto",children:m?D.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading asset info..."]}):D.jsx("div",{className:"space-y-2",children:n.map(A=>D.jsx("div",{className:"rounded-sm border p-3 border-[var(--wui-color-primary)] bg-[var(--wui-color-bg-secondary)]",children:D.jsx(qC,{txn:A,assetInfo:A.assetIndex?h[A.assetIndex.toString()]:void 0,appEscrows:x})},A.index))})}),u===!1&&D.jsx("div",{className:"px-4 pb-4",children:D.jsx("div",{className:"text-sm font-bold text-[var(--wui-color-danger-text)] border border-[var(--wui-color-danger-text)] rounded-xl p-3 bg-[var(--wui-color-danger-bg)]",children:"Payload verification failed. The provided payload was invalid and has been recalculated from the raw transactions."})}),D.jsx("div",{className:"px-4 pb-4",children:D.jsxs("div",{className:"text-sm flex flex-col gap-2 border border-[var(--wui-color-border)] rounded-xl p-3",children:[D.jsxs("div",{className:"flex items-center gap-2",children:[D.jsx("span",{children:"Transaction ID to sign:"}),u===!0&&D.jsx("span",{className:"text-xs text-green-600 font-medium",children:"Verified"})]}),D.jsx("div",{className:"font-mono break-all text-[var(--wui-color-danger-text)]",children:e}),D.jsx("div",{children:"Ensure the transaction ID is correct before approving."})]})}),a?D.jsx("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)]",children:D.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsxs("svg",{className:"animate-spin h-4 w-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Signing..."]})}):t?D.jsxs("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)] flex gap-3",children:[D.jsx("button",{onClick:s,className:"flex-1 py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Reject"}),D.jsx("button",{onClick:o,className:"flex-1 py-2.5 px-4 bg-[var(--wui-color-danger-text)] text-white font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Sign (Dangerous)"})]}):D.jsx("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)]",children:D.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsxs("svg",{className:"animate-spin h-4 w-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Review in ",l||"wallet","..."]})})]})}function Ux({className:n,scale:e=.85}){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:`inline-block align-baseline ${n??""}`,style:{width:`${e}em`,height:`${e}em`},"aria-label":"Algorand",fill:"currentColor",children:D.jsx("path",{d:"M23.98 23.99h-3.75l-2.44-9.07-5.25 9.07H8.34l8.1-14.04-1.3-4.88L4.22 24H.02L13.88 0h3.67l1.61 5.96h3.79l-2.59 4.5 3.62 13.53z"})})}function Qs({className:n}){return D.jsxs("svg",{className:`animate-spin h-4 w-4 ${n??""}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function ey(n){return n.length<=12?n:`${n.slice(0,6)}...${n.slice(-4)}`}function jx({status:n,error:e,successMessage:t,onRetry:r,txId:i,explorerUrl:o}){return n==="idle"?null:n==="signing"?D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Waiting for signature..."]}):n==="sending"?D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Sending transaction..."]}):n==="success"?D.jsxs("div",{className:"text-center py-4",children:[D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),D.jsx("p",{className:"text-sm font-medium text-[var(--wui-color-text)]",children:t}),i&&D.jsxs("p",{className:"mt-1.5 text-xs text-[var(--wui-color-text-tertiary)]",children:["TX:"," ",o?D.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-[var(--wui-color-primary)] hover:underline",children:ey(i)}):D.jsx("span",{className:"font-mono",children:ey(i)})]})]}):D.jsxs("div",{className:"text-center py-3",children:[D.jsx("p",{className:"text-sm text-[var(--wui-color-danger-text)] mb-2",children:e}),D.jsx("button",{onClick:r,className:"text-sm text-[var(--wui-color-primary)] hover:underline",children:"Try again"})]})}function JC({activeAddress:n,optedInAssetIds:e,assetIdInput:t,setAssetIdInput:r,assetInfo:i,assetLookupLoading:o,assetLookupError:s,txId:a,explorerUrl:l,status:c,error:d,handleOptIn:u,reset:m,retry:h,onBack:x,nameSearchResults:A,nameSearchLoading:v,registryLoading:F,selectedNameAsset:w,onSelectNameAsset:C,isNameMode:M,evmAddress:N}){const[b,j]=Y.useState("idle"),[p,E]=Y.useState(!1),S=async()=>{if(n)try{await navigator.clipboard.writeText(n),j("copied"),setTimeout(()=>j("idle"),1e3)}catch{j("error"),setTimeout(()=>j("idle"),1e3)}},$=M?w==null?void 0:w.index:i==null?void 0:i.index,B=$!=null&&(e==null?void 0:e.has($));return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[D.jsx("button",{onClick:x,className:"-ml-1 p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-secondary)] flex items-center justify-center",title:"Back",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D.jsx("path",{d:"m15 18-6-6 6-6"})})}),D.jsx("h3",{className:"text-lg font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font",children:"Receive"}),F&&D.jsxs("div",{className:"ml-auto flex items-center gap-1 text-xs text-[var(--wui-color-text-tertiary)]",children:[D.jsx(Qs,{className:"h-3 w-3"}),D.jsx("span",{children:"Loading registry..."})]})]}),D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-2 leading-relaxed",children:"This is your liquid EVM Algorand account. You can receive ALGO and any opted-in assets here, and manage your asset opt-ins below."}),n&&D.jsxs("div",{className:"mb-4 bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-secondary)] mb-1.5",children:"Your ALGO address:"}),D.jsxs("div",{className:"flex items-center gap-2",children:[D.jsx("code",{className:"text-sm font-medium text-[var(--wui-color-text)] flex-1 truncate",children:n}),D.jsx("button",{onClick:S,className:"shrink-0 px-2.5 py-1 text-xs font-medium rounded-md bg-[var(--wui-color-bg-tertiary)] hover:brightness-90 transition-all",style:{color:b==="copied"?"var(--wui-color-success-text, #16a34a)":b==="error"?"var(--wui-color-danger-text)":"var(--wui-color-text-secondary)"},children:b==="copied"?"COPIED":b==="error"?"ERROR":"COPY"})]})]}),N&&D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-2 leading-relaxed",children:"It is controlled entirely by your EVM account:"}),D.jsxs("div",{className:"mb-2 bg-[var(--wui-color-bg-secondary)] rounded-lg",children:[D.jsxs("button",{type:"button",onClick:()=>E(P=>!P),className:"w-full flex items-center justify-between px-3 py-2 text-xs text-[var(--wui-color-text-secondary)] hover:text-[var(--wui-color-text)] transition-colors focus:outline-none",children:[D.jsx("span",{children:"EVM Controller"}),D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:p?"rotate(180deg)":"none",transition:"transform 150ms ease"},children:D.jsx("path",{d:"m6 9 6 6 6-6"})})]}),p&&D.jsx("div",{className:"px-3 pb-2.5",children:D.jsx("code",{className:"text-sm font-medium text-[var(--wui-color-text)] truncate block",children:N})})]})]}),D.jsx("h4",{className:"text-base font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font mt-6 mb-3",children:"Asset opt-in"}),c==="idle"&&D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-3 leading-relaxed",children:"Algorand accounts must opt in to assets before receiving them. Search for an asset below to opt in."}),D.jsx("div",{className:"mb-4",children:D.jsx("input",{type:"text",placeholder:"Search by name or asset ID",value:t,onChange:P=>r(P.target.value),className:"w-full rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-3 text-sm text-[var(--wui-color-text)] placeholder:text-[var(--wui-color-text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent"})}),!M&&o&&D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Looking up asset..."]}),!M&&s&&D.jsx("div",{className:"py-3 text-center text-sm text-[var(--wui-color-danger-text)]",children:s}),!M&&i&&D.jsx(ty,{name:i.name,unitName:i.unitName,index:i.index,isAlreadyOptedIn:B,onOptIn:u}),M&&v&&D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Searching..."]}),M&&!w&&A&&A.length>0&&!v&&D.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-lg border border-[var(--wui-color-border)]",children:A.map(P=>D.jsxs("button",{onClick:()=>C==null?void 0:C(P),className:"w-full flex items-center justify-between px-3 py-2 text-left hover:bg-[var(--wui-color-bg-secondary)] transition-colors border-b border-[var(--wui-color-border)] last:border-b-0",children:[D.jsx("div",{className:"flex items-center gap-2 min-w-0",children:D.jsxs("div",{className:"min-w-0",children:[D.jsxs("p",{className:"text-sm font-medium text-[var(--wui-color-text)] truncate",children:[P.name,P.peraVerified&&D.jsx(Gx,{}),(e==null?void 0:e.has(P.index))&&D.jsx("span",{className:"ml-1.5 text-xs text-[var(--wui-color-text-tertiary)]",children:"(opted in)"})]}),P.unitName&&D.jsx("p",{className:"text-xs text-[var(--wui-color-text-secondary)]",children:P.unitName})]})}),D.jsxs("span",{className:"text-xs text-[var(--wui-color-text-tertiary)] shrink-0 ml-2",children:["ID: ",P.index]})]},P.index))}),M&&!w&&A&&A.length===0&&!v&&t.trim().length>0&&D.jsx("div",{className:"py-3 text-center text-sm text-[var(--wui-color-text-secondary)]",children:"No assets found"}),M&&w&&D.jsx(ty,{name:w.name,unitName:w.unitName,index:w.index,peraVerified:w.peraVerified,isAlreadyOptedIn:B,onOptIn:u})]}),D.jsx(jx,{status:c,error:d,successMessage:"Opted in successfully!",onRetry:h,txId:a,explorerUrl:l}),c==="success"&&D.jsx("button",{onClick:m,className:"mt-1 w-full text-sm text-[var(--wui-color-primary)] hover:underline",children:"Opt in to another asset"})]})}function Gx(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"var(--wui-color-primary)",className:"inline-block ml-1 -mt-0.5",children:D.jsx("path",{d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}function ty({name:n,unitName:e,index:t,peraVerified:r,isAlreadyOptedIn:i,onOptIn:o}){return D.jsxs("div",{className:"bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:[D.jsxs("div",{className:"flex justify-between items-start mb-3",children:[D.jsxs("div",{children:[D.jsxs("p",{className:"text-sm font-medium text-[var(--wui-color-text)]",children:[n,r&&D.jsx(Gx,{})]}),e&&D.jsx("p",{className:"text-xs text-[var(--wui-color-text-secondary)]",children:e})]}),D.jsxs("span",{className:"text-xs text-[var(--wui-color-text-tertiary)]",children:["ID: ",t]})]}),i?D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] text-center py-1",children:"Already opted in — no action needed."}):D.jsx("button",{onClick:o,className:"w-full py-2 px-4 bg-[var(--wui-color-primary)] text-white font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Opt In"})]})}const QC=.1;function e2({sendType:n,setSendType:e,receiver:t,setReceiver:r,amount:i,setAmount:o,assetIdInput:s,setAssetIdInput:a,assetInfo:l,assetLookupLoading:c,assetLookupError:d,receiverOptInStatus:u,receiverAddressError:m,txId:h,explorerUrl:x,accountAssets:A,availableBalance:v,status:F,error:w,handleSend:C,reset:M,retry:N,onBack:b}){const j=le=>{le==="algo"?(e("algo"),a("")):(e("asa"),a(le),L(!1)),o("")},p=n==="algo"?"algo":s,E=A==null?void 0:A.find(le=>String(le.assetId)===s),S=n==="algo"?"ALGO":(l==null?void 0:l.unitName)||(l==null?void 0:l.name)||"Asset",$=n==="algo"&&v!=null?`Available: ${v.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})} ALGO`:n==="asa"&&E?`Available: ${E.amount} ${E.unitName||E.name}`:null,[B,P]=Y.useState(!0),[W,L]=Y.useState(!1),q=le=>v==null?"0":Math.max(0,le?v-QC:v).toFixed(6).replace(/\.?0+$/,"")||"0",J=()=>{n==="algo"&&v!=null?(L(!0),o(q(B))):n==="asa"&&E&&(L(!1),o(E.amount))},U=()=>{const le=!B;P(le),o(q(le))},ne=i!==""?parseFloat(i):NaN,fe=!isNaN(ne)&&ne>0&&(n==="algo"&&v!=null&&ne>v||n==="asa"&&E!=null&&ne>parseFloat(E.amount));return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[D.jsx("button",{onClick:b,className:"-ml-1 p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-secondary)] flex items-center justify-center",title:"Back",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D.jsx("path",{d:"m15 18-6-6 6-6"})})}),D.jsx("h3",{className:"text-lg font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font",children:"Send"})]}),F==="idle"&&D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-2",children:"Send ALGO or assets to any Algorand address"}),$&&D.jsx("p",{className:"self-end text-xs text-[var(--wui-color-text-secondary)] mb-1",children:$}),D.jsxs("div",{className:"mb-3 flex gap-2",children:[D.jsxs("div",{className:"flex-1 min-w-0 relative",children:[D.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Amount",value:i,onChange:le=>o(le.target.value.replace(/[^0-9.]/g,"")),className:"w-full rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-3 pr-12 text-sm text-[var(--wui-color-text)] placeholder:text-[var(--wui-color-text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent"}),D.jsx("button",{type:"button",onClick:J,className:"absolute right-2 inset-y-0 my-auto h-fit text-[10px] font-medium text-[var(--wui-color-primary)] bg-[var(--wui-color-bg-tertiary)] rounded px-1.5 py-0.5 hover:brightness-90 transition-all",children:"max"})]}),D.jsxs("select",{value:p,onChange:le=>j(le.target.value),className:"w-[120px] shrink-0 rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-2 text-sm text-[var(--wui-color-text)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent",children:[D.jsx("option",{value:"algo",children:"ALGO"}),A==null?void 0:A.map(le=>D.jsx("option",{value:String(le.assetId),children:le.name},le.assetId))]})]}),n==="algo"&&W&&D.jsxs("label",{className:"flex items-center gap-1.5 mb-3 cursor-pointer select-none",children:[D.jsx("input",{type:"checkbox",checked:B,onChange:U,className:"accent-[var(--wui-color-primary)] h-3.5 w-3.5"}),D.jsx("span",{className:"text-xs text-[var(--wui-color-text-secondary)]",children:"Save some for transaction costs"})]}),fe&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:"Amount exceeds available balance"}),n==="asa"&&D.jsxs(D.Fragment,{children:[c&&D.jsxs("div",{className:"flex items-center mb-3 text-xs text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-3 w-3 mr-1.5"}),"Looking up asset..."]}),d&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:d})]}),D.jsx("div",{className:"mb-3",children:D.jsx("input",{type:"text",placeholder:"Receiver ALGO address",value:t,onChange:le=>r(le.target.value),className:"w-full rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-3 text-sm text-[var(--wui-color-text)] placeholder:text-[var(--wui-color-text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent"})}),m&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:m}),n==="asa"&&u==="not-opted-in"&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:"Receiver has not opted into this asset"}),D.jsx("button",{onClick:C,disabled:!t||!i||!!m||fe||n==="asa"&&!l||n==="asa"&&u!=="opted-in"&&u!=="idle",className:"w-full py-2.5 px-4 bg-[var(--wui-color-primary)] text-white font-medium rounded-xl hover:brightness-90 transition-all text-sm disabled:opacity-50 disabled:cursor-not-allowed",children:n==="asa"&&u==="checking"?"Verifying...":`Send ${S}`})]}),D.jsx(jx,{status:F,error:w,successMessage:"Sent successfully!",onRetry:N,txId:h,explorerUrl:x}),F==="success"&&D.jsx("button",{onClick:M,className:"mt-1 w-full text-sm text-[var(--wui-color-primary)] hover:underline",children:"Send more"})]})}const t2=new Intl.NumberFormat(void 0,{minimumFractionDigits:4,maximumFractionDigits:4}),Cu=3;function n2(n){const e=parseFloat(n);if(isNaN(e))return n;const[,t]=n.split(".");return e.toLocaleString(void 0,{minimumFractionDigits:(t==null?void 0:t.length)??0,maximumFractionDigits:(t==null?void 0:t.length)??0})}function r2({displayBalance:n,showAvailableBalance:e,onToggleBalance:t,onBack:r,send:i,optIn:o,assets:s,availableBalance:a,onRefresh:l,isRefreshing:c,onBridge:d,onExplore:u}){const[m,h]=Y.useState("main"),[x,A]=Y.useState(!1),[v,F]=Y.useState("none"),w=Y.useCallback(b=>{F("forward"),h(b)},[]),C=Y.useCallback(b=>{F("back"),h("main"),b==null||b()},[]);let M;m==="send"&&i?M=D.jsx(e2,{...i,accountAssets:s,availableBalance:a,onBack:()=>C(i.reset)}):m==="opt-in"&&o?M=D.jsx(JC,{...o,onBack:()=>C(o.reset)}):M=D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[D.jsx("button",{onClick:r,className:"-ml-1 p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-secondary)] flex items-center justify-center",title:"Back",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D.jsx("path",{d:"m15 18-6-6 6-6"})})}),D.jsx("h3",{className:"text-lg font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font",children:"Manage Liquid Account"}),l&&D.jsx("button",{onClick:l,disabled:c,className:"ml-auto p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] flex items-center justify-center disabled:pointer-events-none",title:"Refresh",children:D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:c?"animate-spin":"",children:[D.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),D.jsx("path",{d:"M21 3v5h-5"})]})})]}),D.jsx("div",{className:"mb-4 bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:D.jsxs("div",{className:"flex justify-between items-center",children:[n!==null&&D.jsxs("span",{className:"text-base font-medium text-[var(--wui-color-text)] flex items-center gap-1",children:[t2.format(n),D.jsx(Ux,{})]}),D.jsxs("button",{onClick:t,className:"flex items-center gap-1 text-sm text-[var(--wui-color-text-secondary)] bg-[var(--wui-color-bg-tertiary)] py-1 pl-2.5 pr-2 rounded-md hover:brightness-90 transition-all focus:outline-none",title:e?"Show total balance":"Show available balance",children:[e?"Available":"Total",D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-0.5 opacity-80",children:[D.jsx("path",{d:"m17 10-5-5-5 5"}),D.jsx("path",{d:"m17 14-5 5-5-5"})]})]})]})}),s&&s.length>0&&D.jsxs("div",{className:"mb-4",children:[D.jsx("h4",{className:"text-xs font-medium text-[var(--wui-color-text-tertiary)] uppercase tracking-wide mb-1.5",children:"Assets"}),D.jsx("div",{className:x?"overflow-y-auto":"",style:x?{maxHeight:`${Cu*2*28}px`}:void 0,children:(x?s:s.slice(0,Cu)).map(b=>D.jsxs("div",{className:"flex justify-between items-center py-1",children:[D.jsxs("span",{className:"text-sm text-[var(--wui-color-text-secondary)] truncate mr-3 flex items-center gap-1.5",children:[b.name," ",D.jsxs("span",{className:"text-[var(--wui-color-text-tertiary)]",children:["(ID ",b.assetId,")"]}),i&&D.jsx("button",{onClick:()=>{i.setSendType("asa"),i.setAssetIdInput(String(b.assetId)),w("send")},className:"inline-flex items-center justify-center w-4 h-4 rounded-xs border border-[var(--wui-color-border)] text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] hover:border-[var(--wui-color-text-tertiary)] transition-colors shrink-0",title:`Send ${b.unitName||b.name}`,children:D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M7 17 17 7"}),D.jsx("path",{d:"M7 7h10v10"})]})})]}),D.jsxs("span",{className:"text-sm font-medium text-[var(--wui-color-text)] tabular-nums whitespace-nowrap",children:[n2(b.amount),b.unitName?` ${b.unitName}`:""]})]},b.assetId))}),s.length>Cu&&D.jsx("button",{onClick:()=>A(b=>!b),className:"text-xs text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] transition-colors mt-1",children:x?"show less":`+${s.length-Cu} more`})]}),D.jsx("div",{className:"border-t border-[var(--wui-color-border)] mb-3"}),D.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[D.jsxs("button",{onClick:()=>w("send"),disabled:!i,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M7 17 17 7"}),D.jsx("path",{d:"M7 7h10v10"})]}),"Send"]}),D.jsxs("button",{onClick:()=>w("opt-in"),disabled:!o,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M17 7 7 17"}),D.jsx("path",{d:"M17 17H7V7"})]}),"Receive"]}),D.jsxs("button",{onClick:d,disabled:!d,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M8 3l4 4-4 4"}),D.jsx("path",{d:"M16 3l-4 4 4 4"}),D.jsx("path",{d:"M12 7H4"}),D.jsx("path",{d:"M12 7h8"}),D.jsx("path",{d:"M8 21l4-4-4-4"}),D.jsx("path",{d:"M16 21l-4-4 4-4"}),D.jsx("path",{d:"M12 17H4"}),D.jsx("path",{d:"M12 17h8"})]}),"Bridge"]}),D.jsxs("button",{onClick:u,disabled:!u,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("circle",{cx:"11",cy:"11",r:"8"}),D.jsx("path",{d:"m21 21-4.3-4.3"})]}),"Explore"]})]})]});const N=v==="forward"?"wui-slide-fwd 180ms ease-out both":v==="back"?"wui-slide-back 180ms ease-out both":"none";return D.jsxs(D.Fragment,{children:[D.jsx("style",{children:`
39
+ `}function yC(n,e){if(!n.appCallTrace||!n.disassembly)return"";let t=e;return e!==void 0?t=e:t={maxValueWidth:mg,topOfStackFirst:!1},Tx(n.appCallTrace,n.disassembly,t)}function wC(n,e){if(!n.logicSigTrace||!n.logicSigDisassembly)return"";let t;return e!==void 0?t=e:t={maxValueWidth:mg,topOfStackFirst:!0},Tx(n.logicSigTrace,n.logicSigDisassembly,t)}function xC({sender:n,receiver:e,amount:t,closeRemainderTo:r,suggestedParams:i,note:o,lease:s,rekeyTo:a}){return new br({type:Bt.pay,sender:n,note:o,lease:s,rekeyTo:a,suggestedParams:i,paymentParams:{receiver:e,amount:t,closeRemainderTo:r}})}function vC({sender:n,voteKey:e,selectionKey:t,stateProofKey:r,voteFirst:i,voteLast:o,voteKeyDilution:s,nonParticipation:a,suggestedParams:l,note:c,lease:d,rekeyTo:u}){return new br({type:Bt.keyreg,sender:n,note:c,lease:d,rekeyTo:u,suggestedParams:l,keyregParams:{voteKey:e,selectionKey:t,stateProofKey:r,voteFirst:i,voteLast:o,voteKeyDilution:s,nonParticipation:a}})}function eh({sender:n,assetIndex:e,total:t,decimals:r,defaultFrozen:i,manager:o,reserve:s,freeze:a,clawback:l,unitName:c,assetName:d,assetURL:u,assetMetadataHash:m,note:h,lease:x,rekeyTo:A,suggestedParams:v}){return new br({type:Bt.acfg,sender:n,note:h,lease:x,rekeyTo:A,suggestedParams:v,assetConfigParams:{assetIndex:e,total:t,decimals:r,defaultFrozen:i,manager:o,reserve:s,freeze:a,clawback:l,unitName:c,assetName:d,assetURL:u,assetMetadataHash:m}})}function SC({sender:n,total:e,decimals:t,defaultFrozen:r,manager:i,reserve:o,freeze:s,clawback:a,unitName:l,assetName:c,assetURL:d,assetMetadataHash:u,note:m,lease:h,rekeyTo:x,suggestedParams:A}){return eh({sender:n,total:e,decimals:t,defaultFrozen:r,manager:i,reserve:o,freeze:s,clawback:a,unitName:l,assetName:c,assetURL:d,assetMetadataHash:u,note:m,lease:h,rekeyTo:x,suggestedParams:A})}function bC({sender:n,assetIndex:e,manager:t,reserve:r,freeze:i,clawback:o,strictEmptyAddressChecking:s,note:a,lease:l,rekeyTo:c,suggestedParams:d}){if(!e)throw Error("assetIndex must be provided");if((s??!0)&&(t==null||r==null||i==null||o==null))throw Error("strictEmptyAddressChecking is enabled, but an address is empty. If this is intentional, set strictEmptyAddressChecking to false.");return eh({sender:n,assetIndex:e,manager:t,reserve:r,freeze:i,clawback:o,note:a,lease:l,rekeyTo:c,suggestedParams:d})}function EC({sender:n,assetIndex:e,note:t,lease:r,rekeyTo:i,suggestedParams:o}){if(!e)throw Error("assetIndex must be provided");return eh({sender:n,assetIndex:e,note:t,lease:r,rekeyTo:i,suggestedParams:o})}function AC({sender:n,assetIndex:e,freezeTarget:t,frozen:r,suggestedParams:i,note:o,lease:s,rekeyTo:a}){return new br({type:Bt.afrz,sender:n,note:o,lease:s,rekeyTo:a,suggestedParams:i,assetFreezeParams:{assetIndex:e,freezeTarget:t,frozen:r}})}function IC({sender:n,receiver:e,amount:t,closeRemainderTo:r,assetSender:i,note:o,assetIndex:s,suggestedParams:a,rekeyTo:l,lease:c}){if(!s)throw Error("assetIndex must be provided");return new br({type:Bt.axfer,sender:n,note:o,lease:c,rekeyTo:l,suggestedParams:a,assetTransferParams:{assetIndex:s,receiver:e,amount:t,assetSender:i,closeRemainderTo:r}})}function Ei({sender:n,appIndex:e,onComplete:t,appArgs:r,accounts:i,foreignApps:o,foreignAssets:s,boxes:a,convertToAccess:l,holdings:c,locals:d,access:u,approvalProgram:m,clearProgram:h,numLocalInts:x,numLocalByteSlices:A,numGlobalInts:v,numGlobalByteSlices:F,extraPages:w,rejectVersion:C,note:M,lease:N,rekeyTo:b,suggestedParams:j}){if(t==null)throw Error("onComplete must be provided");if(u&&(i||o||s||a||c||d))throw Error("cannot specify both access and other access fields");let p=u;return l&&(p=aI({appIndex:e,accounts:i,foreignApps:o,foreignAssets:s,holdings:c,locals:d,boxes:a})),new br({type:Bt.appl,sender:n,note:M,lease:N,rekeyTo:b,suggestedParams:j,appCallParams:{appIndex:e,onComplete:t,appArgs:r,accounts:p?void 0:i,foreignAssets:p?void 0:s,foreignApps:p?void 0:o,boxes:p?void 0:a,access:p,approvalProgram:m,clearProgram:h,numLocalInts:x,numLocalByteSlices:A,numGlobalInts:v,numGlobalByteSlices:F,extraPages:w,rejectVersion:C}})}function kC({sender:n,onComplete:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,numLocalInts:h,numLocalByteSlices:x,numGlobalInts:A,numGlobalByteSlices:v,extraPages:F,note:w,lease:C,rekeyTo:M,suggestedParams:N}){if(!u||!m)throw Error("approvalProgram and clearProgram must be provided");if(e==null)throw Error("onComplete must be provided");return Ei({sender:n,appIndex:0,onComplete:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,numLocalInts:h,numLocalByteSlices:x,numGlobalInts:A,numGlobalByteSlices:v,extraPages:F,note:w,lease:C,rekeyTo:M,suggestedParams:N})}function CC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,note:h,lease:x,rekeyTo:A,suggestedParams:v}){if(!e)throw Error("appIndex must be provided");if(!u||!m)throw Error("approvalProgram and clearProgram must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.UpdateApplicationOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,approvalProgram:u,clearProgram:m,note:h,lease:x,rekeyTo:A,suggestedParams:v})}function FC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.DeleteApplicationOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function DC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.OptInOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,note:u,convertToAccess:a,holdings:l,locals:c,access:d,lease:m,rekeyTo:h,suggestedParams:x})}function TC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.CloseOutOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function MC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.ClearStateOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function RC({sender:n,appIndex:e,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x}){if(!e)throw Error("appIndex must be provided");return Ei({sender:n,appIndex:e,onComplete:kn.NoOpOC,appArgs:t,accounts:r,foreignApps:i,foreignAssets:o,boxes:s,convertToAccess:a,holdings:l,locals:c,access:d,note:u,lease:m,rekeyTo:h,suggestedParams:x})}function BC(n){return(e,t)=>{const r=[];for(const i of t)r.push(e[i].signTxn(n.sk));return Promise.resolve(r)}}function NC(n){return(e,t)=>{const r=[];for(const i of t){const{blob:o}=gg(e[i],n);r.push(o)}return Promise.resolve(r)}}function PC(n,e){return(t,r)=>{const i=[];for(const o of r){const s=t[o],a=[];for(const l of e){const{blob:c}=Cx(s,n,l);a.push(c)}a.length>1?i.push(Qd(a)):i.push(a[0])}return Promise.resolve(i)}}function Mx(){return(n,e)=>{const t=[];for(const r of e)t.push(hx(n[r]));return Promise.resolve(t)}}function Fp(n){return typeof n=="object"&&Object.keys(n).length===2&&typeof n.txn=="object"&&typeof n.signer=="function"}const Wo=2**16-1,Rx=32,Bx=1,Nx=1,zn=2,OC=/^([a-z\d[\](),]+)\[(0|[1-9][\d]*)]$/,LC=/^ufixed([1-9][\d]*)x([1-9][\d]*)$/;class On{static from(e){if(e.endsWith("[]")){const t=On.from(e.slice(0,e.length-2));return new Bs(t)}if(e.endsWith("]")){const t=e.match(OC);if(!t||t.length!==3)throw new Error(`malformed static array string: ${e}`);const r=t[2],i=parseInt(r,10);if(i>Wo)throw new Error(`array length exceeds limit ${Wo}`);const o=On.from(t[1]);return new Rs(o,i)}if(e.startsWith("uint")){const t=o=>[...o].every(s=>"0123456789".includes(s)),r=e.slice(4,e.length);if(!t(r))throw new Error(`malformed uint string: ${r}`);const i=parseInt(r,10);if(i>Wo)throw new Error(`malformed uint string: ${i}`);return new Qi(i)}if(e==="byte")return new fu;if(e.startsWith("ufixed")){const t=e.match(LC);if(!t||t.length!==3)throw new Error(`malformed ufixed type: ${e}`);const r=parseInt(t[1],10),i=parseInt(t[2],10);return new th(r,i)}if(e==="bool")return new pi;if(e==="address")return new hu;if(e==="string")return new nh;if(e.length>=2&&e[0]==="("&&e[e.length-1]===")"){const t=Mr.parseTupleContent(e.slice(1,e.length-1)),r=[];for(let i=0;i<t.length;i++){const o=On.from(t[i]);r.push(o)}return new Mr(r)}throw new Error(`cannot convert a string ${e} to an ABI type`)}}class Qi extends On{constructor(e){if(super(),e%8!==0||e<8||e>512)throw new Error(`unsupported uint type bitSize: ${e}`);this.bitSize=e}toString(){return`uint${this.bitSize}`}equals(e){return e instanceof Qi&&this.bitSize===e.bitSize}isDynamic(){return!1}byteLen(){return this.bitSize/8}encode(e){if(typeof e!="bigint"&&typeof e!="number")throw new Error(`Cannot encode value as uint${this.bitSize}: ${e}`);if(e>=BigInt(2**this.bitSize)||e<BigInt(0))throw new Error(`${e} is not a non-negative int or too big to fit in size uint${this.bitSize}`);if(typeof e=="number"&&!Number.isSafeInteger(e))throw new Error(`${e} should be converted into a BigInt before it is encoded`);return Ms(e,this.bitSize/8)}decode(e){if(e.length!==this.bitSize/8)throw new Error(`byte string must correspond to a uint${this.bitSize}`);return hg(e)}}class th extends On{constructor(e,t){if(super(),e%8!==0||e<8||e>512)throw new Error(`unsupported ufixed type bitSize: ${e}`);if(t>160||t<1)throw new Error(`unsupported ufixed type precision: ${t}`);this.bitSize=e,this.precision=t}toString(){return`ufixed${this.bitSize}x${this.precision}`}equals(e){return e instanceof th&&this.bitSize===e.bitSize&&this.precision===e.precision}isDynamic(){return!1}byteLen(){return this.bitSize/8}encode(e){if(typeof e!="bigint"&&typeof e!="number")throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);if(e>=BigInt(2**this.bitSize)||e<BigInt(0))throw new Error(`${e} is not a non-negative int or too big to fit in size ${this.toString()}`);if(typeof e=="number"&&!Number.isSafeInteger(e))throw new Error(`${e} should be converted into a BigInt before it is encoded`);return Ms(e,this.bitSize/8)}decode(e){if(e.length!==this.bitSize/8)throw new Error(`byte string must correspond to a ${this.toString()}`);return hg(e)}}class hu extends On{toString(){return"address"}equals(e){return e instanceof hu}isDynamic(){return!1}byteLen(){return Rx}encode(e){if(typeof e=="string")return W0(e).publicKey;if(e instanceof ze)return e.publicKey;if(e instanceof Uint8Array){if(e.byteLength!==32)throw new Error("byte string must be 32 bytes long for an address");return e}throw new Error(`Cannot encode value as ${this.toString()}: ${e}`)}decode(e){if(e.byteLength!==32)throw new Error("byte string must be 32 bytes long for an address");return H0(e)}}class pi extends On{toString(){return"bool"}equals(e){return e instanceof pi}isDynamic(){return!1}byteLen(){return Nx}encode(e){if(typeof e!="boolean")throw new Error(`Cannot encode value as bool: ${e}`);return e?new Uint8Array([128]):new Uint8Array([0])}decode(e){if(e.byteLength!==1)throw new Error("bool string must be 1 byte long");const t=e[0];if(t===128)return!0;if(t===0)return!1;throw new Error("boolean could not be decoded from the byte string")}}class fu extends On{toString(){return"byte"}equals(e){return e instanceof fu}isDynamic(){return!1}byteLen(){return Bx}encode(e){if(typeof e!="number"&&typeof e!="bigint")throw new Error(`Cannot encode value as byte: ${e}`);if(typeof e=="bigint"&&(e=Number(e)),e<0||e>255)throw new Error(`${e} cannot be encoded into a byte`);return new Uint8Array([e])}decode(e){if(e.byteLength!==1)throw new Error("byte string must be 1 byte long");return e[0]}}class nh extends On{toString(){return"string"}equals(e){return e instanceof nh}isDynamic(){return!0}byteLen(){throw new Error(`${this.toString()} is a dynamic type`)}encode(e){if(typeof e!="string"&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as string: ${e}`);let t;typeof e=="string"?t=new TextEncoder().encode(e):t=e;const r=Ms(t.length,zn),i=new Uint8Array(t.length+zn);return i.set(r),i.set(t,zn),i}decode(e){if(e.length<zn)throw new Error(`byte string is too short to be decoded. Actual length is ${e.length}, but expected at least ${zn}`);const r=new DataView(e.buffer,e.byteOffset,zn).getUint16(0),i=e.slice(zn,e.length);if(r!==i.length)throw new Error(`string length bytes do not match the actual length of string. Expected ${r}, got ${i.length}`);return new TextDecoder("utf-8").decode(i)}}class Rs extends On{constructor(e,t){if(super(),t<0)throw new Error(`static array must have a non negative length: ${t}`);this.childType=e,this.staticLength=t}toString(){return`${this.childType.toString()}[${this.staticLength}]`}equals(e){return e instanceof Rs&&this.staticLength===e.staticLength&&this.childType.equals(e.childType)}isDynamic(){return this.childType.isDynamic()}byteLen(){return this.childType.constructor===pi?Math.ceil(this.staticLength/8):this.staticLength*this.childType.byteLen()}encode(e){if(!Array.isArray(e)&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);if(e.length!==this.staticLength)throw new Error(`Value array does not match static array length. Expected ${this.staticLength}, got ${e.length}`);return this.toABITupleType().encode(e)}decode(e){return this.toABITupleType().decode(e)}toABITupleType(){return new Mr(Array(this.staticLength).fill(this.childType))}}class Bs extends On{constructor(e){super(),this.childType=e}toString(){return`${this.childType.toString()}[]`}equals(e){return e instanceof Bs&&this.childType.equals(e.childType)}isDynamic(){return!0}byteLen(){throw new Error(`${this.toString()} is a dynamic type`)}encode(e){if(!Array.isArray(e)&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);const t=this.toABITupleType(e.length),r=t.encode(e),i=Ms(t.childTypes.length,zn);return hn(i,r)}decode(e){const r=new DataView(e.buffer,0,zn).getUint16(0);return this.toABITupleType(r).decode(e.slice(zn,e.length))}toABITupleType(e){return new Mr(Array(e).fill(this.childType))}}class Mr extends On{constructor(e){if(super(),e.length>=Wo)throw new Error("tuple type child type number larger than maximum uint16 error");this.childTypes=e}toString(){const e=[];for(let t=0;t<this.childTypes.length;t++)e[t]=this.childTypes[t].toString();return`(${e.join(",")})`}equals(e){return e instanceof Mr&&this.childTypes.length===e.childTypes.length&&this.childTypes.every((t,r)=>t.equals(e.childTypes[r]))}isDynamic(){const e=t=>t.isDynamic();return this.childTypes.some(e)}byteLen(){let e=0;for(let t=0;t<this.childTypes.length;t++)if(this.childTypes[t].constructor===pi){const r=Gc(this.childTypes,t,1),i=r+1;t+=r,e+=Math.trunc((i+7)/8)}else{const r=this.childTypes[t].byteLen();e+=r}return e}encode(e){if(!Array.isArray(e)&&!(e instanceof Uint8Array))throw new Error(`Cannot encode value as ${this.toString()}: ${e}`);const t=Array.from(e);if(e.length>Wo)throw new Error("length of tuple array should not exceed a uint16");const r=this.childTypes,i=[],o=[],s=new Map;let a=0;for(;a<r.length;){const d=r[a];if(d.isDynamic())s.set(i.length,!0),i.push(new Uint8Array([0,0])),o.push(d.encode(t[a]));else{if(d.constructor===pi){const u=Gc(r,a,-1);let m=Gc(r,a,1);if(u%8!==0)throw new Error("expected before index should have number of bool mod 8 equal 0");m=Math.min(7,m);const h=VC(t.slice(a,a+m+1));i.push(Ms(h,1)),a+=m}else{const u=d.encode(t[a]);i.push(u)}s.set(a,!1),o.push(new Uint8Array)}a+=1}let l=0;for(const d of i)l+=d.length;let c=0;for(let d=0;d<i.length;d++){if(s.get(d)){const u=l+c;if(u>Wo)throw new Error(`byte length of ${u} should not exceed a uint16`);i[d]=Ms(u,zn)}c+=o[d].length}return hn(...i,...o)}decode(e){const t=this.childTypes,r=[],i=[];let o=0,s=0;const a=new DataView(e.buffer);for(;o<t.length;){const d=t[o];if(d.isDynamic()){if(e.slice(s,e.length).length<zn)throw new Error("dynamic type in tuple is too short to be decoded");const u=a.getUint16(s);if(r.length>0&&(r[r.length-1].right=u,u<r[r.length-1].left))throw new Error("dynamic index segment miscalculation: left is greater than right index");const m={left:u,right:-1};r.push(m),i.push(null),s+=zn}else if(d.constructor===pi){const u=Gc(this.childTypes,o,-1);let m=Gc(this.childTypes,o,1);if(u%8!==0)throw new Error("expected before bool number mod 8 === 0");m=Math.min(7,m);for(let h=0;h<=m;h++){const x=128>>h;(e[s]&x)>0?i.push(new Uint8Array([128])):i.push(new Uint8Array([0]))}o+=m,s+=1}else{const u=d.byteLen();i.push(e.slice(s,s+u)),s+=u}if(o!==t.length-1&&s>=e.length)throw new Error("input byte not enough to decode");o+=1}if(r.length>0&&(r[r.length-1].right=e.length,s=e.length),s<e.length)throw new Error("input byte not fully consumed");for(let d=0;d<r.length;d++){const u=r[d];if(u.left>u.right)throw new Error("dynamic segment should display a [l, r] space with l <= r");if(d!==r.length-1&&u.right!==r[d+1].left)throw new Error("dynamic segment should be consecutive")}let l=0;for(let d=0;d<t.length;d++)t[d].isDynamic()&&(i[d]=e.slice(r[l].left,r[l].right),l+=1);const c=[];for(let d=0;d<t.length;d++){const u=t[d].decode(i[d]);c.push(u)}return c}static parseTupleContent(e){if(e.length===0)return[];if(e.endsWith(",")||e.startsWith(","))throw new Error("tuple string should not start with comma");if(e.includes(",,"))throw new Error("tuple string should not have consecutive commas");const t=[];let r=0,i="";for(const o of e)i+=o,o==="("?r+=1:o===")"?r-=1:o===","&&r===0&&(t.push(i.slice(0,i.length-1)),i="");if(i.length!==0&&t.push(i),r!==0)throw new Error("tuple string has mismatched parentheses");return t}}function VC(n){let e=0;if(n.length>8)throw new Error("value list passed in should be no greater than length 8");for(let t=0;t<n.length;t++){const r=n[t];if(typeof r!="boolean")throw new Error("non-boolean values cannot be compressed into a byte");r&&(e|=1<<7-t)}return e}function Gc(n,e,t){let r=0;for(;;){const i=e+t*r;if(n[i].constructor===pi)if(i!==n.length-1&&t===1)r+=1;else if(i>0&&t===-1)r+=1;else break;else{r-=1;break}}return r}var kr;(function(n){n.any="txn",n.pay="pay",n.keyreg="keyreg",n.acfg="acfg",n.axfer="axfer",n.afrz="afrz",n.appl="appl"})(kr||(kr={}));function Ed(n){return n===kr.any||n===kr.pay||n===kr.keyreg||n===kr.acfg||n===kr.axfer||n===kr.afrz||n===kr.appl}function Px(n,e){return n===kr.any?!0:e.type?e.type.toString()===n.toString():!1}var gi;(function(n){n.account="account",n.application="application",n.asset="asset"})(gi||(gi={}));function yg(n){return n===gi.account||n===gi.application||n===gi.asset}function $C(n){const e=n.indexOf("(");if(e===-1)throw new Error(`Invalid method signature: ${n}`);let t=-1,r=0;for(let i=e;i<n.length;i++){const o=n[i];if(o==="(")r+=1;else if(o===")"){if(r===0)break;if(r-=1,r===0){t=i;break}}}if(t===-1)throw new Error(`Invalid method signature: ${n}`);return{name:n.slice(0,e),args:Mr.parseTupleContent(n.slice(e+1,t)),returns:n.slice(t+1)}}let rh=class Ox{constructor(e){if(typeof e.name!="string"||typeof e.returns!="object"||!Array.isArray(e.args))throw new Error("Invalid ABIMethod parameters");this.name=e.name,this.description=e.desc,this.args=e.args.map(({type:t,name:r,desc:i})=>Ed(t)||yg(t)?{type:t,name:r,description:i}:{type:On.from(t),name:r,description:i}),this.returns={type:e.returns.type==="void"?e.returns.type:On.from(e.returns.type),description:e.returns.desc},this.events=e.events,this.readonly=e.readonly}getSignature(){const e=this.args.map(r=>r.type.toString()).join(","),t=this.returns.type.toString();return`${this.name}(${e})${t}`}getSelector(){const e=wi(this.getSignature());return new Uint8Array(e.slice(0,4))}txnCount(){let e=1;for(const t of this.args)typeof t.type=="string"&&Ed(t.type)&&(e+=1);return e}toJSON(){return{name:this.name,desc:this.description,args:this.args.map(({type:e,name:t,description:r})=>({type:e.toString(),name:t,desc:r})),returns:{type:this.returns.type.toString(),desc:this.returns.description},events:this.events,readonly:this.readonly}}static fromSignature(e){const{name:t,args:r,returns:i}=$C(e);return new Ox({name:t,args:r.map(o=>({type:o})),returns:{type:i}})}};function wg(n,e){if(n===null||!Array.isArray(n)||!n.every(r=>r instanceof rh))throw new Error("Methods list provided is null or not the correct type");const t=n.filter(r=>r.name===e);if(t.length>1)throw new Error(`found ${t.length} methods with the same name ${t.map(r=>r.getSignature()).join(",")}`);if(t.length===0)throw new Error(`found 0 methods with the name ${e}`);return t[0]}class _C{constructor(e){if(typeof e.name!="string"||!Array.isArray(e.methods)||e.networks&&typeof e.networks!="object")throw new Error("Invalid ABIContract parameters");this.name=e.name,this.description=e.desc,this.networks=e.networks?{...e.networks}:{},this.methods=e.methods.map(t=>new rh(t)),this.events=e.events}toJSON(){return{name:this.name,desc:this.description,networks:this.networks,methods:this.methods.map(e=>e.toJSON()),events:this.events}}getMethodByName(e){return wg(this.methods,e)}}class UC{constructor(e){if(typeof e.name!="string"||!Array.isArray(e.methods))throw new Error("Invalid ABIInterface parameters");this.name=e.name,this.description=e.desc,this.methods=e.methods.map(t=>new rh(t))}toJSON(){return{name:this.name,desc:this.description,methods:this.methods.map(e=>e.toJSON())}}getMethodByName(e){return wg(this.methods,e)}}const jC=new Uint8Array([21,31,124,117]),Wc=16;var Mn;(function(n){n[n.BUILDING=0]="BUILDING",n[n.BUILT=1]="BUILT",n[n.SIGNED=2]="SIGNED",n[n.SUBMITTED=3]="SUBMITTED",n[n.COMMITTED=4]="COMMITTED"})(Mn||(Mn={}));function Lh(n,e,t){if(t!=null&&n===t)return 0;const r=t==null?0:1;for(let i=0;i<e.length;i++)if(n===e[i])return i+r;return e.push(n),e.length-1+r}let Lx=class Ti{constructor(){this.status=Mn.BUILDING,this.transactions=[],this.methodCalls=new Map,this.signedTxns=[],this.txIDs=[]}getStatus(){return this.status}count(){return this.transactions.length}clone(){const e=new Ti;return e.transactions=this.transactions.map(({txn:t,signer:r})=>{const i=t.toEncodingData();return i.delete("grp"),{txn:br.fromEncodingData(i),signer:r}}),e.methodCalls=new Map(this.methodCalls),e}addTransaction(e){if(this.status!==Mn.BUILDING)throw new Error("Cannot add transactions when composer status is not BUILDING");if(this.transactions.length===Ti.MAX_GROUP_SIZE)throw new Error(`Adding an additional transaction exceeds the maximum atomic group size of ${Ti.MAX_GROUP_SIZE}`);if(e.txn.group&&e.txn.group.some(t=>t!==0))throw new Error("Cannot add a transaction with nonzero group ID");this.transactions.push(e)}addMethodCall({appID:e,method:t,methodArgs:r,sender:i,suggestedParams:o,onComplete:s,approvalProgram:a,clearProgram:l,numGlobalInts:c,numGlobalByteSlices:d,numLocalInts:u,numLocalByteSlices:m,extraPages:h,appAccounts:x,appForeignApps:A,appForeignAssets:v,boxes:F,access:w,note:C,lease:M,rekeyTo:N,rejectVersion:b,signer:j}){if(this.status!==Mn.BUILDING)throw new Error("Cannot add transactions when composer status is not BUILDING");if(this.transactions.length+t.txnCount()>Ti.MAX_GROUP_SIZE)throw new Error(`Adding additional transactions exceeds the maximum atomic group size of ${Ti.MAX_GROUP_SIZE}`);if(BigInt(e)===BigInt(0)){if(a==null||l==null||c==null||d==null||u==null||m==null)throw new Error("One of the following required parameters for application creation is missing: approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices")}else if(s===kn.UpdateApplicationOC){if(a==null||l==null)throw new Error("One of the following required parameters for OnApplicationComplete.UpdateApplicationOC is missing: approvalProgram, clearProgram");if(c!=null||d!=null||u!=null||m!=null||h!=null)throw new Error("One of the following application creation parameters were set on a non-creation call: numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages")}else if(a!=null||l!=null||c!=null||d!=null||u!=null||m!=null||h!=null)throw new Error("One of the following application creation parameters were set on a non-creation call: approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages");if(w&&(x||A||v||F))throw new Error("Cannot specify both access and legacy foreign arrays (appAccounts, appForeignApps, appForeignAssets, boxes)");if(r==null&&(r=[]),r.length!==t.args.length)throw new Error(`Incorrect number of method arguments. Expected ${t.args.length}, got ${r.length}`);let p=[],E=[];const S=[],$=[],B=[],P=new Map,W=F||[];for(let le=0;le<r.length;le++){let ye=t.args[le].type;const he=r[le];if(Ed(ye)){if(!Fp(he)||!Px(ye,he.txn))throw new Error(`Expected ${ye} TransactionWithSigner for argument at index ${le}`);if(he.txn.group&&he.txn.group.some(de=>de!==0))throw new Error("Cannot add a transaction with nonzero group ID");S.push(he);continue}if(Fp(he))throw new Error(`Expected non-transaction value for argument at index ${le}`);if(yg(ye)&&(P.set($.length,p.length),$.push(ye),B.push(he),ye=new Qi(8)),typeof ye=="string")throw new Error(`Unknown ABI type: ${ye}`);p.push(ye),E.push(he)}const L=[],q=x==null?[]:x.map(le=>le.toString()),J=A==null?[]:A.map(Wt),U=v==null?[]:v.map(Wt);for(let le=0;le<$.length;le++){const ye=$[le],he=B[le];let de=0;switch(ye){case gi.account:{const be=new hu,Ae=be.decode(be.encode(he));de=Lh(Ae,q,i.toString());break}case gi.application:{const be=new Qi(64),Ae=be.decode(be.encode(he));if(Ae>Number.MAX_SAFE_INTEGER)throw new Error(`Expected safe integer for application value, got ${Ae}`);de=Lh(Ae,J,Wt(e));break}case gi.asset:{const be=new Qi(64),Ae=be.decode(be.encode(he));if(Ae>Number.MAX_SAFE_INTEGER)throw new Error(`Expected safe integer for asset value, got ${Ae}`);de=Lh(Ae,U);break}default:throw new Error(`Unknown reference type: ${ye}`)}L.push(de)}for(let le=0;le<L.length;le++){const ye=P.get(le);E[ye]=L[le]}if(p.length>Wc-1){const le=p.slice(Wc-2),ye=E.slice(Wc-2);p=p.slice(0,Wc-2),E=E.slice(0,Wc-2),p.push(new Mr(le)),E.push(ye)}const ne=[t.getSelector()];for(let le=0;le<p.length;le++)ne.push(p[le].encode(E[le]));const fe={txn:Ei({sender:i,appIndex:e,appArgs:ne,accounts:w?void 0:q,foreignApps:w?void 0:J,foreignAssets:w?void 0:U,boxes:w?void 0:W,access:w,onComplete:s??kn.NoOpOC,approvalProgram:a,clearProgram:l,numGlobalInts:c,numGlobalByteSlices:d,numLocalInts:u,numLocalByteSlices:m,extraPages:h,rejectVersion:b,lease:M,note:C,rekeyTo:N,suggestedParams:o}),signer:j};this.transactions.push(...S,fe),this.methodCalls.set(this.transactions.length-1,t)}buildGroup(){if(this.status===Mn.BUILDING){if(this.transactions.length===0)throw new Error("Cannot build a group with 0 transactions");this.transactions.length>1&&Ex(this.transactions.map(e=>e.txn)),this.status=Mn.BUILT}return this.transactions}async gatherSignatures(){if(this.status>=Mn.SIGNED)return this.signedTxns;const e=this.buildGroup(),t=e.map(c=>c.txn),r=new Map;for(let c=0;c<e.length;c++){const{signer:d}=e[c];r.has(d)||r.set(d,[]),r.get(d).push(c)}const i=Array.from(r),o=await Promise.all(i.map(([c,d])=>c(t,d))),s=e.map(()=>null);for(let c=0;c<i.length;c++){const d=i[c][1],u=o[c];for(let m=0;m<d.length;m++)s[d[m]]=u[m]}function a(c){return c.every(d=>d!=null)}if(!a(s))throw new Error(`Missing signatures. Got ${s}`);const l=s.map((c,d)=>{try{return Xt(c,jt).txn.txID()}catch(u){throw new Error(`Cannot decode signed transaction at index ${d}. ${u}`)}});return this.signedTxns=s,this.txIDs=l,this.status=Mn.SIGNED,s}async submit(e){if(this.status>Mn.SUBMITTED)throw new Error("Transaction group cannot be resubmitted");const t=await this.gatherSignatures();return await e.sendRawTransaction(t).do(),this.status=Mn.SUBMITTED,this.txIDs}async simulate(e,t){if(this.status>Mn.SUBMITTED)throw new Error("Simulated Transaction group has already been submitted to the network");const i=(await this.gatherSignatures()).map(l=>Xt(l,jt)),o=t??new Oa({txnGroups:[]});o.txnGroups=[new ro({txns:i})];const s=await e.simulateTransactions(o).do(),a=[];for(const[l,c]of this.methodCalls){const d=this.txIDs[l],u=s.txnGroups[0].txnResults[l].txnResult,m={txID:d,rawReturnValue:new Uint8Array,method:c};a.push(Ti.parseMethodResponse(c,m,u))}return{methodResults:a,simulateResponse:s}}async execute(e,t){if(this.status===Mn.COMMITTED)throw new Error("Transaction group has already been executed successfully");const r=await this.submit(e);this.status=Mn.SUBMITTED;const i=this.transactions.findIndex((c,d)=>this.methodCalls.has(d)),s=await wx(e,r[i===-1?0:i],t);this.status=Mn.COMMITTED;const a=s.confirmedRound,l=[];for(const[c,d]of this.methodCalls){const u=r[c];let m={txID:u,rawReturnValue:new Uint8Array,method:d};try{const h=c===i?s:await e.pendingTransactionInformation(u).do();m=Ti.parseMethodResponse(d,m,h)}catch(h){m.decodeError=h}l.push(m)}return{confirmedRound:a,txIDs:r,methodResults:l}}static parseMethodResponse(e,t,r){const i=t;try{if(i.txInfo=r,e.returns.type!=="void"){const o=r.logs||[];if(o.length===0)throw new Error(`App call transaction did not log a return value ${yi(r)}`);const s=o[o.length-1];if(s.byteLength<4||!Kr(s.slice(0,4),jC))throw new Error(`App call transaction did not log a ABI return value ${yi(r)}`);i.rawReturnValue=new Uint8Array(s.slice(4)),i.returnValue=e.returns.type.decode(t.rawReturnValue)}}catch(o){i.decodeError=o}return i}};Lx.MAX_GROUP_SIZE=16;const Vx=Uint8Array.from([77,88]),$x="The transaction sender address and multisig preimage do not match.";function GC(n,e){return{txID:n.txID(),blob:n.signTxn(e)}}function WC(n,e){const t=hn(Vx,n);return ll(t,e)}function zC(n,e,t){const r=hn(Vx,n),i=typeof t=="string"?ze.fromString(t):t;return Gd(r,e,i.publicKey)}const HC=new Error($x),YC=new Error(ag),Le=Object.freeze(Object.defineProperty({__proto__:null,ABIAddressType:hu,ABIArrayDynamicType:Bs,ABIArrayStaticType:Rs,ABIBoolType:pi,ABIByteType:fu,ABIContract:_C,ABIInterface:UC,ABIMethod:rh,get ABIReferenceType(){return gi},ABIStringType:nh,get ABITransactionType(){return kr},ABITupleType:Mr,ABIType:On,ABIUfixedType:th,ABIUintType:Qi,ADDR_BYTE_SIZE:Rx,ALGORAND_ZERO_ADDRESS_STRING:Q1,AccountBaseData:ys,AccountData:ws,AccountDeltas:vs,AccountTotals:As,Address:ze,AlgoCount:Tr,Algodv2:Sk,AppLocalState:ls,AppLocalStateDelta:us,AppParams:cs,AppParamsDelta:ds,AppResourceRecord:hs,ApplyData:wa,AssetHolding:Zd,AssetHoldingDelta:fs,AssetParams:Jd,AssetParamsDelta:ps,AssetResourceRecord:gs,AtomicTransactionComposer:Lx,get AtomicTransactionComposerStatus(){return Mn},BalanceRecord:xs,Block:md,BlockHeader:vi,ENCODED_MULTISIG_SCHEMA:fd,ENCODED_SUBSIG_SCHEMA:ax,ERROR_INVALID_MICROALGOS:YC,ERROR_MULTISIG_BAD_SENDER:HC,EvalDelta:Kf,FalconSignatureStruct:Qo,FalconVerifier:Jo,HashFactory:Yd,INVALID_MICROALGOS_ERROR_MSG:ag,IncludedTransactions:bs,Indexer:zk,IntDecoding:an,Kmd:bk,KvValueDelta:Ss,LENGTH_ENCODE_BYTE_SIZE:zn,LedgerStateDelta:Si,LogicSig:rr,LogicSigAccount:dg,MAX_LEN:Wo,MULTISIG_BAD_SENDER_ERROR_MSG:$x,MerkleArrayProof:to,MerkleSignatureVerifier:Xo,ModifiedCreatable:Es,get OnApplicationComplete(){return kn},Participant:Zo,ParticipationUpdates:Xd,ProgramSourceMap:Dx,Reveal:ts,RewardState:is,SINGLE_BOOL_SIZE:Nx,SINGLE_BYTE_SIZE:Bx,SignedTransaction:jt,SignedTxnInBlock:as,SignedTxnWithAD:no,SigslotCommit:es,StateProof:Kd,StateProofMessage:qd,StateProofTrackingData:ns,StateSchema:Xr,TealValue:Mc,Transaction:br,get TransactionType(){return Bt},TxnCommitments:rs,UntypedValue:Sn,UpgradeState:os,UpgradeVote:ss,ValueDelta:di,VotingData:ms,abiCheckTransactionType:Px,abiTypeIsReference:yg,abiTypeIsTransaction:Ed,algosToMicroalgos:rA,appendSignMultisigTransaction:uC,appendSignRawMultisigSignature:dC,assignGroupID:Ex,base64ToBytes:Ge,bigIntToBytes:Ms,bytesToBase64:In,bytesToBigInt:hg,bytesToHex:zd,bytesToString:Wd,coerceToBytes:qr,computeGroupID:bx,createDryrun:pC,createMultisigTransaction:Ax,decodeAddress:W0,decodeJSON:Et,decodeMsgpack:Xt,decodeObj:JA,decodeSignedTransaction:MI,decodeUint64:G0,decodeUnsignedTransaction:vI,dryrunTxnResultAppTrace:yC,dryrunTxnResultLogicSigTrace:wC,encodeAddress:H0,encodeJSON:eI,encodeMsgpack:Sr,encodeObj:ZA,encodeUint64:j0,encodeUnsignedSimulateTransaction:hx,encodeUnsignedTransaction:xI,encodedMultiSigFromEncodingData:pd,encodedMultiSigToEncodingData:gd,encodedSubsigFromEncodingData:cx,encodedSubsigToEncodingData:lx,generateAccount:Hk,getApplicationAddress:dd,getMethodByName:wg,hexToBytes:J1,indexerModels:Ek,isOnApplicationComplete:rx,isTransactionType:jf,isTransactionWithSigner:Fp,isValidAddress:z0,logicSigFromByte:FI,makeApplicationCallTxnFromObject:Ei,makeApplicationClearStateTxnFromObject:MC,makeApplicationCloseOutTxnFromObject:TC,makeApplicationCreateTxnFromObject:kC,makeApplicationDeleteTxnFromObject:FC,makeApplicationNoOpTxnFromObject:RC,makeApplicationOptInTxnFromObject:DC,makeApplicationUpdateTxnFromObject:CC,makeAssetConfigTxnWithSuggestedParamsFromObject:bC,makeAssetCreateTxnWithSuggestedParamsFromObject:SC,makeAssetDestroyTxnWithSuggestedParamsFromObject:EC,makeAssetFreezeTxnWithSuggestedParamsFromObject:AC,makeAssetTransferTxnWithSuggestedParamsFromObject:IC,makeBaseAssetConfigTxn:eh,makeBasicAccountTransactionSigner:BC,makeEmptyTransactionSigner:Mx,makeKeyRegistrationTxnWithSuggestedParamsFromObject:vC,makeLogicSigAccountTransactionSigner:NC,makeMultiSigAccountTransactionSigner:PC,makePaymentTxnWithSuggestedParamsFromObject:xC,masterDerivationKeyToMnemonic:Jk,mergeMultisigTransactions:Qd,microalgosToAlgos:nA,mnemonicFromSeed:fg,mnemonicToMasterDerivationKey:Zk,mnemonicToSecretKey:qk,modelsv2:NI,msgpackRawDecode:ex,msgpackRawDecodeAsMap:tx,msgpackRawEncode:du,multisigAddress:kI,parseJSON:_d,secretKeyToMnemonic:Xk,seedFromMnemonic:pg,signBytes:WC,signLogicSigTransaction:nC,signLogicSigTransactionObject:gg,signMultisigTransaction:Cx,signTransaction:GC,stringifyJSON:yi,tealSign:dx,tealSignFromProgram:TI,verifyBytes:zC,verifyMultisig:Hf,verifyTealSign:DI,waitForConfirmation:wx},Symbol.toStringTag,{value:"Module"}));function KC(n,e){if(n===void 0)return`0 ${e.unitName}`;const t=typeof n=="bigint"?n:BigInt(n);if(e.decimals===0)return`${t} ${e.unitName}`;const r=10n**BigInt(e.decimals),i=t/r,o=t%r;if(o===0n)return`${i} ${e.unitName}`;const s=o.toString().padStart(e.decimals,"0").replace(/0+$/,"");return`${i}.${s} ${e.unitName}`}function Vh(n,e){return e!=null&&e.unitName?e.unitName:n.assetIndex?`ASA#${n.assetIndex}`:"ASA"}function qC({txn:n,assetInfo:e,appEscrows:t={}}){const r=(a,l)=>a&&t[a]||l,i=(a,l,c,d=!1,u=!1)=>D.jsxs("div",{className:`grid grid-cols-[1fr_auto_1fr] w-full items-center font-mono text-xs ${u?"mt-1":""}`,children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] text-left",children:a}),D.jsxs("span",{className:"flex items-center justify-center gap-1 px-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"--["}),D.jsx("span",{className:d?"text-[var(--wui-color-danger-text)] font-bold":"text-[var(--wui-color-primary)] font-medium",children:l}),D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"]-->"})]}),D.jsx("span",{className:`text-right ${d?"text-[var(--wui-color-danger-text)] font-bold":"text-[var(--wui-color-text-secondary)]"}`,children:c})]}),o=a=>D.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center font-mono text-xs mt-1",children:[D.jsx("span",{}),D.jsxs("span",{className:"flex items-center justify-center gap-1 px-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"--["}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold",children:"remainder"}),D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"]-->"})]}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold text-right",children:a})]}),s=(a,l)=>D.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center font-mono text-xs mt-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] text-left",children:a}),D.jsxs("span",{className:"flex items-center justify-center gap-1 px-1",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"--["}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold",children:"REKEY"}),D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"]-->"})]}),D.jsx("span",{className:"text-[var(--wui-color-danger-text)] font-bold text-right",children:l})]});return D.jsxs("div",{className:"space-y-0",children:[n.type==="pay"&&n.receiverShort&&D.jsxs(D.Fragment,{children:[i(n.senderShort,n.amount||"0 ALGO",r(n.receiver,n.receiverShort)),n.closeRemainderToShort&&o(n.closeRemainderToShort)]}),n.type==="axfer"&&n.receiverShort&&D.jsxs(D.Fragment,{children:[i(n.senderShort,e?KC(n.rawAmount,e):`${n.amount||"0"} ${Vh(n)}`,r(n.receiver,n.receiverShort)),n.closeRemainderToShort&&o(n.closeRemainderToShort)]}),n.type==="afrz"&&n.freezeTargetShort&&D.jsx(D.Fragment,{children:i(n.senderShort,`${n.isFreezing?"Freeze":"Unfreeze"} ${Vh(n,e)}`,n.freezeTargetShort)}),n.type==="acfg"&&D.jsx(D.Fragment,{children:i(n.senderShort,`Configure ${n.assetIndex?Vh(n,e):"NEW"}`,n.senderShort)}),n.type==="appl"&&D.jsx(D.Fragment,{children:i(n.senderShort,"APP CALL",`App ${n.appIndex||"NEW"}`)}),n.type==="keyreg"&&D.jsx(D.Fragment,{children:i(n.senderShort,"KEY REG",n.senderShort)}),n.rekeyToShort&&s(n.senderShort,n.rekeyToShort)]})}function _x(n,e){const t=F1({queries:n.map(o=>({queryKey:["asset",o],queryFn:async()=>{const s=await e.getAssetByID(Number(o)).do();return{decimals:s.params.decimals,name:s.params.name||"",unitName:s.params.unitName||""}},retries:0,enabled:!!e,staleTime:1/0,gcTime:1/0}))}),r=t.some(o=>o.isLoading),i=Y.useMemo(()=>{var s;const o={};for(let a=0;a<n.length;a++){const l=(s=t[a])==null?void 0:s.data;l&&(o[n[a]]=l)}return o},[n,t]);return{loading:r,assets:i}}function XC(n,e){const t=e==null?void 0:e.algodClient,r=e==null?void 0:e.getApplicationAddress,i=Y.useMemo(()=>{const l=new Set;for(const c of n)c.assetIndex&&l.add(c.assetIndex.toString());return Array.from(l)},[n]),{loading:o,assets:s}=_x(i,t),a=Y.useMemo(()=>{if(!r)return{};const l={};for(const c of n)if(c.type==="appl"&&c.appIndex){const d=r(c.appIndex);l[d.toString()]=`App ${c.appIndex}`}return l},[n,r]);return{loading:o,assets:s,appEscrows:a}}function ZC({transactions:n,message:e,dangerous:t,algodClient:r,getApplicationAddress:i,onApprove:o,onReject:s,signing:a,walletName:l,origin:c,headerAction:d,payloadVerified:u}){const{loading:m,assets:h,appEscrows:x}=XC(n,{algodClient:r,getApplicationAddress:i});return D.jsxs("div",{className:"flex flex-col",children:[D.jsxs("div",{className:"flex items-center justify-between px-6 pt-5 pb-1",children:[D.jsxs("h2",{className:`text-lg font-bold ${t?"text-[var(--wui-color-danger-text)]":"text-[var(--wui-color-text)]"}`,children:[t?"Review Dangerous ":"Review ","Transaction",n.length>1?"s":""]}),d]}),c&&D.jsx("div",{className:"px-6 text-xs text-[var(--wui-color-text-tertiary)] truncate",children:c}),t?D.jsx("div",{className:"px-6 pb-3 text-sm font-bold text-[var(--wui-color-danger-text)]",children:t==="rekey"?"This transaction will rekey your account, transferring signing authority to a different address. You will no longer be able to sign transactions with your current key.":"This transaction will close your account and transfer all remaining funds to another address. This action is irreversible."}):D.jsx("div",{className:"px-6 pb-3 text-sm text-[var(--wui-color-text-secondary)]",children:n.length===1?"You are about to sign the following transaction:":`You are about to sign ${n.length} transactions:`}),D.jsx("div",{className:"px-4 pb-4 max-h-80 overflow-y-auto",children:m?D.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading asset info..."]}):D.jsx("div",{className:"space-y-2",children:n.map(A=>D.jsx("div",{className:"rounded-sm border p-3 border-[var(--wui-color-primary)] bg-[var(--wui-color-bg-secondary)]",children:D.jsx(qC,{txn:A,assetInfo:A.assetIndex?h[A.assetIndex.toString()]:void 0,appEscrows:x})},A.index))})}),u===!1&&D.jsx("div",{className:"px-4 pb-4",children:D.jsx("div",{className:"text-sm font-bold text-[var(--wui-color-danger-text)] border border-[var(--wui-color-danger-text)] rounded-xl p-3 bg-[var(--wui-color-danger-bg)]",children:"Payload verification failed. The provided payload was invalid and has been recalculated from the raw transactions."})}),D.jsx("div",{className:"px-4 pb-4",children:D.jsxs("div",{className:"text-sm flex flex-col gap-2 border border-[var(--wui-color-border)] rounded-xl p-3",children:[D.jsxs("div",{className:"flex items-center gap-2",children:[D.jsx("span",{children:"Transaction ID to sign:"}),u===!0&&D.jsx("span",{className:"text-xs text-green-600 font-medium",children:"Verified"})]}),D.jsx("div",{className:"font-mono break-all text-[var(--wui-color-danger-text)]",children:e}),D.jsx("div",{children:"Ensure the transaction ID is correct before approving."})]})}),a?D.jsx("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)]",children:D.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsxs("svg",{className:"animate-spin h-4 w-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Signing..."]})}):t?D.jsxs("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)] flex gap-3",children:[D.jsx("button",{onClick:s,className:"flex-1 py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Reject"}),D.jsx("button",{onClick:o,className:"flex-1 py-2.5 px-4 bg-[var(--wui-color-danger-text)] text-white font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Sign (Dangerous)"})]}):D.jsx("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)]",children:D.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsxs("svg",{className:"animate-spin h-4 w-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Review in ",l||"wallet","..."]})})]})}function Ux({className:n,scale:e=.85}){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:`inline-block align-baseline ${n??""}`,style:{width:`${e}em`,height:`${e}em`},"aria-label":"Algorand",fill:"currentColor",children:D.jsx("path",{d:"M23.98 23.99h-3.75l-2.44-9.07-5.25 9.07H8.34l8.1-14.04-1.3-4.88L4.22 24H.02L13.88 0h3.67l1.61 5.96h3.79l-2.59 4.5 3.62 13.53z"})})}function Qs({className:n}){return D.jsxs("svg",{className:`animate-spin h-4 w-4 ${n??""}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function ey(n){return n.length<=12?n:`${n.slice(0,6)}...${n.slice(-4)}`}function jx({status:n,error:e,successMessage:t,onRetry:r,txId:i,explorerUrl:o}){return n==="idle"?null:n==="signing"?D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Waiting for signature..."]}):n==="sending"?D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Sending transaction..."]}):n==="success"?D.jsxs("div",{className:"text-center py-4",children:[D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),D.jsx("p",{className:"text-sm font-medium text-[var(--wui-color-text)]",children:t}),i&&D.jsxs("p",{className:"mt-1.5 text-xs text-[var(--wui-color-text-tertiary)]",children:["TX:"," ",o?D.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-[var(--wui-color-primary)] hover:underline",children:ey(i)}):D.jsx("span",{className:"font-mono",children:ey(i)})]})]}):D.jsxs("div",{className:"text-center py-3",children:[D.jsx("p",{className:"text-sm text-[var(--wui-color-danger-text)] mb-2",children:e}),D.jsx("button",{onClick:r,className:"text-sm text-[var(--wui-color-primary)] hover:underline",children:"Try again"})]})}function JC({activeAddress:n,optedInAssetIds:e,assetIdInput:t,setAssetIdInput:r,assetInfo:i,assetLookupLoading:o,assetLookupError:s,txId:a,explorerUrl:l,status:c,error:d,handleOptIn:u,reset:m,retry:h,onBack:x,nameSearchResults:A,nameSearchLoading:v,registryLoading:F,selectedNameAsset:w,onSelectNameAsset:C,isNameMode:M,evmAddress:N}){const[b,j]=Y.useState("idle"),[p,E]=Y.useState(!1),S=async()=>{if(n)try{await navigator.clipboard.writeText(n),j("copied"),setTimeout(()=>j("idle"),1e3)}catch{j("error"),setTimeout(()=>j("idle"),1e3)}},$=M?w==null?void 0:w.index:i==null?void 0:i.index,B=$!=null&&(e==null?void 0:e.has($));return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[D.jsx("button",{onClick:x,className:"-ml-1 p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-secondary)] flex items-center justify-center",title:"Back",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D.jsx("path",{d:"m15 18-6-6 6-6"})})}),D.jsx("h3",{className:"text-lg font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font",children:"Receive"}),F&&D.jsxs("div",{className:"ml-auto flex items-center gap-1 text-xs text-[var(--wui-color-text-tertiary)]",children:[D.jsx(Qs,{className:"h-3 w-3"}),D.jsx("span",{children:"Loading registry..."})]})]}),D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-2 leading-relaxed",children:"This is your liquid EVM Algorand account. You can receive ALGO and any opted-in assets here, and manage your asset opt-ins below."}),n&&D.jsxs("div",{className:"mb-4 bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-secondary)] mb-1.5",children:"Your ALGO address:"}),D.jsxs("div",{className:"flex items-center gap-2",children:[D.jsx("code",{className:"text-sm font-medium text-[var(--wui-color-text)] flex-1 truncate",children:n}),D.jsx("button",{onClick:S,className:"shrink-0 px-2.5 py-1 text-xs font-medium rounded-md bg-[var(--wui-color-bg-tertiary)] hover:brightness-90 transition-all",style:{color:b==="copied"?"var(--wui-color-success-text, #16a34a)":b==="error"?"var(--wui-color-danger-text)":"var(--wui-color-text-secondary)"},children:b==="copied"?"COPIED":b==="error"?"ERROR":"COPY"})]})]}),N&&D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-2 leading-relaxed",children:"It is controlled entirely by your EVM account:"}),D.jsxs("div",{className:"mb-2 bg-[var(--wui-color-bg-secondary)] rounded-lg",children:[D.jsxs("button",{type:"button",onClick:()=>E(P=>!P),className:"w-full flex items-center justify-between px-3 py-2 text-xs text-[var(--wui-color-text-secondary)] hover:text-[var(--wui-color-text)] transition-colors focus:outline-none",children:[D.jsx("span",{children:"EVM Controller"}),D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:p?"rotate(180deg)":"none",transition:"transform 150ms ease"},children:D.jsx("path",{d:"m6 9 6 6 6-6"})})]}),p&&D.jsx("div",{className:"px-3 pb-2.5",children:D.jsx("code",{className:"text-sm font-medium text-[var(--wui-color-text)] truncate block",children:N})})]})]}),D.jsx("h4",{className:"text-base font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font mt-6 mb-3",children:"Asset opt-in"}),c==="idle"&&D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-3 leading-relaxed",children:"Algorand accounts must opt in to assets before receiving them. Search for an asset below to opt in."}),D.jsx("div",{className:"mb-4",children:D.jsx("input",{type:"text",placeholder:"Search by name or asset ID",value:t,onChange:P=>r(P.target.value),className:"w-full rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-3 text-sm text-[var(--wui-color-text)] placeholder:text-[var(--wui-color-text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent"})}),!M&&o&&D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Looking up asset..."]}),!M&&s&&D.jsx("div",{className:"py-3 text-center text-sm text-[var(--wui-color-danger-text)]",children:s}),!M&&i&&D.jsx(ty,{name:i.name,unitName:i.unitName,index:i.index,isAlreadyOptedIn:B,onOptIn:u}),M&&v&&D.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-4 w-4 mr-2"}),"Searching..."]}),M&&!w&&A&&A.length>0&&!v&&D.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-lg border border-[var(--wui-color-border)]",children:A.map(P=>D.jsxs("button",{onClick:()=>C==null?void 0:C(P),className:"w-full flex items-center justify-between px-3 py-2 text-left hover:bg-[var(--wui-color-bg-secondary)] transition-colors border-b border-[var(--wui-color-border)] last:border-b-0",children:[D.jsx("div",{className:"flex items-center gap-2 min-w-0",children:D.jsxs("div",{className:"min-w-0",children:[D.jsxs("p",{className:"text-sm font-medium text-[var(--wui-color-text)] truncate",children:[P.name,P.peraVerified&&D.jsx(Gx,{}),(e==null?void 0:e.has(P.index))&&D.jsx("span",{className:"ml-1.5 text-xs text-[var(--wui-color-text-tertiary)]",children:"(opted in)"})]}),P.unitName&&D.jsx("p",{className:"text-xs text-[var(--wui-color-text-secondary)]",children:P.unitName})]})}),D.jsxs("span",{className:"text-xs text-[var(--wui-color-text-tertiary)] shrink-0 ml-2",children:["ID: ",P.index]})]},P.index))}),M&&!w&&A&&A.length===0&&!v&&t.trim().length>0&&D.jsx("div",{className:"py-3 text-center text-sm text-[var(--wui-color-text-secondary)]",children:"No assets found"}),M&&w&&D.jsx(ty,{name:w.name,unitName:w.unitName,index:w.index,peraVerified:w.peraVerified,isAlreadyOptedIn:B,onOptIn:u})]}),D.jsx(jx,{status:c,error:d,successMessage:"Opted in successfully!",onRetry:h,txId:a,explorerUrl:l}),c==="success"&&D.jsx("button",{onClick:m,className:"mt-1 w-full text-sm text-[var(--wui-color-primary)] hover:underline",children:"Opt in to another asset"})]})}function Gx(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"var(--wui-color-primary)",className:"inline-block ml-1 -mt-0.5",children:D.jsx("path",{d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}function ty({name:n,unitName:e,index:t,peraVerified:r,isAlreadyOptedIn:i,onOptIn:o}){return D.jsxs("div",{className:"bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:[D.jsxs("div",{className:"flex justify-between items-start mb-3",children:[D.jsxs("div",{children:[D.jsxs("p",{className:"text-sm font-medium text-[var(--wui-color-text)]",children:[n,r&&D.jsx(Gx,{})]}),e&&D.jsx("p",{className:"text-xs text-[var(--wui-color-text-secondary)]",children:e})]}),D.jsxs("span",{className:"text-xs text-[var(--wui-color-text-tertiary)]",children:["ID: ",t]})]}),i?D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] text-center py-1",children:"Already opted in — no action needed."}):D.jsx("button",{onClick:o,className:"w-full py-2 px-4 bg-[var(--wui-color-primary)] text-white font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Opt In"})]})}const QC=.1;function e2({sendType:n,setSendType:e,receiver:t,setReceiver:r,amount:i,setAmount:o,assetIdInput:s,setAssetIdInput:a,assetInfo:l,assetLookupLoading:c,assetLookupError:d,receiverOptInStatus:u,receiverAddressError:m,txId:h,explorerUrl:x,accountAssets:A,availableBalance:v,status:F,error:w,handleSend:C,reset:M,retry:N,onBack:b}){const j=le=>{le==="algo"?(e("algo"),a("")):(e("asa"),a(le),L(!1)),o("")},p=n==="algo"?"algo":s,E=A==null?void 0:A.find(le=>String(le.assetId)===s),S=n==="algo"?"ALGO":(l==null?void 0:l.unitName)||(l==null?void 0:l.name)||"Asset",$=n==="algo"&&v!=null?`Available: ${v.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})} ALGO`:n==="asa"&&E?`Available: ${E.amount} ${E.unitName||E.name}`:null,[B,P]=Y.useState(!0),[W,L]=Y.useState(!1),q=le=>v==null?"0":Math.max(0,le?v-QC:v).toFixed(6).replace(/\.?0+$/,"")||"0",J=()=>{n==="algo"&&v!=null?(L(!0),o(q(B))):n==="asa"&&E&&(L(!1),o(E.amount))},U=()=>{const le=!B;P(le),o(q(le))},ne=i!==""?parseFloat(i):NaN,fe=!isNaN(ne)&&ne>0&&(n==="algo"&&v!=null&&ne>v||n==="asa"&&E!=null&&ne>parseFloat(E.amount));return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[D.jsx("button",{onClick:b,className:"-ml-1 p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-secondary)] flex items-center justify-center",title:"Back",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D.jsx("path",{d:"m15 18-6-6 6-6"})})}),D.jsx("h3",{className:"text-lg font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font",children:"Send"})]}),F==="idle"&&D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-xs text-[var(--wui-color-text-tertiary)] mb-2",children:"Send ALGO or assets to any Algorand address"}),$&&D.jsx("p",{className:"self-end text-xs text-[var(--wui-color-text-secondary)] mb-1",children:$}),D.jsxs("div",{className:"mb-3 flex gap-2",children:[D.jsxs("div",{className:"flex-1 min-w-0 relative",children:[D.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Amount",value:i,onChange:le=>o(le.target.value.replace(/[^0-9.]/g,"")),className:"w-full rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-3 pr-12 text-sm text-[var(--wui-color-text)] placeholder:text-[var(--wui-color-text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent"}),D.jsx("button",{type:"button",onClick:J,className:"absolute right-2 inset-y-0 my-auto h-fit text-[10px] font-medium text-[var(--wui-color-primary)] bg-[var(--wui-color-bg-tertiary)] rounded px-1.5 py-0.5 hover:brightness-90 transition-all",children:"max"})]}),D.jsxs("select",{value:p,onChange:le=>j(le.target.value),className:"w-[120px] shrink-0 rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-2 text-sm text-[var(--wui-color-text)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent",children:[D.jsx("option",{value:"algo",children:"ALGO"}),A==null?void 0:A.map(le=>D.jsx("option",{value:String(le.assetId),children:le.name},le.assetId))]})]}),n==="algo"&&W&&D.jsxs("label",{className:"flex items-center gap-1.5 mb-3 cursor-pointer select-none",children:[D.jsx("input",{type:"checkbox",checked:B,onChange:U,className:"accent-[var(--wui-color-primary)] h-3.5 w-3.5"}),D.jsx("span",{className:"text-xs text-[var(--wui-color-text-secondary)]",children:"Save some for transaction costs"})]}),fe&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:"Amount exceeds available balance"}),n==="asa"&&D.jsxs(D.Fragment,{children:[c&&D.jsxs("div",{className:"flex items-center mb-3 text-xs text-[var(--wui-color-text-secondary)]",children:[D.jsx(Qs,{className:"h-3 w-3 mr-1.5"}),"Looking up asset..."]}),d&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:d})]}),D.jsx("div",{className:"mb-3",children:D.jsx("input",{type:"text",placeholder:"Receiver ALGO address",value:t,onChange:le=>r(le.target.value),className:"w-full rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2.5 px-3 text-sm text-[var(--wui-color-text)] placeholder:text-[var(--wui-color-text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent"})}),m&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:m}),n==="asa"&&u==="not-opted-in"&&D.jsx("p",{className:"mb-3 text-xs text-[var(--wui-color-danger-text)]",children:"Receiver has not opted into this asset"}),D.jsx("button",{onClick:C,disabled:!t||!i||!!m||fe||n==="asa"&&!l||n==="asa"&&u!=="opted-in"&&u!=="idle",className:"w-full py-2.5 px-4 bg-[var(--wui-color-primary)] text-white font-medium rounded-xl hover:brightness-90 transition-all text-sm disabled:opacity-50 disabled:cursor-not-allowed",children:n==="asa"&&u==="checking"?"Verifying...":`Send ${S}`})]}),D.jsx(jx,{status:F,error:w,successMessage:"Sent successfully!",onRetry:N,txId:h,explorerUrl:x}),F==="success"&&D.jsx("button",{onClick:M,className:"mt-1 w-full text-sm text-[var(--wui-color-primary)] hover:underline",children:"Send more"})]})}const t2=new Intl.NumberFormat(void 0,{minimumFractionDigits:4,maximumFractionDigits:4}),Cu=3;function n2(n){const e=parseFloat(n);if(isNaN(e))return n;const[,t]=n.split(".");return e.toLocaleString(void 0,{minimumFractionDigits:(t==null?void 0:t.length)??0,maximumFractionDigits:(t==null?void 0:t.length)??0})}function r2({displayBalance:n,showAvailableBalance:e,onToggleBalance:t,onBack:r,send:i,optIn:o,assets:s,availableBalance:a,onRefresh:l,isRefreshing:c,onBridge:d,onExplore:u}){const[m,h]=Y.useState("main"),[x,A]=Y.useState(!1),[v,F]=Y.useState("none"),w=Y.useCallback(b=>{F("forward"),h(b)},[]),C=Y.useCallback(b=>{F("back"),h("main"),b==null||b()},[]);let M;m==="send"&&i?M=D.jsx(e2,{...i,accountAssets:s,availableBalance:a,onBack:()=>C(i.reset)}):m==="opt-in"&&o?M=D.jsx(JC,{...o,onBack:()=>C(o.reset)}):M=D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[D.jsx("button",{onClick:r,className:"-ml-1 p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-secondary)] flex items-center justify-center",title:"Back",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:D.jsx("path",{d:"m15 18-6-6 6-6"})})}),D.jsx("h3",{className:"text-lg font-bold leading-none text-[var(--wui-color-text)] wallet-custom-font",children:"Manage Liquid Account"}),l&&D.jsx("button",{onClick:l,disabled:c,className:"ml-auto p-1 rounded-lg hover:bg-[var(--wui-color-bg-secondary)] transition-colors text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] flex items-center justify-center disabled:pointer-events-none",title:"Refresh",children:D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:c?"animate-spin":"",children:[D.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),D.jsx("path",{d:"M21 3v5h-5"})]})})]}),D.jsx("div",{className:"mb-4 bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:D.jsxs("div",{className:"flex justify-between items-center",children:[n!==null&&D.jsxs("span",{className:"text-base font-medium text-[var(--wui-color-text)] flex items-center gap-1",children:[t2.format(n),D.jsx(Ux,{})]}),D.jsxs("button",{onClick:t,className:"flex items-center gap-1 text-sm text-[var(--wui-color-text-secondary)] bg-[var(--wui-color-bg-tertiary)] py-1 pl-2.5 pr-2 rounded-md hover:brightness-90 transition-all focus:outline-none",title:e?"Show total balance":"Show available balance",children:[e?"Available":"Total",D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-0.5 opacity-80",children:[D.jsx("path",{d:"m17 10-5-5-5 5"}),D.jsx("path",{d:"m17 14-5 5-5-5"})]})]})]})}),s&&s.length>0&&D.jsxs("div",{className:"mb-4",children:[D.jsx("h4",{className:"text-xs font-medium text-[var(--wui-color-text-tertiary)] uppercase tracking-wide mb-1.5",children:"Assets"}),D.jsx("div",{className:x?"overflow-y-auto":"",style:x?{maxHeight:`${Cu*2*28}px`}:void 0,children:(x?s:s.slice(0,Cu)).map(b=>D.jsxs("div",{className:"flex justify-between items-center py-1",children:[D.jsxs("span",{className:"text-sm text-[var(--wui-color-text-secondary)] truncate mr-3 flex items-center gap-1.5",children:[b.name," ",D.jsxs("span",{className:"text-[var(--wui-color-text-tertiary)]",children:["(ID ",b.assetId,")"]}),i&&D.jsx("button",{onClick:()=>{i.setSendType("asa"),i.setAssetIdInput(String(b.assetId)),w("send")},className:"inline-flex items-center justify-center w-4 h-4 rounded-xs border border-[var(--wui-color-border)] text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] hover:border-[var(--wui-color-text-tertiary)] transition-colors shrink-0",title:`Send ${b.unitName||b.name}`,children:D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M7 17 17 7"}),D.jsx("path",{d:"M7 7h10v10"})]})})]}),D.jsxs("span",{className:"text-sm font-medium text-[var(--wui-color-text)] tabular-nums whitespace-nowrap",children:[n2(b.amount),b.unitName?` ${b.unitName}`:""]})]},b.assetId))}),s.length>Cu&&D.jsx("button",{onClick:()=>A(b=>!b),className:"text-xs text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] transition-colors mt-1",children:x?"show less":`+${s.length-Cu} more`})]}),D.jsx("div",{className:"border-t border-[var(--wui-color-border)] mb-3"}),D.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[D.jsxs("button",{onClick:()=>w("send"),disabled:!i,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M7 17 17 7"}),D.jsx("path",{d:"M7 7h10v10"})]}),"Send"]}),D.jsxs("button",{onClick:()=>w("opt-in"),disabled:!o,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M17 7 7 17"}),D.jsx("path",{d:"M17 17H7V7"})]}),"Receive"]}),D.jsxs("button",{onClick:d,disabled:!d,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("path",{d:"M8 3l4 4-4 4"}),D.jsx("path",{d:"M16 3l-4 4 4 4"}),D.jsx("path",{d:"M12 7H4"}),D.jsx("path",{d:"M12 7h8"}),D.jsx("path",{d:"M8 21l4-4-4-4"}),D.jsx("path",{d:"M16 21l-4-4 4-4"}),D.jsx("path",{d:"M12 17H4"}),D.jsx("path",{d:"M12 17h8"})]}),"Bridge"]}),D.jsxs("button",{onClick:u,disabled:!u,className:"py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none",children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("circle",{cx:"11",cy:"11",r:"8"}),D.jsx("path",{d:"m21 21-4.3-4.3"})]}),"Explore"]})]})]});const N=v==="forward"?"wui-slide-fwd 180ms ease-out both":v==="back"?"wui-slide-back 180ms ease-out both":"none";return D.jsxs(D.Fragment,{children:[D.jsx("style",{children:`
40
40
  @keyframes wui-slide-fwd {
41
41
  from { opacity: 0; transform: translateX(24px); }
42
42
  to { opacity: 1; transform: translateX(0); }
@@ -45,7 +45,7 @@
45
45
  from { opacity: 0; transform: translateX(-24px); }
46
46
  to { opacity: 1; transform: translateX(0); }
47
47
  }
48
- `}),D.jsx("div",{style:{animation:N},children:M},m)]})}function ny(n){return`${n.slice(0,6)}...${n.slice(-6)}`}function i2({algorandAddress:n,evmAddress:e,onClose:t,labelId:r,descriptionId:i}){const[o,s]=Y.useState(null),a=Y.useCallback((d,u)=>{navigator.clipboard.writeText(d),s(u),setTimeout(()=>s(null),1500)},[]),l=ny(n),c=ny(e);return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"relative flex items-center px-6 pt-5 pb-4",children:[D.jsx("h2",{id:r,className:"text-xl font-bold text-[var(--wui-color-text)] wallet-custom-font",children:"Welcome to Algorand"}),D.jsx("button",{onClick:t,className:"absolute right-4 top-5 w-9 h-9 flex items-center justify-center rounded-full bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] hover:brightness-90 transition-all","aria-label":"Close dialog",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),D.jsxs("div",{id:i,className:"px-6 pb-4 space-y-4",children:[D.jsxs("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:["You can use Algorand with your very own Liquid EVM account, which wraps your EVM private key, preserving full self-custodial control."," ",D.jsx("a",{className:"text-[var(--wui-color-link)] hover:text-[var(--wui-color-link-hover)]",rel:"noopener noreferrer",href:"#",onClick:()=>(alert("Soon"),!1),children:"Learn more."})]}),D.jsxs("div",{className:"!my-4 rounded-xl border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] p-3 space-y-2",children:[D.jsxs("div",{className:"flex justify-between items-center text-xs",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"Your EVM Address"}),D.jsxs("span",{className:"flex items-center gap-1.5",children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] font-mono",children:c}),D.jsx("button",{onClick:()=>a(e,"evm"),className:"text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] transition-colors","aria-label":"Copy EVM address",children:o==="evm"?D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:[D.jsx("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),D.jsx("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"})]})})]})]}),D.jsxs("div",{className:"flex justify-between items-center text-xs",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"Your Algorand Address"}),D.jsxs("span",{className:"flex items-center gap-1.5",children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] font-mono",children:l}),D.jsx("button",{onClick:()=>a(n,"algorand"),className:"text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] transition-colors","aria-label":"Copy Algorand address",children:o==="algorand"?D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:[D.jsx("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),D.jsx("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"})]})})]})]})]}),D.jsxs("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:["To get started,"," ",D.jsx("a",{className:"text-[var(--wui-color-link)] hover:text-[var(--wui-color-link-hover)]",rel:"noopener noreferrer",target:"_blank",href:"https://algorand.co/ecosystem/directory?tags=CEX",children:"fund"})," ","your new Algorand account via CEX, Card onramp, or"," ",D.jsx("a",{className:"text-[var(--wui-color-link)] hover:text-[var(--wui-color-link-hover)]",rel:"noopener noreferrer",target:"_blank",href:"https://core.allbridge.io/?ft=USDC&tt=USDC&f=BAS&t=ALG",children:"bridge USDC"})," ","in 2 minutes."]})]}),D.jsxs("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)] flex flex gap-2",children:[D.jsx("button",{onClick:()=>{t(),window.open("https://algorand.co/algorand-start-here#hs_cos_wrapper_widget_1769533007886")},className:"w-full py-2.5 px-4 bg-[var(--wui-color-primary)] text-[var(--wui-color-primary-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Get Started"}),D.jsx("button",{onClick:t,className:"w-full py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Close"})]})]})}const o2="walletUiAssets",po="assets",go="meta",s2=1;let zc=null;function Rc(){return zc||(zc=new Promise((n,e)=>{const t=indexedDB.open(o2,s2);t.onupgradeneeded=()=>{const r=t.result;r.objectStoreNames.contains(po)||r.createObjectStore(po,{keyPath:"index"}),r.objectStoreNames.contains(go)||r.createObjectStore(go)},t.onsuccess=()=>n(t.result),t.onerror=()=>{zc=null,e(t.error)}}),zc)}let Hu=[],Fu=null,Dp=[];function a2(){return new Promise((n,e)=>{if(Hu.length===0){n();return}const t=Hu.slice(),r=Dp.slice();Hu=[],Dp=[],Rc().then(i=>{const o=i.transaction(po,"readwrite"),s=o.objectStore(po);for(const a of t)s.put(a);o.oncomplete=()=>{for(const a of r)a.resolve();n()},o.onerror=()=>{const a=o.error;for(const l of r)l.reject(a);e(a)}}).catch(i=>{for(const o of r)o.reject(i);e(i)})})}function c2(n){return new Promise((e,t)=>{Hu.push(...n),Dp.push({resolve:e,reject:t}),Fu&&clearTimeout(Fu),Fu=setTimeout(()=>{Fu=null,a2()},500)})}function l2(n,e=20){const t=n.toLowerCase();return Rc().then(r=>new Promise((i,o)=>{const l=r.transaction(po,"readonly").objectStore(po).openCursor(),c=[];l.onsuccess=()=>{const d=l.result;if(!d||c.length>=e){i(c);return}const u=d.value;(u.name.toLowerCase().includes(t)||u.unitName.toLowerCase().includes(t))&&c.push(u),d.continue()},l.onerror=()=>o(l.error)}))}function u2(){return Rc().then(n=>new Promise((e,t)=>{const i=n.transaction(go,"readonly").objectStore(go).get("lastUpdated");i.onsuccess=()=>e(i.result??null),i.onerror=()=>t(i.error)}))}function d2(n){return Rc().then(e=>new Promise((t,r)=>{const i=e.transaction(go,"readwrite");i.objectStore(go).put(n,"lastUpdated"),i.oncomplete=()=>t(),i.onerror=()=>r(i.error)}))}function h2(){return Rc().then(n=>new Promise((e,t)=>{const r=n.transaction([po,go],"readwrite");r.objectStore(po).clear(),r.objectStore(go).clear(),r.oncomplete=()=>e(),r.onerror=()=>t(r.error)}))}const Du={open:Rc,insertMany:c2,searchByName:l2,getLastUpdated:u2,setLastUpdated:d2,clear:h2};function f2({transactions:n,message:e,dangerous:t,onApprove:r,onReject:i,onClose:o,signing:s,walletName:a,algodClient:l}){const{theme:c}=ti(),[d,u]=Y.useState("starting"),m=c==="system"?void 0:c,{refs:h,context:x}=Ld({open:!0,onOpenChange:N=>{N||(u("exiting"),setTimeout(t?()=>i():()=>o(),150))}}),A=Od(x,{outsidePressEvent:"mousedown"}),v=tg(x,{role:"alertdialog"}),{getFloatingProps:F}=Vd([A,v]),w=Yr(),C=Yr();d==="starting"&&requestAnimationFrame(()=>u("entered"));const M=D.jsx("button",{onClick:()=>{u("exiting"),setTimeout(()=>{t?i():r()},150)},className:"w-8 h-8 flex-none flex items-center justify-center rounded-full bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] hover:brightness-90 transition-all","aria-label":"Close dialog",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})});return D.jsx(uu,{id:"wallet-sign-dialog-portal",children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":m,children:D.jsx(eg,{className:"grid place-items-center px-4 z-[100] transition-opacity duration-150 ease-in-out bg-[var(--wui-color-overlay)] data-[state=starting]:opacity-0 data-[state=exiting]:opacity-0 data-[state=entered]:opacity-100","data-state":d,lockScroll:!0,children:D.jsx(Pd,{context:x,modal:!0,children:D.jsx("div",{ref:h.setFloating,...F({"aria-labelledby":w,"aria-describedby":C}),role:"alertdialog","data-state":d,className:"w-full max-w-md rounded-3xl bg-[var(--wui-color-bg)] shadow-xl transform transition-all duration-150 ease-in-out data-[state=starting]:opacity-0 data-[state=starting]:scale-90 data-[state=exiting]:opacity-0 data-[state=exiting]:scale-90 data-[state=entered]:opacity-100 data-[state=entered]:scale-100",style:{marginTop:"-0.5rem"},children:D.jsx(ZC,{transactions:n,message:e,dangerous:t,algodClient:l,getApplicationAddress:N=>dd(BigInt(N)),onApprove:()=>{u("exiting"),setTimeout(()=>r(),150)},onReject:()=>{u("exiting"),setTimeout(()=>i(),150)},signing:s,walletName:a,headerAction:M})})})})})})}function p2({transactionCount:n,dangerous:e,onReject:t}){const{theme:r}=ti(),i=r==="system"?void 0:r;return D.jsx(uu,{id:"wallet-extension-indicator-portal",children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":i,children:D.jsxs("div",{className:"fixed bottom-4 right-4 z-[100] flex items-center gap-3 rounded-2xl bg-[var(--wui-color-bg)] shadow-lg border border-[var(--wui-color-border)] px-4 py-3 max-w-sm",children:[D.jsxs("svg",{className:"animate-spin h-5 w-5 text-[var(--wui-color-primary)] flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),D.jsxs("div",{className:"flex flex-col min-w-0",children:[D.jsxs("span",{className:`text-sm font-medium ${e?"text-[var(--wui-color-danger-text)]":"text-[var(--wui-color-text)]"}`,children:["Review ",n>1?`${n} transactions`:"transaction"," in extension",e&&" (dangerous)"]}),D.jsx("span",{className:"text-xs text-[var(--wui-color-text-tertiary)]",children:"Open the Liquid Wallet Companion popup"})]}),D.jsx("button",{onClick:t,className:"ml-auto flex-shrink-0 text-xs px-2.5 py-1 rounded-lg bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] hover:brightness-90 transition-all",children:"Cancel"})]})})})}function g2({algorandAddress:n,evmAddress:e,onDismiss:t}){const{theme:r}=ti(),[i,o]=Y.useState("starting"),s=()=>{o("exiting"),setTimeout(()=>t(),150)},a=r==="system"?void 0:r,{refs:l,context:c}=Ld({open:!0,onOpenChange:A=>{A||s()}}),d=Od(c,{outsidePressEvent:"mousedown"}),u=tg(c,{role:"dialog"}),{getFloatingProps:m}=Vd([d,u]),h=Yr(),x=Yr();return i==="starting"&&requestAnimationFrame(()=>o("entered")),D.jsx(uu,{id:"wallet-welcome-dialog-portal",children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":a,children:D.jsx(eg,{className:"grid place-items-center px-4 z-[100] transition-opacity duration-150 ease-in-out bg-[var(--wui-color-overlay)] data-[state=starting]:opacity-0 data-[state=exiting]:opacity-0 data-[state=entered]:opacity-100","data-state":i,lockScroll:!0,children:D.jsx(Pd,{context:c,modal:!0,children:D.jsx("div",{ref:l.setFloating,...m({"aria-labelledby":h,"aria-describedby":x}),role:"dialog","data-state":i,className:"w-full max-w-md rounded-3xl bg-[var(--wui-color-bg)] shadow-xl transform transition-all duration-150 ease-in-out data-[state=starting]:opacity-0 data-[state=starting]:scale-90 data-[state=exiting]:opacity-0 data-[state=exiting]:scale-90 data-[state=entered]:opacity-100 data-[state=entered]:scale-100",style:{marginTop:"-0.5rem"},children:D.jsx(i2,{algorandAddress:n,evmAddress:e,onClose:s,labelId:h,descriptionId:x})})})})})})}function Wx(n){const[e,t]=Y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return Y.useEffect(()=>{if(n!=="system")return;const r=window.matchMedia("(prefers-color-scheme: dark)");t(r.matches?"dark":"light");const i=o=>{t(o.matches?"dark":"light")};return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[n]),n==="system"?e:n}var m2=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,$h=Math.ceil,lr=Math.floor,jn="[BigNumber Error] ",ry=jn+"Number primitive has more than 15 significant digits: ",Er=1e14,It=14,iy=9007199254740991,_h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Fi=1e7,Kn=1e9;function zx(n){var e,t,r,i=w.prototype={constructor:w,toString:null,valueOf:null},o=new w(1),s=20,a=4,l=-7,c=21,d=-1e7,u=1e7,m=!1,h=1,x=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},v="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function w(p,E){var S,$,B,P,W,L,q,J,U=this;if(!(U instanceof w))return new w(p,E);if(E==null){if(p&&p._isBigNumber===!0){U.s=p.s,!p.c||p.e>u?U.c=U.e=null:p.e<d?U.c=[U.e=0]:(U.e=p.e,U.c=p.c.slice());return}if((L=typeof p=="number")&&p*0==0){if(U.s=1/p<0?(p=-p,-1):1,p===~~p){for(P=0,W=p;W>=10;W/=10,P++);P>u?U.c=U.e=null:(U.e=P,U.c=[p]);return}J=String(p)}else{if(!m2.test(J=String(p)))return r(U,J,L);U.s=J.charCodeAt(0)==45?(J=J.slice(1),-1):1}(P=J.indexOf("."))>-1&&(J=J.replace(".","")),(W=J.search(/e/i))>0?(P<0&&(P=W),P+=+J.slice(W+1),J=J.substring(0,W)):P<0&&(P=J.length)}else{if(Zt(E,2,v.length,"Base"),E==10&&F)return U=new w(p),b(U,s+U.e+1,a);if(J=String(p),L=typeof p=="number"){if(p*0!=0)return r(U,J,L,E);if(U.s=1/p<0?(J=J.slice(1),-1):1,w.DEBUG&&J.replace(/^0\.0*|\./,"").length>15)throw Error(ry+p)}else U.s=J.charCodeAt(0)===45?(J=J.slice(1),-1):1;for(S=v.slice(0,E),P=W=0,q=J.length;W<q;W++)if(S.indexOf($=J.charAt(W))<0){if($=="."){if(W>P){P=q;continue}}else if(!B&&(J==J.toUpperCase()&&(J=J.toLowerCase())||J==J.toLowerCase()&&(J=J.toUpperCase()))){B=!0,W=-1,P=0;continue}return r(U,String(p),L,E)}L=!1,J=t(J,E,10,U.s),(P=J.indexOf("."))>-1?J=J.replace(".",""):P=J.length}for(W=0;J.charCodeAt(W)===48;W++);for(q=J.length;J.charCodeAt(--q)===48;);if(J=J.slice(W,++q)){if(q-=W,L&&w.DEBUG&&q>15&&(p>iy||p!==lr(p)))throw Error(ry+U.s*p);if((P=P-W-1)>u)U.c=U.e=null;else if(P<d)U.c=[U.e=0];else{if(U.e=P,U.c=[],W=(P+1)%It,P<0&&(W+=It),W<q){for(W&&U.c.push(+J.slice(0,W)),q-=It;W<q;)U.c.push(+J.slice(W,W+=It));W=It-(J=J.slice(W)).length}else W-=q;for(;W--;J+="0");U.c.push(+J)}}else U.c=[U.e=0]}w.clone=zx,w.ROUND_UP=0,w.ROUND_DOWN=1,w.ROUND_CEIL=2,w.ROUND_FLOOR=3,w.ROUND_HALF_UP=4,w.ROUND_HALF_DOWN=5,w.ROUND_HALF_EVEN=6,w.ROUND_HALF_CEIL=7,w.ROUND_HALF_FLOOR=8,w.EUCLID=9,w.config=w.set=function(p){var E,S;if(p!=null)if(typeof p=="object"){if(p.hasOwnProperty(E="DECIMAL_PLACES")&&(S=p[E],Zt(S,0,Kn,E),s=S),p.hasOwnProperty(E="ROUNDING_MODE")&&(S=p[E],Zt(S,0,8,E),a=S),p.hasOwnProperty(E="EXPONENTIAL_AT")&&(S=p[E],S&&S.pop?(Zt(S[0],-1e9,0,E),Zt(S[1],0,Kn,E),l=S[0],c=S[1]):(Zt(S,-1e9,Kn,E),l=-(c=S<0?-S:S))),p.hasOwnProperty(E="RANGE"))if(S=p[E],S&&S.pop)Zt(S[0],-1e9,-1,E),Zt(S[1],1,Kn,E),d=S[0],u=S[1];else if(Zt(S,-1e9,Kn,E),S)d=-(u=S<0?-S:S);else throw Error(jn+E+" cannot be zero: "+S);if(p.hasOwnProperty(E="CRYPTO"))if(S=p[E],S===!!S)if(S)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))m=S;else throw m=!S,Error(jn+"crypto unavailable");else m=S;else throw Error(jn+E+" not true or false: "+S);if(p.hasOwnProperty(E="MODULO_MODE")&&(S=p[E],Zt(S,0,9,E),h=S),p.hasOwnProperty(E="POW_PRECISION")&&(S=p[E],Zt(S,0,Kn,E),x=S),p.hasOwnProperty(E="FORMAT"))if(S=p[E],typeof S=="object")A=S;else throw Error(jn+E+" not an object: "+S);if(p.hasOwnProperty(E="ALPHABET"))if(S=p[E],typeof S=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(S))F=S.slice(0,10)=="0123456789",v=S;else throw Error(jn+E+" invalid: "+S)}else throw Error(jn+"Object expected: "+p);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[l,c],RANGE:[d,u],CRYPTO:m,MODULO_MODE:h,POW_PRECISION:x,FORMAT:A,ALPHABET:v}},w.isBigNumber=function(p){if(!p||p._isBigNumber!==!0)return!1;if(!w.DEBUG)return!0;var E,S,$=p.c,B=p.e,P=p.s;e:if({}.toString.call($)=="[object Array]"){if((P===1||P===-1)&&B>=-1e9&&B<=Kn&&B===lr(B)){if($[0]===0){if(B===0&&$.length===1)return!0;break e}if(E=(B+1)%It,E<1&&(E+=It),String($[0]).length==E){for(E=0;E<$.length;E++)if(S=$[E],S<0||S>=Er||S!==lr(S))break e;if(S!==0)return!0}}}else if($===null&&B===null&&(P===null||P===1||P===-1))return!0;throw Error(jn+"Invalid BigNumber: "+p)},w.maximum=w.max=function(){return M(arguments,-1)},w.minimum=w.min=function(){return M(arguments,1)},w.random=(function(){var p=9007199254740992,E=Math.random()*p&2097151?function(){return lr(Math.random()*p)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(S){var $,B,P,W,L,q=0,J=[],U=new w(o);if(S==null?S=s:Zt(S,0,Kn),W=$h(S/It),m)if(crypto.getRandomValues){for($=crypto.getRandomValues(new Uint32Array(W*=2));q<W;)L=$[q]*131072+($[q+1]>>>11),L>=9e15?(B=crypto.getRandomValues(new Uint32Array(2)),$[q]=B[0],$[q+1]=B[1]):(J.push(L%1e14),q+=2);q=W/2}else if(crypto.randomBytes){for($=crypto.randomBytes(W*=7);q<W;)L=($[q]&31)*281474976710656+$[q+1]*1099511627776+$[q+2]*4294967296+$[q+3]*16777216+($[q+4]<<16)+($[q+5]<<8)+$[q+6],L>=9e15?crypto.randomBytes(7).copy($,q):(J.push(L%1e14),q+=7);q=W/7}else throw m=!1,Error(jn+"crypto unavailable");if(!m)for(;q<W;)L=E(),L<9e15&&(J[q++]=L%1e14);for(W=J[--q],S%=It,W&&S&&(L=_h[It-S],J[q]=lr(W/L)*L);J[q]===0;J.pop(),q--);if(q<0)J=[P=0];else{for(P=-1;J[0]===0;J.splice(0,1),P-=It);for(q=1,L=J[0];L>=10;L/=10,q++);q<It&&(P-=It-q)}return U.e=P,U.c=J,U}})(),w.sum=function(){for(var p=1,E=arguments,S=new w(E[0]);p<E.length;)S=S.plus(E[p++]);return S},t=(function(){var p="0123456789";function E(S,$,B,P){for(var W,L=[0],q,J=0,U=S.length;J<U;){for(q=L.length;q--;L[q]*=$);for(L[0]+=P.indexOf(S.charAt(J++)),W=0;W<L.length;W++)L[W]>B-1&&(L[W+1]==null&&(L[W+1]=0),L[W+1]+=L[W]/B|0,L[W]%=B)}return L.reverse()}return function(S,$,B,P,W){var L,q,J,U,ne,fe,le,ye,he=S.indexOf("."),de=s,be=a;for(he>=0&&(U=x,x=0,S=S.replace(".",""),ye=new w($),fe=ye.pow(S.length-he),x=U,ye.c=E(oi(or(fe.c),fe.e,"0"),10,B,p),ye.e=ye.c.length),le=E(S,$,B,W?(L=v,p):(L=p,v)),J=U=le.length;le[--U]==0;le.pop());if(!le[0])return L.charAt(0);if(he<0?--J:(fe.c=le,fe.e=J,fe.s=P,fe=e(fe,ye,de,be,B),le=fe.c,ne=fe.r,J=fe.e),q=J+de+1,he=le[q],U=B/2,ne=ne||q<0||le[q+1]!=null,ne=be<4?(he!=null||ne)&&(be==0||be==(fe.s<0?3:2)):he>U||he==U&&(be==4||ne||be==6&&le[q-1]&1||be==(fe.s<0?8:7)),q<1||!le[0])S=ne?oi(L.charAt(1),-de,L.charAt(0)):L.charAt(0);else{if(le.length=q,ne)for(--B;++le[--q]>B;)le[q]=0,q||(++J,le=[1].concat(le));for(U=le.length;!le[--U];);for(he=0,S="";he<=U;S+=L.charAt(le[he++]));S=oi(S,J,L.charAt(0))}return S}})(),e=(function(){function p($,B,P){var W,L,q,J,U=0,ne=$.length,fe=B%Fi,le=B/Fi|0;for($=$.slice();ne--;)q=$[ne]%Fi,J=$[ne]/Fi|0,W=le*q+J*fe,L=fe*q+W%Fi*Fi+U,U=(L/P|0)+(W/Fi|0)+le*J,$[ne]=L%P;return U&&($=[U].concat($)),$}function E($,B,P,W){var L,q;if(P!=W)q=P>W?1:-1;else for(L=q=0;L<P;L++)if($[L]!=B[L]){q=$[L]>B[L]?1:-1;break}return q}function S($,B,P,W){for(var L=0;P--;)$[P]-=L,L=$[P]<B[P]?1:0,$[P]=L*W+$[P]-B[P];for(;!$[0]&&$.length>1;$.splice(0,1));}return function($,B,P,W,L){var q,J,U,ne,fe,le,ye,he,de,be,Ae,_e,De,Te,T,G,X,re=$.s==B.s?1:-1,H=$.c,Z=B.c;if(!H||!H[0]||!Z||!Z[0])return new w(!$.s||!B.s||(H?Z&&H[0]==Z[0]:!Z)?NaN:H&&H[0]==0||!Z?re*0:re/0);for(he=new w(re),de=he.c=[],J=$.e-B.e,re=P+J+1,L||(L=Er,J=ur($.e/It)-ur(B.e/It),re=re/It|0),U=0;Z[U]==(H[U]||0);U++);if(Z[U]>(H[U]||0)&&J--,re<0)de.push(1),ne=!0;else{for(Te=H.length,G=Z.length,U=0,re+=2,fe=lr(L/(Z[0]+1)),fe>1&&(Z=p(Z,fe,L),H=p(H,fe,L),G=Z.length,Te=H.length),De=G,be=H.slice(0,G),Ae=be.length;Ae<G;be[Ae++]=0);X=Z.slice(),X=[0].concat(X),T=Z[0],Z[1]>=L/2&&T++;do{if(fe=0,q=E(Z,be,G,Ae),q<0){if(_e=be[0],G!=Ae&&(_e=_e*L+(be[1]||0)),fe=lr(_e/T),fe>1)for(fe>=L&&(fe=L-1),le=p(Z,fe,L),ye=le.length,Ae=be.length;E(le,be,ye,Ae)==1;)fe--,S(le,G<ye?X:Z,ye,L),ye=le.length,q=1;else fe==0&&(q=fe=1),le=Z.slice(),ye=le.length;if(ye<Ae&&(le=[0].concat(le)),S(be,le,Ae,L),Ae=be.length,q==-1)for(;E(Z,be,G,Ae)<1;)fe++,S(be,G<Ae?X:Z,Ae,L),Ae=be.length}else q===0&&(fe++,be=[0]);de[U++]=fe,be[0]?be[Ae++]=H[De]||0:(be=[H[De]],Ae=1)}while((De++<Te||be[0]!=null)&&re--);ne=be[0]!=null,de[0]||de.splice(0,1)}if(L==Er){for(U=1,re=de[0];re>=10;re/=10,U++);b(he,P+(he.e=U+J*It-1)+1,W,ne)}else he.e=J,he.r=+ne;return he}})();function C(p,E,S,$){var B,P,W,L,q;if(S==null?S=a:Zt(S,0,8),!p.c)return p.toString();if(B=p.c[0],W=p.e,E==null)q=or(p.c),q=$==1||$==2&&(W<=l||W>=c)?Mu(q,W):oi(q,W,"0");else if(p=b(new w(p),E,S),P=p.e,q=or(p.c),L=q.length,$==1||$==2&&(E<=P||P<=l)){for(;L<E;q+="0",L++);q=Mu(q,P)}else if(E-=W,q=oi(q,P,"0"),P+1>L){if(--E>0)for(q+=".";E--;q+="0");}else if(E+=P-L,E>0)for(P+1==L&&(q+=".");E--;q+="0");return p.s<0&&B?"-"+q:q}function M(p,E){for(var S,$,B=1,P=new w(p[0]);B<p.length;B++)$=new w(p[B]),(!$.s||(S=bo(P,$))===E||S===0&&P.s===E)&&(P=$);return P}function N(p,E,S){for(var $=1,B=E.length;!E[--B];E.pop());for(B=E[0];B>=10;B/=10,$++);return(S=$+S*It-1)>u?p.c=p.e=null:S<d?p.c=[p.e=0]:(p.e=S,p.c=E),p}r=(function(){var p=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,S=/^\.([^.]+)$/,$=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,W,L,q){var J,U=L?W:W.replace(B,"");if($.test(U))P.s=isNaN(U)?null:U<0?-1:1;else{if(!L&&(U=U.replace(p,function(ne,fe,le){return J=(le=le.toLowerCase())=="x"?16:le=="b"?2:8,!q||q==J?fe:ne}),q&&(J=q,U=U.replace(E,"$1").replace(S,"0.$1")),W!=U))return new w(U,J);if(w.DEBUG)throw Error(jn+"Not a"+(q?" base "+q:"")+" number: "+W);P.s=null}P.c=P.e=null}})();function b(p,E,S,$){var B,P,W,L,q,J,U,ne=p.c,fe=_h;if(ne){e:{for(B=1,L=ne[0];L>=10;L/=10,B++);if(P=E-B,P<0)P+=It,W=E,q=ne[J=0],U=lr(q/fe[B-W-1]%10);else if(J=$h((P+1)/It),J>=ne.length)if($){for(;ne.length<=J;ne.push(0));q=U=0,B=1,P%=It,W=P-It+1}else break e;else{for(q=L=ne[J],B=1;L>=10;L/=10,B++);P%=It,W=P-It+B,U=W<0?0:lr(q/fe[B-W-1]%10)}if($=$||E<0||ne[J+1]!=null||(W<0?q:q%fe[B-W-1]),$=S<4?(U||$)&&(S==0||S==(p.s<0?3:2)):U>5||U==5&&(S==4||$||S==6&&(P>0?W>0?q/fe[B-W]:0:ne[J-1])%10&1||S==(p.s<0?8:7)),E<1||!ne[0])return ne.length=0,$?(E-=p.e+1,ne[0]=fe[(It-E%It)%It],p.e=-E||0):ne[0]=p.e=0,p;if(P==0?(ne.length=J,L=1,J--):(ne.length=J+1,L=fe[It-P],ne[J]=W>0?lr(q/fe[B-W]%fe[W])*L:0),$)for(;;)if(J==0){for(P=1,W=ne[0];W>=10;W/=10,P++);for(W=ne[0]+=L,L=1;W>=10;W/=10,L++);P!=L&&(p.e++,ne[0]==Er&&(ne[0]=1));break}else{if(ne[J]+=L,ne[J]!=Er)break;ne[J--]=0,L=1}for(P=ne.length;ne[--P]===0;ne.pop());}p.e>u?p.c=p.e=null:p.e<d&&(p.c=[p.e=0])}return p}function j(p){var E,S=p.e;return S===null?p.toString():(E=or(p.c),E=S<=l||S>=c?Mu(E,S):oi(E,S,"0"),p.s<0?"-"+E:E)}return i.absoluteValue=i.abs=function(){var p=new w(this);return p.s<0&&(p.s=1),p},i.comparedTo=function(p,E){return bo(this,new w(p,E))},i.decimalPlaces=i.dp=function(p,E){var S,$,B,P=this;if(p!=null)return Zt(p,0,Kn),E==null?E=a:Zt(E,0,8),b(new w(P),p+P.e+1,E);if(!(S=P.c))return null;if($=((B=S.length-1)-ur(this.e/It))*It,B=S[B])for(;B%10==0;B/=10,$--);return $<0&&($=0),$},i.dividedBy=i.div=function(p,E){return e(this,new w(p,E),s,a)},i.dividedToIntegerBy=i.idiv=function(p,E){return e(this,new w(p,E),0,1)},i.exponentiatedBy=i.pow=function(p,E){var S,$,B,P,W,L,q,J,U,ne=this;if(p=new w(p),p.c&&!p.isInteger())throw Error(jn+"Exponent not an integer: "+j(p));if(E!=null&&(E=new w(E)),L=p.e>14,!ne.c||!ne.c[0]||ne.c[0]==1&&!ne.e&&ne.c.length==1||!p.c||!p.c[0])return U=new w(Math.pow(+j(ne),L?p.s*(2-Tu(p)):+j(p))),E?U.mod(E):U;if(q=p.s<0,E){if(E.c?!E.c[0]:!E.s)return new w(NaN);$=!q&&ne.isInteger()&&E.isInteger(),$&&(ne=ne.mod(E))}else{if(p.e>9&&(ne.e>0||ne.e<-1||(ne.e==0?ne.c[0]>1||L&&ne.c[1]>=24e7:ne.c[0]<8e13||L&&ne.c[0]<=9999975e7)))return P=ne.s<0&&Tu(p)?-0:0,ne.e>-1&&(P=1/P),new w(q?1/P:P);x&&(P=$h(x/It+2))}for(L?(S=new w(.5),q&&(p.s=1),J=Tu(p)):(B=Math.abs(+j(p)),J=B%2),U=new w(o);;){if(J){if(U=U.times(ne),!U.c)break;P?U.c.length>P&&(U.c.length=P):$&&(U=U.mod(E))}if(B){if(B=lr(B/2),B===0)break;J=B%2}else if(p=p.times(S),b(p,p.e+1,1),p.e>14)J=Tu(p);else{if(B=+j(p),B===0)break;J=B%2}ne=ne.times(ne),P?ne.c&&ne.c.length>P&&(ne.c.length=P):$&&(ne=ne.mod(E))}return $?U:(q&&(U=o.div(U)),E?U.mod(E):P?b(U,x,a,W):U)},i.integerValue=function(p){var E=new w(this);return p==null?p=a:Zt(p,0,8),b(E,E.e+1,p)},i.isEqualTo=i.eq=function(p,E){return bo(this,new w(p,E))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(p,E){return bo(this,new w(p,E))>0},i.isGreaterThanOrEqualTo=i.gte=function(p,E){return(E=bo(this,new w(p,E)))===1||E===0},i.isInteger=function(){return!!this.c&&ur(this.e/It)>this.c.length-2},i.isLessThan=i.lt=function(p,E){return bo(this,new w(p,E))<0},i.isLessThanOrEqualTo=i.lte=function(p,E){return(E=bo(this,new w(p,E)))===-1||E===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(p,E){var S,$,B,P,W=this,L=W.s;if(p=new w(p,E),E=p.s,!L||!E)return new w(NaN);if(L!=E)return p.s=-E,W.plus(p);var q=W.e/It,J=p.e/It,U=W.c,ne=p.c;if(!q||!J){if(!U||!ne)return U?(p.s=-E,p):new w(ne?W:NaN);if(!U[0]||!ne[0])return ne[0]?(p.s=-E,p):new w(U[0]?W:a==3?-0:0)}if(q=ur(q),J=ur(J),U=U.slice(),L=q-J){for((P=L<0)?(L=-L,B=U):(J=q,B=ne),B.reverse(),E=L;E--;B.push(0));B.reverse()}else for($=(P=(L=U.length)<(E=ne.length))?L:E,L=E=0;E<$;E++)if(U[E]!=ne[E]){P=U[E]<ne[E];break}if(P&&(B=U,U=ne,ne=B,p.s=-p.s),E=($=ne.length)-(S=U.length),E>0)for(;E--;U[S++]=0);for(E=Er-1;$>L;){if(U[--$]<ne[$]){for(S=$;S&&!U[--S];U[S]=E);--U[S],U[$]+=Er}U[$]-=ne[$]}for(;U[0]==0;U.splice(0,1),--J);return U[0]?N(p,U,J):(p.s=a==3?-1:1,p.c=[p.e=0],p)},i.modulo=i.mod=function(p,E){var S,$,B=this;return p=new w(p,E),!B.c||!p.s||p.c&&!p.c[0]?new w(NaN):!p.c||B.c&&!B.c[0]?new w(B):(h==9?($=p.s,p.s=1,S=e(B,p,0,3),p.s=$,S.s*=$):S=e(B,p,0,h),p=B.minus(S.times(p)),!p.c[0]&&h==1&&(p.s=B.s),p)},i.multipliedBy=i.times=function(p,E){var S,$,B,P,W,L,q,J,U,ne,fe,le,ye,he,de,be=this,Ae=be.c,_e=(p=new w(p,E)).c;if(!Ae||!_e||!Ae[0]||!_e[0])return!be.s||!p.s||Ae&&!Ae[0]&&!_e||_e&&!_e[0]&&!Ae?p.c=p.e=p.s=null:(p.s*=be.s,!Ae||!_e?p.c=p.e=null:(p.c=[0],p.e=0)),p;for($=ur(be.e/It)+ur(p.e/It),p.s*=be.s,q=Ae.length,ne=_e.length,q<ne&&(ye=Ae,Ae=_e,_e=ye,B=q,q=ne,ne=B),B=q+ne,ye=[];B--;ye.push(0));for(he=Er,de=Fi,B=ne;--B>=0;){for(S=0,fe=_e[B]%de,le=_e[B]/de|0,W=q,P=B+W;P>B;)J=Ae[--W]%de,U=Ae[W]/de|0,L=le*J+U*fe,J=fe*J+L%de*de+ye[P]+S,S=(J/he|0)+(L/de|0)+le*U,ye[P--]=J%he;ye[P]=S}return S?++$:ye.splice(0,1),N(p,ye,$)},i.negated=function(){var p=new w(this);return p.s=-p.s||null,p},i.plus=function(p,E){var S,$=this,B=$.s;if(p=new w(p,E),E=p.s,!B||!E)return new w(NaN);if(B!=E)return p.s=-E,$.minus(p);var P=$.e/It,W=p.e/It,L=$.c,q=p.c;if(!P||!W){if(!L||!q)return new w(B/0);if(!L[0]||!q[0])return q[0]?p:new w(L[0]?$:B*0)}if(P=ur(P),W=ur(W),L=L.slice(),B=P-W){for(B>0?(W=P,S=q):(B=-B,S=L),S.reverse();B--;S.push(0));S.reverse()}for(B=L.length,E=q.length,B-E<0&&(S=q,q=L,L=S,E=B),B=0;E;)B=(L[--E]=L[E]+q[E]+B)/Er|0,L[E]=Er===L[E]?0:L[E]%Er;return B&&(L=[B].concat(L),++W),N(p,L,W)},i.precision=i.sd=function(p,E){var S,$,B,P=this;if(p!=null&&p!==!!p)return Zt(p,1,Kn),E==null?E=a:Zt(E,0,8),b(new w(P),p,E);if(!(S=P.c))return null;if(B=S.length-1,$=B*It+1,B=S[B]){for(;B%10==0;B/=10,$--);for(B=S[0];B>=10;B/=10,$++);}return p&&P.e+1>$&&($=P.e+1),$},i.shiftedBy=function(p){return Zt(p,-9007199254740991,iy),this.times("1e"+p)},i.squareRoot=i.sqrt=function(){var p,E,S,$,B,P=this,W=P.c,L=P.s,q=P.e,J=s+4,U=new w("0.5");if(L!==1||!W||!W[0])return new w(!L||L<0&&(!W||W[0])?NaN:W?P:1/0);if(L=Math.sqrt(+j(P)),L==0||L==1/0?(E=or(W),(E.length+q)%2==0&&(E+="0"),L=Math.sqrt(+E),q=ur((q+1)/2)-(q<0||q%2),L==1/0?E="5e"+q:(E=L.toExponential(),E=E.slice(0,E.indexOf("e")+1)+q),S=new w(E)):S=new w(L+""),S.c[0]){for(q=S.e,L=q+J,L<3&&(L=0);;)if(B=S,S=U.times(B.plus(e(P,B,J,1))),or(B.c).slice(0,L)===(E=or(S.c)).slice(0,L))if(S.e<q&&--L,E=E.slice(L-3,L+1),E=="9999"||!$&&E=="4999"){if(!$&&(b(B,B.e+s+2,0),B.times(B).eq(P))){S=B;break}J+=4,L+=4,$=1}else{(!+E||!+E.slice(1)&&E.charAt(0)=="5")&&(b(S,S.e+s+2,1),p=!S.times(S).eq(P));break}}return b(S,S.e+s+1,a,p)},i.toExponential=function(p,E){return p!=null&&(Zt(p,0,Kn),p++),C(this,p,E,1)},i.toFixed=function(p,E){return p!=null&&(Zt(p,0,Kn),p=p+this.e+1),C(this,p,E)},i.toFormat=function(p,E,S){var $,B=this;if(S==null)p!=null&&E&&typeof E=="object"?(S=E,E=null):p&&typeof p=="object"?(S=p,p=E=null):S=A;else if(typeof S!="object")throw Error(jn+"Argument not an object: "+S);if($=B.toFixed(p,E),B.c){var P,W=$.split("."),L=+S.groupSize,q=+S.secondaryGroupSize,J=S.groupSeparator||"",U=W[0],ne=W[1],fe=B.s<0,le=fe?U.slice(1):U,ye=le.length;if(q&&(P=L,L=q,q=P,ye-=P),L>0&&ye>0){for(P=ye%L||L,U=le.substr(0,P);P<ye;P+=L)U+=J+le.substr(P,L);q>0&&(U+=J+le.slice(P)),fe&&(U="-"+U)}$=ne?U+(S.decimalSeparator||"")+((q=+S.fractionGroupSize)?ne.replace(new RegExp("\\d{"+q+"}\\B","g"),"$&"+(S.fractionGroupSeparator||"")):ne):U}return(S.prefix||"")+$+(S.suffix||"")},i.toFraction=function(p){var E,S,$,B,P,W,L,q,J,U,ne,fe,le=this,ye=le.c;if(p!=null&&(L=new w(p),!L.isInteger()&&(L.c||L.s!==1)||L.lt(o)))throw Error(jn+"Argument "+(L.isInteger()?"out of range: ":"not an integer: ")+j(L));if(!ye)return new w(le);for(E=new w(o),J=S=new w(o),$=q=new w(o),fe=or(ye),P=E.e=fe.length-le.e-1,E.c[0]=_h[(W=P%It)<0?It+W:W],p=!p||L.comparedTo(E)>0?P>0?E:J:L,W=u,u=1/0,L=new w(fe),q.c[0]=0;U=e(L,E,0,1),B=S.plus(U.times($)),B.comparedTo(p)!=1;)S=$,$=B,J=q.plus(U.times(B=J)),q=B,E=L.minus(U.times(B=E)),L=B;return B=e(p.minus(S),$,0,1),q=q.plus(B.times(J)),S=S.plus(B.times($)),q.s=J.s=le.s,P=P*2,ne=e(J,$,P,a).minus(le).abs().comparedTo(e(q,S,P,a).minus(le).abs())<1?[J,$]:[q,S],u=W,ne},i.toNumber=function(){return+j(this)},i.toPrecision=function(p,E){return p!=null&&Zt(p,1,Kn),C(this,p,E,2)},i.toString=function(p){var E,S=this,$=S.s,B=S.e;return B===null?$?(E="Infinity",$<0&&(E="-"+E)):E="NaN":(p==null?E=B<=l||B>=c?Mu(or(S.c),B):oi(or(S.c),B,"0"):p===10&&F?(S=b(new w(S),s+B+1,a),E=oi(or(S.c),S.e,"0")):(Zt(p,2,v.length,"Base"),E=t(oi(or(S.c),B,"0"),10,p,$,!0)),$<0&&S.c[0]&&(E="-"+E)),E},i.valueOf=i.toJSON=function(){return j(this)},i._isBigNumber=!0,i[Symbol.toStringTag]="BigNumber",i[Symbol.for("nodejs.util.inspect.custom")]=i.valueOf,n!=null&&w.set(n),w}function ur(n){var e=n|0;return n>0||n===e?e:e-1}function or(n){for(var e,t,r=1,i=n.length,o=n[0]+"";r<i;){for(e=n[r++]+"",t=It-e.length;t--;e="0"+e);o+=e}for(i=o.length;o.charCodeAt(--i)===48;);return o.slice(0,i+1||1)}function bo(n,e){var t,r,i=n.c,o=e.c,s=n.s,a=e.s,l=n.e,c=e.e;if(!s||!a)return null;if(t=i&&!i[0],r=o&&!o[0],t||r)return t?r?0:-a:s;if(s!=a)return s;if(t=s<0,r=l==c,!i||!o)return r?0:!i^t?1:-1;if(!r)return l>c^t?1:-1;for(a=(l=i.length)<(c=o.length)?l:c,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^t?1:-1;return l==c?0:l>c^t?1:-1}function Zt(n,e,t,r){if(n<e||n>t||n!==lr(n))throw Error(jn+(r||"Argument")+(typeof n=="number"?n<e||n>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(n))}function Tu(n){var e=n.c.length-1;return ur(n.e/It)==e&&n.c[e]%2!=0}function Mu(n,e){return(n.length>1?n.charAt(0)+"."+n.slice(1):n)+(e<0?"e":"e+")+e}function oi(n,e,t){var r,i;if(e<0){for(i=t+".";++e;i+=t);n=i+n}else if(r=n.length,++e>r){for(i=t,e-=r;--e;i+=t);n+=i}else e<r&&(n=n.slice(0,e)+"."+n.slice(e));return n}zx();const y2=100000n,w2=(n,e={})=>{const{style:t="decimal",compact:r=!1,fractionDigits:i,adaptiveDecimals:o=!1}=e,s=typeof n=="string"?Number(n):n,a=typeof s=="bigint"?s<0n?-s:s:Math.abs(s),l=r==="auto"?a>=y2:r,c=typeof s=="bigint"?Number(s):s,d=o&&c!==0&&Math.abs(c)<Math.pow(10,-(i??2)),u=new Intl.NumberFormat("en-US",{style:t,...t==="currency"&&{currency:"USD"},maximumFractionDigits:d?20:i??2,minimumFractionDigits:d?0:i??2});if(!l)return d?u.format(oy(c)):u.format(s);const m=[{threshold:1e12,suffix:"T",divisor:1e12},{threshold:1e9,suffix:"B",divisor:1e9},{threshold:1e6,suffix:"M",divisor:1e6},{threshold:1e3,suffix:"K",divisor:1e3}].find(h=>a>=h.threshold);if(m){const h=new Intl.NumberFormat("en-US",{style:t,...t==="currency"&&{currency:"USD"},maximumFractionDigits:i??1,minimumFractionDigits:i??1}),x=Number(s)/m.divisor;return h.format(x)+m.suffix}return d?u.format(oy(c)):u.format(s)};function oy(n){if(n===0)return 0;const e=n.toExponential().split("e"),t=parseInt(e[1]),r=Math.abs(t);return Number(n.toFixed(r))}function pr(n,e=5,t=5){return n?n.length<=e+t?n:`${n.slice(0,e)}...${n.slice(-t)}`:""}const x2={pay:"Payment",keyreg:"Key Registration",acfg:"Asset Config",axfer:"Asset Transfer",afrz:"Asset Freeze",appl:"Application Call",stpf:"State Proof",hb:"Heartbeat"};function v2(n){try{return Oe.decodeUnsignedTransaction(n)}catch{try{return Oe.decodeSignedTransaction(n).txn}catch{return null}}}function S2(n,e){return`${Number(n)/1e6} ALGO`}function b2(n){const e=[],t=[];let r=!1;for(let i=0;i<n.length;i++){const o=n[i];let s=null;if(o instanceof Uint8Array?s=v2(o):o instanceof Oe.Transaction&&(s=o),s!=null&&s.rekeyTo&&(r="rekey"),!s)continue;const a=s.sender.toString(),l={index:i,type:s.type,typeLabel:x2[s.type]||s.type,sender:a,senderShort:pr(a,4,4)};if(s.rekeyTo){const c=s.rekeyTo.toString();l.rekeyTo=c,l.rekeyToShort=pr(c,4,4)}if(s.payment){const c=s.payment.receiver.toString();if(l.receiver=c,l.receiverShort=pr(c,4,4),l.amount=S2(s.payment.amount),s.payment.closeRemainderTo){const d=s.payment.closeRemainderTo.toString();l.closeRemainderTo=d,l.closeRemainderToShort=pr(d,4,4),r="closeTo"}}if(s.assetTransfer){const c=s.assetTransfer.receiver.toString();if(l.receiver=c,l.receiverShort=pr(c,4,4),l.rawAmount=s.assetTransfer.amount,l.amount=s.assetTransfer.amount.toString(),l.assetIndex=Number(s.assetTransfer.assetIndex),s.assetTransfer.closeRemainderTo){const d=s.assetTransfer.closeRemainderTo.toString();l.closeRemainderTo=d,l.closeRemainderToShort=pr(d,4,4),r="closeTo"}}if(s.assetConfig&&(l.assetIndex=Number(s.assetConfig.assetIndex)),s.assetFreeze){l.assetIndex=Number(s.assetFreeze.assetIndex);const c=s.assetFreeze.freezeAccount.toString();l.freezeTarget=c,l.freezeTargetShort=pr(c,4,4),l.isFreezing=s.assetFreeze.frozen}s.applicationCall&&(l.appIndex=Number(s.applicationCall.appIndex)),e.push(l),t.push(s)}return{transactions:t,decodedTransactions:e,dangerous:r}}const E2=`#pragma version 11
48
+ `}),D.jsx("div",{style:{animation:N},children:M},m)]})}function ny(n){return`${n.slice(0,6)}...${n.slice(-6)}`}function i2({algorandAddress:n,evmAddress:e,onClose:t,labelId:r,descriptionId:i}){const[o,s]=Y.useState(null),a=Y.useCallback((d,u)=>{navigator.clipboard.writeText(d),s(u),setTimeout(()=>s(null),1500)},[]),l=ny(n),c=ny(e);return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"relative flex items-center px-6 pt-5 pb-4",children:[D.jsx("h2",{id:r,className:"text-xl font-bold text-[var(--wui-color-text)] wallet-custom-font",children:"Welcome to Algorand"}),D.jsx("button",{onClick:t,className:"absolute right-4 top-5 w-9 h-9 flex items-center justify-center rounded-full bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] hover:brightness-90 transition-all","aria-label":"Close dialog",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),D.jsxs("div",{id:i,className:"px-6 pb-4 space-y-4",children:[D.jsxs("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:["You can use Algorand with your very own Liquid EVM account, which wraps your EVM private key, preserving full self-custodial control."," ",D.jsx("a",{className:"text-[var(--wui-color-link)] hover:text-[var(--wui-color-link-hover)]",rel:"noopener noreferrer",href:"#",onClick:()=>(alert("Soon"),!1),children:"Learn more."})]}),D.jsxs("div",{className:"!my-4 rounded-xl border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] p-3 space-y-2",children:[D.jsxs("div",{className:"flex justify-between items-center text-xs",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"Your EVM Address"}),D.jsxs("span",{className:"flex items-center gap-1.5",children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] font-mono",children:c}),D.jsx("button",{onClick:()=>a(e,"evm"),className:"text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] transition-colors","aria-label":"Copy EVM address",children:o==="evm"?D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:[D.jsx("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),D.jsx("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"})]})})]})]}),D.jsxs("div",{className:"flex justify-between items-center text-xs",children:[D.jsx("span",{className:"text-[var(--wui-color-text-tertiary)]",children:"Your Algorand Address"}),D.jsxs("span",{className:"flex items-center gap-1.5",children:[D.jsx("span",{className:"text-[var(--wui-color-text-secondary)] font-mono",children:l}),D.jsx("button",{onClick:()=>a(n,"algorand"),className:"text-[var(--wui-color-text-tertiary)] hover:text-[var(--wui-color-text-secondary)] transition-colors","aria-label":"Copy Algorand address",children:o==="algorand"?D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:[D.jsx("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),D.jsx("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"})]})})]})]})]}),D.jsxs("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:["To get started,"," ",D.jsx("a",{className:"text-[var(--wui-color-link)] hover:text-[var(--wui-color-link-hover)]",rel:"noopener noreferrer",target:"_blank",href:"https://algorand.co/ecosystem/directory?tags=CEX",children:"fund"})," ","your new Algorand account via CEX, Card onramp, or"," ",D.jsx("a",{className:"text-[var(--wui-color-link)] hover:text-[var(--wui-color-link-hover)]",rel:"noopener noreferrer",target:"_blank",href:"https://core.allbridge.io/?ft=USDC&tt=USDC&f=BAS&t=ALG",children:"bridge USDC"})," ","in 2 minutes."]})]}),D.jsxs("div",{className:"px-6 py-4 border-t border-[var(--wui-color-border)] flex flex gap-2",children:[D.jsx("button",{onClick:()=>{t(),window.open("https://algorand.co/algorand-start-here#hs_cos_wrapper_widget_1769533007886")},className:"w-full py-2.5 px-4 bg-[var(--wui-color-primary)] text-[var(--wui-color-primary-text)] font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Get Started"}),D.jsx("button",{onClick:t,className:"w-full py-2.5 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm",children:"Close"})]})]})}const o2="walletUiAssets",po="assets",go="meta",s2=1;let zc=null;function Rc(){return zc||(zc=new Promise((n,e)=>{const t=indexedDB.open(o2,s2);t.onupgradeneeded=()=>{const r=t.result;r.objectStoreNames.contains(po)||r.createObjectStore(po,{keyPath:"index"}),r.objectStoreNames.contains(go)||r.createObjectStore(go)},t.onsuccess=()=>n(t.result),t.onerror=()=>{zc=null,e(t.error)}}),zc)}let Hu=[],Fu=null,Dp=[];function a2(){return new Promise((n,e)=>{if(Hu.length===0){n();return}const t=Hu.slice(),r=Dp.slice();Hu=[],Dp=[],Rc().then(i=>{const o=i.transaction(po,"readwrite"),s=o.objectStore(po);for(const a of t)s.put(a);o.oncomplete=()=>{for(const a of r)a.resolve();n()},o.onerror=()=>{const a=o.error;for(const l of r)l.reject(a);e(a)}}).catch(i=>{for(const o of r)o.reject(i);e(i)})})}function c2(n){return new Promise((e,t)=>{Hu.push(...n),Dp.push({resolve:e,reject:t}),Fu&&clearTimeout(Fu),Fu=setTimeout(()=>{Fu=null,a2()},500)})}function l2(n,e=20){const t=n.toLowerCase();return Rc().then(r=>new Promise((i,o)=>{const l=r.transaction(po,"readonly").objectStore(po).openCursor(),c=[];l.onsuccess=()=>{const d=l.result;if(!d||c.length>=e){i(c);return}const u=d.value;(u.name.toLowerCase().includes(t)||u.unitName.toLowerCase().includes(t))&&c.push(u),d.continue()},l.onerror=()=>o(l.error)}))}function u2(){return Rc().then(n=>new Promise((e,t)=>{const i=n.transaction(go,"readonly").objectStore(go).get("lastUpdated");i.onsuccess=()=>e(i.result??null),i.onerror=()=>t(i.error)}))}function d2(n){return Rc().then(e=>new Promise((t,r)=>{const i=e.transaction(go,"readwrite");i.objectStore(go).put(n,"lastUpdated"),i.oncomplete=()=>t(),i.onerror=()=>r(i.error)}))}function h2(){return Rc().then(n=>new Promise((e,t)=>{const r=n.transaction([po,go],"readwrite");r.objectStore(po).clear(),r.objectStore(go).clear(),r.oncomplete=()=>e(),r.onerror=()=>t(r.error)}))}const Du={open:Rc,insertMany:c2,searchByName:l2,getLastUpdated:u2,setLastUpdated:d2,clear:h2};function f2({transactions:n,message:e,dangerous:t,onApprove:r,onReject:i,onClose:o,signing:s,walletName:a,algodClient:l}){const{theme:c}=ti(),[d,u]=Y.useState("starting"),m=c==="system"?void 0:c,{refs:h,context:x}=Ld({open:!0,onOpenChange:N=>{N||(u("exiting"),setTimeout(t?()=>i():()=>o(),150))}}),A=Od(x,{outsidePressEvent:"mousedown"}),v=tg(x,{role:"alertdialog"}),{getFloatingProps:F}=Vd([A,v]),w=Yr(),C=Yr();d==="starting"&&requestAnimationFrame(()=>u("entered"));const M=D.jsx("button",{onClick:()=>{u("exiting"),setTimeout(()=>{t?i():r()},150)},className:"w-8 h-8 flex-none flex items-center justify-center rounded-full bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] hover:brightness-90 transition-all","aria-label":"Close dialog",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})});return D.jsx(uu,{id:"wallet-sign-dialog-portal",children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":m,children:D.jsx(eg,{className:"grid place-items-center px-4 z-[100] transition-opacity duration-150 ease-in-out bg-[var(--wui-color-overlay)] data-[state=starting]:opacity-0 data-[state=exiting]:opacity-0 data-[state=entered]:opacity-100","data-state":d,lockScroll:!0,children:D.jsx(Pd,{context:x,modal:!0,children:D.jsx("div",{ref:h.setFloating,...F({"aria-labelledby":w,"aria-describedby":C}),role:"alertdialog","data-state":d,className:"w-full max-w-md rounded-3xl bg-[var(--wui-color-bg)] shadow-xl transform transition-all duration-150 ease-in-out data-[state=starting]:opacity-0 data-[state=starting]:scale-90 data-[state=exiting]:opacity-0 data-[state=exiting]:scale-90 data-[state=entered]:opacity-100 data-[state=entered]:scale-100",style:{marginTop:"-0.5rem"},children:D.jsx(ZC,{transactions:n,message:e,dangerous:t,algodClient:l,getApplicationAddress:N=>dd(BigInt(N)),onApprove:()=>{u("exiting"),setTimeout(()=>r(),150)},onReject:()=>{u("exiting"),setTimeout(()=>i(),150)},signing:s,walletName:a,headerAction:M})})})})})})}function p2({transactionCount:n,dangerous:e,onReject:t}){const{theme:r}=ti(),i=r==="system"?void 0:r;return D.jsx(uu,{id:"wallet-extension-indicator-portal",children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":i,children:D.jsxs("div",{className:"fixed bottom-4 right-4 z-[100] flex items-center gap-3 rounded-2xl bg-[var(--wui-color-bg)] shadow-lg border border-[var(--wui-color-border)] px-4 py-3 max-w-sm",children:[D.jsxs("svg",{className:"animate-spin h-5 w-5 text-[var(--wui-color-primary)] flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[D.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),D.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),D.jsxs("div",{className:"flex flex-col min-w-0",children:[D.jsxs("span",{className:`text-sm font-medium ${e?"text-[var(--wui-color-danger-text)]":"text-[var(--wui-color-text)]"}`,children:["Review ",n>1?`${n} transactions`:"transaction"," in extension",e&&" (dangerous)"]}),D.jsx("span",{className:"text-xs text-[var(--wui-color-text-tertiary)]",children:"Open the Liquid Wallet Companion popup"})]}),D.jsx("button",{onClick:t,className:"ml-auto flex-shrink-0 text-xs px-2.5 py-1 rounded-lg bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] hover:brightness-90 transition-all",children:"Cancel"})]})})})}function g2({algorandAddress:n,evmAddress:e,onDismiss:t}){const{theme:r}=ti(),[i,o]=Y.useState("starting"),s=()=>{o("exiting"),setTimeout(()=>t(),150)},a=r==="system"?void 0:r,{refs:l,context:c}=Ld({open:!0,onOpenChange:A=>{A||s()}}),d=Od(c,{outsidePressEvent:"mousedown"}),u=tg(c,{role:"dialog"}),{getFloatingProps:m}=Vd([d,u]),h=Yr(),x=Yr();return i==="starting"&&requestAnimationFrame(()=>o("entered")),D.jsx(uu,{id:"wallet-welcome-dialog-portal",children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":a,children:D.jsx(eg,{className:"grid place-items-center px-4 z-[100] transition-opacity duration-150 ease-in-out bg-[var(--wui-color-overlay)] data-[state=starting]:opacity-0 data-[state=exiting]:opacity-0 data-[state=entered]:opacity-100","data-state":i,lockScroll:!0,children:D.jsx(Pd,{context:c,modal:!0,children:D.jsx("div",{ref:l.setFloating,...m({"aria-labelledby":h,"aria-describedby":x}),role:"dialog","data-state":i,className:"w-full max-w-md rounded-3xl bg-[var(--wui-color-bg)] shadow-xl transform transition-all duration-150 ease-in-out data-[state=starting]:opacity-0 data-[state=starting]:scale-90 data-[state=exiting]:opacity-0 data-[state=exiting]:scale-90 data-[state=entered]:opacity-100 data-[state=entered]:scale-100",style:{marginTop:"-0.5rem"},children:D.jsx(i2,{algorandAddress:n,evmAddress:e,onClose:s,labelId:h,descriptionId:x})})})})})})}function Wx(n){const[e,t]=Y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return Y.useEffect(()=>{if(n!=="system")return;const r=window.matchMedia("(prefers-color-scheme: dark)");t(r.matches?"dark":"light");const i=o=>{t(o.matches?"dark":"light")};return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[n]),n==="system"?e:n}var m2=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,$h=Math.ceil,lr=Math.floor,jn="[BigNumber Error] ",ry=jn+"Number primitive has more than 15 significant digits: ",Er=1e14,It=14,iy=9007199254740991,_h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Fi=1e7,Kn=1e9;function zx(n){var e,t,r,i=w.prototype={constructor:w,toString:null,valueOf:null},o=new w(1),s=20,a=4,l=-7,c=21,d=-1e7,u=1e7,m=!1,h=1,x=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},v="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function w(p,E){var S,$,B,P,W,L,q,J,U=this;if(!(U instanceof w))return new w(p,E);if(E==null){if(p&&p._isBigNumber===!0){U.s=p.s,!p.c||p.e>u?U.c=U.e=null:p.e<d?U.c=[U.e=0]:(U.e=p.e,U.c=p.c.slice());return}if((L=typeof p=="number")&&p*0==0){if(U.s=1/p<0?(p=-p,-1):1,p===~~p){for(P=0,W=p;W>=10;W/=10,P++);P>u?U.c=U.e=null:(U.e=P,U.c=[p]);return}J=String(p)}else{if(!m2.test(J=String(p)))return r(U,J,L);U.s=J.charCodeAt(0)==45?(J=J.slice(1),-1):1}(P=J.indexOf("."))>-1&&(J=J.replace(".","")),(W=J.search(/e/i))>0?(P<0&&(P=W),P+=+J.slice(W+1),J=J.substring(0,W)):P<0&&(P=J.length)}else{if(Zt(E,2,v.length,"Base"),E==10&&F)return U=new w(p),b(U,s+U.e+1,a);if(J=String(p),L=typeof p=="number"){if(p*0!=0)return r(U,J,L,E);if(U.s=1/p<0?(J=J.slice(1),-1):1,w.DEBUG&&J.replace(/^0\.0*|\./,"").length>15)throw Error(ry+p)}else U.s=J.charCodeAt(0)===45?(J=J.slice(1),-1):1;for(S=v.slice(0,E),P=W=0,q=J.length;W<q;W++)if(S.indexOf($=J.charAt(W))<0){if($=="."){if(W>P){P=q;continue}}else if(!B&&(J==J.toUpperCase()&&(J=J.toLowerCase())||J==J.toLowerCase()&&(J=J.toUpperCase()))){B=!0,W=-1,P=0;continue}return r(U,String(p),L,E)}L=!1,J=t(J,E,10,U.s),(P=J.indexOf("."))>-1?J=J.replace(".",""):P=J.length}for(W=0;J.charCodeAt(W)===48;W++);for(q=J.length;J.charCodeAt(--q)===48;);if(J=J.slice(W,++q)){if(q-=W,L&&w.DEBUG&&q>15&&(p>iy||p!==lr(p)))throw Error(ry+U.s*p);if((P=P-W-1)>u)U.c=U.e=null;else if(P<d)U.c=[U.e=0];else{if(U.e=P,U.c=[],W=(P+1)%It,P<0&&(W+=It),W<q){for(W&&U.c.push(+J.slice(0,W)),q-=It;W<q;)U.c.push(+J.slice(W,W+=It));W=It-(J=J.slice(W)).length}else W-=q;for(;W--;J+="0");U.c.push(+J)}}else U.c=[U.e=0]}w.clone=zx,w.ROUND_UP=0,w.ROUND_DOWN=1,w.ROUND_CEIL=2,w.ROUND_FLOOR=3,w.ROUND_HALF_UP=4,w.ROUND_HALF_DOWN=5,w.ROUND_HALF_EVEN=6,w.ROUND_HALF_CEIL=7,w.ROUND_HALF_FLOOR=8,w.EUCLID=9,w.config=w.set=function(p){var E,S;if(p!=null)if(typeof p=="object"){if(p.hasOwnProperty(E="DECIMAL_PLACES")&&(S=p[E],Zt(S,0,Kn,E),s=S),p.hasOwnProperty(E="ROUNDING_MODE")&&(S=p[E],Zt(S,0,8,E),a=S),p.hasOwnProperty(E="EXPONENTIAL_AT")&&(S=p[E],S&&S.pop?(Zt(S[0],-1e9,0,E),Zt(S[1],0,Kn,E),l=S[0],c=S[1]):(Zt(S,-1e9,Kn,E),l=-(c=S<0?-S:S))),p.hasOwnProperty(E="RANGE"))if(S=p[E],S&&S.pop)Zt(S[0],-1e9,-1,E),Zt(S[1],1,Kn,E),d=S[0],u=S[1];else if(Zt(S,-1e9,Kn,E),S)d=-(u=S<0?-S:S);else throw Error(jn+E+" cannot be zero: "+S);if(p.hasOwnProperty(E="CRYPTO"))if(S=p[E],S===!!S)if(S)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))m=S;else throw m=!S,Error(jn+"crypto unavailable");else m=S;else throw Error(jn+E+" not true or false: "+S);if(p.hasOwnProperty(E="MODULO_MODE")&&(S=p[E],Zt(S,0,9,E),h=S),p.hasOwnProperty(E="POW_PRECISION")&&(S=p[E],Zt(S,0,Kn,E),x=S),p.hasOwnProperty(E="FORMAT"))if(S=p[E],typeof S=="object")A=S;else throw Error(jn+E+" not an object: "+S);if(p.hasOwnProperty(E="ALPHABET"))if(S=p[E],typeof S=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(S))F=S.slice(0,10)=="0123456789",v=S;else throw Error(jn+E+" invalid: "+S)}else throw Error(jn+"Object expected: "+p);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[l,c],RANGE:[d,u],CRYPTO:m,MODULO_MODE:h,POW_PRECISION:x,FORMAT:A,ALPHABET:v}},w.isBigNumber=function(p){if(!p||p._isBigNumber!==!0)return!1;if(!w.DEBUG)return!0;var E,S,$=p.c,B=p.e,P=p.s;e:if({}.toString.call($)=="[object Array]"){if((P===1||P===-1)&&B>=-1e9&&B<=Kn&&B===lr(B)){if($[0]===0){if(B===0&&$.length===1)return!0;break e}if(E=(B+1)%It,E<1&&(E+=It),String($[0]).length==E){for(E=0;E<$.length;E++)if(S=$[E],S<0||S>=Er||S!==lr(S))break e;if(S!==0)return!0}}}else if($===null&&B===null&&(P===null||P===1||P===-1))return!0;throw Error(jn+"Invalid BigNumber: "+p)},w.maximum=w.max=function(){return M(arguments,-1)},w.minimum=w.min=function(){return M(arguments,1)},w.random=(function(){var p=9007199254740992,E=Math.random()*p&2097151?function(){return lr(Math.random()*p)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(S){var $,B,P,W,L,q=0,J=[],U=new w(o);if(S==null?S=s:Zt(S,0,Kn),W=$h(S/It),m)if(crypto.getRandomValues){for($=crypto.getRandomValues(new Uint32Array(W*=2));q<W;)L=$[q]*131072+($[q+1]>>>11),L>=9e15?(B=crypto.getRandomValues(new Uint32Array(2)),$[q]=B[0],$[q+1]=B[1]):(J.push(L%1e14),q+=2);q=W/2}else if(crypto.randomBytes){for($=crypto.randomBytes(W*=7);q<W;)L=($[q]&31)*281474976710656+$[q+1]*1099511627776+$[q+2]*4294967296+$[q+3]*16777216+($[q+4]<<16)+($[q+5]<<8)+$[q+6],L>=9e15?crypto.randomBytes(7).copy($,q):(J.push(L%1e14),q+=7);q=W/7}else throw m=!1,Error(jn+"crypto unavailable");if(!m)for(;q<W;)L=E(),L<9e15&&(J[q++]=L%1e14);for(W=J[--q],S%=It,W&&S&&(L=_h[It-S],J[q]=lr(W/L)*L);J[q]===0;J.pop(),q--);if(q<0)J=[P=0];else{for(P=-1;J[0]===0;J.splice(0,1),P-=It);for(q=1,L=J[0];L>=10;L/=10,q++);q<It&&(P-=It-q)}return U.e=P,U.c=J,U}})(),w.sum=function(){for(var p=1,E=arguments,S=new w(E[0]);p<E.length;)S=S.plus(E[p++]);return S},t=(function(){var p="0123456789";function E(S,$,B,P){for(var W,L=[0],q,J=0,U=S.length;J<U;){for(q=L.length;q--;L[q]*=$);for(L[0]+=P.indexOf(S.charAt(J++)),W=0;W<L.length;W++)L[W]>B-1&&(L[W+1]==null&&(L[W+1]=0),L[W+1]+=L[W]/B|0,L[W]%=B)}return L.reverse()}return function(S,$,B,P,W){var L,q,J,U,ne,fe,le,ye,he=S.indexOf("."),de=s,be=a;for(he>=0&&(U=x,x=0,S=S.replace(".",""),ye=new w($),fe=ye.pow(S.length-he),x=U,ye.c=E(oi(or(fe.c),fe.e,"0"),10,B,p),ye.e=ye.c.length),le=E(S,$,B,W?(L=v,p):(L=p,v)),J=U=le.length;le[--U]==0;le.pop());if(!le[0])return L.charAt(0);if(he<0?--J:(fe.c=le,fe.e=J,fe.s=P,fe=e(fe,ye,de,be,B),le=fe.c,ne=fe.r,J=fe.e),q=J+de+1,he=le[q],U=B/2,ne=ne||q<0||le[q+1]!=null,ne=be<4?(he!=null||ne)&&(be==0||be==(fe.s<0?3:2)):he>U||he==U&&(be==4||ne||be==6&&le[q-1]&1||be==(fe.s<0?8:7)),q<1||!le[0])S=ne?oi(L.charAt(1),-de,L.charAt(0)):L.charAt(0);else{if(le.length=q,ne)for(--B;++le[--q]>B;)le[q]=0,q||(++J,le=[1].concat(le));for(U=le.length;!le[--U];);for(he=0,S="";he<=U;S+=L.charAt(le[he++]));S=oi(S,J,L.charAt(0))}return S}})(),e=(function(){function p($,B,P){var W,L,q,J,U=0,ne=$.length,fe=B%Fi,le=B/Fi|0;for($=$.slice();ne--;)q=$[ne]%Fi,J=$[ne]/Fi|0,W=le*q+J*fe,L=fe*q+W%Fi*Fi+U,U=(L/P|0)+(W/Fi|0)+le*J,$[ne]=L%P;return U&&($=[U].concat($)),$}function E($,B,P,W){var L,q;if(P!=W)q=P>W?1:-1;else for(L=q=0;L<P;L++)if($[L]!=B[L]){q=$[L]>B[L]?1:-1;break}return q}function S($,B,P,W){for(var L=0;P--;)$[P]-=L,L=$[P]<B[P]?1:0,$[P]=L*W+$[P]-B[P];for(;!$[0]&&$.length>1;$.splice(0,1));}return function($,B,P,W,L){var q,J,U,ne,fe,le,ye,he,de,be,Ae,_e,De,Te,T,G,X,re=$.s==B.s?1:-1,H=$.c,Z=B.c;if(!H||!H[0]||!Z||!Z[0])return new w(!$.s||!B.s||(H?Z&&H[0]==Z[0]:!Z)?NaN:H&&H[0]==0||!Z?re*0:re/0);for(he=new w(re),de=he.c=[],J=$.e-B.e,re=P+J+1,L||(L=Er,J=ur($.e/It)-ur(B.e/It),re=re/It|0),U=0;Z[U]==(H[U]||0);U++);if(Z[U]>(H[U]||0)&&J--,re<0)de.push(1),ne=!0;else{for(Te=H.length,G=Z.length,U=0,re+=2,fe=lr(L/(Z[0]+1)),fe>1&&(Z=p(Z,fe,L),H=p(H,fe,L),G=Z.length,Te=H.length),De=G,be=H.slice(0,G),Ae=be.length;Ae<G;be[Ae++]=0);X=Z.slice(),X=[0].concat(X),T=Z[0],Z[1]>=L/2&&T++;do{if(fe=0,q=E(Z,be,G,Ae),q<0){if(_e=be[0],G!=Ae&&(_e=_e*L+(be[1]||0)),fe=lr(_e/T),fe>1)for(fe>=L&&(fe=L-1),le=p(Z,fe,L),ye=le.length,Ae=be.length;E(le,be,ye,Ae)==1;)fe--,S(le,G<ye?X:Z,ye,L),ye=le.length,q=1;else fe==0&&(q=fe=1),le=Z.slice(),ye=le.length;if(ye<Ae&&(le=[0].concat(le)),S(be,le,Ae,L),Ae=be.length,q==-1)for(;E(Z,be,G,Ae)<1;)fe++,S(be,G<Ae?X:Z,Ae,L),Ae=be.length}else q===0&&(fe++,be=[0]);de[U++]=fe,be[0]?be[Ae++]=H[De]||0:(be=[H[De]],Ae=1)}while((De++<Te||be[0]!=null)&&re--);ne=be[0]!=null,de[0]||de.splice(0,1)}if(L==Er){for(U=1,re=de[0];re>=10;re/=10,U++);b(he,P+(he.e=U+J*It-1)+1,W,ne)}else he.e=J,he.r=+ne;return he}})();function C(p,E,S,$){var B,P,W,L,q;if(S==null?S=a:Zt(S,0,8),!p.c)return p.toString();if(B=p.c[0],W=p.e,E==null)q=or(p.c),q=$==1||$==2&&(W<=l||W>=c)?Mu(q,W):oi(q,W,"0");else if(p=b(new w(p),E,S),P=p.e,q=or(p.c),L=q.length,$==1||$==2&&(E<=P||P<=l)){for(;L<E;q+="0",L++);q=Mu(q,P)}else if(E-=W,q=oi(q,P,"0"),P+1>L){if(--E>0)for(q+=".";E--;q+="0");}else if(E+=P-L,E>0)for(P+1==L&&(q+=".");E--;q+="0");return p.s<0&&B?"-"+q:q}function M(p,E){for(var S,$,B=1,P=new w(p[0]);B<p.length;B++)$=new w(p[B]),(!$.s||(S=bo(P,$))===E||S===0&&P.s===E)&&(P=$);return P}function N(p,E,S){for(var $=1,B=E.length;!E[--B];E.pop());for(B=E[0];B>=10;B/=10,$++);return(S=$+S*It-1)>u?p.c=p.e=null:S<d?p.c=[p.e=0]:(p.e=S,p.c=E),p}r=(function(){var p=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,S=/^\.([^.]+)$/,$=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,W,L,q){var J,U=L?W:W.replace(B,"");if($.test(U))P.s=isNaN(U)?null:U<0?-1:1;else{if(!L&&(U=U.replace(p,function(ne,fe,le){return J=(le=le.toLowerCase())=="x"?16:le=="b"?2:8,!q||q==J?fe:ne}),q&&(J=q,U=U.replace(E,"$1").replace(S,"0.$1")),W!=U))return new w(U,J);if(w.DEBUG)throw Error(jn+"Not a"+(q?" base "+q:"")+" number: "+W);P.s=null}P.c=P.e=null}})();function b(p,E,S,$){var B,P,W,L,q,J,U,ne=p.c,fe=_h;if(ne){e:{for(B=1,L=ne[0];L>=10;L/=10,B++);if(P=E-B,P<0)P+=It,W=E,q=ne[J=0],U=lr(q/fe[B-W-1]%10);else if(J=$h((P+1)/It),J>=ne.length)if($){for(;ne.length<=J;ne.push(0));q=U=0,B=1,P%=It,W=P-It+1}else break e;else{for(q=L=ne[J],B=1;L>=10;L/=10,B++);P%=It,W=P-It+B,U=W<0?0:lr(q/fe[B-W-1]%10)}if($=$||E<0||ne[J+1]!=null||(W<0?q:q%fe[B-W-1]),$=S<4?(U||$)&&(S==0||S==(p.s<0?3:2)):U>5||U==5&&(S==4||$||S==6&&(P>0?W>0?q/fe[B-W]:0:ne[J-1])%10&1||S==(p.s<0?8:7)),E<1||!ne[0])return ne.length=0,$?(E-=p.e+1,ne[0]=fe[(It-E%It)%It],p.e=-E||0):ne[0]=p.e=0,p;if(P==0?(ne.length=J,L=1,J--):(ne.length=J+1,L=fe[It-P],ne[J]=W>0?lr(q/fe[B-W]%fe[W])*L:0),$)for(;;)if(J==0){for(P=1,W=ne[0];W>=10;W/=10,P++);for(W=ne[0]+=L,L=1;W>=10;W/=10,L++);P!=L&&(p.e++,ne[0]==Er&&(ne[0]=1));break}else{if(ne[J]+=L,ne[J]!=Er)break;ne[J--]=0,L=1}for(P=ne.length;ne[--P]===0;ne.pop());}p.e>u?p.c=p.e=null:p.e<d&&(p.c=[p.e=0])}return p}function j(p){var E,S=p.e;return S===null?p.toString():(E=or(p.c),E=S<=l||S>=c?Mu(E,S):oi(E,S,"0"),p.s<0?"-"+E:E)}return i.absoluteValue=i.abs=function(){var p=new w(this);return p.s<0&&(p.s=1),p},i.comparedTo=function(p,E){return bo(this,new w(p,E))},i.decimalPlaces=i.dp=function(p,E){var S,$,B,P=this;if(p!=null)return Zt(p,0,Kn),E==null?E=a:Zt(E,0,8),b(new w(P),p+P.e+1,E);if(!(S=P.c))return null;if($=((B=S.length-1)-ur(this.e/It))*It,B=S[B])for(;B%10==0;B/=10,$--);return $<0&&($=0),$},i.dividedBy=i.div=function(p,E){return e(this,new w(p,E),s,a)},i.dividedToIntegerBy=i.idiv=function(p,E){return e(this,new w(p,E),0,1)},i.exponentiatedBy=i.pow=function(p,E){var S,$,B,P,W,L,q,J,U,ne=this;if(p=new w(p),p.c&&!p.isInteger())throw Error(jn+"Exponent not an integer: "+j(p));if(E!=null&&(E=new w(E)),L=p.e>14,!ne.c||!ne.c[0]||ne.c[0]==1&&!ne.e&&ne.c.length==1||!p.c||!p.c[0])return U=new w(Math.pow(+j(ne),L?p.s*(2-Tu(p)):+j(p))),E?U.mod(E):U;if(q=p.s<0,E){if(E.c?!E.c[0]:!E.s)return new w(NaN);$=!q&&ne.isInteger()&&E.isInteger(),$&&(ne=ne.mod(E))}else{if(p.e>9&&(ne.e>0||ne.e<-1||(ne.e==0?ne.c[0]>1||L&&ne.c[1]>=24e7:ne.c[0]<8e13||L&&ne.c[0]<=9999975e7)))return P=ne.s<0&&Tu(p)?-0:0,ne.e>-1&&(P=1/P),new w(q?1/P:P);x&&(P=$h(x/It+2))}for(L?(S=new w(.5),q&&(p.s=1),J=Tu(p)):(B=Math.abs(+j(p)),J=B%2),U=new w(o);;){if(J){if(U=U.times(ne),!U.c)break;P?U.c.length>P&&(U.c.length=P):$&&(U=U.mod(E))}if(B){if(B=lr(B/2),B===0)break;J=B%2}else if(p=p.times(S),b(p,p.e+1,1),p.e>14)J=Tu(p);else{if(B=+j(p),B===0)break;J=B%2}ne=ne.times(ne),P?ne.c&&ne.c.length>P&&(ne.c.length=P):$&&(ne=ne.mod(E))}return $?U:(q&&(U=o.div(U)),E?U.mod(E):P?b(U,x,a,W):U)},i.integerValue=function(p){var E=new w(this);return p==null?p=a:Zt(p,0,8),b(E,E.e+1,p)},i.isEqualTo=i.eq=function(p,E){return bo(this,new w(p,E))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(p,E){return bo(this,new w(p,E))>0},i.isGreaterThanOrEqualTo=i.gte=function(p,E){return(E=bo(this,new w(p,E)))===1||E===0},i.isInteger=function(){return!!this.c&&ur(this.e/It)>this.c.length-2},i.isLessThan=i.lt=function(p,E){return bo(this,new w(p,E))<0},i.isLessThanOrEqualTo=i.lte=function(p,E){return(E=bo(this,new w(p,E)))===-1||E===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(p,E){var S,$,B,P,W=this,L=W.s;if(p=new w(p,E),E=p.s,!L||!E)return new w(NaN);if(L!=E)return p.s=-E,W.plus(p);var q=W.e/It,J=p.e/It,U=W.c,ne=p.c;if(!q||!J){if(!U||!ne)return U?(p.s=-E,p):new w(ne?W:NaN);if(!U[0]||!ne[0])return ne[0]?(p.s=-E,p):new w(U[0]?W:a==3?-0:0)}if(q=ur(q),J=ur(J),U=U.slice(),L=q-J){for((P=L<0)?(L=-L,B=U):(J=q,B=ne),B.reverse(),E=L;E--;B.push(0));B.reverse()}else for($=(P=(L=U.length)<(E=ne.length))?L:E,L=E=0;E<$;E++)if(U[E]!=ne[E]){P=U[E]<ne[E];break}if(P&&(B=U,U=ne,ne=B,p.s=-p.s),E=($=ne.length)-(S=U.length),E>0)for(;E--;U[S++]=0);for(E=Er-1;$>L;){if(U[--$]<ne[$]){for(S=$;S&&!U[--S];U[S]=E);--U[S],U[$]+=Er}U[$]-=ne[$]}for(;U[0]==0;U.splice(0,1),--J);return U[0]?N(p,U,J):(p.s=a==3?-1:1,p.c=[p.e=0],p)},i.modulo=i.mod=function(p,E){var S,$,B=this;return p=new w(p,E),!B.c||!p.s||p.c&&!p.c[0]?new w(NaN):!p.c||B.c&&!B.c[0]?new w(B):(h==9?($=p.s,p.s=1,S=e(B,p,0,3),p.s=$,S.s*=$):S=e(B,p,0,h),p=B.minus(S.times(p)),!p.c[0]&&h==1&&(p.s=B.s),p)},i.multipliedBy=i.times=function(p,E){var S,$,B,P,W,L,q,J,U,ne,fe,le,ye,he,de,be=this,Ae=be.c,_e=(p=new w(p,E)).c;if(!Ae||!_e||!Ae[0]||!_e[0])return!be.s||!p.s||Ae&&!Ae[0]&&!_e||_e&&!_e[0]&&!Ae?p.c=p.e=p.s=null:(p.s*=be.s,!Ae||!_e?p.c=p.e=null:(p.c=[0],p.e=0)),p;for($=ur(be.e/It)+ur(p.e/It),p.s*=be.s,q=Ae.length,ne=_e.length,q<ne&&(ye=Ae,Ae=_e,_e=ye,B=q,q=ne,ne=B),B=q+ne,ye=[];B--;ye.push(0));for(he=Er,de=Fi,B=ne;--B>=0;){for(S=0,fe=_e[B]%de,le=_e[B]/de|0,W=q,P=B+W;P>B;)J=Ae[--W]%de,U=Ae[W]/de|0,L=le*J+U*fe,J=fe*J+L%de*de+ye[P]+S,S=(J/he|0)+(L/de|0)+le*U,ye[P--]=J%he;ye[P]=S}return S?++$:ye.splice(0,1),N(p,ye,$)},i.negated=function(){var p=new w(this);return p.s=-p.s||null,p},i.plus=function(p,E){var S,$=this,B=$.s;if(p=new w(p,E),E=p.s,!B||!E)return new w(NaN);if(B!=E)return p.s=-E,$.minus(p);var P=$.e/It,W=p.e/It,L=$.c,q=p.c;if(!P||!W){if(!L||!q)return new w(B/0);if(!L[0]||!q[0])return q[0]?p:new w(L[0]?$:B*0)}if(P=ur(P),W=ur(W),L=L.slice(),B=P-W){for(B>0?(W=P,S=q):(B=-B,S=L),S.reverse();B--;S.push(0));S.reverse()}for(B=L.length,E=q.length,B-E<0&&(S=q,q=L,L=S,E=B),B=0;E;)B=(L[--E]=L[E]+q[E]+B)/Er|0,L[E]=Er===L[E]?0:L[E]%Er;return B&&(L=[B].concat(L),++W),N(p,L,W)},i.precision=i.sd=function(p,E){var S,$,B,P=this;if(p!=null&&p!==!!p)return Zt(p,1,Kn),E==null?E=a:Zt(E,0,8),b(new w(P),p,E);if(!(S=P.c))return null;if(B=S.length-1,$=B*It+1,B=S[B]){for(;B%10==0;B/=10,$--);for(B=S[0];B>=10;B/=10,$++);}return p&&P.e+1>$&&($=P.e+1),$},i.shiftedBy=function(p){return Zt(p,-9007199254740991,iy),this.times("1e"+p)},i.squareRoot=i.sqrt=function(){var p,E,S,$,B,P=this,W=P.c,L=P.s,q=P.e,J=s+4,U=new w("0.5");if(L!==1||!W||!W[0])return new w(!L||L<0&&(!W||W[0])?NaN:W?P:1/0);if(L=Math.sqrt(+j(P)),L==0||L==1/0?(E=or(W),(E.length+q)%2==0&&(E+="0"),L=Math.sqrt(+E),q=ur((q+1)/2)-(q<0||q%2),L==1/0?E="5e"+q:(E=L.toExponential(),E=E.slice(0,E.indexOf("e")+1)+q),S=new w(E)):S=new w(L+""),S.c[0]){for(q=S.e,L=q+J,L<3&&(L=0);;)if(B=S,S=U.times(B.plus(e(P,B,J,1))),or(B.c).slice(0,L)===(E=or(S.c)).slice(0,L))if(S.e<q&&--L,E=E.slice(L-3,L+1),E=="9999"||!$&&E=="4999"){if(!$&&(b(B,B.e+s+2,0),B.times(B).eq(P))){S=B;break}J+=4,L+=4,$=1}else{(!+E||!+E.slice(1)&&E.charAt(0)=="5")&&(b(S,S.e+s+2,1),p=!S.times(S).eq(P));break}}return b(S,S.e+s+1,a,p)},i.toExponential=function(p,E){return p!=null&&(Zt(p,0,Kn),p++),C(this,p,E,1)},i.toFixed=function(p,E){return p!=null&&(Zt(p,0,Kn),p=p+this.e+1),C(this,p,E)},i.toFormat=function(p,E,S){var $,B=this;if(S==null)p!=null&&E&&typeof E=="object"?(S=E,E=null):p&&typeof p=="object"?(S=p,p=E=null):S=A;else if(typeof S!="object")throw Error(jn+"Argument not an object: "+S);if($=B.toFixed(p,E),B.c){var P,W=$.split("."),L=+S.groupSize,q=+S.secondaryGroupSize,J=S.groupSeparator||"",U=W[0],ne=W[1],fe=B.s<0,le=fe?U.slice(1):U,ye=le.length;if(q&&(P=L,L=q,q=P,ye-=P),L>0&&ye>0){for(P=ye%L||L,U=le.substr(0,P);P<ye;P+=L)U+=J+le.substr(P,L);q>0&&(U+=J+le.slice(P)),fe&&(U="-"+U)}$=ne?U+(S.decimalSeparator||"")+((q=+S.fractionGroupSize)?ne.replace(new RegExp("\\d{"+q+"}\\B","g"),"$&"+(S.fractionGroupSeparator||"")):ne):U}return(S.prefix||"")+$+(S.suffix||"")},i.toFraction=function(p){var E,S,$,B,P,W,L,q,J,U,ne,fe,le=this,ye=le.c;if(p!=null&&(L=new w(p),!L.isInteger()&&(L.c||L.s!==1)||L.lt(o)))throw Error(jn+"Argument "+(L.isInteger()?"out of range: ":"not an integer: ")+j(L));if(!ye)return new w(le);for(E=new w(o),J=S=new w(o),$=q=new w(o),fe=or(ye),P=E.e=fe.length-le.e-1,E.c[0]=_h[(W=P%It)<0?It+W:W],p=!p||L.comparedTo(E)>0?P>0?E:J:L,W=u,u=1/0,L=new w(fe),q.c[0]=0;U=e(L,E,0,1),B=S.plus(U.times($)),B.comparedTo(p)!=1;)S=$,$=B,J=q.plus(U.times(B=J)),q=B,E=L.minus(U.times(B=E)),L=B;return B=e(p.minus(S),$,0,1),q=q.plus(B.times(J)),S=S.plus(B.times($)),q.s=J.s=le.s,P=P*2,ne=e(J,$,P,a).minus(le).abs().comparedTo(e(q,S,P,a).minus(le).abs())<1?[J,$]:[q,S],u=W,ne},i.toNumber=function(){return+j(this)},i.toPrecision=function(p,E){return p!=null&&Zt(p,1,Kn),C(this,p,E,2)},i.toString=function(p){var E,S=this,$=S.s,B=S.e;return B===null?$?(E="Infinity",$<0&&(E="-"+E)):E="NaN":(p==null?E=B<=l||B>=c?Mu(or(S.c),B):oi(or(S.c),B,"0"):p===10&&F?(S=b(new w(S),s+B+1,a),E=oi(or(S.c),S.e,"0")):(Zt(p,2,v.length,"Base"),E=t(oi(or(S.c),B,"0"),10,p,$,!0)),$<0&&S.c[0]&&(E="-"+E)),E},i.valueOf=i.toJSON=function(){return j(this)},i._isBigNumber=!0,i[Symbol.toStringTag]="BigNumber",i[Symbol.for("nodejs.util.inspect.custom")]=i.valueOf,n!=null&&w.set(n),w}function ur(n){var e=n|0;return n>0||n===e?e:e-1}function or(n){for(var e,t,r=1,i=n.length,o=n[0]+"";r<i;){for(e=n[r++]+"",t=It-e.length;t--;e="0"+e);o+=e}for(i=o.length;o.charCodeAt(--i)===48;);return o.slice(0,i+1||1)}function bo(n,e){var t,r,i=n.c,o=e.c,s=n.s,a=e.s,l=n.e,c=e.e;if(!s||!a)return null;if(t=i&&!i[0],r=o&&!o[0],t||r)return t?r?0:-a:s;if(s!=a)return s;if(t=s<0,r=l==c,!i||!o)return r?0:!i^t?1:-1;if(!r)return l>c^t?1:-1;for(a=(l=i.length)<(c=o.length)?l:c,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^t?1:-1;return l==c?0:l>c^t?1:-1}function Zt(n,e,t,r){if(n<e||n>t||n!==lr(n))throw Error(jn+(r||"Argument")+(typeof n=="number"?n<e||n>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(n))}function Tu(n){var e=n.c.length-1;return ur(n.e/It)==e&&n.c[e]%2!=0}function Mu(n,e){return(n.length>1?n.charAt(0)+"."+n.slice(1):n)+(e<0?"e":"e+")+e}function oi(n,e,t){var r,i;if(e<0){for(i=t+".";++e;i+=t);n=i+n}else if(r=n.length,++e>r){for(i=t,e-=r;--e;i+=t);n+=i}else e<r&&(n=n.slice(0,e)+"."+n.slice(e));return n}zx();const y2=100000n,w2=(n,e={})=>{const{style:t="decimal",compact:r=!1,fractionDigits:i,adaptiveDecimals:o=!1}=e,s=typeof n=="string"?Number(n):n,a=typeof s=="bigint"?s<0n?-s:s:Math.abs(s),l=r==="auto"?a>=y2:r,c=typeof s=="bigint"?Number(s):s,d=o&&c!==0&&Math.abs(c)<Math.pow(10,-(i??2)),u=new Intl.NumberFormat("en-US",{style:t,...t==="currency"&&{currency:"USD"},maximumFractionDigits:d?20:i??2,minimumFractionDigits:d?0:i??2});if(!l)return d?u.format(oy(c)):u.format(s);const m=[{threshold:1e12,suffix:"T",divisor:1e12},{threshold:1e9,suffix:"B",divisor:1e9},{threshold:1e6,suffix:"M",divisor:1e6},{threshold:1e3,suffix:"K",divisor:1e3}].find(h=>a>=h.threshold);if(m){const h=new Intl.NumberFormat("en-US",{style:t,...t==="currency"&&{currency:"USD"},maximumFractionDigits:i??1,minimumFractionDigits:i??1}),x=Number(s)/m.divisor;return h.format(x)+m.suffix}return d?u.format(oy(c)):u.format(s)};function oy(n){if(n===0)return 0;const e=n.toExponential().split("e"),t=parseInt(e[1]),r=Math.abs(t);return Number(n.toFixed(r))}function pr(n,e=5,t=5){return n?n.length<=e+t?n:`${n.slice(0,e)}...${n.slice(-t)}`:""}const x2={pay:"Payment",keyreg:"Key Registration",acfg:"Asset Config",axfer:"Asset Transfer",afrz:"Asset Freeze",appl:"Application Call",stpf:"State Proof",hb:"Heartbeat"};function v2(n){try{return Le.decodeUnsignedTransaction(n)}catch{try{return Le.decodeSignedTransaction(n).txn}catch{return null}}}function S2(n,e){return`${Number(n)/1e6} ALGO`}function b2(n){const e=[],t=[];let r=!1;for(let i=0;i<n.length;i++){const o=n[i];let s=null;if(o instanceof Uint8Array?s=v2(o):o&&typeof o=="object"&&"sender"in o&&"type"in o&&(s=o),s!=null&&s.rekeyTo&&(r="rekey"),!s)continue;const a=s.sender.toString(),l={index:i,type:s.type,typeLabel:x2[s.type]||s.type,sender:a,senderShort:pr(a,4,4)};if(s.rekeyTo){const c=s.rekeyTo.toString();l.rekeyTo=c,l.rekeyToShort=pr(c,4,4)}if(s.payment){const c=s.payment.receiver.toString();if(l.receiver=c,l.receiverShort=pr(c,4,4),l.amount=S2(s.payment.amount),s.payment.closeRemainderTo){const d=s.payment.closeRemainderTo.toString();l.closeRemainderTo=d,l.closeRemainderToShort=pr(d,4,4),r="closeTo"}}if(s.assetTransfer){const c=s.assetTransfer.receiver.toString();if(l.receiver=c,l.receiverShort=pr(c,4,4),l.rawAmount=s.assetTransfer.amount,l.amount=s.assetTransfer.amount.toString(),l.assetIndex=Number(s.assetTransfer.assetIndex),s.assetTransfer.closeRemainderTo){const d=s.assetTransfer.closeRemainderTo.toString();l.closeRemainderTo=d,l.closeRemainderToShort=pr(d,4,4),r="closeTo"}}if(s.assetConfig&&(l.assetIndex=Number(s.assetConfig.assetIndex)),s.assetFreeze){l.assetIndex=Number(s.assetFreeze.assetIndex);const c=s.assetFreeze.freezeAccount.toString();l.freezeTarget=c,l.freezeTargetShort=pr(c,4,4),l.isFreezing=s.assetFreeze.frozen}s.applicationCall&&(l.appIndex=Number(s.applicationCall.appIndex)),e.push(l),t.push(s)}return{transactions:t,decodedTransactions:e,dangerous:r}}const E2=`#pragma version 11
49
49
  #pragma typetrack false
50
50
 
51
51
  // smart_contracts/liquidevm/logicsig.algo.ts::program() -> uint64:
@@ -121,7 +121,7 @@ main_ternary_false@2:
121
121
  // const txnIdPayload = Global.groupSize === 1 ? Txn.txId : Global.groupId
122
122
  global GroupID
123
123
  b main_ternary_merge@3
124
- `;function A2(n){const e=new Uint8Array(n.length/2);for(let t=0;t<n.length;t+=2)e[t/2]=parseInt(n.substring(t,t+2),16);return e}const Hx=BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"),I2=Hx/2n;function k2(n){if(n.length!==65)throw new Error("Invalid signature length");const e=n.slice(32,64);let t=0n;for(let r=0;r<32;r++)t=t<<8n|BigInt(e[r]);if(t>I2){t=Hx-t;const r=new Uint8Array(65);r.set(n.slice(0,32),0);for(let o=31;o>=0;o--)r[32+o]=Number(t&0xffn),t>>=8n;const i=n[64];return r[64]=i===27?28:27,r}return n}const C2=1;function sy(n){const e=n.startsWith("0x")?n.slice(2):n,t=new Uint8Array(65);for(let o=0;o<65;o++)t[o]=parseInt(e.substring(o*2,o*2+2),16);const r=k2(t),i=new Uint8Array(66);return i[0]=C2,i.set(r,1),i}const F2=4160,D2={name:"Liquid Accounts",version:"1",chainId:F2},T2={AlgorandTransaction:[{name:"Transaction ID",type:"bytes32"}]};function M2(n){return{"Transaction ID":"0x"+Buffer.from(n).toString("hex")}}function ay(n){return{domain:D2,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"}],...T2},primaryType:"AlgorandTransaction",message:M2(n)}}class el{constructor({algorand:e}){dt(this,"algorand");dt(this,"compiledCache",new Map);this.algorand=e}static normalizeAddress(e){return e.startsWith("0x")?e.slice(2).toLowerCase():e.toLowerCase()}async getCompiled(e){const t=el.normalizeAddress(e);if(!this.compiledCache.has(t)){const r=await this.algorand.app.compileTealTemplate(E2,{TMPL_OWNER:A2(t)});this.compiledCache.set(t,r.compiledBase64ToBytes)}return this.compiledCache.get(t)}async getAddress({evmAddress:e}){const t=await this.getCompiled(e);return new Oe.LogicSigAccount(t,[]).address().toString()}static getSignPayload(e){return e.length>1?e[0].group:e[0].rawTxID()}async signTxn({evmAddress:e,txns:t,signMessage:r,signature:i}){const o=await this.getCompiled(e);let s;if(i)s=i;else if(r){const c=el.getSignPayload(t);s=await r(ay(c))}else throw new Error("Either signMessage or signature must be provided");const a=sy(s),l=new Oe.LogicSigAccount(o,[a]);return t.map(c=>Oe.signLogicSigTransactionObject(c,l).blob)}async getSigner({evmAddress:e,signMessage:t}){const r=await this.getCompiled(e);return{addr:new Oe.LogicSigAccount(r,[]).address().toString(),signer:async(a,l)=>{const c=el.getSignPayload(a),d=await t(ay(c)),u=sy(d),m=new Oe.LogicSigAccount(r,[u]);return l.map(h=>Oe.signLogicSigTransactionObject(a[h],m).blob)}}}}const Eo={PING:"LIQUID_WALLET_COMP_EXT_PING",PONG:"LIQUID_WALLET_COMP_EXT_PONG",ANNOUNCE:"LIQUID_WALLET_COMP_EXT_ANNOUNCE",SIGN_REQUEST:"LIQUID_WALLET_COMP_EXT_SIGN_REQUEST",SIGN_RESPONSE:"LIQUID_WALLET_COMP_EXT_SIGN_RESPONSE",SIGN_COMPLETE:"LIQUID_WALLET_COMP_EXT_SIGN_COMPLETE"},Ao={PAGE:"use-wallet-ui",CONTENT:"liquid-wallet-companion-content",POPUP:"liquid-wallet-companion-popup"};function R2(n){return{...n,rawAmount:n.rawAmount!==void 0?n.rawAmount.toString():void 0}}const cy="wallet-ui-theme-styles",B2=`
124
+ `;function A2(n){const e=new Uint8Array(n.length/2);for(let t=0;t<n.length;t+=2)e[t/2]=parseInt(n.substring(t,t+2),16);return e}const Hx=BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"),I2=Hx/2n;function k2(n){if(n.length!==65)throw new Error("Invalid signature length");const e=n.slice(32,64);let t=0n;for(let r=0;r<32;r++)t=t<<8n|BigInt(e[r]);if(t>I2){t=Hx-t;const r=new Uint8Array(65);r.set(n.slice(0,32),0);for(let o=31;o>=0;o--)r[32+o]=Number(t&0xffn),t>>=8n;const i=n[64];return r[64]=i===27?28:27,r}return n}const C2=1;function sy(n){const e=n.startsWith("0x")?n.slice(2):n,t=new Uint8Array(65);for(let o=0;o<65;o++)t[o]=parseInt(e.substring(o*2,o*2+2),16);const r=k2(t),i=new Uint8Array(66);return i[0]=C2,i.set(r,1),i}const F2=4160,D2={name:"Liquid Accounts",version:"1",chainId:F2},T2={AlgorandTransaction:[{name:"Transaction ID",type:"bytes32"}]};function M2(n){return{"Transaction ID":"0x"+Buffer.from(n).toString("hex")}}function ay(n){return{domain:D2,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"}],...T2},primaryType:"AlgorandTransaction",message:M2(n)}}class el{constructor({algorand:e}){dt(this,"algorand");dt(this,"compiledCache",new Map);this.algorand=e}static normalizeAddress(e){return e.startsWith("0x")?e.slice(2).toLowerCase():e.toLowerCase()}async getCompiled(e){const t=el.normalizeAddress(e);if(!this.compiledCache.has(t)){const r=await this.algorand.app.compileTealTemplate(E2,{TMPL_OWNER:A2(t)});this.compiledCache.set(t,r.compiledBase64ToBytes)}return this.compiledCache.get(t)}async getAddress({evmAddress:e}){const t=await this.getCompiled(e);return new Le.LogicSigAccount(t,[]).address().toString()}static getSignPayload(e){if(e.length===0)throw new Error("Cannot get sign payload from empty transaction group");return e.length>1?e[0].group:e[0].rawTxID()}async signTxn({evmAddress:e,txns:t,signMessage:r,signature:i}){const o=await this.getCompiled(e);let s;if(i)s=i;else if(r){const c=el.getSignPayload(t);s=await r(ay(c))}else throw new Error("Either signMessage or signature must be provided");const a=sy(s),l=new Le.LogicSigAccount(o,[a]);return t.map(c=>Le.signLogicSigTransactionObject(c,l).blob)}async getSigner({evmAddress:e,signMessage:t}){const r=await this.getCompiled(e);return{addr:new Le.LogicSigAccount(r,[]).address().toString(),signer:async(a,l)=>{const c=el.getSignPayload(a),d=await t(ay(c)),u=sy(d),m=new Le.LogicSigAccount(r,[u]);return l.map(h=>Le.signLogicSigTransactionObject(a[h],m).blob)}}}}const Eo={PING:"LIQUID_WALLET_COMP_EXT_PING",PONG:"LIQUID_WALLET_COMP_EXT_PONG",ANNOUNCE:"LIQUID_WALLET_COMP_EXT_ANNOUNCE",SIGN_REQUEST:"LIQUID_WALLET_COMP_EXT_SIGN_REQUEST",SIGN_RESPONSE:"LIQUID_WALLET_COMP_EXT_SIGN_RESPONSE",SIGN_COMPLETE:"LIQUID_WALLET_COMP_EXT_SIGN_COMPLETE"},Ao={PAGE:"use-wallet-ui",CONTENT:"liquid-wallet-companion-content",POPUP:"liquid-wallet-companion-popup"};function R2(n){return{...n,rawAmount:n.rawAmount!==void 0?n.rawAmount.toString():void 0}}const cy="wallet-ui-theme-styles",B2=`
125
125
  --wui-color-primary: #2d2df1;
126
126
  --wui-color-primary-hover: #2929d9;
127
127
  --wui-color-primary-text: #ffffff;
@@ -220,17 +220,17 @@ main_ternary_false@2:
220
220
  *
221
221
  * @author Feross Aboukhadijeh <https://feross.org>
222
222
  * @license MIT
223
- */var zy;function xM(){return zy||(zy=1,(function(n){const e=yM(),t=wM(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=w,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const R=new Uint8Array(1),g={foo:function(){return 42}};return Object.setPrototypeOf(g,Uint8Array.prototype),Object.setPrototypeOf(R,g),R.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(R){if(R>i)throw new RangeError('The value "'+R+'" is invalid for option "size"');const g=new Uint8Array(R);return Object.setPrototypeOf(g,a.prototype),g}function a(R,g,y){if(typeof R=="number"){if(typeof g=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(R)}return l(R,g,y)}a.poolSize=8192;function l(R,g,y){if(typeof R=="string")return m(R,g);if(ArrayBuffer.isView(R))return x(R);if(R==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof R);if(Ee(R,ArrayBuffer)||R&&Ee(R.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ee(R,SharedArrayBuffer)||R&&Ee(R.buffer,SharedArrayBuffer)))return A(R,g,y);if(typeof R=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const K=R.valueOf&&R.valueOf();if(K!=null&&K!==R)return a.from(K,g,y);const ie=v(R);if(ie)return ie;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof R[Symbol.toPrimitive]=="function")return a.from(R[Symbol.toPrimitive]("string"),g,y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof R)}a.from=function(R,g,y){return l(R,g,y)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function c(R){if(typeof R!="number")throw new TypeError('"size" argument must be of type number');if(R<0)throw new RangeError('The value "'+R+'" is invalid for option "size"')}function d(R,g,y){return c(R),R<=0?s(R):g!==void 0?typeof y=="string"?s(R).fill(g,y):s(R).fill(g):s(R)}a.alloc=function(R,g,y){return d(R,g,y)};function u(R){return c(R),s(R<0?0:F(R)|0)}a.allocUnsafe=function(R){return u(R)},a.allocUnsafeSlow=function(R){return u(R)};function m(R,g){if((typeof g!="string"||g==="")&&(g="utf8"),!a.isEncoding(g))throw new TypeError("Unknown encoding: "+g);const y=C(R,g)|0;let K=s(y);const ie=K.write(R,g);return ie!==y&&(K=K.slice(0,ie)),K}function h(R){const g=R.length<0?0:F(R.length)|0,y=s(g);for(let K=0;K<g;K+=1)y[K]=R[K]&255;return y}function x(R){if(Ee(R,Uint8Array)){const g=new Uint8Array(R);return A(g.buffer,g.byteOffset,g.byteLength)}return h(R)}function A(R,g,y){if(g<0||R.byteLength<g)throw new RangeError('"offset" is outside of buffer bounds');if(R.byteLength<g+(y||0))throw new RangeError('"length" is outside of buffer bounds');let K;return g===void 0&&y===void 0?K=new Uint8Array(R):y===void 0?K=new Uint8Array(R,g):K=new Uint8Array(R,g,y),Object.setPrototypeOf(K,a.prototype),K}function v(R){if(a.isBuffer(R)){const g=F(R.length)|0,y=s(g);return y.length===0||R.copy(y,0,0,g),y}if(R.length!==void 0)return typeof R.length!="number"||Fe(R.length)?s(0):h(R);if(R.type==="Buffer"&&Array.isArray(R.data))return h(R.data)}function F(R){if(R>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return R|0}function w(R){return+R!=R&&(R=0),a.alloc(+R)}a.isBuffer=function(g){return g!=null&&g._isBuffer===!0&&g!==a.prototype},a.compare=function(g,y){if(Ee(g,Uint8Array)&&(g=a.from(g,g.offset,g.byteLength)),Ee(y,Uint8Array)&&(y=a.from(y,y.offset,y.byteLength)),!a.isBuffer(g)||!a.isBuffer(y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===y)return 0;let K=g.length,ie=y.length;for(let ge=0,Se=Math.min(K,ie);ge<Se;++ge)if(g[ge]!==y[ge]){K=g[ge],ie=y[ge];break}return K<ie?-1:ie<K?1:0},a.isEncoding=function(g){switch(String(g).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(g,y){if(!Array.isArray(g))throw new TypeError('"list" argument must be an Array of Buffers');if(g.length===0)return a.alloc(0);let K;if(y===void 0)for(y=0,K=0;K<g.length;++K)y+=g[K].length;const ie=a.allocUnsafe(y);let ge=0;for(K=0;K<g.length;++K){let Se=g[K];if(Ee(Se,Uint8Array))ge+Se.length>ie.length?(a.isBuffer(Se)||(Se=a.from(Se)),Se.copy(ie,ge)):Uint8Array.prototype.set.call(ie,Se,ge);else if(a.isBuffer(Se))Se.copy(ie,ge);else throw new TypeError('"list" argument must be an Array of Buffers');ge+=Se.length}return ie};function C(R,g){if(a.isBuffer(R))return R.length;if(ArrayBuffer.isView(R)||Ee(R,ArrayBuffer))return R.byteLength;if(typeof R!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof R);const y=R.length,K=arguments.length>2&&arguments[2]===!0;if(!K&&y===0)return 0;let ie=!1;for(;;)switch(g){case"ascii":case"latin1":case"binary":return y;case"utf8":case"utf-8":return Q(R).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y*2;case"hex":return y>>>1;case"base64":return ae(R).length;default:if(ie)return K?-1:Q(R).length;g=(""+g).toLowerCase(),ie=!0}}a.byteLength=C;function M(R,g,y){let K=!1;if((g===void 0||g<0)&&(g=0),g>this.length||((y===void 0||y>this.length)&&(y=this.length),y<=0)||(y>>>=0,g>>>=0,y<=g))return"";for(R||(R="utf8");;)switch(R){case"hex":return ne(this,g,y);case"utf8":case"utf-8":return W(this,g,y);case"ascii":return J(this,g,y);case"latin1":case"binary":return U(this,g,y);case"base64":return P(this,g,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,g,y);default:if(K)throw new TypeError("Unknown encoding: "+R);R=(R+"").toLowerCase(),K=!0}}a.prototype._isBuffer=!0;function N(R,g,y){const K=R[g];R[g]=R[y],R[y]=K}a.prototype.swap16=function(){const g=this.length;if(g%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let y=0;y<g;y+=2)N(this,y,y+1);return this},a.prototype.swap32=function(){const g=this.length;if(g%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let y=0;y<g;y+=4)N(this,y,y+3),N(this,y+1,y+2);return this},a.prototype.swap64=function(){const g=this.length;if(g%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let y=0;y<g;y+=8)N(this,y,y+7),N(this,y+1,y+6),N(this,y+2,y+5),N(this,y+3,y+4);return this},a.prototype.toString=function(){const g=this.length;return g===0?"":arguments.length===0?W(this,0,g):M.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(g){if(!a.isBuffer(g))throw new TypeError("Argument must be a Buffer");return this===g?!0:a.compare(this,g)===0},a.prototype.inspect=function(){let g="";const y=n.INSPECT_MAX_BYTES;return g=this.toString("hex",0,y).replace(/(.{2})/g,"$1 ").trim(),this.length>y&&(g+=" ... "),"<Buffer "+g+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(g,y,K,ie,ge){if(Ee(g,Uint8Array)&&(g=a.from(g,g.offset,g.byteLength)),!a.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(y===void 0&&(y=0),K===void 0&&(K=g?g.length:0),ie===void 0&&(ie=0),ge===void 0&&(ge=this.length),y<0||K>g.length||ie<0||ge>this.length)throw new RangeError("out of range index");if(ie>=ge&&y>=K)return 0;if(ie>=ge)return-1;if(y>=K)return 1;if(y>>>=0,K>>>=0,ie>>>=0,ge>>>=0,this===g)return 0;let Se=ge-ie,Je=K-y;const ct=Math.min(Se,Je),it=this.slice(ie,ge),Ze=g.slice(y,K);for(let pt=0;pt<ct;++pt)if(it[pt]!==Ze[pt]){Se=it[pt],Je=Ze[pt];break}return Se<Je?-1:Je<Se?1:0};function b(R,g,y,K,ie){if(R.length===0)return-1;if(typeof y=="string"?(K=y,y=0):y>2147483647?y=2147483647:y<-2147483648&&(y=-2147483648),y=+y,Fe(y)&&(y=ie?0:R.length-1),y<0&&(y=R.length+y),y>=R.length){if(ie)return-1;y=R.length-1}else if(y<0)if(ie)y=0;else return-1;if(typeof g=="string"&&(g=a.from(g,K)),a.isBuffer(g))return g.length===0?-1:j(R,g,y,K,ie);if(typeof g=="number")return g=g&255,typeof Uint8Array.prototype.indexOf=="function"?ie?Uint8Array.prototype.indexOf.call(R,g,y):Uint8Array.prototype.lastIndexOf.call(R,g,y):j(R,[g],y,K,ie);throw new TypeError("val must be string, number or Buffer")}function j(R,g,y,K,ie){let ge=1,Se=R.length,Je=g.length;if(K!==void 0&&(K=String(K).toLowerCase(),K==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le")){if(R.length<2||g.length<2)return-1;ge=2,Se/=2,Je/=2,y/=2}function ct(Ze,pt){return ge===1?Ze[pt]:Ze.readUInt16BE(pt*ge)}let it;if(ie){let Ze=-1;for(it=y;it<Se;it++)if(ct(R,it)===ct(g,Ze===-1?0:it-Ze)){if(Ze===-1&&(Ze=it),it-Ze+1===Je)return Ze*ge}else Ze!==-1&&(it-=it-Ze),Ze=-1}else for(y+Je>Se&&(y=Se-Je),it=y;it>=0;it--){let Ze=!0;for(let pt=0;pt<Je;pt++)if(ct(R,it+pt)!==ct(g,pt)){Ze=!1;break}if(Ze)return it}return-1}a.prototype.includes=function(g,y,K){return this.indexOf(g,y,K)!==-1},a.prototype.indexOf=function(g,y,K){return b(this,g,y,K,!0)},a.prototype.lastIndexOf=function(g,y,K){return b(this,g,y,K,!1)};function p(R,g,y,K){y=Number(y)||0;const ie=R.length-y;K?(K=Number(K),K>ie&&(K=ie)):K=ie;const ge=g.length;K>ge/2&&(K=ge/2);let Se;for(Se=0;Se<K;++Se){const Je=parseInt(g.substr(Se*2,2),16);if(Fe(Je))return Se;R[y+Se]=Je}return Se}function E(R,g,y,K){return xe(Q(g,R.length-y),R,y,K)}function S(R,g,y,K){return xe(se(g),R,y,K)}function $(R,g,y,K){return xe(ae(g),R,y,K)}function B(R,g,y,K){return xe(ue(g,R.length-y),R,y,K)}a.prototype.write=function(g,y,K,ie){if(y===void 0)ie="utf8",K=this.length,y=0;else if(K===void 0&&typeof y=="string")ie=y,K=this.length,y=0;else if(isFinite(y))y=y>>>0,isFinite(K)?(K=K>>>0,ie===void 0&&(ie="utf8")):(ie=K,K=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ge=this.length-y;if((K===void 0||K>ge)&&(K=ge),g.length>0&&(K<0||y<0)||y>this.length)throw new RangeError("Attempt to write outside buffer bounds");ie||(ie="utf8");let Se=!1;for(;;)switch(ie){case"hex":return p(this,g,y,K);case"utf8":case"utf-8":return E(this,g,y,K);case"ascii":case"latin1":case"binary":return S(this,g,y,K);case"base64":return $(this,g,y,K);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,g,y,K);default:if(Se)throw new TypeError("Unknown encoding: "+ie);ie=(""+ie).toLowerCase(),Se=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(R,g,y){return g===0&&y===R.length?e.fromByteArray(R):e.fromByteArray(R.slice(g,y))}function W(R,g,y){y=Math.min(R.length,y);const K=[];let ie=g;for(;ie<y;){const ge=R[ie];let Se=null,Je=ge>239?4:ge>223?3:ge>191?2:1;if(ie+Je<=y){let ct,it,Ze,pt;switch(Je){case 1:ge<128&&(Se=ge);break;case 2:ct=R[ie+1],(ct&192)===128&&(pt=(ge&31)<<6|ct&63,pt>127&&(Se=pt));break;case 3:ct=R[ie+1],it=R[ie+2],(ct&192)===128&&(it&192)===128&&(pt=(ge&15)<<12|(ct&63)<<6|it&63,pt>2047&&(pt<55296||pt>57343)&&(Se=pt));break;case 4:ct=R[ie+1],it=R[ie+2],Ze=R[ie+3],(ct&192)===128&&(it&192)===128&&(Ze&192)===128&&(pt=(ge&15)<<18|(ct&63)<<12|(it&63)<<6|Ze&63,pt>65535&&pt<1114112&&(Se=pt))}}Se===null?(Se=65533,Je=1):Se>65535&&(Se-=65536,K.push(Se>>>10&1023|55296),Se=56320|Se&1023),K.push(Se),ie+=Je}return q(K)}const L=4096;function q(R){const g=R.length;if(g<=L)return String.fromCharCode.apply(String,R);let y="",K=0;for(;K<g;)y+=String.fromCharCode.apply(String,R.slice(K,K+=L));return y}function J(R,g,y){let K="";y=Math.min(R.length,y);for(let ie=g;ie<y;++ie)K+=String.fromCharCode(R[ie]&127);return K}function U(R,g,y){let K="";y=Math.min(R.length,y);for(let ie=g;ie<y;++ie)K+=String.fromCharCode(R[ie]);return K}function ne(R,g,y){const K=R.length;(!g||g<0)&&(g=0),(!y||y<0||y>K)&&(y=K);let ie="";for(let ge=g;ge<y;++ge)ie+=Ue[R[ge]];return ie}function fe(R,g,y){const K=R.slice(g,y);let ie="";for(let ge=0;ge<K.length-1;ge+=2)ie+=String.fromCharCode(K[ge]+K[ge+1]*256);return ie}a.prototype.slice=function(g,y){const K=this.length;g=~~g,y=y===void 0?K:~~y,g<0?(g+=K,g<0&&(g=0)):g>K&&(g=K),y<0?(y+=K,y<0&&(y=0)):y>K&&(y=K),y<g&&(y=g);const ie=this.subarray(g,y);return Object.setPrototypeOf(ie,a.prototype),ie};function le(R,g,y){if(R%1!==0||R<0)throw new RangeError("offset is not uint");if(R+g>y)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=this[g],ge=1,Se=0;for(;++Se<y&&(ge*=256);)ie+=this[g+Se]*ge;return ie},a.prototype.readUintBE=a.prototype.readUIntBE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=this[g+--y],ge=1;for(;y>0&&(ge*=256);)ie+=this[g+--y]*ge;return ie},a.prototype.readUint8=a.prototype.readUInt8=function(g,y){return g=g>>>0,y||le(g,1,this.length),this[g]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(g,y){return g=g>>>0,y||le(g,2,this.length),this[g]|this[g+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(g,y){return g=g>>>0,y||le(g,2,this.length),this[g]<<8|this[g+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(g,y){return g=g>>>0,y||le(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+this[g+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(g,y){return g=g>>>0,y||le(g,4,this.length),this[g]*16777216+(this[g+1]<<16|this[g+2]<<8|this[g+3])},a.prototype.readBigUInt64LE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=y+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24,ge=this[++g]+this[++g]*2**8+this[++g]*2**16+K*2**24;return BigInt(ie)+(BigInt(ge)<<BigInt(32))}),a.prototype.readBigUInt64BE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=y*2**24+this[++g]*2**16+this[++g]*2**8+this[++g],ge=this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+K;return(BigInt(ie)<<BigInt(32))+BigInt(ge)}),a.prototype.readIntLE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=this[g],ge=1,Se=0;for(;++Se<y&&(ge*=256);)ie+=this[g+Se]*ge;return ge*=128,ie>=ge&&(ie-=Math.pow(2,8*y)),ie},a.prototype.readIntBE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=y,ge=1,Se=this[g+--ie];for(;ie>0&&(ge*=256);)Se+=this[g+--ie]*ge;return ge*=128,Se>=ge&&(Se-=Math.pow(2,8*y)),Se},a.prototype.readInt8=function(g,y){return g=g>>>0,y||le(g,1,this.length),this[g]&128?(255-this[g]+1)*-1:this[g]},a.prototype.readInt16LE=function(g,y){g=g>>>0,y||le(g,2,this.length);const K=this[g]|this[g+1]<<8;return K&32768?K|4294901760:K},a.prototype.readInt16BE=function(g,y){g=g>>>0,y||le(g,2,this.length);const K=this[g+1]|this[g]<<8;return K&32768?K|4294901760:K},a.prototype.readInt32LE=function(g,y){return g=g>>>0,y||le(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},a.prototype.readInt32BE=function(g,y){return g=g>>>0,y||le(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},a.prototype.readBigInt64LE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=this[g+4]+this[g+5]*2**8+this[g+6]*2**16+(K<<24);return(BigInt(ie)<<BigInt(32))+BigInt(y+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24)}),a.prototype.readBigInt64BE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=(y<<24)+this[++g]*2**16+this[++g]*2**8+this[++g];return(BigInt(ie)<<BigInt(32))+BigInt(this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+K)}),a.prototype.readFloatLE=function(g,y){return g=g>>>0,y||le(g,4,this.length),t.read(this,g,!0,23,4)},a.prototype.readFloatBE=function(g,y){return g=g>>>0,y||le(g,4,this.length),t.read(this,g,!1,23,4)},a.prototype.readDoubleLE=function(g,y){return g=g>>>0,y||le(g,8,this.length),t.read(this,g,!0,52,8)},a.prototype.readDoubleBE=function(g,y){return g=g>>>0,y||le(g,8,this.length),t.read(this,g,!1,52,8)};function ye(R,g,y,K,ie,ge){if(!a.isBuffer(R))throw new TypeError('"buffer" argument must be a Buffer instance');if(g>ie||g<ge)throw new RangeError('"value" argument is out of bounds');if(y+K>R.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(g,y,K,ie){if(g=+g,y=y>>>0,K=K>>>0,!ie){const Je=Math.pow(2,8*K)-1;ye(this,g,y,K,Je,0)}let ge=1,Se=0;for(this[y]=g&255;++Se<K&&(ge*=256);)this[y+Se]=g/ge&255;return y+K},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(g,y,K,ie){if(g=+g,y=y>>>0,K=K>>>0,!ie){const Je=Math.pow(2,8*K)-1;ye(this,g,y,K,Je,0)}let ge=K-1,Se=1;for(this[y+ge]=g&255;--ge>=0&&(Se*=256);)this[y+ge]=g/Se&255;return y+K},a.prototype.writeUint8=a.prototype.writeUInt8=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,1,255,0),this[y]=g&255,y+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,65535,0),this[y]=g&255,this[y+1]=g>>>8,y+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,65535,0),this[y]=g>>>8,this[y+1]=g&255,y+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,4294967295,0),this[y+3]=g>>>24,this[y+2]=g>>>16,this[y+1]=g>>>8,this[y]=g&255,y+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,4294967295,0),this[y]=g>>>24,this[y+1]=g>>>16,this[y+2]=g>>>8,this[y+3]=g&255,y+4};function he(R,g,y,K,ie){X(g,K,ie,R,y,7);let ge=Number(g&BigInt(4294967295));R[y++]=ge,ge=ge>>8,R[y++]=ge,ge=ge>>8,R[y++]=ge,ge=ge>>8,R[y++]=ge;let Se=Number(g>>BigInt(32)&BigInt(4294967295));return R[y++]=Se,Se=Se>>8,R[y++]=Se,Se=Se>>8,R[y++]=Se,Se=Se>>8,R[y++]=Se,y}function de(R,g,y,K,ie){X(g,K,ie,R,y,7);let ge=Number(g&BigInt(4294967295));R[y+7]=ge,ge=ge>>8,R[y+6]=ge,ge=ge>>8,R[y+5]=ge,ge=ge>>8,R[y+4]=ge;let Se=Number(g>>BigInt(32)&BigInt(4294967295));return R[y+3]=Se,Se=Se>>8,R[y+2]=Se,Se=Se>>8,R[y+1]=Se,Se=Se>>8,R[y]=Se,y+8}a.prototype.writeBigUInt64LE=Ye(function(g,y=0){return he(this,g,y,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Ye(function(g,y=0){return de(this,g,y,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(g,y,K,ie){if(g=+g,y=y>>>0,!ie){const ct=Math.pow(2,8*K-1);ye(this,g,y,K,ct-1,-ct)}let ge=0,Se=1,Je=0;for(this[y]=g&255;++ge<K&&(Se*=256);)g<0&&Je===0&&this[y+ge-1]!==0&&(Je=1),this[y+ge]=(g/Se>>0)-Je&255;return y+K},a.prototype.writeIntBE=function(g,y,K,ie){if(g=+g,y=y>>>0,!ie){const ct=Math.pow(2,8*K-1);ye(this,g,y,K,ct-1,-ct)}let ge=K-1,Se=1,Je=0;for(this[y+ge]=g&255;--ge>=0&&(Se*=256);)g<0&&Je===0&&this[y+ge+1]!==0&&(Je=1),this[y+ge]=(g/Se>>0)-Je&255;return y+K},a.prototype.writeInt8=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,1,127,-128),g<0&&(g=255+g+1),this[y]=g&255,y+1},a.prototype.writeInt16LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,32767,-32768),this[y]=g&255,this[y+1]=g>>>8,y+2},a.prototype.writeInt16BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,32767,-32768),this[y]=g>>>8,this[y+1]=g&255,y+2},a.prototype.writeInt32LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,2147483647,-2147483648),this[y]=g&255,this[y+1]=g>>>8,this[y+2]=g>>>16,this[y+3]=g>>>24,y+4},a.prototype.writeInt32BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,2147483647,-2147483648),g<0&&(g=4294967295+g+1),this[y]=g>>>24,this[y+1]=g>>>16,this[y+2]=g>>>8,this[y+3]=g&255,y+4},a.prototype.writeBigInt64LE=Ye(function(g,y=0){return he(this,g,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Ye(function(g,y=0){return de(this,g,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function be(R,g,y,K,ie,ge){if(y+K>R.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("Index out of range")}function Ae(R,g,y,K,ie){return g=+g,y=y>>>0,ie||be(R,g,y,4),t.write(R,g,y,K,23,4),y+4}a.prototype.writeFloatLE=function(g,y,K){return Ae(this,g,y,!0,K)},a.prototype.writeFloatBE=function(g,y,K){return Ae(this,g,y,!1,K)};function _e(R,g,y,K,ie){return g=+g,y=y>>>0,ie||be(R,g,y,8),t.write(R,g,y,K,52,8),y+8}a.prototype.writeDoubleLE=function(g,y,K){return _e(this,g,y,!0,K)},a.prototype.writeDoubleBE=function(g,y,K){return _e(this,g,y,!1,K)},a.prototype.copy=function(g,y,K,ie){if(!a.isBuffer(g))throw new TypeError("argument should be a Buffer");if(K||(K=0),!ie&&ie!==0&&(ie=this.length),y>=g.length&&(y=g.length),y||(y=0),ie>0&&ie<K&&(ie=K),ie===K||g.length===0||this.length===0)return 0;if(y<0)throw new RangeError("targetStart out of bounds");if(K<0||K>=this.length)throw new RangeError("Index out of range");if(ie<0)throw new RangeError("sourceEnd out of bounds");ie>this.length&&(ie=this.length),g.length-y<ie-K&&(ie=g.length-y+K);const ge=ie-K;return this===g&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(y,K,ie):Uint8Array.prototype.set.call(g,this.subarray(K,ie),y),ge},a.prototype.fill=function(g,y,K,ie){if(typeof g=="string"){if(typeof y=="string"?(ie=y,y=0,K=this.length):typeof K=="string"&&(ie=K,K=this.length),ie!==void 0&&typeof ie!="string")throw new TypeError("encoding must be a string");if(typeof ie=="string"&&!a.isEncoding(ie))throw new TypeError("Unknown encoding: "+ie);if(g.length===1){const Se=g.charCodeAt(0);(ie==="utf8"&&Se<128||ie==="latin1")&&(g=Se)}}else typeof g=="number"?g=g&255:typeof g=="boolean"&&(g=Number(g));if(y<0||this.length<y||this.length<K)throw new RangeError("Out of range index");if(K<=y)return this;y=y>>>0,K=K===void 0?this.length:K>>>0,g||(g=0);let ge;if(typeof g=="number")for(ge=y;ge<K;++ge)this[ge]=g;else{const Se=a.isBuffer(g)?g:a.from(g,ie),Je=Se.length;if(Je===0)throw new TypeError('The value "'+g+'" is invalid for argument "value"');for(ge=0;ge<K-y;++ge)this[ge+y]=Se[ge%Je]}return this};const De={};function Te(R,g,y){De[R]=class extends y{constructor(){super(),Object.defineProperty(this,"message",{value:g.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${R}]`,delete this.name}get code(){return R}set code(ie){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ie,writable:!0})}toString(){return`${this.name} [${R}]: ${this.message}`}}}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(R){return R?`${R} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(R,g){return`The "${R}" argument must be of type number. Received type ${typeof g}`},TypeError),Te("ERR_OUT_OF_RANGE",function(R,g,y){let K=`The value of "${R}" is out of range.`,ie=y;return Number.isInteger(y)&&Math.abs(y)>2**32?ie=T(String(y)):typeof y=="bigint"&&(ie=String(y),(y>BigInt(2)**BigInt(32)||y<-(BigInt(2)**BigInt(32)))&&(ie=T(ie)),ie+="n"),K+=` It must be ${g}. Received ${ie}`,K},RangeError);function T(R){let g="",y=R.length;const K=R[0]==="-"?1:0;for(;y>=K+4;y-=3)g=`_${R.slice(y-3,y)}${g}`;return`${R.slice(0,y)}${g}`}function G(R,g,y){re(g,"offset"),(R[g]===void 0||R[g+y]===void 0)&&H(g,R.length-(y+1))}function X(R,g,y,K,ie,ge){if(R>y||R<g){const Se=typeof g=="bigint"?"n":"";let Je;throw g===0||g===BigInt(0)?Je=`>= 0${Se} and < 2${Se} ** ${(ge+1)*8}${Se}`:Je=`>= -(2${Se} ** ${(ge+1)*8-1}${Se}) and < 2 ** ${(ge+1)*8-1}${Se}`,new De.ERR_OUT_OF_RANGE("value",Je,R)}G(K,ie,ge)}function re(R,g){if(typeof R!="number")throw new De.ERR_INVALID_ARG_TYPE(g,"number",R)}function H(R,g,y){throw Math.floor(R)!==R?(re(R,y),new De.ERR_OUT_OF_RANGE("offset","an integer",R)):g<0?new De.ERR_BUFFER_OUT_OF_BOUNDS:new De.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${g}`,R)}const Z=/[^+/0-9A-Za-z-_]/g;function ce(R){if(R=R.split("=")[0],R=R.trim().replace(Z,""),R.length<2)return"";for(;R.length%4!==0;)R=R+"=";return R}function Q(R,g){g=g||1/0;let y;const K=R.length;let ie=null;const ge=[];for(let Se=0;Se<K;++Se){if(y=R.charCodeAt(Se),y>55295&&y<57344){if(!ie){if(y>56319){(g-=3)>-1&&ge.push(239,191,189);continue}else if(Se+1===K){(g-=3)>-1&&ge.push(239,191,189);continue}ie=y;continue}if(y<56320){(g-=3)>-1&&ge.push(239,191,189),ie=y;continue}y=(ie-55296<<10|y-56320)+65536}else ie&&(g-=3)>-1&&ge.push(239,191,189);if(ie=null,y<128){if((g-=1)<0)break;ge.push(y)}else if(y<2048){if((g-=2)<0)break;ge.push(y>>6|192,y&63|128)}else if(y<65536){if((g-=3)<0)break;ge.push(y>>12|224,y>>6&63|128,y&63|128)}else if(y<1114112){if((g-=4)<0)break;ge.push(y>>18|240,y>>12&63|128,y>>6&63|128,y&63|128)}else throw new Error("Invalid code point")}return ge}function se(R){const g=[];for(let y=0;y<R.length;++y)g.push(R.charCodeAt(y)&255);return g}function ue(R,g){let y,K,ie;const ge=[];for(let Se=0;Se<R.length&&!((g-=2)<0);++Se)y=R.charCodeAt(Se),K=y>>8,ie=y%256,ge.push(ie),ge.push(K);return ge}function ae(R){return e.toByteArray(ce(R))}function xe(R,g,y,K){let ie;for(ie=0;ie<K&&!(ie+y>=g.length||ie>=R.length);++ie)g[ie+y]=R[ie];return ie}function Ee(R,g){return R instanceof g||R!=null&&R.constructor!=null&&R.constructor.name!=null&&R.constructor.name===g.name}function Fe(R){return R!==R}const Ue=(function(){const R="0123456789abcdef",g=new Array(256);for(let y=0;y<16;++y){const K=y*16;for(let ie=0;ie<16;++ie)g[K+ie]=R[y]+R[ie]}return g})();function Ye(R){return typeof BigInt>"u"?vt:R}function vt(){throw new Error("BigInt not supported")}})(Zh)),Zh}var nn=xM();class vM{constructor(){this.listenerWrapperMap=new WeakMap,this.listenerMap={},this.off=this.removeListener}async emitAsync(e,t){for(const r of this.listenerMap[e]??[])await r(t,e)}on(e,t){return this.listenerMap[e]||(this.listenerMap[e]=[]),this.listenerMap[e].push(t),this}once(e,t){const r=async(i,o)=>{try{return await t(i,o)}finally{this.removeListener(o,r)}};return this.listenerWrapperMap.set(t,r),this.on(e,r)}removeListener(e,t){var i,o;const r=this.listenerWrapperMap.get(t);return r?(this.listenerWrapperMap.delete(t),((i=this.listenerMap[e])==null?void 0:i.indexOf(r))!==-1&&this.listenerMap[e].splice(this.listenerMap[e].indexOf(r),1)):((o=this.listenerMap[e])==null?void 0:o.indexOf(t))!==-1&&this.listenerMap[e].splice(this.listenerMap[e].indexOf(t),1),this}}const SM={error:console.error,warn:console.warn,info:console.info,verbose:()=>{},debug:console.debug},bM={error:function(n,...e){},warn:function(n,...e){},info:function(n,...e){},verbose:function(n,...e){},debug:function(n,...e){}};class EM{get populateAppCallResources(){return this.config.populateAppCallResources}get logger(){return this.config.logger}get debug(){return this.config.debug}get projectRoot(){return this.config.projectRoot}get traceAll(){return this.config.traceAll}get traceBufferSizeMb(){return this.config.traceBufferSizeMb}get maxSearchDepth(){return this.config.maxSearchDepth}get events(){return this.config.events}getLogger(e){return e?bM:this.logger}withDebug(e){const t=this.config.debug;try{this.config.debug=!0,e()}finally{this.config.debug=t}}constructor(){this.config={logger:SM,debug:!1,projectRoot:null,traceAll:!1,traceBufferSizeMb:256,maxSearchDepth:10,populateAppCallResources:!0,events:new vM}}configure(e){this.config={...this.config,...e}}}const ft=new EM,Xu="TMPL_UPDATABLE",Zu="TMPL_DELETABLE",$u="ALGOKIT_DEPLOYER",AM=2048;var Hs;(function(n){n[n.Fail=0]="Fail",n[n.UpdateApp=1]="UpdateApp",n[n.ReplaceApp=2]="ReplaceApp",n[n.AppendApp=3]="AppendApp"})(Hs||(Hs={}));var Cd;(function(n){n[n.Fail=0]="Fail",n[n.ReplaceApp=1]="ReplaceApp",n[n.AppendApp=2]="AppendApp"})(Cd||(Cd={}));const IM=n=>{if(typeof n=="number")return n;if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Hy(`Cannot convert ${n} to a Number as it is larger than the maximum safe integer the Number type can hold.`);if(n<BigInt(Number.MIN_SAFE_INTEGER))throw new Hy(`Cannot convert ${n} to a Number as it is smaller than the minimum safe integer the Number type can hold.`);return Number(n)};class Hy extends Error{}const kM=(n,e,t)=>{if(n>e){const r=n-e;return BigInt(Math.max(Number(r),Number(t)))}else return null};function*Yy(n,e){for(let t=0;t<n.length;t+=e)yield n.slice(t,t+e)}const CM=n=>{const e=new Map,t=function(r){return(e.has(r)||e.set(r,n.call(this,r)))&&e.get(r)};return t.cache=e,t},Ky=(n,e)=>{if(e.length>n.length)return!1;for(let t=0;t<e.length;t++)if(n[t]!==e[t])return!1;return!0},Xv=(n,e)=>{if(typeof e=="bigint")try{return IM(e)}catch{return e.toString()}return e},ea=(n,e=Xv,t)=>JSON.stringify(n,e,t),jp=(n,e)=>Math.floor((n.length+((e==null?void 0:e.length)??0)-1)/AM);function Ic(n,e){if(!e.toString().includes("byte")||n instanceof Uint8Array)return n;if((e instanceof Rs||e instanceof Bs)&&e.childType instanceof fu&&Array.isArray(n))return new Uint8Array(n);if((e instanceof Rs||e instanceof Bs)&&Array.isArray(n)){const t=[];for(let r=0;r<n.length;r++)t.push(Ic(n[r],e.childType));return t}if(e instanceof Mr&&Array.isArray(n)){const t=[];for(let r=0;r<n.length&&r<e.childTypes.length;r++)t.push(Ic(n[r],e.childTypes[r]));return t}return n}const Xl=(n,e)=>typeof n=="bigint"?e instanceof Qi&&e.bitSize<53?Number(n):n:Array.isArray(n)&&(e instanceof Rs||e instanceof Bs)?n.map(t=>Xl(t,e.childType)):Array.isArray(n)&&e instanceof Mr?n.map((t,r)=>Xl(t,e.childTypes[r])):n;var Ps;(function(n){n.TxnGroupSimulated="TxnGroupSimulated",n.AppCompiled="AppCompiled"})(Ps||(Ps={}));var Jh=Oe.modelsv2;async function qy(n,e,t){const i=n.buildGroup().map(a=>Oe.encodeUnsignedSimulateTransaction(a.txn)),o=new Jh.SimulateRequest({allowEmptySignatures:!0,fixSigners:!0,allowMoreLogging:!0,execTraceConfig:new Jh.SimulateTraceConfig({enable:!0,scratchChange:!0,stackChange:!0,stateChange:!0}),txnGroups:[new Jh.SimulateRequestTransactionGroup({txns:i.map(a=>Xt(a,jt))})]});return await e.simulateTransactions(o).do()}const Io=8,Yc=8;function FM(n){if(!(n===null||typeof n>"u"))if(typeof n=="object"&&n.constructor===Uint8Array){if(n.length===0||n.length>32)throw new Error(`Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${n.length}`);if(n.length===32)return n;const e=new Uint8Array(32);return e.set(n,0),e}else if(typeof n=="string"){if(n.length===0||n.length>32)throw new Error(`Received invalid lease; expected something with length between 1 and 32, but received '${n}' with length ${n.length}`);const e=new TextEncoder,t=new Uint8Array(32);return t.set(e.encode(n),0),t}else throw new Error(`Unknown lease type received of ${typeof n}`)}async function DM(n,e,t,r){var x,A,v,F,w,C;const i=new Oe.modelsv2.SimulateRequest({txnGroups:[],allowUnnamedResources:!0,allowEmptySignatures:!0,fixSigners:!0}),o=Oe.makeEmptyTransactionSigner(),s=n.clone(),a=[];if(s.transactions.forEach((M,N)=>{var b,j;if(M.signer=o,t.coverAppCallInnerTransactionFees&&M.txn.type===Bt.appl){if(!(r!=null&&r.suggestedParams))throw Error("Please provide additionalAtcContext.suggestedParams when coverAppCallInnerTransactionFees is enabled");const p=(j=(b=r==null?void 0:r.maxFees)==null?void 0:b.get(N))==null?void 0:j.microAlgo;p===void 0?a.push(N):M.txn.fee=p}}),t.coverAppCallInnerTransactionFees&&a.length>0)throw Error(`Please provide a maxFee for each app call transaction when coverAppCallInnerTransactionFees is enabled. Required for transaction ${a.join(", ")}`);const l=BigInt((r==null?void 0:r.suggestedParams.fee)??0n),c=BigInt((r==null?void 0:r.suggestedParams.minFee)??1000n),u=(await s.simulate(e,i)).simulateResponse.txnGroups[0];if(u.failureMessage)throw t.coverAppCallInnerTransactionFees&&u.failureMessage.match(/fee too small/)?Error("Fees were too small to resolve execution info via simulate. You may need to increase an app call transaction maxFee."):Error(`Error resolving execution info via simulate in transaction ${u.failedAt}: ${u.failureMessage}`);const m=u.unnamedResourcesAccessed,h=(M,N)=>M<N?-1:M>N?1:0;return m&&((x=m.accounts)==null||x.sort((M,N)=>h(M.toString(),N.toString())),(A=m.assets)==null||A.sort(h),(v=m.apps)==null||v.sort(h),(F=m.boxes)==null||F.sort((M,N)=>{const b=`${M.app}-${M.name}`,j=`${N.app}-${N.name}`;return h(b,j)}),(w=m.appLocals)==null||w.sort((M,N)=>{const b=`${M.app}-${M.account}`,j=`${N.app}-${N.account}`;return h(b,j)}),(C=m.assetHoldings)==null||C.sort((M,N)=>{const b=`${M.asset}-${M.account}`,j=`${N.asset}-${N.account}`;return h(b,j)})),{groupUnnamedResourcesAccessed:t.populateAppCallResources?m:void 0,txns:u.txnResults.map((M,N)=>{const b=n.transactions[N].txn;let j=0n;if(t.coverAppCallInnerTransactionFees){const p=l*BigInt(b.toByte().length+75),S=(p<c?c:p)-b.fee;if(b.type===Bt.appl){const $=(P,W=0n)=>P.reverse().reduce((L,q)=>{const J=(q.innerTxns&&q.innerTxns.length>0?$(q.innerTxns,L):L)+(c-q.txn.txn.fee);return J<0n?0n:J},W);j=$(M.txnResult.innerTxns??[])+S}else j=S}return{unnamedResourcesAccessed:t.populateAppCallResources?M.unnamedResourcesAccessed:void 0,requiredFeeDelta:j}})}}async function TM(n,e,t,r){var u,m,h,x,A,v;const i=await DM(n,e,t,r),o=n.buildGroup(),[s,a]=t.coverAppCallInnerTransactionFees?i.txns.map((F,w)=>{var p,E;const C=w,M=o[C].txn,N=(E=(p=r==null?void 0:r.maxFees)==null?void 0:p.get(w))==null?void 0:E.microAlgo,b=N!==void 0&&N===M.fee,j=F.requiredFeeDelta>0n&&(b||M.type!==Oe.TransactionType.appl)?1000n:1n;return{...F,groupIndex:C,surplusFeePriorityLevel:F.requiredFeeDelta>0n?F.requiredFeeDelta*j:-1n}}).sort((F,w)=>F.surplusFeePriorityLevel>w.surplusFeePriorityLevel?-1:F.surplusFeePriorityLevel<w.surplusFeePriorityLevel?1:0).reduce((F,{groupIndex:w,requiredFeeDelta:C})=>{if(C>0n){let M=F[0];const N=F[1],b=C-M;return b<=0n?M=-b:(N.set(w,b),M=0n),[M,N]}return F},[i.txns.reduce((F,{requiredFeeDelta:w})=>w<0n?F+-w:F,0n),new Map]):[0n,new Map],l=F=>{var w,C;return F.type===Bt.appl&&((w=F.applicationCall)==null?void 0:w.access)&&((C=F.applicationCall)==null?void 0:C.access.length)>0},c=[];if(i.txns.forEach(({unnamedResourcesAccessed:F},w)=>{var C,M,N,b,j,p,E,S,$,B,P,W,L,q,J,U,ne,fe;if(t.populateAppCallResources&&o[w].txn.type===Bt.appl){const le=l(o[w].txn);if(le&&(F||i.groupUnnamedResourcesAccessed)&&c.push(w),F&&!le){if(F.boxes||F.extraBoxRefs)throw Error("Unexpected boxes at the transaction level");if(F.appLocals)throw Error("Unexpected app local at the transaction level");if(F.assetHoldings)throw Error("Unexpected asset holding at the transaction level");o[w].txn.applicationCall={...o[w].txn.applicationCall,accounts:[...((M=(C=o[w].txn)==null?void 0:C.applicationCall)==null?void 0:M.accounts)??[],...F.accounts??[]],foreignApps:[...((b=(N=o[w].txn)==null?void 0:N.applicationCall)==null?void 0:b.foreignApps)??[],...F.apps??[]],foreignAssets:[...((p=(j=o[w].txn)==null?void 0:j.applicationCall)==null?void 0:p.foreignAssets)??[],...F.assets??[]],boxes:[...((S=(E=o[w].txn)==null?void 0:E.applicationCall)==null?void 0:S.boxes)??[],...F.boxes??[]]};const ye=((B=($=o[w].txn.applicationCall)==null?void 0:$.accounts)==null?void 0:B.length)??0;if(ye>Yc)throw Error(`Account reference limit of ${Yc} exceeded in transaction ${w}`);const he=((W=(P=o[w].txn.applicationCall)==null?void 0:P.foreignAssets)==null?void 0:W.length)??0,de=((q=(L=o[w].txn.applicationCall)==null?void 0:L.foreignApps)==null?void 0:q.length)??0,be=((U=(J=o[w].txn.applicationCall)==null?void 0:J.boxes)==null?void 0:U.length)??0;if(ye+he+de+be>Io)throw Error(`Resource reference limit of ${Io} exceeded in transaction ${w}`)}}if(t.coverAppCallInnerTransactionFees){const le=a.get(w);if(le!==void 0){if(o[w].txn.type!==Oe.TransactionType.appl)throw Error(`An additional fee of ${le} µALGO is required for non app call transaction ${w}`);const ye=o[w].txn.fee+le,he=(fe=(ne=r==null?void 0:r.maxFees)==null?void 0:ne.get(w))==null?void 0:fe.microAlgo;if(he===void 0||ye>he)throw Error(`Calculated transaction fee ${ye} µALGO is greater than max of ${he??"undefined"} for transaction ${w}`);o[w].txn.fee=ye}}}),t.populateAppCallResources){c.length>0&&ft.logger.warn(`Resource population will be skipped for transaction indexes ${c.join(", ")} as they use access references.`);const F=(C,M,N)=>{var p,E,S,$,B,P,W,L,q,J,U,ne,fe,le,ye,he,de,be,Ae,_e,De,Te,T,G,X,re;const b=H=>{var ue,ae,xe,Ee,Fe,Ue,Ye,vt;if(H.txn.type!==Oe.TransactionType.appl||l(H.txn))return!1;const Z=((ae=(ue=H.txn.applicationCall)==null?void 0:ue.accounts)==null?void 0:ae.length)??0,ce=((Ee=(xe=H.txn.applicationCall)==null?void 0:xe.foreignAssets)==null?void 0:Ee.length)??0,Q=((Ue=(Fe=H.txn.applicationCall)==null?void 0:Fe.foreignApps)==null?void 0:Ue.length)??0,se=((vt=(Ye=H.txn.applicationCall)==null?void 0:Ye.boxes)==null?void 0:vt.length)??0;return Z+ce+Q+se<Io};if(N==="assetHolding"||N==="appLocal"){const{account:H}=M;let Z=C.findIndex(ce=>{var Q,se,ue,ae;return b(ce)?((se=(Q=ce.txn.applicationCall)==null?void 0:Q.accounts)==null?void 0:se.map(xe=>xe.toString()).includes(H.toString()))||((ae=(ue=ce.txn.applicationCall)==null?void 0:ue.foreignApps)==null?void 0:ae.map(xe=>Oe.getApplicationAddress(xe).toString()).includes(H.toString()))||Object.values(ce.txn).some(xe=>{var Ee;return(Ee=yi(xe,(Fe,Ue)=>Ue instanceof ze?Ue.toString():Ue))==null?void 0:Ee.includes(H.toString())}):!1});if(Z>-1){if(N==="assetHolding"){const{asset:ce}=M;C[Z].txn.applicationCall={...C[Z].txn.applicationCall,foreignAssets:[...((E=(p=C[Z].txn)==null?void 0:p.applicationCall)==null?void 0:E.foreignAssets)??[],ce]}}else{const{app:ce}=M;C[Z].txn.applicationCall={...C[Z].txn.applicationCall,foreignApps:[...(($=(S=C[Z].txn)==null?void 0:S.applicationCall)==null?void 0:$.foreignApps)??[],ce]}}return}if(Z=C.findIndex(ce=>{var Q,se,ue,ae,xe,Ee,Fe;if(!b(ce)||(((se=(Q=ce.txn.applicationCall)==null?void 0:Q.accounts)==null?void 0:se.length)??0)>=Yc)return!1;if(N==="assetHolding"){const{asset:Ue}=M;return(ae=(ue=ce.txn.applicationCall)==null?void 0:ue.foreignAssets)==null?void 0:ae.includes(Ue)}else{const{app:Ue}=M;return((Ee=(xe=ce.txn.applicationCall)==null?void 0:xe.foreignApps)==null?void 0:Ee.includes(Ue))||((Fe=ce.txn.applicationCall)==null?void 0:Fe.appIndex)===Ue}}),Z>-1){const{account:ce}=M;C[Z].txn.applicationCall={...C[Z].txn.applicationCall,accounts:[...((P=(B=C[Z].txn)==null?void 0:B.applicationCall)==null?void 0:P.accounts)??[],ce]};return}}if(N==="box"){const{app:H,name:Z}=M,ce=C.findIndex(Q=>{var se,ue,ae;return b(Q)?((ue=(se=Q.txn.applicationCall)==null?void 0:se.foreignApps)==null?void 0:ue.includes(H))||((ae=Q.txn.applicationCall)==null?void 0:ae.appIndex)===H:!1});if(ce>-1){C[ce].txn.applicationCall={...C[ce].txn.applicationCall,boxes:[...((L=(W=C[ce].txn)==null?void 0:W.applicationCall)==null?void 0:L.boxes)??[],{appIndex:H,name:Z}]};return}}const j=C.findIndex(H=>{var ue,ae,xe,Ee,Fe,Ue,Ye,vt;if(H.txn.type!==Oe.TransactionType.appl||l(H.txn))return!1;const Z=((ae=(ue=H.txn.applicationCall)==null?void 0:ue.accounts)==null?void 0:ae.length)??0,ce=((Ee=(xe=H.txn.applicationCall)==null?void 0:xe.foreignAssets)==null?void 0:Ee.length)??0,Q=((Ue=(Fe=H.txn.applicationCall)==null?void 0:Fe.foreignApps)==null?void 0:Ue.length)??0,se=((vt=(Ye=H.txn.applicationCall)==null?void 0:Ye.boxes)==null?void 0:vt.length)??0;return N==="account"?Z<Yc&&Z+ce+Q+se<Io:N==="assetHolding"||N==="appLocal"?Z+ce+Q+se<Io-1&&Z<Yc:N==="box"&&BigInt(M.app)!==BigInt(0)?Z+ce+Q+se<Io-1:Z+ce+Q+se<Io});if(j===-1)throw Error("No more transactions below reference limit. Add another app call to the group.");if(N==="account")C[j].txn.applicationCall={...C[j].txn.applicationCall,accounts:[...((J=(q=C[j].txn)==null?void 0:q.applicationCall)==null?void 0:J.accounts)??[],M]};else if(N==="app")C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignApps:[...((ne=(U=C[j].txn)==null?void 0:U.applicationCall)==null?void 0:ne.foreignApps)??[],typeof M=="bigint"?M:BigInt(M)]};else if(N==="box"){const{app:H,name:Z}=M;C[j].txn.applicationCall={...C[j].txn.applicationCall,boxes:[...((le=(fe=C[j].txn)==null?void 0:fe.applicationCall)==null?void 0:le.boxes)??[],{appIndex:H,name:Z}]},H.toString()!=="0"&&(C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignApps:[...((he=(ye=C[j].txn)==null?void 0:ye.applicationCall)==null?void 0:he.foreignApps)??[],H]})}else if(N==="assetHolding"){const{asset:H,account:Z}=M;C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignAssets:[...((be=(de=C[j].txn)==null?void 0:de.applicationCall)==null?void 0:be.foreignAssets)??[],H],accounts:[...((_e=(Ae=C[j].txn)==null?void 0:Ae.applicationCall)==null?void 0:_e.accounts)??[],Z]}}else if(N==="appLocal"){const{app:H,account:Z}=M;C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignApps:[...((Te=(De=C[j].txn)==null?void 0:De.applicationCall)==null?void 0:Te.foreignApps)??[],H],accounts:[...((G=(T=C[j].txn)==null?void 0:T.applicationCall)==null?void 0:G.accounts)??[],Z]}}else N==="asset"&&(C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignAssets:[...((re=(X=C[j].txn)==null?void 0:X.applicationCall)==null?void 0:re.foreignAssets)??[],typeof M=="bigint"?M:BigInt(M)]})},w=i.groupUnnamedResourcesAccessed;if(w&&((u=w.appLocals)==null||u.forEach(C=>{var M,N;F(o,C,"appLocal"),w.accounts=(M=w.accounts)==null?void 0:M.filter(b=>b!==C.account),w.apps=(N=w.apps)==null?void 0:N.filter(b=>BigInt(b)!==BigInt(C.app))}),(m=w.assetHoldings)==null||m.forEach(C=>{var M,N;F(o,C,"assetHolding"),w.accounts=(M=w.accounts)==null?void 0:M.filter(b=>b!==C.account),w.assets=(N=w.assets)==null?void 0:N.filter(b=>BigInt(b)!==BigInt(C.asset))}),(h=w.accounts)==null||h.forEach(C=>{F(o,C,"account")}),(x=w.boxes)==null||x.forEach(C=>{var M;F(o,C,"box"),w.apps=(M=w.apps)==null?void 0:M.filter(N=>BigInt(N)!==BigInt(C.app))}),(A=w.assets)==null||A.forEach(C=>{F(o,C,"asset")}),(v=w.apps)==null||v.forEach(C=>{F(o,C,"app")}),w.extraBoxRefs))for(let C=0;C<w.extraBoxRefs;C+=1){const M=new Oe.modelsv2.BoxReference({app:0,name:new Uint8Array(0)});F(o,M,"box")}}const d=new Oe.AtomicTransactionComposer;return o.forEach(F=>{F.txn.group=void 0,d.addTransaction(F)}),d.methodCalls=n.methodCalls,d}const MM=async function(n,e){var a,l;const{atc:t,sendParams:r,additionalAtcContext:i,...o}=n;let s;s=t;try{const c=s.buildGroup(),d=(o==null?void 0:o.populateAppCallResources)??(r==null?void 0:r.populateAppCallResources)??ft.populateAppCallResources,u=o==null?void 0:o.coverAppCallInnerTransactionFees;(d||u)&&c.map(F=>F.txn.type).includes(Oe.TransactionType.appl)&&(s=await TM(t,e,{populateAppCallResources:d,coverAppCallInnerTransactionFees:u},i));const m=s.buildGroup().map(F=>F.txn);let h;if(m.length>1&&(h=m[0].group?nn.Buffer.from(m[0].group).toString("base64"):"",ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).verbose(`Sending group of ${m.length} transactions (${h})`,{transactionsToSend:m}),ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).debug(`Transaction IDs (${h})`,m.map(F=>F.txID()))),ft.debug&&ft.traceAll){const F=await qy(s,e);await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:F})}const x=await s.execute(e,(o==null?void 0:o.maxRoundsToWaitForConfirmation)??(r==null?void 0:r.maxRoundsToWaitForConfirmation)??5);m.length>1?ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).verbose(`Group transaction (${h}) sent with ${m.length} transactions`):ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).verbose(`Sent transaction ID ${m[0].txID()} ${m[0].type} from ${m[0].sender.toString()}`);let A;r!=null&&r.skipWaiting||(A=await Promise.all(m.map(async F=>await e.pendingTransactionInformation(F.txID()).do())));const v=[...s.methodCalls.values()];return{groupId:h,confirmations:A,txIds:m.map(F=>F.txID()),transactions:m,returns:x.methodResults.map((F,w)=>Bg(F,v[w].returns.type))}}catch(c){const d=new Error(typeof c=="object"?c==null?void 0:c.message:"Received error executing Atomic Transaction Composer");if(d.cause=c,typeof c=="object"&&((a=c.response)==null||delete a.headers,d.response=c.response,c.response&&"body"in c.response&&delete d.response.body,d.name=c.name),ft.debug&&typeof c=="object"){d.traces=[],ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).error("Received error executing Atomic Transaction Composer and debug flag enabled; attempting simulation to get more information",d);const u=await qy(s,e);if(ft.debug&&!ft.traceAll&&await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:u}),u&&u.txnGroups[0].failedAt)for(const m of u.txnGroups[0].txnResults)d.traces.push({trace:(l=m.execTrace)==null?void 0:l.toEncodingData(),appBudget:m.appBudgetConsumed,logicSigBudget:m.logicSigBudgetConsumed,logs:m.txnResult.logs,message:u.txnGroups[0].failureMessage})}else ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).error("Received error executing Atomic Transaction Composer, for more information enable the debug flag",d);throw d.sentTransactions=s.buildGroup().map(u=>u.txn),d}};function Bg(n,e){if(n.decodeError)return{decodeError:n.decodeError};const t=Ic(n.returnValue!==void 0&&n.method.returns.type!=="void"?Xl(n.returnValue,n.method.returns.type):n.returnValue,e);return{method:n.method,rawReturnValue:n.rawReturnValue,decodeError:void 0,returnValue:t}}class Qn{constructor(e){this._compilationResults={},this._algod=e}async compileTeal(e){if(this._compilationResults[e])return this._compilationResults[e];const t=await this._algod.compile(e).sourcemap(!0).do(),r={teal:e,compiled:t.result,compiledHash:t.hash,compiledBase64ToBytes:new Uint8Array(Buffer.from(t.result,"base64")),sourceMap:new Dx(JSON.parse(Oe.encodeJSON(t.sourcemap)))};return this._compilationResults[e]=r,r}async compileTealTemplate(e,t,r){let i=Qn.stripTealComments(e);return i=Qn.replaceTealTemplateParams(i,t),r&&(i=Qn.replaceTealTemplateDeployTimeControlParams(i,r)),await this.compileTeal(i)}getCompilationResult(e){return this._compilationResults[e]}async getById(e){var r,i,o,s;const t=await this._algod.getApplicationByID(Number(e)).do();return{appId:BigInt(t.id),appAddress:Oe.getApplicationAddress(t.id),approvalProgram:t.params.approvalProgram,clearStateProgram:t.params.clearStateProgram,creator:t.params.creator,localInts:Number(((r=t.params.localStateSchema)==null?void 0:r.numUint)??0),localByteSlices:Number(((i=t.params.localStateSchema)==null?void 0:i.numByteSlice)??0),globalInts:Number(((o=t.params.globalStateSchema)==null?void 0:o.numUint)??0),globalByteSlices:Number(((s=t.params.globalStateSchema)==null?void 0:s.numByteSlice)??0),extraProgramPages:Number(t.params.extraProgramPages??0),globalState:Qn.decodeAppState(t.params.globalState??[]),version:t.params.version}}async getGlobalState(e){return(await this.getById(e)).globalState}async getLocalState(e,t){var i;const r=await this._algod.accountApplicationInformation(t,e).do();if(!((i=r.appLocalState)!=null&&i.keyValue))throw new Error("Couldn't find local state");return Qn.decodeAppState(r.appLocalState.keyValue)}async getBoxNames(e){return(await this._algod.getApplicationBoxes(e).do()).boxes.map(r=>({nameRaw:r.name,nameBase64:Buffer.from(r.name).toString("base64"),name:Buffer.from(r.name).toString("utf-8")}))}async getBoxValue(e,t){const r=typeof t=="object"&&"nameRaw"in t?t.nameRaw:t,i=Qn.getBoxReference(r).name;return(await this._algod.getApplicationBoxByName(Number(e),i).do()).value}async getBoxValues(e,t){return await Promise.all(t.map(async r=>await this.getBoxValue(e,r)))}async getBoxValueFromABIType(e){const{appId:t,boxName:r,type:i}=e,o=await this.getBoxValue(t,r);return i.decode(o)}async getBoxValuesFromABIType(e){const{appId:t,boxNames:r,type:i}=e;return await Promise.all(r.map(async o=>await this.getBoxValueFromABIType({appId:t,boxName:o,type:i})))}static getBoxReference(e){const t=typeof e=="object"&&"appId"in e?e:{appId:0n,name:e};return{appIndex:t.appId,name:typeof t.name=="string"?new TextEncoder().encode(t.name):"length"in t.name?t.name:t.name.addr.publicKey}}static decodeAppState(e){const t={};for(const r of e){const i=Buffer.from(r.key).toString("base64"),o=r.key,s=Buffer.from(r.key).toString("utf-8"),a=r.value,l="action"in a?a.action:a.type;let c,d;switch(l){case 1:c=typeof a.bytes=="string"?a.bytes:a.bytes?Buffer.from(a.bytes).toString("base64"):"",d=Buffer.from(c,"base64"),t[s]={keyRaw:o,keyBase64:i,valueRaw:new Uint8Array(d),valueBase64:c,value:d.toString("utf-8")};break;case 2:{const u=a.uint??0;t[s]={keyRaw:o,keyBase64:i,value:BigInt(u)};break}default:throw new Error(`Received unknown state data type of ${l}`)}}return t}static getABIReturn(e,t){if(!t||!e||t.returns.type==="void")return;const r={txID:"",method:t,rawReturnValue:new Uint8Array};return Bg(Oe.AtomicTransactionComposer.parseMethodResponse(t,r,e),t.returns.type)}static replaceTealTemplateDeployTimeControlParams(e,t){if(t.updatable!==void 0){if(!e.includes(Xu))throw new Error(`Deploy-time updatability control requested for app deployment, but ${Xu} not present in TEAL code`);e=Qh(e,Xu,(t.updatable?1:0).toString())}if(t.deletable!==void 0){if(!e.includes(Zu))throw new Error(`Deploy-time deletability control requested for app deployment, but ${Zu} not present in TEAL code`);e=Qh(e,Zu,(t.deletable?1:0).toString())}return e}static replaceTealTemplateParams(e,t){if(t!==void 0)for(const r in t){const i=t[r],o=`TMPL_${r.replace(/^TMPL_/,"")}`;(typeof i=="number"||typeof i=="bigint")&&(e=e.replace(new RegExp(`(?<=bytes )${o}`,"g"),`0x${i.toString(16).padStart(16,"0")}`)),e=Qh(e,o,typeof i=="string"?`0x${Buffer.from(i,"utf-8").toString("hex")}`:ArrayBuffer.isView(i)?`0x${Buffer.from(i).toString("hex")}`:i.toString())}return e}static stripTealComments(e){const t=r=>{const i=Ng(r,"//");return i===void 0?r:r.slice(0,i).trimEnd()};return e.split(`
223
+ */var zy;function xM(){return zy||(zy=1,(function(n){const e=yM(),t=wM(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=w,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const R=new Uint8Array(1),g={foo:function(){return 42}};return Object.setPrototypeOf(g,Uint8Array.prototype),Object.setPrototypeOf(R,g),R.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(R){if(R>i)throw new RangeError('The value "'+R+'" is invalid for option "size"');const g=new Uint8Array(R);return Object.setPrototypeOf(g,a.prototype),g}function a(R,g,y){if(typeof R=="number"){if(typeof g=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(R)}return l(R,g,y)}a.poolSize=8192;function l(R,g,y){if(typeof R=="string")return m(R,g);if(ArrayBuffer.isView(R))return x(R);if(R==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof R);if(Ee(R,ArrayBuffer)||R&&Ee(R.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ee(R,SharedArrayBuffer)||R&&Ee(R.buffer,SharedArrayBuffer)))return A(R,g,y);if(typeof R=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const K=R.valueOf&&R.valueOf();if(K!=null&&K!==R)return a.from(K,g,y);const ie=v(R);if(ie)return ie;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof R[Symbol.toPrimitive]=="function")return a.from(R[Symbol.toPrimitive]("string"),g,y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof R)}a.from=function(R,g,y){return l(R,g,y)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function c(R){if(typeof R!="number")throw new TypeError('"size" argument must be of type number');if(R<0)throw new RangeError('The value "'+R+'" is invalid for option "size"')}function d(R,g,y){return c(R),R<=0?s(R):g!==void 0?typeof y=="string"?s(R).fill(g,y):s(R).fill(g):s(R)}a.alloc=function(R,g,y){return d(R,g,y)};function u(R){return c(R),s(R<0?0:F(R)|0)}a.allocUnsafe=function(R){return u(R)},a.allocUnsafeSlow=function(R){return u(R)};function m(R,g){if((typeof g!="string"||g==="")&&(g="utf8"),!a.isEncoding(g))throw new TypeError("Unknown encoding: "+g);const y=C(R,g)|0;let K=s(y);const ie=K.write(R,g);return ie!==y&&(K=K.slice(0,ie)),K}function h(R){const g=R.length<0?0:F(R.length)|0,y=s(g);for(let K=0;K<g;K+=1)y[K]=R[K]&255;return y}function x(R){if(Ee(R,Uint8Array)){const g=new Uint8Array(R);return A(g.buffer,g.byteOffset,g.byteLength)}return h(R)}function A(R,g,y){if(g<0||R.byteLength<g)throw new RangeError('"offset" is outside of buffer bounds');if(R.byteLength<g+(y||0))throw new RangeError('"length" is outside of buffer bounds');let K;return g===void 0&&y===void 0?K=new Uint8Array(R):y===void 0?K=new Uint8Array(R,g):K=new Uint8Array(R,g,y),Object.setPrototypeOf(K,a.prototype),K}function v(R){if(a.isBuffer(R)){const g=F(R.length)|0,y=s(g);return y.length===0||R.copy(y,0,0,g),y}if(R.length!==void 0)return typeof R.length!="number"||Fe(R.length)?s(0):h(R);if(R.type==="Buffer"&&Array.isArray(R.data))return h(R.data)}function F(R){if(R>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return R|0}function w(R){return+R!=R&&(R=0),a.alloc(+R)}a.isBuffer=function(g){return g!=null&&g._isBuffer===!0&&g!==a.prototype},a.compare=function(g,y){if(Ee(g,Uint8Array)&&(g=a.from(g,g.offset,g.byteLength)),Ee(y,Uint8Array)&&(y=a.from(y,y.offset,y.byteLength)),!a.isBuffer(g)||!a.isBuffer(y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===y)return 0;let K=g.length,ie=y.length;for(let ge=0,Se=Math.min(K,ie);ge<Se;++ge)if(g[ge]!==y[ge]){K=g[ge],ie=y[ge];break}return K<ie?-1:ie<K?1:0},a.isEncoding=function(g){switch(String(g).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(g,y){if(!Array.isArray(g))throw new TypeError('"list" argument must be an Array of Buffers');if(g.length===0)return a.alloc(0);let K;if(y===void 0)for(y=0,K=0;K<g.length;++K)y+=g[K].length;const ie=a.allocUnsafe(y);let ge=0;for(K=0;K<g.length;++K){let Se=g[K];if(Ee(Se,Uint8Array))ge+Se.length>ie.length?(a.isBuffer(Se)||(Se=a.from(Se)),Se.copy(ie,ge)):Uint8Array.prototype.set.call(ie,Se,ge);else if(a.isBuffer(Se))Se.copy(ie,ge);else throw new TypeError('"list" argument must be an Array of Buffers');ge+=Se.length}return ie};function C(R,g){if(a.isBuffer(R))return R.length;if(ArrayBuffer.isView(R)||Ee(R,ArrayBuffer))return R.byteLength;if(typeof R!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof R);const y=R.length,K=arguments.length>2&&arguments[2]===!0;if(!K&&y===0)return 0;let ie=!1;for(;;)switch(g){case"ascii":case"latin1":case"binary":return y;case"utf8":case"utf-8":return Q(R).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y*2;case"hex":return y>>>1;case"base64":return ae(R).length;default:if(ie)return K?-1:Q(R).length;g=(""+g).toLowerCase(),ie=!0}}a.byteLength=C;function M(R,g,y){let K=!1;if((g===void 0||g<0)&&(g=0),g>this.length||((y===void 0||y>this.length)&&(y=this.length),y<=0)||(y>>>=0,g>>>=0,y<=g))return"";for(R||(R="utf8");;)switch(R){case"hex":return ne(this,g,y);case"utf8":case"utf-8":return W(this,g,y);case"ascii":return J(this,g,y);case"latin1":case"binary":return U(this,g,y);case"base64":return P(this,g,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,g,y);default:if(K)throw new TypeError("Unknown encoding: "+R);R=(R+"").toLowerCase(),K=!0}}a.prototype._isBuffer=!0;function N(R,g,y){const K=R[g];R[g]=R[y],R[y]=K}a.prototype.swap16=function(){const g=this.length;if(g%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let y=0;y<g;y+=2)N(this,y,y+1);return this},a.prototype.swap32=function(){const g=this.length;if(g%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let y=0;y<g;y+=4)N(this,y,y+3),N(this,y+1,y+2);return this},a.prototype.swap64=function(){const g=this.length;if(g%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let y=0;y<g;y+=8)N(this,y,y+7),N(this,y+1,y+6),N(this,y+2,y+5),N(this,y+3,y+4);return this},a.prototype.toString=function(){const g=this.length;return g===0?"":arguments.length===0?W(this,0,g):M.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(g){if(!a.isBuffer(g))throw new TypeError("Argument must be a Buffer");return this===g?!0:a.compare(this,g)===0},a.prototype.inspect=function(){let g="";const y=n.INSPECT_MAX_BYTES;return g=this.toString("hex",0,y).replace(/(.{2})/g,"$1 ").trim(),this.length>y&&(g+=" ... "),"<Buffer "+g+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(g,y,K,ie,ge){if(Ee(g,Uint8Array)&&(g=a.from(g,g.offset,g.byteLength)),!a.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(y===void 0&&(y=0),K===void 0&&(K=g?g.length:0),ie===void 0&&(ie=0),ge===void 0&&(ge=this.length),y<0||K>g.length||ie<0||ge>this.length)throw new RangeError("out of range index");if(ie>=ge&&y>=K)return 0;if(ie>=ge)return-1;if(y>=K)return 1;if(y>>>=0,K>>>=0,ie>>>=0,ge>>>=0,this===g)return 0;let Se=ge-ie,Je=K-y;const ct=Math.min(Se,Je),it=this.slice(ie,ge),Ze=g.slice(y,K);for(let pt=0;pt<ct;++pt)if(it[pt]!==Ze[pt]){Se=it[pt],Je=Ze[pt];break}return Se<Je?-1:Je<Se?1:0};function b(R,g,y,K,ie){if(R.length===0)return-1;if(typeof y=="string"?(K=y,y=0):y>2147483647?y=2147483647:y<-2147483648&&(y=-2147483648),y=+y,Fe(y)&&(y=ie?0:R.length-1),y<0&&(y=R.length+y),y>=R.length){if(ie)return-1;y=R.length-1}else if(y<0)if(ie)y=0;else return-1;if(typeof g=="string"&&(g=a.from(g,K)),a.isBuffer(g))return g.length===0?-1:j(R,g,y,K,ie);if(typeof g=="number")return g=g&255,typeof Uint8Array.prototype.indexOf=="function"?ie?Uint8Array.prototype.indexOf.call(R,g,y):Uint8Array.prototype.lastIndexOf.call(R,g,y):j(R,[g],y,K,ie);throw new TypeError("val must be string, number or Buffer")}function j(R,g,y,K,ie){let ge=1,Se=R.length,Je=g.length;if(K!==void 0&&(K=String(K).toLowerCase(),K==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le")){if(R.length<2||g.length<2)return-1;ge=2,Se/=2,Je/=2,y/=2}function ct(Ze,pt){return ge===1?Ze[pt]:Ze.readUInt16BE(pt*ge)}let it;if(ie){let Ze=-1;for(it=y;it<Se;it++)if(ct(R,it)===ct(g,Ze===-1?0:it-Ze)){if(Ze===-1&&(Ze=it),it-Ze+1===Je)return Ze*ge}else Ze!==-1&&(it-=it-Ze),Ze=-1}else for(y+Je>Se&&(y=Se-Je),it=y;it>=0;it--){let Ze=!0;for(let pt=0;pt<Je;pt++)if(ct(R,it+pt)!==ct(g,pt)){Ze=!1;break}if(Ze)return it}return-1}a.prototype.includes=function(g,y,K){return this.indexOf(g,y,K)!==-1},a.prototype.indexOf=function(g,y,K){return b(this,g,y,K,!0)},a.prototype.lastIndexOf=function(g,y,K){return b(this,g,y,K,!1)};function p(R,g,y,K){y=Number(y)||0;const ie=R.length-y;K?(K=Number(K),K>ie&&(K=ie)):K=ie;const ge=g.length;K>ge/2&&(K=ge/2);let Se;for(Se=0;Se<K;++Se){const Je=parseInt(g.substr(Se*2,2),16);if(Fe(Je))return Se;R[y+Se]=Je}return Se}function E(R,g,y,K){return xe(Q(g,R.length-y),R,y,K)}function S(R,g,y,K){return xe(se(g),R,y,K)}function $(R,g,y,K){return xe(ae(g),R,y,K)}function B(R,g,y,K){return xe(ue(g,R.length-y),R,y,K)}a.prototype.write=function(g,y,K,ie){if(y===void 0)ie="utf8",K=this.length,y=0;else if(K===void 0&&typeof y=="string")ie=y,K=this.length,y=0;else if(isFinite(y))y=y>>>0,isFinite(K)?(K=K>>>0,ie===void 0&&(ie="utf8")):(ie=K,K=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ge=this.length-y;if((K===void 0||K>ge)&&(K=ge),g.length>0&&(K<0||y<0)||y>this.length)throw new RangeError("Attempt to write outside buffer bounds");ie||(ie="utf8");let Se=!1;for(;;)switch(ie){case"hex":return p(this,g,y,K);case"utf8":case"utf-8":return E(this,g,y,K);case"ascii":case"latin1":case"binary":return S(this,g,y,K);case"base64":return $(this,g,y,K);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,g,y,K);default:if(Se)throw new TypeError("Unknown encoding: "+ie);ie=(""+ie).toLowerCase(),Se=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(R,g,y){return g===0&&y===R.length?e.fromByteArray(R):e.fromByteArray(R.slice(g,y))}function W(R,g,y){y=Math.min(R.length,y);const K=[];let ie=g;for(;ie<y;){const ge=R[ie];let Se=null,Je=ge>239?4:ge>223?3:ge>191?2:1;if(ie+Je<=y){let ct,it,Ze,pt;switch(Je){case 1:ge<128&&(Se=ge);break;case 2:ct=R[ie+1],(ct&192)===128&&(pt=(ge&31)<<6|ct&63,pt>127&&(Se=pt));break;case 3:ct=R[ie+1],it=R[ie+2],(ct&192)===128&&(it&192)===128&&(pt=(ge&15)<<12|(ct&63)<<6|it&63,pt>2047&&(pt<55296||pt>57343)&&(Se=pt));break;case 4:ct=R[ie+1],it=R[ie+2],Ze=R[ie+3],(ct&192)===128&&(it&192)===128&&(Ze&192)===128&&(pt=(ge&15)<<18|(ct&63)<<12|(it&63)<<6|Ze&63,pt>65535&&pt<1114112&&(Se=pt))}}Se===null?(Se=65533,Je=1):Se>65535&&(Se-=65536,K.push(Se>>>10&1023|55296),Se=56320|Se&1023),K.push(Se),ie+=Je}return q(K)}const L=4096;function q(R){const g=R.length;if(g<=L)return String.fromCharCode.apply(String,R);let y="",K=0;for(;K<g;)y+=String.fromCharCode.apply(String,R.slice(K,K+=L));return y}function J(R,g,y){let K="";y=Math.min(R.length,y);for(let ie=g;ie<y;++ie)K+=String.fromCharCode(R[ie]&127);return K}function U(R,g,y){let K="";y=Math.min(R.length,y);for(let ie=g;ie<y;++ie)K+=String.fromCharCode(R[ie]);return K}function ne(R,g,y){const K=R.length;(!g||g<0)&&(g=0),(!y||y<0||y>K)&&(y=K);let ie="";for(let ge=g;ge<y;++ge)ie+=Ue[R[ge]];return ie}function fe(R,g,y){const K=R.slice(g,y);let ie="";for(let ge=0;ge<K.length-1;ge+=2)ie+=String.fromCharCode(K[ge]+K[ge+1]*256);return ie}a.prototype.slice=function(g,y){const K=this.length;g=~~g,y=y===void 0?K:~~y,g<0?(g+=K,g<0&&(g=0)):g>K&&(g=K),y<0?(y+=K,y<0&&(y=0)):y>K&&(y=K),y<g&&(y=g);const ie=this.subarray(g,y);return Object.setPrototypeOf(ie,a.prototype),ie};function le(R,g,y){if(R%1!==0||R<0)throw new RangeError("offset is not uint");if(R+g>y)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=this[g],ge=1,Se=0;for(;++Se<y&&(ge*=256);)ie+=this[g+Se]*ge;return ie},a.prototype.readUintBE=a.prototype.readUIntBE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=this[g+--y],ge=1;for(;y>0&&(ge*=256);)ie+=this[g+--y]*ge;return ie},a.prototype.readUint8=a.prototype.readUInt8=function(g,y){return g=g>>>0,y||le(g,1,this.length),this[g]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(g,y){return g=g>>>0,y||le(g,2,this.length),this[g]|this[g+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(g,y){return g=g>>>0,y||le(g,2,this.length),this[g]<<8|this[g+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(g,y){return g=g>>>0,y||le(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+this[g+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(g,y){return g=g>>>0,y||le(g,4,this.length),this[g]*16777216+(this[g+1]<<16|this[g+2]<<8|this[g+3])},a.prototype.readBigUInt64LE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=y+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24,ge=this[++g]+this[++g]*2**8+this[++g]*2**16+K*2**24;return BigInt(ie)+(BigInt(ge)<<BigInt(32))}),a.prototype.readBigUInt64BE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=y*2**24+this[++g]*2**16+this[++g]*2**8+this[++g],ge=this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+K;return(BigInt(ie)<<BigInt(32))+BigInt(ge)}),a.prototype.readIntLE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=this[g],ge=1,Se=0;for(;++Se<y&&(ge*=256);)ie+=this[g+Se]*ge;return ge*=128,ie>=ge&&(ie-=Math.pow(2,8*y)),ie},a.prototype.readIntBE=function(g,y,K){g=g>>>0,y=y>>>0,K||le(g,y,this.length);let ie=y,ge=1,Se=this[g+--ie];for(;ie>0&&(ge*=256);)Se+=this[g+--ie]*ge;return ge*=128,Se>=ge&&(Se-=Math.pow(2,8*y)),Se},a.prototype.readInt8=function(g,y){return g=g>>>0,y||le(g,1,this.length),this[g]&128?(255-this[g]+1)*-1:this[g]},a.prototype.readInt16LE=function(g,y){g=g>>>0,y||le(g,2,this.length);const K=this[g]|this[g+1]<<8;return K&32768?K|4294901760:K},a.prototype.readInt16BE=function(g,y){g=g>>>0,y||le(g,2,this.length);const K=this[g+1]|this[g]<<8;return K&32768?K|4294901760:K},a.prototype.readInt32LE=function(g,y){return g=g>>>0,y||le(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},a.prototype.readInt32BE=function(g,y){return g=g>>>0,y||le(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},a.prototype.readBigInt64LE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=this[g+4]+this[g+5]*2**8+this[g+6]*2**16+(K<<24);return(BigInt(ie)<<BigInt(32))+BigInt(y+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24)}),a.prototype.readBigInt64BE=Ye(function(g){g=g>>>0,re(g,"offset");const y=this[g],K=this[g+7];(y===void 0||K===void 0)&&H(g,this.length-8);const ie=(y<<24)+this[++g]*2**16+this[++g]*2**8+this[++g];return(BigInt(ie)<<BigInt(32))+BigInt(this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+K)}),a.prototype.readFloatLE=function(g,y){return g=g>>>0,y||le(g,4,this.length),t.read(this,g,!0,23,4)},a.prototype.readFloatBE=function(g,y){return g=g>>>0,y||le(g,4,this.length),t.read(this,g,!1,23,4)},a.prototype.readDoubleLE=function(g,y){return g=g>>>0,y||le(g,8,this.length),t.read(this,g,!0,52,8)},a.prototype.readDoubleBE=function(g,y){return g=g>>>0,y||le(g,8,this.length),t.read(this,g,!1,52,8)};function ye(R,g,y,K,ie,ge){if(!a.isBuffer(R))throw new TypeError('"buffer" argument must be a Buffer instance');if(g>ie||g<ge)throw new RangeError('"value" argument is out of bounds');if(y+K>R.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(g,y,K,ie){if(g=+g,y=y>>>0,K=K>>>0,!ie){const Je=Math.pow(2,8*K)-1;ye(this,g,y,K,Je,0)}let ge=1,Se=0;for(this[y]=g&255;++Se<K&&(ge*=256);)this[y+Se]=g/ge&255;return y+K},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(g,y,K,ie){if(g=+g,y=y>>>0,K=K>>>0,!ie){const Je=Math.pow(2,8*K)-1;ye(this,g,y,K,Je,0)}let ge=K-1,Se=1;for(this[y+ge]=g&255;--ge>=0&&(Se*=256);)this[y+ge]=g/Se&255;return y+K},a.prototype.writeUint8=a.prototype.writeUInt8=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,1,255,0),this[y]=g&255,y+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,65535,0),this[y]=g&255,this[y+1]=g>>>8,y+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,65535,0),this[y]=g>>>8,this[y+1]=g&255,y+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,4294967295,0),this[y+3]=g>>>24,this[y+2]=g>>>16,this[y+1]=g>>>8,this[y]=g&255,y+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,4294967295,0),this[y]=g>>>24,this[y+1]=g>>>16,this[y+2]=g>>>8,this[y+3]=g&255,y+4};function he(R,g,y,K,ie){X(g,K,ie,R,y,7);let ge=Number(g&BigInt(4294967295));R[y++]=ge,ge=ge>>8,R[y++]=ge,ge=ge>>8,R[y++]=ge,ge=ge>>8,R[y++]=ge;let Se=Number(g>>BigInt(32)&BigInt(4294967295));return R[y++]=Se,Se=Se>>8,R[y++]=Se,Se=Se>>8,R[y++]=Se,Se=Se>>8,R[y++]=Se,y}function de(R,g,y,K,ie){X(g,K,ie,R,y,7);let ge=Number(g&BigInt(4294967295));R[y+7]=ge,ge=ge>>8,R[y+6]=ge,ge=ge>>8,R[y+5]=ge,ge=ge>>8,R[y+4]=ge;let Se=Number(g>>BigInt(32)&BigInt(4294967295));return R[y+3]=Se,Se=Se>>8,R[y+2]=Se,Se=Se>>8,R[y+1]=Se,Se=Se>>8,R[y]=Se,y+8}a.prototype.writeBigUInt64LE=Ye(function(g,y=0){return he(this,g,y,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Ye(function(g,y=0){return de(this,g,y,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(g,y,K,ie){if(g=+g,y=y>>>0,!ie){const ct=Math.pow(2,8*K-1);ye(this,g,y,K,ct-1,-ct)}let ge=0,Se=1,Je=0;for(this[y]=g&255;++ge<K&&(Se*=256);)g<0&&Je===0&&this[y+ge-1]!==0&&(Je=1),this[y+ge]=(g/Se>>0)-Je&255;return y+K},a.prototype.writeIntBE=function(g,y,K,ie){if(g=+g,y=y>>>0,!ie){const ct=Math.pow(2,8*K-1);ye(this,g,y,K,ct-1,-ct)}let ge=K-1,Se=1,Je=0;for(this[y+ge]=g&255;--ge>=0&&(Se*=256);)g<0&&Je===0&&this[y+ge+1]!==0&&(Je=1),this[y+ge]=(g/Se>>0)-Je&255;return y+K},a.prototype.writeInt8=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,1,127,-128),g<0&&(g=255+g+1),this[y]=g&255,y+1},a.prototype.writeInt16LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,32767,-32768),this[y]=g&255,this[y+1]=g>>>8,y+2},a.prototype.writeInt16BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,2,32767,-32768),this[y]=g>>>8,this[y+1]=g&255,y+2},a.prototype.writeInt32LE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,2147483647,-2147483648),this[y]=g&255,this[y+1]=g>>>8,this[y+2]=g>>>16,this[y+3]=g>>>24,y+4},a.prototype.writeInt32BE=function(g,y,K){return g=+g,y=y>>>0,K||ye(this,g,y,4,2147483647,-2147483648),g<0&&(g=4294967295+g+1),this[y]=g>>>24,this[y+1]=g>>>16,this[y+2]=g>>>8,this[y+3]=g&255,y+4},a.prototype.writeBigInt64LE=Ye(function(g,y=0){return he(this,g,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Ye(function(g,y=0){return de(this,g,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function be(R,g,y,K,ie,ge){if(y+K>R.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("Index out of range")}function Ae(R,g,y,K,ie){return g=+g,y=y>>>0,ie||be(R,g,y,4),t.write(R,g,y,K,23,4),y+4}a.prototype.writeFloatLE=function(g,y,K){return Ae(this,g,y,!0,K)},a.prototype.writeFloatBE=function(g,y,K){return Ae(this,g,y,!1,K)};function _e(R,g,y,K,ie){return g=+g,y=y>>>0,ie||be(R,g,y,8),t.write(R,g,y,K,52,8),y+8}a.prototype.writeDoubleLE=function(g,y,K){return _e(this,g,y,!0,K)},a.prototype.writeDoubleBE=function(g,y,K){return _e(this,g,y,!1,K)},a.prototype.copy=function(g,y,K,ie){if(!a.isBuffer(g))throw new TypeError("argument should be a Buffer");if(K||(K=0),!ie&&ie!==0&&(ie=this.length),y>=g.length&&(y=g.length),y||(y=0),ie>0&&ie<K&&(ie=K),ie===K||g.length===0||this.length===0)return 0;if(y<0)throw new RangeError("targetStart out of bounds");if(K<0||K>=this.length)throw new RangeError("Index out of range");if(ie<0)throw new RangeError("sourceEnd out of bounds");ie>this.length&&(ie=this.length),g.length-y<ie-K&&(ie=g.length-y+K);const ge=ie-K;return this===g&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(y,K,ie):Uint8Array.prototype.set.call(g,this.subarray(K,ie),y),ge},a.prototype.fill=function(g,y,K,ie){if(typeof g=="string"){if(typeof y=="string"?(ie=y,y=0,K=this.length):typeof K=="string"&&(ie=K,K=this.length),ie!==void 0&&typeof ie!="string")throw new TypeError("encoding must be a string");if(typeof ie=="string"&&!a.isEncoding(ie))throw new TypeError("Unknown encoding: "+ie);if(g.length===1){const Se=g.charCodeAt(0);(ie==="utf8"&&Se<128||ie==="latin1")&&(g=Se)}}else typeof g=="number"?g=g&255:typeof g=="boolean"&&(g=Number(g));if(y<0||this.length<y||this.length<K)throw new RangeError("Out of range index");if(K<=y)return this;y=y>>>0,K=K===void 0?this.length:K>>>0,g||(g=0);let ge;if(typeof g=="number")for(ge=y;ge<K;++ge)this[ge]=g;else{const Se=a.isBuffer(g)?g:a.from(g,ie),Je=Se.length;if(Je===0)throw new TypeError('The value "'+g+'" is invalid for argument "value"');for(ge=0;ge<K-y;++ge)this[ge+y]=Se[ge%Je]}return this};const De={};function Te(R,g,y){De[R]=class extends y{constructor(){super(),Object.defineProperty(this,"message",{value:g.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${R}]`,delete this.name}get code(){return R}set code(ie){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ie,writable:!0})}toString(){return`${this.name} [${R}]: ${this.message}`}}}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(R){return R?`${R} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(R,g){return`The "${R}" argument must be of type number. Received type ${typeof g}`},TypeError),Te("ERR_OUT_OF_RANGE",function(R,g,y){let K=`The value of "${R}" is out of range.`,ie=y;return Number.isInteger(y)&&Math.abs(y)>2**32?ie=T(String(y)):typeof y=="bigint"&&(ie=String(y),(y>BigInt(2)**BigInt(32)||y<-(BigInt(2)**BigInt(32)))&&(ie=T(ie)),ie+="n"),K+=` It must be ${g}. Received ${ie}`,K},RangeError);function T(R){let g="",y=R.length;const K=R[0]==="-"?1:0;for(;y>=K+4;y-=3)g=`_${R.slice(y-3,y)}${g}`;return`${R.slice(0,y)}${g}`}function G(R,g,y){re(g,"offset"),(R[g]===void 0||R[g+y]===void 0)&&H(g,R.length-(y+1))}function X(R,g,y,K,ie,ge){if(R>y||R<g){const Se=typeof g=="bigint"?"n":"";let Je;throw g===0||g===BigInt(0)?Je=`>= 0${Se} and < 2${Se} ** ${(ge+1)*8}${Se}`:Je=`>= -(2${Se} ** ${(ge+1)*8-1}${Se}) and < 2 ** ${(ge+1)*8-1}${Se}`,new De.ERR_OUT_OF_RANGE("value",Je,R)}G(K,ie,ge)}function re(R,g){if(typeof R!="number")throw new De.ERR_INVALID_ARG_TYPE(g,"number",R)}function H(R,g,y){throw Math.floor(R)!==R?(re(R,y),new De.ERR_OUT_OF_RANGE("offset","an integer",R)):g<0?new De.ERR_BUFFER_OUT_OF_BOUNDS:new De.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${g}`,R)}const Z=/[^+/0-9A-Za-z-_]/g;function ce(R){if(R=R.split("=")[0],R=R.trim().replace(Z,""),R.length<2)return"";for(;R.length%4!==0;)R=R+"=";return R}function Q(R,g){g=g||1/0;let y;const K=R.length;let ie=null;const ge=[];for(let Se=0;Se<K;++Se){if(y=R.charCodeAt(Se),y>55295&&y<57344){if(!ie){if(y>56319){(g-=3)>-1&&ge.push(239,191,189);continue}else if(Se+1===K){(g-=3)>-1&&ge.push(239,191,189);continue}ie=y;continue}if(y<56320){(g-=3)>-1&&ge.push(239,191,189),ie=y;continue}y=(ie-55296<<10|y-56320)+65536}else ie&&(g-=3)>-1&&ge.push(239,191,189);if(ie=null,y<128){if((g-=1)<0)break;ge.push(y)}else if(y<2048){if((g-=2)<0)break;ge.push(y>>6|192,y&63|128)}else if(y<65536){if((g-=3)<0)break;ge.push(y>>12|224,y>>6&63|128,y&63|128)}else if(y<1114112){if((g-=4)<0)break;ge.push(y>>18|240,y>>12&63|128,y>>6&63|128,y&63|128)}else throw new Error("Invalid code point")}return ge}function se(R){const g=[];for(let y=0;y<R.length;++y)g.push(R.charCodeAt(y)&255);return g}function ue(R,g){let y,K,ie;const ge=[];for(let Se=0;Se<R.length&&!((g-=2)<0);++Se)y=R.charCodeAt(Se),K=y>>8,ie=y%256,ge.push(ie),ge.push(K);return ge}function ae(R){return e.toByteArray(ce(R))}function xe(R,g,y,K){let ie;for(ie=0;ie<K&&!(ie+y>=g.length||ie>=R.length);++ie)g[ie+y]=R[ie];return ie}function Ee(R,g){return R instanceof g||R!=null&&R.constructor!=null&&R.constructor.name!=null&&R.constructor.name===g.name}function Fe(R){return R!==R}const Ue=(function(){const R="0123456789abcdef",g=new Array(256);for(let y=0;y<16;++y){const K=y*16;for(let ie=0;ie<16;++ie)g[K+ie]=R[y]+R[ie]}return g})();function Ye(R){return typeof BigInt>"u"?vt:R}function vt(){throw new Error("BigInt not supported")}})(Zh)),Zh}var nn=xM();class vM{constructor(){this.listenerWrapperMap=new WeakMap,this.listenerMap={},this.off=this.removeListener}async emitAsync(e,t){for(const r of this.listenerMap[e]??[])await r(t,e)}on(e,t){return this.listenerMap[e]||(this.listenerMap[e]=[]),this.listenerMap[e].push(t),this}once(e,t){const r=async(i,o)=>{try{return await t(i,o)}finally{this.removeListener(o,r)}};return this.listenerWrapperMap.set(t,r),this.on(e,r)}removeListener(e,t){var i,o;const r=this.listenerWrapperMap.get(t);return r?(this.listenerWrapperMap.delete(t),((i=this.listenerMap[e])==null?void 0:i.indexOf(r))!==-1&&this.listenerMap[e].splice(this.listenerMap[e].indexOf(r),1)):((o=this.listenerMap[e])==null?void 0:o.indexOf(t))!==-1&&this.listenerMap[e].splice(this.listenerMap[e].indexOf(t),1),this}}const SM={error:console.error,warn:console.warn,info:console.info,verbose:()=>{},debug:console.debug},bM={error:function(n,...e){},warn:function(n,...e){},info:function(n,...e){},verbose:function(n,...e){},debug:function(n,...e){}};class EM{get populateAppCallResources(){return this.config.populateAppCallResources}get logger(){return this.config.logger}get debug(){return this.config.debug}get projectRoot(){return this.config.projectRoot}get traceAll(){return this.config.traceAll}get traceBufferSizeMb(){return this.config.traceBufferSizeMb}get maxSearchDepth(){return this.config.maxSearchDepth}get events(){return this.config.events}getLogger(e){return e?bM:this.logger}withDebug(e){const t=this.config.debug;try{this.config.debug=!0,e()}finally{this.config.debug=t}}constructor(){this.config={logger:SM,debug:!1,projectRoot:null,traceAll:!1,traceBufferSizeMb:256,maxSearchDepth:10,populateAppCallResources:!0,events:new vM}}configure(e){this.config={...this.config,...e}}}const ft=new EM,Xu="TMPL_UPDATABLE",Zu="TMPL_DELETABLE",$u="ALGOKIT_DEPLOYER",AM=2048;var Hs;(function(n){n[n.Fail=0]="Fail",n[n.UpdateApp=1]="UpdateApp",n[n.ReplaceApp=2]="ReplaceApp",n[n.AppendApp=3]="AppendApp"})(Hs||(Hs={}));var Cd;(function(n){n[n.Fail=0]="Fail",n[n.ReplaceApp=1]="ReplaceApp",n[n.AppendApp=2]="AppendApp"})(Cd||(Cd={}));const IM=n=>{if(typeof n=="number")return n;if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Hy(`Cannot convert ${n} to a Number as it is larger than the maximum safe integer the Number type can hold.`);if(n<BigInt(Number.MIN_SAFE_INTEGER))throw new Hy(`Cannot convert ${n} to a Number as it is smaller than the minimum safe integer the Number type can hold.`);return Number(n)};class Hy extends Error{}const kM=(n,e,t)=>{if(n>e){const r=n-e;return BigInt(Math.max(Number(r),Number(t)))}else return null};function*Yy(n,e){for(let t=0;t<n.length;t+=e)yield n.slice(t,t+e)}const CM=n=>{const e=new Map,t=function(r){return(e.has(r)||e.set(r,n.call(this,r)))&&e.get(r)};return t.cache=e,t},Ky=(n,e)=>{if(e.length>n.length)return!1;for(let t=0;t<e.length;t++)if(n[t]!==e[t])return!1;return!0},Xv=(n,e)=>{if(typeof e=="bigint")try{return IM(e)}catch{return e.toString()}return e},ea=(n,e=Xv,t)=>JSON.stringify(n,e,t),jp=(n,e)=>Math.floor((n.length+((e==null?void 0:e.length)??0)-1)/AM);function Ic(n,e){if(!e.toString().includes("byte")||n instanceof Uint8Array)return n;if((e instanceof Rs||e instanceof Bs)&&e.childType instanceof fu&&Array.isArray(n))return new Uint8Array(n);if((e instanceof Rs||e instanceof Bs)&&Array.isArray(n)){const t=[];for(let r=0;r<n.length;r++)t.push(Ic(n[r],e.childType));return t}if(e instanceof Mr&&Array.isArray(n)){const t=[];for(let r=0;r<n.length&&r<e.childTypes.length;r++)t.push(Ic(n[r],e.childTypes[r]));return t}return n}const Xl=(n,e)=>typeof n=="bigint"?e instanceof Qi&&e.bitSize<53?Number(n):n:Array.isArray(n)&&(e instanceof Rs||e instanceof Bs)?n.map(t=>Xl(t,e.childType)):Array.isArray(n)&&e instanceof Mr?n.map((t,r)=>Xl(t,e.childTypes[r])):n;var Ps;(function(n){n.TxnGroupSimulated="TxnGroupSimulated",n.AppCompiled="AppCompiled"})(Ps||(Ps={}));var Jh=Le.modelsv2;async function qy(n,e,t){const i=n.buildGroup().map(a=>Le.encodeUnsignedSimulateTransaction(a.txn)),o=new Jh.SimulateRequest({allowEmptySignatures:!0,fixSigners:!0,allowMoreLogging:!0,execTraceConfig:new Jh.SimulateTraceConfig({enable:!0,scratchChange:!0,stackChange:!0,stateChange:!0}),txnGroups:[new Jh.SimulateRequestTransactionGroup({txns:i.map(a=>Xt(a,jt))})]});return await e.simulateTransactions(o).do()}const Io=8,Yc=8;function FM(n){if(!(n===null||typeof n>"u"))if(typeof n=="object"&&n.constructor===Uint8Array){if(n.length===0||n.length>32)throw new Error(`Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${n.length}`);if(n.length===32)return n;const e=new Uint8Array(32);return e.set(n,0),e}else if(typeof n=="string"){if(n.length===0||n.length>32)throw new Error(`Received invalid lease; expected something with length between 1 and 32, but received '${n}' with length ${n.length}`);const e=new TextEncoder,t=new Uint8Array(32);return t.set(e.encode(n),0),t}else throw new Error(`Unknown lease type received of ${typeof n}`)}async function DM(n,e,t,r){var x,A,v,F,w,C;const i=new Le.modelsv2.SimulateRequest({txnGroups:[],allowUnnamedResources:!0,allowEmptySignatures:!0,fixSigners:!0}),o=Le.makeEmptyTransactionSigner(),s=n.clone(),a=[];if(s.transactions.forEach((M,N)=>{var b,j;if(M.signer=o,t.coverAppCallInnerTransactionFees&&M.txn.type===Bt.appl){if(!(r!=null&&r.suggestedParams))throw Error("Please provide additionalAtcContext.suggestedParams when coverAppCallInnerTransactionFees is enabled");const p=(j=(b=r==null?void 0:r.maxFees)==null?void 0:b.get(N))==null?void 0:j.microAlgo;p===void 0?a.push(N):M.txn.fee=p}}),t.coverAppCallInnerTransactionFees&&a.length>0)throw Error(`Please provide a maxFee for each app call transaction when coverAppCallInnerTransactionFees is enabled. Required for transaction ${a.join(", ")}`);const l=BigInt((r==null?void 0:r.suggestedParams.fee)??0n),c=BigInt((r==null?void 0:r.suggestedParams.minFee)??1000n),u=(await s.simulate(e,i)).simulateResponse.txnGroups[0];if(u.failureMessage)throw t.coverAppCallInnerTransactionFees&&u.failureMessage.match(/fee too small/)?Error("Fees were too small to resolve execution info via simulate. You may need to increase an app call transaction maxFee."):Error(`Error resolving execution info via simulate in transaction ${u.failedAt}: ${u.failureMessage}`);const m=u.unnamedResourcesAccessed,h=(M,N)=>M<N?-1:M>N?1:0;return m&&((x=m.accounts)==null||x.sort((M,N)=>h(M.toString(),N.toString())),(A=m.assets)==null||A.sort(h),(v=m.apps)==null||v.sort(h),(F=m.boxes)==null||F.sort((M,N)=>{const b=`${M.app}-${M.name}`,j=`${N.app}-${N.name}`;return h(b,j)}),(w=m.appLocals)==null||w.sort((M,N)=>{const b=`${M.app}-${M.account}`,j=`${N.app}-${N.account}`;return h(b,j)}),(C=m.assetHoldings)==null||C.sort((M,N)=>{const b=`${M.asset}-${M.account}`,j=`${N.asset}-${N.account}`;return h(b,j)})),{groupUnnamedResourcesAccessed:t.populateAppCallResources?m:void 0,txns:u.txnResults.map((M,N)=>{const b=n.transactions[N].txn;let j=0n;if(t.coverAppCallInnerTransactionFees){const p=l*BigInt(b.toByte().length+75),S=(p<c?c:p)-b.fee;if(b.type===Bt.appl){const $=(P,W=0n)=>P.reverse().reduce((L,q)=>{const J=(q.innerTxns&&q.innerTxns.length>0?$(q.innerTxns,L):L)+(c-q.txn.txn.fee);return J<0n?0n:J},W);j=$(M.txnResult.innerTxns??[])+S}else j=S}return{unnamedResourcesAccessed:t.populateAppCallResources?M.unnamedResourcesAccessed:void 0,requiredFeeDelta:j}})}}async function TM(n,e,t,r){var u,m,h,x,A,v;const i=await DM(n,e,t,r),o=n.buildGroup(),[s,a]=t.coverAppCallInnerTransactionFees?i.txns.map((F,w)=>{var p,E;const C=w,M=o[C].txn,N=(E=(p=r==null?void 0:r.maxFees)==null?void 0:p.get(w))==null?void 0:E.microAlgo,b=N!==void 0&&N===M.fee,j=F.requiredFeeDelta>0n&&(b||M.type!==Le.TransactionType.appl)?1000n:1n;return{...F,groupIndex:C,surplusFeePriorityLevel:F.requiredFeeDelta>0n?F.requiredFeeDelta*j:-1n}}).sort((F,w)=>F.surplusFeePriorityLevel>w.surplusFeePriorityLevel?-1:F.surplusFeePriorityLevel<w.surplusFeePriorityLevel?1:0).reduce((F,{groupIndex:w,requiredFeeDelta:C})=>{if(C>0n){let M=F[0];const N=F[1],b=C-M;return b<=0n?M=-b:(N.set(w,b),M=0n),[M,N]}return F},[i.txns.reduce((F,{requiredFeeDelta:w})=>w<0n?F+-w:F,0n),new Map]):[0n,new Map],l=F=>{var w,C;return F.type===Bt.appl&&((w=F.applicationCall)==null?void 0:w.access)&&((C=F.applicationCall)==null?void 0:C.access.length)>0},c=[];if(i.txns.forEach(({unnamedResourcesAccessed:F},w)=>{var C,M,N,b,j,p,E,S,$,B,P,W,L,q,J,U,ne,fe;if(t.populateAppCallResources&&o[w].txn.type===Bt.appl){const le=l(o[w].txn);if(le&&(F||i.groupUnnamedResourcesAccessed)&&c.push(w),F&&!le){if(F.boxes||F.extraBoxRefs)throw Error("Unexpected boxes at the transaction level");if(F.appLocals)throw Error("Unexpected app local at the transaction level");if(F.assetHoldings)throw Error("Unexpected asset holding at the transaction level");o[w].txn.applicationCall={...o[w].txn.applicationCall,accounts:[...((M=(C=o[w].txn)==null?void 0:C.applicationCall)==null?void 0:M.accounts)??[],...F.accounts??[]],foreignApps:[...((b=(N=o[w].txn)==null?void 0:N.applicationCall)==null?void 0:b.foreignApps)??[],...F.apps??[]],foreignAssets:[...((p=(j=o[w].txn)==null?void 0:j.applicationCall)==null?void 0:p.foreignAssets)??[],...F.assets??[]],boxes:[...((S=(E=o[w].txn)==null?void 0:E.applicationCall)==null?void 0:S.boxes)??[],...F.boxes??[]]};const ye=((B=($=o[w].txn.applicationCall)==null?void 0:$.accounts)==null?void 0:B.length)??0;if(ye>Yc)throw Error(`Account reference limit of ${Yc} exceeded in transaction ${w}`);const he=((W=(P=o[w].txn.applicationCall)==null?void 0:P.foreignAssets)==null?void 0:W.length)??0,de=((q=(L=o[w].txn.applicationCall)==null?void 0:L.foreignApps)==null?void 0:q.length)??0,be=((U=(J=o[w].txn.applicationCall)==null?void 0:J.boxes)==null?void 0:U.length)??0;if(ye+he+de+be>Io)throw Error(`Resource reference limit of ${Io} exceeded in transaction ${w}`)}}if(t.coverAppCallInnerTransactionFees){const le=a.get(w);if(le!==void 0){if(o[w].txn.type!==Le.TransactionType.appl)throw Error(`An additional fee of ${le} µALGO is required for non app call transaction ${w}`);const ye=o[w].txn.fee+le,he=(fe=(ne=r==null?void 0:r.maxFees)==null?void 0:ne.get(w))==null?void 0:fe.microAlgo;if(he===void 0||ye>he)throw Error(`Calculated transaction fee ${ye} µALGO is greater than max of ${he??"undefined"} for transaction ${w}`);o[w].txn.fee=ye}}}),t.populateAppCallResources){c.length>0&&ft.logger.warn(`Resource population will be skipped for transaction indexes ${c.join(", ")} as they use access references.`);const F=(C,M,N)=>{var p,E,S,$,B,P,W,L,q,J,U,ne,fe,le,ye,he,de,be,Ae,_e,De,Te,T,G,X,re;const b=H=>{var ue,ae,xe,Ee,Fe,Ue,Ye,vt;if(H.txn.type!==Le.TransactionType.appl||l(H.txn))return!1;const Z=((ae=(ue=H.txn.applicationCall)==null?void 0:ue.accounts)==null?void 0:ae.length)??0,ce=((Ee=(xe=H.txn.applicationCall)==null?void 0:xe.foreignAssets)==null?void 0:Ee.length)??0,Q=((Ue=(Fe=H.txn.applicationCall)==null?void 0:Fe.foreignApps)==null?void 0:Ue.length)??0,se=((vt=(Ye=H.txn.applicationCall)==null?void 0:Ye.boxes)==null?void 0:vt.length)??0;return Z+ce+Q+se<Io};if(N==="assetHolding"||N==="appLocal"){const{account:H}=M;let Z=C.findIndex(ce=>{var Q,se,ue,ae;return b(ce)?((se=(Q=ce.txn.applicationCall)==null?void 0:Q.accounts)==null?void 0:se.map(xe=>xe.toString()).includes(H.toString()))||((ae=(ue=ce.txn.applicationCall)==null?void 0:ue.foreignApps)==null?void 0:ae.map(xe=>Le.getApplicationAddress(xe).toString()).includes(H.toString()))||Object.values(ce.txn).some(xe=>{var Ee;return(Ee=yi(xe,(Fe,Ue)=>Ue instanceof ze?Ue.toString():Ue))==null?void 0:Ee.includes(H.toString())}):!1});if(Z>-1){if(N==="assetHolding"){const{asset:ce}=M;C[Z].txn.applicationCall={...C[Z].txn.applicationCall,foreignAssets:[...((E=(p=C[Z].txn)==null?void 0:p.applicationCall)==null?void 0:E.foreignAssets)??[],ce]}}else{const{app:ce}=M;C[Z].txn.applicationCall={...C[Z].txn.applicationCall,foreignApps:[...(($=(S=C[Z].txn)==null?void 0:S.applicationCall)==null?void 0:$.foreignApps)??[],ce]}}return}if(Z=C.findIndex(ce=>{var Q,se,ue,ae,xe,Ee,Fe;if(!b(ce)||(((se=(Q=ce.txn.applicationCall)==null?void 0:Q.accounts)==null?void 0:se.length)??0)>=Yc)return!1;if(N==="assetHolding"){const{asset:Ue}=M;return(ae=(ue=ce.txn.applicationCall)==null?void 0:ue.foreignAssets)==null?void 0:ae.includes(Ue)}else{const{app:Ue}=M;return((Ee=(xe=ce.txn.applicationCall)==null?void 0:xe.foreignApps)==null?void 0:Ee.includes(Ue))||((Fe=ce.txn.applicationCall)==null?void 0:Fe.appIndex)===Ue}}),Z>-1){const{account:ce}=M;C[Z].txn.applicationCall={...C[Z].txn.applicationCall,accounts:[...((P=(B=C[Z].txn)==null?void 0:B.applicationCall)==null?void 0:P.accounts)??[],ce]};return}}if(N==="box"){const{app:H,name:Z}=M,ce=C.findIndex(Q=>{var se,ue,ae;return b(Q)?((ue=(se=Q.txn.applicationCall)==null?void 0:se.foreignApps)==null?void 0:ue.includes(H))||((ae=Q.txn.applicationCall)==null?void 0:ae.appIndex)===H:!1});if(ce>-1){C[ce].txn.applicationCall={...C[ce].txn.applicationCall,boxes:[...((L=(W=C[ce].txn)==null?void 0:W.applicationCall)==null?void 0:L.boxes)??[],{appIndex:H,name:Z}]};return}}const j=C.findIndex(H=>{var ue,ae,xe,Ee,Fe,Ue,Ye,vt;if(H.txn.type!==Le.TransactionType.appl||l(H.txn))return!1;const Z=((ae=(ue=H.txn.applicationCall)==null?void 0:ue.accounts)==null?void 0:ae.length)??0,ce=((Ee=(xe=H.txn.applicationCall)==null?void 0:xe.foreignAssets)==null?void 0:Ee.length)??0,Q=((Ue=(Fe=H.txn.applicationCall)==null?void 0:Fe.foreignApps)==null?void 0:Ue.length)??0,se=((vt=(Ye=H.txn.applicationCall)==null?void 0:Ye.boxes)==null?void 0:vt.length)??0;return N==="account"?Z<Yc&&Z+ce+Q+se<Io:N==="assetHolding"||N==="appLocal"?Z+ce+Q+se<Io-1&&Z<Yc:N==="box"&&BigInt(M.app)!==BigInt(0)?Z+ce+Q+se<Io-1:Z+ce+Q+se<Io});if(j===-1)throw Error("No more transactions below reference limit. Add another app call to the group.");if(N==="account")C[j].txn.applicationCall={...C[j].txn.applicationCall,accounts:[...((J=(q=C[j].txn)==null?void 0:q.applicationCall)==null?void 0:J.accounts)??[],M]};else if(N==="app")C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignApps:[...((ne=(U=C[j].txn)==null?void 0:U.applicationCall)==null?void 0:ne.foreignApps)??[],typeof M=="bigint"?M:BigInt(M)]};else if(N==="box"){const{app:H,name:Z}=M;C[j].txn.applicationCall={...C[j].txn.applicationCall,boxes:[...((le=(fe=C[j].txn)==null?void 0:fe.applicationCall)==null?void 0:le.boxes)??[],{appIndex:H,name:Z}]},H.toString()!=="0"&&(C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignApps:[...((he=(ye=C[j].txn)==null?void 0:ye.applicationCall)==null?void 0:he.foreignApps)??[],H]})}else if(N==="assetHolding"){const{asset:H,account:Z}=M;C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignAssets:[...((be=(de=C[j].txn)==null?void 0:de.applicationCall)==null?void 0:be.foreignAssets)??[],H],accounts:[...((_e=(Ae=C[j].txn)==null?void 0:Ae.applicationCall)==null?void 0:_e.accounts)??[],Z]}}else if(N==="appLocal"){const{app:H,account:Z}=M;C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignApps:[...((Te=(De=C[j].txn)==null?void 0:De.applicationCall)==null?void 0:Te.foreignApps)??[],H],accounts:[...((G=(T=C[j].txn)==null?void 0:T.applicationCall)==null?void 0:G.accounts)??[],Z]}}else N==="asset"&&(C[j].txn.applicationCall={...C[j].txn.applicationCall,foreignAssets:[...((re=(X=C[j].txn)==null?void 0:X.applicationCall)==null?void 0:re.foreignAssets)??[],typeof M=="bigint"?M:BigInt(M)]})},w=i.groupUnnamedResourcesAccessed;if(w&&((u=w.appLocals)==null||u.forEach(C=>{var M,N;F(o,C,"appLocal"),w.accounts=(M=w.accounts)==null?void 0:M.filter(b=>b!==C.account),w.apps=(N=w.apps)==null?void 0:N.filter(b=>BigInt(b)!==BigInt(C.app))}),(m=w.assetHoldings)==null||m.forEach(C=>{var M,N;F(o,C,"assetHolding"),w.accounts=(M=w.accounts)==null?void 0:M.filter(b=>b!==C.account),w.assets=(N=w.assets)==null?void 0:N.filter(b=>BigInt(b)!==BigInt(C.asset))}),(h=w.accounts)==null||h.forEach(C=>{F(o,C,"account")}),(x=w.boxes)==null||x.forEach(C=>{var M;F(o,C,"box"),w.apps=(M=w.apps)==null?void 0:M.filter(N=>BigInt(N)!==BigInt(C.app))}),(A=w.assets)==null||A.forEach(C=>{F(o,C,"asset")}),(v=w.apps)==null||v.forEach(C=>{F(o,C,"app")}),w.extraBoxRefs))for(let C=0;C<w.extraBoxRefs;C+=1){const M=new Le.modelsv2.BoxReference({app:0,name:new Uint8Array(0)});F(o,M,"box")}}const d=new Le.AtomicTransactionComposer;return o.forEach(F=>{F.txn.group=void 0,d.addTransaction(F)}),d.methodCalls=n.methodCalls,d}const MM=async function(n,e){var a,l;const{atc:t,sendParams:r,additionalAtcContext:i,...o}=n;let s;s=t;try{const c=s.buildGroup(),d=(o==null?void 0:o.populateAppCallResources)??(r==null?void 0:r.populateAppCallResources)??ft.populateAppCallResources,u=o==null?void 0:o.coverAppCallInnerTransactionFees;(d||u)&&c.map(F=>F.txn.type).includes(Le.TransactionType.appl)&&(s=await TM(t,e,{populateAppCallResources:d,coverAppCallInnerTransactionFees:u},i));const m=s.buildGroup().map(F=>F.txn);let h;if(m.length>1&&(h=m[0].group?nn.Buffer.from(m[0].group).toString("base64"):"",ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).verbose(`Sending group of ${m.length} transactions (${h})`,{transactionsToSend:m}),ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).debug(`Transaction IDs (${h})`,m.map(F=>F.txID()))),ft.debug&&ft.traceAll){const F=await qy(s,e);await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:F})}const x=await s.execute(e,(o==null?void 0:o.maxRoundsToWaitForConfirmation)??(r==null?void 0:r.maxRoundsToWaitForConfirmation)??5);m.length>1?ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).verbose(`Group transaction (${h}) sent with ${m.length} transactions`):ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).verbose(`Sent transaction ID ${m[0].txID()} ${m[0].type} from ${m[0].sender.toString()}`);let A;r!=null&&r.skipWaiting||(A=await Promise.all(m.map(async F=>await e.pendingTransactionInformation(F.txID()).do())));const v=[...s.methodCalls.values()];return{groupId:h,confirmations:A,txIds:m.map(F=>F.txID()),transactions:m,returns:x.methodResults.map((F,w)=>Bg(F,v[w].returns.type))}}catch(c){const d=new Error(typeof c=="object"?c==null?void 0:c.message:"Received error executing Atomic Transaction Composer");if(d.cause=c,typeof c=="object"&&((a=c.response)==null||delete a.headers,d.response=c.response,c.response&&"body"in c.response&&delete d.response.body,d.name=c.name),ft.debug&&typeof c=="object"){d.traces=[],ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).error("Received error executing Atomic Transaction Composer and debug flag enabled; attempting simulation to get more information",d);const u=await qy(s,e);if(ft.debug&&!ft.traceAll&&await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:u}),u&&u.txnGroups[0].failedAt)for(const m of u.txnGroups[0].txnResults)d.traces.push({trace:(l=m.execTrace)==null?void 0:l.toEncodingData(),appBudget:m.appBudgetConsumed,logicSigBudget:m.logicSigBudgetConsumed,logs:m.txnResult.logs,message:u.txnGroups[0].failureMessage})}else ft.getLogger((o==null?void 0:o.suppressLog)??(r==null?void 0:r.suppressLog)).error("Received error executing Atomic Transaction Composer, for more information enable the debug flag",d);throw d.sentTransactions=s.buildGroup().map(u=>u.txn),d}};function Bg(n,e){if(n.decodeError)return{decodeError:n.decodeError};const t=Ic(n.returnValue!==void 0&&n.method.returns.type!=="void"?Xl(n.returnValue,n.method.returns.type):n.returnValue,e);return{method:n.method,rawReturnValue:n.rawReturnValue,decodeError:void 0,returnValue:t}}class Qn{constructor(e){this._compilationResults={},this._algod=e}async compileTeal(e){if(this._compilationResults[e])return this._compilationResults[e];const t=await this._algod.compile(e).sourcemap(!0).do(),r={teal:e,compiled:t.result,compiledHash:t.hash,compiledBase64ToBytes:new Uint8Array(Buffer.from(t.result,"base64")),sourceMap:new Dx(JSON.parse(Le.encodeJSON(t.sourcemap)))};return this._compilationResults[e]=r,r}async compileTealTemplate(e,t,r){let i=Qn.stripTealComments(e);return i=Qn.replaceTealTemplateParams(i,t),r&&(i=Qn.replaceTealTemplateDeployTimeControlParams(i,r)),await this.compileTeal(i)}getCompilationResult(e){return this._compilationResults[e]}async getById(e){var r,i,o,s;const t=await this._algod.getApplicationByID(Number(e)).do();return{appId:BigInt(t.id),appAddress:Le.getApplicationAddress(t.id),approvalProgram:t.params.approvalProgram,clearStateProgram:t.params.clearStateProgram,creator:t.params.creator,localInts:Number(((r=t.params.localStateSchema)==null?void 0:r.numUint)??0),localByteSlices:Number(((i=t.params.localStateSchema)==null?void 0:i.numByteSlice)??0),globalInts:Number(((o=t.params.globalStateSchema)==null?void 0:o.numUint)??0),globalByteSlices:Number(((s=t.params.globalStateSchema)==null?void 0:s.numByteSlice)??0),extraProgramPages:Number(t.params.extraProgramPages??0),globalState:Qn.decodeAppState(t.params.globalState??[]),version:t.params.version}}async getGlobalState(e){return(await this.getById(e)).globalState}async getLocalState(e,t){var i;const r=await this._algod.accountApplicationInformation(t,e).do();if(!((i=r.appLocalState)!=null&&i.keyValue))throw new Error("Couldn't find local state");return Qn.decodeAppState(r.appLocalState.keyValue)}async getBoxNames(e){return(await this._algod.getApplicationBoxes(e).do()).boxes.map(r=>({nameRaw:r.name,nameBase64:Buffer.from(r.name).toString("base64"),name:Buffer.from(r.name).toString("utf-8")}))}async getBoxValue(e,t){const r=typeof t=="object"&&"nameRaw"in t?t.nameRaw:t,i=Qn.getBoxReference(r).name;return(await this._algod.getApplicationBoxByName(Number(e),i).do()).value}async getBoxValues(e,t){return await Promise.all(t.map(async r=>await this.getBoxValue(e,r)))}async getBoxValueFromABIType(e){const{appId:t,boxName:r,type:i}=e,o=await this.getBoxValue(t,r);return i.decode(o)}async getBoxValuesFromABIType(e){const{appId:t,boxNames:r,type:i}=e;return await Promise.all(r.map(async o=>await this.getBoxValueFromABIType({appId:t,boxName:o,type:i})))}static getBoxReference(e){const t=typeof e=="object"&&"appId"in e?e:{appId:0n,name:e};return{appIndex:t.appId,name:typeof t.name=="string"?new TextEncoder().encode(t.name):"length"in t.name?t.name:t.name.addr.publicKey}}static decodeAppState(e){const t={};for(const r of e){const i=Buffer.from(r.key).toString("base64"),o=r.key,s=Buffer.from(r.key).toString("utf-8"),a=r.value,l="action"in a?a.action:a.type;let c,d;switch(l){case 1:c=typeof a.bytes=="string"?a.bytes:a.bytes?Buffer.from(a.bytes).toString("base64"):"",d=Buffer.from(c,"base64"),t[s]={keyRaw:o,keyBase64:i,valueRaw:new Uint8Array(d),valueBase64:c,value:d.toString("utf-8")};break;case 2:{const u=a.uint??0;t[s]={keyRaw:o,keyBase64:i,value:BigInt(u)};break}default:throw new Error(`Received unknown state data type of ${l}`)}}return t}static getABIReturn(e,t){if(!t||!e||t.returns.type==="void")return;const r={txID:"",method:t,rawReturnValue:new Uint8Array};return Bg(Le.AtomicTransactionComposer.parseMethodResponse(t,r,e),t.returns.type)}static replaceTealTemplateDeployTimeControlParams(e,t){if(t.updatable!==void 0){if(!e.includes(Xu))throw new Error(`Deploy-time updatability control requested for app deployment, but ${Xu} not present in TEAL code`);e=Qh(e,Xu,(t.updatable?1:0).toString())}if(t.deletable!==void 0){if(!e.includes(Zu))throw new Error(`Deploy-time deletability control requested for app deployment, but ${Zu} not present in TEAL code`);e=Qh(e,Zu,(t.deletable?1:0).toString())}return e}static replaceTealTemplateParams(e,t){if(t!==void 0)for(const r in t){const i=t[r],o=`TMPL_${r.replace(/^TMPL_/,"")}`;(typeof i=="number"||typeof i=="bigint")&&(e=e.replace(new RegExp(`(?<=bytes )${o}`,"g"),`0x${i.toString(16).padStart(16,"0")}`)),e=Qh(e,o,typeof i=="string"?`0x${Buffer.from(i,"utf-8").toString("hex")}`:ArrayBuffer.isView(i)?`0x${Buffer.from(i).toString("hex")}`:i.toString())}return e}static stripTealComments(e){const t=r=>{const i=Ng(r,"//");return i===void 0?r:r.slice(0,i).trimEnd()};return e.split(`
224
224
  `).map(r=>t(r)).join(`
225
225
  `)}}const Ng=(n,e,t=0,r)=>{const i=r===void 0?n.length:r;let o=t,s=!1,a=!1;for(;o<i;){const l=n[o];if((l===" "||l==="(")&&!s&&RM(n,o))a=!0;else if((l===" "||l===")")&&!s&&a)a=!1;else if(l==="\\"&&s)o+=1;else if(l==='"')s=!s;else if(!s&&!a&&n.startsWith(e,o))return o;o+=1}},RM=(n,e)=>{try{const t=n.slice(0,e).split(/\s+/),r=t[t.length-1];return["base64","b64"].includes(r)}catch{return!1}};function Qh(n,e,t){const r=[],i=t.length-e.length,o=n.split(`
226
226
  `);for(const s of o){const a=Ng(s,"//"),l=a===void 0?s.length:a;let c=s.substring(0,l);const d=s.substring(l);let u=0;for(;;){const m=BM(c,e,u);if(m===void 0)break;u=m+e.length;const h=c.substring(0,m),x=c.substring(u);c=`${h}${t}${x}`,u+=i}r.push(c+d)}return r.join(`
227
- `)}const BM=(n,e,t=0,r)=>{const i=n.length;let o=t;for(;o<i;){const s=Ng(n,e,o,i);if(s===void 0)break;const a=s+e.length;if((s===0||!Xy(n[s-1]))&&(a>=n.length||!Xy(n[a])))return s;o=a}};function Xy(n){return n.length===1&&(/\w/.test(n)||n==="_")}const ef=({method:n,args:e})=>`${n.name}(${(e??[]).map(t=>typeof t=="object"?ea(t,(r,i)=>{const o=Xv(r,i);return o instanceof Uint8Array?nn.Buffer.from(o).toString("base64"):o}):t)})`;class NM{constructor(e,t,r){this.payment=this._send(i=>i.addPayment,{preLog:(i,o)=>`Sending ${i.amount.microAlgo} µALGO from ${i.sender} to ${i.receiver} via transaction ${o.txID()}`}),this.assetCreate=async i=>{const o=await this._send(s=>s.addAssetCreate,{postLog:(s,a)=>`Created asset${s.assetName?` ${s.assetName}`:""}${s.unitName?` (${s.unitName})`:""} with ${s.total} units and ${s.decimals??0} decimals created by ${s.sender} with ID ${a.confirmation.assetIndex} via transaction ${a.txIds.at(-1)}`})(i);return{...o,assetId:BigInt(o.confirmation.assetIndex??0)}},this.assetConfig=this._send(i=>i.addAssetConfig,{preLog:(i,o)=>`Configuring asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetFreeze=this._send(i=>i.addAssetFreeze,{preLog:(i,o)=>`Freezing asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetDestroy=this._send(i=>i.addAssetDestroy,{preLog:(i,o)=>`Destroying asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetTransfer=this._send(i=>i.addAssetTransfer,{preLog:(i,o)=>`Transferring ${i.amount} units of asset with ID ${i.assetId} from ${i.sender} to ${i.receiver} via transaction ${o.txID()}`}),this.assetOptIn=this._send(i=>i.addAssetOptIn,{preLog:(i,o)=>`Opting in ${i.sender} to asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetOptOut=async i=>{if(i.ensureZeroBalance){let o=0n;try{o=(await this._assetManager.getAccountInformation(i.sender,i.assetId)).balance}catch{throw new Error(`Account ${i.sender} is not opted-in to Asset ${i.assetId}; can't opt-out.`)}if(o!==0n)throw new Error(`Account ${i.sender} does not have a zero balance for Asset ${i.assetId}; can't opt-out.`)}return i.creator=i.creator??(await this._assetManager.getById(i.assetId)).creator,await this._send(o=>o.addAssetOptOut,{preLog:(o,s)=>`Opting ${o.sender} out of asset with ID ${o.assetId} to creator ${o.creator} via transaction ${s.txID()}`})(i)},this.appCreate=this._sendAppCreateCall(i=>i.addAppCreate,{postLog:(i,o)=>`App created by ${i.sender} with ID ${o.confirmation.applicationIndex} via transaction ${o.txIds.at(-1)}`}),this.appUpdate=this._sendAppUpdateCall(i=>i.addAppUpdate,{postLog:(i,o)=>`App ${i.appId} updated ${i.args?` with ${i.args.map(s=>nn.Buffer.from(s).toString("base64"))}`:""} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appDelete=this._sendAppCall(i=>i.addAppDelete,{postLog:(i,o)=>`App ${i.appId} deleted ${i.args?` with ${i.args.map(s=>nn.Buffer.from(s).toString("base64"))}`:""} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appCall=this._sendAppCall(i=>i.addAppCall,{postLog:(i,o)=>`App ${i.appId} called ${i.args?` with ${i.args.map(s=>nn.Buffer.from(s).toString("base64"))}`:""} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appCreateMethodCall=this._sendAppCreateCall(i=>i.addAppCreateMethodCall,{postLog:(i,o)=>`App created by ${i.sender} with ID ${o.confirmation.applicationIndex} via transaction ${o.txIds.at(-1)}`}),this.appUpdateMethodCall=this._sendAppUpdateCall(i=>i.addAppUpdateMethodCall,{postLog:(i,o)=>`App ${i.appId} updated with ${ef(i)} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appDeleteMethodCall=this._sendAppCall(i=>i.addAppDeleteMethodCall,{postLog:(i,o)=>`App ${i.appId} deleted with ${ef(i)} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appCallMethodCall=this._sendAppCall(i=>i.addAppCallMethodCall,{postLog:(i,o)=>`App ${i.appId} called with ${ef(i)} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.onlineKeyRegistration=this._send(i=>i.addOnlineKeyRegistration,{preLog:(i,o)=>`Registering online key for ${i.sender} via transaction ${o.txID()}`}),this.offlineKeyRegistration=this._send(i=>i.addOfflineKeyRegistration,{preLog:(i,o)=>`Registering offline key for ${i.sender} via transaction ${o.txID()}`}),this._newGroup=e,this._assetManager=t,this._appManager=r}newGroup(){return this._newGroup()}_send(e,t){return async r=>{const i=this._newGroup();if(e(i).apply(i,[r]),t!=null&&t.preLog){const a=(await i.build()).transactions.at(-1).txn;ft.getLogger(r==null?void 0:r.suppressLog).debug(t.preLog(r,a))}const o=await i.send(r),s={transaction:o.transactions.at(-1),confirmation:o.confirmations.at(-1),txId:o.txIds.at(-1),...o};return t!=null&&t.postLog&&ft.getLogger(r==null?void 0:r.suppressLog).debug(t.postLog(r,s)),s}}_sendAppCall(e,t){return async r=>{const i=await this._send(e,t)(r);return{...i,return:Qn.getABIReturn(i.confirmation,"method"in r?r.method:void 0)}}}_sendAppUpdateCall(e,t){return async r=>{const i=await this._sendAppCall(e,t)(r),o=typeof r.approvalProgram=="string"?this._appManager.getCompilationResult(r.approvalProgram):void 0,s=typeof r.clearStateProgram=="string"?this._appManager.getCompilationResult(r.clearStateProgram):void 0;return{...i,compiledApproval:o,compiledClear:s}}}_sendAppCreateCall(e,t){return async r=>{const i=await this._sendAppUpdateCall(e,t)(r);return{...i,appId:BigInt(i.confirmation.applicationIndex),appAddress:Oe.getApplicationAddress(i.confirmation.applicationIndex)}}}}function Zv(n){return n==="devnet-v1"||n==="sandnet-v1"||n==="dockernet-v1"}var PM=Oe.AtomicTransactionComposer,tf=Oe.isTransactionWithSigner,Zy=Oe.modelsv2;const OM=n=>typeof n=="string"?ze.fromString(n):n,Jy=16;class LM extends Error{constructor(e,t){super(`An error transformer returned a non-error value: ${t}. The original error before any transformation: ${e}`)}}class VM extends Error{constructor(e,t){super(`An error transformer threw an error: ${t}. The original error before any transformation: ${e} `,{cause:t})}}class zr{async transformError(e){if(!(e instanceof Error))return e;let t=e;for(const r of this.errorTransformers)try{if(t=await r(t),!(t instanceof Error))return new LM(e,t)}catch(i){return new VM(e,i)}return t}constructor(e){this.atc=new Oe.AtomicTransactionComposer,this.txnMaxFees=new Map,this.txns=[],this.defaultValidityWindow=10n,this.defaultValidityWindowIsExplicit=!1,this.algod=e.algod;const t=()=>e.algod.getTransactionParams().do();this.getSuggestedParams=e.getSuggestedParams??t,this.getSigner=e.getSigner,this.defaultValidityWindow=e.defaultValidityWindow??this.defaultValidityWindow,this.defaultValidityWindowIsExplicit=e.defaultValidityWindow!==void 0,this.appManager=e.appManager??new Qn(e.algod),this.errorTransformers=e.errorTransformers??[]}registerErrorTransformer(e){return this.errorTransformers.push(e),this}addTransaction(e,t){return this.txns.push({txn:e,signer:t??this.getSigner(e.sender),type:"txnWithSigner"}),this}addPayment(e){return this.txns.push({...e,type:"pay"}),this}addAssetCreate(e){return this.txns.push({...e,type:"assetCreate"}),this}addAssetConfig(e){return this.txns.push({...e,type:"assetConfig"}),this}addAssetFreeze(e){return this.txns.push({...e,type:"assetFreeze"}),this}addAssetDestroy(e){return this.txns.push({...e,type:"assetDestroy"}),this}addAssetTransfer(e){return this.txns.push({...e,type:"assetTransfer"}),this}addAssetOptIn(e){return this.txns.push({...e,type:"assetOptIn"}),this}addAssetOptOut(e){return this.txns.push({...e,type:"assetOptOut"}),this}addAppCreate(e){return this.txns.push({...e,type:"appCall"}),this}addAppUpdate(e){return this.txns.push({...e,type:"appCall",onComplete:Oe.OnApplicationComplete.UpdateApplicationOC}),this}addAppDelete(e){return this.txns.push({...e,type:"appCall",onComplete:Oe.OnApplicationComplete.DeleteApplicationOC}),this}addAppCall(e){return this.txns.push({...e,type:"appCall"}),this}addAppCreateMethodCall(e){return this.txns.push({...e,type:"methodCall"}),this}addAppUpdateMethodCall(e){return this.txns.push({...e,type:"methodCall",onComplete:Oe.OnApplicationComplete.UpdateApplicationOC}),this}addAppDeleteMethodCall(e){return this.txns.push({...e,type:"methodCall",onComplete:Oe.OnApplicationComplete.DeleteApplicationOC}),this}addAppCallMethodCall(e){return this.txns.push({...e,type:"methodCall"}),this}addOnlineKeyRegistration(e){return this.txns.push({...e,type:"keyReg"}),this}addOfflineKeyRegistration(e){return this.txns.push({...e,type:"keyReg"}),this}addAtc(e){return this.txns.push({atc:e,type:"atc"}),this}buildAtc(e){return e.buildGroup().map((i,o)=>(i.txn.group=void 0,e.methodCalls.get(o)?{...i,context:{abiMethod:e.methodCalls.get(o)}}:{...i,context:{}}))}commonTxnBuildStep(e,t,r){var a;r.suggestedParams={...r.suggestedParams},t.lease&&(r.lease=FM(t.lease)),t.rekeyTo&&(r.rekeyTo=OM(t.rekeyTo));const i=new TextEncoder;if(t.note&&(r.note=typeof t.note=="string"?i.encode(t.note):t.note),t.firstValidRound&&(r.suggestedParams.firstValid=t.firstValidRound),t.lastValidRound)r.suggestedParams.lastValid=t.lastValidRound;else{const l=t.validityWindow?BigInt(t.validityWindow):!this.defaultValidityWindowIsExplicit&&Zv(r.suggestedParams.genesisID??"unknown")?1000n:this.defaultValidityWindow;r.suggestedParams.lastValid=BigInt(r.suggestedParams.firstValid)+l}if(t.staticFee!==void 0&&t.extraFee!==void 0)throw Error("Cannot set both staticFee and extraFee");t.staticFee!==void 0&&(r.suggestedParams.fee=t.staticFee.microAlgo,r.suggestedParams.flatFee=!0);const o=e(r);if(t.extraFee&&(o.fee+=t.extraFee.microAlgo),t.maxFee!==void 0&&o.fee>t.maxFee.microAlgo)throw Error(`Transaction fee ${o.fee} µALGO is greater than maxFee ${t.maxFee}`);const s=t.maxFee!==void 0&&t.maxFee.microAlgo>(((a=t.staticFee)==null?void 0:a.microAlgo)??0n)?t.maxFee:t.staticFee;return{txn:o,context:{maxFee:s}}}async buildMethodCall(e,t,r){var x,A,v,F,w,C,M,N;const i=[],o=[],s=b=>Array.isArray(b)?b.length==0||b.every(s):typeof b=="bigint"||typeof b=="boolean"||typeof b=="number"||typeof b=="string"||b instanceof Uint8Array||b instanceof Oe.Address;for(let b=(e.args??[]).length-1;b>=0;b--){const j=e.args[b];if(j===void 0){if(Oe.abiTypeIsTransaction(e.method.args[b].type)&&o.length>0){const E=o.splice(-1,1)[0];i.push(E);continue}throw Error(`No value provided for argument ${b+1} within call to ${e.method.name}`)}if(s(j)){i.push(j);continue}if(tf(j)){i.push(j);continue}if("method"in j){const E=await this.buildMethodCall(j,t,r);i.push(...E.slice(-1)),o.push(...E.slice(0,-1).reverse());continue}const p=await j;i.push({txn:p,signer:r?e.signer?"signer"in e.signer?e.signer.signer:e.signer:this.getSigner(p.sender):zr.NULL_SIGNER})}const a=new Oe.AtomicTransactionComposer,l=new Map;o.reverse().forEach(({context:b,...j})=>{a.addTransaction(j);const p=a.count()-1;b.abiMethod&&a.methodCalls.set(p,b.abiMethod),b.maxFee!==void 0&&l.set(p,b.maxFee)}),i.filter(b=>{if(typeof b=="object"&&"context"in b){const{context:j,...p}=b;return tf(p)}return tf(b)}).reverse().forEach((b,j)=>{if(typeof b=="object"&&"context"in b&&b.context){const p=a.count()+j;b.context.abiMethod&&a.methodCalls.set(p,b.context.abiMethod),b.context.maxFee!==void 0&&l.set(p,b.context.maxFee)}});const c=Number("appId"in e?e.appId:0n),d="approvalProgram"in e?typeof e.approvalProgram=="string"?(await this.appManager.compileTeal(e.approvalProgram)).compiledBase64ToBytes:e.approvalProgram:void 0,u="clearStateProgram"in e?typeof e.clearStateProgram=="string"?(await this.appManager.compileTeal(e.clearStateProgram)).compiledBase64ToBytes:e.clearStateProgram:void 0,m={appID:c,sender:e.sender,suggestedParams:t,onComplete:e.onComplete??Oe.OnApplicationComplete.NoOpOC,appAccounts:e.accountReferences,appForeignApps:(x=e.appReferences)==null?void 0:x.map(b=>Number(b)),appForeignAssets:(A=e.assetReferences)==null?void 0:A.map(b=>Number(b)),boxes:(v=e.boxReferences)==null?void 0:v.map(Qn.getBoxReference),access:(F=e.accessReferences)==null?void 0:F.map(Qy),approvalProgram:d,clearProgram:u,extraPages:c===0?"extraProgramPages"in e&&e.extraProgramPages!==void 0?e.extraProgramPages:d?jp(d,u):0:void 0,numLocalInts:c===0?"schema"in e?((w=e.schema)==null?void 0:w.localInts)??0:0:void 0,numLocalByteSlices:c===0?"schema"in e?((C=e.schema)==null?void 0:C.localByteSlices)??0:0:void 0,numGlobalInts:c===0?"schema"in e?((M=e.schema)==null?void 0:M.globalInts)??0:0:void 0,numGlobalByteSlices:c===0?"schema"in e?((N=e.schema)==null?void 0:N.globalByteSlices)??0:0:void 0,method:e.method,signer:r?e.signer?"signer"in e.signer?e.signer.signer:e.signer:this.getSigner(e.sender):zr.NULL_SIGNER,methodArgs:i.map(b=>{if(typeof b=="object"&&"context"in b){const{context:j,...p}=b;return p}return b}).reverse(),rejectVersion:e.rejectVersion,note:void 0,lease:void 0,rekeyTo:void 0},h=this.commonTxnBuildStep(b=>(a.addMethodCall(b),a.buildGroup()[a.count()-1].txn),e,m);return this.buildAtc(a).map(({context:b,...j},p)=>{const E=p===a.count()-1?h.context.maxFee:l.get(p),S={...b,maxFee:E};return{...j,context:S}})}buildPayment(e,t){return this.commonTxnBuildStep(Oe.makePaymentTxnWithSuggestedParamsFromObject,e,{sender:e.sender,receiver:e.receiver,amount:e.amount.microAlgo,closeRemainderTo:e.closeRemainderTo,suggestedParams:t})}buildAssetCreate(e,t){return this.commonTxnBuildStep(Oe.makeAssetCreateTxnWithSuggestedParamsFromObject,e,{sender:e.sender,total:e.total,decimals:e.decimals??0,assetName:e.assetName,unitName:e.unitName,assetURL:e.url,defaultFrozen:e.defaultFrozen??!1,assetMetadataHash:typeof e.metadataHash=="string"?Buffer.from(e.metadataHash,"utf-8"):e.metadataHash,manager:e.manager,reserve:e.reserve,freeze:e.freeze,clawback:e.clawback,suggestedParams:t})}buildAssetConfig(e,t){return this.commonTxnBuildStep(Oe.makeAssetConfigTxnWithSuggestedParamsFromObject,e,{sender:e.sender,assetIndex:e.assetId,suggestedParams:t,manager:e.manager,reserve:e.reserve,freeze:e.freeze,clawback:e.clawback,strictEmptyAddressChecking:!1})}buildAssetDestroy(e,t){return this.commonTxnBuildStep(Oe.makeAssetDestroyTxnWithSuggestedParamsFromObject,e,{sender:e.sender,assetIndex:e.assetId,suggestedParams:t})}buildAssetFreeze(e,t){return this.commonTxnBuildStep(Oe.makeAssetFreezeTxnWithSuggestedParamsFromObject,e,{sender:e.sender,assetIndex:e.assetId,freezeTarget:e.account,frozen:e.frozen,suggestedParams:t})}buildAssetTransfer(e,t){return this.commonTxnBuildStep(Oe.makeAssetTransferTxnWithSuggestedParamsFromObject,e,{sender:e.sender,receiver:e.receiver,assetIndex:e.assetId,amount:e.amount,suggestedParams:t,closeRemainderTo:e.closeAssetTo,assetSender:e.clawbackTarget})}async buildAppCall(e,t){var a,l,c,d,u,m,h,x;const r="appId"in e?e.appId:0n,i="approvalProgram"in e?typeof e.approvalProgram=="string"?(await this.appManager.compileTeal(e.approvalProgram)).compiledBase64ToBytes:e.approvalProgram:void 0,o="clearStateProgram"in e?typeof e.clearStateProgram=="string"?(await this.appManager.compileTeal(e.clearStateProgram)).compiledBase64ToBytes:e.clearStateProgram:void 0,s={sender:e.sender,suggestedParams:t,appArgs:e.args,onComplete:e.onComplete??Oe.OnApplicationComplete.NoOpOC,accounts:e.accountReferences,foreignApps:(a=e.appReferences)==null?void 0:a.map(A=>Number(A)),foreignAssets:(l=e.assetReferences)==null?void 0:l.map(A=>Number(A)),boxes:(c=e.boxReferences)==null?void 0:c.map(Qn.getBoxReference),access:(d=e.accessReferences)==null?void 0:d.map(Qy),approvalProgram:i,clearProgram:o,rejectVersion:e.rejectVersion};if(r===0n){if(s.approvalProgram===void 0||s.clearProgram===void 0)throw new Error("approvalProgram and clearStateProgram are required for application creation");return this.commonTxnBuildStep(Oe.makeApplicationCreateTxnFromObject,e,{...s,extraPages:"extraProgramPages"in e&&e.extraProgramPages!==void 0?e.extraProgramPages:jp(i,o),numLocalInts:"schema"in e?((u=e.schema)==null?void 0:u.localInts)??0:0,numLocalByteSlices:"schema"in e?((m=e.schema)==null?void 0:m.localByteSlices)??0:0,numGlobalInts:"schema"in e?((h=e.schema)==null?void 0:h.globalInts)??0:0,numGlobalByteSlices:"schema"in e?((x=e.schema)==null?void 0:x.globalByteSlices)??0:0,approvalProgram:i,clearProgram:o})}else return this.commonTxnBuildStep(Oe.makeApplicationCallTxnFromObject,e,{...s,appIndex:r})}buildKeyReg(e,t){return"voteKey"in e?this.commonTxnBuildStep(Oe.makeKeyRegistrationTxnWithSuggestedParamsFromObject,e,{sender:e.sender,voteKey:e.voteKey,selectionKey:e.selectionKey,voteFirst:e.voteFirst,voteLast:e.voteLast,voteKeyDilution:e.voteKeyDilution,suggestedParams:t,nonParticipation:!1,stateProofKey:e.stateProofKey}):this.commonTxnBuildStep(Oe.makeKeyRegistrationTxnWithSuggestedParamsFromObject,e,{sender:e.sender,suggestedParams:t,nonParticipation:e.preventAccountFromEverParticipatingAgain})}async buildTxn(e,t){switch(e.type){case"pay":return[this.buildPayment(e,t)];case"assetCreate":return[this.buildAssetCreate(e,t)];case"appCall":return[await this.buildAppCall(e,t)];case"assetConfig":return[this.buildAssetConfig(e,t)];case"assetDestroy":return[this.buildAssetDestroy(e,t)];case"assetFreeze":return[this.buildAssetFreeze(e,t)];case"assetTransfer":return[this.buildAssetTransfer(e,t)];case"assetOptIn":return[this.buildAssetTransfer({...e,receiver:e.sender,amount:0n},t)];case"assetOptOut":return[this.buildAssetTransfer({...e,receiver:e.sender,amount:0n,closeAssetTo:e.creator},t)];case"keyReg":return[this.buildKeyReg(e,t)];default:throw Error("Unsupported txn type")}}async buildTxnWithSigner(e,t){if(e.type==="txnWithSigner")return[{...e,context:{}}];if(e.type==="atc")return this.buildAtc(e.atc);if(e.type==="methodCall")return await this.buildMethodCall(e,t,!0);const r=e.signer?"signer"in e.signer?e.signer.signer:e.signer:this.getSigner(e.sender);return(await this.buildTxn(e,t)).map(({txn:i,context:o})=>({txn:i,signer:r,context:o}))}async buildTransactions(){const e=await this.getSuggestedParams(),t=[],r=new Map,i=new Map;for(const o of this.txns)["txnWithSigner","atc","methodCall"].includes(o.type)?(o.type==="txnWithSigner"?[o]:o.type==="atc"?this.buildAtc(o.atc):o.type==="methodCall"?await this.buildMethodCall(o,e,!1):[]).forEach(a=>{t.push(a.txn);const l=t.length-1;a.signer&&a.signer!==zr.NULL_SIGNER&&i.set(l,a.signer),"context"in a&&a.context.abiMethod&&r.set(l,a.context.abiMethod)}):t.push(...(await this.buildTxn(o,e)).map(s=>s.txn));return{transactions:t,methodCalls:r,signers:i}}async count(){return(await this.buildTransactions()).transactions.length}async build(){if(this.atc.getStatus()===Oe.AtomicTransactionComposerStatus.BUILDING){const t=await this.getSuggestedParams(),r=[];for(const o of this.txns)r.push(...await this.buildTxnWithSigner(o,t));const i=new Map;r.forEach(({context:o,...s},a)=>{this.atc.addTransaction(s),o.abiMethod&&i.set(a,o.abiMethod),o.maxFee!==void 0&&this.txnMaxFees.set(a,o.maxFee)}),this.atc.methodCalls=i}const e=this.atc.buildGroup();return{atc:this.atc,transactions:e,methodCalls:this.atc.methodCalls}}async rebuild(){return this.atc=new Oe.AtomicTransactionComposer,await this.build()}async send(e){const t=(await this.build()).transactions;let r=e==null?void 0:e.maxRoundsToWaitForConfirmation;const i=r===void 0||e!=null&&e.coverAppCallInnerTransactionFees?await this.getSuggestedParams():void 0;if(r===void 0){const o=t.reduce((a,l)=>l.txn.lastValid>a?l.txn.lastValid:BigInt(a),0n),{firstValid:s}=i;r=Number(BigInt(o)-BigInt(s))+1}try{return await MM({atc:this.atc,suppressLog:e==null?void 0:e.suppressLog,maxRoundsToWaitForConfirmation:r,populateAppCallResources:e==null?void 0:e.populateAppCallResources,coverAppCallInnerTransactionFees:e==null?void 0:e.coverAppCallInnerTransactionFees,additionalAtcContext:e!=null&&e.coverAppCallInnerTransactionFees?{maxFees:this.txnMaxFees,suggestedParams:i}:void 0},this.algod)}catch(o){throw await this.transformError(o)}}async execute(e){return this.send(e)}async simulate(e){var d;const{skipSignatures:t=!1,...r}=e??{},i=t?new PM:this.atc;if(t){r.allowEmptySignatures=!0,r.fixSigners=!0;const u=await this.buildTransactions();for(const m of u.transactions)i.addTransaction({txn:m,signer:zr.NULL_SIGNER});i.methodCalls=u.methodCalls}else await this.build();const{methodResults:o,simulateResponse:s}=await i.simulate(this.algod,new Zy.SimulateRequest({txnGroups:[],...r,...ft.debug?{allowEmptySignatures:!0,fixSigners:!0,allowMoreLogging:!0,execTraceConfig:new Zy.SimulateTraceConfig({enable:!0,scratchChange:!0,stackChange:!0,stateChange:!0})}:void 0})),a=s==null?void 0:s.txnGroups[0];if(a!=null&&a.failureMessage){const u=`Transaction failed at transaction(s) ${((d=a.failedAt)==null?void 0:d.join(", "))||"unknown"} in the group. ${a.failureMessage}`,m=new Error(u);throw ft.debug&&await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:s}),await this.transformError(m)}ft.debug&&ft.traceAll&&await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:s});const l=i.buildGroup().map(u=>u.txn),c=[...i.methodCalls.values()];return{confirmations:s.txnGroups[0].txnResults.map(u=>u.txnResult),transactions:l,txIds:l.map(u=>u.txID()),groupId:Buffer.from(l[0].group??new Uint8Array).toString("base64"),simulateResponse:s,returns:o.map((u,m)=>Bg(u,c[m].returns.type))}}static arc2Note(e){const t=`${e.dAppName}:${e.format}${typeof e.data=="string"?e.data:ea(e.data)}`;return new TextEncoder().encode(t)}}zr.NULL_SIGNER=Oe.makeEmptyTransactionSigner();function Qy(n){return{address:typeof n.address=="string"?ze.fromString(n.address):n.address,appIndex:n.appId,assetIndex:n.assetId,holding:n.holding?$M(n.holding):void 0,locals:n.locals?_M(n.locals):void 0,box:n.box?Qn.getBoxReference(n.box):void 0}}function $M(n){return{assetIndex:n.assetId,address:typeof n.address=="string"?ze.fromString(n.address):n.address}}function _M(n){return{appIndex:n.appId,address:typeof n.address=="string"?ze.fromString(n.address):n.address}}class UM{constructor(e,t){this._algod=e,this._newGroup=t}async getById(e){const t=await this._algod.getAssetByID(Number(e)).do();return{assetId:BigInt(t.index),total:BigInt(t.params.total),decimals:Number(t.params.decimals),assetName:t.params.name,assetNameAsBytes:t.params.nameB64,unitName:t.params.unitName,unitNameAsBytes:t.params.unitNameB64,url:t.params.url,urlAsBytes:t.params.urlB64,creator:t.params.creator,manager:t.params.manager,clawback:t.params.clawback,freeze:t.params.freeze,reserve:t.params.reserve,defaultFrozen:t.params.defaultFrozen,metadataHash:t.params.metadataHash}}async getAccountInformation(e,t){var i,o;const r=await this._algod.accountAssetInformation(e,Number(t)).do();return{assetId:BigInt(t),balance:BigInt(((i=r.assetHolding)==null?void 0:i.amount)??0),frozen:((o=r.assetHolding)==null?void 0:o.isFrozen)===!0,round:BigInt(r.round)}}async bulkOptIn(e,t,r){var o,s;const i=[];for(const a of Yy(t,Jy)){const l=this._newGroup();for(const d of a)l.addAssetOptIn({...r,sender:e,assetId:BigInt(d)});const c=await l.send(r);ft.getLogger(r==null?void 0:r.suppressLog).info(`Successfully opted in ${e} for assets ${a.join(", ")} with transaction IDs ${c.txIds.join(", ")}
227
+ `)}const BM=(n,e,t=0,r)=>{const i=n.length;let o=t;for(;o<i;){const s=Ng(n,e,o,i);if(s===void 0)break;const a=s+e.length;if((s===0||!Xy(n[s-1]))&&(a>=n.length||!Xy(n[a])))return s;o=a}};function Xy(n){return n.length===1&&(/\w/.test(n)||n==="_")}const ef=({method:n,args:e})=>`${n.name}(${(e??[]).map(t=>typeof t=="object"?ea(t,(r,i)=>{const o=Xv(r,i);return o instanceof Uint8Array?nn.Buffer.from(o).toString("base64"):o}):t)})`;class NM{constructor(e,t,r){this.payment=this._send(i=>i.addPayment,{preLog:(i,o)=>`Sending ${i.amount.microAlgo} µALGO from ${i.sender} to ${i.receiver} via transaction ${o.txID()}`}),this.assetCreate=async i=>{const o=await this._send(s=>s.addAssetCreate,{postLog:(s,a)=>`Created asset${s.assetName?` ${s.assetName}`:""}${s.unitName?` (${s.unitName})`:""} with ${s.total} units and ${s.decimals??0} decimals created by ${s.sender} with ID ${a.confirmation.assetIndex} via transaction ${a.txIds.at(-1)}`})(i);return{...o,assetId:BigInt(o.confirmation.assetIndex??0)}},this.assetConfig=this._send(i=>i.addAssetConfig,{preLog:(i,o)=>`Configuring asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetFreeze=this._send(i=>i.addAssetFreeze,{preLog:(i,o)=>`Freezing asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetDestroy=this._send(i=>i.addAssetDestroy,{preLog:(i,o)=>`Destroying asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetTransfer=this._send(i=>i.addAssetTransfer,{preLog:(i,o)=>`Transferring ${i.amount} units of asset with ID ${i.assetId} from ${i.sender} to ${i.receiver} via transaction ${o.txID()}`}),this.assetOptIn=this._send(i=>i.addAssetOptIn,{preLog:(i,o)=>`Opting in ${i.sender} to asset with ID ${i.assetId} via transaction ${o.txID()}`}),this.assetOptOut=async i=>{if(i.ensureZeroBalance){let o=0n;try{o=(await this._assetManager.getAccountInformation(i.sender,i.assetId)).balance}catch{throw new Error(`Account ${i.sender} is not opted-in to Asset ${i.assetId}; can't opt-out.`)}if(o!==0n)throw new Error(`Account ${i.sender} does not have a zero balance for Asset ${i.assetId}; can't opt-out.`)}return i.creator=i.creator??(await this._assetManager.getById(i.assetId)).creator,await this._send(o=>o.addAssetOptOut,{preLog:(o,s)=>`Opting ${o.sender} out of asset with ID ${o.assetId} to creator ${o.creator} via transaction ${s.txID()}`})(i)},this.appCreate=this._sendAppCreateCall(i=>i.addAppCreate,{postLog:(i,o)=>`App created by ${i.sender} with ID ${o.confirmation.applicationIndex} via transaction ${o.txIds.at(-1)}`}),this.appUpdate=this._sendAppUpdateCall(i=>i.addAppUpdate,{postLog:(i,o)=>`App ${i.appId} updated ${i.args?` with ${i.args.map(s=>nn.Buffer.from(s).toString("base64"))}`:""} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appDelete=this._sendAppCall(i=>i.addAppDelete,{postLog:(i,o)=>`App ${i.appId} deleted ${i.args?` with ${i.args.map(s=>nn.Buffer.from(s).toString("base64"))}`:""} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appCall=this._sendAppCall(i=>i.addAppCall,{postLog:(i,o)=>`App ${i.appId} called ${i.args?` with ${i.args.map(s=>nn.Buffer.from(s).toString("base64"))}`:""} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appCreateMethodCall=this._sendAppCreateCall(i=>i.addAppCreateMethodCall,{postLog:(i,o)=>`App created by ${i.sender} with ID ${o.confirmation.applicationIndex} via transaction ${o.txIds.at(-1)}`}),this.appUpdateMethodCall=this._sendAppUpdateCall(i=>i.addAppUpdateMethodCall,{postLog:(i,o)=>`App ${i.appId} updated with ${ef(i)} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appDeleteMethodCall=this._sendAppCall(i=>i.addAppDeleteMethodCall,{postLog:(i,o)=>`App ${i.appId} deleted with ${ef(i)} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.appCallMethodCall=this._sendAppCall(i=>i.addAppCallMethodCall,{postLog:(i,o)=>`App ${i.appId} called with ${ef(i)} by ${i.sender} via transaction ${o.txIds.at(-1)}`}),this.onlineKeyRegistration=this._send(i=>i.addOnlineKeyRegistration,{preLog:(i,o)=>`Registering online key for ${i.sender} via transaction ${o.txID()}`}),this.offlineKeyRegistration=this._send(i=>i.addOfflineKeyRegistration,{preLog:(i,o)=>`Registering offline key for ${i.sender} via transaction ${o.txID()}`}),this._newGroup=e,this._assetManager=t,this._appManager=r}newGroup(){return this._newGroup()}_send(e,t){return async r=>{const i=this._newGroup();if(e(i).apply(i,[r]),t!=null&&t.preLog){const a=(await i.build()).transactions.at(-1).txn;ft.getLogger(r==null?void 0:r.suppressLog).debug(t.preLog(r,a))}const o=await i.send(r),s={transaction:o.transactions.at(-1),confirmation:o.confirmations.at(-1),txId:o.txIds.at(-1),...o};return t!=null&&t.postLog&&ft.getLogger(r==null?void 0:r.suppressLog).debug(t.postLog(r,s)),s}}_sendAppCall(e,t){return async r=>{const i=await this._send(e,t)(r);return{...i,return:Qn.getABIReturn(i.confirmation,"method"in r?r.method:void 0)}}}_sendAppUpdateCall(e,t){return async r=>{const i=await this._sendAppCall(e,t)(r),o=typeof r.approvalProgram=="string"?this._appManager.getCompilationResult(r.approvalProgram):void 0,s=typeof r.clearStateProgram=="string"?this._appManager.getCompilationResult(r.clearStateProgram):void 0;return{...i,compiledApproval:o,compiledClear:s}}}_sendAppCreateCall(e,t){return async r=>{const i=await this._sendAppUpdateCall(e,t)(r);return{...i,appId:BigInt(i.confirmation.applicationIndex),appAddress:Le.getApplicationAddress(i.confirmation.applicationIndex)}}}}function Zv(n){return n==="devnet-v1"||n==="sandnet-v1"||n==="dockernet-v1"}var PM=Le.AtomicTransactionComposer,tf=Le.isTransactionWithSigner,Zy=Le.modelsv2;const OM=n=>typeof n=="string"?ze.fromString(n):n,Jy=16;class LM extends Error{constructor(e,t){super(`An error transformer returned a non-error value: ${t}. The original error before any transformation: ${e}`)}}class VM extends Error{constructor(e,t){super(`An error transformer threw an error: ${t}. The original error before any transformation: ${e} `,{cause:t})}}class zr{async transformError(e){if(!(e instanceof Error))return e;let t=e;for(const r of this.errorTransformers)try{if(t=await r(t),!(t instanceof Error))return new LM(e,t)}catch(i){return new VM(e,i)}return t}constructor(e){this.atc=new Le.AtomicTransactionComposer,this.txnMaxFees=new Map,this.txns=[],this.defaultValidityWindow=10n,this.defaultValidityWindowIsExplicit=!1,this.algod=e.algod;const t=()=>e.algod.getTransactionParams().do();this.getSuggestedParams=e.getSuggestedParams??t,this.getSigner=e.getSigner,this.defaultValidityWindow=e.defaultValidityWindow??this.defaultValidityWindow,this.defaultValidityWindowIsExplicit=e.defaultValidityWindow!==void 0,this.appManager=e.appManager??new Qn(e.algod),this.errorTransformers=e.errorTransformers??[]}registerErrorTransformer(e){return this.errorTransformers.push(e),this}addTransaction(e,t){return this.txns.push({txn:e,signer:t??this.getSigner(e.sender),type:"txnWithSigner"}),this}addPayment(e){return this.txns.push({...e,type:"pay"}),this}addAssetCreate(e){return this.txns.push({...e,type:"assetCreate"}),this}addAssetConfig(e){return this.txns.push({...e,type:"assetConfig"}),this}addAssetFreeze(e){return this.txns.push({...e,type:"assetFreeze"}),this}addAssetDestroy(e){return this.txns.push({...e,type:"assetDestroy"}),this}addAssetTransfer(e){return this.txns.push({...e,type:"assetTransfer"}),this}addAssetOptIn(e){return this.txns.push({...e,type:"assetOptIn"}),this}addAssetOptOut(e){return this.txns.push({...e,type:"assetOptOut"}),this}addAppCreate(e){return this.txns.push({...e,type:"appCall"}),this}addAppUpdate(e){return this.txns.push({...e,type:"appCall",onComplete:Le.OnApplicationComplete.UpdateApplicationOC}),this}addAppDelete(e){return this.txns.push({...e,type:"appCall",onComplete:Le.OnApplicationComplete.DeleteApplicationOC}),this}addAppCall(e){return this.txns.push({...e,type:"appCall"}),this}addAppCreateMethodCall(e){return this.txns.push({...e,type:"methodCall"}),this}addAppUpdateMethodCall(e){return this.txns.push({...e,type:"methodCall",onComplete:Le.OnApplicationComplete.UpdateApplicationOC}),this}addAppDeleteMethodCall(e){return this.txns.push({...e,type:"methodCall",onComplete:Le.OnApplicationComplete.DeleteApplicationOC}),this}addAppCallMethodCall(e){return this.txns.push({...e,type:"methodCall"}),this}addOnlineKeyRegistration(e){return this.txns.push({...e,type:"keyReg"}),this}addOfflineKeyRegistration(e){return this.txns.push({...e,type:"keyReg"}),this}addAtc(e){return this.txns.push({atc:e,type:"atc"}),this}buildAtc(e){return e.buildGroup().map((i,o)=>(i.txn.group=void 0,e.methodCalls.get(o)?{...i,context:{abiMethod:e.methodCalls.get(o)}}:{...i,context:{}}))}commonTxnBuildStep(e,t,r){var a;r.suggestedParams={...r.suggestedParams},t.lease&&(r.lease=FM(t.lease)),t.rekeyTo&&(r.rekeyTo=OM(t.rekeyTo));const i=new TextEncoder;if(t.note&&(r.note=typeof t.note=="string"?i.encode(t.note):t.note),t.firstValidRound&&(r.suggestedParams.firstValid=t.firstValidRound),t.lastValidRound)r.suggestedParams.lastValid=t.lastValidRound;else{const l=t.validityWindow?BigInt(t.validityWindow):!this.defaultValidityWindowIsExplicit&&Zv(r.suggestedParams.genesisID??"unknown")?1000n:this.defaultValidityWindow;r.suggestedParams.lastValid=BigInt(r.suggestedParams.firstValid)+l}if(t.staticFee!==void 0&&t.extraFee!==void 0)throw Error("Cannot set both staticFee and extraFee");t.staticFee!==void 0&&(r.suggestedParams.fee=t.staticFee.microAlgo,r.suggestedParams.flatFee=!0);const o=e(r);if(t.extraFee&&(o.fee+=t.extraFee.microAlgo),t.maxFee!==void 0&&o.fee>t.maxFee.microAlgo)throw Error(`Transaction fee ${o.fee} µALGO is greater than maxFee ${t.maxFee}`);const s=t.maxFee!==void 0&&t.maxFee.microAlgo>(((a=t.staticFee)==null?void 0:a.microAlgo)??0n)?t.maxFee:t.staticFee;return{txn:o,context:{maxFee:s}}}async buildMethodCall(e,t,r){var x,A,v,F,w,C,M,N;const i=[],o=[],s=b=>Array.isArray(b)?b.length==0||b.every(s):typeof b=="bigint"||typeof b=="boolean"||typeof b=="number"||typeof b=="string"||b instanceof Uint8Array||b instanceof Le.Address;for(let b=(e.args??[]).length-1;b>=0;b--){const j=e.args[b];if(j===void 0){if(Le.abiTypeIsTransaction(e.method.args[b].type)&&o.length>0){const E=o.splice(-1,1)[0];i.push(E);continue}throw Error(`No value provided for argument ${b+1} within call to ${e.method.name}`)}if(s(j)){i.push(j);continue}if(tf(j)){i.push(j);continue}if("method"in j){const E=await this.buildMethodCall(j,t,r);i.push(...E.slice(-1)),o.push(...E.slice(0,-1).reverse());continue}const p=await j;i.push({txn:p,signer:r?e.signer?"signer"in e.signer?e.signer.signer:e.signer:this.getSigner(p.sender):zr.NULL_SIGNER})}const a=new Le.AtomicTransactionComposer,l=new Map;o.reverse().forEach(({context:b,...j})=>{a.addTransaction(j);const p=a.count()-1;b.abiMethod&&a.methodCalls.set(p,b.abiMethod),b.maxFee!==void 0&&l.set(p,b.maxFee)}),i.filter(b=>{if(typeof b=="object"&&"context"in b){const{context:j,...p}=b;return tf(p)}return tf(b)}).reverse().forEach((b,j)=>{if(typeof b=="object"&&"context"in b&&b.context){const p=a.count()+j;b.context.abiMethod&&a.methodCalls.set(p,b.context.abiMethod),b.context.maxFee!==void 0&&l.set(p,b.context.maxFee)}});const c=Number("appId"in e?e.appId:0n),d="approvalProgram"in e?typeof e.approvalProgram=="string"?(await this.appManager.compileTeal(e.approvalProgram)).compiledBase64ToBytes:e.approvalProgram:void 0,u="clearStateProgram"in e?typeof e.clearStateProgram=="string"?(await this.appManager.compileTeal(e.clearStateProgram)).compiledBase64ToBytes:e.clearStateProgram:void 0,m={appID:c,sender:e.sender,suggestedParams:t,onComplete:e.onComplete??Le.OnApplicationComplete.NoOpOC,appAccounts:e.accountReferences,appForeignApps:(x=e.appReferences)==null?void 0:x.map(b=>Number(b)),appForeignAssets:(A=e.assetReferences)==null?void 0:A.map(b=>Number(b)),boxes:(v=e.boxReferences)==null?void 0:v.map(Qn.getBoxReference),access:(F=e.accessReferences)==null?void 0:F.map(Qy),approvalProgram:d,clearProgram:u,extraPages:c===0?"extraProgramPages"in e&&e.extraProgramPages!==void 0?e.extraProgramPages:d?jp(d,u):0:void 0,numLocalInts:c===0?"schema"in e?((w=e.schema)==null?void 0:w.localInts)??0:0:void 0,numLocalByteSlices:c===0?"schema"in e?((C=e.schema)==null?void 0:C.localByteSlices)??0:0:void 0,numGlobalInts:c===0?"schema"in e?((M=e.schema)==null?void 0:M.globalInts)??0:0:void 0,numGlobalByteSlices:c===0?"schema"in e?((N=e.schema)==null?void 0:N.globalByteSlices)??0:0:void 0,method:e.method,signer:r?e.signer?"signer"in e.signer?e.signer.signer:e.signer:this.getSigner(e.sender):zr.NULL_SIGNER,methodArgs:i.map(b=>{if(typeof b=="object"&&"context"in b){const{context:j,...p}=b;return p}return b}).reverse(),rejectVersion:e.rejectVersion,note:void 0,lease:void 0,rekeyTo:void 0},h=this.commonTxnBuildStep(b=>(a.addMethodCall(b),a.buildGroup()[a.count()-1].txn),e,m);return this.buildAtc(a).map(({context:b,...j},p)=>{const E=p===a.count()-1?h.context.maxFee:l.get(p),S={...b,maxFee:E};return{...j,context:S}})}buildPayment(e,t){return this.commonTxnBuildStep(Le.makePaymentTxnWithSuggestedParamsFromObject,e,{sender:e.sender,receiver:e.receiver,amount:e.amount.microAlgo,closeRemainderTo:e.closeRemainderTo,suggestedParams:t})}buildAssetCreate(e,t){return this.commonTxnBuildStep(Le.makeAssetCreateTxnWithSuggestedParamsFromObject,e,{sender:e.sender,total:e.total,decimals:e.decimals??0,assetName:e.assetName,unitName:e.unitName,assetURL:e.url,defaultFrozen:e.defaultFrozen??!1,assetMetadataHash:typeof e.metadataHash=="string"?Buffer.from(e.metadataHash,"utf-8"):e.metadataHash,manager:e.manager,reserve:e.reserve,freeze:e.freeze,clawback:e.clawback,suggestedParams:t})}buildAssetConfig(e,t){return this.commonTxnBuildStep(Le.makeAssetConfigTxnWithSuggestedParamsFromObject,e,{sender:e.sender,assetIndex:e.assetId,suggestedParams:t,manager:e.manager,reserve:e.reserve,freeze:e.freeze,clawback:e.clawback,strictEmptyAddressChecking:!1})}buildAssetDestroy(e,t){return this.commonTxnBuildStep(Le.makeAssetDestroyTxnWithSuggestedParamsFromObject,e,{sender:e.sender,assetIndex:e.assetId,suggestedParams:t})}buildAssetFreeze(e,t){return this.commonTxnBuildStep(Le.makeAssetFreezeTxnWithSuggestedParamsFromObject,e,{sender:e.sender,assetIndex:e.assetId,freezeTarget:e.account,frozen:e.frozen,suggestedParams:t})}buildAssetTransfer(e,t){return this.commonTxnBuildStep(Le.makeAssetTransferTxnWithSuggestedParamsFromObject,e,{sender:e.sender,receiver:e.receiver,assetIndex:e.assetId,amount:e.amount,suggestedParams:t,closeRemainderTo:e.closeAssetTo,assetSender:e.clawbackTarget})}async buildAppCall(e,t){var a,l,c,d,u,m,h,x;const r="appId"in e?e.appId:0n,i="approvalProgram"in e?typeof e.approvalProgram=="string"?(await this.appManager.compileTeal(e.approvalProgram)).compiledBase64ToBytes:e.approvalProgram:void 0,o="clearStateProgram"in e?typeof e.clearStateProgram=="string"?(await this.appManager.compileTeal(e.clearStateProgram)).compiledBase64ToBytes:e.clearStateProgram:void 0,s={sender:e.sender,suggestedParams:t,appArgs:e.args,onComplete:e.onComplete??Le.OnApplicationComplete.NoOpOC,accounts:e.accountReferences,foreignApps:(a=e.appReferences)==null?void 0:a.map(A=>Number(A)),foreignAssets:(l=e.assetReferences)==null?void 0:l.map(A=>Number(A)),boxes:(c=e.boxReferences)==null?void 0:c.map(Qn.getBoxReference),access:(d=e.accessReferences)==null?void 0:d.map(Qy),approvalProgram:i,clearProgram:o,rejectVersion:e.rejectVersion};if(r===0n){if(s.approvalProgram===void 0||s.clearProgram===void 0)throw new Error("approvalProgram and clearStateProgram are required for application creation");return this.commonTxnBuildStep(Le.makeApplicationCreateTxnFromObject,e,{...s,extraPages:"extraProgramPages"in e&&e.extraProgramPages!==void 0?e.extraProgramPages:jp(i,o),numLocalInts:"schema"in e?((u=e.schema)==null?void 0:u.localInts)??0:0,numLocalByteSlices:"schema"in e?((m=e.schema)==null?void 0:m.localByteSlices)??0:0,numGlobalInts:"schema"in e?((h=e.schema)==null?void 0:h.globalInts)??0:0,numGlobalByteSlices:"schema"in e?((x=e.schema)==null?void 0:x.globalByteSlices)??0:0,approvalProgram:i,clearProgram:o})}else return this.commonTxnBuildStep(Le.makeApplicationCallTxnFromObject,e,{...s,appIndex:r})}buildKeyReg(e,t){return"voteKey"in e?this.commonTxnBuildStep(Le.makeKeyRegistrationTxnWithSuggestedParamsFromObject,e,{sender:e.sender,voteKey:e.voteKey,selectionKey:e.selectionKey,voteFirst:e.voteFirst,voteLast:e.voteLast,voteKeyDilution:e.voteKeyDilution,suggestedParams:t,nonParticipation:!1,stateProofKey:e.stateProofKey}):this.commonTxnBuildStep(Le.makeKeyRegistrationTxnWithSuggestedParamsFromObject,e,{sender:e.sender,suggestedParams:t,nonParticipation:e.preventAccountFromEverParticipatingAgain})}async buildTxn(e,t){switch(e.type){case"pay":return[this.buildPayment(e,t)];case"assetCreate":return[this.buildAssetCreate(e,t)];case"appCall":return[await this.buildAppCall(e,t)];case"assetConfig":return[this.buildAssetConfig(e,t)];case"assetDestroy":return[this.buildAssetDestroy(e,t)];case"assetFreeze":return[this.buildAssetFreeze(e,t)];case"assetTransfer":return[this.buildAssetTransfer(e,t)];case"assetOptIn":return[this.buildAssetTransfer({...e,receiver:e.sender,amount:0n},t)];case"assetOptOut":return[this.buildAssetTransfer({...e,receiver:e.sender,amount:0n,closeAssetTo:e.creator},t)];case"keyReg":return[this.buildKeyReg(e,t)];default:throw Error("Unsupported txn type")}}async buildTxnWithSigner(e,t){if(e.type==="txnWithSigner")return[{...e,context:{}}];if(e.type==="atc")return this.buildAtc(e.atc);if(e.type==="methodCall")return await this.buildMethodCall(e,t,!0);const r=e.signer?"signer"in e.signer?e.signer.signer:e.signer:this.getSigner(e.sender);return(await this.buildTxn(e,t)).map(({txn:i,context:o})=>({txn:i,signer:r,context:o}))}async buildTransactions(){const e=await this.getSuggestedParams(),t=[],r=new Map,i=new Map;for(const o of this.txns)["txnWithSigner","atc","methodCall"].includes(o.type)?(o.type==="txnWithSigner"?[o]:o.type==="atc"?this.buildAtc(o.atc):o.type==="methodCall"?await this.buildMethodCall(o,e,!1):[]).forEach(a=>{t.push(a.txn);const l=t.length-1;a.signer&&a.signer!==zr.NULL_SIGNER&&i.set(l,a.signer),"context"in a&&a.context.abiMethod&&r.set(l,a.context.abiMethod)}):t.push(...(await this.buildTxn(o,e)).map(s=>s.txn));return{transactions:t,methodCalls:r,signers:i}}async count(){return(await this.buildTransactions()).transactions.length}async build(){if(this.atc.getStatus()===Le.AtomicTransactionComposerStatus.BUILDING){const t=await this.getSuggestedParams(),r=[];for(const o of this.txns)r.push(...await this.buildTxnWithSigner(o,t));const i=new Map;r.forEach(({context:o,...s},a)=>{this.atc.addTransaction(s),o.abiMethod&&i.set(a,o.abiMethod),o.maxFee!==void 0&&this.txnMaxFees.set(a,o.maxFee)}),this.atc.methodCalls=i}const e=this.atc.buildGroup();return{atc:this.atc,transactions:e,methodCalls:this.atc.methodCalls}}async rebuild(){return this.atc=new Le.AtomicTransactionComposer,await this.build()}async send(e){const t=(await this.build()).transactions;let r=e==null?void 0:e.maxRoundsToWaitForConfirmation;const i=r===void 0||e!=null&&e.coverAppCallInnerTransactionFees?await this.getSuggestedParams():void 0;if(r===void 0){const o=t.reduce((a,l)=>l.txn.lastValid>a?l.txn.lastValid:BigInt(a),0n),{firstValid:s}=i;r=Number(BigInt(o)-BigInt(s))+1}try{return await MM({atc:this.atc,suppressLog:e==null?void 0:e.suppressLog,maxRoundsToWaitForConfirmation:r,populateAppCallResources:e==null?void 0:e.populateAppCallResources,coverAppCallInnerTransactionFees:e==null?void 0:e.coverAppCallInnerTransactionFees,additionalAtcContext:e!=null&&e.coverAppCallInnerTransactionFees?{maxFees:this.txnMaxFees,suggestedParams:i}:void 0},this.algod)}catch(o){throw await this.transformError(o)}}async execute(e){return this.send(e)}async simulate(e){var d;const{skipSignatures:t=!1,...r}=e??{},i=t?new PM:this.atc;if(t){r.allowEmptySignatures=!0,r.fixSigners=!0;const u=await this.buildTransactions();for(const m of u.transactions)i.addTransaction({txn:m,signer:zr.NULL_SIGNER});i.methodCalls=u.methodCalls}else await this.build();const{methodResults:o,simulateResponse:s}=await i.simulate(this.algod,new Zy.SimulateRequest({txnGroups:[],...r,...ft.debug?{allowEmptySignatures:!0,fixSigners:!0,allowMoreLogging:!0,execTraceConfig:new Zy.SimulateTraceConfig({enable:!0,scratchChange:!0,stackChange:!0,stateChange:!0})}:void 0})),a=s==null?void 0:s.txnGroups[0];if(a!=null&&a.failureMessage){const u=`Transaction failed at transaction(s) ${((d=a.failedAt)==null?void 0:d.join(", "))||"unknown"} in the group. ${a.failureMessage}`,m=new Error(u);throw ft.debug&&await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:s}),await this.transformError(m)}ft.debug&&ft.traceAll&&await ft.events.emitAsync(Ps.TxnGroupSimulated,{simulateResponse:s});const l=i.buildGroup().map(u=>u.txn),c=[...i.methodCalls.values()];return{confirmations:s.txnGroups[0].txnResults.map(u=>u.txnResult),transactions:l,txIds:l.map(u=>u.txID()),groupId:Buffer.from(l[0].group??new Uint8Array).toString("base64"),simulateResponse:s,returns:o.map((u,m)=>Bg(u,c[m].returns.type))}}static arc2Note(e){const t=`${e.dAppName}:${e.format}${typeof e.data=="string"?e.data:ea(e.data)}`;return new TextEncoder().encode(t)}}zr.NULL_SIGNER=Le.makeEmptyTransactionSigner();function Qy(n){return{address:typeof n.address=="string"?ze.fromString(n.address):n.address,appIndex:n.appId,assetIndex:n.assetId,holding:n.holding?$M(n.holding):void 0,locals:n.locals?_M(n.locals):void 0,box:n.box?Qn.getBoxReference(n.box):void 0}}function $M(n){return{assetIndex:n.assetId,address:typeof n.address=="string"?ze.fromString(n.address):n.address}}function _M(n){return{appIndex:n.appId,address:typeof n.address=="string"?ze.fromString(n.address):n.address}}class UM{constructor(e,t){this._algod=e,this._newGroup=t}async getById(e){const t=await this._algod.getAssetByID(Number(e)).do();return{assetId:BigInt(t.index),total:BigInt(t.params.total),decimals:Number(t.params.decimals),assetName:t.params.name,assetNameAsBytes:t.params.nameB64,unitName:t.params.unitName,unitNameAsBytes:t.params.unitNameB64,url:t.params.url,urlAsBytes:t.params.urlB64,creator:t.params.creator,manager:t.params.manager,clawback:t.params.clawback,freeze:t.params.freeze,reserve:t.params.reserve,defaultFrozen:t.params.defaultFrozen,metadataHash:t.params.metadataHash}}async getAccountInformation(e,t){var i,o;const r=await this._algod.accountAssetInformation(e,Number(t)).do();return{assetId:BigInt(t),balance:BigInt(((i=r.assetHolding)==null?void 0:i.amount)??0),frozen:((o=r.assetHolding)==null?void 0:o.isFrozen)===!0,round:BigInt(r.round)}}async bulkOptIn(e,t,r){var o,s;const i=[];for(const a of Yy(t,Jy)){const l=this._newGroup();for(const d of a)l.addAssetOptIn({...r,sender:e,assetId:BigInt(d)});const c=await l.send(r);ft.getLogger(r==null?void 0:r.suppressLog).info(`Successfully opted in ${e} for assets ${a.join(", ")} with transaction IDs ${c.txIds.join(", ")}
228
228
  Grouped under ${c.groupId} in round ${(s=(o=c.confirmations)==null?void 0:o[0])==null?void 0:s.confirmedRound}.`),a.forEach((d,u)=>{i.push({assetId:BigInt(d),transactionId:c.txIds[u]})})}return i}async bulkOptOut(e,t,r){var o,s;const i=[];for(const a of Yy(t,Jy)){const l=this._newGroup(),c=[],d=[];for(const m of a)if((r==null?void 0:r.ensureZeroBalance)!==!1)try{(await this.getAccountInformation(e,m)).balance!==0n&&d.push(BigInt(m))}catch{c.push(BigInt(m))}if(c.length>0||d.length>0)throw new Error(`Account ${e}${c.length>0?` is not opted-in to Asset${c.length>1?"s":""} ${c.join(", ")}`:""}${d.length>0?` has non-zero balance for Asset${d.length>1?"s":""} ${d.join(", ")}`:""}; can't opt-out.`);for(const m of a)l.addAssetOptOut({...r,creator:(await this.getById(BigInt(m))).creator,sender:e,assetId:BigInt(m)});const u=await l.send(r);ft.getLogger(r==null?void 0:r.suppressLog).info(`Successfully opted ${e} out of assets ${a.join(", ")} with transaction IDs ${u.txIds.join(", ")}
229
- Grouped under ${u.groupId} in round ${(s=(o=u.confirmations)==null?void 0:o[0])==null?void 0:s.confirmedRound}.`),a.forEach((m,h)=>{i.push({assetId:BigInt(m),transactionId:u.txIds[h]})})}return i}}const Jv=1e3;async function jM(n,e,t=void 0,r){return await Qv(i=>{if("message"in i)throw{status:404,...i};return i.applications},i=>{let o=n.lookupAccountCreatedApplications(e).includeAll(t).limit(Jv);return i&&(o=o.nextToken(i)),o})}async function GM(n,e,t){let r=0n;const i=await Qv(o=>{if("message"in o)throw{status:404,...o};return o.currentRound>r&&(r=o.currentRound),o.transactions},o=>{let s=e(n.searchForTransactions()).limit(Jv);return o&&(s=s.nextToken(o)),s});return new Oe.indexerModels.TransactionsResponse({currentRound:r,nextToken:void 0,transactions:i})}async function Qv(n,e){const t=[];let r;for(;;){const o=await e(r).do(),s=n(o);if(s==null||s.length===0||(t.push(...s),r=o.nextToken,!r))break}return t}class WM{constructor(e,t,r){this._appLookups=new Map,this._appManager=e,this._transactionSender=t,this._indexer=r}async deploy(e){var q,J,U,ne;const{metadata:t,deployTimeParams:r,onSchemaBreak:i,onUpdate:o,createParams:s,updateParams:a,deleteParams:l,existingDeployments:c,ignoreCache:d,...u}=e;if(s.note=a.note=zr.arc2Note({dAppName:$u,data:t,format:"j"}),c&&c.creator.toString()!==s.sender.toString())throw new Error(`Received invalid existingDeployments value for creator ${c.creator} when attempting to deploy for creator ${s.sender}`);if(!c&&!this._indexer)throw new Error("Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided");ft.getLogger(u==null?void 0:u.suppressLog).info(`Idempotently deploying app "${t.name}" from creator ${s.sender} using ${s.approvalProgram.length} bytes of ${typeof s.approvalProgram=="string"?"teal code":"AVM bytecode"} and ${s.clearStateProgram.length} bytes of ${typeof s.approvalProgram=="string"?"teal code":"AVM bytecode"}`);const m=typeof s.approvalProgram=="string"?await this._appManager.compileTealTemplate(s.approvalProgram,r,t):void 0,h=m?m.compiledBase64ToBytes:s.approvalProgram,x=typeof s.clearStateProgram=="string"?await this._appManager.compileTealTemplate(s.clearStateProgram,r):void 0,A=x?x.compiledBase64ToBytes:s.clearStateProgram,v=async()=>{const fe=await("method"in s?this._transactionSender.appCreateMethodCall({...s,approvalProgram:h,clearStateProgram:A,...u}):this._transactionSender.appCreate({...s,approvalProgram:h,clearStateProgram:A,...u})),le={appId:fe.appId,appAddress:fe.appAddress,...t,createdMetadata:t,createdRound:BigInt(fe.confirmation.confirmedRound),updatedRound:BigInt(fe.confirmation.confirmedRound),deleted:!1};return this.updateAppLookup(s.sender,le),{operationPerformed:"create",compiledApproval:m,compiledClear:x,...fe,...le}},F=async fe=>{ft.getLogger(u==null?void 0:u.suppressLog).info(`Updating existing ${t.name} app for ${s.sender} to version ${t.version}.`);const le=await("method"in a?this._transactionSender.appUpdateMethodCall({appId:fe.appId,approvalProgram:h,clearStateProgram:A,...a,...u}):this._transactionSender.appUpdate({appId:fe.appId,approvalProgram:h,clearStateProgram:A,...a,...u})),ye={appId:fe.appId,appAddress:fe.appAddress,createdMetadata:fe.createdMetadata,createdRound:fe.createdRound,updatedRound:BigInt(le.confirmation.confirmedRound),...t,deleted:!1};return this.updateAppLookup(s.sender,ye),{operationPerformed:"update",compiledApproval:m,compiledClear:x,...le,...ye}},w=async fe=>{var De,Te;ft.getLogger(u==null?void 0:u.suppressLog).info(`Deploying a new ${t.name} app for ${s.sender}; deploying app with version ${t.version}.`),ft.getLogger(u==null?void 0:u.suppressLog).warn(`Deleting existing ${t.name} app with id ${fe.appId} from ${l.sender} account.`);const le=this._transactionSender.newGroup();"method"in s?le.addAppCreateMethodCall({...s,approvalProgram:h,clearStateProgram:A}):le.addAppCreate({...s,approvalProgram:h,clearStateProgram:A});const ye=await le.count();"method"in l?le.addAppDeleteMethodCall({appId:fe.appId,...l}):le.addAppDelete({appId:fe.appId,...l});const he=await le.send({...u}),de=he.confirmations.at(ye-1),be=he.transactions.at(ye-1),Ae=he.transactions.at(-1);ft.getLogger(u==null?void 0:u.suppressLog).warn(`Sent transactions ${be.txID()} to create app with id ${de.applicationIndex} and ${Ae.txID()} to delete app with id ${fe.appId} from ${s.sender} account.`);const _e={appId:BigInt(de.applicationIndex),appAddress:Oe.getApplicationAddress(de.applicationIndex),...t,createdMetadata:t,createdRound:BigInt(de.confirmedRound),updatedRound:BigInt(de.confirmedRound),deleted:!1};return this.updateAppLookup(s.sender,_e),{operationPerformed:"replace",...he,compiledApproval:m,compiledClear:x,transaction:be,confirmation:de,return:"method"in s?(De=he.returns)==null?void 0:De[0]:void 0,deleteReturn:"method"in l?(Te=he.returns)==null?void 0:Te.at(-1):void 0,..._e,deleteResult:{transaction:Ae,confirmation:he.confirmations.at(-1)}}},M=(c??await this.getCreatorAppsByName(s.sender,d)).apps[t.name];if(!M||M.deleted)return ft.getLogger(u==null?void 0:u.suppressLog).info(`App ${t.name} not found in apps created by ${s.sender}; deploying app with version ${t.version}.`),await v();ft.getLogger(u==null?void 0:u.suppressLog).info(`Existing app ${t.name} found by creator ${s.sender}, with app id ${M.appId} and version ${M.version}.`);const N=await this._appManager.getById(M.appId),b=Buffer.from(N.approvalProgram).toString("base64"),j=Buffer.from(N.clearStateProgram).toString("base64"),p=N.extraProgramPages??0,E=Buffer.from(h),S=Buffer.from(A),$=E.toString("base64"),B=S.toString("base64"),P=jp(E,S),W=$!==b||B!==j;if(N.localInts<(((q=s.schema)==null?void 0:q.localInts)??0)||N.globalInts<(((J=s.schema)==null?void 0:J.globalInts)??0)||N.localByteSlices<(((U=s.schema)==null?void 0:U.localByteSlices)??0)||N.globalByteSlices<(((ne=s.schema)==null?void 0:ne.globalByteSlices)??0)||p<P){if(ft.getLogger(u==null?void 0:u.suppressLog).warn(`Detected a breaking app schema change in app ${M.appId}:`,{from:{globalInts:N.globalInts,globalByteSlices:N.globalByteSlices,localInts:N.localInts,localByteSlices:N.localByteSlices,extraProgramPages:p},to:{...s.schema,extraProgramPages:P}}),i===void 0||i==="fail"||i===Cd.Fail)throw new Error("Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. If you want to try deleting and recreating the app then re-run with onSchemaBreak=OnSchemaBreak.ReplaceApp");return i==="append"||i===Cd.AppendApp?(ft.getLogger(u==null?void 0:u.suppressLog).info("onSchemaBreak=AppendApp, will attempt to create a new app"),await v()):(M.deletable?ft.getLogger(u==null?void 0:u.suppressLog).info("App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app"):ft.getLogger(u==null?void 0:u.suppressLog).info("App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail"),await w(M))}if(W){if(ft.getLogger(u==null?void 0:u.suppressLog).info(`Detected a TEAL update in app ${M.appId} for creator ${s.sender}`),o===void 0||o==="fail"||o===Hs.Fail)throw new Error("Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.");if(o==="append"||o===Hs.AppendApp)return ft.getLogger(u==null?void 0:u.suppressLog).info("onUpdate=AppendApp, will attempt to create a new app"),await v();if(o==="update"||o===Hs.UpdateApp)return M.updatable?ft.getLogger(u==null?void 0:u.suppressLog).info("App is updatable and onUpdate=UpdateApp, updating app..."):ft.getLogger(u==null?void 0:u.suppressLog).warn("App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail"),await F(M);if(o==="replace"||o===Hs.ReplaceApp)return M.deletable?ft.getLogger(u==null?void 0:u.suppressLog).warn("App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app..."):ft.getLogger(u==null?void 0:u.suppressLog).warn("App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail"),await w(M)}return ft.getLogger(u==null?void 0:u.suppressLog).debug("No detected changes in app, nothing to do."),{...M,operationPerformed:"nothing"}}updateAppLookup(e,t){const r=typeof e=="string"?e:e.toString(),i=this._appLookups.get(r);i?i.apps[t.name]=t:this._appLookups.set(r,{creator:ze.fromString(r),apps:{[t.name]:t}})}async getCreatorAppsByName(e,t){const r={},i=typeof e=="string"?e:e.toString();if(!t&&this._appLookups.has(i))return this._appLookups.get(i);if(!this._indexer)throw new Error("Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps");const o=(await jM(this._indexer,e)).map(l=>({id:l.id,createdAtRound:l.createdAtRound,deleted:l.deleted})).sort((l,c)=>Number(l.createdAtRound-c.createdAtRound));(await Promise.all(o.map(async l=>{const c=await GM(this._indexer,m=>m.minRound(l.createdAtRound).txType(Oe.TransactionType.appl).applicationID(Number(l.id)).address(e).addressRole("sender").notePrefix(Buffer.from($u).toString("base64"))),d=c.transactions.filter(m=>{var h;return((h=m.applicationTransaction)==null?void 0:h.applicationId)===0n&&m.sender.toString()===e.toString()})[0],u=c.transactions.filter(m=>m.sender.toString()===e.toString()).sort((m,h)=>m.confirmedRound===h.confirmedRound?(h.intraRoundOffset-m.intraRoundOffset)/10:Number(h.confirmedRound-m.confirmedRound))[0];return d!=null&&d.note?{createdApp:l,appCreationTransaction:d,latestAppUpdateTransaction:u}:null}))).filter(l=>l!==null).forEach(l=>{const{createdApp:c,appCreationTransaction:d,latestAppUpdateTransaction:u}=l,m=h=>{if(h&&h.startsWith(`${$u}:j{`))return JSON.parse(h.substring($u.length+2))};try{const h=m(d.note?Buffer.from(d.note).toString("utf-8"):void 0),x=m(u.note?Buffer.from(u.note).toString("utf-8"):void 0);h!=null&&h.name&&(r[h.name]={appId:c.id,appAddress:Oe.getApplicationAddress(c.id),createdMetadata:h,createdRound:d.confirmedRound??0n,...x??h,updatedRound:(u==null?void 0:u.confirmedRound)??0n,deleted:c.deleted??!1})}catch(h){ft.logger.warn(`Received error trying to retrieve app with ${c.id} for creator ${e}; failing silently`,h);return}});const a={creator:typeof e=="string"?ze.fromString(e):e,apps:r};return this._appLookups.set(e.toString(),a),a}}class zM extends Oe.ABIMethod{constructor(e){super(e),this.method=e,this.args=e.args.map(t=>({...t,type:Oe.abiTypeIsTransaction(t.type)||Oe.abiTypeIsReference(t.type)?t.type:Oe.ABIType.from(t.type)})),this.returns={...this.method.returns,type:this.method.returns.type==="void"?"void":Oe.ABIType.from(this.method.returns.type)}}toJSON(){return this.method}}function kc(n,e){return new Oe.ABITupleType(n.map(t=>typeof t.type=="string"?e[t.type]?kc(e[t.type],e):Oe.ABIType.from(t.type):kc(t.type,e)))}function Pg(n,e,t){return Object.fromEntries(e.map(({name:r,type:i},o)=>{let s;typeof i=="string"?i in t?s=kc(t[i],t):s=Oe.ABIType.from(i):s=kc(i,t);const a=Ic(n[o],s),l=Xl(a,s);return[r,typeof i=="string"&&!t[i]||!Array.isArray(l)?l:Pg(l,typeof i=="string"?t[i]:i,t)]}))}function Zl(n,e,t){return e.map(({name:r,type:i})=>{const o=n[r];return typeof i=="string"&&!t[i]?o:Zl(o,typeof i=="string"?t[i]:i,t)})}function qn(n,e,t){if(e==="AVMBytes"||typeof n!="object")return n;if(e==="AVMString")return Buffer.from(n).toString("utf-8");if(e==="AVMUint64")return Oe.ABIType.from("uint64").decode(n);if(t[e]){const o=kc(t[e],t).decode(n);return Pg(o,t[e],t)}const r=Oe.ABIType.from(e),i=Ic(r.decode(n),r);return Xl(i,r)}function ew(n,e,t){if(typeof n=="object"&&n instanceof Uint8Array)return n;if(e==="AVMUint64")return Oe.ABIType.from("uint64").encode(n);if(e==="AVMBytes"||e==="AVMString"){if(typeof n=="string")return Buffer.from(n,"utf-8");if(typeof n!="object"||!(n instanceof Uint8Array))throw new Error(`Expected bytes value for ${e}, but got ${n}`);return n}if(t[e]){const r=kc(t[e],t);if(Array.isArray(n))r.encode(n);else return r.encode(Zl(n,t[e],t))}return Oe.ABIType.from(e).encode(n)}function Bn(n,e){let t;if(n.includes("(")){const r=e.methods.find(i=>new Oe.ABIMethod(i).getSignature()===n);if(!r)throw new Error(`Unable to find method ${n} in ${e.name} app.`);t=r}else{const r=e.methods.filter(i=>i.name===n);if(r.length===0)throw new Error(`Unable to find method ${n} in ${e.name} app.`);if(r.length>1)throw new Error(`Received a call to method ${n} in contract ${e.name}, but this resolved to multiple methods; please pass in an ABI signature instead: ${e.methods.map(i=>new Oe.ABIMethod(i).getSignature()).join(", ")}`);t=r[0]}return new zM(t)}function Ys(n,e,t){const r="method"in e?e.method:e,i=r.returns.struct??r.returns.type;if(n!=null&&n.decodeError)throw n.decodeError;if(!(i===void 0||i==="void"||(n==null?void 0:n.returnValue)===void 0))return i==="AVMBytes"?n.rawReturnValue:i==="AVMString"?Buffer.from(n.rawReturnValue).toString("utf-8"):i==="AVMUint64"?Oe.ABIType.from("uint64").decode(n.rawReturnValue):t[i]?Pg(n.returnValue,t[i],t):Ic(n.returnValue,Oe.ABIType.from(i))}var HM=Oe.ABIMethod;function YM(n){const e=Object.values(n.hints).flatMap(l=>Object.entries(l.structs??{})),t=Object.fromEntries(e.map(([l,c])=>{const d=c.elements.map(u=>({name:u[0],type:u[1]}));return[c.name,d]})),r=l=>n.hints[new HM(l).getSignature()],i=(l,c)=>{var d,u;return((d=r(l))==null?void 0:d.call_config)!==void 0?s((u=r(l))==null?void 0:u.call_config,c):[]},o=l=>s(n.bare_call_config,l),s=(l,c)=>{const d=[];return l.close_out&&["ALL",c].includes(l.close_out)&&d.push("CloseOut"),l.delete_application&&["ALL",c].includes(l.delete_application)&&d.push("DeleteApplication"),l.no_op&&["ALL",c].includes(l.no_op)&&d.push("NoOp"),l.opt_in&&["ALL",c].includes(l.opt_in)&&d.push("OptIn"),l.update_application&&["ALL",c].includes(l.update_application)&&d.push("UpdateApplication"),d},a=(l,c)=>{if(c)return c.source==="abi-method"?{source:"method",data:c.data.name}:{source:c.source==="constant"?"literal":c.source==="global-state"?"global":"local",data:Buffer.from(typeof c.data=="number"?Oe.ABIType.from("uint64").encode(c.data):c.data).toString("base64"),type:l==="string"?"AVMString":l}};return{arcs:[],name:n.contract.name,desc:n.contract.desc,structs:t,methods:n.contract.methods.map(l=>{var c,d,u,m;return{name:l.name,desc:l.desc,args:l.args.map(h=>{var x,A,v,F,w;return{name:h.name,type:h.type,desc:h.desc,struct:h.name?(v=(A=(x=r(l))==null?void 0:x.structs)==null?void 0:A[h.name])==null?void 0:v.name:void 0,defaultValue:a(h.type,h.name?(w=(F=r(l))==null?void 0:F.default_arguments)==null?void 0:w[h.name]:void 0)}}),returns:{type:l.returns.type,desc:l.returns.desc,struct:(u=(d=(c=r(l))==null?void 0:c.structs)==null?void 0:d.output)==null?void 0:u.name},events:[],readonly:(m=r(l))==null?void 0:m.read_only,actions:{create:i(l,"CREATE"),call:i(l,"CALL")}}}),state:{schema:{global:{ints:n.state.global.num_uints,bytes:n.state.global.num_byte_slices},local:{ints:n.state.local.num_uints,bytes:n.state.local.num_byte_slices}},keys:{global:Object.fromEntries(Object.entries(n.schema.global.declared).map(l=>[l[0],{key:Buffer.from(l[1].key,"utf-8").toString("base64"),keyType:"AVMString",valueType:l[1].type==="uint64"?"AVMUint64":"AVMBytes",desc:l[1].descr}])),local:Object.fromEntries(Object.entries(n.schema.local.declared).map(l=>[l[0],{key:Buffer.from(l[1].key,"utf-8").toString("base64"),keyType:"AVMString",valueType:l[1].type==="uint64"?"AVMUint64":"AVMBytes",desc:l[1].descr}])),box:{}},maps:{global:{},local:{},box:{}}},source:n.source,bareActions:{create:o("CREATE"),call:o("CALL")},byteCode:void 0,compilerInfo:void 0,events:void 0,networks:void 0,scratchVariables:void 0,sourceInfo:void 0,templateVariables:void 0}}const KM=/transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/,qM=/inner tx (\d+) failed:.*?pc=([0-9]+)/;class nf extends Error{static parseLogicError(e){const t=e.message,r=KM.exec(t),i=qM.exec(t);if(!(r===null||r.length<=3))return{txId:r[1],msg:r[2],desc:t,pc:parseInt((i==null?void 0:i[2])??r[3]??"0"),traces:e.traces}}constructor(e,t,r){super(),this.lines=5,this.teal_line=0,this.led=e,this.program=t;const i=r(e.pc);if(this.teal_line=i===void 0?0:i,this.message=`${this.led.msg}. at:${i}. ${this.led.desc}`,this.teal_line>0){const o=this.teal_line>this.lines?this.teal_line-this.lines:0,s=t.length>this.teal_line+this.lines?this.teal_line+this.lines:t.length,a=t.slice(o,s);a[a.length/2]+=" <--- Error",this.stack=a.join(`
230
- `)}}}var ar=Oe.OnApplicationComplete,tw=Oe.ProgramSourceMap;const XM=2e4*16,rf=38,nw=32;function ZM(n){const e=[...n],t=e.length;e.shift();let r,i;for(;e.length>0;){const o=e.shift();if(o===rf||o===nw){const s=o===rf,a=e.shift();for(let l=0;l<a;l++)if(s){const c=e.shift();e.splice(0,c)}else for(;(e.shift()&128)!==0;);if(s?r=t-e.length-1:i=t-e.length-1,e[0]!==rf&&e[0]!==nw)break}}return Math.max(r??0,i??0)}class cn{constructor(e){this.handleCallErrors=async t=>{var i,o,s,a;if(this.appId===0n){if(t.sentTransactions===void 0)return t;const c=t.sentTransactions.find(u=>t.message.includes(u.txID())),d=(u,m)=>{if(u===void 0||m===void 0||u.length!==m.length)return!1;for(let h=0;h<u.length;h++)if(u[h]!==m[h])return!1;return!0};if(!d((i=c==null?void 0:c.applicationCall)==null?void 0:i.clearProgram,this._lastCompiled.clear)||!d((o=c==null?void 0:c.applicationCall)==null?void 0:o.approvalProgram,(s=this._lastCompiled)==null?void 0:s.approval))return t}else{const l=`app=${this._appId.toString()}`;if(!t.message.includes(l))return t}const r=await this.exposeLogicError(t);if(r instanceof nf){let l=r.teal_line-r.lines-1;const c=(a=r.stack)==null?void 0:a.split(`
229
+ Grouped under ${u.groupId} in round ${(s=(o=u.confirmations)==null?void 0:o[0])==null?void 0:s.confirmedRound}.`),a.forEach((m,h)=>{i.push({assetId:BigInt(m),transactionId:u.txIds[h]})})}return i}}const Jv=1e3;async function jM(n,e,t=void 0,r){return await Qv(i=>{if("message"in i)throw{status:404,...i};return i.applications},i=>{let o=n.lookupAccountCreatedApplications(e).includeAll(t).limit(Jv);return i&&(o=o.nextToken(i)),o})}async function GM(n,e,t){let r=0n;const i=await Qv(o=>{if("message"in o)throw{status:404,...o};return o.currentRound>r&&(r=o.currentRound),o.transactions},o=>{let s=e(n.searchForTransactions()).limit(Jv);return o&&(s=s.nextToken(o)),s});return new Le.indexerModels.TransactionsResponse({currentRound:r,nextToken:void 0,transactions:i})}async function Qv(n,e){const t=[];let r;for(;;){const o=await e(r).do(),s=n(o);if(s==null||s.length===0||(t.push(...s),r=o.nextToken,!r))break}return t}class WM{constructor(e,t,r){this._appLookups=new Map,this._appManager=e,this._transactionSender=t,this._indexer=r}async deploy(e){var q,J,U,ne;const{metadata:t,deployTimeParams:r,onSchemaBreak:i,onUpdate:o,createParams:s,updateParams:a,deleteParams:l,existingDeployments:c,ignoreCache:d,...u}=e;if(s.note=a.note=zr.arc2Note({dAppName:$u,data:t,format:"j"}),c&&c.creator.toString()!==s.sender.toString())throw new Error(`Received invalid existingDeployments value for creator ${c.creator} when attempting to deploy for creator ${s.sender}`);if(!c&&!this._indexer)throw new Error("Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided");ft.getLogger(u==null?void 0:u.suppressLog).info(`Idempotently deploying app "${t.name}" from creator ${s.sender} using ${s.approvalProgram.length} bytes of ${typeof s.approvalProgram=="string"?"teal code":"AVM bytecode"} and ${s.clearStateProgram.length} bytes of ${typeof s.approvalProgram=="string"?"teal code":"AVM bytecode"}`);const m=typeof s.approvalProgram=="string"?await this._appManager.compileTealTemplate(s.approvalProgram,r,t):void 0,h=m?m.compiledBase64ToBytes:s.approvalProgram,x=typeof s.clearStateProgram=="string"?await this._appManager.compileTealTemplate(s.clearStateProgram,r):void 0,A=x?x.compiledBase64ToBytes:s.clearStateProgram,v=async()=>{const fe=await("method"in s?this._transactionSender.appCreateMethodCall({...s,approvalProgram:h,clearStateProgram:A,...u}):this._transactionSender.appCreate({...s,approvalProgram:h,clearStateProgram:A,...u})),le={appId:fe.appId,appAddress:fe.appAddress,...t,createdMetadata:t,createdRound:BigInt(fe.confirmation.confirmedRound),updatedRound:BigInt(fe.confirmation.confirmedRound),deleted:!1};return this.updateAppLookup(s.sender,le),{operationPerformed:"create",compiledApproval:m,compiledClear:x,...fe,...le}},F=async fe=>{ft.getLogger(u==null?void 0:u.suppressLog).info(`Updating existing ${t.name} app for ${s.sender} to version ${t.version}.`);const le=await("method"in a?this._transactionSender.appUpdateMethodCall({appId:fe.appId,approvalProgram:h,clearStateProgram:A,...a,...u}):this._transactionSender.appUpdate({appId:fe.appId,approvalProgram:h,clearStateProgram:A,...a,...u})),ye={appId:fe.appId,appAddress:fe.appAddress,createdMetadata:fe.createdMetadata,createdRound:fe.createdRound,updatedRound:BigInt(le.confirmation.confirmedRound),...t,deleted:!1};return this.updateAppLookup(s.sender,ye),{operationPerformed:"update",compiledApproval:m,compiledClear:x,...le,...ye}},w=async fe=>{var De,Te;ft.getLogger(u==null?void 0:u.suppressLog).info(`Deploying a new ${t.name} app for ${s.sender}; deploying app with version ${t.version}.`),ft.getLogger(u==null?void 0:u.suppressLog).warn(`Deleting existing ${t.name} app with id ${fe.appId} from ${l.sender} account.`);const le=this._transactionSender.newGroup();"method"in s?le.addAppCreateMethodCall({...s,approvalProgram:h,clearStateProgram:A}):le.addAppCreate({...s,approvalProgram:h,clearStateProgram:A});const ye=await le.count();"method"in l?le.addAppDeleteMethodCall({appId:fe.appId,...l}):le.addAppDelete({appId:fe.appId,...l});const he=await le.send({...u}),de=he.confirmations.at(ye-1),be=he.transactions.at(ye-1),Ae=he.transactions.at(-1);ft.getLogger(u==null?void 0:u.suppressLog).warn(`Sent transactions ${be.txID()} to create app with id ${de.applicationIndex} and ${Ae.txID()} to delete app with id ${fe.appId} from ${s.sender} account.`);const _e={appId:BigInt(de.applicationIndex),appAddress:Le.getApplicationAddress(de.applicationIndex),...t,createdMetadata:t,createdRound:BigInt(de.confirmedRound),updatedRound:BigInt(de.confirmedRound),deleted:!1};return this.updateAppLookup(s.sender,_e),{operationPerformed:"replace",...he,compiledApproval:m,compiledClear:x,transaction:be,confirmation:de,return:"method"in s?(De=he.returns)==null?void 0:De[0]:void 0,deleteReturn:"method"in l?(Te=he.returns)==null?void 0:Te.at(-1):void 0,..._e,deleteResult:{transaction:Ae,confirmation:he.confirmations.at(-1)}}},M=(c??await this.getCreatorAppsByName(s.sender,d)).apps[t.name];if(!M||M.deleted)return ft.getLogger(u==null?void 0:u.suppressLog).info(`App ${t.name} not found in apps created by ${s.sender}; deploying app with version ${t.version}.`),await v();ft.getLogger(u==null?void 0:u.suppressLog).info(`Existing app ${t.name} found by creator ${s.sender}, with app id ${M.appId} and version ${M.version}.`);const N=await this._appManager.getById(M.appId),b=Buffer.from(N.approvalProgram).toString("base64"),j=Buffer.from(N.clearStateProgram).toString("base64"),p=N.extraProgramPages??0,E=Buffer.from(h),S=Buffer.from(A),$=E.toString("base64"),B=S.toString("base64"),P=jp(E,S),W=$!==b||B!==j;if(N.localInts<(((q=s.schema)==null?void 0:q.localInts)??0)||N.globalInts<(((J=s.schema)==null?void 0:J.globalInts)??0)||N.localByteSlices<(((U=s.schema)==null?void 0:U.localByteSlices)??0)||N.globalByteSlices<(((ne=s.schema)==null?void 0:ne.globalByteSlices)??0)||p<P){if(ft.getLogger(u==null?void 0:u.suppressLog).warn(`Detected a breaking app schema change in app ${M.appId}:`,{from:{globalInts:N.globalInts,globalByteSlices:N.globalByteSlices,localInts:N.localInts,localByteSlices:N.localByteSlices,extraProgramPages:p},to:{...s.schema,extraProgramPages:P}}),i===void 0||i==="fail"||i===Cd.Fail)throw new Error("Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. If you want to try deleting and recreating the app then re-run with onSchemaBreak=OnSchemaBreak.ReplaceApp");return i==="append"||i===Cd.AppendApp?(ft.getLogger(u==null?void 0:u.suppressLog).info("onSchemaBreak=AppendApp, will attempt to create a new app"),await v()):(M.deletable?ft.getLogger(u==null?void 0:u.suppressLog).info("App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app"):ft.getLogger(u==null?void 0:u.suppressLog).info("App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail"),await w(M))}if(W){if(ft.getLogger(u==null?void 0:u.suppressLog).info(`Detected a TEAL update in app ${M.appId} for creator ${s.sender}`),o===void 0||o==="fail"||o===Hs.Fail)throw new Error("Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.");if(o==="append"||o===Hs.AppendApp)return ft.getLogger(u==null?void 0:u.suppressLog).info("onUpdate=AppendApp, will attempt to create a new app"),await v();if(o==="update"||o===Hs.UpdateApp)return M.updatable?ft.getLogger(u==null?void 0:u.suppressLog).info("App is updatable and onUpdate=UpdateApp, updating app..."):ft.getLogger(u==null?void 0:u.suppressLog).warn("App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail"),await F(M);if(o==="replace"||o===Hs.ReplaceApp)return M.deletable?ft.getLogger(u==null?void 0:u.suppressLog).warn("App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app..."):ft.getLogger(u==null?void 0:u.suppressLog).warn("App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail"),await w(M)}return ft.getLogger(u==null?void 0:u.suppressLog).debug("No detected changes in app, nothing to do."),{...M,operationPerformed:"nothing"}}updateAppLookup(e,t){const r=typeof e=="string"?e:e.toString(),i=this._appLookups.get(r);i?i.apps[t.name]=t:this._appLookups.set(r,{creator:ze.fromString(r),apps:{[t.name]:t}})}async getCreatorAppsByName(e,t){const r={},i=typeof e=="string"?e:e.toString();if(!t&&this._appLookups.has(i))return this._appLookups.get(i);if(!this._indexer)throw new Error("Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps");const o=(await jM(this._indexer,e)).map(l=>({id:l.id,createdAtRound:l.createdAtRound,deleted:l.deleted})).sort((l,c)=>Number(l.createdAtRound-c.createdAtRound));(await Promise.all(o.map(async l=>{const c=await GM(this._indexer,m=>m.minRound(l.createdAtRound).txType(Le.TransactionType.appl).applicationID(Number(l.id)).address(e).addressRole("sender").notePrefix(Buffer.from($u).toString("base64"))),d=c.transactions.filter(m=>{var h;return((h=m.applicationTransaction)==null?void 0:h.applicationId)===0n&&m.sender.toString()===e.toString()})[0],u=c.transactions.filter(m=>m.sender.toString()===e.toString()).sort((m,h)=>m.confirmedRound===h.confirmedRound?(h.intraRoundOffset-m.intraRoundOffset)/10:Number(h.confirmedRound-m.confirmedRound))[0];return d!=null&&d.note?{createdApp:l,appCreationTransaction:d,latestAppUpdateTransaction:u}:null}))).filter(l=>l!==null).forEach(l=>{const{createdApp:c,appCreationTransaction:d,latestAppUpdateTransaction:u}=l,m=h=>{if(h&&h.startsWith(`${$u}:j{`))return JSON.parse(h.substring($u.length+2))};try{const h=m(d.note?Buffer.from(d.note).toString("utf-8"):void 0),x=m(u.note?Buffer.from(u.note).toString("utf-8"):void 0);h!=null&&h.name&&(r[h.name]={appId:c.id,appAddress:Le.getApplicationAddress(c.id),createdMetadata:h,createdRound:d.confirmedRound??0n,...x??h,updatedRound:(u==null?void 0:u.confirmedRound)??0n,deleted:c.deleted??!1})}catch(h){ft.logger.warn(`Received error trying to retrieve app with ${c.id} for creator ${e}; failing silently`,h);return}});const a={creator:typeof e=="string"?ze.fromString(e):e,apps:r};return this._appLookups.set(e.toString(),a),a}}class zM extends Le.ABIMethod{constructor(e){super(e),this.method=e,this.args=e.args.map(t=>({...t,type:Le.abiTypeIsTransaction(t.type)||Le.abiTypeIsReference(t.type)?t.type:Le.ABIType.from(t.type)})),this.returns={...this.method.returns,type:this.method.returns.type==="void"?"void":Le.ABIType.from(this.method.returns.type)}}toJSON(){return this.method}}function kc(n,e){return new Le.ABITupleType(n.map(t=>typeof t.type=="string"?e[t.type]?kc(e[t.type],e):Le.ABIType.from(t.type):kc(t.type,e)))}function Pg(n,e,t){return Object.fromEntries(e.map(({name:r,type:i},o)=>{let s;typeof i=="string"?i in t?s=kc(t[i],t):s=Le.ABIType.from(i):s=kc(i,t);const a=Ic(n[o],s),l=Xl(a,s);return[r,typeof i=="string"&&!t[i]||!Array.isArray(l)?l:Pg(l,typeof i=="string"?t[i]:i,t)]}))}function Zl(n,e,t){return e.map(({name:r,type:i})=>{const o=n[r];return typeof i=="string"&&!t[i]?o:Zl(o,typeof i=="string"?t[i]:i,t)})}function qn(n,e,t){if(e==="AVMBytes"||typeof n!="object")return n;if(e==="AVMString")return Buffer.from(n).toString("utf-8");if(e==="AVMUint64")return Le.ABIType.from("uint64").decode(n);if(t[e]){const o=kc(t[e],t).decode(n);return Pg(o,t[e],t)}const r=Le.ABIType.from(e),i=Ic(r.decode(n),r);return Xl(i,r)}function ew(n,e,t){if(typeof n=="object"&&n instanceof Uint8Array)return n;if(e==="AVMUint64")return Le.ABIType.from("uint64").encode(n);if(e==="AVMBytes"||e==="AVMString"){if(typeof n=="string")return Buffer.from(n,"utf-8");if(typeof n!="object"||!(n instanceof Uint8Array))throw new Error(`Expected bytes value for ${e}, but got ${n}`);return n}if(t[e]){const r=kc(t[e],t);if(Array.isArray(n))r.encode(n);else return r.encode(Zl(n,t[e],t))}return Le.ABIType.from(e).encode(n)}function Bn(n,e){let t;if(n.includes("(")){const r=e.methods.find(i=>new Le.ABIMethod(i).getSignature()===n);if(!r)throw new Error(`Unable to find method ${n} in ${e.name} app.`);t=r}else{const r=e.methods.filter(i=>i.name===n);if(r.length===0)throw new Error(`Unable to find method ${n} in ${e.name} app.`);if(r.length>1)throw new Error(`Received a call to method ${n} in contract ${e.name}, but this resolved to multiple methods; please pass in an ABI signature instead: ${e.methods.map(i=>new Le.ABIMethod(i).getSignature()).join(", ")}`);t=r[0]}return new zM(t)}function Ys(n,e,t){const r="method"in e?e.method:e,i=r.returns.struct??r.returns.type;if(n!=null&&n.decodeError)throw n.decodeError;if(!(i===void 0||i==="void"||(n==null?void 0:n.returnValue)===void 0))return i==="AVMBytes"?n.rawReturnValue:i==="AVMString"?Buffer.from(n.rawReturnValue).toString("utf-8"):i==="AVMUint64"?Le.ABIType.from("uint64").decode(n.rawReturnValue):t[i]?Pg(n.returnValue,t[i],t):Ic(n.returnValue,Le.ABIType.from(i))}var HM=Le.ABIMethod;function YM(n){const e=Object.values(n.hints).flatMap(l=>Object.entries(l.structs??{})),t=Object.fromEntries(e.map(([l,c])=>{const d=c.elements.map(u=>({name:u[0],type:u[1]}));return[c.name,d]})),r=l=>n.hints[new HM(l).getSignature()],i=(l,c)=>{var d,u;return((d=r(l))==null?void 0:d.call_config)!==void 0?s((u=r(l))==null?void 0:u.call_config,c):[]},o=l=>s(n.bare_call_config,l),s=(l,c)=>{const d=[];return l.close_out&&["ALL",c].includes(l.close_out)&&d.push("CloseOut"),l.delete_application&&["ALL",c].includes(l.delete_application)&&d.push("DeleteApplication"),l.no_op&&["ALL",c].includes(l.no_op)&&d.push("NoOp"),l.opt_in&&["ALL",c].includes(l.opt_in)&&d.push("OptIn"),l.update_application&&["ALL",c].includes(l.update_application)&&d.push("UpdateApplication"),d},a=(l,c)=>{if(c)return c.source==="abi-method"?{source:"method",data:c.data.name}:{source:c.source==="constant"?"literal":c.source==="global-state"?"global":"local",data:Buffer.from(typeof c.data=="number"?Le.ABIType.from("uint64").encode(c.data):c.data).toString("base64"),type:l==="string"?"AVMString":l}};return{arcs:[],name:n.contract.name,desc:n.contract.desc,structs:t,methods:n.contract.methods.map(l=>{var c,d,u,m;return{name:l.name,desc:l.desc,args:l.args.map(h=>{var x,A,v,F,w;return{name:h.name,type:h.type,desc:h.desc,struct:h.name?(v=(A=(x=r(l))==null?void 0:x.structs)==null?void 0:A[h.name])==null?void 0:v.name:void 0,defaultValue:a(h.type,h.name?(w=(F=r(l))==null?void 0:F.default_arguments)==null?void 0:w[h.name]:void 0)}}),returns:{type:l.returns.type,desc:l.returns.desc,struct:(u=(d=(c=r(l))==null?void 0:c.structs)==null?void 0:d.output)==null?void 0:u.name},events:[],readonly:(m=r(l))==null?void 0:m.read_only,actions:{create:i(l,"CREATE"),call:i(l,"CALL")}}}),state:{schema:{global:{ints:n.state.global.num_uints,bytes:n.state.global.num_byte_slices},local:{ints:n.state.local.num_uints,bytes:n.state.local.num_byte_slices}},keys:{global:Object.fromEntries(Object.entries(n.schema.global.declared).map(l=>[l[0],{key:Buffer.from(l[1].key,"utf-8").toString("base64"),keyType:"AVMString",valueType:l[1].type==="uint64"?"AVMUint64":"AVMBytes",desc:l[1].descr}])),local:Object.fromEntries(Object.entries(n.schema.local.declared).map(l=>[l[0],{key:Buffer.from(l[1].key,"utf-8").toString("base64"),keyType:"AVMString",valueType:l[1].type==="uint64"?"AVMUint64":"AVMBytes",desc:l[1].descr}])),box:{}},maps:{global:{},local:{},box:{}}},source:n.source,bareActions:{create:o("CREATE"),call:o("CALL")},byteCode:void 0,compilerInfo:void 0,events:void 0,networks:void 0,scratchVariables:void 0,sourceInfo:void 0,templateVariables:void 0}}const KM=/transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/,qM=/inner tx (\d+) failed:.*?pc=([0-9]+)/;class nf extends Error{static parseLogicError(e){const t=e.message,r=KM.exec(t),i=qM.exec(t);if(!(r===null||r.length<=3))return{txId:r[1],msg:r[2],desc:t,pc:parseInt((i==null?void 0:i[2])??r[3]??"0"),traces:e.traces}}constructor(e,t,r){super(),this.lines=5,this.teal_line=0,this.led=e,this.program=t;const i=r(e.pc);if(this.teal_line=i===void 0?0:i,this.message=`${this.led.msg}. at:${i}. ${this.led.desc}`,this.teal_line>0){const o=this.teal_line>this.lines?this.teal_line-this.lines:0,s=t.length>this.teal_line+this.lines?this.teal_line+this.lines:t.length,a=t.slice(o,s);a[a.length/2]+=" <--- Error",this.stack=a.join(`
230
+ `)}}}var ar=Le.OnApplicationComplete,tw=Le.ProgramSourceMap;const XM=2e4*16,rf=38,nw=32;function ZM(n){const e=[...n],t=e.length;e.shift();let r,i;for(;e.length>0;){const o=e.shift();if(o===rf||o===nw){const s=o===rf,a=e.shift();for(let l=0;l<a;l++)if(s){const c=e.shift();e.splice(0,c)}else for(;(e.shift()&128)!==0;);if(s?r=t-e.length-1:i=t-e.length-1,e[0]!==rf&&e[0]!==nw)break}}return Math.max(r??0,i??0)}class cn{constructor(e){this.handleCallErrors=async t=>{var i,o,s,a;if(this.appId===0n){if(t.sentTransactions===void 0)return t;const c=t.sentTransactions.find(u=>t.message.includes(u.txID())),d=(u,m)=>{if(u===void 0||m===void 0||u.length!==m.length)return!1;for(let h=0;h<u.length;h++)if(u[h]!==m[h])return!1;return!0};if(!d((i=c==null?void 0:c.applicationCall)==null?void 0:i.clearProgram,this._lastCompiled.clear)||!d((o=c==null?void 0:c.applicationCall)==null?void 0:o.approvalProgram,(s=this._lastCompiled)==null?void 0:s.approval))return t}else{const l=`app=${this._appId.toString()}`;if(!t.message.includes(l))return t}const r=await this.exposeLogicError(t);if(r instanceof nf){let l=r.teal_line-r.lines-1;const c=(a=r.stack)==null?void 0:a.split(`
231
231
  `).map(d=>`${l+=1}: ${d}`).join(`
232
232
  `);ft.logger.error(`${r.message}
233
233
 
234
- ${c}`)}return r},this._appId=e.appId,this._appAddress=Oe.getApplicationAddress(this._appId),this._appSpec=cn.normaliseAppSpec(e.appSpec),this._appName=e.appName??this._appSpec.name,this._algorand=e.algorand,this._algorand.registerErrorTransformer(this.handleCallErrors),this._defaultSender=typeof e.defaultSender=="string"?ze.fromString(e.defaultSender):e.defaultSender,this._defaultSigner=e.defaultSigner,this._lastCompiled={},this._approvalSourceMap=e.approvalSourceMap,this._clearSourceMap=e.clearSourceMap,this._localStateMethods=t=>this.getStateMethods(()=>this.getLocalState(t),()=>this._appSpec.state.keys.local,()=>this._appSpec.state.maps.local),this._globalStateMethods=this.getStateMethods(()=>this.getGlobalState(),()=>this._appSpec.state.keys.global,()=>this._appSpec.state.maps.global),this._boxStateMethods=this.getBoxMethods(),this._paramsMethods={...this.getMethodCallParamsMethods(),bare:this.getBareParamsMethods()},this._createTransactionsMethods={...this.getMethodCallCreateTransactionMethods(),bare:this.getBareCreateTransactionMethods()},this._sendMethods={...this.getMethodCallSendMethods(),bare:this.getBareSendMethods()}}clone(e){return new cn({appId:this._appId,appSpec:this._appSpec,algorand:this._algorand,appName:this._appName,defaultSender:this._defaultSender,defaultSigner:this._defaultSigner,approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap,...e})}static async fromCreatorAndName(e){const t=cn.normaliseAppSpec(e.appSpec),i=(e.appLookupCache??await e.algorand.appDeployer.getCreatorAppsByName(e.creatorAddress,e.ignoreCache)).apps[e.appName??t.name];if(!i)throw new Error(`App not found for creator ${e.creatorAddress} and name ${e.appName??t.name}`);return new cn({...e,algorand:e.algorand,appId:i.appId})}static async fromNetwork(e){const t=await e.algorand.client.network(),r=cn.normaliseAppSpec(e.appSpec),i=[t.genesisHash];t.isLocalNet&&i.push("localnet"),t.isTestNet&&i.push("testnet"),t.isMainNet&&i.push("mainnet");const s=Object.keys(r.networks??{}).findIndex(l=>i.includes(l));if(s===-1)throw new Error(`No app ID found for network ${ea(i)} in the app spec`);const a=BigInt(r.networks[s].appID);return new cn({...e,appId:a,appSpec:r})}static normaliseAppSpec(e){const t=typeof e=="string"?JSON.parse(e):e;return"hints"in t?YM(t):t}get appId(){return this._appId}get appAddress(){return this._appAddress}get appName(){return this._appName}get appSpec(){return this._appSpec}get algorand(){return this._algorand}get params(){return this._paramsMethods}get createTransaction(){return this._createTransactionsMethods}get send(){return this._sendMethods}get state(){return{local:this._localStateMethods,global:this._globalStateMethods,box:this._boxStateMethods}}async fundAppAccount(e){return this.send.fundAppAccount(e)}async getGlobalState(){return await this._algorand.app.getGlobalState(this.appId)}async getLocalState(e){return await this._algorand.app.getLocalState(this.appId,e)}async getBoxNames(){return await this._algorand.app.getBoxNames(this.appId)}async getBoxValue(e){return await this._algorand.app.getBoxValue(this.appId,e)}async getBoxValueFromABIType(e,t){return await this._algorand.app.getBoxValueFromABIType({appId:this.appId,boxName:e,type:t})}async getBoxValues(e){const t=(await this.getBoxNames()).filter(e??(i=>!0)),r=await this._algorand.app.getBoxValues(this.appId,t.map(i=>i.nameRaw));return t.map((i,o)=>({name:i,value:r[o]}))}async getBoxValuesFromABIType(e,t){const r=(await this.getBoxNames()).filter(t??(o=>!0)),i=await this._algorand.app.getBoxValuesFromABIType({appId:this.appId,boxNames:r.map(o=>o.nameRaw),type:e});return r.map((o,s)=>({name:o,value:i[s]}))}async exposeLogicError(e,t){var o,s;const r=(s=(o=this._appSpec.sourceInfo)==null?void 0:o[t?"clear":"approval"])==null?void 0:s.pcOffsetMethod;let i;if(r==="cblocks"){const a=await this._algorand.app.getById(this.appId);i=t?a.clearStateProgram:a.approvalProgram}return cn.exposeLogicError(e,this._appSpec,{isClearStateProgram:t,approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap,program:i})}exportSourceMaps(){if(!this._approvalSourceMap||!this._clearSourceMap)throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");return{approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap}}importSourceMaps(e){this._approvalSourceMap=new tw(e.approvalSourceMap),this._clearSourceMap=new tw(e.clearSourceMap)}getABIMethod(e){return Bn(e,this._appSpec)}async processMethodCallReturn(e,t){const r=await e;return{...r,return:Ys(r.return,t,this._appSpec.structs)}}async compile(e){const t=await cn.compile(this._appSpec,this._algorand.app,e);return t.compiledApproval&&(this._approvalSourceMap=t.compiledApproval.sourceMap,this._lastCompiled.approval=t.compiledApproval.compiledBase64ToBytes),t.compiledClear&&(this._clearSourceMap=t.compiledClear.sourceMap,this._lastCompiled.clear=t.compiledClear.compiledBase64ToBytes),t}static exposeLogicError(e,t,r){var A,v,F,w;const{isClearStateProgram:i,approvalSourceMap:o,clearSourceMap:s,program:a}=r,l=i?s:o,c=nf.parseLogicError(e);if(c===void 0||(c==null?void 0:c.pc)===void 0)return e;let d=c==null?void 0:c.pc;const u=i?(A=t.sourceInfo)==null?void 0:A.clear:(v=t.sourceInfo)==null?void 0:v.approval;let m=0;if((u==null?void 0:u.pcOffsetMethod)==="cblocks"){if(a===void 0)throw new Error("Program bytes are required to calculate the ARC56 cblocks PC offset");m=ZM(a),d=c.pc-m}const h=u==null?void 0:u.sourceInfo.find(C=>C.pc.includes(d)),x=h==null?void 0:h.errorMessage;if(t.source){let C=M=>{var N,b;return(b=(N=l==null?void 0:l.getLocationForPc)==null?void 0:N.call(l,M))==null?void 0:b.line};l===void 0&&(C=M=>{var b;const N=(b=u==null?void 0:u.sourceInfo.find(j=>j.pc.includes(M-m)))==null?void 0:b.teal;if(N!==void 0)return N-1}),e=new nf(c,nn.Buffer.from(i?t.source.clear:t.source.approval,"base64").toString().split(`
235
- `),C)}if(x){const C=((F=ea(e).match(new RegExp("(?<=app=)\\d+")))==null?void 0:F[0])||"",M=(w=ea(e).match(new RegExp("(?<=transaction )\\S+(?=:)")))==null?void 0:w[0],N=new Error(`Runtime error when executing ${t.name} (appId: ${C}) in transaction ${M}: ${x}`);return N.cause=e,N}return e}static async compile(e,t,r){var u,m;const{deployTimeParams:i,updatable:o,deletable:s}=r??{};if(!e.source){if(!((u=e.byteCode)!=null&&u.approval)||!((m=e.byteCode)!=null&&m.clear))throw new Error(`Attempt to compile app ${e.name} without source or byteCode`);return{approvalProgram:nn.Buffer.from(e.byteCode.approval,"base64"),clearStateProgram:nn.Buffer.from(e.byteCode.clear,"base64")}}const a=nn.Buffer.from(e.source.approval,"base64").toString("utf-8"),l=await t.compileTealTemplate(a,i,{updatable:o,deletable:s}),c=nn.Buffer.from(e.source.clear,"base64").toString("utf-8"),d=await t.compileTealTemplate(c,i);return ft.debug&&await ft.events.emitAsync(Ps.AppCompiled,{sources:[{compiledTeal:l,appName:e.name,fileName:"approval"},{compiledTeal:d,appName:e.name,fileName:"clear"}]}),{approvalProgram:l.compiledBase64ToBytes,compiledApproval:l,clearStateProgram:d.compiledBase64ToBytes,compiledClear:d}}async getABIArgsWithDefaultValues(e,t,r){const i=Bn(e,this._appSpec);return await Promise.all((t==null?void 0:t.map(async(o,s)=>{var c,d,u;const a=i.args[s];if(!a)throw new Error(`Unexpected arg at position ${s}. ${i.name} only expects ${i.args.length} args`);if(o!==void 0)return a.struct&&typeof o=="object"&&!Array.isArray(o)?Zl(o,this._appSpec.structs[a.struct],this._appSpec.structs):o;const l=a.defaultValue;if(l)switch(l.source){case"literal":return qn(nn.Buffer.from(l.data,"base64"),((c=i.method.args[s].defaultValue)==null?void 0:c.type)??i.method.args[s].type,this._appSpec.structs);case"method":{const m=this.getABIMethod(l.data),h=await this.send.call({method:l.data,args:m.args.map(()=>{}),sender:r});if(h.return===void 0)throw new Error("Default value method call did not return a value");return typeof h.return=="object"&&!(h.return instanceof Uint8Array)&&!Array.isArray(h.return)&&!(h.return instanceof ze)?Zl(h.return,this._appSpec.structs[m.returns.struct],this._appSpec.structs):h.return}case"local":case"global":{const m=l.source==="global"?await this.getGlobalState():await this.getLocalState(r),h=Object.values(m).find(x=>x.keyBase64===l.data);if(!h)throw new Error(`Preparing default value for argument ${a.name??`arg${s+1}`} resulted in the failure: The key '${l.data}' could not be found in ${l.source} storage`);return"valueRaw"in h?qn(h.valueRaw,((d=i.method.args[s].defaultValue)==null?void 0:d.type)??i.method.args[s].type,this._appSpec.structs):h.value}case"box":{const m=await this.getBoxValue(nn.Buffer.from(l.data,"base64"));return qn(m,((u=i.method.args[s].defaultValue)==null?void 0:u.type)??i.method.args[s].type,this._appSpec.structs)}}if(!Oe.abiTypeIsTransaction(a.type))throw new Error(`No value provided for required argument ${a.name??`arg${s+1}`} in call to method ${i.name}`)}))??[])}getBareParamsMethods(){return{update:async e=>this.getBareParams({...e,...await this.compile(e)},ar.UpdateApplicationOC),optIn:e=>this.getBareParams(e,ar.OptInOC),delete:e=>this.getBareParams(e,ar.DeleteApplicationOC),clearState:e=>this.getBareParams(e,ar.ClearStateOC),closeOut:e=>this.getBareParams(e,ar.CloseOutOC),call:e=>this.getBareParams(e,(e==null?void 0:e.onComplete)??ar.NoOpOC)}}getBareCreateTransactionMethods(){return{update:async e=>this._algorand.createTransaction.appUpdate(await this.params.bare.update(e)),optIn:e=>this._algorand.createTransaction.appCall(this.params.bare.optIn(e)),delete:e=>this._algorand.createTransaction.appDelete(this.params.bare.delete(e)),clearState:e=>this._algorand.createTransaction.appCall(this.params.bare.clearState(e)),closeOut:e=>this._algorand.createTransaction.appCall(this.params.bare.closeOut(e)),call:e=>this._algorand.createTransaction.appCall(this.params.bare.call(e))}}getBareSendMethods(){return{update:async e=>{const t=await this.compile(e);return{...await this._algorand.send.appUpdate(await this.params.bare.update(e)),...t}},optIn:e=>this._algorand.send.appCall(this.params.bare.optIn(e)),delete:e=>this._algorand.send.appDelete(this.params.bare.delete(e)),clearState:e=>this._algorand.send.appCall(this.params.bare.clearState(e)),closeOut:e=>this._algorand.send.appCall(this.params.bare.closeOut(e)),call:e=>this._algorand.send.appCall(this.params.bare.call(e))}}getMethodCallParamsMethods(){return{fundAppAccount:e=>({...e,sender:this.getSender(e.sender),signer:this.getSigner(e.sender,e.signer),receiver:this.appAddress}),update:async e=>await this.getABIParams({...e,...await this.compile(e)},ar.UpdateApplicationOC),optIn:async e=>await this.getABIParams(e,ar.OptInOC),delete:async e=>await this.getABIParams(e,ar.DeleteApplicationOC),closeOut:async e=>await this.getABIParams(e,ar.CloseOutOC),call:async e=>await this.getABIParams(e,e.onComplete??ar.NoOpOC)}}getMethodCallSendMethods(){return{fundAppAccount:e=>this._algorand.send.payment(this.params.fundAppAccount(e)),update:async e=>{const t=await this.compile(e);return{...await this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({...e})),Bn(e.method,this._appSpec)),...t}},optIn:async e=>this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(e)),Bn(e.method,this._appSpec)),delete:async e=>this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(e)),Bn(e.method,this._appSpec)),closeOut:async e=>this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(e)),Bn(e.method,this._appSpec)),call:async e=>{var t,r;if((e.onComplete===ar.NoOpOC||!e.onComplete)&&Bn(e.method,this._appSpec).method.readonly){const i={...e};e.coverAppCallInnerTransactionFees&&e.maxFee&&(i.staticFee=e.maxFee,i.extraFee=void 0);try{const o=await this._algorand.newGroup().addAppCallMethodCall(await this.params.call(i)).simulate({allowUnnamedResources:e.populateAppCallResources??!0,skipSignatures:!0,extraOpcodeBudget:XM});return this.processMethodCallReturn({...o,transaction:o.transactions.at(-1),confirmation:o.confirmations.at(-1),return:((t=o.returns)==null?void 0:t.length)??!1?(r=o.returns)==null?void 0:r.at(-1):void 0},Bn(e.method,this._appSpec))}catch(o){const s=o;throw e.coverAppCallInnerTransactionFees&&s&&s.message&&s.message.match(/fee too small/)?Error("Fees were too small. You may need to increase the transaction maxFee."):o}}return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(e)),Bn(e.method,this._appSpec))}}}getMethodCallCreateTransactionMethods(){return{fundAppAccount:e=>this._algorand.createTransaction.payment(this.params.fundAppAccount(e)),update:async e=>this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(e)),optIn:async e=>this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(e)),delete:async e=>this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(e)),closeOut:async e=>this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(e)),call:async e=>this._algorand.createTransaction.appCallMethodCall(await this.params.call(e))}}getSender(e){if(!e&&!this._defaultSender)throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`);return typeof e=="string"?ze.fromString(e):e??this._defaultSender}getSigner(e,t){return t??(!e||e===this._defaultSender?this._defaultSigner:void 0)}getBareParams(e,t){return{...e,appId:this._appId,sender:this.getSender(e==null?void 0:e.sender),signer:this.getSigner(e==null?void 0:e.sender,e==null?void 0:e.signer),onComplete:t}}async getABIParams(e,t){const r=this.getSender(e.sender),i=Bn(e.method,this._appSpec),o=await this.getABIArgsWithDefaultValues(e.method,e.args,r);return{...e,appId:this._appId,sender:r,signer:this.getSigner(e.sender,e.signer),method:i,onComplete:t,args:o}}getBoxMethods(){const e=this,t={getAll:async()=>Object.fromEntries(await Promise.all(Object.keys(e._appSpec.state.keys.box).map(async r=>[r,await t.getValue(r)]))),getValue:async r=>{const i=e._appSpec.state.keys.box[r],o=await e.getBoxValue(nn.Buffer.from(i.key,"base64"));return qn(o,i.valueType,e._appSpec.structs)},getMapValue:async(r,i)=>{const o=e._appSpec.state.maps.box[r],s=nn.Buffer.from(o.prefix??"","base64"),a=nn.Buffer.concat([s,ew(i,o.keyType,e._appSpec.structs)]),l=nn.Buffer.from(a).toString("base64"),c=await e.getBoxValue(nn.Buffer.from(l,"base64"));return qn(c,o.valueType,e._appSpec.structs)},getMap:async r=>{const i=e._appSpec.state.maps.box[r],o=nn.Buffer.from(i.prefix??"","base64"),s=await e.getBoxNames();return new Map(await Promise.all(s.filter(a=>Ky(a.nameRaw,o)).map(async a=>[qn(a.nameRaw.slice(o.length),i.keyType,e._appSpec.structs),qn(await e.getBoxValue(a.nameRaw),i.valueType,e._appSpec.structs)])))}};return t}getStateMethods(e,t,r){const i=this,o={getAll:async()=>{const s=await e();return Object.fromEntries(await Promise.all(Object.keys(t()).map(async a=>[a,await o.getValue(a,s)])))},getValue:async(s,a)=>{const l=Object.values(a??await e()),c=t()[s];if(c===void 0)throw new Error(`Attempted to get state value ${s}, but it does not exist`);const d=l.find(u=>u.keyBase64===c.key);return d&&"valueRaw"in d?qn(d.valueRaw,c.valueType,i._appSpec.structs):d==null?void 0:d.value},getMapValue:async(s,a,l)=>{const c=Object.values(l??await e()),d=r()[s],u=nn.Buffer.from(d.prefix??"","base64"),m=nn.Buffer.concat([u,ew(a,d.keyType,i._appSpec.structs)]),h=nn.Buffer.from(m).toString("base64"),x=c.find(A=>A.keyBase64===h);return x&&"valueRaw"in x?qn(x.valueRaw,d.valueType,i._appSpec.structs):x==null?void 0:x.value},getMap:async s=>{const a=Object.values(await e()),l=r()[s],c=nn.Buffer.from(l.prefix??"","base64");return new Map(a.filter(d=>Ky(d.keyRaw,c)).map(d=>{const u=d.keyRaw.slice(c.length);return[qn(u,l.keyType,this._appSpec.structs),qn("valueRaw"in d?d.valueRaw:d.value,l.valueType,this._appSpec.structs)]}))}};return o}}const rw="DISPENSER";class JM{get params(){return this._params}get signingAccounts(){return this._signingAccounts}get addr(){return this._addr}get signer(){return this._signer}constructor(e,t){this._params=e,this._signingAccounts=t,this._addr=Oe.multisigAddress(e),this._signer=Oe.makeMultiSigAccountTransactionSigner(e,t.map(r=>r.sk))}sign(e){let t="sender"in e?void 0:e;for(const r of this._signingAccounts)t?t=Oe.appendSignMultisigTransaction(t,this._params,r.sk).blob:t=Oe.signMultisigTransaction(e,this._params,r.sk).blob;return t}}class Gp{get addr(){return this._sender}get sk(){return this._account.sk}get signer(){return this._signer}get sender(){return{addr:this._sender,sk:this._account.sk}}constructor(e,t){this._account=e,this._sender=typeof t=="string"?ze.fromString(t):t??e.addr,this._signer=Oe.makeBasicAccountTransactionSigner(e)}}class Wn{get microAlgos(){return this.amountInMicroAlgo}get microAlgo(){return this.amountInMicroAlgo}get algos(){return Oe.microalgosToAlgos(Number(this.amountInMicroAlgo))}get algo(){return Oe.microalgosToAlgos(Number(this.amountInMicroAlgo))}constructor(e){this.amountInMicroAlgo="microAlgos"in e?BigInt(e.microAlgos):"microAlgo"in e?BigInt(e.microAlgo):"algos"in e?BigInt(Oe.algosToMicroalgos(Number(e.algos))):BigInt(Oe.algosToMicroalgos(Number(e.algo)))}toString(){return`${this.microAlgo.toLocaleString("en-US")} µALGO`}valueOf(){return Number(this.microAlgo)}static Algos(e){return new Wn({algos:e})}static Algo(e){return new Wn({algos:e})}static MicroAlgos(e){return new Wn({microAlgos:e})}static MicroAlgo(e){return new Wn({microAlgos:e})}}class er extends Ni{async callWithRetry(e){let t,r=1;do try{t=await e()}catch(i){if(r>=er.MAX_TRIES||!(er.RETRY_ERROR_CODES.includes(i.code)||er.RETRY_STATUS_CODES.includes(Number(i.status))||"response"in i&&er.RETRY_STATUS_CODES.includes(Number(i.response.status))))throw i;const o=r==1?0:Math.min(1e3*Math.pow(2,r-1),er.MAX_BACKOFF_MS);o>0&&await new Promise(s=>setTimeout(s,o)),ft.logger.warn(`algosdk request failed ${r} times. Retrying in ${o}ms: ${i}`)}while(!t&&++r<=er.MAX_TRIES);return t}async get(e,t,r={}){var o;const i=await this.callWithRetry(()=>super.get(e,t,r));if(e.startsWith("/v2/accounts/")&&e.endsWith("/created-applications")&&i.status===200&&((o=t==null?void 0:t["include-all"])==null?void 0:o.toString())==="true")try{const s=_d(Buffer.from(i.body).toString(),{intDecoding:an.MIXED});if(s.applications){for(const a of s.applications)a.params&&(a.params["approval-program"]===null&&(a.params["approval-program"]=""),a.params["clear-state-program"]===null&&(a.params["clear-state-program"]=""));i.body=Buffer.from(yi(s))}}catch(s){ft.logger.warn("Failed to fix indexer response for created applications",s)}return i}async post(e,t,r,i={}){return await this.callWithRetry(()=>super.post(e,t,r,i))}async delete(e,t,r,i={}){return await this.callWithRetry(()=>super.delete(e,t,r,i))}}er.MAX_TRIES=5;er.MAX_BACKOFF_MS=1e4;er.RETRY_STATUS_CODES=[408,413,429,500,502,503,504];er.RETRY_ERROR_CODES=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN","EPROTO"];var iw=Oe.ProgramSourceMap,js=Oe.OnApplicationComplete;class eS{constructor(e){this.createTransaction={bare:{create:async t=>this._algorand.createTransaction.appCreate(await this.params.bare.create(t))},create:async t=>this._algorand.createTransaction.appCreateMethodCall(await this.params.create(t))},this.send={bare:{create:async t=>{const r=(t==null?void 0:t.updatable)??this._updatable,i=(t==null?void 0:t.deletable)??this._deletable,o=(t==null?void 0:t.deployTimeParams)??this._deployTimeParams,s=await this.compile({deployTimeParams:o,updatable:r,deletable:i}),a=await this.handleCallErrors(async()=>({...await this._algorand.send.appCreate(await this.params.bare.create({...t,updatable:r,deletable:i,deployTimeParams:o})),return:void 0}));return{appClient:this.getAppClientById({appId:a.appId}),result:{...a,...s}}}},create:async t=>{const r=(t==null?void 0:t.updatable)??this._updatable,i=(t==null?void 0:t.deletable)??this._deletable,o=(t==null?void 0:t.deployTimeParams)??this._deployTimeParams,s=await this.compile({deployTimeParams:o,updatable:r,deletable:i}),a=await this.handleCallErrors(async()=>this.parseMethodCallReturn(this._algorand.send.appCreateMethodCall(await this.params.create({...t,updatable:r,deletable:i,deployTimeParams:o})),Bn(t.method,this._appSpec)));return{appClient:this.getAppClientById({appId:a.appId}),result:{...a,...s}}}},this._appSpec=cn.normaliseAppSpec(e.appSpec),this._appName=e.appName??this._appSpec.name,this._algorand=e.algorand,this._version=e.version??"1.0",this._defaultSender=typeof e.defaultSender=="string"?ze.fromString(e.defaultSender):e.defaultSender,this._defaultSigner=e.defaultSigner,this._deployTimeParams=e.deployTimeParams,this._updatable=e.updatable,this._deletable=e.deletable,this._paramsMethods=this.getParamsMethods()}get appName(){return this._appName}get appSpec(){return this._appSpec}get algorand(){return this._algorand}get params(){return this._paramsMethods}async deploy(e){const t=e.updatable??this._updatable??this.getDeployTimeControl("updatable"),r=e.deletable??this._deletable??this.getDeployTimeControl("deletable"),i=e.deployTimeParams??this._deployTimeParams,s=await this.getAppClientById({appId:0n}).compile({deployTimeParams:i,updatable:t,deletable:r}),a=await this._algorand.appDeployer.deploy({...e,createParams:await(e.createParams&&"method"in e.createParams?this.params.create({...e.createParams,updatable:t,deletable:r,deployTimeParams:i}):this.params.bare.create({...e.createParams,updatable:t,deletable:r,deployTimeParams:i})),updateParams:e.updateParams&&"method"in e.updateParams?this.params.deployUpdate(e.updateParams):this.params.bare.deployUpdate(e.updateParams),deleteParams:e.deleteParams&&"method"in e.deleteParams?this.params.deployDelete(e.deleteParams):this.params.bare.deployDelete(e.deleteParams),metadata:{name:e.appName??this._appName,version:this._version,updatable:t,deletable:r}}),l=this.getAppClientById({appId:a.appId,appName:e.appName}),c={...a,...s};return{appClient:l,result:{...c,return:"return"in c?c.operationPerformed==="update"?e.updateParams&&"method"in e.updateParams?Ys(c.return,Bn(e.updateParams.method,this._appSpec),this._appSpec.structs):void 0:e.createParams&&"method"in e.createParams?Ys(c.return,Bn(e.createParams.method,this._appSpec),this._appSpec.structs):void 0:void 0,deleteReturn:"deleteReturn"in c&&e.deleteParams&&"method"in e.deleteParams?Ys(c.deleteReturn,Bn(e.deleteParams.method,this._appSpec),this._appSpec.structs):void 0}}}getAppClientById(e){return new cn({...e,algorand:this._algorand,appSpec:this._appSpec,appName:e.appName??this._appName,defaultSender:e.defaultSender??this._defaultSender,defaultSigner:e.defaultSigner??this._defaultSigner,approvalSourceMap:e.approvalSourceMap??this._approvalSourceMap,clearSourceMap:e.clearSourceMap??this._clearSourceMap})}getAppClientByCreatorAndName(e){return cn.fromCreatorAndName({...e,algorand:this._algorand,appSpec:this._appSpec,appName:e.appName??this._appName,defaultSender:e.defaultSender??this._defaultSender,approvalSourceMap:e.approvalSourceMap??this._approvalSourceMap,clearSourceMap:e.clearSourceMap??this._clearSourceMap})}exposeLogicError(e,t){return cn.exposeLogicError(e,this._appSpec,{isClearStateProgram:t,approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap})}exportSourceMaps(){if(!this._approvalSourceMap||!this._clearSourceMap)throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");return{approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap}}importSourceMaps(e){this._approvalSourceMap=new iw(e.approvalSourceMap),this._clearSourceMap=new iw(e.clearSourceMap)}getDeployTimeControl(e){var r;const t=(r=this._appSpec.source)!=null&&r.approval?Buffer.from(this._appSpec.source.approval,"base64").toString("utf-8"):void 0;if(!(!t||!t.includes(e==="updatable"?Xu:Zu)))return this._appSpec.bareActions.call.includes(e==="updatable"?"UpdateApplication":"DeleteApplication")||Object.values(this._appSpec.methods).some(i=>i.actions.call.includes(e==="updatable"?"UpdateApplication":"DeleteApplication"))}getParamsMethods(){return{create:async e=>{const t=await this.compile({...e,deployTimeParams:e.deployTimeParams??this._deployTimeParams});return this.getABIParams({...e,deployTimeParams:e.deployTimeParams??this._deployTimeParams,schema:e.schema??{globalByteSlices:this._appSpec.state.schema.global.bytes,globalInts:this._appSpec.state.schema.global.ints,localByteSlices:this._appSpec.state.schema.local.bytes,localInts:this._appSpec.state.schema.local.ints},approvalProgram:t.approvalProgram,clearStateProgram:t.clearStateProgram},e.onComplete??js.NoOpOC)},deployUpdate:e=>this.getABIParams(e,js.UpdateApplicationOC),deployDelete:e=>this.getABIParams(e,js.DeleteApplicationOC),bare:{create:async e=>this.getBareParams({...e,deployTimeParams:(e==null?void 0:e.deployTimeParams)??this._deployTimeParams,schema:(e==null?void 0:e.schema)??{globalByteSlices:this._appSpec.state.schema.global.bytes,globalInts:this._appSpec.state.schema.global.ints,localByteSlices:this._appSpec.state.schema.local.bytes,localInts:this._appSpec.state.schema.local.ints},...await this.compile({...e,deployTimeParams:(e==null?void 0:e.deployTimeParams)??this._deployTimeParams})},(e==null?void 0:e.onComplete)??js.NoOpOC),deployUpdate:e=>this.getBareParams(e,js.UpdateApplicationOC),deployDelete:e=>this.getBareParams(e,js.DeleteApplicationOC)}}}async handleCallErrors(e){try{return await e()}catch(t){throw this.exposeLogicError(t)}}async compile(e){const t=await cn.compile(this._appSpec,this._algorand.app,e);return t.compiledApproval&&(this._approvalSourceMap=t.compiledApproval.sourceMap),t.compiledClear&&(this._clearSourceMap=t.compiledClear.sourceMap),t}getBareParams(e,t){return{...e,sender:this.getSender(e==null?void 0:e.sender),signer:this.getSigner(e==null?void 0:e.sender,e==null?void 0:e.signer),onComplete:t}}getABIParams(e,t){return{...e,sender:this.getSender(e.sender),signer:this.getSigner(e.sender,e.signer),method:Bn(e.method,this._appSpec),args:this.getCreateABIArgsWithDefaultValues(e.method,e.args),onComplete:t}}getCreateABIArgsWithDefaultValues(e,t){const r=Bn(e,this._appSpec);return t==null?void 0:t.map((i,o)=>{const s=r.args[o];if(i!==void 0)return s.struct&&typeof i=="object"&&!Array.isArray(i)?Zl(i,this._appSpec.structs[s.struct],this._appSpec.structs):i;const a=s.defaultValue;if(a)switch(a.source){case"literal":return qn(Buffer.from(a.data,"base64"),r.method.args[o].type,this._appSpec.structs);default:throw new Error(`Can't provide default value for ${a.source} for a contract creation call`)}throw new Error(`No value provided for required argument ${s.name??`arg${o+1}`} in call to method ${r.name}`)})}getSender(e){if(!e&&!this._defaultSender)throw new Error(`No sender provided and no default sender present in app factory for call to app ${this._appName}`);return typeof e=="string"?ze.fromString(e):e??this._defaultSender}getSigner(e,t){return t??(!e||e===this._defaultSender?this._defaultSigner:void 0)}async parseMethodCallReturn(e,t){const r=await e;return{...r,return:Ys(r.return,t,this._appSpec.structs)}}}const QM="https://api.dispenser.algorandfoundation.tools",eR=15,ow="ALGOKIT_DISPENSER_ACCESS_TOKEN";var ta;(function(n){n[n.Algo=0]="Algo"})(ta||(ta={}));const of={[ta.Algo]:{assetId:0,decimals:6,description:"Algo"}};class sw{constructor(e){var r;const t=(r=process==null?void 0:process.env)==null?void 0:r[ow];if(e!=null&&e.authToken)this._authToken=e.authToken;else if(t)this._authToken=t;else throw new Error(`Can't init AlgoKit TestNet Dispenser API client because neither environment variable ${ow} or the authToken were provided.`);this._requestTimeout=(e==null?void 0:e.requestTimeout)||eR}get authToken(){return this._authToken}get requestTimeout(){return this._requestTimeout}async processDispenserRequest(e,t,r=null,i="POST"){const o={Authorization:`Bearer ${e}`},s={method:i,headers:o,signal:AbortSignal.timeout(this.requestTimeout*1e3)};r&&(s.body=ea(r));const a=await fetch(`${QM}/${t}`,s);if(!a.ok){let l=`Error processing dispenser API request: ${a.status}`,c=null;try{c=await a.json()}catch{}throw c&&c.code?l=c.code:a.status===400&&(l=(await a.json()).message),new Error(l)}return a}async fund(e,t){const i=await(await this.processDispenserRequest(this.authToken,`fund/${of[ta.Algo].assetId}`,{receiver:typeof e=="string"?e:e.toString(),amount:Number(t),assetID:of[ta.Algo].assetId},"POST")).json();return{txId:i.txID,amount:i.amount}}async refund(e){await this.processDispenserRequest(this.authToken,"refund",{refundTransactionID:e},"POST")}async getLimit(){return{amount:(await(await this.processDispenserRequest(this.authToken,`fund/${of[ta.Algo].assetId}/limit`,null,"GET")).json()).amount}}}var tR=Oe.Kmd,nR=Oe.Indexer;class zt{constructor(e,t){const r="algod"in e?e:{algod:zt.getAlgodClient(e.algodConfig),indexer:e.indexerConfig?zt.getIndexerClient(e.indexerConfig):void 0,kmd:e.kmdConfig?zt.getKmdClient(e.kmdConfig):void 0};this._algod=r.algod,this._indexer=r.indexer,this._kmd=r.kmd,this._algorand=t}get algod(){return this._algod}get indexer(){if(!this._indexer)throw new Error("Attempt to use Indexer client in AlgoKit instance with no Indexer configured");return this._indexer}get indexerIfPresent(){return this._indexer}get kmd(){if(!this._kmd)throw new Error("Attempt to use Kmd client in AlgoKit instance with no Kmd configured");return this._kmd}async network(){this._getNetworkPromise||(this._getNetworkPromise=this._algod.getTransactionParams().do());const e=await this._getNetworkPromise;return{isTestNet:["testnet-v1.0","testnet-v1","testnet"].includes(e.genesisID??"unknown"),isMainNet:["mainnet-v1.0","mainnet-v1","mainnet"].includes(e.genesisID??"unknown"),isLocalNet:zt.genesisIdIsLocalNet(e.genesisID??"unknown"),genesisId:e.genesisID??"unknown",genesisHash:e.genesisHash?Buffer.from(e.genesisHash).toString("base64"):"unknown"}}static genesisIdIsLocalNet(e){return Zv(e)}async isLocalNet(){return(await this.network()).isLocalNet}async isTestNet(){return(await this.network()).isTestNet}async isMainNet(){return(await this.network()).isMainNet}getTestNetDispenser(e){return new sw(e)}getTestNetDispenserFromEnvironment(e){return new sw(e?{...e,authToken:""}:void 0)}getAppFactory(e){if(!this._algorand)throw new Error("Attempt to get app factory from a ClientManager without an Algorand client");return new eS({...e,algorand:this._algorand})}getAppClientByCreatorAndName(e){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return cn.fromCreatorAndName({...e,algorand:this._algorand})}getAppClientById(e){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return new cn({...e,algorand:this._algorand})}async getAppClientByNetwork(e){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return cn.fromNetwork({...e,algorand:this._algorand})}async getTypedAppClientByCreatorAndName(e,t){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return e.fromCreatorAndName({...t,algorand:this._algorand})}getTypedAppClientById(e,t){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return new e({...t,algorand:this._algorand})}getTypedAppClientByNetwork(e,t){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return e.fromNetwork({...t,algorand:this._algorand})}getTypedAppFactory(e,t){if(!this._algorand)throw new Error("Attempt to get app factory from a ClientManager without an Algorand client");return new e({...t,algorand:this._algorand})}static getConfigFromEnvironmentOrLocalNet(){var i;if(!process||!process.env)throw new Error("Attempt to get default client configuration from a non Node.js context; supply the config instead");const[e,t,r]=process.env.ALGOD_SERVER?[zt.getAlgodConfigFromEnvironment(),process.env.INDEXER_SERVER?zt.getIndexerConfigFromEnvironment():void 0,!process.env.ALGOD_SERVER.includes("mainnet")&&!process.env.ALGOD_SERVER.includes("testnet")?{...zt.getAlgodConfigFromEnvironment(),port:((i=process==null?void 0:process.env)==null?void 0:i.KMD_PORT)??"4002"}:void 0]:[zt.getDefaultLocalNetConfig("algod"),zt.getDefaultLocalNetConfig("indexer"),zt.getDefaultLocalNetConfig("kmd")];return{algodConfig:e,indexerConfig:t,kmdConfig:r}}static getAlgodConfigFromEnvironment(){if(!process||!process.env)throw new Error("Attempt to get default algod configuration from a non Node.js context; supply the config instead");if(!process.env.ALGOD_SERVER)throw new Error("Attempt to get default algod configuration without specifying ALGOD_SERVER in the environment variables");return{server:process.env.ALGOD_SERVER,port:process.env.ALGOD_PORT,token:process.env.ALGOD_TOKEN}}static getIndexerConfigFromEnvironment(){if(!process||!process.env)throw new Error("Attempt to get default indexer configuration from a non Node.js context; supply the config instead");if(!process.env.INDEXER_SERVER)throw new Error("Attempt to get default indexer configuration without specifying INDEXER_SERVER in the environment variables");return{server:process.env.INDEXER_SERVER,port:process.env.INDEXER_PORT,token:process.env.INDEXER_TOKEN}}static getAlgoNodeConfig(e,t){return{server:`https://${e}-${t==="algod"?"api":"idx"}.algonode.cloud/`,port:443}}static getDefaultLocalNetConfig(e){return{server:"http://localhost",port:e==="algod"?4001:e==="indexer"?8980:e==="kmd"?4002:e,token:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}}static getAlgodClient(e){const{token:t,server:r,port:i}=e,o=typeof t=="string"?{"X-Algo-API-Token":t}:t??{},s=new er(o,r,i);return new Oe.Algodv2(s,r)}static getAlgodClientFromEnvironment(){return zt.getAlgodClient(zt.getAlgodConfigFromEnvironment())}static getIndexerClient(e){const{token:t,server:r,port:i}=e,o=typeof t=="string"?{"X-Indexer-API-Token":t}:t??{},s=new er(o,r,i);return new nR(s)}static getIndexerClientFromEnvironment(){return zt.getIndexerClient(zt.getIndexerConfigFromEnvironment())}static getKmdClient(e){const{token:t,server:r,port:i}=e;return new tR(t,r,i)}static getKmdClientFromEnvironment(){var e;return zt.getKmdClient({...zt.getAlgodConfigFromEnvironment(),port:((e=process==null?void 0:process.env)==null?void 0:e.KMD_PORT)??"4002"})}}class rR{constructor(e){this._clientManager=e;try{this._kmd=e.kmd}catch{this._kmd=void 0}}async kmd(){if(this._kmd===void 0){if(await this._clientManager.isLocalNet()){const{kmdConfig:e}=zt.getConfigFromEnvironmentOrLocalNet();if(e)return this._kmd=zt.getKmdClient(e),this._kmd}this._kmd=null}if(!this._kmd)throw new Error("Attempt to use Kmd client in AlgoKit instance with no Kmd configured");return this._kmd}async getWalletAccount(e,t,r){return this.findWalletAccount(e,t,r)}async findWalletAccount(e,t,r){const i=await this.kmd(),s=(await i.listWallets()).wallets.filter(x=>x.name===e);if(s.length===0)return;const a=s[0].id,l=(await i.initWalletHandle(a,"")).wallet_handle_token;let c;if(t&&typeof t=="string")c=t;else{const x=(await i.listKeys(l)).addresses;if(x.length>0)if(t&&typeof t=="function")for(let A=0;A<x.length;A++){const v=await this._clientManager.algod.accountInformation(x[A]).do();if(t(v)){c=x[A];break}}else c=x[0]}if(!c)return;const d=(await i.exportKey(l,"",c)).private_key,u=Oe.secretKeyToMnemonic(d),m=Oe.mnemonicToSecretKey(u),h=new Gp(m,r);return{account:h,addr:h.addr,signer:h.signer}}async getOrCreateWalletAccount(e,t){const r=await this.getWalletAccount(e);if(r)return r;const i=await this.kmd(),o=(await i.createWallet(e,"")).wallet.id,s=(await i.initWalletHandle(o,"")).wallet_handle_token;await i.generateKey(s);const a=await this.getWalletAccount(e);ft.logger.info(`LocalNet account '${e}' doesn't yet exist; created account ${a.addr} with keys stored in KMD and funding with ${(t==null?void 0:t.algo)??1e3} ALGO`);const l=await this.getLocalNetDispenserAccount();return await new zr({algod:this._clientManager.algod,getSigner:()=>l.signer,getSuggestedParams:()=>this._clientManager.algod.getTransactionParams().do()}).addPayment({amount:t??Wn.Algo(1e3),receiver:a.addr,sender:l.addr}).send(),a}async getLocalNetDispenserAccount(){if(!await this._clientManager.isLocalNet())throw new Error("Can't get LocalNet dispenser account from non LocalNet network");const t=JSON.parse(await this._clientManager.algod.genesis().do()).alloc.filter(r=>r.comment==="Wallet1").map(r=>r.addr);if(t.length>0){const r=await this.findWalletAccount("unencrypted-default-wallet",t[0]);if(r)return r}throw new Error("Error retrieving LocalNet dispenser account; couldn't find the default account in KMD")}}var iR=Oe.LogicSigAccount;const cr=n=>typeof n=="string"?ze.fromString(n):n,oR=CM(function(n){return"signer"in n?n.signer:"lsig"in n?Oe.makeLogicSigAccountTransactionSigner(n):Oe.makeBasicAccountTransactionSigner(n)});class sR{constructor(e){this._accounts={},this._clientManager=e,this._kmdAccountManager=new rR(e)}_getComposer(e){return new zr({algod:this._clientManager.algod,getSigner:this.getSigner.bind(this),getSuggestedParams:e??(()=>this._clientManager.algod.getTransactionParams().do())})}get kmd(){return this._kmdAccountManager}setDefaultSigner(e){return this._defaultSigner="signer"in e?e.signer:e,this}signerAccount(e){const t=oR(e),r={addr:"addr"in e?e.addr:e.address(),signer:t};this._accounts[r.addr.toString()]=r;const i=ze.fromString(r.addr.toString());return i.account=e,i.addr=r.addr,i.signer=t,i}setSignerFromAccount(e){return this.signerAccount(e),this}setSigner(e,t){return this._accounts[cr(e).toString()]={addr:cr(e),signer:t},this}setSigners(e,t=!0){return this._accounts=t?{...this._accounts,...e._accounts}:{...e._accounts,...this._accounts},this}getSigner(e){var r;const t=((r=this._accounts[cr(e).toString()])==null?void 0:r.signer)??this._defaultSigner;if(!t)throw new Error(`No signer found for address ${e}`);return t}getAccount(e){const t=this._accounts[cr(e).toString()];if(!t)throw new Error(`No signer found for address ${e}`);return t}async getInformation(e){const{round:t,lastHeartbeat:r=void 0,lastProposed:i=void 0,address:o,...s}=await this._clientManager.algod.accountInformation(e).do();return{...s,address:ze.fromString(o),balance:Wn.MicroAlgo(Number(s.amount)),amountWithoutPendingRewards:Wn.MicroAlgo(Number(s.amountWithoutPendingRewards)),minBalance:Wn.MicroAlgo(Number(s.minBalance)),pendingRewards:Wn.MicroAlgo(Number(s.pendingRewards)),rewards:Wn.MicroAlgo(Number(s.rewards)),validAsOfRound:BigInt(t),totalAppsOptedIn:Number(s.totalAppsOptedIn),totalAssetsOptedIn:Number(s.totalAssetsOptedIn),totalCreatedApps:Number(s.totalCreatedApps),totalCreatedAssets:Number(s.totalCreatedAssets),appsTotalExtraPages:s.appsTotalExtraPages!==void 0?Number(s.appsTotalExtraPages):void 0,rewardBase:s.rewardBase!==void 0?Number(s.rewardBase):void 0,totalBoxBytes:s.totalBoxBytes!==void 0?Number(s.totalBoxBytes):void 0,totalBoxes:s.totalBoxes!==void 0?Number(s.totalBoxes):void 0,lastHeartbeatRound:r!==void 0?BigInt(r):void 0,lastProposedRound:i!==void 0?BigInt(i):void 0}}fromMnemonic(e,t){const r=Oe.mnemonicToSecretKey(e);return this.signerAccount(new Gp(r,t))}rekeyed(e,t){return this.signerAccount({addr:cr(e),signer:t.signer})}async fromEnvironment(e,t){if(!process||!process.env)throw new Error("Attempt to get account with private key from a non Node.js context; this is not supported!");const r=process.env[`${e.toUpperCase()}_MNEMONIC`],i=process.env[`${e.toUpperCase()}_SENDER`];if(r){const o=Oe.mnemonicToSecretKey(r);return this.signerAccount(new Gp(o,i))}if(await this._clientManager.isLocalNet()){const o=await this._kmdAccountManager.getOrCreateWalletAccount(e,t);return this.signerAccount(o.account)}throw new Error(`Missing environment variable ${e.toUpperCase()}_MNEMONIC when looking for account ${e}`)}async fromKmd(e,t,r){const i=await this._kmdAccountManager.getWalletAccount(e,t,r);if(!i)throw new Error(`Unable to find KMD account ${e}${t?" with predicate":""}`);return this.signerAccount(i.account)}multisig(e,t){return this.signerAccount(new JM(e,t))}logicsig(e,t){return this.signerAccount(new iR(e,t))}random(){return this.signerAccount(Oe.generateAccount())}async dispenserFromEnvironment(){if(!process||!process.env)throw new Error("Attempt to get dispenser from environment from a non Node.js context; this is not supported!");return process.env[`${rw.toUpperCase()}_MNEMONIC`]?await this.fromEnvironment(rw):await this.localNetDispenser()}async localNetDispenser(){const e=await this._kmdAccountManager.getLocalNetDispenserAccount();return this.signerAccount(e.account)}async rekeyAccount(e,t,r){const i=await this._getComposer().addPayment({...r,sender:cr(e),receiver:cr(e),amount:Wn.MicroAlgo(0),rekeyTo:cr(typeof t=="object"&&"addr"in t?t.addr:t)}).send(r);return typeof t=="object"&&"addr"in t&&this.rekeyed(e,t),ft.getLogger(r==null?void 0:r.suppressLog).info(`Rekeyed ${e} to ${t} via transaction ${i.txIds.at(-1)}`),{...i,transaction:i.transactions.at(-1),confirmation:i.confirmations.at(-1)}}async _getEnsureFundedAmount(e,t,r){const i=await this.getInformation(e),o=i.balance.microAlgo-i.minBalance.microAlgo,s=kM(t.microAlgo,o,(r==null?void 0:r.microAlgo)??0n);return s===null?void 0:Wn.MicroAlgo(s)}async ensureFunded(e,t,r,i){const o=cr(e),s=await this._getEnsureFundedAmount(o,r,i==null?void 0:i.minFundingIncrement);if(!s)return;const a=await this._getComposer().addPayment({...i,sender:cr(t),receiver:o,amount:s}).send(i);return{...a,transaction:a.transactions[0],confirmation:a.confirmations[0],transactionId:a.txIds[0],amountFunded:s}}async ensureFundedFromEnvironment(e,t,r){const i=cr(e),o=await this.dispenserFromEnvironment(),s=await this._getEnsureFundedAmount(i,t,r==null?void 0:r.minFundingIncrement);if(!s)return;const a=await this._getComposer().addPayment({...r,sender:o,receiver:i,amount:s}).send(r);return{...a,transaction:a.transactions[0],confirmation:a.confirmations[0],transactionId:a.txIds[0],amountFunded:s}}async ensureFundedFromTestNetDispenserApi(e,t,r,i){if(!await this._clientManager.isTestNet())throw new Error("Attempt to fund using TestNet dispenser API on non TestNet network.");const o=cr(e),s=await this._getEnsureFundedAmount(o,r,i==null?void 0:i.minFundingIncrement);if(!s)return;const a=await t.fund(o,s.microAlgo);return{amountFunded:Wn.MicroAlgo(a.amount),transactionId:a.txId}}}class Ri{constructor(e){this._cachedSuggestedParamsTimeout=3e3,this._defaultValidityWindow=void 0,this._errorTransformers=new Set,this._clientManager=new zt(e,this),this._accountManager=new sR(this._clientManager),this._appManager=new Qn(this._clientManager.algod),this._assetManager=new UM(this._clientManager.algod,()=>this.newGroup()),this._transactionSender=new NM(()=>this.newGroup(),this._assetManager,this._appManager),this._transactionCreator=new mM(()=>this.newGroup()),this._appDeployer=new WM(this._appManager,this._transactionSender,this._clientManager.indexerIfPresent)}setDefaultValidityWindow(e){return this._defaultValidityWindow=BigInt(e),this}setDefaultSigner(e){return this._accountManager.setDefaultSigner(e),this}setSignerFromAccount(e){return this._accountManager.setSignerFromAccount(e),this}setSigner(e,t){return this._accountManager.setSigner(e,t),this}setSuggestedParamsCache(e,t){return this._cachedSuggestedParams=e,this._cachedSuggestedParamsExpiry=t??new Date(+new Date+this._cachedSuggestedParamsTimeout),this}setSuggestedParamsCacheTimeout(e){return this._cachedSuggestedParamsTimeout=e,this}async getSuggestedParams(){return this._cachedSuggestedParams&&(!this._cachedSuggestedParamsExpiry||this._cachedSuggestedParamsExpiry>new Date)?{...this._cachedSuggestedParams}:(this._cachedSuggestedParams=await this._clientManager.algod.getTransactionParams().do(),this._cachedSuggestedParamsExpiry=new Date(new Date().getTime()+this._cachedSuggestedParamsTimeout),{...this._cachedSuggestedParams})}get client(){return this._clientManager}get account(){return this._accountManager}get asset(){return this._assetManager}get app(){return this._appManager}get appDeployer(){return this._appDeployer}registerErrorTransformer(e){this._errorTransformers.add(e)}unregisterErrorTransformer(e){this._errorTransformers.delete(e)}newGroup(){return new zr({algod:this.client.algod,getSigner:e=>this.account.getSigner(e),getSuggestedParams:()=>this.getSuggestedParams(),defaultValidityWindow:this._defaultValidityWindow,appManager:this._appManager,errorTransformers:[...this._errorTransformers]})}get send(){return this._transactionSender}get createTransaction(){return this._transactionCreator}static defaultLocalNet(){return new Ri({algodConfig:zt.getDefaultLocalNetConfig("algod"),indexerConfig:zt.getDefaultLocalNetConfig("indexer"),kmdConfig:zt.getDefaultLocalNetConfig("kmd")})}static testNet(){return new Ri({algodConfig:zt.getAlgoNodeConfig("testnet","algod"),indexerConfig:zt.getAlgoNodeConfig("testnet","indexer"),kmdConfig:void 0})}static mainNet(){return new Ri({algodConfig:zt.getAlgoNodeConfig("mainnet","algod"),indexerConfig:zt.getAlgoNodeConfig("mainnet","indexer"),kmdConfig:void 0})}static fromClients(e){return new Ri(e)}static fromEnvironment(){return new Ri(zt.getConfigFromEnvironmentOrLocalNet())}static fromConfig(e){return new Ri(e)}}const mr={name:"AbelReader",structs:{AssetTinyLabels:[{name:"name",type:"string"},{name:"unitName",type:"string"},{name:"decimals",type:"uint8"},{name:"labels",type:"string[]"}],BalanceInfo:[{name:"balance",type:"uint64"},{name:"minBalance",type:"uint64"}]},methods:[{name:"getBalanceInfo",args:[{type:"address[]",name:"accounts"}],returns:{type:"(uint64,uint64)",struct:"BalanceInfo"},actions:{create:["NoOp"],call:["NoOp"]},readonly:!0,events:[],recommendations:{}},{name:"getAssetsTiny",args:[{type:"uint64[]",name:"assetIds"},{type:"uint64",name:"abelAppId"}],returns:{type:"(string,string,uint8,string[])",struct:"AssetTinyLabels"},actions:{create:["NoOp"],call:["NoOp"]},readonly:!0,events:[],recommendations:{}},{name:"get_asset_labels",args:[{type:"asset",name:"assetId"}],returns:{type:"string[]"},actions:{create:["NoOp"],call:["NoOp"]},readonly:!0,events:[],recommendations:{}}],arcs:[22,28],networks:{},state:{schema:{global:{ints:0,bytes:0},local:{ints:0,bytes:0}},keys:{global:{},local:{},box:{}},maps:{global:{},local:{},box:{}}},bareActions:{create:[],call:["DeleteApplication","UpdateApplication"]},sourceInfo:{approval:{sourceInfo:[{pc:[332],errorMessage:"Bytes has valid prefix"},{pc:[8],errorMessage:"OnCompletion must be NoOp"},{pc:[48],errorMessage:"OnCompletion must be one of UpdateApplication, DeleteApplication && can only call when not creating"},{pc:[347,354,357],errorMessage:"asset exists"},{pc:[108,236],errorMessage:"index access is out of bounds"},{pc:[77,195],errorMessage:"invalid array length header"},{pc:[89],errorMessage:"invalid number of bytes for arc4.dynamic_array<account>"},{pc:[207],errorMessage:"invalid number of bytes for arc4.dynamic_array<asset>"},{pc:[215,337],errorMessage:"invalid number of bytes for arc4.uint64"},{pc:[485],errorMessage:"invalid number of bytes for arc4.uint8"},{pc:[363],errorMessage:"overflow"}],pcOffsetMethod:"cblocks"},clear:{sourceInfo:[],pcOffsetMethod:"none"}},source:{approval:"I3ByYWdtYSB2ZXJzaW9uIDExCiNwcmFnbWEgdHlwZXRyYWNrIGZhbHNlCgovLyBAYWxnb3JhbmRmb3VuZGF0aW9uL2FsZ29yYW5kLXR5cGVzY3JpcHQvYXJjNC9pbmRleC5kLnRzOjpDb250cmFjdC5hcHByb3ZhbFByb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW46CiAgICBpbnRjYmxvY2sgMCAxIDggMzIgVE1QTF9VUERBVEFCTEUKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjMwCiAgICAvLyBleHBvcnQgY2xhc3MgQWJlbFJlYWRlciBleHRlbmRzIENvbnRyYWN0IHsKICAgIHR4biBOdW1BcHBBcmdzCiAgICBieiBtYWluX2FkbWluT25seUAxMAogICAgdHhuIE9uQ29tcGxldGlvbgogICAgIQogICAgYXNzZXJ0IC8vIE9uQ29tcGxldGlvbiBtdXN0IGJlIE5vT3AKICAgIHB1c2hieXRlc3MgMHg0ODc3YTk2NyAweGQ1YWIzMzY2IDB4YzJlZDc0M2YgLy8gbWV0aG9kICJnZXRCYWxhbmNlSW5mbyhhZGRyZXNzW10pKHVpbnQ2NCx1aW50NjQpIiwgbWV0aG9kICJnZXRBc3NldHNUaW55KHVpbnQ2NFtdLHVpbnQ2NCkoc3RyaW5nLHN0cmluZyx1aW50OCxzdHJpbmdbXSkiLCBtZXRob2QgImdldF9hc3NldF9sYWJlbHMoYXNzZXQpc3RyaW5nW10iCiAgICB0eG5hIEFwcGxpY2F0aW9uQXJncyAwCiAgICBtYXRjaCBnZXRCYWxhbmNlSW5mbyBnZXRBc3NldHNUaW55IGdldEFzc2V0TGFiZWxzCiAgICBlcnIKCm1haW5fYWRtaW5Pbmx5QDEwOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzEKICAgIC8vIEBiYXJlbWV0aG9kKHsgYWxsb3dBY3Rpb25zOiBbIlVwZGF0ZUFwcGxpY2F0aW9uIiwgIkRlbGV0ZUFwcGxpY2F0aW9uIl0gfSkKICAgIGludGNfMSAvLyAxCiAgICB0eG4gT25Db21wbGV0aW9uCiAgICBzaGwKICAgIHB1c2hpbnQgNDggLy8gNDgKICAgICYKICAgIHR4biBBcHBsaWNhdGlvbklECiAgICAmJgogICAgYXNzZXJ0IC8vIE9uQ29tcGxldGlvbiBtdXN0IGJlIG9uZSBvZiBVcGRhdGVBcHBsaWNhdGlvbiwgRGVsZXRlQXBwbGljYXRpb24gJiYgY2FuIG9ubHkgY2FsbCB3aGVuIG5vdCBjcmVhdGluZwogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzMKICAgIC8vIGFzc2VydChUZW1wbGF0ZVZhcjx1aW50NjQ+KCJVUERBVEFCTEUiKSA9PT0gMSAmJiBUeG4uc2VuZGVyID09PSBHbG9iYWwuY3JlYXRvckFkZHJlc3MpOwogICAgaW50YyA0IC8vIFRNUExfVVBEQVRBQkxFCiAgICBpbnRjXzEgLy8gMQogICAgPT0KICAgIGJ6IG1haW5fYm9vbF9mYWxzZUAxNAogICAgdHhuIFNlbmRlcgogICAgZ2xvYmFsIENyZWF0b3JBZGRyZXNzCiAgICA9PQogICAgYnogbWFpbl9ib29sX2ZhbHNlQDE0CiAgICBpbnRjXzEgLy8gMQogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzEKICAgIC8vIEBiYXJlbWV0aG9kKHsgYWxsb3dBY3Rpb25zOiBbIlVwZGF0ZUFwcGxpY2F0aW9uIiwgIkRlbGV0ZUFwcGxpY2F0aW9uIl0gfSkKICAgIHJldHVybgoKbWFpbl9ib29sX2ZhbHNlQDE0OgogICAgaW50Y18wIC8vIDAKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjMxCiAgICAvLyBAYmFyZW1ldGhvZCh7IGFsbG93QWN0aW9uczogWyJVcGRhdGVBcHBsaWNhdGlvbiIsICJEZWxldGVBcHBsaWNhdGlvbiJdIH0pCiAgICByZXR1cm4KCgovLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo6QWJlbFJlYWRlci5nZXRCYWxhbmNlSW5mb1tyb3V0aW5nXSgpIC0+IHZvaWQ6CmdldEJhbGFuY2VJbmZvOgogICAgaW50Y18wIC8vIDAKICAgIHB1c2hieXRlcyAiIgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzYKICAgIC8vIEBhYmltZXRob2QoeyByZWFkb25seTogdHJ1ZSwgb25DcmVhdGU6ICJhbGxvdyIgfSkKICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDEKICAgIGR1cG4gMgogICAgaW50Y18wIC8vIDAKICAgIGV4dHJhY3RfdWludDE2IC8vIG9uIGVycm9yOiBpbnZhbGlkIGFycmF5IGxlbmd0aCBoZWFkZXIKICAgIGR1cAogICAgY292ZXIgMgogICAgaW50Y18zIC8vIDMyCiAgICAqCiAgICBwdXNoaW50IDIgLy8gMgogICAgKwogICAgc3dhcAogICAgbGVuCiAgICA9PQogICAgYXNzZXJ0IC8vIGludmFsaWQgbnVtYmVyIG9mIGJ5dGVzIGZvciBhcmM0LmR5bmFtaWNfYXJyYXk8YWNjb3VudD4KICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFjY291bnRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGludGNfMCAvLyAwCgpnZXRCYWxhbmNlSW5mb193aGlsZV90b3BAMjoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFjY291bnRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGR1cAogICAgZGlnIDIKICAgIDwKICAgIGJ6IGdldEJhbGFuY2VJbmZvX2FmdGVyX3doaWxlQDcKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM5CiAgICAvLyBjb25zdCBhY2NvdW50ID0gYWNjb3VudHNbaWR4XTsKICAgIGRpZyAyCiAgICBleHRyYWN0IDIgMAogICAgZGlnIDEKICAgIGludGNfMyAvLyAzMgogICAgKgogICAgaW50Y18zIC8vIDMyCiAgICBleHRyYWN0MyAvLyBvbiBlcnJvcjogaW5kZXggYWNjZXNzIGlzIG91dCBvZiBib3VuZHMKICAgIGR1cAogICAgYnVyeSA2CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo0MAogICAgLy8gY29uc3QgYmFsYW5jZSA9IG9wLmJhbGFuY2UoYWNjb3VudCk7CiAgICBiYWxhbmNlCiAgICBkdXAKICAgIGJ1cnkgNQogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NDEKICAgIC8vIGlmIChiYWxhbmNlID4gMCkgewogICAgYnogZ2V0QmFsYW5jZUluZm9fZWxzZV9ib2R5QDUKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjQyCiAgICAvLyBjb25zdCBtaW5CYWxhbmNlID0gb3AubWluQmFsYW5jZShhY2NvdW50KTsKICAgIGRpZyA0CiAgICBtaW5fYmFsYW5jZQogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NDMKICAgIC8vIGNvbnN0IGJhbGFuY2VJbmZvOiBCYWxhbmNlSW5mbyA9IHsgYmFsYW5jZSwgbWluQmFsYW5jZSB9OwogICAgZGlnIDQKICAgIGl0b2IKICAgIHN3YXAKICAgIGl0b2IKICAgIGNvbmNhdAogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NDQKICAgIC8vIGxvZyhlbmNvZGVBcmM0KGJhbGFuY2VJbmZvKSk7CiAgICBsb2cKCmdldEJhbGFuY2VJbmZvX2FmdGVyX2lmX2Vsc2VANjoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFjY291bnRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGR1cAogICAgaW50Y18xIC8vIDEKICAgICsKICAgIGJ1cnkgMQogICAgYiBnZXRCYWxhbmNlSW5mb193aGlsZV90b3BAMgoKZ2V0QmFsYW5jZUluZm9fZWxzZV9ib2R5QDU6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo1MwogICAgLy8gcmV0dXJuIHsgYmFsYW5jZTogMCwgbWluQmFsYW5jZTogMCB9OwogICAgcHVzaGJ5dGVzIDB4MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjQ2CiAgICAvLyBsb2coZW5jb2RlQXJjNCh0aGlzLmdldEVtcHR5QmFsYW5jZUluZm8oKSkpOwogICAgbG9nCiAgICBiIGdldEJhbGFuY2VJbmZvX2FmdGVyX2lmX2Vsc2VANgoKZ2V0QmFsYW5jZUluZm9fYWZ0ZXJfd2hpbGVANzoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM2CiAgICAvLyBAYWJpbWV0aG9kKHsgcmVhZG9ubHk6IHRydWUsIG9uQ3JlYXRlOiAiYWxsb3ciIH0pCiAgICBwdXNoYnl0ZXMgMHgxNTFmN2M3NTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCiAgICBsb2cKICAgIGludGNfMSAvLyAxCiAgICByZXR1cm4KCgovLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo6QWJlbFJlYWRlci5nZXRBc3NldHNUaW55W3JvdXRpbmddKCkgLT4gdm9pZDoKZ2V0QXNzZXRzVGlueToKICAgIGludGNfMCAvLyAwCiAgICBkdXBuIDMKICAgIHB1c2hieXRlcyAiIgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTYKICAgIC8vIEBhYmltZXRob2QoeyByZWFkb25seTogdHJ1ZSwgb25DcmVhdGU6ICJhbGxvdyIgfSkKICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDEKICAgIGR1cG4gMgogICAgaW50Y18wIC8vIDAKICAgIGV4dHJhY3RfdWludDE2IC8vIG9uIGVycm9yOiBpbnZhbGlkIGFycmF5IGxlbmd0aCBoZWFkZXIKICAgIGR1cAogICAgY292ZXIgMgogICAgaW50Y18yIC8vIDgKICAgICoKICAgIHB1c2hpbnQgMiAvLyAyCiAgICArCiAgICBzd2FwCiAgICBsZW4KICAgID09CiAgICBhc3NlcnQgLy8gaW52YWxpZCBudW1iZXIgb2YgYnl0ZXMgZm9yIGFyYzQuZHluYW1pY19hcnJheTxhc3NldD4KICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDIKICAgIGR1cAogICAgbGVuCiAgICBpbnRjXzIgLy8gOAogICAgPT0KICAgIGFzc2VydCAvLyBpbnZhbGlkIG51bWJlciBvZiBieXRlcyBmb3IgYXJjNC51aW50NjQKICAgIGJ0b2kKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjU4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFzc2V0SWRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGludGNfMCAvLyAwCgpnZXRBc3NldHNUaW55X3doaWxlX3RvcEAyOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTgKICAgIC8vIGZvciAobGV0IGlkeDogdWludDY0ID0gMDsgaWR4IDwgYXNzZXRJZHMubGVuZ3RoOyBpZHgrKykgewogICAgZHVwCiAgICBkaWcgMwogICAgPAogICAgYnogZ2V0QXNzZXRzVGlueV9hZnRlcl93aGlsZUAxNAogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTkKICAgIC8vIGNvbnN0IGFzc2V0ID0gYXNzZXRJZHNbaWR4XTsKICAgIGRpZyAzCiAgICBleHRyYWN0IDIgMAogICAgZGlnIDEKICAgIGludGNfMiAvLyA4CiAgICAqCiAgICBkdXAyCiAgICBpbnRjXzIgLy8gOAogICAgZXh0cmFjdDMgLy8gb24gZXJyb3I6IGluZGV4IGFjY2VzcyBpcyBvdXQgb2YgYm91bmRzCiAgICBidXJ5IDExCiAgICBleHRyYWN0X3VpbnQ2NAogICAgZHVwCiAgICBidXJ5IDYKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjYwCiAgICAvLyBjb25zdCBbXywgZXhpc3RzXSA9IG9wLkFzc2V0UGFyYW1zLmFzc2V0Q3JlYXRvcihhc3NldC5pZCk7CiAgICBhc3NldF9wYXJhbXNfZ2V0IEFzc2V0Q3JlYXRvcgogICAgYnVyeSAxCiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo2MQogICAgLy8gaWYgKCFleGlzdHMpIHsKICAgIGJueiBnZXRBc3NldHNUaW55X2Vsc2VfYm9keUA1CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo4NS05MAogICAgLy8gcmV0dXJuIHsKICAgIC8vICAgbmFtZTogIiIsCiAgICAvLyAgIHVuaXRfbmFtZTogIiIsCiAgICAvLyAgIGRlY2ltYWxzOiBuZXcgVWludDgoMCksCiAgICAvLyAgIGxhYmVsczogW10sCiAgICAvLyB9OwogICAgcHVzaGJ5dGVzIDB4MDAwNzAwMDkwMDAwMGIwMDAwMDAwMDAwMDAKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjYyCiAgICAvLyBsb2coZW5jb2RlQXJjNCh0aGlzLmdldEVtcHR5QXNzZXRUaW55TGFiZWxzKCkpKTsKICAgIGxvZwoKZ2V0QXNzZXRzVGlueV9hZnRlcl9pZl9lbHNlQDEzOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTgKICAgIC8vIGZvciAobGV0IGlkeDogdWludDY0ID0gMDsgaWR4IDwgYXNzZXRJZHMubGVuZ3RoOyBpZHgrKykgewogICAgZHVwCiAgICBpbnRjXzEgLy8gMQogICAgKwogICAgYnVyeSAxCiAgICBiIGdldEFzc2V0c1Rpbnlfd2hpbGVfdG9wQDIKCmdldEFzc2V0c1RpbnlfZWxzZV9ib2R5QDU6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo2NQogICAgLy8gYWJlbEFwcElkICE9PSAwID8gY29tcGlsZUFyYzQoQWJlbFN0dWIpLmNhbGwuaGFzX2Fzc2V0X2xhYmVsKHsgYXBwSWQ6IGFiZWxBcHBJZCwgYXJnczogW2Fzc2V0LmlkLCAicHYiXSB9KS5yZXR1cm5WYWx1ZSA6IDA7CiAgICBkaWcgMQogICAgYnogZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X2ZhbHNlQDgKICAgIGl0eG5fYmVnaW4KICAgIHB1c2hieXRlcyAweDk3ZjQwYThhIC8vIG1ldGhvZCAiaGFzX2Fzc2V0X2xhYmVsKHVpbnQ2NCxzdHJpbmcpdWludDY0IgogICAgaXR4bl9maWVsZCBBcHBsaWNhdGlvbkFyZ3MKICAgIGRpZyA4CiAgICBpdHhuX2ZpZWxkIEFwcGxpY2F0aW9uQXJncwogICAgcHVzaGJ5dGVzIDB4MDAwMjcwNzYKICAgIGl0eG5fZmllbGQgQXBwbGljYXRpb25BcmdzCiAgICBpbnRjXzAgLy8gMAogICAgaXR4bl9maWVsZCBPbkNvbXBsZXRpb24KICAgIGRpZyAxCiAgICBpdHhuX2ZpZWxkIEFwcGxpY2F0aW9uSUQKICAgIHB1c2hpbnQgNiAvLyBhcHBsCiAgICBpdHhuX2ZpZWxkIFR5cGVFbnVtCiAgICBpbnRjXzAgLy8gMAogICAgaXR4bl9maWVsZCBGZWUKICAgIGl0eG5fc3VibWl0CiAgICBpdHhuIExhc3RMb2cKICAgIGR1cAogICAgZXh0cmFjdCA0IDAKICAgIHN3YXAKICAgIGV4dHJhY3QgMCA0CiAgICBwdXNoYnl0ZXMgMHgxNTFmN2M3NQogICAgPT0KICAgIGFzc2VydCAvLyBCeXRlcyBoYXMgdmFsaWQgcHJlZml4CiAgICBkdXAKICAgIGxlbgogICAgaW50Y18yIC8vIDgKICAgID09CiAgICBhc3NlcnQgLy8gaW52YWxpZCBudW1iZXIgb2YgYnl0ZXMgZm9yIGFyYzQudWludDY0CiAgICBidG9pCgpnZXRBc3NldHNUaW55X3Rlcm5hcnlfbWVyZ2VAOToKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjY3CiAgICAvLyBuYW1lOiBhc3NldC5uYW1lLnRvU3RyaW5nKCksCiAgICBkaWcgNQogICAgZHVwCiAgICBhc3NldF9wYXJhbXNfZ2V0IEFzc2V0TmFtZQogICAgc3dhcAogICAgYnVyeSAxMAogICAgYXNzZXJ0IC8vIGFzc2V0IGV4aXN0cwogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NjgKICAgIC8vIHVuaXRfbmFtZTogYXNzZXQudW5pdE5hbWUudG9TdHJpbmcoKSwKICAgIGR1cAogICAgYXNzZXRfcGFyYW1zX2dldCBBc3NldFVuaXROYW1lCiAgICBzd2FwCiAgICBidXJ5IDkKICAgIGFzc2VydCAvLyBhc3NldCBleGlzdHMKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjY5CiAgICAvLyBkZWNpbWFsczogbmV3IFVpbnQ4KGFzc2V0LmRlY2ltYWxzKSwKICAgIGFzc2V0X3BhcmFtc19nZXQgQXNzZXREZWNpbWFscwogICAgYXNzZXJ0IC8vIGFzc2V0IGV4aXN0cwogICAgaXRvYgogICAgZHVwCiAgICBiaXRsZW4KICAgIGludGNfMiAvLyA4CiAgICA8PQogICAgYXNzZXJ0IC8vIG92ZXJmbG93CiAgICBleHRyYWN0IDcgMQogICAgYnVyeSA5CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo3MAogICAgLy8gbGFiZWxzOiBwdiA9PT0gMCA/IChbXSBhcyBzdHJpbmdbXSkgOiBbInB2Il0sCiAgICBibnogZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X2ZhbHNlQDExCiAgICBwdXNoYnl0ZXMgMHgwMDAwCgpnZXRBc3NldHNUaW55X3Rlcm5hcnlfbWVyZ2VAMTI6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo2Ni03MQogICAgLy8gY29uc3QgYXNzZXRJbmZvOiBBc3NldFRpbnlMYWJlbHMgPSB7CiAgICAvLyAgIG5hbWU6IGFzc2V0Lm5hbWUudG9TdHJpbmcoKSwKICAgIC8vICAgdW5pdF9uYW1lOiBhc3NldC51bml0TmFtZS50b1N0cmluZygpLAogICAgLy8gICBkZWNpbWFsczogbmV3IFVpbnQ4KGFzc2V0LmRlY2ltYWxzKSwKICAgIC8vICAgbGFiZWxzOiBwdiA9PT0gMCA/IChbXSBhcyBzdHJpbmdbXSkgOiBbInB2Il0sCiAgICAvLyB9OwogICAgZGlnIDcKICAgIGR1cAogICAgbGVuCiAgICBpdG9iCiAgICBleHRyYWN0IDYgMgogICAgc3dhcAogICAgY29uY2F0CiAgICBkdXAKICAgIGxlbgogICAgcHVzaGludCA3IC8vIDcKICAgICsKICAgIGRpZyA4CiAgICBkdXAKICAgIGxlbgogICAgaXRvYgogICAgZXh0cmFjdCA2IDIKICAgIHN3YXAKICAgIGNvbmNhdAogICAgZGlnIDEKICAgIGl0b2IKICAgIGV4dHJhY3QgNiAyCiAgICBwdXNoYnl0ZXMgMHgwMDA3CiAgICBzd2FwCiAgICBjb25jYXQKICAgIGRpZyAxCiAgICBsZW4KICAgIHVuY292ZXIgMwogICAgKwogICAgc3dhcAogICAgZGlnIDEyCiAgICBjb25jYXQKICAgIHN3YXAKICAgIGl0b2IKICAgIGV4dHJhY3QgNiAyCiAgICBjb25jYXQKICAgIHVuY292ZXIgMgogICAgY29uY2F0CiAgICBzd2FwCiAgICBjb25jYXQKICAgIHN3YXAKICAgIGNvbmNhdAogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NzIKICAgIC8vIGxvZyhlbmNvZGVBcmM0KGFzc2V0SW5mbykpOwogICAgbG9nCiAgICBiIGdldEFzc2V0c1RpbnlfYWZ0ZXJfaWZfZWxzZUAxMwoKZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X2ZhbHNlQDExOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NzAKICAgIC8vIGxhYmVsczogcHYgPT09IDAgPyAoW10gYXMgc3RyaW5nW10pIDogWyJwdiJdLAogICAgcHVzaGJ5dGVzIDB4MDAwMTAwMDIwMDAyNzA3NgogICAgYiBnZXRBc3NldHNUaW55X3Rlcm5hcnlfbWVyZ2VAMTIKCmdldEFzc2V0c1RpbnlfdGVybmFyeV9mYWxzZUA4OgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NjUKICAgIC8vIGFiZWxBcHBJZCAhPT0gMCA/IGNvbXBpbGVBcmM0KEFiZWxTdHViKS5jYWxsLmhhc19hc3NldF9sYWJlbCh7IGFwcElkOiBhYmVsQXBwSWQsIGFyZ3M6IFthc3NldC5pZCwgInB2Il0gfSkucmV0dXJuVmFsdWUgOiAwOwogICAgaW50Y18wIC8vIDAKICAgIGIgZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X21lcmdlQDkKCmdldEFzc2V0c1RpbnlfYWZ0ZXJfd2hpbGVAMTQ6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo1NgogICAgLy8gQGFiaW1ldGhvZCh7IHJlYWRvbmx5OiB0cnVlLCBvbkNyZWF0ZTogImFsbG93IiB9KQogICAgcHVzaGJ5dGVzIDB4MTUxZjdjNzUwMDA3MDAwOTAwMDAwYjAwMDAwMDAwMDAwMAogICAgbG9nCiAgICBpbnRjXzEgLy8gMQogICAgcmV0dXJuCgoKLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6OkFiZWxSZWFkZXIuZ2V0QXNzZXRMYWJlbHNbcm91dGluZ10oKSAtPiB2b2lkOgpnZXRBc3NldExhYmVsczoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjc4CiAgICAvLyBAYWJpbWV0aG9kKHsgcmVhZG9ubHk6IHRydWUsIG9uQ3JlYXRlOiAiYWxsb3ciLCBuYW1lOiAiZ2V0X2Fzc2V0X2xhYmVscyIsIHJlc291cmNlRW5jb2Rpbmc6ICJpbmRleCIgfSkKICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDEKICAgIGxlbgogICAgaW50Y18xIC8vIDEKICAgID09CiAgICBhc3NlcnQgLy8gaW52YWxpZCBudW1iZXIgb2YgYnl0ZXMgZm9yIGFyYzQudWludDgKICAgIHB1c2hieXRlcyAweDE1MWY3Yzc1MDAwMAogICAgbG9nCiAgICBpbnRjXzEgLy8gMQogICAgcmV0dXJuCg==",clear:"I3ByYWdtYSB2ZXJzaW9uIDExCiNwcmFnbWEgdHlwZXRyYWNrIGZhbHNlCgovLyBAYWxnb3JhbmRmb3VuZGF0aW9uL2FsZ29yYW5kLXR5cGVzY3JpcHQvYmFzZS1jb250cmFjdC5kLnRzOjpCYXNlQ29udHJhY3QuY2xlYXJTdGF0ZVByb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW46CiAgICBwdXNoaW50IDEgLy8gMQogICAgcmV0dXJuCg=="},byteCode:{approval:"CyAFAAEIIAAxG0EAITEZFESCAwRId6lnBNWrM2YEwu10PzYaAI4DAB8AkwG6ACMxGZCBMBoxGBBEIQQjEkEACjEAMgkSQQACI0MiQyKAADYaAUcCIllJTgIlC4ECCEwVEkQiSUsCDEEAPUsCVwIASwElCyVYSUUGYElFBUEAEksEeEsEFkwWULBJIwhFAUL/0oAQAAAAAAAAAAAAAAAAAAAAALBC/+KAFBUffHUAAAAAAAAAAAAAAAAAAAAAsCNDIkcDgAA2GgFHAiJZSU4CJAuBAghMFRJENhoCSRUkEkQXIklLAwxBAOhLA1cCAEsBJAtKJFhFC1tJRQZxC0UBQAAYgA0ABwAJAAALAAAAAAAAsEkjCEUBQv/ISwFBAK6xgASX9AqKshpLCLIagAQAAnB2shoishlLAbIYgQayECKyAbO0PklXBABMVwAEgAQVH3x1EkRJFSQSRBdLBUlxBExFCkRJcQNMRQlEcQFEFkmTJA5EVwcBRQlAAESAAgAASwdJFRZXBgJMUEkVgQcISwhJFRZXBgJMUEsBFlcGAoACAAdMUEsBFU8DCExLDFBMFlcGAlBPAlBMUExQsEL/UoAIAAEAAgACcHZC/7MiQv+KgBEVH3x1AAcACQAACwAAAAAAALAjQzYaARUjEkSABhUffHUAALAjQw==",clear:"C4EBQw=="},events:[],templateVariables:{UPDATABLE:{type:"AVMUint64"}}};class Kt{static get create(){return{_resolveByMethod(e){switch(e.method){case"getBalanceInfo":case"getBalanceInfo(address[])(uint64,uint64)":return Kt.create.getBalanceInfo(e);case"getAssetsTiny":case"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])":return Kt.create.getAssetsTiny(e);case"get_asset_labels":case"get_asset_labels(asset)string[]":return Kt.create.getAssetLabels(e)}throw new Error("Unknown ' + verb + ' method")},getBalanceInfo(e){return{...e,method:"getBalanceInfo(address[])(uint64,uint64)",args:Array.isArray(e.args)?e.args:[e.args.accounts]}},getAssetsTiny(e){return{...e,method:"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",args:Array.isArray(e.args)?e.args:[e.args.assetIds,e.args.abelAppId]}},getAssetLabels(e){return{...e,method:"get_asset_labels(asset)string[]",args:Array.isArray(e.args)?e.args:[e.args.assetId]}}}}static getBalanceInfo(e){return{...e,method:"getBalanceInfo(address[])(uint64,uint64)",args:Array.isArray(e.args)?e.args:[e.args.accounts]}}static getAssetsTiny(e){return{...e,method:"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",args:Array.isArray(e.args)?e.args:[e.args.assetIds,e.args.abelAppId]}}static getAssetLabels(e){return{...e,method:"get_asset_labels(asset)string[]",args:Array.isArray(e.args)?e.args:[e.args.assetId]}}}class aw{constructor(e){dt(this,"appFactory");dt(this,"params",{create:{getBalanceInfo:e=>this.appFactory.params.create(Kt.create.getBalanceInfo(e)),getAssetsTiny:e=>this.appFactory.params.create(Kt.create.getAssetsTiny(e)),getAssetLabels:e=>this.appFactory.params.create(Kt.create.getAssetLabels(e))},deployUpdate:{bare:e=>this.appFactory.params.bare.deployUpdate(e)},deployDelete:{bare:e=>this.appFactory.params.bare.deployDelete(e)}});dt(this,"createTransaction",{create:{getBalanceInfo:e=>this.appFactory.createTransaction.create(Kt.create.getBalanceInfo(e)),getAssetsTiny:e=>this.appFactory.createTransaction.create(Kt.create.getAssetsTiny(e)),getAssetLabels:e=>this.appFactory.createTransaction.create(Kt.create.getAssetLabels(e))}});dt(this,"send",{create:{getBalanceInfo:async e=>{const t=await this.appFactory.send.create(Kt.create.getBalanceInfo(e));return{result:{...t.result,return:t.result.return},appClient:new Fr(t.appClient)}},getAssetsTiny:async e=>{const t=await this.appFactory.send.create(Kt.create.getAssetsTiny(e));return{result:{...t.result,return:t.result.return},appClient:new Fr(t.appClient)}},getAssetLabels:async e=>{const t=await this.appFactory.send.create(Kt.create.getAssetLabels(e));return{result:{...t.result,return:t.result.return},appClient:new Fr(t.appClient)}}}});this.appFactory=new eS({...e,appSpec:mr})}get appName(){return this.appFactory.appName}get appSpec(){return mr}get algorand(){return this.appFactory.algorand}getAppClientById(e){return new Fr(this.appFactory.getAppClientById(e))}async getAppClientByCreatorAndName(e){return new Fr(await this.appFactory.getAppClientByCreatorAndName(e))}async deploy(e={}){var r;const t=await this.appFactory.deploy({...e,createParams:(r=e.createParams)!=null&&r.method?Kt.create._resolveByMethod(e.createParams):e.createParams?e.createParams:void 0});return{result:t.result,appClient:new Fr(t.appClient)}}}class Fr{constructor(e){dt(this,"appClient");dt(this,"params",{update:{bare:e=>this.appClient.params.bare.update(e)},delete:{bare:e=>this.appClient.params.bare.delete(e)},clearState:e=>this.appClient.params.bare.clearState(e),getBalanceInfo:e=>this.appClient.params.call(Kt.getBalanceInfo(e)),getAssetsTiny:e=>this.appClient.params.call(Kt.getAssetsTiny(e)),getAssetLabels:e=>this.appClient.params.call(Kt.getAssetLabels(e))});dt(this,"createTransaction",{update:{bare:e=>this.appClient.createTransaction.bare.update(e)},delete:{bare:e=>this.appClient.createTransaction.bare.delete(e)},clearState:e=>this.appClient.createTransaction.bare.clearState(e),getBalanceInfo:e=>this.appClient.createTransaction.call(Kt.getBalanceInfo(e)),getAssetsTiny:e=>this.appClient.createTransaction.call(Kt.getAssetsTiny(e)),getAssetLabels:e=>this.appClient.createTransaction.call(Kt.getAssetLabels(e))});dt(this,"send",{update:{bare:e=>this.appClient.send.bare.update(e)},delete:{bare:e=>this.appClient.send.bare.delete(e)},clearState:e=>this.appClient.send.bare.clearState(e),getBalanceInfo:async e=>{const t=await this.appClient.send.call(Kt.getBalanceInfo(e));return{...t,return:t.return}},getAssetsTiny:async e=>{const t=await this.appClient.send.call(Kt.getAssetsTiny(e));return{...t,return:t.return}},getAssetLabels:async e=>{const t=await this.appClient.send.call(Kt.getAssetLabels(e));return{...t,return:t.return}}});dt(this,"state",{});this.appClient=e instanceof cn?e:new cn({...e,appSpec:mr})}decodeReturnValue(e,t){return t!==void 0?Ys(t,this.appClient.getABIMethod(e),mr.structs):void 0}static async fromCreatorAndName(e){return new Fr(await cn.fromCreatorAndName({...e,appSpec:mr}))}static async fromNetwork(e){return new Fr(await cn.fromNetwork({...e,appSpec:mr}))}get appId(){return this.appClient.appId}get appAddress(){return this.appClient.appAddress}get appName(){return this.appClient.appName}get appSpec(){return this.appClient.appSpec}get algorand(){return this.appClient.algorand}clone(e){return new Fr(this.appClient.clone(e))}async getBalanceInfo(e){return(await this.appClient.send.call(Kt.getBalanceInfo(e))).return}async getAssetsTiny(e){return(await this.appClient.send.call(Kt.getAssetsTiny(e))).return}async getAssetLabels(e){return(await this.appClient.send.call(Kt.getAssetLabels(e))).return}newGroup(){const e=this,t=this.algorand.newGroup();let r=Promise.resolve();const i=[];return{getBalanceInfo(o){return r=r.then(async()=>t.addAppCallMethodCall(await e.params.getBalanceInfo(o))),i.push(s=>e.decodeReturnValue("getBalanceInfo(address[])(uint64,uint64)",s)),this},getAssetsTiny(o){return r=r.then(async()=>t.addAppCallMethodCall(await e.params.getAssetsTiny(o))),i.push(s=>e.decodeReturnValue("getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",s)),this},getAssetLabels(o){return r=r.then(async()=>t.addAppCallMethodCall(await e.params.getAssetLabels(o))),i.push(s=>e.decodeReturnValue("get_asset_labels(asset)string[]",s)),this},get update(){return{bare:o=>(r=r.then(async()=>t.addAppUpdate(await e.params.update.bare(o))),this)}},get delete(){return{bare:o=>(r=r.then(()=>t.addAppDelete(e.params.delete.bare(o))),this)}},clearState(o){return r=r.then(()=>t.addAppCall(e.params.clearState(o))),this},addTransaction(o,s){return r=r.then(()=>t.addTransaction(o,s)),this},async composer(){return await r,t},async simulate(o){var a;await r;const s=await(o?t.simulate(o):t.simulate());return{...s,returns:(a=s.returns)==null?void 0:a.map((l,c)=>i[c]!==void 0?i[c](l):l.returnValue)}},async send(o){var a;await r;const s=await t.send(o);return{...s,returns:(a=s.returns)==null?void 0:a.map((l,c)=>i[c]!==void 0?i[c](l):l.returnValue)}}}}}const sf=Mx();class Wp{constructor({algorand:e,readerAccount:t,ghostAppId:r}){dt(this,"algorand");dt(this,"readerAccount","A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE");dt(this,"ghostAppId");dt(this,"factory");dt(this,"client");dt(this,"cacheParamsTimeout",75);this.algorand=e,t&&(this.readerAccount=t),this.factory=this.algorand.client.getTypedAppFactory(aw,{defaultSender:this.readerAccount}),this.ghostAppId=r,this.client=this.factory.getAppClientById({appId:r??13n})}async getAndCacheSuggestedParams(){const e=await this.algorand.getSuggestedParams();return this.cacheParamsTimeout&&this.algorand.setSuggestedParamsCache(e,new Date(Date.now()+this.cacheParamsTimeout)),e}async execute({signature:e,txnBuilder:t,methodArgsOrArgsArray:r,extraMethodCallArgs:i,extraSimulateArgs:o}){var h;await this.getAndCacheSuggestedParams();const s=e.slice(0,e.indexOf("("));let a=this.client.newGroup();if(this.ghostAppId){const x=Array.isArray(r)?r:[r];for(let A=0;A<x.length;A++){const v=x[A],F=Array.isArray(i)?i[A]:i;a=t(a,{args:v,signer:sf,...F})}}else{let x=this.client.newGroup();const A=Array.isArray(r)?r:[r];for(let F=0;F<A.length;F++){const w=A[F],C=Array.isArray(i)?i[F]:i;x=t(x,{args:w,signer:sf,...C})}const{transactions:v}=await(await x.composer()).buildTransactions();for(const F of v)F.applicationCall={...F.applicationCall,appIndex:0,approvalProgram:Buffer.from(mr.byteCode.approval,"base64"),clearProgram:Buffer.from(mr.byteCode.clear,"base64"),numGlobalByteSlices:mr.state.schema.global.bytes,numGlobalInts:mr.state.schema.global.ints,numLocalByteSlices:mr.state.schema.local.bytes,numLocalInts:mr.state.schema.local.ints,extraPages:3},a=a.addTransaction(F,sf)}const{confirmations:l}=await a.simulate({extraOpcodeBudget:17e4,allowMoreLogging:!0,allowEmptySignatures:!0,allowUnnamedResources:!0,...o}),c=l.flatMap(({logs:x},A)=>{if(!x)throw new Error(`logs were not returned from simulate txn ${A}. this should never happen`);return x.slice(0,-1)}),d=(h=this.client.appSpec.methods.find(({name:x})=>x===s))==null?void 0:h.returns;if(!d)throw new Error("Method not found in app spec");const u=d.struct??d.type,m=[];for(let x=0;x<c.length;x++)m.push(qn(new Uint8Array(c[x]),u,this.factory.appSpec.structs));return m}}dt(Wp,"factory",aw),dt(Wp,"client",Fr);class cw extends Wp{constructor(e){super(e)}async getBalanceInfo({methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r}){return this.execute({signature:"getBalanceInfo(address[])(uint64,uint64)",txnBuilder:(i,o)=>i.getBalanceInfo(o),methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r})}async getAssetsTiny({methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r}){return this.execute({signature:"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",txnBuilder:(i,o)=>i.getAssetsTiny(o),methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r})}async get_asset_labels({methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r}){return this.execute({signature:"get_asset_labels(asset)string[]",txnBuilder:(i,o)=>i.getAssetLabels(o),methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r})}}async function aR(n,e,{concurrency:t=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((o,s)=>{if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(t)&&t>=1||t===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`);const a=[],l=[],c=new Map;let d=!1,u=!1,m=!1,h=0,x=0;const A=n[Symbol.iterator]===void 0?n[Symbol.asyncIterator]():n[Symbol.iterator](),v=()=>{C(i.reason)},F=()=>{i==null||i.removeEventListener("abort",v)},w=N=>{o(N),F()},C=N=>{d=!0,u=!0,s(N),F()};i&&(i.aborted&&C(i.reason),i.addEventListener("abort",v,{once:!0}));const M=async()=>{if(u)return;const N=await A.next(),b=x;if(x++,N.done){if(m=!0,h===0&&!u){if(!r&&l.length>0){C(new AggregateError(l));return}if(u=!0,c.size===0){w(a);return}const j=[];for(const[p,E]of a.entries())c.get(p)!==lw&&j.push(E);w(j)}return}h++,(async()=>{try{const j=await N.value;if(u)return;const p=await e(j,b);p===lw&&c.set(b,p),a[b]=p,h--,await M()}catch(j){if(r)C(j);else{l.push(j),h--;try{await M()}catch(p){C(p)}}}})()};(async()=>{for(let N=0;N<t;N++){try{await M()}catch(b){C(b);break}if(m||d)break}})()})}const lw=Symbol("skip");function cR(n,e){const t=[];let r=0;for(;r<n.length;)t.push(n.slice(r,e+r)),r+=e;return t}function tS(n,e=0){return function(t,r,i){const o=i.value;return i.value=async function(...s){if(s[e].length<=n)return o.apply(this,s);const a=this&&typeof this.concurrency=="number"?this.concurrency:2,l=cR(s[e],n);return(await aR(l,async d=>{const u=e===0?[d,...s.slice(1)]:[...s.slice(0,e),d,...s.slice(e+1)];return o.apply(this,u)},{concurrency:a})).flat()},i}}var nS=function(n,e,t,r){var i=arguments.length,o=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(e,t,o):s(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o};class uh{constructor({algorand:e,registryAppId:t,concurrency:r=4,ghostAppId:i,readerAccount:o}){dt(this,"algorand");dt(this,"registryAppId");dt(this,"baseSDK");dt(this,"concurrency");this.algorand=e,this.registryAppId=t!==void 0?BigInt(t):void 0,this.concurrency=r,this.baseSDK=new cw({algorand:this.algorand,readerAccount:o??"A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE",ghostAppId:i})}async getBalanceInfo(e){const t=await this.getBalanceInfoInternal(e);return new Map(t.map((r,i)=>[e[i],r]))}async getBalanceInfoInternal(e){return this.baseSDK.getBalanceInfo({methodArgsOrArgsArray:{accounts:e}})}async getAssetsTinyLabels(e){const t=await this.getAssetsTinyLabelsInternal(e);return new Map(t.map((r,i)=>[BigInt(e[i]),{...r,id:BigInt(e[i])}]))}async getAssetsTinyLabelsInternal(e){return this.baseSDK.getAssetsTiny({methodArgsOrArgsArray:{assetIds:e,abelAppId:this.registryAppId??0n},extraMethodCallArgs:{extraFee:(e.length*1e3).microAlgo()}})}async getAssetLabels(e){if(!this.registryAppId)return[];const{return:t}=await this.baseSDK.factory.getAppClientById({appId:this.registryAppId}).send.getAssetLabels({args:{assetId:BigInt(e)}});return t??[]}async getAllAssetIDs(){return this.registryAppId?(await this.getBoxesByLength(8)).map(e=>G0(e.nameRaw,"bigint")):[]}async getBoxesByLength(e){return this.registryAppId?(await this.algorand.app.getBoxNames(this.registryAppId)).filter(r=>r.nameRaw.length===e):[]}}dt(uh,"baseSDK",cw);nS([tS(63)],uh.prototype,"getBalanceInfoInternal",null);nS([tS(63)],uh.prototype,"getAssetsTinyLabelsInternal",null);const lR=2914159523n,uR=3381542955n,dR="Y76M3MSY6DKBRHBL7C3NNDXGS5IIMQVQVUAB6MP4XEMMGVF2QWNPL226CA",hR=1440*60*1e3,uw=200,fR={usdc:31566704};function pR(){const{algodClient:n}=yn.useWallet(),{activeNetwork:e}=yn.useNetwork(),[t,r]=Y.useState(!1),[i,o]=Y.useState(!1),[s,a]=Y.useState(null),l=Y.useRef(!1),c=e==="mainnet";Y.useEffect(()=>{if(!c||!n||l.current)return;let u=!1;return(async()=>{try{const h=await Du.getLastUpdated();if(h&&Date.now()-h<hR){o(!0);return}l.current=!0,r(!0),a(null);const x=Ri.fromClients({algod:n}),A=new uh({algorand:x,concurrency:7,registryAppId:lR,ghostAppId:uR,readerAccount:dR}),v=await A.getAllAssetIDs();if(u)return;for(let F=0;F<v.length;F+=uw){if(u)return;const w=v.slice(F,F+uw),C=await A.getAssetsTinyLabels(w),M=[];for(const[N,b]of C)M.push({index:Number(N),name:b.name,unitName:b.unitName,decimals:b.decimals,peraVerified:b.labels.includes("pv")});await Du.insertMany(M)}if(u)return;await Du.setLastUpdated(Date.now()),o(!0)}catch(h){u||a(h instanceof Error?h.message:"Failed to load asset registry")}finally{u||(r(!1),l.current=!1)}})(),()=>{u=!0}},[c,n]);const d=Y.useCallback(async(u,m)=>{const h=await Du.searchByName(u,m);if(!c)return h;const x=u.trim().toLowerCase(),A=fR[x];if(A==null)return h;const v=h.find(F=>F.index===A);return v?[v]:h},[c]);return{registryLoading:t,registryLoaded:i,registryError:s,searchByName:d}}function rS(n={}){const{enabled:e=!0}=n,{algodClient:t}=yn.useWallet(),[r,i]=Y.useState(""),[o,s]=Y.useState(null),[a,l]=Y.useState(!1),[c,d]=Y.useState(null),u=Y.useCallback(()=>{i(""),s(null),l(!1),d(null)},[]);return Y.useEffect(()=>{s(null),d(null);const m=parseInt(r,10);if(!r||isNaN(m)||m<=0||!t||!e){l(!1);return}l(!0);const h=setTimeout(async()=>{try{const x=await t.getAssetByID(m).do();s({index:Number(x.index),name:x.params.name||"Unnamed Asset",unitName:x.params.unitName||"",decimals:x.params.decimals})}catch{d("Asset not found")}finally{l(!1)}},500);return()=>clearTimeout(h)},[r,t,e]),{assetIdInput:r,setAssetIdInput:i,assetInfo:o,isLoading:a,error:c,reset:u}}function gR(n){const[e,t]=Y.useState(""),[r,i]=Y.useState([]),[o,s]=Y.useState(!1),[a,l]=Y.useState(null),c=Y.useCallback(x=>{t(x),l(null)},[]),d=Y.useRef(null),u=Y.useRef(n.searchByName);u.current=n.searchByName,Y.useEffect(()=>{if(d.current&&clearTimeout(d.current),!e.trim()){i([]),s(!1);return}return s(!0),d.current=setTimeout(async()=>{try{const x=await u.current(e.trim());i(x)}catch{i([])}finally{s(!1)}},300),()=>{d.current&&clearTimeout(d.current)}},[e]);const m=Y.useCallback(x=>{l(x),i([])},[]),h=Y.useCallback(()=>{t(""),i([]),l(null),s(!1)},[]);return{nameInput:e,setNameInput:c,results:r,isSearching:o,selectedAsset:a,selectAsset:m,reset:h}}function af(n){return/^\d*$/.test(n)}function mR(n,e=new Set){const{activeAddress:t,algodClient:r,signTransactions:i}=yn.useWallet(),o=Ls(),s=rS(),a=gR(n),[l,c]=Y.useState("idle"),[d,u]=Y.useState(null),[m,h]=Y.useState(null),[x,A]=Y.useState(""),v=!af(x),F=Y.useCallback(()=>{A(""),s.reset(),a.reset(),h(null),c("idle"),u(null)},[s,a]),w=Y.useCallback(()=>{c("idle"),u(null)},[]),C=Y.useCallback(N=>{A(N),af(N)?(s.setAssetIdInput(N),a.reset()):(s.setAssetIdInput(""),a.setNameInput(N))},[s,a]),M=Y.useCallback(async()=>{var j,p;const b=!af(x)?(j=a.selectedAsset)==null?void 0:j.index:(p=s.assetInfo)==null?void 0:p.index;if(!(!b||!t||!r)){c("signing"),u(null),h(null);try{const E=await r.getTransactionParams().do(),S=Oe.makeAssetTransferTxnWithSuggestedParamsFromObject({sender:t,receiver:t,amount:0,assetIndex:b,suggestedParams:E}),B=(await i([S.toByte()]))[0];if(!B)throw new Error("Transaction was not signed");c("sending");const P=S.txID();await r.sendRawTransaction(B).do(),await Oe.waitForConfirmation(r,P,4),o.invalidateQueries({queryKey:["account-info"]}),h(P),c("success")}catch(E){c("error"),u(E instanceof Error?E.message:"Opt-in failed")}}},[x,a.selectedAsset,s.assetInfo,t,r,i,o]);return{activeAddress:t??null,optedInAssetIds:e,assetIdInput:x,setAssetIdInput:C,assetInfo:s.assetInfo,assetLookupLoading:s.isLoading,assetLookupError:s.error,txId:m,status:l,error:d,handleOptIn:M,reset:F,retry:w,nameSearchResults:a.results,nameSearchLoading:a.isSearching,registryLoading:n.registryLoading,selectedNameAsset:a.selectedAsset,onSelectNameAsset:a.selectAsset,isNameMode:v}}function dw(n,e){const[t="0",r=""]=n.split("."),i=r.slice(0,e).padEnd(e,"0"),o=parseInt(t+i,10);if(isNaN(o)||o<=0)throw new Error("Invalid amount");return o}function yR(){const{activeAddress:n,algodClient:e,signTransactions:t}=yn.useWallet(),r=Ls(),[i,o]=Y.useState("algo"),[s,a]=Y.useState(""),[l,c]=Y.useState(""),[d,u]=Y.useState("idle"),[m,h]=Y.useState(null),[x,A]=Y.useState(null),v=rS({enabled:i==="asa"}),[F,w]=Y.useState("idle"),C=s.length>0&&!Oe.isValidAddress(s)?"Invalid Algorand address":null,M=v.assetIdInput;Y.useEffect(()=>{if(i!=="asa"||!M||!s||!e){w("idle");return}let p=!1;try{p=Oe.isValidAddress(s)}catch{}if(!p){w("idle");return}w("checking");let E=!1;const S=setTimeout(async()=>{var $;try{const B=await e.accountInformation(s).do();if(E)return;const P=Number(M),W=($=B.assets)==null?void 0:$.some(L=>Number(L.assetId)===P);w(W?"opted-in":"not-opted-in")}catch{E||w("idle")}},500);return()=>{E=!0,clearTimeout(S)}},[i,M,s,e]);const N=Y.useCallback(()=>{o("algo"),a(""),c(""),v.reset(),w("idle"),A(null),u("idle"),h(null)},[v]),b=Y.useCallback(()=>{u("idle"),h(null)},[]),j=Y.useCallback(async()=>{if(!(!n||!e||!s||!l)){u("signing"),h(null),A(null);try{const p=await e.getTransactionParams().do();let E;if(i==="algo"){const P=dw(l,6);E=Oe.makePaymentTxnWithSuggestedParamsFromObject({sender:n,receiver:s,amount:P,suggestedParams:p})}else{if(!v.assetInfo)throw new Error("No asset selected");const P=dw(l,v.assetInfo.decimals);E=Oe.makeAssetTransferTxnWithSuggestedParamsFromObject({sender:n,receiver:s,amount:P,assetIndex:v.assetInfo.index,suggestedParams:p})}const $=(await t([E.toByte()]))[0];if(!$)throw new Error("Transaction was not signed");u("sending");const B=E.txID();await e.sendRawTransaction($).do(),await Oe.waitForConfirmation(e,B,4),r.invalidateQueries({queryKey:["account-info"]}),A(B),u("success")}catch(p){u("error"),h(p instanceof Error?p.message:"Send failed")}}},[i,l,s,v.assetInfo,n,e,t,r]);return{sendType:i,setSendType:o,receiver:s,setReceiver:a,amount:l,setAmount:c,assetIdInput:v.assetIdInput,setAssetIdInput:v.setAssetIdInput,assetInfo:v.assetInfo,assetLookupLoading:v.isLoading,assetLookupError:v.error,receiverOptInStatus:F,receiverAddressError:C,txId:x,status:d,error:m,handleSend:j,reset:N,retry:b}}function wR({children:n}){var re;const{activeAddress:e,activeWallet:t,algodClient:r}=yn.useWallet(),{theme:i}=ti(),o=Ls(),s=T1(),[a,l]=Y.useState(!1),[c,d]=Y.useState("main"),[u,m]=Y.useState(!1),{activeNetwork:h}=yn.useNetwork(),x=pR(),A=yR(),[v,F]=Y.useState(()=>{const H=localStorage.getItem("uwui:balance-preference");return H?H==="available":!1}),w=i==="system"?void 0:i,C=xg({enabled:!!e}),M=((re=C.data)==null?void 0:re.name)??null,{data:N}=qv({enabled:!!e}),b=Y.useMemo(()=>!N||N.amount===void 0?null:Number(N.amount)/1e6,[N]),j=Y.useMemo(()=>{if(!N||N.amount===void 0||N.minBalance===void 0)return null;const H=Number(N.amount)-Number(N.minBalance);return Math.max(0,H/1e6)},[N]),p=v?j:b,E=Y.useMemo(()=>N!=null&&N.assets?N.assets:[],[N]),S=Y.useMemo(()=>E.map(H=>String(H.assetId)),[E]),$=Y.useMemo(()=>new Set(E.map(H=>Number(H.assetId))),[E]),B=Y.useMemo(()=>{var H,Z;return((Z=(H=t==null?void 0:t.activeAccount)==null?void 0:H.metadata)==null?void 0:Z.evmAddress)??null},[t]),P=mR(x,$),{assets:W}=_x(S,r),L=Y.useMemo(()=>E.map(H=>{const Z=W[String(H.assetId)];if(!Z)return null;const ce=BigInt(H.amount);let Q;if(Z.decimals===0)Q=ce.toString();else{const se=10n**BigInt(Z.decimals),ue=ce/se,ae=ce%se;if(ae===0n)Q=ue.toString();else{const xe=ae.toString().padStart(Z.decimals,"0").replace(/0+$/,"");Q=`${ue}.${xe}`}}return{assetId:Number(H.assetId),name:Z.name||`ASA#${H.assetId}`,unitName:Z.unitName,amount:Q}}).filter(H=>H!==null),[E,W]),{refs:q,floatingStyles:J,context:U}=Ld({open:a,onOpenChange:H=>{l(H),H||(d("main"),P.reset(),A.reset())},placement:"bottom-end",middleware:[Xp(8),f0(),h0()],whileElementsMounted:l0}),ne=w0(U),fe=Od(U,{outsidePressEvent:"mousedown"}),{getReferenceProps:le,getFloatingProps:ye}=Vd([ne,fe]),he=Yr(),de=()=>{e&&(navigator.clipboard.writeText(e),m(!0),setTimeout(()=>m(!1),2e3))},be=async()=>{if(t)try{await t.disconnect(),l(!1)}catch(H){console.error("Error disconnecting wallet:",H)}},Ae=H=>{t&&t.setActiveAccount&&t.setActiveAccount(H)},_e=()=>{const H=!v;F(H),localStorage.setItem("uwui:balance-preference",H?"available":"total")},De=Y.useCallback(H=>{if(!H||!h)return null;const ce=dy(h,"transaction")[0];return ce?ce.getUrl(h,"transaction",H):null},[h]),Te=Y.useMemo(()=>{if(!e||!h)return;const Z=dy(h,"account")[0];if(!Z)return;const ce=Z.getUrl(h,"account",e);if(ce)return()=>window.open(ce,"_blank","noopener,noreferrer")},[e,h]),T=D.jsx("div",{className:"mb-4 bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:D.jsxs("div",{className:"flex justify-between items-center",children:[p!==null&&D.jsxs("span",{className:"text-base font-medium text-[var(--wui-color-text)] flex items-center gap-1",children:[w2(p,{fractionDigits:4}),D.jsx(Ux,{})]}),D.jsxs("button",{onClick:_e,className:"flex items-center gap-1 text-sm text-[var(--wui-color-text-secondary)] bg-[var(--wui-color-bg-tertiary)] py-1 pl-2.5 pr-2 rounded-md hover:brightness-90 transition-all focus:outline-none",title:v?"Show total balance":"Show available balance",children:[v?"Available":"Total",D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-0.5 opacity-80",children:[D.jsx("path",{d:"m17 10-5-5-5 5"}),D.jsx("path",{d:"m17 14-5 5-5-5"})]})]})]})}),G=n||D.jsx(ih,{}),X=Y.cloneElement(G,le({ref:q.setReference}));return D.jsxs(D.Fragment,{children:[X,a&&D.jsx(uu,{children:D.jsx(Pd,{context:U,modal:!1,children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":w,children:D.jsx("div",{ref:q.setFloating,style:{...J,width:c==="main"?320:"min(420px, 95vw)"},...ye(),role:"menu","aria-labelledby":he,className:"z-50 rounded-xl bg-[var(--wui-color-bg)] shadow-xl border border-[var(--wui-color-border)] transition-[width] duration-200 ease-in-out",children:D.jsx("div",{className:"p-4",children:c==="main"?D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[D.jsx("div",{className:"h-12 w-12 overflow-hidden",children:D.jsx(vg,{nfd:C.data,alt:`${M||e} avatar`,size:48})}),D.jsxs("div",{children:[D.jsx("h3",{id:he,className:"text-lg font-bold text-[var(--wui-color-text)] max-w-[220px] truncate wallet-custom-font",children:M||(e?pr(e,6,4):"My Wallet")}),M&&e&&D.jsx("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:pr(e,6,4)})]})]}),T,t&&t.accounts&&t.accounts.length>1&&D.jsx("div",{className:"mb-4",children:D.jsxs(gM,{value:e||"",onChange:Ae,children:[D.jsx(Sv,{className:"block text-sm font-medium text-[var(--wui-color-text-secondary)] mb-1",children:"Select Account"}),D.jsxs("div",{className:"relative mt-1",children:[D.jsxs(Hv,{className:"grid w-full cursor-default grid-cols-1 rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2 px-3 text-left text-[var(--wui-color-text)] shadow-sm focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent text-sm",children:[D.jsx("span",{className:"col-start-1 row-start-1 truncate pr-8",children:e?pr(e,6,4):"Select account"}),D.jsx("span",{className:"col-start-1 row-start-1 self-center justify-self-end",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"text-[var(--wui-color-text-secondary)]","aria-hidden":"true",children:D.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),D.jsx(Yv,{transition:!0,className:"absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-[var(--wui-color-bg-secondary)] py-1 shadow-lg ring-1 ring-black/5 focus:outline-none text-sm data-[closed]:data-[leave]:opacity-0 data-[leave]:transition data-[leave]:duration-100 data-[leave]:ease-in",children:t.accounts.map(H=>D.jsxs(Kv,{value:H.address,className:"group relative cursor-default select-none py-2 pl-3 pr-9 text-[var(--wui-color-text)] data-[focus]:bg-[var(--wui-color-bg-hover)] data-[focus]:outline-none",children:[D.jsx("span",{className:"block truncate font-normal group-data-[selected]:font-medium",children:pr(H.address,6,4)}),D.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-[var(--wui-color-primary)] group-[&:not([data-selected])]:hidden",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"h-5 w-5","aria-hidden":"true",children:D.jsx("path",{d:"M13.3334 4L6.00008 11.3333L2.66675 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},H.address))})]})]})}),D.jsx("div",{className:"border-t border-[var(--wui-color-border)] mt-2 mb-2"}),t&&D.jsxs("div",{className:"mb-2 flex justify-between",children:[D.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[D.jsx("div",{className:"h-5 w-5 overflow-hidden rounded flex items-center justify-center",children:t.metadata.icon?D.jsx("img",{src:t.metadata.icon,alt:`${t.metadata.name} icon`,className:"max-w-full max-h-full"}):D.jsx("div",{className:"h-5 w-5 rounded-full bg-[var(--wui-color-bg-tertiary)] flex items-center justify-center",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3 text-[var(--wui-color-text-tertiary)]",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M17 9c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V9zm-1 0v8h-4V9h4zM8 4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V4zM3 3h4v14H3V3z",clipRule:"evenodd"})})})}),D.jsx("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:t.metadata.name})]}),D.jsx("div",{children:t.metadata.isLiquid&&D.jsxs("button",{onClick:()=>d("manage"),className:"flex-1 py-2 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center",title:"Manage Liquid Account",children:[D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:D.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),"Manage"]})})]}),D.jsx("div",{className:"border-t border-[var(--wui-color-border)] mb-3 mt-2"}),D.jsxs("div",{className:"flex gap-2",children:[D.jsx("button",{onClick:de,className:"flex-1 py-2 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center",title:"Copy address",children:u?D.jsxs(D.Fragment,{children:[D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-green-500 mr-1.5",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"Copied"]}):D.jsxs(D.Fragment,{children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 20 20",fill:"currentColor",children:[D.jsx("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),D.jsx("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"})]}),"Copy"]})}),D.jsx("button",{onClick:be,className:"flex-1 py-2 px-4 bg-[var(--wui-color-danger-bg)] text-[var(--wui-color-danger-text)] font-medium rounded-xl hover:bg-[var(--wui-color-danger-bg-hover)] transition-colors text-sm",children:"Disconnect"})]})]}):D.jsx(r2,{displayBalance:p,showAvailableBalance:v,onToggleBalance:_e,onBack:()=>d("main"),send:{...A,explorerUrl:De(A.txId)},optIn:{...P,evmAddress:B,explorerUrl:De(P.txId)},assets:L.length>0?L:void 0,availableBalance:j,onRefresh:()=>o.invalidateQueries(),isRefreshing:s>0,onExplore:Te})})})})})})]})}function iS(n){const{queryClient:e}=ti();return D.jsx(F0,{client:e,children:D.jsx(wR,{...n})})}function xR({size:n,className:e,style:t}){const{activeAddress:r}=yn.useWallet();return r?D.jsx(iS,{children:D.jsx(ih,{size:n,className:e,style:t})}):D.jsx(qx,{children:D.jsx(Fd,{size:n,className:e,style:t})})}lS();exports.ConnectWalletButton=Fd;exports.ConnectWalletMenu=qx;exports.ConnectedWalletButton=ih;exports.ConnectedWalletMenu=iS;exports.NfdAvatar=vg;exports.WalletButton=xR;exports.WalletList=Kx;exports.WalletUIProvider=L2;exports.useAccountInfo=qv;exports.useAfterSignDialog=$2;exports.useBeforeSignDialog=V2;exports.useNfd=xg;exports.useResolvedTheme=Wx;exports.useWalletUI=ti;exports.useWelcomeDialog=_2;
234
+ ${c}`)}return r},this._appId=e.appId,this._appAddress=Le.getApplicationAddress(this._appId),this._appSpec=cn.normaliseAppSpec(e.appSpec),this._appName=e.appName??this._appSpec.name,this._algorand=e.algorand,this._algorand.registerErrorTransformer(this.handleCallErrors),this._defaultSender=typeof e.defaultSender=="string"?ze.fromString(e.defaultSender):e.defaultSender,this._defaultSigner=e.defaultSigner,this._lastCompiled={},this._approvalSourceMap=e.approvalSourceMap,this._clearSourceMap=e.clearSourceMap,this._localStateMethods=t=>this.getStateMethods(()=>this.getLocalState(t),()=>this._appSpec.state.keys.local,()=>this._appSpec.state.maps.local),this._globalStateMethods=this.getStateMethods(()=>this.getGlobalState(),()=>this._appSpec.state.keys.global,()=>this._appSpec.state.maps.global),this._boxStateMethods=this.getBoxMethods(),this._paramsMethods={...this.getMethodCallParamsMethods(),bare:this.getBareParamsMethods()},this._createTransactionsMethods={...this.getMethodCallCreateTransactionMethods(),bare:this.getBareCreateTransactionMethods()},this._sendMethods={...this.getMethodCallSendMethods(),bare:this.getBareSendMethods()}}clone(e){return new cn({appId:this._appId,appSpec:this._appSpec,algorand:this._algorand,appName:this._appName,defaultSender:this._defaultSender,defaultSigner:this._defaultSigner,approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap,...e})}static async fromCreatorAndName(e){const t=cn.normaliseAppSpec(e.appSpec),i=(e.appLookupCache??await e.algorand.appDeployer.getCreatorAppsByName(e.creatorAddress,e.ignoreCache)).apps[e.appName??t.name];if(!i)throw new Error(`App not found for creator ${e.creatorAddress} and name ${e.appName??t.name}`);return new cn({...e,algorand:e.algorand,appId:i.appId})}static async fromNetwork(e){const t=await e.algorand.client.network(),r=cn.normaliseAppSpec(e.appSpec),i=[t.genesisHash];t.isLocalNet&&i.push("localnet"),t.isTestNet&&i.push("testnet"),t.isMainNet&&i.push("mainnet");const s=Object.keys(r.networks??{}).findIndex(l=>i.includes(l));if(s===-1)throw new Error(`No app ID found for network ${ea(i)} in the app spec`);const a=BigInt(r.networks[s].appID);return new cn({...e,appId:a,appSpec:r})}static normaliseAppSpec(e){const t=typeof e=="string"?JSON.parse(e):e;return"hints"in t?YM(t):t}get appId(){return this._appId}get appAddress(){return this._appAddress}get appName(){return this._appName}get appSpec(){return this._appSpec}get algorand(){return this._algorand}get params(){return this._paramsMethods}get createTransaction(){return this._createTransactionsMethods}get send(){return this._sendMethods}get state(){return{local:this._localStateMethods,global:this._globalStateMethods,box:this._boxStateMethods}}async fundAppAccount(e){return this.send.fundAppAccount(e)}async getGlobalState(){return await this._algorand.app.getGlobalState(this.appId)}async getLocalState(e){return await this._algorand.app.getLocalState(this.appId,e)}async getBoxNames(){return await this._algorand.app.getBoxNames(this.appId)}async getBoxValue(e){return await this._algorand.app.getBoxValue(this.appId,e)}async getBoxValueFromABIType(e,t){return await this._algorand.app.getBoxValueFromABIType({appId:this.appId,boxName:e,type:t})}async getBoxValues(e){const t=(await this.getBoxNames()).filter(e??(i=>!0)),r=await this._algorand.app.getBoxValues(this.appId,t.map(i=>i.nameRaw));return t.map((i,o)=>({name:i,value:r[o]}))}async getBoxValuesFromABIType(e,t){const r=(await this.getBoxNames()).filter(t??(o=>!0)),i=await this._algorand.app.getBoxValuesFromABIType({appId:this.appId,boxNames:r.map(o=>o.nameRaw),type:e});return r.map((o,s)=>({name:o,value:i[s]}))}async exposeLogicError(e,t){var o,s;const r=(s=(o=this._appSpec.sourceInfo)==null?void 0:o[t?"clear":"approval"])==null?void 0:s.pcOffsetMethod;let i;if(r==="cblocks"){const a=await this._algorand.app.getById(this.appId);i=t?a.clearStateProgram:a.approvalProgram}return cn.exposeLogicError(e,this._appSpec,{isClearStateProgram:t,approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap,program:i})}exportSourceMaps(){if(!this._approvalSourceMap||!this._clearSourceMap)throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");return{approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap}}importSourceMaps(e){this._approvalSourceMap=new tw(e.approvalSourceMap),this._clearSourceMap=new tw(e.clearSourceMap)}getABIMethod(e){return Bn(e,this._appSpec)}async processMethodCallReturn(e,t){const r=await e;return{...r,return:Ys(r.return,t,this._appSpec.structs)}}async compile(e){const t=await cn.compile(this._appSpec,this._algorand.app,e);return t.compiledApproval&&(this._approvalSourceMap=t.compiledApproval.sourceMap,this._lastCompiled.approval=t.compiledApproval.compiledBase64ToBytes),t.compiledClear&&(this._clearSourceMap=t.compiledClear.sourceMap,this._lastCompiled.clear=t.compiledClear.compiledBase64ToBytes),t}static exposeLogicError(e,t,r){var A,v,F,w;const{isClearStateProgram:i,approvalSourceMap:o,clearSourceMap:s,program:a}=r,l=i?s:o,c=nf.parseLogicError(e);if(c===void 0||(c==null?void 0:c.pc)===void 0)return e;let d=c==null?void 0:c.pc;const u=i?(A=t.sourceInfo)==null?void 0:A.clear:(v=t.sourceInfo)==null?void 0:v.approval;let m=0;if((u==null?void 0:u.pcOffsetMethod)==="cblocks"){if(a===void 0)throw new Error("Program bytes are required to calculate the ARC56 cblocks PC offset");m=ZM(a),d=c.pc-m}const h=u==null?void 0:u.sourceInfo.find(C=>C.pc.includes(d)),x=h==null?void 0:h.errorMessage;if(t.source){let C=M=>{var N,b;return(b=(N=l==null?void 0:l.getLocationForPc)==null?void 0:N.call(l,M))==null?void 0:b.line};l===void 0&&(C=M=>{var b;const N=(b=u==null?void 0:u.sourceInfo.find(j=>j.pc.includes(M-m)))==null?void 0:b.teal;if(N!==void 0)return N-1}),e=new nf(c,nn.Buffer.from(i?t.source.clear:t.source.approval,"base64").toString().split(`
235
+ `),C)}if(x){const C=((F=ea(e).match(new RegExp("(?<=app=)\\d+")))==null?void 0:F[0])||"",M=(w=ea(e).match(new RegExp("(?<=transaction )\\S+(?=:)")))==null?void 0:w[0],N=new Error(`Runtime error when executing ${t.name} (appId: ${C}) in transaction ${M}: ${x}`);return N.cause=e,N}return e}static async compile(e,t,r){var u,m;const{deployTimeParams:i,updatable:o,deletable:s}=r??{};if(!e.source){if(!((u=e.byteCode)!=null&&u.approval)||!((m=e.byteCode)!=null&&m.clear))throw new Error(`Attempt to compile app ${e.name} without source or byteCode`);return{approvalProgram:nn.Buffer.from(e.byteCode.approval,"base64"),clearStateProgram:nn.Buffer.from(e.byteCode.clear,"base64")}}const a=nn.Buffer.from(e.source.approval,"base64").toString("utf-8"),l=await t.compileTealTemplate(a,i,{updatable:o,deletable:s}),c=nn.Buffer.from(e.source.clear,"base64").toString("utf-8"),d=await t.compileTealTemplate(c,i);return ft.debug&&await ft.events.emitAsync(Ps.AppCompiled,{sources:[{compiledTeal:l,appName:e.name,fileName:"approval"},{compiledTeal:d,appName:e.name,fileName:"clear"}]}),{approvalProgram:l.compiledBase64ToBytes,compiledApproval:l,clearStateProgram:d.compiledBase64ToBytes,compiledClear:d}}async getABIArgsWithDefaultValues(e,t,r){const i=Bn(e,this._appSpec);return await Promise.all((t==null?void 0:t.map(async(o,s)=>{var c,d,u;const a=i.args[s];if(!a)throw new Error(`Unexpected arg at position ${s}. ${i.name} only expects ${i.args.length} args`);if(o!==void 0)return a.struct&&typeof o=="object"&&!Array.isArray(o)?Zl(o,this._appSpec.structs[a.struct],this._appSpec.structs):o;const l=a.defaultValue;if(l)switch(l.source){case"literal":return qn(nn.Buffer.from(l.data,"base64"),((c=i.method.args[s].defaultValue)==null?void 0:c.type)??i.method.args[s].type,this._appSpec.structs);case"method":{const m=this.getABIMethod(l.data),h=await this.send.call({method:l.data,args:m.args.map(()=>{}),sender:r});if(h.return===void 0)throw new Error("Default value method call did not return a value");return typeof h.return=="object"&&!(h.return instanceof Uint8Array)&&!Array.isArray(h.return)&&!(h.return instanceof ze)?Zl(h.return,this._appSpec.structs[m.returns.struct],this._appSpec.structs):h.return}case"local":case"global":{const m=l.source==="global"?await this.getGlobalState():await this.getLocalState(r),h=Object.values(m).find(x=>x.keyBase64===l.data);if(!h)throw new Error(`Preparing default value for argument ${a.name??`arg${s+1}`} resulted in the failure: The key '${l.data}' could not be found in ${l.source} storage`);return"valueRaw"in h?qn(h.valueRaw,((d=i.method.args[s].defaultValue)==null?void 0:d.type)??i.method.args[s].type,this._appSpec.structs):h.value}case"box":{const m=await this.getBoxValue(nn.Buffer.from(l.data,"base64"));return qn(m,((u=i.method.args[s].defaultValue)==null?void 0:u.type)??i.method.args[s].type,this._appSpec.structs)}}if(!Le.abiTypeIsTransaction(a.type))throw new Error(`No value provided for required argument ${a.name??`arg${s+1}`} in call to method ${i.name}`)}))??[])}getBareParamsMethods(){return{update:async e=>this.getBareParams({...e,...await this.compile(e)},ar.UpdateApplicationOC),optIn:e=>this.getBareParams(e,ar.OptInOC),delete:e=>this.getBareParams(e,ar.DeleteApplicationOC),clearState:e=>this.getBareParams(e,ar.ClearStateOC),closeOut:e=>this.getBareParams(e,ar.CloseOutOC),call:e=>this.getBareParams(e,(e==null?void 0:e.onComplete)??ar.NoOpOC)}}getBareCreateTransactionMethods(){return{update:async e=>this._algorand.createTransaction.appUpdate(await this.params.bare.update(e)),optIn:e=>this._algorand.createTransaction.appCall(this.params.bare.optIn(e)),delete:e=>this._algorand.createTransaction.appDelete(this.params.bare.delete(e)),clearState:e=>this._algorand.createTransaction.appCall(this.params.bare.clearState(e)),closeOut:e=>this._algorand.createTransaction.appCall(this.params.bare.closeOut(e)),call:e=>this._algorand.createTransaction.appCall(this.params.bare.call(e))}}getBareSendMethods(){return{update:async e=>{const t=await this.compile(e);return{...await this._algorand.send.appUpdate(await this.params.bare.update(e)),...t}},optIn:e=>this._algorand.send.appCall(this.params.bare.optIn(e)),delete:e=>this._algorand.send.appDelete(this.params.bare.delete(e)),clearState:e=>this._algorand.send.appCall(this.params.bare.clearState(e)),closeOut:e=>this._algorand.send.appCall(this.params.bare.closeOut(e)),call:e=>this._algorand.send.appCall(this.params.bare.call(e))}}getMethodCallParamsMethods(){return{fundAppAccount:e=>({...e,sender:this.getSender(e.sender),signer:this.getSigner(e.sender,e.signer),receiver:this.appAddress}),update:async e=>await this.getABIParams({...e,...await this.compile(e)},ar.UpdateApplicationOC),optIn:async e=>await this.getABIParams(e,ar.OptInOC),delete:async e=>await this.getABIParams(e,ar.DeleteApplicationOC),closeOut:async e=>await this.getABIParams(e,ar.CloseOutOC),call:async e=>await this.getABIParams(e,e.onComplete??ar.NoOpOC)}}getMethodCallSendMethods(){return{fundAppAccount:e=>this._algorand.send.payment(this.params.fundAppAccount(e)),update:async e=>{const t=await this.compile(e);return{...await this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({...e})),Bn(e.method,this._appSpec)),...t}},optIn:async e=>this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(e)),Bn(e.method,this._appSpec)),delete:async e=>this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(e)),Bn(e.method,this._appSpec)),closeOut:async e=>this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(e)),Bn(e.method,this._appSpec)),call:async e=>{var t,r;if((e.onComplete===ar.NoOpOC||!e.onComplete)&&Bn(e.method,this._appSpec).method.readonly){const i={...e};e.coverAppCallInnerTransactionFees&&e.maxFee&&(i.staticFee=e.maxFee,i.extraFee=void 0);try{const o=await this._algorand.newGroup().addAppCallMethodCall(await this.params.call(i)).simulate({allowUnnamedResources:e.populateAppCallResources??!0,skipSignatures:!0,extraOpcodeBudget:XM});return this.processMethodCallReturn({...o,transaction:o.transactions.at(-1),confirmation:o.confirmations.at(-1),return:((t=o.returns)==null?void 0:t.length)??!1?(r=o.returns)==null?void 0:r.at(-1):void 0},Bn(e.method,this._appSpec))}catch(o){const s=o;throw e.coverAppCallInnerTransactionFees&&s&&s.message&&s.message.match(/fee too small/)?Error("Fees were too small. You may need to increase the transaction maxFee."):o}}return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(e)),Bn(e.method,this._appSpec))}}}getMethodCallCreateTransactionMethods(){return{fundAppAccount:e=>this._algorand.createTransaction.payment(this.params.fundAppAccount(e)),update:async e=>this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(e)),optIn:async e=>this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(e)),delete:async e=>this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(e)),closeOut:async e=>this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(e)),call:async e=>this._algorand.createTransaction.appCallMethodCall(await this.params.call(e))}}getSender(e){if(!e&&!this._defaultSender)throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`);return typeof e=="string"?ze.fromString(e):e??this._defaultSender}getSigner(e,t){return t??(!e||e===this._defaultSender?this._defaultSigner:void 0)}getBareParams(e,t){return{...e,appId:this._appId,sender:this.getSender(e==null?void 0:e.sender),signer:this.getSigner(e==null?void 0:e.sender,e==null?void 0:e.signer),onComplete:t}}async getABIParams(e,t){const r=this.getSender(e.sender),i=Bn(e.method,this._appSpec),o=await this.getABIArgsWithDefaultValues(e.method,e.args,r);return{...e,appId:this._appId,sender:r,signer:this.getSigner(e.sender,e.signer),method:i,onComplete:t,args:o}}getBoxMethods(){const e=this,t={getAll:async()=>Object.fromEntries(await Promise.all(Object.keys(e._appSpec.state.keys.box).map(async r=>[r,await t.getValue(r)]))),getValue:async r=>{const i=e._appSpec.state.keys.box[r],o=await e.getBoxValue(nn.Buffer.from(i.key,"base64"));return qn(o,i.valueType,e._appSpec.structs)},getMapValue:async(r,i)=>{const o=e._appSpec.state.maps.box[r],s=nn.Buffer.from(o.prefix??"","base64"),a=nn.Buffer.concat([s,ew(i,o.keyType,e._appSpec.structs)]),l=nn.Buffer.from(a).toString("base64"),c=await e.getBoxValue(nn.Buffer.from(l,"base64"));return qn(c,o.valueType,e._appSpec.structs)},getMap:async r=>{const i=e._appSpec.state.maps.box[r],o=nn.Buffer.from(i.prefix??"","base64"),s=await e.getBoxNames();return new Map(await Promise.all(s.filter(a=>Ky(a.nameRaw,o)).map(async a=>[qn(a.nameRaw.slice(o.length),i.keyType,e._appSpec.structs),qn(await e.getBoxValue(a.nameRaw),i.valueType,e._appSpec.structs)])))}};return t}getStateMethods(e,t,r){const i=this,o={getAll:async()=>{const s=await e();return Object.fromEntries(await Promise.all(Object.keys(t()).map(async a=>[a,await o.getValue(a,s)])))},getValue:async(s,a)=>{const l=Object.values(a??await e()),c=t()[s];if(c===void 0)throw new Error(`Attempted to get state value ${s}, but it does not exist`);const d=l.find(u=>u.keyBase64===c.key);return d&&"valueRaw"in d?qn(d.valueRaw,c.valueType,i._appSpec.structs):d==null?void 0:d.value},getMapValue:async(s,a,l)=>{const c=Object.values(l??await e()),d=r()[s],u=nn.Buffer.from(d.prefix??"","base64"),m=nn.Buffer.concat([u,ew(a,d.keyType,i._appSpec.structs)]),h=nn.Buffer.from(m).toString("base64"),x=c.find(A=>A.keyBase64===h);return x&&"valueRaw"in x?qn(x.valueRaw,d.valueType,i._appSpec.structs):x==null?void 0:x.value},getMap:async s=>{const a=Object.values(await e()),l=r()[s],c=nn.Buffer.from(l.prefix??"","base64");return new Map(a.filter(d=>Ky(d.keyRaw,c)).map(d=>{const u=d.keyRaw.slice(c.length);return[qn(u,l.keyType,this._appSpec.structs),qn("valueRaw"in d?d.valueRaw:d.value,l.valueType,this._appSpec.structs)]}))}};return o}}const rw="DISPENSER";class JM{get params(){return this._params}get signingAccounts(){return this._signingAccounts}get addr(){return this._addr}get signer(){return this._signer}constructor(e,t){this._params=e,this._signingAccounts=t,this._addr=Le.multisigAddress(e),this._signer=Le.makeMultiSigAccountTransactionSigner(e,t.map(r=>r.sk))}sign(e){let t="sender"in e?void 0:e;for(const r of this._signingAccounts)t?t=Le.appendSignMultisigTransaction(t,this._params,r.sk).blob:t=Le.signMultisigTransaction(e,this._params,r.sk).blob;return t}}class Gp{get addr(){return this._sender}get sk(){return this._account.sk}get signer(){return this._signer}get sender(){return{addr:this._sender,sk:this._account.sk}}constructor(e,t){this._account=e,this._sender=typeof t=="string"?ze.fromString(t):t??e.addr,this._signer=Le.makeBasicAccountTransactionSigner(e)}}class Wn{get microAlgos(){return this.amountInMicroAlgo}get microAlgo(){return this.amountInMicroAlgo}get algos(){return Le.microalgosToAlgos(Number(this.amountInMicroAlgo))}get algo(){return Le.microalgosToAlgos(Number(this.amountInMicroAlgo))}constructor(e){this.amountInMicroAlgo="microAlgos"in e?BigInt(e.microAlgos):"microAlgo"in e?BigInt(e.microAlgo):"algos"in e?BigInt(Le.algosToMicroalgos(Number(e.algos))):BigInt(Le.algosToMicroalgos(Number(e.algo)))}toString(){return`${this.microAlgo.toLocaleString("en-US")} µALGO`}valueOf(){return Number(this.microAlgo)}static Algos(e){return new Wn({algos:e})}static Algo(e){return new Wn({algos:e})}static MicroAlgos(e){return new Wn({microAlgos:e})}static MicroAlgo(e){return new Wn({microAlgos:e})}}class er extends Ni{async callWithRetry(e){let t,r=1;do try{t=await e()}catch(i){if(r>=er.MAX_TRIES||!(er.RETRY_ERROR_CODES.includes(i.code)||er.RETRY_STATUS_CODES.includes(Number(i.status))||"response"in i&&er.RETRY_STATUS_CODES.includes(Number(i.response.status))))throw i;const o=r==1?0:Math.min(1e3*Math.pow(2,r-1),er.MAX_BACKOFF_MS);o>0&&await new Promise(s=>setTimeout(s,o)),ft.logger.warn(`algosdk request failed ${r} times. Retrying in ${o}ms: ${i}`)}while(!t&&++r<=er.MAX_TRIES);return t}async get(e,t,r={}){var o;const i=await this.callWithRetry(()=>super.get(e,t,r));if(e.startsWith("/v2/accounts/")&&e.endsWith("/created-applications")&&i.status===200&&((o=t==null?void 0:t["include-all"])==null?void 0:o.toString())==="true")try{const s=_d(Buffer.from(i.body).toString(),{intDecoding:an.MIXED});if(s.applications){for(const a of s.applications)a.params&&(a.params["approval-program"]===null&&(a.params["approval-program"]=""),a.params["clear-state-program"]===null&&(a.params["clear-state-program"]=""));i.body=Buffer.from(yi(s))}}catch(s){ft.logger.warn("Failed to fix indexer response for created applications",s)}return i}async post(e,t,r,i={}){return await this.callWithRetry(()=>super.post(e,t,r,i))}async delete(e,t,r,i={}){return await this.callWithRetry(()=>super.delete(e,t,r,i))}}er.MAX_TRIES=5;er.MAX_BACKOFF_MS=1e4;er.RETRY_STATUS_CODES=[408,413,429,500,502,503,504];er.RETRY_ERROR_CODES=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN","EPROTO"];var iw=Le.ProgramSourceMap,js=Le.OnApplicationComplete;class eS{constructor(e){this.createTransaction={bare:{create:async t=>this._algorand.createTransaction.appCreate(await this.params.bare.create(t))},create:async t=>this._algorand.createTransaction.appCreateMethodCall(await this.params.create(t))},this.send={bare:{create:async t=>{const r=(t==null?void 0:t.updatable)??this._updatable,i=(t==null?void 0:t.deletable)??this._deletable,o=(t==null?void 0:t.deployTimeParams)??this._deployTimeParams,s=await this.compile({deployTimeParams:o,updatable:r,deletable:i}),a=await this.handleCallErrors(async()=>({...await this._algorand.send.appCreate(await this.params.bare.create({...t,updatable:r,deletable:i,deployTimeParams:o})),return:void 0}));return{appClient:this.getAppClientById({appId:a.appId}),result:{...a,...s}}}},create:async t=>{const r=(t==null?void 0:t.updatable)??this._updatable,i=(t==null?void 0:t.deletable)??this._deletable,o=(t==null?void 0:t.deployTimeParams)??this._deployTimeParams,s=await this.compile({deployTimeParams:o,updatable:r,deletable:i}),a=await this.handleCallErrors(async()=>this.parseMethodCallReturn(this._algorand.send.appCreateMethodCall(await this.params.create({...t,updatable:r,deletable:i,deployTimeParams:o})),Bn(t.method,this._appSpec)));return{appClient:this.getAppClientById({appId:a.appId}),result:{...a,...s}}}},this._appSpec=cn.normaliseAppSpec(e.appSpec),this._appName=e.appName??this._appSpec.name,this._algorand=e.algorand,this._version=e.version??"1.0",this._defaultSender=typeof e.defaultSender=="string"?ze.fromString(e.defaultSender):e.defaultSender,this._defaultSigner=e.defaultSigner,this._deployTimeParams=e.deployTimeParams,this._updatable=e.updatable,this._deletable=e.deletable,this._paramsMethods=this.getParamsMethods()}get appName(){return this._appName}get appSpec(){return this._appSpec}get algorand(){return this._algorand}get params(){return this._paramsMethods}async deploy(e){const t=e.updatable??this._updatable??this.getDeployTimeControl("updatable"),r=e.deletable??this._deletable??this.getDeployTimeControl("deletable"),i=e.deployTimeParams??this._deployTimeParams,s=await this.getAppClientById({appId:0n}).compile({deployTimeParams:i,updatable:t,deletable:r}),a=await this._algorand.appDeployer.deploy({...e,createParams:await(e.createParams&&"method"in e.createParams?this.params.create({...e.createParams,updatable:t,deletable:r,deployTimeParams:i}):this.params.bare.create({...e.createParams,updatable:t,deletable:r,deployTimeParams:i})),updateParams:e.updateParams&&"method"in e.updateParams?this.params.deployUpdate(e.updateParams):this.params.bare.deployUpdate(e.updateParams),deleteParams:e.deleteParams&&"method"in e.deleteParams?this.params.deployDelete(e.deleteParams):this.params.bare.deployDelete(e.deleteParams),metadata:{name:e.appName??this._appName,version:this._version,updatable:t,deletable:r}}),l=this.getAppClientById({appId:a.appId,appName:e.appName}),c={...a,...s};return{appClient:l,result:{...c,return:"return"in c?c.operationPerformed==="update"?e.updateParams&&"method"in e.updateParams?Ys(c.return,Bn(e.updateParams.method,this._appSpec),this._appSpec.structs):void 0:e.createParams&&"method"in e.createParams?Ys(c.return,Bn(e.createParams.method,this._appSpec),this._appSpec.structs):void 0:void 0,deleteReturn:"deleteReturn"in c&&e.deleteParams&&"method"in e.deleteParams?Ys(c.deleteReturn,Bn(e.deleteParams.method,this._appSpec),this._appSpec.structs):void 0}}}getAppClientById(e){return new cn({...e,algorand:this._algorand,appSpec:this._appSpec,appName:e.appName??this._appName,defaultSender:e.defaultSender??this._defaultSender,defaultSigner:e.defaultSigner??this._defaultSigner,approvalSourceMap:e.approvalSourceMap??this._approvalSourceMap,clearSourceMap:e.clearSourceMap??this._clearSourceMap})}getAppClientByCreatorAndName(e){return cn.fromCreatorAndName({...e,algorand:this._algorand,appSpec:this._appSpec,appName:e.appName??this._appName,defaultSender:e.defaultSender??this._defaultSender,approvalSourceMap:e.approvalSourceMap??this._approvalSourceMap,clearSourceMap:e.clearSourceMap??this._clearSourceMap})}exposeLogicError(e,t){return cn.exposeLogicError(e,this._appSpec,{isClearStateProgram:t,approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap})}exportSourceMaps(){if(!this._approvalSourceMap||!this._clearSourceMap)throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");return{approvalSourceMap:this._approvalSourceMap,clearSourceMap:this._clearSourceMap}}importSourceMaps(e){this._approvalSourceMap=new iw(e.approvalSourceMap),this._clearSourceMap=new iw(e.clearSourceMap)}getDeployTimeControl(e){var r;const t=(r=this._appSpec.source)!=null&&r.approval?Buffer.from(this._appSpec.source.approval,"base64").toString("utf-8"):void 0;if(!(!t||!t.includes(e==="updatable"?Xu:Zu)))return this._appSpec.bareActions.call.includes(e==="updatable"?"UpdateApplication":"DeleteApplication")||Object.values(this._appSpec.methods).some(i=>i.actions.call.includes(e==="updatable"?"UpdateApplication":"DeleteApplication"))}getParamsMethods(){return{create:async e=>{const t=await this.compile({...e,deployTimeParams:e.deployTimeParams??this._deployTimeParams});return this.getABIParams({...e,deployTimeParams:e.deployTimeParams??this._deployTimeParams,schema:e.schema??{globalByteSlices:this._appSpec.state.schema.global.bytes,globalInts:this._appSpec.state.schema.global.ints,localByteSlices:this._appSpec.state.schema.local.bytes,localInts:this._appSpec.state.schema.local.ints},approvalProgram:t.approvalProgram,clearStateProgram:t.clearStateProgram},e.onComplete??js.NoOpOC)},deployUpdate:e=>this.getABIParams(e,js.UpdateApplicationOC),deployDelete:e=>this.getABIParams(e,js.DeleteApplicationOC),bare:{create:async e=>this.getBareParams({...e,deployTimeParams:(e==null?void 0:e.deployTimeParams)??this._deployTimeParams,schema:(e==null?void 0:e.schema)??{globalByteSlices:this._appSpec.state.schema.global.bytes,globalInts:this._appSpec.state.schema.global.ints,localByteSlices:this._appSpec.state.schema.local.bytes,localInts:this._appSpec.state.schema.local.ints},...await this.compile({...e,deployTimeParams:(e==null?void 0:e.deployTimeParams)??this._deployTimeParams})},(e==null?void 0:e.onComplete)??js.NoOpOC),deployUpdate:e=>this.getBareParams(e,js.UpdateApplicationOC),deployDelete:e=>this.getBareParams(e,js.DeleteApplicationOC)}}}async handleCallErrors(e){try{return await e()}catch(t){throw this.exposeLogicError(t)}}async compile(e){const t=await cn.compile(this._appSpec,this._algorand.app,e);return t.compiledApproval&&(this._approvalSourceMap=t.compiledApproval.sourceMap),t.compiledClear&&(this._clearSourceMap=t.compiledClear.sourceMap),t}getBareParams(e,t){return{...e,sender:this.getSender(e==null?void 0:e.sender),signer:this.getSigner(e==null?void 0:e.sender,e==null?void 0:e.signer),onComplete:t}}getABIParams(e,t){return{...e,sender:this.getSender(e.sender),signer:this.getSigner(e.sender,e.signer),method:Bn(e.method,this._appSpec),args:this.getCreateABIArgsWithDefaultValues(e.method,e.args),onComplete:t}}getCreateABIArgsWithDefaultValues(e,t){const r=Bn(e,this._appSpec);return t==null?void 0:t.map((i,o)=>{const s=r.args[o];if(i!==void 0)return s.struct&&typeof i=="object"&&!Array.isArray(i)?Zl(i,this._appSpec.structs[s.struct],this._appSpec.structs):i;const a=s.defaultValue;if(a)switch(a.source){case"literal":return qn(Buffer.from(a.data,"base64"),r.method.args[o].type,this._appSpec.structs);default:throw new Error(`Can't provide default value for ${a.source} for a contract creation call`)}throw new Error(`No value provided for required argument ${s.name??`arg${o+1}`} in call to method ${r.name}`)})}getSender(e){if(!e&&!this._defaultSender)throw new Error(`No sender provided and no default sender present in app factory for call to app ${this._appName}`);return typeof e=="string"?ze.fromString(e):e??this._defaultSender}getSigner(e,t){return t??(!e||e===this._defaultSender?this._defaultSigner:void 0)}async parseMethodCallReturn(e,t){const r=await e;return{...r,return:Ys(r.return,t,this._appSpec.structs)}}}const QM="https://api.dispenser.algorandfoundation.tools",eR=15,ow="ALGOKIT_DISPENSER_ACCESS_TOKEN";var ta;(function(n){n[n.Algo=0]="Algo"})(ta||(ta={}));const of={[ta.Algo]:{assetId:0,decimals:6,description:"Algo"}};class sw{constructor(e){var r;const t=(r=process==null?void 0:process.env)==null?void 0:r[ow];if(e!=null&&e.authToken)this._authToken=e.authToken;else if(t)this._authToken=t;else throw new Error(`Can't init AlgoKit TestNet Dispenser API client because neither environment variable ${ow} or the authToken were provided.`);this._requestTimeout=(e==null?void 0:e.requestTimeout)||eR}get authToken(){return this._authToken}get requestTimeout(){return this._requestTimeout}async processDispenserRequest(e,t,r=null,i="POST"){const o={Authorization:`Bearer ${e}`},s={method:i,headers:o,signal:AbortSignal.timeout(this.requestTimeout*1e3)};r&&(s.body=ea(r));const a=await fetch(`${QM}/${t}`,s);if(!a.ok){let l=`Error processing dispenser API request: ${a.status}`,c=null;try{c=await a.json()}catch{}throw c&&c.code?l=c.code:a.status===400&&(l=(await a.json()).message),new Error(l)}return a}async fund(e,t){const i=await(await this.processDispenserRequest(this.authToken,`fund/${of[ta.Algo].assetId}`,{receiver:typeof e=="string"?e:e.toString(),amount:Number(t),assetID:of[ta.Algo].assetId},"POST")).json();return{txId:i.txID,amount:i.amount}}async refund(e){await this.processDispenserRequest(this.authToken,"refund",{refundTransactionID:e},"POST")}async getLimit(){return{amount:(await(await this.processDispenserRequest(this.authToken,`fund/${of[ta.Algo].assetId}/limit`,null,"GET")).json()).amount}}}var tR=Le.Kmd,nR=Le.Indexer;class zt{constructor(e,t){const r="algod"in e?e:{algod:zt.getAlgodClient(e.algodConfig),indexer:e.indexerConfig?zt.getIndexerClient(e.indexerConfig):void 0,kmd:e.kmdConfig?zt.getKmdClient(e.kmdConfig):void 0};this._algod=r.algod,this._indexer=r.indexer,this._kmd=r.kmd,this._algorand=t}get algod(){return this._algod}get indexer(){if(!this._indexer)throw new Error("Attempt to use Indexer client in AlgoKit instance with no Indexer configured");return this._indexer}get indexerIfPresent(){return this._indexer}get kmd(){if(!this._kmd)throw new Error("Attempt to use Kmd client in AlgoKit instance with no Kmd configured");return this._kmd}async network(){this._getNetworkPromise||(this._getNetworkPromise=this._algod.getTransactionParams().do());const e=await this._getNetworkPromise;return{isTestNet:["testnet-v1.0","testnet-v1","testnet"].includes(e.genesisID??"unknown"),isMainNet:["mainnet-v1.0","mainnet-v1","mainnet"].includes(e.genesisID??"unknown"),isLocalNet:zt.genesisIdIsLocalNet(e.genesisID??"unknown"),genesisId:e.genesisID??"unknown",genesisHash:e.genesisHash?Buffer.from(e.genesisHash).toString("base64"):"unknown"}}static genesisIdIsLocalNet(e){return Zv(e)}async isLocalNet(){return(await this.network()).isLocalNet}async isTestNet(){return(await this.network()).isTestNet}async isMainNet(){return(await this.network()).isMainNet}getTestNetDispenser(e){return new sw(e)}getTestNetDispenserFromEnvironment(e){return new sw(e?{...e,authToken:""}:void 0)}getAppFactory(e){if(!this._algorand)throw new Error("Attempt to get app factory from a ClientManager without an Algorand client");return new eS({...e,algorand:this._algorand})}getAppClientByCreatorAndName(e){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return cn.fromCreatorAndName({...e,algorand:this._algorand})}getAppClientById(e){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return new cn({...e,algorand:this._algorand})}async getAppClientByNetwork(e){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return cn.fromNetwork({...e,algorand:this._algorand})}async getTypedAppClientByCreatorAndName(e,t){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return e.fromCreatorAndName({...t,algorand:this._algorand})}getTypedAppClientById(e,t){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return new e({...t,algorand:this._algorand})}getTypedAppClientByNetwork(e,t){if(!this._algorand)throw new Error("Attempt to get app client from a ClientManager without an Algorand client");return e.fromNetwork({...t,algorand:this._algorand})}getTypedAppFactory(e,t){if(!this._algorand)throw new Error("Attempt to get app factory from a ClientManager without an Algorand client");return new e({...t,algorand:this._algorand})}static getConfigFromEnvironmentOrLocalNet(){var i;if(!process||!process.env)throw new Error("Attempt to get default client configuration from a non Node.js context; supply the config instead");const[e,t,r]=process.env.ALGOD_SERVER?[zt.getAlgodConfigFromEnvironment(),process.env.INDEXER_SERVER?zt.getIndexerConfigFromEnvironment():void 0,!process.env.ALGOD_SERVER.includes("mainnet")&&!process.env.ALGOD_SERVER.includes("testnet")?{...zt.getAlgodConfigFromEnvironment(),port:((i=process==null?void 0:process.env)==null?void 0:i.KMD_PORT)??"4002"}:void 0]:[zt.getDefaultLocalNetConfig("algod"),zt.getDefaultLocalNetConfig("indexer"),zt.getDefaultLocalNetConfig("kmd")];return{algodConfig:e,indexerConfig:t,kmdConfig:r}}static getAlgodConfigFromEnvironment(){if(!process||!process.env)throw new Error("Attempt to get default algod configuration from a non Node.js context; supply the config instead");if(!process.env.ALGOD_SERVER)throw new Error("Attempt to get default algod configuration without specifying ALGOD_SERVER in the environment variables");return{server:process.env.ALGOD_SERVER,port:process.env.ALGOD_PORT,token:process.env.ALGOD_TOKEN}}static getIndexerConfigFromEnvironment(){if(!process||!process.env)throw new Error("Attempt to get default indexer configuration from a non Node.js context; supply the config instead");if(!process.env.INDEXER_SERVER)throw new Error("Attempt to get default indexer configuration without specifying INDEXER_SERVER in the environment variables");return{server:process.env.INDEXER_SERVER,port:process.env.INDEXER_PORT,token:process.env.INDEXER_TOKEN}}static getAlgoNodeConfig(e,t){return{server:`https://${e}-${t==="algod"?"api":"idx"}.algonode.cloud/`,port:443}}static getDefaultLocalNetConfig(e){return{server:"http://localhost",port:e==="algod"?4001:e==="indexer"?8980:e==="kmd"?4002:e,token:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}}static getAlgodClient(e){const{token:t,server:r,port:i}=e,o=typeof t=="string"?{"X-Algo-API-Token":t}:t??{},s=new er(o,r,i);return new Le.Algodv2(s,r)}static getAlgodClientFromEnvironment(){return zt.getAlgodClient(zt.getAlgodConfigFromEnvironment())}static getIndexerClient(e){const{token:t,server:r,port:i}=e,o=typeof t=="string"?{"X-Indexer-API-Token":t}:t??{},s=new er(o,r,i);return new nR(s)}static getIndexerClientFromEnvironment(){return zt.getIndexerClient(zt.getIndexerConfigFromEnvironment())}static getKmdClient(e){const{token:t,server:r,port:i}=e;return new tR(t,r,i)}static getKmdClientFromEnvironment(){var e;return zt.getKmdClient({...zt.getAlgodConfigFromEnvironment(),port:((e=process==null?void 0:process.env)==null?void 0:e.KMD_PORT)??"4002"})}}class rR{constructor(e){this._clientManager=e;try{this._kmd=e.kmd}catch{this._kmd=void 0}}async kmd(){if(this._kmd===void 0){if(await this._clientManager.isLocalNet()){const{kmdConfig:e}=zt.getConfigFromEnvironmentOrLocalNet();if(e)return this._kmd=zt.getKmdClient(e),this._kmd}this._kmd=null}if(!this._kmd)throw new Error("Attempt to use Kmd client in AlgoKit instance with no Kmd configured");return this._kmd}async getWalletAccount(e,t,r){return this.findWalletAccount(e,t,r)}async findWalletAccount(e,t,r){const i=await this.kmd(),s=(await i.listWallets()).wallets.filter(x=>x.name===e);if(s.length===0)return;const a=s[0].id,l=(await i.initWalletHandle(a,"")).wallet_handle_token;let c;if(t&&typeof t=="string")c=t;else{const x=(await i.listKeys(l)).addresses;if(x.length>0)if(t&&typeof t=="function")for(let A=0;A<x.length;A++){const v=await this._clientManager.algod.accountInformation(x[A]).do();if(t(v)){c=x[A];break}}else c=x[0]}if(!c)return;const d=(await i.exportKey(l,"",c)).private_key,u=Le.secretKeyToMnemonic(d),m=Le.mnemonicToSecretKey(u),h=new Gp(m,r);return{account:h,addr:h.addr,signer:h.signer}}async getOrCreateWalletAccount(e,t){const r=await this.getWalletAccount(e);if(r)return r;const i=await this.kmd(),o=(await i.createWallet(e,"")).wallet.id,s=(await i.initWalletHandle(o,"")).wallet_handle_token;await i.generateKey(s);const a=await this.getWalletAccount(e);ft.logger.info(`LocalNet account '${e}' doesn't yet exist; created account ${a.addr} with keys stored in KMD and funding with ${(t==null?void 0:t.algo)??1e3} ALGO`);const l=await this.getLocalNetDispenserAccount();return await new zr({algod:this._clientManager.algod,getSigner:()=>l.signer,getSuggestedParams:()=>this._clientManager.algod.getTransactionParams().do()}).addPayment({amount:t??Wn.Algo(1e3),receiver:a.addr,sender:l.addr}).send(),a}async getLocalNetDispenserAccount(){if(!await this._clientManager.isLocalNet())throw new Error("Can't get LocalNet dispenser account from non LocalNet network");const t=JSON.parse(await this._clientManager.algod.genesis().do()).alloc.filter(r=>r.comment==="Wallet1").map(r=>r.addr);if(t.length>0){const r=await this.findWalletAccount("unencrypted-default-wallet",t[0]);if(r)return r}throw new Error("Error retrieving LocalNet dispenser account; couldn't find the default account in KMD")}}var iR=Le.LogicSigAccount;const cr=n=>typeof n=="string"?ze.fromString(n):n,oR=CM(function(n){return"signer"in n?n.signer:"lsig"in n?Le.makeLogicSigAccountTransactionSigner(n):Le.makeBasicAccountTransactionSigner(n)});class sR{constructor(e){this._accounts={},this._clientManager=e,this._kmdAccountManager=new rR(e)}_getComposer(e){return new zr({algod:this._clientManager.algod,getSigner:this.getSigner.bind(this),getSuggestedParams:e??(()=>this._clientManager.algod.getTransactionParams().do())})}get kmd(){return this._kmdAccountManager}setDefaultSigner(e){return this._defaultSigner="signer"in e?e.signer:e,this}signerAccount(e){const t=oR(e),r={addr:"addr"in e?e.addr:e.address(),signer:t};this._accounts[r.addr.toString()]=r;const i=ze.fromString(r.addr.toString());return i.account=e,i.addr=r.addr,i.signer=t,i}setSignerFromAccount(e){return this.signerAccount(e),this}setSigner(e,t){return this._accounts[cr(e).toString()]={addr:cr(e),signer:t},this}setSigners(e,t=!0){return this._accounts=t?{...this._accounts,...e._accounts}:{...e._accounts,...this._accounts},this}getSigner(e){var r;const t=((r=this._accounts[cr(e).toString()])==null?void 0:r.signer)??this._defaultSigner;if(!t)throw new Error(`No signer found for address ${e}`);return t}getAccount(e){const t=this._accounts[cr(e).toString()];if(!t)throw new Error(`No signer found for address ${e}`);return t}async getInformation(e){const{round:t,lastHeartbeat:r=void 0,lastProposed:i=void 0,address:o,...s}=await this._clientManager.algod.accountInformation(e).do();return{...s,address:ze.fromString(o),balance:Wn.MicroAlgo(Number(s.amount)),amountWithoutPendingRewards:Wn.MicroAlgo(Number(s.amountWithoutPendingRewards)),minBalance:Wn.MicroAlgo(Number(s.minBalance)),pendingRewards:Wn.MicroAlgo(Number(s.pendingRewards)),rewards:Wn.MicroAlgo(Number(s.rewards)),validAsOfRound:BigInt(t),totalAppsOptedIn:Number(s.totalAppsOptedIn),totalAssetsOptedIn:Number(s.totalAssetsOptedIn),totalCreatedApps:Number(s.totalCreatedApps),totalCreatedAssets:Number(s.totalCreatedAssets),appsTotalExtraPages:s.appsTotalExtraPages!==void 0?Number(s.appsTotalExtraPages):void 0,rewardBase:s.rewardBase!==void 0?Number(s.rewardBase):void 0,totalBoxBytes:s.totalBoxBytes!==void 0?Number(s.totalBoxBytes):void 0,totalBoxes:s.totalBoxes!==void 0?Number(s.totalBoxes):void 0,lastHeartbeatRound:r!==void 0?BigInt(r):void 0,lastProposedRound:i!==void 0?BigInt(i):void 0}}fromMnemonic(e,t){const r=Le.mnemonicToSecretKey(e);return this.signerAccount(new Gp(r,t))}rekeyed(e,t){return this.signerAccount({addr:cr(e),signer:t.signer})}async fromEnvironment(e,t){if(!process||!process.env)throw new Error("Attempt to get account with private key from a non Node.js context; this is not supported!");const r=process.env[`${e.toUpperCase()}_MNEMONIC`],i=process.env[`${e.toUpperCase()}_SENDER`];if(r){const o=Le.mnemonicToSecretKey(r);return this.signerAccount(new Gp(o,i))}if(await this._clientManager.isLocalNet()){const o=await this._kmdAccountManager.getOrCreateWalletAccount(e,t);return this.signerAccount(o.account)}throw new Error(`Missing environment variable ${e.toUpperCase()}_MNEMONIC when looking for account ${e}`)}async fromKmd(e,t,r){const i=await this._kmdAccountManager.getWalletAccount(e,t,r);if(!i)throw new Error(`Unable to find KMD account ${e}${t?" with predicate":""}`);return this.signerAccount(i.account)}multisig(e,t){return this.signerAccount(new JM(e,t))}logicsig(e,t){return this.signerAccount(new iR(e,t))}random(){return this.signerAccount(Le.generateAccount())}async dispenserFromEnvironment(){if(!process||!process.env)throw new Error("Attempt to get dispenser from environment from a non Node.js context; this is not supported!");return process.env[`${rw.toUpperCase()}_MNEMONIC`]?await this.fromEnvironment(rw):await this.localNetDispenser()}async localNetDispenser(){const e=await this._kmdAccountManager.getLocalNetDispenserAccount();return this.signerAccount(e.account)}async rekeyAccount(e,t,r){const i=await this._getComposer().addPayment({...r,sender:cr(e),receiver:cr(e),amount:Wn.MicroAlgo(0),rekeyTo:cr(typeof t=="object"&&"addr"in t?t.addr:t)}).send(r);return typeof t=="object"&&"addr"in t&&this.rekeyed(e,t),ft.getLogger(r==null?void 0:r.suppressLog).info(`Rekeyed ${e} to ${t} via transaction ${i.txIds.at(-1)}`),{...i,transaction:i.transactions.at(-1),confirmation:i.confirmations.at(-1)}}async _getEnsureFundedAmount(e,t,r){const i=await this.getInformation(e),o=i.balance.microAlgo-i.minBalance.microAlgo,s=kM(t.microAlgo,o,(r==null?void 0:r.microAlgo)??0n);return s===null?void 0:Wn.MicroAlgo(s)}async ensureFunded(e,t,r,i){const o=cr(e),s=await this._getEnsureFundedAmount(o,r,i==null?void 0:i.minFundingIncrement);if(!s)return;const a=await this._getComposer().addPayment({...i,sender:cr(t),receiver:o,amount:s}).send(i);return{...a,transaction:a.transactions[0],confirmation:a.confirmations[0],transactionId:a.txIds[0],amountFunded:s}}async ensureFundedFromEnvironment(e,t,r){const i=cr(e),o=await this.dispenserFromEnvironment(),s=await this._getEnsureFundedAmount(i,t,r==null?void 0:r.minFundingIncrement);if(!s)return;const a=await this._getComposer().addPayment({...r,sender:o,receiver:i,amount:s}).send(r);return{...a,transaction:a.transactions[0],confirmation:a.confirmations[0],transactionId:a.txIds[0],amountFunded:s}}async ensureFundedFromTestNetDispenserApi(e,t,r,i){if(!await this._clientManager.isTestNet())throw new Error("Attempt to fund using TestNet dispenser API on non TestNet network.");const o=cr(e),s=await this._getEnsureFundedAmount(o,r,i==null?void 0:i.minFundingIncrement);if(!s)return;const a=await t.fund(o,s.microAlgo);return{amountFunded:Wn.MicroAlgo(a.amount),transactionId:a.txId}}}class Ri{constructor(e){this._cachedSuggestedParamsTimeout=3e3,this._defaultValidityWindow=void 0,this._errorTransformers=new Set,this._clientManager=new zt(e,this),this._accountManager=new sR(this._clientManager),this._appManager=new Qn(this._clientManager.algod),this._assetManager=new UM(this._clientManager.algod,()=>this.newGroup()),this._transactionSender=new NM(()=>this.newGroup(),this._assetManager,this._appManager),this._transactionCreator=new mM(()=>this.newGroup()),this._appDeployer=new WM(this._appManager,this._transactionSender,this._clientManager.indexerIfPresent)}setDefaultValidityWindow(e){return this._defaultValidityWindow=BigInt(e),this}setDefaultSigner(e){return this._accountManager.setDefaultSigner(e),this}setSignerFromAccount(e){return this._accountManager.setSignerFromAccount(e),this}setSigner(e,t){return this._accountManager.setSigner(e,t),this}setSuggestedParamsCache(e,t){return this._cachedSuggestedParams=e,this._cachedSuggestedParamsExpiry=t??new Date(+new Date+this._cachedSuggestedParamsTimeout),this}setSuggestedParamsCacheTimeout(e){return this._cachedSuggestedParamsTimeout=e,this}async getSuggestedParams(){return this._cachedSuggestedParams&&(!this._cachedSuggestedParamsExpiry||this._cachedSuggestedParamsExpiry>new Date)?{...this._cachedSuggestedParams}:(this._cachedSuggestedParams=await this._clientManager.algod.getTransactionParams().do(),this._cachedSuggestedParamsExpiry=new Date(new Date().getTime()+this._cachedSuggestedParamsTimeout),{...this._cachedSuggestedParams})}get client(){return this._clientManager}get account(){return this._accountManager}get asset(){return this._assetManager}get app(){return this._appManager}get appDeployer(){return this._appDeployer}registerErrorTransformer(e){this._errorTransformers.add(e)}unregisterErrorTransformer(e){this._errorTransformers.delete(e)}newGroup(){return new zr({algod:this.client.algod,getSigner:e=>this.account.getSigner(e),getSuggestedParams:()=>this.getSuggestedParams(),defaultValidityWindow:this._defaultValidityWindow,appManager:this._appManager,errorTransformers:[...this._errorTransformers]})}get send(){return this._transactionSender}get createTransaction(){return this._transactionCreator}static defaultLocalNet(){return new Ri({algodConfig:zt.getDefaultLocalNetConfig("algod"),indexerConfig:zt.getDefaultLocalNetConfig("indexer"),kmdConfig:zt.getDefaultLocalNetConfig("kmd")})}static testNet(){return new Ri({algodConfig:zt.getAlgoNodeConfig("testnet","algod"),indexerConfig:zt.getAlgoNodeConfig("testnet","indexer"),kmdConfig:void 0})}static mainNet(){return new Ri({algodConfig:zt.getAlgoNodeConfig("mainnet","algod"),indexerConfig:zt.getAlgoNodeConfig("mainnet","indexer"),kmdConfig:void 0})}static fromClients(e){return new Ri(e)}static fromEnvironment(){return new Ri(zt.getConfigFromEnvironmentOrLocalNet())}static fromConfig(e){return new Ri(e)}}const mr={name:"AbelReader",structs:{AssetTinyLabels:[{name:"name",type:"string"},{name:"unitName",type:"string"},{name:"decimals",type:"uint8"},{name:"labels",type:"string[]"}],BalanceInfo:[{name:"balance",type:"uint64"},{name:"minBalance",type:"uint64"}]},methods:[{name:"getBalanceInfo",args:[{type:"address[]",name:"accounts"}],returns:{type:"(uint64,uint64)",struct:"BalanceInfo"},actions:{create:["NoOp"],call:["NoOp"]},readonly:!0,events:[],recommendations:{}},{name:"getAssetsTiny",args:[{type:"uint64[]",name:"assetIds"},{type:"uint64",name:"abelAppId"}],returns:{type:"(string,string,uint8,string[])",struct:"AssetTinyLabels"},actions:{create:["NoOp"],call:["NoOp"]},readonly:!0,events:[],recommendations:{}},{name:"get_asset_labels",args:[{type:"asset",name:"assetId"}],returns:{type:"string[]"},actions:{create:["NoOp"],call:["NoOp"]},readonly:!0,events:[],recommendations:{}}],arcs:[22,28],networks:{},state:{schema:{global:{ints:0,bytes:0},local:{ints:0,bytes:0}},keys:{global:{},local:{},box:{}},maps:{global:{},local:{},box:{}}},bareActions:{create:[],call:["DeleteApplication","UpdateApplication"]},sourceInfo:{approval:{sourceInfo:[{pc:[332],errorMessage:"Bytes has valid prefix"},{pc:[8],errorMessage:"OnCompletion must be NoOp"},{pc:[48],errorMessage:"OnCompletion must be one of UpdateApplication, DeleteApplication && can only call when not creating"},{pc:[347,354,357],errorMessage:"asset exists"},{pc:[108,236],errorMessage:"index access is out of bounds"},{pc:[77,195],errorMessage:"invalid array length header"},{pc:[89],errorMessage:"invalid number of bytes for arc4.dynamic_array<account>"},{pc:[207],errorMessage:"invalid number of bytes for arc4.dynamic_array<asset>"},{pc:[215,337],errorMessage:"invalid number of bytes for arc4.uint64"},{pc:[485],errorMessage:"invalid number of bytes for arc4.uint8"},{pc:[363],errorMessage:"overflow"}],pcOffsetMethod:"cblocks"},clear:{sourceInfo:[],pcOffsetMethod:"none"}},source:{approval:"I3ByYWdtYSB2ZXJzaW9uIDExCiNwcmFnbWEgdHlwZXRyYWNrIGZhbHNlCgovLyBAYWxnb3JhbmRmb3VuZGF0aW9uL2FsZ29yYW5kLXR5cGVzY3JpcHQvYXJjNC9pbmRleC5kLnRzOjpDb250cmFjdC5hcHByb3ZhbFByb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW46CiAgICBpbnRjYmxvY2sgMCAxIDggMzIgVE1QTF9VUERBVEFCTEUKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjMwCiAgICAvLyBleHBvcnQgY2xhc3MgQWJlbFJlYWRlciBleHRlbmRzIENvbnRyYWN0IHsKICAgIHR4biBOdW1BcHBBcmdzCiAgICBieiBtYWluX2FkbWluT25seUAxMAogICAgdHhuIE9uQ29tcGxldGlvbgogICAgIQogICAgYXNzZXJ0IC8vIE9uQ29tcGxldGlvbiBtdXN0IGJlIE5vT3AKICAgIHB1c2hieXRlc3MgMHg0ODc3YTk2NyAweGQ1YWIzMzY2IDB4YzJlZDc0M2YgLy8gbWV0aG9kICJnZXRCYWxhbmNlSW5mbyhhZGRyZXNzW10pKHVpbnQ2NCx1aW50NjQpIiwgbWV0aG9kICJnZXRBc3NldHNUaW55KHVpbnQ2NFtdLHVpbnQ2NCkoc3RyaW5nLHN0cmluZyx1aW50OCxzdHJpbmdbXSkiLCBtZXRob2QgImdldF9hc3NldF9sYWJlbHMoYXNzZXQpc3RyaW5nW10iCiAgICB0eG5hIEFwcGxpY2F0aW9uQXJncyAwCiAgICBtYXRjaCBnZXRCYWxhbmNlSW5mbyBnZXRBc3NldHNUaW55IGdldEFzc2V0TGFiZWxzCiAgICBlcnIKCm1haW5fYWRtaW5Pbmx5QDEwOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzEKICAgIC8vIEBiYXJlbWV0aG9kKHsgYWxsb3dBY3Rpb25zOiBbIlVwZGF0ZUFwcGxpY2F0aW9uIiwgIkRlbGV0ZUFwcGxpY2F0aW9uIl0gfSkKICAgIGludGNfMSAvLyAxCiAgICB0eG4gT25Db21wbGV0aW9uCiAgICBzaGwKICAgIHB1c2hpbnQgNDggLy8gNDgKICAgICYKICAgIHR4biBBcHBsaWNhdGlvbklECiAgICAmJgogICAgYXNzZXJ0IC8vIE9uQ29tcGxldGlvbiBtdXN0IGJlIG9uZSBvZiBVcGRhdGVBcHBsaWNhdGlvbiwgRGVsZXRlQXBwbGljYXRpb24gJiYgY2FuIG9ubHkgY2FsbCB3aGVuIG5vdCBjcmVhdGluZwogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzMKICAgIC8vIGFzc2VydChUZW1wbGF0ZVZhcjx1aW50NjQ+KCJVUERBVEFCTEUiKSA9PT0gMSAmJiBUeG4uc2VuZGVyID09PSBHbG9iYWwuY3JlYXRvckFkZHJlc3MpOwogICAgaW50YyA0IC8vIFRNUExfVVBEQVRBQkxFCiAgICBpbnRjXzEgLy8gMQogICAgPT0KICAgIGJ6IG1haW5fYm9vbF9mYWxzZUAxNAogICAgdHhuIFNlbmRlcgogICAgZ2xvYmFsIENyZWF0b3JBZGRyZXNzCiAgICA9PQogICAgYnogbWFpbl9ib29sX2ZhbHNlQDE0CiAgICBpbnRjXzEgLy8gMQogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzEKICAgIC8vIEBiYXJlbWV0aG9kKHsgYWxsb3dBY3Rpb25zOiBbIlVwZGF0ZUFwcGxpY2F0aW9uIiwgIkRlbGV0ZUFwcGxpY2F0aW9uIl0gfSkKICAgIHJldHVybgoKbWFpbl9ib29sX2ZhbHNlQDE0OgogICAgaW50Y18wIC8vIDAKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjMxCiAgICAvLyBAYmFyZW1ldGhvZCh7IGFsbG93QWN0aW9uczogWyJVcGRhdGVBcHBsaWNhdGlvbiIsICJEZWxldGVBcHBsaWNhdGlvbiJdIH0pCiAgICByZXR1cm4KCgovLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo6QWJlbFJlYWRlci5nZXRCYWxhbmNlSW5mb1tyb3V0aW5nXSgpIC0+IHZvaWQ6CmdldEJhbGFuY2VJbmZvOgogICAgaW50Y18wIC8vIDAKICAgIHB1c2hieXRlcyAiIgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6MzYKICAgIC8vIEBhYmltZXRob2QoeyByZWFkb25seTogdHJ1ZSwgb25DcmVhdGU6ICJhbGxvdyIgfSkKICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDEKICAgIGR1cG4gMgogICAgaW50Y18wIC8vIDAKICAgIGV4dHJhY3RfdWludDE2IC8vIG9uIGVycm9yOiBpbnZhbGlkIGFycmF5IGxlbmd0aCBoZWFkZXIKICAgIGR1cAogICAgY292ZXIgMgogICAgaW50Y18zIC8vIDMyCiAgICAqCiAgICBwdXNoaW50IDIgLy8gMgogICAgKwogICAgc3dhcAogICAgbGVuCiAgICA9PQogICAgYXNzZXJ0IC8vIGludmFsaWQgbnVtYmVyIG9mIGJ5dGVzIGZvciBhcmM0LmR5bmFtaWNfYXJyYXk8YWNjb3VudD4KICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFjY291bnRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGludGNfMCAvLyAwCgpnZXRCYWxhbmNlSW5mb193aGlsZV90b3BAMjoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFjY291bnRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGR1cAogICAgZGlnIDIKICAgIDwKICAgIGJ6IGdldEJhbGFuY2VJbmZvX2FmdGVyX3doaWxlQDcKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM5CiAgICAvLyBjb25zdCBhY2NvdW50ID0gYWNjb3VudHNbaWR4XTsKICAgIGRpZyAyCiAgICBleHRyYWN0IDIgMAogICAgZGlnIDEKICAgIGludGNfMyAvLyAzMgogICAgKgogICAgaW50Y18zIC8vIDMyCiAgICBleHRyYWN0MyAvLyBvbiBlcnJvcjogaW5kZXggYWNjZXNzIGlzIG91dCBvZiBib3VuZHMKICAgIGR1cAogICAgYnVyeSA2CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo0MAogICAgLy8gY29uc3QgYmFsYW5jZSA9IG9wLmJhbGFuY2UoYWNjb3VudCk7CiAgICBiYWxhbmNlCiAgICBkdXAKICAgIGJ1cnkgNQogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NDEKICAgIC8vIGlmIChiYWxhbmNlID4gMCkgewogICAgYnogZ2V0QmFsYW5jZUluZm9fZWxzZV9ib2R5QDUKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjQyCiAgICAvLyBjb25zdCBtaW5CYWxhbmNlID0gb3AubWluQmFsYW5jZShhY2NvdW50KTsKICAgIGRpZyA0CiAgICBtaW5fYmFsYW5jZQogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NDMKICAgIC8vIGNvbnN0IGJhbGFuY2VJbmZvOiBCYWxhbmNlSW5mbyA9IHsgYmFsYW5jZSwgbWluQmFsYW5jZSB9OwogICAgZGlnIDQKICAgIGl0b2IKICAgIHN3YXAKICAgIGl0b2IKICAgIGNvbmNhdAogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NDQKICAgIC8vIGxvZyhlbmNvZGVBcmM0KGJhbGFuY2VJbmZvKSk7CiAgICBsb2cKCmdldEJhbGFuY2VJbmZvX2FmdGVyX2lmX2Vsc2VANjoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFjY291bnRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGR1cAogICAgaW50Y18xIC8vIDEKICAgICsKICAgIGJ1cnkgMQogICAgYiBnZXRCYWxhbmNlSW5mb193aGlsZV90b3BAMgoKZ2V0QmFsYW5jZUluZm9fZWxzZV9ib2R5QDU6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo1MwogICAgLy8gcmV0dXJuIHsgYmFsYW5jZTogMCwgbWluQmFsYW5jZTogMCB9OwogICAgcHVzaGJ5dGVzIDB4MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjQ2CiAgICAvLyBsb2coZW5jb2RlQXJjNCh0aGlzLmdldEVtcHR5QmFsYW5jZUluZm8oKSkpOwogICAgbG9nCiAgICBiIGdldEJhbGFuY2VJbmZvX2FmdGVyX2lmX2Vsc2VANgoKZ2V0QmFsYW5jZUluZm9fYWZ0ZXJfd2hpbGVANzoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjM2CiAgICAvLyBAYWJpbWV0aG9kKHsgcmVhZG9ubHk6IHRydWUsIG9uQ3JlYXRlOiAiYWxsb3ciIH0pCiAgICBwdXNoYnl0ZXMgMHgxNTFmN2M3NTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwCiAgICBsb2cKICAgIGludGNfMSAvLyAxCiAgICByZXR1cm4KCgovLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo6QWJlbFJlYWRlci5nZXRBc3NldHNUaW55W3JvdXRpbmddKCkgLT4gdm9pZDoKZ2V0QXNzZXRzVGlueToKICAgIGludGNfMCAvLyAwCiAgICBkdXBuIDMKICAgIHB1c2hieXRlcyAiIgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTYKICAgIC8vIEBhYmltZXRob2QoeyByZWFkb25seTogdHJ1ZSwgb25DcmVhdGU6ICJhbGxvdyIgfSkKICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDEKICAgIGR1cG4gMgogICAgaW50Y18wIC8vIDAKICAgIGV4dHJhY3RfdWludDE2IC8vIG9uIGVycm9yOiBpbnZhbGlkIGFycmF5IGxlbmd0aCBoZWFkZXIKICAgIGR1cAogICAgY292ZXIgMgogICAgaW50Y18yIC8vIDgKICAgICoKICAgIHB1c2hpbnQgMiAvLyAyCiAgICArCiAgICBzd2FwCiAgICBsZW4KICAgID09CiAgICBhc3NlcnQgLy8gaW52YWxpZCBudW1iZXIgb2YgYnl0ZXMgZm9yIGFyYzQuZHluYW1pY19hcnJheTxhc3NldD4KICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDIKICAgIGR1cAogICAgbGVuCiAgICBpbnRjXzIgLy8gOAogICAgPT0KICAgIGFzc2VydCAvLyBpbnZhbGlkIG51bWJlciBvZiBieXRlcyBmb3IgYXJjNC51aW50NjQKICAgIGJ0b2kKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjU4CiAgICAvLyBmb3IgKGxldCBpZHg6IHVpbnQ2NCA9IDA7IGlkeCA8IGFzc2V0SWRzLmxlbmd0aDsgaWR4KyspIHsKICAgIGludGNfMCAvLyAwCgpnZXRBc3NldHNUaW55X3doaWxlX3RvcEAyOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTgKICAgIC8vIGZvciAobGV0IGlkeDogdWludDY0ID0gMDsgaWR4IDwgYXNzZXRJZHMubGVuZ3RoOyBpZHgrKykgewogICAgZHVwCiAgICBkaWcgMwogICAgPAogICAgYnogZ2V0QXNzZXRzVGlueV9hZnRlcl93aGlsZUAxNAogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTkKICAgIC8vIGNvbnN0IGFzc2V0ID0gYXNzZXRJZHNbaWR4XTsKICAgIGRpZyAzCiAgICBleHRyYWN0IDIgMAogICAgZGlnIDEKICAgIGludGNfMiAvLyA4CiAgICAqCiAgICBkdXAyCiAgICBpbnRjXzIgLy8gOAogICAgZXh0cmFjdDMgLy8gb24gZXJyb3I6IGluZGV4IGFjY2VzcyBpcyBvdXQgb2YgYm91bmRzCiAgICBidXJ5IDExCiAgICBleHRyYWN0X3VpbnQ2NAogICAgZHVwCiAgICBidXJ5IDYKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjYwCiAgICAvLyBjb25zdCBbXywgZXhpc3RzXSA9IG9wLkFzc2V0UGFyYW1zLmFzc2V0Q3JlYXRvcihhc3NldC5pZCk7CiAgICBhc3NldF9wYXJhbXNfZ2V0IEFzc2V0Q3JlYXRvcgogICAgYnVyeSAxCiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo2MQogICAgLy8gaWYgKCFleGlzdHMpIHsKICAgIGJueiBnZXRBc3NldHNUaW55X2Vsc2VfYm9keUA1CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo4NS05MAogICAgLy8gcmV0dXJuIHsKICAgIC8vICAgbmFtZTogIiIsCiAgICAvLyAgIHVuaXRfbmFtZTogIiIsCiAgICAvLyAgIGRlY2ltYWxzOiBuZXcgVWludDgoMCksCiAgICAvLyAgIGxhYmVsczogW10sCiAgICAvLyB9OwogICAgcHVzaGJ5dGVzIDB4MDAwNzAwMDkwMDAwMGIwMDAwMDAwMDAwMDAKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjYyCiAgICAvLyBsb2coZW5jb2RlQXJjNCh0aGlzLmdldEVtcHR5QXNzZXRUaW55TGFiZWxzKCkpKTsKICAgIGxvZwoKZ2V0QXNzZXRzVGlueV9hZnRlcl9pZl9lbHNlQDEzOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NTgKICAgIC8vIGZvciAobGV0IGlkeDogdWludDY0ID0gMDsgaWR4IDwgYXNzZXRJZHMubGVuZ3RoOyBpZHgrKykgewogICAgZHVwCiAgICBpbnRjXzEgLy8gMQogICAgKwogICAgYnVyeSAxCiAgICBiIGdldEFzc2V0c1Rpbnlfd2hpbGVfdG9wQDIKCmdldEFzc2V0c1RpbnlfZWxzZV9ib2R5QDU6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo2NQogICAgLy8gYWJlbEFwcElkICE9PSAwID8gY29tcGlsZUFyYzQoQWJlbFN0dWIpLmNhbGwuaGFzX2Fzc2V0X2xhYmVsKHsgYXBwSWQ6IGFiZWxBcHBJZCwgYXJnczogW2Fzc2V0LmlkLCAicHYiXSB9KS5yZXR1cm5WYWx1ZSA6IDA7CiAgICBkaWcgMQogICAgYnogZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X2ZhbHNlQDgKICAgIGl0eG5fYmVnaW4KICAgIHB1c2hieXRlcyAweDk3ZjQwYThhIC8vIG1ldGhvZCAiaGFzX2Fzc2V0X2xhYmVsKHVpbnQ2NCxzdHJpbmcpdWludDY0IgogICAgaXR4bl9maWVsZCBBcHBsaWNhdGlvbkFyZ3MKICAgIGRpZyA4CiAgICBpdHhuX2ZpZWxkIEFwcGxpY2F0aW9uQXJncwogICAgcHVzaGJ5dGVzIDB4MDAwMjcwNzYKICAgIGl0eG5fZmllbGQgQXBwbGljYXRpb25BcmdzCiAgICBpbnRjXzAgLy8gMAogICAgaXR4bl9maWVsZCBPbkNvbXBsZXRpb24KICAgIGRpZyAxCiAgICBpdHhuX2ZpZWxkIEFwcGxpY2F0aW9uSUQKICAgIHB1c2hpbnQgNiAvLyBhcHBsCiAgICBpdHhuX2ZpZWxkIFR5cGVFbnVtCiAgICBpbnRjXzAgLy8gMAogICAgaXR4bl9maWVsZCBGZWUKICAgIGl0eG5fc3VibWl0CiAgICBpdHhuIExhc3RMb2cKICAgIGR1cAogICAgZXh0cmFjdCA0IDAKICAgIHN3YXAKICAgIGV4dHJhY3QgMCA0CiAgICBwdXNoYnl0ZXMgMHgxNTFmN2M3NQogICAgPT0KICAgIGFzc2VydCAvLyBCeXRlcyBoYXMgdmFsaWQgcHJlZml4CiAgICBkdXAKICAgIGxlbgogICAgaW50Y18yIC8vIDgKICAgID09CiAgICBhc3NlcnQgLy8gaW52YWxpZCBudW1iZXIgb2YgYnl0ZXMgZm9yIGFyYzQudWludDY0CiAgICBidG9pCgpnZXRBc3NldHNUaW55X3Rlcm5hcnlfbWVyZ2VAOToKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjY3CiAgICAvLyBuYW1lOiBhc3NldC5uYW1lLnRvU3RyaW5nKCksCiAgICBkaWcgNQogICAgZHVwCiAgICBhc3NldF9wYXJhbXNfZ2V0IEFzc2V0TmFtZQogICAgc3dhcAogICAgYnVyeSAxMAogICAgYXNzZXJ0IC8vIGFzc2V0IGV4aXN0cwogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NjgKICAgIC8vIHVuaXRfbmFtZTogYXNzZXQudW5pdE5hbWUudG9TdHJpbmcoKSwKICAgIGR1cAogICAgYXNzZXRfcGFyYW1zX2dldCBBc3NldFVuaXROYW1lCiAgICBzd2FwCiAgICBidXJ5IDkKICAgIGFzc2VydCAvLyBhc3NldCBleGlzdHMKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjY5CiAgICAvLyBkZWNpbWFsczogbmV3IFVpbnQ4KGFzc2V0LmRlY2ltYWxzKSwKICAgIGFzc2V0X3BhcmFtc19nZXQgQXNzZXREZWNpbWFscwogICAgYXNzZXJ0IC8vIGFzc2V0IGV4aXN0cwogICAgaXRvYgogICAgZHVwCiAgICBiaXRsZW4KICAgIGludGNfMiAvLyA4CiAgICA8PQogICAgYXNzZXJ0IC8vIG92ZXJmbG93CiAgICBleHRyYWN0IDcgMQogICAgYnVyeSA5CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo3MAogICAgLy8gbGFiZWxzOiBwdiA9PT0gMCA/IChbXSBhcyBzdHJpbmdbXSkgOiBbInB2Il0sCiAgICBibnogZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X2ZhbHNlQDExCiAgICBwdXNoYnl0ZXMgMHgwMDAwCgpnZXRBc3NldHNUaW55X3Rlcm5hcnlfbWVyZ2VAMTI6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo2Ni03MQogICAgLy8gY29uc3QgYXNzZXRJbmZvOiBBc3NldFRpbnlMYWJlbHMgPSB7CiAgICAvLyAgIG5hbWU6IGFzc2V0Lm5hbWUudG9TdHJpbmcoKSwKICAgIC8vICAgdW5pdF9uYW1lOiBhc3NldC51bml0TmFtZS50b1N0cmluZygpLAogICAgLy8gICBkZWNpbWFsczogbmV3IFVpbnQ4KGFzc2V0LmRlY2ltYWxzKSwKICAgIC8vICAgbGFiZWxzOiBwdiA9PT0gMCA/IChbXSBhcyBzdHJpbmdbXSkgOiBbInB2Il0sCiAgICAvLyB9OwogICAgZGlnIDcKICAgIGR1cAogICAgbGVuCiAgICBpdG9iCiAgICBleHRyYWN0IDYgMgogICAgc3dhcAogICAgY29uY2F0CiAgICBkdXAKICAgIGxlbgogICAgcHVzaGludCA3IC8vIDcKICAgICsKICAgIGRpZyA4CiAgICBkdXAKICAgIGxlbgogICAgaXRvYgogICAgZXh0cmFjdCA2IDIKICAgIHN3YXAKICAgIGNvbmNhdAogICAgZGlnIDEKICAgIGl0b2IKICAgIGV4dHJhY3QgNiAyCiAgICBwdXNoYnl0ZXMgMHgwMDA3CiAgICBzd2FwCiAgICBjb25jYXQKICAgIGRpZyAxCiAgICBsZW4KICAgIHVuY292ZXIgMwogICAgKwogICAgc3dhcAogICAgZGlnIDEyCiAgICBjb25jYXQKICAgIHN3YXAKICAgIGl0b2IKICAgIGV4dHJhY3QgNiAyCiAgICBjb25jYXQKICAgIHVuY292ZXIgMgogICAgY29uY2F0CiAgICBzd2FwCiAgICBjb25jYXQKICAgIHN3YXAKICAgIGNvbmNhdAogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NzIKICAgIC8vIGxvZyhlbmNvZGVBcmM0KGFzc2V0SW5mbykpOwogICAgbG9nCiAgICBiIGdldEFzc2V0c1RpbnlfYWZ0ZXJfaWZfZWxzZUAxMwoKZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X2ZhbHNlQDExOgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NzAKICAgIC8vIGxhYmVsczogcHYgPT09IDAgPyAoW10gYXMgc3RyaW5nW10pIDogWyJwdiJdLAogICAgcHVzaGJ5dGVzIDB4MDAwMTAwMDIwMDAyNzA3NgogICAgYiBnZXRBc3NldHNUaW55X3Rlcm5hcnlfbWVyZ2VAMTIKCmdldEFzc2V0c1RpbnlfdGVybmFyeV9mYWxzZUA4OgogICAgLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6NjUKICAgIC8vIGFiZWxBcHBJZCAhPT0gMCA/IGNvbXBpbGVBcmM0KEFiZWxTdHViKS5jYWxsLmhhc19hc3NldF9sYWJlbCh7IGFwcElkOiBhYmVsQXBwSWQsIGFyZ3M6IFthc3NldC5pZCwgInB2Il0gfSkucmV0dXJuVmFsdWUgOiAwOwogICAgaW50Y18wIC8vIDAKICAgIGIgZ2V0QXNzZXRzVGlueV90ZXJuYXJ5X21lcmdlQDkKCmdldEFzc2V0c1RpbnlfYWZ0ZXJfd2hpbGVAMTQ6CiAgICAvLyBzbWFydF9jb250cmFjdHMvYWJlbF9yZWFkZXIvY29udHJhY3QuYWxnby50czo1NgogICAgLy8gQGFiaW1ldGhvZCh7IHJlYWRvbmx5OiB0cnVlLCBvbkNyZWF0ZTogImFsbG93IiB9KQogICAgcHVzaGJ5dGVzIDB4MTUxZjdjNzUwMDA3MDAwOTAwMDAwYjAwMDAwMDAwMDAwMAogICAgbG9nCiAgICBpbnRjXzEgLy8gMQogICAgcmV0dXJuCgoKLy8gc21hcnRfY29udHJhY3RzL2FiZWxfcmVhZGVyL2NvbnRyYWN0LmFsZ28udHM6OkFiZWxSZWFkZXIuZ2V0QXNzZXRMYWJlbHNbcm91dGluZ10oKSAtPiB2b2lkOgpnZXRBc3NldExhYmVsczoKICAgIC8vIHNtYXJ0X2NvbnRyYWN0cy9hYmVsX3JlYWRlci9jb250cmFjdC5hbGdvLnRzOjc4CiAgICAvLyBAYWJpbWV0aG9kKHsgcmVhZG9ubHk6IHRydWUsIG9uQ3JlYXRlOiAiYWxsb3ciLCBuYW1lOiAiZ2V0X2Fzc2V0X2xhYmVscyIsIHJlc291cmNlRW5jb2Rpbmc6ICJpbmRleCIgfSkKICAgIHR4bmEgQXBwbGljYXRpb25BcmdzIDEKICAgIGxlbgogICAgaW50Y18xIC8vIDEKICAgID09CiAgICBhc3NlcnQgLy8gaW52YWxpZCBudW1iZXIgb2YgYnl0ZXMgZm9yIGFyYzQudWludDgKICAgIHB1c2hieXRlcyAweDE1MWY3Yzc1MDAwMAogICAgbG9nCiAgICBpbnRjXzEgLy8gMQogICAgcmV0dXJuCg==",clear:"I3ByYWdtYSB2ZXJzaW9uIDExCiNwcmFnbWEgdHlwZXRyYWNrIGZhbHNlCgovLyBAYWxnb3JhbmRmb3VuZGF0aW9uL2FsZ29yYW5kLXR5cGVzY3JpcHQvYmFzZS1jb250cmFjdC5kLnRzOjpCYXNlQ29udHJhY3QuY2xlYXJTdGF0ZVByb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW46CiAgICBwdXNoaW50IDEgLy8gMQogICAgcmV0dXJuCg=="},byteCode:{approval:"CyAFAAEIIAAxG0EAITEZFESCAwRId6lnBNWrM2YEwu10PzYaAI4DAB8AkwG6ACMxGZCBMBoxGBBEIQQjEkEACjEAMgkSQQACI0MiQyKAADYaAUcCIllJTgIlC4ECCEwVEkQiSUsCDEEAPUsCVwIASwElCyVYSUUGYElFBUEAEksEeEsEFkwWULBJIwhFAUL/0oAQAAAAAAAAAAAAAAAAAAAAALBC/+KAFBUffHUAAAAAAAAAAAAAAAAAAAAAsCNDIkcDgAA2GgFHAiJZSU4CJAuBAghMFRJENhoCSRUkEkQXIklLAwxBAOhLA1cCAEsBJAtKJFhFC1tJRQZxC0UBQAAYgA0ABwAJAAALAAAAAAAAsEkjCEUBQv/ISwFBAK6xgASX9AqKshpLCLIagAQAAnB2shoishlLAbIYgQayECKyAbO0PklXBABMVwAEgAQVH3x1EkRJFSQSRBdLBUlxBExFCkRJcQNMRQlEcQFEFkmTJA5EVwcBRQlAAESAAgAASwdJFRZXBgJMUEkVgQcISwhJFRZXBgJMUEsBFlcGAoACAAdMUEsBFU8DCExLDFBMFlcGAlBPAlBMUExQsEL/UoAIAAEAAgACcHZC/7MiQv+KgBEVH3x1AAcACQAACwAAAAAAALAjQzYaARUjEkSABhUffHUAALAjQw==",clear:"C4EBQw=="},events:[],templateVariables:{UPDATABLE:{type:"AVMUint64"}}};class Kt{static get create(){return{_resolveByMethod(e){switch(e.method){case"getBalanceInfo":case"getBalanceInfo(address[])(uint64,uint64)":return Kt.create.getBalanceInfo(e);case"getAssetsTiny":case"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])":return Kt.create.getAssetsTiny(e);case"get_asset_labels":case"get_asset_labels(asset)string[]":return Kt.create.getAssetLabels(e)}throw new Error("Unknown ' + verb + ' method")},getBalanceInfo(e){return{...e,method:"getBalanceInfo(address[])(uint64,uint64)",args:Array.isArray(e.args)?e.args:[e.args.accounts]}},getAssetsTiny(e){return{...e,method:"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",args:Array.isArray(e.args)?e.args:[e.args.assetIds,e.args.abelAppId]}},getAssetLabels(e){return{...e,method:"get_asset_labels(asset)string[]",args:Array.isArray(e.args)?e.args:[e.args.assetId]}}}}static getBalanceInfo(e){return{...e,method:"getBalanceInfo(address[])(uint64,uint64)",args:Array.isArray(e.args)?e.args:[e.args.accounts]}}static getAssetsTiny(e){return{...e,method:"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",args:Array.isArray(e.args)?e.args:[e.args.assetIds,e.args.abelAppId]}}static getAssetLabels(e){return{...e,method:"get_asset_labels(asset)string[]",args:Array.isArray(e.args)?e.args:[e.args.assetId]}}}class aw{constructor(e){dt(this,"appFactory");dt(this,"params",{create:{getBalanceInfo:e=>this.appFactory.params.create(Kt.create.getBalanceInfo(e)),getAssetsTiny:e=>this.appFactory.params.create(Kt.create.getAssetsTiny(e)),getAssetLabels:e=>this.appFactory.params.create(Kt.create.getAssetLabels(e))},deployUpdate:{bare:e=>this.appFactory.params.bare.deployUpdate(e)},deployDelete:{bare:e=>this.appFactory.params.bare.deployDelete(e)}});dt(this,"createTransaction",{create:{getBalanceInfo:e=>this.appFactory.createTransaction.create(Kt.create.getBalanceInfo(e)),getAssetsTiny:e=>this.appFactory.createTransaction.create(Kt.create.getAssetsTiny(e)),getAssetLabels:e=>this.appFactory.createTransaction.create(Kt.create.getAssetLabels(e))}});dt(this,"send",{create:{getBalanceInfo:async e=>{const t=await this.appFactory.send.create(Kt.create.getBalanceInfo(e));return{result:{...t.result,return:t.result.return},appClient:new Fr(t.appClient)}},getAssetsTiny:async e=>{const t=await this.appFactory.send.create(Kt.create.getAssetsTiny(e));return{result:{...t.result,return:t.result.return},appClient:new Fr(t.appClient)}},getAssetLabels:async e=>{const t=await this.appFactory.send.create(Kt.create.getAssetLabels(e));return{result:{...t.result,return:t.result.return},appClient:new Fr(t.appClient)}}}});this.appFactory=new eS({...e,appSpec:mr})}get appName(){return this.appFactory.appName}get appSpec(){return mr}get algorand(){return this.appFactory.algorand}getAppClientById(e){return new Fr(this.appFactory.getAppClientById(e))}async getAppClientByCreatorAndName(e){return new Fr(await this.appFactory.getAppClientByCreatorAndName(e))}async deploy(e={}){var r;const t=await this.appFactory.deploy({...e,createParams:(r=e.createParams)!=null&&r.method?Kt.create._resolveByMethod(e.createParams):e.createParams?e.createParams:void 0});return{result:t.result,appClient:new Fr(t.appClient)}}}class Fr{constructor(e){dt(this,"appClient");dt(this,"params",{update:{bare:e=>this.appClient.params.bare.update(e)},delete:{bare:e=>this.appClient.params.bare.delete(e)},clearState:e=>this.appClient.params.bare.clearState(e),getBalanceInfo:e=>this.appClient.params.call(Kt.getBalanceInfo(e)),getAssetsTiny:e=>this.appClient.params.call(Kt.getAssetsTiny(e)),getAssetLabels:e=>this.appClient.params.call(Kt.getAssetLabels(e))});dt(this,"createTransaction",{update:{bare:e=>this.appClient.createTransaction.bare.update(e)},delete:{bare:e=>this.appClient.createTransaction.bare.delete(e)},clearState:e=>this.appClient.createTransaction.bare.clearState(e),getBalanceInfo:e=>this.appClient.createTransaction.call(Kt.getBalanceInfo(e)),getAssetsTiny:e=>this.appClient.createTransaction.call(Kt.getAssetsTiny(e)),getAssetLabels:e=>this.appClient.createTransaction.call(Kt.getAssetLabels(e))});dt(this,"send",{update:{bare:e=>this.appClient.send.bare.update(e)},delete:{bare:e=>this.appClient.send.bare.delete(e)},clearState:e=>this.appClient.send.bare.clearState(e),getBalanceInfo:async e=>{const t=await this.appClient.send.call(Kt.getBalanceInfo(e));return{...t,return:t.return}},getAssetsTiny:async e=>{const t=await this.appClient.send.call(Kt.getAssetsTiny(e));return{...t,return:t.return}},getAssetLabels:async e=>{const t=await this.appClient.send.call(Kt.getAssetLabels(e));return{...t,return:t.return}}});dt(this,"state",{});this.appClient=e instanceof cn?e:new cn({...e,appSpec:mr})}decodeReturnValue(e,t){return t!==void 0?Ys(t,this.appClient.getABIMethod(e),mr.structs):void 0}static async fromCreatorAndName(e){return new Fr(await cn.fromCreatorAndName({...e,appSpec:mr}))}static async fromNetwork(e){return new Fr(await cn.fromNetwork({...e,appSpec:mr}))}get appId(){return this.appClient.appId}get appAddress(){return this.appClient.appAddress}get appName(){return this.appClient.appName}get appSpec(){return this.appClient.appSpec}get algorand(){return this.appClient.algorand}clone(e){return new Fr(this.appClient.clone(e))}async getBalanceInfo(e){return(await this.appClient.send.call(Kt.getBalanceInfo(e))).return}async getAssetsTiny(e){return(await this.appClient.send.call(Kt.getAssetsTiny(e))).return}async getAssetLabels(e){return(await this.appClient.send.call(Kt.getAssetLabels(e))).return}newGroup(){const e=this,t=this.algorand.newGroup();let r=Promise.resolve();const i=[];return{getBalanceInfo(o){return r=r.then(async()=>t.addAppCallMethodCall(await e.params.getBalanceInfo(o))),i.push(s=>e.decodeReturnValue("getBalanceInfo(address[])(uint64,uint64)",s)),this},getAssetsTiny(o){return r=r.then(async()=>t.addAppCallMethodCall(await e.params.getAssetsTiny(o))),i.push(s=>e.decodeReturnValue("getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",s)),this},getAssetLabels(o){return r=r.then(async()=>t.addAppCallMethodCall(await e.params.getAssetLabels(o))),i.push(s=>e.decodeReturnValue("get_asset_labels(asset)string[]",s)),this},get update(){return{bare:o=>(r=r.then(async()=>t.addAppUpdate(await e.params.update.bare(o))),this)}},get delete(){return{bare:o=>(r=r.then(()=>t.addAppDelete(e.params.delete.bare(o))),this)}},clearState(o){return r=r.then(()=>t.addAppCall(e.params.clearState(o))),this},addTransaction(o,s){return r=r.then(()=>t.addTransaction(o,s)),this},async composer(){return await r,t},async simulate(o){var a;await r;const s=await(o?t.simulate(o):t.simulate());return{...s,returns:(a=s.returns)==null?void 0:a.map((l,c)=>i[c]!==void 0?i[c](l):l.returnValue)}},async send(o){var a;await r;const s=await t.send(o);return{...s,returns:(a=s.returns)==null?void 0:a.map((l,c)=>i[c]!==void 0?i[c](l):l.returnValue)}}}}}const sf=Mx();class Wp{constructor({algorand:e,readerAccount:t,ghostAppId:r}){dt(this,"algorand");dt(this,"readerAccount","A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE");dt(this,"ghostAppId");dt(this,"factory");dt(this,"client");dt(this,"cacheParamsTimeout",75);this.algorand=e,t&&(this.readerAccount=t),this.factory=this.algorand.client.getTypedAppFactory(aw,{defaultSender:this.readerAccount}),this.ghostAppId=r,this.client=this.factory.getAppClientById({appId:r??13n})}async getAndCacheSuggestedParams(){const e=await this.algorand.getSuggestedParams();return this.cacheParamsTimeout&&this.algorand.setSuggestedParamsCache(e,new Date(Date.now()+this.cacheParamsTimeout)),e}async execute({signature:e,txnBuilder:t,methodArgsOrArgsArray:r,extraMethodCallArgs:i,extraSimulateArgs:o}){var h;await this.getAndCacheSuggestedParams();const s=e.slice(0,e.indexOf("("));let a=this.client.newGroup();if(this.ghostAppId){const x=Array.isArray(r)?r:[r];for(let A=0;A<x.length;A++){const v=x[A],F=Array.isArray(i)?i[A]:i;a=t(a,{args:v,signer:sf,...F})}}else{let x=this.client.newGroup();const A=Array.isArray(r)?r:[r];for(let F=0;F<A.length;F++){const w=A[F],C=Array.isArray(i)?i[F]:i;x=t(x,{args:w,signer:sf,...C})}const{transactions:v}=await(await x.composer()).buildTransactions();for(const F of v)F.applicationCall={...F.applicationCall,appIndex:0,approvalProgram:Buffer.from(mr.byteCode.approval,"base64"),clearProgram:Buffer.from(mr.byteCode.clear,"base64"),numGlobalByteSlices:mr.state.schema.global.bytes,numGlobalInts:mr.state.schema.global.ints,numLocalByteSlices:mr.state.schema.local.bytes,numLocalInts:mr.state.schema.local.ints,extraPages:3},a=a.addTransaction(F,sf)}const{confirmations:l}=await a.simulate({extraOpcodeBudget:17e4,allowMoreLogging:!0,allowEmptySignatures:!0,allowUnnamedResources:!0,...o}),c=l.flatMap(({logs:x},A)=>{if(!x)throw new Error(`logs were not returned from simulate txn ${A}. this should never happen`);return x.slice(0,-1)}),d=(h=this.client.appSpec.methods.find(({name:x})=>x===s))==null?void 0:h.returns;if(!d)throw new Error("Method not found in app spec");const u=d.struct??d.type,m=[];for(let x=0;x<c.length;x++)m.push(qn(new Uint8Array(c[x]),u,this.factory.appSpec.structs));return m}}dt(Wp,"factory",aw),dt(Wp,"client",Fr);class cw extends Wp{constructor(e){super(e)}async getBalanceInfo({methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r}){return this.execute({signature:"getBalanceInfo(address[])(uint64,uint64)",txnBuilder:(i,o)=>i.getBalanceInfo(o),methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r})}async getAssetsTiny({methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r}){return this.execute({signature:"getAssetsTiny(uint64[],uint64)(string,string,uint8,string[])",txnBuilder:(i,o)=>i.getAssetsTiny(o),methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r})}async get_asset_labels({methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r}){return this.execute({signature:"get_asset_labels(asset)string[]",txnBuilder:(i,o)=>i.getAssetLabels(o),methodArgsOrArgsArray:e,extraMethodCallArgs:t,extraSimulateArgs:r})}}async function aR(n,e,{concurrency:t=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((o,s)=>{if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(t)&&t>=1||t===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`);const a=[],l=[],c=new Map;let d=!1,u=!1,m=!1,h=0,x=0;const A=n[Symbol.iterator]===void 0?n[Symbol.asyncIterator]():n[Symbol.iterator](),v=()=>{C(i.reason)},F=()=>{i==null||i.removeEventListener("abort",v)},w=N=>{o(N),F()},C=N=>{d=!0,u=!0,s(N),F()};i&&(i.aborted&&C(i.reason),i.addEventListener("abort",v,{once:!0}));const M=async()=>{if(u)return;const N=await A.next(),b=x;if(x++,N.done){if(m=!0,h===0&&!u){if(!r&&l.length>0){C(new AggregateError(l));return}if(u=!0,c.size===0){w(a);return}const j=[];for(const[p,E]of a.entries())c.get(p)!==lw&&j.push(E);w(j)}return}h++,(async()=>{try{const j=await N.value;if(u)return;const p=await e(j,b);p===lw&&c.set(b,p),a[b]=p,h--,await M()}catch(j){if(r)C(j);else{l.push(j),h--;try{await M()}catch(p){C(p)}}}})()};(async()=>{for(let N=0;N<t;N++){try{await M()}catch(b){C(b);break}if(m||d)break}})()})}const lw=Symbol("skip");function cR(n,e){const t=[];let r=0;for(;r<n.length;)t.push(n.slice(r,e+r)),r+=e;return t}function tS(n,e=0){return function(t,r,i){const o=i.value;return i.value=async function(...s){if(s[e].length<=n)return o.apply(this,s);const a=this&&typeof this.concurrency=="number"?this.concurrency:2,l=cR(s[e],n);return(await aR(l,async d=>{const u=e===0?[d,...s.slice(1)]:[...s.slice(0,e),d,...s.slice(e+1)];return o.apply(this,u)},{concurrency:a})).flat()},i}}var nS=function(n,e,t,r){var i=arguments.length,o=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(e,t,o):s(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o};class uh{constructor({algorand:e,registryAppId:t,concurrency:r=4,ghostAppId:i,readerAccount:o}){dt(this,"algorand");dt(this,"registryAppId");dt(this,"baseSDK");dt(this,"concurrency");this.algorand=e,this.registryAppId=t!==void 0?BigInt(t):void 0,this.concurrency=r,this.baseSDK=new cw({algorand:this.algorand,readerAccount:o??"A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE",ghostAppId:i})}async getBalanceInfo(e){const t=await this.getBalanceInfoInternal(e);return new Map(t.map((r,i)=>[e[i],r]))}async getBalanceInfoInternal(e){return this.baseSDK.getBalanceInfo({methodArgsOrArgsArray:{accounts:e}})}async getAssetsTinyLabels(e){const t=await this.getAssetsTinyLabelsInternal(e);return new Map(t.map((r,i)=>[BigInt(e[i]),{...r,id:BigInt(e[i])}]))}async getAssetsTinyLabelsInternal(e){return this.baseSDK.getAssetsTiny({methodArgsOrArgsArray:{assetIds:e,abelAppId:this.registryAppId??0n},extraMethodCallArgs:{extraFee:(e.length*1e3).microAlgo()}})}async getAssetLabels(e){if(!this.registryAppId)return[];const{return:t}=await this.baseSDK.factory.getAppClientById({appId:this.registryAppId}).send.getAssetLabels({args:{assetId:BigInt(e)}});return t??[]}async getAllAssetIDs(){return this.registryAppId?(await this.getBoxesByLength(8)).map(e=>G0(e.nameRaw,"bigint")):[]}async getBoxesByLength(e){return this.registryAppId?(await this.algorand.app.getBoxNames(this.registryAppId)).filter(r=>r.nameRaw.length===e):[]}}dt(uh,"baseSDK",cw);nS([tS(63)],uh.prototype,"getBalanceInfoInternal",null);nS([tS(63)],uh.prototype,"getAssetsTinyLabelsInternal",null);const lR=2914159523n,uR=3381542955n,dR="Y76M3MSY6DKBRHBL7C3NNDXGS5IIMQVQVUAB6MP4XEMMGVF2QWNPL226CA",hR=1440*60*1e3,uw=200,fR={usdc:31566704};function pR(){const{algodClient:n}=yn.useWallet(),{activeNetwork:e}=yn.useNetwork(),[t,r]=Y.useState(!1),[i,o]=Y.useState(!1),[s,a]=Y.useState(null),l=Y.useRef(!1),c=e==="mainnet";Y.useEffect(()=>{if(!c||!n||l.current)return;let u=!1;return(async()=>{try{const h=await Du.getLastUpdated();if(h&&Date.now()-h<hR){o(!0);return}l.current=!0,r(!0),a(null);const x=Ri.fromClients({algod:n}),A=new uh({algorand:x,concurrency:7,registryAppId:lR,ghostAppId:uR,readerAccount:dR}),v=await A.getAllAssetIDs();if(u)return;for(let F=0;F<v.length;F+=uw){if(u)return;const w=v.slice(F,F+uw),C=await A.getAssetsTinyLabels(w),M=[];for(const[N,b]of C)M.push({index:Number(N),name:b.name,unitName:b.unitName,decimals:b.decimals,peraVerified:b.labels.includes("pv")});await Du.insertMany(M)}if(u)return;await Du.setLastUpdated(Date.now()),o(!0)}catch(h){u||a(h instanceof Error?h.message:"Failed to load asset registry")}finally{u||(r(!1),l.current=!1)}})(),()=>{u=!0}},[c,n]);const d=Y.useCallback(async(u,m)=>{const h=await Du.searchByName(u,m);if(!c)return h;const x=u.trim().toLowerCase(),A=fR[x];if(A==null)return h;const v=h.find(F=>F.index===A);return v?[v]:h},[c]);return{registryLoading:t,registryLoaded:i,registryError:s,searchByName:d}}function rS(n={}){const{enabled:e=!0}=n,{algodClient:t}=yn.useWallet(),[r,i]=Y.useState(""),[o,s]=Y.useState(null),[a,l]=Y.useState(!1),[c,d]=Y.useState(null),u=Y.useCallback(()=>{i(""),s(null),l(!1),d(null)},[]);return Y.useEffect(()=>{s(null),d(null);const m=parseInt(r,10);if(!r||isNaN(m)||m<=0||!t||!e){l(!1);return}l(!0);const h=setTimeout(async()=>{try{const x=await t.getAssetByID(m).do();s({index:Number(x.index),name:x.params.name||"Unnamed Asset",unitName:x.params.unitName||"",decimals:x.params.decimals})}catch{d("Asset not found")}finally{l(!1)}},500);return()=>clearTimeout(h)},[r,t,e]),{assetIdInput:r,setAssetIdInput:i,assetInfo:o,isLoading:a,error:c,reset:u}}function gR(n){const[e,t]=Y.useState(""),[r,i]=Y.useState([]),[o,s]=Y.useState(!1),[a,l]=Y.useState(null),c=Y.useCallback(x=>{t(x),l(null)},[]),d=Y.useRef(null),u=Y.useRef(n.searchByName);u.current=n.searchByName,Y.useEffect(()=>{if(d.current&&clearTimeout(d.current),!e.trim()){i([]),s(!1);return}return s(!0),d.current=setTimeout(async()=>{try{const x=await u.current(e.trim());i(x)}catch{i([])}finally{s(!1)}},300),()=>{d.current&&clearTimeout(d.current)}},[e]);const m=Y.useCallback(x=>{l(x),i([])},[]),h=Y.useCallback(()=>{t(""),i([]),l(null),s(!1)},[]);return{nameInput:e,setNameInput:c,results:r,isSearching:o,selectedAsset:a,selectAsset:m,reset:h}}function af(n){return/^\d*$/.test(n)}function mR(n,e=new Set){const{activeAddress:t,algodClient:r,signTransactions:i}=yn.useWallet(),o=Ls(),s=rS(),a=gR(n),[l,c]=Y.useState("idle"),[d,u]=Y.useState(null),[m,h]=Y.useState(null),[x,A]=Y.useState(""),v=!af(x),F=Y.useCallback(()=>{A(""),s.reset(),a.reset(),h(null),c("idle"),u(null)},[s,a]),w=Y.useCallback(()=>{c("idle"),u(null)},[]),C=Y.useCallback(N=>{A(N),af(N)?(s.setAssetIdInput(N),a.reset()):(s.setAssetIdInput(""),a.setNameInput(N))},[s,a]),M=Y.useCallback(async()=>{var j,p;const b=!af(x)?(j=a.selectedAsset)==null?void 0:j.index:(p=s.assetInfo)==null?void 0:p.index;if(!(!b||!t||!r)){c("signing"),u(null),h(null);try{const E=await r.getTransactionParams().do(),S=Le.makeAssetTransferTxnWithSuggestedParamsFromObject({sender:t,receiver:t,amount:0,assetIndex:b,suggestedParams:E}),B=(await i([S.toByte()]))[0];if(!B)throw new Error("Transaction was not signed");c("sending");const P=S.txID();await r.sendRawTransaction(B).do(),await Le.waitForConfirmation(r,P,4),o.invalidateQueries({queryKey:["account-info"]}),h(P),c("success")}catch(E){c("error"),u(E instanceof Error?E.message:"Opt-in failed")}}},[x,a.selectedAsset,s.assetInfo,t,r,i,o]);return{activeAddress:t??null,optedInAssetIds:e,assetIdInput:x,setAssetIdInput:C,assetInfo:s.assetInfo,assetLookupLoading:s.isLoading,assetLookupError:s.error,txId:m,status:l,error:d,handleOptIn:M,reset:F,retry:w,nameSearchResults:a.results,nameSearchLoading:a.isSearching,registryLoading:n.registryLoading,selectedNameAsset:a.selectedAsset,onSelectNameAsset:a.selectAsset,isNameMode:v}}function dw(n,e){const[t="0",r=""]=n.split("."),i=r.slice(0,e).padEnd(e,"0"),o=parseInt(t+i,10);if(isNaN(o)||o<=0)throw new Error("Invalid amount");return o}function yR(){const{activeAddress:n,algodClient:e,signTransactions:t}=yn.useWallet(),r=Ls(),[i,o]=Y.useState("algo"),[s,a]=Y.useState(""),[l,c]=Y.useState(""),[d,u]=Y.useState("idle"),[m,h]=Y.useState(null),[x,A]=Y.useState(null),v=rS({enabled:i==="asa"}),[F,w]=Y.useState("idle"),C=s.length>0&&!Le.isValidAddress(s)?"Invalid Algorand address":null,M=v.assetIdInput;Y.useEffect(()=>{if(i!=="asa"||!M||!s||!e){w("idle");return}let p=!1;try{p=Le.isValidAddress(s)}catch{}if(!p){w("idle");return}w("checking");let E=!1;const S=setTimeout(async()=>{var $;try{const B=await e.accountInformation(s).do();if(E)return;const P=Number(M),W=($=B.assets)==null?void 0:$.some(L=>Number(L.assetId)===P);w(W?"opted-in":"not-opted-in")}catch{E||w("idle")}},500);return()=>{E=!0,clearTimeout(S)}},[i,M,s,e]);const N=Y.useCallback(()=>{o("algo"),a(""),c(""),v.reset(),w("idle"),A(null),u("idle"),h(null)},[v]),b=Y.useCallback(()=>{u("idle"),h(null)},[]),j=Y.useCallback(async()=>{if(!(!n||!e||!s||!l)){u("signing"),h(null),A(null);try{const p=await e.getTransactionParams().do();let E;if(i==="algo"){const P=dw(l,6);E=Le.makePaymentTxnWithSuggestedParamsFromObject({sender:n,receiver:s,amount:P,suggestedParams:p})}else{if(!v.assetInfo)throw new Error("No asset selected");const P=dw(l,v.assetInfo.decimals);E=Le.makeAssetTransferTxnWithSuggestedParamsFromObject({sender:n,receiver:s,amount:P,assetIndex:v.assetInfo.index,suggestedParams:p})}const $=(await t([E.toByte()]))[0];if(!$)throw new Error("Transaction was not signed");u("sending");const B=E.txID();await e.sendRawTransaction($).do(),await Le.waitForConfirmation(e,B,4),r.invalidateQueries({queryKey:["account-info"]}),A(B),u("success")}catch(p){u("error"),h(p instanceof Error?p.message:"Send failed")}}},[i,l,s,v.assetInfo,n,e,t,r]);return{sendType:i,setSendType:o,receiver:s,setReceiver:a,amount:l,setAmount:c,assetIdInput:v.assetIdInput,setAssetIdInput:v.setAssetIdInput,assetInfo:v.assetInfo,assetLookupLoading:v.isLoading,assetLookupError:v.error,receiverOptInStatus:F,receiverAddressError:C,txId:x,status:d,error:m,handleSend:j,reset:N,retry:b}}function wR({children:n}){var re;const{activeAddress:e,activeWallet:t,algodClient:r}=yn.useWallet(),{theme:i}=ti(),o=Ls(),s=T1(),[a,l]=Y.useState(!1),[c,d]=Y.useState("main"),[u,m]=Y.useState(!1),{activeNetwork:h}=yn.useNetwork(),x=pR(),A=yR(),[v,F]=Y.useState(()=>{const H=localStorage.getItem("uwui:balance-preference");return H?H==="available":!1}),w=i==="system"?void 0:i,C=xg({enabled:!!e}),M=((re=C.data)==null?void 0:re.name)??null,{data:N}=qv({enabled:!!e}),b=Y.useMemo(()=>!N||N.amount===void 0?null:Number(N.amount)/1e6,[N]),j=Y.useMemo(()=>{if(!N||N.amount===void 0||N.minBalance===void 0)return null;const H=Number(N.amount)-Number(N.minBalance);return Math.max(0,H/1e6)},[N]),p=v?j:b,E=Y.useMemo(()=>N!=null&&N.assets?N.assets:[],[N]),S=Y.useMemo(()=>E.map(H=>String(H.assetId)),[E]),$=Y.useMemo(()=>new Set(E.map(H=>Number(H.assetId))),[E]),B=Y.useMemo(()=>{var H,Z;return((Z=(H=t==null?void 0:t.activeAccount)==null?void 0:H.metadata)==null?void 0:Z.evmAddress)??null},[t]),P=mR(x,$),{assets:W}=_x(S,r),L=Y.useMemo(()=>E.map(H=>{const Z=W[String(H.assetId)];if(!Z)return null;const ce=BigInt(H.amount);let Q;if(Z.decimals===0)Q=ce.toString();else{const se=10n**BigInt(Z.decimals),ue=ce/se,ae=ce%se;if(ae===0n)Q=ue.toString();else{const xe=ae.toString().padStart(Z.decimals,"0").replace(/0+$/,"");Q=`${ue}.${xe}`}}return{assetId:Number(H.assetId),name:Z.name||`ASA#${H.assetId}`,unitName:Z.unitName,amount:Q}}).filter(H=>H!==null),[E,W]),{refs:q,floatingStyles:J,context:U}=Ld({open:a,onOpenChange:H=>{l(H),H||(d("main"),P.reset(),A.reset())},placement:"bottom-end",middleware:[Xp(8),f0(),h0()],whileElementsMounted:l0}),ne=w0(U),fe=Od(U,{outsidePressEvent:"mousedown"}),{getReferenceProps:le,getFloatingProps:ye}=Vd([ne,fe]),he=Yr(),de=()=>{e&&(navigator.clipboard.writeText(e),m(!0),setTimeout(()=>m(!1),2e3))},be=async()=>{if(t)try{await t.disconnect(),l(!1)}catch(H){console.error("Error disconnecting wallet:",H)}},Ae=H=>{t&&t.setActiveAccount&&t.setActiveAccount(H)},_e=()=>{const H=!v;F(H),localStorage.setItem("uwui:balance-preference",H?"available":"total")},De=Y.useCallback(H=>{if(!H||!h)return null;const ce=dy(h,"transaction")[0];return ce?ce.getUrl(h,"transaction",H):null},[h]),Te=Y.useMemo(()=>{if(!e||!h)return;const Z=dy(h,"account")[0];if(!Z)return;const ce=Z.getUrl(h,"account",e);if(ce)return()=>window.open(ce,"_blank","noopener,noreferrer")},[e,h]),T=D.jsx("div",{className:"mb-4 bg-[var(--wui-color-bg-secondary)] rounded-lg p-3",children:D.jsxs("div",{className:"flex justify-between items-center",children:[p!==null&&D.jsxs("span",{className:"text-base font-medium text-[var(--wui-color-text)] flex items-center gap-1",children:[w2(p,{fractionDigits:4}),D.jsx(Ux,{})]}),D.jsxs("button",{onClick:_e,className:"flex items-center gap-1 text-sm text-[var(--wui-color-text-secondary)] bg-[var(--wui-color-bg-tertiary)] py-1 pl-2.5 pr-2 rounded-md hover:brightness-90 transition-all focus:outline-none",title:v?"Show total balance":"Show available balance",children:[v?"Available":"Total",D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-0.5 opacity-80",children:[D.jsx("path",{d:"m17 10-5-5-5 5"}),D.jsx("path",{d:"m17 14-5 5-5-5"})]})]})]})}),G=n||D.jsx(ih,{}),X=Y.cloneElement(G,le({ref:q.setReference}));return D.jsxs(D.Fragment,{children:[X,a&&D.jsx(uu,{children:D.jsx(Pd,{context:U,modal:!1,children:D.jsx("div",{"data-wallet-theme":!0,"data-wallet-ui":!0,"data-theme":w,children:D.jsx("div",{ref:q.setFloating,style:{...J,width:c==="main"?320:"min(420px, 95vw)"},...ye(),role:"menu","aria-labelledby":he,className:"z-50 rounded-xl bg-[var(--wui-color-bg)] shadow-xl border border-[var(--wui-color-border)] transition-[width] duration-200 ease-in-out",children:D.jsx("div",{className:"p-4",children:c==="main"?D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[D.jsx("div",{className:"h-12 w-12 overflow-hidden",children:D.jsx(vg,{nfd:C.data,alt:`${M||e} avatar`,size:48})}),D.jsxs("div",{children:[D.jsx("h3",{id:he,className:"text-lg font-bold text-[var(--wui-color-text)] max-w-[220px] truncate wallet-custom-font",children:M||(e?pr(e,6,4):"My Wallet")}),M&&e&&D.jsx("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:pr(e,6,4)})]})]}),T,t&&t.accounts&&t.accounts.length>1&&D.jsx("div",{className:"mb-4",children:D.jsxs(gM,{value:e||"",onChange:Ae,children:[D.jsx(Sv,{className:"block text-sm font-medium text-[var(--wui-color-text-secondary)] mb-1",children:"Select Account"}),D.jsxs("div",{className:"relative mt-1",children:[D.jsxs(Hv,{className:"grid w-full cursor-default grid-cols-1 rounded-lg border border-[var(--wui-color-border)] bg-[var(--wui-color-bg-secondary)] py-2 px-3 text-left text-[var(--wui-color-text)] shadow-sm focus:outline-none focus:ring-2 focus:ring-[var(--wui-color-primary)] focus:border-transparent text-sm",children:[D.jsx("span",{className:"col-start-1 row-start-1 truncate pr-8",children:e?pr(e,6,4):"Select account"}),D.jsx("span",{className:"col-start-1 row-start-1 self-center justify-self-end",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"text-[var(--wui-color-text-secondary)]","aria-hidden":"true",children:D.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),D.jsx(Yv,{transition:!0,className:"absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-[var(--wui-color-bg-secondary)] py-1 shadow-lg ring-1 ring-black/5 focus:outline-none text-sm data-[closed]:data-[leave]:opacity-0 data-[leave]:transition data-[leave]:duration-100 data-[leave]:ease-in",children:t.accounts.map(H=>D.jsxs(Kv,{value:H.address,className:"group relative cursor-default select-none py-2 pl-3 pr-9 text-[var(--wui-color-text)] data-[focus]:bg-[var(--wui-color-bg-hover)] data-[focus]:outline-none",children:[D.jsx("span",{className:"block truncate font-normal group-data-[selected]:font-medium",children:pr(H.address,6,4)}),D.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-[var(--wui-color-primary)] group-[&:not([data-selected])]:hidden",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"h-5 w-5","aria-hidden":"true",children:D.jsx("path",{d:"M13.3334 4L6.00008 11.3333L2.66675 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},H.address))})]})]})}),D.jsx("div",{className:"border-t border-[var(--wui-color-border)] mt-2 mb-2"}),t&&D.jsxs("div",{className:"mb-2 flex justify-between",children:[D.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[D.jsx("div",{className:"h-5 w-5 overflow-hidden rounded flex items-center justify-center",children:t.metadata.icon?D.jsx("img",{src:t.metadata.icon,alt:`${t.metadata.name} icon`,className:"max-w-full max-h-full"}):D.jsx("div",{className:"h-5 w-5 rounded-full bg-[var(--wui-color-bg-tertiary)] flex items-center justify-center",children:D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3 text-[var(--wui-color-text-tertiary)]",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M17 9c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V9zm-1 0v8h-4V9h4zM8 4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V4zM3 3h4v14H3V3z",clipRule:"evenodd"})})})}),D.jsx("p",{className:"text-sm text-[var(--wui-color-text-secondary)]",children:t.metadata.name})]}),D.jsx("div",{children:t.metadata.isLiquid&&D.jsxs("button",{onClick:()=>d("manage"),className:"flex-1 py-2 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center",title:"Manage Liquid Account",children:[D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:D.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),"Manage"]})})]}),D.jsx("div",{className:"border-t border-[var(--wui-color-border)] mb-3 mt-2"}),D.jsxs("div",{className:"flex gap-2",children:[D.jsx("button",{onClick:de,className:"flex-1 py-2 px-4 bg-[var(--wui-color-bg-tertiary)] text-[var(--wui-color-text-secondary)] font-medium rounded-xl hover:brightness-90 transition-all text-sm flex items-center justify-center",title:"Copy address",children:u?D.jsxs(D.Fragment,{children:[D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-green-500 mr-1.5",viewBox:"0 0 20 20",fill:"currentColor",children:D.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"Copied"]}):D.jsxs(D.Fragment,{children:[D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1.5",viewBox:"0 0 20 20",fill:"currentColor",children:[D.jsx("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),D.jsx("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"})]}),"Copy"]})}),D.jsx("button",{onClick:be,className:"flex-1 py-2 px-4 bg-[var(--wui-color-danger-bg)] text-[var(--wui-color-danger-text)] font-medium rounded-xl hover:bg-[var(--wui-color-danger-bg-hover)] transition-colors text-sm",children:"Disconnect"})]})]}):D.jsx(r2,{displayBalance:p,showAvailableBalance:v,onToggleBalance:_e,onBack:()=>d("main"),send:{...A,explorerUrl:De(A.txId)},optIn:{...P,evmAddress:B,explorerUrl:De(P.txId)},assets:L.length>0?L:void 0,availableBalance:j,onRefresh:()=>o.invalidateQueries(),isRefreshing:s>0,onExplore:Te})})})})})})]})}function iS(n){const{queryClient:e}=ti();return D.jsx(F0,{client:e,children:D.jsx(wR,{...n})})}function xR({size:n,className:e,style:t}){const{activeAddress:r}=yn.useWallet();return r?D.jsx(iS,{children:D.jsx(ih,{size:n,className:e,style:t})}):D.jsx(qx,{children:D.jsx(Fd,{size:n,className:e,style:t})})}lS();exports.ConnectWalletButton=Fd;exports.ConnectWalletMenu=qx;exports.ConnectedWalletButton=ih;exports.ConnectedWalletMenu=iS;exports.NfdAvatar=vg;exports.WalletButton=xR;exports.WalletList=Kx;exports.WalletUIProvider=L2;exports.useAccountInfo=qv;exports.useAfterSignDialog=$2;exports.useBeforeSignDialog=V2;exports.useNfd=xg;exports.useResolvedTheme=Wx;exports.useWalletUI=ti;exports.useWelcomeDialog=_2;
236
236
  //# sourceMappingURL=index.cjs.map