@mysten-incubation/dev-wallet 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/adapters/build-managed-account.d.mts +15 -2
  3. package/dist/adapters/build-managed-account.d.mts.map +1 -1
  4. package/dist/adapters/build-managed-account.mjs +28 -4
  5. package/dist/adapters/build-managed-account.mjs.map +1 -1
  6. package/dist/adapters/devstack-adapter.d.mts +19 -7
  7. package/dist/adapters/devstack-adapter.d.mts.map +1 -1
  8. package/dist/adapters/devstack-adapter.mjs +16 -8
  9. package/dist/adapters/devstack-adapter.mjs.map +1 -1
  10. package/dist/inject/index.d.mts +37 -16
  11. package/dist/inject/index.d.mts.map +1 -1
  12. package/dist/inject/index.mjs +12 -4
  13. package/dist/inject/index.mjs.map +1 -1
  14. package/dist/standalone/assets/{base-adapter-DET6CP7z.js → base-adapter-C5w5q7XZ.js} +1 -1
  15. package/dist/standalone/assets/{in-memory-adapter-CX7xym4e.js → in-memory-adapter-Ban2kRYS.js} +1 -1
  16. package/dist/standalone/assets/{main-CuOnBmaa.js → main-xfzarPod.js} +3 -3
  17. package/dist/standalone/assets/{webcrypto-adapter-CUQmbHDy.js → webcrypto-adapter-Ddqn-RAu.js} +1 -1
  18. package/dist/standalone/index.html +2 -2
  19. package/dist/ui/dev-wallet-balances.d.mts +7 -0
  20. package/dist/ui/dev-wallet-balances.d.mts.map +1 -1
  21. package/dist/ui/dev-wallet-balances.mjs +50 -3
  22. package/dist/ui/dev-wallet-balances.mjs.map +1 -1
  23. package/dist/ui/wallet-controller.mjs +2 -1
  24. package/dist/ui/wallet-controller.mjs.map +1 -1
  25. package/dist/wallet/dev-wallet.d.mts +26 -2
  26. package/dist/wallet/dev-wallet.d.mts.map +1 -1
  27. package/dist/wallet/dev-wallet.mjs +35 -6
  28. package/dist/wallet/dev-wallet.mjs.map +1 -1
  29. package/package.json +1 -1
  30. package/src/adapters/build-managed-account.ts +28 -2
  31. package/src/adapters/devstack-adapter.ts +28 -8
  32. package/src/inject/index.ts +72 -24
  33. package/src/ui/dev-wallet-balances.ts +62 -3
  34. package/src/ui/wallet-controller.ts +2 -1
  35. package/src/wallet/dev-wallet.ts +47 -7
