diff --git a/ventures/lineage/orgchain/assets/index-BTAQkVlY.js b/ventures/lineage/orgchain/assets/index-BTAQkVlY.js new file mode 100644 index 0000000..8fa377f --- /dev/null +++ b/ventures/lineage/orgchain/assets/index-BTAQkVlY.js @@ -0,0 +1,2053 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const ca=5e9;function cc(t,e,n){const r=[];for(const[s,o]of t){const i=o-s;if(e>=i){e-=i;continue}const a=Math.min(n,i-e);if(a&&r.push([s+e,s+e+a]),n-=a,e=0,!n)break}return r}function uc(t,e){var n;return(n=cc(t,e,1)[0])==null?void 0:n[0]}function es(t,e){let n=0;for(const[r,s]of t){if(e>=r&&ei.ranges);let o=0;return t.vout.map(i=>{const a=cc(s,o,Number(i.value));return o+=Number(i.value),a})}function Po(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Ul(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function lc(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Pl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Po(t.outputLen),Po(t.blockLen)}function Nl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ll(t,e){lc(t);const n=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),tt=(t,e)=>t<<32-e|t>>>e,Hl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hl)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function jl(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function dc(t){if(typeof t=="string"&&(t=jl(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}let Dl=class{clone(){return this._cloneInto()}};function hc(t){const e=r=>t().update(dc(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Zl(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,a,r)}let Kl=class extends Dl{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=so(this.buffer)}update(e){ro.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=dc(e);const o=e.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;ft&e^~t&n,Ml=(t,e,n)=>t&e^t&n^e&n,ql=new Uint32Array([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]),_t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),kt=new Uint32Array(64);let pc=class extends Kl{constructor(){super(64,32,8,!1),this.A=_t[0]|0,this.B=_t[1]|0,this.C=_t[2]|0,this.D=_t[3]|0,this.E=_t[4]|0,this.F=_t[5]|0,this.G=_t[6]|0,this.H=_t[7]|0}get(){const{A:e,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[e,n,r,s,o,i,a,c]}set(e,n,r,s,o,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)kt[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const d=kt[f-15],h=kt[f-2],m=tt(d,7)^tt(d,18)^d>>>3,y=tt(h,17)^tt(h,19)^h>>>10;kt[f]=y+kt[f-7]+m+kt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=tt(a,6)^tt(a,11)^tt(a,25),h=l+d+Vl(a,c,u)+ql[f]+kt[f]|0,y=(tt(r,2)^tt(r,13)^tt(r,22))+Ml(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},zl=class extends pc{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const No=hc(()=>new pc);hc(()=>new zl);function Fl(t,e){if(t.length>e)throw new TypeError(`Data is larger than array size: ${t.length} > ${e}`)}function Gl(t){if(t.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+t);if(t.length%2!==0)throw new Error(`Length of hex string is invalid: ${t.length}`)}function Yl(t){if(t>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:Wl}=crypto??globalThis.crypto??window.crypto;function Xl(t=32){if(typeof Wl=="function")return crypto.getRandomValues(new Uint8Array(t));throw new Error("Crypto module missing getRandomValues!")}function Jl(t,e,n="be"){e===void 0&&(e=t.length),Fl(t,e);const r=new Uint8Array(e).fill(0),s=n==="be"?0:e-t.length;return r.set(t,s),r}function gc(t){let e,n=0;const r=t.reduce((o,i)=>o+i.length,0),s=new Uint8Array(r);for(e=0;e0||(i.length^a)>0?"":"1";c in o||u>0;)l=o[c],l=l>0?l*256+u:u,u=l/s|0,o[c]=l%s,c++;for(;c-- >0;)i+=r[o[c]];return n&&i.length%4>0?i+"=".repeat(4-i.length%4):i}function nd(t,e){const n=mc(e),r=n.length,s=[],o=[];t=t.replace("=","");let i,a=0,c,u;for(i=0;i0||(o.length^i)>0||o.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)o.push(s[a]);return new Uint8Array(o)}function yc(t){return No(No(t))}function rd(t){const e=yc(t);return gc([t,e.slice(0,4)])}function sd(t){const e=t.slice(0,-4),n=t.slice(-4);if(yc(e).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return e}const ua={encode:td,decode:nd},bc={encode:t=>{const e=rd(t);return ua.encode(e,"base58")},decode:t=>{const e=ua.decode(t,"base58");return sd(e)}},wc="qpzry9x8gf2tvdw0s3jn54khce6mua7l",od=[996825010,642813549,513874426,1027748829,705979059],as=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function xc(t){let e=1;for(let n=0;n>25;e=(e&33554431)<<5^t[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(e^=od[s])}return e}function vc(t){const e=[];let n;for(n=0;n>5);for(e.push(0),n=0;n>5*(5-i)&31);return o}function Ec(t,e,n,r=!0){const s=[];let o=0,i=0;const a=(1<>e>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(o=(o<=n;)i-=n,s.push(o>>i&a)}if(r)i>0&&s.push(o<=e||(o<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function cd(t,e,n){const r=e.concat(ad(t,e,n));let s=t+"1";for(let o=0;oo.version===e[0])??as[0];if(!id(r,e,s))throw new Error("Checksum verification failed!");return[r,e.slice(0,e.length-6)]}function ud(t){let e,n,r=!1,s=!1;for(e=0;e126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function fd(t){const e=t.lastIndexOf("1");return!(e<1||e+7>t.length||t.length>90)}function ld(t,e="bc",n=0){const r=[n,...Ec([...t],8,5)],s=as.find(i=>i.version===n)??as[0],o=cd(e,r,s);return _c(o),o}function _c(t){t=t.toLowerCase();const e=t.split("1",1)[0],[n,r]=Sc(t),s=Ec(r.slice(1),5,8,!1),o=s.length;switch(!0){case e!==n:throw new Error("Returned hrp string is invalid.");case(s===null||o<2||o>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function dd(t){t=t.toLowerCase();const[e,n]=Sc(t);return n[0]}const kc={encode:ld,decode:_c,version:dd},Ac="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",hd=new TextEncoder;function $c(t,e=!1,n=!0){typeof t=="string"&&(t=hd.encode(t));const r=e?Bc:Ac;let s="",o=0,i=0;for(let a=0;a=6;)o-=6,s+=r[i>>o&63];if(o>0)for(i<<=6-o,s+=r[i&63];o<6;)s+=n?"=":"",o+=2;return s}function Oc(t,e=!1){const n=e||t.includes("-")||t.includes("_")?Bc.split(""):Ac.split("");t=t.replace(/=+$/,"");const r=t.split("");let s=0,o=0;const i=[];for(let a=0;a=8&&(s-=8,i.push(o>>>s&255))}return new Uint8Array(i)}const Tc={encode:$c,decode:Oc},Cc={encode:t=>$c(t,!0,!1),decode:t=>Oc(t,!0)},pd=BigInt(0),gd=BigInt(255),Ic=BigInt(256);function md(t){if(t<=0xffn)return 1;if(t<=0xffffn)return 2;if(t<=0xffffffffn)return 4;if(t<=0xffffffffffffffffn)return 8;if(t<=0xffffffffffffffffffffffffffffffffn)return 16;if(t<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function yd(t,e,n="be"){e===void 0&&(e=md(t));const r=n==="le",s=new ArrayBuffer(e),o=new DataView(s);let i=r?0:e-1;for(;t>pd;){const a=t&gd,c=Number(a);r?o.setUint8(i++,c):o.setUint8(i--,c),t=(t-a)/Ic}return new Uint8Array(s)}function bd(t){let e=BigInt(0);for(let n=t.length-1;n>=0;n--)e=e*Ic+BigInt(t[n]);return BigInt(e)}function wd(t){const e=t.split("").map(Number);if(e.length%8!==0)throw new Error(`Binary array is invalid length: ${t.length}`);const n=new Uint8Array(e.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)e[n]=r>>s&1}return e.join("")}function vd(t){if(t<=255)return 1;if(t<=65535)return 2;if(t<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function Ed(t,e,n="be"){e===void 0&&(e=vd(t));const r=n==="le",s=new ArrayBuffer(e),o=new DataView(s);let i=r?0:e-1;for(;t>0;){const a=t&255;r?o.setUint8(i++,t):o.setUint8(i--,t),t=(t-a)/256}return new Uint8Array(s)}function Sd(t){let e=0;for(let n=t.length-1;n>=0;n--)e=e*256+t[n],Yl(e);return e}const _d=new TextEncoder,kd=new TextDecoder;function li(t){return _d.encode(t)}function oo(t){return kd.decode(t)}function Ad(t,e){Gl(t);const n=t.length/2;if(e===void 0&&(e=n),n>e)throw new TypeError(`Hex string is larger than array size: ${n} > ${e}`);return e}function Bd(t,e,n="le"){e=Ad(t,e);const r=n==="le",s=new ArrayBuffer(e),o=new DataView(s);let i=r?0:e-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return li(e)}function Td(t,e,n){if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Uint8Array)return Jl(t,e,n);if(typeof t=="string")return Bd(t,e,n);if(typeof t=="bigint")return yd(t,e,n);if(typeof t=="number")return Ed(t,e,n);if(typeof t=="boolean")return Uint8Array.of(t?1:0);throw TypeError("Unsupported format:"+typeof t)}var X;let _=(X=class extends Uint8Array{static random(e=32){const n=Xl(e);return new X(n,e)}constructor(e,n,r){const s=Td(e,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new Yn(this)}toNum(e="be"){const n=e==="be"?this.reverse():this;return Sd(n)}toBin(){return xd(this)}toBig(e="be"){const n=e==="be"?this.reverse():this;return bd(n)}toHash(){const e=No(this);return new X(e)}toJson(){const e=oo(this);return JSON.parse(e)}toBech32(e,n=0){return kc.encode(this,e,n)}toStr(){return oo(this)}toHex(){return $d(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return bc.encode(this)}toBase64(){return Tc.encode(this)}toB64url(){return Cc.encode(this)}prepend(e){return X.join([X.bytes(e),this])}append(e){return X.join([this,X.bytes(e)])}slice(e,n){const r=new Uint8Array(this).slice(e,n);return new X(r)}subarray(e,n){const r=new Uint8Array(this).subarray(e,n);return new X(r)}reverse(){const e=new Uint8Array(this).reverse();return new X(e)}write(e,n){const r=X.bytes(e);this.set(r,n)}prefixSize(e){const n=X.varInt(this.length,e);return X.join([n,this])}static from(e){return new X(Uint8Array.from(e))}static of(...e){return new X(Uint8Array.of(...e))}static join(e){const n=e.map(s=>X.bytes(s)),r=gc(n);return new X(r)}static varInt(e,n){if(e<253)return X.num(e,1);if(e<65536)return X.of(253,...X.num(e,2,n));if(e<4294967296)return X.of(254,...X.num(e,4,n));if(BigInt(e)<0x10000000000000000n)return X.of(255,...X.num(e,8,n));throw new Error(`Value is too large: ${e}`)}},X.num=Cd,X.big=Ud,X.bin=Id,X.raw=Pd,X.str=Nd,X.hex=Ld,X.bytes=Rd,X.json=Hd,X.base64=jd,X.b64url=Dd,X.bech32=Zd,X.b58chk=Kd,X.encode=li,X.decode=oo,X);function Cd(t,e,n){return new _(t,e,n)}function Id(t,e,n){return new _(wd(t),e,n)}function Ud(t,e,n){return new _(t,e,n)}function Pd(t,e,n){return new _(t,e,n)}function Nd(t,e,n){return new _(li(t),e,n)}function Ld(t,e,n){return new _(t,e,n)}function Rd(t,e,n){return new _(t,e,n)}function Hd(t){return new _(Od(t))}function jd(t){return new _(Tc.decode(t))}function Dd(t){return new _(Cc.decode(t))}function Zd(t){return new _(kc.decode(t))}function Kd(t){return new _(bc.decode(t))}let Yn=class{constructor(e){this.data=_.bytes(e),this.size=this.data.length}peek(e){if(e>this.size)throw new Error(`Size greater than stream: ${e} > ${this.size}`);return new _(this.data.slice(0,e))}read(e){e=e??this.readSize();const n=this.peek(e);return this.data=this.data.slice(e),this.size=this.data.length,n}readSize(e){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(e);case n===254:return this.read(4).toNum(e);case n===255:return this.read(8).toNum(e);default:throw new Error(`Varint is out of range: ${n}`)}}};function Uc(t,e){const n=_.bytes(t);if(n.length!==e)throw new Error(`Invalid input size: ${n.hex} !== ${e}`)}function Te(t,e){if(e)throw new Error(t);return!1}function ts(t,...e){const n=_.str(t).digest.raw,r=e.map(s=>_.bytes(s));return _.join([n,n,_.join(r)]).digest}const Pc={OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_SUCCESS80:80,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_SUCCESS98:98,OP_IF:99,OP_NOTIF:100,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_SUCCESS126:126,OP_SUCCESS127:127,OP_SUCCESS128:128,OP_SUCCESS129:129,OP_SIZE:130,OP_SUCCESS131:131,OP_SUCCESS132:132,OP_SUCCESS133:133,OP_SUCCESS134:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_SUCCESS137:137,OP_SUCCESS138:138,OP_1ADD:139,OP_1SUB:140,OP_SUCCESS141:141,OP_SUCCESS142:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_SUCCESS149:149,OP_SUCCESS150:150,OP_SUCCESS151:151,OP_SUCCESS152:152,OP_SUCCESS153:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_SUCCESS187:187,OP_SUCCESS188:188,OP_SUCCESS189:189,OP_SUCCESS190:190,OP_SUCCESS191:191,OP_SUCCESS192:192,OP_SUCCESS193:193,OP_SUCCESS194:194,OP_SUCCESS195:195,OP_SUCCESS196:196,OP_SUCCESS197:197,OP_SUCCESS198:198,OP_SUCCESS199:199,OP_SUCCESS200:200,OP_SUCCESS201:201,OP_SUCCESS202:202,OP_SUCCESS203:203,OP_SUCCESS204:204,OP_SUCCESS205:205,OP_SUCCESS206:206,OP_SUCCESS207:207,OP_SUCCESS208:208,OP_SUCCESS209:209,OP_SUCCESS210:210,OP_SUCCESS211:211,OP_SUCCESS212:212,OP_SUCCESS213:213,OP_SUCCESS214:214,OP_SUCCESS215:215,OP_SUCCESS216:216,OP_SUCCESS217:217,OP_SUCCESS218:218,OP_SUCCESS219:219,OP_SUCCESS220:220,OP_SUCCESS221:221,OP_SUCCESS222:222,OP_SUCCESS223:223,OP_SUCCESS224:224,OP_SUCCESS225:225,OP_SUCCESS226:226,OP_SUCCESS227:227,OP_SUCCESS228:228,OP_SUCCESS229:229,OP_SUCCESS230:230,OP_SUCCESS231:231,OP_SUCCESS232:232,OP_SUCCESS233:233,OP_SUCCESS234:234,OP_SUCCESS235:235,OP_SUCCESS236:236,OP_SUCCESS237:237,OP_SUCCESS238:238,OP_SUCCESS239:239,OP_SUCCESS240:240,OP_SUCCESS241:241,OP_SUCCESS242:242,OP_SUCCESS243:243,OP_SUCCESS244:244,OP_SUCCESS245:245,OP_SUCCESS246:246,OP_SUCCESS247:247,OP_SUCCESS248:248,OP_SUCCESS249:249,OP_SUCCESS250:250,OP_SUCCESS251:251,OP_SUCCESS252:252,OP_SUCCESS253:253,OP_SUCCESS254:254};function Vd(t){if(t>186&&t<255)return"OP_SUCCESS"+String(t);for(const[e,n]of Object.entries(Pc))if(n===t)return e;throw new Error("OPCODE not found:"+String(t))}function Md(t){for(const[e,n]of Object.entries(Pc))if(e===t)return Number(n);throw new Error("OPCODE not found:"+t)}function qd(t){switch(!0){case t===0:return"opcode";case(t>=1&&t<=75):return"varint";case t===76:return"pushdata1";case t===77:return"pushdata2";case t===78:return"pushdata4";case t<=254:return"opcode";default:throw new Error(`Invalid word range: ${t}`)}}function zd(t){const r=[];switch(!0){case typeof t!="number":return!1;case t===0:return!0;case r.includes(t):return!1;case(750?_.join(e):new Uint8Array}function Fd(t){let e=new Uint8Array;if(typeof t=="string"){if(t.startsWith("OP_"))return _.num(Md(t),1);St(t)?e=_.hex(t):e=_.str(t)}else e=_.bytes(t);if(e.length===1)return e[0]!==0&&e[0]<=16?(e[0]+=80,e):(e[0]>128&&e[0]<=255&&(e=new Uint8Array([e[0],0])),_.join([fa(e.length),e]));if(e.length>cs){const n=Gd(e);return Lc(n)}else return _.join([fa(e.length),e])}function fa(t){const e=_.num(76,1),n=_.num(77,1);switch(!0){case t<=75:return _.num(t);case(t>75&&t<256):return _.join([e,_.num(t,1,"le")]);case(t>=256&&t<=cs):return _.join([n,_.num(t,2,"le")]);default:throw new Error("Invalid word size:"+t.toString())}}function Gd(t){const e=[],n=new Yn(t);for(;n.size>cs;)e.push(n.read(cs));return e.push(n.read(n.size)),e}function di(t,e=!1){let n=_.bytes(t);if(e){const s=n.stream.readSize("le");if(n=n.slice(1),n.length!==s)throw new Error(`Varint does not match stream size: ${s} !== ${n.length}`)}return Yd(n)}function Yd(t){const e=new Yn(t),n=[],r=e.size;let s,o,i,a=0;for(;a0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function th(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Lo(t.outputLen),Lo(t.blockLen)}function nh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function rh(t,e){Rc(t);const n=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),nt=(t,e)=>t<<32-e|t>>>e,oh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!oh)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ih(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function hi(t){if(typeof t=="string"&&(t=ih(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}function ah(...t){if(!t.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(t.length===1)return t[0];const e=t.reduce((r,s)=>r+s.length,0),n=new Uint8Array(e);for(let r=0,s=0;rt().update(hi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ch(t=32){if(io&&typeof io.getRandomValues=="function")return io.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function uh(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,a,r)}let fh=class extends Hc{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ao(this.buffer)}update(e){tn.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=hi(e);const o=e.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;ft&e^~t&n,dh=(t,e,n)=>t&e^t&n^e&n,hh=new Uint32Array([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]),At=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Bt=new Uint32Array(64);let Dc=class extends fh{constructor(){super(64,32,8,!1),this.A=At[0]|0,this.B=At[1]|0,this.C=At[2]|0,this.D=At[3]|0,this.E=At[4]|0,this.F=At[5]|0,this.G=At[6]|0,this.H=At[7]|0}get(){const{A:e,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[e,n,r,s,o,i,a,c]}set(e,n,r,s,o,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)Bt[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const d=Bt[f-15],h=Bt[f-2],m=nt(d,7)^nt(d,18)^d>>>3,y=nt(h,17)^nt(h,19)^h>>>10;Bt[f]=y+Bt[f-7]+m+Bt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=nt(a,6)^nt(a,11)^nt(a,25),h=l+d+lh(a,c,u)+hh[f]+Bt[f]|0,y=(nt(r,2)^nt(r,13)^nt(r,22))+dh(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Bt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},ph=class extends Dc{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const Zc=jc(()=>new Dc);jc(()=>new ph);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gh=BigInt(0),pi=BigInt(1),mh=BigInt(2),Zs=t=>t instanceof Uint8Array,yh=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ln(t){if(!Zs(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nRn(t.toString(16).padStart(e*2,"0")),Vc=(t,e)=>Tn(t,e).reverse(),bh=t=>Rn(Kc(t));function qe(t,e,n){let r;if(typeof e=="string")try{r=Rn(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Zs(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${t} expected ${n} bytes, got ${s}`);return r}function ze(...t){const e=new Uint8Array(t.reduce((r,s)=>r+s.length,0));let n=0;return t.forEach(r=>{if(!Zs(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function wh(t,e){if(t.length!==e.length)return!1;for(let n=0;n0n;t>>=pi,e+=1);return e}const vh=(t,e)=>t>>BigInt(e)&1n,Eh=(t,e,n)=>t|(n?pi:gh)<(mh<new Uint8Array(t),la=t=>Uint8Array.from(t);function Mc(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=co(t),s=co(t),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},a=(...f)=>n(s,r,...f),c=(f=co())=>{s=a(la([0]),f),r=a(),f.length!==0&&(s=a(la([1]),f),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f{i(),c(f);let h;for(;!(h=d(u()));)c();return i(),h}}const Sh={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Wn(t,e,n={}){const r=(s,o,i)=>{const a=Sh[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const c=t[s];if(!(i&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(const[s,o]of Object.entries(e))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return t}var _h=Object.freeze({__proto__:null,bitGet:vh,bitLen:xh,bitMask:yi,bitSet:Eh,bytesToHex:Ln,bytesToNumberBE:Kt,bytesToNumberLE:mi,concatBytes:ze,createHmacDrbg:Mc,ensureBytes:qe,equalBytes:wh,hexToBytes:Rn,hexToNumber:gi,numberToBytesBE:Tn,numberToBytesLE:Vc,numberToHexUnpadded:Kc,numberToVarBytesBE:bh,utf8ToBytes:Ks,validateObject:Wn});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ae=BigInt(0),ve=BigInt(1),Jt=BigInt(2),kh=BigInt(3),Ro=BigInt(4),da=BigInt(5),ha=BigInt(8);BigInt(9);BigInt(16);function Ce(t,e){const n=t%e;return n>=Ae?n:e+n}function Ah(t,e,n){if(n<=Ae||e 0");if(n===ve)return Ae;let r=ve;for(;e>Ae;)e&ve&&(r=r*t%n),t=t*t%n,e>>=ve;return r}function Ve(t,e,n){let r=t;for(;e-- >Ae;)r*=r,r%=n;return r}function Ho(t,e){if(t===Ae||e<=Ae)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=Ce(t,e),r=e,s=Ae,o=ve;for(;n!==Ae;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==ve)throw new Error("invert: does not exist");return Ce(s,e)}function Bh(t){const e=(t-ve)/Jt;let n,r,s;for(n=t-ve,r=0;n%Jt===Ae;n/=Jt,r++);for(s=Jt;s(r[s]="function",r),e);return Wn(t,n)}function Th(t,e,n){if(n 0");if(n===Ae)return t.ONE;if(n===ve)return e;let r=t.ONE,s=e;for(;n>Ae;)n&ve&&(r=t.mul(r,s)),s=t.sqr(s),n>>=ve;return r}function Ch(t,e){const n=new Array(e.length),r=e.reduce((o,i,a)=>t.is0(i)?o:(n[a]=o,t.mul(o,i)),t.ONE),s=t.inv(r);return e.reduceRight((o,i,a)=>t.is0(i)?o:(n[a]=t.mul(o,n[a]),t.mul(o,i)),s),n}function bi(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function zc(t,e,n=!1,r={}){if(t<=Ae)throw new Error(`Expected Fp ORDER > 0, got ${t}`);const{nBitLength:s,nByteLength:o}=bi(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=$h(t),a=Object.freeze({ORDER:t,BITS:s,BYTES:o,MASK:yi(s),ZERO:Ae,ONE:ve,create:c=>Ce(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ae<=c&&cc===Ae,isOdd:c=>(c&ve)===ve,neg:c=>Ce(-c,t),eql:(c,u)=>c===u,sqr:c=>Ce(c*c,t),add:(c,u)=>Ce(c+u,t),sub:(c,u)=>Ce(c-u,t),mul:(c,u)=>Ce(c*u,t),pow:(c,u)=>Th(a,c,u),div:(c,u)=>Ce(c*Ho(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Ho(c,t),sqrt:r.sqrt||(c=>i(a,c)),invertBatch:c=>Ch(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>n?Vc(c,o):Tn(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?mi(c):Kt(c)}});return Object.freeze(a)}function Ih(t,e,n=!1){t=qe("privateHash",t);const r=t.length,s=bi(e).nByteLength+8;if(s<24||r1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const o=n?mi(t):Kt(t);return Ce(o,e-ve)+ve}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Uh=BigInt(0),uo=BigInt(1);function Ph(t,e){const n=(s,o)=>{const i=o.negate();return s?i:o},r=s=>{const o=Math.ceil(e/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:n,unsafeLadder(s,o){let i=t.ZERO,a=s;for(;o>Uh;)o&uo&&(i=i.add(a)),a=a.double(),o>>=uo;return i},precomputeWindow(s,o){const{windows:i,windowSize:a}=r(o),c=[];let u=s,l=u;for(let f=0;f>=h,p>c&&(p-=d,i+=uo);const g=y,x=y+Math.abs(p)-1,w=m%2!==0,$=p<0;p===0?l=l.add(n(w,o[g])):u=u.add(n($,o[x]))}return{p:u,f:l}},wNAFCached(s,o,i,a){const c=s._WINDOW_SIZE||1;let u=o.get(s);return u||(u=this.precomputeWindow(s,c),c!==1&&o.set(s,a(u))),this.wNAF(c,u,i)}}}function Fc(t){return qc(t.Fp),Wn(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...bi(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Nh(t){const e=Fc(t);Wn(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Lh,hexToBytes:Rh}=_h,nn={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=nn;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new e("Invalid signature integer: trailing length");return{d:Lh(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=nn,n=typeof t=="string"?Rh(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:o}=nn._parseInt(n.subarray(2)),{d:i,l:a}=nn._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(t){const e=u=>Number.parseInt(u[0],16)>=8?"00"+u:u,n=u=>{const l=u.toString(16);return l.length&1?`0${l}`:l},r=e(n(t.s)),s=e(n(t.r)),o=r.length/2,i=s.length/2,a=n(o),c=n(i);return`30${n(i+o+4)}02${c}${s}02${a}${r}`}},Fe=BigInt(0),Ee=BigInt(1),ht=BigInt(2),us=BigInt(3),pa=BigInt(4);function Hh(t){const e=Nh(t),{Fp:n}=e,r=e.toBytes||((m,y,p)=>{const g=y.toAffine();return ze(Uint8Array.from([4]),n.toBytes(g.x),n.toBytes(g.y))}),s=e.fromBytes||(m=>{const y=m.subarray(1),p=n.fromBytes(y.subarray(0,n.BYTES)),g=n.fromBytes(y.subarray(n.BYTES,2*n.BYTES));return{x:p,y:g}});function o(m){const{a:y,b:p}=e,g=n.sqr(m),x=n.mul(g,m);return n.add(n.add(x,n.mul(m,y)),p)}function i(m){return typeof m=="bigint"&&Fen.eql(w,n.ZERO);return x(p)&&x(g)?f.ZERO:new f(p,g,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){const p=n.invertBatch(y.map(g=>g.pz));return y.map((g,x)=>g.toAffine(p[x])).map(f.fromAffine)}static fromHex(y){const p=f.fromAffine(s(qe("pointHex",y)));return p.assertValidity(),p}static fromPrivateKey(y){return f.BASE.multiply(c(y))}_setWindowSize(y){this._WINDOW_SIZE=y,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:y,y:p}=this.toAffine();if(!n.isValid(y)||!n.isValid(p))throw new Error("bad point: x or y not FE");const g=n.sqr(p),x=o(y);if(!n.eql(g,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y}=this.toAffine();if(n.isOdd)return!n.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){l(y);const{px:p,py:g,pz:x}=this,{px:w,py:$,pz:A}=y,O=n.eql(n.mul(p,A),n.mul(w,x)),P=n.eql(n.mul(g,A),n.mul($,x));return O&&P}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:y,b:p}=e,g=n.mul(p,us),{px:x,py:w,pz:$}=this;let A=n.ZERO,O=n.ZERO,P=n.ZERO,I=n.mul(x,x),k=n.mul(w,w),U=n.mul($,$),R=n.mul(x,w);return R=n.add(R,R),P=n.mul(x,$),P=n.add(P,P),A=n.mul(y,P),O=n.mul(g,U),O=n.add(A,O),A=n.sub(k,O),O=n.add(k,O),O=n.mul(A,O),A=n.mul(R,A),P=n.mul(g,P),U=n.mul(y,U),R=n.sub(I,U),R=n.mul(y,R),R=n.add(R,P),P=n.add(I,I),I=n.add(P,I),I=n.add(I,U),I=n.mul(I,R),O=n.add(O,I),U=n.mul(w,$),U=n.add(U,U),I=n.mul(U,R),A=n.sub(A,I),P=n.mul(U,k),P=n.add(P,P),P=n.add(P,P),new f(A,O,P)}add(y){l(y);const{px:p,py:g,pz:x}=this,{px:w,py:$,pz:A}=y;let O=n.ZERO,P=n.ZERO,I=n.ZERO;const k=e.a,U=n.mul(e.b,us);let R=n.mul(p,w),D=n.mul(g,$),v=n.mul(x,A),E=n.add(p,g),b=n.add(w,$);E=n.mul(E,b),b=n.add(R,D),E=n.sub(E,b),b=n.add(p,x);let S=n.add(w,A);return b=n.mul(b,S),S=n.add(R,v),b=n.sub(b,S),S=n.add(g,x),O=n.add($,A),S=n.mul(S,O),O=n.add(D,v),S=n.sub(S,O),I=n.mul(k,b),O=n.mul(U,v),I=n.add(O,I),O=n.sub(D,I),I=n.add(D,I),P=n.mul(O,I),D=n.add(R,R),D=n.add(D,R),v=n.mul(k,v),b=n.mul(U,b),D=n.add(D,v),v=n.sub(R,v),v=n.mul(k,v),b=n.add(b,v),R=n.mul(D,b),P=n.add(P,R),R=n.mul(S,b),O=n.mul(E,O),O=n.sub(O,R),R=n.mul(E,D),I=n.mul(S,I),I=n.add(I,R),new f(O,P,I)}subtract(y){return this.add(y.negate())}is0(){return this.equals(f.ZERO)}wNAF(y){return h.wNAFCached(this,u,y,p=>{const g=n.invertBatch(p.map(x=>x.pz));return p.map((x,w)=>x.toAffine(g[w])).map(f.fromAffine)})}multiplyUnsafe(y){const p=f.ZERO;if(y===Fe)return p;if(a(y),y===Ee)return this;const{endo:g}=e;if(!g)return h.unsafeLadder(this,y);let{k1neg:x,k1:w,k2neg:$,k2:A}=g.splitScalar(y),O=p,P=p,I=this;for(;w>Fe||A>Fe;)w&Ee&&(O=O.add(I)),A&Ee&&(P=P.add(I)),I=I.double(),w>>=Ee,A>>=Ee;return x&&(O=O.negate()),$&&(P=P.negate()),P=new f(n.mul(P.px,g.beta),P.py,P.pz),O.add(P)}multiply(y){a(y);let p=y,g,x;const{endo:w}=e;if(w){const{k1neg:$,k1:A,k2neg:O,k2:P}=w.splitScalar(p);let{p:I,f:k}=this.wNAF(A),{p:U,f:R}=this.wNAF(P);I=h.constTimeNegate($,I),U=h.constTimeNegate(O,U),U=new f(n.mul(U.px,w.beta),U.py,U.pz),g=I.add(U),x=k.add(R)}else{const{p:$,f:A}=this.wNAF(p);g=$,x=A}return f.normalizeZ([g,x])[0]}multiplyAndAddUnsafe(y,p,g){const x=f.BASE,w=(A,O)=>O===Fe||O===Ee||!A.equals(x)?A.multiplyUnsafe(O):A.multiply(O),$=w(this,p).add(w(y,g));return $.is0()?void 0:$}toAffine(y){const{px:p,py:g,pz:x}=this,w=this.is0();y==null&&(y=w?n.ONE:n.inv(x));const $=n.mul(p,y),A=n.mul(g,y),O=n.mul(x,y);if(w)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:$,y:A}}isTorsionFree(){const{h:y,isTorsionFree:p}=e;if(y===Ee)return!0;if(p)return p(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:y,clearCofactor:p}=e;return y===Ee?this:p?p(f,this):this.multiplyUnsafe(e.h)}toRawBytes(y=!0){return this.assertValidity(),r(f,this,y)}toHex(y=!0){return Ln(this.toRawBytes(y))}}f.BASE=new f(e.Gx,e.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,h=Ph(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function jh(t){const e=Fc(t);return Wn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Dh(t){const e=jh(t),{Fp:n,n:r}=e,s=n.BYTES+1,o=2*n.BYTES+1;function i(b){return FeLn(Tn(b,e.nByteLength));function m(b){const S=r>>Ee;return b>S}function y(b){return m(b)?a(-b):b}const p=(b,S,B)=>Kt(b.slice(S,B));class g{constructor(S,B,N){this.r=S,this.s=B,this.recovery=N,this.assertValidity()}static fromCompact(S){const B=e.nByteLength;return S=qe("compactSignature",S,B*2),new g(p(S,0,B),p(S,B,2*B))}static fromDER(S){const{r:B,s:N}=nn.toSig(qe("DER",S));return new g(B,N)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(S){return new g(this.r,this.s,S)}recoverPublicKey(S){const{r:B,s:N,recovery:T}=this,H=P(qe("msgHash",S));if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");const Z=T===2||T===3?B+e.n:B;if(Z>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const M=(T&1)===0?"02":"03",re=u.fromHex(M+h(Z)),ne=c(Z),W=a(-H*ne),oe=a(N*ne),ie=u.BASE.multiplyAndAddUnsafe(re,W,oe);if(!ie)throw new Error("point at infinify");return ie.assertValidity(),ie}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rn(this.toDERHex())}toDERHex(){return nn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rn(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(b){try{return l(b),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const b=e.randomBytes(n.BYTES+8),S=Ih(b,r);return Tn(S,e.nByteLength)},precompute(b=8,S=u.BASE){return S._setWindowSize(b),S.multiply(BigInt(3)),S}};function w(b,S=!0){return u.fromPrivateKey(b).toRawBytes(S)}function $(b){const S=b instanceof Uint8Array,B=typeof b=="string",N=(S||B)&&b.length;return S?N===s||N===o:B?N===2*s||N===2*o:b instanceof u}function A(b,S,B=!0){if($(b))throw new Error("first arg must be private key");if(!$(S))throw new Error("second arg must be public key");return u.fromHex(S).multiply(l(b)).toRawBytes(B)}const O=e.bits2int||function(b){const S=Kt(b),B=b.length*8-e.nBitLength;return B>0?S>>BigInt(B):S},P=e.bits2int_modN||function(b){return a(O(b))},I=yi(e.nBitLength);function k(b){if(typeof b!="bigint")throw new Error("bigint expected");if(!(Fe<=b&&bse in B))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:T}=e;let{lowS:H,prehash:Z,extraEntropy:M}=B;H==null&&(H=!0),b=qe("msgHash",b),Z&&(b=qe("prehashed msgHash",N(b)));const re=P(b),ne=l(S),W=[k(ne),k(re)];if(M!=null){const se=M===!0?T(n.BYTES):M;W.push(qe("extraEntropy",se,n.BYTES))}const oe=ze(...W),ie=re;function xe(se){const he=O(se);if(!d(he))return;const lt=c(he),Ke=u.BASE.multiply(he).toAffine(),Be=a(Ke.x);if(Be===Fe)return;const dt=a(lt*a(ie+Be*ne));if(dt===Fe)return;let nr=(Ke.x===Be?0:2)|Number(Ke.y&Ee),aa=dt;return H&&m(dt)&&(aa=y(dt),nr^=1),new g(Be,aa,nr)}return{seed:oe,k2sig:xe}}const R={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function v(b,S,B=R){const{seed:N,k2sig:T}=U(b,S,B);return Mc(e.hash.outputLen,e.nByteLength,e.hmac)(N,T)}u.BASE._setWindowSize(8);function E(b,S,B,N=D){var Ke;const T=b;if(S=qe("msgHash",S),B=qe("publicKey",B),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:H,prehash:Z}=N;let M,re;try{if(typeof T=="string"||T instanceof Uint8Array)try{M=g.fromDER(T)}catch(Be){if(!(Be instanceof nn.Err))throw Be;M=g.fromCompact(T)}else if(typeof T=="object"&&typeof T.r=="bigint"&&typeof T.s=="bigint"){const{r:Be,s:dt}=T;M=new g(Be,dt)}else throw new Error("PARSE");re=u.fromHex(B)}catch(Be){if(Be.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(H&&M.hasHighS())return!1;Z&&(S=e.hash(S));const{r:ne,s:W}=M,oe=P(S),ie=c(W),xe=a(oe*ie),se=a(ne*ie),he=(Ke=u.BASE.multiplyAndAddUnsafe(re,xe,se))==null?void 0:Ke.toAffine();return he?a(he.x)===ne:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:A,sign:v,verify:E,ProjectivePoint:u,Signature:g,utils:x}}function Zh(t,e){const n=t.ORDER;let r=Fe;for(let d=n-Ee;d%ht===Fe;d/=ht)r+=Ee;const s=r,o=(n-Ee)/ht**s,i=(o-Ee)/ht,a=ht**s-Ee,c=ht**(s-Ee),u=t.pow(e,o),l=t.pow(e,(o+Ee)/ht);let f=(d,h)=>{let m=u,y=t.pow(h,a),p=t.sqr(y);p=t.mul(p,h);let g=t.mul(d,p);g=t.pow(g,i),g=t.mul(g,y),y=t.mul(g,h),p=t.mul(g,d);let x=t.mul(p,y);g=t.pow(x,c);let w=t.eql(g,t.ONE);y=t.mul(p,l),g=t.mul(x,m),p=t.cmov(y,p,w),x=t.cmov(g,x,w);for(let $=s;$>1;$--){let A=ht**($-ht),O=t.pow(x,A);const P=t.eql(O,t.ONE);y=t.mul(p,m),m=t.mul(m,m),O=t.mul(x,m),p=t.cmov(y,p,P),x=t.cmov(O,x,P)}return{isValid:w,value:p}};if(t.ORDER%pa===us){const d=(t.ORDER-us)/pa,h=t.sqrt(t.neg(e));f=(m,y)=>{let p=t.sqr(y);const g=t.mul(m,y);p=t.mul(p,g);let x=t.pow(p,d);x=t.mul(x,g);const w=t.mul(x,h),$=t.mul(t.sqr(x),y),A=t.eql($,m);let O=t.cmov(w,x,A);return{isValid:A,value:O}}}return f}function Kh(t,e){if(qc(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=Zh(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,o,i,a,c,u,l,f;s=t.sqr(r),s=t.mul(s,e.Z),o=t.sqr(s),o=t.add(o,s),i=t.add(o,t.ONE),i=t.mul(i,e.B),a=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),a=t.mul(a,e.A),o=t.sqr(i),u=t.sqr(a),c=t.mul(u,e.A),o=t.add(o,c),o=t.mul(o,i),u=t.mul(u,a),c=t.mul(u,e.B),o=t.add(o,c),l=t.mul(s,i);const{isValid:d,value:h}=n(o,u);f=t.mul(s,r),f=t.mul(f,h),l=t.cmov(l,i,d),f=t.cmov(f,h,d);const m=t.isOdd(r)===t.isOdd(f);return f=t.cmov(t.neg(f),f,m),l=t.div(l,a),{x:l,y:f}}}function Vh(t){if(t instanceof Uint8Array)return t;if(typeof t=="string")return Ks(t);throw new Error("DST must be Uint8Array or string")}const Mh=Kt;function jt(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const n=Array.from({length:e}).fill(0);for(let r=e-1;r>=0;r--)n[r]=t&255,t>>>=8;return new Uint8Array(n)}function qh(t,e){const n=new Uint8Array(t.length);for(let r=0;r255&&(e=r(ze(Ks("H2C-OVERSIZE-DST-"),e)));const{outputLen:s,blockLen:o}=r,i=Math.ceil(n/s);if(i>255)throw new Error("Invalid xmd length");const a=ze(e,jt(e.length,1)),c=jt(0,o),u=jt(n,2),l=new Array(i),f=r(ze(c,t,u,jt(0,1),a));l[0]=r(ze(f,jt(1,1),a));for(let h=1;h<=i;h++){const m=[qh(f,l[h-1]),jt(h+1,1),a];l[h]=r(ze(...m))}return ze(...l).slice(0,n)}function Fh(t,e,n,r,s){if(fr(t),fr(e),wi(n),e.length>255){const o=Math.ceil(2*r/8);e=s.create({dkLen:o}).update(Ks("H2C-OVERSIZE-DST-")).update(e).digest()}if(n>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(t).update(jt(n,2)).update(e).update(jt(e.length,1)).digest()}function ga(t,e,n){Wn(n,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:o,hash:i,expand:a,DST:c}=n;fr(t),wi(e);const u=Vh(c),l=r.toString(2).length,f=Math.ceil((l+s)/8),d=e*o*f;let h;if(a==="xmd")h=zh(t,u,d,i);else if(a==="xof")h=Fh(t,u,d,s,i);else if(a===void 0)h=t;else throw new Error('expand must be "xmd", "xof" or undefined');const m=new Array(e);for(let y=0;yArray.from(r).reverse());return(r,s)=>{const[o,i,a,c]=n.map(u=>u.reduce((l,f)=>t.add(t.mul(l,r),f)));return r=t.div(o,i),s=t.mul(s,t.div(a,c)),{x:r,y:s}}}function Yh(t,e,n){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,s){const o=ga(r,2,{...n,DST:n.DST,...s}),i=t.fromAffine(e(o[0])),a=t.fromAffine(e(o[1])),c=i.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,s){const o=ga(r,1,{...n,DST:n.encodeDST,...s}),i=t.fromAffine(e(o[0])).clearCofactor();return i.assertValidity(),i}}}let Gc=class extends Hc{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,tn.hash(e);const r=hi(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?e.create().update(r).digest():r);for(let i=0;inew Gc(t,e).update(n).digest();Yc.create=(t,e)=>new Gc(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Wh(t){return{hash:t,hmac:(e,...n)=>Yc(t,e,ah(...n)),randomBytes:ch}}function Xh(t,e){const n=r=>Dh({...t,...Wh(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ma=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Jh=BigInt(1),jo=BigInt(2),ya=(t,e)=>(t+e/jo)/e;function Qh(t){const e=Wc,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,l=u*u*t%e,f=Ve(l,n,e)*l%e,d=Ve(f,n,e)*l%e,h=Ve(d,jo,e)*u%e,m=Ve(h,s,e)*h%e,y=Ve(m,o,e)*m%e,p=Ve(y,a,e)*y%e,g=Ve(p,c,e)*p%e,x=Ve(g,a,e)*y%e,w=Ve(x,n,e)*l%e,$=Ve(w,i,e)*m%e,A=Ve($,r,e)*u%e,O=Ve(A,jo,e);if(!Mt.eql(Mt.sqr(O),t))throw new Error("Cannot find square root");return O}const Mt=zc(Wc,void 0,void 0,{sqrt:Qh}),xt=Xh({a:BigInt(0),b:BigInt(7),Fp:Mt,n:ma,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ma,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Jh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,i=BigInt("0x100000000000000000000000000000000"),a=ya(o*t,e),c=ya(-r*t,e);let u=Ce(t-a*n-c*s,e),l=Ce(-a*r-c*o,e);const f=u>i,d=l>i;if(f&&(u=e-u),d&&(l=e-l),u>i||l>i)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:u,k2neg:d,k2:l}}}},Zc);BigInt(0);xt.ProjectivePoint;xt.utils.randomPrivateKey;const e0=Gh(Mt,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),t0=Kh(Mt,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Mt.create(BigInt("-11"))});Yh(xt.ProjectivePoint,t=>{const{x:e,y:n}=t0(Mt.create(t[0]));return e0(e,n)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Mt.ORDER,m:1,k:128,expand:"xmd",hash:Zc});function Do(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n0(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Xc(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function r0(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Do(t.outputLen),Do(t.blockLen)}function s0(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function o0(t,e){Xc(t);const n=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),rt=(t,e)=>t<<32-e|t>>>e,a0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!a0)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function c0(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function Jc(t){if(typeof t=="string"&&(t=c0(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}let u0=class{clone(){return this._cloneInto()}};function Qc(t){const e=r=>t().update(Jc(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function f0(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,a,r)}let l0=class extends u0{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=lo(this.buffer)}update(e){fo.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=Jc(e);const o=e.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;ft&e^~t&n,h0=(t,e,n)=>t&e^t&n^e&n,p0=new Uint32Array([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]),$t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ot=new Uint32Array(64);let eu=class extends l0{constructor(){super(64,32,8,!1),this.A=$t[0]|0,this.B=$t[1]|0,this.C=$t[2]|0,this.D=$t[3]|0,this.E=$t[4]|0,this.F=$t[5]|0,this.G=$t[6]|0,this.H=$t[7]|0}get(){const{A:e,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[e,n,r,s,o,i,a,c]}set(e,n,r,s,o,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)Ot[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const d=Ot[f-15],h=Ot[f-2],m=rt(d,7)^rt(d,18)^d>>>3,y=rt(h,17)^rt(h,19)^h>>>10;Ot[f]=y+Ot[f-7]+m+Ot[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=rt(a,6)^rt(a,11)^rt(a,25),h=l+d+d0(a,c,u)+p0[f]+Ot[f]|0,y=(rt(r,2)^rt(r,13)^rt(r,22))+h0(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Ot.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},g0=class extends eu{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const Zo=Qc(()=>new eu);Qc(()=>new g0);function m0(t,e){if(t.length>e)throw new TypeError(`Data is larger than array size: ${t.length} > ${e}`)}function y0(t){if(t.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+t);if(t.length%2!==0)throw new Error(`Length of hex string is invalid: ${t.length}`)}function b0(t){if(t>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:w0}=crypto??globalThis.crypto??window.crypto;function x0(t=32){if(typeof w0=="function")return crypto.getRandomValues(new Uint8Array(t));throw new Error("Crypto module missing getRandomValues!")}function v0(t,e,n="be"){e===void 0&&(e=t.length),m0(t,e);const r=new Uint8Array(e).fill(0),s=n==="be"?0:e-t.length;return r.set(t,s),r}function tu(t){let e,n=0;const r=t.reduce((o,i)=>o+i.length,0),s=new Uint8Array(r);for(e=0;e0||(i.length^a)>0?"":"1";c in o||u>0;)l=o[c],l=l>0?l*256+u:u,u=l/s|0,o[c]=l%s,c++;for(;c-- >0;)i+=r[o[c]];return n&&i.length%4>0?i+"=".repeat(4-i.length%4):i}function k0(t,e){const n=nu(e),r=n.length,s=[],o=[];t=t.replace("=","");let i,a=0,c,u;for(i=0;i0||(o.length^i)>0||o.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)o.push(s[a]);return new Uint8Array(o)}function ru(t){return Zo(Zo(t))}function A0(t){const e=ru(t);return tu([t,e.slice(0,4)])}function B0(t){const e=t.slice(0,-4),n=t.slice(-4);if(ru(e).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return e}const ba={encode:_0,decode:k0},su={encode:t=>{const e=A0(t);return ba.encode(e,"base58")},decode:t=>{const e=ba.decode(t,"base58");return B0(e)}},ou="qpzry9x8gf2tvdw0s3jn54khce6mua7l",$0=[996825010,642813549,513874426,1027748829,705979059],fs=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function iu(t){let e=1;for(let n=0;n>25;e=(e&33554431)<<5^t[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(e^=$0[s])}return e}function au(t){const e=[];let n;for(n=0;n>5);for(e.push(0),n=0;n>5*(5-i)&31);return o}function cu(t,e,n,r=!0){const s=[];let o=0,i=0;const a=(1<>e>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(o=(o<=n;)i-=n,s.push(o>>i&a)}if(r)i>0&&s.push(o<=e||(o<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function C0(t,e,n){const r=e.concat(T0(t,e,n));let s=t+"1";for(let o=0;oo.version===e[0])??fs[0];if(!O0(r,e,s))throw new Error("Checksum verification failed!");return[r,e.slice(0,e.length-6)]}function I0(t){let e,n,r=!1,s=!1;for(e=0;e126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function U0(t){const e=t.lastIndexOf("1");return!(e<1||e+7>t.length||t.length>90)}function P0(t,e="bc",n=0){const r=[n,...cu([...t],8,5)],s=fs.find(i=>i.version===n)??fs[0],o=C0(e,r,s);return fu(o),o}function fu(t){t=t.toLowerCase();const e=t.split("1",1)[0],[n,r]=uu(t),s=cu(r.slice(1),5,8,!1),o=s.length;switch(!0){case e!==n:throw new Error("Returned hrp string is invalid.");case(s===null||o<2||o>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function N0(t){t=t.toLowerCase();const[e,n]=uu(t);return n[0]}const lu={encode:P0,decode:fu,version:N0},du="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",L0=new TextEncoder;function pu(t,e=!1,n=!0){typeof t=="string"&&(t=L0.encode(t));const r=e?hu:du;let s="",o=0,i=0;for(let a=0;a=6;)o-=6,s+=r[i>>o&63];if(o>0)for(i<<=6-o,s+=r[i&63];o<6;)s+=n?"=":"",o+=2;return s}function gu(t,e=!1){const n=e||t.includes("-")||t.includes("_")?hu.split(""):du.split("");t=t.replace(/=+$/,"");const r=t.split("");let s=0,o=0;const i=[];for(let a=0;a=8&&(s-=8,i.push(o>>>s&255))}return new Uint8Array(i)}const mu={encode:pu,decode:gu},yu={encode:t=>pu(t,!0,!1),decode:t=>gu(t,!0)},R0=BigInt(0),H0=BigInt(255),bu=BigInt(256);function j0(t){if(t<=0xffn)return 1;if(t<=0xffffn)return 2;if(t<=0xffffffffn)return 4;if(t<=0xffffffffffffffffn)return 8;if(t<=0xffffffffffffffffffffffffffffffffn)return 16;if(t<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function D0(t,e,n="be"){e===void 0&&(e=j0(t));const r=n==="le",s=new ArrayBuffer(e),o=new DataView(s);let i=r?0:e-1;for(;t>R0;){const a=t&H0,c=Number(a);r?o.setUint8(i++,c):o.setUint8(i--,c),t=(t-a)/bu}return new Uint8Array(s)}function Z0(t){let e=BigInt(0);for(let n=t.length-1;n>=0;n--)e=e*bu+BigInt(t[n]);return BigInt(e)}function K0(t){const e=t.split("").map(Number);if(e.length%8!==0)throw new Error(`Binary array is invalid length: ${t.length}`);const n=new Uint8Array(e.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)e[n]=r>>s&1}return e.join("")}function M0(t){if(t<=255)return 1;if(t<=65535)return 2;if(t<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function q0(t,e,n="be"){e===void 0&&(e=M0(t));const r=n==="le",s=new ArrayBuffer(e),o=new DataView(s);let i=r?0:e-1;for(;t>0;){const a=t&255;r?o.setUint8(i++,t):o.setUint8(i--,t),t=(t-a)/256}return new Uint8Array(s)}function z0(t){let e=0;for(let n=t.length-1;n>=0;n--)e=e*256+t[n],b0(e);return e}const F0=new TextEncoder,G0=new TextDecoder;function xi(t){return F0.encode(t)}function ho(t){return G0.decode(t)}function Y0(t,e){y0(t);const n=t.length/2;if(e===void 0&&(e=n),n>e)throw new TypeError(`Hex string is larger than array size: ${n} > ${e}`);return e}function W0(t,e,n="le"){e=Y0(t,e);const r=n==="le",s=new ArrayBuffer(e),o=new DataView(s);let i=r?0:e-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return xi(e)}function Q0(t,e,n){if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Uint8Array)return v0(t,e,n);if(typeof t=="string")return W0(t,e,n);if(typeof t=="bigint")return D0(t,e,n);if(typeof t=="number")return q0(t,e,n);if(typeof t=="boolean")return Uint8Array.of(t?1:0);throw TypeError("Unsupported format:"+typeof t)}const ee=class ee extends Uint8Array{static random(e=32){const n=x0(e);return new ee(n,e)}constructor(e,n,r){const s=Q0(e,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new dp(this)}toNum(e="be"){const n=e==="be"?this.reverse():this;return z0(n)}toBin(){return V0(this)}toBig(e="be"){const n=e==="be"?this.reverse():this;return Z0(n)}toHash(){const e=Zo(this);return new ee(e)}toJson(){const e=ho(this);return JSON.parse(e)}toBech32(e,n=0){return lu.encode(this,e,n)}toStr(){return ho(this)}toHex(){return X0(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return su.encode(this)}toBase64(){return mu.encode(this)}toB64url(){return yu.encode(this)}prepend(e){return ee.join([ee.bytes(e),this])}append(e){return ee.join([this,ee.bytes(e)])}slice(e,n){const r=new Uint8Array(this).slice(e,n);return new ee(r)}subarray(e,n){const r=new Uint8Array(this).subarray(e,n);return new ee(r)}reverse(){const e=new Uint8Array(this).reverse();return new ee(e)}write(e,n){const r=ee.bytes(e);this.set(r,n)}prefixSize(e){const n=ee.varInt(this.length,e);return ee.join([n,this])}static from(e){return new ee(Uint8Array.from(e))}static of(...e){return new ee(Uint8Array.of(...e))}static join(e){const n=e.map(s=>ee.bytes(s)),r=tu(n);return new ee(r)}static varInt(e,n){if(e<253)return ee.num(e,1);if(e<65536)return ee.of(253,...ee.num(e,2,n));if(e<4294967296)return ee.of(254,...ee.num(e,4,n));if(BigInt(e)<0x10000000000000000n)return ee.of(255,...ee.num(e,8,n));throw new Error(`Value is too large: ${e}`)}};ee.num=ep,ee.big=np,ee.bin=tp,ee.raw=rp,ee.str=sp,ee.hex=op,ee.bytes=ip,ee.json=ap,ee.base64=cp,ee.b64url=up,ee.bech32=fp,ee.b58chk=lp,ee.encode=xi,ee.decode=ho;let G=ee;function ep(t,e,n){return new G(t,e,n)}function tp(t,e,n){return new G(K0(t),e,n)}function np(t,e,n){return new G(t,e,n)}function rp(t,e,n){return new G(t,e,n)}function sp(t,e,n){return new G(xi(t),e,n)}function op(t,e,n){return new G(t,e,n)}function ip(t,e,n){return new G(t,e,n)}function ap(t){return new G(J0(t))}function cp(t){return new G(mu.decode(t))}function up(t){return new G(yu.decode(t))}function fp(t){return new G(lu.decode(t))}function lp(t){return new G(su.decode(t))}class dp{constructor(e){this.data=G.bytes(e),this.size=this.data.length}peek(e){if(e>this.size)throw new Error(`Size greater than stream: ${e} > ${this.size}`);return new G(this.data.slice(0,e))}read(e){e=e??this.readSize();const n=this.peek(e);return this.data=this.data.slice(e),this.size=this.data.length,n}readSize(e){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(e);case n===254:return this.read(4).toNum(e);case n===255:return this.read(8).toNum(e);default:throw new Error(`Varint is out of range: ${n}`)}}}const ls=xt.CURVE,vi=ls.n,hp=ls.p,pp={x:ls.Gx,y:ls.Gy},gp=BigInt(0);BigInt(1);BigInt(2);BigInt(3);BigInt(4);const Ko={N:vi,P:hp,G:pp,_0n:gp},rr=zc(vi,32,!0),wu=t=>Ce(t,vi);function Ei(t,e=!1){if(e)throw new Error(t);return!1}function xu(t){return G.random(t)}function mp(t){const e=G.bytes(t).big;return G.big(wu(e),32)}var yp=Object.freeze({__proto__:null,fail:Ei,mod_bytes:mp,random:xu});const{N:bp,_0n:wp}=Ko;function xp(t,e,n){const r=G.bytes(t);return r.length!==e?Ei(`Invalid byte size: ${r.hex} !== ${e}`,n):!0}function vp(t,e){return typeof t=="bigint"&&wpthis.big}lt(e){return new pe(e).big0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function kp(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Vo(t.outputLen),Vo(t.blockLen)}function Ap(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Bp(t,e){vu(t);const n=e.outputLen;if(t.lengtht instanceof Uint8Array,po=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),st=(t,e)=>t<<32-e|t>>>e,Tp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Tp)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Cp(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Si(t){if(typeof t=="string"&&(t=Cp(t)),!Op(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}let Eu=class{clone(){return this._cloneInto()}};function vn(t){const e=r=>t().update(Si(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ip(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,a,r)}class _i extends Eu{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=po(this.buffer)}update(e){rn.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=Si(e);const o=e.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;ft&e^~t&n,Pp=(t,e,n)=>t&e^t&n^e&n,Np=new Uint32Array([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]),Tt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ct=new Uint32Array(64);let Su=class extends _i{constructor(){super(64,32,8,!1),this.A=Tt[0]|0,this.B=Tt[1]|0,this.C=Tt[2]|0,this.D=Tt[3]|0,this.E=Tt[4]|0,this.F=Tt[5]|0,this.G=Tt[6]|0,this.H=Tt[7]|0}get(){const{A:e,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[e,n,r,s,o,i,a,c]}set(e,n,r,s,o,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)Ct[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const d=Ct[f-15],h=Ct[f-2],m=st(d,7)^st(d,18)^d>>>3,y=st(h,17)^st(h,19)^h>>>10;Ct[f]=y+Ct[f-7]+m+Ct[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=st(a,6)^st(a,11)^st(a,25),h=l+d+Up(a,c,u)+Np[f]+Ct[f]|0,y=(st(r,2)^st(r,13)^st(r,22))+Pp(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Ct.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class Lp extends Su{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const Mo=vn(()=>new Su);vn(()=>new Lp);const Rr=BigInt(2**32-1),qo=BigInt(32);function _u(t,e=!1){return e?{h:Number(t&Rr),l:Number(t>>qo&Rr)}:{h:Number(t>>qo&Rr)|0,l:Number(t&Rr)|0}}function Rp(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;sBigInt(t>>>0)<>>0),jp=(t,e,n)=>t>>>n,Dp=(t,e,n)=>t<<32-n|e>>>n,Zp=(t,e,n)=>t>>>n|e<<32-n,Kp=(t,e,n)=>t<<32-n|e>>>n,Vp=(t,e,n)=>t<<64-n|e>>>n-32,Mp=(t,e,n)=>t>>>n-32|e<<64-n,qp=(t,e)=>e,zp=(t,e)=>t,Fp=(t,e,n)=>t<>>32-n,Gp=(t,e,n)=>e<>>32-n,Yp=(t,e,n)=>e<>>64-n,Wp=(t,e,n)=>t<>>64-n;function Xp(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Jp=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Qp=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,eg=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),tg=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,ng=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),rg=(t,e,n,r,s,o)=>e+n+r+s+o+(t/2**32|0)|0,sg={fromBig:_u,split:Rp,toBig:Hp,shrSH:jp,shrSL:Dp,rotrSH:Zp,rotrSL:Kp,rotrBH:Vp,rotrBL:Mp,rotr32H:qp,rotr32L:zp,rotlSH:Fp,rotlSL:Gp,rotlBH:Yp,rotlBL:Wp,add:Xp,add3L:Jp,add3H:Qp,add4L:eg,add4H:tg,add5H:rg,add5L:ng};var Q=sg;const[og,ig]=Q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),It=new Uint32Array(80),Ut=new Uint32Array(80);let Vs=class extends _i{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:d,Gh:h,Gl:m,Hh:y,Hl:p}=this;return[e,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p]}set(e,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=p|0}process(e,n){for(let w=0;w<16;w++,n+=4)It[w]=e.getUint32(n),Ut[w]=e.getUint32(n+=4);for(let w=16;w<80;w++){const $=It[w-15]|0,A=Ut[w-15]|0,O=Q.rotrSH($,A,1)^Q.rotrSH($,A,8)^Q.shrSH($,A,7),P=Q.rotrSL($,A,1)^Q.rotrSL($,A,8)^Q.shrSL($,A,7),I=It[w-2]|0,k=Ut[w-2]|0,U=Q.rotrSH(I,k,19)^Q.rotrBH(I,k,61)^Q.shrSH(I,k,6),R=Q.rotrSL(I,k,19)^Q.rotrBL(I,k,61)^Q.shrSL(I,k,6),D=Q.add4L(P,R,Ut[w-7],Ut[w-16]),v=Q.add4H(D,O,U,It[w-7],It[w-16]);It[w]=v|0,Ut[w]=D|0}let{Ah:r,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:d,Fh:h,Fl:m,Gh:y,Gl:p,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){const $=Q.rotrSH(f,d,14)^Q.rotrSH(f,d,18)^Q.rotrBH(f,d,41),A=Q.rotrSL(f,d,14)^Q.rotrSL(f,d,18)^Q.rotrBL(f,d,41),O=f&h^~f&y,P=d&m^~d&p,I=Q.add5L(x,A,P,ig[w],Ut[w]),k=Q.add5H(I,g,$,O,og[w],It[w]),U=I|0,R=Q.rotrSH(r,s,28)^Q.rotrBH(r,s,34)^Q.rotrBH(r,s,39),D=Q.rotrSL(r,s,28)^Q.rotrBL(r,s,34)^Q.rotrBL(r,s,39),v=r&o^r&a^o&a,E=s&i^s&c^i&c;g=y|0,x=p|0,y=h|0,p=m|0,h=f|0,m=d|0,{h:f,l:d}=Q.add(u|0,l|0,k|0,U|0),u=a|0,l=c|0,a=o|0,c=i|0,o=r|0,i=s|0;const b=Q.add3L(U,D,E);r=Q.add3H(b,k,R,v),s=b|0}({h:r,l:s}=Q.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:o,l:i}=Q.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=Q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=Q.add(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:d}=Q.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:m}=Q.add(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:p}=Q.add(this.Gh|0,this.Gl|0,y|0,p|0),{h:g,l:x}=Q.add(this.Hh|0,this.Hl|0,g|0,x|0),this.set(r,s,o,i,a,c,u,l,f,d,h,m,y,p,g,x)}roundClean(){It.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class ag extends Vs{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class cg extends Vs{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class ug extends Vs{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const fg=vn(()=>new Vs);vn(()=>new ag);vn(()=>new cg);vn(()=>new ug);const lg=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),ku=Uint8Array.from({length:16},(t,e)=>e),dg=ku.map(t=>(9*t+5)%16);let ki=[ku],Ai=[dg];for(let t=0;t<4;t++)for(let e of[ki,Ai])e.push(e[t].map(n=>lg[n]));const Au=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),hg=ki.map((t,e)=>t.map(n=>Au[e][n])),pg=Ai.map((t,e)=>t.map(n=>Au[e][n])),gg=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),mg=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),Hr=(t,e)=>t<>>32-e;function xa(t,e,n,r){return t===0?e^n^r:t===1?e&n|~e&r:t===2?(e|~n)^r:t===3?e&r|n&~r:e^(n|~r)}const jr=new Uint32Array(16);let yg=class extends _i{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:r,h3:s,h4:o}=this;return[e,n,r,s,o]}set(e,n,r,s,o){this.h0=e|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=o|0}process(e,n){for(let h=0;h<16;h++,n+=4)jr[h]=e.getUint32(n,!0);let r=this.h0|0,s=r,o=this.h1|0,i=o,a=this.h2|0,c=a,u=this.h3|0,l=u,f=this.h4|0,d=f;for(let h=0;h<5;h++){const m=4-h,y=gg[h],p=mg[h],g=ki[h],x=Ai[h],w=hg[h],$=pg[h];for(let A=0;A<16;A++){const O=Hr(r+xa(h,o,a,u)+jr[g[A]]+y,w[A])+f|0;r=f,f=u,u=Hr(a,10)|0,a=o,o=O}for(let A=0;A<16;A++){const O=Hr(s+xa(m,i,c,l)+jr[x[A]]+p,$[A])+d|0;s=d,d=l,l=Hr(c,10)|0,c=i,i=O}}this.set(this.h1+a+l|0,this.h2+u+d|0,this.h3+f+s|0,this.h4+r+i|0,this.h0+o+c|0)}roundClean(){jr.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const bg=vn(()=>new yg);let Bu=class extends Eu{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,rn.hash(e);const r=Si(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?e.create().update(r).digest():r);for(let i=0;inew Bu(t,e).update(n).digest();$u.create=(t,e)=>new Bu(t,e);function Hn(t){const e=G.bytes(t);return G.raw(Mo(Mo(e)))}function wg(t){const e=G.bytes(t);return G.raw(bg(Mo(e)))}function xg(t,e){const n=G.bytes(t),r=G.bytes(e);return G.raw($u(fg,n,r))}function vg(t){const e=G.str(t).digest;return G.join([e,e])}function Eg(t=32){return Bi(xu(t))}function Bi(t){return Ne.mod(t).buff}function Ou(t,e=!1){const n=Ne.mod(t).point;return e?n.x:n.buff}function Tu(t,e){const n=xn.from_x(e),r=Ne.mod(t);return n.mul(r).buff}function Sg(t,e,n="ecdh/code"){const r=vg(n),s=Bi(t),o=Ou(s),i=G.bytes(e),a=Tu(s,i),c=[o.hex,i.hex];return c.sort(),xg(a,G.join([r,...c]))}function _g(t){const e=G.bytes(t);switch(!0){case e.length===32:return!0;case(e.length===33&&e[0]===2):return!0;case(e.length===33&&e[0]===3):return!1;default:throw new TypeError(`Invalid public key: ${e.hex}`)}}function kg(t){const e=G.bytes(t);switch(e.length){case 32:return e;case 33:return e.slice(1,33);default:throw new Error(`Invalid key length: ${e.length}`)}}var Ag=Object.freeze({__proto__:null,genSecretKey:Eg,getPublicKey:Ou,getSecretKey:Bi,getSharedCode:Sg,getSharedKey:Tu,is_even_pub:_g,xonly_pub:kg});G.random(32);const Cu={secp:xt},zo={...Ag,...yp},Bg={main:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"};function ln(t){const e=_.bytes(t);return e.length>32?e.slice(1,33):e}const $g=["bc1p","tb1p","bcrt1p"];function Iu(t){for(const e of $g)if(t.startsWith(e))return!0;return!1}function Uu(t,e="main"){const n=Bg[e],r=_.bytes(t);return Uc(r,32),r.toBech32(n,1)}function Og(t){if(!Iu(t))throw new TypeError("Invalid taproot address!");return _.bech32(t)}function Tg(t){const e=_.bytes(t);return Uc(e,32),["OP_1",e.hex]}function Cg(t,e){const n=ln(t);return Uu(n,e)}const Ig={check:Iu,encode:Uu,decode:Og,scriptPubKey:Tg,fromPubKey:Cg},Ug={version:2,vin:[],vout:[],locktime:0},Pg={scriptSig:[],sequence:4294967293,witness:[]},Ng={value:0n,scriptPubKey:[]};function $i(t){const e={...Ug,...t};return e.vin=e.vin.map(n=>({...Pg,...n})),e.vout=e.vout.map(n=>({...Ng,...n})),e}function jn(t,e){const{version:n,vin:r,vout:s,locktime:o}=$i(t),i=e!==!0&&Lg(r),a=[Oi(n)];i&&a.push(_.hex("0001")),a.push(Rg(r)),a.push(Hg(s));for(const c of r)i&&a.push(Dg(c.witness));return a.push(Ti(o)),_.join(a)}function Lg(t){for(const e of t){const{witness:n}=e;if(typeof n=="string"||n instanceof Uint8Array||Array.isArray(n)&&n.length>0)return!0}return!1}function Oi(t){return _.num(t,4).reverse()}function kr(t){return _.hex(t,32).reverse()}function Ar(t){return _.num(t,4).reverse()}function Br(t){if(typeof t=="string")return _.hex(t,4).reverse();if(typeof t=="number")return _.num(t,4).reverse();throw new Error("Unrecognized format: "+String(t))}function Rg(t){const e=[_.varInt(t.length,"le")];for(const n of t){const{txid:r,vout:s,scriptSig:o,sequence:i}=n;e.push(kr(r)),e.push(Ar(s)),e.push(wn(o,!0)),e.push(Br(i))}return _.join(e)}function qt(t){if(typeof t=="number"){if(t%1!==0)throw new Error("Value must be an integer:"+String(t));return _.num(t,8).reverse()}return _.big(t,8).reverse()}function Hg(t){const e=[_.varInt(t.length,"le")];for(const n of t)e.push(jg(n));return _.join(e)}function jg(t){const{value:e,scriptPubKey:n}=t,r=[];return r.push(qt(e)),r.push(wn(n,!0)),_.join(r)}function Dg(t=[]){const e=[];if(Array.isArray(t)){const n=_.varInt(t.length);e.push(n);for(const r of t)e.push(Zg(r));return _.join(e)}else return _.bytes(t)}function Zg(t){return Kg(t)?new _(0):wn(t,!0)}function Kg(t){if(Array.isArray(t))return t.length===0;if(typeof t=="string"&&t==="")return!0;const e=_.bytes(t);return e.length===1&&e[0]===0}function Ti(t){if(typeof t=="string")return _.hex(t,4);if(typeof t=="number")return _.num(t,4).reverse();throw new Error("Unrecognized format: "+String(t))}function Ci(t){typeof t=="string"&&(t=_.hex(t).raw);const e=new Yn(t),n=Vg(e),r=Mg(e),s=qg(e),o=Fg(e);if(r)for(const a of s)a.witness=Yg(e);const i=Wg(e);return{version:n,vin:s,vout:o,locktime:i}}function Vg(t){return t.read(4).reverse().toNum()}function Mg(t){const[e,n]=[...t.peek(2)];if(e===0){if(t.read(2),n===1)return!0;throw new Error(`Invalid witness flag: ${n}`)}return!1}function qg(t){const e=[],n=t.readSize("le");for(let r=0;r0?t.read(n).hex:null}function Nu(t,e){const n=Pu(t);return n!==null?n:[]}function Wg(t){return t.read(4).reverse().toNum()}function Xg(t){if(Nc(t))return Ci(t);if(typeof t=="object"&&!(t instanceof Uint8Array))return jn(t),$i(t);throw new Error("Invalid format: "+typeof t)}function Jg(t){if(Nc(t))return Ci(t),_.bytes(t);if(typeof t=="object")return jn(t);throw new Error("Invalid format: "+typeof t)}const Ii={toBytes:Jg,toJson:Xg},Qg=[["p2pkh",/^76a914(?\w{40})88ac$/],["p2sh",/^a914(?\w{40})87$/],["p2w-pkh",/^0014(?\w{40})$/],["p2w-sh",/^0020(?\w{64})$/],["p2tr",/^5120(?\w{64})$/]],em=[192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,102,126,128,132,150,152,186,188,190];function tm(t){let e=t.at(-1);return St(e)&&(e=_.hex(e)),t.length>1&&e instanceof Uint8Array&&e[0]===80?(t.pop(),_.raw(e)):null}function nm(t){let e=t.at(-1);return St(e)&&(e=_.hex(e)),t.length>1&&e instanceof Uint8Array&&e.length>32&&em.includes(e[0]&254)?(t.pop(),_.raw(e)):null}function rm(t){if(t.length>1){const e=t.at(-1);try{const n=Se.fmt.toBytes(e);return t.pop(),n}catch{return null}}return null}function sm(t){const e=[];for(const n of t)if(St(n)||n instanceof Uint8Array||typeof n=="number")e.push(_.bytes(n));else throw new Error("unrecognized value: "+String(n));return e}function om(t=[]){const e=[...t],n=tm(e),r=nm(e),s=rm(e),o=sm(e);return{annex:n,cblock:r,script:s,params:o}}function im(t){const e=Se.fmt.toBytes(t,!1).hex;for(const[n,r]of Qg){const s=n,{groups:o}=r.exec(e)??{},{hash:i}=o??{};if(St(i))return{type:s,data:_.hex(i)}}return{type:"raw",data:_.hex(e)}}function am(t){const e=Ii.toJson(t),n=jn(e,!0);return Hn(n).reverse().hex}function cm(t){const e=Ii.toJson(t),n=jn(e,!0).length,r=jn(e,!1).length,s=n*3+r,o=s%4>0?1:0,i=Math.floor(s/4)+o;return{size:r,bsize:n,vsize:i,weight:s}}const le={create:$i,encode:jn,decode:Ci,fmt:Ii,util:{getTxSize:cm,getTxid:am,readScriptPubKey:im,readWitness:om}},um={p2tr:Ig},fm=[1,2,3];function Ui(t,e,n={}){const{sigflag:r=1}=n,s=(r&128)===128,o=r%128;if(!fm.includes(o))throw new Error("Invalid hash type: "+String(r));const i=le.fmt.toJson(t),{version:a,vin:c,vout:u,locktime:l}=i,{txid:f,vout:d,prevout:h,sequence:m}=c[e],{value:y}=h??{};if(y===void 0)throw new Error("Prevout value is empty!");let p=n.script;if(p===void 0&&n.pubkey!==void 0&&(p=`76a914${wg(n.pubkey).hex}88ac`),p===void 0)throw new Error("No pubkey / script has been set!");if(Se.fmt.toAsm(p).includes("OP_CODESEPARATOR"))throw new Error("This library does not currently support the use of OP_CODESEPARATOR in segwit scripts.");const g=[Oi(a),lm(c,s),dm(c,o,s),kr(f),Ar(d),Se.encode(p,!0),qt(y),Br(m),hm(u,e,o),Ti(l),_.num(r,4).reverse()];return Hn(_.join(g))}function lm(t,e){if(e===!0)return _.num(0,32);const n=[];for(const{txid:r,vout:s}of t)n.push(kr(r)),n.push(Ar(s));return Hn(_.join(n))}function dm(t,e,n){if(n||e!==1)return _.num(0,32);const r=[];for(const{sequence:s}of t)r.push(Br(s));return Hn(_.join(r))}function hm(t,e,n){const r=[];if(n===1){for(const{value:s,scriptPubKey:o}of t)r.push(qt(s)),r.push(Se.encode(o,!0));return Hn(_.join(r))}if(n===3&&e1&&c[1].length===33)u=_.bytes(c[1]);else return Te("No pubkey provided!",s);const l=Se.fmt.toParam(c[0]),f=l.slice(0,-1),d=l.slice(-1)[0],h=Ui(r,e,{...n,sigflag:d});return Cu.secp.verify(f,h,u)?!0:Te("Invalid signature!",s)}const mm={hash:Ui,sign:pm,verify:gm},ym=[0,1,2,3,129,130,131];function Pi(t,e,n={}){const{extension:r,sigflag:s=0,extflag:o=0,key_version:i=0,separator_pos:a=4294967295}=n,c=le.fmt.toJson(t),{version:u,vin:l,vout:f,locktime:d}=c;if(e>=l.length)throw new Error("Index out of bounds: "+String(e));if(!ym.includes(s))throw new Error("Invalid hash type: "+String(s));if(o<0||o>127)throw new Error("Extention flag out of range: "+String(o));const{txid:h,vout:m,sequence:y,witness:p=[]}=l[e],g=(s&128)===128,x=_m(p),w=x!==void 0?1:0,A=(o+(r!==void 0?1:0))*2+w,O=_.str("TapSighash").digest,P=[O,O,_.num(0,1),_.num(s,1),Oi(u),Ti(d)];if(!g){const I=l.map(k=>va(k));P.push(bm(l),xm(I),vm(I),wm(l))}if(((s&3)<2||(s&3)>3)&&P.push(Em(f)),P.push(_.num(A,1)),g){const{value:I,scriptPubKey:k}=va(l[e]);P.push(kr(h),Ar(m),qt(I),Se.encode(k,!0),Br(y))}else P.push(_.num(e,4).reverse());return x!==void 0&&P.push(x),(s&3)===3&&P.push(Sm(f[e])),r!==void 0&&P.push(_.bytes(r),_.num(i),_.num(a,4,"le")),_.join(P).digest}function bm(t){const e=[];for(const{txid:n,vout:r}of t)e.push(kr(n)),e.push(Ar(r));return _.join(e).digest}function wm(t){const e=[];for(const{sequence:n}of t)e.push(Br(n));return _.join(e).digest}function xm(t){const e=[];for(const{value:n}of t)e.push(qt(n));return _.join(e).digest}function vm(t){const e=[];for(const{scriptPubKey:n}of t)e.push(wn(n,!0));return _.join(e).digest}function Em(t){const e=[];for(const{value:n,scriptPubKey:r}of t)e.push(qt(n)),e.push(Se.encode(r,!0));return _.join(e).digest}function Sm(t){return _.join([qt(t.value),Se.encode(t.scriptPubKey,!0)]).digest}function _m(t){if(t===void 0||t.length<2)return;let e=t.at(-1);if(typeof e=="string"&&(e=_.hex(e)),e instanceof Uint8Array&&e[0]===80)return _.raw(e).prefixSize("be").digest}function va(t){if(t.prevout===void 0)throw new Error("Prevout data missing for input: "+String(t.txid));return t.prevout}const km=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Am=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Bm(t,e,n,r={}){const{sigflag:s=0}=r,o=Pi(e,n,r),i=$m(t,o);return s===0?_.raw(i):_.join([i,s])}function $m(t,e,n=_.random(32)){const r=_.bytes(e),s=new Ne(t),o=s.point,i=o.hasEvenY?s.big:s.negated.big,a=ts("BIP0340/aux",_.bytes(n)),c=i^a.big,u=ts("BIP0340/nonce",c,o.x.raw,r),l=new Ne(u),f=l.point,d=f.hasEvenY?l.big:l.negated.big,h=new Ne(ts("BIP0340/challenge",f.x.raw,o.x.raw,r)),m=new Ne(d+h.big*i);return _.join([f.x.raw,m.raw])}function Om(t,e,n,r=!1){const s=xn.from_x(ln(n)),o=_.bytes(e),i=_.bytes(t).stream;i.size<64&&Te("Signature length is too small: "+String(i.size),r);const a=i.read(32);a.big>km&&Te("Signature r value greater than field size!",r);const c=i.read(32);c.big>Am&&Te("Signature s value greater than curve order!",r);const u=new Ne(ts("BIP0340/challenge",a.raw,s.x.raw,o)),l=new Ne(c).point,f=s.mul(u.big),d=l.sub(f);return d.hasOddY&&Te("Signature R value has odd Y coordinate!",r),d.x.big===0n&&Te("Signature R value is infinite!",r),d.x.big===a.big}const Tm=192;function Ms(t){const e=_.str(t).digest;return _.join([e,e])}function Ni(t,e=Tm){return _.join([Ms("TapLeaf"),Um(e),_.bytes(t)]).digest.hex}function Cm(t,e){return Ni(Se.fmt.toBytes(t),e)}function Li(t,e){return e0){const[h,m,y]=ds(r,i);c=y,a=Cn(t,h,n)}else i!==void 0?a=Cn(t,i,n):a=Cn(t,void 0,n);const u=n?zo.getPublicKey(a)[0]:a[0],f=[_.num(s+Zu(u)),o];c.length>0&&c.forEach(h=>f.push(_.hex(h)));const d=_.join(f);if(i!==void 0&&!Ri(a,i,d,e))throw new Error("Path checking failed! Unable to generate path.");return[ln(a).hex,d.hex]}function Ri(t,e,n,r={}){const{isPrivate:s=!1,throws:o=!1}=r,{parity:i,paths:a,intkey:c}=Du(n),u=s?zo.getPublicKey(t,!0):ln(t),l=_.join([i,u]);if(l.length!==33)return Te("Invalid tapkey: "+l.hex,o);let f=_.bytes(e).hex;for(const h of a)f=Li(f,h);const d=Cn(c,f);return _.raw(d).hex===_.raw(l).hex}function Du(t){const e=new Yn(_.bytes(t)),n=e.read(1).num,r=e.read(32),[s,o]=n%2===0?[n,2]:[n-1,3],i=[];for(;e.size>=32;)i.push(e.read(32).hex);if(e.size!==0)throw new Error("Non-empty buffer on control block: "+String(e));return{intkey:r,paths:i,parity:o,version:s}}function Zu(t=2){if(t===0||t===1)return t;if(t===2||t==="02")return 0;if(t===3||t==="03")return 1;throw new Error("Invalid parity bit: "+String(t))}function Zm(t,e,n={}){const r=le.fmt.toJson(t),{throws:s=!1}=n,{prevout:o,witness:i=[]}=r.vin[e],a=le.util.readWitness(i),{cblock:c,script:u,params:l}=a;let f;if(l.length<1)return Te("Invalid witness data: "+String(i),s);const{scriptPubKey:d}=o??{};if(d===void 0)return Te("Prevout scriptPubKey is empty!",s);const{type:h,data:m}=le.util.readScriptPubKey(d);if(h!=="p2tr")return Te("Prevout script is not a valid taproot output:"+m.hex,s);if(m.length!==32)return Te("Invalid tapkey length: "+String(m.length),s);if(c!==null&&u!==null){const w=c[0]&254,$=Ni(u,w);if(n.extension=$,!Ri(m,$,c,{throws:s}))return Te("cblock verification failed!",s)}n.pubkey!==void 0?f=_.bytes(n.pubkey):l.length>1&&l[1].length===32?f=_.bytes(l[1]):f=_.bytes(m);const y=Se.fmt.toParam(l[0]),p=new Yn(y),g=p.read(64).raw;if(p.size===1&&(n.sigflag=p.read(1).num,n.sigflag===0))return Te("0x00 is not a valid appended sigflag!",s);const x=Pi(r,e,n);return Om(g,x,f,s)?!0:Te("Invalid signature!",s)}const Km={hash:Pi,sign:Bm,verify:Zm},Ku={segwit:mm,taproot:Km},Vm={getTag:Ms,getLeaf:Ni,getBranch:Li,getRoot:Im},Mm={readCtrlBlock:Du,readParityBit:Zu},qm={getPubKey:Pm,getSecKey:Nm,getTweak:Lu,tweakSecKey:Ru,tweakPubKey:Hu},Fo={getPubKey:Dm,getSecKey:jm,encodeScript:Cm,checkPath:Ri,tree:Vm,tweak:qm,util:Mm,SCRIPT_PUBKEY:Rm};var ae;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},t.getValidEnumValues=s=>{const o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(const a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(const i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(ae||(ae={}));var Go;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Go||(Go={}));const K=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Dt=t=>{switch(typeof t){case"undefined":return K.undefined;case"string":return K.string;case"number":return isNaN(t)?K.nan:K.number;case"boolean":return K.boolean;case"function":return K.function;case"bigint":return K.bigint;case"symbol":return K.symbol;case"object":return Array.isArray(t)?K.array:t===null?K.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?K.promise:typeof Map<"u"&&t instanceof Map?K.map:typeof Set<"u"&&t instanceof Set?K.set:typeof Date<"u"&&t instanceof Date?K.date:K.object;default:return K.unknown}},L=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),zm=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Je extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(o){return o.message},r={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;cn.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Je.create=t=>new Je(t);const lr=(t,e)=>{let n;switch(t.code){case L.invalid_type:t.received===K.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case L.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,ae.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:n=`Unrecognized key(s) in object: ${ae.joinValues(t.keys,", ")}`;break;case L.invalid_union:n="Invalid input";break;case L.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ae.joinValues(t.options)}`;break;case L.invalid_enum_value:n=`Invalid enum value. Expected ${ae.joinValues(t.options)}, received '${t.received}'`;break;case L.invalid_arguments:n="Invalid function arguments";break;case L.invalid_return_type:n="Invalid function return type";break;case L.invalid_date:n="Invalid date";break;case L.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:ae.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case L.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case L.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case L.custom:n="Invalid input";break;case L.invalid_intersection_types:n="Intersection results could not be merged";break;case L.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case L.not_finite:n="Number must be finite";break;default:n=e.defaultError,ae.assertNever(t)}return{message:n}};let Vu=lr;function Fm(t){Vu=t}function hs(){return Vu}const ps=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,o=[...n,...s.path||[]],i={...s,path:o};let a="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)a=u(i,{data:e,defaultError:a}).message;return{...s,path:o,message:s.message||a}},Gm=[];function V(t,e){const n=ps({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,hs(),lr].filter(r=>!!r)});t.common.issues.push(n)}class Pe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return Y;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n)r.push({key:await s.key,value:await s.value});return Pe.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return Y;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),(typeof i.value<"u"||s.alwaysSet)&&(r[o.value]=i.value)}return{status:e.value,value:r}}}const Y=Object.freeze({status:"aborted"}),Mu=t=>({status:"dirty",value:t}),Re=t=>({status:"valid",value:t}),Yo=t=>t.status==="aborted",Wo=t=>t.status==="dirty",gs=t=>t.status==="valid",ms=t=>typeof Promise<"u"&&t instanceof Promise;var z;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(z||(z={}));class ct{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ea=(t,e)=>{if(gs(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Je(t.common.issues);return this._error=n,this._error}}};function J(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>i.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:r??a.defaultError}:{message:n??a.defaultError},description:s}}class te{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Dt(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Dt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Pe,ctx:{common:e.parent.common,data:e.data,parsedType:Dt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(ms(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const s={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Dt(e)},o=this._parseSync({data:e,path:s.path,parent:s});return Ea(s,o)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Dt(e)},s=this._parse({data:e,path:r.path,parent:r}),o=await(ms(s)?s:Promise.resolve(s));return Ea(r,o)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{const i=e(s),a=()=>o.addIssue({code:L.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new et({schema:this,typeName:F.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return wt.create(this,this._def)}nullable(){return pn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qe.create(this,this._def)}promise(){return Zn.create(this,this._def)}or(e){return gr.create([this,e],this._def)}and(e){return mr.create(this,e,this._def)}transform(e){return new et({...J(this._def),schema:this,typeName:F.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new vr({...J(this._def),innerType:this,defaultValue:n,typeName:F.ZodDefault})}brand(){return new zu({typeName:F.ZodBranded,type:this,...J(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new xs({...J(this._def),innerType:this,catchValue:n,typeName:F.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return $r.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ym=/^c[^\s-]{8,}$/i,Wm=/^[a-z][a-z0-9]*$/,Xm=/[0-9A-HJKMNP-TV-Z]{26}/,Jm=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,Qm=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,ey=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),ty=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ny=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ry=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function sy(t,e){return!!((e==="v4"||!e)&&ty.test(t)||(e==="v6"||!e)&&ny.test(t))}class Ge extends te{constructor(){super(...arguments),this._regex=(e,n,r)=>this.refinement(s=>e.test(s),{validation:n,code:L.invalid_string,...z.errToObj(r)}),this.nonempty=e=>this.min(1,z.errToObj(e)),this.trim=()=>new Ge({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new Ge({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new Ge({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==K.string){const o=this._getOrReturnCtx(e);return V(o,{code:L.invalid_type,expected:K.string,received:o.parsedType}),Y}const r=new Pe;let s;for(const o of this._def.checks)if(o.kind==="min")e.data.lengtho.value&&(s=this._getOrReturnCtx(e,s),V(s,{code:L.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const i=e.data.length>o.value,a=e.data.length"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,...z.errToObj(e==null?void 0:e.message)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...z.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...z.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...z.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...z.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...z.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...z.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...z.errToObj(n)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value{var e;return new Ge({checks:[],typeName:F.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...J(t)})};function oy(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,o=parseInt(t.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return o%i/Math.pow(10,s)}class zt extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==K.number){const o=this._getOrReturnCtx(e);return V(o,{code:L.invalid_type,expected:K.number,received:o.parsedType}),Y}let r;const s=new Pe;for(const o of this._def.checks)o.kind==="int"?ae.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),V(r,{code:L.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.datao.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),V(r,{code:L.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?oy(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),V(r,{code:L.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),V(r,{code:L.not_finite,message:o.message}),s.dirty()):ae.assertNever(o);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,z.toString(n))}gt(e,n){return this.setLimit("min",e,!1,z.toString(n))}lte(e,n){return this.setLimit("max",e,!0,z.toString(n))}lt(e,n){return this.setLimit("max",e,!1,z.toString(n))}setLimit(e,n,r,s){return new zt({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:z.toString(s)}]})}_addCheck(e){return new zt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:z.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.valuee.kind==="int"||e.kind==="multipleOf"&&ae.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.valuenew zt({checks:[],typeName:F.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...J(t)});class Ft extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==K.bigint){const o=this._getOrReturnCtx(e);return V(o,{code:L.invalid_type,expected:K.bigint,received:o.parsedType}),Y}let r;const s=new Pe;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.datao.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),V(r,{code:L.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),V(r,{code:L.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):ae.assertNever(o);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,z.toString(n))}gt(e,n){return this.setLimit("min",e,!1,z.toString(n))}lte(e,n){return this.setLimit("max",e,!0,z.toString(n))}lt(e,n){return this.setLimit("max",e,!1,z.toString(n))}setLimit(e,n,r,s){return new Ft({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:z.toString(s)}]})}_addCheck(e){return new Ft({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:z.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value{var e;return new Ft({checks:[],typeName:F.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...J(t)})};class dr extends te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==K.boolean){const r=this._getOrReturnCtx(e);return V(r,{code:L.invalid_type,expected:K.boolean,received:r.parsedType}),Y}return Re(e.data)}}dr.create=t=>new dr({typeName:F.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...J(t)});class dn extends te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==K.date){const o=this._getOrReturnCtx(e);return V(o,{code:L.invalid_type,expected:K.date,received:o.parsedType}),Y}if(isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return V(o,{code:L.invalid_date}),Y}const r=new Pe;let s;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()o.value&&(s=this._getOrReturnCtx(e,s),V(s,{code:L.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):ae.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new dn({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:z.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:z.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.valuenew dn({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:F.ZodDate,...J(t)});class ys extends te{_parse(e){if(this._getType(e)!==K.symbol){const r=this._getOrReturnCtx(e);return V(r,{code:L.invalid_type,expected:K.symbol,received:r.parsedType}),Y}return Re(e.data)}}ys.create=t=>new ys({typeName:F.ZodSymbol,...J(t)});class hr extends te{_parse(e){if(this._getType(e)!==K.undefined){const r=this._getOrReturnCtx(e);return V(r,{code:L.invalid_type,expected:K.undefined,received:r.parsedType}),Y}return Re(e.data)}}hr.create=t=>new hr({typeName:F.ZodUndefined,...J(t)});class pr extends te{_parse(e){if(this._getType(e)!==K.null){const r=this._getOrReturnCtx(e);return V(r,{code:L.invalid_type,expected:K.null,received:r.parsedType}),Y}return Re(e.data)}}pr.create=t=>new pr({typeName:F.ZodNull,...J(t)});class Dn extends te{constructor(){super(...arguments),this._any=!0}_parse(e){return Re(e.data)}}Dn.create=t=>new Dn({typeName:F.ZodAny,...J(t)});class un extends te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Re(e.data)}}un.create=t=>new un({typeName:F.ZodUnknown,...J(t)});class vt extends te{_parse(e){const n=this._getOrReturnCtx(e);return V(n,{code:L.invalid_type,expected:K.never,received:n.parsedType}),Y}}vt.create=t=>new vt({typeName:F.ZodNever,...J(t)});class bs extends te{_parse(e){if(this._getType(e)!==K.undefined){const r=this._getOrReturnCtx(e);return V(r,{code:L.invalid_type,expected:K.void,received:r.parsedType}),Y}return Re(e.data)}}bs.create=t=>new bs({typeName:F.ZodVoid,...J(t)});class Qe extends te{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==K.array)return V(n,{code:L.invalid_type,expected:K.array,received:n.parsedType}),Y;if(s.exactLength!==null){const i=n.data.length>s.exactLength.value,a=n.data.lengths.maxLength.value&&(V(n,{code:L.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>s.type._parseAsync(new ct(n,i,n.path,a)))).then(i=>Pe.mergeArray(r,i));const o=[...n.data].map((i,a)=>s.type._parseSync(new ct(n,i,n.path,a)));return Pe.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new Qe({...this._def,minLength:{value:e,message:z.toString(n)}})}max(e,n){return new Qe({...this._def,maxLength:{value:e,message:z.toString(n)}})}length(e,n){return new Qe({...this._def,exactLength:{value:e,message:z.toString(n)}})}nonempty(e){return this.min(1,e)}}Qe.create=(t,e)=>new Qe({type:t,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...J(e)});function $n(t){if(t instanceof be){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=wt.create($n(r))}return new be({...t._def,shape:()=>e})}else return t instanceof Qe?new Qe({...t._def,type:$n(t.element)}):t instanceof wt?wt.create($n(t.unwrap())):t instanceof pn?pn.create($n(t.unwrap())):t instanceof ut?ut.create(t.items.map(e=>$n(e))):t}class be extends te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=ae.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==K.object){const u=this._getOrReturnCtx(e);return V(u,{code:L.invalid_type,expected:K.object,received:u.parsedType}),Y}const{status:r,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof vt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||a.push(u);const c=[];for(const u of i){const l=o[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ct(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof vt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(V(s,{code:L.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of a){const f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ct(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const f=await l.key;u.push({key:f,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>Pe.mergeObjectSync(r,u)):Pe.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return new be({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var s,o,i,a;const c=(i=(o=(s=this._def).errorMap)===null||o===void 0?void 0:o.call(s,n,r).message)!==null&&i!==void 0?i:r.defaultError;return n.code==="unrecognized_keys"?{message:(a=z.errToObj(e).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new be({...this._def,unknownKeys:"strip"})}passthrough(){return new be({...this._def,unknownKeys:"passthrough"})}extend(e){return new be({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new be({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:F.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new be({...this._def,catchall:e})}pick(e){const n={};return ae.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new be({...this._def,shape:()=>n})}omit(e){const n={};return ae.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new be({...this._def,shape:()=>n})}deepPartial(){return $n(this)}partial(e){const n={};return ae.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}),new be({...this._def,shape:()=>n})}required(e){const n={};return ae.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof wt;)o=o._def.innerType;n[r]=o}}),new be({...this._def,shape:()=>n})}keyof(){return qu(ae.objectKeys(this.shape))}}be.create=(t,e)=>new be({shape:()=>t,unknownKeys:"strip",catchall:vt.create(),typeName:F.ZodObject,...J(e)});be.strictCreate=(t,e)=>new be({shape:()=>t,unknownKeys:"strict",catchall:vt.create(),typeName:F.ZodObject,...J(e)});be.lazycreate=(t,e)=>new be({shape:t,unknownKeys:"strip",catchall:vt.create(),typeName:F.ZodObject,...J(e)});class gr extends te{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(a=>new Je(a.ctx.common.issues));return V(n,{code:L.invalid_union,unionErrors:i}),Y}if(n.common.async)return Promise.all(r.map(async o=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(s);{let o;const i=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(c=>new Je(c));return V(n,{code:L.invalid_union,unionErrors:a}),Y}}get options(){return this._def.options}}gr.create=(t,e)=>new gr({options:t,typeName:F.ZodUnion,...J(e)});const ns=t=>t instanceof br?ns(t.schema):t instanceof et?ns(t.innerType()):t instanceof wr?[t.value]:t instanceof Gt?t.options:t instanceof xr?Object.keys(t.enum):t instanceof vr?ns(t._def.innerType):t instanceof hr?[void 0]:t instanceof pr?[null]:null;class qs extends te{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==K.object)return V(n,{code:L.invalid_type,expected:K.object,received:n.parsedType}),Y;const r=this.discriminator,s=n.data[r],o=this.optionsMap.get(s);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(V(n,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const o of n){const i=ns(o.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of i){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o)}}return new qs({typeName:F.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...J(r)})}}function Xo(t,e){const n=Dt(t),r=Dt(e);if(t===e)return{valid:!0,data:t};if(n===K.object&&r===K.object){const s=ae.objectKeys(e),o=ae.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(const a of o){const c=Xo(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(n===K.array&&r===K.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let o=0;o{if(Yo(o)||Yo(i))return Y;const a=Xo(o.value,i.value);return a.valid?((Wo(o)||Wo(i))&&n.dirty(),{status:n.value,value:a.data}):(V(r,{code:L.invalid_intersection_types}),Y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}mr.create=(t,e,n)=>new mr({left:t,right:e,typeName:F.ZodIntersection,...J(n)});class ut extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==K.array)return V(r,{code:L.invalid_type,expected:K.array,received:r.parsedType}),Y;if(r.data.lengththis._def.items.length&&(V(r,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((i,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new ct(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(o).then(i=>Pe.mergeArray(n,i)):Pe.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new ut({...this._def,rest:e})}}ut.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ut({items:t,typeName:F.ZodTuple,rest:null,...J(e)})};class yr extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==K.object)return V(r,{code:L.invalid_type,expected:K.object,received:r.parsedType}),Y;const s=[],o=this._def.keyType,i=this._def.valueType;for(const a in r.data)s.push({key:o._parse(new ct(r,a,r.path,a)),value:i._parse(new ct(r,r.data[a],r.path,a))});return r.common.async?Pe.mergeObjectAsync(n,s):Pe.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof te?new yr({keyType:e,valueType:n,typeName:F.ZodRecord,...J(r)}):new yr({keyType:Ge.create(),valueType:e,typeName:F.ZodRecord,...J(n)})}}class ws extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==K.map)return V(r,{code:L.invalid_type,expected:K.map,received:r.parsedType}),Y;const s=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new ct(r,a,r.path,[u,"key"])),value:o._parse(new ct(r,c,r.path,[u,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return Y;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const c of i){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return Y;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}}ws.create=(t,e,n)=>new ws({valueType:e,keyType:t,typeName:F.ZodMap,...J(n)});class hn extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==K.set)return V(r,{code:L.invalid_type,expected:K.set,received:r.parsedType}),Y;const s=this._def;s.minSize!==null&&r.data.sizes.maxSize.value&&(V(r,{code:L.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const o=this._def.valueType;function i(c){const u=new Set;for(const l of c){if(l.status==="aborted")return Y;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}const a=[...r.data.values()].map((c,u)=>o._parse(new ct(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,n){return new hn({...this._def,minSize:{value:e,message:z.toString(n)}})}max(e,n){return new hn({...this._def,maxSize:{value:e,message:z.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}hn.create=(t,e)=>new hn({valueType:t,minSize:null,maxSize:null,typeName:F.ZodSet,...J(e)});class In extends te{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==K.function)return V(n,{code:L.invalid_type,expected:K.function,received:n.parsedType}),Y;function r(a,c){return ps({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hs(),lr].filter(u=>!!u),issueData:{code:L.invalid_arguments,argumentsError:c}})}function s(a,c){return ps({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hs(),lr].filter(u=>!!u),issueData:{code:L.invalid_return_type,returnTypeError:c}})}const o={errorMap:n.common.contextualErrorMap},i=n.data;return this._def.returns instanceof Zn?Re(async(...a)=>{const c=new Je([]),u=await this._def.args.parseAsync(a,o).catch(d=>{throw c.addIssue(r(a,d)),c}),l=await i(...u);return await this._def.returns._def.type.parseAsync(l,o).catch(d=>{throw c.addIssue(s(l,d)),c})}):Re((...a)=>{const c=this._def.args.safeParse(a,o);if(!c.success)throw new Je([r(a,c.error)]);const u=i(...c.data),l=this._def.returns.safeParse(u,o);if(!l.success)throw new Je([s(u,l.error)]);return l.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new In({...this._def,args:ut.create(e).rest(un.create())})}returns(e){return new In({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new In({args:e||ut.create([]).rest(un.create()),returns:n||un.create(),typeName:F.ZodFunction,...J(r)})}}class br extends te{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}br.create=(t,e)=>new br({getter:t,typeName:F.ZodLazy,...J(e)});class wr extends te{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return V(n,{received:n.data,code:L.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:e.data}}get value(){return this._def.value}}wr.create=(t,e)=>new wr({value:t,typeName:F.ZodLiteral,...J(e)});function qu(t,e){return new Gt({values:t,typeName:F.ZodEnum,...J(e)})}class Gt extends te{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return V(n,{expected:ae.joinValues(r),received:n.parsedType,code:L.invalid_type}),Y}if(this._def.values.indexOf(e.data)===-1){const n=this._getOrReturnCtx(e),r=this._def.values;return V(n,{received:n.data,code:L.invalid_enum_value,options:r}),Y}return Re(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e){return Gt.create(e)}exclude(e){return Gt.create(this.options.filter(n=>!e.includes(n)))}}Gt.create=qu;class xr extends te{_parse(e){const n=ae.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==K.string&&r.parsedType!==K.number){const s=ae.objectValues(n);return V(r,{expected:ae.joinValues(s),received:r.parsedType,code:L.invalid_type}),Y}if(n.indexOf(e.data)===-1){const s=ae.objectValues(n);return V(r,{received:r.data,code:L.invalid_enum_value,options:s}),Y}return Re(e.data)}get enum(){return this._def.values}}xr.create=(t,e)=>new xr({values:t,typeName:F.ZodNativeEnum,...J(e)});class Zn extends te{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==K.promise&&n.common.async===!1)return V(n,{code:L.invalid_type,expected:K.promise,received:n.parsedType}),Y;const r=n.parsedType===K.promise?n.data:Promise.resolve(n.data);return Re(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Zn.create=(t,e)=>new Zn({type:t,typeName:F.ZodPromise,...J(e)});class et extends te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){const i=s.transform(r.data);return r.common.async?Promise.resolve(i).then(a=>this._def.schema._parseAsync({data:a,path:r.path,parent:r})):this._def.schema._parseSync({data:i,path:r.path,parent:r})}const o={addIssue:i=>{V(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="refinement"){const i=a=>{const c=s.refinement(a,o);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Y:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Y:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!gs(i))return i;const a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>gs(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:n.value,value:a})):i);ae.assertNever(s)}}et.create=(t,e,n)=>new et({schema:t,typeName:F.ZodEffects,effect:e,...J(n)});et.createWithPreprocess=(t,e,n)=>new et({schema:e,effect:{type:"preprocess",transform:t},typeName:F.ZodEffects,...J(n)});class wt extends te{_parse(e){return this._getType(e)===K.undefined?Re(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wt.create=(t,e)=>new wt({innerType:t,typeName:F.ZodOptional,...J(e)});class pn extends te{_parse(e){return this._getType(e)===K.null?Re(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pn.create=(t,e)=>new pn({innerType:t,typeName:F.ZodNullable,...J(e)});class vr extends te{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===K.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}vr.create=(t,e)=>new vr({innerType:t,typeName:F.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...J(e)});class xs extends te{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ms(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Je(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Je(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}xs.create=(t,e)=>new xs({innerType:t,typeName:F.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...J(e)});class vs extends te{_parse(e){if(this._getType(e)!==K.nan){const r=this._getOrReturnCtx(e);return V(r,{code:L.invalid_type,expected:K.nan,received:r.parsedType}),Y}return{status:"valid",value:e.data}}}vs.create=t=>new vs({typeName:F.ZodNaN,...J(t)});const iy=Symbol("zod_brand");class zu extends te{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class $r extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Y:o.status==="dirty"?(n.dirty(),Mu(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Y:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new $r({in:e,out:n,typeName:F.ZodPipeline})}}const Fu=(t,e={},n)=>t?Dn.create().superRefine((r,s)=>{var o,i;if(!t(r)){const a=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(i=(o=a.fatal)!==null&&o!==void 0?o:n)!==null&&i!==void 0?i:!0,u=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...u,fatal:c})}}):Dn.create(),ay={object:be.lazycreate};var F;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline"})(F||(F={}));const cy=(t,e={message:`Input not instance of ${t.name}`})=>Fu(n=>n instanceof t,e),Gu=Ge.create,Yu=zt.create,uy=vs.create,fy=Ft.create,Wu=dr.create,ly=dn.create,dy=ys.create,hy=hr.create,py=pr.create,gy=Dn.create,my=un.create,yy=vt.create,by=bs.create,wy=Qe.create,xy=be.create,vy=be.strictCreate,Ey=gr.create,Sy=qs.create,_y=mr.create,ky=ut.create,Ay=yr.create,By=ws.create,$y=hn.create,Oy=In.create,Ty=br.create,Cy=wr.create,Iy=Gt.create,Uy=xr.create,Py=Zn.create,Sa=et.create,Ny=wt.create,Ly=pn.create,Ry=et.createWithPreprocess,Hy=$r.create,jy=()=>Gu().optional(),Dy=()=>Yu().optional(),Zy=()=>Wu().optional(),Ky={string:(t=>Ge.create({...t,coerce:!0})),number:(t=>zt.create({...t,coerce:!0})),boolean:(t=>dr.create({...t,coerce:!0})),bigint:(t=>Ft.create({...t,coerce:!0})),date:(t=>dn.create({...t,coerce:!0}))},Vy=Y;var Le=Object.freeze({__proto__:null,defaultErrorMap:lr,setErrorMap:Fm,getErrorMap:hs,makeIssue:ps,EMPTY_PATH:Gm,addIssueToContext:V,ParseStatus:Pe,INVALID:Y,DIRTY:Mu,OK:Re,isAborted:Yo,isDirty:Wo,isValid:gs,isAsync:ms,get util(){return ae},get objectUtil(){return Go},ZodParsedType:K,getParsedType:Dt,ZodType:te,ZodString:Ge,ZodNumber:zt,ZodBigInt:Ft,ZodBoolean:dr,ZodDate:dn,ZodSymbol:ys,ZodUndefined:hr,ZodNull:pr,ZodAny:Dn,ZodUnknown:un,ZodNever:vt,ZodVoid:bs,ZodArray:Qe,ZodObject:be,ZodUnion:gr,ZodDiscriminatedUnion:qs,ZodIntersection:mr,ZodTuple:ut,ZodRecord:yr,ZodMap:ws,ZodSet:hn,ZodFunction:In,ZodLazy:br,ZodLiteral:wr,ZodEnum:Gt,ZodNativeEnum:xr,ZodPromise:Zn,ZodEffects:et,ZodTransformer:et,ZodOptional:wt,ZodNullable:pn,ZodDefault:vr,ZodCatch:xs,ZodNaN:vs,BRAND:iy,ZodBranded:zu,ZodPipeline:$r,custom:Fu,Schema:te,ZodSchema:te,late:ay,get ZodFirstPartyTypeKind(){return F},coerce:Ky,any:gy,array:wy,bigint:fy,boolean:Wu,date:ly,discriminatedUnion:Sy,effect:Sa,enum:Iy,function:Oy,instanceof:cy,intersection:_y,lazy:Ty,literal:Cy,map:By,nan:uy,nativeEnum:Uy,never:yy,null:py,nullable:Ly,number:Yu,object:xy,oboolean:Zy,onumber:Dy,optional:Ny,ostring:jy,pipeline:Hy,preprocess:Ry,promise:Py,record:Ay,set:$y,strictObject:vy,string:Gu,symbol:dy,transformer:Sa,tuple:ky,undefined:hy,union:Ey,unknown:my,void:by,NEVER:Vy,ZodIssueCode:L,quotelessJson:zm,ZodError:Je});const Xu=Le.string().regex(/^[a-fA-F0-9]$/),My=Le.string().regex(/^[a-fA-F0-9]{64}$/),Kn=Le.number().min(0).max(4294967295),qy=Le.bigint(),Ju=Le.instanceof(Uint8Array),zy=Le.union([Xu,Kn,Le.string(),Ju]).array(),Hi=Le.union([zy,Xu,Ju]),Fy=Le.array(Hi),Qu=Le.object({value:Le.union([Kn,qy]),scriptPubKey:Hi}),Gy=Le.object({txid:My,vout:Kn,scriptSig:Hi,sequence:Kn,prevout:Qu.optional(),witness:Fy});Le.object({version:Kn,vin:Le.array(Gy),vout:Le.array(Qu),locktime:Kn});const Jo=2048,Yy=new TextEncoder;function ef(t){const e=[],n=(s,o)=>{if(o<24)e.push(s*32+o);else if(o<=255)e.push(s*32+24,o);else if(o<=65535)e.push(s*32+25,o>>>8,o&255);else if(o<=4294967295){const i=new Uint8Array(4);new DataView(i.buffer).setUint32(0,o),e.push(s*32+26,...i)}else{e.push(s*32+27);const i=new Uint8Array(8);new DataView(i.buffer).setBigUint64(0,BigInt(o)),e.push(...i)}},r=(s,o=0)=>{if(o>64)throw new Error("Metadata nesting exceeds 64 levels.");if(s===null)e.push(246);else if(typeof s=="boolean")e.push(s?245:244);else if(typeof s=="number"&&Number.isFinite(s))if(Number.isSafeInteger(s)&&!Object.is(s,-0))n(s>=0?0:1,s>=0?s:-1-s);else{const i=new Uint8Array(8);new DataView(i.buffer).setFloat64(0,s),e.push(251,...i)}else if(typeof s=="string"){const i=Yy.encode(s);n(3,i.length);for(const a of i)e.push(a)}else if(Array.isArray(s))n(4,s.length),s.forEach(i=>r(i,o+1));else if(typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){const i=Object.entries(s);n(5,i.length);for(const[a,c]of i)r(a,o+1),r(c,o+1)}else throw new Error("Metadata must contain only JSON values.");if(e.length>Jo)throw new Error(`Metadata must be at most ${Jo} CBOR bytes.`)};return r(t),Uint8Array.from(e)}function Wy(t){if(t=new Uint8Array(t),!t.length||t.length>Jo)throw new Error("Invalid CBOR metadata size.");let e=0;const n=o=>{if(e+o>t.length)throw new Error("Truncated CBOR metadata.");const i=t.slice(e,e+o);return e+=o,i},r=(o=0)=>{if(o>64)throw new Error("Metadata nesting exceeds 64 levels.");const i=n(1)[0],a=i>>5,c=i&31;if(a===7){if(c===20)return!1;if(c===21)return!0;if(c===22)return null;if(c===27){const l=new DataView(n(8).buffer).getFloat64(0);if(Number.isFinite(l))return l}throw new Error("Unsupported CBOR value.")}let u=c;if(c>=24&&c<=27){u=0;for(const l of n(2**(c-24)))u=u*256+l}else if(c>=28)throw new Error("Unsupported CBOR length.");if(!Number.isSafeInteger(u))throw new Error("CBOR integer exceeds JSON precision.");if(a===0)return u;if(a===1)return-1-u;if(a===3)return new TextDecoder("utf-8",{fatal:!0}).decode(n(u));if((a===4||a===5)&&u>t.length)throw new Error("Invalid CBOR collection length.");if(a===4)return Array.from({length:u},()=>r(o+1));if(a===5){const l={};for(let f=0;f({txid:t,vout:e,sequence:4294967295,prevout:{value:n,scriptPubKey:r}}),Ye=(t,e)=>({value:t,scriptPubKey:e}),_a=16*1024,mt=1e3,Ie=500,Es="text/plain;charset=utf-8",Xy=["text/plain","application/json","text/html","image/svg+xml","image/png","image/jpeg","image/webp"],tf=new TextEncoder,ir=t=>Array.from(t,e=>e.toString(16).padStart(2,"0")).join(""),Qt=t=>Uint8Array.from(t.match(/../g)??[],e=>parseInt(e,16)),Ss=t=>ir(tf.encode(t));function ji(t){const e=typeof t=="string"?{contentType:Es,bytes:tf.encode(t)}:t;if(!e||![...Xy,Es].includes(e.contentType))throw new Error("Unsupported MIME type.");if(!(e.bytes instanceof Uint8Array)||!e.bytes.length)throw new Error("Enter non-empty inscription bytes.");if(e.bytes.length>_a)throw new Error(`Body must be at most ${_a} bytes.`);return{contentType:e.contentType,bytes:new Uint8Array(e.bytes)}}function _s(t){const e=/^([0-9a-f]{64})i(0|[1-9][0-9]*)$/.exec(t);if(!e||Number(e[2])>4294967295)throw new Error("Invalid parent inscription id.");let n=Number(e[2]),r="";for(;n;)r+=(n%256).toString(16).padStart(2,"0"),n=Math.floor(n/256);return e[1].match(/../g).reverse().join("")+r}function ka(t){if(typeof t!="string"||!/^[0-9a-f]{64,72}$/.test(t)||t.length%2)throw new Error("Invalid parent tag.");const e=[...Qt(t.slice(64))].reduce((r,s,o)=>r+s*256**o,0),n=`${t.slice(0,64).match(/../g).reverse().join("")}i${e}`;if(_s(n)!==t)throw new Error("Non-canonical parent tag.");return n}function nf(t,e,n=null,r=void 0,s={}){const{contentType:o,bytes:i}=ji(e),{delegate:a=null,pointer:c,metaprotocol:u=null}=s,l=u==null||u===""?null:new TextEncoder().encode(String(u));if(l&&l.length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");const f=r===void 0?void 0:ef(r),d=[];for(let m=0;m{const y=m.length/2;return(y<=75?y.toString(16).padStart(2,"0"):y<=255?"4c"+y.toString(16).padStart(2,"0"):"4d"+(y%256).toString(16).padStart(2,"0")+Math.floor(y/256).toString(16).padStart(2,"0"))+m};return h(t)+"ac0063"+h(Ss("ord"))+h("01")+h(Ss(o))+(a?h("0b")+h(_s(a)):"")+(c===void 0?"":h("02")+h(rf(c)))+(n?h("03")+h(_s(n)):"")+(f===void 0?"":Array.from({length:Math.ceil(f.length/520)},(m,y)=>h("05")+h(ir(f.slice(y*520,(y+1)*520)))).join(""))+(l?h("07")+h(ir(l)):"")+"00"+d.map(h).join("")+"68"}function Di(t){if(!Array.isArray(t)||t.length!==3)throw new Error("Unsupported script-path witness.");const e=Se.decode(t[1]);let n=7,r=null,s=null,o;e[n]==="0b"&&(s=ka(e[n+1]),n+=2),e[n]==="02"&&(o=Qy(e[n+1]==="OP_0"?"":e[n+1]),n+=2),e[n]==="03"&&(r=ka(e[n+1]),n+=2);const i=[];for(;e[n]==="05";){const m=e[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metadata push.");i.push(m),n+=2}const a=i.length?Wy(Qt(i.join(""))):void 0;let c=null;if(e[n]==="07"){const m=e[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metaprotocol field.");c=new TextDecoder().decode(Qt(m)),n+=2}if(e[n]!=="OP_0")throw new Error("Unsupported ord tag or missing body separator.");const u=e.slice(n+1,-1);if(!u.length||u.some(m=>typeof m!="string"||!/^(?:[0-9a-f]{2})+$/.test(m)))throw new Error("Invalid body envelope.");const l=new TextDecoder().decode(Qt(e[6])),f=ji({contentType:l,bytes:Qt(u.join(""))}),d=nf(e[0],f,r,a,{delegate:s,pointer:o,metaprotocol:c}),h=a===void 0&&!r&&l===Es&&f.bytes.length<=280&&Se.encode([e[0],"OP_CHECKSIG","OP_0","OP_IF",Ss("ord"),"01",Ss(Es),"OP_0",ir(f.bytes),"OP_ENDIF"],!1).hex;if(d!==t[1]&&h!==t[1])throw new Error("Unsupported ord envelope.");if(!/^[0-9a-f]{64}$/.test(e[0]))throw new Error("Invalid inscription signing key.");return{...f,parent:r,delegate:s,pointer:o,metaprotocol:c,metadata:a,metadataBytes:i.length?Qt(i.join("")):void 0,text:new TextDecoder().decode(f.bytes),pubkey:e[0]}}class Jy{constructor(e,n){this.chain=e,this.wallet=n}prepare(e,n=null,r=void 0,s={}){const o=ji(e);if(r!==void 0&&ef(r),s.delegate&&_s(s.delegate),s.pointer!==void 0&&rf(s.pointer),s.metaprotocol!==void 0&&s.metaprotocol!==null&&s.metaprotocol!==""&&new TextEncoder().encode(String(s.metaprotocol)).length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");if(n&&s.reinscribe)throw new Error("Choose parent or reinscription, not both.");const i=this.chain.coins(this.wallet.script),a=n?i.find(l=>{var f;return(f=l.inscriptions)==null?void 0:f.some(d=>d.id===n)}):null;if(n&&!a)throw new Error("Parent must be an owned, unspent inscription.");const c=s.reinscribe?i.find(l=>{var f;return(f=l.inscriptions)==null?void 0:f.some(d=>d.id===s.reinscribe)}):null;if(s.reinscribe&&!c)throw new Error("Reinscription must spend an owned sat.");const u=i.find(l=>!l.inscription&&l.value>=mt+2*Ie+330);if(!u)throw new Error("Mine a block first to get spendable fake BTC.");return{...o,coin:u,parent:a,reinscribe:c,totalFee:Ie*2,postage:mt}}inscribe(e,n=null,r=void 0,s={}){const{coin:o,parent:i,reinscribe:a,...c}=this.prepare(e,n,r,s),u=i??a,l=a==null?void 0:a.inscriptions.find($=>$.id===s.reinscribe),f=l?this.chain.satLocation(l.sat).offset:s.pointer??(i?i.value:void 0),d=nf(this.wallet.pubkey,c,n,r,{...s,pointer:f}),h=Fo.encodeScript(d),[m,y]=Fo.getPubKey(this.wallet.pubkey,{target:h}),p=le.create({vin:[Un(o.txid,o.vout,o.value,o.scriptPubKey)],vout:[Ye(mt+Ie,["OP_1",m]),Ye(o.value-mt-2*Ie,this.wallet.script)]});p.vin[0].witness=[this.wallet.sign(p)];const g=le.util.getTxid(p),x=le.create({vin:[...u?[Un(u.txid,u.vout,u.value,u.scriptPubKey)]:[],Un(g,0,mt+Ie,["OP_1",m])],vout:[...u?[Ye(u.value,this.wallet.script)]:[],Ye(mt,this.wallet.script)]}),w=u?1:0;return x.vin[w].witness=[this.wallet.sign(x,h,w),Se.encode(d,!1).hex,y],u&&(x.vin[0].witness=[this.wallet.sign(x)]),this.chain.submitPackage([le.encode(p).hex,le.encode(x).hex]),`${le.util.getTxid(x)}i0`}list(){return this.chain.coins(this.wallet.script).flatMap(e=>e.inscriptions??[])}}function rf(t){let e;try{e=BigInt(t)}catch{throw new Error("Invalid pointer.")}if(e<0n||e>0xffffffffffffffffn||typeof t=="number"&&!Number.isSafeInteger(t))throw new Error("Invalid pointer.");let n="";for(;e;)n+=Number(e&255n).toString(16).padStart(2,"0"),e>>=8n;return n}function Qy(t){if(typeof t!="string"||!/^(?:[0-9a-f]{2}){0,8}$/.test(t))throw new Error("Invalid pointer tag.");return[...Qt(t)].reduce((e,n,r)=>e+(BigInt(n)<{var g;const i=le.decode(r),a=le.util.getTxid(i),c=i.vin[0].txid==="0".repeat(64),u=c?[]:i.vin.map(x=>this.utxos.get(`${x.txid}:${x.vout}`)),l=fc(i,u,s,c);i.vin.forEach(x=>this.utxos.delete(`${x.txid}:${x.vout}`)),i.vout.forEach((x,w)=>this.utxos.set(`${a}:${w}`,{txid:a,vout:w,value:Number(x.value),ranges:l[w]}));const f=(g=i.vin.find(x=>{var w;return((w=x.witness)==null?void 0:w.length)===3}))==null?void 0:g.witness;if(!f)return;const d=Di(f),h=BigInt(d.pointer??0),m=i.vout.reduce((x,w)=>x+Number(w.value),0),y=uc(l.flat(),hx.sat===y).length,status:s===null?"pending":"confirmed",height:s,block:o,metadata:p??null,hasMetadata:p!==void 0,parent:d.parent,protocol:d.metaprotocol??(p&&!Array.isArray(p)&&typeof p=="object"&&Object.hasOwn(p,"protocol")&&typeof p.protocol=="string"?p.protocol:null)})};for(const r of e.blocks)for(const s of r.raws)n(s,r.height,r.hash);for(const r of e.mempool)n(r,null,null);for(const r of this.events){r.location=null;for(const s of this.utxos.values()){const o=es(s.ranges,r.sat);if(o!==null){r.location={txid:s.txid,vout:s.vout,offset:o};break}}r.delegatedBy=this.events.filter(s=>s.delegate===r.id).map(s=>s.id),r.inscriptions=this.events.filter(s=>s.sat===r.sat).map(s=>s.id)}}forProtocol(e){return this.events.filter(n=>n.protocol===e)}get protocols(){return[...new Set(this.events.filter(e=>e.protocol!==null).map(e=>e.protocol))].sort()}get stats(){return{events:this.events.length,withMetadata:this.events.filter(e=>e.hasMetadata).length,confirmed:this.events.filter(e=>e.status==="confirmed").length,pending:this.events.filter(e=>e.status==="pending").length,protocols:this.protocols}}}const Zi="lineage/v0",eb=["white","green","black"],Aa="names are 1-40 lowercase letters, digits or hyphens (they become domains)",tb=/^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/,go=t=>typeof t=="string"&&tb.test(t),rs=(t,e)=>typeof t=="string"?t.trim().slice(0,e):"";function Ki(t){return String(t??"").toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,"")}const Vi=t=>t.events.filter(e=>e.protocol===Zi);function Vn(t,{upTo:e=1/0,pending:n=!1}={}){const r=new Map,s=[],o=[],i=a=>a.status==="active";for(const a of t){const c=a.status==="confirmed";if(c?a.height>e:!n)continue;const u=a.metadata&&typeof a.metadata=="object"&&!Array.isArray(a.metadata)?a.metadata:{},l={id:a.id,op:typeof u.op=="string"?u.op.slice(0,20):"?",beat:c?a.height:null,pending:!c,meta:u,parent:a.parent??null,ok:!0,why:"",node:null,root:null,also:[]},f=l.parent?r.get(l.parent):null,d=l.beat??"cued",h=p=>{l.ok=!1,l.why=p},m=p=>f?i(f)?"":`the ${p} is ${f.status}`:`the ${p} is not in this lineage`;let y="";switch(l.op){case"found":if(l.parent)h("a holding has no parent");else if(!go(u.name))h(Aa);else if(s.some(p=>i(p)&&p.name===u.name))h(`an active holding is already named ${u.name}`);else{const p=Ba(a,u.name,null,"holding");r.set(p.id,p),s.push(p),l.node=p.id}break;case"birth":{const p=u.kind==="agent"?"agent":"org";if(y=m("parent"))h(y);else if(f.kind==="agent")h("agents do not give birth");else if(!go(u.name))h(Aa);else if(f.children.some(g=>i(r.get(g))&&r.get(g).name===u.name))h(`${f.name} already has an active ${u.name}`);else{const g=Ba(a,u.name,f,p);g.index=f.children.filter(x=>r.get(x).kind===p).length,f.children.push(g.id),r.set(g.id,g),l.node=g.id}break}case"award":{const p=r.get(u.to);(y=m("issuer"))?h(y):f.kind==="agent"?h("agents do not award belts"):!p||p.root!==f.root||p.id===f.id?h("the recipient must be another node in this holding"):i(p)?!go(u.skill)||!eb.includes(u.belt)?h("an award needs a skill name and a belt (white, green or black)"):(p.badges=p.badges.filter(g=>g.skill!==u.skill),p.badges.push({skill:u.skill,belt:u.belt,by:f.id,beat:d,id:a.id}),l.node=p.id):h(`the recipient is ${p.status}`);break}case"decide":(y=m("decider"))?h(y):rs(u.title,140)?(f.decisions.push({title:rs(u.title,140),why:rs(u.why,400),beat:d,id:a.id}),l.node=f.id):h("a decision needs a title");break;case"graduate":{const p=r.get(u.of);(y=m("parent"))?h(y):!p||p.parent!==f.id?h("only its parent can graduate a child"):p.kind!=="org"?h("only orgs graduate"):i(p)?p.edge==="adopted"?h("already graduated"):(p.edge="adopted",p.graduated=d,l.node=p.id):h(`the child is ${p.status}`);break}case"close":if(!f)h(l.parent?"that node is not in this lineage":"a close spends the node it closes");else if(!i(f))h(`already ${f.status}`);else{const p=g=>{g.status="closed",g.closed=d;for(const x of g.children){const w=r.get(x);w.edge==="derived"&&i(w)&&(l.also.push(w.id),p(w))}};p(f),l.node=f.id}break;default:h("not a lineage/v0 op")}l.root=l.node?r.get(l.node).root:(f==null?void 0:f.root)??null,o.push(l)}return{nodes:r,roots:s,log:o}}function Ba(t,e,n,r){return{id:t.id,name:e,kind:r,parent:(n==null?void 0:n.id)??null,root:n?n.root:t.id,edge:n?"derived":null,status:"active",index:null,born:t.status==="confirmed"?t.height:"cued",children:[],badges:[],decisions:[],graduated:null,closed:null}}function nb(t,e){const n=[],r=t.nodes.get(e),s=(o,i,a)=>{n.push({type:"node",node:o,guide:i,path:o.parent?`${o.index}'`:"●"});const c=o.children.map(l=>t.nodes.get(l)),u=[["agents",c.filter(l=>l.kind==="agent")],["orgs",c.filter(l=>l.kind!=="agent")]].filter(([,l])=>l.length);u.forEach(([l,f],d)=>{const h=d===u.length-1,m=a+(h?" ":"│ ");n.push({type:"group",label:l,guide:a+(h?"└─ ":"├─ ")}),f.forEach((y,p)=>{const g=p===f.length-1;s(y,m+(g?"└─ ":"├─ "),m+(g?" ":"│ "))})})};return r&&s(r,"",""),n}function rb(t,e){const n={orgs:0,agents:0,belts:0,decisions:0,closed:0};for(const r of t.nodes.values())r.root===e&&(r.id!==e&&(n[r.kind==="agent"?"agents":"orgs"]++,r.status==="closed"&&n.closed++),n.belts+=r.badges.length,n.decisions+=r.decisions.length);return n}function sf(t,e){const n=[];for(let r=t.nodes.get(e);r;r=t.nodes.get(r.parent))n.unshift(r.name);return n.join(" / ")}function of(t,e){const n=t.meta,r=s=>{var o;return((o=e.nodes.get(s))==null?void 0:o.name)??(typeof s=="string"?`${s.slice(0,8)}…`:"?")};if(!t.ok)return`${t.op}: ${t.why}`;switch(t.op){case"found":return`found ${n.name}`;case"birth":return`birth ${n.name}${n.kind==="agent"?" (agent)":""} ← ${r(t.parent)}`;case"award":return`award ${n.skill} · ${n.belt} → ${r(n.to)}, from ${r(t.parent)}`;case"decide":return`decide “${rs(n.title,140)}” · ${r(t.parent)}`;case"graduate":return`graduate ${r(n.of)} from ${r(t.parent)}`;case"close":return`close ${r(t.parent)}${t.also.length?` and ${t.also.length} derived`:""}`;default:return t.op}}const _n=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Or(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Vt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Ue(t,...e){if(!Or(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Tr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Vt(t.outputLen),Vt(t.blockLen)}function ks(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function sb(t,e){Ue(t);const n=e.outputLen;if(t.length>>e}function Dr(t,e){return t<>>32-e>>>0}const af=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ob=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ze(t){if(Ue(t),af)return t.toHex();let e="";for(let n=0;n=pt._0&&t<=pt._9)return t-pt._0;if(t>=pt.A&&t<=pt.F)return t-(pt.A-10);if(t>=pt.a&&t<=pt.f)return t-(pt.a-10)}function Mn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(af)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,o=0;st().update(Er(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function En(t=32){if(_n&&typeof _n.getRandomValues=="function")return _n.getRandomValues(new Uint8Array(t));if(_n&&typeof _n.randomBytes=="function")return Uint8Array.from(_n.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function ab(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,a,r)}function cb(t,e,n){return t&e^~t&n}function ub(t,e,n){return t&e^t&n^e&n}class qi extends cf{constructor(e,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(e),this.view=fn(this.buffer)}update(e){ks(this),e=Er(e),Ue(e);const{view:n,buffer:r,blockLen:s}=this,o=e.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f>Ta&Zr)}:{h:Number(t>>Ta&Zr)|0,l:Number(t&Zr)|0}}function lb(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;ot>>>n,Ia=(t,e,n)=>t<<32-n|e>>>n,kn=(t,e,n)=>t>>>n|e<<32-n,An=(t,e,n)=>t<<32-n|e>>>n,Kr=(t,e,n)=>t<<64-n|e>>>n-32,Vr=(t,e,n)=>t>>>n-32|e<<64-n;function gt(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const db=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),hb=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,pb=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),gb=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,mb=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),yb=(t,e,n,r,s,o)=>e+n+r+s+o+(t/2**32|0)|0,bb=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]),Nt=new Uint32Array(64);class wb extends qi{constructor(e=32){super(64,e,8,!1),this.A=Pt[0]|0,this.B=Pt[1]|0,this.C=Pt[2]|0,this.D=Pt[3]|0,this.E=Pt[4]|0,this.F=Pt[5]|0,this.G=Pt[6]|0,this.H=Pt[7]|0}get(){const{A:e,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[e,n,r,s,o,i,a,c]}set(e,n,r,s,o,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)Nt[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const d=Nt[f-15],h=Nt[f-2],m=ot(d,7)^ot(d,18)^d>>>3,y=ot(h,17)^ot(h,19)^h>>>10;Nt[f]=y+Nt[f-7]+m+Nt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=ot(a,6)^ot(a,11)^ot(a,25),h=l+d+cb(a,c,u)+bb[f]+Nt[f]|0,y=(ot(r,2)^ot(r,13)^ot(r,22))+ub(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){ft(Nt)}destroy(){this.set(0,0,0,0,0,0,0,0),ft(this.buffer)}}const uf=lb(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),xb=uf[0],vb=uf[1],Lt=new Uint32Array(80),Rt=new Uint32Array(80);class Eb extends qi{constructor(e=64){super(128,e,16,!1),this.Ah=Oe[0]|0,this.Al=Oe[1]|0,this.Bh=Oe[2]|0,this.Bl=Oe[3]|0,this.Ch=Oe[4]|0,this.Cl=Oe[5]|0,this.Dh=Oe[6]|0,this.Dl=Oe[7]|0,this.Eh=Oe[8]|0,this.El=Oe[9]|0,this.Fh=Oe[10]|0,this.Fl=Oe[11]|0,this.Gh=Oe[12]|0,this.Gl=Oe[13]|0,this.Hh=Oe[14]|0,this.Hl=Oe[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:d,Gh:h,Gl:m,Hh:y,Hl:p}=this;return[e,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p]}set(e,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=p|0}process(e,n){for(let w=0;w<16;w++,n+=4)Lt[w]=e.getUint32(n),Rt[w]=e.getUint32(n+=4);for(let w=16;w<80;w++){const $=Lt[w-15]|0,A=Rt[w-15]|0,O=kn($,A,1)^kn($,A,8)^Ca($,A,7),P=An($,A,1)^An($,A,8)^Ia($,A,7),I=Lt[w-2]|0,k=Rt[w-2]|0,U=kn(I,k,19)^Kr(I,k,61)^Ca(I,k,6),R=An(I,k,19)^Vr(I,k,61)^Ia(I,k,6),D=pb(P,R,Rt[w-7],Rt[w-16]),v=gb(D,O,U,Lt[w-7],Lt[w-16]);Lt[w]=v|0,Rt[w]=D|0}let{Ah:r,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:d,Fh:h,Fl:m,Gh:y,Gl:p,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){const $=kn(f,d,14)^kn(f,d,18)^Kr(f,d,41),A=An(f,d,14)^An(f,d,18)^Vr(f,d,41),O=f&h^~f&y,P=d&m^~d&p,I=mb(x,A,P,vb[w],Rt[w]),k=yb(I,g,$,O,xb[w],Lt[w]),U=I|0,R=kn(r,s,28)^Kr(r,s,34)^Kr(r,s,39),D=An(r,s,28)^Vr(r,s,34)^Vr(r,s,39),v=r&o^r&a^o&a,E=s&i^s&c^i&c;g=y|0,x=p|0,y=h|0,p=m|0,h=f|0,m=d|0,{h:f,l:d}=gt(u|0,l|0,k|0,U|0),u=a|0,l=c|0,a=o|0,c=i|0,o=r|0,i=s|0;const b=db(U,D,E);r=hb(b,k,R,v),s=b|0}({h:r,l:s}=gt(this.Ah|0,this.Al|0,r|0,s|0)),{h:o,l:i}=gt(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=gt(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=gt(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:d}=gt(this.Eh|0,this.El|0,f|0,d|0),{h,l:m}=gt(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:p}=gt(this.Gh|0,this.Gl|0,y|0,p|0),{h:g,l:x}=gt(this.Hh|0,this.Hl|0,g|0,x|0),this.set(r,s,o,i,a,c,u,l,f,d,h,m,y,p,g,x)}roundClean(){ft(Lt,Rt)}destroy(){ft(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Et=Mi(()=>new wb),Sr=Mi(()=>new Eb);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zi=BigInt(0),Qo=BigInt(1);function gn(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function We(t,e,n=""){const r=Or(t),s=t==null?void 0:t.length,o=e!==void 0;if(!r||o&&s!==e){const i=n&&`"${n}" `,a=o?` of length ${e}`:"",c=r?`length=${s}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return t}function Mr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function ff(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?zi:BigInt("0x"+t)}function Xn(t){return ff(Ze(t))}function mn(t){return Ue(t),ff(Ze(Uint8Array.from(t).reverse()))}function Fs(t,e){return Mn(t.toString(16).padStart(e*2,"0"))}function Fi(t,e){return Fs(t,e).reverse()}function ue(t,e,n){let r;if(typeof e=="string")try{r=Mn(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(Or(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Ua(t){return Uint8Array.from(t)}const mo=t=>typeof t=="bigint"&&zi<=t;function ei(t,e,n){return mo(t)&&mo(e)&&mo(n)&&e<=t&&tzi;t>>=Qo,e+=1);return e}const Cr=t=>(Qo<new Uint8Array(h),s=h=>Uint8Array.of(h);let o=r(t),i=r(t),a=0;const c=()=>{o.fill(1),i.fill(0),a=0},u=(...h)=>n(i,o,...h),l=(h=r(0))=>{i=u(s(0),h),o=u(),h.length!==0&&(i=u(s(1),h),o=u())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const m=[];for(;h{c(),l(h);let y;for(;!(y=m(f()));)l();return c(),y}}function Jn(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(s,o,i){const a=t[s];if(i&&a===void 0)return;const c=typeof a;if(c!==o||a===null)throw new Error(`param "${s}" is invalid: expected ${o}, got ${c}`)}Object.entries(e).forEach(([s,o])=>r(s,o,!1)),Object.entries(n).forEach(([s,o])=>r(s,o,!0))}function As(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const o=t(n,...r);return e.set(n,o),o}}const ti=Ze;class df extends cf{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Tr(e);const r=Er(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?e.create().update(r).digest():r);for(let i=0;inew df(t,e).update(n).digest();Yt.create=(t,e)=>new df(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const je=BigInt(0),$e=BigInt(1),sn=BigInt(2),hf=BigInt(3),pf=BigInt(4),gf=BigInt(5),_b=BigInt(7),mf=BigInt(8),kb=BigInt(9),yf=BigInt(16);function ge(t,e){const n=t%e;return n>=je?n:e+n}function ye(t,e,n){let r=t;for(;e-- >je;)r*=r,r%=n;return r}function Pa(t,e){if(t===je)throw new Error("invert: expected non-zero number");if(e<=je)throw new Error("invert: expected positive modulus, got "+e);let n=ge(t,e),r=e,s=je,o=$e;for(;n!==je;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==$e)throw new Error("invert: does not exist");return ge(s,e)}function Gi(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function bf(t,e){const n=(t.ORDER+$e)/pf,r=t.pow(e,n);return Gi(t,r,e),r}function Ab(t,e){const n=(t.ORDER-gf)/mf,r=t.mul(e,sn),s=t.pow(r,n),o=t.mul(e,s),i=t.mul(t.mul(o,sn),s),a=t.mul(o,t.sub(i,t.ONE));return Gi(t,a,e),a}function Bb(t){const e=Sn(t),n=wf(t),r=n(e,e.neg(e.ONE)),s=n(e,r),o=n(e,e.neg(r)),i=(t+_b)/yf;return(a,c)=>{let u=a.pow(c,i),l=a.mul(u,r);const f=a.mul(u,s),d=a.mul(u,o),h=a.eql(a.sqr(l),c),m=a.eql(a.sqr(f),c);u=a.cmov(u,l,h),l=a.cmov(d,f,m);const y=a.eql(a.sqr(l),c),p=a.cmov(u,l,y);return Gi(a,p,c),p}}function wf(t){if(t1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return bf;let o=s.pow(r,e);const i=(e+$e)/sn;return function(c,u){if(c.is0(u))return u;if(Na(c,u)!==1)throw new Error("Cannot find square root");let l=n,f=c.mul(c.ONE,o),d=c.pow(u,e),h=c.pow(u,i);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let m=1,y=c.sqr(d);for(;!c.eql(y,c.ONE);)if(m++,y=c.sqr(y),m===l)throw new Error("Cannot find square root");const p=$e<(ge(t,e)&$e)===$e,Tb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cb(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Tb.reduce((r,s)=>(r[s]="function",r),e);return Jn(t,n),t}function Ib(t,e,n){if(nje;)n&$e&&(r=t.mul(r,s)),s=t.sqr(s),n>>=$e;return r}function xf(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((i,a,c)=>t.is0(a)?i:(r[c]=i,t.mul(i,a)),t.ONE),o=t.inv(s);return e.reduceRight((i,a,c)=>t.is0(a)?i:(r[c]=t.mul(i,r[c]),t.mul(i,a)),o),r}function Na(t,e){const n=(t.ORDER-$e)/sn,r=t.pow(e,n),s=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),i=t.eql(r,t.neg(t.ONE));if(!s&&!o&&!i)throw new Error("invalid Legendre symbol result");return s?1:o?0:-1}function vf(t,e){e!==void 0&&Vt(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Sn(t,e,n=!1,r={}){if(t<=je)throw new Error("invalid field: expected ORDER > 0, got "+t);let s,o,i=!1,a;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=e;d.BITS&&(s=d.BITS),d.sqrt&&(o=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(i=d.modFromBytes),a=d.allowedLengths}else typeof e=="number"&&(s=e),r.sqrt&&(o=r.sqrt);const{nBitLength:c,nByteLength:u}=vf(t,s);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const f=Object.freeze({ORDER:t,isLE:n,BITS:c,BYTES:u,MASK:Cr(c),ZERO:je,ONE:$e,allowedLengths:a,create:d=>ge(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return je<=d&&dd===je,isValidNot0:d=>!f.is0(d)&&f.isValid(d),isOdd:d=>(d&$e)===$e,neg:d=>ge(-d,t),eql:(d,h)=>d===h,sqr:d=>ge(d*d,t),add:(d,h)=>ge(d+h,t),sub:(d,h)=>ge(d-h,t),mul:(d,h)=>ge(d*h,t),pow:(d,h)=>Ib(f,d,h),div:(d,h)=>ge(d*Pa(h,t),t),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>Pa(d,t),sqrt:o||(d=>(l||(l=$b(t)),l(f,d))),toBytes:d=>n?Fi(d,u):Fs(d,u),fromBytes:(d,h=!0)=>{if(a){if(!a.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);const y=new Uint8Array(u);y.set(d,n?0:y.length-d.length),d=y}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let m=n?mn(d):Xn(d);if(i&&(m=ge(m,t)),!h&&!f.isValid(m))throw new Error("invalid field element: outside of range 0..ORDER");return m},invertBatch:d=>xf(f,d),cmov:(d,h,m)=>m?h:d});return Object.freeze(f)}function Ef(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Sf(t){const e=Ef(t);return e+Math.ceil(e/2)}function _f(t,e,n=!1){const r=t.length,s=Ef(e),o=Sf(e);if(r<16||r1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const i=n?mn(t):Xn(t),a=ge(i,e-$e)+$e;return n?Fi(a,s):Fs(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qn=BigInt(0),on=BigInt(1);function Bs(t,e){const n=e.negate();return t?n:e}function an(t,e){const n=xf(t.Fp,e.map(r=>r.Z));return e.map((r,s)=>t.fromAffine(r.toAffine(n[s])))}function kf(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function yo(t,e){kf(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,o=Cr(t),i=BigInt(t);return{windows:n,windowSize:r,mask:o,maxNumber:s,shiftBy:i}}function La(t,e,n){const{windowSize:r,mask:s,maxNumber:o,shiftBy:i}=n;let a=Number(t&s),c=t>>i;a>r&&(a-=o,c+=on);const u=e*r,l=u+Math.abs(a)-1,f=a===0,d=a<0,h=e%2!==0;return{nextN:c,offset:l,isZero:f,isNeg:d,isNegF:h,offsetF:u}}function Ub(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function Pb(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const bo=new WeakMap,Af=new WeakMap;function wo(t){return Af.get(t)||1}function Ra(t){if(t!==qn)throw new Error("invalid wNAF")}class Bf{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let s=e;for(;n>qn;)n&on&&(r=r.add(s)),s=s.double(),n>>=on;return r}precomputeWindow(e,n){const{windows:r,windowSize:s}=yo(n,this.bits),o=[];let i=e,a=i;for(let c=0;cqn||r>qn;)n&on&&(o=o.add(s)),r&on&&(i=i.add(s)),s=s.double(),n>>=on,r>>=on;return{p1:o,p2:i}}function $f(t,e,n,r){Ub(n,t),Pb(r,e);const s=n.length,o=r.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,a=lf(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Cr(c),l=new Array(Number(u)+1).fill(i),f=Math.floor((e.BITS-1)/c)*c;let d=i;for(let h=f;h>=0;h-=c){l.fill(i);for(let y=0;y>BigInt(h)&u);l[g]=l[g].add(n[y])}let m=i;for(let y=l.length-1,p=i;y>0;y--)p=p.add(l[y]),m=m.add(p);if(d=d.add(m),h!==0)for(let y=0;yqn))throw new Error(`CURVE.${c} must be positive bigint`)}const s=Ha(e.p,n.Fp,r),o=Ha(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(const c of a)if(!s.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:s,Fn:o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ja=(t,e)=>(t+(t>=0?e:-e)/Tf)/e;function Lb(t,e,n){const[[r,s],[o,i]]=e,a=ja(i*t,n),c=ja(-s*t,n);let u=t-a*r-c*o,l=-a*s-c*i;const f=u=h||l=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:f,k1:u,k2neg:d,k2:l}}function ni(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function xo(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return gn(n.lowS,"lowS"),gn(n.prehash,"prehash"),n.format!==void 0&&ni(n.format),n}class Rb extends Error{constructor(e=""){super(e)}}const yt={Err:Rb,_tlv:{encode:(t,e)=>{const{Err:n}=yt;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=Mr(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?Mr(s.length/2|128):"";return Mr(t)+o+s+e},decode(t,e){const{Err:n}=yt;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],o=!!(s&128);let i=0;if(!o)i=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of u)i=i<<8|l;if(r+=c,i<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+i)}}},_int:{encode(t){const{Err:e}=yt;if(t{const{X:E,Y:b,Z:S}=D;if(r.eql(S,r.ONE))return{x:E,y:b};const B=D.is0();v==null&&(v=B?r.ONE:r.inv(S));const N=r.mul(E,v),T=r.mul(b,v),H=r.mul(S,v);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(H,r.ONE))throw new Error("invZ was invalid");return{x:N,y:T}}),P=As(D=>{if(D.is0()){if(e.allowInfinityPoint&&!r.is0(D.Y))return;throw new Error("bad point: ZERO")}const{x:v,y:E}=D.toAffine();if(!r.isValid(v)||!r.isValid(E))throw new Error("bad point: x or y not field elements");if(!p(v,E))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function I(D,v,E,b,S){return E=new k(r.mul(E.X,D),E.Y,E.Z),v=Bs(b,v),E=Bs(S,E),v.add(E)}class k{constructor(v,E,b){this.X=w("x",v),this.Y=w("y",E,!0),this.Z=w("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(v){const{x:E,y:b}=v||{};if(!v||!r.isValid(E)||!r.isValid(b))throw new Error("invalid affine point");if(v instanceof k)throw new Error("projective point not allowed");return r.is0(E)&&r.is0(b)?k.ZERO:new k(E,b,r.ONE)}static fromBytes(v){const E=k.fromAffine(m(We(v,void 0,"point")));return E.assertValidity(),E}static fromHex(v){return k.fromBytes(ue("pointHex",v))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,E=!0){return R.createCache(this,v),E||this.multiply(qr),this}assertValidity(){P(this)}hasEvenY(){const{y:v}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(v)}equals(v){$(v);const{X:E,Y:b,Z:S}=this,{X:B,Y:N,Z:T}=v,H=r.eql(r.mul(E,T),r.mul(B,S)),Z=r.eql(r.mul(b,T),r.mul(N,S));return H&&Z}negate(){return new k(this.X,r.neg(this.Y),this.Z)}double(){const{a:v,b:E}=o,b=r.mul(E,qr),{X:S,Y:B,Z:N}=this;let T=r.ZERO,H=r.ZERO,Z=r.ZERO,M=r.mul(S,S),re=r.mul(B,B),ne=r.mul(N,N),W=r.mul(S,B);return W=r.add(W,W),Z=r.mul(S,N),Z=r.add(Z,Z),T=r.mul(v,Z),H=r.mul(b,ne),H=r.add(T,H),T=r.sub(re,H),H=r.add(re,H),H=r.mul(T,H),T=r.mul(W,T),Z=r.mul(b,Z),ne=r.mul(v,ne),W=r.sub(M,ne),W=r.mul(v,W),W=r.add(W,Z),Z=r.add(M,M),M=r.add(Z,M),M=r.add(M,ne),M=r.mul(M,W),H=r.add(H,M),ne=r.mul(B,N),ne=r.add(ne,ne),M=r.mul(ne,W),T=r.sub(T,M),Z=r.mul(ne,re),Z=r.add(Z,Z),Z=r.add(Z,Z),new k(T,H,Z)}add(v){$(v);const{X:E,Y:b,Z:S}=this,{X:B,Y:N,Z:T}=v;let H=r.ZERO,Z=r.ZERO,M=r.ZERO;const re=o.a,ne=r.mul(o.b,qr);let W=r.mul(E,B),oe=r.mul(b,N),ie=r.mul(S,T),xe=r.add(E,b),se=r.add(B,N);xe=r.mul(xe,se),se=r.add(W,oe),xe=r.sub(xe,se),se=r.add(E,S);let he=r.add(B,T);return se=r.mul(se,he),he=r.add(W,ie),se=r.sub(se,he),he=r.add(b,S),H=r.add(N,T),he=r.mul(he,H),H=r.add(oe,ie),he=r.sub(he,H),M=r.mul(re,se),H=r.mul(ne,ie),M=r.add(H,M),H=r.sub(oe,M),M=r.add(oe,M),Z=r.mul(H,M),oe=r.add(W,W),oe=r.add(oe,W),ie=r.mul(re,ie),se=r.mul(ne,se),oe=r.add(oe,ie),ie=r.sub(W,ie),ie=r.mul(re,ie),se=r.add(se,ie),W=r.mul(oe,se),Z=r.add(Z,W),W=r.mul(he,se),H=r.mul(xe,H),H=r.sub(H,W),W=r.mul(xe,oe),M=r.mul(he,M),M=r.add(M,W),new k(H,Z,M)}subtract(v){return this.add(v.negate())}is0(){return this.equals(k.ZERO)}multiply(v){const{endo:E}=e;if(!s.isValidNot0(v))throw new Error("invalid scalar: out of range");let b,S;const B=N=>R.cached(this,N,T=>an(k,T));if(E){const{k1neg:N,k1:T,k2neg:H,k2:Z}=A(v),{p:M,f:re}=B(T),{p:ne,f:W}=B(Z);S=re.add(W),b=I(E.beta,M,ne,N,H)}else{const{p:N,f:T}=B(v);b=N,S=T}return an(k,[b,S])[0]}multiplyUnsafe(v){const{endo:E}=e,b=this;if(!s.isValid(v))throw new Error("invalid scalar: out of range");if(v===bt||b.is0())return k.ZERO;if(v===Pn)return b;if(R.hasCache(this))return this.multiply(v);if(E){const{k1neg:S,k1:B,k2neg:N,k2:T}=A(v),{p1:H,p2:Z}=Nb(k,b,B,T);return I(E.beta,H,Z,S,N)}else return R.unsafe(b,v)}multiplyAndAddUnsafe(v,E,b){const S=this.multiplyUnsafe(E).add(v.multiplyUnsafe(b));return S.is0()?void 0:S}toAffine(v){return O(this,v)}isTorsionFree(){const{isTorsionFree:v}=e;return i===Pn?!0:v?v(k,this):R.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:v}=e;return i===Pn?this:v?v(k,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(v=!0){return gn(v,"isCompressed"),this.assertValidity(),h(k,this,v)}toHex(v=!0){return Ze(this.toBytes(v))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(v=!0){return this.toBytes(v)}_setWindowSize(v){this.precompute(v)}static normalizeZ(v){return an(k,v)}static msm(v,E){return $f(k,s,v,E)}static fromPrivateKey(v){return k.BASE.multiply(cn(s,v))}}k.BASE=new k(o.Gx,o.Gy,r.ONE),k.ZERO=new k(r.ZERO,r.ONE,r.ZERO),k.Fp=r,k.Fn=s;const U=s.BITS,R=new Bf(k,e.endo?Math.ceil(U/2):U);return k.BASE.precompute(8),k}function Cf(t){return Uint8Array.of(t?2:3)}function If(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Db(t,e={}){const{Fn:n}=t,r=e.randomBytes||En,s=Object.assign(If(t.Fp,n),{seed:Sf(n.ORDER)});function o(h){try{return!!cn(n,h)}catch{return!1}}function i(h,m){const{publicKey:y,publicKeyUncompressed:p}=s;try{const g=h.length;return m===!0&&g!==y||m===!1&&g!==p?!1:!!t.fromBytes(h)}catch{return!1}}function a(h=r(s.seed)){return _f(We(h,s.seed,"seed"),n.ORDER)}function c(h,m=!0){return t.BASE.multiply(cn(n,h)).toBytes(m)}function u(h){const m=a(h);return{secretKey:m,publicKey:c(m)}}function l(h){if(typeof h=="bigint")return!1;if(h instanceof t)return!0;const{secretKey:m,publicKey:y,publicKeyUncompressed:p}=s;if(n.allowedLengths||m===y)return;const g=ue("key",h).length;return g===y||g===p}function f(h,m,y=!0){if(l(h)===!0)throw new Error("first arg must be private key");if(l(m)===!1)throw new Error("second arg must be public key");const p=cn(n,h);return t.fromHex(m).multiply(p).toBytes(y)}return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:u,Point:t,utils:{isValidSecretKey:o,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:h=>cn(n,h),precompute(h=8,m=t.BASE){return m.precompute(h,!1)}},lengths:s})}function Zb(t,e,n={}){Tr(e),Jn(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||En,s=n.hmac||((E,...b)=>Yt(e,E,ke(...b))),{Fp:o,Fn:i}=t,{ORDER:a,BITS:c}=i,{keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h}=Db(t,n),m={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},y="compact";function p(E){const b=a>>Pn;return E>b}function g(E,b){if(!i.isValidNot0(b))throw new Error(`invalid signature ${E}: out of range 1..Point.Fn.ORDER`);return b}function x(E,b){ni(b);const S=h.signature,B=b==="compact"?S:b==="recovered"?S+1:void 0;return We(E,B,`${b} signature`)}class w{constructor(b,S,B){this.r=g("r",b),this.s=g("s",S),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(b,S=y){x(b,S);let B;if(S==="der"){const{r:Z,s:M}=yt.toSig(We(b));return new w(Z,M)}S==="recovered"&&(B=b[0],S="compact",b=b.subarray(1));const N=i.BYTES,T=b.subarray(0,N),H=b.subarray(N,N*2);return new w(i.fromBytes(T),i.fromBytes(H),B)}static fromHex(b,S){return this.fromBytes(Mn(b),S)}addRecoveryBit(b){return new w(this.r,this.s,b)}recoverPublicKey(b){const S=o.ORDER,{r:B,s:N,recovery:T}=this;if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");if(a*Tf1)throw new Error("recovery id is ambiguous for h>1 curve");const Z=T===2||T===3?B+a:B;if(!o.isValid(Z))throw new Error("recovery id 2 or 3 invalid");const M=o.toBytes(Z),re=t.fromBytes(ke(Cf((T&1)===0),M)),ne=i.inv(Z),W=A(ue("msgHash",b)),oe=i.create(-W*ne),ie=i.create(N*ne),xe=t.BASE.multiplyUnsafe(oe).add(re.multiplyUnsafe(ie));if(xe.is0())throw new Error("point at infinify");return xe.assertValidity(),xe}hasHighS(){return p(this.s)}toBytes(b=y){if(ni(b),b==="der")return Mn(yt.hexFromSig(this));const S=i.toBytes(this.r),B=i.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return ke(Uint8Array.of(this.recovery),S,B)}return ke(S,B)}toHex(b){return Ze(this.toBytes(b))}assertValidity(){}static fromCompact(b){return w.fromBytes(ue("sig",b),"compact")}static fromDER(b){return w.fromBytes(ue("sig",b),"der")}normalizeS(){return this.hasHighS()?new w(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Ze(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Ze(this.toBytes("compact"))}}const $=n.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const S=Xn(b),B=b.length*8-c;return B>0?S>>BigInt(B):S},A=n.bits2int_modN||function(b){return i.create($(b))},O=Cr(c);function P(E){return _r("num < 2^"+c,E,bt,O),i.toBytes(E)}function I(E,b){return We(E,void 0,"message"),b?We(e(E),void 0,"prehashed message"):E}function k(E,b,S){if(["recovered","canonical"].some(oe=>oe in S))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:N,extraEntropy:T}=xo(S,m);E=I(E,N);const H=A(E),Z=cn(i,b),M=[P(Z),P(H)];if(T!=null&&T!==!1){const oe=T===!0?r(h.secretKey):T;M.push(ue("extraEntropy",oe))}const re=ke(...M),ne=H;function W(oe){const ie=$(oe);if(!i.isValidNot0(ie))return;const xe=i.inv(ie),se=t.BASE.multiply(ie).toAffine(),he=i.create(se.x);if(he===bt)return;const lt=i.create(xe*i.create(ne+he*Z));if(lt===bt)return;let Ke=(se.x===he?0:2)|Number(se.y&Pn),Be=lt;return B&&p(lt)&&(Be=i.neg(lt),Ke^=1),new w(he,Be,Ke)}return{seed:re,k2sig:W}}function U(E,b,S={}){E=ue("message",E);const{seed:B,k2sig:N}=k(E,b,S);return Sb(e.outputLen,i.BYTES,s)(B,N)}function R(E){let b;const S=typeof E=="string"||Or(E),B=!S&&E!==null&&typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!S&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)b=new w(E.r,E.s);else if(S){try{b=w.fromBytes(ue("sig",E),"der")}catch(N){if(!(N instanceof yt.Err))throw N}if(!b)try{b=w.fromBytes(ue("sig",E),"compact")}catch{return!1}}return b||!1}function D(E,b,S,B={}){const{lowS:N,prehash:T,format:H}=xo(B,m);if(S=ue("publicKey",S),b=I(ue("message",b),T),"strict"in B)throw new Error("options.strict was renamed to lowS");const Z=H===void 0?R(E):w.fromBytes(ue("sig",E),H);if(Z===!1)return!1;try{const M=t.fromBytes(S);if(N&&Z.hasHighS())return!1;const{r:re,s:ne}=Z,W=A(b),oe=i.inv(ne),ie=i.create(W*oe),xe=i.create(re*oe),se=t.BASE.multiplyUnsafe(ie).add(M.multiplyUnsafe(xe));return se.is0()?!1:i.create(se.x)===re}catch{return!1}}function v(E,b,S={}){const{prehash:B}=xo(S,m);return b=I(b,B),w.fromBytes(E,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h,Point:t,sign:U,verify:D,recoverPublicKey:v,Signature:w,hash:e})}function Kb(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp;let r=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const s=Sn(e.n,{BITS:t.nBitLength,allowedLengths:r,modFromBytes:t.wrapPrivateKey}),o={Fp:n,Fn:s,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:o}}function Vb(t){const{CURVE:e,curveOpts:n}=Kb(t),r={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:n,hash:t.hash,ecdsaOpts:r}}function Mb(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,vf(n.Fn.ORDER,n.Fn.BITS))})}function qb(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:s}=Vb(t),o=jb(e,n),i=Zb(o,r,s);return Mb(t,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zb(t,e){const n=r=>qb({...t,hash:r});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Fb={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Gb=BigInt(0),Da=BigInt(1),ri=BigInt(2);function Yb(t){const e=zn.p,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,l=u*u*t%e,f=ye(l,n,e)*l%e,d=ye(f,n,e)*l%e,h=ye(d,ri,e)*u%e,m=ye(h,s,e)*h%e,y=ye(m,o,e)*m%e,p=ye(y,a,e)*y%e,g=ye(p,c,e)*p%e,x=ye(g,a,e)*y%e,w=ye(x,n,e)*l%e,$=ye(w,i,e)*m%e,A=ye($,r,e)*u%e,O=ye(A,ri,e);if(!$s.eql($s.sqr(O),t))throw new Error("Cannot find square root");return O}const $s=Sn(zn.p,{sqrt:Yb}),De=zb({...zn,Fp:$s,lowS:!0,endo:Fb},Et),Za={};function Os(t,...e){let n=Za[t];if(n===void 0){const r=Et(Xt(t));n=ke(r,r),Za[t]=n}return Et(ke(n,...e))}const Yi=t=>t.toBytes(!0).slice(1),Qn=De.Point,Wi=t=>t%ri===Gb;function si(t){const{Fn:e,BASE:n}=Qn,r=cn(e,t),s=n.multiply(r);return{scalar:Wi(s.y)?r:e.neg(r),bytes:Yi(s)}}function Uf(t){const e=$s;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const n=e.create(t*t),r=e.create(n*t+BigInt(7));let s=e.sqrt(r);Wi(s)||(s=e.neg(s));const o=Qn.fromAffine({x:t,y:s});return o.assertValidity(),o}const ar=Xn;function Pf(...t){return Qn.Fn.create(ar(Os("BIP0340/challenge",...t)))}function Ka(t){return si(t).bytes}function Wb(t,e,n=En(32)){const{Fn:r}=Qn,s=ue("message",t),{bytes:o,scalar:i}=si(e),a=ue("auxRand",n,32),c=r.toBytes(i^ar(Os("BIP0340/aux",a))),u=Os("BIP0340/nonce",c,o,s),{bytes:l,scalar:f}=si(u),d=Pf(l,o,s),h=new Uint8Array(64);if(h.set(l,0),h.set(r.toBytes(r.create(f+d*i)),32),!Nf(h,s,o))throw new Error("sign: Invalid signature produced");return h}function Nf(t,e,n){const{Fn:r,BASE:s}=Qn,o=ue("signature",t,64),i=ue("message",e),a=ue("publicKey",n,32);try{const c=Uf(ar(a)),u=ar(o.subarray(0,32));if(!ei(u,Da,zn.p))return!1;const l=ar(o.subarray(32,64));if(!ei(l,Da,zn.n))return!1;const f=Pf(r.toBytes(u),Yi(c),i),d=s.multiplyUnsafe(l).add(c.multiplyUnsafe(r.neg(f))),{x:h,y:m}=d.toAffine();return!(d.is0()||!Wi(m)||h!==u)}catch{return!1}}const Lf=(()=>{const n=(s=En(48))=>_f(s,zn.n);De.utils.randomSecretKey;function r(s){const o=n(s);return{secretKey:o,publicKey:Ka(o)}}return{keygen:r,getPublicKey:Ka,sign:Wb,verify:Nf,Point:Qn,utils:{randomSecretKey:n,randomPrivateKey:n,taggedHash:Os,lift_x:Uf,pointToBytes:Yi,numberToBytesBE:Fs,bytesToNumberBE:Xn,mod:ge},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),Zt="super-testnet-local-v0";class Wt{constructor(e){if(!/^[0-9a-f]{64}$/.test(e)||!De.utils.isValidPrivateKey(e))throw new Error("Invalid test wallet key. Load a Super Testnet v0 backup.");this.kind="test-wallet",this.secret=e,this.pubkey=ti(Lf.getPublicKey(e)),this.address=um.p2tr.fromPubKey(this.pubkey,"regtest"),this.script=["OP_1",this.pubkey]}static create(){return new Wt(ti(De.utils.randomPrivateKey()))}static load(e){if((e==null?void 0:e.network)!==Zt||(e==null?void 0:e.version)!==1||(e==null?void 0:e.kind)!=="test-wallet")throw new Error("Only Super Testnet v0 test-wallet backups are accepted.");return new Wt(e.secret)}backup(){return{kind:"test-wallet",version:1,network:Zt,secret:this.secret}}sign(e,n,r=0){return Ku.taproot.sign(this.secret,e,r,n?{extension:n}:{}).hex}}const vo=50*1e8,zr="0".repeat(64),Va=t=>ti(Et(new TextEncoder().encode(JSON.stringify(t)))),Fr=(t,e)=>`${t}:${e}`,Me=t=>Se.encode(t,!1).hex,ce=(t,e)=>{if(!t)throw new Error(e)};class Gs{constructor(e){if(this.blocks=[],this.mempool=[],this.utxos=new Map,this.transactions=new Map,e){ce(e.network===Zt&&e.version===1,"Unsupported local chain version/network."),ce(Array.isArray(e.blocks)&&Array.isArray(e.mempool),"Invalid chain snapshot.");for(const n of e.blocks)this.acceptBlock(structuredClone(n));this.submitPackage(e.mempool)}}snapshot(){return{network:Zt,version:1,blocks:structuredClone(this.blocks),mempool:[...this.mempool]}}coins(e){return[...this.utxos.values()].filter(n=>Me(n.scriptPubKey)===Me(e))}satLocation(e){for(const n of this.utxos.values()){const r=es(n.ranges,e);if(r!==null)return{txid:n.txid,vout:n.vout,offset:r}}return null}balance(e){return this.coins(e).reduce((n,r)=>n+r.value,0)}apply(e,n,r=!1){var h,m,y;ce(typeof e=="string"&&e.length<4e4&&/^(?:[a-f0-9]{2})+$/.test(e),"Invalid raw transaction.");const s=le.decode(e),o=le.util.getTxid(s);ce(!this.transactions.has(o),"Duplicate transaction."),ce(s.version===2&&s.locktime===0,"Unsupported transaction version or locktime."),ce((s.vin.length===1||!r&&s.vin.length===2)&&s.vout.length>=1&&s.vout.length<=2,"Unsupported transaction shape.");let i=0;for(const p of s.vout){const g=Number(p.value);ce(Number.isSafeInteger(g)&&g>=330&&g<=vo,"Invalid output amount."),ce(/^5120[0-9a-f]{64}$/.test(Me(p.scriptPubKey)),"Only Taproot outputs are supported."),i+=g}let a,c=[];const u=s.vin.findIndex(p=>{var g;return((g=p.witness)==null?void 0:g.length)===3}),l=s.vin[u<0?0:u];if(r)ce(l.txid===zr&&l.vout===4294967295&&s.vout.length===1&&i===vo,"Invalid local coinbase."),ce(Me(l.scriptSig)===Se.encode([new TextEncoder().encode(`${Zt}:${n}`)],!1).hex,"Wrong coinbase height."),ce(!((h=l.witness)!=null&&h.length),"Unexpected coinbase witness.");else{c=s.vin.map(g=>this.utxos.get(Fr(g.txid,g.vout))),ce(c.every(Boolean),"Input is missing or already spent."),ce(new Set(s.vin.map(g=>Fr(g.txid,g.vout))).size===s.vin.length,"Duplicate input."),s.vin.forEach((g,x)=>{var w,$;ce(g.sequence==="ffffffff"&&Me(g.scriptSig)==="","Unsupported input flags."),g.prevout={value:c[x].value,scriptPubKey:c[x].scriptPubKey},ce(((w=g.witness)==null?void 0:w.length)===1||x===u&&(($=g.witness)==null?void 0:$.length)===3,"Unsupported witness."),ce(/^[0-9a-f]{128}$/.test(g.witness[0]),"Only default 64-byte Schnorr signatures are accepted.")}),ce(c.reduce((g,x)=>g+x.value,0)-i===Ie,"v0 requires a fixed 500 sat fee per transaction.");let p={};if(l.witness.length===3){const g=Di(l.witness),x=u;if(ce(Number(s.vout[x].value)===mt,"Invalid reveal postage."),ce(Me(s.vout[x].scriptPubKey)===`5120${g.pubkey}`,"Reveal must return to its signing wallet."),g.parent){const w=u===0?1:0,$=c[w];ce((m=$==null?void 0:$.inscriptions)==null?void 0:m.some(A=>A.id===g.parent),"Referenced parent inscription must actually be spent."),ce(s.vout.length===2&&Number(s.vout[w].value)===$.value&&Me($.scriptPubKey)===`5120${g.pubkey}`&&Me(s.vout[w].scriptPubKey)===Me($.scriptPubKey),"Parent must be owned and preserved in the same wallet.")}else s.vin.length===2&&(ce(u===1&&((y=c[0].inscriptions)==null?void 0:y.length)&&g.pointer!==void 0,"Reinscription spend requires correct tag and owned sat."),ce(Number(s.vout[0].value)===c[0].value&&Me(s.vout[0].scriptPubKey)===Me(c[0].scriptPubKey)&&Me(c[0].scriptPubKey)===`5120${g.pubkey}`,"Reinscription sat must be returned to owner."));p={pubkey:g.pubkey},a={id:`${o}i0`,txid:o,commitTxid:l.txid,text:g.text,bytes:Array.from(g.bytes),contentType:g.contentType,parent:g.parent,delegate:g.delegate,pointer:g.pointer,metaprotocol:g.metaprotocol,metadata:g.metadata,height:n,value:mt}}s.vin.forEach((g,x)=>{let w=!1;try{w=Ku.taproot.verify(s,x,x===u?p:{})}catch{}ce(w,"Invalid signature or Taproot commitment.")})}const f=fc(s,c,n,r),d=c.flatMap(p=>p.inscriptions??[]);if(a){const p=BigInt(a.pointer??0),g=p{var w;return((w=x.inscription)==null?void 0:w.sat)===a.sat}).length,d.push(a)}return ce(d.every(p=>f.some(g=>es(g,p.sat)!==null)),"Local lab protects inscription sats from fee loss."),r||s.vin.forEach(p=>this.utxos.delete(Fr(p.txid,p.vout))),s.vout.forEach((p,g)=>{const x=d.filter(w=>es(f[g],w.sat)!==null);this.utxos.set(Fr(o,g),{txid:o,vout:g,value:Number(p.value),scriptPubKey:p.scriptPubKey,height:n,ranges:f[g],inscriptions:x,...x.length?{inscription:x[0]}:{}})}),this.transactions.set(o,{txid:o,raw:e,height:n,coinbase:r,tx:s,...a?{inscription:a}:{}}),o}submitPackage(e){ce(Array.isArray(e)&&this.mempool.length+e.length<=1e3,"Invalid package or mempool full; mine a block first.");const n=new Map(this.utxos),r=new Map(this.transactions);try{e.forEach(s=>this.apply(s,null))}catch(s){throw this.utxos=n,this.transactions=r,s}this.mempool.push(...e)}acceptBlock(e){var i;ce(e.height===this.blocks.length+1&&e.previous===(((i=this.blocks.at(-1))==null?void 0:i.hash)??zr),"Invalid block ancestry."),ce(Number.isSafeInteger(e.time)&&e.time>0&&Array.isArray(e.raws)&&e.raws.length>0&&e.raws.length<=1001,"Invalid block.");const{hash:n,...r}=e;ce(Va(r)===n,"Invalid local block hash.");const s=new Map(this.utxos),o=new Map(this.transactions);try{e.raws.forEach((a,c)=>this.apply(a,e.height,c===0))}catch(a){throw this.utxos=s,this.transactions=o,a}this.blocks.push(e)}mine(e){var a;const n=new Gs({...this.snapshot(),mempool:[]}),r=this.blocks.length+1,s=le.create({vin:[{txid:zr,vout:4294967295,scriptSig:[new TextEncoder().encode(`${Zt}:${r}`)]}],vout:[Ye(vo,e)]}),o={height:r,previous:((a=this.blocks.at(-1))==null?void 0:a.hash)??zr,time:Date.now(),raws:[le.encode(s).hex,...this.mempool]},i={...o,hash:Va(o)};return n.acceptBlock(i),Object.assign(this,n),i}}const Xb=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Rf=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),Jb=Rf.map(t=>(9*t+5)%16),Hf=(()=>{const n=[[Rf],[Jb]];for(let r=0;r<4;r++)for(let s of n)s.push(s[r].map(o=>Xb[o]));return n})(),jf=Hf[0],Df=Hf[1],Zf=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Qb=jf.map((t,e)=>t.map(n=>Zf[e][n])),ew=Df.map((t,e)=>t.map(n=>Zf[e][n])),tw=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),nw=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Ma(t,e,n,r){return t===0?e^n^r:t===1?e&n|~e&r:t===2?(e|~n)^r:t===3?e&r|n&~r:e^(n|~r)}const Gr=new Uint32Array(16);class rw extends qi{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:r,h3:s,h4:o}=this;return[e,n,r,s,o]}set(e,n,r,s,o){this.h0=e|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=o|0}process(e,n){for(let h=0;h<16;h++,n+=4)Gr[h]=e.getUint32(n,!0);let r=this.h0|0,s=r,o=this.h1|0,i=o,a=this.h2|0,c=a,u=this.h3|0,l=u,f=this.h4|0,d=f;for(let h=0;h<5;h++){const m=4-h,y=tw[h],p=nw[h],g=jf[h],x=Df[h],w=Qb[h],$=ew[h];for(let A=0;A<16;A++){const O=Dr(r+Ma(h,o,a,u)+Gr[g[A]]+y,w[A])+f|0;r=f,f=u,u=Dr(a,10)|0,a=o,o=O}for(let A=0;A<16;A++){const O=Dr(s+Ma(m,i,c,l)+Gr[x[A]]+p,$[A])+d|0;s=d,d=l,l=Dr(c,10)|0,c=i,i=O}}this.set(this.h1+a+l|0,this.h2+u+d|0,this.h3+f+s|0,this.h4+r+i|0,this.h0+o+c|0)}roundClean(){ft(Gr)}destroy(){this.destroyed=!0,ft(this.buffer),this.set(0,0,0,0,0)}}const sw=Mi(()=>new rw);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ow(t,...e){if(!Fn(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Kf(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function Vf(t){if(typeof t!="function")throw new Error("function expected");return!0}function yn(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function er(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Ts(t){if(!Array.isArray(t))throw new Error("array expected")}function Cs(t,e){if(!Kf(!0,e))throw new Error(`${t}: array of strings expected`)}function Xi(t,e){if(!Kf(!1,e))throw new Error(`${t}: array of numbers expected`)}function Ir(...t){const e=o=>o,n=(o,i)=>a=>o(i(a)),r=t.map(o=>o.encode).reduceRight(n,e),s=t.map(o=>o.decode).reduce(n,e);return{encode:r,decode:s}}function Ys(t){const e=typeof t=="string"?t.split(""):t,n=e.length;Cs("alphabet",e);const r=new Map(e.map((s,o)=>[s,o]));return{encode:s=>(Ts(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${t}`);return e[o]})),decode:s=>(Ts(s),s.map(o=>{yn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${t}`);return i}))}}function Ws(t=""){return yn("join",t),{encode:e=>(Cs("join.decode",e),e.join(t)),decode:e=>(yn("join.decode",e),e.split(t))}}function Mf(t,e="="){return er(t),yn("padding",e),{encode(n){for(Cs("padding.encode",n);n.length*t%8;)n.push(e);return n},decode(n){Cs("padding.decode",n);let r=n.length;if(r*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if((r-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function oi(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Ts(t),!t.length)return[];let r=0;const s=[],o=Array.from(t,a=>{if(er(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,c=!0;for(let u=r;ue===0?t:qf(e,t%e),Is=(t,e)=>t+(e-qf(t,e)),ss=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Us(t,e,n,r){if(Ts(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Is(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Is(e,n)}`);let s=0,o=0;const i=ss[e],a=ss[n]-1,c=[];for(const u of t){if(er(u),u>=i)throw new Error(`convertRadix2: invalid data word=${u} from=${e}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)c.push((s>>o-n&a)>>>0);const l=ss[o];if(l===void 0)throw new Error("invalid carry");s&=l-1}if(s=s<=e)throw new Error("Excess padding");if(!r&&s>0)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&c.push(s>>>0),c}function zf(t){er(t);const e=2**8;return{encode:n=>{if(!Fn(n))throw new Error("radix.encode input should be Uint8Array");return oi(Array.from(n),e,t)},decode:n=>(Xi("radix.decode",n),Uint8Array.from(oi(n,t,e)))}}function Ji(t,e=!1){if(er(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Is(8,t)>32||Is(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Fn(n))throw new Error("radix2.encode input should be Uint8Array");return Us(Array.from(n),8,t,!e)},decode:n=>(Xi("radix2.decode",n),Uint8Array.from(Us(n,t,8,e)))}}function qa(t){return Vf(t),function(...e){try{return t.apply(null,e)}catch{}}}function Ff(t,e){return er(t),Vf(e),{encode(n){if(!Fn(n))throw new Error("checksum.encode: input should be Uint8Array");const r=e(n).slice(0,t),s=new Uint8Array(n.length+t);return s.set(n),s.set(r,n.length),s},decode(n){if(!Fn(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-t),s=n.slice(-t),o=e(r).slice(0,t);for(let i=0;i{yn("base64",t);const n=/^[A-Za-z0-9=+/]+$/,r="base64";if(t.length>0&&!n.test(t))throw new Error("invalid base64");return Uint8Array.fromBase64(t,{alphabet:r,lastChunkHandling:"strict"})},Nn=iw?{encode(t){return ow(t),t.toBase64()},decode(t){return aw(t)}}:Ir(Ji(6),Ys("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Mf(6),Ws("")),cw=t=>Ir(zf(58),Ys(t),Ws("")),uw=cw("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),fw=t=>Ir(Ff(4,e=>t(t(e))),uw),ii=Ir(Ys("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ws("")),za=[996825010,642813549,513874426,1027748829,705979059];function sr(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r>r&1)===1&&(n^=za[r]);return n}function Fa(t,e,n=1){const r=t.length;let s=1;for(let o=0;o126)throw new Error(`Invalid prefix (${t})`);s=sr(s)^i>>5}s=sr(s);for(let o=0;oh)throw new TypeError(`Length ${y} exceeds limit ${h}`);const p=f.toLowerCase(),g=Fa(p,d,e);return`${p}1${ii.encode(d)}${g}`}function a(f,d=90){yn("bech32.decode input",f);const h=f.length;if(h<8||d!==!1&&h>d)throw new TypeError(`invalid string length: ${h} (${f}). Expected (8..${d})`);const m=f.toLowerCase();if(f!==m&&f!==f.toUpperCase())throw new Error("String must be lowercase or uppercase");const y=m.lastIndexOf("1");if(y===0||y===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=m.slice(0,y),g=m.slice(y+1);if(g.length<6)throw new Error("Data must be at least 6 characters long");const x=ii.decode(g).slice(0,-6),w=Fa(p,x,e);if(!g.endsWith(w))throw new Error(`Invalid checksum in ${f}: expected "${w}"`);return{prefix:p,words:x}}const c=qa(a);function u(f){const{prefix:d,words:h}=a(f,!1);return{prefix:d,words:h,bytes:r(h)}}function l(f,d){return i(f,s(d))}return{encode:i,decode:a,encodeFromBytes:l,decodeToBytes:u,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:s}}const Ga=lw("bech32");/*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const Wr=De.ProjectivePoint,Eo=fw(Et);function Ya(t){Ue(t);const e=t.length===0?"0":Ze(t);return BigInt("0x"+e)}function dw(t){if(typeof t!="bigint")throw new Error("bigint expected");return Mn(t.toString(16).padStart(64,"0"))}const hw=Xt("Bitcoin seed"),So={private:76066276,public:76067358},_o=2147483648,pw=t=>sw(Et(t)),gw=t=>fn(t).getUint32(0,!1),Xr=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error("invalid number, should be from 0 to 2**32-1, got "+t);const e=new Uint8Array(4);return fn(e).setUint32(0,t,!1),e};class en{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return gw(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return Eo.encode(this.serialize(this.versions.private,ke(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return Eo.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,n=So){if(Ue(e),8*e.length<128||8*e.length>512)throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+e.length);const r=Yt(Sr,hw,e);return new en({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(e,n=So){const r=Eo.decode(e),s=fn(r),o=s.getUint32(0,!1),i={versions:n,depth:r[4],parentFingerprint:s.getUint32(5,!1),index:s.getUint32(9,!1),chainCode:r.slice(13,45)},a=r.slice(45),c=a[0]===0;if(o!==n[c?"private":"public"])throw new Error("Version mismatch");return c?new en({...i,privateKey:a.slice(1)}):new en({...i,publicKey:a})}static fromJSON(e){return en.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||So,this.depth=e.depth||0,this.chainCode=e.chainCode||null,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!De.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey=typeof e.privateKey=="bigint"?e.privateKey:Ya(e.privateKey),this.privKeyBytes=dw(this.privKey),this.pubKey=De.getPublicKey(e.privateKey,!0)}else if(e.publicKey)this.pubKey=Wr.fromHex(e.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=pw(this.pubKey)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const n=e.replace(/^[mM]'?\//,"").split("/");let r=this;for(const s of n){const o=/^(\d+)('?)$/.exec(s),i=o&&o[1];if(!o||o.length!==3||typeof i!="string")throw new Error("invalid child index: "+s);let a=+i;if(!Number.isSafeInteger(a)||a>=_o)throw new Error("Invalid index");o[2]==="'"&&(a+=_o),r=r.deriveChild(a)}return r}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=Xr(e);if(e>=_o){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=ke(new Uint8Array([0]),a,n)}else n=ke(this.pubKey,n);const r=Yt(Sr,this.chainCode,n),s=Ya(r.slice(0,32)),o=r.slice(32);if(!De.utils.isValidPrivateKey(s))throw new Error("Tweak bigger than curve order");const i={versions:this.versions,chainCode:o,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const a=ge(this.privKey+s,De.CURVE.n);if(!De.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=a}else{const a=Wr.fromHex(this.pubKey).add(Wr.fromPrivateKey(s));if(a.equals(Wr.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=a.toRawBytes(!0)}return new en(i)}catch{return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return Ue(e,32),De.sign(e,this.privKey).toCompactRawBytes()}verify(e,n){if(Ue(e,32),Ue(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=De.Signature.fromCompact(n)}catch{return!1}return De.verify(r,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,n){if(!this.chainCode)throw new Error("No chainCode set");return Ue(n,33),ke(Xr(e),new Uint8Array([this.depth]),Xr(this.parentFingerprint),Xr(this.index),this.chainCode,n)}}function mw(t,e,n,r){Tr(t);const s=ib({dkLen:32,asyncTick:10},r),{c:o,dkLen:i,asyncTick:a}=s;if(Vt(o),Vt(i),Vt(a),o<1)throw new Error("iterations (c) should be >= 1");const c=Oa(e),u=Oa(n),l=new Uint8Array(i),f=Yt.create(t,c),d=f._cloneInto().update(u);return{c:o,dkLen:i,asyncTick:a,DK:l,PRF:f,PRFSalt:d}}function yw(t,e,n,r,s){return t.destroy(),e.destroy(),r&&r.destroy(),ft(s),n}function bw(t,e,n,r){const{c:s,dkLen:o,DK:i,PRF:a,PRFSalt:c}=mw(t,e,n,r);let u;const l=new Uint8Array(4),f=fn(l),d=new Uint8Array(a.outputLen);for(let h=1,m=0;mt[0]==="あいこくしん";function Gf(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function Yf(t){const e=Gf(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}function Wf(t){Ue(t,16,20,24,28,32)}function xw(t,e=128){if(Vt(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return Jf(En(e/8),t)}const vw=t=>{const e=8-t.length/4;return new Uint8Array([Et(t)[0]>>e<{if(typeof e!="string")throw new Error("wordlist: non-string element: "+e)}),Yr.chain(Yr.checksum(1,vw),Yr.radix2(11,!0),Yr.alphabet(t))}function Ew(t,e){const{words:n}=Yf(t),r=Xf(e).decode(n);return Wf(r),r}function Jf(t,e){return Wf(t),Xf(e).encode(t).join(ww(e)?" ":" ")}function Sw(t,e){try{Ew(t,e)}catch{return!1}return!0}const _w=t=>Gf("mnemonic"+t);function kw(t,e=""){return bw(Sr,Yf(t).nfkd,_w(e),{c:2048,dkLen:64})}const Qi=`abandon +ability +able +about +above +absent +absorb +abstract +absurd +abuse +access +accident +account +accuse +achieve +acid +acoustic +acquire +across +act +action +actor +actress +actual +adapt +add +addict +address +adjust +admit +adult +advance +advice +aerobic +affair +afford +afraid +again +age +agent +agree +ahead +aim +air +airport +aisle +alarm +album +alcohol +alert +alien +all +alley +allow +almost +alone +alpha +already +also +alter +always +amateur +amazing +among +amount +amused +analyst +anchor +ancient +anger +angle +angry +animal +ankle +announce +annual +another +answer +antenna +antique +anxiety +any +apart +apology +appear +apple +approve +april +arch +arctic +area +arena +argue +arm +armed +armor +army +around +arrange +arrest +arrive +arrow +art +artefact +artist +artwork +ask +aspect +assault +asset +assist +assume +asthma +athlete +atom +attack +attend +attitude +attract +auction +audit +august +aunt +author +auto +autumn +average +avocado +avoid +awake +aware +away +awesome +awful +awkward +axis +baby +bachelor +bacon +badge +bag +balance +balcony +ball +bamboo +banana +banner +bar +barely +bargain +barrel +base +basic +basket +battle +beach +bean +beauty +because +become +beef +before +begin +behave +behind +believe +below +belt +bench +benefit +best +betray +better +between +beyond +bicycle +bid +bike +bind +biology +bird +birth +bitter +black +blade +blame +blanket +blast +bleak +bless +blind +blood +blossom +blouse +blue +blur +blush +board +boat +body +boil +bomb +bone +bonus +book +boost +border +boring +borrow +boss +bottom +bounce +box +boy +bracket +brain +brand +brass +brave +bread +breeze +brick +bridge +brief +bright +bring +brisk +broccoli +broken +bronze +broom +brother +brown +brush +bubble +buddy +budget +buffalo +build +bulb +bulk +bullet +bundle +bunker +burden +burger +burst +bus +business +busy +butter +buyer +buzz +cabbage +cabin +cable +cactus +cage +cake +call +calm +camera +camp +can +canal +cancel +candy +cannon +canoe +canvas +canyon +capable +capital +captain +car +carbon +card +cargo +carpet +carry +cart +case +cash +casino +castle +casual +cat +catalog +catch +category +cattle +caught +cause +caution +cave +ceiling +celery +cement +census +century +cereal +certain +chair +chalk +champion +change +chaos +chapter +charge +chase +chat +cheap +check +cheese +chef +cherry +chest +chicken +chief +child +chimney +choice +choose +chronic +chuckle +chunk +churn +cigar +cinnamon +circle +citizen +city +civil +claim +clap +clarify +claw +clay +clean +clerk +clever +click +client +cliff +climb +clinic +clip +clock +clog +close +cloth +cloud +clown +club +clump +cluster +clutch +coach +coast +coconut +code +coffee +coil +coin +collect +color +column +combine +come +comfort +comic +common +company +concert +conduct +confirm +congress +connect +consider +control +convince +cook +cool +copper +copy +coral +core +corn +correct +cost +cotton +couch +country +couple +course +cousin +cover +coyote +crack +cradle +craft +cram +crane +crash +crater +crawl +crazy +cream +credit +creek +crew +cricket +crime +crisp +critic +crop +cross +crouch +crowd +crucial +cruel +cruise +crumble +crunch +crush +cry +crystal +cube +culture +cup +cupboard +curious +current +curtain +curve +cushion +custom +cute +cycle +dad +damage +damp +dance +danger +daring +dash +daughter +dawn +day +deal +debate +debris +decade +december +decide +decline +decorate +decrease +deer +defense +define +defy +degree +delay +deliver +demand +demise +denial +dentist +deny +depart +depend +deposit +depth +deputy +derive +describe +desert +design +desk +despair +destroy +detail +detect +develop +device +devote +diagram +dial +diamond +diary +dice +diesel +diet +differ +digital +dignity +dilemma +dinner +dinosaur +direct +dirt +disagree +discover +disease +dish +dismiss +disorder +display +distance +divert +divide +divorce +dizzy +doctor +document +dog +doll +dolphin +domain +donate +donkey +donor +door +dose +double +dove +draft +dragon +drama +drastic +draw +dream +dress +drift +drill +drink +drip +drive +drop +drum +dry +duck +dumb +dune +during +dust +dutch +duty +dwarf +dynamic +eager +eagle +early +earn +earth +easily +east +easy +echo +ecology +economy +edge +edit +educate +effort +egg +eight +either +elbow +elder +electric +elegant +element +elephant +elevator +elite +else +embark +embody +embrace +emerge +emotion +employ +empower +empty +enable +enact +end +endless +endorse +enemy +energy +enforce +engage +engine +enhance +enjoy +enlist +enough +enrich +enroll +ensure +enter +entire +entry +envelope +episode +equal +equip +era +erase +erode +erosion +error +erupt +escape +essay +essence +estate +eternal +ethics +evidence +evil +evoke +evolve +exact +example +excess +exchange +excite +exclude +excuse +execute +exercise +exhaust +exhibit +exile +exist +exit +exotic +expand +expect +expire +explain +expose +express +extend +extra +eye +eyebrow +fabric +face +faculty +fade +faint +faith +fall +false +fame +family +famous +fan +fancy +fantasy +farm +fashion +fat +fatal +father +fatigue +fault +favorite +feature +february +federal +fee +feed +feel +female +fence +festival +fetch +fever +few +fiber +fiction +field +figure +file +film +filter +final +find +fine +finger +finish +fire +firm +first +fiscal +fish +fit +fitness +fix +flag +flame +flash +flat +flavor +flee +flight +flip +float +flock +floor +flower +fluid +flush +fly +foam +focus +fog +foil +fold +follow +food +foot +force +forest +forget +fork +fortune +forum +forward +fossil +foster +found +fox +fragile +frame +frequent +fresh +friend +fringe +frog +front +frost +frown +frozen +fruit +fuel +fun +funny +furnace +fury +future +gadget +gain +galaxy +gallery +game +gap +garage +garbage +garden +garlic +garment +gas +gasp +gate +gather +gauge +gaze +general +genius +genre +gentle +genuine +gesture +ghost +giant +gift +giggle +ginger +giraffe +girl +give +glad +glance +glare +glass +glide +glimpse +globe +gloom +glory +glove +glow +glue +goat +goddess +gold +good +goose +gorilla +gospel +gossip +govern +gown +grab +grace +grain +grant +grape +grass +gravity +great +green +grid +grief +grit +grocery +group +grow +grunt +guard +guess +guide +guilt +guitar +gun +gym +habit +hair +half +hammer +hamster +hand +happy +harbor +hard +harsh +harvest +hat +have +hawk +hazard +head +health +heart +heavy +hedgehog +height +hello +helmet +help +hen +hero +hidden +high +hill +hint +hip +hire +history +hobby +hockey +hold +hole +holiday +hollow +home +honey +hood +hope +horn +horror +horse +hospital +host +hotel +hour +hover +hub +huge +human +humble +humor +hundred +hungry +hunt +hurdle +hurry +hurt +husband +hybrid +ice +icon +idea +identify +idle +ignore +ill +illegal +illness +image +imitate +immense +immune +impact +impose +improve +impulse +inch +include +income +increase +index +indicate +indoor +industry +infant +inflict +inform +inhale +inherit +initial +inject +injury +inmate +inner +innocent +input +inquiry +insane +insect +inside +inspire +install +intact +interest +into +invest +invite +involve +iron +island +isolate +issue +item +ivory +jacket +jaguar +jar +jazz +jealous +jeans +jelly +jewel +job +join +joke +journey +joy +judge +juice +jump +jungle +junior +junk +just +kangaroo +keen +keep +ketchup +key +kick +kid +kidney +kind +kingdom +kiss +kit +kitchen +kite +kitten +kiwi +knee +knife +knock +know +lab +label +labor +ladder +lady +lake +lamp +language +laptop +large +later +latin +laugh +laundry +lava +law +lawn +lawsuit +layer +lazy +leader +leaf +learn +leave +lecture +left +leg +legal +legend +leisure +lemon +lend +length +lens +leopard +lesson +letter +level +liar +liberty +library +license +life +lift +light +like +limb +limit +link +lion +liquid +list +little +live +lizard +load +loan +lobster +local +lock +logic +lonely +long +loop +lottery +loud +lounge +love +loyal +lucky +luggage +lumber +lunar +lunch +luxury +lyrics +machine +mad +magic +magnet +maid +mail +main +major +make +mammal +man +manage +mandate +mango +mansion +manual +maple +marble +march +margin +marine +market +marriage +mask +mass +master +match +material +math +matrix +matter +maximum +maze +meadow +mean +measure +meat +mechanic +medal +media +melody +melt +member +memory +mention +menu +mercy +merge +merit +merry +mesh +message +metal +method +middle +midnight +milk +million +mimic +mind +minimum +minor +minute +miracle +mirror +misery +miss +mistake +mix +mixed +mixture +mobile +model +modify +mom +moment +monitor +monkey +monster +month +moon +moral +more +morning +mosquito +mother +motion +motor +mountain +mouse +move +movie +much +muffin +mule +multiply +muscle +museum +mushroom +music +must +mutual +myself +mystery +myth +naive +name +napkin +narrow +nasty +nation +nature +near +neck +need +negative +neglect +neither +nephew +nerve +nest +net +network +neutral +never +news +next +nice +night +noble +noise +nominee +noodle +normal +north +nose +notable +note +nothing +notice +novel +now +nuclear +number +nurse +nut +oak +obey +object +oblige +obscure +observe +obtain +obvious +occur +ocean +october +odor +off +offer +office +often +oil +okay +old +olive +olympic +omit +once +one +onion +online +only +open +opera +opinion +oppose +option +orange +orbit +orchard +order +ordinary +organ +orient +original +orphan +ostrich +other +outdoor +outer +output +outside +oval +oven +over +own +owner +oxygen +oyster +ozone +pact +paddle +page +pair +palace +palm +panda +panel +panic +panther +paper +parade +parent +park +parrot +party +pass +patch +path +patient +patrol +pattern +pause +pave +payment +peace +peanut +pear +peasant +pelican +pen +penalty +pencil +people +pepper +perfect +permit +person +pet +phone +photo +phrase +physical +piano +picnic +picture +piece +pig +pigeon +pill +pilot +pink +pioneer +pipe +pistol +pitch +pizza +place +planet +plastic +plate +play +please +pledge +pluck +plug +plunge +poem +poet +point +polar +pole +police +pond +pony +pool +popular +portion +position +possible +post +potato +pottery +poverty +powder +power +practice +praise +predict +prefer +prepare +present +pretty +prevent +price +pride +primary +print +priority +prison +private +prize +problem +process +produce +profit +program +project +promote +proof +property +prosper +protect +proud +provide +public +pudding +pull +pulp +pulse +pumpkin +punch +pupil +puppy +purchase +purity +purpose +purse +push +put +puzzle +pyramid +quality +quantum +quarter +question +quick +quit +quiz +quote +rabbit +raccoon +race +rack +radar +radio +rail +rain +raise +rally +ramp +ranch +random +range +rapid +rare +rate +rather +raven +raw +razor +ready +real +reason +rebel +rebuild +recall +receive +recipe +record +recycle +reduce +reflect +reform +refuse +region +regret +regular +reject +relax +release +relief +rely +remain +remember +remind +remove +render +renew +rent +reopen +repair +repeat +replace +report +require +rescue +resemble +resist +resource +response +result +retire +retreat +return +reunion +reveal +review +reward +rhythm +rib +ribbon +rice +rich +ride +ridge +rifle +right +rigid +ring +riot +ripple +risk +ritual +rival +river +road +roast +robot +robust +rocket +romance +roof +rookie +room +rose +rotate +rough +round +route +royal +rubber +rude +rug +rule +run +runway +rural +sad +saddle +sadness +safe +sail +salad +salmon +salon +salt +salute +same +sample +sand +satisfy +satoshi +sauce +sausage +save +say +scale +scan +scare +scatter +scene +scheme +school +science +scissors +scorpion +scout +scrap +screen +script +scrub +sea +search +season +seat +second +secret +section +security +seed +seek +segment +select +sell +seminar +senior +sense +sentence +series +service +session +settle +setup +seven +shadow +shaft +shallow +share +shed +shell +sheriff +shield +shift +shine +ship +shiver +shock +shoe +shoot +shop +short +shoulder +shove +shrimp +shrug +shuffle +shy +sibling +sick +side +siege +sight +sign +silent +silk +silly +silver +similar +simple +since +sing +siren +sister +situate +six +size +skate +sketch +ski +skill +skin +skirt +skull +slab +slam +sleep +slender +slice +slide +slight +slim +slogan +slot +slow +slush +small +smart +smile +smoke +smooth +snack +snake +snap +sniff +snow +soap +soccer +social +sock +soda +soft +solar +soldier +solid +solution +solve +someone +song +soon +sorry +sort +soul +sound +soup +source +south +space +spare +spatial +spawn +speak +special +speed +spell +spend +sphere +spice +spider +spike +spin +spirit +split +spoil +sponsor +spoon +sport +spot +spray +spread +spring +spy +square +squeeze +squirrel +stable +stadium +staff +stage +stairs +stamp +stand +start +state +stay +steak +steel +stem +step +stereo +stick +still +sting +stock +stomach +stone +stool +story +stove +strategy +street +strike +strong +struggle +student +stuff +stumble +style +subject +submit +subway +success +such +sudden +suffer +sugar +suggest +suit +summer +sun +sunny +sunset +super +supply +supreme +sure +surface +surge +surprise +surround +survey +suspect +sustain +swallow +swamp +swap +swarm +swear +sweet +swift +swim +swing +switch +sword +symbol +symptom +syrup +system +table +tackle +tag +tail +talent +talk +tank +tape +target +task +taste +tattoo +taxi +teach +team +tell +ten +tenant +tennis +tent +term +test +text +thank +that +theme +then +theory +there +they +thing +this +thought +three +thrive +throw +thumb +thunder +ticket +tide +tiger +tilt +timber +time +tiny +tip +tired +tissue +title +toast +tobacco +today +toddler +toe +together +toilet +token +tomato +tomorrow +tone +tongue +tonight +tool +tooth +top +topic +topple +torch +tornado +tortoise +toss +total +tourist +toward +tower +town +toy +track +trade +traffic +tragic +train +transfer +trap +trash +travel +tray +treat +tree +trend +trial +tribe +trick +trigger +trim +trip +trophy +trouble +truck +true +truly +trumpet +trust +truth +try +tube +tuition +tumble +tuna +tunnel +turkey +turn +turtle +twelve +twenty +twice +twin +twist +two +type +typical +ugly +umbrella +unable +unaware +uncle +uncover +under +undo +unfair +unfold +unhappy +uniform +unique +unit +universe +unknown +unlock +until +unusual +unveil +update +upgrade +uphold +upon +upper +upset +urban +urge +usage +use +used +useful +useless +usual +utility +vacant +vacuum +vague +valid +valley +valve +van +vanish +vapor +various +vast +vault +vehicle +velvet +vendor +venture +venue +verb +verify +version +very +vessel +veteran +viable +vibrant +vicious +victory +video +view +village +vintage +violin +virtual +virus +visa +visit +visual +vital +vivid +vocal +voice +void +volcano +volume +vote +voyage +wage +wagon +wait +walk +wall +walnut +want +warfare +warm +warrior +wash +wasp +waste +water +wave +way +wealth +weapon +wear +weasel +weather +web +wedding +weekend +weird +welcome +west +wet +whale +what +wheat +wheel +when +where +whip +whisper +wide +width +wife +wild +will +win +window +wine +wing +wink +winner +winter +wire +wisdom +wise +wish +witness +wolf +woman +wonder +wood +wool +word +work +world +worry +worth +wrap +wreck +wrestle +wrist +write +wrong +yard +year +yellow +you +young +youth +zebra +zero +zone +zoo`.split(` +`),Gn={orgSeed:t=>`m/83696968'/39'/0'/24'/${t}'`,wallet:(t,e=1)=>`m/86'/${e}'/${t}'/0/0`,nostr:t=>`m/44'/1237'/${t}'/0/0`},Aw=2**31-1,ko=new Map,Ao=new Map,Wa=()=>xw(Qi,256);function Qf(t,e=0){if(typeof t!="string"||!Sw(t,Qi)||e&&t.split(" ").length!==e)throw new Error("Invalid lab mnemonic.");return t}function Xs(t,e){if(!Number.isSafeInteger(t)||t<0||t>Aw)throw new Error(`Invalid ${e}.`);return t}const Bo=new Map;function el(t){return Bo.has(t)||Bo.set(t,kw(Qf(t))),Bo.get(t)}function Js(t){return ko.has(t)||ko.set(t,en.fromMasterSeed(el(t))),ko.get(t)}function Bw(t,e){const n=t.derive(e).privateKey;if(!n)throw new Error("BIP-85 path produced no private key.");return Yt(Sr,Xt("bip-entropy-from-k"),n)}function $w(t,e){const n=`${t}|${Xs(e,"child index")}`;return Ao.has(n)||Ao.set(n,Jf(Bw(Js(t),Gn.orgSeed(e)).slice(0,32),Qi)),Ao.get(n)}function Ow(t,e=0,n=1){return Ze(Js(t).derive(Gn.wallet(Xs(e,"account"),n)).privateKey)}function tl(t,e=0){return Ze(Js(t).derive(Gn.nostr(Xs(e,"account"))).privateKey)}function Tw(t,e=0){const n=Lf.getPublicKey(Js(t).derive(Gn.nostr(Xs(e,"account"))).privateKey);return{pubkey:Ze(n),npub:Ga.encode("npub",Ga.toWords(n))}}const nl="lineage-claim",ai=330,Ps=t=>Se.encode(t,!1).hex,Xa=t=>({txid:t.txid,vout:t.vout,value:t.value,script:Ps(t.scriptPubKey)}),$o=/^[0-9a-f]{64}$/,Cw=/^5120[0-9a-f]{64}$/;function ea(t,e){var n;for(const r of t.utxos.values())if((n=r.inscriptions)!=null&&n.some(s=>s.id===e))return r;return null}function rl(t){return le.create({vin:[Un(t.holder.txid,t.holder.vout,t.holder.value,t.holder.script),Un(t.payer.txid,t.payer.vout,t.payer.value,t.payer.script)],vout:[Ye(t.holder.value,["OP_1",t.to]),Ye(t.payer.value-Ie,["OP_1",t.to])]})}function Iw(t,e,n,r=Date.now()){if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Claims are signed by local test wallets.");const s=ea(t,e);if(!s)throw new Error("That inscription is not in an unspent output.");if(Ps(s.scriptPubKey)===Ps(n.script))throw new Error("The recipient already holds that inscription.");const o=t.coins(n.script).find(c=>{var u;return!((u=c.inscriptions)!=null&&u.length)&&c.value>=Ie+ai});if(!o)throw new Error("The recipient needs a plain coin for the 500-sat fee. Mine a block to it first.");const i={kind:nl,version:1,inscription:e,carried:s.inscriptions.map(c=>c.id),holder:Xa(s),payer:Xa(o),to:n.pubkey,at:r},a=rl(i);return i.txid=le.util.getTxid(a),i.sig=n.sign(a,void 0,1),i}function Uw(t,e,n){const r=Nw(e);if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Countersigning needs a local test wallet.");if(Ps(n.script)!==r.holder.script)throw new Error("Only the current holder can countersign.");if(Pw(t,r)!=="open")throw new Error("This claim is stale: an input it spends was already spent.");const s=rl(r);return s.vin[1].witness=[r.sig],s.vin[0].witness=[n.sign(s,void 0,0)],t.submitPackage([le.encode(s).hex]),le.util.getTxid(s)}function Pw(t,e){return t.utxos.has(`${e.holder.txid}:${e.holder.vout}`)&&t.utxos.has(`${e.payer.txid}:${e.payer.vout}`)?"open":"stale"}function Nw(t){const e=n=>n&&$o.test(n.txid)&&Number.isSafeInteger(n.vout)&&n.vout>=0&&Number.isSafeInteger(n.value)&&n.value>=ai&&Cw.test(n.script);if((t==null?void 0:t.kind)!==nl||t.version!==1||!/^[0-9a-f]{64}i\d+$/.test(t.inscription)||!Array.isArray(t.carried)||!e(t.holder)||!e(t.payer)||t.payer.value255*s)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/s);n===void 0&&(n=Ja);const i=new Uint8Array(o*s),a=Yt.create(t,e),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let l=0;lRw(t,Lw(t,e,n),r,s);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ht=BigInt(0),_e=BigInt(1),To=BigInt(2),jw=BigInt(8);function Dw(t,e,n,r){const s=t.sqr(n),o=t.sqr(r),i=t.add(t.mul(e.a,s),o),a=t.add(t.ONE,t.mul(e.d,t.mul(s,o)));return t.eql(i,a)}function Zw(t,e={}){const n=Of("edwards",t,e,e.FpFnLE),{Fp:r,Fn:s}=n;let o=n.CURVE;const{h:i}=o;Jn(e,{},{uvRatio:"function"});const a=To<r.create(p),u=e.uvRatio||((p,g)=>{try{return{isValid:!0,value:r.sqrt(r.div(p,g))}}catch{return{isValid:!1,value:Ht}}});if(!Dw(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function l(p,g,x=!1){const w=x?_e:Ht;return _r("coordinate "+p,g,w,a),g}function f(p){if(!(p instanceof m))throw new Error("ExtendedPoint expected")}const d=As((p,g)=>{const{X:x,Y:w,Z:$}=p,A=p.is0();g==null&&(g=A?jw:r.inv($));const O=c(x*g),P=c(w*g),I=r.mul($,g);if(A)return{x:Ht,y:_e};if(I!==_e)throw new Error("invZ was invalid");return{x:O,y:P}}),h=As(p=>{const{a:g,d:x}=o;if(p.is0())throw new Error("bad point: ZERO");const{X:w,Y:$,Z:A,T:O}=p,P=c(w*w),I=c($*$),k=c(A*A),U=c(k*k),R=c(P*g),D=c(k*c(R+I)),v=c(U+c(x*c(P*I)));if(D!==v)throw new Error("bad point: equation left != right (1)");const E=c(w*$),b=c(A*O);if(E!==b)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(g,x,w,$){this.X=l("x",g),this.Y=l("y",x),this.Z=l("z",w,!0),this.T=l("t",$),Object.freeze(this)}static CURVE(){return o}static fromAffine(g){if(g instanceof m)throw new Error("extended point not allowed");const{x,y:w}=g||{};return l("x",x),l("y",w),new m(x,w,_e,c(x*w))}static fromBytes(g,x=!1){const w=r.BYTES,{a:$,d:A}=o;g=Ua(We(g,w,"point")),gn(x,"zip215");const O=Ua(g),P=g[w-1];O[w-1]=P&-129;const I=mn(O),k=x?a:r.ORDER;_r("point.y",I,Ht,k);const U=c(I*I),R=c(U-_e),D=c(A*U-$);let{isValid:v,value:E}=u(R,D);if(!v)throw new Error("bad point: invalid y coordinate");const b=(E&_e)===_e,S=(P&128)!==0;if(!x&&E===Ht&&S)throw new Error("bad point: x=0 and x_0=1");return S!==b&&(E=c(-E)),m.fromAffine({x:E,y:I})}static fromHex(g,x=!1){return m.fromBytes(ue("point",g),x)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,x=!0){return y.createCache(this,g),x||this.multiply(To),this}assertValidity(){h(this)}equals(g){f(g);const{X:x,Y:w,Z:$}=this,{X:A,Y:O,Z:P}=g,I=c(x*P),k=c(A*$),U=c(w*P),R=c(O*$);return I===k&&U===R}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:g}=o,{X:x,Y:w,Z:$}=this,A=c(x*x),O=c(w*w),P=c(To*c($*$)),I=c(g*A),k=x+w,U=c(c(k*k)-A-O),R=I+O,D=R-P,v=I-O,E=c(U*D),b=c(R*v),S=c(U*v),B=c(D*R);return new m(E,b,B,S)}add(g){f(g);const{a:x,d:w}=o,{X:$,Y:A,Z:O,T:P}=this,{X:I,Y:k,Z:U,T:R}=g,D=c($*I),v=c(A*k),E=c(P*w*R),b=c(O*U),S=c(($+A)*(I+k)-D-v),B=b-E,N=b+E,T=c(v-x*D),H=c(S*B),Z=c(N*T),M=c(S*T),re=c(B*N);return new m(H,Z,re,M)}subtract(g){return this.add(g.negate())}multiply(g){if(!s.isValidNot0(g))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:x,f:w}=y.cached(this,g,$=>an(m,$));return an(m,[x,w])[0]}multiplyUnsafe(g,x=m.ZERO){if(!s.isValid(g))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return g===Ht?m.ZERO:this.is0()||g===_e?this:y.unsafe(this,g,w=>an(m,w),x)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return y.unsafe(this,o.n).is0()}toAffine(g){return d(this,g)}clearCofactor(){return i===_e?this:this.multiplyUnsafe(i)}toBytes(){const{x:g,y:x}=this.toAffine(),w=r.toBytes(x);return w[w.length-1]|=g&_e?128:0,w}toHex(){return Ze(this.toBytes())}toString(){return``}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(g){return an(m,g)}static msm(g,x){return $f(m,s,g,x)}_setWindowSize(g){this.precompute(g)}toRawBytes(){return this.toBytes()}}m.BASE=new m(o.Gx,o.Gy,_e,c(o.Gx*o.Gy)),m.ZERO=new m(Ht,_e,_e,Ht),m.Fp=r,m.Fn=s;const y=new Bf(m,s.BITS);return m.BASE.precompute(8),m}function Kw(t,e,n={}){if(typeof e!="function")throw new Error('"hash" function param is required');Jn(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:s,Fp:o,Fn:i}=t,a=n.randomBytes||En,c=n.adjustScalarBytes||(k=>k),u=n.domain||((k,U,R)=>{if(gn(R,"phflag"),U.length||R)throw new Error("Contexts/pre-hash are not supported");return k});function l(k){return i.create(mn(k))}function f(k){const U=w.secretKey;k=ue("private key",k,U);const R=ue("hashed private key",e(k),2*U),D=c(R.slice(0,U)),v=R.slice(U,2*U),E=l(D);return{head:D,prefix:v,scalar:E}}function d(k){const{head:U,prefix:R,scalar:D}=f(k),v=s.multiply(D),E=v.toBytes();return{head:U,prefix:R,scalar:D,point:v,pointBytes:E}}function h(k){return d(k).pointBytes}function m(k=Uint8Array.of(),...U){const R=ke(...U);return l(e(u(R,ue("context",k),!!r)))}function y(k,U,R={}){k=ue("message",k),r&&(k=r(k));const{prefix:D,scalar:v,pointBytes:E}=d(U),b=m(R.context,D,k),S=s.multiply(b).toBytes(),B=m(R.context,S,E,k),N=i.create(b+B*v);if(!i.isValid(N))throw new Error("sign failed: invalid s");const T=ke(S,i.toBytes(N));return We(T,w.signature,"result")}const p={zip215:!0};function g(k,U,R,D=p){const{context:v,zip215:E}=D,b=w.signature;k=ue("signature",k,b),U=ue("message",U),R=ue("publicKey",R,w.publicKey),E!==void 0&&gn(E,"zip215"),r&&(U=r(U));const S=b/2,B=k.subarray(0,S),N=mn(k.subarray(S,b));let T,H,Z;try{T=t.fromBytes(R,E),H=t.fromBytes(B,E),Z=s.multiplyUnsafe(N)}catch{return!1}if(!E&&T.isSmallOrder())return!1;const M=m(v,H.toBytes(),T.toBytes(),U);return H.add(T.multiplyUnsafe(M)).subtract(Z).clearCofactor().is0()}const x=o.BYTES,w={secretKey:x,publicKey:x,signature:2*x,seed:x};function $(k=a(w.seed)){return We(k,w.seed,"seed")}function A(k){const U=I.randomSecretKey(k);return{secretKey:U,publicKey:h(U)}}function O(k){return Or(k)&&k.length===i.BYTES}function P(k,U){try{return!!t.fromBytes(k,U)}catch{return!1}}const I={getExtendedPublicKey:d,randomSecretKey:$,isValidSecretKey:O,isValidPublicKey:P,toMontgomery(k){const{y:U}=t.fromBytes(k),R=w.publicKey,D=R===32;if(!D&&R!==57)throw new Error("only defined for 25519 and 448");const v=D?o.div(_e+U,_e-U):o.div(U-_e,U+_e);return o.toBytes(v)},toMontgomerySecret(k){const U=w.secretKey;We(k,U);const R=e(k.subarray(0,U));return c(R).subarray(0,U)},randomPrivateKey:$,precompute(k=8,U=t.BASE){return U.precompute(k,!1)}};return Object.freeze({keygen:A,getPublicKey:h,sign:y,verify:g,utils:I,Point:t,lengths:w})}function Vw(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp,r=Sn(e.n,t.nBitLength,!0),s={Fp:n,Fn:r,uvRatio:t.uvRatio},o={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:s,hash:t.hash,eddsaOpts:o}}function Mw(t,e){const n=e.Point;return Object.assign({},e,{ExtendedPoint:n,CURVE:t,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function qw(t){const{CURVE:e,curveOpts:n,hash:r,eddsaOpts:s}=Vw(t),o=Zw(e,n),i=Kw(o,r,s);return Mw(t,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=BigInt(0),Bn=BigInt(1),Jr=BigInt(2);function zw(t){return Jn(t,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...t})}function Fw(t){const e=zw(t),{P:n,type:r,adjustScalarBytes:s,powPminus2:o,randomBytes:i}=e,a=r==="x25519";if(!a&&r!=="x448")throw new Error("invalid type");const c=i||En,u=a?255:448,l=a?32:56,f=BigInt(a?9:5),d=BigInt(a?121665:39081),h=a?Jr**BigInt(254):Jr**BigInt(447),m=a?BigInt(8)*Jr**BigInt(251)-Bn:BigInt(4)*Jr**BigInt(445)-Bn,y=h+m+Bn,p=v=>ge(v,n),g=x(f);function x(v){return Fi(p(v),l)}function w(v){const E=ue("u coordinate",v,l);return a&&(E[31]&=127),p(mn(E))}function $(v){return mn(s(ue("scalar",v,l)))}function A(v,E){const b=I(w(E),$(v));if(b===or)throw new Error("invalid private or public key received");return x(b)}function O(v){return A(v,g)}function P(v,E,b){const S=p(v*(E-b));return E=p(E-S),b=p(b+S),{x_2:E,x_3:b}}function I(v,E){_r("u",v,or,n),_r("scalar",E,h,y);const b=E,S=v;let B=Bn,N=or,T=v,H=Bn,Z=or;for(let re=BigInt(u-1);re>=or;re--){const ne=b>>re&Bn;Z^=ne,{x_2:B,x_3:T}=P(Z,B,T),{x_2:N,x_3:H}=P(Z,N,H),Z=ne;const W=B+N,oe=p(W*W),ie=B-N,xe=p(ie*ie),se=oe-xe,he=T+H,lt=T-H,Ke=p(lt*W),Be=p(he*ie),dt=Ke+Be,nr=Ke-Be;T=p(dt*dt),H=p(S*p(nr*nr)),B=p(oe*xe),N=p(se*(oe+p(d*se)))}({x_2:B,x_3:T}=P(Z,B,T)),{x_2:N,x_3:H}=P(Z,N,H);const M=o(N);return p(B*M)}const k={secretKey:l,publicKey:l,seed:l},U=(v=c(l))=>(Ue(v,k.seed),v);function R(v){const E=U(v);return{secretKey:E,publicKey:O(E)}}return{keygen:R,getSharedSecret:(v,E)=>A(v,E),getPublicKey:v=>O(v),scalarMult:A,scalarMultBase:O,utils:{randomSecretKey:U,randomPrivateKey:U},GuBytes:g.slice(),lengths:k}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gw=BigInt(1),Qa=BigInt(2),Yw=BigInt(3),Ww=BigInt(5),Xw=BigInt(8),ta=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),sl={p:ta,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Xw,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ol(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),o=ta,a=t*t%o*t%o,c=ye(a,Qa,o)*a%o,u=ye(c,Gw,o)*t%o,l=ye(u,Ww,o)*u%o,f=ye(l,e,o)*l%o,d=ye(f,n,o)*f%o,h=ye(d,r,o)*d%o,m=ye(h,s,o)*h%o,y=ye(m,s,o)*h%o,p=ye(y,e,o)*l%o;return{pow_p_5_8:ye(p,Qa,o)*t%o,b2:a}}function il(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const ec=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Jw(t,e){const n=ta,r=ge(e*e*e,n),s=ge(r*r*e,n),o=ol(t*s).pow_p_5_8;let i=ge(t*r*o,n);const a=ge(e*i*i,n),c=i,u=ge(i*ec,n),l=a===t,f=a===ge(-t,n),d=a===ge(-t*ec,n);return l&&(i=c),(f||d)&&(i=u),Ob(i,n)&&(i=ge(-i,n)),{isValid:l||f,value:i}}const al=Sn(sl.p,{isLE:!0}),Qw={...sl,Fp:al,hash:Sr,adjustScalarBytes:il,uvRatio:Jw},cl=qw(Qw),ul=(()=>{const t=al.ORDER;return Fw({P:t,type:"x25519",powPminus2:e=>{const{pow_p_5_8:n,b2:r}=ol(e);return ge(ye(n,Yw,t)*r,t)},adjustScalarBytes:il})})(),e1=Xt("lineage/v0"),Ns=(t,e)=>Hw(Et,t,e1,Xt(e),32),fl=t=>{const e=Uint8Array.from(t);return e[0]&=248,e[31]&=127,e[31]|=64,e},t1=t=>{const e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t),e},tc=t=>ke(t1(t.length),t),ll=t=>ke(tc(Xt("ssh-ed25519")),tc(t)),ci=(t,e)=>`ssh-ed25519 ${Nn.encode(ll(t))}${e?` ${e}`:""}`,ui=t=>`SHA256:${Nn.encode(Et(ll(t))).replace(/=+$/,"")}`;function n1(t){const e=Mn(t),n=r=>cl.getPublicKey(Ns(e,r));return{ssh:n("ssh"),git:n("git"),dkim:n("dkim"),wg:ul.getPublicKey(fl(Ns(e,"wg")))}}function r1(t){const e=n=>cl.getPublicKey(Ns(t,n));return{"ssh-ca":e("node/ssh-ca"),mtls:e("node/mtls"),noise:ul.getPublicKey(fl(Ns(t,"node/noise")))}}function s1(t,e,n,r){return[["ssh",ui(t.ssh),ci(t.ssh,e)],["git",ui(t.git),`${e} namespaces="git" ${ci(t.git,e)}`],["dkim",`${n}._domainkey.${r}`,`${n}._domainkey.${r}. IN TXT "v=DKIM1; k=ed25519; p=${Nn.encode(t.dkim)}"`],["wg",Nn.encode(t.wg),`[Peer] +# ${e} +PublicKey = ${Nn.encode(t.wg)}`]]}function o1(t,e){return[["ssh-ca",ui(t["ssh-ca"]),ci(t["ssh-ca"],`lineage-ca@${e}`)],["mtls",Nn.encode(t.mtls),null],["noise",`mkey:${Ze(t.noise)}`,null]]}const i1=["tapkey","wallet"],na=()=>({scheme:"tapkey",roots:{},adopted:{}}),dl=(t,e,n)=>t.scheme==="wallet"?Ow(e,n):Fo.getSecKey(tl(e,n))[0],a1=(t,e)=>t.scheme==="wallet"?Gn.wallet(e):Gn.nostr(e),c1=(t,e)=>new Wt(dl(t,e,0)),Qr=t=>Se.encode(t,!1).hex;function Ls(t,e,n){if(!n)return null;const r=i=>i?{mnemonic:i,account:0,origin:`${n.name} root`,steps:[]}:null;if(n.kind==="holding")return r(t.roots[n.id]);const s=e.nodes.get(n.parent);if(n.kind==="agent"){const i=Ls(t,e,s);return i&&{...i,account:n.index+1}}if(n.edge==="adopted")return r(t.adopted[n.id]);const o=Ls(t,e,s);return o&&{mnemonic:$w(o.mnemonic,n.index),account:0,origin:o.origin,steps:[...o.steps,`${n.index}'`]}}function it(t,e,n){const r=Ls(t,e,n);if(!r)return null;const{npub:s,pubkey:o}=Tw(r.mnemonic,r.account);return{wallet:new Wt(dl(t,r.mnemonic,r.account)),npub:s,pubkey:o,tapkey:t.scheme==="tapkey",path:`${[r.origin,...r.steps].join(" › ")} · ${a1(t,r.account)}`}}function hl(t,e,n){const r=ea(t.chain,n);if(!r)return null;const s=Qr(r.scriptPubKey),o=e.nodes.get(n),i=it(t.keys,e,o),a=o&&it(t.keys,e,e.nodes.get(o.parent));return i&&Qr(i.wallet.script)===s?{wallet:i.wallet,who:"own"}:t.wallet&&Qr(t.wallet.script)===s?{wallet:t.wallet,who:"lab"}:a&&Qr(a.wallet.script)===s?{wallet:a.wallet,who:"parent"}:{wallet:null,who:"other",script:s}}function pl(t,e){const n=t.nodes.get(e),r=[n];for(const s of n.children){const o=t.nodes.get(s);o.status==="active"&&o.edge==="derived"&&r.push(...pl(t,s))}return r}function nc(t,e){const n=[];for(let r=e;r;r=t.nodes.get(r.parent))n.push(r.name);return n.join(".")}function u1(t,e,n){const r=Ls(t,e,n);if(!r)return null;if(n.kind!=="agent")return o1(r1(el(r.mnemonic)),nc(e,n));const s=nc(e,e.nodes.get(n.parent));return s1(n1(tl(r.mnemonic,r.account)),`${n.name}@${s}`,n.name,s)}const Qs="orgchain:lab:v1",f1=["each",10,30,60,"manual"];function Ur(t={tempo:"each",nextAt:null}){const{tempo:e,nextAt:n}=t??{},r=typeof e=="number";if(!f1.includes(e)||!(n===null||r&&Number.isSafeInteger(n)&&n>0))throw new Error("Invalid clock.");return{tempo:e,nextAt:n}}function gl(t){const e=na();for(const n of["roots","adopted"])for(const[r,s]of Object.entries((t==null?void 0:t[n])??{})){if(!/^[0-9a-f]{64}i0$/.test(r))throw new Error("Invalid lab keys.");e[n][r]=Qf(s,24)}if(e.scheme=(t==null?void 0:t.scheme)??(Object.keys(e.roots).length?"wallet":"tapkey"),!i1.includes(e.scheme))throw new Error("Invalid lab keys.");return e}const Pr=()=>({wallet:null,chain:new Gs,clock:Ur(),keys:na()});function ml(t){if(!t)return Pr();const e=JSON.parse(t);if((e==null?void 0:e.kind)!=="orgchain-lab"||e.network!==Zt||e.version!==1)throw new Error("That is not an Orgchain v1 lab.");return{wallet:e.wallet?Wt.load(e.wallet):null,chain:new Gs(e.chain),clock:Ur(e.clock),keys:gl(e.keys)}}const yl=t=>{var e;return JSON.stringify({kind:"orgchain-lab",network:Zt,version:1,wallet:((e=t.wallet)==null?void 0:e.backup())??null,chain:t.chain.snapshot(),clock:Ur(t.clock),keys:gl(t.keys)})},ra=()=>ml(localStorage.getItem(Qs));function l1(t){try{localStorage.setItem(Qs,yl(t))}catch{throw new Error("Browser storage is full or unavailable, so nothing was saved. Save a backup, then reset.")}}async function d1(t,{locks:e=(s=>(s=globalThis.navigator)==null?void 0:s.locks)(),read:n=ra,save:r=l1}={}){if(!e)throw new Error("Orgchain needs Web Locks: open it over HTTPS or on localhost.");return e.request(Qs,async()=>{const o=n(),i=await t(o);return i!==!1&&r(o),{lab:o,result:i}})}function bn(t){t.wallet||(t.wallet=Wt.create());const e=t.chain.mine(t.wallet.script);return t.clock=Ur({tempo:t.clock.tempo,nextAt:null}),e}function sa(t,e=Date.now()){const{tempo:n,nextAt:r}=t.clock;typeof n=="number"&&t.chain.mempool.length&&r===null&&(t.clock={tempo:n,nextAt:e+n*1e3})}function h1(t,e,n=Date.now()){t.clock=Ur({tempo:e,nextAt:null}),e==="each"&&t.chain.mempool.length?bn(t):sa(t,n)}function p1(t,e=Date.now()){const{tempo:n,nextAt:r}=t.clock;return typeof n!="number"||!t.chain.mempool.length?!1:r===null?(sa(t,e),!0):e`found ${t.name}`,birth:t=>`birth ${t.name}`,award:t=>`award ${t.skill} ${t.belt}`,decide:t=>`decide ${t.title}`,graduate:()=>"graduate",close:()=>"close"};function m1(t,e={}){if(!Object.hasOwn(rc,t))throw new Error("Unknown verb.");const n={op:t};for(const r of rc[t]){const s=e[r];typeof s=="string"&&s.trim()&&(n[r]=s.trim())}return n}const Co=t=>Vn(Vi(new zs(t.chain)),{pending:!0});function bl(t,e,n,r){const s=m1(e,r),o=Vi(new zs(t.chain)),i={id:"check",status:"pending",height:null,metadata:s,parent:n??null,protocol:Zi},{ok:a,why:c}=Vn([...o,i],{pending:!0}).log.at(-1);if(!a)throw new Error(`${c[0].toUpperCase()}${c.slice(1)}.`);return s}const y1=mt+2*Ie+330,os=1e5,Rs=(t,e,n)=>t.chain.coins(e.script).find(r=>{var s;return!((s=r.inscriptions)!=null&&s.length)&&r.value>=n}),fi=t=>Un(t.txid,t.vout,t.value,t.scriptPubKey),wl=(t,e)=>(e.forEach((n,r)=>{t.vin[r].witness=[n.sign(t,void 0,r)]}),le.encode(t).hex);function xl(t){t.keys??(t.keys=na()),t.wallet||(t.wallet=Wt.create()),Rs(t,t.wallet,os+Ie+330)||bn(t)}function Io(t,e,n=y1){if(e===t.wallet||Rs(t,e,n))return;const r=Rs(t,t.wallet,os+Ie+330),s=le.create({vin:[fi(r)],vout:[Ye(os,e.script),Ye(r.value-os-Ie,t.wallet.script)]});t.chain.submitPackage([wl(s,[t.wallet])])}function sc(t,e,n,r){const s=ea(t.chain,e),o=Rs(t,t.wallet,Ie+330),i=le.create({vin:[fi(s),fi(o)],vout:[Ye(s.value,r.script),Ye(o.value-Ie,t.wallet.script)]});t.chain.submitPackage([wl(i,[n,t.wallet])])}function oc(t,e,n,r,s){return new Jy(t.chain,e).inscribe(g1[n](s),r??null,s,{metaprotocol:Zi})}function ic(t,e,n){var s;const r=hl(t,e,n);if(!(r!=null&&r.wallet))throw new Error(`No key in this lab holds ${((s=e.nodes.get(n))==null?void 0:s.name)??"that node"}'s inscription.`);return r.wallet}function vl(t,e,n,r){if(e==="found"){const u=Wa(),l=c1(t.keys,u);Io(t,l);const f=oc(t,l,e,null,r);return t.keys.roots[f]=u,f}const s=Co(t),o=ic(t,s,n),i=e==="graduate"?s.nodes.get(r.of):null,a=i&&it(t.keys,s,i)?pl(s,i.id).map(u=>[u.id,ic(t,s,u.id)]):[];Io(t,o);const c=oc(t,o,e,n,r);if(e==="birth"){const u=Co(t),l=it(t.keys,u,u.nodes.get(c));l&&sc(t,c,o,l.wallet)}if(a.length){t.keys.adopted[i.id]=Wa();const u=Co(t);for(const[l,f]of a){const d=it(t.keys,u,u.nodes.get(l)).wallet;if(l!==i.id){sc(t,l,f,d);continue}Io(t,d,Ie+330),Uw(t.chain,Iw(t.chain,l,d),f)}}return c}function b1(t,e,n,r,s=Date.now()){const o=bl(t,e,n,r);xl(t);const i=vl(t,e,n??null,o);return t.clock.tempo==="each"?bn(t):sa(t,s),i}const El="yolopreneur",w1=[[["found",null,{name:"yolopreneur"}]],[["birth","yolopreneur",{name:"well-known",kind:"org"}],["birth","yolopreneur",{name:"time",kind:"org"}]],[["birth","well-known",{name:"mailr",kind:"org"}],["birth","well-known",{name:"lineage",kind:"org"}],["birth","time",{name:"luna",kind:"agent"}],["birth","time",{name:"sol",kind:"agent"}],["birth","time",{name:"astra",kind:"agent"}]],[["birth","time",{name:"docscope",kind:"org"}],["birth","time",{name:"dollhouse",kind:"org"}],["birth","time",{name:"doodleloop",kind:"org"}],["birth","time",{name:"hearthframe",kind:"org"}]],[["award","time",{to:"sol",skill:"launch",belt:"green"}],["award","time",{to:"luna",skill:"post",belt:"white"}],["decide","yolopreneur",{title:"Every venture gets a page",why:".yolopreneur.lol, served from one pages branch."}]],[["graduate","well-known",{of:"lineage"}],["decide","lineage",{title:"Lineage gets its own org",why:"Its own repo on Teahub now, lineage.llc later: adopted, not derived."}]]];function x1(t){xl(t),t.chain.mempool.length&&bn(t);const e={};for(const n of w1){for(const[r,s,o]of n){const i=Object.fromEntries(Object.entries(o).map(([u,l])=>[u,u==="to"||u==="of"?e[l]:l])),a=s?e[s]:null,c=vl(t,r,a,bl(t,r,a,i));(r==="found"||r==="birth")&&(e[o.name]=c)}bn(t)}return e[El]}const q=t=>document.getElementById(t);function C(t,e={},...n){const r=document.createElement(t);for(const[s,o]of Object.entries(e))o==null||o===!1||(s==="class"?r.className=o:s==="text"?r.textContent=o:s.startsWith("on")?r.addEventListener(s.slice(2),o):r.setAttribute(s,o===!0?"":String(o)));for(const s of n.flat(1/0))s!=null&&s!==!1&&s!==""&&r.append(s instanceof Node?s:String(s));return r}const cr=(t,e)=>`${t} ${e}${t===1?"":"s"}`,On=t=>t==="cued"?"cued":`beat ${t}`,v1=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),ac=t=>JSON.stringify(t,(e,n)=>typeof n=="bigint"?String(n):n,2),j={holding:null,node:null,event:null,beat:null,verb:"birth",busy:!1,replay:null,closing:null};let we=Pr(),Hs=new zs(we.chain),ur=[],me=Vn([]),at=me;const Xe=()=>we.chain.blocks.length,is=()=>ur.filter(t=>t.status==="pending").length,de=(t,e=me)=>t?e.nodes.get(t)??null:null,Sl=t=>Object.assign(j,{event:null,closing:null},t),eo=t=>{Sl(t),to()};function He(t,e=!1){const n=q("say");n.textContent=t,n.classList.toggle("bad",e)}function _l(){try{we=ra()}catch(t){we=Pr(),He(`This browser's saved lab could not be read (${t.message}) Load a backup, or reset to start over.`,!0)}oa()}function oa(){var t;Hs=new zs(we.chain),ur=Vi(Hs),me=Vn(ur,{pending:!0}),j.beat!==null&&j.beat>=Xe()&&(j.beat=null),de(j.holding)||(j.holding=((t=me.roots.at(-1))==null?void 0:t.id)??null),(!de(j.node)||de(j.node).root!==j.holding)&&(j.node=j.holding),j.event&&!me.log.some(e=>e.id===j.event)&&(j.event=null),at=j.beat===null?me:Vn(ur,{upTo:j.beat}),to()}function js(t){j.beat=t>=Xe()?null:Math.max(0,t),at=j.beat===null?me:Vn(ur,{upTo:j.beat}),to()}async function Nr(t,e){if(j.busy)return!1;j.busy=!0,document.body.classList.add("busy");try{return we=(await d1(t,e)).lab,!0}catch(n){return He((n==null?void 0:n.message)||String(n),!0),!1}finally{j.busy=!1,document.body.classList.remove("busy"),oa()}}async function tr(t,e,n,r){let s=null;if(!await Nr(i=>{s=b1(i,t,e,n)}))return!1;const o=Hs.events.find(i=>i.id===s);return He(r(s,(o==null?void 0:o.status)==="confirmed"?`at beat ${o.height}`:"cued for the next beat")),to(),!0}async function kl(t){const e=is();await Nr(t)&&is(){const e=rb(me,t.id),n=t.id===j.holding,r=[On(t.born),cr(e.orgs,"org"),cr(e.agents,"agent"),cr(e.belts,"belt"),t.status==="closed"&&"closed"].filter(Boolean);return C("li",{},C("button",{type:"button",class:`hold${n?" on":""}${t.status==="closed"?" gone":""}`,"aria-pressed":String(n),onclick:()=>eo({holding:t.id,node:t.id})},C("span",{class:"hn",text:t.name})," ",C("span",{class:"hm",text:r.join(" · ")})))})),q("holdings-empty").hidden=me.roots.length>0,q("holdings-sub").textContent=me.roots.length?String(me.roots.length):"",q("sample").disabled=me.roots.some(t=>t.name===El&&t.status==="active")}function _1(){var r;const t=q("tree-rows"),e=de(j.holding);if(q("tree-sub").textContent=e?`${e.name} · ${j.beat===null?"now":`beat ${j.beat} of ${Xe()}`}`:"",!e)return t.replaceChildren(C("p",{class:"wait",text:"No holding yet. Found one, or load the yolopreneur sample."}));if(!at.nodes.has(e.id))return t.replaceChildren(C("p",{class:"wait",text:`${e.name} is founded at ${On(e.born)}. Move the slider forward.`}));const n=t.contains(document.activeElement)?document.activeElement.dataset.id:null;t.replaceChildren(...nb(at,e.id).map(s=>s.type==="group"?C("div",{class:"row grp"},C("span",{class:"g","aria-hidden":"true",text:s.guide}),C("span",{class:"gl",text:s.label})):k1(s))),n&&((r=t.querySelector(`[data-id="${n}"]`))==null||r.focus())}function k1({node:t,guide:e,path:n}){const r=t.id===j.node,s=["row",r&&"on",t.status==="closed"&&"gone",t.born==="cued"&&"cue"].filter(Boolean).join(" ");return C("div",{class:s},C("button",{type:"button",class:"sel","data-id":t.id,"aria-pressed":String(r),onclick:()=>eo({node:t.id})},C("span",{class:"g","aria-hidden":"true",text:e}),C("span",{class:"p",text:`${n} `}),C("span",{class:"l",text:t.name})," ",C("span",{class:"v"},A1(t))))}function A1(t){return[t.kind==="agent"&&C("span",{class:"mk",text:"agent"}),t.edge==="adopted"&&C("span",{class:"mk ok",text:"graduated"}),t.status==="closed"&&C("span",{class:"mk bad",text:"closed"}),t.born==="cued"&&C("span",{class:"mk",text:"cued"}),...t.badges.map(Bl)].filter(Boolean).flatMap((n,r)=>r?[" ",n]:[n])}const Bl=t=>C("span",{class:`belt ${t.belt}`,title:`${t.skill}: ${t.belt} belt`},t.skill,C("span",{class:"sr",text:` (${t.belt} belt)`})),B1=(t,e)=>{for(let n=de(t.parent);n;n=de(n.parent))if(n.id===e.id)return!0;return!1},$l=t=>[...me.nodes.values()].filter(e=>e.root===t.root&&e.id!==t.id&&e.status==="active").map(e=>[e,(B1(e,t)?0:2)+(e.kind==="agent"?0:1)]).sort((e,n)=>e[1]-n[1]).map(([e])=>e),Ol=t=>t.children.reduce((e,n)=>{const r=de(n);return r&&r.edge==="derived"&&r.status==="active"?e+1+Ol(r):e},0);function $1(t){const e=de(t.parent),n=t.status==="closed"?`${t.name} is closed`:"";return{birth:n||(t.kind==="agent"?"Agents do not give birth":""),award:n||(t.kind==="agent"?"Agents do not award belts":$l(t).length?"":"There is nobody else in this holding to award yet"),decide:n,graduate:n||(e?t.kind!=="org"?"Only orgs graduate":t.edge==="adopted"?`${t.name} has already graduated`:e.status!=="active"?`${e.name} is closed`:"":"A holding has no parent to graduate from"),close:n}}function no(){const t=de(j.node),e=j.beat!==null;if(q("act-none").hidden=!!t,q("act-past").hidden=!t||!e,q("act-on").hidden=!t||e,q("act-sub").textContent=(t==null?void 0:t.name)??"",q("past-beat").textContent=String(j.beat??""),!t||e)return;const n=$1(t),r=de(t.parent);for(const d of document.querySelectorAll("[data-verb]"))d.setAttribute("aria-pressed",String(d.dataset.verb===j.verb)),d.classList.toggle("off",!!n[d.dataset.verb]);for(const d of document.querySelectorAll("form[data-form]"))d.hidden=d.dataset.form!==j.verb||!!n[j.verb];q("act-why").textContent=n[j.verb]?`${n[j.verb]}.`:"";for(const d of document.querySelectorAll("#act-on [data-name]"))d.textContent=t.name;for(const d of document.querySelectorAll("#act-on [data-parent]"))d.textContent=(r==null?void 0:r.name)??"";const s=q("award-to"),o=s.value,i=$l(t).map(d=>C("option",{value:d.id,text:`${sf(me,d.id)}${d.kind==="agent"?" (agent)":""}`})),a=d=>d.map(h=>`${h.value}=${h.textContent}`).join("|");a(i)!==a([...s.options])&&(s.replaceChildren(...i),i.some(d=>d.value===o)&&(s.value=o)),q("graduate-go").textContent=`Graduate ${t.name}`;const c=j.verb==="graduate"?r:t,u=c&&it(we.keys,me,c);q("act-key").textContent=!c||n[j.verb]?"":u?`Signs as ${c.name}: ${u.path}`:"Signs with the lab wallet: this holding predates lab keys.";const l=Ol(t),f=j.closing===t.id;q("close-note").textContent=l?`Closing ${t.name} spends it for the last time, and its ${cr(l,"derived descendant")} close with it. Graduated children hold their own roots and stay open.`:`Closing ${t.name} spends its inscription for the last time. Nothing can act through it afterwards.`,q("close-go").textContent=f?`Yes, close ${t.name}`:`Close ${t.name}`,q("close-keep").hidden=!f}function O1(){const t=q("inspect-body"),e=j.event?me.log.find(s=>s.id===j.event):null;if(e)return q("inspect-sub").textContent="event",t.replaceChildren(...N1(e));const n=de(j.node);if(q("inspect-sub").textContent=(n==null?void 0:n.kind)??"",!n)return t.replaceChildren(C("p",{class:"note pad",text:"Select a node in the tree, or an event in the timeline."}));const r=de(j.node,at);if(!r)return t.replaceChildren(C("p",{class:"note pad",text:`${n.name} is not born yet at beat ${j.beat}.`}));t.replaceChildren(...T1(r))}const Ds=([t,e,n])=>C("div",{class:"f"},C("dt",{text:t}),C("dd",{},e,n&&C("span",{class:"fn",text:n})));function T1(t){const e=de(t.parent,at),n=[["Born",t.born==="cued"?"cued for the next beat":`beat ${t.born}`],e&&["Parent",`${e.name} · ${t.kind} ${t.index}'`],e&&["Edge",t.edge==="adopted"?`adopted at ${On(t.graduated)}: it holds its own root`:`derived: ${e.name} holds its seed`],t.closed!==null&&["Closed",On(t.closed)],["Children",t.children.length?t.children.map(r=>{var s;return(s=de(r,at))==null?void 0:s.name}).join(", "):"none yet"],["Inscription",t.id]].filter(Boolean);return[C("div",{class:"ih"},C("p",{class:"eyebrow",text:sf(at,t.id)}),C("h3",{class:"it",text:t.name}),C("div",{class:"chips"},C("span",{class:"chip",text:t.kind}),C("span",{class:`chip ${t.status==="active"?"ok":"bad"}`,text:t.status}),t.edge==="adopted"&&C("span",{class:"chip ok",text:"graduated"}),t.born==="cued"&&C("span",{class:"chip",text:"cued"}))),C("div",{class:"ib"},C("dl",{class:"fl"},n.map(Ds)),t.badges.length>0&&C("div",{},C("p",{class:"lab",text:"Belts"}),C("ul",{class:"list"},t.badges.map(r=>{var s;return C("li",{},Bl(r),C("span",{class:"when",text:` from ${((s=de(r.by))==null?void 0:s.name)??"?"}, ${On(r.beat)}`}))}))),t.decisions.length>0&&C("div",{},C("p",{class:"lab",text:"Decisions"}),C("ul",{class:"list"},t.decisions.map(r=>C("li",{},C("b",{text:r.title}),r.why&&` · ${r.why}`,C("span",{class:"when",text:` (${On(r.beat)})`}))))),U1(t))]}const C1={own:"its own key",lab:"the lab wallet",parent:"its parent's key (its handoff is cued)",other:"a key outside this lab"},I1={ssh:"shell access, certified by the CA",git:"commit signing",dkim:"mail signing",wg:"WireGuard peer key","ssh-ca":"SSH certificate authority",mtls:"TLS identity between nodes",noise:"Headscale noise key"};function U1(t){const e=it(we.keys,at,t),n=hl(we,me,t.id),r=["Held now by",n?C1[n.who]:"nobody: its inscription has been spent"];if(!e)return C("div",{class:"keys"},C("p",{class:"lab",text:"Keys"}),C("dl",{class:"fl"},[["Signs with","the lab wallet: this holding predates lab keys, so it has no tapkey or leaves"],r].map(Ds)));const s=t.kind==="agent",o=u1(we.keys,at,t),i=o.map(([,,c])=>c).filter(Boolean),a=e.tapkey?["Tapkey",e.wallet.address,"Its npub with the BIP-86 tweak: one secret signs its nostr events and its chain spends."]:["Chain key",e.wallet.address,"A separate key at m/86', the way v1.1 keyed this lab. Reset the lab to key it by tapkey."];return C("div",{class:"keys"},C("p",{class:"lab",text:"Keys"}),C("dl",{class:"fl"},[a,["npub",e.npub],["Derived",e.path],r].map(Ds)),C("p",{class:"lab"},"Leaves",C("span",{text:` · HKDF-SHA256 from its ${s?"nostr secret":"seed"}`})),C("ul",{class:"list leaves"},o.map(([c,u])=>C("li",{},C("b",{text:c}),C("span",{class:"when",text:` ${I1[c]}`}),C("code",{text:u})))),C("div",{class:"code"},C("p",{class:"code-h",text:s?"Public lines to paste":"CA key for TrustedUserCAKeys"}),C("pre",{text:i.join(` + +`)})))}function P1(t){var i,a,c;const e=(a=(i=we.chain.transactions.get(t.id.slice(0,-2)))==null?void 0:i.tx.vin.find(u=>{var l;return((l=u.witness)==null?void 0:l.length)===3}))==null?void 0:a.witness;if(!e)return"?";const n=Di(e).pubkey,r=de(t.parent),s=t.op==="found"?de(t.node):null,o=[[s&&it(we.keys,me,s),`${s==null?void 0:s.name}'s root`],[r&&it(we.keys,me,r),`${r==null?void 0:r.name}'s key`],[(r==null?void 0:r.edge)==="adopted"&&it(we.keys,me,{...r,edge:"derived"}),`${r==null?void 0:r.name}'s derived key, from before it graduated`]];for(const[u,l]of o)if(u&&u.wallet.pubkey===n)return l;return((c=we.wallet)==null?void 0:c.pubkey)===n?"the lab wallet":`a key outside this lab (${n.slice(0,12)}…)`}function N1(t){var o,i,a;const e=Hs.events.find(c=>c.id===t.id),n=(i=(o=we.chain.transactions.get(t.id.slice(0,-2)))==null?void 0:o.inscription)==null?void 0:i.text,r=[["When",t.pending?"cued for the next beat":`beat ${t.beat}`],["Authorized by",t.parent?`${((a=de(t.parent))==null?void 0:a.name)??"an unknown inscription"}, whose inscription this event spent`:"nothing: a founding has no parent"],["Signed by",P1(t)],["Inscription",t.id],n&&["Body",n],(e==null?void 0:e.block)&&["Block",e.block]].filter(Boolean),s=e&&{id:e.id,status:e.status,height:e.height,block:e.block,parent:e.parent??null,metaprotocol:e.metaprotocol??null,contentType:e.contentType,sat:e.sat,location:e.location};return[C("div",{class:"ih"},C("p",{class:"eyebrow",text:`${t.op} · ${t.pending?"cued":`beat ${t.beat}`}`}),C("h3",{class:"it",text:of(t,me)}),C("div",{class:"chips"},C("span",{class:"chip",text:(e==null?void 0:e.protocol)??"?"}),C("span",{class:`chip ${t.ok?"ok":"bad"}`,text:t.ok?"applied":"rejected"})),!t.ok&&C("p",{class:"idesc",text:"The reducer rejected this event. It stays on the chain, but it does not change the tree."})),C("div",{class:"ib"},C("dl",{class:"fl"},r.map(Ds)),C("div",{class:"code"},C("p",{class:"code-h",text:"Metadata · CBOR, tag 5"}),C("pre",{text:ac(t.meta)})),s&&C("div",{class:"code"},C("p",{class:"code-h",text:"Raw index entry"}),C("pre",{text:ac(s)})))]}function ia(){const t=Xe(),e=q("beat"),n=de(j.holding);e.max=String(t),e.value=String(j.beat??t),e.disabled=t===0,q("beat-label").textContent=j.beat===null?`Now · beat ${t}`:`Beat ${j.beat} of ${t}`,q("replay").textContent=j.replay?"Stop":"Replay",q("replay").disabled=!n||t===0,q("to-now").disabled=j.beat===null,q("timeline-sub").textContent=(n==null?void 0:n.name)??"";const r=new Map;for(const o of me.log)if(o.root&&o.root===j.holding){const i=o.pending?"cued":o.beat;r.set(i,[...r.get(i)??[],o])}const s=[...r.keys()].sort((o,i)=>o==="cued"?-1:i==="cued"?1:i-o);if(!s.length)return q("timeline-list").replaceChildren(C("li",{class:"wait",text:n?"Nothing yet.":"Found a holding to start its timeline."}));q("timeline-list").replaceChildren(...s.map(o=>{const i=o==="cued"?null:we.chain.blocks[o-1],a=j.beat!==null&&(o==="cued"||o>j.beat),c=j.beat!==null&&o===j.beat;return C("li",{class:`beat${a?" later":""}${c?" now":""}`},C("p",{class:"bh"},C("span",{class:"bn",text:o==="cued"?"Cued":`Beat ${o}`}),C("span",{class:"bt",text:i?v1(i.time):we.clock.tempo==="manual"?"waiting for Beat now":"landing on the next beat"})),C("ol",{class:"evs"},r.get(o).map(u=>{const[l,...f]=of(u,me).split(" ");return C("li",{},C("button",{type:"button",class:`ev${u.ok?"":" bad"}${u.id===j.event?" on":""}`,"aria-pressed":String(u.id===j.event),onclick:()=>eo({event:u.id,node:u.node??j.node})},C("span",{class:"op",text:u.ok?l:`✕ ${l.replace(/:$/,"")}`})," ",C("span",{class:"es",text:f.join(" ")})))})))}))}q("f-found").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=Ki(e.elements.name.value);if(!n)return He("Name the holding: lowercase letters, digits and hyphens.",!0);await tr("found",null,{name:n},(r,s)=>(Sl({holding:r,node:r}),`${n} is founded, ${s}.`))&&e.reset()});q("sample").addEventListener("click",async()=>{let t=null;He("Rehearsing the yolopreneur tree over six beats…"),await Nr(e=>{t=x1(e)})&&(eo({holding:t,node:t}),He("Loaded the yolopreneur sample: six beats of history. Press Replay to watch it grow."))});q("f-birth").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=de(j.node),r=Ki(e.elements.name.value),s=e.elements.kind.value;if(!r)return He("Name the child: lowercase letters, digits and hyphens.",!0);await tr("birth",n.id,{name:r,kind:s},(o,i)=>`${r} is born to ${n.name}, ${i}.`)&&(e.elements.name.value="")});q("f-award").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=de(j.node),r=e.elements.to.value,s=Ki(e.elements.skill.value),o=e.elements.belt.value;if(!s)return He("Name the skill, for example launch.",!0);await tr("award",n.id,{to:r,skill:s,belt:o},(i,a)=>{var c;return`${(c=de(r))==null?void 0:c.name} holds a ${o} belt in ${s}, ${a}.`})&&(e.elements.skill.value="")});q("f-decide").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=de(j.node),r=e.elements.title.value.trim(),s=e.elements.why.value.trim();if(!r)return He("A decision needs a title.",!0);await tr("decide",n.id,{title:r,why:s},(o,i)=>`${n.name} decided “${r}”, ${i}.`)&&e.reset()});q("f-graduate").addEventListener("submit",async t=>{t.preventDefault();const e=de(j.node),n=de(e.parent);await tr("graduate",n.id,{of:e.id},(r,s)=>`${e.name} graduates from ${n.name}, ${s}. Its edge is adopted now.`)});q("f-close").addEventListener("submit",async t=>{t.preventDefault();const e=de(j.node);if(j.closing!==e.id)return j.closing=e.id,no(),q("close-go").focus();j.closing=null,await tr("close",e.id,{},(n,r)=>`${e.name} is closed, ${r}.`)});q("close-keep").addEventListener("click",()=>{j.closing=null,no(),q("close-go").focus()});for(const t of document.querySelectorAll("[data-verb]"))t.addEventListener("click",()=>{j.verb=t.dataset.verb,j.closing=null,no()});for(const t of document.querySelectorAll("[data-tempo]"))t.addEventListener("click",async()=>{const e=t.dataset.tempo,n=/^\d+$/.test(e)?Number(e):e;await Nr(r=>h1(r,n))&&He(e==="each"?"Each act is its own beat.":e==="manual"?"Acts are cued until you press Beat now.":`Acts are cued and land together on the next beat, at most ${e} seconds after the first.`)});q("beat-now").addEventListener("click",()=>kl(t=>t.chain.mempool.length?bn(t):!1));setInterval(()=>{Al();const{tempo:t,nextAt:e}=we.clock;j.busy||document.hidden||typeof t!="number"||!we.chain.mempool.length||e&&Date.now()p1(n))},1e3);addEventListener("storage",t=>{(t.key===Qs||t.key===null)&&_l()});function Lr(){j.replay&&(clearInterval(j.replay),j.replay=null,ia())}function L1(){const t=de(j.holding);if(!(!t||!Xe())){if(js(typeof t.born=="number"?t.born:Xe()),j.beat===null)return He("Nothing to replay yet: this holding has one beat of history.");j.replay=setInterval(()=>{(j.beat===null||j.beat+1>=Xe())&&Lr(),js(j.beat===null?Xe():j.beat+1)},800),ia()}}q("beat").addEventListener("input",t=>{Lr(),js(Number(t.target.value))});q("replay").addEventListener("click",()=>j.replay?Lr():L1());for(const t of["to-now","past-now"])q(t).addEventListener("click",()=>{Lr(),js(Xe())});const Uo=["system","light","dark"],Tl=()=>{q("theme").textContent=`Theme: ${document.documentElement.dataset.theme??"system"}`};q("theme").addEventListener("click",()=>{const t=Uo[(Uo.indexOf(document.documentElement.dataset.theme??"system")+1)%Uo.length];t==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t;try{t==="system"?localStorage.removeItem("orgchain-theme"):localStorage.setItem("orgchain-theme",t)}catch{}Tl()});function Cl(t,e,n){const r=q("confirm");r.replaceChildren(C("span",{text:t}),C("button",{type:"button",class:"btn sm danger",text:e,onclick:()=>{r.hidden=!0,n()}}),C("button",{type:"button",class:"btn sm",text:"Cancel",onclick:()=>{r.hidden=!0}})),r.hidden=!1,r.querySelector("button").focus()}const R1={read:()=>{try{return ra()}catch{return Pr()}}};async function Il(t,e){Lr(),await Nr(n=>{Object.assign(n,t())},R1)&&(Object.assign(j,{holding:null,node:null,event:null,beat:null,closing:null}),oa(),He(e))}q("save").addEventListener("click",()=>{const t=C("a",{href:URL.createObjectURL(new Blob([yl(we)],{type:"application/json"})),download:`orgchain-lab-${new Date().toISOString().slice(0,10)}.json`});document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(t.href),5e3),He("Saved a backup of this lab, test wallet included. Load it in any browser to carry on.")});q("load").addEventListener("click",()=>q("load-file").click());q("load-file").addEventListener("change",async t=>{var r;const e=(r=t.target.files)==null?void 0:r[0];if(t.target.value="",!e)return;let n;try{n=ml(await e.text())}catch(s){return He(`${e.name} is not an Orgchain lab: ${s.message}`,!0)}Cl(`Replace this browser's lab with ${e.name}?`,"Replace",()=>Il(()=>n,`Loaded ${e.name}.`))});q("reset").addEventListener("click",()=>Cl("Erase this browser's lab: every holding, the chain and the test wallet?","Erase",()=>Il(Pr,"Erased. This is a fresh lab.")));Tl();_l(); diff --git a/ventures/lineage/orgchain/assets/index-BmeAqZOd.css b/ventures/lineage/orgchain/assets/index-DCSoHK59.css similarity index 79% rename from ventures/lineage/orgchain/assets/index-BmeAqZOd.css rename to ventures/lineage/orgchain/assets/index-DCSoHK59.css index 0e6bdd6..a17dac2 100644 --- a/ventures/lineage/orgchain/assets/index-BmeAqZOd.css +++ b/ventures/lineage/orgchain/assets/index-DCSoHK59.css @@ -1 +1 @@ -:root{--concrete: #e4e3dd;--slab: #f6f5f1;--ink: #141414;--ink-2: #4a4944;--ink-3: #66655f;--signal: #ffc21a;--on-signal: #141414;--ok: #1d7a3a;--danger: #b3261e;--focus: #2346ff;--band: #141414;--band-fg: #f6f5f1;--band-muted: #b0afa8;--shadow: #141414;--mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;--display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--t-xs: .75rem;--t-s: .8125rem;--t-m: .9375rem;--t-l: 1.25rem;--gutter: max(16px, env(safe-area-inset-left, 0px));color-scheme:light}@media(prefers-color-scheme:dark){:root:not([data-theme=light]){--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}}:root[data-theme=dark]{--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}*{box-sizing:border-box}[hidden]{display:none!important}html{-webkit-text-size-adjust:100%}body{margin:0;background:var(--concrete);color:var(--ink);font:400 var(--t-m)/1.5 var(--mono)}body.busy{cursor:progress}::selection{background:var(--signal);color:var(--on-signal)}button,select,input,textarea{font:inherit;color:inherit}:focus-visible{outline:3px solid var(--focus);outline-offset:2px}a{color:inherit;text-decoration-thickness:2px;text-underline-offset:3px}b{font-weight:700}.band{background:var(--band);color:var(--band-fg);border-bottom:3px solid var(--ink)}.band-in{max-width:1320px;margin:0 auto;padding:16px var(--gutter) 14px;display:flex;flex-wrap:wrap;gap:14px 32px;align-items:flex-end;justify-content:space-between}.kicker{margin:0 0 8px;font:700 var(--t-xs)/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--band-muted)}.kicker a{color:var(--band-fg)}.wordmark{margin:0;font:900 clamp(2.25rem,6vw,3.5rem)/.84 var(--display);letter-spacing:-.05em;text-transform:uppercase}.lede{margin:10px 0 0;color:var(--band-muted);font-size:var(--t-s);max-width:88ch}.lede b{color:var(--band-fg)}.flags{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.flag{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;padding:7px 9px 6px;border:2px solid var(--band-fg);background:transparent;color:var(--band-fg);border-radius:0}.flag.hz{background:var(--signal);border-color:var(--signal);color:var(--on-signal)}button.flag{cursor:pointer}button.flag:hover{background:var(--band-fg);color:var(--band)}.clock{background:var(--slab);border-bottom:3px solid var(--ink);position:sticky;top:0;z-index:5}.clock-in{max-width:1320px;margin:0 auto;padding:10px var(--gutter);display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center}.tempo{display:flex;flex-wrap:wrap;align-items:center}.tempo .lab{margin:0 10px 0 0}.seg{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:9px 10px 8px;border:2px solid var(--ink);background:var(--slab);color:var(--ink);cursor:pointer;border-radius:0;margin-left:-2px}.seg:first-of-type{margin-left:0}.seg:hover:not([aria-pressed=true]){background:var(--concrete)}.seg[aria-pressed=true]{background:var(--ink);color:var(--slab)}.seg:focus-visible{position:relative;z-index:1}.beatno{margin:0;flex:1 1 22ch;font-size:var(--t-s);color:var(--ink-2)}.beatno b{color:var(--ink);font-size:var(--t-m)}.say{max-width:1320px;margin:0 auto;padding:0 var(--gutter) 10px;font-size:var(--t-s);color:var(--ink-2)}.say:empty{display:none}.say.bad{color:var(--danger);font-weight:700}.wrap{max-width:1320px;margin:0 auto;padding:32px var(--gutter) 56px;display:grid;gap:40px}.work{display:grid;gap:36px 28px;align-items:start;grid-template-columns:minmax(0,250px) minmax(0,1fr) minmax(0,390px);grid-template-areas:"hold tree side" "time time side"}.hold-blk{grid-area:hold}.tree-blk{grid-area:tree}.time-blk{grid-area:time}.side{grid-area:side;display:grid;gap:36px;min-width:0}.blk{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.blk>.panel{align-self:stretch}.tab{margin:0;background:var(--ink);color:var(--slab);font:700 var(--t-xs)/1 var(--mono);letter-spacing:.14em;text-transform:uppercase;padding:8px 11px 7px;display:flex;gap:12px;max-width:100%}.tab .sub{font-weight:400;letter-spacing:.06em;text-transform:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tab .sub:empty{display:none}.panel{background:var(--slab);border:3px solid var(--ink);box-shadow:8px 8px 0 var(--shadow);min-width:0}.pad{padding:16px 18px}.lab{display:block;font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.lab span{font-weight:400;letter-spacing:.04em;text-transform:none}.note{margin:0;font-size:var(--t-s);color:var(--ink-2)}.note p{margin:0 0 12px}.wait{margin:0;padding:4px 16px;color:var(--ink-3);font-size:var(--t-s)}.hint{margin:8px 0 0;font-size:var(--t-xs);color:var(--ink-2)}input:not([type]),input[type=text],select,textarea{width:100%;padding:8px 10px;border:2px solid var(--ink);border-radius:0;background:var(--concrete);min-width:0}textarea{resize:vertical;line-height:1.5}.line{display:flex;flex-wrap:wrap;gap:10px;align-items:stretch}.line input{flex:1 1 12ch;width:auto}.btn{font:700 var(--t-s)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:10px 12px 9px;background:var(--slab);color:var(--ink);border:2px solid var(--ink);box-shadow:3px 3px 0 var(--shadow);cursor:pointer;border-radius:0}.btn:hover{background:var(--concrete)}.btn:active{transform:translate(3px,3px);box-shadow:none}.btn.primary{background:var(--signal);color:var(--on-signal);border-color:var(--ink)}.btn.danger{background:var(--danger);color:var(--slab)}.btn.sm{font-size:var(--t-xs);padding:7px 9px 6px;box-shadow:2px 2px 0 var(--shadow)}.btn.sm:active{transform:translate(2px,2px)}.btn:disabled,.seg:disabled{cursor:not-allowed;background:var(--concrete);color:var(--ink-3);border-color:var(--ink-3);box-shadow:none;transform:none}.holds{list-style:none;margin:0;padding:0}.holds li+li{border-top:2px solid var(--ink)}.hold{width:100%;display:grid;gap:3px;text-align:left;background:transparent;border:0;padding:12px 18px;cursor:pointer;border-radius:0}.hold:hover .hn{text-decoration:underline;text-underline-offset:3px}.hn{font-weight:700;overflow-wrap:anywhere}.hm{font-size:var(--t-xs);color:var(--ink-2)}.hold.on{background:var(--signal)}.hold.on .hn,.hold.on .hm{color:var(--on-signal)}.hold.gone .hn{text-decoration:line-through;text-decoration-thickness:2px}.holds:not(:empty)~.found{border-top:3px solid var(--ink)}.empty p{margin:0;font-size:var(--t-s);color:var(--ink-2)}.found .lab{margin-bottom:8px}.sample{border-top:2px dashed var(--ink-3)}.tree{padding:12px 0;font-size:.875rem;overflow-x:auto}.row{display:flex;align-items:stretch;min-width:max-content}.sel{flex:1;display:flex;align-items:baseline;text-align:left;background:transparent;border:0;padding:4px 14px 4px 16px;cursor:pointer;line-height:1.55;border-radius:0}.sel:hover .l{text-decoration:underline;text-underline-offset:3px}.g{white-space:pre;color:var(--ink-3);flex:none}.p{white-space:pre;font-weight:700;flex:none}.l{flex:none;color:var(--ink);font-weight:700;white-space:nowrap}.v{flex:1 0 auto;display:flex;gap:5px;justify-content:flex-end;align-items:center;margin-left:2ch}.grp{padding:0 14px 0 16px;line-height:1.55;color:var(--ink-3)}.gl{color:var(--ink-2)}.row.on .sel{background:var(--signal)}.row.on .g,.row.on .p,.row.on .l,.row.on .mk,.row.on .belt{color:var(--on-signal);border-color:var(--on-signal)}.row.gone .l,.row.gone .p{text-decoration:line-through;text-decoration-thickness:2px}.row.gone .l{color:var(--ink-2)}.row.cue .l{font-weight:400;font-style:italic}.mk{font:700 .6875rem/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 5px 2px;border:2px solid currentColor;color:var(--ink-2);white-space:nowrap}.mk.ok{color:var(--ok)}.mk.bad{color:var(--danger)}.belt{display:inline-flex;align-items:center;gap:5px;font:700 .6875rem/1 var(--mono);padding:2px 5px 2px 3px;border:2px solid var(--ink);color:var(--ink);white-space:nowrap}.belt:before{content:"";width:10px;height:10px;flex:none;border:1.5px solid currentColor;background:#f6f5f1}.belt.green:before{background:#1d7a3a}.belt.black:before{background:#141414}.verbs{display:flex;flex-wrap:wrap;border-bottom:3px solid var(--ink)}.verbs button{flex:1 1 auto;font:700 var(--t-s)/1 var(--mono);padding:12px 10px;background:transparent;border:0;border-right:2px solid var(--ink);color:var(--ink-2);cursor:pointer;border-radius:0}.verbs button:last-child{border-right:0}.verbs button.off{color:var(--ink-3)}.verbs button:hover:not([aria-pressed=true]){color:var(--ink);text-decoration:underline;text-underline-offset:3px}.verbs button[aria-pressed=true]{background:var(--ink);color:var(--slab)}.why{margin:0;font-size:var(--t-s);color:var(--ink-2)}.keyline{margin:0;padding:10px 18px;font-size:var(--t-xs);color:var(--ink-2);overflow-wrap:anywhere;border-bottom:1px dashed var(--ink-3)}.keyline:empty{display:none}.why:empty{display:none}.vf{display:grid;gap:6px}.vf .lab{margin-top:8px}.vh{margin:0;font-size:var(--t-s);color:var(--ink-2)}.vh b{color:var(--ink)}.vf .go,.vf .line{margin-top:12px}.vf>.go{justify-self:start}.vf .line .go{margin-top:0}.kinds{border:0;margin:0;padding:0;display:grid;gap:6px;min-width:0}.kinds legend{padding:0;margin:8px 0 6px}.kinds label{display:flex;gap:8px;align-items:baseline;cursor:pointer;font-weight:700}.kinds label span{font-weight:400;font-size:var(--t-s);color:var(--ink-2)}.kinds input{accent-color:var(--ink);margin:0}.ih{padding:16px 18px 14px;border-bottom:3px solid var(--ink)}.eyebrow{margin:0 0 8px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink-2);overflow-wrap:anywhere}.it{margin:0;font:700 var(--t-l)/1.25 var(--mono);overflow-wrap:anywhere}.idesc{margin:10px 0 0;color:var(--ink-2);font-size:var(--t-s)}.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.chip{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.08em;text-transform:uppercase;padding:5px 7px 4px;border:2px solid currentColor}.chip.ok{color:var(--ok)}.chip.bad{color:var(--danger)}.ib{padding:4px 18px 18px;display:grid;gap:16px}.fl{margin:0;display:grid}.f{display:grid;gap:4px;padding-top:12px;margin-top:12px;border-top:1px dashed var(--ink-3)}.f:first-child{border-top:0}.f dt{font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.f dd{margin:0;font-size:var(--t-s);overflow-wrap:anywhere;min-width:0}.list{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px;font-size:var(--t-s)}.list .when{color:var(--ink-2)}.code{border:2px solid var(--ink);min-width:0}.code-h{padding:6px 10px;border-bottom:2px solid var(--ink);background:var(--concrete);font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2)}.code pre{margin:0;padding:10px;font-size:var(--t-xs);line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.scrub{flex:1 1 400px;display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center}.scrub .lab{margin:0}.scrub input[type=range]{flex:1 1 120px;min-width:80px;min-width:0;margin:0;height:28px;accent-color:var(--ink);cursor:pointer}.scrub output{font:700 var(--t-s)/1 var(--mono);min-width:12ch;white-space:nowrap}.beats{list-style:none;margin:0;padding:6px 0;max-height:480px;overflow:auto;overscroll-behavior:contain}.beat{padding:10px 18px}.beat+.beat{border-top:1px dashed var(--ink-3)}.bh{margin:0 0 6px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2);display:flex;flex-wrap:wrap;gap:4px 12px}.bt{font-weight:400;letter-spacing:.04em}.beat.now .bh .bn{background:var(--signal);color:var(--on-signal);padding:2px 5px;margin:-2px -5px}.evs{list-style:none;margin:0;padding:0;display:grid;gap:2px}.ev{width:calc(100% + 6px);display:flex;gap:1ch;text-align:left;background:transparent;border:0;padding:3px 6px;margin-left:-6px;cursor:pointer;border-radius:0;font-size:var(--t-s)}.ev .op{flex:none;min-width:9ch;font-weight:700}.ev .es{min-width:0;color:var(--ink-2);overflow-wrap:anywhere}.ev:hover .es{text-decoration:underline;text-underline-offset:3px}.ev.bad .op,.ev.bad .es{color:var(--danger)}.beat.later .bh,.beat.later .op,.beat.later .es{color:var(--ink-3)}.beat.later .ev .op{font-weight:400}.ev.on{background:var(--signal)}.ev.on .op,.ev.on .es{color:var(--on-signal)}.foot{display:grid;gap:10px;color:var(--ink-2);font-size:var(--t-s);max-width:100ch}.foot p{margin:0}.labrow{display:flex;flex-wrap:wrap;gap:10px;align-items:center}.confirm{flex-basis:100%;display:flex;flex-wrap:wrap;gap:10px;align-items:center;padding:10px 12px;border:2px dashed var(--ink);color:var(--ink)}@media(min-width:761px){.scrub{flex-wrap:nowrap}}@media(max-width:1120px){.work{grid-template-columns:minmax(0,1fr) minmax(0,370px);grid-template-areas:"hold side" "tree side" "time time"}}@media(max-width:760px){.clock{position:static}.work{grid-template-columns:minmax(0,1fr);grid-template-areas:"hold" "tree" "side" "time"}}@media(max-width:640px){.panel{box-shadow:5px 5px 0 var(--shadow)}.flag.proto{display:none}.tree{font-size:var(--t-s)}.sel,.grp{padding-left:10px}.v .belt{display:none}.beat{padding:10px 14px}.ev{flex-direction:column;gap:0}}@media(prefers-reduced-motion:reduce){.btn:active,.btn.sm:active{transform:none}}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.code-h{margin:0} +:root{--concrete: #e4e3dd;--slab: #f6f5f1;--ink: #141414;--ink-2: #4a4944;--ink-3: #66655f;--signal: #ffc21a;--on-signal: #141414;--ok: #1d7a3a;--danger: #b3261e;--focus: #2346ff;--band: #141414;--band-fg: #f6f5f1;--band-muted: #b0afa8;--shadow: #141414;--mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;--display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--t-xs: .75rem;--t-s: .8125rem;--t-m: .9375rem;--t-l: 1.25rem;--gutter: max(16px, env(safe-area-inset-left, 0px));color-scheme:light}@media(prefers-color-scheme:dark){:root:not([data-theme=light]){--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}}:root[data-theme=dark]{--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}*{box-sizing:border-box}[hidden]{display:none!important}html{-webkit-text-size-adjust:100%}body{margin:0;background:var(--concrete);color:var(--ink);font:400 var(--t-m)/1.5 var(--mono)}body.busy{cursor:progress}::selection{background:var(--signal);color:var(--on-signal)}button,select,input,textarea{font:inherit;color:inherit}:focus-visible{outline:3px solid var(--focus);outline-offset:2px}a{color:inherit;text-decoration-thickness:2px;text-underline-offset:3px}b{font-weight:700}.band{background:var(--band);color:var(--band-fg);border-bottom:3px solid var(--ink)}.band-in{max-width:1320px;margin:0 auto;padding:16px var(--gutter) 14px;display:flex;flex-wrap:wrap;gap:14px 32px;align-items:flex-end;justify-content:space-between}.kicker{margin:0 0 8px;font:700 var(--t-xs)/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--band-muted)}.kicker a{color:var(--band-fg)}.wordmark{margin:0;font:900 clamp(2.25rem,6vw,3.5rem)/.84 var(--display);letter-spacing:-.05em;text-transform:uppercase}.lede{margin:10px 0 0;color:var(--band-muted);font-size:var(--t-s);max-width:88ch}.lede b{color:var(--band-fg)}.flags{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.flag{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;padding:7px 9px 6px;border:2px solid var(--band-fg);background:transparent;color:var(--band-fg);border-radius:0}.flag.hz{background:var(--signal);border-color:var(--signal);color:var(--on-signal)}button.flag{cursor:pointer}button.flag:hover{background:var(--band-fg);color:var(--band)}.clock{background:var(--slab);border-bottom:3px solid var(--ink);position:sticky;top:0;z-index:5}.clock-in{max-width:1320px;margin:0 auto;padding:10px var(--gutter);display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center}.tempo{display:flex;flex-wrap:wrap;align-items:center}.tempo .lab{margin:0 10px 0 0}.seg{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:9px 10px 8px;border:2px solid var(--ink);background:var(--slab);color:var(--ink);cursor:pointer;border-radius:0;margin-left:-2px}.seg:first-of-type{margin-left:0}.seg:hover:not([aria-pressed=true]){background:var(--concrete)}.seg[aria-pressed=true]{background:var(--ink);color:var(--slab)}.seg:focus-visible{position:relative;z-index:1}.beatno{margin:0;flex:1 1 22ch;font-size:var(--t-s);color:var(--ink-2)}.beatno b{color:var(--ink);font-size:var(--t-m)}.say{max-width:1320px;margin:0 auto;padding:0 var(--gutter) 10px;font-size:var(--t-s);color:var(--ink-2)}.say:empty{display:none}.say.bad{color:var(--danger);font-weight:700}.wrap{max-width:1320px;margin:0 auto;padding:32px var(--gutter) 56px;display:grid;gap:40px}.work{display:grid;gap:36px 28px;align-items:start;grid-template-columns:minmax(0,250px) minmax(0,1fr) minmax(0,390px);grid-template-areas:"hold tree side" "time time side"}.hold-blk{grid-area:hold}.tree-blk{grid-area:tree}.time-blk{grid-area:time}.side{grid-area:side;display:grid;gap:36px;min-width:0}.blk{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.blk>.panel{align-self:stretch}.tab{margin:0;background:var(--ink);color:var(--slab);font:700 var(--t-xs)/1 var(--mono);letter-spacing:.14em;text-transform:uppercase;padding:8px 11px 7px;display:flex;gap:12px;max-width:100%}.tab .sub{font-weight:400;letter-spacing:.06em;text-transform:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tab .sub:empty{display:none}.panel{background:var(--slab);border:3px solid var(--ink);box-shadow:8px 8px 0 var(--shadow);min-width:0}.pad{padding:16px 18px}.lab{display:block;font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.lab span{font-weight:400;letter-spacing:.04em;text-transform:none}.note{margin:0;font-size:var(--t-s);color:var(--ink-2)}.note p{margin:0 0 12px}.wait{margin:0;padding:4px 16px;color:var(--ink-3);font-size:var(--t-s)}.hint{margin:8px 0 0;font-size:var(--t-xs);color:var(--ink-2)}input:not([type]),input[type=text],select,textarea{width:100%;padding:8px 10px;border:2px solid var(--ink);border-radius:0;background:var(--concrete);min-width:0}textarea{resize:vertical;line-height:1.5}.line{display:flex;flex-wrap:wrap;gap:10px;align-items:stretch}.line input{flex:1 1 12ch;width:auto}.btn{font:700 var(--t-s)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:10px 12px 9px;background:var(--slab);color:var(--ink);border:2px solid var(--ink);box-shadow:3px 3px 0 var(--shadow);cursor:pointer;border-radius:0}.btn:hover{background:var(--concrete)}.btn:active{transform:translate(3px,3px);box-shadow:none}.btn.primary{background:var(--signal);color:var(--on-signal);border-color:var(--ink)}.btn.danger{background:var(--danger);color:var(--slab)}.btn.sm{font-size:var(--t-xs);padding:7px 9px 6px;box-shadow:2px 2px 0 var(--shadow)}.btn.sm:active{transform:translate(2px,2px)}.btn:disabled,.seg:disabled{cursor:not-allowed;background:var(--concrete);color:var(--ink-3);border-color:var(--ink-3);box-shadow:none;transform:none}.holds{list-style:none;margin:0;padding:0}.holds li+li{border-top:2px solid var(--ink)}.hold{width:100%;display:grid;gap:3px;text-align:left;background:transparent;border:0;padding:12px 18px;cursor:pointer;border-radius:0}.hold:hover .hn{text-decoration:underline;text-underline-offset:3px}.hn{font-weight:700;overflow-wrap:anywhere}.hm{font-size:var(--t-xs);color:var(--ink-2)}.hold.on{background:var(--signal)}.hold.on .hn,.hold.on .hm{color:var(--on-signal)}.hold.gone .hn{text-decoration:line-through;text-decoration-thickness:2px}.holds:not(:empty)~.found{border-top:3px solid var(--ink)}.empty p{margin:0;font-size:var(--t-s);color:var(--ink-2)}.found .lab{margin-bottom:8px}.sample{border-top:2px dashed var(--ink-3)}.tree{padding:12px 0;font-size:.875rem;overflow-x:auto}.row{display:flex;align-items:stretch;min-width:max-content}.sel{flex:1;display:flex;align-items:baseline;text-align:left;background:transparent;border:0;padding:4px 14px 4px 16px;cursor:pointer;line-height:1.55;border-radius:0}.sel:hover .l{text-decoration:underline;text-underline-offset:3px}.g{white-space:pre;color:var(--ink-3);flex:none}.p{white-space:pre;font-weight:700;flex:none}.l{flex:none;color:var(--ink);font-weight:700;white-space:nowrap}.v{flex:1 0 auto;display:flex;gap:5px;justify-content:flex-end;align-items:center;margin-left:2ch}.grp{padding:0 14px 0 16px;line-height:1.55;color:var(--ink-3)}.gl{color:var(--ink-2)}.row.on .sel{background:var(--signal)}.row.on .g,.row.on .p,.row.on .l,.row.on .mk,.row.on .belt{color:var(--on-signal);border-color:var(--on-signal)}.row.gone .l,.row.gone .p{text-decoration:line-through;text-decoration-thickness:2px}.row.gone .l{color:var(--ink-2)}.row.cue .l{font-weight:400;font-style:italic}.mk{font:700 .6875rem/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 5px 2px;border:2px solid currentColor;color:var(--ink-2);white-space:nowrap}.mk.ok{color:var(--ok)}.mk.bad{color:var(--danger)}.belt{display:inline-flex;align-items:center;gap:5px;font:700 .6875rem/1 var(--mono);padding:2px 5px 2px 3px;border:2px solid var(--ink);color:var(--ink);white-space:nowrap}.belt:before{content:"";width:10px;height:10px;flex:none;border:1.5px solid currentColor;background:#f6f5f1}.belt.green:before{background:#1d7a3a}.belt.black:before{background:#141414}.verbs{display:flex;flex-wrap:wrap;border-bottom:3px solid var(--ink)}.verbs button{flex:1 1 auto;font:700 var(--t-s)/1 var(--mono);padding:12px 10px;background:transparent;border:0;border-right:2px solid var(--ink);color:var(--ink-2);cursor:pointer;border-radius:0}.verbs button:last-child{border-right:0}.verbs button.off{color:var(--ink-3)}.verbs button:hover:not([aria-pressed=true]){color:var(--ink);text-decoration:underline;text-underline-offset:3px}.verbs button[aria-pressed=true]{background:var(--ink);color:var(--slab)}.why{margin:0;font-size:var(--t-s);color:var(--ink-2)}.keyline{margin:0;padding:10px 18px;font-size:var(--t-xs);color:var(--ink-2);overflow-wrap:anywhere;border-bottom:1px dashed var(--ink-3)}.keyline:empty{display:none}.why:empty{display:none}.vf{display:grid;gap:6px}.vf .lab{margin-top:8px}.vh{margin:0;font-size:var(--t-s);color:var(--ink-2)}.vh b{color:var(--ink)}.vf .go,.vf .line{margin-top:12px}.vf>.go{justify-self:start}.vf .line .go{margin-top:0}.kinds{border:0;margin:0;padding:0;display:grid;gap:6px;min-width:0}.kinds legend{padding:0;margin:8px 0 6px}.kinds label{display:flex;gap:8px;align-items:baseline;cursor:pointer;font-weight:700}.kinds label span{font-weight:400;font-size:var(--t-s);color:var(--ink-2)}.kinds input{accent-color:var(--ink);margin:0}.ih{padding:16px 18px 14px;border-bottom:3px solid var(--ink)}.eyebrow{margin:0 0 8px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink-2);overflow-wrap:anywhere}.it{margin:0;font:700 var(--t-l)/1.25 var(--mono);overflow-wrap:anywhere}.idesc{margin:10px 0 0;color:var(--ink-2);font-size:var(--t-s)}.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.chip{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.08em;text-transform:uppercase;padding:5px 7px 4px;border:2px solid currentColor}.chip.ok{color:var(--ok)}.chip.bad{color:var(--danger)}.ib{padding:4px 18px 18px;display:grid;gap:16px}.fl{margin:0;display:grid}.f{display:grid;gap:4px;padding-top:12px;margin-top:12px;border-top:1px dashed var(--ink-3)}.f:first-child{border-top:0}.f dt{font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.f dd{margin:0;font-size:var(--t-s);overflow-wrap:anywhere;min-width:0}.list{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px;font-size:var(--t-s)}.list .when{color:var(--ink-2)}.code{border:2px solid var(--ink);min-width:0}.code-h{padding:6px 10px;border-bottom:2px solid var(--ink);background:var(--concrete);font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2)}.code pre{margin:0;padding:10px;font-size:var(--t-xs);line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.fn{display:block;margin-top:4px;font-size:var(--t-xs);color:var(--ink-2)}.keys{display:grid;gap:10px;min-width:0}.keys .fl{margin-top:-4px}.keys .f:first-child{margin-top:0}.keys .lab:not(:first-child){margin-top:6px}.leaves{margin:0}.leaves code{display:block;margin-top:2px;font:var(--t-xs)/1.5 var(--mono);overflow-wrap:anywhere}.scrub{flex:1 1 400px;display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center}.scrub .lab{margin:0}.scrub input[type=range]{flex:1 1 120px;min-width:80px;min-width:0;margin:0;height:28px;accent-color:var(--ink);cursor:pointer}.scrub output{font:700 var(--t-s)/1 var(--mono);min-width:12ch;white-space:nowrap}.beats{list-style:none;margin:0;padding:6px 0;max-height:480px;overflow:auto;overscroll-behavior:contain}.beat{padding:10px 18px}.beat+.beat{border-top:1px dashed var(--ink-3)}.bh{margin:0 0 6px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2);display:flex;flex-wrap:wrap;gap:4px 12px}.bt{font-weight:400;letter-spacing:.04em}.beat.now .bh .bn{background:var(--signal);color:var(--on-signal);padding:2px 5px;margin:-2px -5px}.evs{list-style:none;margin:0;padding:0;display:grid;gap:2px}.ev{width:calc(100% + 6px);display:flex;gap:1ch;text-align:left;background:transparent;border:0;padding:3px 6px;margin-left:-6px;cursor:pointer;border-radius:0;font-size:var(--t-s)}.ev .op{flex:none;min-width:9ch;font-weight:700}.ev .es{min-width:0;color:var(--ink-2);overflow-wrap:anywhere}.ev:hover .es{text-decoration:underline;text-underline-offset:3px}.ev.bad .op,.ev.bad .es{color:var(--danger)}.beat.later .bh,.beat.later .op,.beat.later .es{color:var(--ink-3)}.beat.later .ev .op{font-weight:400}.ev.on{background:var(--signal)}.ev.on .op,.ev.on .es{color:var(--on-signal)}.foot{display:grid;gap:10px;color:var(--ink-2);font-size:var(--t-s);max-width:100ch}.foot p{margin:0}.labrow{display:flex;flex-wrap:wrap;gap:10px;align-items:center}.confirm{flex-basis:100%;display:flex;flex-wrap:wrap;gap:10px;align-items:center;padding:10px 12px;border:2px dashed var(--ink);color:var(--ink)}@media(min-width:761px){.scrub{flex-wrap:nowrap}}@media(max-width:1120px){.work{grid-template-columns:minmax(0,1fr) minmax(0,370px);grid-template-areas:"hold side" "tree side" "time time"}}@media(max-width:760px){.clock{position:static}.work{grid-template-columns:minmax(0,1fr);grid-template-areas:"hold" "tree" "side" "time"}}@media(max-width:640px){.panel{box-shadow:5px 5px 0 var(--shadow)}.flag.proto{display:none}.tree{font-size:var(--t-s)}.sel,.grp{padding-left:10px}.v .belt{display:none}.beat{padding:10px 14px}.ev{flex-direction:column;gap:0}}@media(prefers-reduced-motion:reduce){.btn:active,.btn.sm:active{transform:none}}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.code-h{margin:0} diff --git a/ventures/lineage/orgchain/assets/index-eJVOEOGG.js b/ventures/lineage/orgchain/assets/index-eJVOEOGG.js deleted file mode 100644 index ffa7696..0000000 --- a/ventures/lineage/orgchain/assets/index-eJVOEOGG.js +++ /dev/null @@ -1,2049 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();const Mo=5e9;function Ra(t,e,n){const r=[];for(const[s,i]of t){const o=i-s;if(e>=o){e-=o;continue}const a=Math.min(n,o-e);if(a&&r.push([s+e,s+e+a]),n-=a,e=0,!n)break}return r}function ja(t,e){var n;return(n=Ra(t,e,1)[0])==null?void 0:n[0]}function Lr(t,e){let n=0;for(const[r,s]of t){if(e>=r&&eo.ranges);let i=0;return t.vout.map(o=>{const a=Ra(s,i,Number(o.value));return i+=Number(o.value),a})}function li(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Jl(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Za(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Ql(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");li(t.outputLen),li(t.blockLen)}function ef(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function tf(t,e){Za(t);const n=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),Xe=(t,e)=>t<<32-e|t>>>e,rf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!rf)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function sf(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function Ma(t){if(typeof t=="string"&&(t=sf(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}let of=class{clone(){return this._cloneInto()}};function Va(t){const e=r=>t().update(Ma(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function af(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}let cf=class extends of{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hs(this.buffer)}update(e){Ls.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=Ma(e);const i=e.length;for(let o=0;os-o&&(this.process(r,0),o=0);for(let l=o;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&n,lf=(t,e,n)=>t&e^t&n^e&n,ff=new Uint32Array([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]),wt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xt=new Uint32Array(64);let Ka=class extends cf{constructor(){super(64,32,8,!1),this.A=wt[0]|0,this.B=wt[1]|0,this.C=wt[2]|0,this.D=wt[3]|0,this.E=wt[4]|0,this.F=wt[5]|0,this.G=wt[6]|0,this.H=wt[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:c}=this;return[e,n,r,s,i,o,a,c]}set(e,n,r,s,i,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)xt[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const d=xt[l-15],h=xt[l-2],m=Xe(d,7)^Xe(d,18)^d>>>3,p=Xe(h,17)^Xe(h,19)^h>>>10;xt[l]=p+xt[l-7]+m+xt[l-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=Xe(a,6)^Xe(a,11)^Xe(a,25),h=f+d+uf(a,c,u)+ff[l]+xt[l]|0,p=(Xe(r,2)^Xe(r,13)^Xe(r,22))+lf(r,s,i)|0;f=u,u=c,c=a,a=o+h|0,o=i,i=s,s=r,r=h+p|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,i,o,a,c,u,f)}roundClean(){xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},df=class extends Ka{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const fi=Va(()=>new Ka);Va(()=>new df);function hf(t,e){if(t.length>e)throw new TypeError(`Data is larger than array size: ${t.length} > ${e}`)}function pf(t){if(t.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+t);if(t.length%2!==0)throw new Error(`Length of hex string is invalid: ${t.length}`)}function gf(t){if(t>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:mf}=crypto??globalThis.crypto??window.crypto;function bf(t=32){if(typeof mf=="function")return crypto.getRandomValues(new Uint8Array(t));throw new Error("Crypto module missing getRandomValues!")}function yf(t,e,n="be"){e===void 0&&(e=t.length),hf(t,e);const r=new Uint8Array(e).fill(0),s=n==="be"?0:e-t.length;return r.set(t,s),r}function qa(t){let e,n=0;const r=t.reduce((i,o)=>i+o.length,0),s=new Uint8Array(r);for(e=0;e0||(o.length^a)>0?"":"1";c in i||u>0;)f=i[c],f=f>0?f*256+u:u,u=f/s|0,i[c]=f%s,c++;for(;c-- >0;)o+=r[i[c]];return n&&o.length%4>0?o+"=".repeat(4-o.length%4):o}function Ef(t,e){const n=za(e),r=n.length,s=[],i=[];t=t.replace("=","");let o,a=0,c,u;for(o=0;o0||(i.length^o)>0||i.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)i.push(s[a]);return new Uint8Array(i)}function Fa(t){return fi(fi(t))}function Sf(t){const e=Fa(t);return qa([t,e.slice(0,4)])}function _f(t){const e=t.slice(0,-4),n=t.slice(-4);if(Fa(e).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return e}const Vo={encode:vf,decode:Ef},Ga={encode:t=>{const e=Sf(t);return Vo.encode(e,"base58")},decode:t=>{const e=Vo.decode(t,"base58");return _f(e)}},Wa="qpzry9x8gf2tvdw0s3jn54khce6mua7l",kf=[996825010,642813549,513874426,1027748829,705979059],Vr=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function Ya(t){let e=1;for(let n=0;n>25;e=(e&33554431)<<5^t[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(e^=kf[s])}return e}function Xa(t){const e=[];let n;for(n=0;n>5);for(e.push(0),n=0;n>5*(5-o)&31);return i}function Ja(t,e,n,r=!0){const s=[];let i=0,o=0;const a=(1<>e>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(i=(i<=n;)o-=n,s.push(i>>o&a)}if(r)o>0&&s.push(i<=e||(i<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function Bf(t,e,n){const r=e.concat($f(t,e,n));let s=t+"1";for(let i=0;ii.version===e[0])??Vr[0];if(!Af(r,e,s))throw new Error("Checksum verification failed!");return[r,e.slice(0,e.length-6)]}function Of(t){let e,n,r=!1,s=!1;for(e=0;e126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function Cf(t){const e=t.lastIndexOf("1");return!(e<1||e+7>t.length||t.length>90)}function Tf(t,e="bc",n=0){const r=[n,...Ja([...t],8,5)],s=Vr.find(o=>o.version===n)??Vr[0],i=Bf(e,r,s);return ec(i),i}function ec(t){t=t.toLowerCase();const e=t.split("1",1)[0],[n,r]=Qa(t),s=Ja(r.slice(1),5,8,!1),i=s.length;switch(!0){case e!==n:throw new Error("Returned hrp string is invalid.");case(s===null||i<2||i>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function If(t){t=t.toLowerCase();const[e,n]=Qa(t);return n[0]}const tc={encode:Tf,decode:ec,version:If},nc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",rc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Uf=new TextEncoder;function sc(t,e=!1,n=!0){typeof t=="string"&&(t=Uf.encode(t));const r=e?rc:nc;let s="",i=0,o=0;for(let a=0;a=6;)i-=6,s+=r[o>>i&63];if(i>0)for(o<<=6-i,s+=r[o&63];i<6;)s+=n?"=":"",i+=2;return s}function ic(t,e=!1){const n=e||t.includes("-")||t.includes("_")?rc.split(""):nc.split("");t=t.replace(/=+$/,"");const r=t.split("");let s=0,i=0;const o=[];for(let a=0;a=8&&(s-=8,o.push(i>>>s&255))}return new Uint8Array(o)}const oc={encode:sc,decode:ic},ac={encode:t=>sc(t,!0,!1),decode:t=>ic(t,!0)},Pf=BigInt(0),Nf=BigInt(255),cc=BigInt(256);function Lf(t){if(t<=0xffn)return 1;if(t<=0xffffn)return 2;if(t<=0xffffffffn)return 4;if(t<=0xffffffffffffffffn)return 8;if(t<=0xffffffffffffffffffffffffffffffffn)return 16;if(t<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function Hf(t,e,n="be"){e===void 0&&(e=Lf(t));const r=n==="le",s=new ArrayBuffer(e),i=new DataView(s);let o=r?0:e-1;for(;t>Pf;){const a=t&Nf,c=Number(a);r?i.setUint8(o++,c):i.setUint8(o--,c),t=(t-a)/cc}return new Uint8Array(s)}function Rf(t){let e=BigInt(0);for(let n=t.length-1;n>=0;n--)e=e*cc+BigInt(t[n]);return BigInt(e)}function jf(t){const e=t.split("").map(Number);if(e.length%8!==0)throw new Error(`Binary array is invalid length: ${t.length}`);const n=new Uint8Array(e.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)e[n]=r>>s&1}return e.join("")}function Zf(t){if(t<=255)return 1;if(t<=65535)return 2;if(t<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function Mf(t,e,n="be"){e===void 0&&(e=Zf(t));const r=n==="le",s=new ArrayBuffer(e),i=new DataView(s);let o=r?0:e-1;for(;t>0;){const a=t&255;r?i.setUint8(o++,t):i.setUint8(o--,t),t=(t-a)/256}return new Uint8Array(s)}function Vf(t){let e=0;for(let n=t.length-1;n>=0;n--)e=e*256+t[n],gf(e);return e}const Kf=new TextEncoder,qf=new TextDecoder;function ji(t){return Kf.encode(t)}function Rs(t){return qf.decode(t)}function zf(t,e){pf(t);const n=t.length/2;if(e===void 0&&(e=n),n>e)throw new TypeError(`Hex string is larger than array size: ${n} > ${e}`);return e}function Ff(t,e,n="le"){e=zf(t,e);const r=n==="le",s=new ArrayBuffer(e),i=new DataView(s);let o=r?0:e-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return ji(e)}function Yf(t,e,n){if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Uint8Array)return yf(t,e,n);if(typeof t=="string")return Ff(t,e,n);if(typeof t=="bigint")return Hf(t,e,n);if(typeof t=="number")return Mf(t,e,n);if(typeof t=="boolean")return Uint8Array.of(t?1:0);throw TypeError("Unsupported format:"+typeof t)}var W;let v=(W=class extends Uint8Array{static random(e=32){const n=bf(e);return new W(n,e)}constructor(e,n,r){const s=Yf(e,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new Ln(this)}toNum(e="be"){const n=e==="be"?this.reverse():this;return Vf(n)}toBin(){return Df(this)}toBig(e="be"){const n=e==="be"?this.reverse():this;return Rf(n)}toHash(){const e=fi(this);return new W(e)}toJson(){const e=Rs(this);return JSON.parse(e)}toBech32(e,n=0){return tc.encode(this,e,n)}toStr(){return Rs(this)}toHex(){return Gf(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return Ga.encode(this)}toBase64(){return oc.encode(this)}toB64url(){return ac.encode(this)}prepend(e){return W.join([W.bytes(e),this])}append(e){return W.join([this,W.bytes(e)])}slice(e,n){const r=new Uint8Array(this).slice(e,n);return new W(r)}subarray(e,n){const r=new Uint8Array(this).subarray(e,n);return new W(r)}reverse(){const e=new Uint8Array(this).reverse();return new W(e)}write(e,n){const r=W.bytes(e);this.set(r,n)}prefixSize(e){const n=W.varInt(this.length,e);return W.join([n,this])}static from(e){return new W(Uint8Array.from(e))}static of(...e){return new W(Uint8Array.of(...e))}static join(e){const n=e.map(s=>W.bytes(s)),r=qa(n);return new W(r)}static varInt(e,n){if(e<253)return W.num(e,1);if(e<65536)return W.of(253,...W.num(e,2,n));if(e<4294967296)return W.of(254,...W.num(e,4,n));if(BigInt(e)<0x10000000000000000n)return W.of(255,...W.num(e,8,n));throw new Error(`Value is too large: ${e}`)}},W.num=Xf,W.big=Qf,W.bin=Jf,W.raw=ed,W.str=td,W.hex=nd,W.bytes=rd,W.json=sd,W.base64=id,W.b64url=od,W.bech32=ad,W.b58chk=cd,W.encode=ji,W.decode=Rs,W);function Xf(t,e,n){return new v(t,e,n)}function Jf(t,e,n){return new v(jf(t),e,n)}function Qf(t,e,n){return new v(t,e,n)}function ed(t,e,n){return new v(t,e,n)}function td(t,e,n){return new v(ji(t),e,n)}function nd(t,e,n){return new v(t,e,n)}function rd(t,e,n){return new v(t,e,n)}function sd(t){return new v(Wf(t))}function id(t){return new v(oc.decode(t))}function od(t){return new v(ac.decode(t))}function ad(t){return new v(tc.decode(t))}function cd(t){return new v(Ga.decode(t))}let Ln=class{constructor(e){this.data=v.bytes(e),this.size=this.data.length}peek(e){if(e>this.size)throw new Error(`Size greater than stream: ${e} > ${this.size}`);return new v(this.data.slice(0,e))}read(e){e=e??this.readSize();const n=this.peek(e);return this.data=this.data.slice(e),this.size=this.data.length,n}readSize(e){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(e);case n===254:return this.read(4).toNum(e);case n===255:return this.read(8).toNum(e);default:throw new Error(`Varint is out of range: ${n}`)}}};function uc(t,e){const n=v.bytes(t);if(n.length!==e)throw new Error(`Invalid input size: ${n.hex} !== ${e}`)}function _e(t,e){if(e)throw new Error(t);return!1}function Hr(t,...e){const n=v.str(t).digest.raw,r=e.map(s=>v.bytes(s));return v.join([n,n,v.join(r)]).digest}const lc={OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_SUCCESS80:80,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_SUCCESS98:98,OP_IF:99,OP_NOTIF:100,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_SUCCESS126:126,OP_SUCCESS127:127,OP_SUCCESS128:128,OP_SUCCESS129:129,OP_SIZE:130,OP_SUCCESS131:131,OP_SUCCESS132:132,OP_SUCCESS133:133,OP_SUCCESS134:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_SUCCESS137:137,OP_SUCCESS138:138,OP_1ADD:139,OP_1SUB:140,OP_SUCCESS141:141,OP_SUCCESS142:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_SUCCESS149:149,OP_SUCCESS150:150,OP_SUCCESS151:151,OP_SUCCESS152:152,OP_SUCCESS153:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_SUCCESS187:187,OP_SUCCESS188:188,OP_SUCCESS189:189,OP_SUCCESS190:190,OP_SUCCESS191:191,OP_SUCCESS192:192,OP_SUCCESS193:193,OP_SUCCESS194:194,OP_SUCCESS195:195,OP_SUCCESS196:196,OP_SUCCESS197:197,OP_SUCCESS198:198,OP_SUCCESS199:199,OP_SUCCESS200:200,OP_SUCCESS201:201,OP_SUCCESS202:202,OP_SUCCESS203:203,OP_SUCCESS204:204,OP_SUCCESS205:205,OP_SUCCESS206:206,OP_SUCCESS207:207,OP_SUCCESS208:208,OP_SUCCESS209:209,OP_SUCCESS210:210,OP_SUCCESS211:211,OP_SUCCESS212:212,OP_SUCCESS213:213,OP_SUCCESS214:214,OP_SUCCESS215:215,OP_SUCCESS216:216,OP_SUCCESS217:217,OP_SUCCESS218:218,OP_SUCCESS219:219,OP_SUCCESS220:220,OP_SUCCESS221:221,OP_SUCCESS222:222,OP_SUCCESS223:223,OP_SUCCESS224:224,OP_SUCCESS225:225,OP_SUCCESS226:226,OP_SUCCESS227:227,OP_SUCCESS228:228,OP_SUCCESS229:229,OP_SUCCESS230:230,OP_SUCCESS231:231,OP_SUCCESS232:232,OP_SUCCESS233:233,OP_SUCCESS234:234,OP_SUCCESS235:235,OP_SUCCESS236:236,OP_SUCCESS237:237,OP_SUCCESS238:238,OP_SUCCESS239:239,OP_SUCCESS240:240,OP_SUCCESS241:241,OP_SUCCESS242:242,OP_SUCCESS243:243,OP_SUCCESS244:244,OP_SUCCESS245:245,OP_SUCCESS246:246,OP_SUCCESS247:247,OP_SUCCESS248:248,OP_SUCCESS249:249,OP_SUCCESS250:250,OP_SUCCESS251:251,OP_SUCCESS252:252,OP_SUCCESS253:253,OP_SUCCESS254:254};function ud(t){if(t>186&&t<255)return"OP_SUCCESS"+String(t);for(const[e,n]of Object.entries(lc))if(n===t)return e;throw new Error("OPCODE not found:"+String(t))}function ld(t){for(const[e,n]of Object.entries(lc))if(e===t)return Number(n);throw new Error("OPCODE not found:"+t)}function fd(t){switch(!0){case t===0:return"opcode";case(t>=1&&t<=75):return"varint";case t===76:return"pushdata1";case t===77:return"pushdata2";case t===78:return"pushdata4";case t<=254:return"opcode";default:throw new Error(`Invalid word range: ${t}`)}}function dd(t){const r=[];switch(!0){case typeof t!="number":return!1;case t===0:return!0;case r.includes(t):return!1;case(750?v.join(e):new Uint8Array}function hd(t){let e=new Uint8Array;if(typeof t=="string"){if(t.startsWith("OP_"))return v.num(ld(t),1);yt(t)?e=v.hex(t):e=v.str(t)}else e=v.bytes(t);if(e.length===1)return e[0]!==0&&e[0]<=16?(e[0]+=80,e):(e[0]>128&&e[0]<=255&&(e=new Uint8Array([e[0],0])),v.join([Ko(e.length),e]));if(e.length>Kr){const n=pd(e);return dc(n)}else return v.join([Ko(e.length),e])}function Ko(t){const e=v.num(76,1),n=v.num(77,1);switch(!0){case t<=75:return v.num(t);case(t>75&&t<256):return v.join([e,v.num(t,1,"le")]);case(t>=256&&t<=Kr):return v.join([n,v.num(t,2,"le")]);default:throw new Error("Invalid word size:"+t.toString())}}function pd(t){const e=[],n=new Ln(t);for(;n.size>Kr;)e.push(n.read(Kr));return e.push(n.read(n.size)),e}function Di(t,e=!1){let n=v.bytes(t);if(e){const s=n.stream.readSize("le");if(n=n.slice(1),n.length!==s)throw new Error(`Varint does not match stream size: ${s} !== ${n.length}`)}return gd(n)}function gd(t){const e=new Ln(t),n=[],r=e.size;let s,i,o,a=0;for(;a0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function vd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");di(t.outputLen),di(t.blockLen)}function Ed(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Sd(t,e){hc(t);const n=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),Je=(t,e)=>t<<32-e|t>>>e,kd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!kd)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ad(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function Zi(t){if(typeof t=="string"&&(t=Ad(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}function $d(...t){if(!t.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(t.length===1)return t[0];const e=t.reduce((r,s)=>r+s.length,0),n=new Uint8Array(e);for(let r=0,s=0;rt().update(Zi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Bd(t=32){if(js&&typeof js.getRandomValues=="function")return js.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Od(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}let Cd=class extends pc{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ds(this.buffer)}update(e){Ft.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=Zi(e);const i=e.length;for(let o=0;os-o&&(this.process(r,0),o=0);for(let l=o;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&n,Id=(t,e,n)=>t&e^t&n^e&n,Ud=new Uint32Array([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]),vt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Et=new Uint32Array(64);let mc=class extends Cd{constructor(){super(64,32,8,!1),this.A=vt[0]|0,this.B=vt[1]|0,this.C=vt[2]|0,this.D=vt[3]|0,this.E=vt[4]|0,this.F=vt[5]|0,this.G=vt[6]|0,this.H=vt[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:c}=this;return[e,n,r,s,i,o,a,c]}set(e,n,r,s,i,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)Et[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const d=Et[l-15],h=Et[l-2],m=Je(d,7)^Je(d,18)^d>>>3,p=Je(h,17)^Je(h,19)^h>>>10;Et[l]=p+Et[l-7]+m+Et[l-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=Je(a,6)^Je(a,11)^Je(a,25),h=f+d+Td(a,c,u)+Ud[l]+Et[l]|0,p=(Je(r,2)^Je(r,13)^Je(r,22))+Id(r,s,i)|0;f=u,u=c,c=a,a=o+h|0,o=i,i=s,s=r,r=h+p|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,i,o,a,c,u,f)}roundClean(){Et.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Pd=class extends mc{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const bc=gc(()=>new mc);gc(()=>new Pd);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nd=BigInt(0),Mi=BigInt(1),Ld=BigInt(2),vs=t=>t instanceof Uint8Array,Hd=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function _n(t){if(!vs(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nkn(t.toString(16).padStart(e*2,"0")),wc=(t,e)=>wn(t,e).reverse(),Rd=t=>kn(yc(t));function Me(t,e,n){let r;if(typeof e=="string")try{r=kn(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(vs(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${t} expected ${n} bytes, got ${s}`);return r}function Ve(...t){const e=new Uint8Array(t.reduce((r,s)=>r+s.length,0));let n=0;return t.forEach(r=>{if(!vs(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function jd(t,e){if(t.length!==e.length)return!1;for(let n=0;n0n;t>>=Mi,e+=1);return e}const Zd=(t,e)=>t>>BigInt(e)&1n,Md=(t,e,n)=>t|(n?Mi:Nd)<(Ld<new Uint8Array(t),qo=t=>Uint8Array.from(t);function xc(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Zs(t),s=Zs(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...l)=>n(s,r,...l),c=(l=Zs())=>{s=a(qo([0]),l),r=a(),l.length!==0&&(s=a(qo([1]),l),r=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const d=[];for(;l{o(),c(l);let h;for(;!(h=d(u()));)c();return o(),h}}const Vd={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Hn(t,e,n={}){const r=(s,i,o)=>{const a=Vd[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=t[s];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(n))r(s,i,!0);return t}var Kd=Object.freeze({__proto__:null,bitGet:Zd,bitLen:Dd,bitMask:qi,bitSet:Md,bytesToHex:_n,bytesToNumberBE:Lt,bytesToNumberLE:Ki,concatBytes:Ve,createHmacDrbg:xc,ensureBytes:Me,equalBytes:jd,hexToBytes:kn,hexToNumber:Vi,numberToBytesBE:wn,numberToBytesLE:wc,numberToHexUnpadded:yc,numberToVarBytesBE:Rd,utf8ToBytes:Es,validateObject:Hn});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ee=BigInt(0),be=BigInt(1),Kt=BigInt(2),qd=BigInt(3),hi=BigInt(4),zo=BigInt(5),Fo=BigInt(8);BigInt(9);BigInt(16);function ke(t,e){const n=t%e;return n>=Ee?n:e+n}function zd(t,e,n){if(n<=Ee||e 0");if(n===be)return Ee;let r=be;for(;e>Ee;)e&be&&(r=r*t%n),t=t*t%n,e>>=be;return r}function je(t,e,n){let r=t;for(;e-- >Ee;)r*=r,r%=n;return r}function pi(t,e){if(t===Ee||e<=Ee)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ke(t,e),r=e,s=Ee,i=be;for(;n!==Ee;){const a=r/n,c=r%n,u=s-i*a;r=n,n=c,s=i,i=u}if(r!==be)throw new Error("invert: does not exist");return ke(s,e)}function Fd(t){const e=(t-be)/Kt;let n,r,s;for(n=t-be,r=0;n%Kt===Ee;n/=Kt,r++);for(s=Kt;s(r[s]="function",r),e);return Hn(t,n)}function Yd(t,e,n){if(n 0");if(n===Ee)return t.ONE;if(n===be)return e;let r=t.ONE,s=e;for(;n>Ee;)n&be&&(r=t.mul(r,s)),s=t.sqr(s),n>>=be;return r}function Xd(t,e){const n=new Array(e.length),r=e.reduce((i,o,a)=>t.is0(o)?i:(n[a]=i,t.mul(i,o)),t.ONE),s=t.inv(r);return e.reduceRight((i,o,a)=>t.is0(o)?i:(n[a]=t.mul(i,n[a]),t.mul(i,o)),s),n}function zi(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ec(t,e,n=!1,r={}){if(t<=Ee)throw new Error(`Expected Fp ORDER > 0, got ${t}`);const{nBitLength:s,nByteLength:i}=zi(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Gd(t),a=Object.freeze({ORDER:t,BITS:s,BYTES:i,MASK:qi(s),ZERO:Ee,ONE:be,create:c=>ke(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ee<=c&&cc===Ee,isOdd:c=>(c&be)===be,neg:c=>ke(-c,t),eql:(c,u)=>c===u,sqr:c=>ke(c*c,t),add:(c,u)=>ke(c+u,t),sub:(c,u)=>ke(c-u,t),mul:(c,u)=>ke(c*u,t),pow:(c,u)=>Yd(a,c,u),div:(c,u)=>ke(c*pi(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>pi(c,t),sqrt:r.sqrt||(c=>o(a,c)),invertBatch:c=>Xd(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>n?wc(c,i):wn(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return n?Ki(c):Lt(c)}});return Object.freeze(a)}function Jd(t,e,n=!1){t=Me("privateHash",t);const r=t.length,s=zi(e).nByteLength+8;if(s<24||r1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const i=n?Ki(t):Lt(t);return ke(i,e-be)+be}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qd=BigInt(0),Ms=BigInt(1);function eh(t,e){const n=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:n,unsafeLadder(s,i){let o=t.ZERO,a=s;for(;i>Qd;)i&Ms&&(o=o.add(a)),a=a.double(),i>>=Ms;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),c=[];let u=s,f=u;for(let l=0;l>=h,g>c&&(g-=d,o+=Ms);const b=p,x=p+Math.abs(g)-1,w=m%2!==0,B=g<0;g===0?f=f.add(n(w,i[b])):u=u.add(n(B,i[x]))}return{p:u,f}},wNAFCached(s,i,o,a){const c=s._WINDOW_SIZE||1;let u=i.get(s);return u||(u=this.precomputeWindow(s,c),c!==1&&i.set(s,a(u))),this.wNAF(c,u,o)}}}function Sc(t){return vc(t.Fp),Hn(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...zi(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function th(t){const e=Sc(t);Hn(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:nh,hexToBytes:rh}=Kd,Gt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=Gt;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new e("Invalid signature integer: trailing length");return{d:nh(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=Gt,n=typeof t=="string"?rh(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Gt._parseInt(n.subarray(2)),{d:o,l:a}=Gt._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(t){const e=u=>Number.parseInt(u[0],16)>=8?"00"+u:u,n=u=>{const f=u.toString(16);return f.length&1?`0${f}`:f},r=e(n(t.s)),s=e(n(t.r)),i=r.length/2,o=s.length/2,a=n(i),c=n(o);return`30${n(o+i+4)}02${c}${s}02${a}${r}`}},Ke=BigInt(0),we=BigInt(1),at=BigInt(2),qr=BigInt(3),Go=BigInt(4);function sh(t){const e=th(t),{Fp:n}=e,r=e.toBytes||((m,p,g)=>{const b=p.toAffine();return Ve(Uint8Array.from([4]),n.toBytes(b.x),n.toBytes(b.y))}),s=e.fromBytes||(m=>{const p=m.subarray(1),g=n.fromBytes(p.subarray(0,n.BYTES)),b=n.fromBytes(p.subarray(n.BYTES,2*n.BYTES));return{x:g,y:b}});function i(m){const{a:p,b:g}=e,b=n.sqr(m),x=n.mul(b,m);return n.add(n.add(x,n.mul(m,p)),g)}function o(m){return typeof m=="bigint"&&Ken.eql(w,n.ZERO);return x(g)&&x(b)?l.ZERO:new l(g,b,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){const g=n.invertBatch(p.map(b=>b.pz));return p.map((b,x)=>b.toAffine(g[x])).map(l.fromAffine)}static fromHex(p){const g=l.fromAffine(s(Me("pointHex",p)));return g.assertValidity(),g}static fromPrivateKey(p){return l.BASE.multiply(c(p))}_setWindowSize(p){this._WINDOW_SIZE=p,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:p,y:g}=this.toAffine();if(!n.isValid(p)||!n.isValid(g))throw new Error("bad point: x or y not FE");const b=n.sqr(g),x=i(p);if(!n.eql(b,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:p}=this.toAffine();if(n.isOdd)return!n.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){f(p);const{px:g,py:b,pz:x}=this,{px:w,py:B,pz:A}=p,C=n.eql(n.mul(g,A),n.mul(w,x)),R=n.eql(n.mul(b,A),n.mul(B,x));return C&&R}negate(){return new l(this.px,n.neg(this.py),this.pz)}double(){const{a:p,b:g}=e,b=n.mul(g,qr),{px:x,py:w,pz:B}=this;let A=n.ZERO,C=n.ZERO,R=n.ZERO,L=n.mul(x,x),P=n.mul(w,w),J=n.mul(B,B),z=n.mul(x,w);return z=n.add(z,z),R=n.mul(x,B),R=n.add(R,R),A=n.mul(p,R),C=n.mul(b,J),C=n.add(A,C),A=n.sub(P,C),C=n.add(P,C),C=n.mul(A,C),A=n.mul(z,A),R=n.mul(b,R),J=n.mul(p,J),z=n.sub(L,J),z=n.mul(p,z),z=n.add(z,R),R=n.add(L,L),L=n.add(R,L),L=n.add(L,J),L=n.mul(L,z),C=n.add(C,L),J=n.mul(w,B),J=n.add(J,J),L=n.mul(J,z),A=n.sub(A,L),R=n.mul(J,P),R=n.add(R,R),R=n.add(R,R),new l(A,C,R)}add(p){f(p);const{px:g,py:b,pz:x}=this,{px:w,py:B,pz:A}=p;let C=n.ZERO,R=n.ZERO,L=n.ZERO;const P=e.a,J=n.mul(e.b,qr);let z=n.mul(g,w),M=n.mul(b,B),S=n.mul(x,A),_=n.add(g,b),y=n.add(w,B);_=n.mul(_,y),y=n.add(z,M),_=n.sub(_,y),y=n.add(g,x);let E=n.add(w,A);return y=n.mul(y,E),E=n.add(z,S),y=n.sub(y,E),E=n.add(b,x),C=n.add(B,A),E=n.mul(E,C),C=n.add(M,S),E=n.sub(E,C),L=n.mul(P,y),C=n.mul(J,S),L=n.add(C,L),C=n.sub(M,L),L=n.add(M,L),R=n.mul(C,L),M=n.add(z,z),M=n.add(M,z),S=n.mul(P,S),y=n.mul(J,y),M=n.add(M,S),S=n.sub(z,S),S=n.mul(P,S),y=n.add(y,S),z=n.mul(M,y),R=n.add(R,z),z=n.mul(E,y),C=n.mul(_,C),C=n.sub(C,z),z=n.mul(_,M),L=n.mul(E,L),L=n.add(L,z),new l(C,R,L)}subtract(p){return this.add(p.negate())}is0(){return this.equals(l.ZERO)}wNAF(p){return h.wNAFCached(this,u,p,g=>{const b=n.invertBatch(g.map(x=>x.pz));return g.map((x,w)=>x.toAffine(b[w])).map(l.fromAffine)})}multiplyUnsafe(p){const g=l.ZERO;if(p===Ke)return g;if(a(p),p===we)return this;const{endo:b}=e;if(!b)return h.unsafeLadder(this,p);let{k1neg:x,k1:w,k2neg:B,k2:A}=b.splitScalar(p),C=g,R=g,L=this;for(;w>Ke||A>Ke;)w&we&&(C=C.add(L)),A&we&&(R=R.add(L)),L=L.double(),w>>=we,A>>=we;return x&&(C=C.negate()),B&&(R=R.negate()),R=new l(n.mul(R.px,b.beta),R.py,R.pz),C.add(R)}multiply(p){a(p);let g=p,b,x;const{endo:w}=e;if(w){const{k1neg:B,k1:A,k2neg:C,k2:R}=w.splitScalar(g);let{p:L,f:P}=this.wNAF(A),{p:J,f:z}=this.wNAF(R);L=h.constTimeNegate(B,L),J=h.constTimeNegate(C,J),J=new l(n.mul(J.px,w.beta),J.py,J.pz),b=L.add(J),x=P.add(z)}else{const{p:B,f:A}=this.wNAF(g);b=B,x=A}return l.normalizeZ([b,x])[0]}multiplyAndAddUnsafe(p,g,b){const x=l.BASE,w=(A,C)=>C===Ke||C===we||!A.equals(x)?A.multiplyUnsafe(C):A.multiply(C),B=w(this,g).add(w(p,b));return B.is0()?void 0:B}toAffine(p){const{px:g,py:b,pz:x}=this,w=this.is0();p==null&&(p=w?n.ONE:n.inv(x));const B=n.mul(g,p),A=n.mul(b,p),C=n.mul(x,p);if(w)return{x:n.ZERO,y:n.ZERO};if(!n.eql(C,n.ONE))throw new Error("invZ was invalid");return{x:B,y:A}}isTorsionFree(){const{h:p,isTorsionFree:g}=e;if(p===we)return!0;if(g)return g(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:p,clearCofactor:g}=e;return p===we?this:g?g(l,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return this.assertValidity(),r(l,this,p)}toHex(p=!0){return _n(this.toRawBytes(p))}}l.BASE=new l(e.Gx,e.Gy,n.ONE),l.ZERO=new l(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,h=eh(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:o}}function ih(t){const e=Sc(t);return Hn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function oh(t){const e=ih(t),{Fp:n,n:r}=e,s=n.BYTES+1,i=2*n.BYTES+1;function o(y){return Ke_n(wn(y,e.nByteLength));function m(y){const E=r>>we;return y>E}function p(y){return m(y)?a(-y):y}const g=(y,E,k)=>Lt(y.slice(E,k));class b{constructor(E,k,U){this.r=E,this.s=k,this.recovery=U,this.assertValidity()}static fromCompact(E){const k=e.nByteLength;return E=Me("compactSignature",E,k*2),new b(g(E,0,k),g(E,k,2*k))}static fromDER(E){const{r:k,s:U}=Gt.toSig(Me("DER",E));return new b(k,U)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new b(this.r,this.s,E)}recoverPublicKey(E){const{r:k,s:U,recovery:I}=this,H=R(Me("msgHash",E));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const D=I===2||I===3?k+e.n:k;if(D>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const V=(I&1)===0?"02":"03",oe=u.fromHex(V+h(D)),ne=c(D),Q=a(-H*ne),ae=a(U*ne),ce=u.BASE.multiplyAndAddUnsafe(oe,Q,ae);if(!ce)throw new Error("point at infinify");return ce.assertValidity(),ce}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return kn(this.toDERHex())}toDERHex(){return Gt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return kn(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(y){try{return f(y),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const y=e.randomBytes(n.BYTES+8),E=Jd(y,r);return wn(E,e.nByteLength)},precompute(y=8,E=u.BASE){return E._setWindowSize(y),E.multiply(BigInt(3)),E}};function w(y,E=!0){return u.fromPrivateKey(y).toRawBytes(E)}function B(y){const E=y instanceof Uint8Array,k=typeof y=="string",U=(E||k)&&y.length;return E?U===s||U===i:k?U===2*s||U===2*i:y instanceof u}function A(y,E,k=!0){if(B(y))throw new Error("first arg must be private key");if(!B(E))throw new Error("second arg must be public key");return u.fromHex(E).multiply(f(y)).toRawBytes(k)}const C=e.bits2int||function(y){const E=Lt(y),k=y.length*8-e.nBitLength;return k>0?E>>BigInt(k):E},R=e.bits2int_modN||function(y){return a(C(y))},L=qi(e.nBitLength);function P(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(Ke<=y&&yse in k))throw new Error("sign() legacy options not supported");const{hash:U,randomBytes:I}=e;let{lowS:H,prehash:D,extraEntropy:V}=k;H==null&&(H=!0),y=Me("msgHash",y),D&&(y=Me("prehashed msgHash",U(y)));const oe=R(y),ne=f(E),Q=[P(ne),P(oe)];if(V!=null){const se=V===!0?I(n.BYTES):V;Q.push(Me("extraEntropy",se,n.BYTES))}const ae=Ve(...Q),ce=oe;function ve(se){const pe=C(se);if(!d(pe))return;const Vt=c(pe),ot=u.BASE.multiply(pe).toAffine(),Pe=a(ot.x);if(Pe===Ke)return;const hn=a(Vt*a(ce+Pe*ne));if(hn===Ke)return;let Do=(ot.x===Pe?0:2)|Number(ot.y&we),Zo=hn;return H&&m(hn)&&(Zo=p(hn),Do^=1),new b(Pe,Zo,Do)}return{seed:ae,k2sig:ve}}const z={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function S(y,E,k=z){const{seed:U,k2sig:I}=J(y,E,k);return xc(e.hash.outputLen,e.nByteLength,e.hmac)(U,I)}u.BASE._setWindowSize(8);function _(y,E,k,U=M){var ot;const I=y;if(E=Me("msgHash",E),k=Me("publicKey",k),"strict"in U)throw new Error("options.strict was renamed to lowS");const{lowS:H,prehash:D}=U;let V,oe;try{if(typeof I=="string"||I instanceof Uint8Array)try{V=b.fromDER(I)}catch(Pe){if(!(Pe instanceof Gt.Err))throw Pe;V=b.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:Pe,s:hn}=I;V=new b(Pe,hn)}else throw new Error("PARSE");oe=u.fromHex(k)}catch(Pe){if(Pe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(H&&V.hasHighS())return!1;D&&(E=e.hash(E));const{r:ne,s:Q}=V,ae=R(E),ce=c(Q),ve=a(ae*ce),se=a(ne*ce),pe=(ot=u.BASE.multiplyAndAddUnsafe(oe,ve,se))==null?void 0:ot.toAffine();return pe?a(pe.x)===ne:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:A,sign:S,verify:_,ProjectivePoint:u,Signature:b,utils:x}}function ah(t,e){const n=t.ORDER;let r=Ke;for(let d=n-we;d%at===Ke;d/=at)r+=we;const s=r,i=(n-we)/at**s,o=(i-we)/at,a=at**s-we,c=at**(s-we),u=t.pow(e,i),f=t.pow(e,(i+we)/at);let l=(d,h)=>{let m=u,p=t.pow(h,a),g=t.sqr(p);g=t.mul(g,h);let b=t.mul(d,g);b=t.pow(b,o),b=t.mul(b,p),p=t.mul(b,h),g=t.mul(b,d);let x=t.mul(g,p);b=t.pow(x,c);let w=t.eql(b,t.ONE);p=t.mul(g,f),b=t.mul(x,m),g=t.cmov(p,g,w),x=t.cmov(b,x,w);for(let B=s;B>1;B--){let A=at**(B-at),C=t.pow(x,A);const R=t.eql(C,t.ONE);p=t.mul(g,m),m=t.mul(m,m),C=t.mul(x,m),g=t.cmov(p,g,R),x=t.cmov(C,x,R)}return{isValid:w,value:g}};if(t.ORDER%Go===qr){const d=(t.ORDER-qr)/Go,h=t.sqrt(t.neg(e));l=(m,p)=>{let g=t.sqr(p);const b=t.mul(m,p);g=t.mul(g,b);let x=t.pow(g,d);x=t.mul(x,b);const w=t.mul(x,h),B=t.mul(t.sqr(x),p),A=t.eql(B,m);let C=t.cmov(w,x,A);return{isValid:A,value:C}}}return l}function ch(t,e){if(vc(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=ah(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,i,o,a,c,u,f,l;s=t.sqr(r),s=t.mul(s,e.Z),i=t.sqr(s),i=t.add(i,s),o=t.add(i,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(i),!t.eql(i,t.ZERO)),a=t.mul(a,e.A),i=t.sqr(o),u=t.sqr(a),c=t.mul(u,e.A),i=t.add(i,c),i=t.mul(i,o),u=t.mul(u,a),c=t.mul(u,e.B),i=t.add(i,c),f=t.mul(s,o);const{isValid:d,value:h}=n(i,u);l=t.mul(s,r),l=t.mul(l,h),f=t.cmov(f,o,d),l=t.cmov(l,h,d);const m=t.isOdd(r)===t.isOdd(l);return l=t.cmov(t.neg(l),l,m),f=t.div(f,a),{x:f,y:l}}}function uh(t){if(t instanceof Uint8Array)return t;if(typeof t=="string")return Es(t);throw new Error("DST must be Uint8Array or string")}const lh=Lt;function Ut(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const n=Array.from({length:e}).fill(0);for(let r=e-1;r>=0;r--)n[r]=t&255,t>>>=8;return new Uint8Array(n)}function fh(t,e){const n=new Uint8Array(t.length);for(let r=0;r255&&(e=r(Ve(Es("H2C-OVERSIZE-DST-"),e)));const{outputLen:s,blockLen:i}=r,o=Math.ceil(n/s);if(o>255)throw new Error("Invalid xmd length");const a=Ve(e,Ut(e.length,1)),c=Ut(0,i),u=Ut(n,2),f=new Array(o),l=r(Ve(c,t,u,Ut(0,1),a));f[0]=r(Ve(l,Ut(1,1),a));for(let h=1;h<=o;h++){const m=[fh(l,f[h-1]),Ut(h+1,1),a];f[h]=r(Ve(...m))}return Ve(...f).slice(0,n)}function hh(t,e,n,r,s){if(Gn(t),Gn(e),Fi(n),e.length>255){const i=Math.ceil(2*r/8);e=s.create({dkLen:i}).update(Es("H2C-OVERSIZE-DST-")).update(e).digest()}if(n>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(t).update(Ut(n,2)).update(e).update(Ut(e.length,1)).digest()}function Wo(t,e,n){Hn(n,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:i,hash:o,expand:a,DST:c}=n;Gn(t),Fi(e);const u=uh(c),f=r.toString(2).length,l=Math.ceil((f+s)/8),d=e*i*l;let h;if(a==="xmd")h=dh(t,u,d,o);else if(a==="xof")h=hh(t,u,d,s,o);else if(a===void 0)h=t;else throw new Error('expand must be "xmd", "xof" or undefined');const m=new Array(e);for(let p=0;pArray.from(r).reverse());return(r,s)=>{const[i,o,a,c]=n.map(u=>u.reduce((f,l)=>t.add(t.mul(f,r),l)));return r=t.div(i,o),s=t.mul(s,t.div(a,c)),{x:r,y:s}}}function gh(t,e,n){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,s){const i=Wo(r,2,{...n,DST:n.DST,...s}),o=t.fromAffine(e(i[0])),a=t.fromAffine(e(i[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,s){const i=Wo(r,1,{...n,DST:n.encodeDST,...s}),o=t.fromAffine(e(i[0])).clearCofactor();return o.assertValidity(),o}}}let _c=class extends pc{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Ft.hash(e);const r=Zi(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;onew _c(t,e).update(n).digest();kc.create=(t,e)=>new _c(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mh(t){return{hash:t,hmac:(e,...n)=>kc(t,e,$d(...n)),randomBytes:Bd}}function bh(t,e){const n=r=>oh({...t,...mh(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ac=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Yo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),yh=BigInt(1),gi=BigInt(2),Xo=(t,e)=>(t+e/gi)/e;function wh(t){const e=Ac,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,f=u*u*t%e,l=je(f,n,e)*f%e,d=je(l,n,e)*f%e,h=je(d,gi,e)*u%e,m=je(h,s,e)*h%e,p=je(m,i,e)*m%e,g=je(p,a,e)*p%e,b=je(g,c,e)*g%e,x=je(b,a,e)*p%e,w=je(x,n,e)*f%e,B=je(w,o,e)*m%e,A=je(B,r,e)*u%e,C=je(A,gi,e);if(!Ht.eql(Ht.sqr(C),t))throw new Error("Cannot find square root");return C}const Ht=Ec(Ac,void 0,void 0,{sqrt:wh}),gt=bh({a:BigInt(0),b:BigInt(7),Fp:Ht,n:Yo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Yo,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-yh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=Xo(i*t,e),c=Xo(-r*t,e);let u=ke(t-a*n-c*s,e),f=ke(-a*r-c*i,e);const l=u>o,d=f>o;if(l&&(u=e-u),d&&(f=e-f),u>o||f>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:d,k2:f}}}},bc);BigInt(0);gt.ProjectivePoint;gt.utils.randomPrivateKey;const xh=ph(Ht,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),vh=ch(Ht,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Ht.create(BigInt("-11"))});gh(gt.ProjectivePoint,t=>{const{x:e,y:n}=vh(Ht.create(t[0]));return xh(e,n)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Ht.ORDER,m:1,k:128,expand:"xmd",hash:bc});function mi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Eh(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function $c(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Sh(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");mi(t.outputLen),mi(t.blockLen)}function _h(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kh(t,e){$c(t);const n=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),Qe=(t,e)=>t<<32-e|t>>>e,$h=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!$h)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Bh(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function Bc(t){if(typeof t=="string"&&(t=Bh(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}let Oh=class{clone(){return this._cloneInto()}};function Oc(t){const e=r=>t().update(Bc(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ch(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}let Th=class extends Oh{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ks(this.buffer)}update(e){Vs.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=Bc(e);const i=e.length;for(let o=0;os-o&&(this.process(r,0),o=0);for(let l=o;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&n,Uh=(t,e,n)=>t&e^t&n^e&n,Ph=new Uint32Array([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]),St=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_t=new Uint32Array(64);let Cc=class extends Th{constructor(){super(64,32,8,!1),this.A=St[0]|0,this.B=St[1]|0,this.C=St[2]|0,this.D=St[3]|0,this.E=St[4]|0,this.F=St[5]|0,this.G=St[6]|0,this.H=St[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:c}=this;return[e,n,r,s,i,o,a,c]}set(e,n,r,s,i,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)_t[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const d=_t[l-15],h=_t[l-2],m=Qe(d,7)^Qe(d,18)^d>>>3,p=Qe(h,17)^Qe(h,19)^h>>>10;_t[l]=p+_t[l-7]+m+_t[l-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=Qe(a,6)^Qe(a,11)^Qe(a,25),h=f+d+Ih(a,c,u)+Ph[l]+_t[l]|0,p=(Qe(r,2)^Qe(r,13)^Qe(r,22))+Uh(r,s,i)|0;f=u,u=c,c=a,a=o+h|0,o=i,i=s,s=r,r=h+p|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,i,o,a,c,u,f)}roundClean(){_t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Nh=class extends Cc{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const bi=Oc(()=>new Cc);Oc(()=>new Nh);function Lh(t,e){if(t.length>e)throw new TypeError(`Data is larger than array size: ${t.length} > ${e}`)}function Hh(t){if(t.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+t);if(t.length%2!==0)throw new Error(`Length of hex string is invalid: ${t.length}`)}function Rh(t){if(t>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:jh}=crypto??globalThis.crypto??window.crypto;function Dh(t=32){if(typeof jh=="function")return crypto.getRandomValues(new Uint8Array(t));throw new Error("Crypto module missing getRandomValues!")}function Zh(t,e,n="be"){e===void 0&&(e=t.length),Lh(t,e);const r=new Uint8Array(e).fill(0),s=n==="be"?0:e-t.length;return r.set(t,s),r}function Tc(t){let e,n=0;const r=t.reduce((i,o)=>i+o.length,0),s=new Uint8Array(r);for(e=0;e0||(o.length^a)>0?"":"1";c in i||u>0;)f=i[c],f=f>0?f*256+u:u,u=f/s|0,i[c]=f%s,c++;for(;c-- >0;)o+=r[i[c]];return n&&o.length%4>0?o+"=".repeat(4-o.length%4):o}function qh(t,e){const n=Ic(e),r=n.length,s=[],i=[];t=t.replace("=","");let o,a=0,c,u;for(o=0;o0||(i.length^o)>0||i.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)i.push(s[a]);return new Uint8Array(i)}function Uc(t){return bi(bi(t))}function zh(t){const e=Uc(t);return Tc([t,e.slice(0,4)])}function Fh(t){const e=t.slice(0,-4),n=t.slice(-4);if(Uc(e).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return e}const Jo={encode:Kh,decode:qh},Pc={encode:t=>{const e=zh(t);return Jo.encode(e,"base58")},decode:t=>{const e=Jo.decode(t,"base58");return Fh(e)}},Nc="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Gh=[996825010,642813549,513874426,1027748829,705979059],zr=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function Lc(t){let e=1;for(let n=0;n>25;e=(e&33554431)<<5^t[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(e^=Gh[s])}return e}function Hc(t){const e=[];let n;for(n=0;n>5);for(e.push(0),n=0;n>5*(5-o)&31);return i}function Rc(t,e,n,r=!0){const s=[];let i=0,o=0;const a=(1<>e>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(i=(i<=n;)o-=n,s.push(i>>o&a)}if(r)o>0&&s.push(i<=e||(i<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function Xh(t,e,n){const r=e.concat(Yh(t,e,n));let s=t+"1";for(let i=0;ii.version===e[0])??zr[0];if(!Wh(r,e,s))throw new Error("Checksum verification failed!");return[r,e.slice(0,e.length-6)]}function Jh(t){let e,n,r=!1,s=!1;for(e=0;e126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function Qh(t){const e=t.lastIndexOf("1");return!(e<1||e+7>t.length||t.length>90)}function e0(t,e="bc",n=0){const r=[n,...Rc([...t],8,5)],s=zr.find(o=>o.version===n)??zr[0],i=Xh(e,r,s);return Dc(i),i}function Dc(t){t=t.toLowerCase();const e=t.split("1",1)[0],[n,r]=jc(t),s=Rc(r.slice(1),5,8,!1),i=s.length;switch(!0){case e!==n:throw new Error("Returned hrp string is invalid.");case(s===null||i<2||i>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function t0(t){t=t.toLowerCase();const[e,n]=jc(t);return n[0]}const Zc={encode:e0,decode:Dc,version:t0},Mc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",n0=new TextEncoder;function Kc(t,e=!1,n=!0){typeof t=="string"&&(t=n0.encode(t));const r=e?Vc:Mc;let s="",i=0,o=0;for(let a=0;a=6;)i-=6,s+=r[o>>i&63];if(i>0)for(o<<=6-i,s+=r[o&63];i<6;)s+=n?"=":"",i+=2;return s}function qc(t,e=!1){const n=e||t.includes("-")||t.includes("_")?Vc.split(""):Mc.split("");t=t.replace(/=+$/,"");const r=t.split("");let s=0,i=0;const o=[];for(let a=0;a=8&&(s-=8,o.push(i>>>s&255))}return new Uint8Array(o)}const zc={encode:Kc,decode:qc},Fc={encode:t=>Kc(t,!0,!1),decode:t=>qc(t,!0)},r0=BigInt(0),s0=BigInt(255),Gc=BigInt(256);function i0(t){if(t<=0xffn)return 1;if(t<=0xffffn)return 2;if(t<=0xffffffffn)return 4;if(t<=0xffffffffffffffffn)return 8;if(t<=0xffffffffffffffffffffffffffffffffn)return 16;if(t<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function o0(t,e,n="be"){e===void 0&&(e=i0(t));const r=n==="le",s=new ArrayBuffer(e),i=new DataView(s);let o=r?0:e-1;for(;t>r0;){const a=t&s0,c=Number(a);r?i.setUint8(o++,c):i.setUint8(o--,c),t=(t-a)/Gc}return new Uint8Array(s)}function a0(t){let e=BigInt(0);for(let n=t.length-1;n>=0;n--)e=e*Gc+BigInt(t[n]);return BigInt(e)}function c0(t){const e=t.split("").map(Number);if(e.length%8!==0)throw new Error(`Binary array is invalid length: ${t.length}`);const n=new Uint8Array(e.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)e[n]=r>>s&1}return e.join("")}function l0(t){if(t<=255)return 1;if(t<=65535)return 2;if(t<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function f0(t,e,n="be"){e===void 0&&(e=l0(t));const r=n==="le",s=new ArrayBuffer(e),i=new DataView(s);let o=r?0:e-1;for(;t>0;){const a=t&255;r?i.setUint8(o++,t):i.setUint8(o--,t),t=(t-a)/256}return new Uint8Array(s)}function d0(t){let e=0;for(let n=t.length-1;n>=0;n--)e=e*256+t[n],Rh(e);return e}const h0=new TextEncoder,p0=new TextDecoder;function Gi(t){return h0.encode(t)}function qs(t){return p0.decode(t)}function g0(t,e){Hh(t);const n=t.length/2;if(e===void 0&&(e=n),n>e)throw new TypeError(`Hex string is larger than array size: ${n} > ${e}`);return e}function m0(t,e,n="le"){e=g0(t,e);const r=n==="le",s=new ArrayBuffer(e),i=new DataView(s);let o=r?0:e-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return Gi(e)}function w0(t,e,n){if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Uint8Array)return Zh(t,e,n);if(typeof t=="string")return m0(t,e,n);if(typeof t=="bigint")return o0(t,e,n);if(typeof t=="number")return f0(t,e,n);if(typeof t=="boolean")return Uint8Array.of(t?1:0);throw TypeError("Unsupported format:"+typeof t)}const ee=class ee extends Uint8Array{static random(e=32){const n=Dh(e);return new ee(n,e)}constructor(e,n,r){const s=w0(e,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new I0(this)}toNum(e="be"){const n=e==="be"?this.reverse():this;return d0(n)}toBin(){return u0(this)}toBig(e="be"){const n=e==="be"?this.reverse():this;return a0(n)}toHash(){const e=bi(this);return new ee(e)}toJson(){const e=qs(this);return JSON.parse(e)}toBech32(e,n=0){return Zc.encode(this,e,n)}toStr(){return qs(this)}toHex(){return b0(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return Pc.encode(this)}toBase64(){return zc.encode(this)}toB64url(){return Fc.encode(this)}prepend(e){return ee.join([ee.bytes(e),this])}append(e){return ee.join([this,ee.bytes(e)])}slice(e,n){const r=new Uint8Array(this).slice(e,n);return new ee(r)}subarray(e,n){const r=new Uint8Array(this).subarray(e,n);return new ee(r)}reverse(){const e=new Uint8Array(this).reverse();return new ee(e)}write(e,n){const r=ee.bytes(e);this.set(r,n)}prefixSize(e){const n=ee.varInt(this.length,e);return ee.join([n,this])}static from(e){return new ee(Uint8Array.from(e))}static of(...e){return new ee(Uint8Array.of(...e))}static join(e){const n=e.map(s=>ee.bytes(s)),r=Tc(n);return new ee(r)}static varInt(e,n){if(e<253)return ee.num(e,1);if(e<65536)return ee.of(253,...ee.num(e,2,n));if(e<4294967296)return ee.of(254,...ee.num(e,4,n));if(BigInt(e)<0x10000000000000000n)return ee.of(255,...ee.num(e,8,n));throw new Error(`Value is too large: ${e}`)}};ee.num=x0,ee.big=E0,ee.bin=v0,ee.raw=S0,ee.str=_0,ee.hex=k0,ee.bytes=A0,ee.json=$0,ee.base64=B0,ee.b64url=O0,ee.bech32=C0,ee.b58chk=T0,ee.encode=Gi,ee.decode=qs;let F=ee;function x0(t,e,n){return new F(t,e,n)}function v0(t,e,n){return new F(c0(t),e,n)}function E0(t,e,n){return new F(t,e,n)}function S0(t,e,n){return new F(t,e,n)}function _0(t,e,n){return new F(Gi(t),e,n)}function k0(t,e,n){return new F(t,e,n)}function A0(t,e,n){return new F(t,e,n)}function $0(t){return new F(y0(t))}function B0(t){return new F(zc.decode(t))}function O0(t){return new F(Fc.decode(t))}function C0(t){return new F(Zc.decode(t))}function T0(t){return new F(Pc.decode(t))}class I0{constructor(e){this.data=F.bytes(e),this.size=this.data.length}peek(e){if(e>this.size)throw new Error(`Size greater than stream: ${e} > ${this.size}`);return new F(this.data.slice(0,e))}read(e){e=e??this.readSize();const n=this.peek(e);return this.data=this.data.slice(e),this.size=this.data.length,n}readSize(e){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(e);case n===254:return this.read(4).toNum(e);case n===255:return this.read(8).toNum(e);default:throw new Error(`Varint is out of range: ${n}`)}}}const Fr=gt.CURVE,Wi=Fr.n,U0=Fr.p,P0={x:Fr.Gx,y:Fr.Gy},N0=BigInt(0);BigInt(1);BigInt(2);BigInt(3);BigInt(4);const yi={N:Wi,P:U0,G:P0,_0n:N0},Mn=Ec(Wi,32,!0),Wc=t=>ke(t,Wi);function Yi(t,e=!1){if(e)throw new Error(t);return!1}function Yc(t){return F.random(t)}function L0(t){const e=F.bytes(t).big;return F.big(Wc(e),32)}var H0=Object.freeze({__proto__:null,fail:Yi,mod_bytes:L0,random:Yc});const{N:R0,_0n:j0}=yi;function D0(t,e,n){const r=F.bytes(t);return r.length!==e?Yi(`Invalid byte size: ${r.hex} !== ${e}`,n):!0}function Z0(t,e){return typeof t=="bigint"&&j0this.big}lt(e){return new de(e).big0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function q0(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");wi(t.outputLen),wi(t.blockLen)}function z0(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function F0(t,e){Xc(t);const n=e.outputLen;if(t.lengtht instanceof Uint8Array,zs=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),et=(t,e)=>t<<32-e|t>>>e,Y0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Y0)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function X0(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Xi(t){if(typeof t=="string"&&(t=X0(t)),!W0(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}let Jc=class{clone(){return this._cloneInto()}};function dn(t){const e=r=>t().update(Xi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function J0(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}class Ji extends Jc{constructor(e,n,r,s){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=zs(this.buffer)}update(e){Wt.exists(this);const{view:n,buffer:r,blockLen:s}=this;e=Xi(e);const i=e.length;for(let o=0;os-o&&(this.process(r,0),o=0);for(let l=o;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&n,ep=(t,e,n)=>t&e^t&n^e&n,tp=new Uint32Array([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]),kt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),At=new Uint32Array(64);let Qc=class extends Ji{constructor(){super(64,32,8,!1),this.A=kt[0]|0,this.B=kt[1]|0,this.C=kt[2]|0,this.D=kt[3]|0,this.E=kt[4]|0,this.F=kt[5]|0,this.G=kt[6]|0,this.H=kt[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:c}=this;return[e,n,r,s,i,o,a,c]}set(e,n,r,s,i,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)At[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const d=At[l-15],h=At[l-2],m=et(d,7)^et(d,18)^d>>>3,p=et(h,17)^et(h,19)^h>>>10;At[l]=p+At[l-7]+m+At[l-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=et(a,6)^et(a,11)^et(a,25),h=f+d+Q0(a,c,u)+tp[l]+At[l]|0,p=(et(r,2)^et(r,13)^et(r,22))+ep(r,s,i)|0;f=u,u=c,c=a,a=o+h|0,o=i,i=s,s=r,r=h+p|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,i,o,a,c,u,f)}roundClean(){At.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class np extends Qc{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const xi=dn(()=>new Qc);dn(()=>new np);const xr=BigInt(2**32-1),vi=BigInt(32);function eu(t,e=!1){return e?{h:Number(t&xr),l:Number(t>>vi&xr)}:{h:Number(t>>vi&xr)|0,l:Number(t&xr)|0}}function rp(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;sBigInt(t>>>0)<>>0),ip=(t,e,n)=>t>>>n,op=(t,e,n)=>t<<32-n|e>>>n,ap=(t,e,n)=>t>>>n|e<<32-n,cp=(t,e,n)=>t<<32-n|e>>>n,up=(t,e,n)=>t<<64-n|e>>>n-32,lp=(t,e,n)=>t>>>n-32|e<<64-n,fp=(t,e)=>e,dp=(t,e)=>t,hp=(t,e,n)=>t<>>32-n,pp=(t,e,n)=>e<>>32-n,gp=(t,e,n)=>e<>>64-n,mp=(t,e,n)=>t<>>64-n;function bp(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const yp=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),wp=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,xp=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),vp=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Ep=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Sp=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,_p={fromBig:eu,split:rp,toBig:sp,shrSH:ip,shrSL:op,rotrSH:ap,rotrSL:cp,rotrBH:up,rotrBL:lp,rotr32H:fp,rotr32L:dp,rotlSH:hp,rotlSL:pp,rotlBH:gp,rotlBL:mp,add:bp,add3L:yp,add3H:wp,add4L:xp,add4H:vp,add5H:Sp,add5L:Ep};var X=_p;const[kp,Ap]=X.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),$t=new Uint32Array(80),Bt=new Uint32Array(80);let Ss=class extends Ji{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:d,Gh:h,Gl:m,Hh:p,Hl:g}=this;return[e,n,r,s,i,o,a,c,u,f,l,d,h,m,p,g]}set(e,n,r,s,i,o,a,c,u,f,l,d,h,m,p,g){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=p|0,this.Hl=g|0}process(e,n){for(let w=0;w<16;w++,n+=4)$t[w]=e.getUint32(n),Bt[w]=e.getUint32(n+=4);for(let w=16;w<80;w++){const B=$t[w-15]|0,A=Bt[w-15]|0,C=X.rotrSH(B,A,1)^X.rotrSH(B,A,8)^X.shrSH(B,A,7),R=X.rotrSL(B,A,1)^X.rotrSL(B,A,8)^X.shrSL(B,A,7),L=$t[w-2]|0,P=Bt[w-2]|0,J=X.rotrSH(L,P,19)^X.rotrBH(L,P,61)^X.shrSH(L,P,6),z=X.rotrSL(L,P,19)^X.rotrBL(L,P,61)^X.shrSL(L,P,6),M=X.add4L(R,z,Bt[w-7],Bt[w-16]),S=X.add4H(M,C,J,$t[w-7],$t[w-16]);$t[w]=S|0,Bt[w]=M|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:h,Fl:m,Gh:p,Gl:g,Hh:b,Hl:x}=this;for(let w=0;w<80;w++){const B=X.rotrSH(l,d,14)^X.rotrSH(l,d,18)^X.rotrBH(l,d,41),A=X.rotrSL(l,d,14)^X.rotrSL(l,d,18)^X.rotrBL(l,d,41),C=l&h^~l&p,R=d&m^~d&g,L=X.add5L(x,A,R,Ap[w],Bt[w]),P=X.add5H(L,b,B,C,kp[w],$t[w]),J=L|0,z=X.rotrSH(r,s,28)^X.rotrBH(r,s,34)^X.rotrBH(r,s,39),M=X.rotrSL(r,s,28)^X.rotrBL(r,s,34)^X.rotrBL(r,s,39),S=r&i^r&a^i&a,_=s&o^s&c^o&c;b=p|0,x=g|0,p=h|0,g=m|0,h=l|0,m=d|0,{h:l,l:d}=X.add(u|0,f|0,P|0,J|0),u=a|0,f=c|0,a=i|0,c=o|0,i=r|0,o=s|0;const y=X.add3L(J,M,_);r=X.add3H(y,P,z,S),s=y|0}({h:r,l:s}=X.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=X.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=X.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=X.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=X.add(this.Eh|0,this.El|0,l|0,d|0),{h,l:m}=X.add(this.Fh|0,this.Fl|0,h|0,m|0),{h:p,l:g}=X.add(this.Gh|0,this.Gl|0,p|0,g|0),{h:b,l:x}=X.add(this.Hh|0,this.Hl|0,b|0,x|0),this.set(r,s,i,o,a,c,u,f,l,d,h,m,p,g,b,x)}roundClean(){$t.fill(0),Bt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class $p extends Ss{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class Bp extends Ss{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class Op extends Ss{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const Cp=dn(()=>new Ss);dn(()=>new $p);dn(()=>new Bp);dn(()=>new Op);const Tp=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),tu=Uint8Array.from({length:16},(t,e)=>e),Ip=tu.map(t=>(9*t+5)%16);let Qi=[tu],eo=[Ip];for(let t=0;t<4;t++)for(let e of[Qi,eo])e.push(e[t].map(n=>Tp[n]));const nu=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),Up=Qi.map((t,e)=>t.map(n=>nu[e][n])),Pp=eo.map((t,e)=>t.map(n=>nu[e][n])),Np=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Lp=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),vr=(t,e)=>t<>>32-e;function ea(t,e,n,r){return t===0?e^n^r:t===1?e&n|~e&r:t===2?(e|~n)^r:t===3?e&r|n&~r:e^(n|~r)}const Er=new Uint32Array(16);let Hp=class extends Ji{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:r,h3:s,h4:i}=this;return[e,n,r,s,i]}set(e,n,r,s,i){this.h0=e|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=i|0}process(e,n){for(let h=0;h<16;h++,n+=4)Er[h]=e.getUint32(n,!0);let r=this.h0|0,s=r,i=this.h1|0,o=i,a=this.h2|0,c=a,u=this.h3|0,f=u,l=this.h4|0,d=l;for(let h=0;h<5;h++){const m=4-h,p=Np[h],g=Lp[h],b=Qi[h],x=eo[h],w=Up[h],B=Pp[h];for(let A=0;A<16;A++){const C=vr(r+ea(h,i,a,u)+Er[b[A]]+p,w[A])+l|0;r=l,l=u,u=vr(a,10)|0,a=i,i=C}for(let A=0;A<16;A++){const C=vr(s+ea(m,o,c,f)+Er[x[A]]+g,B[A])+d|0;s=d,d=f,f=vr(c,10)|0,c=o,o=C}}this.set(this.h1+a+f|0,this.h2+u+d|0,this.h3+l+s|0,this.h4+r+o|0,this.h0+i+c|0)}roundClean(){Er.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const Rp=dn(()=>new Hp);let ru=class extends Jc{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Wt.hash(e);const r=Xi(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;onew ru(t,e).update(n).digest();su.create=(t,e)=>new ru(t,e);function An(t){const e=F.bytes(t);return F.raw(xi(xi(e)))}function jp(t){const e=F.bytes(t);return F.raw(Rp(xi(e)))}function Dp(t,e){const n=F.bytes(t),r=F.bytes(e);return F.raw(su(Cp,n,r))}function Zp(t){const e=F.str(t).digest;return F.join([e,e])}function Mp(t=32){return to(Yc(t))}function to(t){return Oe.mod(t).buff}function iu(t,e=!1){const n=Oe.mod(t).point;return e?n.x:n.buff}function ou(t,e){const n=fn.from_x(e),r=Oe.mod(t);return n.mul(r).buff}function Vp(t,e,n="ecdh/code"){const r=Zp(n),s=to(t),i=iu(s),o=F.bytes(e),a=ou(s,o),c=[i.hex,o.hex];return c.sort(),Dp(a,F.join([r,...c]))}function Kp(t){const e=F.bytes(t);switch(!0){case e.length===32:return!0;case(e.length===33&&e[0]===2):return!0;case(e.length===33&&e[0]===3):return!1;default:throw new TypeError(`Invalid public key: ${e.hex}`)}}function qp(t){const e=F.bytes(t);switch(e.length){case 32:return e;case 33:return e.slice(1,33);default:throw new Error(`Invalid key length: ${e.length}`)}}var zp=Object.freeze({__proto__:null,genSecretKey:Mp,getPublicKey:iu,getSecretKey:to,getSharedCode:Vp,getSharedKey:ou,is_even_pub:Kp,xonly_pub:qp});F.random(32);const au={secp:gt},Ei={...zp,...H0},Fp={main:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"};function rn(t){const e=v.bytes(t);return e.length>32?e.slice(1,33):e}const Gp=["bc1p","tb1p","bcrt1p"];function cu(t){for(const e of Gp)if(t.startsWith(e))return!0;return!1}function uu(t,e="main"){const n=Fp[e],r=v.bytes(t);return uc(r,32),r.toBech32(n,1)}function Wp(t){if(!cu(t))throw new TypeError("Invalid taproot address!");return v.bech32(t)}function Yp(t){const e=v.bytes(t);return uc(e,32),["OP_1",e.hex]}function Xp(t,e){const n=rn(t);return uu(n,e)}const Jp={check:cu,encode:uu,decode:Wp,scriptPubKey:Yp,fromPubKey:Xp},Qp={version:2,vin:[],vout:[],locktime:0},eg={scriptSig:[],sequence:4294967293,witness:[]},tg={value:0n,scriptPubKey:[]};function no(t){const e={...Qp,...t};return e.vin=e.vin.map(n=>({...eg,...n})),e.vout=e.vout.map(n=>({...tg,...n})),e}function $n(t,e){const{version:n,vin:r,vout:s,locktime:i}=no(t),o=e!==!0&&ng(r),a=[ro(n)];o&&a.push(v.hex("0001")),a.push(rg(r)),a.push(sg(s));for(const c of r)o&&a.push(og(c.witness));return a.push(so(i)),v.join(a)}function ng(t){for(const e of t){const{witness:n}=e;if(typeof n=="string"||n instanceof Uint8Array||Array.isArray(n)&&n.length>0)return!0}return!1}function ro(t){return v.num(t,4).reverse()}function cr(t){return v.hex(t,32).reverse()}function ur(t){return v.num(t,4).reverse()}function lr(t){if(typeof t=="string")return v.hex(t,4).reverse();if(typeof t=="number")return v.num(t,4).reverse();throw new Error("Unrecognized format: "+String(t))}function rg(t){const e=[v.varInt(t.length,"le")];for(const n of t){const{txid:r,vout:s,scriptSig:i,sequence:o}=n;e.push(cr(r)),e.push(ur(s)),e.push(ln(i,!0)),e.push(lr(o))}return v.join(e)}function Rt(t){if(typeof t=="number"){if(t%1!==0)throw new Error("Value must be an integer:"+String(t));return v.num(t,8).reverse()}return v.big(t,8).reverse()}function sg(t){const e=[v.varInt(t.length,"le")];for(const n of t)e.push(ig(n));return v.join(e)}function ig(t){const{value:e,scriptPubKey:n}=t,r=[];return r.push(Rt(e)),r.push(ln(n,!0)),v.join(r)}function og(t=[]){const e=[];if(Array.isArray(t)){const n=v.varInt(t.length);e.push(n);for(const r of t)e.push(ag(r));return v.join(e)}else return v.bytes(t)}function ag(t){return cg(t)?new v(0):ln(t,!0)}function cg(t){if(Array.isArray(t))return t.length===0;if(typeof t=="string"&&t==="")return!0;const e=v.bytes(t);return e.length===1&&e[0]===0}function so(t){if(typeof t=="string")return v.hex(t,4);if(typeof t=="number")return v.num(t,4).reverse();throw new Error("Unrecognized format: "+String(t))}function io(t){typeof t=="string"&&(t=v.hex(t).raw);const e=new Ln(t),n=ug(e),r=lg(e),s=fg(e),i=hg(e);if(r)for(const a of s)a.witness=gg(e);const o=mg(e);return{version:n,vin:s,vout:i,locktime:o}}function ug(t){return t.read(4).reverse().toNum()}function lg(t){const[e,n]=[...t.peek(2)];if(e===0){if(t.read(2),n===1)return!0;throw new Error(`Invalid witness flag: ${n}`)}return!1}function fg(t){const e=[],n=t.readSize("le");for(let r=0;r0?t.read(n).hex:null}function fu(t,e){const n=lu(t);return n!==null?n:[]}function mg(t){return t.read(4).reverse().toNum()}function bg(t){if(fc(t))return io(t);if(typeof t=="object"&&!(t instanceof Uint8Array))return $n(t),no(t);throw new Error("Invalid format: "+typeof t)}function yg(t){if(fc(t))return io(t),v.bytes(t);if(typeof t=="object")return $n(t);throw new Error("Invalid format: "+typeof t)}const oo={toBytes:yg,toJson:bg},wg=[["p2pkh",/^76a914(?\w{40})88ac$/],["p2sh",/^a914(?\w{40})87$/],["p2w-pkh",/^0014(?\w{40})$/],["p2w-sh",/^0020(?\w{64})$/],["p2tr",/^5120(?\w{64})$/]],xg=[192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,102,126,128,132,150,152,186,188,190];function vg(t){let e=t.at(-1);return yt(e)&&(e=v.hex(e)),t.length>1&&e instanceof Uint8Array&&e[0]===80?(t.pop(),v.raw(e)):null}function Eg(t){let e=t.at(-1);return yt(e)&&(e=v.hex(e)),t.length>1&&e instanceof Uint8Array&&e.length>32&&xg.includes(e[0]&254)?(t.pop(),v.raw(e)):null}function Sg(t){if(t.length>1){const e=t.at(-1);try{const n=xe.fmt.toBytes(e);return t.pop(),n}catch{return null}}return null}function _g(t){const e=[];for(const n of t)if(yt(n)||n instanceof Uint8Array||typeof n=="number")e.push(v.bytes(n));else throw new Error("unrecognized value: "+String(n));return e}function kg(t=[]){const e=[...t],n=vg(e),r=Eg(e),s=Sg(e),i=_g(e);return{annex:n,cblock:r,script:s,params:i}}function Ag(t){const e=xe.fmt.toBytes(t,!1).hex;for(const[n,r]of wg){const s=n,{groups:i}=r.exec(e)??{},{hash:o}=i??{};if(yt(o))return{type:s,data:v.hex(o)}}return{type:"raw",data:v.hex(e)}}function $g(t){const e=oo.toJson(t),n=$n(e,!0);return An(n).reverse().hex}function Bg(t){const e=oo.toJson(t),n=$n(e,!0).length,r=$n(e,!1).length,s=n*3+r,i=s%4>0?1:0,o=Math.floor(s/4)+i;return{size:r,bsize:n,vsize:o,weight:s}}const le={create:no,encode:$n,decode:io,fmt:oo,util:{getTxSize:Bg,getTxid:$g,readScriptPubKey:Ag,readWitness:kg}},Og={p2tr:Jp},Cg=[1,2,3];function ao(t,e,n={}){const{sigflag:r=1}=n,s=(r&128)===128,i=r%128;if(!Cg.includes(i))throw new Error("Invalid hash type: "+String(r));const o=le.fmt.toJson(t),{version:a,vin:c,vout:u,locktime:f}=o,{txid:l,vout:d,prevout:h,sequence:m}=c[e],{value:p}=h??{};if(p===void 0)throw new Error("Prevout value is empty!");let g=n.script;if(g===void 0&&n.pubkey!==void 0&&(g=`76a914${jp(n.pubkey).hex}88ac`),g===void 0)throw new Error("No pubkey / script has been set!");if(xe.fmt.toAsm(g).includes("OP_CODESEPARATOR"))throw new Error("This library does not currently support the use of OP_CODESEPARATOR in segwit scripts.");const b=[ro(a),Tg(c,s),Ig(c,i,s),cr(l),ur(d),xe.encode(g,!0),Rt(p),lr(m),Ug(u,e,i),so(f),v.num(r,4).reverse()];return An(v.join(b))}function Tg(t,e){if(e===!0)return v.num(0,32);const n=[];for(const{txid:r,vout:s}of t)n.push(cr(r)),n.push(ur(s));return An(v.join(n))}function Ig(t,e,n){if(n||e!==1)return v.num(0,32);const r=[];for(const{sequence:s}of t)r.push(lr(s));return An(v.join(r))}function Ug(t,e,n){const r=[];if(n===1){for(const{value:s,scriptPubKey:i}of t)r.push(Rt(s)),r.push(xe.encode(i,!0));return An(v.join(r))}if(n===3&&e1&&c[1].length===33)u=v.bytes(c[1]);else return _e("No pubkey provided!",s);const f=xe.fmt.toParam(c[0]),l=f.slice(0,-1),d=f.slice(-1)[0],h=ao(r,e,{...n,sigflag:d});return au.secp.verify(l,h,u)?!0:_e("Invalid signature!",s)}const Lg={hash:ao,sign:Pg,verify:Ng},Hg=[0,1,2,3,129,130,131];function co(t,e,n={}){const{extension:r,sigflag:s=0,extflag:i=0,key_version:o=0,separator_pos:a=4294967295}=n,c=le.fmt.toJson(t),{version:u,vin:f,vout:l,locktime:d}=c;if(e>=f.length)throw new Error("Index out of bounds: "+String(e));if(!Hg.includes(s))throw new Error("Invalid hash type: "+String(s));if(i<0||i>127)throw new Error("Extention flag out of range: "+String(i));const{txid:h,vout:m,sequence:p,witness:g=[]}=f[e],b=(s&128)===128,x=Kg(g),w=x!==void 0?1:0,A=(i+(r!==void 0?1:0))*2+w,C=v.str("TapSighash").digest,R=[C,C,v.num(0,1),v.num(s,1),ro(u),so(d)];if(!b){const L=f.map(P=>ta(P));R.push(Rg(f),Dg(L),Zg(L),jg(f))}if(((s&3)<2||(s&3)>3)&&R.push(Mg(l)),R.push(v.num(A,1)),b){const{value:L,scriptPubKey:P}=ta(f[e]);R.push(cr(h),ur(m),Rt(L),xe.encode(P,!0),lr(p))}else R.push(v.num(e,4).reverse());return x!==void 0&&R.push(x),(s&3)===3&&R.push(Vg(l[e])),r!==void 0&&R.push(v.bytes(r),v.num(o),v.num(a,4,"le")),v.join(R).digest}function Rg(t){const e=[];for(const{txid:n,vout:r}of t)e.push(cr(n)),e.push(ur(r));return v.join(e).digest}function jg(t){const e=[];for(const{sequence:n}of t)e.push(lr(n));return v.join(e).digest}function Dg(t){const e=[];for(const{value:n}of t)e.push(Rt(n));return v.join(e).digest}function Zg(t){const e=[];for(const{scriptPubKey:n}of t)e.push(ln(n,!0));return v.join(e).digest}function Mg(t){const e=[];for(const{value:n,scriptPubKey:r}of t)e.push(Rt(n)),e.push(xe.encode(r,!0));return v.join(e).digest}function Vg(t){return v.join([Rt(t.value),xe.encode(t.scriptPubKey,!0)]).digest}function Kg(t){if(t===void 0||t.length<2)return;let e=t.at(-1);if(typeof e=="string"&&(e=v.hex(e)),e instanceof Uint8Array&&e[0]===80)return v.raw(e).prefixSize("be").digest}function ta(t){if(t.prevout===void 0)throw new Error("Prevout data missing for input: "+String(t.txid));return t.prevout}const qg=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,zg=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Fg(t,e,n,r={}){const{sigflag:s=0}=r,i=co(e,n,r),o=Gg(t,i);return s===0?v.raw(o):v.join([o,s])}function Gg(t,e,n=v.random(32)){const r=v.bytes(e),s=new Oe(t),i=s.point,o=i.hasEvenY?s.big:s.negated.big,a=Hr("BIP0340/aux",v.bytes(n)),c=o^a.big,u=Hr("BIP0340/nonce",c,i.x.raw,r),f=new Oe(u),l=f.point,d=l.hasEvenY?f.big:f.negated.big,h=new Oe(Hr("BIP0340/challenge",l.x.raw,i.x.raw,r)),m=new Oe(d+h.big*o);return v.join([l.x.raw,m.raw])}function Wg(t,e,n,r=!1){const s=fn.from_x(rn(n)),i=v.bytes(e),o=v.bytes(t).stream;o.size<64&&_e("Signature length is too small: "+String(o.size),r);const a=o.read(32);a.big>qg&&_e("Signature r value greater than field size!",r);const c=o.read(32);c.big>zg&&_e("Signature s value greater than curve order!",r);const u=new Oe(Hr("BIP0340/challenge",a.raw,s.x.raw,i)),f=new Oe(c).point,l=s.mul(u.big),d=f.sub(l);return d.hasOddY&&_e("Signature R value has odd Y coordinate!",r),d.x.big===0n&&_e("Signature R value is infinite!",r),d.x.big===a.big}const Yg=192;function _s(t){const e=v.str(t).digest;return v.join([e,e])}function uo(t,e=Yg){return v.join([_s("TapLeaf"),Qg(e),v.bytes(t)]).digest.hex}function Xg(t,e){return uo(xe.fmt.toBytes(t),e)}function lo(t,e){return e0){const[h,m,p]=Gr(r,o);c=p,a=xn(t,h,n)}else o!==void 0?a=xn(t,o,n):a=xn(t,void 0,n);const u=n?Ei.getPublicKey(a)[0]:a[0],l=[v.num(s+bu(u)),i];c.length>0&&c.forEach(h=>l.push(v.hex(h)));const d=v.join(l);if(o!==void 0&&!fo(a,o,d,e))throw new Error("Path checking failed! Unable to generate path.");return[rn(a).hex,d.hex]}function fo(t,e,n,r={}){const{isPrivate:s=!1,throws:i=!1}=r,{parity:o,paths:a,intkey:c}=mu(n),u=s?Ei.getPublicKey(t,!0):rn(t),f=v.join([o,u]);if(f.length!==33)return _e("Invalid tapkey: "+f.hex,i);let l=v.bytes(e).hex;for(const h of a)l=lo(l,h);const d=xn(c,l);return v.raw(d).hex===v.raw(f).hex}function mu(t){const e=new Ln(v.bytes(t)),n=e.read(1).num,r=e.read(32),[s,i]=n%2===0?[n,2]:[n-1,3],o=[];for(;e.size>=32;)o.push(e.read(32).hex);if(e.size!==0)throw new Error("Non-empty buffer on control block: "+String(e));return{intkey:r,paths:o,parity:i,version:s}}function bu(t=2){if(t===0||t===1)return t;if(t===2||t==="02")return 0;if(t===3||t==="03")return 1;throw new Error("Invalid parity bit: "+String(t))}function am(t,e,n={}){const r=le.fmt.toJson(t),{throws:s=!1}=n,{prevout:i,witness:o=[]}=r.vin[e],a=le.util.readWitness(o),{cblock:c,script:u,params:f}=a;let l;if(f.length<1)return _e("Invalid witness data: "+String(o),s);const{scriptPubKey:d}=i??{};if(d===void 0)return _e("Prevout scriptPubKey is empty!",s);const{type:h,data:m}=le.util.readScriptPubKey(d);if(h!=="p2tr")return _e("Prevout script is not a valid taproot output:"+m.hex,s);if(m.length!==32)return _e("Invalid tapkey length: "+String(m.length),s);if(c!==null&&u!==null){const w=c[0]&254,B=uo(u,w);if(n.extension=B,!fo(m,B,c,{throws:s}))return _e("cblock verification failed!",s)}n.pubkey!==void 0?l=v.bytes(n.pubkey):f.length>1&&f[1].length===32?l=v.bytes(f[1]):l=v.bytes(m);const p=xe.fmt.toParam(f[0]),g=new Ln(p),b=g.read(64).raw;if(g.size===1&&(n.sigflag=g.read(1).num,n.sigflag===0))return _e("0x00 is not a valid appended sigflag!",s);const x=co(r,e,n);return Wg(b,x,l,s)?!0:_e("Invalid signature!",s)}const cm={hash:co,sign:Fg,verify:am},yu={segwit:Lg,taproot:cm},um={getTag:_s,getLeaf:uo,getBranch:lo,getRoot:Jg},lm={readCtrlBlock:mu,readParityBit:bu},fm={getPubKey:em,getSecKey:tm,getTweak:du,tweakSecKey:hu,tweakPubKey:pu},na={getPubKey:om,getSecKey:im,encodeScript:Xg,checkPath:fo,tree:um,tweak:fm,util:lm,SCRIPT_PUBKEY:rm};var re;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(re||(re={}));var Si;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Si||(Si={}));const N=re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=t=>{switch(typeof t){case"undefined":return N.undefined;case"string":return N.string;case"number":return isNaN(t)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(t)?N.array:t===null?N.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?N.promise:typeof Map<"u"&&t instanceof Map?N.map:typeof Set<"u"&&t instanceof Set?N.set:typeof Date<"u"&&t instanceof Date?N.date:N.object;default:return N.unknown}},$=re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dm=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Ge extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;cn.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ge.create=t=>new Ge(t);const Wn=(t,e)=>{let n;switch(t.code){case $.invalid_type:t.received===N.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case $.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,re.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:n=`Unrecognized key(s) in object: ${re.joinValues(t.keys,", ")}`;break;case $.invalid_union:n="Invalid input";break;case $.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${re.joinValues(t.options)}`;break;case $.invalid_enum_value:n=`Invalid enum value. Expected ${re.joinValues(t.options)}, received '${t.received}'`;break;case $.invalid_arguments:n="Invalid function arguments";break;case $.invalid_return_type:n="Invalid function return type";break;case $.invalid_date:n="Invalid date";break;case $.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:re.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case $.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case $.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case $.custom:n="Invalid input";break;case $.invalid_intersection_types:n="Intersection results could not be merged";break;case $.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case $.not_finite:n="Number must be finite";break;default:n=e.defaultError,re.assertNever(t)}return{message:n}};let wu=Wn;function hm(t){wu=t}function Wr(){return wu}const Yr=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};let a="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:s.message||a}},pm=[];function j(t,e){const n=Yr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wr(),Wn].filter(r=>!!r)});t.common.issues.push(n)}class $e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return G;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n)r.push({key:await s.key,value:await s.value});return $e.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return G;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const G=Object.freeze({status:"aborted"}),xu=t=>({status:"dirty",value:t}),Ie=t=>({status:"valid",value:t}),_i=t=>t.status==="aborted",ki=t=>t.status==="dirty",Xr=t=>t.status==="valid",Jr=t=>typeof Promise<"u"&&t instanceof Promise;var K;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(K||(K={}));class st{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ra=(t,e)=>{if(Xr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ge(t.common.issues);return this._error=n,this._error}}};function Y(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>o.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:r??a.defaultError}:{message:n??a.defaultError},description:s}}class te{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $e,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Jr(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const s={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},i=this._parseSync({data:e,path:s.path,parent:s});return ra(s,i)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Jr(s)?s:Promise.resolve(s));return ra(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:$.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new Ye({schema:this,typeName:q.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ht.create(this,this._def)}nullable(){return an.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return We.create(this,this._def)}promise(){return On.create(this,this._def)}or(e){return Qn.create([this,e],this._def)}and(e){return er.create(this,e,this._def)}transform(e){return new Ye({...Y(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ir({...Y(this._def),innerType:this,defaultValue:n,typeName:q.ZodDefault})}brand(){return new Eu({typeName:q.ZodBranded,type:this,...Y(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ns({...Y(this._def),innerType:this,catchValue:n,typeName:q.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return fr.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const gm=/^c[^\s-]{8,}$/i,mm=/^[a-z][a-z0-9]*$/,bm=/[0-9A-HJKMNP-TV-Z]{26}/,ym=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,wm=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,xm=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),vm=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Em=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Sm=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function _m(t,e){return!!((e==="v4"||!e)&&vm.test(t)||(e==="v6"||!e)&&Em.test(t))}class qe extends te{constructor(){super(...arguments),this._regex=(e,n,r)=>this.refinement(s=>e.test(s),{validation:n,code:$.invalid_string,...K.errToObj(r)}),this.nonempty=e=>this.min(1,K.errToObj(e)),this.trim=()=>new qe({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new qe({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new qe({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){const i=this._getOrReturnCtx(e);return j(i,{code:$.invalid_type,expected:N.string,received:i.parsedType}),G}const r=new $e;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(s=this._getOrReturnCtx(e,s),j(s,{code:$.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,...K.errToObj(e==null?void 0:e.message)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...K.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...K.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...K.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...K.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...K.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...K.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...K.errToObj(n)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value{var e;return new qe({checks:[],typeName:q.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...Y(t)})};function km(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}class jt extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){const i=this._getOrReturnCtx(e);return j(i,{code:$.invalid_type,expected:N.number,received:i.parsedType}),G}let r;const s=new $e;for(const i of this._def.checks)i.kind==="int"?re.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),j(r,{code:$.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),j(r,{code:$.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?km(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),j(r,{code:$.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),j(r,{code:$.not_finite,message:i.message}),s.dirty()):re.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,K.toString(n))}gt(e,n){return this.setLimit("min",e,!1,K.toString(n))}lte(e,n){return this.setLimit("max",e,!0,K.toString(n))}lt(e,n){return this.setLimit("max",e,!1,K.toString(n))}setLimit(e,n,r,s){return new jt({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:K.toString(s)}]})}_addCheck(e){return new jt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:K.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:K.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:K.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.valuee.kind==="int"||e.kind==="multipleOf"&&re.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.valuenew jt({checks:[],typeName:q.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Y(t)});class Dt extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==N.bigint){const i=this._getOrReturnCtx(e);return j(i,{code:$.invalid_type,expected:N.bigint,received:i.parsedType}),G}let r;const s=new $e;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),j(r,{code:$.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),j(r,{code:$.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):re.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,K.toString(n))}gt(e,n){return this.setLimit("min",e,!1,K.toString(n))}lte(e,n){return this.setLimit("max",e,!0,K.toString(n))}lt(e,n){return this.setLimit("max",e,!1,K.toString(n))}setLimit(e,n,r,s){return new Dt({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:K.toString(s)}]})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:K.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value{var e;return new Dt({checks:[],typeName:q.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...Y(t)})};class Yn extends te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==N.boolean){const r=this._getOrReturnCtx(e);return j(r,{code:$.invalid_type,expected:N.boolean,received:r.parsedType}),G}return Ie(e.data)}}Yn.create=t=>new Yn({typeName:q.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Y(t)});class sn extends te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){const i=this._getOrReturnCtx(e);return j(i,{code:$.invalid_type,expected:N.date,received:i.parsedType}),G}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return j(i,{code:$.invalid_date}),G}const r=new $e;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(s=this._getOrReturnCtx(e,s),j(s,{code:$.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):re.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new sn({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:K.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:K.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.valuenew sn({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:q.ZodDate,...Y(t)});class Qr extends te{_parse(e){if(this._getType(e)!==N.symbol){const r=this._getOrReturnCtx(e);return j(r,{code:$.invalid_type,expected:N.symbol,received:r.parsedType}),G}return Ie(e.data)}}Qr.create=t=>new Qr({typeName:q.ZodSymbol,...Y(t)});class Xn extends te{_parse(e){if(this._getType(e)!==N.undefined){const r=this._getOrReturnCtx(e);return j(r,{code:$.invalid_type,expected:N.undefined,received:r.parsedType}),G}return Ie(e.data)}}Xn.create=t=>new Xn({typeName:q.ZodUndefined,...Y(t)});class Jn extends te{_parse(e){if(this._getType(e)!==N.null){const r=this._getOrReturnCtx(e);return j(r,{code:$.invalid_type,expected:N.null,received:r.parsedType}),G}return Ie(e.data)}}Jn.create=t=>new Jn({typeName:q.ZodNull,...Y(t)});class Bn extends te{constructor(){super(...arguments),this._any=!0}_parse(e){return Ie(e.data)}}Bn.create=t=>new Bn({typeName:q.ZodAny,...Y(t)});class en extends te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ie(e.data)}}en.create=t=>new en({typeName:q.ZodUnknown,...Y(t)});class mt extends te{_parse(e){const n=this._getOrReturnCtx(e);return j(n,{code:$.invalid_type,expected:N.never,received:n.parsedType}),G}}mt.create=t=>new mt({typeName:q.ZodNever,...Y(t)});class es extends te{_parse(e){if(this._getType(e)!==N.undefined){const r=this._getOrReturnCtx(e);return j(r,{code:$.invalid_type,expected:N.void,received:r.parsedType}),G}return Ie(e.data)}}es.create=t=>new es({typeName:q.ZodVoid,...Y(t)});class We extends te{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==N.array)return j(n,{code:$.invalid_type,expected:N.array,received:n.parsedType}),G;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.lengths.maxLength.value&&(j(n,{code:$.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new st(n,o,n.path,a)))).then(o=>$e.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new st(n,o,n.path,a)));return $e.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new We({...this._def,minLength:{value:e,message:K.toString(n)}})}max(e,n){return new We({...this._def,maxLength:{value:e,message:K.toString(n)}})}length(e,n){return new We({...this._def,exactLength:{value:e,message:K.toString(n)}})}nonempty(e){return this.min(1,e)}}We.create=(t,e)=>new We({type:t,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...Y(e)});function bn(t){if(t instanceof ge){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=ht.create(bn(r))}return new ge({...t._def,shape:()=>e})}else return t instanceof We?new We({...t._def,type:bn(t.element)}):t instanceof ht?ht.create(bn(t.unwrap())):t instanceof an?an.create(bn(t.unwrap())):t instanceof it?it.create(t.items.map(e=>bn(e))):t}class ge extends te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=re.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==N.object){const u=this._getOrReturnCtx(e);return j(u,{code:$.invalid_type,expected:N.object,received:u.parsedType}),G}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof mt&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||a.push(u);const c=[];for(const u of o){const f=i[u],l=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new st(s,l,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof mt){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of a)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")a.length>0&&(j(s,{code:$.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of a){const l=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new st(s,l,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const l=await f.key;u.push({key:l,value:await f.value,alwaysSet:f.alwaysSet})}return u}).then(u=>$e.mergeObjectSync(r,u)):$e.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return new ge({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var s,i,o,a;const c=(o=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(a=K.errToObj(e).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new ge({...this._def,unknownKeys:"strip"})}passthrough(){return new ge({...this._def,unknownKeys:"passthrough"})}extend(e){return new ge({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ge({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:q.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new ge({...this._def,catchall:e})}pick(e){const n={};return re.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new ge({...this._def,shape:()=>n})}omit(e){const n={};return re.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new ge({...this._def,shape:()=>n})}deepPartial(){return bn(this)}partial(e){const n={};return re.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}),new ge({...this._def,shape:()=>n})}required(e){const n={};return re.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ht;)i=i._def.innerType;n[r]=i}}),new ge({...this._def,shape:()=>n})}keyof(){return vu(re.objectKeys(this.shape))}}ge.create=(t,e)=>new ge({shape:()=>t,unknownKeys:"strip",catchall:mt.create(),typeName:q.ZodObject,...Y(e)});ge.strictCreate=(t,e)=>new ge({shape:()=>t,unknownKeys:"strict",catchall:mt.create(),typeName:q.ZodObject,...Y(e)});ge.lazycreate=(t,e)=>new ge({shape:t,unknownKeys:"strip",catchall:mt.create(),typeName:q.ZodObject,...Y(e)});class Qn extends te{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new Ge(a.ctx.common.issues));return j(n,{code:$.invalid_union,unionErrors:o}),G}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},f=c._parseSync({data:n.data,path:n.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(c=>new Ge(c));return j(n,{code:$.invalid_union,unionErrors:a}),G}}get options(){return this._def.options}}Qn.create=(t,e)=>new Qn({options:t,typeName:q.ZodUnion,...Y(e)});const Rr=t=>t instanceof nr?Rr(t.schema):t instanceof Ye?Rr(t.innerType()):t instanceof rr?[t.value]:t instanceof Zt?t.options:t instanceof sr?Object.keys(t.enum):t instanceof ir?Rr(t._def.innerType):t instanceof Xn?[void 0]:t instanceof Jn?[null]:null;class ks extends te{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.object)return j(n,{code:$.invalid_type,expected:N.object,received:n.parsedType}),G;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(j(n,{code:$.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),G)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const i of n){const o=Rr(i.shape[e]);if(!o)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new ks({typeName:q.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Y(r)})}}function Ai(t,e){const n=Pt(t),r=Pt(e);if(t===e)return{valid:!0,data:t};if(n===N.object&&r===N.object){const s=re.objectKeys(e),i=re.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const c=Ai(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===N.array&&r===N.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i{if(_i(i)||_i(o))return G;const a=Ai(i.value,o.value);return a.valid?((ki(i)||ki(o))&&n.dirty(),{status:n.value,value:a.data}):(j(r,{code:$.invalid_intersection_types}),G)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}er.create=(t,e,n)=>new er({left:t,right:e,typeName:q.ZodIntersection,...Y(n)});class it extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.array)return j(r,{code:$.invalid_type,expected:N.array,received:r.parsedType}),G;if(r.data.lengththis._def.items.length&&(j(r,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new st(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>$e.mergeArray(n,o)):$e.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new it({...this._def,rest:e})}}it.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new it({items:t,typeName:q.ZodTuple,rest:null,...Y(e)})};class tr extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.object)return j(r,{code:$.invalid_type,expected:N.object,received:r.parsedType}),G;const s=[],i=this._def.keyType,o=this._def.valueType;for(const a in r.data)s.push({key:i._parse(new st(r,a,r.path,a)),value:o._parse(new st(r,r.data[a],r.path,a))});return r.common.async?$e.mergeObjectAsync(n,s):$e.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof te?new tr({keyType:e,valueType:n,typeName:q.ZodRecord,...Y(r)}):new tr({keyType:qe.create(),valueType:e,typeName:q.ZodRecord,...Y(n)})}}class ts extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.map)return j(r,{code:$.invalid_type,expected:N.map,received:r.parsedType}),G;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new st(r,a,r.path,[u,"key"])),value:i._parse(new st(r,c,r.path,[u,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return G;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),a.set(u.value,f.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const c of o){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return G;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),a.set(u.value,f.value)}return{status:n.value,value:a}}}}ts.create=(t,e,n)=>new ts({valueType:e,keyType:t,typeName:q.ZodMap,...Y(n)});class on extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.set)return j(r,{code:$.invalid_type,expected:N.set,received:r.parsedType}),G;const s=this._def;s.minSize!==null&&r.data.sizes.maxSize.value&&(j(r,{code:$.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(c){const u=new Set;for(const f of c){if(f.status==="aborted")return G;f.status==="dirty"&&n.dirty(),u.add(f.value)}return{status:n.value,value:u}}const a=[...r.data.values()].map((c,u)=>i._parse(new st(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new on({...this._def,minSize:{value:e,message:K.toString(n)}})}max(e,n){return new on({...this._def,maxSize:{value:e,message:K.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}on.create=(t,e)=>new on({valueType:t,minSize:null,maxSize:null,typeName:q.ZodSet,...Y(e)});class vn extends te{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.function)return j(n,{code:$.invalid_type,expected:N.function,received:n.parsedType}),G;function r(a,c){return Yr({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Wr(),Wn].filter(u=>!!u),issueData:{code:$.invalid_arguments,argumentsError:c}})}function s(a,c){return Yr({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Wr(),Wn].filter(u=>!!u),issueData:{code:$.invalid_return_type,returnTypeError:c}})}const i={errorMap:n.common.contextualErrorMap},o=n.data;return this._def.returns instanceof On?Ie(async(...a)=>{const c=new Ge([]),u=await this._def.args.parseAsync(a,i).catch(d=>{throw c.addIssue(r(a,d)),c}),f=await o(...u);return await this._def.returns._def.type.parseAsync(f,i).catch(d=>{throw c.addIssue(s(f,d)),c})}):Ie((...a)=>{const c=this._def.args.safeParse(a,i);if(!c.success)throw new Ge([r(a,c.error)]);const u=o(...c.data),f=this._def.returns.safeParse(u,i);if(!f.success)throw new Ge([s(u,f.error)]);return f.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new vn({...this._def,args:it.create(e).rest(en.create())})}returns(e){return new vn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new vn({args:e||it.create([]).rest(en.create()),returns:n||en.create(),typeName:q.ZodFunction,...Y(r)})}}class nr extends te{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}nr.create=(t,e)=>new nr({getter:t,typeName:q.ZodLazy,...Y(e)});class rr extends te{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return j(n,{received:n.data,code:$.invalid_literal,expected:this._def.value}),G}return{status:"valid",value:e.data}}get value(){return this._def.value}}rr.create=(t,e)=>new rr({value:t,typeName:q.ZodLiteral,...Y(e)});function vu(t,e){return new Zt({values:t,typeName:q.ZodEnum,...Y(e)})}class Zt extends te{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return j(n,{expected:re.joinValues(r),received:n.parsedType,code:$.invalid_type}),G}if(this._def.values.indexOf(e.data)===-1){const n=this._getOrReturnCtx(e),r=this._def.values;return j(n,{received:n.data,code:$.invalid_enum_value,options:r}),G}return Ie(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e){return Zt.create(e)}exclude(e){return Zt.create(this.options.filter(n=>!e.includes(n)))}}Zt.create=vu;class sr extends te{_parse(e){const n=re.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){const s=re.objectValues(n);return j(r,{expected:re.joinValues(s),received:r.parsedType,code:$.invalid_type}),G}if(n.indexOf(e.data)===-1){const s=re.objectValues(n);return j(r,{received:r.data,code:$.invalid_enum_value,options:s}),G}return Ie(e.data)}get enum(){return this._def.values}}sr.create=(t,e)=>new sr({values:t,typeName:q.ZodNativeEnum,...Y(e)});class On extends te{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.promise&&n.common.async===!1)return j(n,{code:$.invalid_type,expected:N.promise,received:n.parsedType}),G;const r=n.parsedType===N.promise?n.data:Promise.resolve(n.data);return Ie(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}On.create=(t,e)=>new On({type:t,typeName:q.ZodPromise,...Y(e)});class Ye extends te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){const o=s.transform(r.data);return r.common.async?Promise.resolve(o).then(a=>this._def.schema._parseAsync({data:a,path:r.path,parent:r})):this._def.schema._parseSync({data:o,path:r.path,parent:r})}const i={addIssue:o=>{j(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="refinement"){const o=a=>{const c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?G:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?G:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Xr(o))return o;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Xr(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):o);re.assertNever(s)}}Ye.create=(t,e,n)=>new Ye({schema:t,typeName:q.ZodEffects,effect:e,...Y(n)});Ye.createWithPreprocess=(t,e,n)=>new Ye({schema:e,effect:{type:"preprocess",transform:t},typeName:q.ZodEffects,...Y(n)});class ht extends te{_parse(e){return this._getType(e)===N.undefined?Ie(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ht.create=(t,e)=>new ht({innerType:t,typeName:q.ZodOptional,...Y(e)});class an extends te{_parse(e){return this._getType(e)===N.null?Ie(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}an.create=(t,e)=>new an({innerType:t,typeName:q.ZodNullable,...Y(e)});class ir extends te{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===N.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ir.create=(t,e)=>new ir({innerType:t,typeName:q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Y(e)});class ns extends te{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Jr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ge(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ge(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ns.create=(t,e)=>new ns({innerType:t,typeName:q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Y(e)});class rs extends te{_parse(e){if(this._getType(e)!==N.nan){const r=this._getOrReturnCtx(e);return j(r,{code:$.invalid_type,expected:N.nan,received:r.parsedType}),G}return{status:"valid",value:e.data}}}rs.create=t=>new rs({typeName:q.ZodNaN,...Y(t)});const Am=Symbol("zod_brand");class Eu extends te{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class fr extends te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?G:i.status==="dirty"?(n.dirty(),xu(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?G:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new fr({in:e,out:n,typeName:q.ZodPipeline})}}const Su=(t,e={},n)=>t?Bn.create().superRefine((r,s)=>{var i,o;if(!t(r)){const a=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(o=(i=a.fatal)!==null&&i!==void 0?i:n)!==null&&o!==void 0?o:!0,u=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...u,fatal:c})}}):Bn.create(),$m={object:ge.lazycreate};var q;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline"})(q||(q={}));const Bm=(t,e={message:`Input not instance of ${t.name}`})=>Su(n=>n instanceof t,e),_u=qe.create,ku=jt.create,Om=rs.create,Cm=Dt.create,Au=Yn.create,Tm=sn.create,Im=Qr.create,Um=Xn.create,Pm=Jn.create,Nm=Bn.create,Lm=en.create,Hm=mt.create,Rm=es.create,jm=We.create,Dm=ge.create,Zm=ge.strictCreate,Mm=Qn.create,Vm=ks.create,Km=er.create,qm=it.create,zm=tr.create,Fm=ts.create,Gm=on.create,Wm=vn.create,Ym=nr.create,Xm=rr.create,Jm=Zt.create,Qm=sr.create,eb=On.create,sa=Ye.create,tb=ht.create,nb=an.create,rb=Ye.createWithPreprocess,sb=fr.create,ib=()=>_u().optional(),ob=()=>ku().optional(),ab=()=>Au().optional(),cb={string:(t=>qe.create({...t,coerce:!0})),number:(t=>jt.create({...t,coerce:!0})),boolean:(t=>Yn.create({...t,coerce:!0})),bigint:(t=>Dt.create({...t,coerce:!0})),date:(t=>sn.create({...t,coerce:!0}))},ub=G;var Ce=Object.freeze({__proto__:null,defaultErrorMap:Wn,setErrorMap:hm,getErrorMap:Wr,makeIssue:Yr,EMPTY_PATH:pm,addIssueToContext:j,ParseStatus:$e,INVALID:G,DIRTY:xu,OK:Ie,isAborted:_i,isDirty:ki,isValid:Xr,isAsync:Jr,get util(){return re},get objectUtil(){return Si},ZodParsedType:N,getParsedType:Pt,ZodType:te,ZodString:qe,ZodNumber:jt,ZodBigInt:Dt,ZodBoolean:Yn,ZodDate:sn,ZodSymbol:Qr,ZodUndefined:Xn,ZodNull:Jn,ZodAny:Bn,ZodUnknown:en,ZodNever:mt,ZodVoid:es,ZodArray:We,ZodObject:ge,ZodUnion:Qn,ZodDiscriminatedUnion:ks,ZodIntersection:er,ZodTuple:it,ZodRecord:tr,ZodMap:ts,ZodSet:on,ZodFunction:vn,ZodLazy:nr,ZodLiteral:rr,ZodEnum:Zt,ZodNativeEnum:sr,ZodPromise:On,ZodEffects:Ye,ZodTransformer:Ye,ZodOptional:ht,ZodNullable:an,ZodDefault:ir,ZodCatch:ns,ZodNaN:rs,BRAND:Am,ZodBranded:Eu,ZodPipeline:fr,custom:Su,Schema:te,ZodSchema:te,late:$m,get ZodFirstPartyTypeKind(){return q},coerce:cb,any:Nm,array:jm,bigint:Cm,boolean:Au,date:Tm,discriminatedUnion:Vm,effect:sa,enum:Jm,function:Wm,instanceof:Bm,intersection:Km,lazy:Ym,literal:Xm,map:Fm,nan:Om,nativeEnum:Qm,never:Hm,null:Pm,nullable:nb,number:ku,object:Dm,oboolean:ab,onumber:ob,optional:tb,ostring:ib,pipeline:sb,preprocess:rb,promise:eb,record:zm,set:Gm,strictObject:Zm,string:_u,symbol:Im,transformer:sa,tuple:qm,undefined:Um,union:Mm,unknown:Lm,void:Rm,NEVER:ub,ZodIssueCode:$,quotelessJson:dm,ZodError:Ge});const $u=Ce.string().regex(/^[a-fA-F0-9]$/),lb=Ce.string().regex(/^[a-fA-F0-9]{64}$/),Cn=Ce.number().min(0).max(4294967295),fb=Ce.bigint(),Bu=Ce.instanceof(Uint8Array),db=Ce.union([$u,Cn,Ce.string(),Bu]).array(),ho=Ce.union([db,$u,Bu]),hb=Ce.array(ho),Ou=Ce.object({value:Ce.union([Cn,fb]),scriptPubKey:ho}),pb=Ce.object({txid:lb,vout:Cn,scriptSig:ho,sequence:Cn,prevout:Ou.optional(),witness:hb});Ce.object({version:Cn,vin:Ce.array(pb),vout:Ce.array(Ou),locktime:Cn});const $i=2048,gb=new TextEncoder;function Cu(t){const e=[],n=(s,i)=>{if(i<24)e.push(s*32+i);else if(i<=255)e.push(s*32+24,i);else if(i<=65535)e.push(s*32+25,i>>>8,i&255);else if(i<=4294967295){const o=new Uint8Array(4);new DataView(o.buffer).setUint32(0,i),e.push(s*32+26,...o)}else{e.push(s*32+27);const o=new Uint8Array(8);new DataView(o.buffer).setBigUint64(0,BigInt(i)),e.push(...o)}},r=(s,i=0)=>{if(i>64)throw new Error("Metadata nesting exceeds 64 levels.");if(s===null)e.push(246);else if(typeof s=="boolean")e.push(s?245:244);else if(typeof s=="number"&&Number.isFinite(s))if(Number.isSafeInteger(s)&&!Object.is(s,-0))n(s>=0?0:1,s>=0?s:-1-s);else{const o=new Uint8Array(8);new DataView(o.buffer).setFloat64(0,s),e.push(251,...o)}else if(typeof s=="string"){const o=gb.encode(s);n(3,o.length);for(const a of o)e.push(a)}else if(Array.isArray(s))n(4,s.length),s.forEach(o=>r(o,i+1));else if(typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){const o=Object.entries(s);n(5,o.length);for(const[a,c]of o)r(a,i+1),r(c,i+1)}else throw new Error("Metadata must contain only JSON values.");if(e.length>$i)throw new Error(`Metadata must be at most ${$i} CBOR bytes.`)};return r(t),Uint8Array.from(e)}function mb(t){if(t=new Uint8Array(t),!t.length||t.length>$i)throw new Error("Invalid CBOR metadata size.");let e=0;const n=i=>{if(e+i>t.length)throw new Error("Truncated CBOR metadata.");const o=t.slice(e,e+i);return e+=i,o},r=(i=0)=>{if(i>64)throw new Error("Metadata nesting exceeds 64 levels.");const o=n(1)[0],a=o>>5,c=o&31;if(a===7){if(c===20)return!1;if(c===21)return!0;if(c===22)return null;if(c===27){const f=new DataView(n(8).buffer).getFloat64(0);if(Number.isFinite(f))return f}throw new Error("Unsupported CBOR value.")}let u=c;if(c>=24&&c<=27){u=0;for(const f of n(2**(c-24)))u=u*256+f}else if(c>=28)throw new Error("Unsupported CBOR length.");if(!Number.isSafeInteger(u))throw new Error("CBOR integer exceeds JSON precision.");if(a===0)return u;if(a===1)return-1-u;if(a===3)return new TextDecoder("utf-8",{fatal:!0}).decode(n(u));if((a===4||a===5)&&u>t.length)throw new Error("Invalid CBOR collection length.");if(a===4)return Array.from({length:u},()=>r(i+1));if(a===5){const f={};for(let l=0;l({txid:t,vout:e,sequence:4294967295,prevout:{value:n,scriptPubKey:r}}),ze=(t,e)=>({value:t,scriptPubKey:e}),ia=16*1024,lt=1e3,Ae=500,ss="text/plain;charset=utf-8",bb=["text/plain","application/json","text/html","image/svg+xml","image/png","image/jpeg","image/webp"],Tu=new TextEncoder,Kn=t=>Array.from(t,e=>e.toString(16).padStart(2,"0")).join(""),qt=t=>Uint8Array.from(t.match(/../g)??[],e=>parseInt(e,16)),is=t=>Kn(Tu.encode(t));function po(t){const e=typeof t=="string"?{contentType:ss,bytes:Tu.encode(t)}:t;if(!e||![...bb,ss].includes(e.contentType))throw new Error("Unsupported MIME type.");if(!(e.bytes instanceof Uint8Array)||!e.bytes.length)throw new Error("Enter non-empty inscription bytes.");if(e.bytes.length>ia)throw new Error(`Body must be at most ${ia} bytes.`);return{contentType:e.contentType,bytes:new Uint8Array(e.bytes)}}function os(t){const e=/^([0-9a-f]{64})i(0|[1-9][0-9]*)$/.exec(t);if(!e||Number(e[2])>4294967295)throw new Error("Invalid parent inscription id.");let n=Number(e[2]),r="";for(;n;)r+=(n%256).toString(16).padStart(2,"0"),n=Math.floor(n/256);return e[1].match(/../g).reverse().join("")+r}function oa(t){if(typeof t!="string"||!/^[0-9a-f]{64,72}$/.test(t)||t.length%2)throw new Error("Invalid parent tag.");const e=[...qt(t.slice(64))].reduce((r,s,i)=>r+s*256**i,0),n=`${t.slice(0,64).match(/../g).reverse().join("")}i${e}`;if(os(n)!==t)throw new Error("Non-canonical parent tag.");return n}function Iu(t,e,n=null,r=void 0,s={}){const{contentType:i,bytes:o}=po(e),{delegate:a=null,pointer:c,metaprotocol:u=null}=s,f=u==null||u===""?null:new TextEncoder().encode(String(u));if(f&&f.length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");const l=r===void 0?void 0:Cu(r),d=[];for(let m=0;m{const p=m.length/2;return(p<=75?p.toString(16).padStart(2,"0"):p<=255?"4c"+p.toString(16).padStart(2,"0"):"4d"+(p%256).toString(16).padStart(2,"0")+Math.floor(p/256).toString(16).padStart(2,"0"))+m};return h(t)+"ac0063"+h(is("ord"))+h("01")+h(is(i))+(a?h("0b")+h(os(a)):"")+(c===void 0?"":h("02")+h(Uu(c)))+(n?h("03")+h(os(n)):"")+(l===void 0?"":Array.from({length:Math.ceil(l.length/520)},(m,p)=>h("05")+h(Kn(l.slice(p*520,(p+1)*520)))).join(""))+(f?h("07")+h(Kn(f)):"")+"00"+d.map(h).join("")+"68"}function go(t){if(!Array.isArray(t)||t.length!==3)throw new Error("Unsupported script-path witness.");const e=xe.decode(t[1]);let n=7,r=null,s=null,i;e[n]==="0b"&&(s=oa(e[n+1]),n+=2),e[n]==="02"&&(i=wb(e[n+1]==="OP_0"?"":e[n+1]),n+=2),e[n]==="03"&&(r=oa(e[n+1]),n+=2);const o=[];for(;e[n]==="05";){const m=e[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metadata push.");o.push(m),n+=2}const a=o.length?mb(qt(o.join(""))):void 0;let c=null;if(e[n]==="07"){const m=e[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metaprotocol field.");c=new TextDecoder().decode(qt(m)),n+=2}if(e[n]!=="OP_0")throw new Error("Unsupported ord tag or missing body separator.");const u=e.slice(n+1,-1);if(!u.length||u.some(m=>typeof m!="string"||!/^(?:[0-9a-f]{2})+$/.test(m)))throw new Error("Invalid body envelope.");const f=new TextDecoder().decode(qt(e[6])),l=po({contentType:f,bytes:qt(u.join(""))}),d=Iu(e[0],l,r,a,{delegate:s,pointer:i,metaprotocol:c}),h=a===void 0&&!r&&f===ss&&l.bytes.length<=280&&xe.encode([e[0],"OP_CHECKSIG","OP_0","OP_IF",is("ord"),"01",is(ss),"OP_0",Kn(l.bytes),"OP_ENDIF"],!1).hex;if(d!==t[1]&&h!==t[1])throw new Error("Unsupported ord envelope.");if(!/^[0-9a-f]{64}$/.test(e[0]))throw new Error("Invalid inscription signing key.");return{...l,parent:r,delegate:s,pointer:i,metaprotocol:c,metadata:a,metadataBytes:o.length?qt(o.join("")):void 0,text:new TextDecoder().decode(l.bytes),pubkey:e[0]}}class yb{constructor(e,n){this.chain=e,this.wallet=n}prepare(e,n=null,r=void 0,s={}){const i=po(e);if(r!==void 0&&Cu(r),s.delegate&&os(s.delegate),s.pointer!==void 0&&Uu(s.pointer),s.metaprotocol!==void 0&&s.metaprotocol!==null&&s.metaprotocol!==""&&new TextEncoder().encode(String(s.metaprotocol)).length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");if(n&&s.reinscribe)throw new Error("Choose parent or reinscription, not both.");const o=this.chain.coins(this.wallet.script),a=n?o.find(f=>{var l;return(l=f.inscriptions)==null?void 0:l.some(d=>d.id===n)}):null;if(n&&!a)throw new Error("Parent must be an owned, unspent inscription.");const c=s.reinscribe?o.find(f=>{var l;return(l=f.inscriptions)==null?void 0:l.some(d=>d.id===s.reinscribe)}):null;if(s.reinscribe&&!c)throw new Error("Reinscription must spend an owned sat.");const u=o.find(f=>!f.inscription&&f.value>=lt+2*Ae+330);if(!u)throw new Error("Mine a block first to get spendable fake BTC.");return{...i,coin:u,parent:a,reinscribe:c,totalFee:Ae*2,postage:lt}}inscribe(e,n=null,r=void 0,s={}){const{coin:i,parent:o,reinscribe:a,...c}=this.prepare(e,n,r,s),u=o??a,f=a==null?void 0:a.inscriptions.find(B=>B.id===s.reinscribe),l=f?this.chain.satLocation(f.sat).offset:s.pointer??(o?o.value:void 0),d=Iu(this.wallet.pubkey,c,n,r,{...s,pointer:l}),h=na.encodeScript(d),[m,p]=na.getPubKey(this.wallet.pubkey,{target:h}),g=le.create({vin:[En(i.txid,i.vout,i.value,i.scriptPubKey)],vout:[ze(lt+Ae,["OP_1",m]),ze(i.value-lt-2*Ae,this.wallet.script)]});g.vin[0].witness=[this.wallet.sign(g)];const b=le.util.getTxid(g),x=le.create({vin:[...u?[En(u.txid,u.vout,u.value,u.scriptPubKey)]:[],En(b,0,lt+Ae,["OP_1",m])],vout:[...u?[ze(u.value,this.wallet.script)]:[],ze(lt,this.wallet.script)]}),w=u?1:0;return x.vin[w].witness=[this.wallet.sign(x,h,w),xe.encode(d,!1).hex,p],u&&(x.vin[0].witness=[this.wallet.sign(x)]),this.chain.submitPackage([le.encode(g).hex,le.encode(x).hex]),`${le.util.getTxid(x)}i0`}list(){return this.chain.coins(this.wallet.script).flatMap(e=>e.inscriptions??[])}}function Uu(t){let e;try{e=BigInt(t)}catch{throw new Error("Invalid pointer.")}if(e<0n||e>0xffffffffffffffffn||typeof t=="number"&&!Number.isSafeInteger(t))throw new Error("Invalid pointer.");let n="";for(;e;)n+=Number(e&255n).toString(16).padStart(2,"0"),e>>=8n;return n}function wb(t){if(typeof t!="string"||!/^(?:[0-9a-f]{2}){0,8}$/.test(t))throw new Error("Invalid pointer tag.");return[...qt(t)].reduce((e,n,r)=>e+(BigInt(n)<{var b;const o=le.decode(r),a=le.util.getTxid(o),c=o.vin[0].txid==="0".repeat(64),u=c?[]:o.vin.map(x=>this.utxos.get(`${x.txid}:${x.vout}`)),f=Da(o,u,s,c);o.vin.forEach(x=>this.utxos.delete(`${x.txid}:${x.vout}`)),o.vout.forEach((x,w)=>this.utxos.set(`${a}:${w}`,{txid:a,vout:w,value:Number(x.value),ranges:f[w]}));const l=(b=o.vin.find(x=>{var w;return((w=x.witness)==null?void 0:w.length)===3}))==null?void 0:b.witness;if(!l)return;const d=go(l),h=BigInt(d.pointer??0),m=o.vout.reduce((x,w)=>x+Number(w.value),0),p=ja(f.flat(),hx.sat===p).length,status:s===null?"pending":"confirmed",height:s,block:i,metadata:g??null,hasMetadata:g!==void 0,parent:d.parent,protocol:d.metaprotocol??(g&&!Array.isArray(g)&&typeof g=="object"&&Object.hasOwn(g,"protocol")&&typeof g.protocol=="string"?g.protocol:null)})};for(const r of e.blocks)for(const s of r.raws)n(s,r.height,r.hash);for(const r of e.mempool)n(r,null,null);for(const r of this.events){r.location=null;for(const s of this.utxos.values()){const i=Lr(s.ranges,r.sat);if(i!==null){r.location={txid:s.txid,vout:s.vout,offset:i};break}}r.delegatedBy=this.events.filter(s=>s.delegate===r.id).map(s=>s.id),r.inscriptions=this.events.filter(s=>s.sat===r.sat).map(s=>s.id)}}forProtocol(e){return this.events.filter(n=>n.protocol===e)}get protocols(){return[...new Set(this.events.filter(e=>e.protocol!==null).map(e=>e.protocol))].sort()}get stats(){return{events:this.events.length,withMetadata:this.events.filter(e=>e.hasMetadata).length,confirmed:this.events.filter(e=>e.status==="confirmed").length,pending:this.events.filter(e=>e.status==="pending").length,protocols:this.protocols}}}const mo="lineage/v0",xb=["white","green","black"],aa="names are 1-40 lowercase letters, digits or hyphens (they become domains)",vb=/^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/,Fs=t=>typeof t=="string"&&vb.test(t),jr=(t,e)=>typeof t=="string"?t.trim().slice(0,e):"";function bo(t){return String(t??"").toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,"")}const yo=t=>t.events.filter(e=>e.protocol===mo);function Tn(t,{upTo:e=1/0,pending:n=!1}={}){const r=new Map,s=[],i=[],o=a=>a.status==="active";for(const a of t){const c=a.status==="confirmed";if(c?a.height>e:!n)continue;const u=a.metadata&&typeof a.metadata=="object"&&!Array.isArray(a.metadata)?a.metadata:{},f={id:a.id,op:typeof u.op=="string"?u.op.slice(0,20):"?",beat:c?a.height:null,pending:!c,meta:u,parent:a.parent??null,ok:!0,why:"",node:null,root:null,also:[]},l=f.parent?r.get(f.parent):null,d=f.beat??"cued",h=g=>{f.ok=!1,f.why=g},m=g=>l?o(l)?"":`the ${g} is ${l.status}`:`the ${g} is not in this lineage`;let p="";switch(f.op){case"found":if(f.parent)h("a holding has no parent");else if(!Fs(u.name))h(aa);else if(s.some(g=>o(g)&&g.name===u.name))h(`an active holding is already named ${u.name}`);else{const g=ca(a,u.name,null,"holding");r.set(g.id,g),s.push(g),f.node=g.id}break;case"birth":{const g=u.kind==="agent"?"agent":"org";if(p=m("parent"))h(p);else if(l.kind==="agent")h("agents do not give birth");else if(!Fs(u.name))h(aa);else if(l.children.some(b=>o(r.get(b))&&r.get(b).name===u.name))h(`${l.name} already has an active ${u.name}`);else{const b=ca(a,u.name,l,g);b.index=l.children.filter(x=>r.get(x).kind===g).length,l.children.push(b.id),r.set(b.id,b),f.node=b.id}break}case"award":{const g=r.get(u.to);(p=m("issuer"))?h(p):l.kind==="agent"?h("agents do not award belts"):!g||g.root!==l.root||g.id===l.id?h("the recipient must be another node in this holding"):o(g)?!Fs(u.skill)||!xb.includes(u.belt)?h("an award needs a skill name and a belt (white, green or black)"):(g.badges=g.badges.filter(b=>b.skill!==u.skill),g.badges.push({skill:u.skill,belt:u.belt,by:l.id,beat:d,id:a.id}),f.node=g.id):h(`the recipient is ${g.status}`);break}case"decide":(p=m("decider"))?h(p):jr(u.title,140)?(l.decisions.push({title:jr(u.title,140),why:jr(u.why,400),beat:d,id:a.id}),f.node=l.id):h("a decision needs a title");break;case"graduate":{const g=r.get(u.of);(p=m("parent"))?h(p):!g||g.parent!==l.id?h("only its parent can graduate a child"):g.kind!=="org"?h("only orgs graduate"):o(g)?g.edge==="adopted"?h("already graduated"):(g.edge="adopted",g.graduated=d,f.node=g.id):h(`the child is ${g.status}`);break}case"close":if(!l)h(f.parent?"that node is not in this lineage":"a close spends the node it closes");else if(!o(l))h(`already ${l.status}`);else{const g=b=>{b.status="closed",b.closed=d;for(const x of b.children){const w=r.get(x);w.edge==="derived"&&o(w)&&(f.also.push(w.id),g(w))}};g(l),f.node=l.id}break;default:h("not a lineage/v0 op")}f.root=f.node?r.get(f.node).root:(l==null?void 0:l.root)??null,i.push(f)}return{nodes:r,roots:s,log:i}}function ca(t,e,n,r){return{id:t.id,name:e,kind:r,parent:(n==null?void 0:n.id)??null,root:n?n.root:t.id,edge:n?"derived":null,status:"active",index:null,born:t.status==="confirmed"?t.height:"cued",children:[],badges:[],decisions:[],graduated:null,closed:null}}function Eb(t,e){const n=[],r=t.nodes.get(e),s=(i,o,a)=>{n.push({type:"node",node:i,guide:o,path:i.parent?`${i.index}'`:"●"});const c=i.children.map(f=>t.nodes.get(f)),u=[["agents",c.filter(f=>f.kind==="agent")],["orgs",c.filter(f=>f.kind!=="agent")]].filter(([,f])=>f.length);u.forEach(([f,l],d)=>{const h=d===u.length-1,m=a+(h?" ":"│ ");n.push({type:"group",label:f,guide:a+(h?"└─ ":"├─ ")}),l.forEach((p,g)=>{const b=g===l.length-1;s(p,m+(b?"└─ ":"├─ "),m+(b?" ":"│ "))})})};return r&&s(r,"",""),n}function Sb(t,e){const n={orgs:0,agents:0,belts:0,decisions:0,closed:0};for(const r of t.nodes.values())r.root===e&&(r.id!==e&&(n[r.kind==="agent"?"agents":"orgs"]++,r.status==="closed"&&n.closed++),n.belts+=r.badges.length,n.decisions+=r.decisions.length);return n}function Pu(t,e){const n=[];for(let r=t.nodes.get(e);r;r=t.nodes.get(r.parent))n.unshift(r.name);return n.join(" / ")}function Nu(t,e){const n=t.meta,r=s=>{var i;return((i=e.nodes.get(s))==null?void 0:i.name)??(typeof s=="string"?`${s.slice(0,8)}…`:"?")};if(!t.ok)return`${t.op}: ${t.why}`;switch(t.op){case"found":return`found ${n.name}`;case"birth":return`birth ${n.name}${n.kind==="agent"?" (agent)":""} ← ${r(t.parent)}`;case"award":return`award ${n.skill} · ${n.belt} → ${r(n.to)}, from ${r(t.parent)}`;case"decide":return`decide “${jr(n.title,140)}” · ${r(t.parent)}`;case"graduate":return`graduate ${r(n.of)} from ${r(t.parent)}`;case"close":return`close ${r(t.parent)}${t.also.length?` and ${t.also.length} derived`:""}`;default:return t.op}}const pn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $s(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function tn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Be(t,...e){if(!$s(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function wo(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");tn(t.outputLen),tn(t.blockLen)}function as(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function _b(t,e){Be(t);const n=e.outputLen;if(t.length>>e}function Sr(t,e){return t<>>32-e>>>0}const Lu=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",kb=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nt(t){if(Be(t),Lu)return t.toHex();let e="";for(let n=0;n=ct._0&&t<=ct._9)return t-ct._0;if(t>=ct.A&&t<=ct.F)return t-(ct.A-10);if(t>=ct.a&&t<=ct.f)return t-(ct.a-10)}function or(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Lu)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,i=0;st().update(xo(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function hr(t=32){if(pn&&typeof pn.getRandomValues=="function")return pn.getRandomValues(new Uint8Array(t));if(pn&&typeof pn.randomBytes=="function")return Uint8Array.from(pn.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function $b(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}function Bb(t,e,n){return t&e^~t&n}function Ob(t,e,n){return t&e^t&n^e&n}class Eo extends Hu{constructor(e,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(e),this.view=nn(this.buffer)}update(e){as(this),e=xo(e),Be(e);const{view:n,buffer:r,blockLen:s}=this,i=e.length;for(let o=0;os-o&&(this.process(r,0),o=0);for(let l=o;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l>fa&_r)}:{h:Number(t>>fa&_r)|0,l:Number(t&_r)|0}}function Tb(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;it>>>n,ha=(t,e,n)=>t<<32-n|e>>>n,gn=(t,e,n)=>t>>>n|e<<32-n,mn=(t,e,n)=>t<<32-n|e>>>n,kr=(t,e,n)=>t<<64-n|e>>>n-32,Ar=(t,e,n)=>t>>>n-32|e<<64-n;function ut(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Ib=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Ub=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Pb=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Nb=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Lb=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Hb=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,Rb=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]),Ct=new Uint32Array(64);class jb extends Eo{constructor(e=32){super(64,e,8,!1),this.A=Ot[0]|0,this.B=Ot[1]|0,this.C=Ot[2]|0,this.D=Ot[3]|0,this.E=Ot[4]|0,this.F=Ot[5]|0,this.G=Ot[6]|0,this.H=Ot[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:c}=this;return[e,n,r,s,i,o,a,c]}set(e,n,r,s,i,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)Ct[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const d=Ct[l-15],h=Ct[l-2],m=tt(d,7)^tt(d,18)^d>>>3,p=tt(h,17)^tt(h,19)^h>>>10;Ct[l]=p+Ct[l-7]+m+Ct[l-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=tt(a,6)^tt(a,11)^tt(a,25),h=f+d+Bb(a,c,u)+Rb[l]+Ct[l]|0,p=(tt(r,2)^tt(r,13)^tt(r,22))+Ob(r,s,i)|0;f=u,u=c,c=a,a=o+h|0,o=i,i=s,s=r,r=h+p|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,i,o,a,c,u,f)}roundClean(){bt(Ct)}destroy(){this.set(0,0,0,0,0,0,0,0),bt(this.buffer)}}const Ru=Tb(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Db=Ru[0],Zb=Ru[1],Tt=new Uint32Array(80),It=new Uint32Array(80);class Mb extends Eo{constructor(e=64){super(128,e,16,!1),this.Ah=Se[0]|0,this.Al=Se[1]|0,this.Bh=Se[2]|0,this.Bl=Se[3]|0,this.Ch=Se[4]|0,this.Cl=Se[5]|0,this.Dh=Se[6]|0,this.Dl=Se[7]|0,this.Eh=Se[8]|0,this.El=Se[9]|0,this.Fh=Se[10]|0,this.Fl=Se[11]|0,this.Gh=Se[12]|0,this.Gl=Se[13]|0,this.Hh=Se[14]|0,this.Hl=Se[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:d,Gh:h,Gl:m,Hh:p,Hl:g}=this;return[e,n,r,s,i,o,a,c,u,f,l,d,h,m,p,g]}set(e,n,r,s,i,o,a,c,u,f,l,d,h,m,p,g){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=p|0,this.Hl=g|0}process(e,n){for(let w=0;w<16;w++,n+=4)Tt[w]=e.getUint32(n),It[w]=e.getUint32(n+=4);for(let w=16;w<80;w++){const B=Tt[w-15]|0,A=It[w-15]|0,C=gn(B,A,1)^gn(B,A,8)^da(B,A,7),R=mn(B,A,1)^mn(B,A,8)^ha(B,A,7),L=Tt[w-2]|0,P=It[w-2]|0,J=gn(L,P,19)^kr(L,P,61)^da(L,P,6),z=mn(L,P,19)^Ar(L,P,61)^ha(L,P,6),M=Pb(R,z,It[w-7],It[w-16]),S=Nb(M,C,J,Tt[w-7],Tt[w-16]);Tt[w]=S|0,It[w]=M|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:h,Fl:m,Gh:p,Gl:g,Hh:b,Hl:x}=this;for(let w=0;w<80;w++){const B=gn(l,d,14)^gn(l,d,18)^kr(l,d,41),A=mn(l,d,14)^mn(l,d,18)^Ar(l,d,41),C=l&h^~l&p,R=d&m^~d&g,L=Lb(x,A,R,Zb[w],It[w]),P=Hb(L,b,B,C,Db[w],Tt[w]),J=L|0,z=gn(r,s,28)^kr(r,s,34)^kr(r,s,39),M=mn(r,s,28)^Ar(r,s,34)^Ar(r,s,39),S=r&i^r&a^i&a,_=s&o^s&c^o&c;b=p|0,x=g|0,p=h|0,g=m|0,h=l|0,m=d|0,{h:l,l:d}=ut(u|0,f|0,P|0,J|0),u=a|0,f=c|0,a=i|0,c=o|0,i=r|0,o=s|0;const y=Ib(J,M,_);r=Ub(y,P,z,S),s=y|0}({h:r,l:s}=ut(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=ut(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=ut(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=ut(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=ut(this.Eh|0,this.El|0,l|0,d|0),{h,l:m}=ut(this.Fh|0,this.Fl|0,h|0,m|0),{h:p,l:g}=ut(this.Gh|0,this.Gl|0,p|0,g|0),{h:b,l:x}=ut(this.Hh|0,this.Hl|0,b|0,x|0),this.set(r,s,i,o,a,c,u,f,l,d,h,m,p,g,b,x)}roundClean(){bt(Tt,It)}destroy(){bt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const cn=vo(()=>new jb),cs=vo(()=>new Mb);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const So=BigInt(0),Bi=BigInt(1);function us(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Yt(t,e,n=""){const r=$s(t),s=t==null?void 0:t.length,i=e!==void 0;if(!r||i&&s!==e){const o=n&&`"${n}" `,a=i?` of length ${e}`:"",c=r?`length=${s}`:`type=${typeof t}`;throw new Error(o+"expected Uint8Array"+a+", got "+c)}return t}function $r(t){const e=t.toString(16);return e.length&1?"0"+e:e}function ju(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?So:BigInt("0x"+t)}function Rn(t){return ju(nt(t))}function Du(t){return Be(t),ju(nt(Uint8Array.from(t).reverse()))}function Bs(t,e){return or(t.toString(16).padStart(e*2,"0"))}function Zu(t,e){return Bs(t,e).reverse()}function ye(t,e,n){let r;if(typeof e=="string")try{r=or(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if($s(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}const Gs=t=>typeof t=="bigint"&&So<=t;function Oi(t,e,n){return Gs(t)&&Gs(e)&&Gs(n)&&e<=t&&tSo;t>>=Bi,e+=1);return e}const pr=t=>(Bi<new Uint8Array(h),s=h=>Uint8Array.of(h);let i=r(t),o=r(t),a=0;const c=()=>{i.fill(1),o.fill(0),a=0},u=(...h)=>n(o,i,...h),f=(h=r(0))=>{o=u(s(0),h),i=u(),h.length!==0&&(o=u(s(1),h),i=u())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const m=[];for(;h{c(),f(h);let p;for(;!(p=m(l()));)f();return c(),p}}function _o(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(s,i,o){const a=t[s];if(o&&a===void 0)return;const c=typeof a;if(c!==i||a===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${c}`)}Object.entries(e).forEach(([s,i])=>r(s,i,!1)),Object.entries(n).forEach(([s,i])=>r(s,i,!0))}function pa(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const i=t(n,...r);return e.set(n,i),i}}const Ci=nt;class Vu extends Hu{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,wo(e);const r=xo(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;onew Vu(t,e).update(n).digest();In.create=(t,e)=>new Vu(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Le=BigInt(0),Te=BigInt(1),Xt=BigInt(2),Ku=BigInt(3),qu=BigInt(4),zu=BigInt(5),qb=BigInt(7),Fu=BigInt(8),zb=BigInt(9),Gu=BigInt(16);function He(t,e){const n=t%e;return n>=Le?n:e+n}function De(t,e,n){let r=t;for(;e-- >Le;)r*=r,r%=n;return r}function ga(t,e){if(t===Le)throw new Error("invert: expected non-zero number");if(e<=Le)throw new Error("invert: expected positive modulus, got "+e);let n=He(t,e),r=e,s=Le,i=Te;for(;n!==Le;){const a=r/n,c=r%n,u=s-i*a;r=n,n=c,s=i,i=u}if(r!==Te)throw new Error("invert: does not exist");return He(s,e)}function ko(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function Wu(t,e){const n=(t.ORDER+Te)/qu,r=t.pow(e,n);return ko(t,r,e),r}function Fb(t,e){const n=(t.ORDER-zu)/Fu,r=t.mul(e,Xt),s=t.pow(r,n),i=t.mul(e,s),o=t.mul(t.mul(i,Xt),s),a=t.mul(i,t.sub(o,t.ONE));return ko(t,a,e),a}function Gb(t){const e=gr(t),n=Yu(t),r=n(e,e.neg(e.ONE)),s=n(e,r),i=n(e,e.neg(r)),o=(t+qb)/Gu;return(a,c)=>{let u=a.pow(c,o),f=a.mul(u,r);const l=a.mul(u,s),d=a.mul(u,i),h=a.eql(a.sqr(f),c),m=a.eql(a.sqr(l),c);u=a.cmov(u,f,h),f=a.cmov(d,l,m);const p=a.eql(a.sqr(f),c),g=a.cmov(u,f,p);return ko(a,g,c),g}}function Yu(t){if(t1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Wu;let i=s.pow(r,e);const o=(e+Te)/Xt;return function(c,u){if(c.is0(u))return u;if(ma(c,u)!==1)throw new Error("Cannot find square root");let f=n,l=c.mul(c.ONE,i),d=c.pow(u,e),h=c.pow(u,o);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let m=1,p=c.sqr(d);for(;!c.eql(p,c.ONE);)if(m++,p=c.sqr(p),m===f)throw new Error("Cannot find square root");const g=Te<(r[s]="function",r),e);return _o(t,n),t}function Jb(t,e,n){if(nLe;)n&Te&&(r=t.mul(r,s)),s=t.sqr(s),n>>=Te;return r}function Xu(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((o,a,c)=>t.is0(a)?o:(r[c]=o,t.mul(o,a)),t.ONE),i=t.inv(s);return e.reduceRight((o,a,c)=>t.is0(a)?o:(r[c]=t.mul(o,r[c]),t.mul(o,a)),i),r}function ma(t,e){const n=(t.ORDER-Te)/Xt,r=t.pow(e,n),s=t.eql(r,t.ONE),i=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Ju(t,e){e!==void 0&&tn(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function gr(t,e,n=!1,r={}){if(t<=Le)throw new Error("invalid field: expected ORDER > 0, got "+t);let s,i,o=!1,a;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=e;d.BITS&&(s=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(o=d.modFromBytes),a=d.allowedLengths}else typeof e=="number"&&(s=e),r.sqrt&&(i=r.sqrt);const{nBitLength:c,nByteLength:u}=Ju(t,s);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const l=Object.freeze({ORDER:t,isLE:n,BITS:c,BYTES:u,MASK:pr(c),ZERO:Le,ONE:Te,allowedLengths:a,create:d=>He(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Le<=d&&dd===Le,isValidNot0:d=>!l.is0(d)&&l.isValid(d),isOdd:d=>(d&Te)===Te,neg:d=>He(-d,t),eql:(d,h)=>d===h,sqr:d=>He(d*d,t),add:(d,h)=>He(d+h,t),sub:(d,h)=>He(d-h,t),mul:(d,h)=>He(d*h,t),pow:(d,h)=>Jb(l,d,h),div:(d,h)=>He(d*ga(h,t),t),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>ga(d,t),sqrt:i||(d=>(f||(f=Wb(t)),f(l,d))),toBytes:d=>n?Zu(d,u):Bs(d,u),fromBytes:(d,h=!0)=>{if(a){if(!a.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);const p=new Uint8Array(u);p.set(d,n?0:p.length-d.length),d=p}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let m=n?Du(d):Rn(d);if(o&&(m=He(m,t)),!h&&!l.isValid(m))throw new Error("invalid field element: outside of range 0..ORDER");return m},invertBatch:d=>Xu(l,d),cmov:(d,h,m)=>m?h:d});return Object.freeze(l)}function Qu(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function el(t){const e=Qu(t);return e+Math.ceil(e/2)}function tl(t,e,n=!1){const r=t.length,s=Qu(e),i=el(e);if(r<16||r1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=n?Du(t):Rn(t),a=He(o,e-Te)+Te;return n?Zu(a,s):Bs(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Un=BigInt(0),Jt=BigInt(1);function ls(t,e){const n=e.negate();return t?n:e}function Ws(t,e){const n=Xu(t.Fp,e.map(r=>r.Z));return e.map((r,s)=>t.fromAffine(r.toAffine(n[s])))}function nl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ys(t,e){nl(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=pr(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function ba(t,e,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:o}=n;let a=Number(t&s),c=t>>o;a>r&&(a-=i,c+=Jt);const u=e*r,f=u+Math.abs(a)-1,l=a===0,d=a<0,h=e%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:d,isNegF:h,offsetF:u}}function Qb(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function ey(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Xs=new WeakMap,rl=new WeakMap;function Js(t){return rl.get(t)||1}function ya(t){if(t!==Un)throw new Error("invalid wNAF")}class ty{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let s=e;for(;n>Un;)n&Jt&&(r=r.add(s)),s=s.double(),n>>=Jt;return r}precomputeWindow(e,n){const{windows:r,windowSize:s}=Ys(n,this.bits),i=[];let o=e,a=o;for(let c=0;cUn||r>Un;)n&Jt&&(i=i.add(s)),r&Jt&&(o=o.add(s)),s=s.double(),n>>=Jt,r>>=Jt;return{p1:i,p2:o}}function ry(t,e,n,r){Qb(n,t),ey(r,e);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=Mu(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=pr(c),f=new Array(Number(u)+1).fill(o),l=Math.floor((e.BITS-1)/c)*c;let d=o;for(let h=l;h>=0;h-=c){f.fill(o);for(let p=0;p>BigInt(h)&u);f[b]=f[b].add(n[p])}let m=o;for(let p=f.length-1,g=o;p>0;p--)g=g.add(f[p]),m=m.add(g);if(d=d.add(m),h!==0)for(let p=0;pUn))throw new Error(`CURVE.${c} must be positive bigint`)}const s=wa(e.p,n.Fp,r),i=wa(e.n,n.Fn,r),a=["Gx","Gy","a","b"];for(const c of a)if(!s.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:s,Fn:i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xa=(t,e)=>(t+(t>=0?e:-e)/sl)/e;function iy(t,e,n){const[[r,s],[i,o]]=e,a=xa(o*t,n),c=xa(-s*t,n);let u=t-a*r-c*i,f=-a*s-c*o;const l=u=h||f=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:u,k2neg:d,k2:f}}function Ti(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Qs(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return us(n.lowS,"lowS"),us(n.prehash,"prehash"),n.format!==void 0&&Ti(n.format),n}class oy extends Error{constructor(e=""){super(e)}}const ft={Err:oy,_tlv:{encode:(t,e)=>{const{Err:n}=ft;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=$r(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?$r(s.length/2|128):"";return $r(t)+i+s+e},decode(t,e){const{Err:n}=ft;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],i=!!(s&128);let o=0;if(!i)o=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const f of u)o=o<<8|f;if(r+=c,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=ft;if(t{const{X:_,Y:y,Z:E}=M;if(r.eql(E,r.ONE))return{x:_,y};const k=M.is0();S==null&&(S=k?r.ONE:r.inv(E));const U=r.mul(_,S),I=r.mul(y,S),H=r.mul(E,S);if(k)return{x:r.ZERO,y:r.ZERO};if(!r.eql(H,r.ONE))throw new Error("invZ was invalid");return{x:U,y:I}}),R=pa(M=>{if(M.is0()){if(e.allowInfinityPoint&&!r.is0(M.Y))return;throw new Error("bad point: ZERO")}const{x:S,y:_}=M.toAffine();if(!r.isValid(S)||!r.isValid(_))throw new Error("bad point: x or y not field elements");if(!g(S,_))throw new Error("bad point: equation left != right");if(!M.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(M,S,_,y,E){return _=new P(r.mul(_.X,M),_.Y,_.Z),S=ls(y,S),_=ls(E,_),S.add(_)}class P{constructor(S,_,y){this.X=w("x",S),this.Y=w("y",_,!0),this.Z=w("z",y),Object.freeze(this)}static CURVE(){return i}static fromAffine(S){const{x:_,y}=S||{};if(!S||!r.isValid(_)||!r.isValid(y))throw new Error("invalid affine point");if(S instanceof P)throw new Error("projective point not allowed");return r.is0(_)&&r.is0(y)?P.ZERO:new P(_,y,r.ONE)}static fromBytes(S){const _=P.fromAffine(m(Yt(S,void 0,"point")));return _.assertValidity(),_}static fromHex(S){return P.fromBytes(ye("pointHex",S))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,_=!0){return z.createCache(this,S),_||this.multiply(Br),this}assertValidity(){R(this)}hasEvenY(){const{y:S}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(S)}equals(S){B(S);const{X:_,Y:y,Z:E}=this,{X:k,Y:U,Z:I}=S,H=r.eql(r.mul(_,I),r.mul(k,E)),D=r.eql(r.mul(y,I),r.mul(U,E));return H&&D}negate(){return new P(this.X,r.neg(this.Y),this.Z)}double(){const{a:S,b:_}=i,y=r.mul(_,Br),{X:E,Y:k,Z:U}=this;let I=r.ZERO,H=r.ZERO,D=r.ZERO,V=r.mul(E,E),oe=r.mul(k,k),ne=r.mul(U,U),Q=r.mul(E,k);return Q=r.add(Q,Q),D=r.mul(E,U),D=r.add(D,D),I=r.mul(S,D),H=r.mul(y,ne),H=r.add(I,H),I=r.sub(oe,H),H=r.add(oe,H),H=r.mul(I,H),I=r.mul(Q,I),D=r.mul(y,D),ne=r.mul(S,ne),Q=r.sub(V,ne),Q=r.mul(S,Q),Q=r.add(Q,D),D=r.add(V,V),V=r.add(D,V),V=r.add(V,ne),V=r.mul(V,Q),H=r.add(H,V),ne=r.mul(k,U),ne=r.add(ne,ne),V=r.mul(ne,Q),I=r.sub(I,V),D=r.mul(ne,oe),D=r.add(D,D),D=r.add(D,D),new P(I,H,D)}add(S){B(S);const{X:_,Y:y,Z:E}=this,{X:k,Y:U,Z:I}=S;let H=r.ZERO,D=r.ZERO,V=r.ZERO;const oe=i.a,ne=r.mul(i.b,Br);let Q=r.mul(_,k),ae=r.mul(y,U),ce=r.mul(E,I),ve=r.add(_,y),se=r.add(k,U);ve=r.mul(ve,se),se=r.add(Q,ae),ve=r.sub(ve,se),se=r.add(_,E);let pe=r.add(k,I);return se=r.mul(se,pe),pe=r.add(Q,ce),se=r.sub(se,pe),pe=r.add(y,E),H=r.add(U,I),pe=r.mul(pe,H),H=r.add(ae,ce),pe=r.sub(pe,H),V=r.mul(oe,se),H=r.mul(ne,ce),V=r.add(H,V),H=r.sub(ae,V),V=r.add(ae,V),D=r.mul(H,V),ae=r.add(Q,Q),ae=r.add(ae,Q),ce=r.mul(oe,ce),se=r.mul(ne,se),ae=r.add(ae,ce),ce=r.sub(Q,ce),ce=r.mul(oe,ce),se=r.add(se,ce),Q=r.mul(ae,se),D=r.add(D,Q),Q=r.mul(pe,se),H=r.mul(ve,H),H=r.sub(H,Q),Q=r.mul(ve,ae),V=r.mul(pe,V),V=r.add(V,Q),new P(H,D,V)}subtract(S){return this.add(S.negate())}is0(){return this.equals(P.ZERO)}multiply(S){const{endo:_}=e;if(!s.isValidNot0(S))throw new Error("invalid scalar: out of range");let y,E;const k=U=>z.cached(this,U,I=>Ws(P,I));if(_){const{k1neg:U,k1:I,k2neg:H,k2:D}=A(S),{p:V,f:oe}=k(I),{p:ne,f:Q}=k(D);E=oe.add(Q),y=L(_.beta,V,ne,U,H)}else{const{p:U,f:I}=k(S);y=U,E=I}return Ws(P,[y,E])[0]}multiplyUnsafe(S){const{endo:_}=e,y=this;if(!s.isValid(S))throw new Error("invalid scalar: out of range");if(S===dt||y.is0())return P.ZERO;if(S===Sn)return y;if(z.hasCache(this))return this.multiply(S);if(_){const{k1neg:E,k1:k,k2neg:U,k2:I}=A(S),{p1:H,p2:D}=ny(P,y,k,I);return L(_.beta,H,D,E,U)}else return z.unsafe(y,S)}multiplyAndAddUnsafe(S,_,y){const E=this.multiplyUnsafe(_).add(S.multiplyUnsafe(y));return E.is0()?void 0:E}toAffine(S){return C(this,S)}isTorsionFree(){const{isTorsionFree:S}=e;return o===Sn?!0:S?S(P,this):z.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:S}=e;return o===Sn?this:S?S(P,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(S=!0){return us(S,"isCompressed"),this.assertValidity(),h(P,this,S)}toHex(S=!0){return nt(this.toBytes(S))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(S=!0){return this.toBytes(S)}_setWindowSize(S){this.precompute(S)}static normalizeZ(S){return Ws(P,S)}static msm(S,_){return ry(P,s,S,_)}static fromPrivateKey(S){return P.BASE.multiply(Qt(s,S))}}P.BASE=new P(i.Gx,i.Gy,r.ONE),P.ZERO=new P(r.ZERO,r.ONE,r.ZERO),P.Fp=r,P.Fn=s;const J=s.BITS,z=new ty(P,e.endo?Math.ceil(J/2):J);return P.BASE.precompute(8),P}function il(t){return Uint8Array.of(t?2:3)}function ol(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function uy(t,e={}){const{Fn:n}=t,r=e.randomBytes||hr,s=Object.assign(ol(t.Fp,n),{seed:el(n.ORDER)});function i(h){try{return!!Qt(n,h)}catch{return!1}}function o(h,m){const{publicKey:p,publicKeyUncompressed:g}=s;try{const b=h.length;return m===!0&&b!==p||m===!1&&b!==g?!1:!!t.fromBytes(h)}catch{return!1}}function a(h=r(s.seed)){return tl(Yt(h,s.seed,"seed"),n.ORDER)}function c(h,m=!0){return t.BASE.multiply(Qt(n,h)).toBytes(m)}function u(h){const m=a(h);return{secretKey:m,publicKey:c(m)}}function f(h){if(typeof h=="bigint")return!1;if(h instanceof t)return!0;const{secretKey:m,publicKey:p,publicKeyUncompressed:g}=s;if(n.allowedLengths||m===p)return;const b=ye("key",h).length;return b===p||b===g}function l(h,m,p=!0){if(f(h)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");const g=Qt(n,h);return t.fromHex(m).multiply(g).toBytes(p)}return Object.freeze({getPublicKey:c,getSharedSecret:l,keygen:u,Point:t,utils:{isValidSecretKey:i,isValidPublicKey:o,randomSecretKey:a,isValidPrivateKey:i,randomPrivateKey:a,normPrivateKeyToScalar:h=>Qt(n,h),precompute(h=8,m=t.BASE){return m.precompute(h,!1)}},lengths:s})}function ly(t,e,n={}){wo(e),_o(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||hr,s=n.hmac||((_,...y)=>In(e,_,Ne(...y))),{Fp:i,Fn:o}=t,{ORDER:a,BITS:c}=o,{keygen:u,getPublicKey:f,getSharedSecret:l,utils:d,lengths:h}=uy(t,n),m={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},p="compact";function g(_){const y=a>>Sn;return _>y}function b(_,y){if(!o.isValidNot0(y))throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);return y}function x(_,y){Ti(y);const E=h.signature,k=y==="compact"?E:y==="recovered"?E+1:void 0;return Yt(_,k,`${y} signature`)}class w{constructor(y,E,k){this.r=b("r",y),this.s=b("s",E),k!=null&&(this.recovery=k),Object.freeze(this)}static fromBytes(y,E=p){x(y,E);let k;if(E==="der"){const{r:D,s:V}=ft.toSig(Yt(y));return new w(D,V)}E==="recovered"&&(k=y[0],E="compact",y=y.subarray(1));const U=o.BYTES,I=y.subarray(0,U),H=y.subarray(U,U*2);return new w(o.fromBytes(I),o.fromBytes(H),k)}static fromHex(y,E){return this.fromBytes(or(y),E)}addRecoveryBit(y){return new w(this.r,this.s,y)}recoverPublicKey(y){const E=i.ORDER,{r:k,s:U,recovery:I}=this;if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");if(a*sl1)throw new Error("recovery id is ambiguous for h>1 curve");const D=I===2||I===3?k+a:k;if(!i.isValid(D))throw new Error("recovery id 2 or 3 invalid");const V=i.toBytes(D),oe=t.fromBytes(Ne(il((I&1)===0),V)),ne=o.inv(D),Q=A(ye("msgHash",y)),ae=o.create(-Q*ne),ce=o.create(U*ne),ve=t.BASE.multiplyUnsafe(ae).add(oe.multiplyUnsafe(ce));if(ve.is0())throw new Error("point at infinify");return ve.assertValidity(),ve}hasHighS(){return g(this.s)}toBytes(y=p){if(Ti(y),y==="der")return or(ft.hexFromSig(this));const E=o.toBytes(this.r),k=o.toBytes(this.s);if(y==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Ne(Uint8Array.of(this.recovery),E,k)}return Ne(E,k)}toHex(y){return nt(this.toBytes(y))}assertValidity(){}static fromCompact(y){return w.fromBytes(ye("sig",y),"compact")}static fromDER(y){return w.fromBytes(ye("sig",y),"der")}normalizeS(){return this.hasHighS()?new w(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return nt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return nt(this.toBytes("compact"))}}const B=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const E=Rn(y),k=y.length*8-c;return k>0?E>>BigInt(k):E},A=n.bits2int_modN||function(y){return o.create(B(y))},C=pr(c);function R(_){return Vb("num < 2^"+c,_,dt,C),o.toBytes(_)}function L(_,y){return Yt(_,void 0,"message"),y?Yt(e(_),void 0,"prehashed message"):_}function P(_,y,E){if(["recovered","canonical"].some(ae=>ae in E))throw new Error("sign() legacy options not supported");const{lowS:k,prehash:U,extraEntropy:I}=Qs(E,m);_=L(_,U);const H=A(_),D=Qt(o,y),V=[R(D),R(H)];if(I!=null&&I!==!1){const ae=I===!0?r(h.secretKey):I;V.push(ye("extraEntropy",ae))}const oe=Ne(...V),ne=H;function Q(ae){const ce=B(ae);if(!o.isValidNot0(ce))return;const ve=o.inv(ce),se=t.BASE.multiply(ce).toAffine(),pe=o.create(se.x);if(pe===dt)return;const Vt=o.create(ve*o.create(ne+pe*D));if(Vt===dt)return;let ot=(se.x===pe?0:2)|Number(se.y&Sn),Pe=Vt;return k&&g(Vt)&&(Pe=o.neg(Vt),ot^=1),new w(pe,Pe,ot)}return{seed:oe,k2sig:Q}}function J(_,y,E={}){_=ye("message",_);const{seed:k,k2sig:U}=P(_,y,E);return Kb(e.outputLen,o.BYTES,s)(k,U)}function z(_){let y;const E=typeof _=="string"||$s(_),k=!E&&_!==null&&typeof _=="object"&&typeof _.r=="bigint"&&typeof _.s=="bigint";if(!E&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(k)y=new w(_.r,_.s);else if(E){try{y=w.fromBytes(ye("sig",_),"der")}catch(U){if(!(U instanceof ft.Err))throw U}if(!y)try{y=w.fromBytes(ye("sig",_),"compact")}catch{return!1}}return y||!1}function M(_,y,E,k={}){const{lowS:U,prehash:I,format:H}=Qs(k,m);if(E=ye("publicKey",E),y=L(ye("message",y),I),"strict"in k)throw new Error("options.strict was renamed to lowS");const D=H===void 0?z(_):w.fromBytes(ye("sig",_),H);if(D===!1)return!1;try{const V=t.fromBytes(E);if(U&&D.hasHighS())return!1;const{r:oe,s:ne}=D,Q=A(y),ae=o.inv(ne),ce=o.create(Q*ae),ve=o.create(oe*ae),se=t.BASE.multiplyUnsafe(ce).add(V.multiplyUnsafe(ve));return se.is0()?!1:o.create(se.x)===oe}catch{return!1}}function S(_,y,E={}){const{prehash:k}=Qs(E,m);return y=L(y,k),w.fromBytes(_,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:l,utils:d,lengths:h,Point:t,sign:J,verify:M,recoverPublicKey:S,Signature:w,hash:e})}function fy(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp;let r=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const s=gr(e.n,{BITS:t.nBitLength,allowedLengths:r,modFromBytes:t.wrapPrivateKey}),i={Fp:n,Fn:s,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:i}}function dy(t){const{CURVE:e,curveOpts:n}=fy(t),r={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:n,hash:t.hash,ecdsaOpts:r}}function hy(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,Ju(n.Fn.ORDER,n.Fn.BITS))})}function py(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:s}=dy(t),i=cy(e,n),o=ly(i,r,s);return hy(t,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gy(t,e){const n=r=>py({...t,hash:r});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},my={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},by=BigInt(0),va=BigInt(1),Ii=BigInt(2);function yy(t){const e=Pn.p,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,f=u*u*t%e,l=De(f,n,e)*f%e,d=De(l,n,e)*f%e,h=De(d,Ii,e)*u%e,m=De(h,s,e)*h%e,p=De(m,i,e)*m%e,g=De(p,a,e)*p%e,b=De(g,c,e)*g%e,x=De(b,a,e)*p%e,w=De(x,n,e)*f%e,B=De(w,o,e)*m%e,A=De(B,r,e)*u%e,C=De(A,Ii,e);if(!fs.eql(fs.sqr(C),t))throw new Error("Cannot find square root");return C}const fs=gr(Pn.p,{sqrt:yy}),Re=gy({...Pn,Fp:fs,lowS:!0,endo:my},cn),Ea={};function ds(t,...e){let n=Ea[t];if(n===void 0){const r=cn(dr(t));n=Ne(r,r),Ea[t]=n}return cn(Ne(n,...e))}const Ao=t=>t.toBytes(!0).slice(1),jn=Re.Point,$o=t=>t%Ii===by;function Ui(t){const{Fn:e,BASE:n}=jn,r=Qt(e,t),s=n.multiply(r);return{scalar:$o(s.y)?r:e.neg(r),bytes:Ao(s)}}function al(t){const e=fs;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const n=e.create(t*t),r=e.create(n*t+BigInt(7));let s=e.sqrt(r);$o(s)||(s=e.neg(s));const i=jn.fromAffine({x:t,y:s});return i.assertValidity(),i}const qn=Rn;function cl(...t){return jn.Fn.create(qn(ds("BIP0340/challenge",...t)))}function Sa(t){return Ui(t).bytes}function wy(t,e,n=hr(32)){const{Fn:r}=jn,s=ye("message",t),{bytes:i,scalar:o}=Ui(e),a=ye("auxRand",n,32),c=r.toBytes(o^qn(ds("BIP0340/aux",a))),u=ds("BIP0340/nonce",c,i,s),{bytes:f,scalar:l}=Ui(u),d=cl(f,i,s),h=new Uint8Array(64);if(h.set(f,0),h.set(r.toBytes(r.create(l+d*o)),32),!ul(h,s,i))throw new Error("sign: Invalid signature produced");return h}function ul(t,e,n){const{Fn:r,BASE:s}=jn,i=ye("signature",t,64),o=ye("message",e),a=ye("publicKey",n,32);try{const c=al(qn(a)),u=qn(i.subarray(0,32));if(!Oi(u,va,Pn.p))return!1;const f=qn(i.subarray(32,64));if(!Oi(f,va,Pn.n))return!1;const l=cl(r.toBytes(u),Ao(c),o),d=s.multiplyUnsafe(f).add(c.multiplyUnsafe(r.neg(l))),{x:h,y:m}=d.toAffine();return!(d.is0()||!$o(m)||h!==u)}catch{return!1}}const ll=(()=>{const n=(s=hr(48))=>tl(s,Pn.n);Re.utils.randomSecretKey;function r(s){const i=n(s);return{secretKey:i,publicKey:Sa(i)}}return{keygen:r,getPublicKey:Sa,sign:wy,verify:ul,Point:jn,utils:{randomSecretKey:n,randomPrivateKey:n,taggedHash:ds,lift_x:al,pointToBytes:Ao,numberToBytesBE:Bs,bytesToNumberBE:Rn,mod:He},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),Nt="super-testnet-local-v0";class Mt{constructor(e){if(!/^[0-9a-f]{64}$/.test(e)||!Re.utils.isValidPrivateKey(e))throw new Error("Invalid test wallet key. Load a Super Testnet v0 backup.");this.kind="test-wallet",this.secret=e,this.pubkey=Ci(ll.getPublicKey(e)),this.address=Og.p2tr.fromPubKey(this.pubkey,"regtest"),this.script=["OP_1",this.pubkey]}static create(){return new Mt(Ci(Re.utils.randomPrivateKey()))}static load(e){if((e==null?void 0:e.network)!==Nt||(e==null?void 0:e.version)!==1||(e==null?void 0:e.kind)!=="test-wallet")throw new Error("Only Super Testnet v0 test-wallet backups are accepted.");return new Mt(e.secret)}backup(){return{kind:"test-wallet",version:1,network:Nt,secret:this.secret}}sign(e,n,r=0){return yu.taproot.sign(this.secret,e,r,n?{extension:n}:{}).hex}}const ei=50*1e8,Or="0".repeat(64),_a=t=>Ci(cn(new TextEncoder().encode(JSON.stringify(t)))),Cr=(t,e)=>`${t}:${e}`,Ze=t=>xe.encode(t,!1).hex,ie=(t,e)=>{if(!t)throw new Error(e)};class Os{constructor(e){if(this.blocks=[],this.mempool=[],this.utxos=new Map,this.transactions=new Map,e){ie(e.network===Nt&&e.version===1,"Unsupported local chain version/network."),ie(Array.isArray(e.blocks)&&Array.isArray(e.mempool),"Invalid chain snapshot.");for(const n of e.blocks)this.acceptBlock(structuredClone(n));this.submitPackage(e.mempool)}}snapshot(){return{network:Nt,version:1,blocks:structuredClone(this.blocks),mempool:[...this.mempool]}}coins(e){return[...this.utxos.values()].filter(n=>Ze(n.scriptPubKey)===Ze(e))}satLocation(e){for(const n of this.utxos.values()){const r=Lr(n.ranges,e);if(r!==null)return{txid:n.txid,vout:n.vout,offset:r}}return null}balance(e){return this.coins(e).reduce((n,r)=>n+r.value,0)}apply(e,n,r=!1){var h,m,p;ie(typeof e=="string"&&e.length<4e4&&/^(?:[a-f0-9]{2})+$/.test(e),"Invalid raw transaction.");const s=le.decode(e),i=le.util.getTxid(s);ie(!this.transactions.has(i),"Duplicate transaction."),ie(s.version===2&&s.locktime===0,"Unsupported transaction version or locktime."),ie((s.vin.length===1||!r&&s.vin.length===2)&&s.vout.length>=1&&s.vout.length<=2,"Unsupported transaction shape.");let o=0;for(const g of s.vout){const b=Number(g.value);ie(Number.isSafeInteger(b)&&b>=330&&b<=ei,"Invalid output amount."),ie(/^5120[0-9a-f]{64}$/.test(Ze(g.scriptPubKey)),"Only Taproot outputs are supported."),o+=b}let a,c=[];const u=s.vin.findIndex(g=>{var b;return((b=g.witness)==null?void 0:b.length)===3}),f=s.vin[u<0?0:u];if(r)ie(f.txid===Or&&f.vout===4294967295&&s.vout.length===1&&o===ei,"Invalid local coinbase."),ie(Ze(f.scriptSig)===xe.encode([new TextEncoder().encode(`${Nt}:${n}`)],!1).hex,"Wrong coinbase height."),ie(!((h=f.witness)!=null&&h.length),"Unexpected coinbase witness.");else{c=s.vin.map(b=>this.utxos.get(Cr(b.txid,b.vout))),ie(c.every(Boolean),"Input is missing or already spent."),ie(new Set(s.vin.map(b=>Cr(b.txid,b.vout))).size===s.vin.length,"Duplicate input."),s.vin.forEach((b,x)=>{var w,B;ie(b.sequence==="ffffffff"&&Ze(b.scriptSig)==="","Unsupported input flags."),b.prevout={value:c[x].value,scriptPubKey:c[x].scriptPubKey},ie(((w=b.witness)==null?void 0:w.length)===1||x===u&&((B=b.witness)==null?void 0:B.length)===3,"Unsupported witness."),ie(/^[0-9a-f]{128}$/.test(b.witness[0]),"Only default 64-byte Schnorr signatures are accepted.")}),ie(c.reduce((b,x)=>b+x.value,0)-o===Ae,"v0 requires a fixed 500 sat fee per transaction.");let g={};if(f.witness.length===3){const b=go(f.witness),x=u;if(ie(Number(s.vout[x].value)===lt,"Invalid reveal postage."),ie(Ze(s.vout[x].scriptPubKey)===`5120${b.pubkey}`,"Reveal must return to its signing wallet."),b.parent){const w=u===0?1:0,B=c[w];ie((m=B==null?void 0:B.inscriptions)==null?void 0:m.some(A=>A.id===b.parent),"Referenced parent inscription must actually be spent."),ie(s.vout.length===2&&Number(s.vout[w].value)===B.value&&Ze(B.scriptPubKey)===`5120${b.pubkey}`&&Ze(s.vout[w].scriptPubKey)===Ze(B.scriptPubKey),"Parent must be owned and preserved in the same wallet.")}else s.vin.length===2&&(ie(u===1&&((p=c[0].inscriptions)==null?void 0:p.length)&&b.pointer!==void 0,"Reinscription spend requires correct tag and owned sat."),ie(Number(s.vout[0].value)===c[0].value&&Ze(s.vout[0].scriptPubKey)===Ze(c[0].scriptPubKey)&&Ze(c[0].scriptPubKey)===`5120${b.pubkey}`,"Reinscription sat must be returned to owner."));g={pubkey:b.pubkey},a={id:`${i}i0`,txid:i,commitTxid:f.txid,text:b.text,bytes:Array.from(b.bytes),contentType:b.contentType,parent:b.parent,delegate:b.delegate,pointer:b.pointer,metaprotocol:b.metaprotocol,metadata:b.metadata,height:n,value:lt}}s.vin.forEach((b,x)=>{let w=!1;try{w=yu.taproot.verify(s,x,x===u?g:{})}catch{}ie(w,"Invalid signature or Taproot commitment.")})}const l=Da(s,c,n,r),d=c.flatMap(g=>g.inscriptions??[]);if(a){const g=BigInt(a.pointer??0),b=g{var w;return((w=x.inscription)==null?void 0:w.sat)===a.sat}).length,d.push(a)}return ie(d.every(g=>l.some(b=>Lr(b,g.sat)!==null)),"Local lab protects inscription sats from fee loss."),r||s.vin.forEach(g=>this.utxos.delete(Cr(g.txid,g.vout))),s.vout.forEach((g,b)=>{const x=d.filter(w=>Lr(l[b],w.sat)!==null);this.utxos.set(Cr(i,b),{txid:i,vout:b,value:Number(g.value),scriptPubKey:g.scriptPubKey,height:n,ranges:l[b],inscriptions:x,...x.length?{inscription:x[0]}:{}})}),this.transactions.set(i,{txid:i,raw:e,height:n,coinbase:r,tx:s,...a?{inscription:a}:{}}),i}submitPackage(e){ie(Array.isArray(e)&&this.mempool.length+e.length<=1e3,"Invalid package or mempool full; mine a block first.");const n=new Map(this.utxos),r=new Map(this.transactions);try{e.forEach(s=>this.apply(s,null))}catch(s){throw this.utxos=n,this.transactions=r,s}this.mempool.push(...e)}acceptBlock(e){var o;ie(e.height===this.blocks.length+1&&e.previous===(((o=this.blocks.at(-1))==null?void 0:o.hash)??Or),"Invalid block ancestry."),ie(Number.isSafeInteger(e.time)&&e.time>0&&Array.isArray(e.raws)&&e.raws.length>0&&e.raws.length<=1001,"Invalid block.");const{hash:n,...r}=e;ie(_a(r)===n,"Invalid local block hash.");const s=new Map(this.utxos),i=new Map(this.transactions);try{e.raws.forEach((a,c)=>this.apply(a,e.height,c===0))}catch(a){throw this.utxos=s,this.transactions=i,a}this.blocks.push(e)}mine(e){var a;const n=new Os({...this.snapshot(),mempool:[]}),r=this.blocks.length+1,s=le.create({vin:[{txid:Or,vout:4294967295,scriptSig:[new TextEncoder().encode(`${Nt}:${r}`)]}],vout:[ze(ei,e)]}),i={height:r,previous:((a=this.blocks.at(-1))==null?void 0:a.hash)??Or,time:Date.now(),raws:[le.encode(s).hex,...this.mempool]},o={...i,hash:_a(i)};return n.acceptBlock(o),Object.assign(this,n),o}}const xy=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),fl=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),vy=fl.map(t=>(9*t+5)%16),dl=(()=>{const n=[[fl],[vy]];for(let r=0;r<4;r++)for(let s of n)s.push(s[r].map(i=>xy[i]));return n})(),hl=dl[0],pl=dl[1],gl=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Ey=hl.map((t,e)=>t.map(n=>gl[e][n])),Sy=pl.map((t,e)=>t.map(n=>gl[e][n])),_y=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),ky=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function ka(t,e,n,r){return t===0?e^n^r:t===1?e&n|~e&r:t===2?(e|~n)^r:t===3?e&r|n&~r:e^(n|~r)}const Tr=new Uint32Array(16);class Ay extends Eo{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:r,h3:s,h4:i}=this;return[e,n,r,s,i]}set(e,n,r,s,i){this.h0=e|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=i|0}process(e,n){for(let h=0;h<16;h++,n+=4)Tr[h]=e.getUint32(n,!0);let r=this.h0|0,s=r,i=this.h1|0,o=i,a=this.h2|0,c=a,u=this.h3|0,f=u,l=this.h4|0,d=l;for(let h=0;h<5;h++){const m=4-h,p=_y[h],g=ky[h],b=hl[h],x=pl[h],w=Ey[h],B=Sy[h];for(let A=0;A<16;A++){const C=Sr(r+ka(h,i,a,u)+Tr[b[A]]+p,w[A])+l|0;r=l,l=u,u=Sr(a,10)|0,a=i,i=C}for(let A=0;A<16;A++){const C=Sr(s+ka(m,o,c,f)+Tr[x[A]]+g,B[A])+d|0;s=d,d=f,f=Sr(c,10)|0,c=o,o=C}}this.set(this.h1+a+f|0,this.h2+u+d|0,this.h3+l+s|0,this.h4+r+o|0,this.h0+i+c|0)}roundClean(){bt(Tr)}destroy(){this.destroyed=!0,bt(this.buffer),this.set(0,0,0,0,0)}}const $y=vo(()=>new Ay);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ar(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ml(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function bl(t){if(typeof t!="function")throw new Error("function expected");return!0}function Nn(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function Dn(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function hs(t){if(!Array.isArray(t))throw new Error("array expected")}function ps(t,e){if(!ml(!0,e))throw new Error(`${t}: array of strings expected`)}function Bo(t,e){if(!ml(!1,e))throw new Error(`${t}: array of numbers expected`)}function Cs(...t){const e=i=>i,n=(i,o)=>a=>i(o(a)),r=t.map(i=>i.encode).reduceRight(n,e),s=t.map(i=>i.decode).reduce(n,e);return{encode:r,decode:s}}function Oo(t){const e=typeof t=="string"?t.split(""):t,n=e.length;ps("alphabet",e);const r=new Map(e.map((s,i)=>[s,i]));return{encode:s=>(hs(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:s=>(hs(s),s.map(i=>{Nn("alphabet.decode",i);const o=r.get(i);if(o===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return o}))}}function Co(t=""){return Nn("join",t),{encode:e=>(ps("join.decode",e),e.join(t)),decode:e=>(Nn("join.decode",e),e.split(t))}}function By(t,e="="){return Dn(t),Nn("padding",e),{encode(n){for(ps("padding.encode",n);n.length*t%8;)n.push(e);return n},decode(n){ps("padding.decode",n);let r=n.length;if(r*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if((r-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function Pi(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(hs(t),!t.length)return[];let r=0;const s=[],i=Array.from(t,a=>{if(Dn(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),o=i.length;for(;;){let a=0,c=!0;for(let u=r;ue===0?t:yl(e,t%e),gs=(t,e)=>t+(e-yl(t,e)),Dr=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function ms(t,e,n,r){if(hs(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(gs(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${gs(e,n)}`);let s=0,i=0;const o=Dr[e],a=Dr[n]-1,c=[];for(const u of t){if(Dn(u),u>=o)throw new Error(`convertRadix2: invalid data word=${u} from=${e}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=n;i-=n)c.push((s>>i-n&a)>>>0);const f=Dr[i];if(f===void 0)throw new Error("invalid carry");s&=f-1}if(s=s<=e)throw new Error("Excess padding");if(!r&&s>0)throw new Error(`Non-zero padding: ${s}`);return r&&i>0&&c.push(s>>>0),c}function wl(t){Dn(t);const e=2**8;return{encode:n=>{if(!ar(n))throw new Error("radix.encode input should be Uint8Array");return Pi(Array.from(n),e,t)},decode:n=>(Bo("radix.decode",n),Uint8Array.from(Pi(n,t,e)))}}function xl(t,e=!1){if(Dn(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(gs(8,t)>32||gs(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!ar(n))throw new Error("radix2.encode input should be Uint8Array");return ms(Array.from(n),8,t,!e)},decode:n=>(Bo("radix2.decode",n),Uint8Array.from(ms(n,t,8,e)))}}function Aa(t){return bl(t),function(...e){try{return t.apply(null,e)}catch{}}}function vl(t,e){return Dn(t),bl(e),{encode(n){if(!ar(n))throw new Error("checksum.encode: input should be Uint8Array");const r=e(n).slice(0,t),s=new Uint8Array(n.length+t);return s.set(n),s.set(r,n.length),s},decode(n){if(!ar(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-t),s=n.slice(-t),i=e(r).slice(0,t);for(let o=0;oCs(wl(58),Oo(t),Co("")),Cy=Oy("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ty=t=>Cs(vl(4,e=>t(t(e))),Cy),Ni=Cs(Oo("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Co("")),$a=[996825010,642813549,513874426,1027748829,705979059];function Vn(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<$a.length;r++)(e>>r&1)===1&&(n^=$a[r]);return n}function Ba(t,e,n=1){const r=t.length;let s=1;for(let i=0;i126)throw new Error(`Invalid prefix (${t})`);s=Vn(s)^o>>5}s=Vn(s);for(let i=0;ih)throw new TypeError(`Length ${p} exceeds limit ${h}`);const g=l.toLowerCase(),b=Ba(g,d,e);return`${g}1${Ni.encode(d)}${b}`}function a(l,d=90){Nn("bech32.decode input",l);const h=l.length;if(h<8||d!==!1&&h>d)throw new TypeError(`invalid string length: ${h} (${l}). Expected (8..${d})`);const m=l.toLowerCase();if(l!==m&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");const p=m.lastIndexOf("1");if(p===0||p===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=m.slice(0,p),b=m.slice(p+1);if(b.length<6)throw new Error("Data must be at least 6 characters long");const x=Ni.decode(b).slice(0,-6),w=Ba(g,x,e);if(!b.endsWith(w))throw new Error(`Invalid checksum in ${l}: expected "${w}"`);return{prefix:g,words:x}}const c=Aa(a);function u(l){const{prefix:d,words:h}=a(l,!1);return{prefix:d,words:h,bytes:r(h)}}function f(l,d){return o(l,s(d))}return{encode:o,decode:a,encodeFromBytes:f,decodeToBytes:u,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:i,toWords:s}}const Oa=Iy("bech32");/*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const Ur=Re.ProjectivePoint,ti=Ty(cn);function Ca(t){Be(t);const e=t.length===0?"0":nt(t);return BigInt("0x"+e)}function Uy(t){if(typeof t!="bigint")throw new Error("bigint expected");return or(t.toString(16).padStart(64,"0"))}const Py=dr("Bitcoin seed"),ni={private:76066276,public:76067358},ri=2147483648,Ny=t=>$y(cn(t)),Ly=t=>nn(t).getUint32(0,!1),Pr=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error("invalid number, should be from 0 to 2**32-1, got "+t);const e=new Uint8Array(4);return nn(e).setUint32(0,t,!1),e};class zt{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return Ly(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return ti.encode(this.serialize(this.versions.private,Ne(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return ti.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,n=ni){if(Be(e),8*e.length<128||8*e.length>512)throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+e.length);const r=In(cs,Py,e);return new zt({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(e,n=ni){const r=ti.decode(e),s=nn(r),i=s.getUint32(0,!1),o={versions:n,depth:r[4],parentFingerprint:s.getUint32(5,!1),index:s.getUint32(9,!1),chainCode:r.slice(13,45)},a=r.slice(45),c=a[0]===0;if(i!==n[c?"private":"public"])throw new Error("Version mismatch");return c?new zt({...o,privateKey:a.slice(1)}):new zt({...o,publicKey:a})}static fromJSON(e){return zt.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||ni,this.depth=e.depth||0,this.chainCode=e.chainCode||null,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!Re.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey=typeof e.privateKey=="bigint"?e.privateKey:Ca(e.privateKey),this.privKeyBytes=Uy(this.privKey),this.pubKey=Re.getPublicKey(e.privateKey,!0)}else if(e.publicKey)this.pubKey=Ur.fromHex(e.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=Ny(this.pubKey)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const n=e.replace(/^[mM]'?\//,"").split("/");let r=this;for(const s of n){const i=/^(\d+)('?)$/.exec(s),o=i&&i[1];if(!i||i.length!==3||typeof o!="string")throw new Error("invalid child index: "+s);let a=+o;if(!Number.isSafeInteger(a)||a>=ri)throw new Error("Invalid index");i[2]==="'"&&(a+=ri),r=r.deriveChild(a)}return r}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=Pr(e);if(e>=ri){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=Ne(new Uint8Array([0]),a,n)}else n=Ne(this.pubKey,n);const r=In(cs,this.chainCode,n),s=Ca(r.slice(0,32)),i=r.slice(32);if(!Re.utils.isValidPrivateKey(s))throw new Error("Tweak bigger than curve order");const o={versions:this.versions,chainCode:i,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const a=He(this.privKey+s,Re.CURVE.n);if(!Re.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");o.privateKey=a}else{const a=Ur.fromHex(this.pubKey).add(Ur.fromPrivateKey(s));if(a.equals(Ur.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");o.publicKey=a.toRawBytes(!0)}return new zt(o)}catch{return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return Be(e,32),Re.sign(e,this.privKey).toCompactRawBytes()}verify(e,n){if(Be(e,32),Be(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=Re.Signature.fromCompact(n)}catch{return!1}return Re.verify(r,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,n){if(!this.chainCode)throw new Error("No chainCode set");return Be(n,33),Ne(Pr(e),new Uint8Array([this.depth]),Pr(this.parentFingerprint),Pr(this.index),this.chainCode,n)}}function Hy(t,e,n,r){wo(t);const s=Ab({dkLen:32,asyncTick:10},r),{c:i,dkLen:o,asyncTick:a}=s;if(tn(i),tn(o),tn(a),i<1)throw new Error("iterations (c) should be >= 1");const c=la(e),u=la(n),f=new Uint8Array(o),l=In.create(t,c),d=l._cloneInto().update(u);return{c:i,dkLen:o,asyncTick:a,DK:f,PRF:l,PRFSalt:d}}function Ry(t,e,n,r,s){return t.destroy(),e.destroy(),r&&r.destroy(),bt(s),n}function jy(t,e,n,r){const{c:s,dkLen:i,DK:o,PRF:a,PRFSalt:c}=Hy(t,e,n,r);let u;const f=new Uint8Array(4),l=nn(f),d=new Uint8Array(a.outputLen);for(let h=1,m=0;mt[0]==="あいこくしん";function El(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function Sl(t){const e=El(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}function _l(t){Be(t,16,20,24,28,32)}function Zy(t,e=128){if(tn(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return Al(hr(e/8),t)}const My=t=>{const e=8-t.length/4;return new Uint8Array([cn(t)[0]>>e<{if(typeof e!="string")throw new Error("wordlist: non-string element: "+e)}),Ir.chain(Ir.checksum(1,My),Ir.radix2(11,!0),Ir.alphabet(t))}function Vy(t,e){const{words:n}=Sl(t),r=kl(e).decode(n);return _l(r),r}function Al(t,e){return _l(t),kl(e).encode(t).join(Dy(e)?" ":" ")}function Ky(t,e){try{Vy(t,e)}catch{return!1}return!0}const qy=t=>El("mnemonic"+t);function zy(t,e=""){return jy(cs,Sl(t).nfkd,qy(e),{c:2048,dkLen:64})}const To=`abandon -ability -able -about -above -absent -absorb -abstract -absurd -abuse -access -accident -account -accuse -achieve -acid -acoustic -acquire -across -act -action -actor -actress -actual -adapt -add -addict -address -adjust -admit -adult -advance -advice -aerobic -affair -afford -afraid -again -age -agent -agree -ahead -aim -air -airport -aisle -alarm -album -alcohol -alert -alien -all -alley -allow -almost -alone -alpha -already -also -alter -always -amateur -amazing -among -amount -amused -analyst -anchor -ancient -anger -angle -angry -animal -ankle -announce -annual -another -answer -antenna -antique -anxiety -any -apart -apology -appear -apple -approve -april -arch -arctic -area -arena -argue -arm -armed -armor -army -around -arrange -arrest -arrive -arrow -art -artefact -artist -artwork -ask -aspect -assault -asset -assist -assume -asthma -athlete -atom -attack -attend -attitude -attract -auction -audit -august -aunt -author -auto -autumn -average -avocado -avoid -awake -aware -away -awesome -awful -awkward -axis -baby -bachelor -bacon -badge -bag -balance -balcony -ball -bamboo -banana -banner -bar -barely -bargain -barrel -base -basic -basket -battle -beach -bean -beauty -because -become -beef -before -begin -behave -behind -believe -below -belt -bench -benefit -best -betray -better -between -beyond -bicycle -bid -bike -bind -biology -bird -birth -bitter -black -blade -blame -blanket -blast -bleak -bless -blind -blood -blossom -blouse -blue -blur -blush -board -boat -body -boil -bomb -bone -bonus -book -boost -border -boring -borrow -boss -bottom -bounce -box -boy -bracket -brain -brand -brass -brave -bread -breeze -brick -bridge -brief -bright -bring -brisk -broccoli -broken -bronze -broom -brother -brown -brush -bubble -buddy -budget -buffalo -build -bulb -bulk -bullet -bundle -bunker -burden -burger -burst -bus -business -busy -butter -buyer -buzz -cabbage -cabin -cable -cactus -cage -cake -call -calm -camera -camp -can -canal -cancel -candy -cannon -canoe -canvas -canyon -capable -capital -captain -car -carbon -card -cargo -carpet -carry -cart -case -cash -casino -castle -casual -cat -catalog -catch -category -cattle -caught -cause -caution -cave -ceiling -celery -cement -census -century -cereal -certain -chair -chalk -champion -change -chaos -chapter -charge -chase -chat -cheap -check -cheese -chef -cherry -chest -chicken -chief -child -chimney -choice -choose -chronic -chuckle -chunk -churn -cigar -cinnamon -circle -citizen -city -civil -claim -clap -clarify -claw -clay -clean -clerk -clever -click -client -cliff -climb -clinic -clip -clock -clog -close -cloth -cloud -clown -club -clump -cluster -clutch -coach -coast -coconut -code -coffee -coil -coin -collect -color -column -combine -come -comfort -comic -common -company -concert -conduct -confirm -congress -connect -consider -control -convince -cook -cool -copper -copy -coral -core -corn -correct -cost -cotton -couch -country -couple -course -cousin -cover -coyote -crack -cradle -craft -cram -crane -crash -crater -crawl -crazy -cream -credit -creek -crew -cricket -crime -crisp -critic -crop -cross -crouch -crowd -crucial -cruel -cruise -crumble -crunch -crush -cry -crystal -cube -culture -cup -cupboard -curious -current -curtain -curve -cushion -custom -cute -cycle -dad -damage -damp -dance -danger -daring -dash -daughter -dawn -day -deal -debate -debris -decade -december -decide -decline -decorate -decrease -deer -defense -define -defy -degree -delay -deliver -demand -demise -denial -dentist -deny -depart -depend -deposit -depth -deputy -derive -describe -desert -design -desk -despair -destroy -detail -detect -develop -device -devote -diagram -dial -diamond -diary -dice -diesel -diet -differ -digital -dignity -dilemma -dinner -dinosaur -direct -dirt -disagree -discover -disease -dish -dismiss -disorder -display -distance -divert -divide -divorce -dizzy -doctor -document -dog -doll -dolphin -domain -donate -donkey -donor -door -dose -double -dove -draft -dragon -drama -drastic -draw -dream -dress -drift -drill -drink -drip -drive -drop -drum -dry -duck -dumb -dune -during -dust -dutch -duty -dwarf -dynamic -eager -eagle -early -earn -earth -easily -east -easy -echo -ecology -economy -edge -edit -educate -effort -egg -eight -either -elbow -elder -electric -elegant -element -elephant -elevator -elite -else -embark -embody -embrace -emerge -emotion -employ -empower -empty -enable -enact -end -endless -endorse -enemy -energy -enforce -engage -engine -enhance -enjoy -enlist -enough -enrich -enroll -ensure -enter -entire -entry -envelope -episode -equal -equip -era -erase -erode -erosion -error -erupt -escape -essay -essence -estate -eternal -ethics -evidence -evil -evoke -evolve -exact -example -excess -exchange -excite -exclude -excuse -execute -exercise -exhaust -exhibit -exile -exist -exit -exotic -expand -expect -expire -explain -expose -express -extend -extra -eye -eyebrow -fabric -face -faculty -fade -faint -faith -fall -false -fame -family -famous -fan -fancy -fantasy -farm -fashion -fat -fatal -father -fatigue -fault -favorite -feature -february -federal -fee -feed -feel -female -fence -festival -fetch -fever -few -fiber -fiction -field -figure -file -film -filter -final -find -fine -finger -finish -fire -firm -first -fiscal -fish -fit -fitness -fix -flag -flame -flash -flat -flavor -flee -flight -flip -float -flock -floor -flower -fluid -flush -fly -foam -focus -fog -foil -fold -follow -food -foot -force -forest -forget -fork -fortune -forum -forward -fossil -foster -found -fox -fragile -frame -frequent -fresh -friend -fringe -frog -front -frost -frown -frozen -fruit -fuel -fun -funny -furnace -fury -future -gadget -gain -galaxy -gallery -game -gap -garage -garbage -garden -garlic -garment -gas -gasp -gate -gather -gauge -gaze -general -genius -genre -gentle -genuine -gesture -ghost -giant -gift -giggle -ginger -giraffe -girl -give -glad -glance -glare -glass -glide -glimpse -globe -gloom -glory -glove -glow -glue -goat -goddess -gold -good -goose -gorilla -gospel -gossip -govern -gown -grab -grace -grain -grant -grape -grass -gravity -great -green -grid -grief -grit -grocery -group -grow -grunt -guard -guess -guide -guilt -guitar -gun -gym -habit -hair -half -hammer -hamster -hand -happy -harbor -hard -harsh -harvest -hat -have -hawk -hazard -head -health -heart -heavy -hedgehog -height -hello -helmet -help -hen -hero -hidden -high -hill -hint -hip -hire -history -hobby -hockey -hold -hole -holiday -hollow -home -honey -hood -hope -horn -horror -horse -hospital -host -hotel -hour -hover -hub -huge -human -humble -humor -hundred -hungry -hunt -hurdle -hurry -hurt -husband -hybrid -ice -icon -idea -identify -idle -ignore -ill -illegal -illness -image -imitate -immense -immune -impact -impose -improve -impulse -inch -include -income -increase -index -indicate -indoor -industry -infant -inflict -inform -inhale -inherit -initial -inject -injury -inmate -inner -innocent -input -inquiry -insane -insect -inside -inspire -install -intact -interest -into -invest -invite -involve -iron -island -isolate -issue -item -ivory -jacket -jaguar -jar -jazz -jealous -jeans -jelly -jewel -job -join -joke -journey -joy -judge -juice -jump -jungle -junior -junk -just -kangaroo -keen -keep -ketchup -key -kick -kid -kidney -kind -kingdom -kiss -kit -kitchen -kite -kitten -kiwi -knee -knife -knock -know -lab -label -labor -ladder -lady -lake -lamp -language -laptop -large -later -latin -laugh -laundry -lava -law -lawn -lawsuit -layer -lazy -leader -leaf -learn -leave -lecture -left -leg -legal -legend -leisure -lemon -lend -length -lens -leopard -lesson -letter -level -liar -liberty -library -license -life -lift -light -like -limb -limit -link -lion -liquid -list -little -live -lizard -load -loan -lobster -local -lock -logic -lonely -long -loop -lottery -loud -lounge -love -loyal -lucky -luggage -lumber -lunar -lunch -luxury -lyrics -machine -mad -magic -magnet -maid -mail -main -major -make -mammal -man -manage -mandate -mango -mansion -manual -maple -marble -march -margin -marine -market -marriage -mask -mass -master -match -material -math -matrix -matter -maximum -maze -meadow -mean -measure -meat -mechanic -medal -media -melody -melt -member -memory -mention -menu -mercy -merge -merit -merry -mesh -message -metal -method -middle -midnight -milk -million -mimic -mind -minimum -minor -minute -miracle -mirror -misery -miss -mistake -mix -mixed -mixture -mobile -model -modify -mom -moment -monitor -monkey -monster -month -moon -moral -more -morning -mosquito -mother -motion -motor -mountain -mouse -move -movie -much -muffin -mule -multiply -muscle -museum -mushroom -music -must -mutual -myself -mystery -myth -naive -name -napkin -narrow -nasty -nation -nature -near -neck -need -negative -neglect -neither -nephew -nerve -nest -net -network -neutral -never -news -next -nice -night -noble -noise -nominee -noodle -normal -north -nose -notable -note -nothing -notice -novel -now -nuclear -number -nurse -nut -oak -obey -object -oblige -obscure -observe -obtain -obvious -occur -ocean -october -odor -off -offer -office -often -oil -okay -old -olive -olympic -omit -once -one -onion -online -only -open -opera -opinion -oppose -option -orange -orbit -orchard -order -ordinary -organ -orient -original -orphan -ostrich -other -outdoor -outer -output -outside -oval -oven -over -own -owner -oxygen -oyster -ozone -pact -paddle -page -pair -palace -palm -panda -panel -panic -panther -paper -parade -parent -park -parrot -party -pass -patch -path -patient -patrol -pattern -pause -pave -payment -peace -peanut -pear -peasant -pelican -pen -penalty -pencil -people -pepper -perfect -permit -person -pet -phone -photo -phrase -physical -piano -picnic -picture -piece -pig -pigeon -pill -pilot -pink -pioneer -pipe -pistol -pitch -pizza -place -planet -plastic -plate -play -please -pledge -pluck -plug -plunge -poem -poet -point -polar -pole -police -pond -pony -pool -popular -portion -position -possible -post -potato -pottery -poverty -powder -power -practice -praise -predict -prefer -prepare -present -pretty -prevent -price -pride -primary -print -priority -prison -private -prize -problem -process -produce -profit -program -project -promote -proof -property -prosper -protect -proud -provide -public -pudding -pull -pulp -pulse -pumpkin -punch -pupil -puppy -purchase -purity -purpose -purse -push -put -puzzle -pyramid -quality -quantum -quarter -question -quick -quit -quiz -quote -rabbit -raccoon -race -rack -radar -radio -rail -rain -raise -rally -ramp -ranch -random -range -rapid -rare -rate -rather -raven -raw -razor -ready -real -reason -rebel -rebuild -recall -receive -recipe -record -recycle -reduce -reflect -reform -refuse -region -regret -regular -reject -relax -release -relief -rely -remain -remember -remind -remove -render -renew -rent -reopen -repair -repeat -replace -report -require -rescue -resemble -resist -resource -response -result -retire -retreat -return -reunion -reveal -review -reward -rhythm -rib -ribbon -rice -rich -ride -ridge -rifle -right -rigid -ring -riot -ripple -risk -ritual -rival -river -road -roast -robot -robust -rocket -romance -roof -rookie -room -rose -rotate -rough -round -route -royal -rubber -rude -rug -rule -run -runway -rural -sad -saddle -sadness -safe -sail -salad -salmon -salon -salt -salute -same -sample -sand -satisfy -satoshi -sauce -sausage -save -say -scale -scan -scare -scatter -scene -scheme -school -science -scissors -scorpion -scout -scrap -screen -script -scrub -sea -search -season -seat -second -secret -section -security -seed -seek -segment -select -sell -seminar -senior -sense -sentence -series -service -session -settle -setup -seven -shadow -shaft -shallow -share -shed -shell -sheriff -shield -shift -shine -ship -shiver -shock -shoe -shoot -shop -short -shoulder -shove -shrimp -shrug -shuffle -shy -sibling -sick -side -siege -sight -sign -silent -silk -silly -silver -similar -simple -since -sing -siren -sister -situate -six -size -skate -sketch -ski -skill -skin -skirt -skull -slab -slam -sleep -slender -slice -slide -slight -slim -slogan -slot -slow -slush -small -smart -smile -smoke -smooth -snack -snake -snap -sniff -snow -soap -soccer -social -sock -soda -soft -solar -soldier -solid -solution -solve -someone -song -soon -sorry -sort -soul -sound -soup -source -south -space -spare -spatial -spawn -speak -special -speed -spell -spend -sphere -spice -spider -spike -spin -spirit -split -spoil -sponsor -spoon -sport -spot -spray -spread -spring -spy -square -squeeze -squirrel -stable -stadium -staff -stage -stairs -stamp -stand -start -state -stay -steak -steel -stem -step -stereo -stick -still -sting -stock -stomach -stone -stool -story -stove -strategy -street -strike -strong -struggle -student -stuff -stumble -style -subject -submit -subway -success -such -sudden -suffer -sugar -suggest -suit -summer -sun -sunny -sunset -super -supply -supreme -sure -surface -surge -surprise -surround -survey -suspect -sustain -swallow -swamp -swap -swarm -swear -sweet -swift -swim -swing -switch -sword -symbol -symptom -syrup -system -table -tackle -tag -tail -talent -talk -tank -tape -target -task -taste -tattoo -taxi -teach -team -tell -ten -tenant -tennis -tent -term -test -text -thank -that -theme -then -theory -there -they -thing -this -thought -three -thrive -throw -thumb -thunder -ticket -tide -tiger -tilt -timber -time -tiny -tip -tired -tissue -title -toast -tobacco -today -toddler -toe -together -toilet -token -tomato -tomorrow -tone -tongue -tonight -tool -tooth -top -topic -topple -torch -tornado -tortoise -toss -total -tourist -toward -tower -town -toy -track -trade -traffic -tragic -train -transfer -trap -trash -travel -tray -treat -tree -trend -trial -tribe -trick -trigger -trim -trip -trophy -trouble -truck -true -truly -trumpet -trust -truth -try -tube -tuition -tumble -tuna -tunnel -turkey -turn -turtle -twelve -twenty -twice -twin -twist -two -type -typical -ugly -umbrella -unable -unaware -uncle -uncover -under -undo -unfair -unfold -unhappy -uniform -unique -unit -universe -unknown -unlock -until -unusual -unveil -update -upgrade -uphold -upon -upper -upset -urban -urge -usage -use -used -useful -useless -usual -utility -vacant -vacuum -vague -valid -valley -valve -van -vanish -vapor -various -vast -vault -vehicle -velvet -vendor -venture -venue -verb -verify -version -very -vessel -veteran -viable -vibrant -vicious -victory -video -view -village -vintage -violin -virtual -virus -visa -visit -visual -vital -vivid -vocal -voice -void -volcano -volume -vote -voyage -wage -wagon -wait -walk -wall -walnut -want -warfare -warm -warrior -wash -wasp -waste -water -wave -way -wealth -weapon -wear -weasel -weather -web -wedding -weekend -weird -welcome -west -wet -whale -what -wheat -wheel -when -where -whip -whisper -wide -width -wife -wild -will -win -window -wine -wing -wink -winner -winter -wire -wisdom -wise -wish -witness -wolf -woman -wonder -wood -wool -word -work -world -worry -worth -wrap -wreck -wrestle -wrist -write -wrong -yard -year -yellow -you -young -youth -zebra -zero -zone -zoo`.split(` -`),Ts={orgSeed:t=>`m/83696968'/39'/0'/24'/${t}'`,wallet:(t,e=1)=>`m/86'/${e}'/${t}'/0/0`,nostr:t=>`m/44'/1237'/${t}'/0/0`},Fy=2**31-1,si=new Map,ii=new Map,Ta=()=>Zy(To,256);function $l(t,e=0){if(typeof t!="string"||!Ky(t,To)||e&&t.split(" ").length!==e)throw new Error("Invalid lab mnemonic.");return t}function Io(t,e){if(!Number.isSafeInteger(t)||t<0||t>Fy)throw new Error(`Invalid ${e}.`);return t}function Uo(t){return si.has(t)||si.set(t,zt.fromMasterSeed(zy($l(t)))),si.get(t)}function Gy(t,e){const n=t.derive(e).privateKey;if(!n)throw new Error("BIP-85 path produced no private key.");return In(cs,dr("bip-entropy-from-k"),n)}function Wy(t,e){const n=`${t}|${Io(e,"child index")}`;return ii.has(n)||ii.set(n,Al(Gy(Uo(t),Ts.orgSeed(e)).slice(0,32),To)),ii.get(n)}function Bl(t,e=0,n=1){return nt(Uo(t).derive(Ts.wallet(Io(e,"account"),n)).privateKey)}function Yy(t,e=0){const n=ll.getPublicKey(Uo(t).derive(Ts.nostr(Io(e,"account"))).privateKey);return{pubkey:nt(n),npub:Oa.encode("npub",Oa.toWords(n))}}const Ol="lineage-claim",Li=330,bs=t=>xe.encode(t,!1).hex,Ia=t=>({txid:t.txid,vout:t.vout,value:t.value,script:bs(t.scriptPubKey)}),oi=/^[0-9a-f]{64}$/,Xy=/^5120[0-9a-f]{64}$/;function Po(t,e){var n;for(const r of t.utxos.values())if((n=r.inscriptions)!=null&&n.some(s=>s.id===e))return r;return null}function Cl(t){return le.create({vin:[En(t.holder.txid,t.holder.vout,t.holder.value,t.holder.script),En(t.payer.txid,t.payer.vout,t.payer.value,t.payer.script)],vout:[ze(t.holder.value,["OP_1",t.to]),ze(t.payer.value-Ae,["OP_1",t.to])]})}function Jy(t,e,n,r=Date.now()){if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Claims are signed by local test wallets.");const s=Po(t,e);if(!s)throw new Error("That inscription is not in an unspent output.");if(bs(s.scriptPubKey)===bs(n.script))throw new Error("The recipient already holds that inscription.");const i=t.coins(n.script).find(c=>{var u;return!((u=c.inscriptions)!=null&&u.length)&&c.value>=Ae+Li});if(!i)throw new Error("The recipient needs a plain coin for the 500-sat fee. Mine a block to it first.");const o={kind:Ol,version:1,inscription:e,carried:s.inscriptions.map(c=>c.id),holder:Ia(s),payer:Ia(i),to:n.pubkey,at:r},a=Cl(o);return o.txid=le.util.getTxid(a),o.sig=n.sign(a,void 0,1),o}function Qy(t,e,n){const r=tw(e);if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Countersigning needs a local test wallet.");if(bs(n.script)!==r.holder.script)throw new Error("Only the current holder can countersign.");if(ew(t,r)!=="open")throw new Error("This claim is stale: an input it spends was already spent.");const s=Cl(r);return s.vin[1].witness=[r.sig],s.vin[0].witness=[n.sign(s,void 0,0)],t.submitPackage([le.encode(s).hex]),le.util.getTxid(s)}function ew(t,e){return t.utxos.has(`${e.holder.txid}:${e.holder.vout}`)&&t.utxos.has(`${e.payer.txid}:${e.payer.vout}`)?"open":"stale"}function tw(t){const e=n=>n&&oi.test(n.txid)&&Number.isSafeInteger(n.vout)&&n.vout>=0&&Number.isSafeInteger(n.value)&&n.value>=Li&&Xy.test(n.script);if((t==null?void 0:t.kind)!==Ol||t.version!==1||!/^[0-9a-f]{64}i\d+$/.test(t.inscription)||!Array.isArray(t.carried)||!e(t.holder)||!e(t.payer)||t.payer.value({roots:{},adopted:{}}),Nr=t=>xe.encode(t,!1).hex;function Hi(t,e,n){if(!n)return null;const r=o=>o?{mnemonic:o,account:0,origin:`${n.name} root`,steps:[]}:null;if(n.kind==="holding")return r(t.roots[n.id]);const s=e.nodes.get(n.parent);if(n.kind==="agent"){const o=Hi(t,e,s);return o&&{...o,account:n.index+1}}if(n.edge==="adopted")return r(t.adopted[n.id]);const i=Hi(t,e,s);return i&&{mnemonic:Wy(i.mnemonic,n.index),account:0,origin:i.origin,steps:[...i.steps,`${n.index}'`]}}function rt(t,e,n){const r=Hi(t,e,n);return r?{wallet:new Mt(Bl(r.mnemonic,r.account)),npub:Yy(r.mnemonic,r.account).npub,path:`${[r.origin,...r.steps].join(" › ")} · ${Ts.wallet(r.account)}`}:null}function Tl(t,e,n){const r=Po(t.chain,n);if(!r)return null;const s=Nr(r.scriptPubKey),i=e.nodes.get(n),o=rt(t.keys,e,i),a=i&&rt(t.keys,e,e.nodes.get(i.parent));return o&&Nr(o.wallet.script)===s?{wallet:o.wallet,who:"own"}:t.wallet&&Nr(t.wallet.script)===s?{wallet:t.wallet,who:"lab"}:a&&Nr(a.wallet.script)===s?{wallet:a.wallet,who:"parent"}:{wallet:null,who:"other",script:s}}function Il(t,e){const n=t.nodes.get(e),r=[n];for(const s of n.children){const i=t.nodes.get(s);i.status==="active"&&i.edge==="derived"&&r.push(...Il(t,s))}return r}const Is="orgchain:lab:v1",nw=["each",10,30,60,"manual"];function mr(t={tempo:"each",nextAt:null}){const{tempo:e,nextAt:n}=t??{},r=typeof e=="number";if(!nw.includes(e)||!(n===null||r&&Number.isSafeInteger(n)&&n>0))throw new Error("Invalid clock.");return{tempo:e,nextAt:n}}function Ul(t){const e=No();for(const n of["roots","adopted"])for(const[r,s]of Object.entries((t==null?void 0:t[n])??{})){if(!/^[0-9a-f]{64}i0$/.test(r))throw new Error("Invalid lab keys.");e[n][r]=$l(s,24)}return e}const br=()=>({wallet:null,chain:new Os,clock:mr(),keys:No()});function Pl(t){if(!t)return br();const e=JSON.parse(t);if((e==null?void 0:e.kind)!=="orgchain-lab"||e.network!==Nt||e.version!==1)throw new Error("That is not an Orgchain v1 lab.");return{wallet:e.wallet?Mt.load(e.wallet):null,chain:new Os(e.chain),clock:mr(e.clock),keys:Ul(e.keys)}}const Nl=t=>{var e;return JSON.stringify({kind:"orgchain-lab",network:Nt,version:1,wallet:((e=t.wallet)==null?void 0:e.backup())??null,chain:t.chain.snapshot(),clock:mr(t.clock),keys:Ul(t.keys)})},Lo=()=>Pl(localStorage.getItem(Is));function rw(t){try{localStorage.setItem(Is,Nl(t))}catch{throw new Error("Browser storage is full or unavailable, so nothing was saved. Save a backup, then reset.")}}async function sw(t,{locks:e=(s=>(s=globalThis.navigator)==null?void 0:s.locks)(),read:n=Lo,save:r=rw}={}){if(!e)throw new Error("Orgchain needs Web Locks: open it over HTTPS or on localhost.");return e.request(Is,async()=>{const i=n(),o=await t(i);return o!==!1&&r(i),{lab:i,result:o}})}function un(t){t.wallet||(t.wallet=Mt.create());const e=t.chain.mine(t.wallet.script);return t.clock=mr({tempo:t.clock.tempo,nextAt:null}),e}function Ho(t,e=Date.now()){const{tempo:n,nextAt:r}=t.clock;typeof n=="number"&&t.chain.mempool.length&&r===null&&(t.clock={tempo:n,nextAt:e+n*1e3})}function iw(t,e,n=Date.now()){t.clock=mr({tempo:e,nextAt:null}),e==="each"&&t.chain.mempool.length?un(t):Ho(t,n)}function ow(t,e=Date.now()){const{tempo:n,nextAt:r}=t.clock;return typeof n!="number"||!t.chain.mempool.length?!1:r===null?(Ho(t,e),!0):e`found ${t.name}`,birth:t=>`birth ${t.name}`,award:t=>`award ${t.skill} ${t.belt}`,decide:t=>`decide ${t.title}`,graduate:()=>"graduate",close:()=>"close"};function cw(t,e={}){if(!Object.hasOwn(Ua,t))throw new Error("Unknown verb.");const n={op:t};for(const r of Ua[t]){const s=e[r];typeof s=="string"&&s.trim()&&(n[r]=s.trim())}return n}const ai=t=>Tn(yo(new As(t.chain)),{pending:!0});function Ll(t,e,n,r){const s=cw(e,r),i=yo(new As(t.chain)),o={id:"check",status:"pending",height:null,metadata:s,parent:n??null,protocol:mo},{ok:a,why:c}=Tn([...i,o],{pending:!0}).log.at(-1);if(!a)throw new Error(`${c[0].toUpperCase()}${c.slice(1)}.`);return s}const uw=lt+2*Ae+330,Zr=1e5,ys=(t,e,n)=>t.chain.coins(e.script).find(r=>{var s;return!((s=r.inscriptions)!=null&&s.length)&&r.value>=n}),Ri=t=>En(t.txid,t.vout,t.value,t.scriptPubKey),Hl=(t,e)=>(e.forEach((n,r)=>{t.vin[r].witness=[n.sign(t,void 0,r)]}),le.encode(t).hex);function Rl(t){t.keys??(t.keys=No()),t.wallet||(t.wallet=Mt.create()),ys(t,t.wallet,Zr+Ae+330)||un(t)}function ci(t,e,n=uw){if(e===t.wallet||ys(t,e,n))return;const r=ys(t,t.wallet,Zr+Ae+330),s=le.create({vin:[Ri(r)],vout:[ze(Zr,e.script),ze(r.value-Zr-Ae,t.wallet.script)]});t.chain.submitPackage([Hl(s,[t.wallet])])}function Pa(t,e,n,r){const s=Po(t.chain,e),i=ys(t,t.wallet,Ae+330),o=le.create({vin:[Ri(s),Ri(i)],vout:[ze(s.value,r.script),ze(i.value-Ae,t.wallet.script)]});t.chain.submitPackage([Hl(o,[n,t.wallet])])}function Na(t,e,n,r,s){return new yb(t.chain,e).inscribe(aw[n](s),r??null,s,{metaprotocol:mo})}function La(t,e,n){var s;const r=Tl(t,e,n);if(!(r!=null&&r.wallet))throw new Error(`No key in this lab holds ${((s=e.nodes.get(n))==null?void 0:s.name)??"that node"}'s inscription.`);return r.wallet}function jl(t,e,n,r){if(e==="found"){const u=Ta(),f=new Mt(Bl(u,0));ci(t,f);const l=Na(t,f,e,null,r);return t.keys.roots[l]=u,l}const s=ai(t),i=La(t,s,n),o=e==="graduate"?s.nodes.get(r.of):null,a=o&&rt(t.keys,s,o)?Il(s,o.id).map(u=>[u.id,La(t,s,u.id)]):[];ci(t,i);const c=Na(t,i,e,n,r);if(e==="birth"){const u=ai(t),f=rt(t.keys,u,u.nodes.get(c));f&&Pa(t,c,i,f.wallet)}if(a.length){t.keys.adopted[o.id]=Ta();const u=ai(t);for(const[f,l]of a){const d=rt(t.keys,u,u.nodes.get(f)).wallet;if(f!==o.id){Pa(t,f,l,d);continue}ci(t,d,Ae+330),Qy(t.chain,Jy(t.chain,f,d),l)}}return c}function lw(t,e,n,r,s=Date.now()){const i=Ll(t,e,n,r);Rl(t);const o=jl(t,e,n??null,i);return t.clock.tempo==="each"?un(t):Ho(t,s),o}const Dl="yolopreneur",fw=[[["found",null,{name:"yolopreneur"}]],[["birth","yolopreneur",{name:"well-known",kind:"org"}],["birth","yolopreneur",{name:"time",kind:"org"}]],[["birth","well-known",{name:"mailr",kind:"org"}],["birth","well-known",{name:"lineage",kind:"org"}],["birth","time",{name:"luna",kind:"agent"}],["birth","time",{name:"sol",kind:"agent"}],["birth","time",{name:"astra",kind:"agent"}]],[["birth","time",{name:"docscope",kind:"org"}],["birth","time",{name:"dollhouse",kind:"org"}],["birth","time",{name:"doodleloop",kind:"org"}],["birth","time",{name:"hearthframe",kind:"org"}]],[["award","time",{to:"sol",skill:"launch",belt:"green"}],["award","time",{to:"luna",skill:"post",belt:"white"}],["decide","yolopreneur",{title:"Every venture gets a page",why:".yolopreneur.lol, served from one pages branch."}]],[["graduate","well-known",{of:"lineage"}],["decide","lineage",{title:"Lineage gets its own org",why:"Its own repo on Teahub now, lineage.llc later: adopted, not derived."}]]];function dw(t){Rl(t),t.chain.mempool.length&&un(t);const e={};for(const n of fw){for(const[r,s,i]of n){const o=Object.fromEntries(Object.entries(i).map(([u,f])=>[u,u==="to"||u==="of"?e[f]:f])),a=s?e[s]:null,c=jl(t,r,a,Ll(t,r,a,o));(r==="found"||r==="birth")&&(e[i.name]=c)}un(t)}return e[Dl]}const Z=t=>document.getElementById(t);function T(t,e={},...n){const r=document.createElement(t);for(const[s,i]of Object.entries(e))i==null||i===!1||(s==="class"?r.className=i:s==="text"?r.textContent=i:s.startsWith("on")?r.addEventListener(s.slice(2),i):r.setAttribute(s,i===!0?"":String(i)));for(const s of n.flat(1/0))s!=null&&s!==!1&&s!==""&&r.append(s instanceof Node?s:String(s));return r}const zn=(t,e)=>`${t} ${e}${t===1?"":"s"}`,yn=t=>t==="cued"?"cued":`beat ${t}`,hw=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),Ha=t=>JSON.stringify(t,(e,n)=>typeof n=="bigint"?String(n):n,2),O={holding:null,node:null,event:null,beat:null,verb:"birth",busy:!1,replay:null,closing:null};let me=br(),ws=new As(me.chain),Fn=[],he=Tn([]),pt=he;const Fe=()=>me.chain.blocks.length,Mr=()=>Fn.filter(t=>t.status==="pending").length,fe=(t,e=he)=>t?e.nodes.get(t)??null:null,Zl=t=>Object.assign(O,{event:null,closing:null},t),Us=t=>{Zl(t),Ps()};function Ue(t,e=!1){const n=Z("say");n.textContent=t,n.classList.toggle("bad",e)}function Ml(){try{me=Lo()}catch(t){me=br(),Ue(`This browser's saved lab could not be read (${t.message}) Load a backup, or reset to start over.`,!0)}Ro()}function Ro(){var t;ws=new As(me.chain),Fn=yo(ws),he=Tn(Fn,{pending:!0}),O.beat!==null&&O.beat>=Fe()&&(O.beat=null),fe(O.holding)||(O.holding=((t=he.roots.at(-1))==null?void 0:t.id)??null),(!fe(O.node)||fe(O.node).root!==O.holding)&&(O.node=O.holding),O.event&&!he.log.some(e=>e.id===O.event)&&(O.event=null),pt=O.beat===null?he:Tn(Fn,{upTo:O.beat}),Ps()}function xs(t){O.beat=t>=Fe()?null:Math.max(0,t),pt=O.beat===null?he:Tn(Fn,{upTo:O.beat}),Ps()}async function yr(t,e){if(O.busy)return!1;O.busy=!0,document.body.classList.add("busy");try{return me=(await sw(t,e)).lab,!0}catch(n){return Ue((n==null?void 0:n.message)||String(n),!0),!1}finally{O.busy=!1,document.body.classList.remove("busy"),Ro()}}async function Zn(t,e,n,r){let s=null;if(!await yr(o=>{s=lw(o,t,e,n)}))return!1;const i=ws.events.find(o=>o.id===s);return Ue(r(s,(i==null?void 0:i.status)==="confirmed"?`at beat ${i.height}`:"cued for the next beat")),Ps(),!0}async function Vl(t){const e=Mr();await yr(t)&&Mr(){const e=Sb(he,t.id),n=t.id===O.holding,r=[yn(t.born),zn(e.orgs,"org"),zn(e.agents,"agent"),zn(e.belts,"belt"),t.status==="closed"&&"closed"].filter(Boolean);return T("li",{},T("button",{type:"button",class:`hold${n?" on":""}${t.status==="closed"?" gone":""}`,"aria-pressed":String(n),onclick:()=>Us({holding:t.id,node:t.id})},T("span",{class:"hn",text:t.name})," ",T("span",{class:"hm",text:r.join(" · ")})))})),Z("holdings-empty").hidden=he.roots.length>0,Z("holdings-sub").textContent=he.roots.length?String(he.roots.length):"",Z("sample").disabled=he.roots.some(t=>t.name===Dl&&t.status==="active")}function mw(){var r;const t=Z("tree-rows"),e=fe(O.holding);if(Z("tree-sub").textContent=e?`${e.name} · ${O.beat===null?"now":`beat ${O.beat} of ${Fe()}`}`:"",!e)return t.replaceChildren(T("p",{class:"wait",text:"No holding yet. Found one, or load the yolopreneur sample."}));if(!pt.nodes.has(e.id))return t.replaceChildren(T("p",{class:"wait",text:`${e.name} is founded at ${yn(e.born)}. Move the slider forward.`}));const n=t.contains(document.activeElement)?document.activeElement.dataset.id:null;t.replaceChildren(...Eb(pt,e.id).map(s=>s.type==="group"?T("div",{class:"row grp"},T("span",{class:"g","aria-hidden":"true",text:s.guide}),T("span",{class:"gl",text:s.label})):bw(s))),n&&((r=t.querySelector(`[data-id="${n}"]`))==null||r.focus())}function bw({node:t,guide:e,path:n}){const r=t.id===O.node,s=["row",r&&"on",t.status==="closed"&&"gone",t.born==="cued"&&"cue"].filter(Boolean).join(" ");return T("div",{class:s},T("button",{type:"button",class:"sel","data-id":t.id,"aria-pressed":String(r),onclick:()=>Us({node:t.id})},T("span",{class:"g","aria-hidden":"true",text:e}),T("span",{class:"p",text:`${n} `}),T("span",{class:"l",text:t.name})," ",T("span",{class:"v"},yw(t))))}function yw(t){return[t.kind==="agent"&&T("span",{class:"mk",text:"agent"}),t.edge==="adopted"&&T("span",{class:"mk ok",text:"graduated"}),t.status==="closed"&&T("span",{class:"mk bad",text:"closed"}),t.born==="cued"&&T("span",{class:"mk",text:"cued"}),...t.badges.map(ql)].filter(Boolean).flatMap((n,r)=>r?[" ",n]:[n])}const ql=t=>T("span",{class:`belt ${t.belt}`,title:`${t.skill}: ${t.belt} belt`},t.skill,T("span",{class:"sr",text:` (${t.belt} belt)`})),ww=(t,e)=>{for(let n=fe(t.parent);n;n=fe(n.parent))if(n.id===e.id)return!0;return!1},zl=t=>[...he.nodes.values()].filter(e=>e.root===t.root&&e.id!==t.id&&e.status==="active").map(e=>[e,(ww(e,t)?0:2)+(e.kind==="agent"?0:1)]).sort((e,n)=>e[1]-n[1]).map(([e])=>e),Fl=t=>t.children.reduce((e,n)=>{const r=fe(n);return r&&r.edge==="derived"&&r.status==="active"?e+1+Fl(r):e},0);function xw(t){const e=fe(t.parent),n=t.status==="closed"?`${t.name} is closed`:"";return{birth:n||(t.kind==="agent"?"Agents do not give birth":""),award:n||(t.kind==="agent"?"Agents do not award belts":zl(t).length?"":"There is nobody else in this holding to award yet"),decide:n,graduate:n||(e?t.kind!=="org"?"Only orgs graduate":t.edge==="adopted"?`${t.name} has already graduated`:e.status!=="active"?`${e.name} is closed`:"":"A holding has no parent to graduate from"),close:n}}function Ns(){const t=fe(O.node),e=O.beat!==null;if(Z("act-none").hidden=!!t,Z("act-past").hidden=!t||!e,Z("act-on").hidden=!t||e,Z("act-sub").textContent=(t==null?void 0:t.name)??"",Z("past-beat").textContent=String(O.beat??""),!t||e)return;const n=xw(t),r=fe(t.parent);for(const d of document.querySelectorAll("[data-verb]"))d.setAttribute("aria-pressed",String(d.dataset.verb===O.verb)),d.classList.toggle("off",!!n[d.dataset.verb]);for(const d of document.querySelectorAll("form[data-form]"))d.hidden=d.dataset.form!==O.verb||!!n[O.verb];Z("act-why").textContent=n[O.verb]?`${n[O.verb]}.`:"";for(const d of document.querySelectorAll("#act-on [data-name]"))d.textContent=t.name;for(const d of document.querySelectorAll("#act-on [data-parent]"))d.textContent=(r==null?void 0:r.name)??"";const s=Z("award-to"),i=s.value,o=zl(t).map(d=>T("option",{value:d.id,text:`${Pu(he,d.id)}${d.kind==="agent"?" (agent)":""}`})),a=d=>d.map(h=>`${h.value}=${h.textContent}`).join("|");a(o)!==a([...s.options])&&(s.replaceChildren(...o),o.some(d=>d.value===i)&&(s.value=i)),Z("graduate-go").textContent=`Graduate ${t.name}`;const c=O.verb==="graduate"?r:t,u=c&&rt(me.keys,he,c);Z("act-key").textContent=!c||n[O.verb]?"":u?`Signs as ${c.name}: ${u.path}`:"Signs with the lab wallet: this holding predates lab keys.";const f=Fl(t),l=O.closing===t.id;Z("close-note").textContent=f?`Closing ${t.name} spends it for the last time, and its ${zn(f,"derived descendant")} close with it. Graduated children hold their own roots and stay open.`:`Closing ${t.name} spends its inscription for the last time. Nothing can act through it afterwards.`,Z("close-go").textContent=l?`Yes, close ${t.name}`:`Close ${t.name}`,Z("close-keep").hidden=!l}function vw(){const t=Z("inspect-body"),e=O.event?he.log.find(s=>s.id===O.event):null;if(e)return Z("inspect-sub").textContent="event",t.replaceChildren(...Aw(e));const n=fe(O.node);if(Z("inspect-sub").textContent=(n==null?void 0:n.kind)??"",!n)return t.replaceChildren(T("p",{class:"note pad",text:"Select a node in the tree, or an event in the timeline."}));const r=fe(O.node,pt);if(!r)return t.replaceChildren(T("p",{class:"note pad",text:`${n.name} is not born yet at beat ${O.beat}.`}));t.replaceChildren(...Ew(r))}const Gl=([t,e])=>T("div",{class:"f"},T("dt",{text:t}),T("dd",{text:e}));function Ew(t){const e=fe(t.parent,pt),n=[["Born",t.born==="cued"?"cued for the next beat":`beat ${t.born}`],e&&["Parent",`${e.name} · ${t.kind} ${t.index}'`],e&&["Edge",t.edge==="adopted"?`adopted at ${yn(t.graduated)}: it holds its own root`:`derived: ${e.name} holds its seed`],t.closed!==null&&["Closed",yn(t.closed)],["Children",t.children.length?t.children.map(r=>{var s;return(s=fe(r,pt))==null?void 0:s.name}).join(", "):"none yet"],..._w(t),["Inscription",t.id]].filter(Boolean);return[T("div",{class:"ih"},T("p",{class:"eyebrow",text:Pu(pt,t.id)}),T("h3",{class:"it",text:t.name}),T("div",{class:"chips"},T("span",{class:"chip",text:t.kind}),T("span",{class:`chip ${t.status==="active"?"ok":"bad"}`,text:t.status}),t.edge==="adopted"&&T("span",{class:"chip ok",text:"graduated"}),t.born==="cued"&&T("span",{class:"chip",text:"cued"}))),T("div",{class:"ib"},T("dl",{class:"fl"},n.map(Gl)),t.badges.length>0&&T("div",{},T("p",{class:"lab",text:"Belts"}),T("ul",{class:"list"},t.badges.map(r=>{var s;return T("li",{},ql(r),T("span",{class:"when",text:` from ${((s=fe(r.by))==null?void 0:s.name)??"?"}, ${yn(r.beat)}`}))}))),t.decisions.length>0&&T("div",{},T("p",{class:"lab",text:"Decisions"}),T("ul",{class:"list"},t.decisions.map(r=>T("li",{},T("b",{text:r.title}),r.why&&` · ${r.why}`,T("span",{class:"when",text:` (${yn(r.beat)})`}))))))]}const Sw={own:"its own key",lab:"the lab wallet",parent:"its parent's key (its handoff is cued)",other:"a key outside this lab"};function _w(t){const e=rt(me.keys,pt,t),n=Tl(me,he,t.id);return[["Key",e?e.path:"the lab wallet: this holding predates lab keys"],e&&["npub",e.npub],e&&["Address",e.wallet.address],["Held now by",n?Sw[n.who]:"nobody: its inscription has been spent"]]}function kw(t){var o,a,c;const e=(a=(o=me.chain.transactions.get(t.id.slice(0,-2)))==null?void 0:o.tx.vin.find(u=>{var f;return((f=u.witness)==null?void 0:f.length)===3}))==null?void 0:a.witness;if(!e)return"?";const n=go(e).pubkey,r=fe(t.parent),s=t.op==="found"?fe(t.node):null,i=[[s&&rt(me.keys,he,s),`${s==null?void 0:s.name}'s root`],[r&&rt(me.keys,he,r),`${r==null?void 0:r.name}'s key`],[(r==null?void 0:r.edge)==="adopted"&&rt(me.keys,he,{...r,edge:"derived"}),`${r==null?void 0:r.name}'s derived key, from before it graduated`]];for(const[u,f]of i)if(u&&u.wallet.pubkey===n)return f;return((c=me.wallet)==null?void 0:c.pubkey)===n?"the lab wallet":`a key outside this lab (${n.slice(0,12)}…)`}function Aw(t){var i,o,a;const e=ws.events.find(c=>c.id===t.id),n=(o=(i=me.chain.transactions.get(t.id.slice(0,-2)))==null?void 0:i.inscription)==null?void 0:o.text,r=[["When",t.pending?"cued for the next beat":`beat ${t.beat}`],["Authorized by",t.parent?`${((a=fe(t.parent))==null?void 0:a.name)??"an unknown inscription"}, whose inscription this event spent`:"nothing: a founding has no parent"],["Signed by",kw(t)],["Inscription",t.id],n&&["Body",n],(e==null?void 0:e.block)&&["Block",e.block]].filter(Boolean),s=e&&{id:e.id,status:e.status,height:e.height,block:e.block,parent:e.parent??null,metaprotocol:e.metaprotocol??null,contentType:e.contentType,sat:e.sat,location:e.location};return[T("div",{class:"ih"},T("p",{class:"eyebrow",text:`${t.op} · ${t.pending?"cued":`beat ${t.beat}`}`}),T("h3",{class:"it",text:Nu(t,he)}),T("div",{class:"chips"},T("span",{class:"chip",text:(e==null?void 0:e.protocol)??"?"}),T("span",{class:`chip ${t.ok?"ok":"bad"}`,text:t.ok?"applied":"rejected"})),!t.ok&&T("p",{class:"idesc",text:"The reducer rejected this event. It stays on the chain, but it does not change the tree."})),T("div",{class:"ib"},T("dl",{class:"fl"},r.map(Gl)),T("div",{class:"code"},T("p",{class:"code-h",text:"Metadata · CBOR, tag 5"}),T("pre",{text:Ha(t.meta)})),s&&T("div",{class:"code"},T("p",{class:"code-h",text:"Raw index entry"}),T("pre",{text:Ha(s)})))]}function jo(){const t=Fe(),e=Z("beat"),n=fe(O.holding);e.max=String(t),e.value=String(O.beat??t),e.disabled=t===0,Z("beat-label").textContent=O.beat===null?`Now · beat ${t}`:`Beat ${O.beat} of ${t}`,Z("replay").textContent=O.replay?"Stop":"Replay",Z("replay").disabled=!n||t===0,Z("to-now").disabled=O.beat===null,Z("timeline-sub").textContent=(n==null?void 0:n.name)??"";const r=new Map;for(const i of he.log)if(i.root&&i.root===O.holding){const o=i.pending?"cued":i.beat;r.set(o,[...r.get(o)??[],i])}const s=[...r.keys()].sort((i,o)=>i==="cued"?-1:o==="cued"?1:o-i);if(!s.length)return Z("timeline-list").replaceChildren(T("li",{class:"wait",text:n?"Nothing yet.":"Found a holding to start its timeline."}));Z("timeline-list").replaceChildren(...s.map(i=>{const o=i==="cued"?null:me.chain.blocks[i-1],a=O.beat!==null&&(i==="cued"||i>O.beat),c=O.beat!==null&&i===O.beat;return T("li",{class:`beat${a?" later":""}${c?" now":""}`},T("p",{class:"bh"},T("span",{class:"bn",text:i==="cued"?"Cued":`Beat ${i}`}),T("span",{class:"bt",text:o?hw(o.time):me.clock.tempo==="manual"?"waiting for Beat now":"landing on the next beat"})),T("ol",{class:"evs"},r.get(i).map(u=>{const[f,...l]=Nu(u,he).split(" ");return T("li",{},T("button",{type:"button",class:`ev${u.ok?"":" bad"}${u.id===O.event?" on":""}`,"aria-pressed":String(u.id===O.event),onclick:()=>Us({event:u.id,node:u.node??O.node})},T("span",{class:"op",text:u.ok?f:`✕ ${f.replace(/:$/,"")}`})," ",T("span",{class:"es",text:l.join(" ")})))})))}))}Z("f-found").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=bo(e.elements.name.value);if(!n)return Ue("Name the holding: lowercase letters, digits and hyphens.",!0);await Zn("found",null,{name:n},(r,s)=>(Zl({holding:r,node:r}),`${n} is founded, ${s}.`))&&e.reset()});Z("sample").addEventListener("click",async()=>{let t=null;Ue("Rehearsing the yolopreneur tree over six beats…"),await yr(e=>{t=dw(e)})&&(Us({holding:t,node:t}),Ue("Loaded the yolopreneur sample: six beats of history. Press Replay to watch it grow."))});Z("f-birth").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=fe(O.node),r=bo(e.elements.name.value),s=e.elements.kind.value;if(!r)return Ue("Name the child: lowercase letters, digits and hyphens.",!0);await Zn("birth",n.id,{name:r,kind:s},(i,o)=>`${r} is born to ${n.name}, ${o}.`)&&(e.elements.name.value="")});Z("f-award").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=fe(O.node),r=e.elements.to.value,s=bo(e.elements.skill.value),i=e.elements.belt.value;if(!s)return Ue("Name the skill, for example launch.",!0);await Zn("award",n.id,{to:r,skill:s,belt:i},(o,a)=>{var c;return`${(c=fe(r))==null?void 0:c.name} holds a ${i} belt in ${s}, ${a}.`})&&(e.elements.skill.value="")});Z("f-decide").addEventListener("submit",async t=>{t.preventDefault();const e=t.currentTarget,n=fe(O.node),r=e.elements.title.value.trim(),s=e.elements.why.value.trim();if(!r)return Ue("A decision needs a title.",!0);await Zn("decide",n.id,{title:r,why:s},(i,o)=>`${n.name} decided “${r}”, ${o}.`)&&e.reset()});Z("f-graduate").addEventListener("submit",async t=>{t.preventDefault();const e=fe(O.node),n=fe(e.parent);await Zn("graduate",n.id,{of:e.id},(r,s)=>`${e.name} graduates from ${n.name}, ${s}. Its edge is adopted now.`)});Z("f-close").addEventListener("submit",async t=>{t.preventDefault();const e=fe(O.node);if(O.closing!==e.id)return O.closing=e.id,Ns(),Z("close-go").focus();O.closing=null,await Zn("close",e.id,{},(n,r)=>`${e.name} is closed, ${r}.`)});Z("close-keep").addEventListener("click",()=>{O.closing=null,Ns(),Z("close-go").focus()});for(const t of document.querySelectorAll("[data-verb]"))t.addEventListener("click",()=>{O.verb=t.dataset.verb,O.closing=null,Ns()});for(const t of document.querySelectorAll("[data-tempo]"))t.addEventListener("click",async()=>{const e=t.dataset.tempo,n=/^\d+$/.test(e)?Number(e):e;await yr(r=>iw(r,n))&&Ue(e==="each"?"Each act is its own beat.":e==="manual"?"Acts are cued until you press Beat now.":`Acts are cued and land together on the next beat, at most ${e} seconds after the first.`)});Z("beat-now").addEventListener("click",()=>Vl(t=>t.chain.mempool.length?un(t):!1));setInterval(()=>{Kl();const{tempo:t,nextAt:e}=me.clock;O.busy||document.hidden||typeof t!="number"||!me.chain.mempool.length||e&&Date.now()ow(n))},1e3);addEventListener("storage",t=>{(t.key===Is||t.key===null)&&Ml()});function wr(){O.replay&&(clearInterval(O.replay),O.replay=null,jo())}function $w(){const t=fe(O.holding);if(!(!t||!Fe())){if(xs(typeof t.born=="number"?t.born:Fe()),O.beat===null)return Ue("Nothing to replay yet: this holding has one beat of history.");O.replay=setInterval(()=>{(O.beat===null||O.beat+1>=Fe())&&wr(),xs(O.beat===null?Fe():O.beat+1)},800),jo()}}Z("beat").addEventListener("input",t=>{wr(),xs(Number(t.target.value))});Z("replay").addEventListener("click",()=>O.replay?wr():$w());for(const t of["to-now","past-now"])Z(t).addEventListener("click",()=>{wr(),xs(Fe())});const ui=["system","light","dark"],Wl=()=>{Z("theme").textContent=`Theme: ${document.documentElement.dataset.theme??"system"}`};Z("theme").addEventListener("click",()=>{const t=ui[(ui.indexOf(document.documentElement.dataset.theme??"system")+1)%ui.length];t==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t;try{t==="system"?localStorage.removeItem("orgchain-theme"):localStorage.setItem("orgchain-theme",t)}catch{}Wl()});function Yl(t,e,n){const r=Z("confirm");r.replaceChildren(T("span",{text:t}),T("button",{type:"button",class:"btn sm danger",text:e,onclick:()=>{r.hidden=!0,n()}}),T("button",{type:"button",class:"btn sm",text:"Cancel",onclick:()=>{r.hidden=!0}})),r.hidden=!1,r.querySelector("button").focus()}const Bw={read:()=>{try{return Lo()}catch{return br()}}};async function Xl(t,e){wr(),await yr(n=>{Object.assign(n,t())},Bw)&&(Object.assign(O,{holding:null,node:null,event:null,beat:null,closing:null}),Ro(),Ue(e))}Z("save").addEventListener("click",()=>{const t=T("a",{href:URL.createObjectURL(new Blob([Nl(me)],{type:"application/json"})),download:`orgchain-lab-${new Date().toISOString().slice(0,10)}.json`});document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(t.href),5e3),Ue("Saved a backup of this lab, test wallet included. Load it in any browser to carry on.")});Z("load").addEventListener("click",()=>Z("load-file").click());Z("load-file").addEventListener("change",async t=>{var r;const e=(r=t.target.files)==null?void 0:r[0];if(t.target.value="",!e)return;let n;try{n=Pl(await e.text())}catch(s){return Ue(`${e.name} is not an Orgchain lab: ${s.message}`,!0)}Yl(`Replace this browser's lab with ${e.name}?`,"Replace",()=>Xl(()=>n,`Loaded ${e.name}.`))});Z("reset").addEventListener("click",()=>Yl("Erase this browser's lab: every holding, the chain and the test wallet?","Erase",()=>Xl(br,"Erased. This is a fresh lab.")));Wl();Ml(); diff --git a/ventures/lineage/orgchain/index.html b/ventures/lineage/orgchain/index.html index 9c4a15c..6270a4e 100644 --- a/ventures/lineage/orgchain/index.html +++ b/ventures/lineage/orgchain/index.html @@ -8,8 +8,8 @@ - - + +
diff --git a/ventures/lineage/orgchain/licenses/scure-base.txt b/ventures/lineage/orgchain/licenses/scure-base.txt new file mode 100644 index 0000000..5b91e4c --- /dev/null +++ b/ventures/lineage/orgchain/licenses/scure-base.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Paul Miller (https://paulmillr.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ventures/lineage/orgchain/licenses/scure-bip32.txt b/ventures/lineage/orgchain/licenses/scure-bip32.txt new file mode 100644 index 0000000..68222b8 --- /dev/null +++ b/ventures/lineage/orgchain/licenses/scure-bip32.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ventures/lineage/orgchain/licenses/scure-bip39.txt b/ventures/lineage/orgchain/licenses/scure-bip39.txt new file mode 100644 index 0000000..68222b8 --- /dev/null +++ b/ventures/lineage/orgchain/licenses/scure-bip39.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.