@@ -1 +1 @@
1
- var e=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,t=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,n=235;function r(r){return r.length>n?!1:r.includes(`@`)?e.test(r):t.test(r)}function i(e){let t=BigInt(e),n=[],r=0;if(t===0n)return[0];for(;t>0;)n[r]=Number(t&127n),t>>=7n,t>0n&&(n[r]|=128),r+=1;return n}function a(e){let t=0n,n=0n,r=0;for(;;){if(r>=e.length)throw Error(`ULEB decode error: buffer overflow`);let i=e[r];if(r+=1,t+=BigInt(i&127)<<n,!(i&128))break;n+=7n}if(t>BigInt(2**53-1))throw Error(`ULEB decode error: value exceeds MAX_SAFE_INTEGER`);return{value:Number(t),length:r}}var o=class{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,`0`);return BigInt(`0x`+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,`0`);return BigInt(`0x`+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,`0`);return BigInt(`0x`+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,{value:t,length:n}=a(new Uint8Array(this.dataView.buffer,e));return this.shift(n),t}readVec(e){let t=this.readULEB(),n=[];for(let r=0;r<t;r++)n.push(e(this,r,t));return n}};function s(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function c(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(e=>typeof e==`string`):t.every(e=>Number.isSafeInteger(e)):!1}function l(e){if(typeof e!=`function`)throw TypeError(`function expected`);return!0}function u(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}function d(e){if(typeof e!=`number`)throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function f(e){if(!Array.isArray(e))throw TypeError(`array expected`)}function p(e,t){if(!c(!0,t))throw TypeError(`${e}: array of strings expected`)}function m(e,t){if(!c(!1,t))throw TypeError(`${e}: array of numbers expected`)}function h(...e){let t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function g(e){let t=typeof e==`string`?e.split(``):e,n=t.length;p(`alphabet`,t);let r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(f(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(f(t),t.map(t=>{u(`alphabet.decode`,t);let n=r.get(t);if(n===void 0)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}function _(e=``){return u(`join`,e),{encode:t=>(p(`join.decode`,t),t.join(e)),decode:t=>(u(`join.decode`,t),t.split(e))}}function v(e,t=`=`){return d(e),u(`padding`,t),{encode(n){for(p(`padding.encode`,n);n.length*e%8;)n.push(t);return n},decode(n){p(`padding.decode`,n);let r=n.length;if(r*e%8)throw Error(`padding: invalid, string should have whole number of bytes`);for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8==0)throw Error(`padding: invalid, string has too much padding`);return n.slice(0,r)}}}function y(e){return l(e),{encode:e=>e,decode:t=>e(t)}}function b(e,t,n){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw RangeError(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(f(e),!e.length)return[];let r=0,i=[],a=Array.from(e,e=>{if(d(e),e<0||e>=t)throw Error(`invalid integer: ${e}`);return e}),o=a.length;for(;;){let e=0,s=!0;for(let i=r;i<o;i++){let o=a[i],c=t*e,l=c+o;if(!Number.isSafeInteger(l)||c/t!==e||l-o!==c)throw Error(`convertRadix: carry overflow`);let u=l/n;e=l%n;let d=Math.floor(u);if(a[i]=d,!Number.isSafeInteger(d)||d*n+e!==l)throw Error(`convertRadix: carry overflow`);if(s)d?s=!1:r=i;else continue}if(i.push(e),s)break}for(let t=0;t<e.length-1&&e[t]===0;t++)i.push(0);return i.reverse()}var x=(e,t)=>t===0?e:x(t,e%t),S=(e,t)=>e+(t-x(e,t)),C=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function w(e,t,n,r){if(f(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw RangeError(`convertRadix2: wrong to=${n}`);if(S(t,n)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${S(t,n)}`);let i=0,a=0,o=C[t],s=C[n]-1,c=[];for(let r of e){if(d(r),r>=o)throw Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,a+t>32)throw Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=n;a-=n)c.push((i>>a-n&s)>>>0);let e=C[a];if(e===void 0)throw Error(`invalid carry`);i&=e-1}if(i=i<<n-a&s,!r&&a>=t)throw Error(`Excess padding`);if(!r&&i>0)throw Error(`Non-zero padding: ${i}`);return r&&a>0&&c.push(i>>>0),c}function ee(e){return d(e),{encode:t=>{if(!s(t))throw TypeError(`radix.encode input should be Uint8Array`);return b(Array.from(t),256,e)},decode:t=>(m(`radix.decode`,t),Uint8Array.from(b(t,e,256)))}}function T(e,t=!1){if(d(e),e<=0||e>32)throw RangeError(`radix2: bits should be in (0..32]`);if(S(8,e)>32||S(e,8)>32)throw RangeError(`radix2: carry overflow`);return{encode:n=>{if(!s(n))throw TypeError(`radix2.encode input should be Uint8Array`);return w(Array.from(n),8,e,!t)},decode:n=>(m(`radix2.decode`,n),Uint8Array.from(w(n,e,8,t)))}}function te(e){return l(e),function(...t){try{return e.apply(null,t)}catch{}}}h(T(4),g(`0123456789ABCDEF`),_(``)),h(T(5),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),v(5),_(``)),h(T(5),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),_(``)),h(T(5),g(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),v(5),_(``)),h(T(5),g(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),_(``)),h(T(5),g(`0123456789ABCDEFGHJKMNPQRSTVWXYZ`),_(``),y(e=>e.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`)));var ne=typeof Uint8Array.from([]).toBase64==`function`&&typeof Uint8Array.fromBase64==`function`;ne||h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),v(6),_(``)),h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),_(``)),ne||h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),v(6),_(``)),h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),_(``));var re=Object.freeze((e=>h(ee(58),g(e),_(``)))(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)),ie=h(g(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),_(``)),ae=[996825010,642813549,513874426,1027748829,705979059];function oe(e){let t=e>>25,n=(e&33554431)<<5;for(let e=0;e<ae.length;e++)(t>>e&1)==1&&(n^=ae[e]);return n}function se(e,t,n=1){let r=e.length,i=1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n<33||n>126)throw Error(`Invalid prefix (${e})`);i=oe(i)^n>>5}i=oe(i);for(let t=0;t<r;t++)i=oe(i)^e.charCodeAt(t)&31;for(let e of t)i=oe(i)^e;for(let e=0;e<6;e++)i=oe(i);return i^=n,ie.encode(w([i%C[30]],30,5,!1))}function ce(e){let t=e===`bech32`?1:734539939,n=T(5),r=n.decode,i=n.encode,a=te(r);function o(e,n,r=90){u(`bech32.encode prefix`,e),s(n)&&(n=Array.from(n)),m(`bech32.encode`,n);let i=e.length;if(i===0)throw TypeError(`Invalid prefix length ${i}`);let a=i+7+n.length;if(r!==!1&&a>r)throw TypeError(`Length ${a} exceeds limit ${r}`);let o=e.toLowerCase(),c=se(o,n,t);return`${o}1${ie.encode(n)}${c}`}function c(e,n=90){u(`bech32.decode input`,e);let r=e.length;if(r<8||n!==!1&&r>n)throw TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);let i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw Error(`String must be lowercase or uppercase`);let a=i.lastIndexOf(`1`);if(a===0||a===-1)throw Error(`Letter "1" must be present between prefix and data only`);let o=i.slice(0,a),s=i.slice(a+1);if(s.length<6)throw Error(`Data must be at least 6 characters long`);let c=ie.decode(s).slice(0,-6),l=se(o,c,t);if(!s.endsWith(l))throw Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:o,words:c}}let l=te(c);function d(e){let{prefix:t,words:n}=c(e,!1);return{prefix:t,words:n,bytes:r(n)}}function f(e,t){return o(e,i(t))}return{encode:o,decode:c,encodeFromBytes:f,decodeToBytes:d,decodeUnsafe:l,fromWords:r,fromWordsUnsafe:a,toWords:i}}var le=Object.freeze(ce(`bech32`));ce(`bech32m`),typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`||h(T(4),g(`0123456789abcdef`),_(``),y(e=>{if(typeof e!=`string`||e.length%2!=0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));var ue=e=>re.encode(e),de=e=>re.decode(e);function E(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}var fe=8192;function D(e){if(e.length<fe)return btoa(String.fromCharCode(...e));let t=``;for(var n=0;n<e.length;n+=fe){let r=e.slice(n,n+fe);t+=String.fromCharCode(...r)}return btoa(t)}function pe(e){let t=e.startsWith(`0x`)?e.slice(2):e,n=t.length%2==0?t:`0${t}`,r=n.match(/[0-9a-fA-F]{2}/g)?.map(e=>parseInt(e,16))??[];if(r.length!==n.length/2)throw Error(`Invalid hex string ${e}`);return Uint8Array.from(r)}function me(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}function he(e,t){switch(t){case`base58`:return ue(e);case`base64`:return D(e);case`hex`:return me(e);default:throw Error(`Unsupported encoding, supported values are: base64, hex`)}}function ge(e,t=[`<`,`>`]){let[n,r]=t,i=[],a=``,o=0;for(let t=0;t<e.length;t++){let s=e[t];if(s===n&&o++,s===r&&o--,o===0&&s===`,`){i.push(a.trim()),a=``;continue}a+=s}return i.push(a.trim()),i}var _e=class{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){let t=this.bytePosition+e;if(t>this.size){let e=Math.min(this.maxSize,Math.max(this.size+t,this.size+this.allocateSize));if(t>e)throw Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;let n=new ArrayBuffer(this.size);new Uint8Array(n).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(n)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}writeBytes(e){this.ensureSizeOrGrow(e.length);for(let t=0;t<e.length;t++)this.dataView.setUint8(this.bytePosition+t,e[t]);return this.shift(e.length)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return ve(BigInt(e),8).forEach(e=>this.write8(e)),this}write128(e){return ve(BigInt(e),16).forEach(e=>this.write8(e)),this}write256(e){return ve(BigInt(e),32).forEach(e=>this.write8(e)),this}writeULEB(e){return i(e).forEach(e=>this.write8(e)),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach((n,r)=>t(this,n,r,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return he(this.toBytes(),e)}};function ve(e,t){let n=new Uint8Array(t),r=0;for(;e>0;)n[r]=Number(e%BigInt(256)),e/=BigInt(256),r+=1;return n}var O=class e{#e;#t;constructor(e){this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),this.#e=e.write,this.#t=e.serialize??((e,t)=>{let n=new _e({initialSize:this.serializedSize(e)??void 0,...t});return this.#e(e,n),n.toBytes()}),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),this.#e(e,t)}serialize(e,t){return this.validate(e),new xe(this,this.#t(e,t))}parse(e){let t=new o(e);return this.read(t)}fromHex(e){return this.parse(pe(e))}fromBase58(e){return this.parse(de(e))}fromBase64(e){return this.parse(E(e))}transform({name:t,input:n,output:r,validate:i}){return new e({name:t??this.name,read:e=>r?r(this.read(e)):this.read(e),write:(e,t)=>this.#e(n?n(e):e,t),serializedSize:e=>this.serializedSize(n?n(e):e),serialize:(e,t)=>this.#t(n?n(e):e,t),validate:e=>{i?.(e),this.validate(n?n(e):e)}})}},ye=Symbol.for(`@mysten/serialized-bcs`);function be(e){return!!e&&typeof e==`object`&&e[ye]===!0}var xe=class{#e;#t;get[ye](){return!0}constructor(e,t){this.#e=e,this.#t=t}toBytes(){return this.#t}toHex(){return me(this.#t)}toBase64(){return D(this.#t)}toBase58(){return ue(this.#t)}parse(){return this.#e.parse(this.#t)}};function Se({size:e,...t}){return new O({...t,serializedSize:()=>e})}function Ce({readMethod:e,writeMethod:t,...n}){return Se({...n,read:t=>t[e](),write:(e,n)=>n[t](e),validate:e=>{if(e<0||e>n.maxValue)throw TypeError(`Invalid ${n.name} value: ${e}. Expected value in range 0-${n.maxValue}`);n.validate?.(e)}})}function we({readMethod:e,writeMethod:t,...n}){return Se({...n,read:t=>t[e](),write:(e,n)=>n[t](BigInt(e)),validate:e=>{let t=BigInt(e);if(t<0||t>n.maxValue)throw TypeError(`Invalid ${n.name} value: ${t}. Expected value in range 0-${n.maxValue}`);n.validate?.(t)}})}function Te({serialize:e,...t}){let n=new O({...t,serialize:e,write:(e,t)=>{for(let r of n.serialize(e).toBytes())t.write8(r)}});return n}function Ee({toBytes:e,fromBytes:t,...n}){return new O({...n,read:e=>{let n=e.readULEB();return t(e.readBytes(n))},write:(t,n)=>{let r=e(t);n.writeULEB(r.length);for(let e=0;e<r.length;e++)n.write8(r[e])},serialize:t=>{let n=e(t),r=i(n.length),a=new Uint8Array(r.length+n.length);return a.set(r,0),a.set(n,r.length),a},validate:e=>{if(typeof e!=`string`)throw TypeError(`Invalid ${n.name} value: ${e}. Expected string`);n.validate?.(e)}})}function De(e){let t=null;function n(){return t||=e(),t}return new O({name:`lazy`,read:e=>n().read(e),serializedSize:e=>n().serializedSize(e),write:(e,t)=>n().write(e,t),serialize:(e,t)=>n().serialize(e,t).toBytes()})}var Oe=class extends O{constructor({name:e,fields:t,...n}){let r=Object.entries(t);super({name:e,serializedSize:e=>{let t=0;for(let[n,i]of r){let r=i.serializedSize(e[n]);if(r==null)return null;t+=r}return t},read:e=>{let t={};for(let[n,i]of r)t[n]=i.read(e);return t},write:(e,t)=>{for(let[n,i]of r)i.write(e[n],t)},...n,validate:e=>{if(n?.validate?.(e),typeof e!=`object`||!e)throw TypeError(`Expected object, found ${typeof e}`)}})}},ke=class extends O{constructor({fields:e,...t}){let n=Object.entries(e);super({read:e=>{let r=e.readULEB(),i=n[r];if(!i)throw TypeError(`Unknown value ${r} for enum ${t.name}`);let[a,o]=i;return{[a]:o?.read(e)??!0,$kind:a}},write:(t,r)=>{let[i,a]=Object.entries(t).filter(([t])=>Object.hasOwn(e,t))[0];for(let e=0;e<n.length;e++){let[t,o]=n[e];if(t===i){r.writeULEB(e),o?.write(a,r);return}}},...t,validate:n=>{if(t?.validate?.(n),typeof n!=`object`||!n)throw TypeError(`Expected object, found ${typeof n}`);let r=Object.keys(n).filter(t=>n[t]!==void 0&&Object.hasOwn(e,t));if(r.length!==1)throw TypeError(`Expected object with one key, but found ${r.length} for type ${t.name}}`);let[i]=r;if(!Object.hasOwn(e,i))throw TypeError(`Invalid enum variant ${i}`)}})}},Ae=class extends O{constructor({fields:e,name:t,...n}){super({name:t??`(${e.map(e=>e.name).join(`, `)})`,serializedSize:t=>{let n=0;for(let r=0;r<e.length;r++){let i=e[r].serializedSize(t[r]);if(i==null)return null;n+=i}return n},read:t=>{let n=[];for(let r of e)n.push(r.read(t));return n},write:(t,n)=>{for(let r=0;r<e.length;r++)e[r].write(t[r],n)},...n,validate:t=>{if(n?.validate?.(t),!Array.isArray(t))throw TypeError(`Expected array, found ${typeof t}`);if(t.length!==e.length)throw TypeError(`Expected array of length ${e.length}, found ${t.length}`)}})}};function je(e,t,n){return new O({read:n=>{let r=Array(e);for(let i=0;i<e;i++)r[i]=t.read(n);return r},write:(e,n)=>{for(let r of e)t.write(r,n)},...n,name:n?.name??`${t.name}[${e}]`,validate:t=>{if(n?.validate?.(t),!t||typeof t!=`object`||!(`length`in t))throw TypeError(`Expected array, found ${typeof t}`);if(t.length!==e)throw TypeError(`Expected array of length ${e}, found ${t.length}`)}})}function Me(e){return k.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>e.$kind===`Some`?e.Some:null})}function Ne(e,t){return new O({read:t=>{let n=t.readULEB(),r=Array(n);for(let i=0;i<n;i++)r[i]=e.read(t);return r},write:(t,n)=>{n.writeULEB(t.length);for(let r of t)e.write(r,n)},...t,name:t?.name??`vector<${e.name}>`,validate:e=>{if(t?.validate?.(e),!e||typeof e!=`object`||!(`length`in e))throw TypeError(`Expected array, found ${typeof e}`)}})}function Pe(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length}function Fe(e,t){return new O({name:`Map<${e.name}, ${t.name}>`,read:n=>{let r=n.readULEB(),i=new Map;for(let a=0;a<r;a++)i.set(e.read(n),t.read(n));return i},write:(n,r)=>{let i=[...n.entries()].map(([t,n])=>[e.serialize(t).toBytes(),n]);i.sort(([e],[t])=>Pe(e,t)),r.writeULEB(i.length);for(let[e,n]of i)r.writeBytes(e),t.write(n,r)}})}var k={u8(e){return Ce({readMethod:`read8`,writeMethod:`write8`,size:1,maxValue:2**8-1,...e,name:e?.name??`u8`})},u16(e){return Ce({readMethod:`read16`,writeMethod:`write16`,size:2,maxValue:2**16-1,...e,name:e?.name??`u16`})},u32(e){return Ce({readMethod:`read32`,writeMethod:`write32`,size:4,maxValue:2**32-1,...e,name:e?.name??`u32`})},u64(e){return we({readMethod:`read64`,writeMethod:`write64`,size:8,maxValue:2n**64n-1n,...e,name:e?.name??`u64`})},u128(e){return we({readMethod:`read128`,writeMethod:`write128`,size:16,maxValue:2n**128n-1n,...e,name:e?.name??`u128`})},u256(e){return we({readMethod:`read256`,writeMethod:`write256`,size:32,maxValue:2n**256n-1n,...e,name:e?.name??`u256`})},bool(e){return Se({size:1,read:e=>e.read8()===1,write:(e,t)=>t.write8(+!!e),...e,name:e?.name??`bool`,validate:t=>{if(e?.validate?.(t),typeof t!=`boolean`)throw TypeError(`Expected boolean, found ${typeof t}`)}})},uleb128(e){return Te({read:e=>e.readULEB(),serialize:e=>Uint8Array.from(i(e)),...e,name:e?.name??`uleb128`})},bytes(e,t){return Se({size:e,read:t=>t.readBytes(e),write:(e,t)=>{t.writeBytes(new Uint8Array(e))},...t,name:t?.name??`bytes[${e}]`,validate:n=>{if(t?.validate?.(n),!n||typeof n!=`object`||!(`length`in n))throw TypeError(`Expected array, found ${typeof n}`);if(n.length!==e)throw TypeError(`Expected array of length ${e}, found ${n.length}`)}})},byteVector(e){return new O({read:e=>{let t=e.readULEB();return e.readBytes(t)},write:(e,t)=>{let n=new Uint8Array(e);t.writeULEB(n.length),t.writeBytes(n)},...e,name:e?.name??`vector<u8>`,serializedSize:e=>{let t=`length`in e?e.length:null;return t==null?null:i(t).length+t},validate:t=>{if(e?.validate?.(t),!t||typeof t!=`object`||!(`length`in t))throw TypeError(`Expected array, found ${typeof t}`)}})},string(e){return Ee({toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...e,name:e?.name??`string`})},fixedArray:je,option:Me,vector:Ne,tuple(e,t){return new Ae({fields:e,...t})},struct(e,t,n){return new Oe({name:e,fields:t,...n})},enum(e,t,n){return new ke({name:e,fields:t,...n})},map:Fe,lazy(e){return De(e)}};function Ie(e){return Je(e)&&Ye(e)===32}var Le=/^[a-zA-Z][a-zA-Z0-9_]*$/;function Re(e){return Le.test(e)}var ze=[`bool`,`u8`,`u16`,`u32`,`u64`,`u128`,`u256`,`address`,`signer`],Be=/^vector<(.+)>$/;function Ve(e){if(ze.includes(e))return!0;let t=e.match(Be);return t?Ve(t[1]):e.includes(`::`)?Ue(e):!1}function He(e){return!Ie(e.address)&&!et(e.address)||!Re(e.module)||!Re(e.name)?!1:e.typeParams.every(e=>typeof e==`string`?Ve(e):He(e))}function Ue(e){try{return He(Ge(e))}catch{return!1}}function We(e){if(e.startsWith(`vector<`)){if(!e.endsWith(`>`))throw Error(`Invalid type tag: ${e}`);let t=e.slice(7,-1);if(!t)throw Error(`Invalid type tag: ${e}`);let n=We(t);return typeof n==`string`?`vector<${n}>`:`vector<${Ke(n)}>`}return e.includes(`::`)?Ge(e):e}function Ge(e){let t=e.split(`::`);if(t.length<3)throw Error(`Invalid struct tag: ${e}`);let[n,r]=t;if(!n||!r)throw Error(`Invalid struct tag: ${e}`);let i=et(n),a=e.slice(n.length+r.length+4),o=a.includes(`<`)?a.slice(0,a.indexOf(`<`)):a;if(!o||a.includes(`<`)&&!a.endsWith(`>`))throw Error(`Invalid struct tag: ${e}`);let s=a.includes(`<`)?ge(a.slice(a.indexOf(`<`)+1,a.lastIndexOf(`>`))).map(e=>We(e.trim())):[];return{address:i?n:A(n),module:r,name:o,typeParams:s}}function Ke(e){if(typeof e==`string`&&e.startsWith(`vector<`))throw Error(`normalizeStructTag does not support vector types. Use normalizeTypeTag instead.`);let{address:t,module:n,name:r,typeParams:i}=typeof e==`string`?Ge(e):e;return`${t}::${n}::${r}${i?.length>0?`<${i.map(e=>typeof e==`string`?e:Ke(e)).join(`,`)}>`:``}`}function A(e,t=!1){let n=e.toLowerCase();return!t&&n.startsWith(`0x`)&&(n=n.slice(2)),`0x${n.padStart(64,`0`)}`}function qe(e,t=!1){return A(e,t)}function Je(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}function Ye(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}var Xe=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,Ze=/^\d+$/,Qe=64,$e=`/`,et=e=>{let t=e.split($e);if(t.length<2||t.length>3)return!1;let[n,i,a]=t;return a!==void 0&&!Ze.test(a)||!r(n)?!1:Xe.test(i)&&i.length<Qe},tt=e=>{let t=e.split(/::|<|>|,/);for(let e of t)if(e.includes($e)&&!et(e))return!1;return Ue(e)},nt=/^vector<(.+)>$/,rt=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/,it=class e{static parseFromStr(t,n=!1){if(t===`address`)return{address:null};if(t===`bool`)return{bool:null};if(t===`u8`)return{u8:null};if(t===`u16`)return{u16:null};if(t===`u32`)return{u32:null};if(t===`u64`)return{u64:null};if(t===`u128`)return{u128:null};if(t===`u256`)return{u256:null};if(t===`signer`)return{signer:null};let r=t.match(nt);if(r)return{vector:e.parseFromStr(r[1],n)};let i=t.match(rt);if(i)return{struct:{address:n?A(i[1]):i[1],module:i[2],name:i[3],typeParams:i[5]===void 0?[]:e.parseStructTypeArgs(i[5],n)}};throw Error(`Encountered unexpected token when parsing type args for ${t}`)}static parseStructTypeArgs(t,n=!1){return ge(t).map(t=>e.parseFromStr(t,n))}static tagToString(t){if(`bool`in t)return`bool`;if(`u8`in t)return`u8`;if(`u16`in t)return`u16`;if(`u32`in t)return`u32`;if(`u64`in t)return`u64`;if(`u128`in t)return`u128`;if(`u256`in t)return`u256`;if(`address`in t)return`address`;if(`signer`in t)return`signer`;if(`vector`in t)return`vector<${e.tagToString(t.vector)}>`;if(`struct`in t){let n=t.struct,r=n.typeParams.map(e.tagToString).join(`, `);return`${n.address}::${n.module}::${n.name}${r?`<${r}>`:``}`}throw Error(`Invalid TypeTag`)}};function at(e){return k.u64({name:`unsafe_u64`,...e}).transform({input:e=>e,output:e=>Number(e)})}function ot(e){return k.enum(`Option`,{None:null,Some:e})}var j=k.bytes(32).transform({validate:e=>{let t=typeof e==`string`?e:me(e);if(!t||!Ie(A(t)))throw Error(`Invalid Sui address ${t}`)},input:e=>typeof e==`string`?pe(A(e)):e,output:e=>A(me(e))}),M=k.byteVector().transform({name:`ObjectDigest`,input:e=>de(e),output:e=>ue(new Uint8Array(e)),validate:e=>{if(de(e).length!==32)throw Error(`ObjectDigest must be 32 bytes`)}}),N=k.struct(`SuiObjectRef`,{objectId:j,version:k.u64(),digest:M}),st=k.struct(`SharedObjectRef`,{objectId:j,initialSharedVersion:k.u64(),mutable:k.bool()}),ct=k.enum(`ObjectArg`,{ImmOrOwnedObject:N,SharedObject:st,Receiving:N}),lt=k.enum(`Owner`,{AddressOwner:j,ObjectOwner:j,Shared:k.struct(`Shared`,{initialSharedVersion:k.u64()}),Immutable:null,ConsensusAddressOwner:k.struct(`ConsensusAddressOwner`,{startVersion:k.u64(),owner:j})}),ut=k.enum(`Reservation`,{MaxAmountU64:k.u64()}),dt=k.enum(`WithdrawalType`,{Balance:k.lazy(()=>gt)}),ft=k.enum(`WithdrawFrom`,{Sender:null,Sponsor:null}),pt=k.struct(`FundsWithdrawal`,{reservation:ut,typeArg:dt,withdrawFrom:ft}),mt=k.enum(`CallArg`,{Pure:k.struct(`Pure`,{bytes:k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))})}),Object:ct,FundsWithdrawal:pt}),ht=k.enum(`TypeTag`,{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:k.lazy(()=>ht),struct:k.lazy(()=>Ct),u16:null,u32:null,u256:null}),gt=ht.transform({input:e=>typeof e==`string`?it.parseFromStr(e,!0):e,output:e=>it.tagToString(e)}),P=k.enum(`Argument`,{GasCoin:null,Input:k.u16(),Result:k.u16(),NestedResult:k.tuple([k.u16(),k.u16()])}),_t=k.struct(`ProgrammableMoveCall`,{package:j,module:k.string(),function:k.string(),typeArguments:k.vector(gt),arguments:k.vector(P)}),vt=k.enum(`Command`,{MoveCall:_t,TransferObjects:k.struct(`TransferObjects`,{objects:k.vector(P),address:P}),SplitCoins:k.struct(`SplitCoins`,{coin:P,amounts:k.vector(P)}),MergeCoins:k.struct(`MergeCoins`,{destination:P,sources:k.vector(P)}),Publish:k.struct(`Publish`,{modules:k.vector(k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))})),dependencies:k.vector(j)}),MakeMoveVec:k.struct(`MakeMoveVec`,{type:ot(gt).transform({input:e=>e===null?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:k.vector(P)}),Upgrade:k.struct(`Upgrade`,{modules:k.vector(k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))})),dependencies:k.vector(j),package:j,ticket:P})}),yt=k.struct(`ProgrammableTransaction`,{inputs:k.vector(mt),commands:k.vector(vt)}),bt=k.enum(`TransactionKind`,{ProgrammableTransaction:yt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),xt=k.struct(`ValidDuring`,{minEpoch:k.option(k.u64()),maxEpoch:k.option(k.u64()),minTimestamp:k.option(k.u64()),maxTimestamp:k.option(k.u64()),chain:M,nonce:k.u32()}),St=k.enum(`TransactionExpiration`,{None:null,Epoch:at(),ValidDuring:xt}),Ct=k.struct(`StructTag`,{address:j,module:k.string(),name:k.string(),typeParams:k.vector(ht)}),wt=k.struct(`GasData`,{payment:k.vector(N),owner:j,price:k.u64(),budget:k.u64()}),Tt=k.struct(`TransactionDataV1`,{kind:bt,sender:j,gasData:wt,expiration:St}),Et=k.enum(`TransactionData`,{V1:Tt}),Dt=k.enum(`IntentScope`,{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Ot=k.enum(`IntentVersion`,{V0:null}),kt=k.enum(`AppId`,{Sui:null}),At=k.struct(`Intent`,{scope:Dt,version:Ot,appId:kt});function jt(e){return k.struct(`IntentMessage<${e.name}>`,{intent:At,value:e})}var Mt=k.enum(`CompressedSignature`,{ED25519:k.bytes(64),Secp256k1:k.bytes(64),Secp256r1:k.bytes(64),ZkLogin:k.byteVector(),Passkey:k.byteVector()}),Nt=k.enum(`PublicKey`,{ED25519:k.bytes(32),Secp256k1:k.bytes(33),Secp256r1:k.bytes(33),ZkLogin:k.byteVector(),Passkey:k.bytes(33)}),Pt=k.struct(`MultiSigPkMap`,{pubKey:Nt,weight:k.u8()}),Ft=k.struct(`MultiSigPublicKey`,{pk_map:k.vector(Pt),threshold:k.u16()}),It=k.struct(`MultiSig`,{sigs:k.vector(Mt),bitmap:k.u16(),multisig_pk:Ft}),Lt=k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))}),Rt=k.struct(`SenderSignedTransaction`,{intentMessage:jt(Et),txSignatures:k.vector(Lt)}),zt=k.vector(Rt,{name:`SenderSignedData`}),Bt=k.struct(`PasskeyAuthenticator`,{authenticatorData:k.byteVector(),clientDataJson:k.string(),userSignature:k.byteVector()}),Vt=k.enum(`MoveObjectType`,{Other:Ct,GasCoin:null,StakedSui:null,Coin:gt,AccumulatorBalanceWrapper:null}),Ht=k.struct(`TypeOrigin`,{moduleName:k.string(),datatypeName:k.string(),package:j}),Ut=k.struct(`UpgradeInfo`,{upgradedId:j,upgradedVersion:k.u64()}),Wt=k.struct(`MovePackage`,{id:j,version:k.u64(),moduleMap:k.map(k.string(),k.byteVector()),typeOriginTable:k.vector(Ht),linkageTable:k.map(j,Ut)}),Gt=k.struct(`MoveObject`,{type:Vt,hasPublicTransfer:k.bool(),version:k.u64(),contents:k.byteVector()}),Kt=k.enum(`Data`,{Move:Gt,Package:Wt}),qt=k.struct(`ObjectInner`,{data:Kt,owner:lt,previousTransaction:M,storageRebate:k.u64()}),Jt=k.enum(`PackageUpgradeError`,{UnableToFetchPackage:k.struct(`UnableToFetchPackage`,{packageId:j}),NotAPackage:k.struct(`NotAPackage`,{objectId:j}),IncompatibleUpgrade:null,DigestDoesNotMatch:k.struct(`DigestDoesNotMatch`,{digest:k.byteVector()}),UnknownUpgradePolicy:k.struct(`UnknownUpgradePolicy`,{policy:k.u8()}),PackageIDDoesNotMatch:k.struct(`PackageIDDoesNotMatch`,{packageId:j,ticketId:j})}),Yt=k.struct(`ModuleId`,{address:j,name:k.string()}),Xt=k.struct(`MoveLocation`,{module:Yt,function:k.u16(),instruction:k.u16(),functionName:k.option(k.string())}),Zt=k.enum(`CommandArgumentError`,{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:k.struct(`IndexOutOfBounds`,{idx:k.u16()}),SecondaryIndexOutOfBounds:k.struct(`SecondaryIndexOutOfBounds`,{resultIdx:k.u16(),secondaryIdx:k.u16()}),InvalidResultArity:k.struct(`InvalidResultArity`,{resultIdx:k.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null,InvalidArgumentArity:null,InvalidTransferObject:null,InvalidMakeMoveVecNonObjectArgument:null,ArgumentWithoutValue:null,CannotMoveBorrowedValue:null,CannotWriteToExtendedReference:null,InvalidReferenceArgument:null}),Qt=k.enum(`TypeArgumentError`,{TypeNotFound:null,ConstraintNotSatisfied:null}),$t=k.enum(`ExecutionFailureStatus`,{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:k.struct(`MoveObjectTooBig`,{objectSize:k.u64(),maxObjectSize:k.u64()}),MovePackageTooBig:k.struct(`MovePackageTooBig`,{objectSize:k.u64(),maxObjectSize:k.u64()}),CircularObjectOwnership:k.struct(`CircularObjectOwnership`,{object:j}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:k.option(Xt),MoveAbort:k.tuple([Xt,k.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:k.struct(`CommandArgumentError`,{argIdx:k.u16(),kind:Zt}),TypeArgumentError:k.struct(`TypeArgumentError`,{argumentIdx:k.u16(),kind:Qt}),UnusedValueWithoutDrop:k.struct(`UnusedValueWithoutDrop`,{resultIdx:k.u16(),secondaryIdx:k.u16()}),InvalidPublicFunctionReturnType:k.struct(`InvalidPublicFunctionReturnType`,{idx:k.u16()}),InvalidTransferObject:null,EffectsTooLarge:k.struct(`EffectsTooLarge`,{currentSize:k.u64(),maxSize:k.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:k.struct(`PackageUpgradeError`,{upgradeError:Jt}),WrittenObjectsTooLarge:k.struct(`WrittenObjectsTooLarge`,{currentSize:k.u64(),maxSize:k.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null,ExecutionCancelledDueToSharedObjectCongestion:k.struct(`ExecutionCancelledDueToSharedObjectCongestion`,{congested_objects:k.vector(j)}),AddressDeniedForCoin:k.struct(`AddressDeniedForCoin`,{address:j,coinType:k.string()}),CoinTypeGlobalPause:k.struct(`CoinTypeGlobalPause`,{coinType:k.string()}),ExecutionCancelledDueToRandomnessUnavailable:null,MoveVectorElemTooBig:k.struct(`MoveVectorElemTooBig`,{valueSize:k.u64(),maxScaledSize:k.u64()}),MoveRawValueTooBig:k.struct(`MoveRawValueTooBig`,{valueSize:k.u64(),maxScaledSize:k.u64()}),InvalidLinkage:null,InsufficientBalanceForWithdraw:null,NonExclusiveWriteInputObjectModified:k.struct(`NonExclusiveWriteInputObjectModified`,{id:j})}),en=k.enum(`ExecutionStatus`,{Success:null,Failure:k.struct(`Failure`,{error:$t,command:k.option(k.u64())})}),tn=k.struct(`GasCostSummary`,{computationCost:k.u64(),storageCost:k.u64(),storageRebate:k.u64(),nonRefundableStorageFee:k.u64()}),nn=k.struct(`TransactionEffectsV1`,{status:en,executedEpoch:k.u64(),gasUsed:tn,modifiedAtVersions:k.vector(k.tuple([j,k.u64()])),sharedObjects:k.vector(N),transactionDigest:M,created:k.vector(k.tuple([N,lt])),mutated:k.vector(k.tuple([N,lt])),unwrapped:k.vector(k.tuple([N,lt])),deleted:k.vector(N),unwrappedThenDeleted:k.vector(N),wrapped:k.vector(N),gasObject:k.tuple([N,lt]),eventsDigest:k.option(M),dependencies:k.vector(M)}),rn=k.tuple([k.u64(),M]),an=k.enum(`ObjectIn`,{NotExist:null,Exist:k.tuple([rn,lt])}),on=k.struct(`AccumulatorAddress`,{address:j,ty:gt}),sn=k.enum(`AccumulatorOperation`,{Merge:null,Split:null}),cn=k.enum(`AccumulatorValue`,{Integer:k.u64(),IntegerTuple:k.tuple([k.u64(),k.u64()]),EventDigest:k.vector(k.tuple([k.u64(),M]))}),ln=k.struct(`AccumulatorWriteV1`,{address:on,operation:sn,value:cn}),un=k.enum(`ObjectOut`,{NotExist:null,ObjectWrite:k.tuple([M,lt]),PackageWrite:rn,AccumulatorWriteV1:ln}),dn=k.enum(`IDOperation`,{None:null,Created:null,Deleted:null}),fn=k.struct(`EffectsObjectChange`,{inputState:an,outputState:un,idOperation:dn}),pn=k.enum(`UnchangedConsensusKind`,{ReadOnlyRoot:rn,MutateConsensusStreamEnded:k.u64(),ReadConsensusStreamEnded:k.u64(),Cancelled:k.u64(),PerEpochConfig:null}),mn=k.struct(`TransactionEffectsV2`,{status:en,executedEpoch:k.u64(),gasUsed:tn,transactionDigest:M,gasObjectIndex:k.option(k.u32()),eventsDigest:k.option(M),dependencies:k.vector(M),lamportVersion:k.u64(),changedObjects:k.vector(k.tuple([j,fn])),unchangedConsensusObjects:k.vector(k.tuple([j,pn])),auxDataDigest:k.option(M)}),hn=k.enum(`TransactionEffects`,{V1:nn,V2:mn});function gn(e){switch(e){case`u8`:return k.u8();case`u16`:return k.u16();case`u32`:return k.u32();case`u64`:return k.u64();case`u128`:return k.u128();case`u256`:return k.u256();case`bool`:return k.bool();case`string`:return k.string();case`id`:case`address`:return j}let t=e.match(/^(vector|option)<(.+)>$/);if(t){let[e,n]=t.slice(1);return e===`vector`?k.vector(gn(n)):k.option(gn(n))}throw Error(`Invalid Pure type name: ${e}`)}var _n={...k,U8:k.u8(),U16:k.u16(),U32:k.u32(),U64:k.u64(),U128:k.u128(),U256:k.u256(),ULEB128:k.uleb128(),Bool:k.bool(),String:k.string(),Address:j,AppId:kt,Argument:P,CallArg:mt,Command:vt,CompressedSignature:Mt,Data:Kt,GasData:wt,Intent:At,IntentMessage:jt,IntentScope:Dt,IntentVersion:Ot,MoveObject:Gt,MoveObjectType:Vt,MovePackage:Wt,MultiSig:It,MultiSigPkMap:Pt,MultiSigPublicKey:Ft,Object:qt,ObjectArg:ct,ObjectDigest:M,Owner:lt,PasskeyAuthenticator:Bt,ProgrammableMoveCall:_t,ProgrammableTransaction:yt,PublicKey:Nt,SenderSignedData:zt,SenderSignedTransaction:Rt,SharedObjectRef:st,StructTag:Ct,SuiObjectRef:N,TransactionData:Et,TransactionDataV1:Tt,TransactionEffects:hn,TransactionExpiration:St,TransactionKind:bt,TypeOrigin:Ht,TypeTag:gt,UpgradeInfo:Ut};function vn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function F(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw RangeError(`${n}expected integer >= 0, got ${e}`)}}function I(e,t,n=``){let r=vn(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`,l=o+`expected Uint8Array`+s+`, got `+c;throw r?RangeError(l):TypeError(l)}return e}function yn(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`Hash must wrapped by utils.createHasher`);if(F(e.outputLen),F(e.blockLen),e.outputLen<1)throw Error(`"outputLen" must be >= 1`);if(e.blockLen<1)throw Error(`"blockLen" must be >= 1`)}function bn(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function xn(e,t){I(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw RangeError(`"digestInto() output" expected to be of length >=`+n)}function Sn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function L(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Cn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function R(e,t){return e<<32-t|e>>>t}var wn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Tn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}var z=wn?e=>e:e=>Tn(e)>>>0;function En(e){for(let t=0;t<e.length;t++)e[t]=Tn(e[t]);return e}var Dn=wn?e=>e:En,On=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,kn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function An(e){if(I(e),On)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=kn[e[n]];return t}var B={_0:48,_9:57,A:65,F:70,a:97,f:102};function jn(e){if(e>=B._0&&e<=B._9)return e-B._0;if(e>=B.A&&e<=B.F)return e-(B.A-10);if(e>=B.a&&e<=B.f)return e-(B.a-10)}function Mn(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(On)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=jn(e.charCodeAt(i)),a=jn(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Nn(e){if(typeof e!=`string`)throw TypeError(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Pn(e,t=``){return typeof e==`string`?Nn(e):I(e,void 0,t)}function Fn(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];I(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function In(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw TypeError(`options must be object or undefined`);return Object.assign(e,t)}function Ln(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Rn(e=32){F(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var zn=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),Bn=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function Vn(e,t,n){return e&t^~e&n}function Hn(e,t,n){return e&t^e&n^t&n}var Un=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Cn(this.buffer)}update(e){bn(this),I(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Cn(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){bn(this),xn(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,L(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,BigInt(this.length*8),i),this.process(n,0);let o=Cn(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Wn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),V=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Gn=BigInt(2**32-1),Kn=BigInt(32);function qn(e,t=!1){return t?{h:Number(e&Gn),l:Number(e>>Kn&Gn)}:{h:Number(e>>Kn&Gn)|0,l:Number(e&Gn)|0}}function Jn(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=qn(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var Yn=(e,t,n)=>e>>>n,Xn=(e,t,n)=>e<<32-n|t>>>n,Zn=(e,t,n)=>e>>>n|t<<32-n,Qn=(e,t,n)=>e<<32-n|t>>>n,$n=(e,t,n)=>e<<64-n|t>>>n-32,er=(e,t,n)=>e>>>n-32|t<<64-n,tr=(e,t)=>t,nr=(e,t)=>e;function H(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var rr=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),ir=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,ar=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),or=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,sr=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),cr=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,U=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),W=new Uint32Array(32);function lr(e,t,n,r,i,a){let o=i[a],s=i[a+1],c=W[2*e],l=W[2*e+1],u=W[2*t],d=W[2*t+1],f=W[2*n],p=W[2*n+1],m=W[2*r],h=W[2*r+1],g=rr(c,u,o);l=ir(g,l,d,s),c=g|0,{Dh:h,Dl:m}={Dh:h^l,Dl:m^c},{Dh:h,Dl:m}={Dh:tr(h,m),Dl:nr(h,m)},{h:p,l:f}=H(p,f,h,m),{Bh:d,Bl:u}={Bh:d^p,Bl:u^f},{Bh:d,Bl:u}={Bh:Zn(d,u,24),Bl:Qn(d,u,24)},W[2*e]=c,W[2*e+1]=l,W[2*t]=u,W[2*t+1]=d,W[2*n]=f,W[2*n+1]=p,W[2*r]=m,W[2*r+1]=h}function G(e,t,n,r,i,a){let o=i[a],s=i[a+1],c=W[2*e],l=W[2*e+1],u=W[2*t],d=W[2*t+1],f=W[2*n],p=W[2*n+1],m=W[2*r],h=W[2*r+1],g=rr(c,u,o);l=ir(g,l,d,s),c=g|0,{Dh:h,Dl:m}={Dh:h^l,Dl:m^c},{Dh:h,Dl:m}={Dh:Zn(h,m,16),Dl:Qn(h,m,16)},{h:p,l:f}=H(p,f,h,m),{Bh:d,Bl:u}={Bh:d^p,Bl:u^f},{Bh:d,Bl:u}={Bh:$n(d,u,63),Bl:er(d,u,63)},W[2*e]=c,W[2*e+1]=l,W[2*t]=u,W[2*t+1]=d,W[2*n]=f,W[2*n+1]=p,W[2*r]=m,W[2*r+1]=h}function ur(e,t={},n,r,i){if(F(n),e<=0||e>n)throw Error(`outputLen bigger than keyLen`);let{key:a,salt:o,personalization:s}=t;if(a!==void 0&&(a.length<1||a.length>n))throw Error(`"key" expected to be undefined or of length=1..`+n);o!==void 0&&I(o,r,`salt`),s!==void 0&&I(s,i,`personalization`)}var dr=class{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(e,t){F(e),F(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=Sn(this.buffer)}update(e){bn(this),I(e);let{blockLen:t,buffer:n,buffer32:r}=this,i=e.length,a=e.byteOffset,o=e.buffer;for(let s=0;s<i;){this.pos===t&&(Dn(r),this.compress(r,0,!1),Dn(r),this.pos=0);let c=Math.min(t-this.pos,i-s),l=a+s;if(c===t&&!(l%4)&&s+c<i){let e=new Uint32Array(o,l,Math.floor((i-s)/4));Dn(e);for(let n=0;s+t<i;n+=r.length,s+=t)this.length+=t,this.compress(e,n,!1);Dn(e);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,this.length+=c,s+=c}return this}digestInto(e){bn(this),xn(e,this);let{pos:t,buffer32:n}=this;if(this.finished=!0,L(this.buffer.subarray(t)),Dn(n),this.compress(n,0,!0),Dn(n),e.byteOffset&3)throw RangeError(`"digestInto() output" expected 4-byte aligned byteOffset, got `+e.byteOffset);let r=this.get(),i=Sn(e),a=Math.floor(this.outputLen/4);for(let e=0;e<a;e++)i[e]=z(r[e]);let o=this.outputLen%4;if(!o)return;let s=a*4,c=r[a];for(let t=0;t<o;t++)e[s+t]=c>>>8*t}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){let{buffer:t,length:n,finished:r,destroyed:i,outputLen:a,pos:o}=this;return e||=new this.constructor({dkLen:a}),e.set(...this.get()),e.buffer.set(t),e.destroyed=i,e.finished=r,e.length=n,e.pos=o,e.outputLen=a,e}clone(){return this._cloneInto()}},fr=class extends dr{v0l=U[0]|0;v0h=U[1]|0;v1l=U[2]|0;v1h=U[3]|0;v2l=U[4]|0;v2h=U[5]|0;v3l=U[6]|0;v3h=U[7]|0;v4l=U[8]|0;v4h=U[9]|0;v5l=U[10]|0;v5h=U[11]|0;v6l=U[12]|0;v6h=U[13]|0;v7l=U[14]|0;v7h=U[15]|0;constructor(e={}){let t=e.dkLen===void 0?64:e.dkLen;super(128,t),ur(t,e,64,16,16);let{key:n,personalization:r,salt:i}=e,a=0;if(n!==void 0&&(I(n,void 0,`key`),a=n.length),this.v0l^=this.outputLen|a<<8|16842752,i!==void 0){I(i,void 0,`salt`);let e=Sn(i);this.v4l^=z(e[0]),this.v4h^=z(e[1]),this.v5l^=z(e[2]),this.v5h^=z(e[3])}if(r!==void 0){I(r,void 0,`personalization`);let e=Sn(r);this.v6l^=z(e[0]),this.v6h^=z(e[1]),this.v7l^=z(e[2]),this.v7h^=z(e[3])}if(n!==void 0){let e=new Uint8Array(this.blockLen);e.set(n),this.update(e)}}get(){let{v0l:e,v0h:t,v1l:n,v1h:r,v2l:i,v2h:a,v3l:o,v3h:s,v4l:c,v4h:l,v5l:u,v5h:d,v6l:f,v6h:p,v7l:m,v7h:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.v0l=e|0,this.v0h=t|0,this.v1l=n|0,this.v1h=r|0,this.v2l=i|0,this.v2h=a|0,this.v3l=o|0,this.v3h=s|0,this.v4l=c|0,this.v4h=l|0,this.v5l=u|0,this.v5h=d|0,this.v6l=f|0,this.v6h=p|0,this.v7l=m|0,this.v7h=h|0}compress(e,t,n){this.get().forEach((e,t)=>W[t]=e),W.set(U,16);let{h:r,l:i}=qn(BigInt(this.length));W[24]=U[8]^i,W[25]=U[9]^r,n&&(W[28]=~W[28],W[29]=~W[29]);let a=0,o=Bn;for(let n=0;n<12;n++)lr(0,4,8,12,e,t+2*o[a++]),G(0,4,8,12,e,t+2*o[a++]),lr(1,5,9,13,e,t+2*o[a++]),G(1,5,9,13,e,t+2*o[a++]),lr(2,6,10,14,e,t+2*o[a++]),G(2,6,10,14,e,t+2*o[a++]),lr(3,7,11,15,e,t+2*o[a++]),G(3,7,11,15,e,t+2*o[a++]),lr(0,5,10,15,e,t+2*o[a++]),G(0,5,10,15,e,t+2*o[a++]),lr(1,6,11,12,e,t+2*o[a++]),G(1,6,11,12,e,t+2*o[a++]),lr(2,7,8,13,e,t+2*o[a++]),G(2,7,8,13,e,t+2*o[a++]),lr(3,4,9,14,e,t+2*o[a++]),G(3,4,9,14,e,t+2*o[a++]);this.v0l^=W[0]^W[16],this.v0h^=W[1]^W[17],this.v1l^=W[2]^W[18],this.v1h^=W[3]^W[19],this.v2l^=W[4]^W[20],this.v2h^=W[5]^W[21],this.v3l^=W[6]^W[22],this.v3h^=W[7]^W[23],this.v4l^=W[8]^W[24],this.v4h^=W[9]^W[25],this.v5l^=W[10]^W[26],this.v5h^=W[11]^W[27],this.v6l^=W[12]^W[28],this.v6h^=W[13]^W[29],this.v7l^=W[14]^W[30],this.v7h^=W[15]^W[31],L(W)}destroy(){this.destroyed=!0,L(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},pr=Ln(e=>new fr(e));function mr(e,t){return _n.IntentMessage(_n.bytes(t.length)).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}var hr={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5,Passkey:6},gr={ED25519:32,Secp256k1:33,Secp256r1:33,Passkey:33},_r={0:`ED25519`,1:`Secp256k1`,2:`Secp256r1`,3:`MultiSig`,5:`ZkLogin`,6:`Passkey`};function vr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var yr=class{equals(e){return vr(this.toRawBytes(),e.toRawBytes())}toBase64(){return D(this.toRawBytes())}toString(){throw Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return D(this.toSuiBytes())}verifyWithIntent(e,t,n){let r=pr(mr(n,e),{dkLen:32});return this.verify(r,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(_n.byteVector().serialize(e).toBytes(),t,`PersonalMessage`)}verifyTransaction(e,t){return this.verifyWithIntent(e,t,`TransactionData`)}verifyAddress(e){return this.toSuiAddress()===e}toSuiBytes(){let e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return A(An(pr(this.toSuiBytes(),{dkLen:32})).slice(0,64))}};function br(e){let t=E(e),n=_r[t[0]];switch(n){case`ED25519`:case`Secp256k1`:case`Secp256r1`:let r=gr[n],i=t.slice(1,t.length-r);return{serializedSignature:e,signatureScheme:n,signature:i,publicKey:t.slice(1+i.length),bytes:t};default:throw Error(`Unsupported signature scheme`)}}var xr=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Sr=new Uint32Array(64),Cr=class extends Un{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Sr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Sr[e-15],n=Sr[e-2],r=R(t,7)^R(t,18)^t>>>3;Sr[e]=(R(n,17)^R(n,19)^n>>>10)+Sr[e-7]+r+Sr[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=R(o,6)^R(o,11)^R(o,25),u=l+t+Vn(o,s,c)+xr[e]+Sr[e]|0,d=(R(n,2)^R(n,13)^R(n,22))+Hn(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){L(Sr)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),L(this.buffer)}},wr=class extends Cr{A=Wn[0]|0;B=Wn[1]|0;C=Wn[2]|0;D=Wn[3]|0;E=Wn[4]|0;F=Wn[5]|0;G=Wn[6]|0;H=Wn[7]|0;constructor(){super(32)}},Tr=Jn(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Er=Tr[0],Dr=Tr[1],Or=new Uint32Array(80),kr=new Uint32Array(80),Ar=class extends Un{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Or[n]=e.getUint32(t),kr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Or[e-15]|0,n=kr[e-15]|0,r=Zn(t,n,1)^Zn(t,n,8)^Yn(t,n,7),i=Qn(t,n,1)^Qn(t,n,8)^Xn(t,n,7),a=Or[e-2]|0,o=kr[e-2]|0,s=Zn(a,o,19)^$n(a,o,61)^Yn(a,o,6),c=ar(i,Qn(a,o,19)^er(a,o,61)^Xn(a,o,6),kr[e-7],kr[e-16]);Or[e]=or(c,r,s,Or[e-7],Or[e-16])|0,kr[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Zn(u,d,14)^Zn(u,d,18)^$n(u,d,41),v=Qn(u,d,14)^Qn(u,d,18)^er(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=sr(_,v,b,Dr[e],kr[e]),S=cr(x,g,t,y,Er[e],Or[e]),C=x|0,w=Zn(n,r,28)^$n(n,r,34)^$n(n,r,39),ee=Qn(n,r,28)^er(n,r,34)^er(n,r,39),T=n&i^n&o^i&o,te=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=H(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ne=rr(C,ee,te);n=ir(ne,S,w,T),r=ne|0}({h:n,l:r}=H(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=H(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=H(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=H(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=H(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=H(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=H(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=H(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){L(Or,kr)}destroy(){this.destroyed=!0,L(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},jr=class extends Ar{Ah=V[0]|0;Al=V[1]|0;Bh=V[2]|0;Bl=V[3]|0;Ch=V[4]|0;Cl=V[5]|0;Dh=V[6]|0;Dl=V[7]|0;Eh=V[8]|0;El=V[9]|0;Fh=V[10]|0;Fl=V[11]|0;Gh=V[12]|0;Gl=V[13]|0;Hh=V[14]|0;Hl=V[15]|0;constructor(){super(64)}},Mr=Ln(()=>new wr,zn(1)),Nr=Ln(()=>new jr,zn(3)),K=(e,t,n)=>I(e,t,n),Pr=F,Fr=An,q=(...e)=>Fn(...e),Ir=e=>Mn(e),Lr=vn,Rr=e=>Rn(e),zr=BigInt(0),Br=BigInt(1);function Vr(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}" `;throw TypeError(n+`expected boolean, got type=`+typeof e)}return e}function Hr(e){if(typeof e==`bigint`){if(!$r(e))throw RangeError(`positive bigint expected, got `+e)}else Pr(e);return e}function Ur(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function Wr(e){let t=Hr(e).toString(16);return t.length&1?`0`+t:t}function Gr(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?zr:BigInt(`0x`+e)}function Kr(e){return Gr(An(e))}function qr(e){return Gr(An(Zr(I(e)).reverse()))}function Jr(e,t){if(F(t),t===0)throw RangeError(`zero length`);e=Hr(e);let n=e.toString(16);if(n.length>t*2)throw RangeError(`number too large`);return Mn(n.padStart(t*2,`0`))}function Yr(e,t){return Jr(e,t).reverse()}function Xr(e,t){if(e=K(e),t=K(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Zr(e){return Uint8Array.from(K(e))}function Qr(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}var $r=e=>typeof e==`bigint`&&zr<=e;function ei(e,t,n){return $r(e)&&$r(t)&&$r(n)&&t<=e&&e<n}function ti(e,t,n,r){if(!ei(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function ni(e){if(e<zr)throw Error(`expected non-negative bigint, got `+e);let t;for(t=0;e>zr;e>>=Br,t+=1);return t}var ri=e=>(Br<<BigInt(e))-Br;function ii(e,t,n){if(F(e,`hashLen`),F(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,q(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return q(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function ai(e,t={},n={}){if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`expected valid options object`);function r(t,n,r){if(!r&&n!==`function`&&!Object.hasOwn(e,t))throw TypeError(`param "${t}" is invalid: expected own property`);let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw TypeError(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}var oi=()=>{throw Error(`not implemented`)},J=BigInt(0),Y=BigInt(1),si=BigInt(2),ci=BigInt(3),li=BigInt(4),ui=BigInt(5),di=BigInt(7),fi=BigInt(8),pi=BigInt(9),mi=BigInt(16);function X(e,t){if(t<=J)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=J?n:t+n}function hi(e,t,n){if(t<J)throw Error(`pow2: expected non-negative exponent, got `+t);let r=e;for(;t-- >J;)r*=r,r%=n;return r}function gi(e,t){if(e===J)throw Error(`invert: expected non-zero number`);if(t<=J)throw Error(`invert: expected positive modulus, got `+t);let n=X(e,t),r=t,i=J,a=Y,o=Y,s=J;for(;n!==J;){let e=r/n,t=r-n*e,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Y)throw Error(`invert: does not exist`);return X(i,t)}function _i(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function vi(e,t){let n=e,r=(n.ORDER+Y)/li,i=n.pow(t,r);return _i(n,i,t),i}function yi(e,t){let n=e,r=(n.ORDER-ui)/fi,i=n.mul(t,si),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,si),a),c=n.mul(o,n.sub(s,n.ONE));return _i(n,c,t),c}function bi(e){let t=Mi(e),n=xi(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+di)/mi;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return _i(n,m,t),m})}function xi(e){if(e<ci)throw Error(`sqrt is not defined for small field`);let t=e-Y,n=0;for(;t%si===J;)t/=si,n++;let r=si,i=Mi(e);for(;Oi(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return vi;let a=i.pow(r,t),o=(t+Y)/si;return function(e,r){let i=e;if(i.is0(r))return r;if(Oi(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))return i.ZERO;let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=Y<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function Si(e){return e%li===ci?vi:e%fi===ui?yi:e%mi===pi?bi(e):xi(e)}var Ci=(e,t)=>(X(e,t)&Y)===Y,wi=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Ti(e){if(ai(e,wi.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,BYTES:`number`,BITS:`number`})),Ur(e.BYTES,`BYTES`),Ur(e.BITS,`BITS`),e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=Y)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function Ei(e,t,n){let r=e;if(n<J)throw Error(`invalid exponent, negatives unsupported`);if(n===J)return r.ONE;if(n===Y)return t;let i=r.ONE,a=t;for(;n>J;)n&Y&&(i=r.mul(i,a)),a=r.sqr(a),n>>=Y;return i}function Di(e,t,n=!1){let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function Oi(e,t){let n=e,r=(n.ORDER-Y)/si,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function ki(e,t){if(t!==void 0&&Pr(t),e<=J)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=ni(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected bit length (${n}) >= n.length (${t})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var Ai=new WeakMap,ji=class{ORDER;BITS;BYTES;isLE;ZERO=J;ONE=Y;_lengths;_mod;constructor(e,t={}){if(e<=Y)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=ki(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return X(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return J<=e&&e<this.ORDER}is0(e){return e===J}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Y)===Y}neg(e){return X(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return X(e*e,this.ORDER)}add(e,t){return X(e+t,this.ORDER)}sub(e,t){return X(e-t,this.ORDER)}mul(e,t){return X(e*t,this.ORDER)}pow(e,t){return Ei(this,e,t)}div(e,t){return X(e*gi(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return gi(e,this.ORDER)}sqrt(e){let t=Ai.get(this);return t||Ai.set(this,t=Si(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Yr(e,this.BYTES):Jr(e,this.BYTES)}fromBytes(e,t=!1){K(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?qr(e):Kr(e);if(o&&(s=X(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return Di(this,e)}cmov(e,t,n){return Vr(n,`condition`),n?t:e}};Object.freeze(ji.prototype);function Mi(e,t={}){return new ji(e,t)}function Ni(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=Y)throw Error(`field order must be greater than 1`);let t=ni(e-Y);return Math.ceil(t/8)}function Pi(e){let t=Ni(e);return t+Math.ceil(t/2)}function Fi(e,t,n=!1){K(e);let r=e.length,i=Ni(t),a=Math.max(Pi(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=X(n?qr(e):Kr(e),t-Y)+Y;return n?Yr(o,i):Jr(o,i)}var Ii=BigInt(0),Li=BigInt(1);function Ri(e,t){let n=t.negate();return e?n:t}function zi(e,t){let n=Di(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Bi(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function Vi(e,t){Bi(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:ri(e),maxNumber:i,shiftBy:BigInt(e)}}function Hi(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=Li);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var Ui=new WeakMap,Wi=new WeakMap;function Gi(e){return Wi.get(e)||1}function Ki(e){if(e!==Ii)throw Error(`invalid wNAF`)}var qi=class{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ii;)t&Li&&(n=n.add(r)),r=r.double(),t>>=Li;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=Vi(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=Vi(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=Hi(n,e,a);n=o,c?i=i.add(Ri(u,t[d])):r=r.add(Ri(l,t[s]))}return Ki(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=Vi(e,this.bits);for(let e=0;e<i.windows&&n!==Ii;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=Hi(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return Ki(n),r}getPrecomputes(e,t,n){let r=Ui.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),Ui.set(t,r))),r}cached(e,t,n){let r=Gi(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=Gi(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){Bi(t,this.bits),Wi.set(e,t),Ui.delete(e)}hasCache(e){return Gi(e)!==1}};function Ji(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>Ii||r>Ii;)n&Li&&(a=a.add(i)),r&Li&&(o=o.add(i)),i=i.double(),n>>=Li,r>>=Li;return{p1:a,p2:o}}function Yi(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Ti(t),t}else return Mi(e,{isLE:n})}function Xi(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>Ii))throw Error(`CURVE.${e} must be positive bigint`)}let i=Yi(t.p,n.Fp,r),a=Yi(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Zi(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function Qi(e,t){if(Ur(e),Ur(t),t<0||t>4)throw Error(`invalid I2OSP length: `+t);if(e<0||e>2**(8*t)-1)throw Error(`invalid I2OSP input: `+e);let n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function $i(e,t){let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function ea(e){if(!Lr(e)&&typeof e!=`string`)throw Error(`DST must be Uint8Array or ascii string`);let t=typeof e==`string`?Qr(e):e;if(t.length===0)throw Error(`DST must be non-empty`);return t}function ta(e,t,n,r){K(e),Ur(n),t=ea(t),t.length>255&&(t=r(q(Qr(`H2C-OVERSIZE-DST-`),t)));let{outputLen:i,blockLen:a}=r,o=Math.ceil(n/i);if(n>65535||o>255)throw Error(`expand_message_xmd: invalid lenInBytes`);let s=q(t,Qi(t.length,1)),c=new Uint8Array(a),l=Qi(n,2),u=Array(o),d=r(q(c,e,l,Qi(0,1),s));u[0]=r(q(d,Qi(1,1),s));for(let e=1;e<o;e++)u[e]=r(q($i(d,u[e-1]),Qi(e+1,1),s));return q(...u).slice(0,n)}var na=`HashToScalar-`,ra=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(yn(e),I(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),L(r)}update(e){return bn(this),this.iHash.update(e),this}digestInto(e){bn(this),xn(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ia=(()=>{let e=((e,t,n)=>new ra(e,t).update(n).digest());return e.create=(e,t)=>new ra(e,t),e})(),aa=(e,t)=>(e+(e>=0?t:-t)/la)/t;function oa(e,t,n){ti(`scalar`,e,Q,n);let[[r,i],[a,o]]=t,s=aa(o*e,n),c=aa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Q,f=u<Q;d&&(l=-l),f&&(u=-u);let p=ri(Math.ceil(ni(n)/2))+$;if(l<Q||l>=p||u<Q||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function sa(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function ca(e,t){ai(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Vr(n.lowS,`lowS`),Vr(n.prehash,`prehash`),n.format!==void 0&&sa(n.format),n}var Z={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Z;if(Ur(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(typeof t!=`string`)throw TypeError(`"data" expected string, got type=`+typeof t);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=Wr(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?Wr(i.length/2|128):``;return Wr(e)+a+i+t},decode(e,t){let{Err:n}=Z;t=K(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Z;if(Hr(e),e<Q)throw new t(`integer: negative integers are not allowed`);let n=Wr(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Z;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Kr(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=Z,i=K(e,void 0,`signature`),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=Z,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};Object.freeze(Z._tlv),Object.freeze(Z._int),Object.freeze(Z);var Q=BigInt(0),$=BigInt(1),la=BigInt(2),ua=BigInt(3),da=BigInt(4);function fa(e,t={}){let n=Xi(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;ai(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`});let{endo:c,allowInfinityPoint:l}=t;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let u=ma(r,i);function d(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function f(e,t,n){if(l&&t.is0())return Uint8Array.of(0);let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return Vr(n,`isCompressed`),n?(d(),q(pa(!r.isOdd(a)),o)):q(Uint8Array.of(4),o,r.toBytes(a))}function p(e){K(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=u,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=g(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}d();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!_(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let m=t.toBytes===void 0?f:t.toBytes,h=t.fromBytes===void 0?p:t.fromBytes;function g(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function _(e,t){let n=r.sqr(t),i=g(e);return r.eql(n,i)}if(!_(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let v=r.mul(r.pow(a.a,ua),da),y=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(v,y)))throw Error(`bad curve params: a or b`);function b(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function x(e){if(!(e instanceof w))throw Error(`Weierstrass Point expected`)}function S(e){if(!c||!c.basises)throw Error(`no endo`);return oa(e,c.basises,i.ORDER)}function C(e,t,n,i,a){return n=new w(r.mul(n.X,e),n.Y,n.Z),t=Ri(i,t),n=Ri(a,n),t.add(n)}class w{static BASE=new w(a.Gx,a.Gy,r.ONE);static ZERO=new w(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=b(`x`,e),this.Y=b(`y`,t,!0),this.Z=b(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof w)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?w.ZERO:new w(t,n,r.ONE)}static fromBytes(e){let t=w.fromAffine(h(K(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return w.fromBytes(Ir(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return T.createCache(this,e),t||this.multiply(ua),this}assertValidity(){let e=this;if(e.is0()){if(t.allowInfinityPoint&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!_(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){x(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new w(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,ua),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new w(c,l,u)}add(e){x(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,ua),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new w(l,u,d)}subtract(e){return x(e),this.add(e.negate())}is0(){return this.equals(w.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let r,a,o=e=>T.cached(this,e,e=>zi(w,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=S(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=C(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return zi(w,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this,a=e;if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(a===Q||r.is0())return w.ZERO;if(a===$)return r;if(T.hasCache(this))return this.multiply(a);if(n){let{k1neg:e,k1:t,k2neg:i,k2:o}=S(a),{p1:s,p2:c}=Ji(w,r,t,o);return C(n.beta,s,c,e,i)}else return T.unsafe(r,a)}toAffine(e){let t=this,n=e,{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){let{isTorsionFree:e}=t;return o===$?!0:e?e(w,this):T.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===$?this:e?e(w,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===$?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return Vr(e,`isCompressed`),this.assertValidity(),m(w,this,e)}toHex(e=!0){return Fr(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ee=i.BITS,T=new qi(w,t.endo?Math.ceil(ee/2):ee);return ee>=8&&w.BASE.precompute(8),Object.freeze(w.prototype),Object.freeze(w),w}function pa(e){return Uint8Array.of(e?2:3)}function ma(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ha(e,t={}){let{Fn:n}=e,r=t.randomBytes===void 0?Rr:t.randomBytes,i=Object.assign(ma(e.Fp,n),{seed:Math.max(Pi(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,Fi(K(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!Lr(e))return;let s=K(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t);return e.fromBytes(r).multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Zi(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function ga(e,t,n={}){let r=t;yn(r),ai(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`}),n=Object.assign({},n);let i=n.randomBytes===void 0?Rr:n.randomBytes,a=n.hmac===void 0?(e,t)=>ia(r,e,t):n.hmac,{Fp:o,Fn:s}=e,{ORDER:c,BITS:l}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:m}=ha(e,n),h={prehash:!0,lowS:typeof n.lowS==`boolean`?n.lowS:!0,format:`compact`,extraEntropy:!1},g=c*la+$<o.ORDER;function _(e){return e>c>>$}function v(e,t){if(!s.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function y(){if(g)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function b(e,t){sa(t);let n=m.signature;return K(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class x{r;s;recovery;constructor(e,t,n){if(this.r=v(`r`,e),this.s=v(`s`,t),n!=null){if(y(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=h.format){b(e,t);let n;if(t===`der`){let{r:t,s:n}=Z.toSig(K(e));return new x(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=m.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new x(s.fromBytes(i),s.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(Ir(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new x(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+c:n;if(!o.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let l=o.toBytes(a),u=e.fromBytes(q(pa((i&1)==0),l)),d=s.inv(a),f=C(K(t,void 0,`msgHash`)),p=s.create(-f*d),m=s.create(r*d),h=e.BASE.multiplyUnsafe(p).add(u.multiplyUnsafe(m));if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return _(this.s)}toBytes(e=h.format){if(sa(e),e===`der`)return Ir(Z.hexFromSig(this));let{r:t,s:n}=this,r=s.toBytes(t),i=s.toBytes(n);return e===`recovered`?(y(),q(Uint8Array.of(this.assertRecovery()),r,i)):q(r,i)}toHex(e){return Fr(this.toBytes(e))}}Object.freeze(x.prototype),Object.freeze(x);let S=n.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Kr(e),n=e.length*8-l;return n>0?t>>BigInt(n):t}:n.bits2int,C=n.bits2int_modN===void 0?function(e){return s.create(S(e))}:n.bits2int_modN,w=ri(l);function ee(e){return ti(`num < 2^`+l,e,Q,w),s.toBytes(e)}function T(e,t){return K(e,void 0,`message`),t?K(r(e),void 0,`prehashed message`):e}function te(t,n,r){let{lowS:a,prehash:o,extraEntropy:c}=ca(r,h);t=T(t,o);let l=C(t),u=s.fromBytes(n);if(!s.isValidNot0(u))throw Error(`invalid private key`);let d=[ee(u),ee(l)];if(c!=null&&c!==!1){let e=c===!0?i(m.secretKey):c;d.push(K(e,void 0,`extraEntropy`))}let f=q(...d),p=l;function v(t){let n=S(t);if(!s.isValidNot0(n))return;let r=s.inv(n),i=e.BASE.multiply(n).toAffine(),o=s.create(i.x);if(o===Q)return;let c=s.create(r*s.create(p+o*u));if(c===Q)return;let l=(i.x===o?0:2)|Number(i.y&$),d=c;return a&&_(c)&&(d=s.neg(c),l^=1),new x(o,d,g?void 0:l)}return{seed:f,k2sig:v}}function ne(e,t,n={}){let{seed:i,k2sig:o}=te(e,t,n);return ii(r.outputLen,s.BYTES,a)(i,o).toBytes(n.format)}function re(t,n,r,i={}){let{lowS:a,prehash:o,format:c}=ca(i,h);if(r=K(r,void 0,`publicKey`),n=T(n,o),!Lr(t)){let e=t instanceof x?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}b(t,c);try{let i=x.fromBytes(t,c),o=e.fromBytes(r);if(a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=C(n),f=s.inv(u),p=s.create(d*f),m=s.create(l*f),h=e.BASE.multiplyUnsafe(p).add(o.multiplyUnsafe(m));return h.is0()?!1:s.create(h.x)===l}catch{return!1}}function ie(e,t,n={}){let{prehash:r}=ca(n,h);return t=T(t,r),x.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:m,Point:e,sign:ne,verify:re,recoverPublicKey:ie,Signature:x,hash:r})}var _a=ga(fa({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),Mr);new Uint8Array([48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0]),class extends yr{static{this.SIZE=33}constructor(e){if(super(),typeof e==`string`?this.data=E(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==33)throw Error(`Invalid public key input. Expected 33 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return hr.Passkey}async verify(e,t){let n=va(t),r=JSON.parse(n.clientDataJson);if(r.type!==`webauthn.get`||!vr(e,E(r.challenge.replace(/-/g,`+`).replace(/_/g,`/`))))return!1;let i=n.userSignature.slice(65);if(!vr(this.toRawBytes(),i))return!1;let a=new Uint8Array([...n.authenticatorData,...Mr(new TextEncoder().encode(n.clientDataJson))]),o=n.userSignature.slice(1,65);return _a.verify(o,a,i)}};function va(e){let t=typeof e==`string`?E(e):e;if(t[0]!==hr.Passkey)throw Error(`Invalid signature scheme`);let n=Bt.parse(t.slice(1));return{signatureScheme:`Passkey`,serializedSignature:D(t),signature:t,authenticatorData:n.authenticatorData,clientDataJson:n.clientDataJson,userSignature:new Uint8Array(n.userSignature),publicKey:new Uint8Array(n.userSignature.slice(65))}}function ya(e){for(let t=0;t<e.length;t++)if(e[t]!==0)return t;return-1}function ba(e,t){return Mn(e.toString(16).padStart(t*2,`0`).slice(-t*2))}function xa(e,t){let n=ba(e,t),r=ya(n);return r===-1?new Uint8Array([0]):n.slice(r)}function Sa(e){return e===`accounts.google.com`?`https://accounts.google.com`:e}function Ca(e){if(e.length!==1)throw Error(`Invalid base64Url character: `+e);let t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(e);if(t===-1)throw Error(`Invalid base64Url character: `+e);let n=t.toString(2).padStart(6,`0`);return Array.from(n).map(Number)}function wa(e){let t=[];for(let n=0;n<e.length;n++){let r=Ca(e.charAt(n));t=t.concat(r)}return t}function Ta(e,t){if(e.length<2)throw Error(`Input (s = ${e}) is not tightly packed because s.length < 2`);let n=wa(e),r=t%4;if(r!==0)if(r===1)n=n.slice(2);else if(r===2)n=n.slice(4);else throw Error(`Input (s = ${e}) is not tightly packed because i%4 = 3 (i = ${t}))`);let i=(t+e.length-1)%4;if(i!==3)if(i===2)n=n.slice(0,n.length-2);else if(i===1)n=n.slice(0,n.length-4);else throw Error(`Input (s = ${e}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${t}))`);if(n.length%8!=0)throw Error(`We should never reach here...`);let a=new Uint8Array(Math.floor(n.length/8)),o=0;for(let e=0;e<n.length;e+=8){let t=n.slice(e,e+8),r=parseInt(t.join(``),2);a[o++]=r}return new TextDecoder().decode(a)}function Ea(e){if(!(e.slice(-1)===`}`||e.slice(-1)===`,`))throw Error(`Invalid claim`);let t=JSON.parse(`{`+e.slice(0,-1)+`}`);if(Object.keys(t).length!==1)throw Error(`Invalid claim`);let n=Object.keys(t)[0];return[n,t[n]]}function Da(e,t){let[n,r]=Ea(Ta(e.value,e.indexMod4));if(n!==t)throw Error(`Invalid field name: found ${n} expected ${t}`);return r}var Oa=k.struct(`ZkLoginSignature`,{inputs:k.struct(`ZkLoginSignatureInputs`,{proofPoints:k.struct(`ZkLoginSignatureInputsProofPoints`,{a:k.vector(k.string()),b:k.vector(k.vector(k.string())),c:k.vector(k.string())}),issBase64Details:k.struct(`ZkLoginSignatureInputsClaim`,{value:k.string(),indexMod4:k.u8()}),headerBase64:k.string(),addressSeed:k.string()}),maxEpoch:k.u64(),userSignature:k.byteVector()});function ka(e){return Oa.parse(typeof e==`string`?E(e):e)}var Aa=class e extends yr{#e;#t;#n;constructor(e,{client:t}={}){super(),this.#t=t,typeof e==`string`?this.#e=E(e):e instanceof Uint8Array?this.#e=e:this.#e=Uint8Array.from(e),this.#n=this.#e.length!==this.#e[0]+1+32,this.#n&&(this.#e=Ma(this.#e,!1))}static fromBytes(t,{client:n,address:r,legacyAddress:i}={}){let a;if(i===!0?a=new e(Ma(t,!0),{client:n}):i===!1?a=new e(Ma(t,!1),{client:n}):r?(a=new e(Ma(t,!1),{client:n}),a.toSuiAddress()!==r&&(a=new e(Ma(t,!0),{client:n}))):a=new e(t,{client:n}),r&&a.toSuiAddress()!==r)throw Error(`Public key bytes do not match the provided address`);return a}static fromProof(e,t){let{issBase64Details:n,addressSeed:r}=t,i=Da(n,`iss`),a=ja(BigInt(r),i,{legacyAddress:!0});if(a.toSuiAddress()===e)return a;let o=ja(BigInt(r),i,{legacyAddress:!1});if(o.toSuiAddress()!==e)throw Error(`Proof does not match address`);return o}equals(e){return super.equals(e)}toSuiAddress(){return this.#n?this.#r():super.toSuiAddress()}#r(){let e=Ma(this.#e,!0),t=new Uint8Array(e.length+1);return t[0]=this.flag(),t.set(e,1),A(An(pr(t,{dkLen:32})).slice(0,64))}toRawBytes(){return this.#e}flag(){return hr.ZkLogin}async verify(e,t){throw Error(`does not support`)}verifyPersonalMessage(t,n){let r=Pa(n);return Na({address:new e(r.publicKey).toSuiAddress(),bytes:D(t),signature:r.serializedSignature,intentScope:`PersonalMessage`,client:this.#t})}verifyTransaction(t,n){let r=Pa(n);return Na({address:new e(r.publicKey).toSuiAddress(),bytes:D(t),signature:r.serializedSignature,intentScope:`TransactionData`,client:this.#t})}verifyAddress(e){return e===super.toSuiAddress()||e===this.#r()}};function ja(e,t,n){if(n.legacyAddress===void 0)throw Error(`legacyAddress parameter must be specified`);let r=n.legacyAddress?xa(e,32):ba(e,32),i=new TextEncoder().encode(Sa(t)),a=new Uint8Array(1+i.length+r.length);return a.set([i.length],0),a.set(i,1),a.set(r,1+i.length),new Aa(a,n)}function Ma(e,t){let n=e[0]+1,r=BigInt(`0x${me(e.slice(n))}`),i=t?xa(r,32):ba(r,32),a=new Uint8Array(n+i.length);return a.set(e.slice(0,n),0),a.set(i,n),a}async function Na({address:e,bytes:t,signature:n,intentScope:r,client:i}){if(!i)throw Error(`A Sui Client (GRPC, GraphQL, or JSON RPC) is required to verify zkLogin signatures`);let a=await i.core.verifyZkLoginSignature({bytes:t,signature:n,intentScope:r,address:e});return a.success===!0&&a.errors.length===0}function Pa(e){let t=typeof e==`string`?E(e):e;if(t[0]!==hr.ZkLogin)throw Error(`Invalid signature scheme`);let{inputs:n,maxEpoch:r,userSignature:i}=ka(t.slice(1)),{issBase64Details:a,addressSeed:o}=n,s=Da(a,`iss`),c=ja(BigInt(o),s,{legacyAddress:!1});return{serializedSignature:D(t),signatureScheme:`ZkLogin`,zkLogin:{inputs:n,maxEpoch:r,userSignature:i,iss:s,addressSeed:BigInt(o)},signature:t,publicKey:c.toRawBytes()}}function Fa({signature:e,signatureScheme:t,publicKey:n}){if(!n)throw Error("`publicKey` is required");let r=n.toRawBytes(),i=new Uint8Array(1+e.length+r.length);return i.set([hr[t]]),i.set(e,1),i.set(r,1+e.length),D(i)}function Ia(e){let t=E(e),n=_r[t[0]];switch(n){case`Passkey`:return va(e);case`MultiSig`:return{serializedSignature:e,signatureScheme:n,multisig:_n.MultiSig.parse(t.slice(1)),bytes:t,signature:void 0};case`ZkLogin`:return Pa(e);case`ED25519`:case`Secp256k1`:case`Secp256r1`:return br(e);default:throw Error(`Unsupported signature scheme`)}}var La=`suiprivkey`,Ra=class{async signWithIntent(e,t){let n=pr(mr(t,e),{dkLen:32});return{signature:Fa({signature:await this.sign(n),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:D(e)}}async signTransaction(e){return this.signWithIntent(e,`TransactionData`)}async signPersonalMessage(e){let{signature:t}=await this.signWithIntent(k.byteVector().serialize(e).toBytes(),`PersonalMessage`);return{bytes:D(e),signature:t}}async signAndExecuteTransaction({transaction:e,client:t}){e.setSenderIfNotSet(this.toSuiAddress());let n=await e.build({client:t}),{signature:r}=await this.signTransaction(n);return t.core.executeTransaction({transaction:n,signatures:[r],include:{transaction:!0,effects:!0}})}toSuiAddress(){return this.getPublicKey().toSuiAddress()}},za=class extends Ra{};function Ba(e){let{prefix:t,words:n}=le.decode(e);if(t!==`suiprivkey`)throw Error(`invalid private key prefix`);let r=new Uint8Array(le.fromWords(n)),i=r.slice(1);return{scheme:_r[r[0]],secretKey:i}}function Va(e,t){if(e.length!==32)throw Error(`Invalid bytes length`);let n=hr[t],r=new Uint8Array(e.length+1);return r.set([n]),r.set(e,1),le.encode(La,le.toWords(r))}var Ha=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Ua=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},Wa,Ga,Ka,qa,Ja,Ya,Xa=class e{get address(){return Ha(this,Wa,`f`)}get publicKey(){return Ha(this,Ga,`f`).slice()}get chains(){return Ha(this,Ka,`f`).slice()}get features(){return Ha(this,qa,`f`).slice()}get label(){return Ha(this,Ja,`f`)}get icon(){return Ha(this,Ya,`f`)}constructor(t){Wa.set(this,void 0),Ga.set(this,void 0),Ka.set(this,void 0),qa.set(this,void 0),Ja.set(this,void 0),Ya.set(this,void 0),new.target===e&&Object.freeze(this),Ua(this,Wa,t.address,`f`),Ua(this,Ga,t.publicKey.slice(),`f`),Ua(this,Ka,t.chains.slice(),`f`),Ua(this,qa,t.features.slice(),`f`),Ua(this,Ja,t.label,`f`),Ua(this,Ya,t.icon,`f`)}};Wa=new WeakMap,Ga=new WeakMap,Ka=new WeakMap,qa=new WeakMap,Ja=new WeakMap,Ya=new WeakMap;var Za=[`sui:devnet`,`sui:testnet`,`sui:localnet`,`sui:mainnet`],Qa=[`sui:signTransaction`,`sui:signAndExecuteTransaction`,`sui:signPersonalMessage`];function $a(e,t,n,r){return{address:t,label:n,signer:e,walletAccount:new Xa({address:t,label:n,publicKey:e.getPublicKey().toSuiBytes(),chains:[...Za],features:[...r??Qa]})}}var eo=class{constructor(){this.allowAutoSign=!0,this.#e=[],this.#t=new Set}#e;#t;getAccounts(){return[...this.#e]}getAccount(e){return this.#e.find(t=>t.address===e)}onAccountsChanged(e){return this.#t.add(e),()=>{this.#t.delete(e)}}destroy(){this.#e=[],this.#t.clear()}get _accounts(){return this.#e}setInitialAccounts(e){this.#e=e,this.notifyListeners()}addAccount(e){this.#e.push(e),this.notifyListeners()}removeAccountByAddress(e){let t=this.#e.findIndex(t=>t.address===e);return t===-1?!1:(this.#e.splice(t,1),this.notifyListeners(),!0)}replaceAccount(e,t){let n=this.#e.findIndex(t=>t.address===e);return n===-1?!1:(this.#e[n]=t,this.notifyListeners(),!0)}_performRename(e,t){let n=this.getAccount(e);return n?this.replaceAccount(e,$a(n.signer,e,t)):!1}getDefaultLabel(){return`Account ${this.getAccounts().length+1}`}notifyListeners(){let e=this.getAccounts();for(let t of this.#t)t(e)}};export{gn as $,Zr as A,vr as B,ti as C,Fr as D,Ur as E,Rr as F,yn as G,hr as H,ai as I,L as J,F as K,Mr as L,Ir as M,Lr as N,qr as O,oi as P,_n as Q,Nr as R,hi as S,K as T,pr as U,br as V,I as W,Mn as X,Cn as Y,Pn as Z,zi as _,Ra as a,Ke as at,Ci as b,Ia as c,Ge as ct,fa as d,me as dt,en as et,ia as f,E as ft,Zi as g,Xi as h,ue as ht,za as i,Ie as it,Xr as j,q as k,_a as l,be as lt,ta as m,de as mt,$a as n,et as nt,Ba as o,A as ot,na as p,D as pt,In as q,Za as r,tt as rt,Va as s,qe as st,eo as t,it as tt,ga as u,pe as ut,qi as v,Vr as w,X as x,Mi as y,yr as z};
1
+ var e=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,t=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,n=235;function r(r){return r.length>n?!1:r.includes(`@`)?e.test(r):t.test(r)}function i(e){let t=BigInt(e),n=[],r=0;if(t===0n)return[0];for(;t>0;)n[r]=Number(t&127n),t>>=7n,t>0n&&(n[r]|=128),r+=1;return n}function a(e){let t=0n,n=0n,r=0;for(;;){if(r>=e.length)throw Error(`ULEB decode error: buffer overflow`);let i=e[r];if(r+=1,t+=BigInt(i&127)<<n,!(i&128))break;n+=7n}if(t>BigInt(2**53-1))throw Error(`ULEB decode error: value exceeds MAX_SAFE_INTEGER`);return{value:Number(t),length:r}}var o=class{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,`0`);return BigInt(`0x`+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,`0`);return BigInt(`0x`+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,`0`);return BigInt(`0x`+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,{value:t,length:n}=a(new Uint8Array(this.dataView.buffer,e));return this.shift(n),t}readVec(e){let t=this.readULEB(),n=[];for(let r=0;r<t;r++)n.push(e(this,r,t));return n}};function s(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function c(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(e=>typeof e==`string`):t.every(e=>Number.isSafeInteger(e)):!1}function l(e){if(typeof e!=`function`)throw TypeError(`function expected`);return!0}function u(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}function d(e){if(typeof e!=`number`)throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function f(e){if(!Array.isArray(e))throw TypeError(`array expected`)}function p(e,t){if(!c(!0,t))throw TypeError(`${e}: array of strings expected`)}function m(e,t){if(!c(!1,t))throw TypeError(`${e}: array of numbers expected`)}function h(...e){let t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function g(e){let t=typeof e==`string`?e.split(``):e,n=t.length;p(`alphabet`,t);let r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(f(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(f(t),t.map(t=>{u(`alphabet.decode`,t);let n=r.get(t);if(n===void 0)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}function _(e=``){return u(`join`,e),{encode:t=>(p(`join.decode`,t),t.join(e)),decode:t=>(u(`join.decode`,t),t.split(e))}}function v(e,t=`=`){return d(e),u(`padding`,t),{encode(n){for(p(`padding.encode`,n);n.length*e%8;)n.push(t);return n},decode(n){p(`padding.decode`,n);let r=n.length;if(r*e%8)throw Error(`padding: invalid, string should have whole number of bytes`);for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8==0)throw Error(`padding: invalid, string has too much padding`);return n.slice(0,r)}}}function y(e){return l(e),{encode:e=>e,decode:t=>e(t)}}function b(e,t,n){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw RangeError(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(f(e),!e.length)return[];let r=0,i=[],a=Array.from(e,e=>{if(d(e),e<0||e>=t)throw Error(`invalid integer: ${e}`);return e}),o=a.length;for(;;){let e=0,s=!0;for(let i=r;i<o;i++){let o=a[i],c=t*e,l=c+o;if(!Number.isSafeInteger(l)||c/t!==e||l-o!==c)throw Error(`convertRadix: carry overflow`);let u=l/n;e=l%n;let d=Math.floor(u);if(a[i]=d,!Number.isSafeInteger(d)||d*n+e!==l)throw Error(`convertRadix: carry overflow`);if(s)d?s=!1:r=i;else continue}if(i.push(e),s)break}for(let t=0;t<e.length-1&&e[t]===0;t++)i.push(0);return i.reverse()}var x=(e,t)=>t===0?e:x(t,e%t),S=(e,t)=>e+(t-x(e,t)),C=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function w(e,t,n,r){if(f(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw RangeError(`convertRadix2: wrong to=${n}`);if(S(t,n)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${S(t,n)}`);let i=0,a=0,o=C[t],s=C[n]-1,c=[];for(let r of e){if(d(r),r>=o)throw Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,a+t>32)throw Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=n;a-=n)c.push((i>>a-n&s)>>>0);let e=C[a];if(e===void 0)throw Error(`invalid carry`);i&=e-1}if(i=i<<n-a&s,!r&&a>=t)throw Error(`Excess padding`);if(!r&&i>0)throw Error(`Non-zero padding: ${i}`);return r&&a>0&&c.push(i>>>0),c}function ee(e){return d(e),{encode:t=>{if(!s(t))throw TypeError(`radix.encode input should be Uint8Array`);return b(Array.from(t),256,e)},decode:t=>(m(`radix.decode`,t),Uint8Array.from(b(t,e,256)))}}function T(e,t=!1){if(d(e),e<=0||e>32)throw RangeError(`radix2: bits should be in (0..32]`);if(S(8,e)>32||S(e,8)>32)throw RangeError(`radix2: carry overflow`);return{encode:n=>{if(!s(n))throw TypeError(`radix2.encode input should be Uint8Array`);return w(Array.from(n),8,e,!t)},decode:n=>(m(`radix2.decode`,n),Uint8Array.from(w(n,e,8,t)))}}function te(e){return l(e),function(...t){try{return e.apply(null,t)}catch{}}}h(T(4),g(`0123456789ABCDEF`),_(``)),h(T(5),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),v(5),_(``)),h(T(5),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),_(``)),h(T(5),g(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),v(5),_(``)),h(T(5),g(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),_(``)),h(T(5),g(`0123456789ABCDEFGHJKMNPQRSTVWXYZ`),_(``),y(e=>e.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`)));var ne=typeof Uint8Array.from([]).toBase64==`function`&&typeof Uint8Array.fromBase64==`function`;ne||h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),v(6),_(``)),h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),_(``)),ne||h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),v(6),_(``)),h(T(6),g(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),_(``));var re=Object.freeze((e=>h(ee(58),g(e),_(``)))(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)),ie=h(g(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),_(``)),ae=[996825010,642813549,513874426,1027748829,705979059];function oe(e){let t=e>>25,n=(e&33554431)<<5;for(let e=0;e<ae.length;e++)(t>>e&1)==1&&(n^=ae[e]);return n}function se(e,t,n=1){let r=e.length,i=1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n<33||n>126)throw Error(`Invalid prefix (${e})`);i=oe(i)^n>>5}i=oe(i);for(let t=0;t<r;t++)i=oe(i)^e.charCodeAt(t)&31;for(let e of t)i=oe(i)^e;for(let e=0;e<6;e++)i=oe(i);return i^=n,ie.encode(w([i%C[30]],30,5,!1))}function ce(e){let t=e===`bech32`?1:734539939,n=T(5),r=n.decode,i=n.encode,a=te(r);function o(e,n,r=90){u(`bech32.encode prefix`,e),s(n)&&(n=Array.from(n)),m(`bech32.encode`,n);let i=e.length;if(i===0)throw TypeError(`Invalid prefix length ${i}`);let a=i+7+n.length;if(r!==!1&&a>r)throw TypeError(`Length ${a} exceeds limit ${r}`);let o=e.toLowerCase(),c=se(o,n,t);return`${o}1${ie.encode(n)}${c}`}function c(e,n=90){u(`bech32.decode input`,e);let r=e.length;if(r<8||n!==!1&&r>n)throw TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);let i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw Error(`String must be lowercase or uppercase`);let a=i.lastIndexOf(`1`);if(a===0||a===-1)throw Error(`Letter "1" must be present between prefix and data only`);let o=i.slice(0,a),s=i.slice(a+1);if(s.length<6)throw Error(`Data must be at least 6 characters long`);let c=ie.decode(s).slice(0,-6),l=se(o,c,t);if(!s.endsWith(l))throw Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:o,words:c}}let l=te(c);function d(e){let{prefix:t,words:n}=c(e,!1);return{prefix:t,words:n,bytes:r(n)}}function f(e,t){return o(e,i(t))}return{encode:o,decode:c,encodeFromBytes:f,decodeToBytes:d,decodeUnsafe:l,fromWords:r,fromWordsUnsafe:a,toWords:i}}var le=Object.freeze(ce(`bech32`));ce(`bech32m`),typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`||h(T(4),g(`0123456789abcdef`),_(``),y(e=>{if(typeof e!=`string`||e.length%2!=0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));var ue=e=>re.encode(e),de=e=>re.decode(e);function E(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}var fe=8192;function D(e){if(e.length<fe)return btoa(String.fromCharCode(...e));let t=``;for(var n=0;n<e.length;n+=fe){let r=e.slice(n,n+fe);t+=String.fromCharCode(...r)}return btoa(t)}function pe(e){let t=e.startsWith(`0x`)?e.slice(2):e,n=t.length%2==0?t:`0${t}`,r=n.match(/[0-9a-fA-F]{2}/g)?.map(e=>parseInt(e,16))??[];if(r.length!==n.length/2)throw Error(`Invalid hex string ${e}`);return Uint8Array.from(r)}function me(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}function he(e,t){switch(t){case`base58`:return ue(e);case`base64`:return D(e);case`hex`:return me(e);default:throw Error(`Unsupported encoding, supported values are: base64, hex`)}}function ge(e,t=[`<`,`>`]){let[n,r]=t,i=[],a=``,o=0;for(let t=0;t<e.length;t++){let s=e[t];if(s===n&&o++,s===r&&o--,o===0&&s===`,`){i.push(a.trim()),a=``;continue}a+=s}return i.push(a.trim()),i}var _e=class{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){let t=this.bytePosition+e;if(t>this.size){let e=Math.min(this.maxSize,Math.max(this.size+t,this.size+this.allocateSize));if(t>e)throw Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;let n=new ArrayBuffer(this.size);new Uint8Array(n).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(n)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}writeBytes(e){this.ensureSizeOrGrow(e.length);for(let t=0;t<e.length;t++)this.dataView.setUint8(this.bytePosition+t,e[t]);return this.shift(e.length)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return ve(BigInt(e),8).forEach(e=>this.write8(e)),this}write128(e){return ve(BigInt(e),16).forEach(e=>this.write8(e)),this}write256(e){return ve(BigInt(e),32).forEach(e=>this.write8(e)),this}writeULEB(e){return i(e).forEach(e=>this.write8(e)),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach((n,r)=>t(this,n,r,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return he(this.toBytes(),e)}};function ve(e,t){let n=new Uint8Array(t),r=0;for(;e>0;)n[r]=Number(e%BigInt(256)),e/=BigInt(256),r+=1;return n}var O=class e{#e;#t;constructor(e){this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),this.#e=e.write,this.#t=e.serialize??((e,t)=>{let n=new _e({initialSize:this.serializedSize(e)??void 0,...t});return this.#e(e,n),n.toBytes()}),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),this.#e(e,t)}serialize(e,t){return this.validate(e),new xe(this,this.#t(e,t))}parse(e){let t=new o(e);return this.read(t)}fromHex(e){return this.parse(pe(e))}fromBase58(e){return this.parse(de(e))}fromBase64(e){return this.parse(E(e))}transform({name:t,input:n,output:r,validate:i}){return new e({name:t??this.name,read:e=>r?r(this.read(e)):this.read(e),write:(e,t)=>this.#e(n?n(e):e,t),serializedSize:e=>this.serializedSize(n?n(e):e),serialize:(e,t)=>this.#t(n?n(e):e,t),validate:e=>{i?.(e),this.validate(n?n(e):e)}})}},ye=Symbol.for(`@mysten/serialized-bcs`);function be(e){return!!e&&typeof e==`object`&&e[ye]===!0}var xe=class{#e;#t;get[ye](){return!0}constructor(e,t){this.#e=e,this.#t=t}toBytes(){return this.#t}toHex(){return me(this.#t)}toBase64(){return D(this.#t)}toBase58(){return ue(this.#t)}parse(){return this.#e.parse(this.#t)}};function Se({size:e,...t}){return new O({...t,serializedSize:()=>e})}function Ce({readMethod:e,writeMethod:t,...n}){return Se({...n,read:t=>t[e](),write:(e,n)=>n[t](e),validate:e=>{if(e<0||e>n.maxValue)throw TypeError(`Invalid ${n.name} value: ${e}. Expected value in range 0-${n.maxValue}`);n.validate?.(e)}})}function we({readMethod:e,writeMethod:t,...n}){return Se({...n,read:t=>t[e](),write:(e,n)=>n[t](BigInt(e)),validate:e=>{let t=BigInt(e);if(t<0||t>n.maxValue)throw TypeError(`Invalid ${n.name} value: ${t}. Expected value in range 0-${n.maxValue}`);n.validate?.(t)}})}function Te({serialize:e,...t}){let n=new O({...t,serialize:e,write:(e,t)=>{for(let r of n.serialize(e).toBytes())t.write8(r)}});return n}function Ee({toBytes:e,fromBytes:t,...n}){return new O({...n,read:e=>{let n=e.readULEB();return t(e.readBytes(n))},write:(t,n)=>{let r=e(t);n.writeULEB(r.length);for(let e=0;e<r.length;e++)n.write8(r[e])},serialize:t=>{let n=e(t),r=i(n.length),a=new Uint8Array(r.length+n.length);return a.set(r,0),a.set(n,r.length),a},validate:e=>{if(typeof e!=`string`)throw TypeError(`Invalid ${n.name} value: ${e}. Expected string`);n.validate?.(e)}})}function De(e){let t=null;function n(){return t||=e(),t}return new O({name:`lazy`,read:e=>n().read(e),serializedSize:e=>n().serializedSize(e),write:(e,t)=>n().write(e,t),serialize:(e,t)=>n().serialize(e,t).toBytes()})}var Oe=class extends O{constructor({name:e,fields:t,...n}){let r=Object.entries(t);super({name:e,serializedSize:e=>{let t=0;for(let[n,i]of r){let r=i.serializedSize(e[n]);if(r==null)return null;t+=r}return t},read:e=>{let t={};for(let[n,i]of r)t[n]=i.read(e);return t},write:(e,t)=>{for(let[n,i]of r)i.write(e[n],t)},...n,validate:e=>{if(n?.validate?.(e),typeof e!=`object`||!e)throw TypeError(`Expected object, found ${typeof e}`)}})}},ke=class extends O{constructor({fields:e,...t}){let n=Object.entries(e);super({read:e=>{let r=e.readULEB(),i=n[r];if(!i)throw TypeError(`Unknown value ${r} for enum ${t.name}`);let[a,o]=i;return{[a]:o?.read(e)??!0,$kind:a}},write:(t,r)=>{let[i,a]=Object.entries(t).filter(([t])=>Object.hasOwn(e,t))[0];for(let e=0;e<n.length;e++){let[t,o]=n[e];if(t===i){r.writeULEB(e),o?.write(a,r);return}}},...t,validate:n=>{if(t?.validate?.(n),typeof n!=`object`||!n)throw TypeError(`Expected object, found ${typeof n}`);let r=Object.keys(n).filter(t=>n[t]!==void 0&&Object.hasOwn(e,t));if(r.length!==1)throw TypeError(`Expected object with one key, but found ${r.length} for type ${t.name}}`);let[i]=r;if(!Object.hasOwn(e,i))throw TypeError(`Invalid enum variant ${i}`)}})}},Ae=class extends O{constructor({fields:e,name:t,...n}){super({name:t??`(${e.map(e=>e.name).join(`, `)})`,serializedSize:t=>{let n=0;for(let r=0;r<e.length;r++){let i=e[r].serializedSize(t[r]);if(i==null)return null;n+=i}return n},read:t=>{let n=[];for(let r of e)n.push(r.read(t));return n},write:(t,n)=>{for(let r=0;r<e.length;r++)e[r].write(t[r],n)},...n,validate:t=>{if(n?.validate?.(t),!Array.isArray(t))throw TypeError(`Expected array, found ${typeof t}`);if(t.length!==e.length)throw TypeError(`Expected array of length ${e.length}, found ${t.length}`)}})}};function je(e,t,n){return new O({read:n=>{let r=Array(e);for(let i=0;i<e;i++)r[i]=t.read(n);return r},write:(e,n)=>{for(let r of e)t.write(r,n)},...n,name:n?.name??`${t.name}[${e}]`,validate:t=>{if(n?.validate?.(t),!t||typeof t!=`object`||!(`length`in t))throw TypeError(`Expected array, found ${typeof t}`);if(t.length!==e)throw TypeError(`Expected array of length ${e}, found ${t.length}`)}})}function Me(e){return k.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>e.$kind===`Some`?e.Some:null})}function Ne(e,t){return new O({read:t=>{let n=t.readULEB(),r=Array(n);for(let i=0;i<n;i++)r[i]=e.read(t);return r},write:(t,n)=>{n.writeULEB(t.length);for(let r of t)e.write(r,n)},...t,name:t?.name??`vector<${e.name}>`,validate:e=>{if(t?.validate?.(e),!e||typeof e!=`object`||!(`length`in e))throw TypeError(`Expected array, found ${typeof e}`)}})}function Pe(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length}function Fe(e,t){return new O({name:`Map<${e.name}, ${t.name}>`,read:n=>{let r=n.readULEB(),i=new Map;for(let a=0;a<r;a++)i.set(e.read(n),t.read(n));return i},write:(n,r)=>{let i=[...n.entries()].map(([t,n])=>[e.serialize(t).toBytes(),n]);i.sort(([e],[t])=>Pe(e,t)),r.writeULEB(i.length);for(let[e,n]of i)r.writeBytes(e),t.write(n,r)}})}var k={u8(e){return Ce({readMethod:`read8`,writeMethod:`write8`,size:1,maxValue:2**8-1,...e,name:e?.name??`u8`})},u16(e){return Ce({readMethod:`read16`,writeMethod:`write16`,size:2,maxValue:2**16-1,...e,name:e?.name??`u16`})},u32(e){return Ce({readMethod:`read32`,writeMethod:`write32`,size:4,maxValue:2**32-1,...e,name:e?.name??`u32`})},u64(e){return we({readMethod:`read64`,writeMethod:`write64`,size:8,maxValue:2n**64n-1n,...e,name:e?.name??`u64`})},u128(e){return we({readMethod:`read128`,writeMethod:`write128`,size:16,maxValue:2n**128n-1n,...e,name:e?.name??`u128`})},u256(e){return we({readMethod:`read256`,writeMethod:`write256`,size:32,maxValue:2n**256n-1n,...e,name:e?.name??`u256`})},bool(e){return Se({size:1,read:e=>e.read8()===1,write:(e,t)=>t.write8(+!!e),...e,name:e?.name??`bool`,validate:t=>{if(e?.validate?.(t),typeof t!=`boolean`)throw TypeError(`Expected boolean, found ${typeof t}`)}})},uleb128(e){return Te({read:e=>e.readULEB(),serialize:e=>Uint8Array.from(i(e)),...e,name:e?.name??`uleb128`})},bytes(e,t){return Se({size:e,read:t=>t.readBytes(e),write:(e,t)=>{t.writeBytes(new Uint8Array(e))},...t,name:t?.name??`bytes[${e}]`,validate:n=>{if(t?.validate?.(n),!n||typeof n!=`object`||!(`length`in n))throw TypeError(`Expected array, found ${typeof n}`);if(n.length!==e)throw TypeError(`Expected array of length ${e}, found ${n.length}`)}})},byteVector(e){return new O({read:e=>{let t=e.readULEB();return e.readBytes(t)},write:(e,t)=>{let n=new Uint8Array(e);t.writeULEB(n.length),t.writeBytes(n)},...e,name:e?.name??`vector<u8>`,serializedSize:e=>{let t=`length`in e?e.length:null;return t==null?null:i(t).length+t},validate:t=>{if(e?.validate?.(t),!t||typeof t!=`object`||!(`length`in t))throw TypeError(`Expected array, found ${typeof t}`)}})},string(e){return Ee({toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...e,name:e?.name??`string`})},fixedArray:je,option:Me,vector:Ne,tuple(e,t){return new Ae({fields:e,...t})},struct(e,t,n){return new Oe({name:e,fields:t,...n})},enum(e,t,n){return new ke({name:e,fields:t,...n})},map:Fe,lazy(e){return De(e)}};function Ie(e){return Je(e)&&Ye(e)===32}var Le=/^[a-zA-Z][a-zA-Z0-9_]*$/;function Re(e){return Le.test(e)}var ze=[`bool`,`u8`,`u16`,`u32`,`u64`,`u128`,`u256`,`address`,`signer`],Be=/^vector<(.+)>$/;function Ve(e){if(ze.includes(e))return!0;let t=e.match(Be);return t?Ve(t[1]):e.includes(`::`)?Ue(e):!1}function He(e){return!Ie(e.address)&&!et(e.address)||!Re(e.module)||!Re(e.name)?!1:e.typeParams.every(e=>typeof e==`string`?Ve(e):He(e))}function Ue(e){try{return He(Ge(e))}catch{return!1}}function We(e){if(e.startsWith(`vector<`)){if(!e.endsWith(`>`))throw Error(`Invalid type tag: ${e}`);let t=e.slice(7,-1);if(!t)throw Error(`Invalid type tag: ${e}`);let n=We(t);return typeof n==`string`?`vector<${n}>`:`vector<${Ke(n)}>`}return e.includes(`::`)?Ge(e):e}function Ge(e){let t=e.split(`::`);if(t.length<3)throw Error(`Invalid struct tag: ${e}`);let[n,r]=t;if(!n||!r)throw Error(`Invalid struct tag: ${e}`);let i=et(n),a=e.slice(n.length+r.length+4),o=a.includes(`<`)?a.slice(0,a.indexOf(`<`)):a;if(!o||a.includes(`<`)&&!a.endsWith(`>`))throw Error(`Invalid struct tag: ${e}`);let s=a.includes(`<`)?ge(a.slice(a.indexOf(`<`)+1,a.lastIndexOf(`>`))).map(e=>We(e.trim())):[];return{address:i?n:A(n),module:r,name:o,typeParams:s}}function Ke(e){if(typeof e==`string`&&e.startsWith(`vector<`))throw Error(`normalizeStructTag does not support vector types. Use normalizeTypeTag instead.`);let{address:t,module:n,name:r,typeParams:i}=typeof e==`string`?Ge(e):e;return`${t}::${n}::${r}${i?.length>0?`<${i.map(e=>typeof e==`string`?e:Ke(e)).join(`,`)}>`:``}`}function A(e,t=!1){let n=e.toLowerCase();return!t&&n.startsWith(`0x`)&&(n=n.slice(2)),`0x${n.padStart(64,`0`)}`}function qe(e,t=!1){return A(e,t)}function Je(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}function Ye(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}var Xe=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,Ze=/^\d+$/,Qe=64,$e=`/`,et=e=>{let t=e.split($e);if(t.length<2||t.length>3)return!1;let[n,i,a]=t;return a!==void 0&&!Ze.test(a)||!r(n)?!1:Xe.test(i)&&i.length<Qe},tt=e=>{let t=e.split(/::|<|>|,/);for(let e of t)if(e.includes($e)&&!et(e))return!1;return Ue(e)},nt=/^vector<(.+)>$/,rt=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/,it=class e{static parseFromStr(t,n=!1){if(t===`address`)return{address:null};if(t===`bool`)return{bool:null};if(t===`u8`)return{u8:null};if(t===`u16`)return{u16:null};if(t===`u32`)return{u32:null};if(t===`u64`)return{u64:null};if(t===`u128`)return{u128:null};if(t===`u256`)return{u256:null};if(t===`signer`)return{signer:null};let r=t.match(nt);if(r)return{vector:e.parseFromStr(r[1],n)};let i=t.match(rt);if(i)return{struct:{address:n?A(i[1]):i[1],module:i[2],name:i[3],typeParams:i[5]===void 0?[]:e.parseStructTypeArgs(i[5],n)}};throw Error(`Encountered unexpected token when parsing type args for ${t}`)}static parseStructTypeArgs(t,n=!1){return ge(t).map(t=>e.parseFromStr(t,n))}static tagToString(t){if(`bool`in t)return`bool`;if(`u8`in t)return`u8`;if(`u16`in t)return`u16`;if(`u32`in t)return`u32`;if(`u64`in t)return`u64`;if(`u128`in t)return`u128`;if(`u256`in t)return`u256`;if(`address`in t)return`address`;if(`signer`in t)return`signer`;if(`vector`in t)return`vector<${e.tagToString(t.vector)}>`;if(`struct`in t){let n=t.struct,r=n.typeParams.map(e.tagToString).join(`, `);return`${n.address}::${n.module}::${n.name}${r?`<${r}>`:``}`}throw Error(`Invalid TypeTag`)}};function at(e){return k.u64({name:`unsafe_u64`,...e}).transform({input:e=>e,output:e=>Number(e)})}function ot(e){return k.enum(`Option`,{None:null,Some:e})}var j=k.bytes(32).transform({validate:e=>{let t=typeof e==`string`?e:me(e);if(!t||!Ie(A(t)))throw Error(`Invalid Sui address ${t}`)},input:e=>typeof e==`string`?pe(A(e)):e,output:e=>A(me(e))}),M=k.byteVector().transform({name:`ObjectDigest`,input:e=>de(e),output:e=>ue(new Uint8Array(e)),validate:e=>{if(de(e).length!==32)throw Error(`ObjectDigest must be 32 bytes`)}}),N=k.struct(`SuiObjectRef`,{objectId:j,version:k.u64(),digest:M}),st=k.struct(`SharedObjectRef`,{objectId:j,initialSharedVersion:k.u64(),mutable:k.bool()}),ct=k.enum(`ObjectArg`,{ImmOrOwnedObject:N,SharedObject:st,Receiving:N}),lt=k.enum(`Owner`,{AddressOwner:j,ObjectOwner:j,Shared:k.struct(`Shared`,{initialSharedVersion:k.u64()}),Immutable:null,ConsensusAddressOwner:k.struct(`ConsensusAddressOwner`,{startVersion:k.u64(),owner:j})}),ut=k.enum(`Reservation`,{MaxAmountU64:k.u64()}),dt=k.enum(`WithdrawalType`,{Balance:k.lazy(()=>gt)}),ft=k.enum(`WithdrawFrom`,{Sender:null,Sponsor:null}),pt=k.struct(`FundsWithdrawal`,{reservation:ut,typeArg:dt,withdrawFrom:ft}),mt=k.enum(`CallArg`,{Pure:k.struct(`Pure`,{bytes:k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))})}),Object:ct,FundsWithdrawal:pt}),ht=k.enum(`TypeTag`,{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:k.lazy(()=>ht),struct:k.lazy(()=>Ct),u16:null,u32:null,u256:null}),gt=ht.transform({input:e=>typeof e==`string`?it.parseFromStr(e,!0):e,output:e=>it.tagToString(e)}),P=k.enum(`Argument`,{GasCoin:null,Input:k.u16(),Result:k.u16(),NestedResult:k.tuple([k.u16(),k.u16()])}),_t=k.struct(`ProgrammableMoveCall`,{package:j,module:k.string(),function:k.string(),typeArguments:k.vector(gt),arguments:k.vector(P)}),vt=k.enum(`Command`,{MoveCall:_t,TransferObjects:k.struct(`TransferObjects`,{objects:k.vector(P),address:P}),SplitCoins:k.struct(`SplitCoins`,{coin:P,amounts:k.vector(P)}),MergeCoins:k.struct(`MergeCoins`,{destination:P,sources:k.vector(P)}),Publish:k.struct(`Publish`,{modules:k.vector(k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))})),dependencies:k.vector(j)}),MakeMoveVec:k.struct(`MakeMoveVec`,{type:ot(gt).transform({input:e=>e===null?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:k.vector(P)}),Upgrade:k.struct(`Upgrade`,{modules:k.vector(k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))})),dependencies:k.vector(j),package:j,ticket:P})}),yt=k.struct(`ProgrammableTransaction`,{inputs:k.vector(mt),commands:k.vector(vt)}),bt=k.enum(`TransactionKind`,{ProgrammableTransaction:yt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),xt=k.struct(`ValidDuring`,{minEpoch:k.option(k.u64()),maxEpoch:k.option(k.u64()),minTimestamp:k.option(k.u64()),maxTimestamp:k.option(k.u64()),chain:M,nonce:k.u32()}),St=k.enum(`TransactionExpiration`,{None:null,Epoch:at(),ValidDuring:xt}),Ct=k.struct(`StructTag`,{address:j,module:k.string(),name:k.string(),typeParams:k.vector(ht)}),wt=k.struct(`GasData`,{payment:k.vector(N),owner:j,price:k.u64(),budget:k.u64()}),Tt=k.struct(`TransactionDataV1`,{kind:bt,sender:j,gasData:wt,expiration:St}),Et=k.enum(`TransactionData`,{V1:Tt}),Dt=k.enum(`IntentScope`,{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Ot=k.enum(`IntentVersion`,{V0:null}),kt=k.enum(`AppId`,{Sui:null}),At=k.struct(`Intent`,{scope:Dt,version:Ot,appId:kt});function jt(e){return k.struct(`IntentMessage<${e.name}>`,{intent:At,value:e})}var Mt=k.enum(`CompressedSignature`,{ED25519:k.bytes(64),Secp256k1:k.bytes(64),Secp256r1:k.bytes(64),ZkLogin:k.byteVector(),Passkey:k.byteVector()}),Nt=k.enum(`PublicKey`,{ED25519:k.bytes(32),Secp256k1:k.bytes(33),Secp256r1:k.bytes(33),ZkLogin:k.byteVector(),Passkey:k.bytes(33)}),Pt=k.struct(`MultiSigPkMap`,{pubKey:Nt,weight:k.u8()}),Ft=k.struct(`MultiSigPublicKey`,{pk_map:k.vector(Pt),threshold:k.u16()}),It=k.struct(`MultiSig`,{sigs:k.vector(Mt),bitmap:k.u16(),multisig_pk:Ft}),Lt=k.byteVector().transform({input:e=>typeof e==`string`?E(e):e,output:e=>D(new Uint8Array(e))}),Rt=k.struct(`SenderSignedTransaction`,{intentMessage:jt(Et),txSignatures:k.vector(Lt)}),zt=k.vector(Rt,{name:`SenderSignedData`}),Bt=k.struct(`PasskeyAuthenticator`,{authenticatorData:k.byteVector(),clientDataJson:k.string(),userSignature:k.byteVector()}),Vt=k.enum(`MoveObjectType`,{Other:Ct,GasCoin:null,StakedSui:null,Coin:gt,AccumulatorBalanceWrapper:null}),Ht=k.struct(`TypeOrigin`,{moduleName:k.string(),datatypeName:k.string(),package:j}),Ut=k.struct(`UpgradeInfo`,{upgradedId:j,upgradedVersion:k.u64()}),Wt=k.struct(`MovePackage`,{id:j,version:k.u64(),moduleMap:k.map(k.string(),k.byteVector()),typeOriginTable:k.vector(Ht),linkageTable:k.map(j,Ut)}),Gt=k.struct(`MoveObject`,{type:Vt,hasPublicTransfer:k.bool(),version:k.u64(),contents:k.byteVector()}),Kt=k.enum(`Data`,{Move:Gt,Package:Wt}),qt=k.struct(`ObjectInner`,{data:Kt,owner:lt,previousTransaction:M,storageRebate:k.u64()}),Jt=k.enum(`PackageUpgradeError`,{UnableToFetchPackage:k.struct(`UnableToFetchPackage`,{packageId:j}),NotAPackage:k.struct(`NotAPackage`,{objectId:j}),IncompatibleUpgrade:null,DigestDoesNotMatch:k.struct(`DigestDoesNotMatch`,{digest:k.byteVector()}),UnknownUpgradePolicy:k.struct(`UnknownUpgradePolicy`,{policy:k.u8()}),PackageIDDoesNotMatch:k.struct(`PackageIDDoesNotMatch`,{packageId:j,ticketId:j})}),Yt=k.struct(`ModuleId`,{address:j,name:k.string()}),Xt=k.struct(`MoveLocation`,{module:Yt,function:k.u16(),instruction:k.u16(),functionName:k.option(k.string())}),Zt=k.enum(`CommandArgumentError`,{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:k.struct(`IndexOutOfBounds`,{idx:k.u16()}),SecondaryIndexOutOfBounds:k.struct(`SecondaryIndexOutOfBounds`,{resultIdx:k.u16(),secondaryIdx:k.u16()}),InvalidResultArity:k.struct(`InvalidResultArity`,{resultIdx:k.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null,InvalidArgumentArity:null,InvalidTransferObject:null,InvalidMakeMoveVecNonObjectArgument:null,ArgumentWithoutValue:null,CannotMoveBorrowedValue:null,CannotWriteToExtendedReference:null,InvalidReferenceArgument:null}),Qt=k.enum(`TypeArgumentError`,{TypeNotFound:null,ConstraintNotSatisfied:null}),$t=k.enum(`ExecutionFailureStatus`,{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:k.struct(`MoveObjectTooBig`,{objectSize:k.u64(),maxObjectSize:k.u64()}),MovePackageTooBig:k.struct(`MovePackageTooBig`,{objectSize:k.u64(),maxObjectSize:k.u64()}),CircularObjectOwnership:k.struct(`CircularObjectOwnership`,{object:j}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:k.option(Xt),MoveAbort:k.tuple([Xt,k.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:k.struct(`CommandArgumentError`,{argIdx:k.u16(),kind:Zt}),TypeArgumentError:k.struct(`TypeArgumentError`,{argumentIdx:k.u16(),kind:Qt}),UnusedValueWithoutDrop:k.struct(`UnusedValueWithoutDrop`,{resultIdx:k.u16(),secondaryIdx:k.u16()}),InvalidPublicFunctionReturnType:k.struct(`InvalidPublicFunctionReturnType`,{idx:k.u16()}),InvalidTransferObject:null,EffectsTooLarge:k.struct(`EffectsTooLarge`,{currentSize:k.u64(),maxSize:k.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:k.struct(`PackageUpgradeError`,{upgradeError:Jt}),WrittenObjectsTooLarge:k.struct(`WrittenObjectsTooLarge`,{currentSize:k.u64(),maxSize:k.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null,ExecutionCancelledDueToSharedObjectCongestion:k.struct(`ExecutionCancelledDueToSharedObjectCongestion`,{congested_objects:k.vector(j)}),AddressDeniedForCoin:k.struct(`AddressDeniedForCoin`,{address:j,coinType:k.string()}),CoinTypeGlobalPause:k.struct(`CoinTypeGlobalPause`,{coinType:k.string()}),ExecutionCancelledDueToRandomnessUnavailable:null,MoveVectorElemTooBig:k.struct(`MoveVectorElemTooBig`,{valueSize:k.u64(),maxScaledSize:k.u64()}),MoveRawValueTooBig:k.struct(`MoveRawValueTooBig`,{valueSize:k.u64(),maxScaledSize:k.u64()}),InvalidLinkage:null,InsufficientBalanceForWithdraw:null,NonExclusiveWriteInputObjectModified:k.struct(`NonExclusiveWriteInputObjectModified`,{id:j})}),en=k.enum(`ExecutionStatus`,{Success:null,Failure:k.struct(`Failure`,{error:$t,command:k.option(k.u64())})}),tn=k.struct(`GasCostSummary`,{computationCost:k.u64(),storageCost:k.u64(),storageRebate:k.u64(),nonRefundableStorageFee:k.u64()}),nn=k.struct(`TransactionEffectsV1`,{status:en,executedEpoch:k.u64(),gasUsed:tn,modifiedAtVersions:k.vector(k.tuple([j,k.u64()])),sharedObjects:k.vector(N),transactionDigest:M,created:k.vector(k.tuple([N,lt])),mutated:k.vector(k.tuple([N,lt])),unwrapped:k.vector(k.tuple([N,lt])),deleted:k.vector(N),unwrappedThenDeleted:k.vector(N),wrapped:k.vector(N),gasObject:k.tuple([N,lt]),eventsDigest:k.option(M),dependencies:k.vector(M)}),rn=k.tuple([k.u64(),M]),an=k.enum(`ObjectIn`,{NotExist:null,Exist:k.tuple([rn,lt])}),on=k.struct(`AccumulatorAddress`,{address:j,ty:gt}),sn=k.enum(`AccumulatorOperation`,{Merge:null,Split:null}),cn=k.enum(`AccumulatorValue`,{Integer:k.u64(),IntegerTuple:k.tuple([k.u64(),k.u64()]),EventDigest:k.vector(k.tuple([k.u64(),M]))}),ln=k.struct(`AccumulatorWriteV1`,{address:on,operation:sn,value:cn}),un=k.enum(`ObjectOut`,{NotExist:null,ObjectWrite:k.tuple([M,lt]),PackageWrite:rn,AccumulatorWriteV1:ln}),dn=k.enum(`IDOperation`,{None:null,Created:null,Deleted:null}),fn=k.struct(`EffectsObjectChange`,{inputState:an,outputState:un,idOperation:dn}),pn=k.enum(`UnchangedConsensusKind`,{ReadOnlyRoot:rn,MutateConsensusStreamEnded:k.u64(),ReadConsensusStreamEnded:k.u64(),Cancelled:k.u64(),PerEpochConfig:null}),mn=k.struct(`TransactionEffectsV2`,{status:en,executedEpoch:k.u64(),gasUsed:tn,transactionDigest:M,gasObjectIndex:k.option(k.u32()),eventsDigest:k.option(M),dependencies:k.vector(M),lamportVersion:k.u64(),changedObjects:k.vector(k.tuple([j,fn])),unchangedConsensusObjects:k.vector(k.tuple([j,pn])),auxDataDigest:k.option(M)}),hn=k.enum(`TransactionEffects`,{V1:nn,V2:mn});function gn(e){switch(e){case`u8`:return k.u8();case`u16`:return k.u16();case`u32`:return k.u32();case`u64`:return k.u64();case`u128`:return k.u128();case`u256`:return k.u256();case`bool`:return k.bool();case`string`:return k.string();case`id`:case`address`:return j}let t=e.match(/^(vector|option)<(.+)>$/);if(t){let[e,n]=t.slice(1);return e===`vector`?k.vector(gn(n)):k.option(gn(n))}throw Error(`Invalid Pure type name: ${e}`)}var _n={...k,U8:k.u8(),U16:k.u16(),U32:k.u32(),U64:k.u64(),U128:k.u128(),U256:k.u256(),ULEB128:k.uleb128(),Bool:k.bool(),String:k.string(),Address:j,AppId:kt,Argument:P,CallArg:mt,Command:vt,CompressedSignature:Mt,Data:Kt,GasData:wt,Intent:At,IntentMessage:jt,IntentScope:Dt,IntentVersion:Ot,MoveObject:Gt,MoveObjectType:Vt,MovePackage:Wt,MultiSig:It,MultiSigPkMap:Pt,MultiSigPublicKey:Ft,Object:qt,ObjectArg:ct,ObjectDigest:M,Owner:lt,PasskeyAuthenticator:Bt,ProgrammableMoveCall:_t,ProgrammableTransaction:yt,PublicKey:Nt,SenderSignedData:zt,SenderSignedTransaction:Rt,SharedObjectRef:st,StructTag:Ct,SuiObjectRef:N,TransactionData:Et,TransactionDataV1:Tt,TransactionEffects:hn,TransactionExpiration:St,TransactionKind:bt,TypeOrigin:Ht,TypeTag:gt,UpgradeInfo:Ut};function vn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function F(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw RangeError(`${n}expected integer >= 0, got ${e}`)}}function I(e,t,n=``){let r=vn(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`,l=o+`expected Uint8Array`+s+`, got `+c;throw r?RangeError(l):TypeError(l)}return e}function yn(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`Hash must wrapped by utils.createHasher`);if(F(e.outputLen),F(e.blockLen),e.outputLen<1)throw Error(`"outputLen" must be >= 1`);if(e.blockLen<1)throw Error(`"blockLen" must be >= 1`)}function bn(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function xn(e,t){I(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw RangeError(`"digestInto() output" expected to be of length >=`+n)}function Sn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function L(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Cn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function R(e,t){return e<<32-t|e>>>t}var wn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Tn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}var z=wn?e=>e:e=>Tn(e)>>>0;function En(e){for(let t=0;t<e.length;t++)e[t]=Tn(e[t]);return e}var Dn=wn?e=>e:En,On=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,kn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function An(e){if(I(e),On)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=kn[e[n]];return t}var B={_0:48,_9:57,A:65,F:70,a:97,f:102};function jn(e){if(e>=B._0&&e<=B._9)return e-B._0;if(e>=B.A&&e<=B.F)return e-(B.A-10);if(e>=B.a&&e<=B.f)return e-(B.a-10)}function Mn(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(On)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=jn(e.charCodeAt(i)),a=jn(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Nn(e){if(typeof e!=`string`)throw TypeError(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Pn(e,t=``){return typeof e==`string`?Nn(e):I(e,void 0,t)}function Fn(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];I(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function In(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw TypeError(`options must be object or undefined`);return Object.assign(e,t)}function Ln(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Rn(e=32){F(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var zn=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),Bn=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function Vn(e,t,n){return e&t^~e&n}function Hn(e,t,n){return e&t^e&n^t&n}var Un=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Cn(this.buffer)}update(e){bn(this),I(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Cn(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){bn(this),xn(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,L(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,BigInt(this.length*8),i),this.process(n,0);let o=Cn(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Wn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),V=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Gn=BigInt(2**32-1),Kn=BigInt(32);function qn(e,t=!1){return t?{h:Number(e&Gn),l:Number(e>>Kn&Gn)}:{h:Number(e>>Kn&Gn)|0,l:Number(e&Gn)|0}}function Jn(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=qn(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var Yn=(e,t,n)=>e>>>n,Xn=(e,t,n)=>e<<32-n|t>>>n,Zn=(e,t,n)=>e>>>n|t<<32-n,Qn=(e,t,n)=>e<<32-n|t>>>n,$n=(e,t,n)=>e<<64-n|t>>>n-32,er=(e,t,n)=>e>>>n-32|t<<64-n,tr=(e,t)=>t,nr=(e,t)=>e;function H(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var rr=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),ir=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,ar=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),or=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,sr=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),cr=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,U=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),W=new Uint32Array(32);function lr(e,t,n,r,i,a){let o=i[a],s=i[a+1],c=W[2*e],l=W[2*e+1],u=W[2*t],d=W[2*t+1],f=W[2*n],p=W[2*n+1],m=W[2*r],h=W[2*r+1],g=rr(c,u,o);l=ir(g,l,d,s),c=g|0,{Dh:h,Dl:m}={Dh:h^l,Dl:m^c},{Dh:h,Dl:m}={Dh:tr(h,m),Dl:nr(h,m)},{h:p,l:f}=H(p,f,h,m),{Bh:d,Bl:u}={Bh:d^p,Bl:u^f},{Bh:d,Bl:u}={Bh:Zn(d,u,24),Bl:Qn(d,u,24)},W[2*e]=c,W[2*e+1]=l,W[2*t]=u,W[2*t+1]=d,W[2*n]=f,W[2*n+1]=p,W[2*r]=m,W[2*r+1]=h}function G(e,t,n,r,i,a){let o=i[a],s=i[a+1],c=W[2*e],l=W[2*e+1],u=W[2*t],d=W[2*t+1],f=W[2*n],p=W[2*n+1],m=W[2*r],h=W[2*r+1],g=rr(c,u,o);l=ir(g,l,d,s),c=g|0,{Dh:h,Dl:m}={Dh:h^l,Dl:m^c},{Dh:h,Dl:m}={Dh:Zn(h,m,16),Dl:Qn(h,m,16)},{h:p,l:f}=H(p,f,h,m),{Bh:d,Bl:u}={Bh:d^p,Bl:u^f},{Bh:d,Bl:u}={Bh:$n(d,u,63),Bl:er(d,u,63)},W[2*e]=c,W[2*e+1]=l,W[2*t]=u,W[2*t+1]=d,W[2*n]=f,W[2*n+1]=p,W[2*r]=m,W[2*r+1]=h}function ur(e,t={},n,r,i){if(F(n),e<=0||e>n)throw Error(`outputLen bigger than keyLen`);let{key:a,salt:o,personalization:s}=t;if(a!==void 0&&(a.length<1||a.length>n))throw Error(`"key" expected to be undefined or of length=1..`+n);o!==void 0&&I(o,r,`salt`),s!==void 0&&I(s,i,`personalization`)}var dr=class{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(e,t){F(e),F(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=Sn(this.buffer)}update(e){bn(this),I(e);let{blockLen:t,buffer:n,buffer32:r}=this,i=e.length,a=e.byteOffset,o=e.buffer;for(let s=0;s<i;){this.pos===t&&(Dn(r),this.compress(r,0,!1),Dn(r),this.pos=0);let c=Math.min(t-this.pos,i-s),l=a+s;if(c===t&&!(l%4)&&s+c<i){let e=new Uint32Array(o,l,Math.floor((i-s)/4));Dn(e);for(let n=0;s+t<i;n+=r.length,s+=t)this.length+=t,this.compress(e,n,!1);Dn(e);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,this.length+=c,s+=c}return this}digestInto(e){bn(this),xn(e,this);let{pos:t,buffer32:n}=this;if(this.finished=!0,L(this.buffer.subarray(t)),Dn(n),this.compress(n,0,!0),Dn(n),e.byteOffset&3)throw RangeError(`"digestInto() output" expected 4-byte aligned byteOffset, got `+e.byteOffset);let r=this.get(),i=Sn(e),a=Math.floor(this.outputLen/4);for(let e=0;e<a;e++)i[e]=z(r[e]);let o=this.outputLen%4;if(!o)return;let s=a*4,c=r[a];for(let t=0;t<o;t++)e[s+t]=c>>>8*t}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){let{buffer:t,length:n,finished:r,destroyed:i,outputLen:a,pos:o}=this;return e||=new this.constructor({dkLen:a}),e.set(...this.get()),e.buffer.set(t),e.destroyed=i,e.finished=r,e.length=n,e.pos=o,e.outputLen=a,e}clone(){return this._cloneInto()}},fr=class extends dr{v0l=U[0]|0;v0h=U[1]|0;v1l=U[2]|0;v1h=U[3]|0;v2l=U[4]|0;v2h=U[5]|0;v3l=U[6]|0;v3h=U[7]|0;v4l=U[8]|0;v4h=U[9]|0;v5l=U[10]|0;v5h=U[11]|0;v6l=U[12]|0;v6h=U[13]|0;v7l=U[14]|0;v7h=U[15]|0;constructor(e={}){let t=e.dkLen===void 0?64:e.dkLen;super(128,t),ur(t,e,64,16,16);let{key:n,personalization:r,salt:i}=e,a=0;if(n!==void 0&&(I(n,void 0,`key`),a=n.length),this.v0l^=this.outputLen|a<<8|16842752,i!==void 0){I(i,void 0,`salt`);let e=Sn(i);this.v4l^=z(e[0]),this.v4h^=z(e[1]),this.v5l^=z(e[2]),this.v5h^=z(e[3])}if(r!==void 0){I(r,void 0,`personalization`);let e=Sn(r);this.v6l^=z(e[0]),this.v6h^=z(e[1]),this.v7l^=z(e[2]),this.v7h^=z(e[3])}if(n!==void 0){let e=new Uint8Array(this.blockLen);e.set(n),this.update(e)}}get(){let{v0l:e,v0h:t,v1l:n,v1h:r,v2l:i,v2h:a,v3l:o,v3h:s,v4l:c,v4h:l,v5l:u,v5h:d,v6l:f,v6h:p,v7l:m,v7h:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.v0l=e|0,this.v0h=t|0,this.v1l=n|0,this.v1h=r|0,this.v2l=i|0,this.v2h=a|0,this.v3l=o|0,this.v3h=s|0,this.v4l=c|0,this.v4h=l|0,this.v5l=u|0,this.v5h=d|0,this.v6l=f|0,this.v6h=p|0,this.v7l=m|0,this.v7h=h|0}compress(e,t,n){this.get().forEach((e,t)=>W[t]=e),W.set(U,16);let{h:r,l:i}=qn(BigInt(this.length));W[24]=U[8]^i,W[25]=U[9]^r,n&&(W[28]=~W[28],W[29]=~W[29]);let a=0,o=Bn;for(let n=0;n<12;n++)lr(0,4,8,12,e,t+2*o[a++]),G(0,4,8,12,e,t+2*o[a++]),lr(1,5,9,13,e,t+2*o[a++]),G(1,5,9,13,e,t+2*o[a++]),lr(2,6,10,14,e,t+2*o[a++]),G(2,6,10,14,e,t+2*o[a++]),lr(3,7,11,15,e,t+2*o[a++]),G(3,7,11,15,e,t+2*o[a++]),lr(0,5,10,15,e,t+2*o[a++]),G(0,5,10,15,e,t+2*o[a++]),lr(1,6,11,12,e,t+2*o[a++]),G(1,6,11,12,e,t+2*o[a++]),lr(2,7,8,13,e,t+2*o[a++]),G(2,7,8,13,e,t+2*o[a++]),lr(3,4,9,14,e,t+2*o[a++]),G(3,4,9,14,e,t+2*o[a++]);this.v0l^=W[0]^W[16],this.v0h^=W[1]^W[17],this.v1l^=W[2]^W[18],this.v1h^=W[3]^W[19],this.v2l^=W[4]^W[20],this.v2h^=W[5]^W[21],this.v3l^=W[6]^W[22],this.v3h^=W[7]^W[23],this.v4l^=W[8]^W[24],this.v4h^=W[9]^W[25],this.v5l^=W[10]^W[26],this.v5h^=W[11]^W[27],this.v6l^=W[12]^W[28],this.v6h^=W[13]^W[29],this.v7l^=W[14]^W[30],this.v7h^=W[15]^W[31],L(W)}destroy(){this.destroyed=!0,L(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},pr=Ln(e=>new fr(e));function mr(e,t){return _n.IntentMessage(_n.bytes(t.length)).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}var hr={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5,Passkey:6},gr={ED25519:32,Secp256k1:33,Secp256r1:33,Passkey:33},_r={0:`ED25519`,1:`Secp256k1`,2:`Secp256r1`,3:`MultiSig`,5:`ZkLogin`,6:`Passkey`};function vr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var yr=class{equals(e){return vr(this.toRawBytes(),e.toRawBytes())}toBase64(){return D(this.toRawBytes())}toString(){throw Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return D(this.toSuiBytes())}verifyWithIntent(e,t,n){let r=pr(mr(n,e),{dkLen:32});return this.verify(r,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(_n.byteVector().serialize(e).toBytes(),t,`PersonalMessage`)}verifyTransaction(e,t){return this.verifyWithIntent(e,t,`TransactionData`)}verifyAddress(e){return this.toSuiAddress()===e}toSuiBytes(){let e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return A(An(pr(this.toSuiBytes(),{dkLen:32})).slice(0,64))}};function br(e){let t=E(e),n=_r[t[0]];switch(n){case`ED25519`:case`Secp256k1`:case`Secp256r1`:let r=gr[n],i=t.slice(1,t.length-r);return{serializedSignature:e,signatureScheme:n,signature:i,publicKey:t.slice(1+i.length),bytes:t};default:throw Error(`Unsupported signature scheme`)}}var xr=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Sr=new Uint32Array(64),Cr=class extends Un{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Sr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Sr[e-15],n=Sr[e-2],r=R(t,7)^R(t,18)^t>>>3;Sr[e]=(R(n,17)^R(n,19)^n>>>10)+Sr[e-7]+r+Sr[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=R(o,6)^R(o,11)^R(o,25),u=l+t+Vn(o,s,c)+xr[e]+Sr[e]|0,d=(R(n,2)^R(n,13)^R(n,22))+Hn(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){L(Sr)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),L(this.buffer)}},wr=class extends Cr{A=Wn[0]|0;B=Wn[1]|0;C=Wn[2]|0;D=Wn[3]|0;E=Wn[4]|0;F=Wn[5]|0;G=Wn[6]|0;H=Wn[7]|0;constructor(){super(32)}},Tr=Jn(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Er=Tr[0],Dr=Tr[1],Or=new Uint32Array(80),kr=new Uint32Array(80),Ar=class extends Un{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Or[n]=e.getUint32(t),kr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Or[e-15]|0,n=kr[e-15]|0,r=Zn(t,n,1)^Zn(t,n,8)^Yn(t,n,7),i=Qn(t,n,1)^Qn(t,n,8)^Xn(t,n,7),a=Or[e-2]|0,o=kr[e-2]|0,s=Zn(a,o,19)^$n(a,o,61)^Yn(a,o,6),c=ar(i,Qn(a,o,19)^er(a,o,61)^Xn(a,o,6),kr[e-7],kr[e-16]);Or[e]=or(c,r,s,Or[e-7],Or[e-16])|0,kr[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Zn(u,d,14)^Zn(u,d,18)^$n(u,d,41),v=Qn(u,d,14)^Qn(u,d,18)^er(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=sr(_,v,b,Dr[e],kr[e]),S=cr(x,g,t,y,Er[e],Or[e]),C=x|0,w=Zn(n,r,28)^$n(n,r,34)^$n(n,r,39),ee=Qn(n,r,28)^er(n,r,34)^er(n,r,39),T=n&i^n&o^i&o,te=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=H(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ne=rr(C,ee,te);n=ir(ne,S,w,T),r=ne|0}({h:n,l:r}=H(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=H(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=H(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=H(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=H(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=H(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=H(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=H(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){L(Or,kr)}destroy(){this.destroyed=!0,L(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},jr=class extends Ar{Ah=V[0]|0;Al=V[1]|0;Bh=V[2]|0;Bl=V[3]|0;Ch=V[4]|0;Cl=V[5]|0;Dh=V[6]|0;Dl=V[7]|0;Eh=V[8]|0;El=V[9]|0;Fh=V[10]|0;Fl=V[11]|0;Gh=V[12]|0;Gl=V[13]|0;Hh=V[14]|0;Hl=V[15]|0;constructor(){super(64)}},Mr=Ln(()=>new wr,zn(1)),Nr=Ln(()=>new jr,zn(3)),K=(e,t,n)=>I(e,t,n),Pr=F,Fr=An,q=(...e)=>Fn(...e),Ir=e=>Mn(e),Lr=vn,Rr=e=>Rn(e),zr=BigInt(0),Br=BigInt(1);function Vr(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}" `;throw TypeError(n+`expected boolean, got type=`+typeof e)}return e}function Hr(e){if(typeof e==`bigint`){if(!$r(e))throw RangeError(`positive bigint expected, got `+e)}else Pr(e);return e}function Ur(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function Wr(e){let t=Hr(e).toString(16);return t.length&1?`0`+t:t}function Gr(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?zr:BigInt(`0x`+e)}function Kr(e){return Gr(An(e))}function qr(e){return Gr(An(Zr(I(e)).reverse()))}function Jr(e,t){if(F(t),t===0)throw RangeError(`zero length`);e=Hr(e);let n=e.toString(16);if(n.length>t*2)throw RangeError(`number too large`);return Mn(n.padStart(t*2,`0`))}function Yr(e,t){return Jr(e,t).reverse()}function Xr(e,t){if(e=K(e),t=K(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Zr(e){return Uint8Array.from(K(e))}function Qr(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}var $r=e=>typeof e==`bigint`&&zr<=e;function ei(e,t,n){return $r(e)&&$r(t)&&$r(n)&&t<=e&&e<n}function ti(e,t,n,r){if(!ei(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function ni(e){if(e<zr)throw Error(`expected non-negative bigint, got `+e);let t;for(t=0;e>zr;e>>=Br,t+=1);return t}var ri=e=>(Br<<BigInt(e))-Br;function ii(e,t,n){if(F(e,`hashLen`),F(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,q(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return q(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function ai(e,t={},n={}){if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`expected valid options object`);function r(t,n,r){if(!r&&n!==`function`&&!Object.hasOwn(e,t))throw TypeError(`param "${t}" is invalid: expected own property`);let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw TypeError(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}var oi=()=>{throw Error(`not implemented`)},J=BigInt(0),Y=BigInt(1),si=BigInt(2),ci=BigInt(3),li=BigInt(4),ui=BigInt(5),di=BigInt(7),fi=BigInt(8),pi=BigInt(9),mi=BigInt(16);function X(e,t){if(t<=J)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=J?n:t+n}function hi(e,t,n){if(t<J)throw Error(`pow2: expected non-negative exponent, got `+t);let r=e;for(;t-- >J;)r*=r,r%=n;return r}function gi(e,t){if(e===J)throw Error(`invert: expected non-zero number`);if(t<=J)throw Error(`invert: expected positive modulus, got `+t);let n=X(e,t),r=t,i=J,a=Y,o=Y,s=J;for(;n!==J;){let e=r/n,t=r-n*e,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Y)throw Error(`invert: does not exist`);return X(i,t)}function _i(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function vi(e,t){let n=e,r=(n.ORDER+Y)/li,i=n.pow(t,r);return _i(n,i,t),i}function yi(e,t){let n=e,r=(n.ORDER-ui)/fi,i=n.mul(t,si),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,si),a),c=n.mul(o,n.sub(s,n.ONE));return _i(n,c,t),c}function bi(e){let t=Mi(e),n=xi(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+di)/mi;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return _i(n,m,t),m})}function xi(e){if(e<ci)throw Error(`sqrt is not defined for small field`);let t=e-Y,n=0;for(;t%si===J;)t/=si,n++;let r=si,i=Mi(e);for(;Oi(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return vi;let a=i.pow(r,t),o=(t+Y)/si;return function(e,r){let i=e;if(i.is0(r))return r;if(Oi(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))return i.ZERO;let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=Y<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function Si(e){return e%li===ci?vi:e%fi===ui?yi:e%mi===pi?bi(e):xi(e)}var Ci=(e,t)=>(X(e,t)&Y)===Y,wi=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Ti(e){if(ai(e,wi.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,BYTES:`number`,BITS:`number`})),Ur(e.BYTES,`BYTES`),Ur(e.BITS,`BITS`),e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=Y)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function Ei(e,t,n){let r=e;if(n<J)throw Error(`invalid exponent, negatives unsupported`);if(n===J)return r.ONE;if(n===Y)return t;let i=r.ONE,a=t;for(;n>J;)n&Y&&(i=r.mul(i,a)),a=r.sqr(a),n>>=Y;return i}function Di(e,t,n=!1){let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function Oi(e,t){let n=e,r=(n.ORDER-Y)/si,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function ki(e,t){if(t!==void 0&&Pr(t),e<=J)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=ni(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected bit length (${n}) >= n.length (${t})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var Ai=new WeakMap,ji=class{ORDER;BITS;BYTES;isLE;ZERO=J;ONE=Y;_lengths;_mod;constructor(e,t={}){if(e<=Y)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=ki(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return X(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return J<=e&&e<this.ORDER}is0(e){return e===J}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Y)===Y}neg(e){return X(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return X(e*e,this.ORDER)}add(e,t){return X(e+t,this.ORDER)}sub(e,t){return X(e-t,this.ORDER)}mul(e,t){return X(e*t,this.ORDER)}pow(e,t){return Ei(this,e,t)}div(e,t){return X(e*gi(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return gi(e,this.ORDER)}sqrt(e){let t=Ai.get(this);return t||Ai.set(this,t=Si(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Yr(e,this.BYTES):Jr(e,this.BYTES)}fromBytes(e,t=!1){K(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?qr(e):Kr(e);if(o&&(s=X(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return Di(this,e)}cmov(e,t,n){return Vr(n,`condition`),n?t:e}};Object.freeze(ji.prototype);function Mi(e,t={}){return new ji(e,t)}function Ni(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=Y)throw Error(`field order must be greater than 1`);let t=ni(e-Y);return Math.ceil(t/8)}function Pi(e){let t=Ni(e);return t+Math.ceil(t/2)}function Fi(e,t,n=!1){K(e);let r=e.length,i=Ni(t),a=Math.max(Pi(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=X(n?qr(e):Kr(e),t-Y)+Y;return n?Yr(o,i):Jr(o,i)}var Ii=BigInt(0),Li=BigInt(1);function Ri(e,t){let n=t.negate();return e?n:t}function zi(e,t){let n=Di(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Bi(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function Vi(e,t){Bi(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:ri(e),maxNumber:i,shiftBy:BigInt(e)}}function Hi(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=Li);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var Ui=new WeakMap,Wi=new WeakMap;function Gi(e){return Wi.get(e)||1}function Ki(e){if(e!==Ii)throw Error(`invalid wNAF`)}var qi=class{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ii;)t&Li&&(n=n.add(r)),r=r.double(),t>>=Li;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=Vi(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=Vi(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=Hi(n,e,a);n=o,c?i=i.add(Ri(u,t[d])):r=r.add(Ri(l,t[s]))}return Ki(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=Vi(e,this.bits);for(let e=0;e<i.windows&&n!==Ii;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=Hi(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return Ki(n),r}getPrecomputes(e,t,n){let r=Ui.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),Ui.set(t,r))),r}cached(e,t,n){let r=Gi(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=Gi(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){Bi(t,this.bits),Wi.set(e,t),Ui.delete(e)}hasCache(e){return Gi(e)!==1}};function Ji(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>Ii||r>Ii;)n&Li&&(a=a.add(i)),r&Li&&(o=o.add(i)),i=i.double(),n>>=Li,r>>=Li;return{p1:a,p2:o}}function Yi(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Ti(t),t}else return Mi(e,{isLE:n})}function Xi(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>Ii))throw Error(`CURVE.${e} must be positive bigint`)}let i=Yi(t.p,n.Fp,r),a=Yi(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Zi(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function Qi(e,t){if(Ur(e),Ur(t),t<0||t>4)throw Error(`invalid I2OSP length: `+t);if(e<0||e>2**(8*t)-1)throw Error(`invalid I2OSP input: `+e);let n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function $i(e,t){let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function ea(e){if(!Lr(e)&&typeof e!=`string`)throw Error(`DST must be Uint8Array or ascii string`);let t=typeof e==`string`?Qr(e):e;if(t.length===0)throw Error(`DST must be non-empty`);return t}function ta(e,t,n,r){K(e),Ur(n),t=ea(t),t.length>255&&(t=r(q(Qr(`H2C-OVERSIZE-DST-`),t)));let{outputLen:i,blockLen:a}=r,o=Math.ceil(n/i);if(n>65535||o>255)throw Error(`expand_message_xmd: invalid lenInBytes`);let s=q(t,Qi(t.length,1)),c=new Uint8Array(a),l=Qi(n,2),u=Array(o),d=r(q(c,e,l,Qi(0,1),s));u[0]=r(q(d,Qi(1,1),s));for(let e=1;e<o;e++)u[e]=r(q($i(d,u[e-1]),Qi(e+1,1),s));return q(...u).slice(0,n)}var na=`HashToScalar-`,ra=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(yn(e),I(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),L(r)}update(e){return bn(this),this.iHash.update(e),this}digestInto(e){bn(this),xn(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ia=(()=>{let e=((e,t,n)=>new ra(e,t).update(n).digest());return e.create=(e,t)=>new ra(e,t),e})(),aa=(e,t)=>(e+(e>=0?t:-t)/la)/t;function oa(e,t,n){ti(`scalar`,e,Q,n);let[[r,i],[a,o]]=t,s=aa(o*e,n),c=aa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Q,f=u<Q;d&&(l=-l),f&&(u=-u);let p=ri(Math.ceil(ni(n)/2))+$;if(l<Q||l>=p||u<Q||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function sa(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function ca(e,t){ai(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Vr(n.lowS,`lowS`),Vr(n.prehash,`prehash`),n.format!==void 0&&sa(n.format),n}var Z={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Z;if(Ur(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(typeof t!=`string`)throw TypeError(`"data" expected string, got type=`+typeof t);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=Wr(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?Wr(i.length/2|128):``;return Wr(e)+a+i+t},decode(e,t){let{Err:n}=Z;t=K(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Z;if(Hr(e),e<Q)throw new t(`integer: negative integers are not allowed`);let n=Wr(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Z;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Kr(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=Z,i=K(e,void 0,`signature`),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=Z,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};Object.freeze(Z._tlv),Object.freeze(Z._int),Object.freeze(Z);var Q=BigInt(0),$=BigInt(1),la=BigInt(2),ua=BigInt(3),da=BigInt(4);function fa(e,t={}){let n=Xi(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;ai(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`});let{endo:c,allowInfinityPoint:l}=t;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let u=ma(r,i);function d(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function f(e,t,n){if(l&&t.is0())return Uint8Array.of(0);let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return Vr(n,`isCompressed`),n?(d(),q(pa(!r.isOdd(a)),o)):q(Uint8Array.of(4),o,r.toBytes(a))}function p(e){K(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=u,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=g(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}d();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!_(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let m=t.toBytes===void 0?f:t.toBytes,h=t.fromBytes===void 0?p:t.fromBytes;function g(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function _(e,t){let n=r.sqr(t),i=g(e);return r.eql(n,i)}if(!_(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let v=r.mul(r.pow(a.a,ua),da),y=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(v,y)))throw Error(`bad curve params: a or b`);function b(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function x(e){if(!(e instanceof w))throw Error(`Weierstrass Point expected`)}function S(e){if(!c||!c.basises)throw Error(`no endo`);return oa(e,c.basises,i.ORDER)}function C(e,t,n,i,a){return n=new w(r.mul(n.X,e),n.Y,n.Z),t=Ri(i,t),n=Ri(a,n),t.add(n)}class w{static BASE=new w(a.Gx,a.Gy,r.ONE);static ZERO=new w(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=b(`x`,e),this.Y=b(`y`,t,!0),this.Z=b(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof w)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?w.ZERO:new w(t,n,r.ONE)}static fromBytes(e){let t=w.fromAffine(h(K(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return w.fromBytes(Ir(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return T.createCache(this,e),t||this.multiply(ua),this}assertValidity(){let e=this;if(e.is0()){if(t.allowInfinityPoint&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!_(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){x(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new w(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,ua),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new w(c,l,u)}add(e){x(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,ua),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new w(l,u,d)}subtract(e){return x(e),this.add(e.negate())}is0(){return this.equals(w.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let r,a,o=e=>T.cached(this,e,e=>zi(w,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=S(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=C(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return zi(w,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this,a=e;if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(a===Q||r.is0())return w.ZERO;if(a===$)return r;if(T.hasCache(this))return this.multiply(a);if(n){let{k1neg:e,k1:t,k2neg:i,k2:o}=S(a),{p1:s,p2:c}=Ji(w,r,t,o);return C(n.beta,s,c,e,i)}else return T.unsafe(r,a)}toAffine(e){let t=this,n=e,{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){let{isTorsionFree:e}=t;return o===$?!0:e?e(w,this):T.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===$?this:e?e(w,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===$?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return Vr(e,`isCompressed`),this.assertValidity(),m(w,this,e)}toHex(e=!0){return Fr(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ee=i.BITS,T=new qi(w,t.endo?Math.ceil(ee/2):ee);return ee>=8&&w.BASE.precompute(8),Object.freeze(w.prototype),Object.freeze(w),w}function pa(e){return Uint8Array.of(e?2:3)}function ma(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ha(e,t={}){let{Fn:n}=e,r=t.randomBytes===void 0?Rr:t.randomBytes,i=Object.assign(ma(e.Fp,n),{seed:Math.max(Pi(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,Fi(K(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!Lr(e))return;let s=K(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t);return e.fromBytes(r).multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Zi(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function ga(e,t,n={}){let r=t;yn(r),ai(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`}),n=Object.assign({},n);let i=n.randomBytes===void 0?Rr:n.randomBytes,a=n.hmac===void 0?(e,t)=>ia(r,e,t):n.hmac,{Fp:o,Fn:s}=e,{ORDER:c,BITS:l}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:m}=ha(e,n),h={prehash:!0,lowS:typeof n.lowS==`boolean`?n.lowS:!0,format:`compact`,extraEntropy:!1},g=c*la+$<o.ORDER;function _(e){return e>c>>$}function v(e,t){if(!s.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function y(){if(g)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function b(e,t){sa(t);let n=m.signature;return K(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class x{r;s;recovery;constructor(e,t,n){if(this.r=v(`r`,e),this.s=v(`s`,t),n!=null){if(y(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=h.format){b(e,t);let n;if(t===`der`){let{r:t,s:n}=Z.toSig(K(e));return new x(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=m.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new x(s.fromBytes(i),s.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(Ir(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new x(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+c:n;if(!o.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let l=o.toBytes(a),u=e.fromBytes(q(pa((i&1)==0),l)),d=s.inv(a),f=C(K(t,void 0,`msgHash`)),p=s.create(-f*d),m=s.create(r*d),h=e.BASE.multiplyUnsafe(p).add(u.multiplyUnsafe(m));if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return _(this.s)}toBytes(e=h.format){if(sa(e),e===`der`)return Ir(Z.hexFromSig(this));let{r:t,s:n}=this,r=s.toBytes(t),i=s.toBytes(n);return e===`recovered`?(y(),q(Uint8Array.of(this.assertRecovery()),r,i)):q(r,i)}toHex(e){return Fr(this.toBytes(e))}}Object.freeze(x.prototype),Object.freeze(x);let S=n.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Kr(e),n=e.length*8-l;return n>0?t>>BigInt(n):t}:n.bits2int,C=n.bits2int_modN===void 0?function(e){return s.create(S(e))}:n.bits2int_modN,w=ri(l);function ee(e){return ti(`num < 2^`+l,e,Q,w),s.toBytes(e)}function T(e,t){return K(e,void 0,`message`),t?K(r(e),void 0,`prehashed message`):e}function te(t,n,r){let{lowS:a,prehash:o,extraEntropy:c}=ca(r,h);t=T(t,o);let l=C(t),u=s.fromBytes(n);if(!s.isValidNot0(u))throw Error(`invalid private key`);let d=[ee(u),ee(l)];if(c!=null&&c!==!1){let e=c===!0?i(m.secretKey):c;d.push(K(e,void 0,`extraEntropy`))}let f=q(...d),p=l;function v(t){let n=S(t);if(!s.isValidNot0(n))return;let r=s.inv(n),i=e.BASE.multiply(n).toAffine(),o=s.create(i.x);if(o===Q)return;let c=s.create(r*s.create(p+o*u));if(c===Q)return;let l=(i.x===o?0:2)|Number(i.y&$),d=c;return a&&_(c)&&(d=s.neg(c),l^=1),new x(o,d,g?void 0:l)}return{seed:f,k2sig:v}}function ne(e,t,n={}){let{seed:i,k2sig:o}=te(e,t,n);return ii(r.outputLen,s.BYTES,a)(i,o).toBytes(n.format)}function re(t,n,r,i={}){let{lowS:a,prehash:o,format:c}=ca(i,h);if(r=K(r,void 0,`publicKey`),n=T(n,o),!Lr(t)){let e=t instanceof x?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}b(t,c);try{let i=x.fromBytes(t,c),o=e.fromBytes(r);if(a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=C(n),f=s.inv(u),p=s.create(d*f),m=s.create(l*f),h=e.BASE.multiplyUnsafe(p).add(o.multiplyUnsafe(m));return h.is0()?!1:s.create(h.x)===l}catch{return!1}}function ie(e,t,n={}){let{prehash:r}=ca(n,h);return t=T(t,r),x.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:m,Point:e,sign:ne,verify:re,recoverPublicKey:ie,Signature:x,hash:r})}var _a=ga(fa({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),Mr);new Uint8Array([48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0]),class extends yr{static{this.SIZE=33}constructor(e){if(super(),typeof e==`string`?this.data=E(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==33)throw Error(`Invalid public key input. Expected 33 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return hr.Passkey}async verify(e,t){let n=va(t),r=JSON.parse(n.clientDataJson);if(r.type!==`webauthn.get`||!vr(e,E(r.challenge.replace(/-/g,`+`).replace(/_/g,`/`))))return!1;let i=n.userSignature.slice(65);if(!vr(this.toRawBytes(),i))return!1;let a=new Uint8Array([...n.authenticatorData,...Mr(new TextEncoder().encode(n.clientDataJson))]),o=n.userSignature.slice(1,65);return _a.verify(o,a,i)}};function va(e){let t=typeof e==`string`?E(e):e;if(t[0]!==hr.Passkey)throw Error(`Invalid signature scheme`);let n=Bt.parse(t.slice(1));return{signatureScheme:`Passkey`,serializedSignature:D(t),signature:t,authenticatorData:n.authenticatorData,clientDataJson:n.clientDataJson,userSignature:new Uint8Array(n.userSignature),publicKey:new Uint8Array(n.userSignature.slice(65))}}function ya(e){for(let t=0;t<e.length;t++)if(e[t]!==0)return t;return-1}function ba(e,t){return Mn(e.toString(16).padStart(t*2,`0`).slice(-t*2))}function xa(e,t){let n=ba(e,t),r=ya(n);return r===-1?new Uint8Array([0]):n.slice(r)}function Sa(e){return e===`accounts.google.com`?`https://accounts.google.com`:e}function Ca(e){if(e.length!==1)throw Error(`Invalid base64Url character: `+e);let t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(e);if(t===-1)throw Error(`Invalid base64Url character: `+e);let n=t.toString(2).padStart(6,`0`);return Array.from(n).map(Number)}function wa(e){let t=[];for(let n=0;n<e.length;n++){let r=Ca(e.charAt(n));t=t.concat(r)}return t}function Ta(e,t){if(e.length<2)throw Error(`Input (s = ${e}) is not tightly packed because s.length < 2`);let n=wa(e),r=t%4;if(r!==0)if(r===1)n=n.slice(2);else if(r===2)n=n.slice(4);else throw Error(`Input (s = ${e}) is not tightly packed because i%4 = 3 (i = ${t}))`);let i=(t+e.length-1)%4;if(i!==3)if(i===2)n=n.slice(0,n.length-2);else if(i===1)n=n.slice(0,n.length-4);else throw Error(`Input (s = ${e}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${t}))`);if(n.length%8!=0)throw Error(`We should never reach here...`);let a=new Uint8Array(Math.floor(n.length/8)),o=0;for(let e=0;e<n.length;e+=8){let t=n.slice(e,e+8),r=parseInt(t.join(``),2);a[o++]=r}return new TextDecoder().decode(a)}function Ea(e){if(!(e.slice(-1)===`}`||e.slice(-1)===`,`))throw Error(`Invalid claim`);let t=JSON.parse(`{`+e.slice(0,-1)+`}`);if(Object.keys(t).length!==1)throw Error(`Invalid claim`);let n=Object.keys(t)[0];return[n,t[n]]}function Da(e,t){let[n,r]=Ea(Ta(e.value,e.indexMod4));if(n!==t)throw Error(`Invalid field name: found ${n} expected ${t}`);return r}var Oa=k.struct(`ZkLoginSignature`,{inputs:k.struct(`ZkLoginSignatureInputs`,{proofPoints:k.struct(`ZkLoginSignatureInputsProofPoints`,{a:k.vector(k.string()),b:k.vector(k.vector(k.string())),c:k.vector(k.string())}),issBase64Details:k.struct(`ZkLoginSignatureInputsClaim`,{value:k.string(),indexMod4:k.u8()}),headerBase64:k.string(),addressSeed:k.string()}),maxEpoch:k.u64(),userSignature:k.byteVector()});function ka(e){return Oa.parse(typeof e==`string`?E(e):e)}var Aa=class e extends yr{#e;#t;#n;constructor(e,{client:t}={}){super(),this.#t=t,typeof e==`string`?this.#e=E(e):e instanceof Uint8Array?this.#e=e:this.#e=Uint8Array.from(e),this.#n=this.#e.length!==this.#e[0]+1+32,this.#n&&(this.#e=Ma(this.#e,!1))}static fromBytes(t,{client:n,address:r,legacyAddress:i}={}){let a;if(i===!0?a=new e(Ma(t,!0),{client:n}):i===!1?a=new e(Ma(t,!1),{client:n}):r?(a=new e(Ma(t,!1),{client:n}),a.toSuiAddress()!==r&&(a=new e(Ma(t,!0),{client:n}))):a=new e(t,{client:n}),r&&a.toSuiAddress()!==r)throw Error(`Public key bytes do not match the provided address`);return a}static fromProof(e,t){let{issBase64Details:n,addressSeed:r}=t,i=Da(n,`iss`),a=ja(BigInt(r),i,{legacyAddress:!0});if(a.toSuiAddress()===e)return a;let o=ja(BigInt(r),i,{legacyAddress:!1});if(o.toSuiAddress()!==e)throw Error(`Proof does not match address`);return o}equals(e){return super.equals(e)}toSuiAddress(){return this.#n?this.#r():super.toSuiAddress()}#r(){let e=Ma(this.#e,!0),t=new Uint8Array(e.length+1);return t[0]=this.flag(),t.set(e,1),A(An(pr(t,{dkLen:32})).slice(0,64))}toRawBytes(){return this.#e}flag(){return hr.ZkLogin}async verify(e,t){throw Error(`does not support`)}verifyPersonalMessage(t,n){let r=Pa(n);return Na({address:new e(r.publicKey).toSuiAddress(),bytes:D(t),signature:r.serializedSignature,intentScope:`PersonalMessage`,client:this.#t})}verifyTransaction(t,n){let r=Pa(n);return Na({address:new e(r.publicKey).toSuiAddress(),bytes:D(t),signature:r.serializedSignature,intentScope:`TransactionData`,client:this.#t})}verifyAddress(e){return e===super.toSuiAddress()||e===this.#r()}};function ja(e,t,n){if(n.legacyAddress===void 0)throw Error(`legacyAddress parameter must be specified`);let r=n.legacyAddress?xa(e,32):ba(e,32),i=new TextEncoder().encode(Sa(t)),a=new Uint8Array(1+i.length+r.length);return a.set([i.length],0),a.set(i,1),a.set(r,1+i.length),new Aa(a,n)}function Ma(e,t){let n=e[0]+1,r=BigInt(`0x${me(e.slice(n))}`),i=t?xa(r,32):ba(r,32),a=new Uint8Array(n+i.length);return a.set(e.slice(0,n),0),a.set(i,n),a}async function Na({address:e,bytes:t,signature:n,intentScope:r,client:i}){if(!i)throw Error(`A Sui Client (GRPC, GraphQL, or JSON RPC) is required to verify zkLogin signatures`);let a=await i.core.verifyZkLoginSignature({bytes:t,signature:n,intentScope:r,address:e});return a.success===!0&&a.errors.length===0}function Pa(e){let t=typeof e==`string`?E(e):e;if(t[0]!==hr.ZkLogin)throw Error(`Invalid signature scheme`);let{inputs:n,maxEpoch:r,userSignature:i}=ka(t.slice(1)),{issBase64Details:a,addressSeed:o}=n,s=Da(a,`iss`),c=ja(BigInt(o),s,{legacyAddress:!1});return{serializedSignature:D(t),signatureScheme:`ZkLogin`,zkLogin:{inputs:n,maxEpoch:r,userSignature:i,iss:s,addressSeed:BigInt(o)},signature:t,publicKey:c.toRawBytes()}}function Fa({signature:e,signatureScheme:t,publicKey:n}){if(!n)throw Error("`publicKey` is required");let r=n.toRawBytes(),i=new Uint8Array(1+e.length+r.length);return i.set([hr[t]]),i.set(e,1),i.set(r,1+e.length),D(i)}function Ia(e){let t=E(e),n=_r[t[0]];switch(n){case`Passkey`:return va(e);case`MultiSig`:return{serializedSignature:e,signatureScheme:n,multisig:_n.MultiSig.parse(t.slice(1)),bytes:t,signature:void 0};case`ZkLogin`:return Pa(e);case`ED25519`:case`Secp256k1`:case`Secp256r1`:return br(e);default:throw Error(`Unsupported signature scheme`)}}var La=`suiprivkey`,Ra=class{async signWithIntent(e,t){let n=pr(mr(t,e),{dkLen:32});return{signature:Fa({signature:await this.sign(n),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:D(e)}}async signTransaction(e){return this.signWithIntent(e,`TransactionData`)}async signPersonalMessage(e){let{signature:t}=await this.signWithIntent(k.byteVector().serialize(e).toBytes(),`PersonalMessage`);return{bytes:D(e),signature:t}}async signAndExecuteTransaction({transaction:e,client:t}){e.setSenderIfNotSet(this.toSuiAddress());let n=await e.build({client:t}),{signature:r}=await this.signTransaction(n);return t.core.executeTransaction({transaction:n,signatures:[r],include:{transaction:!0,effects:!0}})}toSuiAddress(){return this.getPublicKey().toSuiAddress()}},za=class extends Ra{};function Ba(e){let{prefix:t,words:n}=le.decode(e);if(t!==`suiprivkey`)throw Error(`invalid private key prefix`);let r=new Uint8Array(le.fromWords(n)),i=r.slice(1);return{scheme:_r[r[0]],secretKey:i}}function Va(e,t){if(e.length!==32)throw Error(`Invalid bytes length`);let n=hr[t],r=new Uint8Array(e.length+1);return r.set([n]),r.set(e,1),le.encode(La,le.toWords(r))}var Ha=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Ua=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},Wa,Ga,Ka,qa,Ja,Ya,Xa=class e{get address(){return Ha(this,Wa,`f`)}get publicKey(){return Ha(this,Ga,`f`).slice()}get chains(){return Ha(this,Ka,`f`).slice()}get features(){return Ha(this,qa,`f`).slice()}get label(){return Ha(this,Ja,`f`)}get icon(){return Ha(this,Ya,`f`)}constructor(t){Wa.set(this,void 0),Ga.set(this,void 0),Ka.set(this,void 0),qa.set(this,void 0),Ja.set(this,void 0),Ya.set(this,void 0),new.target===e&&Object.freeze(this),Ua(this,Wa,t.address,`f`),Ua(this,Ga,t.publicKey.slice(),`f`),Ua(this,Ka,t.chains.slice(),`f`),Ua(this,qa,t.features.slice(),`f`),Ua(this,Ja,t.label,`f`),Ua(this,Ya,t.icon,`f`)}};Wa=new WeakMap,Ga=new WeakMap,Ka=new WeakMap,qa=new WeakMap,Ja=new WeakMap,Ya=new WeakMap;var Za=[`sui:devnet`,`sui:testnet`,`sui:localnet`,`sui:mainnet`],Qa=[`sui:signTransaction`,`sui:signAndExecuteTransaction`,`sui:signPersonalMessage`];function $a(e){let t=[...Za],n=new Set(Za);for(let r of e??[]){let e=`sui:${r}`;n.has(e)||(n.add(e),t.push(e))}return t}function eo(e,t,n,r,i){return{address:t,label:n,signer:e,walletAccount:new Xa({address:t,label:n,publicKey:e.getPublicKey().toSuiBytes(),chains:i===void 0?[...Za]:[...i],features:[...r??Qa]})}}var to=class{constructor(){this.allowAutoSign=!0,this.#e=[],this.#t=new Set}#e;#t;getAccounts(){return[...this.#e]}getAccount(e){return this.#e.find(t=>t.address===e)}onAccountsChanged(e){return this.#t.add(e),()=>{this.#t.delete(e)}}destroy(){this.#e=[],this.#t.clear()}get _accounts(){return this.#e}setInitialAccounts(e){this.#e=e,this.notifyListeners()}addAccount(e){this.#e.push(e),this.notifyListeners()}removeAccountByAddress(e){let t=this.#e.findIndex(t=>t.address===e);return t===-1?!1:(this.#e.splice(t,1),this.notifyListeners(),!0)}replaceAccount(e,t){let n=this.#e.findIndex(t=>t.address===e);return n===-1?!1:(this.#e[n]=t,this.notifyListeners(),!0)}_performRename(e,t){let n=this.getAccount(e);return n?this.replaceAccount(e,eo(n.signer,e,t)):!1}getDefaultLabel(){return`Account ${this.getAccounts().length+1}`}notifyListeners(){let e=this.getAccounts();for(let t of this.#t)t(e)}};export{gn as $,Zr as A,vr as B,ti as C,Fr as D,Ur as E,Rr as F,yn as G,hr as H,ai as I,L as J,F as K,Mr as L,Ir as M,Lr as N,qr as O,oi as P,_n as Q,Nr as R,hi as S,K as T,pr as U,br as V,I as W,Mn as X,Cn as Y,Pn as Z,zi as _,Ra as a,Ke as at,Ci as b,Ia as c,Ge as ct,fa as d,me as dt,en as et,ia as f,E as ft,Zi as g,Xi as h,ue as ht,za as i,Ie as it,Xr as j,q as k,_a as l,be as lt,ta as m,de as mt,eo as n,et as nt,Ba as o,A as ot,na as p,D as pt,In as q,$a as r,tt as rt,Va as s,qe as st,to as t,it as tt,ga as u,pe as ut,qi as v,Vr as w,X as x,Mi as y,yr as z};
@@ -1 +1 @@
1
- import{G as e,J as t,K as n,R as r,Y as i,Z as a,dt as o,f as s,i as c,n as l,o as u,q as d,s as f,t as p,ut as m}from"./base-adapter-DET6CP7z.js";import{n as h,r as g}from"./main-CuOnBmaa.js";function _(t,r,i,o){e(t);let{c,dkLen:l,asyncTick:u}=d({dkLen:32,asyncTick:10},o);if(n(c,`c`),n(l,`dkLen`),n(u,`asyncTick`),c<1)throw Error(`iterations (c) must be >= 1`);if(l<1)throw Error(`"dkLen" must be >= 1`);if(l>(2**32-1)*t.outputLen)throw Error(`derived key too long`);let f=a(r,`password`),p=a(i,`salt`),m=new Uint8Array(l),h=s.create(t,f);return{c,dkLen:l,asyncTick:u,DK:m,PRF:h,PRFSalt:h._cloneInto().update(p)}}function v(e,n,r,i,a){return e.destroy(),n.destroy(),i&&i.destroy(),t(a),r}function y(e,t,n,r){let{c:a,dkLen:o,DK:s,PRF:c,PRFSalt:l}=_(e,t,n,r),u,d=new Uint8Array(4),f=i(d),p=new Uint8Array(c.outputLen);for(let e=1,t=0;t<o;e++,t+=c.outputLen){let n=s.subarray(t,t+c.outputLen);f.setInt32(0,e,!1),(u=l._cloneInto(u)).update(d).digestInto(p),n.set(p.subarray(0,n.length));for(let e=1;e<a;e++){c._cloneInto(u).update(p).digestInto(p);for(let e=0;e<n.length;e++)n[e]^=p[e]}}return v(c,l,s,u,p)}function b(e){if(typeof e!=`string`)throw TypeError(`invalid mnemonic type: `+typeof e);return e.normalize(`NFKD`)}function x(e){let t=b(e),n=t.split(` `);if(![12,15,18,21,24].includes(n.length))throw Error(`Invalid mnemonic`);return{nfkd:t,words:n}}var S=e=>b(`mnemonic`+e);function C(e,t=``){return y(r,x(e).nfkd,S(t),{c:2048,dkLen:64})}function w(e){return!!RegExp(`^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$`).test(e)}function T(e){return C(e,``)}function E(e){return o(T(e))}var D=`ed25519 seed`,O=2147483648,k=RegExp(`^m(\\/[0-9]+')+$`),A=e=>e.replace(`'`,``),j=e=>{let t=s.create(r,new TextEncoder().encode(D)).update(m(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},M=({key:e,chainCode:t},n)=>{let i=new ArrayBuffer(4);new DataView(i).setUint32(0,n);let a=new Uint8Array(1+e.length+i.byteLength);a.set(new Uint8Array(1).fill(0)),a.set(e,1),a.set(new Uint8Array(i,0,i.byteLength),e.length+1);let o=s.create(r,t).update(a).digest();return{key:o.slice(0,32),chainCode:o.slice(32)}},N=e=>k.test(e)?!e.split(`/`).slice(1).map(A).some(isNaN):!1,P=(e,t,n=O)=>{if(!N(e))throw Error(`Invalid derivation path`);let{key:r,chainCode:i}=j(t);return e.split(`/`).slice(1).map(A).map(e=>parseInt(e,10)).reduce((e,t)=>M(e,t+n),{key:r,chainCode:i})},F=`m/44'/784'/0'/0'/0'`,I=class e extends c{constructor(e){if(super(),e)this.keypair={publicKey:e.publicKey,secretKey:e.secretKey.slice(0,32)};else{let e=g.utils.randomSecretKey();this.keypair={publicKey:g.getPublicKey(e),secretKey:e}}}getKeyScheme(){return`ED25519`}static generate(){let t=g.utils.randomSecretKey();return new e({publicKey:g.getPublicKey(t),secretKey:t})}static fromSecretKey(t,n){if(typeof t==`string`){let e=u(t);if(e.scheme!==`ED25519`)throw Error(`Expected a ED25519 keypair, got ${e.scheme}`);return this.fromSecretKey(e.secretKey,n)}let r=t.length;if(r!==32)throw Error(`Wrong secretKey size. Expected 32 bytes, got ${r}.`);let i={publicKey:g.getPublicKey(t),secretKey:t};if(!n||!n.skipValidation){let e=new TextEncoder().encode(`sui validation`),n=g.sign(e,t);if(!g.verify(n,e,i.publicKey))throw Error(`provided secretKey is invalid`)}return new e(i)}getPublicKey(){return new h(this.keypair.publicKey)}getSecretKey(){return f(this.keypair.secretKey.slice(0,32),this.getKeyScheme())}async sign(e){return g.sign(e,this.keypair.secretKey)}static deriveKeypair(t,n){if(n??=F,!w(n))throw Error(`Invalid derivation path`);let{key:r}=P(n,E(t));return e.fromSecretKey(r)}static deriveKeypairFromSeed(t,n){if(n??=F,!w(n))throw Error(`Invalid derivation path`);let r=typeof t==`string`?t:o(t),{key:i}=P(n,r);return e.fromSecretKey(i)}},L=class extends p{constructor(...e){super(...e),this.id=`in-memory`,this.name=`In-Memory Signer`}async initialize(){}async createAccount(e){let t=new I,n=l(t,t.getPublicKey().toSuiAddress(),e?.label??this.getDefaultLabel());return this.addAccount(n),n}async importAccount(e){let t=e.signer;if(!t)throw Error(`In-memory adapter requires a signer to import`);let n=t.toSuiAddress(),r=this.getAccount(n);if(r)return r;let i=l(t,n,e.label??this.getDefaultLabel());return this.addAccount(i),i}async renameAccount(e,t){return this._performRename(e,t)}async removeAccount(e){return this.removeAccountByAddress(e)}};export{L as InMemorySignerAdapter};
1
+ import{G as e,J as t,K as n,R as r,Y as i,Z as a,dt as o,f as s,i as c,n as l,o as u,q as d,s as f,t as p,ut as m}from"./base-adapter-C5w5q7XZ.js";import{n as h,r as g}from"./main-xfzarPod.js";function _(t,r,i,o){e(t);let{c,dkLen:l,asyncTick:u}=d({dkLen:32,asyncTick:10},o);if(n(c,`c`),n(l,`dkLen`),n(u,`asyncTick`),c<1)throw Error(`iterations (c) must be >= 1`);if(l<1)throw Error(`"dkLen" must be >= 1`);if(l>(2**32-1)*t.outputLen)throw Error(`derived key too long`);let f=a(r,`password`),p=a(i,`salt`),m=new Uint8Array(l),h=s.create(t,f);return{c,dkLen:l,asyncTick:u,DK:m,PRF:h,PRFSalt:h._cloneInto().update(p)}}function v(e,n,r,i,a){return e.destroy(),n.destroy(),i&&i.destroy(),t(a),r}function y(e,t,n,r){let{c:a,dkLen:o,DK:s,PRF:c,PRFSalt:l}=_(e,t,n,r),u,d=new Uint8Array(4),f=i(d),p=new Uint8Array(c.outputLen);for(let e=1,t=0;t<o;e++,t+=c.outputLen){let n=s.subarray(t,t+c.outputLen);f.setInt32(0,e,!1),(u=l._cloneInto(u)).update(d).digestInto(p),n.set(p.subarray(0,n.length));for(let e=1;e<a;e++){c._cloneInto(u).update(p).digestInto(p);for(let e=0;e<n.length;e++)n[e]^=p[e]}}return v(c,l,s,u,p)}function b(e){if(typeof e!=`string`)throw TypeError(`invalid mnemonic type: `+typeof e);return e.normalize(`NFKD`)}function x(e){let t=b(e),n=t.split(` `);if(![12,15,18,21,24].includes(n.length))throw Error(`Invalid mnemonic`);return{nfkd:t,words:n}}var S=e=>b(`mnemonic`+e);function C(e,t=``){return y(r,x(e).nfkd,S(t),{c:2048,dkLen:64})}function w(e){return!!RegExp(`^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$`).test(e)}function T(e){return C(e,``)}function E(e){return o(T(e))}var D=`ed25519 seed`,O=2147483648,k=RegExp(`^m(\\/[0-9]+')+$`),A=e=>e.replace(`'`,``),j=e=>{let t=s.create(r,new TextEncoder().encode(D)).update(m(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},M=({key:e,chainCode:t},n)=>{let i=new ArrayBuffer(4);new DataView(i).setUint32(0,n);let a=new Uint8Array(1+e.length+i.byteLength);a.set(new Uint8Array(1).fill(0)),a.set(e,1),a.set(new Uint8Array(i,0,i.byteLength),e.length+1);let o=s.create(r,t).update(a).digest();return{key:o.slice(0,32),chainCode:o.slice(32)}},N=e=>k.test(e)?!e.split(`/`).slice(1).map(A).some(isNaN):!1,P=(e,t,n=O)=>{if(!N(e))throw Error(`Invalid derivation path`);let{key:r,chainCode:i}=j(t);return e.split(`/`).slice(1).map(A).map(e=>parseInt(e,10)).reduce((e,t)=>M(e,t+n),{key:r,chainCode:i})},F=`m/44'/784'/0'/0'/0'`,I=class e extends c{constructor(e){if(super(),e)this.keypair={publicKey:e.publicKey,secretKey:e.secretKey.slice(0,32)};else{let e=g.utils.randomSecretKey();this.keypair={publicKey:g.getPublicKey(e),secretKey:e}}}getKeyScheme(){return`ED25519`}static generate(){let t=g.utils.randomSecretKey();return new e({publicKey:g.getPublicKey(t),secretKey:t})}static fromSecretKey(t,n){if(typeof t==`string`){let e=u(t);if(e.scheme!==`ED25519`)throw Error(`Expected a ED25519 keypair, got ${e.scheme}`);return this.fromSecretKey(e.secretKey,n)}let r=t.length;if(r!==32)throw Error(`Wrong secretKey size. Expected 32 bytes, got ${r}.`);let i={publicKey:g.getPublicKey(t),secretKey:t};if(!n||!n.skipValidation){let e=new TextEncoder().encode(`sui validation`),n=g.sign(e,t);if(!g.verify(n,e,i.publicKey))throw Error(`provided secretKey is invalid`)}return new e(i)}getPublicKey(){return new h(this.keypair.publicKey)}getSecretKey(){return f(this.keypair.secretKey.slice(0,32),this.getKeyScheme())}async sign(e){return g.sign(e,this.keypair.secretKey)}static deriveKeypair(t,n){if(n??=F,!w(n))throw Error(`Invalid derivation path`);let{key:r}=P(n,E(t));return e.fromSecretKey(r)}static deriveKeypairFromSeed(t,n){if(n??=F,!w(n))throw Error(`Invalid derivation path`);let r=typeof t==`string`?t:o(t),{key:i}=P(n,r);return e.fromSecretKey(i)}},L=class extends p{constructor(...e){super(...e),this.id=`in-memory`,this.name=`In-Memory Signer`}async initialize(){}async createAccount(e){let t=new I,n=l(t,t.getPublicKey().toSuiAddress(),e?.label??this.getDefaultLabel());return this.addAccount(n),n}async importAccount(e){let t=e.signer;if(!t)throw Error(`In-memory adapter requires a signer to import`);let n=t.toSuiAddress(),r=this.getAccount(n);if(r)return r;let i=l(t,n,e.label??this.getDefaultLabel());return this.addAccount(i),i}async renameAccount(e,t){return this._performRename(e,t)}async removeAccount(e){return this.removeAccountByAddress(e)}};export{L as InMemorySignerAdapter};