@omnisat/lasereyes 0.0.97 → 0.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +2641 -2633
  2. package/dist/index.umd.cjs +26 -26
  3. package/package.json +3 -3
@@ -1,19 +1,19 @@
1
- (function(Y,tn){typeof exports=="object"&&typeof module<"u"?tn(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],tn):(Y=typeof globalThis<"u"?globalThis:Y||self,tn(Y.lasereyes={},Y.React))})(this,function(Y,tn){"use strict";"use client";var Yb=Object.defineProperty,Zb=(e,t,r)=>t in e?Yb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t,r)=>Zb(e,typeof t!="symbol"?t+"":t,r);function Qb(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let ll=Symbol("clean"),rn=[],wi=0;const $a=4;let fl=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=wi+$a;o<rn.length;)rn[o]===n?rn.splice(o,$a):o+=$a;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!rn.length;for(let s of t)rn.push(s,r.value,n,i);if(o){for(wi=0;wi<rn.length;wi+=$a)rn[wi](rn[wi+1],rn[wi+2],rn[wi+3]);rn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[ll]=()=>{t=[],r.lc=0,r.off()}),r};const em=5,Ns=6,Ca=10;let tm=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Ca]||(e.events[r+Ca]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Ca](),delete e.events[r+Ca])}),rm=1e3,nm=(e,t)=>tm(e,r=>{let n=t(r);n&&e.events[Ns].push(n)},em,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[Ns]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[Ns])o();e.events[Ns]=[]}},rm)},process.env.NODE_ENV!=="production"){let o=e[ll];e[ll]=()=>{for(let s of e.events[Ns])s();e.events[Ns]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function kn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Cd(e,t,r){let n=kn(e,t,r);return r(e.value),n}let Nd=(e={})=>{let t=fl(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const bi="oyl",Vn="unisat",Pn="xverse",mi="phantom",vi="leather",Wn="magic-eden",ns="okx",is="wizz",Ei="orange",Ud="op_net",Na="p2tr",im="p2pkh",hl="p2wpkh",sm="p2psh",om="p2wsh",am="p2sh",cm={oyl:{name:bi,icon:"data:image/svg+xml,%3Csvg%20width%3D%2296%22%20height%3D%2216%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M17.27.318c2.947%200%205.72.26%208.32.78%202.6.507%204.714%201.307%206.34%202.4%201.64%201.094%202.46%202.467%202.46%204.12%200%201.654-.82%203.047-2.46%204.18-1.64%201.12-3.766%201.954-6.38%202.5-2.6.547-5.36.82-8.28.82-2.946%200-5.72-.253-8.32-.76-2.6-.52-4.72-1.326-6.36-2.42C.964%2010.845.15%209.472.15%207.818c0-1.653.82-3.04%202.46-4.16%201.64-1.133%203.76-1.973%206.36-2.52%202.614-.546%205.38-.82%208.3-.82Zm.04%2011.96c1.4%200%202.8-.146%204.2-.44%201.414-.293%202.6-.78%203.56-1.46.96-.68%201.44-1.566%201.44-2.66%200-1.093-.48-1.98-1.44-2.66-.96-.68-2.146-1.166-3.56-1.46-1.4-.293-2.8-.44-4.2-.44h-.08c-1.4%200-2.806.147-4.22.44-1.4.294-2.58.78-3.54%201.46-.96.68-1.44%201.567-1.44%202.66%200%201.094.48%201.98%201.44%202.66.96.68%202.14%201.167%203.54%201.46%201.414.294%202.82.44%204.22.44h.08ZM61.293.758c.08-.026.14-.04.18-.04h8.24c.12%200%20.214.04.28.12.08.08.12.174.12.28%200%20.147-.066.26-.2.34l-14%207.7c-.133.067-.2.18-.2.34v4.82c0%20.107-.04.2-.12.28a.384.384%200%200%201-.28.12h-6.94c-.106%200-.2-.04-.28-.12a.384.384%200%200%201-.12-.28v-4.82c0-.16-.066-.273-.2-.34l-13.98-7.7a.376.376%200%200%201-.2-.34c0-.106.034-.2.1-.28.067-.08.16-.12.28-.12h8.24c.054%200%20.12.014.2.04l9.24%205.1c.08.027.147.04.2.04.04%200%20.1-.013.18-.04l9.26-5.1Zm11.232.36c0-.106.033-.2.1-.28.08-.08.173-.12.28-.12h6.84c.106%200%20.193.04.26.12.08.08.12.174.12.28v10.32c0%20.107.04.2.12.28.08.08.173.12.28.12h14.46c.106%200%20.193.04.26.12.08.08.12.174.12.28v2.08c0%20.107-.04.2-.12.28a.322.322%200%200%201-.26.12h-22.08c-.107%200-.2-.04-.28-.12a.424.424%200%200%201-.1-.28v-13.2Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E",site:"https://oyl.io/",disabled:!1},unisat:{name:Vn,icon:"/wallet-logos/unisat_logo.png",site:"https://unisat.io/",disabled:!1},xverse:{name:Pn,icon:"/wallet-logos/xverse_logo.png",site:"https://www.xverse.app/",config:()=>{},disabled:!1},leather:{name:vi,icon:"/wallet-logos/leather_logo.png",site:"https://leather.io/",config:()=>{},disabled:!0}},Ua="defaultWallet",nn={messagePrefix:`Bitcoin Signed Message:
1
+ (function(Y,tn){typeof exports=="object"&&typeof module<"u"?tn(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],tn):(Y=typeof globalThis<"u"?globalThis:Y||self,tn(Y.lasereyes={},Y.React))})(this,function(Y,tn){"use strict";"use client";var Yb=Object.defineProperty,Zb=(e,t,r)=>t in e?Yb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t,r)=>Zb(e,typeof t!="symbol"?t+"":t,r);function Qb(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let ll=Symbol("clean"),rn=[],wi=0;const $a=4;let hl=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=wi+$a;o<rn.length;)rn[o]===n?rn.splice(o,$a):o+=$a;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!rn.length;for(let s of t)rn.push(s,r.value,n,i);if(o){for(wi=0;wi<rn.length;wi+=$a)rn[wi](rn[wi+1],rn[wi+2],rn[wi+3]);rn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[ll]=()=>{t=[],r.lc=0,r.off()}),r};const em=5,Ns=6,Ca=10;let tm=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Ca]||(e.events[r+Ca]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Ca](),delete e.events[r+Ca])}),rm=1e3,nm=(e,t)=>tm(e,r=>{let n=t(r);n&&e.events[Ns].push(n)},em,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[Ns]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[Ns])o();e.events[Ns]=[]}},rm)},process.env.NODE_ENV!=="production"){let o=e[ll];e[ll]=()=>{for(let s of e.events[Ns])s();e.events[Ns]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function kn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Cd(e,t,r){let n=kn(e,t,r);return r(e.value),n}let Nd=(e={})=>{let t=hl(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const bi="oyl",Vn="unisat",Pn="xverse",mi="phantom",vi="leather",Wn="magic-eden",ns="okx",is="wizz",Ei="orange",Ud="op_net",Na="p2tr",im="p2pkh",fl="p2wpkh",sm="p2psh",om="p2wsh",am="p2sh",cm={oyl:{name:bi,icon:"data:image/svg+xml,%3Csvg%20width%3D%2296%22%20height%3D%2216%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M17.27.318c2.947%200%205.72.26%208.32.78%202.6.507%204.714%201.307%206.34%202.4%201.64%201.094%202.46%202.467%202.46%204.12%200%201.654-.82%203.047-2.46%204.18-1.64%201.12-3.766%201.954-6.38%202.5-2.6.547-5.36.82-8.28.82-2.946%200-5.72-.253-8.32-.76-2.6-.52-4.72-1.326-6.36-2.42C.964%2010.845.15%209.472.15%207.818c0-1.653.82-3.04%202.46-4.16%201.64-1.133%203.76-1.973%206.36-2.52%202.614-.546%205.38-.82%208.3-.82Zm.04%2011.96c1.4%200%202.8-.146%204.2-.44%201.414-.293%202.6-.78%203.56-1.46.96-.68%201.44-1.566%201.44-2.66%200-1.093-.48-1.98-1.44-2.66-.96-.68-2.146-1.166-3.56-1.46-1.4-.293-2.8-.44-4.2-.44h-.08c-1.4%200-2.806.147-4.22.44-1.4.294-2.58.78-3.54%201.46-.96.68-1.44%201.567-1.44%202.66%200%201.094.48%201.98%201.44%202.66.96.68%202.14%201.167%203.54%201.46%201.414.294%202.82.44%204.22.44h.08ZM61.293.758c.08-.026.14-.04.18-.04h8.24c.12%200%20.214.04.28.12.08.08.12.174.12.28%200%20.147-.066.26-.2.34l-14%207.7c-.133.067-.2.18-.2.34v4.82c0%20.107-.04.2-.12.28a.384.384%200%200%201-.28.12h-6.94c-.106%200-.2-.04-.28-.12a.384.384%200%200%201-.12-.28v-4.82c0-.16-.066-.273-.2-.34l-13.98-7.7a.376.376%200%200%201-.2-.34c0-.106.034-.2.1-.28.067-.08.16-.12.28-.12h8.24c.054%200%20.12.014.2.04l9.24%205.1c.08.027.147.04.2.04.04%200%20.1-.013.18-.04l9.26-5.1Zm11.232.36c0-.106.033-.2.1-.28.08-.08.173-.12.28-.12h6.84c.106%200%20.193.04.26.12.08.08.12.174.12.28v10.32c0%20.107.04.2.12.28.08.08.173.12.28.12h14.46c.106%200%20.193.04.26.12.08.08.12.174.12.28v2.08c0%20.107-.04.2-.12.28a.322.322%200%200%201-.26.12h-22.08c-.107%200-.2-.04-.28-.12a.424.424%200%200%201-.1-.28v-13.2Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E",site:"https://oyl.io/",disabled:!1},unisat:{name:Vn,icon:"/wallet-logos/unisat_logo.png",site:"https://unisat.io/",disabled:!1},xverse:{name:Pn,icon:"/wallet-logos/xverse_logo.png",site:"https://www.xverse.app/",config:()=>{},disabled:!1},leather:{name:vi,icon:"/wallet-logos/leather_logo.png",site:"https://leather.io/",config:()=>{},disabled:!0}},Ua="defaultWallet",nn={messagePrefix:`Bitcoin Signed Message:
2
2
  `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},um={messagePrefix:`Bitcoin Signed Message:
3
- `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function lm(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function fm(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function hm(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const ze={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,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_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,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_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT: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_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,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_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},Rd={};for(const e of Object.keys(ze)){const t=ze[e];Rd[t]=e}const Ra="0123456789abcdefABCDEF",Ba=Ra.split("").map(e=>e.codePointAt(0)),La=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Ra.indexOf(r);return n<0?void 0:n<16?n:n-6}),Bd=new TextEncoder,Ld=new TextDecoder;function dm(e){return Ld.decode(e)}function pm(e){return Bd.encode(e)}function ot(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function ve(e){const t=e||new Uint8Array;return t.length>512?gm(t):ym(t)}function ym(e){let t="";for(let r=0;r<e.length;++r)t+=Ra[La[Ba[e[r]>>4]]],t+=Ra[La[Ba[e[r]&15]]];return t}function gm(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=Ba[e[r]>>4],t[r*2+1]=Ba[e[r]&15];return Ld.decode(t)}function zn(e){const t=Bd.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=La[t[n*2]],o=La[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function wm(e){return btoa(String.fromCharCode(...e))}function Hd(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Q(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Tr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function bm(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function So(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function mm(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function qn(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function vm(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Us(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Kd(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function jd(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function Em(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function Dd(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function Md(e){return e<ze.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function Am(e,t,r){const n=Md(t);return n===1?Tr(e,r,t):n===2?(Tr(e,r,ze.OP_PUSHDATA1),Tr(e,r+1,t)):n===3?(Tr(e,r,ze.OP_PUSHDATA2),bm(e,r+1,t,"LE")):(Tr(e,r,ze.OP_PUSHDATA4),So(e,r+1,t,"LE")),n}function Sm(e,t){const r=qn(e,t);let n,i;if(r<ze.OP_PUSHDATA1)n=r,i=1;else if(r===ze.OP_PUSHDATA1){if(t+2>e.length)return null;n=qn(e,t+1),i=2}else if(r===ze.OP_PUSHDATA2){if(t+3>e.length)return null;n=vm(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==ze.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=Us(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function Tm(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function _m(e){let t=Math.abs(e);const r=Tm(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Tr(n,o,t&255),t>>=8;return n[r-1]&128?Tr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function km(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function s9(e){}function o9(e){}function Pm(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function To(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function Ft(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??To(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},h=e.kind==="schema",f=(i==null?void 0:i.message)??e.message??Pm(e.reference,u.lang)??(h?(u.lang,void 0):null)??n.message??(u.lang,void 0);f&&(u.message=typeof f=="function"?f(u):f),h&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Om(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var Im=class extends Error{constructor(t){super(t[0].message),we(this,"issues"),this.name="ValiError",this.issues=t}};function Fd(e,t){return{kind:"validation",type:"every_item",reference:Fd,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&Ft(this,"item",r,n),r}}}function dl(e){return{kind:"validation",type:"integer",reference:dl,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&Ft(this,"integer",t,r),t}}}function Vd(e,t){return{kind:"validation",type:"length",reference:Vd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&Ft(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ha(e,t){return{kind:"validation",type:"max_value",reference:Ha,async:!1,expects:`<=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():To(r.value)}),r}}}function Ka(e,t){return{kind:"validation",type:"min_value",reference:Ka,async:!1,expects:`>=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():To(r.value)}),r}}}function Wd(e,t){return{kind:"validation",type:"regex",reference:Wd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&Ft(this,"format",r,n),r}}}function pl(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function ja(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function zd(){return{kind:"schema",type:"any",reference:zd,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function ar(e,t){return{kind:"schema",type:"array",reference:ar,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const h={type:"array",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function qd(e){return{kind:"schema",type:"bigint",reference:qd,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:Ft(this,"type",t,r),t}}}function sn(e,t){return{kind:"schema",type:"custom",reference:sn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:Ft(this,"type",r,n),r}}}function Da(e,t){return{kind:"schema",type:"instance",reference:Da,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:Ft(this,"type",r,n),r}}}function yl(e,...t){const r={kind:"schema",type:"nullable",reference:yl,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=pl(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Gd(e,...t){const r={kind:"schema",type:"nullish",reference:Gd,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=pl(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function cr(e){return{kind:"schema",type:"number",reference:cr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Ft(this,"type",t,r),t}}}function Ot(e,t){return{kind:"schema",type:"object",reference:Ot,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"object",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else Ft(this,"type",r,n);return r}}}function Ma(e,...t){const r={kind:"schema",type:"optional",reference:Ma,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=pl(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function ss(e){return{kind:"schema",type:"string",reference:ss,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:Ft(this,"type",t,r),t}}}function On(e,t){return{kind:"schema",type:"tuple",reference:On,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"array",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function Xd(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function gl(e,t){return{kind:"schema",type:"union",reference:gl,expects:Om(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];Ft(this,"type",r,n,{issues:Xd(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];Ft(this,"type",r,n,{issues:Xd(s)})}return r}}}function at(e,t,r){const n=e._run({typed:!1,value:t},km(r));if(n.issues)throw new Im(n.issues);return n.value}function Ai(e,t){const r={};for(const n in e.entries)r[n]=Ma(e.entries[n]);return{...e,entries:r}}function Rs(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const Jd=new Uint8Array(32),Yd=zn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$t=e=>Rs(Da(Uint8Array),Vd(e));function _o(e,t){return e.length!==t.length?!1:e.every((r,n)=>Q(r,t[n])===0)}function on(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(Q(Jd,r)===0||Q(r,Yd)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return Q(Jd,n)===0||Q(n,Yd)>=0?!1:t===4&&e.length===65}const Fa=254;function wl(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&Fa)===e.version:!0}function Zd(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>Zd(t)):wl(e)}const xm=$t(32),$m=$t(20),Qd=$t(32),De=Da(Uint8Array);Rs(ss(),Wd(/^([0-9a-f]{2})+$/i));const Cm=Rs(cr(),dl(),Ka(0),Ha(255)),Gn=Rs(cr(),dl(),Ka(0),Ha(4294967295)),bl=Rs(qd(),Ka(0n),Ha(0x7fffffffffffffffn)),ep=e=>Ot(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Gd(r[1])}),{})),tp=new Uint8Array(1);function rp(e){let t=0;for(;e[t]===0;)++t;return t===e.length?tp:(e=e.slice(t),e[0]&128?ot([tp,e]):e)}function np(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Nm(e){const t=qn(e,e.length-1);if(!vl(t))throw new Error("Invalid hashType "+t);const r=fm(e.subarray(0,-1)),n=np(r.r),i=np(r.s);return{signature:ot([n,i]),hashType:t}}function Um(e,t){if(at(Ot({signature:$t(64),hashType:Cm}),{signature:e,hashType:t}),!vl(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Tr(r,0,t);const n=rp(e.slice(0,32)),i=rp(e.slice(32,64));return ot([hm(n,i),r])}const Rm=Object.freeze(Object.defineProperty({__proto__:null,decode:Nm,encode:Um},Symbol.toStringTag,{value:"Module"})),ip=ze.OP_RESERVED,sp=ar(gl([Da(Uint8Array),cr()]));function Bm(e){return ja(cr(),e)&&(e===ze.OP_0||e>=ze.OP_1&&e<=ze.OP_16||e===ze.OP_1NEGATE)}function op(e){return ja(De,e)||Bm(e)}function ml(e){return ja(Rs(zd(),Fd(op)),e)}function ap(e){return e.length-e.filter(op).length}function Va(e){if(e.length===0)return ze.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return ip+e[0];if(e[0]===129)return ze.OP_1NEGATE}}function cp(e){return e instanceof Uint8Array}function Lm(e){return ja(sp,e)}function Wa(e){return e instanceof Uint8Array}function ur(e){if(cp(e))return e;at(sp,e);const t=e.reduce((i,o)=>Wa(o)?o.length===1&&Va(o)!==void 0?i+1:i+Md(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(Wa(i)){const o=Va(i);if(o!==void 0){Tr(r,n,o),n+=1;return}n+=Am(r,i.length,n),r.set(i,n),n+=i.length}else Tr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function gt(e){if(Lm(e))return e;at(De,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>ze.OP_0&&n<=ze.OP_PUSHDATA4){const i=Sm(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=Va(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function Hm(e){if(cp(e)&&(e=gt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(Wa(t)){const r=Va(t);if(r===void 0)return ve(t);t=r}return Rd[t]}).join(" ")}function Km(e){return e=gt(e),at(sn(ml),e),e.map(t=>Wa(t)?t:t===ze.OP_0?new Uint8Array(0):_m(t-ip))}function jm(e){return on(e)}function vl(e){const t=e&-129;return t>0&&t<4}function Xn(e){return!(e instanceof Uint8Array)||!vl(e[e.length-1])?!1:lm(e.slice(0,-1))}const ko=Rm;function de(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Ur(e){let t;return()=>(t!==void 0||(t=e()),t)}const Bs=ze,za=Bs.OP_RESERVED;function qa(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return Xn(a)||(t.allowIncomplete&&a===Bs.OP_0)!==void 0}at(Ai(Ot({network:Ot({}),m:cr(),n:cr(),output:De,pubkeys:ar(sn(on),"Received invalid pubkey"),signatures:ar(sn(r),"Expected signature to be of type isAcceptableSignature"),input:De})),e);const n={network:e.network||nn};let i=[],o=!1;function s(a){o||(o=!0,i=gt(a),n.m=i[0]-za,n.n=i[i.length-2]-za,n.pubkeys=i.slice(1,-2))}if(de(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return ur([].concat(za+e.m,e.pubkeys,za+n.n,Bs.OP_CHECKMULTISIG))}),de(n,"m",()=>{if(n.output)return s(n.output),n.m}),de(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),de(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),de(n,"signatures",()=>{if(e.input)return gt(e.input).slice(1)}),de(n,"input",()=>{if(e.signatures)return ur([Bs.OP_0].concat(e.signatures))}),de(n,"witness",()=>{if(n.input)return[]}),de(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),at(cr(),i[0],{message:"Output is invalid"}),at(cr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==Bs.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>on(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!_o(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==Bs.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!_o(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const up=ze;function lp(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(Ot({network:Ot({}),output:De,pubkey:sn(on,"invalid pubkey"),signature:sn(Xn,"Expected signature to be of type isCanonicalScriptSignature"),input:De})),e);const r=Ur(()=>gt(e.input)),n={name:"p2pk",network:e.network||nn};if(de(n,"output",()=>{if(e.pubkey)return ur([e.pubkey,up.OP_CHECKSIG])}),de(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),de(n,"signature",()=>{if(e.input)return r()[0]}),de(n,"input",()=>{if(e.signature)return ur([e.signature])}),de(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==up.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!on(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&Q(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&Q(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!Xn(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function Dm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function fp(e,...t){if(!Dm(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function hp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mm(e,t){fp(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const El=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),In=(e,t)=>e<<32-t|e>>>t,Ga=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Fm(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function dp(e){return typeof e=="string"&&(e=Fm(e)),fp(e),e}let Vm=class{clone(){return this._cloneInto()}};function pp(e){const t=n=>e().update(dp(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Wm(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,h=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+h,a,n)}const zm=(e,t,r)=>e&t^~e&r,qm=(e,t,r)=>e&t^e&r^t&r;let yp=class extends Vm{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=El(this.buffer)}update(t){hp(this);const{view:r,buffer:n,blockLen:i}=this;t=dp(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=El(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){hp(this),Mm(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;Wm(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=El(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=u/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<h;d++)a.setUint32(4*d,f[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};const Gm=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),gp=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Xm=gp.map(e=>(9*e+5)%16);let Al=[gp],Sl=[Xm];for(let e=0;e<4;e++)for(let t of[Al,Sl])t.push(t[e].map(r=>Gm[r]));const wp=[[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(e=>new Uint8Array(e)),Jm=Al.map((e,t)=>e.map(r=>wp[t][r])),Ym=Sl.map((e,t)=>e.map(r=>wp[t][r])),Zm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Qm=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function bp(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const Xa=new Uint32Array(16);let ev=class extends yp{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)Xa[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,h=this.h3|0,f=h,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=Zm[v],x=Qm[v],N=Al[v],I=Sl[v],k=Jm[v],B=Ym[v];for(let z=0;z<16;z++){const V=Ga(n+bp(v,o,a,h)+Xa[N[z]]+T,k[z])+d|0;n=d,d=h,h=Ga(a,10)|0,a=o,o=V}for(let z=0;z<16;z++){const V=Ga(i+bp(E,s,u,f)+Xa[I[z]]+x,B[z])+g|0;i=g,g=f,f=Ga(u,10)|0,u=s,s=V}}this.set(this.h1+a+f|0,this.h2+h+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){Xa.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const tv=pp(()=>new ev),rv=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]),Si=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ti=new Uint32Array(64);let nv=class extends yp{constructor(){super(64,32,8,!1),this.A=Si[0]|0,this.B=Si[1]|0,this.C=Si[2]|0,this.D=Si[3]|0,this.E=Si[4]|0,this.F=Si[5]|0,this.G=Si[6]|0,this.H=Si[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ti[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ti[d-15],v=Ti[d-2],E=In(g,7)^In(g,18)^g>>>3,T=In(v,17)^In(v,19)^v>>>10;Ti[d]=T+Ti[d-7]+E+Ti[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:h,H:f}=this;for(let d=0;d<64;d++){const g=In(a,6)^In(a,11)^In(a,25),v=f+g+zm(a,u,h)+rv[d]+Ti[d]|0,E=(In(n,2)^In(n,13)^In(n,22))+qm(n,i,o)|0;f=h,h=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,h,f)}roundClean(){Ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Xt=pp(()=>new nv);function Jn(e){return tv(Xt(e))}function os(e){return Xt(Xt(e))}const iv={"BIP0340/challenge":Uint8Array.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":Uint8Array.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":Uint8Array.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:Uint8Array.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:Uint8Array.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:Uint8Array.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:Uint8Array.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":Uint8Array.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":Uint8Array.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function Ja(e,t){return Xt(ot([iv[e],t]))}function sv(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let h=0;h<t.length;h++)t[h]=255;for(let h=0;h<e.length;h++){const f=e.charAt(h),d=f.charCodeAt(0);if(t[d]!==255)throw new TypeError(f+" is ambiguous");t[d]=h}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";let f=0,d=0,g=0;const v=h.length;for(;g!==v&&h[g]===0;)g++,f++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let I=h[g],k=0;for(let B=E-1;(I!==0||k<d)&&B!==-1;B--,k++)I+=256*T[B]>>>0,T[B]=I%r>>>0,I=I/r>>>0;if(I!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(f);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;let f=0,d=0,g=0;for(;h[f]===n;)d++,f++;const v=(h.length-f)*i+1>>>0,E=new Uint8Array(v);for(;h[f];){let I=t[h.charCodeAt(f)];if(I===255)return;let k=0;for(let B=v-1;(I!==0||k<g)&&B!==-1;B--,k++)I+=r*E[B]>>>0,E[B]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=k,f++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(h){const f=a(h);if(f)return f;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var ov="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Tl=sv(ov);function av(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,h=new Uint8Array(u);return h.set(s,0),h.set(a.subarray(0,4),s.length),Tl.encode(h)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=Tl.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=Tl.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function cv(e){return Xt(Xt(e))}const Po=av(cv),_i=ze;function Oo(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(Ot({network:Ot({}),address:ss(),hash:$m,output:$t(25),pubkey:sn(on),signature:sn(Xn),input:De})),e);const r=Ur(()=>{const s=Po.decode(e.address),a=qn(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Ur(()=>gt(e.input)),i=e.network||nn,o={name:"p2pkh",network:i};if(de(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Tr(s,0,i.pubKeyHash),s.set(o.hash,1),Po.encode(s)}),de(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return Jn(e.pubkey||o.pubkey)}),de(o,"output",()=>{if(o.hash)return ur([_i.OP_DUP,_i.OP_HASH160,o.hash,_i.OP_EQUALVERIFY,_i.OP_CHECKSIG])}),de(o,"pubkey",()=>{if(e.input)return n()[1]}),de(o,"signature",()=>{if(e.input)return n()[0]}),de(o,"input",()=>{if(e.pubkey&&e.signature)return ur([e.signature,e.pubkey])}),de(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==_i.OP_DUP||e.output[1]!==_i.OP_HASH160||e.output[2]!==20||e.output[23]!==_i.OP_EQUALVERIFY||e.output[24]!==_i.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=Jn(e.pubkey);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!Xn(a[0]))throw new TypeError("Input has invalid signature");if(!on(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&Q(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=Jn(a[1]);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const Io=ze;function Ls(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(Ot({network:Ot({}),address:ss(),hash:$t(20),output:$t(23),redeem:Ai(Ot({network:Ot({}),output:De,input:De,witness:ar(De)})),input:De,witness:ar(De)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||nn);const n={network:r},i=Ur(()=>{const a=Po.decode(e.address),u=qn(a,0),h=a.slice(1);return{version:u,hash:h}}),o=Ur(()=>gt(e.input)),s=Ur(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===Io.OP_FALSE?Uint8Array.from([]):u,input:ur(a.slice(0,-1)),witness:e.witness||[]}});if(de(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Tr(a,0,n.network.scriptHash),a.set(n.hash,1),Po.encode(a)}),de(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return Jn(n.redeem.output)}),de(n,"output",()=>{if(n.hash)return ur([Io.OP_HASH160,n.hash,Io.OP_EQUAL])}),de(n,"redeem",()=>{if(e.input)return s()}),de(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return ur([].concat(gt(e.redeem.input),e.redeem.output))}),de(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),de(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&Q(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==Io.OP_HASH160||e.output[1]!==20||e.output[22]!==Io.OP_EQUAL)throw new TypeError("Output is invalid");const h=e.output.slice(2,22);if(a.length>0&&Q(a,h)!==0)throw new TypeError("Hash mismatch");a=h}const u=h=>{if(h.output){const f=gt(h.output);if(!f||f.length<1)throw new TypeError("Redeem.output too short");if(h.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(ap(f)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=Jn(h.output);if(a.length>0&&Q(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(h.input){const f=h.input.length>0,d=h.witness&&h.witness.length>0;if(!f&&!d)throw new TypeError("Empty input");if(f&&d)throw new TypeError("Input and witness provided");if(f){const g=gt(h.input);if(!ml(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const h=o();if(!h||h.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const h=s();if(e.redeem.output&&Q(e.redeem.output,h.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&Q(e.redeem.input,h.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!_o(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function lv(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var xo={};Object.defineProperty(xo,"__esModule",{value:!0});var $o=xo.bech32m=_r=xo.bech32=void 0;const Ya="qpzry9x8gf2tvdw0s3jn54khce6mua7l",mp={};for(let e=0;e<Ya.length;e++){const t=Ya.charAt(e);mp[t]=e}function Hs(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function vp(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=Hs(t)^n>>5}t=Hs(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=Hs(t)^n&31}return t}function _l(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function fv(e){return _l(e,8,5,!0)}function hv(e){const t=_l(e,5,8,!1);if(Array.isArray(t))return t}function dv(e){const t=_l(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Ep(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let h=vp(s);if(typeof h=="string")throw new Error(h);let f=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");h=Hs(h)^g,f+=Ya.charAt(g)}for(let d=0;d<6;++d)h=Hs(h);h^=t;for(let d=0;d<6;++d){const g=h>>(5-d)*5&31;f+=Ya.charAt(g)}return f}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),h=s.toUpperCase();if(s!==u&&s!==h)return"Mixed-case string "+s;s=u;const f=s.lastIndexOf("1");if(f===-1)return"No separator character for "+s;if(f===0)return"Missing prefix for "+s;const d=s.slice(0,f),g=s.slice(f+1);if(g.length<6)return"Data too short";let v=vp(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=mp[x];if(N===void 0)return"Unknown character "+x;v=Hs(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:fv,fromWordsUnsafe:hv,fromWords:dv}}var _r=xo.bech32=Ep("bech32");$o=xo.bech32m=Ep("bech32m");const Ap=ze,pv=new Uint8Array(0);function Co(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(Ot({address:ss(),hash:$t(20),input:$t(0),network:Ot({}),output:$t(22),pubkey:sn(on,"Not a valid pubkey"),signature:sn(Xn),witness:ar(De)})),e);const r=Ur(()=>{const o=_r.decode(e.address),s=o.words.shift(),a=_r.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||nn,i={name:"p2wpkh",network:n};if(de(i,"address",()=>{if(!i.hash)return;const o=_r.toWords(i.hash);return o.unshift(0),_r.encode(n.bech32,o)}),de(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return Jn(e.pubkey||i.pubkey)}),de(i,"output",()=>{if(i.hash)return ur([Ap.OP_0,i.hash])}),de(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),de(i,"signature",()=>{if(e.witness)return e.witness[0]}),de(i,"input",()=>{if(i.witness)return pv}),de(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&Q(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==Ap.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&Q(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=Jn(e.pubkey);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!on(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!Xn(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!on(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&Q(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=Jn(e.witness[1]);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const Sp=ze,kl=new Uint8Array(0);function Za(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&on(e))}function No(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(ep({network:Ot({}),address:ss(),hash:xm,output:$t(34),redeem:ep({input:De,network:Ot({}),output:De,witness:ar(De)}),input:$t(0),witness:ar(De)}),e);const r=Ur(()=>{const s=_r.decode(e.address),a=s.words.shift(),u=_r.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Ur(()=>gt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||nn);const o={network:i};if(de(o,"address",()=>{if(!o.hash)return;const s=_r.toWords(o.hash);return s.unshift(0),_r.encode(i.bech32,s)}),de(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return Xt(o.redeem.output)}),de(o,"output",()=>{if(o.hash)return ur([Sp.OP_0,o.hash])}),de(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:kl,witness:e.witness.slice(0,-1)}}),de(o,"input",()=>{if(o.witness)return kl}),de(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=Km(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=kl,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),de(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==Sp.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=gt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(ap(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=Xt(e.redeem.output);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!ml(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!_o(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(Za)||e.redeem.output&&(gt(e.redeem.output)||[]).some(Za))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&Q(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(Za)||(gt(a)||[]).some(Za))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const Uo={};function yv(e){e?e!==Uo.eccLib&&(gv(e),Uo.eccLib=e):Uo.eccLib=e}function Pl(){if(!Uo.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return Uo.eccLib}const Yn=e=>zn(e);function gv(e){Rr(typeof e.isXOnlyPoint=="function"),Rr(e.isXOnlyPoint(Yn("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Rr(e.isXOnlyPoint(Yn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Rr(e.isXOnlyPoint(Yn("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Rr(e.isXOnlyPoint(Yn("0000000000000000000000000000000000000000000000000000000000000001"))),Rr(!e.isXOnlyPoint(Yn("0000000000000000000000000000000000000000000000000000000000000000"))),Rr(!e.isXOnlyPoint(Yn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Rr(typeof e.xOnlyPointAddTweak=="function"),wv.forEach(t=>{const r=e.xOnlyPointAddTweak(Yn(t.pubkey),Yn(t.tweak));t.result===null?Rr(r===null):(Rr(r!==null),Rr(r.parity===t.parity),Rr(Q(r.xOnlyPubkey,Yn(t.result))===0))})}function Rr(e){if(!e)throw new Error("ecc library invalid")}const wv=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],Tp="0123456789abcdefABCDEF";Tp.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Tp.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function bv(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function mv(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function vv(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function Ev(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Av(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Sv(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const Tv=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function _v(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function _p(e){typeof e=="number"?_v(e):Tv(e)}function ki(e,t,r){_p(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Br(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),bv(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),mv(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),vv(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function Ks(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=Ev(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=Av(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=Sv(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Br(e){return _p(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const kv=9007199254740991;function Pv(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function Ol(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e}function kp(e){const t=new Uint8Array(e.length);return t.set(e),t}class Vt{constructor(t,r=0){we(this,"buffer"),we(this,"offset"),this.buffer=t,this.offset=r,at(On([De,Gn]),[t,r])}static withCapacity(t){return new Vt(new Uint8Array(t))}writeUInt8(t){this.offset=Tr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Kd(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=jd(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=So(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=mm(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=ki(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}let Ov=class{constructor(t,r=0){we(this,"buffer"),we(this,"offset"),this.buffer=t,this.offset=r,at(On([De,Gn]),[t,r])}readUInt8(){const t=qn(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=Em(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=Us(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=Dd(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=Ks(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){Pv(t,kv);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}};const Pp=192,Iv=128,xv=e=>"left"in e&&"right"in e;function Il(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);Q(n,o)<0?n=$l(n,o):n=$l(o,n)}return n}function xl(e){if(wl(e))return{hash:Zn(e)};const t=[xl(e[0]),xl(e[1])];t.sort((i,o)=>Q(i.hash,o.hash));const[r,n]=t;return{hash:$l(r.hash,n.hash),left:r,right:n}}function Qa(e,t){if(xv(e)){const r=Qa(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=Qa(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(Q(e.hash,t)===0)return[]}function Zn(e){const t=e.version||Pp;return Ja("TapLeaf",ot([Uint8Array.from([t]),Cv(e.output)]))}function $v(e,t){return Ja("TapTweak",ot(t?[e,t]:[e]))}function ec(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=$v(e,t),n=Pl().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function $l(e,t){return Ja("TapBranch",ot([e,t]))}function Cv(e){const t=Br(e.length),r=new Uint8Array(t);return ki(e.length,r),ot([r,e])}const Op=ze,Ip=1,Nv=80;function Ro(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(Ot({address:ss(),input:$t(0),network:Ot({}),output:$t(34),internalPubkey:$t(32),hash:$t(32),pubkey:$t(32),signature:gl([$t(64),$t(65)]),witness:ar(De),scriptTree:sn(Zd,"Taptree is not of type isTaptree"),redeem:Ai(Ot({output:De,redeemVersion:cr(),witness:ar(De)})),redeemVersion:cr()})),e);const r=Ur(()=>Bp(e.address)),n=Ur(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===Nv?e.witness.slice(0,-1):e.witness.slice()}),i=Ur(()=>{if(e.scriptTree)return xl(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||nn,s={name:"p2tr",network:o};if(de(s,"address",()=>{if(!s.pubkey)return;const a=$o.toWords(s.pubkey);return a.unshift(Ip),$o.encode(o.bech32,a)}),de(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const h=u[u.length-1],f=h[0]&Fa,d=u[u.length-2],g=Zn({output:d,version:f});return Il(h,g)}return null}),de(s,"output",()=>{if(s.pubkey)return ur([Op.OP_1,s.pubkey])}),de(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:Pp),de(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&Fa}}),de(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=ec(s.internalPubkey,s.hash);if(a)return a.x}}),de(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),de(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),de(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=Zn({output:e.redeem.output,version:s.redeemVersion}),h=Qa(a,u);if(!h)return;const f=ec(e.internalPubkey,a.hash);if(!f)return;const d=ot([Uint8Array.from([s.redeemVersion|f.parity]),e.internalPubkey].concat(h));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==Ip)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&Q(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==Op.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&Q(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const f=ec(e.internalPubkey,s.hash);if(a.length>0&&Q(a,f.x)!==0)throw new TypeError("Pubkey mismatch");a=f.x}if(a&&a.length&&!Pl().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&Q(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const f=Zn({output:e.redeem.output,version:s.redeemVersion});if(!Qa(u,f))throw new TypeError("Redeem script not in tree")}const h=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(gt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&Q(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!_o(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(h&&h.length)if(h.length===1){if(e.signature&&Q(e.signature,h[0])!==0)throw new TypeError("Signature mismatch")}else{const f=h[h.length-1];if(f.length<33)throw new TypeError(`The control-block length is too small. Got ${f.length}, expected min 33.`);if((f.length-33)%32!==0)throw new TypeError(`The control-block length of ${f.length} is incorrect!`);const d=(f.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=f.slice(1,33);if(e.internalPubkey&&Q(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!Pl().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=f[0]&Fa,E=h[h.length-2],T=Zn({output:E,version:v}),x=Il(f,T),N=ec(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&Q(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(f[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const xp=40,$p=2,Cp=16,Np=2,Up=80,Rp="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function Uv(e,t){const r=e.slice(2);if(r.length<$p||r.length>xp)throw new TypeError("Invalid program length for segwit address");const n=e[0]-Up;if(n<Np||n>Cp)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(Rp),Bv(r,n,t.bech32)}function Rv(e){const t=Po.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=qn(t,0),n=t.slice(1);return{version:r,hash:n}}function Bp(e){let t,r;try{t=_r.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=$o.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=_r.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function Bv(e,t,r){const n=_r.toWords(e);return n.unshift(t),t===0?_r.encode(r,n):$o.encode(r,n)}function Bo(e,t){t=t||nn;try{return Oo({output:e,network:t}).address}catch{}try{return Ls({output:e,network:t}).address}catch{}try{return Co({output:e,network:t}).address}catch{}try{return No({output:e,network:t}).address}catch{}try{return Ro({output:e,network:t}).address}catch{}try{return Uv(e,t)}catch{}throw new Error(Hm(e)+" has no matching Address")}function Lp(e,t){t=t||nn;let r,n;try{r=Rv(e)}catch{}if(r){if(r.version===t.pubKeyHash)return Oo({hash:r.hash}).output;if(r.version===t.scriptHash)return Ls({hash:r.hash}).output}else{try{n=Bp(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return Co({hash:n.data}).output;if(n.data.length===32)return No({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return Ro({pubkey:n.data}).output}else if(n.version>=Np&&n.version<=Cp&&n.data.length>=$p&&n.data.length<=xp)return console.warn(Rp),ur([n.version+Up,n.data])}}throw new Error(e+" has no matching Script")}function xn(e){const t=e.length;return Br(t)+t}function Lv(e){const t=e.length;return Br(t)+e.reduce((r,n)=>r+xn(n),0)}const Pi=new Uint8Array(0),Hp=[],Cl=zn("0000000000000000000000000000000000000000000000000000000000000000"),Kp=zn("0000000000000000000000000000000000000000000000000000000000000001"),Hv=zn("ffffffffffffffff"),Kv={script:Pi,valueBuffer:Hv};function jv(e){return e.value!==void 0}const an=class Qe{constructor(){we(this,"version",1),we(this,"locktime",0),we(this,"ins",[]),we(this,"outs",[])}static fromBuffer(t,r){const n=new Ov(t),i=new Qe;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===Qe.ADVANCED_TRANSACTION_MARKER&&s===Qe.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let f=0;f<u;++f)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:Hp});const h=n.readVarInt();for(let f=0;f<h;++f)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let f=0;f<u;++f)i.ins[f].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==t.length)throw new Error("Transaction has unexpected data");return i}static fromHex(t){return Qe.fromBuffer(zn(t),!1)}static isCoinbaseHash(t){at(Qd,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&Qe.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return at(On([Qd,Gn,yl(Ma(Gn)),yl(Ma(De))]),[t,r,n,i]),n==null&&(n=Qe.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||Pi,sequence:n,witness:Hp})-1}addOutput(t,r){return at(On([De,bl]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Br(this.ins.length)+Br(this.outs.length)+this.ins.reduce((n,i)=>n+40+xn(i.script),0)+this.outs.reduce((n,i)=>n+8+xn(i.script),0)+(r?this.ins.reduce((n,i)=>n+Lv(i.witness),0):0)}clone(){const t=new Qe;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(at(On([Gn,De,cr()]),[t,r,n]),t>=this.ins.length)return Kp;const i=ur(gt(r).filter(a=>a!==ze.OP_CODESEPARATOR)),o=this.clone();if((n&31)===Qe.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===Qe.SIGHASH_SINGLE){if(t>=this.outs.length)return Kp;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=Kv;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&Qe.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=Pi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Kd(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),os(s)}hashForWitnessV1(t,r,n,i,o,s){if(at(On([Gn,ar(De),ar(bl),Gn]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===Qe.SIGHASH_DEFAULT?Qe.SIGHASH_ALL:i&Qe.SIGHASH_OUTPUT_MASK,u=(i&Qe.SIGHASH_INPUT_MASK)===Qe.SIGHASH_ANYONECANPAY,h=a===Qe.SIGHASH_NONE,f=a===Qe.SIGHASH_SINGLE;let d=Pi,g=Pi,v=Pi,E=Pi,T=Pi;if(!u){let k=Vt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=Xt(k.end()),k=Vt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=Xt(k.end()),k=Vt.withCapacity(r.map(xn).reduce((B,z)=>B+z)),r.forEach(B=>k.writeVarSlice(B)),v=Xt(k.end()),k=Vt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=Xt(k.end())}if(h||f){if(f&&t<this.outs.length){const k=this.outs[t],B=Vt.withCapacity(8+xn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=Xt(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(z=>8+xn(z.script)).reduce((z,V)=>z+V),B=Vt.withCapacity(k);this.outs.forEach(z=>{B.writeInt64(z.value),B.writeVarSlice(z.script)}),T=Xt(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(h?32:0)+(s?32:0)+(o?37:0),I=Vt.withCapacity(N);if(I.writeUInt8(i),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(d),I.writeSlice(g),I.writeSlice(v),I.writeSlice(E),h||f||I.writeSlice(T),I.writeUInt8(x),u){const k=this.ins[t];I.writeSlice(k.hash),I.writeUInt32(k.index),I.writeInt64(n[t]),I.writeVarSlice(r[t]),I.writeUInt32(k.sequence)}else I.writeUInt32(t);if(s){const k=Vt.withCapacity(xn(s));k.writeVarSlice(s),I.writeSlice(Xt(k.end()))}return f&&I.writeSlice(T),o&&(I.writeSlice(o),I.writeUInt8(0),I.writeUInt32(4294967295)),Ja("TapSighash",ot([Uint8Array.from([0]),I.end()]))}hashForWitnessV0(t,r,n,i){at(On([Gn,De,bl,Gn]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=Cl,u=Cl,h=Cl;if(i&Qe.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new Vt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=os(o)),!(i&Qe.SIGHASH_ANYONECANPAY)&&(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new Vt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),h=os(o)),(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+xn(v.script),0);o=new Uint8Array(d),s=new Vt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=os(o)}else if((i&31)===Qe.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+xn(d.script)),s=new Vt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=os(o)}o=new Uint8Array(156+xn(r)),s=new Vt(o,0);const f=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(h),s.writeSlice(f.hash),s.writeUInt32(f.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(f.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),os(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):os(this.__toBuffer(void 0,void 0,t))}getId(){return ve(Ol(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return ve(this.toBuffer(void 0,void 0))}setInputScript(t,r){at(On([cr(),De]),[t,r]),this.ins[t].script=r}setWitness(t,r){at(On([cr(),ar(De)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new Vt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(Qe.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(Qe.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{jv(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};we(an,"DEFAULT_SEQUENCE",4294967295),we(an,"SIGHASH_DEFAULT",0),we(an,"SIGHASH_ALL",1),we(an,"SIGHASH_NONE",2),we(an,"SIGHASH_SINGLE",3),we(an,"SIGHASH_ANYONECANPAY",128),we(an,"SIGHASH_OUTPUT_MASK",3),we(an,"SIGHASH_INPUT_MASK",128),we(an,"ADVANCED_TRANSACTION_MARKER",0),we(an,"ADVANCED_TRANSACTION_FLAG",1);let At=an;var $n;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})($n||($n={}));var ie;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(ie||(ie={}));var St;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(St||(St={}));const Dv=e=>[...Array(e).keys()];function Mv(e){if(e.key[0]!==$n.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+ve(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+ve(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of Dv(e.value.length/4-1)){const i=Us(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function Fv(e){const t=new Uint8Array([$n.GLOBAL_XPUB]),r=ot([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),So(i,o,u,"LE"),o+=4}),{key:r,value:i}}const Vv="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function Wv(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function zv(e,t,r){const n=ve(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.extendedPubkey,t.extendedPubkey)).length===0)}const qv=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:zv,check:Wv,decode:Mv,encode:Fv,expected:Vv},Symbol.toStringTag,{value:"Module"}));function Gv(e){return{key:new Uint8Array([$n.UNSIGNED_TX]),value:e.toBuffer()}}const Xv=Object.freeze(Object.defineProperty({__proto__:null,encode:Gv},Symbol.toStringTag,{value:"Module"}));function Jv(e){if(e.key[0]!==ie.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+ve(e.key));return e.value}function Yv(e){return{key:new Uint8Array([ie.FINAL_SCRIPTSIG]),value:e}}const Zv="Uint8Array";function Qv(e){return e instanceof Uint8Array}function eE(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const tE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:eE,check:Qv,decode:Jv,encode:Yv,expected:Zv},Symbol.toStringTag,{value:"Module"}));function rE(e){if(e.key[0]!==ie.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+ve(e.key));return e.value}function nE(e){return{key:new Uint8Array([ie.FINAL_SCRIPTWITNESS]),value:e}}const iE="Uint8Array";function sE(e){return e instanceof Uint8Array}function oE(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const aE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:oE,check:sE,decode:rE,encode:nE,expected:iE},Symbol.toStringTag,{value:"Module"}));function cE(e){if(e.key[0]!==ie.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+ve(e.key));return e.value}function uE(e){return{key:new Uint8Array([ie.NON_WITNESS_UTXO]),value:e}}const lE="Uint8Array";function fE(e){return e instanceof Uint8Array}function hE(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const dE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:hE,check:fE,decode:cE,encode:uE,expected:lE},Symbol.toStringTag,{value:"Module"}));function pE(e){if(e.key[0]!==ie.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+ve(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+ve(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function yE(e){const t=new Uint8Array([ie.PARTIAL_SIG]);return{key:ot([t,e.pubkey]),value:e.signature}}const gE="{ pubkey: Uint8Array; signature: Uint8Array; }";function wE(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&bE(e.signature)}function bE(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function mE(e,t,r){const n=ve(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0).length===0)}const vE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:mE,check:wE,decode:pE,encode:yE,expected:gE},Symbol.toStringTag,{value:"Module"}));function EE(e){if(e.key[0]!==ie.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+ve(e.key));return dm(e.value)}function AE(e){return{key:new Uint8Array([ie.POR_COMMITMENT]),value:pm(e)}}const SE="string";function TE(e){return typeof e=="string"}function _E(e,t){return!!e&&!!t&&e.porCommitment===void 0}const kE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:_E,check:TE,decode:EE,encode:AE,expected:SE},Symbol.toStringTag,{value:"Module"}));function PE(e){if(e.key[0]!==ie.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+ve(e.key));return Number(Us(e.value,0,"LE"))}function OE(e){const t=Uint8Array.from([ie.SIGHASH_TYPE]),r=new Uint8Array(4);return So(r,0,e,"LE"),{key:t,value:r}}const IE="number";function xE(e){return typeof e=="number"}function $E(e,t){return!!e&&!!t&&e.sighashType===void 0}const CE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$E,check:xE,decode:PE,encode:OE,expected:IE},Symbol.toStringTag,{value:"Module"}));function NE(e){if(e.key[0]!==ie.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+ve(e.key));if(!jp(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function UE(e){return{key:Uint8Array.from([ie.TAP_KEY_SIG]),value:e}}const RE="Uint8Array";function jp(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function BE(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const LE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:BE,check:jp,decode:NE,encode:UE,expected:RE},Symbol.toStringTag,{value:"Module"}));function HE(e){if(e.key[0]!==ie.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+ve(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+ve(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+ve(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function KE(e){const t=Uint8Array.from([ie.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:ot([t,e.controlBlock]),value:ot([e.script,r])}}const jE="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function DE(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ME(e,t,r){const n=ve(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.controlBlock,t.controlBlock)===0).length===0)}const FE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ME,check:DE,decode:HE,encode:KE,expected:jE},Symbol.toStringTag,{value:"Module"}));function VE(e){if(e.key[0]!==ie.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+ve(e.key));if(!Dp(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function WE(e){return{key:Uint8Array.from([ie.TAP_MERKLE_ROOT]),value:e}}const zE="Uint8Array";function Dp(e){return e instanceof Uint8Array&&e.length===32}function qE(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const GE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:qE,check:Dp,decode:VE,encode:WE,expected:zE},Symbol.toStringTag,{value:"Module"}));function XE(e){if(e.key[0]!==ie.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+ve(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+ve(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+ve(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function JE(e){const t=Uint8Array.from([ie.TAP_SCRIPT_SIG]);return{key:ot([t,e.pubkey,e.leafHash]),value:e.signature}}const YE="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function ZE(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function QE(e,t,r){const n=ve(t.pubkey)+ve(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0&&Q(i.leafHash,t.leafHash)===0).length===0)}const eA=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:QE,check:ZE,decode:XE,encode:JE,expected:YE},Symbol.toStringTag,{value:"Module"}));function tA(e){if(e.key[0]!==ie.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+ve(e.key));const t=Dd(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=Ks(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function rA(e){const{script:t,value:r}=e,n=Br(t.length),i=new Uint8Array(8+n+t.length);return jd(i,0,BigInt(r),"LE"),ki(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([ie.WITNESS_UTXO]),value:i}}const nA="{ script: Uint8Array; value: bigint; }";function iA(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function sA(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const oA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:sA,check:iA,decode:tA,encode:rA,expected:nA},Symbol.toStringTag,{value:"Module"}));function aA(e){if(e.key[0]!==St.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+ve(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=Ks(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function cA(e){const t=Uint8Array.from([St.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),ki(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:ot(r)}}const uA="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function lA(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function fA(e,t){return!!e&&!!t&&e.tapTree===void 0}const hA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:fA,check:lA,decode:aA,encode:cA,expected:uA},Symbol.toStringTag,{value:"Module"})),dA=e=>[...Array(e).keys()],pA=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Nl(e,t=pA){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+ve(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+ve(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const h={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const f of dA(a.value.length/4-1)){const d=Us(a.value,f*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;h.path+="/"+v.toString(10)+(g?"'":"")}return h}function n(a){const u=Uint8Array.from([e]),h=ot([u,a.pubkey]),f=a.path.split("/"),d=new Uint8Array(f.length*4);d.set(a.masterFingerprint,0);let g=4;return f.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),So(d,g,T,"LE"),g+=4}),{key:h,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,h){const f=ve(u.pubkey);return h.has(f)?!1:(h.add(f),a.filter(d=>Q(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Ul(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+ve(r.key));return n}}function Mp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const yA=e=>e.length===32;function Fp(e){const t=Nl(e,yA);function r(s){const{numberValue:a,bytes:u}=Ks(s.value),h=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),f=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)f[d]=s.value.slice(g,g+32);return{...h,leafHashes:f}}function n(s){const a=t.encode(s),u=Br(s.leafHashes.length),h=new Uint8Array(u);ki(s.leafHashes.length,h);const f=ot([h,...s.leafHashes,a.value]);return{...a,value:f}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function Vp(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+ve(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function Wp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Rl={unsignedTx:Xv,globalXpub:qv,checkPubkey:Ul([])},Ct={nonWitnessUtxo:dE,partialSig:vE,sighashType:CE,finalScriptSig:tE,finalScriptWitness:aE,porCommitment:kE,witnessUtxo:oA,bip32Derivation:Nl(ie.BIP32_DERIVATION),redeemScript:Mp(ie.REDEEM_SCRIPT),witnessScript:Wp(ie.WITNESS_SCRIPT),checkPubkey:Ul([ie.PARTIAL_SIG,ie.BIP32_DERIVATION]),tapKeySig:LE,tapScriptSig:eA,tapLeafScript:FE,tapBip32Derivation:Fp(ie.TAP_BIP32_DERIVATION),tapInternalKey:Vp(ie.TAP_INTERNAL_KEY),tapMerkleRoot:GE},Qn={bip32Derivation:Nl(St.BIP32_DERIVATION),redeemScript:Mp(St.REDEEM_SCRIPT),witnessScript:Wp(St.WITNESS_SCRIPT),checkPubkey:Ul([St.BIP32_DERIVATION]),tapBip32Derivation:Fp(St.TAP_BIP32_DERIVATION),tapTree:hA,tapInternalKey:Vp(St.TAP_INTERNAL_KEY)},gA=Object.freeze(Object.defineProperty({__proto__:null,globals:Rl,inputs:Ct,outputs:Qn},Symbol.toStringTag,{value:"Module"})),tc=e=>[...Array(e).keys()];function zp(e){const t=e.map(wA);return t.push(Uint8Array.from([0])),ot(t)}function wA(e){const t=e.key.length,r=e.value.length,n=Br(t),i=Br(r),o=new Uint8Array(n+t+i+r);return ki(t,o,0),o.set(e.key,n),ki(r,o,n+t),o.set(e.value,n+t+i),o}function bA(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=Ks(e,r);r+=N;const I=e.slice(r,r+Number(x));return r+=Number(x),I}function i(){const x=Us(e,r,"BE");return r+=4,x}function o(){const x=qn(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=qn(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],h={};for(;!a();){const x=s(),N=ve(x.key);if(h[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);h[N]=1,u.push(x)}const f=u.filter(x=>x.key[0]===$n.UNSIGNED_TX);if(f.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(f[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of tc(g)){const N={},I=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,I.push(k)}E.push(I)}for(const x of tc(v)){const N={},I=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,I.push(k)}T.push(I)}return qp(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Wt(e,t,r){if(Q(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${ve(t)}`)}function qp(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const f of t)switch(f.key[0]){case $n.UNSIGNED_TX:if(Wt("global",f.key,$n.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case $n.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Rl.globalXpub.decode(f));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(f)}const s=r.length,a=n.length,u=[],h=[];for(const f of tc(s)){const d={};for(const g of r[f])switch(Ct.checkPubkey(g),g.key[0]){case ie.NON_WITNESS_UTXO:if(Wt("input",g.key,ie.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Ct.nonWitnessUtxo.decode(g);break;case ie.WITNESS_UTXO:if(Wt("input",g.key,ie.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Ct.witnessUtxo.decode(g);break;case ie.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Ct.partialSig.decode(g));break;case ie.SIGHASH_TYPE:if(Wt("input",g.key,ie.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Ct.sighashType.decode(g);break;case ie.REDEEM_SCRIPT:if(Wt("input",g.key,ie.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Ct.redeemScript.decode(g);break;case ie.WITNESS_SCRIPT:if(Wt("input",g.key,ie.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Ct.witnessScript.decode(g);break;case ie.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Ct.bip32Derivation.decode(g));break;case ie.FINAL_SCRIPTSIG:Wt("input",g.key,ie.FINAL_SCRIPTSIG),d.finalScriptSig=Ct.finalScriptSig.decode(g);break;case ie.FINAL_SCRIPTWITNESS:Wt("input",g.key,ie.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Ct.finalScriptWitness.decode(g);break;case ie.POR_COMMITMENT:Wt("input",g.key,ie.POR_COMMITMENT),d.porCommitment=Ct.porCommitment.decode(g);break;case ie.TAP_KEY_SIG:Wt("input",g.key,ie.TAP_KEY_SIG),d.tapKeySig=Ct.tapKeySig.decode(g);break;case ie.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Ct.tapScriptSig.decode(g));break;case ie.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Ct.tapLeafScript.decode(g));break;case ie.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Ct.tapBip32Derivation.decode(g));break;case ie.TAP_INTERNAL_KEY:Wt("input",g.key,ie.TAP_INTERNAL_KEY),d.tapInternalKey=Ct.tapInternalKey.decode(g);break;case ie.TAP_MERKLE_ROOT:Wt("input",g.key,ie.TAP_MERKLE_ROOT),d.tapMerkleRoot=Ct.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const f of tc(a)){const d={};for(const g of n[f])switch(Qn.checkPubkey(g),g.key[0]){case St.REDEEM_SCRIPT:if(Wt("output",g.key,St.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=Qn.redeemScript.decode(g);break;case St.WITNESS_SCRIPT:if(Wt("output",g.key,St.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=Qn.witnessScript.decode(g);break;case St.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Qn.bip32Derivation.decode(g));break;case St.TAP_INTERNAL_KEY:Wt("output",g.key,St.TAP_INTERNAL_KEY),d.tapInternalKey=Qn.tapInternalKey.decode(g);break;case St.TAP_TREE:Wt("output",g.key,St.TAP_TREE),d.tapTree=Qn.tapTree.decode(g);break;case St.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Qn.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}h.push(d)}return{globalMap:i,inputs:u,outputs:h}}function mA({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=Ll({globalMap:e,inputs:t,outputs:r}),s=zp(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(zp),u=a(i),h=a(o),f=new Uint8Array(5);return f.set([112,115,98,116,255],0),ot([f,s].concat(u,h))}const vA=(e,t)=>Q(e.key,t.key);function Bl(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const h=(Array.isArray(a)?a:[a]).map(u.encode);return h.map(f=>ve(f.key)).forEach(f=>{if(r.has(f))throw new Error("Serialize Error: Duplicate key: "+f);r.add(f)}),o.concat(h)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(ve(o.key))):[];return n.concat(i).sort(vA)}function Ll({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Bl(e,Rl),inputKeyVals:t.map(n=>Bl(n,Ct)),outputKeyVals:r.map(n=>Bl(n,Qn))}}function EA(e){const t=e[0],r=Ll(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Gp(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=js(r.globalKeyVals),s=r.inputKeyVals.map(js),a=r.outputKeyVals.map(js);for(const u of n){const h=Gp(u);if(h===void 0||Q(h.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const f=Ll(u);js(f.globalKeyVals).forEach(Hl(o,r.globalKeyVals,f.globalKeyVals)),f.inputKeyVals.map(js).forEach((d,g)=>d.forEach(Hl(s[g],r.inputKeyVals[g],f.inputKeyVals[g]))),f.outputKeyVals.map(js).forEach((d,g)=>d.forEach(Hl(a[g],r.outputKeyVals[g],f.outputKeyVals[g])))}return qp(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function Hl(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>ve(o.key)===n)[0];t.push(i),e.add(n)}}function Gp(e){return e.globalMap.unsignedTx}function js(e){const t=new Set;return e.forEach(r=>{const n=ve(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function Kt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function Lo(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Kl(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>Q(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${ve(e.key)}`)}function jl(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function AA(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function Xp(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Dl(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=gA[e+"s"][n]||{},h=!!s;if(a)if(h){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||Xp(e,n,u,i);const f=r[n]||[],d=new Set;if(!i.every(g=>s(f,g,d)))throw new Error("Can not add duplicate data to array");r[n]=f.concat(i)}else{if(a(i)||Xp(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const SA=Dl("global"),Jp=Dl("input"),Yp=Dl("output");function TA(e,t){const r=e.length-1,n=Kt(e,r);Jp(t,n)}function _A(e,t){const r=e.length-1,n=Lo(e,r);Yp(t,n)}let Zp=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,r){const n=Hd(t);return this.fromBuffer(n,r)}static fromHex(t,r){const n=zn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r){const n=bA(t,r),i=new this(n.globalMap.unsignedTx);return Object.assign(i,n),i}toBase64(){const t=this.toBuffer();return wm(t)}toHex(){const t=this.toBuffer();return ve(t)}toBuffer(){return mA(this)}updateGlobal(t){return SA(t,this.globalMap),this}updateInput(t,r){const n=Kt(this.inputs,t);return Jp(r,n),this}updateOutput(t,r){const n=Lo(this.outputs,t);return Yp(r,n),this}addUnknownKeyValToGlobal(t){return Kl(t,this.globalMap.unknownKeyVals,jl($n)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,r){const n=Kt(this.inputs,t);return Kl(r,n.unknownKeyVals,jl(ie)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addUnknownKeyValToOutput(t,r){const n=Lo(this.outputs,t);return Kl(r,n.unknownKeyVals,jl(St)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.inputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToInput(n,i)),TA(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.outputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToOutput(n,i)),_A(this.outputs,t),this}clearFinalizedInput(t){const r=Kt(this.inputs,t);AA(t,r);for(const n of Object.keys(r))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(n)||delete r[n];return this}combine(...t){const r=EA([this].concat(t));return Object.assign(this,r),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function as(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const kA=as(qa),PA=as(lp),OA=as(Oo),rc=as(Co),Qp=as(No),e0=as(Ls),t0=as(Ro);function nc(e){let t=new Uint8Array(0);function r(s){t=ot([t,s])}function n(s){const a=t.length,u=Br(s);t=ot([t,new Uint8Array(u)]),ki(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function r0(e,t){const r=Jn(e),n=e.slice(1,33),i=gt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:Q(e,o)===0||Q(r,o)===0||Q(n,o)===0)}function ic(e,t){return r0(e,t)!==-1}function IA(e,t){return xA(e).some(r=>n0(r,ko.decode,t))}function n0(e,t,r){const{hashType:n}=t(e),i=[];switch(n&At.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case At.SIGHASH_ALL:break;case At.SIGHASH_SINGLE:case At.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function xA(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=$A(e)}else t=e.partialSig;return t.map(r=>r.signature)}function $A(e){const t=e.finalScriptSig?gt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?gt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&Xn(n)).map(n=>({signature:n}))}const sc=e=>e.length===32?e:e.slice(1,33);function i0(e,t,r){const n=WA(t,e,r);try{const i=FA(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:nc(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function oc(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return ot([e,r])}function cn(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&t0(e.witnessUtxo.script))}function Ml(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function s0(e,t,r){jA(e,t,r),MA(e,t,r)}function o0(e,t,r){DA(e,t,r),CA(e,t)}function CA(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=NA(r,n);if(i&&Q(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function NA(e,t){const r=t&&UA(t.leaves),{output:n}=Ro({internalPubkey:e,scriptTree:r});return n}function UA(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:KA(e)}function RA(e,t){return LA(e).some(r=>n0(r,BA,t))}function BA(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||At.SIGHASH_DEFAULT}}function LA(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=HA(e.finalScriptWitness);r&&t.push(r)}return t}function HA(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function KA(e){let t;for(const r of e)if(t=Fl(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function Fl(e,t,r=0){if(r>Iv)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(wl(t))return;const n=Fl(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=Fl(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function jA(e,t,r){const n=cn(e)&&Ds(t),i=Ds(e)&&cn(t),o=e===t&&cn(t)&&Ds(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function DA(e,t,r){const n=Ml(e)&&Ds(t),i=Ds(e)&&Ml(t),o=e===t&&Ml(t)&&Ds(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function MA(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Vl(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Vl(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Vl(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Vl(e,t){if(!t)return!0;const r=Zn({output:e.script,version:e.leafVersion}),n=Il(e.controlBlock,r);return Q(n,t)===0}function FA(e,t){const r=Zn({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>Q(n.leafHash,r)===0).map(n=>VA(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function VA(e,t){return Object.assign({positionInScript:r0(t.pubkey,e)},t)}function WA(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>zA(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function zA(e,t,r){const n=Zn({output:e.script,version:e.leafVersion});return(!r||Q(n,r)===0)&&t.find(i=>Q(i.leafHash,n)===0)!==void 0}function Ds(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const qA={network:nn,maximumFeeRate:5e3};let Nt=class $d{constructor(t={},r=new Zp(new a0)){we(this,"data"),we(this,"__CACHE"),we(this,"opts"),this.data=r,this.opts=Object.assign({},qA,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Hd(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=zn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=Zp.fromBuffer(t,GA),i=new $d(r,n);return QA(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:kp(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=Bo(t.script,this.opts.network)}catch{}return{script:kp(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=$d.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){ac(t),this.opts.maximumFeeRate=t}setVersion(t){ac(t),Ho(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){ac(t),Ho(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){ac(r),Ho(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");s0(t,t,"addInput"),Ho(this.data.inputs,"addInput"),t.witnessScript&&lc(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];h0(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&ql(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");Ho(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=Lp(r,i);t=Object.assign({},t,{script:o})}o0(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(u0))throw new Error("Not finalized");const r=this.__CACHE;if(t||JA(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return T0(this.data.inputs,n,r,!0),n}getFeeRate(){return g0("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return g0("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return Kt(this.data.inputs,0),Ko(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=Kt(this.data.inputs,t);return cn(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=i0){const i=Kt(this.data.inputs,t);if(cn(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=e3){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=i3(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);YA(r);const{finalScriptSig:u,finalScriptWitness:h}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),h&&this.data.updateInput(t,{finalScriptWitness:h}),!u&&!h)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=i0){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=Ro({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=nc(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=Kt(this.data.inputs,t),n=_0(t,r,this.__CACHE),i=uc(n,t,"input",r.redeemScript||u3(r.finalScriptSig),r.witnessScript||l3(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=P0(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=Kt(this.data.inputs,t);return a3(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=Kt(this.data.inputs,t),i=l0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=Lo(this.data.outputs,t);return c3(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=Lo(this.data.outputs,t),i=l0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return Kt(this.data.inputs,0),Ko(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return cn(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>Q(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,h,f;for(const d of s){const g=ko.decode(d.signature),{hash:v,script:E}=f!==g.hashType?b0(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:h};f=g.hashType,u=v,h=E,f0(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&sc(n);const a=n?zl(t,i,this.data.inputs,n,this.__CACHE):r3(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(f=>!f.leafHash);let h=0;if(o&&u){if(!r(u.pubkey,u.hash,v0(o)))return!1;h++}if(s)for(const f of s){const d=a.find(g=>Q(g.pubkey,f.pubkey)===0);if(d){if(!r(f.pubkey,d.hash,v0(f.signature)))return!1;h++}}return h>0}signAllInputsHD(t,r=[At.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of Ko(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[At.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of Ko(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[At.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return A0(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[At.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=A0(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of Ko(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return cn(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(cn(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[At.SIGHASH_ALL]){const{hash:i,sighashType:o}=w0(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:ko.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[At.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(h=>!h.leafHash).map(h=>oc(n.signSchnorr(h.hash),r.sighashType))[0],u=s.filter(h=>!!h.leafHash).map(h=>({pubkey:sc(n.publicKey),signature:oc(n.signSchnorr(h.hash),r.sighashType),leafHash:h.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return cn(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(cn(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[At.SIGHASH_ALL]){const{hash:i,sighashType:o}=w0(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:ko.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[At.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(f=>!f.leafHash)[0];if(u){const f=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:oc(d,r.sighashType)}));a.push(f)}const h=s.filter(f=>!!f.leafHash);if(h.length){const f=h.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:sc(n.publicKey),signature:oc(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...f)}return Promise.all(a).then(f=>{f.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=zl(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${ve(n.publicKey)}`);return s}toBuffer(){return Wl(this.__CACHE),this.data.toBuffer()}toHex(){return Wl(this.__CACHE),this.data.toHex()}toBase64(){return Wl(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&lc(r.witnessScript),s0(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&ql(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return o0(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}};const GA=e=>new a0(e);let a0=class{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){we(this,"tx"),this.tx=At.fromBuffer(t),ZA(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?Ol(zn(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}};function XA(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return c0(1,e.partialSig);case"multisig":const n=qa({output:t});return c0(n.m,e.partialSig,n.pubkeys);default:return!1}}function Wl(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function c0(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=f3(i);return t.find(s=>Q(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function u0(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function l0(e){return t=>!(Q(e.fingerprint,t.masterFingerprint)||Q(e.derivePath(t.path).publicKey,t.pubkey))}function ac(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function JA(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}function Ho(e,t){e.forEach(r=>{if(cn(r)?RA(r,t):IA(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function YA(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=ko.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function f0(e,t,r){if(!ic(e,t))throw new Error(`Can not ${r} for this input with the key ${ve(e)}`)}function ZA(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function QA(e,t){e.ins.forEach(r=>{h0(t,r)})}function h0(e,t){const r=ve(Ol(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function d0(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(Q(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const p0=d0(Ls,"Redeem script"),y0=d0(No,"Witness script");function g0(e,t,r,n){if(!r.every(u0))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),T0(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function e3(e,t,r,n,i,o){const s=P0(r);if(!XA(t,r,s))throw new Error(`Can not finalize input #${e}`);return t3(r,s,t.partialSig,n,i,o)}function t3(e,t,r,n,i,o){let s,a;const u=n3(e,t,r),h=o?No({redeem:u}):null,f=i?Ls({redeem:h||u}):null;return n?(h?a=nc(h.witness):a=nc(u.witness),f&&(s=f.input)):f?s=f.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function w0(e,t,r,n,i){const o=Kt(e,t),{hash:s,sighashType:a,script:u}=b0(t,o,n,!1,i);return f0(r,u,"sign"),{hash:s,sighashType:a}}function b0(e,t,r,n,i){const o=r.__TX,s=t.sighashType||At.SIGHASH_ALL;E0(s,i);let a,u;if(t.nonWitnessUtxo){const d=cc(r,t,e),g=o.ins[e].hash,v=d.getHash();if(Q(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:h,type:f}=uc(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)a=o.hashForWitnessV0(e,h,u.value,s);else if(rc(h)){const d=Oo({hash:h.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${ve(h)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&console.warn(`Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.
3
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function lm(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function hm(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function fm(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const ze={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,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_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,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_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT: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_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,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_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},Rd={};for(const e of Object.keys(ze)){const t=ze[e];Rd[t]=e}const Ra="0123456789abcdefABCDEF",Ba=Ra.split("").map(e=>e.codePointAt(0)),La=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Ra.indexOf(r);return n<0?void 0:n<16?n:n-6}),Bd=new TextEncoder,Ld=new TextDecoder;function dm(e){return Ld.decode(e)}function pm(e){return Bd.encode(e)}function ot(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function ve(e){const t=e||new Uint8Array;return t.length>512?gm(t):ym(t)}function ym(e){let t="";for(let r=0;r<e.length;++r)t+=Ra[La[Ba[e[r]>>4]]],t+=Ra[La[Ba[e[r]&15]]];return t}function gm(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=Ba[e[r]>>4],t[r*2+1]=Ba[e[r]&15];return Ld.decode(t)}function zn(e){const t=Bd.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=La[t[n*2]],o=La[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function wm(e){return btoa(String.fromCharCode(...e))}function Hd(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Q(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Tr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function bm(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function So(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function mm(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function qn(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function vm(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Us(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Kd(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function jd(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function Em(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function Dd(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function Md(e){return e<ze.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function Am(e,t,r){const n=Md(t);return n===1?Tr(e,r,t):n===2?(Tr(e,r,ze.OP_PUSHDATA1),Tr(e,r+1,t)):n===3?(Tr(e,r,ze.OP_PUSHDATA2),bm(e,r+1,t,"LE")):(Tr(e,r,ze.OP_PUSHDATA4),So(e,r+1,t,"LE")),n}function Sm(e,t){const r=qn(e,t);let n,i;if(r<ze.OP_PUSHDATA1)n=r,i=1;else if(r===ze.OP_PUSHDATA1){if(t+2>e.length)return null;n=qn(e,t+1),i=2}else if(r===ze.OP_PUSHDATA2){if(t+3>e.length)return null;n=vm(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==ze.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=Us(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function Tm(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function _m(e){let t=Math.abs(e);const r=Tm(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Tr(n,o,t&255),t>>=8;return n[r-1]&128?Tr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function km(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function s9(e){}function o9(e){}function Pm(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function To(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function Ft(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??To(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Pm(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Im(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var Om=class extends Error{constructor(t){super(t[0].message),we(this,"issues"),this.name="ValiError",this.issues=t}};function Fd(e,t){return{kind:"validation",type:"every_item",reference:Fd,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&Ft(this,"item",r,n),r}}}function dl(e){return{kind:"validation",type:"integer",reference:dl,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&Ft(this,"integer",t,r),t}}}function Vd(e,t){return{kind:"validation",type:"length",reference:Vd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&Ft(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ha(e,t){return{kind:"validation",type:"max_value",reference:Ha,async:!1,expects:`<=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():To(r.value)}),r}}}function Ka(e,t){return{kind:"validation",type:"min_value",reference:Ka,async:!1,expects:`>=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():To(r.value)}),r}}}function Wd(e,t){return{kind:"validation",type:"regex",reference:Wd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&Ft(this,"format",r,n),r}}}function pl(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function ja(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function zd(){return{kind:"schema",type:"any",reference:zd,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function ar(e,t){return{kind:"schema",type:"array",reference:ar,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function qd(e){return{kind:"schema",type:"bigint",reference:qd,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:Ft(this,"type",t,r),t}}}function sn(e,t){return{kind:"schema",type:"custom",reference:sn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:Ft(this,"type",r,n),r}}}function Da(e,t){return{kind:"schema",type:"instance",reference:Da,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:Ft(this,"type",r,n),r}}}function yl(e,...t){const r={kind:"schema",type:"nullable",reference:yl,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=pl(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Gd(e,...t){const r={kind:"schema",type:"nullish",reference:Gd,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=pl(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function cr(e){return{kind:"schema",type:"number",reference:cr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Ft(this,"type",t,r),t}}}function It(e,t){return{kind:"schema",type:"object",reference:It,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else Ft(this,"type",r,n);return r}}}function Ma(e,...t){const r={kind:"schema",type:"optional",reference:Ma,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=pl(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function ss(e){return{kind:"schema",type:"string",reference:ss,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:Ft(this,"type",t,r),t}}}function In(e,t){return{kind:"schema",type:"tuple",reference:In,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function Xd(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function gl(e,t){return{kind:"schema",type:"union",reference:gl,expects:Im(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];Ft(this,"type",r,n,{issues:Xd(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];Ft(this,"type",r,n,{issues:Xd(s)})}return r}}}function at(e,t,r){const n=e._run({typed:!1,value:t},km(r));if(n.issues)throw new Om(n.issues);return n.value}function Ai(e,t){const r={};for(const n in e.entries)r[n]=Ma(e.entries[n]);return{...e,entries:r}}function Rs(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const Jd=new Uint8Array(32),Yd=zn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$t=e=>Rs(Da(Uint8Array),Vd(e));function _o(e,t){return e.length!==t.length?!1:e.every((r,n)=>Q(r,t[n])===0)}function on(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(Q(Jd,r)===0||Q(r,Yd)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return Q(Jd,n)===0||Q(n,Yd)>=0?!1:t===4&&e.length===65}const Fa=254;function wl(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&Fa)===e.version:!0}function Zd(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>Zd(t)):wl(e)}const xm=$t(32),$m=$t(20),Qd=$t(32),De=Da(Uint8Array);Rs(ss(),Wd(/^([0-9a-f]{2})+$/i));const Cm=Rs(cr(),dl(),Ka(0),Ha(255)),Gn=Rs(cr(),dl(),Ka(0),Ha(4294967295)),bl=Rs(qd(),Ka(0n),Ha(0x7fffffffffffffffn)),ep=e=>It(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Gd(r[1])}),{})),tp=new Uint8Array(1);function rp(e){let t=0;for(;e[t]===0;)++t;return t===e.length?tp:(e=e.slice(t),e[0]&128?ot([tp,e]):e)}function np(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Nm(e){const t=qn(e,e.length-1);if(!vl(t))throw new Error("Invalid hashType "+t);const r=hm(e.subarray(0,-1)),n=np(r.r),i=np(r.s);return{signature:ot([n,i]),hashType:t}}function Um(e,t){if(at(It({signature:$t(64),hashType:Cm}),{signature:e,hashType:t}),!vl(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Tr(r,0,t);const n=rp(e.slice(0,32)),i=rp(e.slice(32,64));return ot([fm(n,i),r])}const Rm=Object.freeze(Object.defineProperty({__proto__:null,decode:Nm,encode:Um},Symbol.toStringTag,{value:"Module"})),ip=ze.OP_RESERVED,sp=ar(gl([Da(Uint8Array),cr()]));function Bm(e){return ja(cr(),e)&&(e===ze.OP_0||e>=ze.OP_1&&e<=ze.OP_16||e===ze.OP_1NEGATE)}function op(e){return ja(De,e)||Bm(e)}function ml(e){return ja(Rs(zd(),Fd(op)),e)}function ap(e){return e.length-e.filter(op).length}function Va(e){if(e.length===0)return ze.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return ip+e[0];if(e[0]===129)return ze.OP_1NEGATE}}function cp(e){return e instanceof Uint8Array}function Lm(e){return ja(sp,e)}function Wa(e){return e instanceof Uint8Array}function ur(e){if(cp(e))return e;at(sp,e);const t=e.reduce((i,o)=>Wa(o)?o.length===1&&Va(o)!==void 0?i+1:i+Md(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(Wa(i)){const o=Va(i);if(o!==void 0){Tr(r,n,o),n+=1;return}n+=Am(r,i.length,n),r.set(i,n),n+=i.length}else Tr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function gt(e){if(Lm(e))return e;at(De,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>ze.OP_0&&n<=ze.OP_PUSHDATA4){const i=Sm(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=Va(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function Hm(e){if(cp(e)&&(e=gt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(Wa(t)){const r=Va(t);if(r===void 0)return ve(t);t=r}return Rd[t]}).join(" ")}function Km(e){return e=gt(e),at(sn(ml),e),e.map(t=>Wa(t)?t:t===ze.OP_0?new Uint8Array(0):_m(t-ip))}function jm(e){return on(e)}function vl(e){const t=e&-129;return t>0&&t<4}function Xn(e){return!(e instanceof Uint8Array)||!vl(e[e.length-1])?!1:lm(e.slice(0,-1))}const ko=Rm;function de(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Ur(e){let t;return()=>(t!==void 0||(t=e()),t)}const Bs=ze,za=Bs.OP_RESERVED;function qa(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return Xn(a)||(t.allowIncomplete&&a===Bs.OP_0)!==void 0}at(Ai(It({network:It({}),m:cr(),n:cr(),output:De,pubkeys:ar(sn(on),"Received invalid pubkey"),signatures:ar(sn(r),"Expected signature to be of type isAcceptableSignature"),input:De})),e);const n={network:e.network||nn};let i=[],o=!1;function s(a){o||(o=!0,i=gt(a),n.m=i[0]-za,n.n=i[i.length-2]-za,n.pubkeys=i.slice(1,-2))}if(de(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return ur([].concat(za+e.m,e.pubkeys,za+n.n,Bs.OP_CHECKMULTISIG))}),de(n,"m",()=>{if(n.output)return s(n.output),n.m}),de(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),de(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),de(n,"signatures",()=>{if(e.input)return gt(e.input).slice(1)}),de(n,"input",()=>{if(e.signatures)return ur([Bs.OP_0].concat(e.signatures))}),de(n,"witness",()=>{if(n.input)return[]}),de(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),at(cr(),i[0],{message:"Output is invalid"}),at(cr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==Bs.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>on(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!_o(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==Bs.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!_o(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const up=ze;function lp(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({network:It({}),output:De,pubkey:sn(on,"invalid pubkey"),signature:sn(Xn,"Expected signature to be of type isCanonicalScriptSignature"),input:De})),e);const r=Ur(()=>gt(e.input)),n={name:"p2pk",network:e.network||nn};if(de(n,"output",()=>{if(e.pubkey)return ur([e.pubkey,up.OP_CHECKSIG])}),de(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),de(n,"signature",()=>{if(e.input)return r()[0]}),de(n,"input",()=>{if(e.signature)return ur([e.signature])}),de(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==up.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!on(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&Q(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&Q(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!Xn(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function Dm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function hp(e,...t){if(!Dm(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function fp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mm(e,t){hp(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const El=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),On=(e,t)=>e<<32-t|e>>>t,Ga=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Fm(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function dp(e){return typeof e=="string"&&(e=Fm(e)),hp(e),e}let Vm=class{clone(){return this._cloneInto()}};function pp(e){const t=n=>e().update(dp(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Wm(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const zm=(e,t,r)=>e&t^~e&r,qm=(e,t,r)=>e&t^e&r^t&r;let yp=class extends Vm{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=El(this.buffer)}update(t){fp(this);const{view:r,buffer:n,blockLen:i}=this;t=dp(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=El(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){fp(this),Mm(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;Wm(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=El(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};const Gm=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),gp=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Xm=gp.map(e=>(9*e+5)%16);let Al=[gp],Sl=[Xm];for(let e=0;e<4;e++)for(let t of[Al,Sl])t.push(t[e].map(r=>Gm[r]));const wp=[[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(e=>new Uint8Array(e)),Jm=Al.map((e,t)=>e.map(r=>wp[t][r])),Ym=Sl.map((e,t)=>e.map(r=>wp[t][r])),Zm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Qm=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function bp(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const Xa=new Uint32Array(16);let ev=class extends yp{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)Xa[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,f=this.h3|0,h=f,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=Zm[v],x=Qm[v],N=Al[v],O=Sl[v],k=Jm[v],B=Ym[v];for(let z=0;z<16;z++){const V=Ga(n+bp(v,o,a,f)+Xa[N[z]]+T,k[z])+d|0;n=d,d=f,f=Ga(a,10)|0,a=o,o=V}for(let z=0;z<16;z++){const V=Ga(i+bp(E,s,u,h)+Xa[O[z]]+x,B[z])+g|0;i=g,g=h,h=Ga(u,10)|0,u=s,s=V}}this.set(this.h1+a+h|0,this.h2+f+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){Xa.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const tv=pp(()=>new ev),rv=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]),Si=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ti=new Uint32Array(64);let nv=class extends yp{constructor(){super(64,32,8,!1),this.A=Si[0]|0,this.B=Si[1]|0,this.C=Si[2]|0,this.D=Si[3]|0,this.E=Si[4]|0,this.F=Si[5]|0,this.G=Si[6]|0,this.H=Si[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ti[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ti[d-15],v=Ti[d-2],E=On(g,7)^On(g,18)^g>>>3,T=On(v,17)^On(v,19)^v>>>10;Ti[d]=T+Ti[d-7]+E+Ti[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=On(a,6)^On(a,11)^On(a,25),v=h+g+zm(a,u,f)+rv[d]+Ti[d]|0,E=(On(n,2)^On(n,13)^On(n,22))+qm(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Xt=pp(()=>new nv);function Jn(e){return tv(Xt(e))}function os(e){return Xt(Xt(e))}const iv={"BIP0340/challenge":Uint8Array.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":Uint8Array.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":Uint8Array.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:Uint8Array.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:Uint8Array.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:Uint8Array.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:Uint8Array.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":Uint8Array.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":Uint8Array.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function Ja(e,t){return Xt(ot([iv[e],t]))}function sv(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let f=0;f<t.length;f++)t[f]=255;for(let f=0;f<e.length;f++){const h=e.charAt(f),d=h.charCodeAt(0);if(t[d]!==255)throw new TypeError(h+" is ambiguous");t[d]=f}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let h=0,d=0,g=0;const v=f.length;for(;g!==v&&f[g]===0;)g++,h++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let O=f[g],k=0;for(let B=E-1;(O!==0||k<d)&&B!==-1;B--,k++)O+=256*T[B]>>>0,T[B]=O%r>>>0,O=O/r>>>0;if(O!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(h);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let h=0,d=0,g=0;for(;f[h]===n;)d++,h++;const v=(f.length-h)*i+1>>>0,E=new Uint8Array(v);for(;f[h];){let O=t[f.charCodeAt(h)];if(O===255)return;let k=0;for(let B=v-1;(O!==0||k<g)&&B!==-1;B--,k++)O+=r*E[B]>>>0,E[B]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");g=k,h++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(f){const h=a(f);if(h)return h;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var ov="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Tl=sv(ov);function av(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,f=new Uint8Array(u);return f.set(s,0),f.set(a.subarray(0,4),s.length),Tl.encode(f)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=Tl.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=Tl.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function cv(e){return Xt(Xt(e))}const Po=av(cv),_i=ze;function Io(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({network:It({}),address:ss(),hash:$m,output:$t(25),pubkey:sn(on),signature:sn(Xn),input:De})),e);const r=Ur(()=>{const s=Po.decode(e.address),a=qn(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Ur(()=>gt(e.input)),i=e.network||nn,o={name:"p2pkh",network:i};if(de(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Tr(s,0,i.pubKeyHash),s.set(o.hash,1),Po.encode(s)}),de(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return Jn(e.pubkey||o.pubkey)}),de(o,"output",()=>{if(o.hash)return ur([_i.OP_DUP,_i.OP_HASH160,o.hash,_i.OP_EQUALVERIFY,_i.OP_CHECKSIG])}),de(o,"pubkey",()=>{if(e.input)return n()[1]}),de(o,"signature",()=>{if(e.input)return n()[0]}),de(o,"input",()=>{if(e.pubkey&&e.signature)return ur([e.signature,e.pubkey])}),de(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==_i.OP_DUP||e.output[1]!==_i.OP_HASH160||e.output[2]!==20||e.output[23]!==_i.OP_EQUALVERIFY||e.output[24]!==_i.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=Jn(e.pubkey);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!Xn(a[0]))throw new TypeError("Input has invalid signature");if(!on(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&Q(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=Jn(a[1]);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const Oo=ze;function Ls(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({network:It({}),address:ss(),hash:$t(20),output:$t(23),redeem:Ai(It({network:It({}),output:De,input:De,witness:ar(De)})),input:De,witness:ar(De)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||nn);const n={network:r},i=Ur(()=>{const a=Po.decode(e.address),u=qn(a,0),f=a.slice(1);return{version:u,hash:f}}),o=Ur(()=>gt(e.input)),s=Ur(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===Oo.OP_FALSE?Uint8Array.from([]):u,input:ur(a.slice(0,-1)),witness:e.witness||[]}});if(de(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Tr(a,0,n.network.scriptHash),a.set(n.hash,1),Po.encode(a)}),de(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return Jn(n.redeem.output)}),de(n,"output",()=>{if(n.hash)return ur([Oo.OP_HASH160,n.hash,Oo.OP_EQUAL])}),de(n,"redeem",()=>{if(e.input)return s()}),de(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return ur([].concat(gt(e.redeem.input),e.redeem.output))}),de(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),de(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&Q(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==Oo.OP_HASH160||e.output[1]!==20||e.output[22]!==Oo.OP_EQUAL)throw new TypeError("Output is invalid");const f=e.output.slice(2,22);if(a.length>0&&Q(a,f)!==0)throw new TypeError("Hash mismatch");a=f}const u=f=>{if(f.output){const h=gt(f.output);if(!h||h.length<1)throw new TypeError("Redeem.output too short");if(f.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(ap(h)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=Jn(f.output);if(a.length>0&&Q(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(f.input){const h=f.input.length>0,d=f.witness&&f.witness.length>0;if(!h&&!d)throw new TypeError("Empty input");if(h&&d)throw new TypeError("Input and witness provided");if(h){const g=gt(f.input);if(!ml(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const f=s();if(e.redeem.output&&Q(e.redeem.output,f.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&Q(e.redeem.input,f.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!_o(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function lv(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var xo={};Object.defineProperty(xo,"__esModule",{value:!0});var $o=xo.bech32m=_r=xo.bech32=void 0;const Ya="qpzry9x8gf2tvdw0s3jn54khce6mua7l",mp={};for(let e=0;e<Ya.length;e++){const t=Ya.charAt(e);mp[t]=e}function Hs(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function vp(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=Hs(t)^n>>5}t=Hs(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=Hs(t)^n&31}return t}function _l(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function hv(e){return _l(e,8,5,!0)}function fv(e){const t=_l(e,5,8,!1);if(Array.isArray(t))return t}function dv(e){const t=_l(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Ep(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let f=vp(s);if(typeof f=="string")throw new Error(f);let h=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");f=Hs(f)^g,h+=Ya.charAt(g)}for(let d=0;d<6;++d)f=Hs(f);f^=t;for(let d=0;d<6;++d){const g=f>>(5-d)*5&31;h+=Ya.charAt(g)}return h}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),f=s.toUpperCase();if(s!==u&&s!==f)return"Mixed-case string "+s;s=u;const h=s.lastIndexOf("1");if(h===-1)return"No separator character for "+s;if(h===0)return"Missing prefix for "+s;const d=s.slice(0,h),g=s.slice(h+1);if(g.length<6)return"Data too short";let v=vp(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=mp[x];if(N===void 0)return"Unknown character "+x;v=Hs(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:hv,fromWordsUnsafe:fv,fromWords:dv}}var _r=xo.bech32=Ep("bech32");$o=xo.bech32m=Ep("bech32m");const Ap=ze,pv=new Uint8Array(0);function Co(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({address:ss(),hash:$t(20),input:$t(0),network:It({}),output:$t(22),pubkey:sn(on,"Not a valid pubkey"),signature:sn(Xn),witness:ar(De)})),e);const r=Ur(()=>{const o=_r.decode(e.address),s=o.words.shift(),a=_r.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||nn,i={name:"p2wpkh",network:n};if(de(i,"address",()=>{if(!i.hash)return;const o=_r.toWords(i.hash);return o.unshift(0),_r.encode(n.bech32,o)}),de(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return Jn(e.pubkey||i.pubkey)}),de(i,"output",()=>{if(i.hash)return ur([Ap.OP_0,i.hash])}),de(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),de(i,"signature",()=>{if(e.witness)return e.witness[0]}),de(i,"input",()=>{if(i.witness)return pv}),de(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&Q(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==Ap.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&Q(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=Jn(e.pubkey);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!on(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!Xn(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!on(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&Q(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=Jn(e.witness[1]);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const Sp=ze,kl=new Uint8Array(0);function Za(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&on(e))}function No(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(ep({network:It({}),address:ss(),hash:xm,output:$t(34),redeem:ep({input:De,network:It({}),output:De,witness:ar(De)}),input:$t(0),witness:ar(De)}),e);const r=Ur(()=>{const s=_r.decode(e.address),a=s.words.shift(),u=_r.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Ur(()=>gt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||nn);const o={network:i};if(de(o,"address",()=>{if(!o.hash)return;const s=_r.toWords(o.hash);return s.unshift(0),_r.encode(i.bech32,s)}),de(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return Xt(o.redeem.output)}),de(o,"output",()=>{if(o.hash)return ur([Sp.OP_0,o.hash])}),de(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:kl,witness:e.witness.slice(0,-1)}}),de(o,"input",()=>{if(o.witness)return kl}),de(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=Km(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=kl,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),de(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==Sp.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=gt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(ap(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=Xt(e.redeem.output);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!ml(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!_o(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(Za)||e.redeem.output&&(gt(e.redeem.output)||[]).some(Za))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&Q(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(Za)||(gt(a)||[]).some(Za))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const Uo={};function yv(e){e?e!==Uo.eccLib&&(gv(e),Uo.eccLib=e):Uo.eccLib=e}function Pl(){if(!Uo.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return Uo.eccLib}const Yn=e=>zn(e);function gv(e){Rr(typeof e.isXOnlyPoint=="function"),Rr(e.isXOnlyPoint(Yn("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Rr(e.isXOnlyPoint(Yn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Rr(e.isXOnlyPoint(Yn("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Rr(e.isXOnlyPoint(Yn("0000000000000000000000000000000000000000000000000000000000000001"))),Rr(!e.isXOnlyPoint(Yn("0000000000000000000000000000000000000000000000000000000000000000"))),Rr(!e.isXOnlyPoint(Yn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Rr(typeof e.xOnlyPointAddTweak=="function"),wv.forEach(t=>{const r=e.xOnlyPointAddTweak(Yn(t.pubkey),Yn(t.tweak));t.result===null?Rr(r===null):(Rr(r!==null),Rr(r.parity===t.parity),Rr(Q(r.xOnlyPubkey,Yn(t.result))===0))})}function Rr(e){if(!e)throw new Error("ecc library invalid")}const wv=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],Tp="0123456789abcdefABCDEF";Tp.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Tp.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function bv(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function mv(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function vv(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function Ev(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Av(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Sv(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const Tv=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function _v(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function _p(e){typeof e=="number"?_v(e):Tv(e)}function ki(e,t,r){_p(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Br(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),bv(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),mv(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),vv(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function Ks(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=Ev(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=Av(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=Sv(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Br(e){return _p(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const kv=9007199254740991;function Pv(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function Il(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e}function kp(e){const t=new Uint8Array(e.length);return t.set(e),t}class Vt{constructor(t,r=0){we(this,"buffer"),we(this,"offset"),this.buffer=t,this.offset=r,at(In([De,Gn]),[t,r])}static withCapacity(t){return new Vt(new Uint8Array(t))}writeUInt8(t){this.offset=Tr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Kd(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=jd(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=So(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=mm(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=ki(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}let Iv=class{constructor(t,r=0){we(this,"buffer"),we(this,"offset"),this.buffer=t,this.offset=r,at(In([De,Gn]),[t,r])}readUInt8(){const t=qn(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=Em(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=Us(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=Dd(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=Ks(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){Pv(t,kv);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}};const Pp=192,Ov=128,xv=e=>"left"in e&&"right"in e;function Ol(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);Q(n,o)<0?n=$l(n,o):n=$l(o,n)}return n}function xl(e){if(wl(e))return{hash:Zn(e)};const t=[xl(e[0]),xl(e[1])];t.sort((i,o)=>Q(i.hash,o.hash));const[r,n]=t;return{hash:$l(r.hash,n.hash),left:r,right:n}}function Qa(e,t){if(xv(e)){const r=Qa(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=Qa(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(Q(e.hash,t)===0)return[]}function Zn(e){const t=e.version||Pp;return Ja("TapLeaf",ot([Uint8Array.from([t]),Cv(e.output)]))}function $v(e,t){return Ja("TapTweak",ot(t?[e,t]:[e]))}function ec(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=$v(e,t),n=Pl().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function $l(e,t){return Ja("TapBranch",ot([e,t]))}function Cv(e){const t=Br(e.length),r=new Uint8Array(t);return ki(e.length,r),ot([r,e])}const Ip=ze,Op=1,Nv=80;function Ro(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({address:ss(),input:$t(0),network:It({}),output:$t(34),internalPubkey:$t(32),hash:$t(32),pubkey:$t(32),signature:gl([$t(64),$t(65)]),witness:ar(De),scriptTree:sn(Zd,"Taptree is not of type isTaptree"),redeem:Ai(It({output:De,redeemVersion:cr(),witness:ar(De)})),redeemVersion:cr()})),e);const r=Ur(()=>Bp(e.address)),n=Ur(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===Nv?e.witness.slice(0,-1):e.witness.slice()}),i=Ur(()=>{if(e.scriptTree)return xl(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||nn,s={name:"p2tr",network:o};if(de(s,"address",()=>{if(!s.pubkey)return;const a=$o.toWords(s.pubkey);return a.unshift(Op),$o.encode(o.bech32,a)}),de(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const f=u[u.length-1],h=f[0]&Fa,d=u[u.length-2],g=Zn({output:d,version:h});return Ol(f,g)}return null}),de(s,"output",()=>{if(s.pubkey)return ur([Ip.OP_1,s.pubkey])}),de(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:Pp),de(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&Fa}}),de(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=ec(s.internalPubkey,s.hash);if(a)return a.x}}),de(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),de(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),de(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=Zn({output:e.redeem.output,version:s.redeemVersion}),f=Qa(a,u);if(!f)return;const h=ec(e.internalPubkey,a.hash);if(!h)return;const d=ot([Uint8Array.from([s.redeemVersion|h.parity]),e.internalPubkey].concat(f));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==Op)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&Q(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==Ip.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&Q(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const h=ec(e.internalPubkey,s.hash);if(a.length>0&&Q(a,h.x)!==0)throw new TypeError("Pubkey mismatch");a=h.x}if(a&&a.length&&!Pl().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&Q(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const h=Zn({output:e.redeem.output,version:s.redeemVersion});if(!Qa(u,h))throw new TypeError("Redeem script not in tree")}const f=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(gt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&Q(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!_o(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(f.length===1){if(e.signature&&Q(e.signature,f[0])!==0)throw new TypeError("Signature mismatch")}else{const h=f[f.length-1];if(h.length<33)throw new TypeError(`The control-block length is too small. Got ${h.length}, expected min 33.`);if((h.length-33)%32!==0)throw new TypeError(`The control-block length of ${h.length} is incorrect!`);const d=(h.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=h.slice(1,33);if(e.internalPubkey&&Q(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!Pl().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=h[0]&Fa,E=f[f.length-2],T=Zn({output:E,version:v}),x=Ol(h,T),N=ec(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&Q(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(h[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const xp=40,$p=2,Cp=16,Np=2,Up=80,Rp="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function Uv(e,t){const r=e.slice(2);if(r.length<$p||r.length>xp)throw new TypeError("Invalid program length for segwit address");const n=e[0]-Up;if(n<Np||n>Cp)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(Rp),Bv(r,n,t.bech32)}function Rv(e){const t=Po.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=qn(t,0),n=t.slice(1);return{version:r,hash:n}}function Bp(e){let t,r;try{t=_r.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=$o.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=_r.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function Bv(e,t,r){const n=_r.toWords(e);return n.unshift(t),t===0?_r.encode(r,n):$o.encode(r,n)}function Bo(e,t){t=t||nn;try{return Io({output:e,network:t}).address}catch{}try{return Ls({output:e,network:t}).address}catch{}try{return Co({output:e,network:t}).address}catch{}try{return No({output:e,network:t}).address}catch{}try{return Ro({output:e,network:t}).address}catch{}try{return Uv(e,t)}catch{}throw new Error(Hm(e)+" has no matching Address")}function Lp(e,t){t=t||nn;let r,n;try{r=Rv(e)}catch{}if(r){if(r.version===t.pubKeyHash)return Io({hash:r.hash}).output;if(r.version===t.scriptHash)return Ls({hash:r.hash}).output}else{try{n=Bp(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return Co({hash:n.data}).output;if(n.data.length===32)return No({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return Ro({pubkey:n.data}).output}else if(n.version>=Np&&n.version<=Cp&&n.data.length>=$p&&n.data.length<=xp)return console.warn(Rp),ur([n.version+Up,n.data])}}throw new Error(e+" has no matching Script")}function xn(e){const t=e.length;return Br(t)+t}function Lv(e){const t=e.length;return Br(t)+e.reduce((r,n)=>r+xn(n),0)}const Pi=new Uint8Array(0),Hp=[],Cl=zn("0000000000000000000000000000000000000000000000000000000000000000"),Kp=zn("0000000000000000000000000000000000000000000000000000000000000001"),Hv=zn("ffffffffffffffff"),Kv={script:Pi,valueBuffer:Hv};function jv(e){return e.value!==void 0}const an=class Qe{constructor(){we(this,"version",1),we(this,"locktime",0),we(this,"ins",[]),we(this,"outs",[])}static fromBuffer(t,r){const n=new Iv(t),i=new Qe;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===Qe.ADVANCED_TRANSACTION_MARKER&&s===Qe.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let h=0;h<u;++h)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:Hp});const f=n.readVarInt();for(let h=0;h<f;++h)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let h=0;h<u;++h)i.ins[h].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==t.length)throw new Error("Transaction has unexpected data");return i}static fromHex(t){return Qe.fromBuffer(zn(t),!1)}static isCoinbaseHash(t){at(Qd,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&Qe.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return at(In([Qd,Gn,yl(Ma(Gn)),yl(Ma(De))]),[t,r,n,i]),n==null&&(n=Qe.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||Pi,sequence:n,witness:Hp})-1}addOutput(t,r){return at(In([De,bl]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Br(this.ins.length)+Br(this.outs.length)+this.ins.reduce((n,i)=>n+40+xn(i.script),0)+this.outs.reduce((n,i)=>n+8+xn(i.script),0)+(r?this.ins.reduce((n,i)=>n+Lv(i.witness),0):0)}clone(){const t=new Qe;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(at(In([Gn,De,cr()]),[t,r,n]),t>=this.ins.length)return Kp;const i=ur(gt(r).filter(a=>a!==ze.OP_CODESEPARATOR)),o=this.clone();if((n&31)===Qe.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===Qe.SIGHASH_SINGLE){if(t>=this.outs.length)return Kp;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=Kv;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&Qe.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=Pi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Kd(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),os(s)}hashForWitnessV1(t,r,n,i,o,s){if(at(In([Gn,ar(De),ar(bl),Gn]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===Qe.SIGHASH_DEFAULT?Qe.SIGHASH_ALL:i&Qe.SIGHASH_OUTPUT_MASK,u=(i&Qe.SIGHASH_INPUT_MASK)===Qe.SIGHASH_ANYONECANPAY,f=a===Qe.SIGHASH_NONE,h=a===Qe.SIGHASH_SINGLE;let d=Pi,g=Pi,v=Pi,E=Pi,T=Pi;if(!u){let k=Vt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=Xt(k.end()),k=Vt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=Xt(k.end()),k=Vt.withCapacity(r.map(xn).reduce((B,z)=>B+z)),r.forEach(B=>k.writeVarSlice(B)),v=Xt(k.end()),k=Vt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=Xt(k.end())}if(f||h){if(h&&t<this.outs.length){const k=this.outs[t],B=Vt.withCapacity(8+xn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=Xt(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(z=>8+xn(z.script)).reduce((z,V)=>z+V),B=Vt.withCapacity(k);this.outs.forEach(z=>{B.writeInt64(z.value),B.writeVarSlice(z.script)}),T=Xt(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(f?32:0)+(s?32:0)+(o?37:0),O=Vt.withCapacity(N);if(O.writeUInt8(i),O.writeInt32(this.version),O.writeUInt32(this.locktime),O.writeSlice(d),O.writeSlice(g),O.writeSlice(v),O.writeSlice(E),f||h||O.writeSlice(T),O.writeUInt8(x),u){const k=this.ins[t];O.writeSlice(k.hash),O.writeUInt32(k.index),O.writeInt64(n[t]),O.writeVarSlice(r[t]),O.writeUInt32(k.sequence)}else O.writeUInt32(t);if(s){const k=Vt.withCapacity(xn(s));k.writeVarSlice(s),O.writeSlice(Xt(k.end()))}return h&&O.writeSlice(T),o&&(O.writeSlice(o),O.writeUInt8(0),O.writeUInt32(4294967295)),Ja("TapSighash",ot([Uint8Array.from([0]),O.end()]))}hashForWitnessV0(t,r,n,i){at(In([Gn,De,bl,Gn]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=Cl,u=Cl,f=Cl;if(i&Qe.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new Vt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=os(o)),!(i&Qe.SIGHASH_ANYONECANPAY)&&(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new Vt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),f=os(o)),(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+xn(v.script),0);o=new Uint8Array(d),s=new Vt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=os(o)}else if((i&31)===Qe.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+xn(d.script)),s=new Vt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=os(o)}o=new Uint8Array(156+xn(r)),s=new Vt(o,0);const h=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(f),s.writeSlice(h.hash),s.writeUInt32(h.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(h.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),os(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):os(this.__toBuffer(void 0,void 0,t))}getId(){return ve(Il(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return ve(this.toBuffer(void 0,void 0))}setInputScript(t,r){at(In([cr(),De]),[t,r]),this.ins[t].script=r}setWitness(t,r){at(In([cr(),ar(De)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new Vt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(Qe.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(Qe.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{jv(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};we(an,"DEFAULT_SEQUENCE",4294967295),we(an,"SIGHASH_DEFAULT",0),we(an,"SIGHASH_ALL",1),we(an,"SIGHASH_NONE",2),we(an,"SIGHASH_SINGLE",3),we(an,"SIGHASH_ANYONECANPAY",128),we(an,"SIGHASH_OUTPUT_MASK",3),we(an,"SIGHASH_INPUT_MASK",128),we(an,"ADVANCED_TRANSACTION_MARKER",0),we(an,"ADVANCED_TRANSACTION_FLAG",1);let At=an;var $n;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})($n||($n={}));var ie;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(ie||(ie={}));var St;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(St||(St={}));const Dv=e=>[...Array(e).keys()];function Mv(e){if(e.key[0]!==$n.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+ve(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+ve(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of Dv(e.value.length/4-1)){const i=Us(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function Fv(e){const t=new Uint8Array([$n.GLOBAL_XPUB]),r=ot([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),So(i,o,u,"LE"),o+=4}),{key:r,value:i}}const Vv="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function Wv(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function zv(e,t,r){const n=ve(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.extendedPubkey,t.extendedPubkey)).length===0)}const qv=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:zv,check:Wv,decode:Mv,encode:Fv,expected:Vv},Symbol.toStringTag,{value:"Module"}));function Gv(e){return{key:new Uint8Array([$n.UNSIGNED_TX]),value:e.toBuffer()}}const Xv=Object.freeze(Object.defineProperty({__proto__:null,encode:Gv},Symbol.toStringTag,{value:"Module"}));function Jv(e){if(e.key[0]!==ie.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+ve(e.key));return e.value}function Yv(e){return{key:new Uint8Array([ie.FINAL_SCRIPTSIG]),value:e}}const Zv="Uint8Array";function Qv(e){return e instanceof Uint8Array}function eE(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const tE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:eE,check:Qv,decode:Jv,encode:Yv,expected:Zv},Symbol.toStringTag,{value:"Module"}));function rE(e){if(e.key[0]!==ie.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+ve(e.key));return e.value}function nE(e){return{key:new Uint8Array([ie.FINAL_SCRIPTWITNESS]),value:e}}const iE="Uint8Array";function sE(e){return e instanceof Uint8Array}function oE(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const aE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:oE,check:sE,decode:rE,encode:nE,expected:iE},Symbol.toStringTag,{value:"Module"}));function cE(e){if(e.key[0]!==ie.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+ve(e.key));return e.value}function uE(e){return{key:new Uint8Array([ie.NON_WITNESS_UTXO]),value:e}}const lE="Uint8Array";function hE(e){return e instanceof Uint8Array}function fE(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const dE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:fE,check:hE,decode:cE,encode:uE,expected:lE},Symbol.toStringTag,{value:"Module"}));function pE(e){if(e.key[0]!==ie.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+ve(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+ve(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function yE(e){const t=new Uint8Array([ie.PARTIAL_SIG]);return{key:ot([t,e.pubkey]),value:e.signature}}const gE="{ pubkey: Uint8Array; signature: Uint8Array; }";function wE(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&bE(e.signature)}function bE(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function mE(e,t,r){const n=ve(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0).length===0)}const vE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:mE,check:wE,decode:pE,encode:yE,expected:gE},Symbol.toStringTag,{value:"Module"}));function EE(e){if(e.key[0]!==ie.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+ve(e.key));return dm(e.value)}function AE(e){return{key:new Uint8Array([ie.POR_COMMITMENT]),value:pm(e)}}const SE="string";function TE(e){return typeof e=="string"}function _E(e,t){return!!e&&!!t&&e.porCommitment===void 0}const kE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:_E,check:TE,decode:EE,encode:AE,expected:SE},Symbol.toStringTag,{value:"Module"}));function PE(e){if(e.key[0]!==ie.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+ve(e.key));return Number(Us(e.value,0,"LE"))}function IE(e){const t=Uint8Array.from([ie.SIGHASH_TYPE]),r=new Uint8Array(4);return So(r,0,e,"LE"),{key:t,value:r}}const OE="number";function xE(e){return typeof e=="number"}function $E(e,t){return!!e&&!!t&&e.sighashType===void 0}const CE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$E,check:xE,decode:PE,encode:IE,expected:OE},Symbol.toStringTag,{value:"Module"}));function NE(e){if(e.key[0]!==ie.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+ve(e.key));if(!jp(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function UE(e){return{key:Uint8Array.from([ie.TAP_KEY_SIG]),value:e}}const RE="Uint8Array";function jp(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function BE(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const LE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:BE,check:jp,decode:NE,encode:UE,expected:RE},Symbol.toStringTag,{value:"Module"}));function HE(e){if(e.key[0]!==ie.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+ve(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+ve(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+ve(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function KE(e){const t=Uint8Array.from([ie.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:ot([t,e.controlBlock]),value:ot([e.script,r])}}const jE="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function DE(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ME(e,t,r){const n=ve(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.controlBlock,t.controlBlock)===0).length===0)}const FE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ME,check:DE,decode:HE,encode:KE,expected:jE},Symbol.toStringTag,{value:"Module"}));function VE(e){if(e.key[0]!==ie.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+ve(e.key));if(!Dp(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function WE(e){return{key:Uint8Array.from([ie.TAP_MERKLE_ROOT]),value:e}}const zE="Uint8Array";function Dp(e){return e instanceof Uint8Array&&e.length===32}function qE(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const GE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:qE,check:Dp,decode:VE,encode:WE,expected:zE},Symbol.toStringTag,{value:"Module"}));function XE(e){if(e.key[0]!==ie.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+ve(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+ve(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+ve(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function JE(e){const t=Uint8Array.from([ie.TAP_SCRIPT_SIG]);return{key:ot([t,e.pubkey,e.leafHash]),value:e.signature}}const YE="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function ZE(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function QE(e,t,r){const n=ve(t.pubkey)+ve(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0&&Q(i.leafHash,t.leafHash)===0).length===0)}const eA=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:QE,check:ZE,decode:XE,encode:JE,expected:YE},Symbol.toStringTag,{value:"Module"}));function tA(e){if(e.key[0]!==ie.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+ve(e.key));const t=Dd(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=Ks(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function rA(e){const{script:t,value:r}=e,n=Br(t.length),i=new Uint8Array(8+n+t.length);return jd(i,0,BigInt(r),"LE"),ki(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([ie.WITNESS_UTXO]),value:i}}const nA="{ script: Uint8Array; value: bigint; }";function iA(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function sA(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const oA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:sA,check:iA,decode:tA,encode:rA,expected:nA},Symbol.toStringTag,{value:"Module"}));function aA(e){if(e.key[0]!==St.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+ve(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=Ks(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function cA(e){const t=Uint8Array.from([St.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),ki(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:ot(r)}}const uA="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function lA(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function hA(e,t){return!!e&&!!t&&e.tapTree===void 0}const fA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:hA,check:lA,decode:aA,encode:cA,expected:uA},Symbol.toStringTag,{value:"Module"})),dA=e=>[...Array(e).keys()],pA=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Nl(e,t=pA){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+ve(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+ve(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const f={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const h of dA(a.value.length/4-1)){const d=Us(a.value,h*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;f.path+="/"+v.toString(10)+(g?"'":"")}return f}function n(a){const u=Uint8Array.from([e]),f=ot([u,a.pubkey]),h=a.path.split("/"),d=new Uint8Array(h.length*4);d.set(a.masterFingerprint,0);let g=4;return h.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),So(d,g,T,"LE"),g+=4}),{key:f,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,f){const h=ve(u.pubkey);return f.has(h)?!1:(f.add(h),a.filter(d=>Q(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Ul(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+ve(r.key));return n}}function Mp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const yA=e=>e.length===32;function Fp(e){const t=Nl(e,yA);function r(s){const{numberValue:a,bytes:u}=Ks(s.value),f=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),h=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)h[d]=s.value.slice(g,g+32);return{...f,leafHashes:h}}function n(s){const a=t.encode(s),u=Br(s.leafHashes.length),f=new Uint8Array(u);ki(s.leafHashes.length,f);const h=ot([f,...s.leafHashes,a.value]);return{...a,value:h}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function Vp(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+ve(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function Wp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Rl={unsignedTx:Xv,globalXpub:qv,checkPubkey:Ul([])},Ct={nonWitnessUtxo:dE,partialSig:vE,sighashType:CE,finalScriptSig:tE,finalScriptWitness:aE,porCommitment:kE,witnessUtxo:oA,bip32Derivation:Nl(ie.BIP32_DERIVATION),redeemScript:Mp(ie.REDEEM_SCRIPT),witnessScript:Wp(ie.WITNESS_SCRIPT),checkPubkey:Ul([ie.PARTIAL_SIG,ie.BIP32_DERIVATION]),tapKeySig:LE,tapScriptSig:eA,tapLeafScript:FE,tapBip32Derivation:Fp(ie.TAP_BIP32_DERIVATION),tapInternalKey:Vp(ie.TAP_INTERNAL_KEY),tapMerkleRoot:GE},Qn={bip32Derivation:Nl(St.BIP32_DERIVATION),redeemScript:Mp(St.REDEEM_SCRIPT),witnessScript:Wp(St.WITNESS_SCRIPT),checkPubkey:Ul([St.BIP32_DERIVATION]),tapBip32Derivation:Fp(St.TAP_BIP32_DERIVATION),tapTree:fA,tapInternalKey:Vp(St.TAP_INTERNAL_KEY)},gA=Object.freeze(Object.defineProperty({__proto__:null,globals:Rl,inputs:Ct,outputs:Qn},Symbol.toStringTag,{value:"Module"})),tc=e=>[...Array(e).keys()];function zp(e){const t=e.map(wA);return t.push(Uint8Array.from([0])),ot(t)}function wA(e){const t=e.key.length,r=e.value.length,n=Br(t),i=Br(r),o=new Uint8Array(n+t+i+r);return ki(t,o,0),o.set(e.key,n),ki(r,o,n+t),o.set(e.value,n+t+i),o}function bA(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=Ks(e,r);r+=N;const O=e.slice(r,r+Number(x));return r+=Number(x),O}function i(){const x=Us(e,r,"BE");return r+=4,x}function o(){const x=qn(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=qn(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],f={};for(;!a();){const x=s(),N=ve(x.key);if(f[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);f[N]=1,u.push(x)}const h=u.filter(x=>x.key[0]===$n.UNSIGNED_TX);if(h.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(h[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of tc(g)){const N={},O=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,O.push(k)}E.push(O)}for(const x of tc(v)){const N={},O=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,O.push(k)}T.push(O)}return qp(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Wt(e,t,r){if(Q(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${ve(t)}`)}function qp(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const h of t)switch(h.key[0]){case $n.UNSIGNED_TX:if(Wt("global",h.key,$n.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case $n.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Rl.globalXpub.decode(h));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(h)}const s=r.length,a=n.length,u=[],f=[];for(const h of tc(s)){const d={};for(const g of r[h])switch(Ct.checkPubkey(g),g.key[0]){case ie.NON_WITNESS_UTXO:if(Wt("input",g.key,ie.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Ct.nonWitnessUtxo.decode(g);break;case ie.WITNESS_UTXO:if(Wt("input",g.key,ie.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Ct.witnessUtxo.decode(g);break;case ie.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Ct.partialSig.decode(g));break;case ie.SIGHASH_TYPE:if(Wt("input",g.key,ie.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Ct.sighashType.decode(g);break;case ie.REDEEM_SCRIPT:if(Wt("input",g.key,ie.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Ct.redeemScript.decode(g);break;case ie.WITNESS_SCRIPT:if(Wt("input",g.key,ie.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Ct.witnessScript.decode(g);break;case ie.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Ct.bip32Derivation.decode(g));break;case ie.FINAL_SCRIPTSIG:Wt("input",g.key,ie.FINAL_SCRIPTSIG),d.finalScriptSig=Ct.finalScriptSig.decode(g);break;case ie.FINAL_SCRIPTWITNESS:Wt("input",g.key,ie.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Ct.finalScriptWitness.decode(g);break;case ie.POR_COMMITMENT:Wt("input",g.key,ie.POR_COMMITMENT),d.porCommitment=Ct.porCommitment.decode(g);break;case ie.TAP_KEY_SIG:Wt("input",g.key,ie.TAP_KEY_SIG),d.tapKeySig=Ct.tapKeySig.decode(g);break;case ie.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Ct.tapScriptSig.decode(g));break;case ie.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Ct.tapLeafScript.decode(g));break;case ie.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Ct.tapBip32Derivation.decode(g));break;case ie.TAP_INTERNAL_KEY:Wt("input",g.key,ie.TAP_INTERNAL_KEY),d.tapInternalKey=Ct.tapInternalKey.decode(g);break;case ie.TAP_MERKLE_ROOT:Wt("input",g.key,ie.TAP_MERKLE_ROOT),d.tapMerkleRoot=Ct.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const h of tc(a)){const d={};for(const g of n[h])switch(Qn.checkPubkey(g),g.key[0]){case St.REDEEM_SCRIPT:if(Wt("output",g.key,St.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=Qn.redeemScript.decode(g);break;case St.WITNESS_SCRIPT:if(Wt("output",g.key,St.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=Qn.witnessScript.decode(g);break;case St.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Qn.bip32Derivation.decode(g));break;case St.TAP_INTERNAL_KEY:Wt("output",g.key,St.TAP_INTERNAL_KEY),d.tapInternalKey=Qn.tapInternalKey.decode(g);break;case St.TAP_TREE:Wt("output",g.key,St.TAP_TREE),d.tapTree=Qn.tapTree.decode(g);break;case St.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Qn.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}f.push(d)}return{globalMap:i,inputs:u,outputs:f}}function mA({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=Ll({globalMap:e,inputs:t,outputs:r}),s=zp(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(zp),u=a(i),f=a(o),h=new Uint8Array(5);return h.set([112,115,98,116,255],0),ot([h,s].concat(u,f))}const vA=(e,t)=>Q(e.key,t.key);function Bl(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const f=(Array.isArray(a)?a:[a]).map(u.encode);return f.map(h=>ve(h.key)).forEach(h=>{if(r.has(h))throw new Error("Serialize Error: Duplicate key: "+h);r.add(h)}),o.concat(f)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(ve(o.key))):[];return n.concat(i).sort(vA)}function Ll({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Bl(e,Rl),inputKeyVals:t.map(n=>Bl(n,Ct)),outputKeyVals:r.map(n=>Bl(n,Qn))}}function EA(e){const t=e[0],r=Ll(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Gp(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=js(r.globalKeyVals),s=r.inputKeyVals.map(js),a=r.outputKeyVals.map(js);for(const u of n){const f=Gp(u);if(f===void 0||Q(f.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const h=Ll(u);js(h.globalKeyVals).forEach(Hl(o,r.globalKeyVals,h.globalKeyVals)),h.inputKeyVals.map(js).forEach((d,g)=>d.forEach(Hl(s[g],r.inputKeyVals[g],h.inputKeyVals[g]))),h.outputKeyVals.map(js).forEach((d,g)=>d.forEach(Hl(a[g],r.outputKeyVals[g],h.outputKeyVals[g])))}return qp(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function Hl(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>ve(o.key)===n)[0];t.push(i),e.add(n)}}function Gp(e){return e.globalMap.unsignedTx}function js(e){const t=new Set;return e.forEach(r=>{const n=ve(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function Kt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function Lo(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Kl(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>Q(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${ve(e.key)}`)}function jl(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function AA(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function Xp(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Dl(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=gA[e+"s"][n]||{},f=!!s;if(a)if(f){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||Xp(e,n,u,i);const h=r[n]||[],d=new Set;if(!i.every(g=>s(h,g,d)))throw new Error("Can not add duplicate data to array");r[n]=h.concat(i)}else{if(a(i)||Xp(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const SA=Dl("global"),Jp=Dl("input"),Yp=Dl("output");function TA(e,t){const r=e.length-1,n=Kt(e,r);Jp(t,n)}function _A(e,t){const r=e.length-1,n=Lo(e,r);Yp(t,n)}let Zp=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,r){const n=Hd(t);return this.fromBuffer(n,r)}static fromHex(t,r){const n=zn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r){const n=bA(t,r),i=new this(n.globalMap.unsignedTx);return Object.assign(i,n),i}toBase64(){const t=this.toBuffer();return wm(t)}toHex(){const t=this.toBuffer();return ve(t)}toBuffer(){return mA(this)}updateGlobal(t){return SA(t,this.globalMap),this}updateInput(t,r){const n=Kt(this.inputs,t);return Jp(r,n),this}updateOutput(t,r){const n=Lo(this.outputs,t);return Yp(r,n),this}addUnknownKeyValToGlobal(t){return Kl(t,this.globalMap.unknownKeyVals,jl($n)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,r){const n=Kt(this.inputs,t);return Kl(r,n.unknownKeyVals,jl(ie)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addUnknownKeyValToOutput(t,r){const n=Lo(this.outputs,t);return Kl(r,n.unknownKeyVals,jl(St)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.inputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToInput(n,i)),TA(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.outputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToOutput(n,i)),_A(this.outputs,t),this}clearFinalizedInput(t){const r=Kt(this.inputs,t);AA(t,r);for(const n of Object.keys(r))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(n)||delete r[n];return this}combine(...t){const r=EA([this].concat(t));return Object.assign(this,r),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function as(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const kA=as(qa),PA=as(lp),IA=as(Io),rc=as(Co),Qp=as(No),e0=as(Ls),t0=as(Ro);function nc(e){let t=new Uint8Array(0);function r(s){t=ot([t,s])}function n(s){const a=t.length,u=Br(s);t=ot([t,new Uint8Array(u)]),ki(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function r0(e,t){const r=Jn(e),n=e.slice(1,33),i=gt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:Q(e,o)===0||Q(r,o)===0||Q(n,o)===0)}function ic(e,t){return r0(e,t)!==-1}function OA(e,t){return xA(e).some(r=>n0(r,ko.decode,t))}function n0(e,t,r){const{hashType:n}=t(e),i=[];switch(n&At.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case At.SIGHASH_ALL:break;case At.SIGHASH_SINGLE:case At.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function xA(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=$A(e)}else t=e.partialSig;return t.map(r=>r.signature)}function $A(e){const t=e.finalScriptSig?gt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?gt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&Xn(n)).map(n=>({signature:n}))}const sc=e=>e.length===32?e:e.slice(1,33);function i0(e,t,r){const n=WA(t,e,r);try{const i=FA(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:nc(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function oc(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return ot([e,r])}function cn(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&t0(e.witnessUtxo.script))}function Ml(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function s0(e,t,r){jA(e,t,r),MA(e,t,r)}function o0(e,t,r){DA(e,t,r),CA(e,t)}function CA(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=NA(r,n);if(i&&Q(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function NA(e,t){const r=t&&UA(t.leaves),{output:n}=Ro({internalPubkey:e,scriptTree:r});return n}function UA(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:KA(e)}function RA(e,t){return LA(e).some(r=>n0(r,BA,t))}function BA(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||At.SIGHASH_DEFAULT}}function LA(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=HA(e.finalScriptWitness);r&&t.push(r)}return t}function HA(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function KA(e){let t;for(const r of e)if(t=Fl(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function Fl(e,t,r=0){if(r>Ov)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(wl(t))return;const n=Fl(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=Fl(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function jA(e,t,r){const n=cn(e)&&Ds(t),i=Ds(e)&&cn(t),o=e===t&&cn(t)&&Ds(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function DA(e,t,r){const n=Ml(e)&&Ds(t),i=Ds(e)&&Ml(t),o=e===t&&Ml(t)&&Ds(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function MA(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Vl(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Vl(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Vl(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Vl(e,t){if(!t)return!0;const r=Zn({output:e.script,version:e.leafVersion}),n=Ol(e.controlBlock,r);return Q(n,t)===0}function FA(e,t){const r=Zn({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>Q(n.leafHash,r)===0).map(n=>VA(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function VA(e,t){return Object.assign({positionInScript:r0(t.pubkey,e)},t)}function WA(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>zA(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function zA(e,t,r){const n=Zn({output:e.script,version:e.leafVersion});return(!r||Q(n,r)===0)&&t.find(i=>Q(i.leafHash,n)===0)!==void 0}function Ds(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const qA={network:nn,maximumFeeRate:5e3};let Nt=class $d{constructor(t={},r=new Zp(new a0)){we(this,"data"),we(this,"__CACHE"),we(this,"opts"),this.data=r,this.opts=Object.assign({},qA,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Hd(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=zn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=Zp.fromBuffer(t,GA),i=new $d(r,n);return QA(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:kp(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=Bo(t.script,this.opts.network)}catch{}return{script:kp(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=$d.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){ac(t),this.opts.maximumFeeRate=t}setVersion(t){ac(t),Ho(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){ac(t),Ho(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){ac(r),Ho(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");s0(t,t,"addInput"),Ho(this.data.inputs,"addInput"),t.witnessScript&&lc(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];f0(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&ql(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");Ho(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=Lp(r,i);t=Object.assign({},t,{script:o})}o0(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(u0))throw new Error("Not finalized");const r=this.__CACHE;if(t||JA(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return T0(this.data.inputs,n,r,!0),n}getFeeRate(){return g0("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return g0("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return Kt(this.data.inputs,0),Ko(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=Kt(this.data.inputs,t);return cn(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=i0){const i=Kt(this.data.inputs,t);if(cn(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=e3){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=i3(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);YA(r);const{finalScriptSig:u,finalScriptWitness:f}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!u&&!f)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=i0){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=Ro({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=nc(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=Kt(this.data.inputs,t),n=_0(t,r,this.__CACHE),i=uc(n,t,"input",r.redeemScript||u3(r.finalScriptSig),r.witnessScript||l3(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=P0(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=Kt(this.data.inputs,t);return a3(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=Kt(this.data.inputs,t),i=l0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=Lo(this.data.outputs,t);return c3(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=Lo(this.data.outputs,t),i=l0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return Kt(this.data.inputs,0),Ko(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return cn(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>Q(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,f,h;for(const d of s){const g=ko.decode(d.signature),{hash:v,script:E}=h!==g.hashType?b0(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:f};h=g.hashType,u=v,f=E,h0(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&sc(n);const a=n?zl(t,i,this.data.inputs,n,this.__CACHE):r3(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(h=>!h.leafHash);let f=0;if(o&&u){if(!r(u.pubkey,u.hash,v0(o)))return!1;f++}if(s)for(const h of s){const d=a.find(g=>Q(g.pubkey,h.pubkey)===0);if(d){if(!r(h.pubkey,d.hash,v0(h.signature)))return!1;f++}}return f>0}signAllInputsHD(t,r=[At.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of Ko(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[At.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of Ko(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[At.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return A0(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[At.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=A0(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of Ko(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return cn(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(cn(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[At.SIGHASH_ALL]){const{hash:i,sighashType:o}=w0(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:ko.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[At.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(f=>!f.leafHash).map(f=>oc(n.signSchnorr(f.hash),r.sighashType))[0],u=s.filter(f=>!!f.leafHash).map(f=>({pubkey:sc(n.publicKey),signature:oc(n.signSchnorr(f.hash),r.sighashType),leafHash:f.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return cn(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(cn(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[At.SIGHASH_ALL]){const{hash:i,sighashType:o}=w0(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:ko.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[At.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(h=>!h.leafHash)[0];if(u){const h=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:oc(d,r.sighashType)}));a.push(h)}const f=s.filter(h=>!!h.leafHash);if(f.length){const h=f.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:sc(n.publicKey),signature:oc(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...h)}return Promise.all(a).then(h=>{h.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=zl(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${ve(n.publicKey)}`);return s}toBuffer(){return Wl(this.__CACHE),this.data.toBuffer()}toHex(){return Wl(this.__CACHE),this.data.toHex()}toBase64(){return Wl(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&lc(r.witnessScript),s0(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&ql(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return o0(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}};const GA=e=>new a0(e);let a0=class{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){we(this,"tx"),this.tx=At.fromBuffer(t),ZA(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?Il(zn(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}};function XA(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return c0(1,e.partialSig);case"multisig":const n=qa({output:t});return c0(n.m,e.partialSig,n.pubkeys);default:return!1}}function Wl(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function c0(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=h3(i);return t.find(s=>Q(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function u0(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function l0(e){return t=>!(Q(e.fingerprint,t.masterFingerprint)||Q(e.derivePath(t.path).publicKey,t.pubkey))}function ac(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function JA(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}function Ho(e,t){e.forEach(r=>{if(cn(r)?RA(r,t):OA(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function YA(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=ko.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function h0(e,t,r){if(!ic(e,t))throw new Error(`Can not ${r} for this input with the key ${ve(e)}`)}function ZA(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function QA(e,t){e.ins.forEach(r=>{f0(t,r)})}function f0(e,t){const r=ve(Il(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function d0(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(Q(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const p0=d0(Ls,"Redeem script"),y0=d0(No,"Witness script");function g0(e,t,r,n){if(!r.every(u0))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),T0(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function e3(e,t,r,n,i,o){const s=P0(r);if(!XA(t,r,s))throw new Error(`Can not finalize input #${e}`);return t3(r,s,t.partialSig,n,i,o)}function t3(e,t,r,n,i,o){let s,a;const u=n3(e,t,r),f=o?No({redeem:u}):null,h=i?Ls({redeem:f||u}):null;return n?(f?a=nc(f.witness):a=nc(u.witness),h&&(s=h.input)):h?s=h.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function w0(e,t,r,n,i){const o=Kt(e,t),{hash:s,sighashType:a,script:u}=b0(t,o,n,!1,i);return h0(r,u,"sign"),{hash:s,sighashType:a}}function b0(e,t,r,n,i){const o=r.__TX,s=t.sighashType||At.SIGHASH_ALL;E0(s,i);let a,u;if(t.nonWitnessUtxo){const d=cc(r,t,e),g=o.ins[e].hash,v=d.getHash();if(Q(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:f,type:h}=uc(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,f,u.value,s);else if(rc(f)){const d=Io({hash:f.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${ve(f)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&console.warn(`Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.
4
4
  *********************
5
5
  PROCEED WITH CAUTION!
6
- *********************`),a=o.hashForSignature(e,h,s)}return{script:h,sighashType:s,hash:a}}function r3(e,t,r,n){const i=[];if(t.tapInternalKey){const o=m0(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>zl(e,t,r,o,n)).flat()}function m0(e,t,r){const{script:n}=Gl(e,t,r);return t0(n)?n.subarray(2,34):null}function v0(e){return e.length===64?e:e.subarray(0,64)}function zl(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||At.SIGHASH_DEFAULT;E0(u,s);const h=r.map((E,T)=>Gl(T,E,i)),f=h.map(E=>E.script),d=h.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=m0(e,t,i)||Uint8Array.from([]);if(Q(sc(n),E)===0){const T=a.hashForWitnessV1(e,f,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>ic(n,E.script)).map(E=>{const T=Zn({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||Q(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,f,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function E0(e,t){if(t&&t.indexOf(e)<0){const r=o3(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function n3(e,t,r){let n;switch(t){case"multisig":const i=s3(e,r);n=qa({output:e,signatures:i});break;case"pubkey":n=lp({output:e,signature:r[0].signature});break;case"pubkeyhash":n=Oo({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=Co({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function i3(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=cc(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||rc(i.script))&&(i.isSegwit=!0),i}function A0(e,t,r){const n=Kt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(Q(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(Q(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function s3(e,t){return qa({output:e}).pubkeys.map(r=>(t.filter(n=>Q(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function S0(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=Ks(e,t);return t+=Br(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function o3(e){let t=e&At.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case At.SIGHASH_ALL:t+="SIGHASH_ALL";break;case At.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case At.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function ql(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=At.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function T0(e,t,r,n){let i=0n;e.forEach((u,h)=>{if(n&&u.finalScriptSig&&(t.ins[h].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[h].witness=S0(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const f=cc(r,u,h),d=t.ins[h].index,g=f.outs[d];i+=g.value}});const o=t.outs.reduce((u,h)=>u+h.value,0n),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(Number(s/BigInt(a)))}function cc(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||ql(e,t,r),n[r]}function _0(e,t,r){const{script:n}=Gl(e,t,r);return n}function Gl(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=cc(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function a3(e,t,r,n){const i=_0(r,t,n),{meaningfulScript:o}=uc(i,r,"input",t.redeemScript,t.witnessScript);return ic(e,o)}function c3(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=uc(i,r,"output",t.redeemScript,t.witnessScript);return ic(e,o)}function u3(e){if(!e)return;const t=gt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||k0(r)||h3(r)||!gt(r)))return r}function l3(e){if(!e)return;const t=S0(e),r=t[t.length-1];if(!(k0(r)||!gt(r)))return r}function f3(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function k0(e){return e.length===33&&jm(e)}function h3(e){return Xn(e)}function uc(e,t,r,n,i){const o=e0(e),s=o&&n&&Qp(n),a=Qp(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,p0(t,e,n,r),y0(t,n,i,r),lc(u)):a?(u=i,y0(t,e,i,r),lc(u)):o?(u=n,p0(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function lc(e){if(rc(e)||e0(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function P0(e){return rc(e)?"witnesspubkeyhash":OA(e)?"pubkeyhash":kA(e)?"multisig":PA(e)?"pubkey":"nonstandard"}function Ko(e){return[...Array(e).keys()]}const Lr=new Error("The connected wallet doesn't support this method..."),O0=new Error("Wallet is not installed");let Cn=class{constructor(t,r,n){we(this,"$store"),we(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),Lr}};const d3="Mainnet",fc="BITCOIN_MAINNET",Xl="BITCOIN_TESTNET",Jl="BITCOIN_TESTNET4",Yl="BITCOIN_SIGNET",Zl="FRACTAL_BITCOIN_MAINNET",Ql="FRACTAL_BITCOIN_TESTNET",p3="livenet",y3="testnet",hc="Mainnet",ef="Testnet",I0="Signet",x0="livenet",$0="testnet",jo="livenet",dc="testnet",tf="testnet4",rf="signet",nf="Mainnet",C0="Testnet",pc="mainnet",sf="testnet",tt="mainnet",Jt="signet",it="testnet",Yt="testnet4",cs="fractal mainnet",Zt="fractal testnet",g3="regtest",Ms=e=>e===tt?hc:e===it?ef:e===Jt?I0:hc,w3=e=>e===tt?pc:e===it?sf:pc,of=e=>e===tt?fc:e===it?Xl:e===Yt?Jl:e===Jt?Yl:e===cs?Zl:e===Zt?Ql:fc,b3=e=>e===tt?jo:e===it?dc:e===Yt?tf:e===Jt?rf:e===Zt?dc:jo,Do=e=>e===tt?nf:e===it?C0:nf,yc=e=>e===fc?tt:e===Xl?it:e===Jl?Yt:e===Yl?Jt:e===Zl?cs:e===Ql?Zt:tt,m3=e=>e===hc?tt:e===ef?it:tt,v3=e=>e===pc?tt:e===sf?it:tt,N0=e=>e===x0?tt:e===$0?it:tt,af=e=>e===jo?tt:e===dc?it:e===tf?Yt:e===rf?Jt:e===Zt?it:tt;function U0(e,t){return function(){return e.apply(t,arguments)}}const{toString:E3}=Object.prototype,{getPrototypeOf:cf}=Object,gc=(e=>t=>{const r=E3.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),un=e=>(e=e.toLowerCase(),t=>gc(t)===e),wc=e=>t=>typeof t===e,{isArray:Fs}=Array,Mo=wc("undefined");function A3(e){return e!==null&&!Mo(e)&&e.constructor!==null&&!Mo(e.constructor)&&kr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const R0=un("ArrayBuffer");function S3(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&R0(e.buffer),t}const T3=wc("string"),kr=wc("function"),B0=wc("number"),bc=e=>e!==null&&typeof e=="object",_3=e=>e===!0||e===!1,mc=e=>{if(gc(e)!=="object")return!1;const t=cf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},k3=un("Date"),P3=un("File"),O3=un("Blob"),I3=un("FileList"),x3=e=>bc(e)&&kr(e.pipe),$3=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||kr(e.append)&&((t=gc(e))==="formdata"||t==="object"&&kr(e.toString)&&e.toString()==="[object FormData]"))},C3=un("URLSearchParams"),[N3,U3,R3,B3]=["ReadableStream","Request","Response","Headers"].map(un),L3=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Fo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),Fs(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function L0(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const us=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,H0=e=>!Mo(e)&&e!==us;function uf(){const{caseless:e}=H0(this)&&this||{},t={},r=(n,i)=>{const o=e&&L0(t,i)||i;mc(t[o])&&mc(n)?t[o]=uf(t[o],n):mc(n)?t[o]=uf({},n):Fs(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Fo(arguments[n],r);return t}const H3=(e,t,r,{allOwnKeys:n}={})=>(Fo(t,(i,o)=>{r&&kr(i)?e[o]=U0(i,r):e[o]=i},{allOwnKeys:n}),e),K3=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),j3=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},D3=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&cf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},M3=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},F3=e=>{if(!e)return null;if(Fs(e))return e;let t=e.length;if(!B0(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},V3=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&cf(Uint8Array)),W3=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},z3=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},q3=un("HTMLFormElement"),G3=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),K0=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),X3=un("RegExp"),j0=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Fo(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},J3=e=>{j0(e,(t,r)=>{if(kr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(kr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Y3=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return Fs(e)?n(e):n(String(e).split(t)),r},Z3=()=>{},Q3=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,lf="abcdefghijklmnopqrstuvwxyz",D0="0123456789",M0={DIGIT:D0,ALPHA:lf,ALPHA_DIGIT:lf+lf.toUpperCase()+D0},e4=(e=16,t=M0.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function t4(e){return!!(e&&kr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const r4=e=>{const t=new Array(10),r=(n,i)=>{if(bc(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=Fs(n)?[]:{};return Fo(n,(s,a)=>{const u=r(s,i+1);!Mo(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},n4=un("AsyncFunction"),i4=e=>e&&(bc(e)||kr(e))&&kr(e.then)&&kr(e.catch),F0=((e,t)=>e?setImmediate:t?((r,n)=>(us.addEventListener("message",({source:i,data:o})=>{i===us&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),us.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",kr(us.postMessage)),s4=typeof queueMicrotask<"u"?queueMicrotask.bind(us):typeof process<"u"&&process.nextTick||F0,D={isArray:Fs,isArrayBuffer:R0,isBuffer:A3,isFormData:$3,isArrayBufferView:S3,isString:T3,isNumber:B0,isBoolean:_3,isObject:bc,isPlainObject:mc,isReadableStream:N3,isRequest:U3,isResponse:R3,isHeaders:B3,isUndefined:Mo,isDate:k3,isFile:P3,isBlob:O3,isRegExp:X3,isFunction:kr,isStream:x3,isURLSearchParams:C3,isTypedArray:V3,isFileList:I3,forEach:Fo,merge:uf,extend:H3,trim:L3,stripBOM:K3,inherits:j3,toFlatObject:D3,kindOf:gc,kindOfTest:un,endsWith:M3,toArray:F3,forEachEntry:W3,matchAll:z3,isHTMLForm:q3,hasOwnProperty:K0,hasOwnProp:K0,reduceDescriptors:j0,freezeMethods:J3,toObjectSet:Y3,toCamelCase:G3,noop:Z3,toFiniteNumber:Q3,findKey:L0,global:us,isContextDefined:H0,ALPHABET:M0,generateString:e4,isSpecCompliantForm:t4,toJSONObject:r4,isAsyncFn:n4,isThenable:i4,setImmediate:F0,asap:s4};function Ie(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}D.inherits(Ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:D.toJSONObject(this.config),code:this.code,status:this.status}}});const V0=Ie.prototype,W0={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{W0[e]={value:e}}),Object.defineProperties(Ie,W0),Object.defineProperty(V0,"isAxiosError",{value:!0}),Ie.from=(e,t,r,n,i,o)=>{const s=Object.create(V0);return D.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),Ie.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const o4=null;function ff(e){return D.isPlainObject(e)||D.isArray(e)}function z0(e){return D.endsWith(e,"[]")?e.slice(0,-2):e}function q0(e,t,r){return e?e.concat(t).map(function(n,i){return n=z0(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function a4(e){return D.isArray(e)&&!e.some(ff)}const c4=D.toFlatObject(D,{},null,function(e){return/^is[A-Z]/.test(e)});function vc(e,t,r){if(!D.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=D.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!D.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||h,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(D.isDate(v))return v.toISOString();if(!a&&D.isBlob(v))throw new Ie("Blob is not supported. Use a Buffer instead.");return D.isArrayBuffer(v)||D.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function h(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(D.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(D.isArray(v)&&a4(v)||(D.isFileList(v)||D.endsWith(E,"[]"))&&(x=D.toArray(v)))return E=z0(E),x.forEach(function(N,I){!(D.isUndefined(N)||N===null)&&t.append(s===!0?q0([E],I,o):s===null?E:E+"[]",u(N))}),!1}return ff(v)?!0:(t.append(q0(T,E,o),u(v)),!1)}const f=[],d=Object.assign(c4,{defaultVisitor:h,convertValue:u,isVisitable:ff});function g(v,E){if(!D.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(v),D.forEach(v,function(T,x){(!(D.isUndefined(T)||T===null)&&i.call(t,T,D.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),f.pop()}}if(!D.isObject(e))throw new TypeError("data must be an object");return g(e),t}function G0(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function hf(e,t){this._pairs=[],e&&vc(e,this,t)}const X0=hf.prototype;X0.append=function(e,t){this._pairs.push([e,t])},X0.toString=function(e){const t=e?function(r){return e.call(this,r,G0)}:G0;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function u4(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function J0(e,t,r){if(!t)return e;const n=r&&r.encode||u4,i=r&&r.serialize;let o;if(i?o=i(t,r):o=D.isURLSearchParams(t)?t.toString():new hf(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}let Y0=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){D.forEach(this.handlers,function(r){r!==null&&t(r)})}};const Z0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},l4=typeof URLSearchParams<"u"?URLSearchParams:hf,f4=typeof FormData<"u"?FormData:null,h4=typeof Blob<"u"?Blob:null,d4={isBrowser:!0,classes:{URLSearchParams:l4,FormData:f4,Blob:h4},protocols:["http","https","file","blob","url","data"]},df=typeof window<"u"&&typeof document<"u",pf=typeof navigator=="object"&&navigator||void 0,p4=df&&(!pf||["ReactNative","NativeScript","NS"].indexOf(pf.product)<0),y4=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",g4=df&&window.location.href||"http://localhost",w4=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:df,hasStandardBrowserEnv:p4,hasStandardBrowserWebWorkerEnv:y4,navigator:pf,origin:g4},Symbol.toStringTag,{value:"Module"})),lr={...w4,...d4};function b4(e,t){return vc(e,new lr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return lr.isNode&&D.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function m4(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function v4(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function Q0(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&D.isArray(i)?i.length:s,u?(D.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!D.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&D.isArray(i[s])&&(i[s]=v4(i[s])),!a)}if(D.isFormData(e)&&D.isFunction(e.entries)){const r={};return D.forEachEntry(e,(n,i)=>{t(m4(n),i,r,0)}),r}return null}function E4(e,t,r){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const Vo={transitional:Z0,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=D.isObject(e);if(i&&D.isHTMLForm(e)&&(e=new FormData(e)),D.isFormData(e))return n?JSON.stringify(Q0(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return b4(e,this.formSerializer).toString();if((o=D.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return vc(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),E4(e)):e}],transformResponse:[function(e){const t=this.transitional||Vo.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?Ie.from(o,Ie.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lr.classes.FormData,Blob:lr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};D.forEach(["delete","get","head","post","put","patch"],e=>{Vo.headers[e]={}});const A4=D.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),S4=e=>{const t={};let r,n,i;return e&&e.split(`
7
- `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&A4[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},ey=Symbol("internals");function Wo(e){return e&&String(e).trim().toLowerCase()}function Ec(e){return e===!1||e==null?e:D.isArray(e)?e.map(Ec):String(e)}function T4(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const _4=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function yf(e,t,r,n,i){if(D.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!D.isString(t)){if(D.isString(n))return t.indexOf(n)!==-1;if(D.isRegExp(n))return n.test(t)}}function k4(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function P4(e,t){const r=D.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class fr{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,h){const f=Wo(u);if(!f)throw new Error("header name must be a non-empty string");const d=D.findKey(i,f);(!d||i[d]===void 0||h===!0||h===void 0&&i[d]!==!1)&&(i[d||u]=Ec(a))}const s=(a,u)=>D.forEach(a,(h,f)=>o(h,f,u));if(D.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(D.isString(t)&&(t=t.trim())&&!_4(t))s(S4(t),r);else if(D.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Wo(t),t){const n=D.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return T4(i);if(D.isFunction(r))return r.call(this,i,n);if(D.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Wo(t),t){const n=D.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||yf(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Wo(s),s){const a=D.findKey(n,s);a&&(!r||yf(n,n[a],a,r))&&(delete n[a],i=!0)}}return D.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||yf(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return D.forEach(this,(i,o)=>{const s=D.findKey(n,o);if(s){r[s]=Ec(i),delete r[o];return}const a=t?k4(o):String(o).trim();a!==o&&delete r[o],r[a]=Ec(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return D.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&D.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
8
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[ey]=this[ey]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Wo(o);r[s]||(P4(n,o),r[s]=!0)}return D.isArray(t)?t.forEach(i):i(t),this}}fr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),D.reduceDescriptors(fr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),D.freezeMethods(fr);function gf(e,t){const r=this||Vo,n=t||r,i=fr.from(n.headers);let o=n.data;return D.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function ty(e){return!!(e&&e.__CANCEL__)}function Vs(e,t,r){Ie.call(this,e??"canceled",Ie.ERR_CANCELED,t,r),this.name="CanceledError"}D.inherits(Vs,Ie,{__CANCEL__:!0});function ry(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ie("Request failed with status code "+r.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function O4(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function I4(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),h=n[o];s||(s=u),r[i]=a,n[i]=u;let f=o,d=0;for(;f!==i;)d+=r[f++],f=f%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=h&&u-h;return g?Math.round(d*1e3/g):void 0}}function x4(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),h=u-r;h>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-h)))},()=>i&&s(i)]}const Ac=(e,t,r=3)=>{let n=0;const i=I4(50,250);return x4(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,h=i(u),f=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:h||void 0,estimated:h&&a&&f?(a-s)/h:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},ny=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},iy=e=>(...t)=>D.asap(()=>e(...t)),$4=lr.hasStandardBrowserEnv?function(){const e=lr.navigator&&/(msie|trident)/i.test(lr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=D.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),C4=lr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];D.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),D.isString(n)&&s.push("path="+n),D.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function N4(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function U4(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function sy(e,t){return e&&!N4(t)?U4(e,t):t}const oy=e=>e instanceof fr?{...e}:e;function ls(e,t){t=t||{};const r={};function n(h,f,d){return D.isPlainObject(h)&&D.isPlainObject(f)?D.merge.call({caseless:d},h,f):D.isPlainObject(f)?D.merge({},f):D.isArray(f)?f.slice():f}function i(h,f,d){if(D.isUndefined(f)){if(!D.isUndefined(h))return n(void 0,h,d)}else return n(h,f,d)}function o(h,f){if(!D.isUndefined(f))return n(void 0,f)}function s(h,f){if(D.isUndefined(f)){if(!D.isUndefined(h))return n(void 0,h)}else return n(void 0,f)}function a(h,f,d){if(d in t)return n(h,f);if(d in e)return n(void 0,h)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(h,f)=>i(oy(h),oy(f),!0)};return D.forEach(Object.keys(Object.assign({},e,t)),function(h){const f=u[h]||i,d=f(e[h],t[h],h);D.isUndefined(d)&&f!==a||(r[h]=d)}),r}const ay=e=>{const t=ls({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=fr.from(s),t.url=J0(sy(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(D.isFormData(r)){if(lr.hasStandardBrowserEnv||lr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[h,...f]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([h||"multipart/form-data",...f].join("; "))}}if(lr.hasStandardBrowserEnv&&(n&&D.isFunction(n)&&(n=n(t)),n||n!==!1&&$4(t.url))){const h=i&&o&&C4.read(o);h&&s.set(i,h)}return t},R4=typeof XMLHttpRequest<"u",B4=R4&&function(e){return new Promise(function(t,r){const n=ay(e);let i=n.data;const o=fr.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,h,f,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(h),n.signal&&n.signal.removeEventListener("abort",h)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const I=fr.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:I,config:e,request:T};ry(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new Ie("Request aborted",Ie.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new Ie("Network Error",Ie.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let I=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||Z0;n.timeoutErrorMessage&&(I=n.timeoutErrorMessage),r(new Ie(I,k.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&D.forEach(o.toJSON(),function(I,k){T.setRequestHeader(k,I)}),D.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ac(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([f,g]=Ac(a),T.upload.addEventListener("progress",f),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(h=I=>{T&&(r(!I||I.type?new Vs(null,e,T):I),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(h),n.signal&&(n.signal.aborted?h():n.signal.addEventListener("abort",h)));const N=O4(n.url);if(N&&lr.protocols.indexOf(N)===-1){r(new Ie("Unsupported protocol "+N+":",Ie.ERR_BAD_REQUEST,e));return}T.send(i||null)})},L4=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(h){if(!i){i=!0,a();const f=h instanceof Error?h:this.reason;n.abort(f instanceof Ie?f:new Vs(f instanceof Error?f.message:f))}};let s=t&&setTimeout(()=>{s=null,o(new Ie(`timeout ${t} of ms exceeded`,Ie.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(h=>{h.unsubscribe?h.unsubscribe(o):h.removeEventListener("abort",o)}),e=null)};e.forEach(h=>h.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>D.asap(a),u}},H4=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},K4=async function*(e,t){for await(const r of j4(e))yield*H4(r,t)},j4=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},cy=(e,t,r,n)=>{const i=K4(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:h,value:f}=await i.next();if(h){a(),u.close();return}let d=f.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(f))}catch(h){throw a(h),h}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Sc=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",uy=Sc&&typeof ReadableStream=="function",D4=Sc&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),ly=(e,...t)=>{try{return!!e(...t)}catch{return!1}},M4=uy&&ly(()=>{let e=!1;const t=new Request(lr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),fy=64*1024,wf=uy&&ly(()=>D.isReadableStream(new Response("").body)),Tc={stream:wf&&(e=>e.body)};Sc&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Tc[t]&&(Tc[t]=D.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new Ie(`Response type '${t}' is not supported`,Ie.ERR_NOT_SUPPORT,n)})})})(new Response);const F4=async e=>{if(e==null)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e))return(await new Request(lr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(D.isArrayBufferView(e)||D.isArrayBuffer(e))return e.byteLength;if(D.isURLSearchParams(e)&&(e=e+""),D.isString(e))return(await D4(e)).byteLength},V4=async(e,t)=>D.toFiniteNumber(e.getContentLength())??F4(t),W4=Sc&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:h,headers:f,withCredentials:d="same-origin",fetchOptions:g}=ay(e);h=h?(h+"").toLowerCase():"text";let v=L4([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&M4&&r!=="get"&&r!=="head"&&(x=await V4(f,n))!==0){let z=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(D.isFormData(n)&&(V=z.headers.get("content-type"))&&f.setContentType(V),z.body){const[Ue,He]=ny(x,Ac(iy(u)));n=cy(z.body,fy,Ue,He)}}D.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:f.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let I=await fetch(E);const k=wf&&(h==="stream"||h==="response");if(wf&&(a||k&&T)){const z={};["status","statusText","headers"].forEach(Ge=>{z[Ge]=I[Ge]});const V=D.toFiniteNumber(I.headers.get("content-length")),[Ue,He]=a&&ny(V,Ac(iy(a),!0))||[];I=new Response(cy(I.body,fy,Ue,()=>{He&&He(),T&&T()}),z)}h=h||"text";let B=await Tc[D.findKey(Tc,h)||"text"](I,e);return!k&&T&&T(),await new Promise((z,V)=>{ry(z,V,{data:B,headers:fr.from(I.headers),status:I.status,statusText:I.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,e,E),{cause:N.cause||N}):Ie.from(N,N&&N.code,e,E)}}),bf={http:o4,xhr:B4,fetch:W4};D.forEach(bf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const hy=e=>`- ${e}`,z4=e=>D.isFunction(e)||e===null||e===!1,dy={getAdapter:e=>{e=D.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!z4(r)&&(n=bf[(s=String(r)).toLowerCase()],n===void 0))throw new Ie(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
9
- `+o.map(hy).join(`
10
- `):" "+hy(o[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:bf};function mf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Vs(null,e)}function py(e){return mf(e),e.headers=fr.from(e.headers),e.data=gf.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),dy.getAdapter(e.adapter||Vo.adapter)(e).then(function(t){return mf(e),t.data=gf.call(e,e.transformResponse,t),t.headers=fr.from(t.headers),t},function(t){return ty(t)||(mf(e),t&&t.response&&(t.response.data=gf.call(e,e.transformResponse,t.response),t.response.headers=fr.from(t.response.headers))),Promise.reject(t)})}const yy="1.7.7",vf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{vf[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const gy={};vf.transitional=function(e,t,r){function n(i,o){return"[Axios v"+yy+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new Ie(n(o," has been removed"+(t?" in "+t:"")),Ie.ERR_DEPRECATED);return t&&!gy[o]&&(gy[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function q4(e,t,r){if(typeof e!="object")throw new Ie("options must be an object",Ie.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new Ie("option "+o+" must be "+u,Ie.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ie("Unknown option "+o,Ie.ERR_BAD_OPTION)}}const Ef={assertOptions:q4,validators:vf},Oi=Ef.validators;let fs=class{constructor(t){this.defaults=t,this.interceptors={request:new Y0,response:new Y0}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
11
- `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ls(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&Ef.assertOptions(n,{silentJSONParsing:Oi.transitional(Oi.boolean),forcedJSONParsing:Oi.transitional(Oi.boolean),clarifyTimeoutError:Oi.transitional(Oi.boolean)},!1),i!=null&&(D.isFunction(i)?r.paramsSerializer={serialize:i}:Ef.assertOptions(i,{encode:Oi.function,serialize:Oi.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&D.merge(o.common,o[r.method]);o&&D.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=fr.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const h=[];this.interceptors.response.forEach(function(E){h.push(E.fulfilled,E.rejected)});let f,d=0,g;if(!u){const E=[py.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,h),g=E.length,f=Promise.resolve(r);d<g;)f=f.then(E[d++],E[d++]);return f}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{f=py.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=h.length;d<g;)f=f.then(h[d++],h[d++]);return f}getUri(t){t=ls(this.defaults,t);const r=sy(t.baseURL,t.url);return J0(r,t.params,t.paramsSerializer)}};D.forEach(["delete","get","head","options"],function(e){fs.prototype[e]=function(t,r){return this.request(ls(r||{},{method:e,url:t,data:(r||{}).data}))}}),D.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(ls(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}fs.prototype[e]=t(),fs.prototype[e+"Form"]=t(!0)});let G4=class Jb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new Vs(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Jb(function(r){t=r}),cancel:t}}};function X4(e){return function(t){return e.apply(null,t)}}function J4(e){return D.isObject(e)&&e.isAxiosError===!0}const Af={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Af).forEach(([e,t])=>{Af[t]=e});function wy(e){const t=new fs(e),r=U0(fs.prototype.request,t);return D.extend(r,fs.prototype,t,{allOwnKeys:!0}),D.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return wy(ls(e,n))},r}const Xe=wy(Vo);Xe.Axios=fs,Xe.CanceledError=Vs,Xe.CancelToken=G4,Xe.isCancel=ty,Xe.VERSION=yy,Xe.toFormData=vc,Xe.AxiosError=Ie,Xe.Cancel=Xe.CanceledError,Xe.all=function(e){return Promise.all(e)},Xe.spread=X4,Xe.isAxiosError=J4,Xe.mergeConfig=ls,Xe.AxiosHeaders=fr,Xe.formToJSON=e=>Q0(D.isHTMLForm(e)?new FormData(e):e),Xe.getAdapter=dy.getAdapter,Xe.HttpStatusCode=Af,Xe.default=Xe;var by={},Ws={};Ws.byteLength=Q4,Ws.toByteArray=tS,Ws.fromByteArray=iS;for(var Nn=[],Hr=[],Y4=typeof Uint8Array<"u"?Uint8Array:Array,Sf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zs=0,Z4=Sf.length;zs<Z4;++zs)Nn[zs]=Sf[zs],Hr[Sf.charCodeAt(zs)]=zs;Hr[45]=62,Hr[95]=63;function my(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Q4(e){var t=my(e),r=t[0],n=t[1];return(r+n)*3/4-n}function eS(e,t,r){return(t+r)*3/4-r}function tS(e){var t,r=my(e),n=r[0],i=r[1],o=new Y4(eS(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Hr[e.charCodeAt(u)]<<18|Hr[e.charCodeAt(u+1)]<<12|Hr[e.charCodeAt(u+2)]<<6|Hr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Hr[e.charCodeAt(u)]<<2|Hr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Hr[e.charCodeAt(u)]<<10|Hr[e.charCodeAt(u+1)]<<4|Hr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function rS(e){return Nn[e>>18&63]+Nn[e>>12&63]+Nn[e>>6&63]+Nn[e&63]}function nS(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(rS(n));return i.join("")}function iS(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(nS(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Nn[t>>2]+Nn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Nn[t>>10]+Nn[t>>4&63]+Nn[t<<2&63]+"=")),i.join("")}var Tf={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Tf.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,h=u>>1,f=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-f)-1,v>>=-f,f+=a;f>0;o=o*256+e[t+d],d+=g,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=s*256+e[t+d],d+=g,f-=8);if(o===0)o=1-h;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-h}return(v?-1:1)*s*Math.pow(2,o-n)},Tf.write=function(e,t,r,n,i,o){var s,a,u,h=o*8-i-1,f=(1<<h)-1,d=f>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;e[r+v]=s&255,v+=E,s/=256,h-=8);e[r+v-E]|=T*128};/*!
6
+ *********************`),a=o.hashForSignature(e,f,s)}return{script:f,sighashType:s,hash:a}}function r3(e,t,r,n){const i=[];if(t.tapInternalKey){const o=m0(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>zl(e,t,r,o,n)).flat()}function m0(e,t,r){const{script:n}=Gl(e,t,r);return t0(n)?n.subarray(2,34):null}function v0(e){return e.length===64?e:e.subarray(0,64)}function zl(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||At.SIGHASH_DEFAULT;E0(u,s);const f=r.map((E,T)=>Gl(T,E,i)),h=f.map(E=>E.script),d=f.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=m0(e,t,i)||Uint8Array.from([]);if(Q(sc(n),E)===0){const T=a.hashForWitnessV1(e,h,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>ic(n,E.script)).map(E=>{const T=Zn({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||Q(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,h,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function E0(e,t){if(t&&t.indexOf(e)<0){const r=o3(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function n3(e,t,r){let n;switch(t){case"multisig":const i=s3(e,r);n=qa({output:e,signatures:i});break;case"pubkey":n=lp({output:e,signature:r[0].signature});break;case"pubkeyhash":n=Io({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=Co({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function i3(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=cc(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||rc(i.script))&&(i.isSegwit=!0),i}function A0(e,t,r){const n=Kt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(Q(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(Q(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function s3(e,t){return qa({output:e}).pubkeys.map(r=>(t.filter(n=>Q(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function S0(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=Ks(e,t);return t+=Br(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function o3(e){let t=e&At.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case At.SIGHASH_ALL:t+="SIGHASH_ALL";break;case At.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case At.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function ql(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=At.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function T0(e,t,r,n){let i=0n;e.forEach((u,f)=>{if(n&&u.finalScriptSig&&(t.ins[f].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[f].witness=S0(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const h=cc(r,u,f),d=t.ins[f].index,g=h.outs[d];i+=g.value}});const o=t.outs.reduce((u,f)=>u+f.value,0n),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(Number(s/BigInt(a)))}function cc(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||ql(e,t,r),n[r]}function _0(e,t,r){const{script:n}=Gl(e,t,r);return n}function Gl(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=cc(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function a3(e,t,r,n){const i=_0(r,t,n),{meaningfulScript:o}=uc(i,r,"input",t.redeemScript,t.witnessScript);return ic(e,o)}function c3(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=uc(i,r,"output",t.redeemScript,t.witnessScript);return ic(e,o)}function u3(e){if(!e)return;const t=gt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||k0(r)||f3(r)||!gt(r)))return r}function l3(e){if(!e)return;const t=S0(e),r=t[t.length-1];if(!(k0(r)||!gt(r)))return r}function h3(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function k0(e){return e.length===33&&jm(e)}function f3(e){return Xn(e)}function uc(e,t,r,n,i){const o=e0(e),s=o&&n&&Qp(n),a=Qp(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,p0(t,e,n,r),y0(t,n,i,r),lc(u)):a?(u=i,y0(t,e,i,r),lc(u)):o?(u=n,p0(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function lc(e){if(rc(e)||e0(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function P0(e){return rc(e)?"witnesspubkeyhash":IA(e)?"pubkeyhash":kA(e)?"multisig":PA(e)?"pubkey":"nonstandard"}function Ko(e){return[...Array(e).keys()]}const Lr=new Error("The connected wallet doesn't support this method..."),I0=new Error("Wallet is not installed");let Cn=class{constructor(t,r,n){we(this,"$store"),we(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),Lr}};const d3="Mainnet",hc="BITCOIN_MAINNET",Xl="BITCOIN_TESTNET",Jl="BITCOIN_TESTNET4",Yl="BITCOIN_SIGNET",Zl="FRACTAL_BITCOIN_MAINNET",Ql="FRACTAL_BITCOIN_TESTNET",p3="livenet",y3="testnet",fc="Mainnet",eh="Testnet",O0="Signet",x0="livenet",$0="testnet",jo="livenet",dc="testnet",th="testnet4",rh="signet",nh="Mainnet",C0="Testnet",pc="mainnet",ih="testnet",tt="mainnet",Jt="signet",it="testnet",Yt="testnet4",cs="fractal mainnet",Zt="fractal testnet",g3="regtest",Ms=e=>e===tt?fc:e===it?eh:e===Jt?O0:fc,w3=e=>e===tt?pc:e===it?ih:pc,sh=e=>e===tt?hc:e===it?Xl:e===Yt?Jl:e===Jt?Yl:e===cs?Zl:e===Zt?Ql:hc,b3=e=>e===tt?jo:e===it?dc:e===Yt?th:e===Jt?rh:e===Zt?dc:jo,Do=e=>e===tt?nh:e===it?C0:nh,yc=e=>e===hc?tt:e===Xl?it:e===Jl?Yt:e===Yl?Jt:e===Zl?cs:e===Ql?Zt:tt,m3=e=>e===fc?tt:e===eh?it:tt,v3=e=>e===pc?tt:e===ih?it:tt,N0=e=>e===x0?tt:e===$0?it:tt,oh=e=>e===jo?tt:e===dc?it:e===th?Yt:e===rh?Jt:e===Zt?it:tt;function U0(e,t){return function(){return e.apply(t,arguments)}}const{toString:E3}=Object.prototype,{getPrototypeOf:ah}=Object,gc=(e=>t=>{const r=E3.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),un=e=>(e=e.toLowerCase(),t=>gc(t)===e),wc=e=>t=>typeof t===e,{isArray:Fs}=Array,Mo=wc("undefined");function A3(e){return e!==null&&!Mo(e)&&e.constructor!==null&&!Mo(e.constructor)&&kr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const R0=un("ArrayBuffer");function S3(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&R0(e.buffer),t}const T3=wc("string"),kr=wc("function"),B0=wc("number"),bc=e=>e!==null&&typeof e=="object",_3=e=>e===!0||e===!1,mc=e=>{if(gc(e)!=="object")return!1;const t=ah(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},k3=un("Date"),P3=un("File"),I3=un("Blob"),O3=un("FileList"),x3=e=>bc(e)&&kr(e.pipe),$3=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||kr(e.append)&&((t=gc(e))==="formdata"||t==="object"&&kr(e.toString)&&e.toString()==="[object FormData]"))},C3=un("URLSearchParams"),[N3,U3,R3,B3]=["ReadableStream","Request","Response","Headers"].map(un),L3=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Fo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),Fs(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function L0(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const us=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,H0=e=>!Mo(e)&&e!==us;function ch(){const{caseless:e}=H0(this)&&this||{},t={},r=(n,i)=>{const o=e&&L0(t,i)||i;mc(t[o])&&mc(n)?t[o]=ch(t[o],n):mc(n)?t[o]=ch({},n):Fs(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Fo(arguments[n],r);return t}const H3=(e,t,r,{allOwnKeys:n}={})=>(Fo(t,(i,o)=>{r&&kr(i)?e[o]=U0(i,r):e[o]=i},{allOwnKeys:n}),e),K3=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),j3=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},D3=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&ah(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},M3=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},F3=e=>{if(!e)return null;if(Fs(e))return e;let t=e.length;if(!B0(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},V3=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ah(Uint8Array)),W3=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},z3=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},q3=un("HTMLFormElement"),G3=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),K0=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),X3=un("RegExp"),j0=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Fo(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},J3=e=>{j0(e,(t,r)=>{if(kr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(kr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Y3=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return Fs(e)?n(e):n(String(e).split(t)),r},Z3=()=>{},Q3=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,uh="abcdefghijklmnopqrstuvwxyz",D0="0123456789",M0={DIGIT:D0,ALPHA:uh,ALPHA_DIGIT:uh+uh.toUpperCase()+D0},e4=(e=16,t=M0.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function t4(e){return!!(e&&kr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const r4=e=>{const t=new Array(10),r=(n,i)=>{if(bc(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=Fs(n)?[]:{};return Fo(n,(s,a)=>{const u=r(s,i+1);!Mo(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},n4=un("AsyncFunction"),i4=e=>e&&(bc(e)||kr(e))&&kr(e.then)&&kr(e.catch),F0=((e,t)=>e?setImmediate:t?((r,n)=>(us.addEventListener("message",({source:i,data:o})=>{i===us&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),us.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",kr(us.postMessage)),s4=typeof queueMicrotask<"u"?queueMicrotask.bind(us):typeof process<"u"&&process.nextTick||F0,D={isArray:Fs,isArrayBuffer:R0,isBuffer:A3,isFormData:$3,isArrayBufferView:S3,isString:T3,isNumber:B0,isBoolean:_3,isObject:bc,isPlainObject:mc,isReadableStream:N3,isRequest:U3,isResponse:R3,isHeaders:B3,isUndefined:Mo,isDate:k3,isFile:P3,isBlob:I3,isRegExp:X3,isFunction:kr,isStream:x3,isURLSearchParams:C3,isTypedArray:V3,isFileList:O3,forEach:Fo,merge:ch,extend:H3,trim:L3,stripBOM:K3,inherits:j3,toFlatObject:D3,kindOf:gc,kindOfTest:un,endsWith:M3,toArray:F3,forEachEntry:W3,matchAll:z3,isHTMLForm:q3,hasOwnProperty:K0,hasOwnProp:K0,reduceDescriptors:j0,freezeMethods:J3,toObjectSet:Y3,toCamelCase:G3,noop:Z3,toFiniteNumber:Q3,findKey:L0,global:us,isContextDefined:H0,ALPHABET:M0,generateString:e4,isSpecCompliantForm:t4,toJSONObject:r4,isAsyncFn:n4,isThenable:i4,setImmediate:F0,asap:s4};function Oe(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}D.inherits(Oe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:D.toJSONObject(this.config),code:this.code,status:this.status}}});const V0=Oe.prototype,W0={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{W0[e]={value:e}}),Object.defineProperties(Oe,W0),Object.defineProperty(V0,"isAxiosError",{value:!0}),Oe.from=(e,t,r,n,i,o)=>{const s=Object.create(V0);return D.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),Oe.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const o4=null;function lh(e){return D.isPlainObject(e)||D.isArray(e)}function z0(e){return D.endsWith(e,"[]")?e.slice(0,-2):e}function q0(e,t,r){return e?e.concat(t).map(function(n,i){return n=z0(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function a4(e){return D.isArray(e)&&!e.some(lh)}const c4=D.toFlatObject(D,{},null,function(e){return/^is[A-Z]/.test(e)});function vc(e,t,r){if(!D.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=D.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!D.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||f,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(D.isDate(v))return v.toISOString();if(!a&&D.isBlob(v))throw new Oe("Blob is not supported. Use a Buffer instead.");return D.isArrayBuffer(v)||D.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(D.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(D.isArray(v)&&a4(v)||(D.isFileList(v)||D.endsWith(E,"[]"))&&(x=D.toArray(v)))return E=z0(E),x.forEach(function(N,O){!(D.isUndefined(N)||N===null)&&t.append(s===!0?q0([E],O,o):s===null?E:E+"[]",u(N))}),!1}return lh(v)?!0:(t.append(q0(T,E,o),u(v)),!1)}const h=[],d=Object.assign(c4,{defaultVisitor:f,convertValue:u,isVisitable:lh});function g(v,E){if(!D.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));h.push(v),D.forEach(v,function(T,x){(!(D.isUndefined(T)||T===null)&&i.call(t,T,D.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),h.pop()}}if(!D.isObject(e))throw new TypeError("data must be an object");return g(e),t}function G0(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function hh(e,t){this._pairs=[],e&&vc(e,this,t)}const X0=hh.prototype;X0.append=function(e,t){this._pairs.push([e,t])},X0.toString=function(e){const t=e?function(r){return e.call(this,r,G0)}:G0;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function u4(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function J0(e,t,r){if(!t)return e;const n=r&&r.encode||u4,i=r&&r.serialize;let o;if(i?o=i(t,r):o=D.isURLSearchParams(t)?t.toString():new hh(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}let Y0=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){D.forEach(this.handlers,function(r){r!==null&&t(r)})}};const Z0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},l4=typeof URLSearchParams<"u"?URLSearchParams:hh,h4=typeof FormData<"u"?FormData:null,f4=typeof Blob<"u"?Blob:null,d4={isBrowser:!0,classes:{URLSearchParams:l4,FormData:h4,Blob:f4},protocols:["http","https","file","blob","url","data"]},fh=typeof window<"u"&&typeof document<"u",dh=typeof navigator=="object"&&navigator||void 0,p4=fh&&(!dh||["ReactNative","NativeScript","NS"].indexOf(dh.product)<0),y4=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",g4=fh&&window.location.href||"http://localhost",w4=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:fh,hasStandardBrowserEnv:p4,hasStandardBrowserWebWorkerEnv:y4,navigator:dh,origin:g4},Symbol.toStringTag,{value:"Module"})),lr={...w4,...d4};function b4(e,t){return vc(e,new lr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return lr.isNode&&D.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function m4(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function v4(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function Q0(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&D.isArray(i)?i.length:s,u?(D.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!D.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&D.isArray(i[s])&&(i[s]=v4(i[s])),!a)}if(D.isFormData(e)&&D.isFunction(e.entries)){const r={};return D.forEachEntry(e,(n,i)=>{t(m4(n),i,r,0)}),r}return null}function E4(e,t,r){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const Vo={transitional:Z0,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=D.isObject(e);if(i&&D.isHTMLForm(e)&&(e=new FormData(e)),D.isFormData(e))return n?JSON.stringify(Q0(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return b4(e,this.formSerializer).toString();if((o=D.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return vc(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),E4(e)):e}],transformResponse:[function(e){const t=this.transitional||Vo.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?Oe.from(o,Oe.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lr.classes.FormData,Blob:lr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};D.forEach(["delete","get","head","post","put","patch"],e=>{Vo.headers[e]={}});const A4=D.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),S4=e=>{const t={};let r,n,i;return e&&e.split(`
7
+ `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&A4[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},ey=Symbol("internals");function Wo(e){return e&&String(e).trim().toLowerCase()}function Ec(e){return e===!1||e==null?e:D.isArray(e)?e.map(Ec):String(e)}function T4(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const _4=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ph(e,t,r,n,i){if(D.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!D.isString(t)){if(D.isString(n))return t.indexOf(n)!==-1;if(D.isRegExp(n))return n.test(t)}}function k4(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function P4(e,t){const r=D.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class hr{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,f){const h=Wo(u);if(!h)throw new Error("header name must be a non-empty string");const d=D.findKey(i,h);(!d||i[d]===void 0||f===!0||f===void 0&&i[d]!==!1)&&(i[d||u]=Ec(a))}const s=(a,u)=>D.forEach(a,(f,h)=>o(f,h,u));if(D.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(D.isString(t)&&(t=t.trim())&&!_4(t))s(S4(t),r);else if(D.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Wo(t),t){const n=D.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return T4(i);if(D.isFunction(r))return r.call(this,i,n);if(D.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Wo(t),t){const n=D.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||ph(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Wo(s),s){const a=D.findKey(n,s);a&&(!r||ph(n,n[a],a,r))&&(delete n[a],i=!0)}}return D.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||ph(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return D.forEach(this,(i,o)=>{const s=D.findKey(n,o);if(s){r[s]=Ec(i),delete r[o];return}const a=t?k4(o):String(o).trim();a!==o&&delete r[o],r[a]=Ec(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return D.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&D.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
8
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[ey]=this[ey]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Wo(o);r[s]||(P4(n,o),r[s]=!0)}return D.isArray(t)?t.forEach(i):i(t),this}}hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),D.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),D.freezeMethods(hr);function yh(e,t){const r=this||Vo,n=t||r,i=hr.from(n.headers);let o=n.data;return D.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function ty(e){return!!(e&&e.__CANCEL__)}function Vs(e,t,r){Oe.call(this,e??"canceled",Oe.ERR_CANCELED,t,r),this.name="CanceledError"}D.inherits(Vs,Oe,{__CANCEL__:!0});function ry(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Oe("Request failed with status code "+r.status,[Oe.ERR_BAD_REQUEST,Oe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function I4(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function O4(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),f=n[o];s||(s=u),r[i]=a,n[i]=u;let h=o,d=0;for(;h!==i;)d+=r[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(d*1e3/g):void 0}}function x4(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),f=u-r;f>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const Ac=(e,t,r=3)=>{let n=0;const i=O4(50,250);return x4(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,f=i(u),h=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:f||void 0,estimated:f&&a&&h?(a-s)/f:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},ny=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},iy=e=>(...t)=>D.asap(()=>e(...t)),$4=lr.hasStandardBrowserEnv?function(){const e=lr.navigator&&/(msie|trident)/i.test(lr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=D.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),C4=lr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];D.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),D.isString(n)&&s.push("path="+n),D.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function N4(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function U4(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function sy(e,t){return e&&!N4(t)?U4(e,t):t}const oy=e=>e instanceof hr?{...e}:e;function ls(e,t){t=t||{};const r={};function n(f,h,d){return D.isPlainObject(f)&&D.isPlainObject(h)?D.merge.call({caseless:d},f,h):D.isPlainObject(h)?D.merge({},h):D.isArray(h)?h.slice():h}function i(f,h,d){if(D.isUndefined(h)){if(!D.isUndefined(f))return n(void 0,f,d)}else return n(f,h,d)}function o(f,h){if(!D.isUndefined(h))return n(void 0,h)}function s(f,h){if(D.isUndefined(h)){if(!D.isUndefined(f))return n(void 0,f)}else return n(void 0,h)}function a(f,h,d){if(d in t)return n(f,h);if(d in e)return n(void 0,f)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(f,h)=>i(oy(f),oy(h),!0)};return D.forEach(Object.keys(Object.assign({},e,t)),function(f){const h=u[f]||i,d=h(e[f],t[f],f);D.isUndefined(d)&&h!==a||(r[f]=d)}),r}const ay=e=>{const t=ls({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=hr.from(s),t.url=J0(sy(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(D.isFormData(r)){if(lr.hasStandardBrowserEnv||lr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[f,...h]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(lr.hasStandardBrowserEnv&&(n&&D.isFunction(n)&&(n=n(t)),n||n!==!1&&$4(t.url))){const f=i&&o&&C4.read(o);f&&s.set(i,f)}return t},R4=typeof XMLHttpRequest<"u",B4=R4&&function(e){return new Promise(function(t,r){const n=ay(e);let i=n.data;const o=hr.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,f,h,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const O=hr.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:O,config:e,request:T};ry(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new Oe("Request aborted",Oe.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new Oe("Network Error",Oe.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let O=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||Z0;n.timeoutErrorMessage&&(O=n.timeoutErrorMessage),r(new Oe(O,k.clarifyTimeoutError?Oe.ETIMEDOUT:Oe.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&D.forEach(o.toJSON(),function(O,k){T.setRequestHeader(k,O)}),D.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ac(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([h,g]=Ac(a),T.upload.addEventListener("progress",h),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(f=O=>{T&&(r(!O||O.type?new Vs(null,e,T):O),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const N=I4(n.url);if(N&&lr.protocols.indexOf(N)===-1){r(new Oe("Unsupported protocol "+N+":",Oe.ERR_BAD_REQUEST,e));return}T.send(i||null)})},L4=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,a();const h=f instanceof Error?f:this.reason;n.abort(h instanceof Oe?h:new Vs(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,o(new Oe(`timeout ${t} of ms exceeded`,Oe.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>D.asap(a),u}},H4=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},K4=async function*(e,t){for await(const r of j4(e))yield*H4(r,t)},j4=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},cy=(e,t,r,n)=>{const i=K4(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:f,value:h}=await i.next();if(f){a(),u.close();return}let d=h.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(h))}catch(f){throw a(f),f}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Sc=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",uy=Sc&&typeof ReadableStream=="function",D4=Sc&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),ly=(e,...t)=>{try{return!!e(...t)}catch{return!1}},M4=uy&&ly(()=>{let e=!1;const t=new Request(lr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),hy=64*1024,gh=uy&&ly(()=>D.isReadableStream(new Response("").body)),Tc={stream:gh&&(e=>e.body)};Sc&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Tc[t]&&(Tc[t]=D.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new Oe(`Response type '${t}' is not supported`,Oe.ERR_NOT_SUPPORT,n)})})})(new Response);const F4=async e=>{if(e==null)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e))return(await new Request(lr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(D.isArrayBufferView(e)||D.isArrayBuffer(e))return e.byteLength;if(D.isURLSearchParams(e)&&(e=e+""),D.isString(e))return(await D4(e)).byteLength},V4=async(e,t)=>D.toFiniteNumber(e.getContentLength())??F4(t),W4=Sc&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:f,headers:h,withCredentials:d="same-origin",fetchOptions:g}=ay(e);f=f?(f+"").toLowerCase():"text";let v=L4([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&M4&&r!=="get"&&r!=="head"&&(x=await V4(h,n))!==0){let z=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(D.isFormData(n)&&(V=z.headers.get("content-type"))&&h.setContentType(V),z.body){const[Ue,He]=ny(x,Ac(iy(u)));n=cy(z.body,hy,Ue,He)}}D.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let O=await fetch(E);const k=gh&&(f==="stream"||f==="response");if(gh&&(a||k&&T)){const z={};["status","statusText","headers"].forEach(Ge=>{z[Ge]=O[Ge]});const V=D.toFiniteNumber(O.headers.get("content-length")),[Ue,He]=a&&ny(V,Ac(iy(a),!0))||[];O=new Response(cy(O.body,hy,Ue,()=>{He&&He(),T&&T()}),z)}f=f||"text";let B=await Tc[D.findKey(Tc,f)||"text"](O,e);return!k&&T&&T(),await new Promise((z,V)=>{ry(z,V,{data:B,headers:hr.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new Oe("Network Error",Oe.ERR_NETWORK,e,E),{cause:N.cause||N}):Oe.from(N,N&&N.code,e,E)}}),wh={http:o4,xhr:B4,fetch:W4};D.forEach(wh,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const fy=e=>`- ${e}`,z4=e=>D.isFunction(e)||e===null||e===!1,dy={getAdapter:e=>{e=D.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!z4(r)&&(n=wh[(s=String(r)).toLowerCase()],n===void 0))throw new Oe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
9
+ `+o.map(fy).join(`
10
+ `):" "+fy(o[0]):"as no adapter specified";throw new Oe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:wh};function bh(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Vs(null,e)}function py(e){return bh(e),e.headers=hr.from(e.headers),e.data=yh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),dy.getAdapter(e.adapter||Vo.adapter)(e).then(function(t){return bh(e),t.data=yh.call(e,e.transformResponse,t),t.headers=hr.from(t.headers),t},function(t){return ty(t)||(bh(e),t&&t.response&&(t.response.data=yh.call(e,e.transformResponse,t.response),t.response.headers=hr.from(t.response.headers))),Promise.reject(t)})}const yy="1.7.7",mh={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{mh[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const gy={};mh.transitional=function(e,t,r){function n(i,o){return"[Axios v"+yy+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new Oe(n(o," has been removed"+(t?" in "+t:"")),Oe.ERR_DEPRECATED);return t&&!gy[o]&&(gy[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function q4(e,t,r){if(typeof e!="object")throw new Oe("options must be an object",Oe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new Oe("option "+o+" must be "+u,Oe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Oe("Unknown option "+o,Oe.ERR_BAD_OPTION)}}const vh={assertOptions:q4,validators:mh},Ii=vh.validators;let hs=class{constructor(t){this.defaults=t,this.interceptors={request:new Y0,response:new Y0}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
11
+ `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ls(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&vh.assertOptions(n,{silentJSONParsing:Ii.transitional(Ii.boolean),forcedJSONParsing:Ii.transitional(Ii.boolean),clarifyTimeoutError:Ii.transitional(Ii.boolean)},!1),i!=null&&(D.isFunction(i)?r.paramsSerializer={serialize:i}:vh.assertOptions(i,{encode:Ii.function,serialize:Ii.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&D.merge(o.common,o[r.method]);o&&D.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=hr.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let h,d=0,g;if(!u){const E=[py.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,f),g=E.length,h=Promise.resolve(r);d<g;)h=h.then(E[d++],E[d++]);return h}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{h=py.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=f.length;d<g;)h=h.then(f[d++],f[d++]);return h}getUri(t){t=ls(this.defaults,t);const r=sy(t.baseURL,t.url);return J0(r,t.params,t.paramsSerializer)}};D.forEach(["delete","get","head","options"],function(e){hs.prototype[e]=function(t,r){return this.request(ls(r||{},{method:e,url:t,data:(r||{}).data}))}}),D.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(ls(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}hs.prototype[e]=t(),hs.prototype[e+"Form"]=t(!0)});let G4=class Jb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new Vs(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Jb(function(r){t=r}),cancel:t}}};function X4(e){return function(t){return e.apply(null,t)}}function J4(e){return D.isObject(e)&&e.isAxiosError===!0}const Eh={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Eh).forEach(([e,t])=>{Eh[t]=e});function wy(e){const t=new hs(e),r=U0(hs.prototype.request,t);return D.extend(r,hs.prototype,t,{allOwnKeys:!0}),D.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return wy(ls(e,n))},r}const Xe=wy(Vo);Xe.Axios=hs,Xe.CanceledError=Vs,Xe.CancelToken=G4,Xe.isCancel=ty,Xe.VERSION=yy,Xe.toFormData=vc,Xe.AxiosError=Oe,Xe.Cancel=Xe.CanceledError,Xe.all=function(e){return Promise.all(e)},Xe.spread=X4,Xe.isAxiosError=J4,Xe.mergeConfig=ls,Xe.AxiosHeaders=hr,Xe.formToJSON=e=>Q0(D.isHTMLForm(e)?new FormData(e):e),Xe.getAdapter=dy.getAdapter,Xe.HttpStatusCode=Eh,Xe.default=Xe;var by={},Ws={};Ws.byteLength=Q4,Ws.toByteArray=tS,Ws.fromByteArray=iS;for(var Nn=[],Hr=[],Y4=typeof Uint8Array<"u"?Uint8Array:Array,Ah="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zs=0,Z4=Ah.length;zs<Z4;++zs)Nn[zs]=Ah[zs],Hr[Ah.charCodeAt(zs)]=zs;Hr[45]=62,Hr[95]=63;function my(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Q4(e){var t=my(e),r=t[0],n=t[1];return(r+n)*3/4-n}function eS(e,t,r){return(t+r)*3/4-r}function tS(e){var t,r=my(e),n=r[0],i=r[1],o=new Y4(eS(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Hr[e.charCodeAt(u)]<<18|Hr[e.charCodeAt(u+1)]<<12|Hr[e.charCodeAt(u+2)]<<6|Hr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Hr[e.charCodeAt(u)]<<2|Hr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Hr[e.charCodeAt(u)]<<10|Hr[e.charCodeAt(u+1)]<<4|Hr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function rS(e){return Nn[e>>18&63]+Nn[e>>12&63]+Nn[e>>6&63]+Nn[e&63]}function nS(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(rS(n));return i.join("")}function iS(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(nS(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Nn[t>>2]+Nn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Nn[t>>10]+Nn[t>>4&63]+Nn[t<<2&63]+"=")),i.join("")}var Sh={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Sh.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,f=u>>1,h=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-h)-1,v>>=-h,h+=a;h>0;o=o*256+e[t+d],d+=g,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+d],d+=g,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(v?-1:1)*s*Math.pow(2,o-n)},Sh.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(1<<f)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+v]=s&255,v+=E,s/=256,f-=8);e[r+v-E]|=T*128};/*!
12
12
  * The buffer module from node.js, for the browser.
13
13
  *
14
14
  * @author Feross Aboukhadijeh <https://feross.org>
15
15
  * @license MIT
16
- */(function(e){const t=Ws,r=Tf,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(We(c,ArrayBuffer)||c&&We(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(We(c,SharedArrayBuffer)||c&&We(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function h(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function f(c,l,p){return h(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return f(c,l,p)};function d(c){return h(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(We(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||or(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),We(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(We(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||We(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ht(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return _n(c).length;default:if(S)return m?-1:Ht(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return vt(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function z(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)z(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)z(this,l,l+3),z(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)z(this,l,l+7),z(this,l+1,l+6),z(this,l+2,l+5),z(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,or(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function He(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(or(ce))return U;c[p+U]=ce}return U}function Ge(c,l,p,m){return Mt(Ht(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(_n(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return He(this,c,l,p);case"utf8":case"utf-8":return Ge(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function vt(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=yi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function H(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function Le(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return H(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return Le(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return H(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return Le(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function pt(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return pt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return pt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const Et={};function Lt(c,l,p){Et[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Lt("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Lt("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Lt("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&yt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new Et.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new Et.ERR_INVALID_ARG_TYPE(l,"number",c)}function yt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new Et.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new Et.ERR_BUFFER_OUT_OF_BOUNDS:new Et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Ht(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function _n(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function We(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function or(c){return c!==c}const yi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(by);const sS="https://mempool.space",oS="https://mempool.space/testnet",aS="https://mempool.space/testnet4",cS="https://mempool.space/signet",uS="https://mempool.fractalbitcoin.io",lS="https://mempool-testnet.fractalbitcoin.io",Ii=e=>e===it?oS:e===Yt?aS:e===Jt?cS:e===cs?uS:e===Zt?lS:sS;var ct={},_f={};const fS={},hS=Object.freeze(Object.defineProperty({__proto__:null,default:fS},Symbol.toStringTag,{value:"Module"})),vy=lv(hS);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=vy,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,h={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,L=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let W=H(b-K*w-q*_,y),X=H(-K*A-q*$,y);const Z=W>L,te=X>L;if(Z&&(W=y-W),te&&(X=y-X),W>L||X>L)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:W,k2neg:te,k2:X}}},f=32,d=32,g=32,v=f+1,E=2*f+1;function T(b){const{a:y,b:w}=a,A=H(b*b),_=H(A*b);return H(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y,q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q);return X===Z&&te===P}negate(){return new k(this.x,H(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=H(y*y),$=H(w*w),L=H($*$),K=y+$,q=H(i*(H(K*K)-_-L)),W=H(o*_),X=H(W*W),Z=H(X-i*q),te=H(W*(q-Z)-s*L),P=H(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y;if($===r||L===r)return this;if(w===r||A===r)return y;const q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q),j=H(Z-X),G=H(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=H(j*j),_e=H(j*ne),$e=H(X*ne),Pe=H(G*G-_e-i*$e),Oe=H(G*($e-Pe)-te*_e),Ze=H(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:L,k2:K}=h.splitScalar(A),q=w,W=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(W=W.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),L&&(W=W.negate()),W=new k(H(W.x*h.beta),W.y,W.z),q.add(W)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let L=0;L<w;L++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&z.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),z.set(w,_)));let $=k.ZERO,L=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),W=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&W);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?L=L.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:L}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:L,k1:K,k2neg:q,k2:W}=h.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(W,w);X=B(L,X),te=B(q,te),te=new k(H(te.x*h.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:L,f:K}=this.wNAF(A,w);_=L,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:pt(_));const L=y,K=H(L*L),q=H(K*L),W=H(w*K),X=H(A*q),Z=H(_*L);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(W,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const z=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,z.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!yt(A))throw new Error("Point is not on curve");const _=T(A);let $=Tn(_);const L=($&n)===n;w?L&&($=H(-$)):(y[0]&1)===1!==L&&($=H(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,f+1)),A=Ce(y.subarray(f+1,f*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===f)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const L=Lt(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,W=pt(q,K),X=H(-L*W,K),Z=H($*W,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!yt(w)||!yt(A))throw new Error(y);const _=H(A*A),$=T(w);if(H(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,H(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),L=k.fromAffine(y).multiplyUnsafe(A),K=$.add(L);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function He(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Ge(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=He(b.subarray(2)),{data:A,left:_}=He(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(vt(_.slice(0,64)),vt(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Ge(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,H(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),L=Ae(_);return`30${Ae(_+A+4)}02${L}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function vt(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return vt(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function H(b,y=a.P){const w=b%y;return w>=r?w:y+w}function Le(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Tn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),L=BigInt(44),K=BigInt(88),q=b*b*b%y,W=q*q*b%y,X=Le(W,o)*W%y,Z=Le(X,o)*W%y,te=Le(Z,i)*q%y,P=Le(te,A)*te%y,j=Le(P,_)*P%y,G=Le(j,L)*j%y,ne=Le(G,K)*G%y,_e=Le(ne,L)*j%y,$e=Le(_e,o)*W%y,Pe=Le($e,$)*P%y,Oe=Le(Pe,w)*q%y,Ze=Le(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function pt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=H(b,y),A=y,_=r,$=n;for(;w!==r;){const L=A/w,K=A%w,q=_-$*L;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return H(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,L,K)=>L===r?$:(w[K]=$,H($*L,y)),n),_=pt(A,y);return b.reduceRight(($,L,K)=>L===r?$:(w[K]=H($*w[K],y),H($*L,y)),_),w}function Et(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Lt(b,y=!1){const w=Et(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function yt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Lt(b,!0);if(!Ve($))return;const L=pt($,_),K=V.BASE.multiply($),q=H(K.x,_);if(q===r)return;const W=H(L*H(y+w*q,_),_);if(W===r)return;let X=new Fe(q,W),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=vt(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Ht(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function _n(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=_n;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function We(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Ht(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=We;function or(b){const y=b.length>f?b.slice(0,f):b;return Ce(y)}function yi(b){const y=or(b),w=H(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),yi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(f));const q=re(w);if(q.length!==f)throw new Error(`sign: Expected ${f} bytes of extra data`);$.push(q)}const L=Ye(...$),K=or(A);return{seed:L,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),L=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[L,A]:L}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);await L.reseed(A);let K;for(;!(K=Ar(await L.generate(),_,$,w.canonical));)await L.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);L.reseedSync(A);let K;for(;!(K=Ar(L.generateSync(),_,$,w.canonical));)L.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:L}=_;if(A.strict&&_.hasHighS())return!1;const K=Lt(y);let q;try{q=Ht(w)}catch{return!1}const{n:W}=a,X=pt(L,W),Z=H(K*X,W),te=H($*X,W),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?H(P.x,W)===$:!1}e.verify=S;function O(b){return H(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!yt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=H(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,H(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,L=this.initNonce(w,await $(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce(await $(kt.nonce,L,A,y)),X=O(await $(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return await rs(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,L=this.initNonce(w,$(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce($(kt.nonce,L,A,y)),X=O($(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Ht(w)}}function gi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),H(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function rs(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=O(await e.utils.taggedHash(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=O(e.utils.taggedHashSync(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:rs,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},kt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:H,invert:pt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=H(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(_f);var kf={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.isBytes=Ay,Kr.number=_c,Kr.bool=Ey,Kr.bytes=Pf,Kr.hash=Sy,Kr.exists=Ty,Kr.output=_y;function _c(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ey(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Ay(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Pf(e,...t){if(!Ay(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Sy(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_c(e.outputLen),_c(e.blockLen)}function Ty(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _y(e,t){Pf(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const dS={number:_c,bool:Ey,bytes:Pf,hash:Sy,exists:Ty,output:_y};Kr.default=dS;var zo={},kc={};Object.defineProperty(kc,"__esModule",{value:!0}),kc.crypto=void 0,kc.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=f,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=He,e.wrapConstructorWithOpts=Ge,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=kc,r=Kr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const h=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=h,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function f(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const vt=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(vt===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=vt*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class z{clone(){return this._cloneInto()}}e.Hash=z;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function He(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Ge(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(zo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Kr,r=zo;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 h=this.blockLen,f=new Uint8Array(h);f.set(u.length>h?s.create().update(u).digest():u);for(let d=0;d<f.length;d++)f[d]^=54;this.iHash.update(f),this.oHash=s.create();for(let d=0;d<f.length;d++)f[d]^=106;this.oHash.update(f),f.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:h,destroyed:f,blockLen:d,outputLen:g}=this;return s=s,s.finished=h,s.destroyed=f,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(kf);var Un={},xi={};Object.defineProperty(xi,"__esModule",{value:!0}),xi.HashMD=xi.Maj=xi.Chi=void 0;const Of=Kr,qo=zo;function pS(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,h=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+h,a,n)}const yS=(e,t,r)=>e&t^~e&r;xi.Chi=yS;const gS=(e,t,r)=>e&t^e&r^t&r;xi.Maj=gS;let wS=class extends qo.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,qo.createView)(this.buffer)}update(t){(0,Of.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,qo.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,qo.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Of.exists)(this),(0,Of.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;pS(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,qo.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=u/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<h;d++)a.setUint32(4*d,f[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};xi.HashMD=wS,Object.defineProperty(Un,"__esModule",{value:!0}),Un.sha224=Un.sha256=Un.SHA256=void 0;const If=xi,jr=zo,bS=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]),$i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ci=new Uint32Array(64);let xf=class extends If.HashMD{constructor(){super(64,32,8,!1),this.A=$i[0]|0,this.B=$i[1]|0,this.C=$i[2]|0,this.D=$i[3]|0,this.E=$i[4]|0,this.F=$i[5]|0,this.G=$i[6]|0,this.H=$i[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ci[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ci[d-15],v=Ci[d-2],E=(0,jr.rotr)(g,7)^(0,jr.rotr)(g,18)^g>>>3,T=(0,jr.rotr)(v,17)^(0,jr.rotr)(v,19)^v>>>10;Ci[d]=T+Ci[d-7]+E+Ci[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:h,H:f}=this;for(let d=0;d<64;d++){const g=(0,jr.rotr)(a,6)^(0,jr.rotr)(a,11)^(0,jr.rotr)(a,25),v=f+g+(0,If.Chi)(a,u,h)+bS[d]+Ci[d]|0,E=((0,jr.rotr)(n,2)^(0,jr.rotr)(n,13)^(0,jr.rotr)(n,22))+(0,If.Maj)(n,i,o)|0;f=h,h=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,h,f)}roundClean(){Ci.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Un.SHA256=xf;let mS=class extends xf{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}};Un.sha256=(0,jr.wrapConstructor)(()=>new xf),Un.sha224=(0,jr.wrapConstructor)(()=>new mS);var vS=_f,ES=kf,ky=Un;function AS(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Re=AS(vS);const Ni="Expected Private",Ui="Expected Point",Go="Expected Tweak",SS="Expected Hash",Pc="Expected Signature",$f="Expected Extra Data (32 bytes)",Xo="Expected Scalar",TS="Bad Recovery Id";Re.utils.hmacSha256Sync=(e,...t)=>ES.hmac(ky.sha256,e,Re.utils.concatBytes(...t)),Re.utils.sha256Sync=(...e)=>ky.sha256(Re.utils.concatBytes(...e));const Cf=Re.utils._normalizePrivateKey,_S=32,kS=32,Nf=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),PS=32,OS=new Uint8Array(32),IS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function xS(e){return e instanceof Uint8Array}function Jo(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Py(e){return Jo(e,OS)===0}function Yo(e){return!(!(e instanceof Uint8Array)||e.length!==kS||Jo(e,Nf)>=0)}function Uf(e){return e instanceof Uint8Array&&e.length===64&&Jo(e.subarray(0,32),Nf)<0&&Jo(e.subarray(32,64),Nf)<0}function $S(e){return xS(e)&&e.length===64&&Jo(e.subarray(0,32),IS)<0}function CS(e){return!(Py(e.subarray(0,32))||Py(e.subarray(32,64)))}function qs(e){return e instanceof Uint8Array&&e.length===_S}function Rf(e){return e===void 0||e instanceof Uint8Array&&e.length===PS}function Oy(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function NS(e){return Oy(Re.utils.bytesToHex(e))}function Bf(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=Oy(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=NS(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const US=(e,t)=>{const r=Cf(e),n=Bf(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r+n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},RS=(e,t)=>{const r=Cf(e),n=Bf(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r-n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},BS=e=>{const t=Cf(e),r=Re.utils._bigintTo32Bytes(Re.CURVE.n-t);return Re.utils.isValidPrivateKey(r)?r:null},Iy=(e,t,r)=>{const n=Re.Point.fromHex(e),i=Bf(t),o=Re.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},LS=(e,t,r)=>{const n=Re.Point.fromHex(e),i=typeof t=="string"?t:Re.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function Gs(e,t){return e===void 0?t!==void 0?xy(t):!0:!!e}function hs(e){try{return e()}catch{return null}}function Lf(e,t){if(e.length===32!==t)return!1;try{return!!Re.Point.fromHex(e)}catch{return!1}}function Ri(e){return Lf(e,!1)}function xy(e){return Lf(e,!1)&&e.length===33}function ei(e){return Re.utils.isValidPrivateKey(e)}function Oc(e){return Lf(e,!0)}function HS(e,t){if(!Oc(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return hs(()=>{const r=Iy(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function $y(e){if(!Ri(e))throw new Error(Ui);return e.slice(1,33)}function Cy(e,t){if(!ei(e))throw new Error(Ni);return hs(()=>Re.getPublicKey(e,Gs(t)))}function KS(e){if(!ei(e))throw new Error(Ni);return $y(Cy(e))}function jS(e,t){if(!Ri(e))throw new Error(Ui);return Re.Point.fromHex(e).toRawBytes(Gs(t,e))}function DS(e,t,r){if(!Ri(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return hs(()=>LS(e,t,Gs(r,e)))}function MS(e,t,r){if(!Ri(e)||!Ri(t))throw new Error(Ui);return hs(()=>{const n=Re.Point.fromHex(e),i=Re.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(Gs(r,e))})}function FS(e,t,r){if(!Ri(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return hs(()=>Iy(e,t,Gs(r,e)))}function VS(e,t){if(ei(e)===!1)throw new Error(Ni);if(Yo(t)===!1)throw new Error(Go);return hs(()=>US(e,t))}function WS(e,t){if(ei(e)===!1)throw new Error(Ni);if(Yo(t)===!1)throw new Error(Go);return hs(()=>RS(e,t))}function zS(e){if(ei(e)===!1)throw new Error(Ni);return BS(e)}function qS(e,t,r){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Rf(r))throw new Error($f);return Re.signSync(e,t,{der:!1,extraEntropy:r})}function GS(e,t,r){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Rf(r))throw new Error($f);const[n,i]=Re.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function XS(e,t,r=Buffer.alloc(32,0)){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Rf(r))throw new Error($f);return Re.schnorr.signSync(e,t,r)}function JS(e,t,r,n){if(!qs(e))throw new Error(SS);if(!Uf(t)||!CS(t))throw new Error(Pc);if(r&2&&!$S(t))throw new Error(TS);if(!Oc(t.subarray(0,32)))throw new Error(Pc);return Re.recoverPublicKey(e,t,r,Gs(n))}function YS(e,t,r,n){if(!Ri(t))throw new Error(Ui);if(!Uf(r))throw new Error(Pc);if(!qs(e))throw new Error(Xo);return Re.verify(r,e,t,{strict:n})}function ZS(e,t,r){if(!Oc(t))throw new Error(Ui);if(!Uf(r))throw new Error(Pc);if(!qs(e))throw new Error(Xo);return Re.schnorr.verifySync(r,e,t)}var QS=ct.isPoint=Ri,e8=ct.isPointCompressed=xy,t8=ct.isPrivate=ei,r8=ct.isXOnlyPoint=Oc,n8=ct.pointAdd=MS,i8=ct.pointAddScalar=FS,s8=ct.pointCompress=jS,o8=ct.pointFromScalar=Cy,a8=ct.pointMultiply=DS,c8=ct.privateAdd=VS,u8=ct.privateNegate=zS,l8=ct.privateSub=WS,f8=ct.recover=JS,h8=ct.sign=qS,d8=ct.signRecoverable=GS,p8=ct.signSchnorr=XS,y8=ct.verify=YS,g8=ct.verifySchnorr=ZS,w8=ct.xOnlyPointAddTweak=HS,b8=ct.xOnlyPointFromPoint=$y,m8=ct.xOnlyPointFromScalar=KS;yv(Qb({__proto__:null,default:ct,isPoint:QS,isPointCompressed:e8,isPrivate:t8,isXOnlyPoint:r8,pointAdd:n8,pointAddScalar:i8,pointCompress:s8,pointFromScalar:o8,pointMultiply:a8,privateAdd:c8,privateNegate:u8,privateSub:l8,recover:f8,sign:h8,signRecoverable:d8,signSchnorr:p8,verify:y8,verifySchnorr:g8,xOnlyPointAddTweak:w8,xOnlyPointFromPoint:b8,xOnlyPointFromScalar:m8},[ct]));const Qt=e=>e===it||e===Yt||e===Jt?um:nn,Hf=e=>e.find(({purpose:t})=>t==="ordinals"),Kf=e=>e.find(({purpose:t})=>t==="payment"),er=async(e,t)=>{try{const r=await Ny(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},v8=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),E8=e=>/^[a-fA-F0-9]+$/.test(e);function A8(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function Ny(e,t){if(e.startsWith("t")){if(t===tt)return[];if(t===cs)return[];if(t===Zt)return[]}return await Xe.get(`${Ii(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function Uy(e,t,r,n,i,o,s=7){const a=e===t,u=await Ny(t,o);if(!u)throw new Error("No UTXOs found");const h=u.sort((T,x)=>x.value-T.value),f=new Nt({network:Qt(o)}),d=A8(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of h){const{txid:x,vout:N,value:I}=T,k=Lp(t,Qt(o));if(f.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=S8(i,o);f.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return f.addOutput({address:r,value:BigInt(n)}),v>g&&f.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:f.toBase64(),psbtHex:f.toHex()}}function S8(e,t){var r;const n=Co({pubkey:by.Buffer.from(e,"hex"),network:Qt(t)}),i=Ls({redeem:n,network:Qt(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}let T8=class extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Vn]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{if(t.provider!==Vn){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Vn):this.parent.disconnect())}handleNetworkChanged(t){const r=yc(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Vn)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Vn),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),er(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?yc(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=Nt.fromHex(a);if(i&&o){const h=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Ii(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=of(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}};function _8(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function k8(){return{$store:Nd({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[Vn]:!1,[Pn]:!1,[bi]:!1,[Wn]:!1,[Ud]:!1,[ns]:!1,[vi]:!1,[mi]:!1,[is]:!1,[Ei]:!1}}),$network:fl(tt),$library:fl(void 0)}}function P8({network:e}){return{network:e}}function c9(e){}function u9(e){}function O8(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Ic(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function hr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Ic(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},h=e.kind==="schema",f=(i==null?void 0:i.message)??e.message??O8(e.reference,u.lang)??(h?(u.lang,void 0):null)??n.message??(u.lang,void 0);f&&(u.message=typeof f=="function"?f(u):f),h&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function I8(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Ry(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function By(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function ln(e,t){return{kind:"schema",type:"array",reference:ln,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const h={type:"array",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else hr(this,"type",r,n);return r}}}function Ly(e){return{kind:"schema",type:"boolean",reference:Ly,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:hr(this,"type",t,r),t}}}function ds(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:ds,expects:r.map(Ic).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:hr(this,"type",n,i),n}}}function ut(e,t){return{kind:"schema",type:"literal",reference:ut,expects:Ic(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:hr(this,"type",r,n),r}}}function Hy(e,t){return{kind:"schema",type:"loose_object",reference:Hy,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"object",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)I8(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else hr(this,"type",r,n);return r}}}function jf(e,t){return{kind:"schema",type:"non_optional",reference:jf,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(hr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function ps(e){return{kind:"schema",type:"null",reference:ps,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:hr(this,"type",t,r),t}}}function ys(e,...t){const r={kind:"schema",type:"nullish",reference:ys,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=Ry(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Rn(e){return{kind:"schema",type:"number",reference:Rn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:hr(this,"type",t,r),t}}}function fe(e,t){return{kind:"schema",type:"object",reference:fe,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"object",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else hr(this,"type",r,n);return r}}}function fn(e,...t){const r={kind:"schema",type:"optional",reference:fn,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=Ry(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Ky(e,t){return{kind:"schema",type:"picklist",reference:Ky,expects:e.map(Ic).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:hr(this,"type",r,n),r}}}function pe(e){return{kind:"schema",type:"string",reference:pe,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:hr(this,"type",t,r),t}}}function Df(e){return{kind:"schema",type:"undefined",reference:Df,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:hr(this,"type",t,r),t}}}function jy(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function xc(e,t){return{kind:"schema",type:"union",reference:xc,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];hr(this,"type",r,n,{issues:jy(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];hr(this,"type",r,n,{issues:jy(s)})}return r}}}function $c(){return{kind:"schema",type:"unknown",reference:$c,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Dr={},Xs={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.decode=tr.encode=tr.unescape=tr.escape=tr.pad=void 0;const Dy=Ws;function Mf(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}tr.pad=Mf;function My(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}tr.escape=My;function Fy(e){return Mf(e).replace(/-/g,"+").replace(/_/g,"/")}tr.unescape=Fy;function x8(e){return My((0,Dy.fromByteArray)(new TextEncoder().encode(e)))}tr.encode=x8;function $8(e){return new TextDecoder().decode((0,Dy.toByteArray)(Mf(Fy(e))))}tr.decode=$8;var Cc={},Nc={},Js={};Object.defineProperty(Js,"__esModule",{value:!0}),Js.joseToDer=Js.derToJose=void 0;const Vy=Ws,Wy=tr;function Ff(e){return(e/8|0)+(e%8===0?0:1)}const C8={ES256:Ff(256),ES384:Ff(384),ES512:Ff(521)};function zy(e){const t=C8[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Uc=128,qy=0,N8=32,U8=16,R8=2,Gy=U8|N8|qy<<6,Rc=R8|qy<<6;function Xy(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Vy.toByteArray)((0,Wy.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function B8(e,t){const r=Xy(e),n=zy(t),i=n+1,o=r.length;let s=0;if(r[s++]!==Gy)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Uc|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Rc)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const h=s;if(s+=u,r[s++]!==Rc)throw new Error('Could not find expected "int" for "s"');const f=r[s++];if(o-s!==f)throw new Error(`"s" specified length of "${f}", expected "${o-s}"`);if(i<f)throw new Error(`"s" specified length of "${f}", max of "${i}" is acceptable`);const d=s;if(s+=f,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-f,E=new Uint8Array(g+u+v+f);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(h+Math.max(-g,0),h+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+f),s),(0,Wy.escape)((0,Vy.fromByteArray)(E))}Js.derToJose=B8;function Jy(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Uc&&--n,n}function L8(e,t){e=Xy(e);const r=zy(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=Jy(e,0,r),o=Jy(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,h=u<Uc,f=new Uint8Array((h?2:3)+u);let d=0;return f[d++]=Gy,h?f[d++]=u:(f[d++]=Uc|1,f[d++]=u&255),f[d++]=Rc,f[d++]=s,i<0?(f[d++]=0,f.set(e.subarray(0,r),d),d+=r):(f.set(e.subarray(i,r),d),d+=r-i),f[d++]=Rc,f[d++]=a,o<0?(f[d++]=0,f.set(e.subarray(r),d)):f.set(e.subarray(r+o),d),f}Js.joseToDer=L8;var ti={};Object.defineProperty(ti,"__esModule",{value:!0}),ti.InvalidTokenError=ti.MissingParametersError=void 0;class H8 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}ti.MissingParametersError=H8;class K8 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}ti.InvalidTokenError=K8,Object.defineProperty(Nc,"__esModule",{value:!0}),Nc.SECP256K1Client=void 0;const j8=kf,D8=Un,Bc=_f,Yy=Js,Zy=ti,Qy=zo;Bc.utils.hmacSha256Sync=(e,...t)=>{const r=j8.hmac.create(D8.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};let eg=class{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,Qy.bytesToHex)(Bc.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new Zy.MissingParametersError("a signing input hash and private key are all required");const i=Bc.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,Qy.bytesToHex)(i);if(n==="jose")return(0,Yy.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,Yy.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new Zy.MissingParametersError("a signing input hash, der signature, and public key are all required");return Bc.verify(r,t,n,{strict:!1})}};Nc.SECP256K1Client=eg,eg.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Nc;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Cc);var gs={},M8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(f){try{h(n.next(f))}catch(d){s(d)}}function u(f){try{h(n.throw(f))}catch(d){s(d)}}function h(f){f.done?o(f.value):i(f.value).then(a,u)}h((n=n.apply(e,t||[])).next())})};Object.defineProperty(gs,"__esModule",{value:!0}),gs.hashSha256Async=gs.hashSha256=void 0;const F8=Un;function tg(e){return(0,F8.sha256)(e)}gs.hashSha256=tg;function V8(e){return M8(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=vy;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(tg(e))}})}gs.hashSha256Async=V8;var W8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(f){try{h(n.next(f))}catch(d){s(d)}}function u(f){try{h(n.throw(f))}catch(d){s(d)}}function h(f){f.done?o(f.value):i(f.value).then(a,u)}h((n=n.apply(e,t||[])).next())})};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.TokenSigner=Xs.createUnsecuredToken=void 0;const Vf=tr,rg=Cc,z8=ti,ng=gs;function Wf(e,t){const r=[],n=Vf.encode(JSON.stringify(t));r.push(n);const i=Vf.encode(JSON.stringify(e));return r.push(i),r.join(".")}function q8(e){return Wf(e,{typ:"JWT",alg:"none"})+"."}Xs.createUnsecuredToken=q8;class G8{constructor(t,r){if(!(t&&r))throw new z8.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!rg.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=rg.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=Wf(t,i),s=(0,ng.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return W8(this,void 0,void 0,function*(){const i=this.header(n),o=Wf(t,i),s=yield(0,ng.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Vf.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}Xs.TokenSigner=G8;var Lc={};Object.defineProperty(Lc,"__esModule",{value:!0}),Lc.TokenVerifier=void 0;const X8=tr,ig=Cc,J8=ti,Hc=gs;class Y8{constructor(t,r){if(!(t&&r))throw new J8.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!ig.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=ig.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Hc.hashSha256Async)(i).then(s=>o(s));{const s=(0,Hc.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),X8.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Hc.hashSha256Async)(n).then(s=>o(s));{const s=(0,Hc.hashSha256)(n);return o(s)}}}Lc.TokenVerifier=Y8;var Kc={};Object.defineProperty(Kc,"__esModule",{value:!0}),Kc.decodeToken=void 0;const jc=tr;function Z8(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(jc.decode(t[0])),n=JSON.parse(jc.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=jc.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(jc.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Kc.decodeToken=Z8,function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Xs,e),r(Lc,e),r(Kc,e),r(ti,e),r(Cc,e)}(Dr);/*! *****************************************************************************
16
+ */(function(e){const t=Ws,r=Sh,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=O,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(We(c,ArrayBuffer)||c&&We(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(We(c,SharedArrayBuffer)||c&&We(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(We(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||or(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function O(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),We(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,I=Math.min(p,m);S<I;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let I=c[p];if(We(I,Uint8Array))S+I.length>m.length?(a.isBuffer(I)||(I=a.from(I)),I.copy(m,S)):Uint8Array.prototype.set.call(m,I,S);else if(a.isBuffer(I))I.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=I.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||We(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ht(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return _n(c).length;default:if(S)return m?-1:Ht(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return vt(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function z(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)z(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)z(this,l,l+3),z(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)z(this,l,l+7),z(this,l+1,l+6),z(this,l+2,l+5),z(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let I=S-m,U=p-l;const ce=Math.min(I,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){I=ke[ae],U=le[ae];break}return I<U?-1:U<I?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,or(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let I=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;I=2,U/=2,ce/=2,p/=2}function ke(ae,me){return I===1?ae[me]:ae.readUInt16BE(me*I)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*I}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function He(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const I=l.length;m>I/2&&(m=I/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(or(ce))return U;c[p+U]=ce}return U}function Ge(c,l,p,m){return Mt(Ht(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(_n(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let I=!1;for(;;)switch(m){case"hex":return He(this,c,l,p);case"utf8":case"utf-8":return Ge(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),I=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const I=c[S];let U=null,ce=I>239?4:I>223?3:I>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:I<128&&(U=I);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(I&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(I&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(I&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function vt(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let I=l;I<p;++I)S+=yi[c[I]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let I=0;I<m.length-1;I+=2)S+=String.fromCharCode(m[I]+m[I+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,I=this[c+--m];for(;m>0&&(S*=256);)I+=this[c+--m]*S;return S*=128,I>=S&&(I-=Math.pow(2,8*l)),I},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,I){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<I)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,I=0;for(this[l]=c&255;++I<p&&(S*=256);)this[l+I]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,I=1;for(this[l+S]=c&255;--S>=0&&(I*=256);)this[l+S]=c/I&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function H(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function Le(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p+7]=I,I=I>>8,c[p+6]=I,I=I>>8,c[p+5]=I,I=I>>8,c[p+4]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return H(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return Le(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,I=1,U=0;for(this[l]=c&255;++S<p&&(I*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,I=1,U=0;for(this[l+S]=c&255;--S>=0&&(I*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return H(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return Le(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tn(c,l,p,m,S,I){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function pt(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return pt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return pt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const I=c.charCodeAt(0);(m==="utf8"&&I<128||m==="latin1")&&(c=I)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const I=a.isBuffer(c)?c:a.from(c,m),U=I.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=I[S%U]}return this};const Et={};function Lt(c,l,p){Et[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Lt("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Lt("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Lt("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&yt(l,c.length-(p+1))}function Er(c,l,p,m,S,I){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(I+1)*8}${U}`:ce=`>= -(2${U} ** ${(I+1)*8-1}${U}) and < 2 ** ${(I+1)*8-1}${U}`,new Et.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,I)}function Ve(c,l){if(typeof c!="number")throw new Et.ERR_INVALID_ARG_TYPE(l,"number",c)}function yt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new Et.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new Et.ERR_BUFFER_OUT_OF_BOUNDS:new Et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Ht(c,l){l=l||1/0;let p;const m=c.length;let S=null;const I=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&I.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&I.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&I.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&I.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;I.push(p)}else if(p<2048){if((l-=2)<0)break;I.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;I.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;I.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return I}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const I=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,I.push(S),I.push(m);return I}function _n(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function We(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function or(c){return c!==c}const yi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(by);const sS="https://mempool.space",oS="https://mempool.space/testnet",aS="https://mempool.space/testnet4",cS="https://mempool.space/signet",uS="https://mempool.fractalbitcoin.io",lS="https://mempool-testnet.fractalbitcoin.io",Oi=e=>e===it?oS:e===Yt?aS:e===Jt?cS:e===cs?uS:e===Zt?lS:sS;var ct={},Th={};const hS={},fS=Object.freeze(Object.defineProperty({__proto__:null,default:hS},Symbol.toStringTag,{value:"Module"})),vy=lv(fS);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=vy,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,L=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let W=H(b-K*w-q*_,y),X=H(-K*A-q*$,y);const Z=W>L,te=X>L;if(Z&&(W=y-W),te&&(X=y-X),W>L||X>L)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:W,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=H(b*b),_=H(A*b);return H(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function O(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y,q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q);return X===Z&&te===P}negate(){return new k(this.x,H(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=H(y*y),$=H(w*w),L=H($*$),K=y+$,q=H(i*(H(K*K)-_-L)),W=H(o*_),X=H(W*W),Z=H(X-i*q),te=H(W*(q-Z)-s*L),P=H(i*w*A);return new k(Z,te,P)}add(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y;if($===r||L===r)return this;if(w===r||A===r)return y;const q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q),j=H(Z-X),G=H(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=H(j*j),_e=H(j*ne),$e=H(X*ne),Pe=H(G*G-_e-i*$e),Ie=H(G*($e-Pe)-te*_e),Ze=H(_*K*j);return new k(Pe,Ie,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:L,k2:K}=f.splitScalar(A),q=w,W=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(W=W.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),L&&(W=W.negate()),W=new k(H(W.x*f.beta),W.y,W.z),q.add(W)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let L=0;L<w;L++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&z.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),z.set(w,_)));let $=k.ZERO,L=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),W=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&W);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?L=L.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:L}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:L,k1:K,k2neg:q,k2:W}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(W,w);X=B(L,X),te=B(q,te),te=new k(H(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:L,f:K}=this.wNAF(A,w);_=L,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:pt(_));const L=y,K=H(L*L),q=H(K*L),W=H(w*K),X=H(A*q),Z=H(_*L);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(W,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const z=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,z.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!yt(A))throw new Error("Point is not on curve");const _=T(A);let $=Tn(_);const L=($&n)===n;w?L&&($=H(-$)):(y[0]&1)===1!==L&&($=H(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const L=Lt(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,W=pt(q,K),X=H(-L*W,K),Z=H($*W,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!yt(w)||!yt(A))throw new Error(y);const _=H(A*A),$=T(w);if(H(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,H(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),L=k.fromAffine(y).multiplyUnsafe(A),K=$.add(L);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function He(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Ge(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=He(b.subarray(2)),{data:A,left:_}=He(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(vt(_.slice(0,64)),vt(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Ge(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,H(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),L=Ae(_);return`30${Ae(_+A+4)}02${L}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function vt(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return vt(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function H(b,y=a.P){const w=b%y;return w>=r?w:y+w}function Le(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Tn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),L=BigInt(44),K=BigInt(88),q=b*b*b%y,W=q*q*b%y,X=Le(W,o)*W%y,Z=Le(X,o)*W%y,te=Le(Z,i)*q%y,P=Le(te,A)*te%y,j=Le(P,_)*P%y,G=Le(j,L)*j%y,ne=Le(G,K)*G%y,_e=Le(ne,L)*j%y,$e=Le(_e,o)*W%y,Pe=Le($e,$)*P%y,Ie=Le(Pe,w)*q%y,Ze=Le(Ie,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function pt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=H(b,y),A=y,_=r,$=n;for(;w!==r;){const L=A/w,K=A%w,q=_-$*L;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return H(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,L,K)=>L===r?$:(w[K]=$,H($*L,y)),n),_=pt(A,y);return b.reduceRight(($,L,K)=>L===r?$:(w[K]=H($*w[K],y),H($*L,y)),_),w}function Et(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Lt(b,y=!1){const w=Et(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function yt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Lt(b,!0);if(!Ve($))return;const L=pt($,_),K=V.BASE.multiply($),q=H(K.x,_);if(q===r)return;const W=H(L*H(y+w*q,_),_);if(W===r)return;let X=new Fe(q,W),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=vt(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Ht(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function _n(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=_n;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function We(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Ht(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=We;function or(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function yi(b){const y=or(b),w=H(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),yi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const L=Ye(...$),K=or(A);return{seed:L,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),L=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[L,A]:L}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);await L.reseed(A);let K;for(;!(K=Ar(await L.generate(),_,$,w.canonical));)await L.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);L.reseedSync(A);let K;for(;!(K=Ar(L.generateSync(),_,$,w.canonical));)L.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:L}=_;if(A.strict&&_.hasHighS())return!1;const K=Lt(y);let q;try{q=Ht(w)}catch{return!1}const{n:W}=a,X=pt(L,W),Z=H(K*X,W),te=H($*X,W),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?H(P.x,W)===$:!1}e.verify=S;function I(b){return H(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!yt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=H(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,H(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,L=this.initNonce(w,await $(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce(await $(kt.nonce,L,A,y)),X=I(await $(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return await rs(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,L=this.initNonce(w,$(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce($(kt.nonce,L,A,y)),X=I($(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Ht(w)}}function gi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),H(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function rs(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(await e.utils.taggedHash(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(e.utils.taggedHashSync(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:rs,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},kt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:H,invert:pt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=H(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(Th);var _h={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.isBytes=Ay,Kr.number=_c,Kr.bool=Ey,Kr.bytes=kh,Kr.hash=Sy,Kr.exists=Ty,Kr.output=_y;function _c(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ey(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Ay(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function kh(e,...t){if(!Ay(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Sy(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_c(e.outputLen),_c(e.blockLen)}function Ty(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _y(e,t){kh(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const dS={number:_c,bool:Ey,bytes:kh,hash:Sy,exists:Ty,output:_y};Kr.default=dS;var zo={},kc={};Object.defineProperty(kc,"__esModule",{value:!0}),kc.crypto=void 0,kc.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=O,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=He,e.wrapConstructorWithOpts=Ge,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=kc,r=Kr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const vt=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(vt===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=vt*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function O(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=O(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class z{clone(){return this._cloneInto()}}e.Hash=z;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function He(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Ge(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(zo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Kr,r=zo;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(_h);var Un={},xi={};Object.defineProperty(xi,"__esModule",{value:!0}),xi.HashMD=xi.Maj=xi.Chi=void 0;const Ph=Kr,qo=zo;function pS(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const yS=(e,t,r)=>e&t^~e&r;xi.Chi=yS;const gS=(e,t,r)=>e&t^e&r^t&r;xi.Maj=gS;let wS=class extends qo.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,qo.createView)(this.buffer)}update(t){(0,Ph.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,qo.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,qo.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Ph.exists)(this),(0,Ph.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;pS(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,qo.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};xi.HashMD=wS,Object.defineProperty(Un,"__esModule",{value:!0}),Un.sha224=Un.sha256=Un.SHA256=void 0;const Ih=xi,jr=zo,bS=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]),$i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ci=new Uint32Array(64);let Oh=class extends Ih.HashMD{constructor(){super(64,32,8,!1),this.A=$i[0]|0,this.B=$i[1]|0,this.C=$i[2]|0,this.D=$i[3]|0,this.E=$i[4]|0,this.F=$i[5]|0,this.G=$i[6]|0,this.H=$i[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ci[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ci[d-15],v=Ci[d-2],E=(0,jr.rotr)(g,7)^(0,jr.rotr)(g,18)^g>>>3,T=(0,jr.rotr)(v,17)^(0,jr.rotr)(v,19)^v>>>10;Ci[d]=T+Ci[d-7]+E+Ci[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,jr.rotr)(a,6)^(0,jr.rotr)(a,11)^(0,jr.rotr)(a,25),v=h+g+(0,Ih.Chi)(a,u,f)+bS[d]+Ci[d]|0,E=((0,jr.rotr)(n,2)^(0,jr.rotr)(n,13)^(0,jr.rotr)(n,22))+(0,Ih.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ci.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Un.SHA256=Oh;let mS=class extends Oh{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}};Un.sha256=(0,jr.wrapConstructor)(()=>new Oh),Un.sha224=(0,jr.wrapConstructor)(()=>new mS);var vS=Th,ES=_h,ky=Un;function AS(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Re=AS(vS);const Ni="Expected Private",Ui="Expected Point",Go="Expected Tweak",SS="Expected Hash",Pc="Expected Signature",xh="Expected Extra Data (32 bytes)",Xo="Expected Scalar",TS="Bad Recovery Id";Re.utils.hmacSha256Sync=(e,...t)=>ES.hmac(ky.sha256,e,Re.utils.concatBytes(...t)),Re.utils.sha256Sync=(...e)=>ky.sha256(Re.utils.concatBytes(...e));const $h=Re.utils._normalizePrivateKey,_S=32,kS=32,Ch=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),PS=32,IS=new Uint8Array(32),OS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function xS(e){return e instanceof Uint8Array}function Jo(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Py(e){return Jo(e,IS)===0}function Yo(e){return!(!(e instanceof Uint8Array)||e.length!==kS||Jo(e,Ch)>=0)}function Nh(e){return e instanceof Uint8Array&&e.length===64&&Jo(e.subarray(0,32),Ch)<0&&Jo(e.subarray(32,64),Ch)<0}function $S(e){return xS(e)&&e.length===64&&Jo(e.subarray(0,32),OS)<0}function CS(e){return!(Py(e.subarray(0,32))||Py(e.subarray(32,64)))}function qs(e){return e instanceof Uint8Array&&e.length===_S}function Uh(e){return e===void 0||e instanceof Uint8Array&&e.length===PS}function Iy(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function NS(e){return Iy(Re.utils.bytesToHex(e))}function Rh(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=Iy(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=NS(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const US=(e,t)=>{const r=$h(e),n=Rh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r+n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},RS=(e,t)=>{const r=$h(e),n=Rh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r-n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},BS=e=>{const t=$h(e),r=Re.utils._bigintTo32Bytes(Re.CURVE.n-t);return Re.utils.isValidPrivateKey(r)?r:null},Oy=(e,t,r)=>{const n=Re.Point.fromHex(e),i=Rh(t),o=Re.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},LS=(e,t,r)=>{const n=Re.Point.fromHex(e),i=typeof t=="string"?t:Re.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function Gs(e,t){return e===void 0?t!==void 0?xy(t):!0:!!e}function fs(e){try{return e()}catch{return null}}function Bh(e,t){if(e.length===32!==t)return!1;try{return!!Re.Point.fromHex(e)}catch{return!1}}function Ri(e){return Bh(e,!1)}function xy(e){return Bh(e,!1)&&e.length===33}function ei(e){return Re.utils.isValidPrivateKey(e)}function Ic(e){return Bh(e,!0)}function HS(e,t){if(!Ic(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return fs(()=>{const r=Oy(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function $y(e){if(!Ri(e))throw new Error(Ui);return e.slice(1,33)}function Cy(e,t){if(!ei(e))throw new Error(Ni);return fs(()=>Re.getPublicKey(e,Gs(t)))}function KS(e){if(!ei(e))throw new Error(Ni);return $y(Cy(e))}function jS(e,t){if(!Ri(e))throw new Error(Ui);return Re.Point.fromHex(e).toRawBytes(Gs(t,e))}function DS(e,t,r){if(!Ri(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return fs(()=>LS(e,t,Gs(r,e)))}function MS(e,t,r){if(!Ri(e)||!Ri(t))throw new Error(Ui);return fs(()=>{const n=Re.Point.fromHex(e),i=Re.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(Gs(r,e))})}function FS(e,t,r){if(!Ri(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return fs(()=>Oy(e,t,Gs(r,e)))}function VS(e,t){if(ei(e)===!1)throw new Error(Ni);if(Yo(t)===!1)throw new Error(Go);return fs(()=>US(e,t))}function WS(e,t){if(ei(e)===!1)throw new Error(Ni);if(Yo(t)===!1)throw new Error(Go);return fs(()=>RS(e,t))}function zS(e){if(ei(e)===!1)throw new Error(Ni);return BS(e)}function qS(e,t,r){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Uh(r))throw new Error(xh);return Re.signSync(e,t,{der:!1,extraEntropy:r})}function GS(e,t,r){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Uh(r))throw new Error(xh);const[n,i]=Re.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function XS(e,t,r=Buffer.alloc(32,0)){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Uh(r))throw new Error(xh);return Re.schnorr.signSync(e,t,r)}function JS(e,t,r,n){if(!qs(e))throw new Error(SS);if(!Nh(t)||!CS(t))throw new Error(Pc);if(r&2&&!$S(t))throw new Error(TS);if(!Ic(t.subarray(0,32)))throw new Error(Pc);return Re.recoverPublicKey(e,t,r,Gs(n))}function YS(e,t,r,n){if(!Ri(t))throw new Error(Ui);if(!Nh(r))throw new Error(Pc);if(!qs(e))throw new Error(Xo);return Re.verify(r,e,t,{strict:n})}function ZS(e,t,r){if(!Ic(t))throw new Error(Ui);if(!Nh(r))throw new Error(Pc);if(!qs(e))throw new Error(Xo);return Re.schnorr.verifySync(r,e,t)}var QS=ct.isPoint=Ri,e8=ct.isPointCompressed=xy,t8=ct.isPrivate=ei,r8=ct.isXOnlyPoint=Ic,n8=ct.pointAdd=MS,i8=ct.pointAddScalar=FS,s8=ct.pointCompress=jS,o8=ct.pointFromScalar=Cy,a8=ct.pointMultiply=DS,c8=ct.privateAdd=VS,u8=ct.privateNegate=zS,l8=ct.privateSub=WS,h8=ct.recover=JS,f8=ct.sign=qS,d8=ct.signRecoverable=GS,p8=ct.signSchnorr=XS,y8=ct.verify=YS,g8=ct.verifySchnorr=ZS,w8=ct.xOnlyPointAddTweak=HS,b8=ct.xOnlyPointFromPoint=$y,m8=ct.xOnlyPointFromScalar=KS;yv(Qb({__proto__:null,default:ct,isPoint:QS,isPointCompressed:e8,isPrivate:t8,isXOnlyPoint:r8,pointAdd:n8,pointAddScalar:i8,pointCompress:s8,pointFromScalar:o8,pointMultiply:a8,privateAdd:c8,privateNegate:u8,privateSub:l8,recover:h8,sign:f8,signRecoverable:d8,signSchnorr:p8,verify:y8,verifySchnorr:g8,xOnlyPointAddTweak:w8,xOnlyPointFromPoint:b8,xOnlyPointFromScalar:m8},[ct]));const Qt=e=>e===it||e===Yt||e===Jt?um:nn,Lh=e=>e.find(({purpose:t})=>t==="ordinals"),Hh=e=>e.find(({purpose:t})=>t==="payment"),er=async(e,t)=>{try{const r=await Ny(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},v8=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),E8=e=>/^[a-fA-F0-9]+$/.test(e);function A8(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function Ny(e,t){if(e.startsWith("t")){if(t===tt)return[];if(t===cs)return[];if(t===Zt)return[]}return await Xe.get(`${Oi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function Uy(e,t,r,n,i,o,s=7){const a=e===t,u=await Ny(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new Nt({network:Qt(o)}),d=A8(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:O}=T,k=Lp(t,Qt(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(O)}}),!a){const B=S8(i,o);h.updateInput(E,{redeemScript:B})}if(v+=O,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function S8(e,t){var r;const n=Co({pubkey:by.Buffer.from(e,"hex"),network:Qt(t)}),i=Ls({redeem:n,network:Qt(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}let T8=class extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Vn]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{if(t.provider!==Vn){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Vn):this.parent.disconnect())}handleNetworkChanged(t){const r=yc(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Vn)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Vn),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),er(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?yc(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=Nt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=sh(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}};function _8(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function k8(){return{$store:Nd({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[Vn]:!1,[Pn]:!1,[bi]:!1,[Wn]:!1,[Ud]:!1,[ns]:!1,[vi]:!1,[mi]:!1,[is]:!1,[Ei]:!1}}),$network:hl(tt),$library:hl(void 0)}}function P8({network:e}){return{network:e}}function c9(e){}function u9(e){}function I8(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Oc(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function fr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Oc(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??I8(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function O8(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Ry(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function By(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function ln(e,t){return{kind:"schema",type:"array",reference:ln,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else fr(this,"type",r,n);return r}}}function Ly(e){return{kind:"schema",type:"boolean",reference:Ly,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:fr(this,"type",t,r),t}}}function ds(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:ds,expects:r.map(Oc).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:fr(this,"type",n,i),n}}}function ut(e,t){return{kind:"schema",type:"literal",reference:ut,expects:Oc(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:fr(this,"type",r,n),r}}}function Hy(e,t){return{kind:"schema",type:"loose_object",reference:Hy,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)O8(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else fr(this,"type",r,n);return r}}}function Kh(e,t){return{kind:"schema",type:"non_optional",reference:Kh,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(fr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function ps(e){return{kind:"schema",type:"null",reference:ps,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:fr(this,"type",t,r),t}}}function ys(e,...t){const r={kind:"schema",type:"nullish",reference:ys,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=Ry(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Rn(e){return{kind:"schema",type:"number",reference:Rn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:fr(this,"type",t,r),t}}}function he(e,t){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else fr(this,"type",r,n);return r}}}function hn(e,...t){const r={kind:"schema",type:"optional",reference:hn,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=Ry(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Ky(e,t){return{kind:"schema",type:"picklist",reference:Ky,expects:e.map(Oc).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:fr(this,"type",r,n),r}}}function pe(e){return{kind:"schema",type:"string",reference:pe,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:fr(this,"type",t,r),t}}}function jh(e){return{kind:"schema",type:"undefined",reference:jh,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:fr(this,"type",t,r),t}}}function jy(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function xc(e,t){return{kind:"schema",type:"union",reference:xc,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];fr(this,"type",r,n,{issues:jy(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];fr(this,"type",r,n,{issues:jy(s)})}return r}}}function $c(){return{kind:"schema",type:"unknown",reference:$c,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Dr={},Xs={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.decode=tr.encode=tr.unescape=tr.escape=tr.pad=void 0;const Dy=Ws;function Dh(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}tr.pad=Dh;function My(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}tr.escape=My;function Fy(e){return Dh(e).replace(/-/g,"+").replace(/_/g,"/")}tr.unescape=Fy;function x8(e){return My((0,Dy.fromByteArray)(new TextEncoder().encode(e)))}tr.encode=x8;function $8(e){return new TextDecoder().decode((0,Dy.toByteArray)(Dh(Fy(e))))}tr.decode=$8;var Cc={},Nc={},Js={};Object.defineProperty(Js,"__esModule",{value:!0}),Js.joseToDer=Js.derToJose=void 0;const Vy=Ws,Wy=tr;function Mh(e){return(e/8|0)+(e%8===0?0:1)}const C8={ES256:Mh(256),ES384:Mh(384),ES512:Mh(521)};function zy(e){const t=C8[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Uc=128,qy=0,N8=32,U8=16,R8=2,Gy=U8|N8|qy<<6,Rc=R8|qy<<6;function Xy(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Vy.toByteArray)((0,Wy.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function B8(e,t){const r=Xy(e),n=zy(t),i=n+1,o=r.length;let s=0;if(r[s++]!==Gy)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Uc|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Rc)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Rc)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Wy.escape)((0,Vy.fromByteArray)(E))}Js.derToJose=B8;function Jy(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Uc&&--n,n}function L8(e,t){e=Xy(e);const r=zy(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=Jy(e,0,r),o=Jy(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Uc,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=Gy,f?h[d++]=u:(h[d++]=Uc|1,h[d++]=u&255),h[d++]=Rc,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Rc,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Js.joseToDer=L8;var ti={};Object.defineProperty(ti,"__esModule",{value:!0}),ti.InvalidTokenError=ti.MissingParametersError=void 0;class H8 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}ti.MissingParametersError=H8;class K8 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}ti.InvalidTokenError=K8,Object.defineProperty(Nc,"__esModule",{value:!0}),Nc.SECP256K1Client=void 0;const j8=_h,D8=Un,Bc=Th,Yy=Js,Zy=ti,Qy=zo;Bc.utils.hmacSha256Sync=(e,...t)=>{const r=j8.hmac.create(D8.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};let eg=class{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,Qy.bytesToHex)(Bc.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new Zy.MissingParametersError("a signing input hash and private key are all required");const i=Bc.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,Qy.bytesToHex)(i);if(n==="jose")return(0,Yy.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,Yy.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new Zy.MissingParametersError("a signing input hash, der signature, and public key are all required");return Bc.verify(r,t,n,{strict:!1})}};Nc.SECP256K1Client=eg,eg.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Nc;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Cc);var gs={},M8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(gs,"__esModule",{value:!0}),gs.hashSha256Async=gs.hashSha256=void 0;const F8=Un;function tg(e){return(0,F8.sha256)(e)}gs.hashSha256=tg;function V8(e){return M8(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=vy;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(tg(e))}})}gs.hashSha256Async=V8;var W8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.TokenSigner=Xs.createUnsecuredToken=void 0;const Fh=tr,rg=Cc,z8=ti,ng=gs;function Vh(e,t){const r=[],n=Fh.encode(JSON.stringify(t));r.push(n);const i=Fh.encode(JSON.stringify(e));return r.push(i),r.join(".")}function q8(e){return Vh(e,{typ:"JWT",alg:"none"})+"."}Xs.createUnsecuredToken=q8;class G8{constructor(t,r){if(!(t&&r))throw new z8.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!rg.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=rg.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=Vh(t,i),s=(0,ng.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return W8(this,void 0,void 0,function*(){const i=this.header(n),o=Vh(t,i),s=yield(0,ng.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Fh.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}Xs.TokenSigner=G8;var Lc={};Object.defineProperty(Lc,"__esModule",{value:!0}),Lc.TokenVerifier=void 0;const X8=tr,ig=Cc,J8=ti,Hc=gs;class Y8{constructor(t,r){if(!(t&&r))throw new J8.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!ig.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=ig.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Hc.hashSha256Async)(i).then(s=>o(s));{const s=(0,Hc.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),X8.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Hc.hashSha256Async)(n).then(s=>o(s));{const s=(0,Hc.hashSha256)(n);return o(s)}}}Lc.TokenVerifier=Y8;var Kc={};Object.defineProperty(Kc,"__esModule",{value:!0}),Kc.decodeToken=void 0;const jc=tr;function Z8(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(jc.decode(t[0])),n=JSON.parse(jc.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=jc.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(jc.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Kc.decodeToken=Z8,function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Xs,e),r(Lc,e),r(Kc,e),r(ti,e),r(Cc,e)}(Dr);/*! *****************************************************************************
17
17
  Copyright (c) Microsoft Corporation.
18
18
 
19
19
  Permission to use, copy, modify, and/or distribute this software for any
@@ -26,22 +26,22 @@ PROCEED WITH CAUTION!
26
26
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
27
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
28
  PERFORMANCE OF THIS SOFTWARE.
29
- ***************************************************************************** */var sg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<sg.length;++t)e[sg.charCodeAt(t)]=t})();var og,zf,Dc,qf=(og=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,I=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,I.push(T>>x&N);if(E)x>0&&I.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return I}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function h(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function f(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const I=(E=x).lastIndexOf("1");if(I===-1)return"No separator character for "+E;if(I===0)return"Missing prefix for "+E;const k=E.slice(0,I),B=E.slice(I+1);if(B.length<6)return"Data too short";let z=o(k);if(typeof z=="string")return z;const V=[];for(let Ue=0;Ue<B.length;++Ue){const He=B.charAt(Ue),Ge=n[He];if(Ge===void 0)return"Unknown character "+He;z=i(z)^Ge,Ue+6>=B.length||V.push(Ge)}return z!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let I=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,I+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)I+=r.charAt(N>>5*(5-k)&31);return I},toWords:a,fromWordsUnsafe:u,fromWords:h}}t.bech32=f("bech32"),t.bech32m=f("bech32m")},og(zf={exports:{}},zf.exports),zf.exports);(Dc=qf)&&Dc.__esModule&&Object.prototype.hasOwnProperty.call(Dc,"default")&&Dc.default,qf.bech32m,qf.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var Ys,Zs;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(Ys||(Ys={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(Zs||(Zs={})),Zs.p2pkh,Ys.mainnet,Zs.p2pkh,Ys.testnet,Zs.p2sh,Ys.mainnet,Zs.p2sh,Ys.testnet;var Q8="accountChange";fe({type:ut(Q8)});var e6="networkChange";fe({type:ut(e6)});var t6="disconnect";fe({type:ut(t6)});async function Gf(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var ag=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(ag||{}),Xf=fn(xc([pe(),Rn(),ps()])),dr=fe({jsonrpc:ut("2.0"),method:pe(),params:fn(xc([ln($c()),Hy({}),ps()])),id:Xf}),Mc=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(Mc||{}),cg=fe({jsonrpc:ut("2.0"),result:jf($c()),id:Xf}),ug=fe({jsonrpc:ut("2.0"),error:jf($c()),id:Xf});xc([cg,ug]);var Fc=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(Fc||{}),lg=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(lg||{}),r6=fe({address:pe(),publicKey:pe(),purpose:ds(Fc),addressType:ds(lg)}),fg=async e=>{var t,r;const n=await Gf(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Dr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},n6="stx_getAddresses",i6=ys(fe({message:fn(pe())}));fe({...dr.entries,...fe({method:ut(n6),params:i6,id:pe()}).entries});var s6="stx_signTransaction",o6=fe({transaction:pe(),pubkey:fn(pe()),broadcast:fn(Ly())});fe({...dr.entries,...fe({method:ut(s6),params:o6,id:pe()}).entries});var a6=["software","ledger"],c6=Ky(a6),u6="getInfo",l6=ys(ps());fe({version:pe(),methods:fn(ln(pe())),supports:ln(pe())}),fe({...dr.entries,...fe({method:ut(u6),params:l6,id:pe()}).entries});var f6="getAddresses",h6=fe({purposes:ln(ds(Fc)),message:fn(pe())});fe({...dr.entries,...fe({method:ut(f6),params:h6,id:pe()}).entries});var d6="signMessage",Vc=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(Vc||{}),p6=fe({address:pe(),message:pe(),protocol:fn(ds(Vc))});fe({signature:pe(),messageHash:pe(),address:pe(),protocol:ds(Vc)}),fe({...dr.entries,...fe({method:ut(d6),params:p6,id:pe()}).entries});var y6="getAccounts",g6=fe({purposes:ln(ds(Fc)),message:fn(pe())});ln(fe({...r6.entries,...fe({walletType:c6}).entries})),fe({...dr.entries,...fe({method:ut(y6),params:g6,id:pe()}).entries});var w6="getBalance";ys(ps()),fe({...dr.entries,...fe({method:ut(w6),id:pe()}).entries});var b6="wallet_requestPermissions",m6=Df();ut(!0),fe({...dr.entries,...fe({method:ut(b6),params:m6,id:pe()}).entries});var v6="wallet_renouncePermissions",E6=Df();ut(!0),fe({...dr.entries,...fe({method:ut(v6),params:E6,id:pe()}).entries});var A6="wallet_getWalletType";ys(ps()),fe({...dr.entries,...fe({method:ut(A6),id:pe()}).entries});var S6="runes_getBalance",T6=ys(ps());fe({balances:ln(fe({runeName:pe(),amount:pe(),divisibility:Rn(),symbol:pe(),inscriptionId:ys(pe())}))}),fe({...dr.entries,...fe({method:ut(S6),params:T6,id:pe()}).entries});var _6="runes_transfer",k6=fe({recipients:ln(fe({runeName:pe(),amount:pe(),address:pe()}))});fe({...dr.entries,...fe({method:ut(_6),params:k6,id:pe()}).entries});var P6="ord_getInscriptions",O6=fe({offset:Rn(),limit:Rn()});fe({total:Rn(),limit:Rn(),offset:Rn(),inscriptions:ln(fe({inscriptionId:pe(),inscriptionNumber:pe(),address:pe(),collectionName:fn(pe()),postage:pe(),contentLength:pe(),contentType:pe(),timestamp:Rn(),offset:Rn(),genesisTransaction:pe(),output:pe()}))}),fe({...dr.entries,...fe({method:ut(P6),params:O6,id:pe()}).entries});var I6="ord_sendInscriptions",x6=fe({transfers:ln(fe({address:pe(),inscriptionId:pe()}))});fe({...dr.entries,...fe({method:ut(I6),params:x6,id:pe()}).entries});var hg=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return By(ug,o)?{status:"error",error:o.error}:By(cg,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},$6=async e=>{var t,r;const n=await Gf(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Dr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},C6=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),N6=async e=>{var t,r;const n=await Gf(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=C6(i),h={network:s,senderAddress:o,message:a,recipients:u},f=Dr.createUnsecuredToken(h),d=await n.sendBtcTransaction(f);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let dg=e=>e,Zo={},Bi={addEventListener(){},removeEventListener(){}};function U6(){try{return typeof localStorage<"u"}catch{return!1}}U6()&&(Zo=localStorage),typeof window<"u"&&(Bi={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function Qs(e,t={},r={}){let n=r.encode||dg,i=r.decode||dg,o=Nd(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&Bi.perKey&&Bi.removeEventListener(e+d,h,f),delete Zo[e+d]):(r.listen!==!1&&Bi.perKey&&!(d in o.value)&&Bi.addEventListener(e+d,h,f),Zo[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function h(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function f(){let d={...t};for(let g in Zo)g.startsWith(e)&&(d[g.slice(e.length)]=i(Zo[g]));for(let g in d)o.setKey(g,d[g])}return nm(o,()=>{if(f(),r.listen!==!1)return Bi.addEventListener(e,h,f),()=>{Bi.removeEventListener(e,h,f);for(let d in o.value)Bi.removeEventListener(e+d,h,f)}}),o}const pg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R6="XVERSE_CONNECTED_WALLET_STATE";class B6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(R6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of pg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Pn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):pg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){kn(this.$store,["provider"],t=>{t.provider!==Pn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Pn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Ms(this.network||tt);await fg({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=Hf(o.addresses),a=Kf(o.addresses);s&&a&&(this.$store.setKey("provider",Pn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),er(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Pn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Pn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){const n=await hg("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await hg("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromBase64(String(n),{network:Qt(this.network)}),h=u.data.inputs,f=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let I of h){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=Bo(k,Qt(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&f.push(d),g.signingIndexes.length>0&&f.push(g);let E,T,x;const N={payload:{network:{type:Ms(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:f},onFinish:I=>{if(I.txId)E=I.txId;else if(I.psbtBase64){const k=Nt.fromBase64(String(I.psbtBase64),{network:Qt(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw Lr}}class L6 extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(is)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){kn(this.$store,["provider"],t=>{t.provider===is?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[is]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw O0;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",is),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?af(r):void 0}async switchNetwork(t){var r;if(t===Zt||t===cs)return await this.library.switchNetwork(jo);const n=af(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=Nt.fromHex(a);let h;return i&&o&&(h=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}async pushPsbt(t){return await Xe.post(`${Ii(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const yg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],H6="OYL_CONNECTED_WALLET_STATE";class K6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(H6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of yg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===bi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):yg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[bi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==bi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",bi),er(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await Uy(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=Nt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw Lr}}const gg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],j6="LEATHER_CONNECTED_WALLET_STATE";class D6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(j6,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of gg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===vi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):gg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==vi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Na),a=i.find(u=>u.type===hl);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==it&&this.network!==Yt&&this.network!==Jt)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",vi),er(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Na:hl;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=Nt.fromHex(String(a));if(i&&o){const h=u.finalizeAllInputs(),f=await this.pushPsbt(h.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}else if(i){const h=u.finalizeAllInputs();return{signedPsbtHex:h.toHex(),signedPsbtBase64:h.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=Nt.fromHex(t).extractTransaction();return await Xe.post(`${Ii(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Na);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await er(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw Lr}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw Lr}}var Jf={},wg={},hn={},bg={};Object.defineProperty(bg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const f=await s();if(f)return f}const h=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!h)throw new Error("No Orange Bitcoin wallet installed");return h}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(h=>h.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((h,f)=>h==null?void 0:h[f],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(bg,e)}(hn);var mg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(mg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Dr,i=hn,o=async s=>{var a,u;const h=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:f}=s.payload;if(!f)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await h.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(mg,e)}(wg);var vg={},Eg={},Ag={};Object.defineProperty(Ag,"__esModule",{value:!0});var Sg={};Object.defineProperty(Sg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Ag,e),r(Sg,e)}(Eg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=hn,i=async(s,a,u)=>{var h;let f=((h=window.OrangecryptoProviders)==null?void 0:h.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(f=await(0,n.getProviderById)(u)),!f)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await f.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(Eg,e)}(vg);var Tg={},_g={};Object.defineProperty(_g,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(a,u,h,f){f===void 0&&(f=h);var d=Object.getOwnPropertyDescriptor(u,h);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[h]}}),Object.defineProperty(a,f,d)}:function(a,u,h,f){f===void 0&&(f=h),a[f]=u[h]}),r=Se&&Se.__exportStar||function(a,u){for(var h in a)h!=="default"&&!Object.prototype.hasOwnProperty.call(u,h)&&t(u,a,h)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Dr,i=hn,o=(a,u)=>{const h=d=>!(!a[d]||u&&!u.has(d)),f={request:h("request"),connect:h("connect"),signMessage:h("signMessage"),signTransaction:h("signTransaction"),sendBtcTransaction:h("sendBtcTransaction"),createInscription:h("createInscription"),createRepeatInscriptions:h("createRepeatInscriptions"),signMultipleTransactions:h("signMultipleTransactions")};return Object.entries(f).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,h,f;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(h=a.onFinish)==null||h.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(f=a.onCancel)==null||f.call(a)}};e.getCapabilities=s,r(_g,e)}(Tg);var kg={},Wc={},Qo={};Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.validateInscriptionPayload=void 0;const M6=4e5,F6=6e4,V6=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?M6:F6))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Qo.validateInscriptionPayload=V6,Object.defineProperty(Wc,"__esModule",{value:!0}),Wc.createInscription=void 0;const W6=Dr,z6=hn,q6=Qo,G6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,z6.getProviderOrThrow)(n);(0,q6.validateInscriptionPayload)(e.payload);try{const o=(0,W6.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};Wc.createInscription=G6;var zc={};Object.defineProperty(zc,"__esModule",{value:!0}),zc.createRepeatInscriptions=void 0;const X6=hn,J6=Dr,Y6=Qo,Z6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,X6.getProviderOrThrow)(n);(0,Y6.validateInscriptionPayload)(e.payload);try{const o=(0,J6.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};zc.createRepeatInscriptions=Z6;var Pg={};Object.defineProperty(Pg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Wc,e),r(zc,e),r(Pg,e)}(kg);var Og={},Ig={};Object.defineProperty(Ig,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Dr,i=hn,o=async s=>{var a,u;const h=await(0,i.getProviderOrThrow)(s.getProvider),{address:f,message:d}=s.payload;if(!f)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await h.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Ig,e)}(Og);var xg={},qc={};Object.defineProperty(qc,"__esModule",{value:!0}),qc.sendBtcTransaction=void 0;const Q6=Dr,e5=hn,t5=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),r5=async e=>{var t,r;const n=await(0,e5.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=t5(i),h={network:s,senderAddress:o,message:a,recipients:u},f=(0,Q6.createUnsecuredToken)(h),d=await n.sendBtcTransaction(f);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};qc.sendBtcTransaction=r5;var Gc={};Object.defineProperty(Gc,"__esModule",{value:!0}),Gc.signTransaction=void 0;const n5=Dr,i5=hn,s5=async e=>{var t,r;const n=await(0,i5.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,n5.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};Gc.signTransaction=s5;var Xc={};Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.signMultipleTransactions=void 0;const o5=Dr,a5=hn,c5=async e=>{var t,r;const n=await(0,a5.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,o5.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};Xc.signMultipleTransactions=c5;var $g={};Object.defineProperty($g,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(qc,e),r(Gc,e),r(Xc,e),r($g,e)}(xg);var Cg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Cg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(wg,e),r(vg,e),r(Tg,e),r(kg,e),r(Og,e),r(hn,e),r(xg,e),r(Cg,e)}(Jf);const u5=uv(Jf),Ng=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:l5,sendBtcTransaction:f5,signTransaction:h5}=u5,d5="ORANGE_CONNECTED_WALLET_STATE";class p5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(d5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ng)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Ei&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ng.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ei]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],r=>{r.provider!==Ei?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Do(this.network||tt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=Hf(s.addresses),u=Kf(s.addresses);a&&u&&(this.$store.setKey("publicKey",String(s.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(s.addresses[1].publicKey)),this.$store.setKey("provider",Ei),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),er(u.address,this.network).then(h=>{this.$store.setKey("balance",h)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Ei} wallet`)}};await Jf.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){let n="";const i={payload:{network:{type:Do(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{console.log(o),n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await f5(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Do(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await l5(o),n}async signPsbt(t,r,n,i,o){const s=Nt.fromBase64(String(n),{network:Qt(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,h=s.data.inputs,f=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let I of h){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=Bo(k,Qt(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&f.push(d),g.signingIndexes.length>0&&f.push(g);let E,T,x;const N={payload:{network:{type:Do(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:f},onFinish:I=>{if(console.log(I),I.txId)E=I.txId;else if(I.psbtBase64){const k=Nt.fromBase64(String(I.psbtBase64),{network:Qt(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await h5(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=Nt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Xe.post(`${Ii(this.network)}/api/tx`,r).then(n=>n.data)}}const Ug=["address","paymentAddress","publicKey","paymentPublicKey","balance"],y5="OKX_CONNECTED_WALLET_STATE";class g5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(y5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===it||this.network===Yt||this.network===Jt||this.network===Zt?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===tt||this.network===cs)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ug)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ns&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ug.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ns]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],r=>{r.provider!==ns?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ns),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===it||r===Yt||r===Zt?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===it?it:r===Yt?Yt:r===Jt?Jt:r===Zt?Zt:it;const n=await this.library.getNetwork();return N0(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=Nt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Ii(this.network)}/api/tx`,t).then(r=>r.data)}}const Rg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],w5="MAGIC_EDEN_CONNECTED_WALLET_STATE";class b5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(w5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Rg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Wn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Rg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Wn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==Wn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Ms(this.network||tt);await fg({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=Hf(o.addresses),a=Kf(o.addresses);s&&a&&(this.$store.setKey("provider",Wn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),er(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Wn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Wn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){let n;if(await N6({getProvider:async()=>this.library,payload:{network:{type:Ms(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await $6({getProvider:async()=>this.library,payload:{network:{type:ag.Mainnet},address:n,message:t,protocol:Vc.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromBase64(String(n),{network:Qt(this.network)}),h=u.data.inputs,f=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of h){const{script:B}=k.witnessUtxo,z=Bo(B,Qt(this.network));z===a?g.signingIndexes.push(Number(v)):z===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&f.push(d),g.signingIndexes.length>0&&f.push(g);let E,T,x;const N=Ms(this.network),I={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:f},onFinish:k=>{if(k.psbtBase64){const B=Nt.fromBase64(String(k.psbtBase64),{network:Qt(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(I),o){const k=Nt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Xe.post(`${Ii(this.network)}/api/tx`,t).then(r=>r.data)}}class m5 extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[mi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{if(t.provider!==mi){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(mi):this.parent.disconnect())}handleNetworkChanged(t){const r=yc(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(mi)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",mi),er(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?it:tt}async sendBTC(t,r){const{psbtHex:n}=await Uy(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromHex(String(r),{network:Qt(this.network)}).data.inputs,h=[],f={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=Bo(x,Qt(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&f.signingIndexes.push(Number(g)),g++}f.signingIndexes.length>0&&h.push(f),d.signingIndexes.length>0&&h.push(d);const v=await this.library.signPsbt(r,{inputsToSign:h}),E=Nt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Ii(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=of(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}let v5=class{constructor(t,r){we(this,"$store"),we(this,"$network"),we(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[vi]:new D6(t,this,r),[Wn]:new b5(t,this,r),[ns]:new g5(t,this,r),[Ei]:new p5(t,this,r),[bi]:new K6(t,this,r),[mi]:new m5(t,this,r),[Vn]:new T8(t,this,r),[Pn]:new B6(t,this,r),[is]:new L6(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Cd(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Cd(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),_8()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(Ua);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(Ua,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(Ua)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(E8(t))s=Nt.fromHex(t).toBase64(),o=t;else if(v8(t))s=t,o=Nt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}};var E5=Object.defineProperty,A5=(e,t,r)=>t in e?E5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,be=(e,t,r)=>A5(e,typeof t!="symbol"?t+"":t,r);function S5(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let Yf=Symbol("clean"),dn=[],Li=0;const Jc=4;let Zf=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=Li+Jc;o<dn.length;)dn[o]===n?dn.splice(o,Jc):o+=Jc;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!dn.length;for(let s of t)dn.push(s,r.value,n,i);if(o){for(Li=0;Li<dn.length;Li+=Jc)dn[Li](dn[Li+1],dn[Li+2],dn[Li+3]);dn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[Yf]=()=>{t=[],r.lc=0,r.off()}),r};const T5=5,eo=6,Yc=10;let _5=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Yc]||(e.events[r+Yc]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Yc](),delete e.events[r+Yc])}),k5=1e3,P5=(e,t)=>_5(e,r=>{let n=t(r);n&&e.events[eo].push(n)},T5,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[eo]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[eo])o();e.events[eo]=[]}},k5)},process.env.NODE_ENV!=="production"){let o=e[Yf];e[Yf]=()=>{for(let s of e.events[eo])s();e.events[eo]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function Bn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Bg(e,t,r){let n=Bn(e,t,r);return r(e.value),n}let Lg=(e={})=>{let t=Zf(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const ws="oyl",Hi="unisat",ri="xverse",Ki="phantom",bs="leather",ni="magic-eden",ms="okx",vs="wizz",ji="orange",Hg="op_net",Qf="p2tr",Kg="p2wpkh",eh="defaultWallet",pn={messagePrefix:`Bitcoin Signed Message:
30
- `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},O5={messagePrefix:`Bitcoin Signed Message:
31
- `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function I5(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function x5(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function $5(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const qe={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,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_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,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_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT: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_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,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_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},jg={};for(const e of Object.keys(qe)){const t=qe[e];jg[t]=e}const Zc="0123456789abcdefABCDEF",Qc=Zc.split("").map(e=>e.codePointAt(0)),eu=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Zc.indexOf(r);return n<0?void 0:n<16?n:n-6}),Dg=new TextEncoder,Mg=new TextDecoder;function C5(e){return Mg.decode(e)}function N5(e){return Dg.encode(e)}function lt(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Ee(e){const t=e||new Uint8Array;return t.length>512?R5(t):U5(t)}function U5(e){let t="";for(let r=0;r<e.length;++r)t+=Zc[eu[Qc[e[r]>>4]]],t+=Zc[eu[Qc[e[r]&15]]];return t}function R5(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=Qc[e[r]>>4],t[r*2+1]=Qc[e[r]&15];return Mg.decode(t)}function ii(e){const t=Dg.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=eu[t[n*2]],o=eu[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function B5(e){return btoa(String.fromCharCode(...e))}function Fg(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function ee(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Pr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function L5(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function ea(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function H5(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function si(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function K5(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function to(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Vg(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function Wg(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function j5(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function zg(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function qg(e){return e<qe.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function D5(e,t,r){const n=qg(t);return n===1?Pr(e,r,t):n===2?(Pr(e,r,qe.OP_PUSHDATA1),Pr(e,r+1,t)):n===3?(Pr(e,r,qe.OP_PUSHDATA2),L5(e,r+1,t,"LE")):(Pr(e,r,qe.OP_PUSHDATA4),ea(e,r+1,t,"LE")),n}function M5(e,t){const r=si(e,t);let n,i;if(r<qe.OP_PUSHDATA1)n=r,i=1;else if(r===qe.OP_PUSHDATA1){if(t+2>e.length)return null;n=si(e,t+1),i=2}else if(r===qe.OP_PUSHDATA2){if(t+3>e.length)return null;n=K5(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==qe.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=to(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function F5(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function V5(e){let t=Math.abs(e);const r=F5(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Pr(n,o,t&255),t>>=8;return n[r-1]&128?Pr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function W5(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function z5(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function ta(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function zt(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??ta(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},h=e.kind==="schema",f=(i==null?void 0:i.message)??e.message??z5(e.reference,u.lang)??(h?(u.lang,void 0):null)??n.message??(u.lang,void 0);f&&(u.message=typeof f=="function"?f(u):f),h&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function q5(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var G5=class extends Error{constructor(e){super(e[0].message),be(this,"issues"),this.name="ValiError",this.issues=e}};function Gg(e,t){return{kind:"validation",type:"every_item",reference:Gg,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&zt(this,"item",r,n),r}}}function th(e){return{kind:"validation",type:"integer",reference:th,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&zt(this,"integer",t,r),t}}}function Xg(e,t){return{kind:"validation",type:"length",reference:Xg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&zt(this,"length",r,n,{received:`${r.value.length}`}),r}}}function tu(e,t){return{kind:"validation",type:"max_value",reference:tu,async:!1,expects:`<=${e instanceof Date?e.toJSON():ta(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&zt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ta(r.value)}),r}}}function ru(e,t){return{kind:"validation",type:"min_value",reference:ru,async:!1,expects:`>=${e instanceof Date?e.toJSON():ta(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&zt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ta(r.value)}),r}}}function Jg(e,t){return{kind:"validation",type:"regex",reference:Jg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&zt(this,"format",r,n),r}}}function rh(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function nu(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Yg(){return{kind:"schema",type:"any",reference:Yg,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function pr(e,t){return{kind:"schema",type:"array",reference:pr,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const h={type:"array",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else zt(this,"type",r,n);return r}}}function Zg(e){return{kind:"schema",type:"bigint",reference:Zg,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:zt(this,"type",t,r),t}}}function yn(e,t){return{kind:"schema",type:"custom",reference:yn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:zt(this,"type",r,n),r}}}function iu(e,t){return{kind:"schema",type:"instance",reference:iu,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:zt(this,"type",r,n),r}}}function nh(e,...t){const r={kind:"schema",type:"nullable",reference:nh,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=rh(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Qg(e,...t){const r={kind:"schema",type:"nullish",reference:Qg,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=rh(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function yr(e){return{kind:"schema",type:"number",reference:yr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:zt(this,"type",t,r),t}}}function It(e,t){return{kind:"schema",type:"object",reference:It,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"object",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else zt(this,"type",r,n);return r}}}function su(e,...t){const r={kind:"schema",type:"optional",reference:su,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=rh(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Es(e){return{kind:"schema",type:"string",reference:Es,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:zt(this,"type",t,r),t}}}function Ln(e,t){return{kind:"schema",type:"tuple",reference:Ln,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"array",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else zt(this,"type",r,n);return r}}}function e1(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ih(e,t){return{kind:"schema",type:"union",reference:ih,expects:q5(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];zt(this,"type",r,n,{issues:e1(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];zt(this,"type",r,n,{issues:e1(s)})}return r}}}function ft(e,t,r){const n=e._run({typed:!1,value:t},W5(r));if(n.issues)throw new G5(n.issues);return n.value}function Di(e,t){const r={};for(const n in e.entries)r[n]=su(e.entries[n]);return{...e,entries:r}}function ro(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const t1=new Uint8Array(32),r1=ii("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ut=e=>ro(iu(Uint8Array),Xg(e));function ra(e,t){return e.length!==t.length?!1:e.every((r,n)=>ee(r,t[n])===0)}function gn(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(ee(t1,r)===0||ee(r,r1)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return ee(t1,n)===0||ee(n,r1)>=0?!1:t===4&&e.length===65}const ou=254;function sh(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&ou)===e.version:!0}function n1(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>n1(t)):sh(e)}const X5=Ut(32),J5=Ut(20),i1=Ut(32),Me=iu(Uint8Array);ro(Es(),Jg(/^([0-9a-f]{2})+$/i));const Y5=ro(yr(),th(),ru(0),tu(255)),oi=ro(yr(),th(),ru(0),tu(4294967295)),oh=ro(Zg(),ru(0n),tu(0x7fffffffffffffffn)),s1=e=>It(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Qg(r[1])}),{})),o1=new Uint8Array(1);function a1(e){let t=0;for(;e[t]===0;)++t;return t===e.length?o1:(e=e.slice(t),e[0]&128?lt([o1,e]):e)}function c1(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Z5(e){const t=si(e,e.length-1);if(!ch(t))throw new Error("Invalid hashType "+t);const r=x5(e.subarray(0,-1)),n=c1(r.r),i=c1(r.s);return{signature:lt([n,i]),hashType:t}}function Q5(e,t){if(ft(It({signature:Ut(64),hashType:Y5}),{signature:e,hashType:t}),!ch(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Pr(r,0,t);const n=a1(e.slice(0,32)),i=a1(e.slice(32,64));return lt([$5(n,i),r])}const eT=Object.freeze(Object.defineProperty({__proto__:null,decode:Z5,encode:Q5},Symbol.toStringTag,{value:"Module"})),u1=qe.OP_RESERVED,l1=pr(ih([iu(Uint8Array),yr()]));function tT(e){return nu(yr(),e)&&(e===qe.OP_0||e>=qe.OP_1&&e<=qe.OP_16||e===qe.OP_1NEGATE)}function f1(e){return nu(Me,e)||tT(e)}function ah(e){return nu(ro(Yg(),Gg(f1)),e)}function h1(e){return e.length-e.filter(f1).length}function au(e){if(e.length===0)return qe.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return u1+e[0];if(e[0]===129)return qe.OP_1NEGATE}}function d1(e){return e instanceof Uint8Array}function rT(e){return nu(l1,e)}function cu(e){return e instanceof Uint8Array}function gr(e){if(d1(e))return e;ft(l1,e);const t=e.reduce((i,o)=>cu(o)?o.length===1&&au(o)!==void 0?i+1:i+qg(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(cu(i)){const o=au(i);if(o!==void 0){Pr(r,n,o),n+=1;return}n+=D5(r,i.length,n),r.set(i,n),n+=i.length}else Pr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function wt(e){if(rT(e))return e;ft(Me,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>qe.OP_0&&n<=qe.OP_PUSHDATA4){const i=M5(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=au(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function nT(e){if(d1(e)&&(e=wt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(cu(t)){const r=au(t);if(r===void 0)return Ee(t);t=r}return jg[t]}).join(" ")}function iT(e){return e=wt(e),ft(yn(ah),e),e.map(t=>cu(t)?t:t===qe.OP_0?new Uint8Array(0):V5(t-u1))}function sT(e){return gn(e)}function ch(e){const t=e&-129;return t>0&&t<4}function ai(e){return!(e instanceof Uint8Array)||!ch(e[e.length-1])?!1:I5(e.slice(0,-1))}const na=eT;function ye(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Mr(e){let t;return()=>(t!==void 0||(t=e()),t)}const no=qe,uu=no.OP_RESERVED;function lu(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return ai(a)||(t.allowIncomplete&&a===no.OP_0)!==void 0}ft(Di(It({network:It({}),m:yr(),n:yr(),output:Me,pubkeys:pr(yn(gn),"Received invalid pubkey"),signatures:pr(yn(r),"Expected signature to be of type isAcceptableSignature"),input:Me})),e);const n={network:e.network||pn};let i=[],o=!1;function s(a){o||(o=!0,i=wt(a),n.m=i[0]-uu,n.n=i[i.length-2]-uu,n.pubkeys=i.slice(1,-2))}if(ye(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return gr([].concat(uu+e.m,e.pubkeys,uu+n.n,no.OP_CHECKMULTISIG))}),ye(n,"m",()=>{if(n.output)return s(n.output),n.m}),ye(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),ye(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),ye(n,"signatures",()=>{if(e.input)return wt(e.input).slice(1)}),ye(n,"input",()=>{if(e.signatures)return gr([no.OP_0].concat(e.signatures))}),ye(n,"witness",()=>{if(n.input)return[]}),ye(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),ft(yr(),i[0],{message:"Output is invalid"}),ft(yr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==no.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>gn(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!ra(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==no.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!ra(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const p1=qe;function y1(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Di(It({network:It({}),output:Me,pubkey:yn(gn,"invalid pubkey"),signature:yn(ai,"Expected signature to be of type isCanonicalScriptSignature"),input:Me})),e);const r=Mr(()=>wt(e.input)),n={name:"p2pk",network:e.network||pn};if(ye(n,"output",()=>{if(e.pubkey)return gr([e.pubkey,p1.OP_CHECKSIG])}),ye(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),ye(n,"signature",()=>{if(e.input)return r()[0]}),ye(n,"input",()=>{if(e.signature)return gr([e.signature])}),ye(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==p1.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!gn(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&ee(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&ee(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!ai(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function oT(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function g1(e,...t){if(!oT(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function w1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function aT(e,t){g1(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uh=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Hn=(e,t)=>e<<32-t|e>>>t,fu=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function cT(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function b1(e){return typeof e=="string"&&(e=cT(e)),g1(e),e}class uT{clone(){return this._cloneInto()}}function m1(e){const t=n=>e().update(b1(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function lT(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,h=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+h,a,n)}const fT=(e,t,r)=>e&t^~e&r,hT=(e,t,r)=>e&t^e&r^t&r;let v1=class extends uT{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=uh(this.buffer)}update(e){w1(this);const{view:t,buffer:r,blockLen:n}=this;e=b1(e);const i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const a=uh(e);for(;n<=i-o;o+=n)this.process(a,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){w1(this),aT(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let f=o;f<n;f++)t[f]=0;lT(r,n-8,BigInt(this.length*8),i),this.process(r,0);const s=uh(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)s.setUint32(4*f,h[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}};const dT=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),E1=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),pT=E1.map(e=>(9*e+5)%16);let lh=[E1],fh=[pT];for(let e=0;e<4;e++)for(let t of[lh,fh])t.push(t[e].map(r=>dT[r]));const A1=[[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(e=>new Uint8Array(e)),yT=lh.map((e,t)=>e.map(r=>A1[t][r])),gT=fh.map((e,t)=>e.map(r=>A1[t][r])),wT=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),bT=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function S1(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const hu=new Uint32Array(16);class mT extends v1{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)hu[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,h=this.h3|0,f=h,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=wT[v],x=bT[v],N=lh[v],I=fh[v],k=yT[v],B=gT[v];for(let z=0;z<16;z++){const V=fu(n+S1(v,o,a,h)+hu[N[z]]+T,k[z])+d|0;n=d,d=h,h=fu(a,10)|0,a=o,o=V}for(let z=0;z<16;z++){const V=fu(i+S1(E,s,u,f)+hu[I[z]]+x,B[z])+g|0;i=g,g=f,f=fu(u,10)|0,u=s,s=V}}this.set(this.h1+a+f|0,this.h2+h+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){hu.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const vT=m1(()=>new mT),ET=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]),Mi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fi=new Uint32Array(64);let AT=class extends v1{constructor(){super(64,32,8,!1),this.A=Mi[0]|0,this.B=Mi[1]|0,this.C=Mi[2]|0,this.D=Mi[3]|0,this.E=Mi[4]|0,this.F=Mi[5]|0,this.G=Mi[6]|0,this.H=Mi[7]|0}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let f=0;f<16;f++,t+=4)Fi[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=Fi[f-15],g=Fi[f-2],v=Hn(d,7)^Hn(d,18)^d>>>3,E=Hn(g,17)^Hn(g,19)^g>>>10;Fi[f]=E+Fi[f-7]+v+Fi[f-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:h}=this;for(let f=0;f<64;f++){const d=Hn(s,6)^Hn(s,11)^Hn(s,25),g=h+d+fT(s,a,u)+ET[f]+Fi[f]|0,v=(Hn(r,2)^Hn(r,13)^Hn(r,22))+hT(r,n,i)|0;h=u,u=a,a=s,s=o+g|0,o=i,i=n,n=r,r=g+v|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,n,i,o,s,a,u,h)}roundClean(){Fi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const rr=m1(()=>new AT);function ci(e){return vT(rr(e))}function As(e){return rr(rr(e))}const ST={"BIP0340/challenge":Uint8Array.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":Uint8Array.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":Uint8Array.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:Uint8Array.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:Uint8Array.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:Uint8Array.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:Uint8Array.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":Uint8Array.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":Uint8Array.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function du(e,t){return rr(lt([ST[e],t]))}function TT(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let h=0;h<t.length;h++)t[h]=255;for(let h=0;h<e.length;h++){const f=e.charAt(h),d=f.charCodeAt(0);if(t[d]!==255)throw new TypeError(f+" is ambiguous");t[d]=h}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";let f=0,d=0,g=0;const v=h.length;for(;g!==v&&h[g]===0;)g++,f++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let I=h[g],k=0;for(let B=E-1;(I!==0||k<d)&&B!==-1;B--,k++)I+=256*T[B]>>>0,T[B]=I%r>>>0,I=I/r>>>0;if(I!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(f);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;let f=0,d=0,g=0;for(;h[f]===n;)d++,f++;const v=(h.length-f)*i+1>>>0,E=new Uint8Array(v);for(;h[f];){let I=t[h.charCodeAt(f)];if(I===255)return;let k=0;for(let B=v-1;(I!==0||k<g)&&B!==-1;B--,k++)I+=r*E[B]>>>0,E[B]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=k,f++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(h){const f=a(h);if(f)return f;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var _T="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const hh=TT(_T);function kT(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,h=new Uint8Array(u);return h.set(s,0),h.set(a.subarray(0,4),s.length),hh.encode(h)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=hh.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=hh.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function PT(e){return rr(rr(e))}const ia=kT(PT),Vi=qe;function sa(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Di(It({network:It({}),address:Es(),hash:J5,output:Ut(25),pubkey:yn(gn),signature:yn(ai),input:Me})),e);const r=Mr(()=>{const s=ia.decode(e.address),a=si(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Mr(()=>wt(e.input)),i=e.network||pn,o={name:"p2pkh",network:i};if(ye(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Pr(s,0,i.pubKeyHash),s.set(o.hash,1),ia.encode(s)}),ye(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return ci(e.pubkey||o.pubkey)}),ye(o,"output",()=>{if(o.hash)return gr([Vi.OP_DUP,Vi.OP_HASH160,o.hash,Vi.OP_EQUALVERIFY,Vi.OP_CHECKSIG])}),ye(o,"pubkey",()=>{if(e.input)return n()[1]}),ye(o,"signature",()=>{if(e.input)return n()[0]}),ye(o,"input",()=>{if(e.pubkey&&e.signature)return gr([e.signature,e.pubkey])}),ye(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==Vi.OP_DUP||e.output[1]!==Vi.OP_HASH160||e.output[2]!==20||e.output[23]!==Vi.OP_EQUALVERIFY||e.output[24]!==Vi.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=ci(e.pubkey);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!ai(a[0]))throw new TypeError("Input has invalid signature");if(!gn(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&ee(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=ci(a[1]);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const oa=qe;function io(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Di(It({network:It({}),address:Es(),hash:Ut(20),output:Ut(23),redeem:Di(It({network:It({}),output:Me,input:Me,witness:pr(Me)})),input:Me,witness:pr(Me)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||pn);const n={network:r},i=Mr(()=>{const a=ia.decode(e.address),u=si(a,0),h=a.slice(1);return{version:u,hash:h}}),o=Mr(()=>wt(e.input)),s=Mr(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===oa.OP_FALSE?Uint8Array.from([]):u,input:gr(a.slice(0,-1)),witness:e.witness||[]}});if(ye(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Pr(a,0,n.network.scriptHash),a.set(n.hash,1),ia.encode(a)}),ye(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return ci(n.redeem.output)}),ye(n,"output",()=>{if(n.hash)return gr([oa.OP_HASH160,n.hash,oa.OP_EQUAL])}),ye(n,"redeem",()=>{if(e.input)return s()}),ye(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return gr([].concat(wt(e.redeem.input),e.redeem.output))}),ye(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),ye(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&ee(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==oa.OP_HASH160||e.output[1]!==20||e.output[22]!==oa.OP_EQUAL)throw new TypeError("Output is invalid");const h=e.output.slice(2,22);if(a.length>0&&ee(a,h)!==0)throw new TypeError("Hash mismatch");a=h}const u=h=>{if(h.output){const f=wt(h.output);if(!f||f.length<1)throw new TypeError("Redeem.output too short");if(h.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(h1(f)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=ci(h.output);if(a.length>0&&ee(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(h.input){const f=h.input.length>0,d=h.witness&&h.witness.length>0;if(!f&&!d)throw new TypeError("Empty input");if(f&&d)throw new TypeError("Input and witness provided");if(f){const g=wt(h.input);if(!ah(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const h=o();if(!h||h.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const h=s();if(e.redeem.output&&ee(e.redeem.output,h.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&ee(e.redeem.input,h.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!ra(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function OT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function IT(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var aa={};Object.defineProperty(aa,"__esModule",{value:!0});var ca=aa.bech32m=Or=aa.bech32=void 0;const pu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",T1={};for(let e=0;e<pu.length;e++){const t=pu.charAt(e);T1[t]=e}function so(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function _1(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=so(t)^n>>5}t=so(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=so(t)^n&31}return t}function dh(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function xT(e){return dh(e,8,5,!0)}function $T(e){const t=dh(e,5,8,!1);if(Array.isArray(t))return t}function CT(e){const t=dh(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function k1(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let h=_1(s);if(typeof h=="string")throw new Error(h);let f=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");h=so(h)^g,f+=pu.charAt(g)}for(let d=0;d<6;++d)h=so(h);h^=t;for(let d=0;d<6;++d){const g=h>>(5-d)*5&31;f+=pu.charAt(g)}return f}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),h=s.toUpperCase();if(s!==u&&s!==h)return"Mixed-case string "+s;s=u;const f=s.lastIndexOf("1");if(f===-1)return"No separator character for "+s;if(f===0)return"Missing prefix for "+s;const d=s.slice(0,f),g=s.slice(f+1);if(g.length<6)return"Data too short";let v=_1(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=T1[x];if(N===void 0)return"Unknown character "+x;v=so(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:xT,fromWordsUnsafe:$T,fromWords:CT}}var Or=aa.bech32=k1("bech32");ca=aa.bech32m=k1("bech32m");const P1=qe,NT=new Uint8Array(0);function ua(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Di(It({address:Es(),hash:Ut(20),input:Ut(0),network:It({}),output:Ut(22),pubkey:yn(gn,"Not a valid pubkey"),signature:yn(ai),witness:pr(Me)})),e);const r=Mr(()=>{const o=Or.decode(e.address),s=o.words.shift(),a=Or.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||pn,i={name:"p2wpkh",network:n};if(ye(i,"address",()=>{if(!i.hash)return;const o=Or.toWords(i.hash);return o.unshift(0),Or.encode(n.bech32,o)}),ye(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return ci(e.pubkey||i.pubkey)}),ye(i,"output",()=>{if(i.hash)return gr([P1.OP_0,i.hash])}),ye(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),ye(i,"signature",()=>{if(e.witness)return e.witness[0]}),ye(i,"input",()=>{if(i.witness)return NT}),ye(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&ee(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==P1.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&ee(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=ci(e.pubkey);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!gn(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!ai(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!gn(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&ee(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=ci(e.witness[1]);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const O1=qe,ph=new Uint8Array(0);function yu(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&gn(e))}function la(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(s1({network:It({}),address:Es(),hash:X5,output:Ut(34),redeem:s1({input:Me,network:It({}),output:Me,witness:pr(Me)}),input:Ut(0),witness:pr(Me)}),e);const r=Mr(()=>{const s=Or.decode(e.address),a=s.words.shift(),u=Or.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Mr(()=>wt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||pn);const o={network:i};if(ye(o,"address",()=>{if(!o.hash)return;const s=Or.toWords(o.hash);return s.unshift(0),Or.encode(i.bech32,s)}),ye(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return rr(o.redeem.output)}),ye(o,"output",()=>{if(o.hash)return gr([O1.OP_0,o.hash])}),ye(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:ph,witness:e.witness.slice(0,-1)}}),ye(o,"input",()=>{if(o.witness)return ph}),ye(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=iT(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=ph,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),ye(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==O1.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=wt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(h1(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=rr(e.redeem.output);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!ah(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!ra(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(yu)||e.redeem.output&&(wt(e.redeem.output)||[]).some(yu))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&ee(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(yu)||(wt(a)||[]).some(yu))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const fa={};function UT(e){e?e!==fa.eccLib&&(RT(e),fa.eccLib=e):fa.eccLib=e}function yh(){if(!fa.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return fa.eccLib}const ui=e=>ii(e);function RT(e){Fr(typeof e.isXOnlyPoint=="function"),Fr(e.isXOnlyPoint(ui("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Fr(e.isXOnlyPoint(ui("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Fr(e.isXOnlyPoint(ui("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Fr(e.isXOnlyPoint(ui("0000000000000000000000000000000000000000000000000000000000000001"))),Fr(!e.isXOnlyPoint(ui("0000000000000000000000000000000000000000000000000000000000000000"))),Fr(!e.isXOnlyPoint(ui("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Fr(typeof e.xOnlyPointAddTweak=="function"),BT.forEach(t=>{const r=e.xOnlyPointAddTweak(ui(t.pubkey),ui(t.tweak));t.result===null?Fr(r===null):(Fr(r!==null),Fr(r.parity===t.parity),Fr(ee(r.xOnlyPubkey,ui(t.result))===0))})}function Fr(e){if(!e)throw new Error("ecc library invalid")}const BT=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],I1="0123456789abcdefABCDEF";I1.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=I1.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function LT(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function HT(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function KT(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function jT(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function DT(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function MT(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const FT=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function VT(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function x1(e){typeof e=="number"?VT(e):FT(e)}function Wi(e,t,r){x1(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Vr(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),LT(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),HT(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),KT(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function oo(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=jT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=DT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=MT(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Vr(e){return x1(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const WT=9007199254740991;function zT(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function gh(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e}function $1(e){const t=new Uint8Array(e.length);return t.set(e),t}class qt{constructor(t,r=0){be(this,"buffer"),be(this,"offset"),this.buffer=t,this.offset=r,ft(Ln([Me,oi]),[t,r])}static withCapacity(t){return new qt(new Uint8Array(t))}writeUInt8(t){this.offset=Pr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Vg(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=Wg(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=ea(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=H5(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=Wi(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}class qT{constructor(t,r=0){be(this,"buffer"),be(this,"offset"),this.buffer=t,this.offset=r,ft(Ln([Me,oi]),[t,r])}readUInt8(){const t=si(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=j5(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=to(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=zg(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=oo(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){zT(t,WT);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}}const C1=192,GT=128,XT=e=>"left"in e&&"right"in e;function wh(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);ee(n,o)<0?n=mh(n,o):n=mh(o,n)}return n}function bh(e){if(sh(e))return{hash:li(e)};const t=[bh(e[0]),bh(e[1])];t.sort((i,o)=>ee(i.hash,o.hash));const[r,n]=t;return{hash:mh(r.hash,n.hash),left:r,right:n}}function gu(e,t){if(XT(e)){const r=gu(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=gu(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(ee(e.hash,t)===0)return[]}function li(e){const t=e.version||C1;return du("TapLeaf",lt([Uint8Array.from([t]),YT(e.output)]))}function JT(e,t){return du("TapTweak",lt(t?[e,t]:[e]))}function wu(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=JT(e,t),n=yh().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function mh(e,t){return du("TapBranch",lt([e,t]))}function YT(e){const t=Vr(e.length),r=new Uint8Array(t);return Wi(e.length,r),lt([r,e])}const N1=qe,U1=1,ZT=80;function ha(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Di(It({address:Es(),input:Ut(0),network:It({}),output:Ut(34),internalPubkey:Ut(32),hash:Ut(32),pubkey:Ut(32),signature:ih([Ut(64),Ut(65)]),witness:pr(Me),scriptTree:yn(n1,"Taptree is not of type isTaptree"),redeem:Di(It({output:Me,redeemVersion:yr(),witness:pr(Me)})),redeemVersion:yr()})),e);const r=Mr(()=>D1(e.address)),n=Mr(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===ZT?e.witness.slice(0,-1):e.witness.slice()}),i=Mr(()=>{if(e.scriptTree)return bh(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||pn,s={name:"p2tr",network:o};if(ye(s,"address",()=>{if(!s.pubkey)return;const a=ca.toWords(s.pubkey);return a.unshift(U1),ca.encode(o.bech32,a)}),ye(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const h=u[u.length-1],f=h[0]&ou,d=u[u.length-2],g=li({output:d,version:f});return wh(h,g)}return null}),ye(s,"output",()=>{if(s.pubkey)return gr([N1.OP_1,s.pubkey])}),ye(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:C1),ye(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&ou}}),ye(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=wu(s.internalPubkey,s.hash);if(a)return a.x}}),ye(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),ye(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),ye(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=li({output:e.redeem.output,version:s.redeemVersion}),h=gu(a,u);if(!h)return;const f=wu(e.internalPubkey,a.hash);if(!f)return;const d=lt([Uint8Array.from([s.redeemVersion|f.parity]),e.internalPubkey].concat(h));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==U1)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&ee(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==N1.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&ee(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const f=wu(e.internalPubkey,s.hash);if(a.length>0&&ee(a,f.x)!==0)throw new TypeError("Pubkey mismatch");a=f.x}if(a&&a.length&&!yh().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&ee(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const f=li({output:e.redeem.output,version:s.redeemVersion});if(!gu(u,f))throw new TypeError("Redeem script not in tree")}const h=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(wt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&ee(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!ra(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(h&&h.length)if(h.length===1){if(e.signature&&ee(e.signature,h[0])!==0)throw new TypeError("Signature mismatch")}else{const f=h[h.length-1];if(f.length<33)throw new TypeError(`The control-block length is too small. Got ${f.length}, expected min 33.`);if((f.length-33)%32!==0)throw new TypeError(`The control-block length of ${f.length} is incorrect!`);const d=(f.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=f.slice(1,33);if(e.internalPubkey&&ee(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!yh().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=f[0]&ou,E=h[h.length-2],T=li({output:E,version:v}),x=wh(f,T),N=wu(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&ee(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(f[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const R1=40,B1=2,L1=16,H1=2,K1=80,j1="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function QT(e,t){const r=e.slice(2);if(r.length<B1||r.length>R1)throw new TypeError("Invalid program length for segwit address");const n=e[0]-K1;if(n<H1||n>L1)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(j1),t_(r,n,t.bech32)}function e_(e){const t=ia.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=si(t,0),n=t.slice(1);return{version:r,hash:n}}function D1(e){let t,r;try{t=Or.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=ca.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=Or.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function t_(e,t,r){const n=Or.toWords(e);return n.unshift(t),t===0?Or.encode(r,n):ca.encode(r,n)}function da(e,t){t=t||pn;try{return sa({output:e,network:t}).address}catch{}try{return io({output:e,network:t}).address}catch{}try{return ua({output:e,network:t}).address}catch{}try{return la({output:e,network:t}).address}catch{}try{return ha({output:e,network:t}).address}catch{}try{return QT(e,t)}catch{}throw new Error(nT(e)+" has no matching Address")}function M1(e,t){t=t||pn;let r,n;try{r=e_(e)}catch{}if(r){if(r.version===t.pubKeyHash)return sa({hash:r.hash}).output;if(r.version===t.scriptHash)return io({hash:r.hash}).output}else{try{n=D1(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return ua({hash:n.data}).output;if(n.data.length===32)return la({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return ha({pubkey:n.data}).output}else if(n.version>=H1&&n.version<=L1&&n.data.length>=B1&&n.data.length<=R1)return console.warn(j1),gr([n.version+K1,n.data])}}throw new Error(e+" has no matching Script")}function Kn(e){const t=e.length;return Vr(t)+t}function r_(e){const t=e.length;return Vr(t)+e.reduce((r,n)=>r+Kn(n),0)}const zi=new Uint8Array(0),F1=[],vh=ii("0000000000000000000000000000000000000000000000000000000000000000"),V1=ii("0000000000000000000000000000000000000000000000000000000000000001"),n_=ii("ffffffffffffffff"),i_={script:zi,valueBuffer:n_};function s_(e){return e.value!==void 0}const wn=class et{constructor(){be(this,"version",1),be(this,"locktime",0),be(this,"ins",[]),be(this,"outs",[])}static fromBuffer(t,r){const n=new qT(t),i=new et;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===et.ADVANCED_TRANSACTION_MARKER&&s===et.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let f=0;f<u;++f)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:F1});const h=n.readVarInt();for(let f=0;f<h;++f)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let f=0;f<u;++f)i.ins[f].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==t.length)throw new Error("Transaction has unexpected data");return i}static fromHex(t){return et.fromBuffer(ii(t),!1)}static isCoinbaseHash(t){ft(i1,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&et.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return ft(Ln([i1,oi,nh(su(oi)),nh(su(Me))]),[t,r,n,i]),n==null&&(n=et.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||zi,sequence:n,witness:F1})-1}addOutput(t,r){return ft(Ln([Me,oh]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Vr(this.ins.length)+Vr(this.outs.length)+this.ins.reduce((n,i)=>n+40+Kn(i.script),0)+this.outs.reduce((n,i)=>n+8+Kn(i.script),0)+(r?this.ins.reduce((n,i)=>n+r_(i.witness),0):0)}clone(){const t=new et;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(ft(Ln([oi,Me,yr()]),[t,r,n]),t>=this.ins.length)return V1;const i=gr(wt(r).filter(a=>a!==qe.OP_CODESEPARATOR)),o=this.clone();if((n&31)===et.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===et.SIGHASH_SINGLE){if(t>=this.outs.length)return V1;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=i_;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&et.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=zi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Vg(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),As(s)}hashForWitnessV1(t,r,n,i,o,s){if(ft(Ln([oi,pr(Me),pr(oh),oi]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===et.SIGHASH_DEFAULT?et.SIGHASH_ALL:i&et.SIGHASH_OUTPUT_MASK,u=(i&et.SIGHASH_INPUT_MASK)===et.SIGHASH_ANYONECANPAY,h=a===et.SIGHASH_NONE,f=a===et.SIGHASH_SINGLE;let d=zi,g=zi,v=zi,E=zi,T=zi;if(!u){let k=qt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=rr(k.end()),k=qt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=rr(k.end()),k=qt.withCapacity(r.map(Kn).reduce((B,z)=>B+z)),r.forEach(B=>k.writeVarSlice(B)),v=rr(k.end()),k=qt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=rr(k.end())}if(h||f){if(f&&t<this.outs.length){const k=this.outs[t],B=qt.withCapacity(8+Kn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=rr(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(z=>8+Kn(z.script)).reduce((z,V)=>z+V),B=qt.withCapacity(k);this.outs.forEach(z=>{B.writeInt64(z.value),B.writeVarSlice(z.script)}),T=rr(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(h?32:0)+(s?32:0)+(o?37:0),I=qt.withCapacity(N);if(I.writeUInt8(i),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(d),I.writeSlice(g),I.writeSlice(v),I.writeSlice(E),h||f||I.writeSlice(T),I.writeUInt8(x),u){const k=this.ins[t];I.writeSlice(k.hash),I.writeUInt32(k.index),I.writeInt64(n[t]),I.writeVarSlice(r[t]),I.writeUInt32(k.sequence)}else I.writeUInt32(t);if(s){const k=qt.withCapacity(Kn(s));k.writeVarSlice(s),I.writeSlice(rr(k.end()))}return f&&I.writeSlice(T),o&&(I.writeSlice(o),I.writeUInt8(0),I.writeUInt32(4294967295)),du("TapSighash",lt([Uint8Array.from([0]),I.end()]))}hashForWitnessV0(t,r,n,i){ft(Ln([oi,Me,oh,oi]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=vh,u=vh,h=vh;if(i&et.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=As(o)),!(i&et.SIGHASH_ANYONECANPAY)&&(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),h=As(o)),(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+Kn(v.script),0);o=new Uint8Array(d),s=new qt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=As(o)}else if((i&31)===et.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+Kn(d.script)),s=new qt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=As(o)}o=new Uint8Array(156+Kn(r)),s=new qt(o,0);const f=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(h),s.writeSlice(f.hash),s.writeUInt32(f.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(f.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),As(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):As(this.__toBuffer(void 0,void 0,t))}getId(){return Ee(gh(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return Ee(this.toBuffer(void 0,void 0))}setInputScript(t,r){ft(Ln([yr(),Me]),[t,r]),this.ins[t].script=r}setWitness(t,r){ft(Ln([yr(),pr(Me)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new qt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(et.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(et.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{s_(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};be(wn,"DEFAULT_SEQUENCE",4294967295),be(wn,"SIGHASH_DEFAULT",0),be(wn,"SIGHASH_ALL",1),be(wn,"SIGHASH_NONE",2),be(wn,"SIGHASH_SINGLE",3),be(wn,"SIGHASH_ANYONECANPAY",128),be(wn,"SIGHASH_OUTPUT_MASK",3),be(wn,"SIGHASH_INPUT_MASK",128),be(wn,"ADVANCED_TRANSACTION_MARKER",0),be(wn,"ADVANCED_TRANSACTION_FLAG",1);let Tt=wn;var jn;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})(jn||(jn={}));var se;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(se||(se={}));var _t;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(_t||(_t={}));const o_=e=>[...Array(e).keys()];function a_(e){if(e.key[0]!==jn.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+Ee(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+Ee(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of o_(e.value.length/4-1)){const i=to(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function c_(e){const t=new Uint8Array([jn.GLOBAL_XPUB]),r=lt([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),ea(i,o,u,"LE"),o+=4}),{key:r,value:i}}const u_="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function l_(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function f_(e,t,r){const n=Ee(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.extendedPubkey,t.extendedPubkey)).length===0)}const h_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:f_,check:l_,decode:a_,encode:c_,expected:u_},Symbol.toStringTag,{value:"Module"}));function d_(e){return{key:new Uint8Array([jn.UNSIGNED_TX]),value:e.toBuffer()}}const p_=Object.freeze(Object.defineProperty({__proto__:null,encode:d_},Symbol.toStringTag,{value:"Module"}));function y_(e){if(e.key[0]!==se.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+Ee(e.key));return e.value}function g_(e){return{key:new Uint8Array([se.FINAL_SCRIPTSIG]),value:e}}const w_="Uint8Array";function b_(e){return e instanceof Uint8Array}function m_(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const v_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:m_,check:b_,decode:y_,encode:g_,expected:w_},Symbol.toStringTag,{value:"Module"}));function E_(e){if(e.key[0]!==se.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+Ee(e.key));return e.value}function A_(e){return{key:new Uint8Array([se.FINAL_SCRIPTWITNESS]),value:e}}const S_="Uint8Array";function T_(e){return e instanceof Uint8Array}function __(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const k_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:__,check:T_,decode:E_,encode:A_,expected:S_},Symbol.toStringTag,{value:"Module"}));function P_(e){if(e.key[0]!==se.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+Ee(e.key));return e.value}function O_(e){return{key:new Uint8Array([se.NON_WITNESS_UTXO]),value:e}}const I_="Uint8Array";function x_(e){return e instanceof Uint8Array}function $_(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const C_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$_,check:x_,decode:P_,encode:O_,expected:I_},Symbol.toStringTag,{value:"Module"}));function N_(e){if(e.key[0]!==se.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+Ee(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+Ee(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function U_(e){const t=new Uint8Array([se.PARTIAL_SIG]);return{key:lt([t,e.pubkey]),value:e.signature}}const R_="{ pubkey: Uint8Array; signature: Uint8Array; }";function B_(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&L_(e.signature)}function L_(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function H_(e,t,r){const n=Ee(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0).length===0)}const K_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:H_,check:B_,decode:N_,encode:U_,expected:R_},Symbol.toStringTag,{value:"Module"}));function j_(e){if(e.key[0]!==se.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+Ee(e.key));return C5(e.value)}function D_(e){return{key:new Uint8Array([se.POR_COMMITMENT]),value:N5(e)}}const M_="string";function F_(e){return typeof e=="string"}function V_(e,t){return!!e&&!!t&&e.porCommitment===void 0}const W_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:V_,check:F_,decode:j_,encode:D_,expected:M_},Symbol.toStringTag,{value:"Module"}));function z_(e){if(e.key[0]!==se.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+Ee(e.key));return Number(to(e.value,0,"LE"))}function q_(e){const t=Uint8Array.from([se.SIGHASH_TYPE]),r=new Uint8Array(4);return ea(r,0,e,"LE"),{key:t,value:r}}const G_="number";function X_(e){return typeof e=="number"}function J_(e,t){return!!e&&!!t&&e.sighashType===void 0}const Y_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:J_,check:X_,decode:z_,encode:q_,expected:G_},Symbol.toStringTag,{value:"Module"}));function Z_(e){if(e.key[0]!==se.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+Ee(e.key));if(!W1(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function Q_(e){return{key:Uint8Array.from([se.TAP_KEY_SIG]),value:e}}const ek="Uint8Array";function W1(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function tk(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const rk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:tk,check:W1,decode:Z_,encode:Q_,expected:ek},Symbol.toStringTag,{value:"Module"}));function nk(e){if(e.key[0]!==se.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+Ee(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+Ee(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+Ee(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function ik(e){const t=Uint8Array.from([se.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:lt([t,e.controlBlock]),value:lt([e.script,r])}}const sk="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function ok(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ak(e,t,r){const n=Ee(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.controlBlock,t.controlBlock)===0).length===0)}const ck=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ak,check:ok,decode:nk,encode:ik,expected:sk},Symbol.toStringTag,{value:"Module"}));function uk(e){if(e.key[0]!==se.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+Ee(e.key));if(!z1(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function lk(e){return{key:Uint8Array.from([se.TAP_MERKLE_ROOT]),value:e}}const fk="Uint8Array";function z1(e){return e instanceof Uint8Array&&e.length===32}function hk(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const dk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:hk,check:z1,decode:uk,encode:lk,expected:fk},Symbol.toStringTag,{value:"Module"}));function pk(e){if(e.key[0]!==se.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+Ee(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+Ee(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+Ee(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function yk(e){const t=Uint8Array.from([se.TAP_SCRIPT_SIG]);return{key:lt([t,e.pubkey,e.leafHash]),value:e.signature}}const gk="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function wk(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function bk(e,t,r){const n=Ee(t.pubkey)+Ee(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0&&ee(i.leafHash,t.leafHash)===0).length===0)}const mk=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:bk,check:wk,decode:pk,encode:yk,expected:gk},Symbol.toStringTag,{value:"Module"}));function vk(e){if(e.key[0]!==se.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+Ee(e.key));const t=zg(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=oo(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function Ek(e){const{script:t,value:r}=e,n=Vr(t.length),i=new Uint8Array(8+n+t.length);return Wg(i,0,BigInt(r),"LE"),Wi(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([se.WITNESS_UTXO]),value:i}}const Ak="{ script: Uint8Array; value: bigint; }";function Sk(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function Tk(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const _k=Object.freeze(Object.defineProperty({__proto__:null,canAdd:Tk,check:Sk,decode:vk,encode:Ek,expected:Ak},Symbol.toStringTag,{value:"Module"}));function kk(e){if(e.key[0]!==_t.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+Ee(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=oo(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function Pk(e){const t=Uint8Array.from([_t.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),Wi(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:lt(r)}}const Ok="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function Ik(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function xk(e,t){return!!e&&!!t&&e.tapTree===void 0}const $k=Object.freeze(Object.defineProperty({__proto__:null,canAdd:xk,check:Ik,decode:kk,encode:Pk,expected:Ok},Symbol.toStringTag,{value:"Module"})),Ck=e=>[...Array(e).keys()],Nk=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Eh(e,t=Nk){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+Ee(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+Ee(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const h={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const f of Ck(a.value.length/4-1)){const d=to(a.value,f*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;h.path+="/"+v.toString(10)+(g?"'":"")}return h}function n(a){const u=Uint8Array.from([e]),h=lt([u,a.pubkey]),f=a.path.split("/"),d=new Uint8Array(f.length*4);d.set(a.masterFingerprint,0);let g=4;return f.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),ea(d,g,T,"LE"),g+=4}),{key:h,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,h){const f=Ee(u.pubkey);return h.has(f)?!1:(h.add(f),a.filter(d=>ee(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Ah(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+Ee(r.key));return n}}function q1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Uk=e=>e.length===32;function G1(e){const t=Eh(e,Uk);function r(s){const{numberValue:a,bytes:u}=oo(s.value),h=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),f=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)f[d]=s.value.slice(g,g+32);return{...h,leafHashes:f}}function n(s){const a=t.encode(s),u=Vr(s.leafHashes.length),h=new Uint8Array(u);Wi(s.leafHashes.length,h);const f=lt([h,...s.leafHashes,a.value]);return{...a,value:f}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function X1(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+Ee(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function J1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Sh={unsignedTx:p_,globalXpub:h_,checkPubkey:Ah([])},Rt={nonWitnessUtxo:C_,partialSig:K_,sighashType:Y_,finalScriptSig:v_,finalScriptWitness:k_,porCommitment:W_,witnessUtxo:_k,bip32Derivation:Eh(se.BIP32_DERIVATION),redeemScript:q1(se.REDEEM_SCRIPT),witnessScript:J1(se.WITNESS_SCRIPT),checkPubkey:Ah([se.PARTIAL_SIG,se.BIP32_DERIVATION]),tapKeySig:rk,tapScriptSig:mk,tapLeafScript:ck,tapBip32Derivation:G1(se.TAP_BIP32_DERIVATION),tapInternalKey:X1(se.TAP_INTERNAL_KEY),tapMerkleRoot:dk},fi={bip32Derivation:Eh(_t.BIP32_DERIVATION),redeemScript:q1(_t.REDEEM_SCRIPT),witnessScript:J1(_t.WITNESS_SCRIPT),checkPubkey:Ah([_t.BIP32_DERIVATION]),tapBip32Derivation:G1(_t.TAP_BIP32_DERIVATION),tapTree:$k,tapInternalKey:X1(_t.TAP_INTERNAL_KEY)},Rk=Object.freeze(Object.defineProperty({__proto__:null,globals:Sh,inputs:Rt,outputs:fi},Symbol.toStringTag,{value:"Module"})),bu=e=>[...Array(e).keys()];function Y1(e){const t=e.map(Bk);return t.push(Uint8Array.from([0])),lt(t)}function Bk(e){const t=e.key.length,r=e.value.length,n=Vr(t),i=Vr(r),o=new Uint8Array(n+t+i+r);return Wi(t,o,0),o.set(e.key,n),Wi(r,o,n+t),o.set(e.value,n+t+i),o}function Lk(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=oo(e,r);r+=N;const I=e.slice(r,r+Number(x));return r+=Number(x),I}function i(){const x=to(e,r,"BE");return r+=4,x}function o(){const x=si(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=si(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],h={};for(;!a();){const x=s(),N=Ee(x.key);if(h[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);h[N]=1,u.push(x)}const f=u.filter(x=>x.key[0]===jn.UNSIGNED_TX);if(f.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(f[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of bu(g)){const N={},I=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,I.push(k)}E.push(I)}for(const x of bu(v)){const N={},I=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,I.push(k)}T.push(I)}return Z1(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Gt(e,t,r){if(ee(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${Ee(t)}`)}function Z1(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const f of t)switch(f.key[0]){case jn.UNSIGNED_TX:if(Gt("global",f.key,jn.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case jn.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Sh.globalXpub.decode(f));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(f)}const s=r.length,a=n.length,u=[],h=[];for(const f of bu(s)){const d={};for(const g of r[f])switch(Rt.checkPubkey(g),g.key[0]){case se.NON_WITNESS_UTXO:if(Gt("input",g.key,se.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Rt.nonWitnessUtxo.decode(g);break;case se.WITNESS_UTXO:if(Gt("input",g.key,se.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Rt.witnessUtxo.decode(g);break;case se.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Rt.partialSig.decode(g));break;case se.SIGHASH_TYPE:if(Gt("input",g.key,se.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Rt.sighashType.decode(g);break;case se.REDEEM_SCRIPT:if(Gt("input",g.key,se.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Rt.redeemScript.decode(g);break;case se.WITNESS_SCRIPT:if(Gt("input",g.key,se.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Rt.witnessScript.decode(g);break;case se.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Rt.bip32Derivation.decode(g));break;case se.FINAL_SCRIPTSIG:Gt("input",g.key,se.FINAL_SCRIPTSIG),d.finalScriptSig=Rt.finalScriptSig.decode(g);break;case se.FINAL_SCRIPTWITNESS:Gt("input",g.key,se.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Rt.finalScriptWitness.decode(g);break;case se.POR_COMMITMENT:Gt("input",g.key,se.POR_COMMITMENT),d.porCommitment=Rt.porCommitment.decode(g);break;case se.TAP_KEY_SIG:Gt("input",g.key,se.TAP_KEY_SIG),d.tapKeySig=Rt.tapKeySig.decode(g);break;case se.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Rt.tapScriptSig.decode(g));break;case se.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Rt.tapLeafScript.decode(g));break;case se.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Rt.tapBip32Derivation.decode(g));break;case se.TAP_INTERNAL_KEY:Gt("input",g.key,se.TAP_INTERNAL_KEY),d.tapInternalKey=Rt.tapInternalKey.decode(g);break;case se.TAP_MERKLE_ROOT:Gt("input",g.key,se.TAP_MERKLE_ROOT),d.tapMerkleRoot=Rt.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const f of bu(a)){const d={};for(const g of n[f])switch(fi.checkPubkey(g),g.key[0]){case _t.REDEEM_SCRIPT:if(Gt("output",g.key,_t.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=fi.redeemScript.decode(g);break;case _t.WITNESS_SCRIPT:if(Gt("output",g.key,_t.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=fi.witnessScript.decode(g);break;case _t.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(fi.bip32Derivation.decode(g));break;case _t.TAP_INTERNAL_KEY:Gt("output",g.key,_t.TAP_INTERNAL_KEY),d.tapInternalKey=fi.tapInternalKey.decode(g);break;case _t.TAP_TREE:Gt("output",g.key,_t.TAP_TREE),d.tapTree=fi.tapTree.decode(g);break;case _t.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(fi.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}h.push(d)}return{globalMap:i,inputs:u,outputs:h}}function Hk({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=_h({globalMap:e,inputs:t,outputs:r}),s=Y1(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(Y1),u=a(i),h=a(o),f=new Uint8Array(5);return f.set([112,115,98,116,255],0),lt([f,s].concat(u,h))}const Kk=(e,t)=>ee(e.key,t.key);function Th(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const h=(Array.isArray(a)?a:[a]).map(u.encode);return h.map(f=>Ee(f.key)).forEach(f=>{if(r.has(f))throw new Error("Serialize Error: Duplicate key: "+f);r.add(f)}),o.concat(h)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(Ee(o.key))):[];return n.concat(i).sort(Kk)}function _h({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Th(e,Sh),inputKeyVals:t.map(n=>Th(n,Rt)),outputKeyVals:r.map(n=>Th(n,fi))}}function jk(e){const t=e[0],r=_h(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Q1(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=ao(r.globalKeyVals),s=r.inputKeyVals.map(ao),a=r.outputKeyVals.map(ao);for(const u of n){const h=Q1(u);if(h===void 0||ee(h.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const f=_h(u);ao(f.globalKeyVals).forEach(kh(o,r.globalKeyVals,f.globalKeyVals)),f.inputKeyVals.map(ao).forEach((d,g)=>d.forEach(kh(s[g],r.inputKeyVals[g],f.inputKeyVals[g]))),f.outputKeyVals.map(ao).forEach((d,g)=>d.forEach(kh(a[g],r.outputKeyVals[g],f.outputKeyVals[g])))}return Z1(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function kh(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>Ee(o.key)===n)[0];t.push(i),e.add(n)}}function Q1(e){return e.globalMap.unsignedTx}function ao(e){const t=new Set;return e.forEach(r=>{const n=Ee(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function jt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function pa(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Ph(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>ee(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${Ee(e.key)}`)}function Oh(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function Dk(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function ew(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Ih(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=Rk[e+"s"][n]||{},h=!!s;if(a)if(h){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||ew(e,n,u,i);const f=r[n]||[],d=new Set;if(!i.every(g=>s(f,g,d)))throw new Error("Can not add duplicate data to array");r[n]=f.concat(i)}else{if(a(i)||ew(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const Mk=Ih("global"),tw=Ih("input"),rw=Ih("output");function Fk(e,t){const r=e.length-1,n=jt(e,r);tw(t,n)}function Vk(e,t){const r=e.length-1,n=pa(e,r);rw(t,n)}let nw=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,t){const r=Fg(e);return this.fromBuffer(r,t)}static fromHex(e,t){const r=ii(e);return this.fromBuffer(r,t)}static fromBuffer(e,t){const r=Lk(e,t),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){const e=this.toBuffer();return B5(e)}toHex(){const e=this.toBuffer();return Ee(e)}toBuffer(){return Hk(this)}updateGlobal(e){return Mk(e,this.globalMap),this}updateInput(e,t){const r=jt(this.inputs,e);return tw(t,r),this}updateOutput(e,t){const r=pa(this.outputs,e);return rw(t,r),this}addUnknownKeyValToGlobal(e){return Ph(e,this.globalMap.unknownKeyVals,Oh(jn)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=jt(this.inputs,e);return Ph(t,r.unknownKeyVals,Oh(se)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=pa(this.outputs,e);return Ph(t,r.unknownKeyVals,Oh(_t)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addInput(e){this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach(n=>this.addUnknownKeyValToInput(r,n)),Fk(this.inputs,e),this}addOutput(e){this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach(n=>this.addUnknownKeyValToOutput(r,n)),Vk(this.outputs,e),this}clearFinalizedInput(e){const t=jt(this.inputs,e);Dk(e,t);for(const r of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(r)||delete t[r];return this}combine(...e){const t=jk([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function Ss(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const Wk=Ss(lu),zk=Ss(y1),qk=Ss(sa),mu=Ss(ua),iw=Ss(la),sw=Ss(io),ow=Ss(ha);function vu(e){let t=new Uint8Array(0);function r(s){t=lt([t,s])}function n(s){const a=t.length,u=Vr(s);t=lt([t,new Uint8Array(u)]),Wi(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function aw(e,t){const r=ci(e),n=e.slice(1,33),i=wt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:ee(e,o)===0||ee(r,o)===0||ee(n,o)===0)}function Eu(e,t){return aw(e,t)!==-1}function Gk(e,t){return Xk(e).some(r=>cw(r,na.decode,t))}function cw(e,t,r){const{hashType:n}=t(e),i=[];switch(n&Tt.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case Tt.SIGHASH_ALL:break;case Tt.SIGHASH_SINGLE:case Tt.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function Xk(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=Jk(e)}else t=e.partialSig;return t.map(r=>r.signature)}function Jk(e){const t=e.finalScriptSig?wt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?wt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&ai(n)).map(n=>({signature:n}))}const Au=e=>e.length===32?e:e.slice(1,33);function uw(e,t,r){const n=lP(t,e,r);try{const i=cP(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:vu(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function Su(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return lt([e,r])}function bn(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&ow(e.witnessUtxo.script))}function xh(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function lw(e,t,r){sP(e,t,r),aP(e,t,r)}function fw(e,t,r){oP(e,t,r),Yk(e,t)}function Yk(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=Zk(r,n);if(i&&ee(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function Zk(e,t){const r=t&&Qk(t.leaves),{output:n}=ha({internalPubkey:e,scriptTree:r});return n}function Qk(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:iP(e)}function eP(e,t){return rP(e).some(r=>cw(r,tP,t))}function tP(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||Tt.SIGHASH_DEFAULT}}function rP(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=nP(e.finalScriptWitness);r&&t.push(r)}return t}function nP(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function iP(e){let t;for(const r of e)if(t=$h(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function $h(e,t,r=0){if(r>GT)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(sh(t))return;const n=$h(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=$h(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function sP(e,t,r){const n=bn(e)&&co(t),i=co(e)&&bn(t),o=e===t&&bn(t)&&co(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function oP(e,t,r){const n=xh(e)&&co(t),i=co(e)&&xh(t),o=e===t&&xh(t)&&co(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function aP(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Ch(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Ch(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Ch(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Ch(e,t){if(!t)return!0;const r=li({output:e.script,version:e.leafVersion}),n=wh(e.controlBlock,r);return ee(n,t)===0}function cP(e,t){const r=li({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>ee(n.leafHash,r)===0).map(n=>uP(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function uP(e,t){return Object.assign({positionInScript:aw(t.pubkey,e)},t)}function lP(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>fP(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function fP(e,t,r){const n=li({output:e.script,version:e.leafVersion});return(!r||ee(n,r)===0)&&t.find(i=>ee(i.leafHash,n)===0)!==void 0}function co(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const hP={network:pn,maximumFeeRate:5e3};class bt{constructor(t={},r=new nw(new hw)){be(this,"data"),be(this,"__CACHE"),be(this,"opts"),this.data=r,this.opts=Object.assign({},hP,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Fg(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=ii(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=nw.fromBuffer(t,dP),i=new bt(r,n);return bP(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:$1(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=da(t.script,this.opts.network)}catch{}return{script:$1(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=bt.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){Tu(t),this.opts.maximumFeeRate=t}setVersion(t){Tu(t),ya(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){Tu(t),ya(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){Tu(r),ya(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");lw(t,t,"addInput"),ya(this.data.inputs,"addInput"),t.witnessScript&&Pu(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];ww(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&Rh(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");ya(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=M1(r,i);t=Object.assign({},t,{script:o})}fw(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(pw))throw new Error("Not finalized");const r=this.__CACHE;if(t||yP(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return Iw(this.data.inputs,n,r,!0),n}getFeeRate(){return Ew("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return Ew("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return jt(this.data.inputs,0),ga(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=jt(this.data.inputs,t);return bn(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=uw){const i=jt(this.data.inputs,t);if(bn(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=mP){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=SP(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);gP(r);const{finalScriptSig:u,finalScriptWitness:h}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),h&&this.data.updateInput(t,{finalScriptWitness:h}),!u&&!h)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=uw){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=ha({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=vu(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=jt(this.data.inputs,t),n=xw(t,r,this.__CACHE),i=ku(n,t,"input",r.redeemScript||OP(r.finalScriptSig),r.witnessScript||IP(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=Cw(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=jt(this.data.inputs,t);return kP(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=jt(this.data.inputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=pa(this.data.outputs,t);return PP(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=pa(this.data.outputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return jt(this.data.inputs,0),ga(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return bn(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>ee(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,h,f;for(const d of s){const g=na.decode(d.signature),{hash:v,script:E}=f!==g.hashType?Sw(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:h};f=g.hashType,u=v,h=E,gw(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&Au(n);const a=n?Uh(t,i,this.data.inputs,n,this.__CACHE):EP(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(f=>!f.leafHash);let h=0;if(o&&u){if(!r(u.pubkey,u.hash,_w(o)))return!1;h++}if(s)for(const f of s){const d=a.find(g=>ee(g.pubkey,f.pubkey)===0);if(d){if(!r(f.pubkey,d.hash,_w(f.signature)))return!1;h++}}return h>0}signAllInputsHD(t,r=[Tt.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of ga(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[Tt.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of ga(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[Tt.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return Pw(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[Tt.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=Pw(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of ga(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return bn(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(bn(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[Tt.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:na.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[Tt.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(h=>!h.leafHash).map(h=>Su(n.signSchnorr(h.hash),r.sighashType))[0],u=s.filter(h=>!!h.leafHash).map(h=>({pubkey:Au(n.publicKey),signature:Su(n.signSchnorr(h.hash),r.sighashType),leafHash:h.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return bn(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(bn(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[Tt.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:na.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[Tt.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(f=>!f.leafHash)[0];if(u){const f=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:Su(d,r.sighashType)}));a.push(f)}const h=s.filter(f=>!!f.leafHash);if(h.length){const f=h.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:Au(n.publicKey),signature:Su(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...f)}return Promise.all(a).then(f=>{f.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=Uh(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${Ee(n.publicKey)}`);return s}toBuffer(){return Nh(this.__CACHE),this.data.toBuffer()}toHex(){return Nh(this.__CACHE),this.data.toHex()}toBase64(){return Nh(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&Pu(r.witnessScript),lw(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&Rh(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return fw(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}const dP=e=>new hw(e);class hw{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){be(this,"tx"),this.tx=Tt.fromBuffer(t),wP(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?gh(ii(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function pP(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return dw(1,e.partialSig);case"multisig":const n=lu({output:t});return dw(n.m,e.partialSig,n.pubkeys);default:return!1}}function Nh(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function dw(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=xP(i);return t.find(s=>ee(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function pw(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function yw(e){return t=>!(ee(e.fingerprint,t.masterFingerprint)||ee(e.derivePath(t.path).publicKey,t.pubkey))}function Tu(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function yP(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}function ya(e,t){e.forEach(r=>{if(bn(r)?eP(r,t):Gk(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function gP(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=na.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function gw(e,t,r){if(!Eu(e,t))throw new Error(`Can not ${r} for this input with the key ${Ee(e)}`)}function wP(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function bP(e,t){e.ins.forEach(r=>{ww(t,r)})}function ww(e,t){const r=Ee(gh(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function bw(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(ee(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const mw=bw(io,"Redeem script"),vw=bw(la,"Witness script");function Ew(e,t,r,n){if(!r.every(pw))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),Iw(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function mP(e,t,r,n,i,o){const s=Cw(r);if(!pP(t,r,s))throw new Error(`Can not finalize input #${e}`);return vP(r,s,t.partialSig,n,i,o)}function vP(e,t,r,n,i,o){let s,a;const u=AP(e,t,r),h=o?la({redeem:u}):null,f=i?io({redeem:h||u}):null;return n?(h?a=vu(h.witness):a=vu(u.witness),f&&(s=f.input)):f?s=f.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function Aw(e,t,r,n,i){const o=jt(e,t),{hash:s,sighashType:a,script:u}=Sw(t,o,n,!1,i);return gw(r,u,"sign"),{hash:s,sighashType:a}}function Sw(e,t,r,n,i){const o=r.__TX,s=t.sighashType||Tt.SIGHASH_ALL;kw(s,i);let a,u;if(t.nonWitnessUtxo){const d=_u(r,t,e),g=o.ins[e].hash,v=d.getHash();if(ee(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:h,type:f}=ku(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)a=o.hashForWitnessV0(e,h,u.value,s);else if(mu(h)){const d=sa({hash:h.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${Ee(h)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&console.warn(`Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.
29
+ ***************************************************************************** */var sg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<sg.length;++t)e[sg.charCodeAt(t)]=t})();var og,Wh,Dc,zh=(og=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,O=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,O.push(T>>x&N);if(E)x>0&&O.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return O}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function f(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function h(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const O=(E=x).lastIndexOf("1");if(O===-1)return"No separator character for "+E;if(O===0)return"Missing prefix for "+E;const k=E.slice(0,O),B=E.slice(O+1);if(B.length<6)return"Data too short";let z=o(k);if(typeof z=="string")return z;const V=[];for(let Ue=0;Ue<B.length;++Ue){const He=B.charAt(Ue),Ge=n[He];if(Ge===void 0)return"Unknown character "+He;z=i(z)^Ge,Ue+6>=B.length||V.push(Ge)}return z!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let O=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,O+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)O+=r.charAt(N>>5*(5-k)&31);return O},toWords:a,fromWordsUnsafe:u,fromWords:f}}t.bech32=h("bech32"),t.bech32m=h("bech32m")},og(Wh={exports:{}},Wh.exports),Wh.exports);(Dc=zh)&&Dc.__esModule&&Object.prototype.hasOwnProperty.call(Dc,"default")&&Dc.default,zh.bech32m,zh.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var Ys,Zs;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(Ys||(Ys={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(Zs||(Zs={})),Zs.p2pkh,Ys.mainnet,Zs.p2pkh,Ys.testnet,Zs.p2sh,Ys.mainnet,Zs.p2sh,Ys.testnet;var Q8="accountChange";he({type:ut(Q8)});var e6="networkChange";he({type:ut(e6)});var t6="disconnect";he({type:ut(t6)});async function qh(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var ag=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(ag||{}),Gh=hn(xc([pe(),Rn(),ps()])),dr=he({jsonrpc:ut("2.0"),method:pe(),params:hn(xc([ln($c()),Hy({}),ps()])),id:Gh}),Mc=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(Mc||{}),cg=he({jsonrpc:ut("2.0"),result:Kh($c()),id:Gh}),ug=he({jsonrpc:ut("2.0"),error:Kh($c()),id:Gh});xc([cg,ug]);var Fc=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(Fc||{}),lg=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(lg||{}),r6=he({address:pe(),publicKey:pe(),purpose:ds(Fc),addressType:ds(lg)}),hg=async e=>{var t,r;const n=await qh(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Dr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},n6="stx_getAddresses",i6=ys(he({message:hn(pe())}));he({...dr.entries,...he({method:ut(n6),params:i6,id:pe()}).entries});var s6="stx_signTransaction",o6=he({transaction:pe(),pubkey:hn(pe()),broadcast:hn(Ly())});he({...dr.entries,...he({method:ut(s6),params:o6,id:pe()}).entries});var a6=["software","ledger"],c6=Ky(a6),u6="getInfo",l6=ys(ps());he({version:pe(),methods:hn(ln(pe())),supports:ln(pe())}),he({...dr.entries,...he({method:ut(u6),params:l6,id:pe()}).entries});var h6="getAddresses",f6=he({purposes:ln(ds(Fc)),message:hn(pe())});he({...dr.entries,...he({method:ut(h6),params:f6,id:pe()}).entries});var d6="signMessage",Vc=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(Vc||{}),p6=he({address:pe(),message:pe(),protocol:hn(ds(Vc))});he({signature:pe(),messageHash:pe(),address:pe(),protocol:ds(Vc)}),he({...dr.entries,...he({method:ut(d6),params:p6,id:pe()}).entries});var y6="getAccounts",g6=he({purposes:ln(ds(Fc)),message:hn(pe())});ln(he({...r6.entries,...he({walletType:c6}).entries})),he({...dr.entries,...he({method:ut(y6),params:g6,id:pe()}).entries});var w6="getBalance";ys(ps()),he({...dr.entries,...he({method:ut(w6),id:pe()}).entries});var b6="wallet_requestPermissions",m6=jh();ut(!0),he({...dr.entries,...he({method:ut(b6),params:m6,id:pe()}).entries});var v6="wallet_renouncePermissions",E6=jh();ut(!0),he({...dr.entries,...he({method:ut(v6),params:E6,id:pe()}).entries});var A6="wallet_getWalletType";ys(ps()),he({...dr.entries,...he({method:ut(A6),id:pe()}).entries});var S6="runes_getBalance",T6=ys(ps());he({balances:ln(he({runeName:pe(),amount:pe(),divisibility:Rn(),symbol:pe(),inscriptionId:ys(pe())}))}),he({...dr.entries,...he({method:ut(S6),params:T6,id:pe()}).entries});var _6="runes_transfer",k6=he({recipients:ln(he({runeName:pe(),amount:pe(),address:pe()}))});he({...dr.entries,...he({method:ut(_6),params:k6,id:pe()}).entries});var P6="ord_getInscriptions",I6=he({offset:Rn(),limit:Rn()});he({total:Rn(),limit:Rn(),offset:Rn(),inscriptions:ln(he({inscriptionId:pe(),inscriptionNumber:pe(),address:pe(),collectionName:hn(pe()),postage:pe(),contentLength:pe(),contentType:pe(),timestamp:Rn(),offset:Rn(),genesisTransaction:pe(),output:pe()}))}),he({...dr.entries,...he({method:ut(P6),params:I6,id:pe()}).entries});var O6="ord_sendInscriptions",x6=he({transfers:ln(he({address:pe(),inscriptionId:pe()}))});he({...dr.entries,...he({method:ut(O6),params:x6,id:pe()}).entries});var fg=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return By(ug,o)?{status:"error",error:o.error}:By(cg,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},$6=async e=>{var t,r;const n=await qh(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Dr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},C6=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),N6=async e=>{var t,r;const n=await qh(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=C6(i),f={network:s,senderAddress:o,message:a,recipients:u},h=Dr.createUnsecuredToken(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let dg=e=>e,Zo={},Bi={addEventListener(){},removeEventListener(){}};function U6(){try{return typeof localStorage<"u"}catch{return!1}}U6()&&(Zo=localStorage),typeof window<"u"&&(Bi={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function Qs(e,t={},r={}){let n=r.encode||dg,i=r.decode||dg,o=Nd(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&Bi.perKey&&Bi.removeEventListener(e+d,f,h),delete Zo[e+d]):(r.listen!==!1&&Bi.perKey&&!(d in o.value)&&Bi.addEventListener(e+d,f,h),Zo[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function f(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function h(){let d={...t};for(let g in Zo)g.startsWith(e)&&(d[g.slice(e.length)]=i(Zo[g]));for(let g in d)o.setKey(g,d[g])}return nm(o,()=>{if(h(),r.listen!==!1)return Bi.addEventListener(e,f,h),()=>{Bi.removeEventListener(e,f,h);for(let d in o.value)Bi.removeEventListener(e+d,f,h)}}),o}const pg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R6="XVERSE_CONNECTED_WALLET_STATE";class B6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(R6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of pg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Pn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):pg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){kn(this.$store,["provider"],t=>{t.provider!==Pn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Pn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Ms(this.network||tt);await hg({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=Lh(o.addresses),a=Hh(o.addresses);if(!s||!a)throw new Error("Could not find the addresses");s&&a&&(this.$store.setKey("provider",Pn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),er(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Pn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Pn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){const n=await fg("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await fg("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromBase64(String(n),{network:Qt(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=Bo(k,Qt(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Ms(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=Nt.fromBase64(String(O.psbtBase64),{network:Qt(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw Lr}}class L6 extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(is)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){kn(this.$store,["provider"],t=>{t.provider===is?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[is]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw I0;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",is),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?oh(r):void 0}async switchNetwork(t){var r;if(t===Zt||t===cs)return await this.library.switchNetwork(jo);const n=oh(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=Nt.fromHex(a);let f;return i&&o&&(f=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}async pushPsbt(t){return await Xe.post(`${Oi(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const yg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],H6="OYL_CONNECTED_WALLET_STATE";class K6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(H6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of yg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===bi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):yg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[bi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==bi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",bi),er(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await Uy(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=Nt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw Lr}}const gg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],j6="LEATHER_CONNECTED_WALLET_STATE";class D6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(j6,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of gg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===vi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):gg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==vi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Na),a=i.find(u=>u.type===fl);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==it&&this.network!==Yt&&this.network!==Jt)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",vi),er(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Na:fl;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=Nt.fromHex(String(a));if(i&&o){const f=u.finalizeAllInputs(),h=await this.pushPsbt(f.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}else if(i){const f=u.finalizeAllInputs();return{signedPsbtHex:f.toHex(),signedPsbtBase64:f.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=Nt.fromHex(t).extractTransaction();return await Xe.post(`${Oi(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Na);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await er(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw Lr}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw Lr}}var Xh={},wg={},fn={},bg={};Object.defineProperty(bg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const h=await s();if(h)return h}const f=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!f)throw new Error("No Orange Bitcoin wallet installed");return f}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(f=>f.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((f,h)=>f==null?void 0:f[h],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(bg,e)}(fn);var mg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(mg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Dr,i=fn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:h}=s.payload;if(!h)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await f.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(mg,e)}(wg);var vg={},Eg={},Ag={};Object.defineProperty(Ag,"__esModule",{value:!0});var Sg={};Object.defineProperty(Sg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Ag,e),r(Sg,e)}(Eg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=fn,i=async(s,a,u)=>{var f;let h=((f=window.OrangecryptoProviders)==null?void 0:f.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(h=await(0,n.getProviderById)(u)),!h)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await h.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(Eg,e)}(vg);var Tg={},_g={};Object.defineProperty(_g,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(a,u,f,h){h===void 0&&(h=f);var d=Object.getOwnPropertyDescriptor(u,f);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[f]}}),Object.defineProperty(a,h,d)}:function(a,u,f,h){h===void 0&&(h=f),a[h]=u[f]}),r=Se&&Se.__exportStar||function(a,u){for(var f in a)f!=="default"&&!Object.prototype.hasOwnProperty.call(u,f)&&t(u,a,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Dr,i=fn,o=(a,u)=>{const f=d=>!(!a[d]||u&&!u.has(d)),h={request:f("request"),connect:f("connect"),signMessage:f("signMessage"),signTransaction:f("signTransaction"),sendBtcTransaction:f("sendBtcTransaction"),createInscription:f("createInscription"),createRepeatInscriptions:f("createRepeatInscriptions"),signMultipleTransactions:f("signMultipleTransactions")};return Object.entries(h).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,f,h;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(f=a.onFinish)==null||f.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(h=a.onCancel)==null||h.call(a)}};e.getCapabilities=s,r(_g,e)}(Tg);var kg={},Wc={},Qo={};Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.validateInscriptionPayload=void 0;const M6=4e5,F6=6e4,V6=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?M6:F6))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Qo.validateInscriptionPayload=V6,Object.defineProperty(Wc,"__esModule",{value:!0}),Wc.createInscription=void 0;const W6=Dr,z6=fn,q6=Qo,G6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,z6.getProviderOrThrow)(n);(0,q6.validateInscriptionPayload)(e.payload);try{const o=(0,W6.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};Wc.createInscription=G6;var zc={};Object.defineProperty(zc,"__esModule",{value:!0}),zc.createRepeatInscriptions=void 0;const X6=fn,J6=Dr,Y6=Qo,Z6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,X6.getProviderOrThrow)(n);(0,Y6.validateInscriptionPayload)(e.payload);try{const o=(0,J6.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};zc.createRepeatInscriptions=Z6;var Pg={};Object.defineProperty(Pg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Wc,e),r(zc,e),r(Pg,e)}(kg);var Ig={},Og={};Object.defineProperty(Og,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Dr,i=fn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{address:h,message:d}=s.payload;if(!h)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await f.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Og,e)}(Ig);var xg={},qc={};Object.defineProperty(qc,"__esModule",{value:!0}),qc.sendBtcTransaction=void 0;const Q6=Dr,e5=fn,t5=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),r5=async e=>{var t,r;const n=await(0,e5.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=t5(i),f={network:s,senderAddress:o,message:a,recipients:u},h=(0,Q6.createUnsecuredToken)(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};qc.sendBtcTransaction=r5;var Gc={};Object.defineProperty(Gc,"__esModule",{value:!0}),Gc.signTransaction=void 0;const n5=Dr,i5=fn,s5=async e=>{var t,r;const n=await(0,i5.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,n5.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};Gc.signTransaction=s5;var Xc={};Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.signMultipleTransactions=void 0;const o5=Dr,a5=fn,c5=async e=>{var t,r;const n=await(0,a5.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,o5.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};Xc.signMultipleTransactions=c5;var $g={};Object.defineProperty($g,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(qc,e),r(Gc,e),r(Xc,e),r($g,e)}(xg);var Cg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Cg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(wg,e),r(vg,e),r(Tg,e),r(kg,e),r(Ig,e),r(fn,e),r(xg,e),r(Cg,e)}(Xh);const u5=uv(Xh),Ng=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:l5,sendBtcTransaction:h5,signTransaction:f5}=u5,d5="ORANGE_CONNECTED_WALLET_STATE";class p5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(d5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ng)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Ei&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ng.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ei]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],r=>{r.provider!==Ei?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Do(this.network||tt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=Lh(s.addresses),u=Hh(s.addresses);if(!a||!(u!=null&&u.address))throw new Error("Could not find addresses");a&&u&&(this.$store.setKey("provider",Ei),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),this.$store.setKey("publicKey",String(a.publicKey)),this.$store.setKey("paymentPublicKey",String(u.publicKey)),er(String(u==null?void 0:u.address),this.network).then(f=>{this.$store.setKey("balance",f)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Ei} wallet`)}};await Xh.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){let n="";const i={payload:{network:{type:Do(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await h5(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Do(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await l5(o),n}async signPsbt(t,r,n,i,o){const s=Nt.fromBase64(String(n),{network:Qt(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,f=s.data.inputs,h=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=Bo(k,Qt(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Do(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=Nt.fromBase64(String(O.psbtBase64),{network:Qt(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await f5(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=Nt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Xe.post(`${Oi(this.network)}/api/tx`,r).then(n=>n.data)}}const Ug=["address","paymentAddress","publicKey","paymentPublicKey","balance"],y5="OKX_CONNECTED_WALLET_STATE";class g5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(y5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===it||this.network===Yt||this.network===Jt||this.network===Zt?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===tt||this.network===cs)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ug)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ns&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ug.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ns]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],r=>{r.provider!==ns?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ns),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===it||r===Yt||r===Zt?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===it?it:r===Yt?Yt:r===Jt?Jt:r===Zt?Zt:it;const n=await this.library.getNetwork();return N0(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=Nt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}}const Rg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],w5="MAGIC_EDEN_CONNECTED_WALLET_STATE";class b5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(w5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Rg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Wn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Rg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Wn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==Wn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Ms(this.network||tt);await hg({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=Lh(o.addresses),a=Hh(o.addresses);if(!s||!a)throw new Error("No address found");s&&a&&(this.$store.setKey("provider",Wn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),er(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Wn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Wn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){let n;if(await N6({getProvider:async()=>this.library,payload:{network:{type:Ms(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await $6({getProvider:async()=>this.library,payload:{network:{type:ag.Mainnet},address:n,message:t,protocol:Vc.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromBase64(String(n),{network:Qt(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of f){const{script:B}=k.witnessUtxo,z=Bo(B,Qt(this.network));z===a?g.signingIndexes.push(Number(v)):z===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N=Ms(this.network),O={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:k=>{if(k.psbtBase64){const B=Nt.fromBase64(String(k.psbtBase64),{network:Qt(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(O),o){const k=Nt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}}class m5 extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[mi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{if(t.provider!==mi){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(mi):this.parent.disconnect())}handleNetworkChanged(t){const r=yc(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(mi)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",mi),er(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?it:tt}async sendBTC(t,r){const{psbtHex:n}=await Uy(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromHex(String(r),{network:Qt(this.network)}).data.inputs,f=[],h={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=Bo(x,Qt(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&h.signingIndexes.push(Number(g)),g++}h.signingIndexes.length>0&&f.push(h),d.signingIndexes.length>0&&f.push(d);const v=await this.library.signPsbt(r,{inputsToSign:f}),E=Nt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=sh(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}let v5=class{constructor(t,r){we(this,"$store"),we(this,"$network"),we(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[vi]:new D6(t,this,r),[Wn]:new b5(t,this,r),[ns]:new g5(t,this,r),[Ei]:new p5(t,this,r),[bi]:new K6(t,this,r),[mi]:new m5(t,this,r),[Vn]:new T8(t,this,r),[Pn]:new B6(t,this,r),[is]:new L6(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Cd(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Cd(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),_8()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(Ua);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(Ua,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(Ua)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(E8(t))s=Nt.fromHex(t).toBase64(),o=t;else if(v8(t))s=t,o=Nt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}};var E5=Object.defineProperty,A5=(e,t,r)=>t in e?E5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,be=(e,t,r)=>A5(e,typeof t!="symbol"?t+"":t,r);function S5(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let Jh=Symbol("clean"),dn=[],Li=0;const Jc=4;let Yh=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=Li+Jc;o<dn.length;)dn[o]===n?dn.splice(o,Jc):o+=Jc;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!dn.length;for(let s of t)dn.push(s,r.value,n,i);if(o){for(Li=0;Li<dn.length;Li+=Jc)dn[Li](dn[Li+1],dn[Li+2],dn[Li+3]);dn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[Jh]=()=>{t=[],r.lc=0,r.off()}),r};const T5=5,eo=6,Yc=10;let _5=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Yc]||(e.events[r+Yc]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Yc](),delete e.events[r+Yc])}),k5=1e3,P5=(e,t)=>_5(e,r=>{let n=t(r);n&&e.events[eo].push(n)},T5,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[eo]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[eo])o();e.events[eo]=[]}},k5)},process.env.NODE_ENV!=="production"){let o=e[Jh];e[Jh]=()=>{for(let s of e.events[eo])s();e.events[eo]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function Bn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Bg(e,t,r){let n=Bn(e,t,r);return r(e.value),n}let Lg=(e={})=>{let t=Yh(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const ws="oyl",Hi="unisat",ri="xverse",Ki="phantom",bs="leather",ni="magic-eden",ms="okx",vs="wizz",ji="orange",Hg="op_net",Zh="p2tr",Kg="p2wpkh",Qh="defaultWallet",pn={messagePrefix:`Bitcoin Signed Message:
30
+ `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},I5={messagePrefix:`Bitcoin Signed Message:
31
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function O5(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function x5(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function $5(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const qe={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,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_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,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_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT: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_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,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_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},jg={};for(const e of Object.keys(qe)){const t=qe[e];jg[t]=e}const Zc="0123456789abcdefABCDEF",Qc=Zc.split("").map(e=>e.codePointAt(0)),eu=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Zc.indexOf(r);return n<0?void 0:n<16?n:n-6}),Dg=new TextEncoder,Mg=new TextDecoder;function C5(e){return Mg.decode(e)}function N5(e){return Dg.encode(e)}function lt(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Ee(e){const t=e||new Uint8Array;return t.length>512?R5(t):U5(t)}function U5(e){let t="";for(let r=0;r<e.length;++r)t+=Zc[eu[Qc[e[r]>>4]]],t+=Zc[eu[Qc[e[r]&15]]];return t}function R5(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=Qc[e[r]>>4],t[r*2+1]=Qc[e[r]&15];return Mg.decode(t)}function ii(e){const t=Dg.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=eu[t[n*2]],o=eu[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function B5(e){return btoa(String.fromCharCode(...e))}function Fg(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function ee(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Pr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function L5(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function ea(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function H5(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function si(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function K5(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function to(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Vg(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function Wg(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function j5(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function zg(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function qg(e){return e<qe.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function D5(e,t,r){const n=qg(t);return n===1?Pr(e,r,t):n===2?(Pr(e,r,qe.OP_PUSHDATA1),Pr(e,r+1,t)):n===3?(Pr(e,r,qe.OP_PUSHDATA2),L5(e,r+1,t,"LE")):(Pr(e,r,qe.OP_PUSHDATA4),ea(e,r+1,t,"LE")),n}function M5(e,t){const r=si(e,t);let n,i;if(r<qe.OP_PUSHDATA1)n=r,i=1;else if(r===qe.OP_PUSHDATA1){if(t+2>e.length)return null;n=si(e,t+1),i=2}else if(r===qe.OP_PUSHDATA2){if(t+3>e.length)return null;n=K5(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==qe.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=to(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function F5(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function V5(e){let t=Math.abs(e);const r=F5(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Pr(n,o,t&255),t>>=8;return n[r-1]&128?Pr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function W5(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function z5(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function ta(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function zt(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??ta(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??z5(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function q5(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var G5=class extends Error{constructor(e){super(e[0].message),be(this,"issues"),this.name="ValiError",this.issues=e}};function Gg(e,t){return{kind:"validation",type:"every_item",reference:Gg,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&zt(this,"item",r,n),r}}}function ef(e){return{kind:"validation",type:"integer",reference:ef,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&zt(this,"integer",t,r),t}}}function Xg(e,t){return{kind:"validation",type:"length",reference:Xg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&zt(this,"length",r,n,{received:`${r.value.length}`}),r}}}function tu(e,t){return{kind:"validation",type:"max_value",reference:tu,async:!1,expects:`<=${e instanceof Date?e.toJSON():ta(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&zt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ta(r.value)}),r}}}function ru(e,t){return{kind:"validation",type:"min_value",reference:ru,async:!1,expects:`>=${e instanceof Date?e.toJSON():ta(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&zt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ta(r.value)}),r}}}function Jg(e,t){return{kind:"validation",type:"regex",reference:Jg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&zt(this,"format",r,n),r}}}function tf(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function nu(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Yg(){return{kind:"schema",type:"any",reference:Yg,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function pr(e,t){return{kind:"schema",type:"array",reference:pr,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else zt(this,"type",r,n);return r}}}function Zg(e){return{kind:"schema",type:"bigint",reference:Zg,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:zt(this,"type",t,r),t}}}function yn(e,t){return{kind:"schema",type:"custom",reference:yn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:zt(this,"type",r,n),r}}}function iu(e,t){return{kind:"schema",type:"instance",reference:iu,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:zt(this,"type",r,n),r}}}function rf(e,...t){const r={kind:"schema",type:"nullable",reference:rf,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=tf(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Qg(e,...t){const r={kind:"schema",type:"nullish",reference:Qg,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=tf(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function yr(e){return{kind:"schema",type:"number",reference:yr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:zt(this,"type",t,r),t}}}function Ot(e,t){return{kind:"schema",type:"object",reference:Ot,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else zt(this,"type",r,n);return r}}}function su(e,...t){const r={kind:"schema",type:"optional",reference:su,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=tf(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Es(e){return{kind:"schema",type:"string",reference:Es,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:zt(this,"type",t,r),t}}}function Ln(e,t){return{kind:"schema",type:"tuple",reference:Ln,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else zt(this,"type",r,n);return r}}}function e1(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function nf(e,t){return{kind:"schema",type:"union",reference:nf,expects:q5(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];zt(this,"type",r,n,{issues:e1(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];zt(this,"type",r,n,{issues:e1(s)})}return r}}}function ht(e,t,r){const n=e._run({typed:!1,value:t},W5(r));if(n.issues)throw new G5(n.issues);return n.value}function Di(e,t){const r={};for(const n in e.entries)r[n]=su(e.entries[n]);return{...e,entries:r}}function ro(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const t1=new Uint8Array(32),r1=ii("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ut=e=>ro(iu(Uint8Array),Xg(e));function ra(e,t){return e.length!==t.length?!1:e.every((r,n)=>ee(r,t[n])===0)}function gn(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(ee(t1,r)===0||ee(r,r1)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return ee(t1,n)===0||ee(n,r1)>=0?!1:t===4&&e.length===65}const ou=254;function sf(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&ou)===e.version:!0}function n1(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>n1(t)):sf(e)}const X5=Ut(32),J5=Ut(20),i1=Ut(32),Me=iu(Uint8Array);ro(Es(),Jg(/^([0-9a-f]{2})+$/i));const Y5=ro(yr(),ef(),ru(0),tu(255)),oi=ro(yr(),ef(),ru(0),tu(4294967295)),of=ro(Zg(),ru(0n),tu(0x7fffffffffffffffn)),s1=e=>Ot(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Qg(r[1])}),{})),o1=new Uint8Array(1);function a1(e){let t=0;for(;e[t]===0;)++t;return t===e.length?o1:(e=e.slice(t),e[0]&128?lt([o1,e]):e)}function c1(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Z5(e){const t=si(e,e.length-1);if(!cf(t))throw new Error("Invalid hashType "+t);const r=x5(e.subarray(0,-1)),n=c1(r.r),i=c1(r.s);return{signature:lt([n,i]),hashType:t}}function Q5(e,t){if(ht(Ot({signature:Ut(64),hashType:Y5}),{signature:e,hashType:t}),!cf(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Pr(r,0,t);const n=a1(e.slice(0,32)),i=a1(e.slice(32,64));return lt([$5(n,i),r])}const eT=Object.freeze(Object.defineProperty({__proto__:null,decode:Z5,encode:Q5},Symbol.toStringTag,{value:"Module"})),u1=qe.OP_RESERVED,l1=pr(nf([iu(Uint8Array),yr()]));function tT(e){return nu(yr(),e)&&(e===qe.OP_0||e>=qe.OP_1&&e<=qe.OP_16||e===qe.OP_1NEGATE)}function h1(e){return nu(Me,e)||tT(e)}function af(e){return nu(ro(Yg(),Gg(h1)),e)}function f1(e){return e.length-e.filter(h1).length}function au(e){if(e.length===0)return qe.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return u1+e[0];if(e[0]===129)return qe.OP_1NEGATE}}function d1(e){return e instanceof Uint8Array}function rT(e){return nu(l1,e)}function cu(e){return e instanceof Uint8Array}function gr(e){if(d1(e))return e;ht(l1,e);const t=e.reduce((i,o)=>cu(o)?o.length===1&&au(o)!==void 0?i+1:i+qg(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(cu(i)){const o=au(i);if(o!==void 0){Pr(r,n,o),n+=1;return}n+=D5(r,i.length,n),r.set(i,n),n+=i.length}else Pr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function wt(e){if(rT(e))return e;ht(Me,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>qe.OP_0&&n<=qe.OP_PUSHDATA4){const i=M5(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=au(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function nT(e){if(d1(e)&&(e=wt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(cu(t)){const r=au(t);if(r===void 0)return Ee(t);t=r}return jg[t]}).join(" ")}function iT(e){return e=wt(e),ht(yn(af),e),e.map(t=>cu(t)?t:t===qe.OP_0?new Uint8Array(0):V5(t-u1))}function sT(e){return gn(e)}function cf(e){const t=e&-129;return t>0&&t<4}function ai(e){return!(e instanceof Uint8Array)||!cf(e[e.length-1])?!1:O5(e.slice(0,-1))}const na=eT;function ye(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Mr(e){let t;return()=>(t!==void 0||(t=e()),t)}const no=qe,uu=no.OP_RESERVED;function lu(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return ai(a)||(t.allowIncomplete&&a===no.OP_0)!==void 0}ht(Di(Ot({network:Ot({}),m:yr(),n:yr(),output:Me,pubkeys:pr(yn(gn),"Received invalid pubkey"),signatures:pr(yn(r),"Expected signature to be of type isAcceptableSignature"),input:Me})),e);const n={network:e.network||pn};let i=[],o=!1;function s(a){o||(o=!0,i=wt(a),n.m=i[0]-uu,n.n=i[i.length-2]-uu,n.pubkeys=i.slice(1,-2))}if(ye(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return gr([].concat(uu+e.m,e.pubkeys,uu+n.n,no.OP_CHECKMULTISIG))}),ye(n,"m",()=>{if(n.output)return s(n.output),n.m}),ye(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),ye(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),ye(n,"signatures",()=>{if(e.input)return wt(e.input).slice(1)}),ye(n,"input",()=>{if(e.signatures)return gr([no.OP_0].concat(e.signatures))}),ye(n,"witness",()=>{if(n.input)return[]}),ye(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),ht(yr(),i[0],{message:"Output is invalid"}),ht(yr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==no.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>gn(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!ra(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==no.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!ra(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const p1=qe;function y1(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({network:Ot({}),output:Me,pubkey:yn(gn,"invalid pubkey"),signature:yn(ai,"Expected signature to be of type isCanonicalScriptSignature"),input:Me})),e);const r=Mr(()=>wt(e.input)),n={name:"p2pk",network:e.network||pn};if(ye(n,"output",()=>{if(e.pubkey)return gr([e.pubkey,p1.OP_CHECKSIG])}),ye(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),ye(n,"signature",()=>{if(e.input)return r()[0]}),ye(n,"input",()=>{if(e.signature)return gr([e.signature])}),ye(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==p1.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!gn(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&ee(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&ee(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!ai(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function oT(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function g1(e,...t){if(!oT(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function w1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function aT(e,t){g1(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uf=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Hn=(e,t)=>e<<32-t|e>>>t,hu=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function cT(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function b1(e){return typeof e=="string"&&(e=cT(e)),g1(e),e}class uT{clone(){return this._cloneInto()}}function m1(e){const t=n=>e().update(b1(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function lT(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const hT=(e,t,r)=>e&t^~e&r,fT=(e,t,r)=>e&t^e&r^t&r;let v1=class extends uT{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=uf(this.buffer)}update(e){w1(this);const{view:t,buffer:r,blockLen:n}=this;e=b1(e);const i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const a=uf(e);for(;n<=i-o;o+=n)this.process(a,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){w1(this),aT(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let h=o;h<n;h++)t[h]=0;lT(r,n-8,BigInt(this.length*8),i),this.process(r,0);const s=uf(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)s.setUint32(4*h,f[h],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}};const dT=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),E1=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),pT=E1.map(e=>(9*e+5)%16);let lf=[E1],hf=[pT];for(let e=0;e<4;e++)for(let t of[lf,hf])t.push(t[e].map(r=>dT[r]));const A1=[[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(e=>new Uint8Array(e)),yT=lf.map((e,t)=>e.map(r=>A1[t][r])),gT=hf.map((e,t)=>e.map(r=>A1[t][r])),wT=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),bT=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function S1(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const fu=new Uint32Array(16);class mT extends v1{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)fu[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,f=this.h3|0,h=f,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=wT[v],x=bT[v],N=lf[v],O=hf[v],k=yT[v],B=gT[v];for(let z=0;z<16;z++){const V=hu(n+S1(v,o,a,f)+fu[N[z]]+T,k[z])+d|0;n=d,d=f,f=hu(a,10)|0,a=o,o=V}for(let z=0;z<16;z++){const V=hu(i+S1(E,s,u,h)+fu[O[z]]+x,B[z])+g|0;i=g,g=h,h=hu(u,10)|0,u=s,s=V}}this.set(this.h1+a+h|0,this.h2+f+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){fu.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const vT=m1(()=>new mT),ET=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]),Mi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fi=new Uint32Array(64);let AT=class extends v1{constructor(){super(64,32,8,!1),this.A=Mi[0]|0,this.B=Mi[1]|0,this.C=Mi[2]|0,this.D=Mi[3]|0,this.E=Mi[4]|0,this.F=Mi[5]|0,this.G=Mi[6]|0,this.H=Mi[7]|0}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let h=0;h<16;h++,t+=4)Fi[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const d=Fi[h-15],g=Fi[h-2],v=Hn(d,7)^Hn(d,18)^d>>>3,E=Hn(g,17)^Hn(g,19)^g>>>10;Fi[h]=E+Fi[h-7]+v+Fi[h-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:f}=this;for(let h=0;h<64;h++){const d=Hn(s,6)^Hn(s,11)^Hn(s,25),g=f+d+hT(s,a,u)+ET[h]+Fi[h]|0,v=(Hn(r,2)^Hn(r,13)^Hn(r,22))+fT(r,n,i)|0;f=u,u=a,a=s,s=o+g|0,o=i,i=n,n=r,r=g+v|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,n,i,o,s,a,u,f)}roundClean(){Fi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const rr=m1(()=>new AT);function ci(e){return vT(rr(e))}function As(e){return rr(rr(e))}const ST={"BIP0340/challenge":Uint8Array.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":Uint8Array.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":Uint8Array.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:Uint8Array.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:Uint8Array.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:Uint8Array.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:Uint8Array.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":Uint8Array.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":Uint8Array.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function du(e,t){return rr(lt([ST[e],t]))}function TT(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let f=0;f<t.length;f++)t[f]=255;for(let f=0;f<e.length;f++){const h=e.charAt(f),d=h.charCodeAt(0);if(t[d]!==255)throw new TypeError(h+" is ambiguous");t[d]=f}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let h=0,d=0,g=0;const v=f.length;for(;g!==v&&f[g]===0;)g++,h++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let O=f[g],k=0;for(let B=E-1;(O!==0||k<d)&&B!==-1;B--,k++)O+=256*T[B]>>>0,T[B]=O%r>>>0,O=O/r>>>0;if(O!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(h);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let h=0,d=0,g=0;for(;f[h]===n;)d++,h++;const v=(f.length-h)*i+1>>>0,E=new Uint8Array(v);for(;f[h];){let O=t[f.charCodeAt(h)];if(O===255)return;let k=0;for(let B=v-1;(O!==0||k<g)&&B!==-1;B--,k++)O+=r*E[B]>>>0,E[B]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");g=k,h++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(f){const h=a(f);if(h)return h;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var _T="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const ff=TT(_T);function kT(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,f=new Uint8Array(u);return f.set(s,0),f.set(a.subarray(0,4),s.length),ff.encode(f)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=ff.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=ff.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function PT(e){return rr(rr(e))}const ia=kT(PT),Vi=qe;function sa(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({network:Ot({}),address:Es(),hash:J5,output:Ut(25),pubkey:yn(gn),signature:yn(ai),input:Me})),e);const r=Mr(()=>{const s=ia.decode(e.address),a=si(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Mr(()=>wt(e.input)),i=e.network||pn,o={name:"p2pkh",network:i};if(ye(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Pr(s,0,i.pubKeyHash),s.set(o.hash,1),ia.encode(s)}),ye(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return ci(e.pubkey||o.pubkey)}),ye(o,"output",()=>{if(o.hash)return gr([Vi.OP_DUP,Vi.OP_HASH160,o.hash,Vi.OP_EQUALVERIFY,Vi.OP_CHECKSIG])}),ye(o,"pubkey",()=>{if(e.input)return n()[1]}),ye(o,"signature",()=>{if(e.input)return n()[0]}),ye(o,"input",()=>{if(e.pubkey&&e.signature)return gr([e.signature,e.pubkey])}),ye(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==Vi.OP_DUP||e.output[1]!==Vi.OP_HASH160||e.output[2]!==20||e.output[23]!==Vi.OP_EQUALVERIFY||e.output[24]!==Vi.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=ci(e.pubkey);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!ai(a[0]))throw new TypeError("Input has invalid signature");if(!gn(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&ee(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=ci(a[1]);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const oa=qe;function io(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({network:Ot({}),address:Es(),hash:Ut(20),output:Ut(23),redeem:Di(Ot({network:Ot({}),output:Me,input:Me,witness:pr(Me)})),input:Me,witness:pr(Me)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||pn);const n={network:r},i=Mr(()=>{const a=ia.decode(e.address),u=si(a,0),f=a.slice(1);return{version:u,hash:f}}),o=Mr(()=>wt(e.input)),s=Mr(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===oa.OP_FALSE?Uint8Array.from([]):u,input:gr(a.slice(0,-1)),witness:e.witness||[]}});if(ye(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Pr(a,0,n.network.scriptHash),a.set(n.hash,1),ia.encode(a)}),ye(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return ci(n.redeem.output)}),ye(n,"output",()=>{if(n.hash)return gr([oa.OP_HASH160,n.hash,oa.OP_EQUAL])}),ye(n,"redeem",()=>{if(e.input)return s()}),ye(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return gr([].concat(wt(e.redeem.input),e.redeem.output))}),ye(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),ye(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&ee(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==oa.OP_HASH160||e.output[1]!==20||e.output[22]!==oa.OP_EQUAL)throw new TypeError("Output is invalid");const f=e.output.slice(2,22);if(a.length>0&&ee(a,f)!==0)throw new TypeError("Hash mismatch");a=f}const u=f=>{if(f.output){const h=wt(f.output);if(!h||h.length<1)throw new TypeError("Redeem.output too short");if(f.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(f1(h)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=ci(f.output);if(a.length>0&&ee(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(f.input){const h=f.input.length>0,d=f.witness&&f.witness.length>0;if(!h&&!d)throw new TypeError("Empty input");if(h&&d)throw new TypeError("Input and witness provided");if(h){const g=wt(f.input);if(!af(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const f=s();if(e.redeem.output&&ee(e.redeem.output,f.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&ee(e.redeem.input,f.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!ra(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function IT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function OT(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var aa={};Object.defineProperty(aa,"__esModule",{value:!0});var ca=aa.bech32m=Ir=aa.bech32=void 0;const pu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",T1={};for(let e=0;e<pu.length;e++){const t=pu.charAt(e);T1[t]=e}function so(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function _1(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=so(t)^n>>5}t=so(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=so(t)^n&31}return t}function df(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function xT(e){return df(e,8,5,!0)}function $T(e){const t=df(e,5,8,!1);if(Array.isArray(t))return t}function CT(e){const t=df(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function k1(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let f=_1(s);if(typeof f=="string")throw new Error(f);let h=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");f=so(f)^g,h+=pu.charAt(g)}for(let d=0;d<6;++d)f=so(f);f^=t;for(let d=0;d<6;++d){const g=f>>(5-d)*5&31;h+=pu.charAt(g)}return h}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),f=s.toUpperCase();if(s!==u&&s!==f)return"Mixed-case string "+s;s=u;const h=s.lastIndexOf("1");if(h===-1)return"No separator character for "+s;if(h===0)return"Missing prefix for "+s;const d=s.slice(0,h),g=s.slice(h+1);if(g.length<6)return"Data too short";let v=_1(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=T1[x];if(N===void 0)return"Unknown character "+x;v=so(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:xT,fromWordsUnsafe:$T,fromWords:CT}}var Ir=aa.bech32=k1("bech32");ca=aa.bech32m=k1("bech32m");const P1=qe,NT=new Uint8Array(0);function ua(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({address:Es(),hash:Ut(20),input:Ut(0),network:Ot({}),output:Ut(22),pubkey:yn(gn,"Not a valid pubkey"),signature:yn(ai),witness:pr(Me)})),e);const r=Mr(()=>{const o=Ir.decode(e.address),s=o.words.shift(),a=Ir.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||pn,i={name:"p2wpkh",network:n};if(ye(i,"address",()=>{if(!i.hash)return;const o=Ir.toWords(i.hash);return o.unshift(0),Ir.encode(n.bech32,o)}),ye(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return ci(e.pubkey||i.pubkey)}),ye(i,"output",()=>{if(i.hash)return gr([P1.OP_0,i.hash])}),ye(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),ye(i,"signature",()=>{if(e.witness)return e.witness[0]}),ye(i,"input",()=>{if(i.witness)return NT}),ye(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&ee(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==P1.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&ee(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=ci(e.pubkey);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!gn(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!ai(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!gn(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&ee(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=ci(e.witness[1]);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const I1=qe,pf=new Uint8Array(0);function yu(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&gn(e))}function la(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(s1({network:Ot({}),address:Es(),hash:X5,output:Ut(34),redeem:s1({input:Me,network:Ot({}),output:Me,witness:pr(Me)}),input:Ut(0),witness:pr(Me)}),e);const r=Mr(()=>{const s=Ir.decode(e.address),a=s.words.shift(),u=Ir.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Mr(()=>wt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||pn);const o={network:i};if(ye(o,"address",()=>{if(!o.hash)return;const s=Ir.toWords(o.hash);return s.unshift(0),Ir.encode(i.bech32,s)}),ye(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return rr(o.redeem.output)}),ye(o,"output",()=>{if(o.hash)return gr([I1.OP_0,o.hash])}),ye(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:pf,witness:e.witness.slice(0,-1)}}),ye(o,"input",()=>{if(o.witness)return pf}),ye(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=iT(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=pf,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),ye(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==I1.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=wt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(f1(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=rr(e.redeem.output);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!af(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!ra(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(yu)||e.redeem.output&&(wt(e.redeem.output)||[]).some(yu))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&ee(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(yu)||(wt(a)||[]).some(yu))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const ha={};function UT(e){e?e!==ha.eccLib&&(RT(e),ha.eccLib=e):ha.eccLib=e}function yf(){if(!ha.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return ha.eccLib}const ui=e=>ii(e);function RT(e){Fr(typeof e.isXOnlyPoint=="function"),Fr(e.isXOnlyPoint(ui("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Fr(e.isXOnlyPoint(ui("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Fr(e.isXOnlyPoint(ui("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Fr(e.isXOnlyPoint(ui("0000000000000000000000000000000000000000000000000000000000000001"))),Fr(!e.isXOnlyPoint(ui("0000000000000000000000000000000000000000000000000000000000000000"))),Fr(!e.isXOnlyPoint(ui("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Fr(typeof e.xOnlyPointAddTweak=="function"),BT.forEach(t=>{const r=e.xOnlyPointAddTweak(ui(t.pubkey),ui(t.tweak));t.result===null?Fr(r===null):(Fr(r!==null),Fr(r.parity===t.parity),Fr(ee(r.xOnlyPubkey,ui(t.result))===0))})}function Fr(e){if(!e)throw new Error("ecc library invalid")}const BT=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],O1="0123456789abcdefABCDEF";O1.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=O1.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function LT(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function HT(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function KT(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function jT(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function DT(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function MT(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const FT=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function VT(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function x1(e){typeof e=="number"?VT(e):FT(e)}function Wi(e,t,r){x1(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Vr(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),LT(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),HT(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),KT(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function oo(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=jT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=DT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=MT(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Vr(e){return x1(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const WT=9007199254740991;function zT(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function gf(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e}function $1(e){const t=new Uint8Array(e.length);return t.set(e),t}class qt{constructor(t,r=0){be(this,"buffer"),be(this,"offset"),this.buffer=t,this.offset=r,ht(Ln([Me,oi]),[t,r])}static withCapacity(t){return new qt(new Uint8Array(t))}writeUInt8(t){this.offset=Pr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Vg(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=Wg(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=ea(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=H5(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=Wi(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}class qT{constructor(t,r=0){be(this,"buffer"),be(this,"offset"),this.buffer=t,this.offset=r,ht(Ln([Me,oi]),[t,r])}readUInt8(){const t=si(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=j5(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=to(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=zg(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=oo(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){zT(t,WT);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}}const C1=192,GT=128,XT=e=>"left"in e&&"right"in e;function wf(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);ee(n,o)<0?n=mf(n,o):n=mf(o,n)}return n}function bf(e){if(sf(e))return{hash:li(e)};const t=[bf(e[0]),bf(e[1])];t.sort((i,o)=>ee(i.hash,o.hash));const[r,n]=t;return{hash:mf(r.hash,n.hash),left:r,right:n}}function gu(e,t){if(XT(e)){const r=gu(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=gu(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(ee(e.hash,t)===0)return[]}function li(e){const t=e.version||C1;return du("TapLeaf",lt([Uint8Array.from([t]),YT(e.output)]))}function JT(e,t){return du("TapTweak",lt(t?[e,t]:[e]))}function wu(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=JT(e,t),n=yf().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function mf(e,t){return du("TapBranch",lt([e,t]))}function YT(e){const t=Vr(e.length),r=new Uint8Array(t);return Wi(e.length,r),lt([r,e])}const N1=qe,U1=1,ZT=80;function fa(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({address:Es(),input:Ut(0),network:Ot({}),output:Ut(34),internalPubkey:Ut(32),hash:Ut(32),pubkey:Ut(32),signature:nf([Ut(64),Ut(65)]),witness:pr(Me),scriptTree:yn(n1,"Taptree is not of type isTaptree"),redeem:Di(Ot({output:Me,redeemVersion:yr(),witness:pr(Me)})),redeemVersion:yr()})),e);const r=Mr(()=>D1(e.address)),n=Mr(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===ZT?e.witness.slice(0,-1):e.witness.slice()}),i=Mr(()=>{if(e.scriptTree)return bf(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||pn,s={name:"p2tr",network:o};if(ye(s,"address",()=>{if(!s.pubkey)return;const a=ca.toWords(s.pubkey);return a.unshift(U1),ca.encode(o.bech32,a)}),ye(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const f=u[u.length-1],h=f[0]&ou,d=u[u.length-2],g=li({output:d,version:h});return wf(f,g)}return null}),ye(s,"output",()=>{if(s.pubkey)return gr([N1.OP_1,s.pubkey])}),ye(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:C1),ye(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&ou}}),ye(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=wu(s.internalPubkey,s.hash);if(a)return a.x}}),ye(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),ye(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),ye(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=li({output:e.redeem.output,version:s.redeemVersion}),f=gu(a,u);if(!f)return;const h=wu(e.internalPubkey,a.hash);if(!h)return;const d=lt([Uint8Array.from([s.redeemVersion|h.parity]),e.internalPubkey].concat(f));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==U1)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&ee(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==N1.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&ee(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const h=wu(e.internalPubkey,s.hash);if(a.length>0&&ee(a,h.x)!==0)throw new TypeError("Pubkey mismatch");a=h.x}if(a&&a.length&&!yf().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&ee(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const h=li({output:e.redeem.output,version:s.redeemVersion});if(!gu(u,h))throw new TypeError("Redeem script not in tree")}const f=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(wt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&ee(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!ra(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(f.length===1){if(e.signature&&ee(e.signature,f[0])!==0)throw new TypeError("Signature mismatch")}else{const h=f[f.length-1];if(h.length<33)throw new TypeError(`The control-block length is too small. Got ${h.length}, expected min 33.`);if((h.length-33)%32!==0)throw new TypeError(`The control-block length of ${h.length} is incorrect!`);const d=(h.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=h.slice(1,33);if(e.internalPubkey&&ee(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!yf().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=h[0]&ou,E=f[f.length-2],T=li({output:E,version:v}),x=wf(h,T),N=wu(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&ee(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(h[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const R1=40,B1=2,L1=16,H1=2,K1=80,j1="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function QT(e,t){const r=e.slice(2);if(r.length<B1||r.length>R1)throw new TypeError("Invalid program length for segwit address");const n=e[0]-K1;if(n<H1||n>L1)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(j1),t_(r,n,t.bech32)}function e_(e){const t=ia.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=si(t,0),n=t.slice(1);return{version:r,hash:n}}function D1(e){let t,r;try{t=Ir.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=ca.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=Ir.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function t_(e,t,r){const n=Ir.toWords(e);return n.unshift(t),t===0?Ir.encode(r,n):ca.encode(r,n)}function da(e,t){t=t||pn;try{return sa({output:e,network:t}).address}catch{}try{return io({output:e,network:t}).address}catch{}try{return ua({output:e,network:t}).address}catch{}try{return la({output:e,network:t}).address}catch{}try{return fa({output:e,network:t}).address}catch{}try{return QT(e,t)}catch{}throw new Error(nT(e)+" has no matching Address")}function M1(e,t){t=t||pn;let r,n;try{r=e_(e)}catch{}if(r){if(r.version===t.pubKeyHash)return sa({hash:r.hash}).output;if(r.version===t.scriptHash)return io({hash:r.hash}).output}else{try{n=D1(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return ua({hash:n.data}).output;if(n.data.length===32)return la({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return fa({pubkey:n.data}).output}else if(n.version>=H1&&n.version<=L1&&n.data.length>=B1&&n.data.length<=R1)return console.warn(j1),gr([n.version+K1,n.data])}}throw new Error(e+" has no matching Script")}function Kn(e){const t=e.length;return Vr(t)+t}function r_(e){const t=e.length;return Vr(t)+e.reduce((r,n)=>r+Kn(n),0)}const zi=new Uint8Array(0),F1=[],vf=ii("0000000000000000000000000000000000000000000000000000000000000000"),V1=ii("0000000000000000000000000000000000000000000000000000000000000001"),n_=ii("ffffffffffffffff"),i_={script:zi,valueBuffer:n_};function s_(e){return e.value!==void 0}const wn=class et{constructor(){be(this,"version",1),be(this,"locktime",0),be(this,"ins",[]),be(this,"outs",[])}static fromBuffer(t,r){const n=new qT(t),i=new et;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===et.ADVANCED_TRANSACTION_MARKER&&s===et.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let h=0;h<u;++h)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:F1});const f=n.readVarInt();for(let h=0;h<f;++h)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let h=0;h<u;++h)i.ins[h].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==t.length)throw new Error("Transaction has unexpected data");return i}static fromHex(t){return et.fromBuffer(ii(t),!1)}static isCoinbaseHash(t){ht(i1,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&et.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return ht(Ln([i1,oi,rf(su(oi)),rf(su(Me))]),[t,r,n,i]),n==null&&(n=et.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||zi,sequence:n,witness:F1})-1}addOutput(t,r){return ht(Ln([Me,of]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Vr(this.ins.length)+Vr(this.outs.length)+this.ins.reduce((n,i)=>n+40+Kn(i.script),0)+this.outs.reduce((n,i)=>n+8+Kn(i.script),0)+(r?this.ins.reduce((n,i)=>n+r_(i.witness),0):0)}clone(){const t=new et;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(ht(Ln([oi,Me,yr()]),[t,r,n]),t>=this.ins.length)return V1;const i=gr(wt(r).filter(a=>a!==qe.OP_CODESEPARATOR)),o=this.clone();if((n&31)===et.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===et.SIGHASH_SINGLE){if(t>=this.outs.length)return V1;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=i_;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&et.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=zi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Vg(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),As(s)}hashForWitnessV1(t,r,n,i,o,s){if(ht(Ln([oi,pr(Me),pr(of),oi]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===et.SIGHASH_DEFAULT?et.SIGHASH_ALL:i&et.SIGHASH_OUTPUT_MASK,u=(i&et.SIGHASH_INPUT_MASK)===et.SIGHASH_ANYONECANPAY,f=a===et.SIGHASH_NONE,h=a===et.SIGHASH_SINGLE;let d=zi,g=zi,v=zi,E=zi,T=zi;if(!u){let k=qt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=rr(k.end()),k=qt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=rr(k.end()),k=qt.withCapacity(r.map(Kn).reduce((B,z)=>B+z)),r.forEach(B=>k.writeVarSlice(B)),v=rr(k.end()),k=qt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=rr(k.end())}if(f||h){if(h&&t<this.outs.length){const k=this.outs[t],B=qt.withCapacity(8+Kn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=rr(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(z=>8+Kn(z.script)).reduce((z,V)=>z+V),B=qt.withCapacity(k);this.outs.forEach(z=>{B.writeInt64(z.value),B.writeVarSlice(z.script)}),T=rr(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(f?32:0)+(s?32:0)+(o?37:0),O=qt.withCapacity(N);if(O.writeUInt8(i),O.writeInt32(this.version),O.writeUInt32(this.locktime),O.writeSlice(d),O.writeSlice(g),O.writeSlice(v),O.writeSlice(E),f||h||O.writeSlice(T),O.writeUInt8(x),u){const k=this.ins[t];O.writeSlice(k.hash),O.writeUInt32(k.index),O.writeInt64(n[t]),O.writeVarSlice(r[t]),O.writeUInt32(k.sequence)}else O.writeUInt32(t);if(s){const k=qt.withCapacity(Kn(s));k.writeVarSlice(s),O.writeSlice(rr(k.end()))}return h&&O.writeSlice(T),o&&(O.writeSlice(o),O.writeUInt8(0),O.writeUInt32(4294967295)),du("TapSighash",lt([Uint8Array.from([0]),O.end()]))}hashForWitnessV0(t,r,n,i){ht(Ln([oi,Me,of,oi]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=vf,u=vf,f=vf;if(i&et.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=As(o)),!(i&et.SIGHASH_ANYONECANPAY)&&(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),f=As(o)),(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+Kn(v.script),0);o=new Uint8Array(d),s=new qt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=As(o)}else if((i&31)===et.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+Kn(d.script)),s=new qt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=As(o)}o=new Uint8Array(156+Kn(r)),s=new qt(o,0);const h=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(f),s.writeSlice(h.hash),s.writeUInt32(h.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(h.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),As(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):As(this.__toBuffer(void 0,void 0,t))}getId(){return Ee(gf(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return Ee(this.toBuffer(void 0,void 0))}setInputScript(t,r){ht(Ln([yr(),Me]),[t,r]),this.ins[t].script=r}setWitness(t,r){ht(Ln([yr(),pr(Me)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new qt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(et.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(et.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{s_(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};be(wn,"DEFAULT_SEQUENCE",4294967295),be(wn,"SIGHASH_DEFAULT",0),be(wn,"SIGHASH_ALL",1),be(wn,"SIGHASH_NONE",2),be(wn,"SIGHASH_SINGLE",3),be(wn,"SIGHASH_ANYONECANPAY",128),be(wn,"SIGHASH_OUTPUT_MASK",3),be(wn,"SIGHASH_INPUT_MASK",128),be(wn,"ADVANCED_TRANSACTION_MARKER",0),be(wn,"ADVANCED_TRANSACTION_FLAG",1);let Tt=wn;var jn;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})(jn||(jn={}));var se;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(se||(se={}));var _t;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(_t||(_t={}));const o_=e=>[...Array(e).keys()];function a_(e){if(e.key[0]!==jn.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+Ee(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+Ee(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of o_(e.value.length/4-1)){const i=to(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function c_(e){const t=new Uint8Array([jn.GLOBAL_XPUB]),r=lt([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),ea(i,o,u,"LE"),o+=4}),{key:r,value:i}}const u_="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function l_(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function h_(e,t,r){const n=Ee(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.extendedPubkey,t.extendedPubkey)).length===0)}const f_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:h_,check:l_,decode:a_,encode:c_,expected:u_},Symbol.toStringTag,{value:"Module"}));function d_(e){return{key:new Uint8Array([jn.UNSIGNED_TX]),value:e.toBuffer()}}const p_=Object.freeze(Object.defineProperty({__proto__:null,encode:d_},Symbol.toStringTag,{value:"Module"}));function y_(e){if(e.key[0]!==se.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+Ee(e.key));return e.value}function g_(e){return{key:new Uint8Array([se.FINAL_SCRIPTSIG]),value:e}}const w_="Uint8Array";function b_(e){return e instanceof Uint8Array}function m_(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const v_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:m_,check:b_,decode:y_,encode:g_,expected:w_},Symbol.toStringTag,{value:"Module"}));function E_(e){if(e.key[0]!==se.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+Ee(e.key));return e.value}function A_(e){return{key:new Uint8Array([se.FINAL_SCRIPTWITNESS]),value:e}}const S_="Uint8Array";function T_(e){return e instanceof Uint8Array}function __(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const k_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:__,check:T_,decode:E_,encode:A_,expected:S_},Symbol.toStringTag,{value:"Module"}));function P_(e){if(e.key[0]!==se.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+Ee(e.key));return e.value}function I_(e){return{key:new Uint8Array([se.NON_WITNESS_UTXO]),value:e}}const O_="Uint8Array";function x_(e){return e instanceof Uint8Array}function $_(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const C_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$_,check:x_,decode:P_,encode:I_,expected:O_},Symbol.toStringTag,{value:"Module"}));function N_(e){if(e.key[0]!==se.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+Ee(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+Ee(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function U_(e){const t=new Uint8Array([se.PARTIAL_SIG]);return{key:lt([t,e.pubkey]),value:e.signature}}const R_="{ pubkey: Uint8Array; signature: Uint8Array; }";function B_(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&L_(e.signature)}function L_(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function H_(e,t,r){const n=Ee(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0).length===0)}const K_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:H_,check:B_,decode:N_,encode:U_,expected:R_},Symbol.toStringTag,{value:"Module"}));function j_(e){if(e.key[0]!==se.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+Ee(e.key));return C5(e.value)}function D_(e){return{key:new Uint8Array([se.POR_COMMITMENT]),value:N5(e)}}const M_="string";function F_(e){return typeof e=="string"}function V_(e,t){return!!e&&!!t&&e.porCommitment===void 0}const W_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:V_,check:F_,decode:j_,encode:D_,expected:M_},Symbol.toStringTag,{value:"Module"}));function z_(e){if(e.key[0]!==se.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+Ee(e.key));return Number(to(e.value,0,"LE"))}function q_(e){const t=Uint8Array.from([se.SIGHASH_TYPE]),r=new Uint8Array(4);return ea(r,0,e,"LE"),{key:t,value:r}}const G_="number";function X_(e){return typeof e=="number"}function J_(e,t){return!!e&&!!t&&e.sighashType===void 0}const Y_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:J_,check:X_,decode:z_,encode:q_,expected:G_},Symbol.toStringTag,{value:"Module"}));function Z_(e){if(e.key[0]!==se.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+Ee(e.key));if(!W1(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function Q_(e){return{key:Uint8Array.from([se.TAP_KEY_SIG]),value:e}}const ek="Uint8Array";function W1(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function tk(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const rk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:tk,check:W1,decode:Z_,encode:Q_,expected:ek},Symbol.toStringTag,{value:"Module"}));function nk(e){if(e.key[0]!==se.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+Ee(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+Ee(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+Ee(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function ik(e){const t=Uint8Array.from([se.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:lt([t,e.controlBlock]),value:lt([e.script,r])}}const sk="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function ok(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ak(e,t,r){const n=Ee(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.controlBlock,t.controlBlock)===0).length===0)}const ck=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ak,check:ok,decode:nk,encode:ik,expected:sk},Symbol.toStringTag,{value:"Module"}));function uk(e){if(e.key[0]!==se.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+Ee(e.key));if(!z1(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function lk(e){return{key:Uint8Array.from([se.TAP_MERKLE_ROOT]),value:e}}const hk="Uint8Array";function z1(e){return e instanceof Uint8Array&&e.length===32}function fk(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const dk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:fk,check:z1,decode:uk,encode:lk,expected:hk},Symbol.toStringTag,{value:"Module"}));function pk(e){if(e.key[0]!==se.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+Ee(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+Ee(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+Ee(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function yk(e){const t=Uint8Array.from([se.TAP_SCRIPT_SIG]);return{key:lt([t,e.pubkey,e.leafHash]),value:e.signature}}const gk="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function wk(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function bk(e,t,r){const n=Ee(t.pubkey)+Ee(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0&&ee(i.leafHash,t.leafHash)===0).length===0)}const mk=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:bk,check:wk,decode:pk,encode:yk,expected:gk},Symbol.toStringTag,{value:"Module"}));function vk(e){if(e.key[0]!==se.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+Ee(e.key));const t=zg(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=oo(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function Ek(e){const{script:t,value:r}=e,n=Vr(t.length),i=new Uint8Array(8+n+t.length);return Wg(i,0,BigInt(r),"LE"),Wi(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([se.WITNESS_UTXO]),value:i}}const Ak="{ script: Uint8Array; value: bigint; }";function Sk(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function Tk(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const _k=Object.freeze(Object.defineProperty({__proto__:null,canAdd:Tk,check:Sk,decode:vk,encode:Ek,expected:Ak},Symbol.toStringTag,{value:"Module"}));function kk(e){if(e.key[0]!==_t.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+Ee(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=oo(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function Pk(e){const t=Uint8Array.from([_t.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),Wi(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:lt(r)}}const Ik="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function Ok(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function xk(e,t){return!!e&&!!t&&e.tapTree===void 0}const $k=Object.freeze(Object.defineProperty({__proto__:null,canAdd:xk,check:Ok,decode:kk,encode:Pk,expected:Ik},Symbol.toStringTag,{value:"Module"})),Ck=e=>[...Array(e).keys()],Nk=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Ef(e,t=Nk){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+Ee(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+Ee(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const f={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const h of Ck(a.value.length/4-1)){const d=to(a.value,h*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;f.path+="/"+v.toString(10)+(g?"'":"")}return f}function n(a){const u=Uint8Array.from([e]),f=lt([u,a.pubkey]),h=a.path.split("/"),d=new Uint8Array(h.length*4);d.set(a.masterFingerprint,0);let g=4;return h.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),ea(d,g,T,"LE"),g+=4}),{key:f,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,f){const h=Ee(u.pubkey);return f.has(h)?!1:(f.add(h),a.filter(d=>ee(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Af(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+Ee(r.key));return n}}function q1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Uk=e=>e.length===32;function G1(e){const t=Ef(e,Uk);function r(s){const{numberValue:a,bytes:u}=oo(s.value),f=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),h=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)h[d]=s.value.slice(g,g+32);return{...f,leafHashes:h}}function n(s){const a=t.encode(s),u=Vr(s.leafHashes.length),f=new Uint8Array(u);Wi(s.leafHashes.length,f);const h=lt([f,...s.leafHashes,a.value]);return{...a,value:h}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function X1(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+Ee(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function J1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Sf={unsignedTx:p_,globalXpub:f_,checkPubkey:Af([])},Rt={nonWitnessUtxo:C_,partialSig:K_,sighashType:Y_,finalScriptSig:v_,finalScriptWitness:k_,porCommitment:W_,witnessUtxo:_k,bip32Derivation:Ef(se.BIP32_DERIVATION),redeemScript:q1(se.REDEEM_SCRIPT),witnessScript:J1(se.WITNESS_SCRIPT),checkPubkey:Af([se.PARTIAL_SIG,se.BIP32_DERIVATION]),tapKeySig:rk,tapScriptSig:mk,tapLeafScript:ck,tapBip32Derivation:G1(se.TAP_BIP32_DERIVATION),tapInternalKey:X1(se.TAP_INTERNAL_KEY),tapMerkleRoot:dk},hi={bip32Derivation:Ef(_t.BIP32_DERIVATION),redeemScript:q1(_t.REDEEM_SCRIPT),witnessScript:J1(_t.WITNESS_SCRIPT),checkPubkey:Af([_t.BIP32_DERIVATION]),tapBip32Derivation:G1(_t.TAP_BIP32_DERIVATION),tapTree:$k,tapInternalKey:X1(_t.TAP_INTERNAL_KEY)},Rk=Object.freeze(Object.defineProperty({__proto__:null,globals:Sf,inputs:Rt,outputs:hi},Symbol.toStringTag,{value:"Module"})),bu=e=>[...Array(e).keys()];function Y1(e){const t=e.map(Bk);return t.push(Uint8Array.from([0])),lt(t)}function Bk(e){const t=e.key.length,r=e.value.length,n=Vr(t),i=Vr(r),o=new Uint8Array(n+t+i+r);return Wi(t,o,0),o.set(e.key,n),Wi(r,o,n+t),o.set(e.value,n+t+i),o}function Lk(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=oo(e,r);r+=N;const O=e.slice(r,r+Number(x));return r+=Number(x),O}function i(){const x=to(e,r,"BE");return r+=4,x}function o(){const x=si(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=si(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],f={};for(;!a();){const x=s(),N=Ee(x.key);if(f[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);f[N]=1,u.push(x)}const h=u.filter(x=>x.key[0]===jn.UNSIGNED_TX);if(h.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(h[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of bu(g)){const N={},O=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,O.push(k)}E.push(O)}for(const x of bu(v)){const N={},O=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,O.push(k)}T.push(O)}return Z1(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Gt(e,t,r){if(ee(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${Ee(t)}`)}function Z1(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const h of t)switch(h.key[0]){case jn.UNSIGNED_TX:if(Gt("global",h.key,jn.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case jn.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Sf.globalXpub.decode(h));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(h)}const s=r.length,a=n.length,u=[],f=[];for(const h of bu(s)){const d={};for(const g of r[h])switch(Rt.checkPubkey(g),g.key[0]){case se.NON_WITNESS_UTXO:if(Gt("input",g.key,se.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Rt.nonWitnessUtxo.decode(g);break;case se.WITNESS_UTXO:if(Gt("input",g.key,se.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Rt.witnessUtxo.decode(g);break;case se.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Rt.partialSig.decode(g));break;case se.SIGHASH_TYPE:if(Gt("input",g.key,se.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Rt.sighashType.decode(g);break;case se.REDEEM_SCRIPT:if(Gt("input",g.key,se.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Rt.redeemScript.decode(g);break;case se.WITNESS_SCRIPT:if(Gt("input",g.key,se.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Rt.witnessScript.decode(g);break;case se.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Rt.bip32Derivation.decode(g));break;case se.FINAL_SCRIPTSIG:Gt("input",g.key,se.FINAL_SCRIPTSIG),d.finalScriptSig=Rt.finalScriptSig.decode(g);break;case se.FINAL_SCRIPTWITNESS:Gt("input",g.key,se.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Rt.finalScriptWitness.decode(g);break;case se.POR_COMMITMENT:Gt("input",g.key,se.POR_COMMITMENT),d.porCommitment=Rt.porCommitment.decode(g);break;case se.TAP_KEY_SIG:Gt("input",g.key,se.TAP_KEY_SIG),d.tapKeySig=Rt.tapKeySig.decode(g);break;case se.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Rt.tapScriptSig.decode(g));break;case se.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Rt.tapLeafScript.decode(g));break;case se.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Rt.tapBip32Derivation.decode(g));break;case se.TAP_INTERNAL_KEY:Gt("input",g.key,se.TAP_INTERNAL_KEY),d.tapInternalKey=Rt.tapInternalKey.decode(g);break;case se.TAP_MERKLE_ROOT:Gt("input",g.key,se.TAP_MERKLE_ROOT),d.tapMerkleRoot=Rt.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const h of bu(a)){const d={};for(const g of n[h])switch(hi.checkPubkey(g),g.key[0]){case _t.REDEEM_SCRIPT:if(Gt("output",g.key,_t.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=hi.redeemScript.decode(g);break;case _t.WITNESS_SCRIPT:if(Gt("output",g.key,_t.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=hi.witnessScript.decode(g);break;case _t.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(hi.bip32Derivation.decode(g));break;case _t.TAP_INTERNAL_KEY:Gt("output",g.key,_t.TAP_INTERNAL_KEY),d.tapInternalKey=hi.tapInternalKey.decode(g);break;case _t.TAP_TREE:Gt("output",g.key,_t.TAP_TREE),d.tapTree=hi.tapTree.decode(g);break;case _t.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(hi.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}f.push(d)}return{globalMap:i,inputs:u,outputs:f}}function Hk({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=_f({globalMap:e,inputs:t,outputs:r}),s=Y1(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(Y1),u=a(i),f=a(o),h=new Uint8Array(5);return h.set([112,115,98,116,255],0),lt([h,s].concat(u,f))}const Kk=(e,t)=>ee(e.key,t.key);function Tf(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const f=(Array.isArray(a)?a:[a]).map(u.encode);return f.map(h=>Ee(h.key)).forEach(h=>{if(r.has(h))throw new Error("Serialize Error: Duplicate key: "+h);r.add(h)}),o.concat(f)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(Ee(o.key))):[];return n.concat(i).sort(Kk)}function _f({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Tf(e,Sf),inputKeyVals:t.map(n=>Tf(n,Rt)),outputKeyVals:r.map(n=>Tf(n,hi))}}function jk(e){const t=e[0],r=_f(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Q1(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=ao(r.globalKeyVals),s=r.inputKeyVals.map(ao),a=r.outputKeyVals.map(ao);for(const u of n){const f=Q1(u);if(f===void 0||ee(f.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const h=_f(u);ao(h.globalKeyVals).forEach(kf(o,r.globalKeyVals,h.globalKeyVals)),h.inputKeyVals.map(ao).forEach((d,g)=>d.forEach(kf(s[g],r.inputKeyVals[g],h.inputKeyVals[g]))),h.outputKeyVals.map(ao).forEach((d,g)=>d.forEach(kf(a[g],r.outputKeyVals[g],h.outputKeyVals[g])))}return Z1(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function kf(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>Ee(o.key)===n)[0];t.push(i),e.add(n)}}function Q1(e){return e.globalMap.unsignedTx}function ao(e){const t=new Set;return e.forEach(r=>{const n=Ee(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function jt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function pa(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Pf(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>ee(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${Ee(e.key)}`)}function If(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function Dk(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function ew(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Of(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=Rk[e+"s"][n]||{},f=!!s;if(a)if(f){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||ew(e,n,u,i);const h=r[n]||[],d=new Set;if(!i.every(g=>s(h,g,d)))throw new Error("Can not add duplicate data to array");r[n]=h.concat(i)}else{if(a(i)||ew(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const Mk=Of("global"),tw=Of("input"),rw=Of("output");function Fk(e,t){const r=e.length-1,n=jt(e,r);tw(t,n)}function Vk(e,t){const r=e.length-1,n=pa(e,r);rw(t,n)}let nw=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,t){const r=Fg(e);return this.fromBuffer(r,t)}static fromHex(e,t){const r=ii(e);return this.fromBuffer(r,t)}static fromBuffer(e,t){const r=Lk(e,t),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){const e=this.toBuffer();return B5(e)}toHex(){const e=this.toBuffer();return Ee(e)}toBuffer(){return Hk(this)}updateGlobal(e){return Mk(e,this.globalMap),this}updateInput(e,t){const r=jt(this.inputs,e);return tw(t,r),this}updateOutput(e,t){const r=pa(this.outputs,e);return rw(t,r),this}addUnknownKeyValToGlobal(e){return Pf(e,this.globalMap.unknownKeyVals,If(jn)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=jt(this.inputs,e);return Pf(t,r.unknownKeyVals,If(se)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=pa(this.outputs,e);return Pf(t,r.unknownKeyVals,If(_t)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addInput(e){this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach(n=>this.addUnknownKeyValToInput(r,n)),Fk(this.inputs,e),this}addOutput(e){this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach(n=>this.addUnknownKeyValToOutput(r,n)),Vk(this.outputs,e),this}clearFinalizedInput(e){const t=jt(this.inputs,e);Dk(e,t);for(const r of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(r)||delete t[r];return this}combine(...e){const t=jk([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function Ss(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const Wk=Ss(lu),zk=Ss(y1),qk=Ss(sa),mu=Ss(ua),iw=Ss(la),sw=Ss(io),ow=Ss(fa);function vu(e){let t=new Uint8Array(0);function r(s){t=lt([t,s])}function n(s){const a=t.length,u=Vr(s);t=lt([t,new Uint8Array(u)]),Wi(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function aw(e,t){const r=ci(e),n=e.slice(1,33),i=wt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:ee(e,o)===0||ee(r,o)===0||ee(n,o)===0)}function Eu(e,t){return aw(e,t)!==-1}function Gk(e,t){return Xk(e).some(r=>cw(r,na.decode,t))}function cw(e,t,r){const{hashType:n}=t(e),i=[];switch(n&Tt.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case Tt.SIGHASH_ALL:break;case Tt.SIGHASH_SINGLE:case Tt.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function Xk(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=Jk(e)}else t=e.partialSig;return t.map(r=>r.signature)}function Jk(e){const t=e.finalScriptSig?wt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?wt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&ai(n)).map(n=>({signature:n}))}const Au=e=>e.length===32?e:e.slice(1,33);function uw(e,t,r){const n=lP(t,e,r);try{const i=cP(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:vu(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function Su(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return lt([e,r])}function bn(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&ow(e.witnessUtxo.script))}function xf(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function lw(e,t,r){sP(e,t,r),aP(e,t,r)}function hw(e,t,r){oP(e,t,r),Yk(e,t)}function Yk(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=Zk(r,n);if(i&&ee(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function Zk(e,t){const r=t&&Qk(t.leaves),{output:n}=fa({internalPubkey:e,scriptTree:r});return n}function Qk(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:iP(e)}function eP(e,t){return rP(e).some(r=>cw(r,tP,t))}function tP(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||Tt.SIGHASH_DEFAULT}}function rP(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=nP(e.finalScriptWitness);r&&t.push(r)}return t}function nP(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function iP(e){let t;for(const r of e)if(t=$f(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function $f(e,t,r=0){if(r>GT)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(sf(t))return;const n=$f(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=$f(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function sP(e,t,r){const n=bn(e)&&co(t),i=co(e)&&bn(t),o=e===t&&bn(t)&&co(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function oP(e,t,r){const n=xf(e)&&co(t),i=co(e)&&xf(t),o=e===t&&xf(t)&&co(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function aP(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Cf(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Cf(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Cf(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Cf(e,t){if(!t)return!0;const r=li({output:e.script,version:e.leafVersion}),n=wf(e.controlBlock,r);return ee(n,t)===0}function cP(e,t){const r=li({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>ee(n.leafHash,r)===0).map(n=>uP(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function uP(e,t){return Object.assign({positionInScript:aw(t.pubkey,e)},t)}function lP(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>hP(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function hP(e,t,r){const n=li({output:e.script,version:e.leafVersion});return(!r||ee(n,r)===0)&&t.find(i=>ee(i.leafHash,n)===0)!==void 0}function co(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const fP={network:pn,maximumFeeRate:5e3};class bt{constructor(t={},r=new nw(new fw)){be(this,"data"),be(this,"__CACHE"),be(this,"opts"),this.data=r,this.opts=Object.assign({},fP,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Fg(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=ii(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=nw.fromBuffer(t,dP),i=new bt(r,n);return bP(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:$1(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=da(t.script,this.opts.network)}catch{}return{script:$1(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=bt.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){Tu(t),this.opts.maximumFeeRate=t}setVersion(t){Tu(t),ya(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){Tu(t),ya(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){Tu(r),ya(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");lw(t,t,"addInput"),ya(this.data.inputs,"addInput"),t.witnessScript&&Pu(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];ww(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&Rf(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");ya(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=M1(r,i);t=Object.assign({},t,{script:o})}hw(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(pw))throw new Error("Not finalized");const r=this.__CACHE;if(t||yP(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return Ow(this.data.inputs,n,r,!0),n}getFeeRate(){return Ew("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return Ew("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return jt(this.data.inputs,0),ga(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=jt(this.data.inputs,t);return bn(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=uw){const i=jt(this.data.inputs,t);if(bn(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=mP){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=SP(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);gP(r);const{finalScriptSig:u,finalScriptWitness:f}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!u&&!f)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=uw){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=fa({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=vu(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=jt(this.data.inputs,t),n=xw(t,r,this.__CACHE),i=ku(n,t,"input",r.redeemScript||IP(r.finalScriptSig),r.witnessScript||OP(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=Cw(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=jt(this.data.inputs,t);return kP(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=jt(this.data.inputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=pa(this.data.outputs,t);return PP(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=pa(this.data.outputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return jt(this.data.inputs,0),ga(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return bn(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>ee(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,f,h;for(const d of s){const g=na.decode(d.signature),{hash:v,script:E}=h!==g.hashType?Sw(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:f};h=g.hashType,u=v,f=E,gw(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&Au(n);const a=n?Uf(t,i,this.data.inputs,n,this.__CACHE):EP(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(h=>!h.leafHash);let f=0;if(o&&u){if(!r(u.pubkey,u.hash,_w(o)))return!1;f++}if(s)for(const h of s){const d=a.find(g=>ee(g.pubkey,h.pubkey)===0);if(d){if(!r(h.pubkey,d.hash,_w(h.signature)))return!1;f++}}return f>0}signAllInputsHD(t,r=[Tt.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of ga(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[Tt.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of ga(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[Tt.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return Pw(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[Tt.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=Pw(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of ga(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return bn(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(bn(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[Tt.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:na.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[Tt.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(f=>!f.leafHash).map(f=>Su(n.signSchnorr(f.hash),r.sighashType))[0],u=s.filter(f=>!!f.leafHash).map(f=>({pubkey:Au(n.publicKey),signature:Su(n.signSchnorr(f.hash),r.sighashType),leafHash:f.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return bn(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(bn(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[Tt.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:na.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[Tt.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(h=>!h.leafHash)[0];if(u){const h=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:Su(d,r.sighashType)}));a.push(h)}const f=s.filter(h=>!!h.leafHash);if(f.length){const h=f.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:Au(n.publicKey),signature:Su(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...h)}return Promise.all(a).then(h=>{h.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=Uf(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${Ee(n.publicKey)}`);return s}toBuffer(){return Nf(this.__CACHE),this.data.toBuffer()}toHex(){return Nf(this.__CACHE),this.data.toHex()}toBase64(){return Nf(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&Pu(r.witnessScript),lw(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&Rf(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return hw(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}const dP=e=>new fw(e);class fw{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){be(this,"tx"),this.tx=Tt.fromBuffer(t),wP(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?gf(ii(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function pP(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return dw(1,e.partialSig);case"multisig":const n=lu({output:t});return dw(n.m,e.partialSig,n.pubkeys);default:return!1}}function Nf(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function dw(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=xP(i);return t.find(s=>ee(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function pw(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function yw(e){return t=>!(ee(e.fingerprint,t.masterFingerprint)||ee(e.derivePath(t.path).publicKey,t.pubkey))}function Tu(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function yP(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}function ya(e,t){e.forEach(r=>{if(bn(r)?eP(r,t):Gk(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function gP(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=na.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function gw(e,t,r){if(!Eu(e,t))throw new Error(`Can not ${r} for this input with the key ${Ee(e)}`)}function wP(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function bP(e,t){e.ins.forEach(r=>{ww(t,r)})}function ww(e,t){const r=Ee(gf(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function bw(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(ee(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const mw=bw(io,"Redeem script"),vw=bw(la,"Witness script");function Ew(e,t,r,n){if(!r.every(pw))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),Ow(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function mP(e,t,r,n,i,o){const s=Cw(r);if(!pP(t,r,s))throw new Error(`Can not finalize input #${e}`);return vP(r,s,t.partialSig,n,i,o)}function vP(e,t,r,n,i,o){let s,a;const u=AP(e,t,r),f=o?la({redeem:u}):null,h=i?io({redeem:f||u}):null;return n?(f?a=vu(f.witness):a=vu(u.witness),h&&(s=h.input)):h?s=h.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function Aw(e,t,r,n,i){const o=jt(e,t),{hash:s,sighashType:a,script:u}=Sw(t,o,n,!1,i);return gw(r,u,"sign"),{hash:s,sighashType:a}}function Sw(e,t,r,n,i){const o=r.__TX,s=t.sighashType||Tt.SIGHASH_ALL;kw(s,i);let a,u;if(t.nonWitnessUtxo){const d=_u(r,t,e),g=o.ins[e].hash,v=d.getHash();if(ee(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:f,type:h}=ku(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,f,u.value,s);else if(mu(f)){const d=sa({hash:f.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${Ee(f)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&console.warn(`Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.
32
32
  *********************
33
33
  PROCEED WITH CAUTION!
34
- *********************`),a=o.hashForSignature(e,h,s)}return{script:h,sighashType:s,hash:a}}function EP(e,t,r,n){const i=[];if(t.tapInternalKey){const o=Tw(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>Uh(e,t,r,o,n)).flat()}function Tw(e,t,r){const{script:n}=Bh(e,t,r);return ow(n)?n.subarray(2,34):null}function _w(e){return e.length===64?e:e.subarray(0,64)}function Uh(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||Tt.SIGHASH_DEFAULT;kw(u,s);const h=r.map((E,T)=>Bh(T,E,i)),f=h.map(E=>E.script),d=h.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=Tw(e,t,i)||Uint8Array.from([]);if(ee(Au(n),E)===0){const T=a.hashForWitnessV1(e,f,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>Eu(n,E.script)).map(E=>{const T=li({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||ee(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,f,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function kw(e,t){if(t&&t.indexOf(e)<0){const r=_P(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function AP(e,t,r){let n;switch(t){case"multisig":const i=TP(e,r);n=lu({output:e,signatures:i});break;case"pubkey":n=y1({output:e,signature:r[0].signature});break;case"pubkeyhash":n=sa({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ua({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function SP(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=_u(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||mu(i.script))&&(i.isSegwit=!0),i}function Pw(e,t,r){const n=jt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(ee(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(ee(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function TP(e,t){return lu({output:e}).pubkeys.map(r=>(t.filter(n=>ee(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function Ow(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=oo(e,t);return t+=Vr(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function _P(e){let t=e&Tt.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case Tt.SIGHASH_ALL:t+="SIGHASH_ALL";break;case Tt.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case Tt.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Rh(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=Tt.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function Iw(e,t,r,n){let i=0n;e.forEach((u,h)=>{if(n&&u.finalScriptSig&&(t.ins[h].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[h].witness=Ow(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const f=_u(r,u,h),d=t.ins[h].index,g=f.outs[d];i+=g.value}});const o=t.outs.reduce((u,h)=>u+h.value,0n),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(Number(s/BigInt(a)))}function _u(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Rh(e,t,r),n[r]}function xw(e,t,r){const{script:n}=Bh(e,t,r);return n}function Bh(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=_u(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function kP(e,t,r,n){const i=xw(r,t,n),{meaningfulScript:o}=ku(i,r,"input",t.redeemScript,t.witnessScript);return Eu(e,o)}function PP(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=ku(i,r,"output",t.redeemScript,t.witnessScript);return Eu(e,o)}function OP(e){if(!e)return;const t=wt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||$w(r)||$P(r)||!wt(r)))return r}function IP(e){if(!e)return;const t=Ow(e),r=t[t.length-1];if(!($w(r)||!wt(r)))return r}function xP(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function $w(e){return e.length===33&&sT(e)}function $P(e){return ai(e)}function ku(e,t,r,n,i){const o=sw(e),s=o&&n&&iw(n),a=iw(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,mw(t,e,n,r),vw(t,n,i,r),Pu(u)):a?(u=i,vw(t,e,i,r),Pu(u)):o?(u=n,mw(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Pu(e){if(mu(e)||sw(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Cw(e){return mu(e)?"witnesspubkeyhash":qk(e)?"pubkeyhash":Wk(e)?"multisig":zk(e)?"pubkey":"nonstandard"}function ga(e){return[...Array(e).keys()]}const mn=new Error("The connected wallet doesn't support this method..."),CP=new Error("Wallet is not installed");class hi{constructor(t,r,n){be(this,"$store"),be(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),mn}}const Lh="BITCOIN_MAINNET",Nw="BITCOIN_TESTNET",Uw="BITCOIN_TESTNET4",Rw="BITCOIN_SIGNET",Bw="FRACTAL_BITCOIN_MAINNET",Lw="FRACTAL_BITCOIN_TESTNET",Hw="Mainnet",NP="Testnet",UP="Signet",RP="livenet",BP="testnet",Kw="livenet",LP="testnet",HP="testnet4",KP="signet",jw="Mainnet",jP="Testnet",mt="mainnet",Ir="signet",Bt="testnet",xr="testnet4",uo="fractal mainnet",$r="fractal testnet",wa=e=>e===mt?Hw:e===Bt?NP:e===Ir?UP:Hw,Dw=e=>e===mt?Lh:e===Bt?Nw:e===xr?Uw:e===Ir?Rw:e===uo?Bw:e===$r?Lw:Lh,Ou=e=>e===mt?jw:e===Bt?jP:jw,Hh=e=>e===Lh?mt:e===Nw?Bt:e===Uw?xr:e===Rw?Ir:e===Bw?uo:e===Lw?$r:mt,DP=e=>e===RP?mt:e===BP?Bt:mt,Mw=e=>e===Kw?mt:e===LP?Bt:e===HP?xr:e===KP?Ir:e===$r?Bt:mt;function Fw(e,t){return function(){return e.apply(t,arguments)}}const{toString:MP}=Object.prototype,{getPrototypeOf:Kh}=Object,Iu=(e=>t=>{const r=MP.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),vn=e=>(e=e.toLowerCase(),t=>Iu(t)===e),xu=e=>t=>typeof t===e,{isArray:lo}=Array,ba=xu("undefined");function FP(e){return e!==null&&!ba(e)&&e.constructor!==null&&!ba(e.constructor)&&Cr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Vw=vn("ArrayBuffer");function VP(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Vw(e.buffer),t}const WP=xu("string"),Cr=xu("function"),Ww=xu("number"),$u=e=>e!==null&&typeof e=="object",zP=e=>e===!0||e===!1,Cu=e=>{if(Iu(e)!=="object")return!1;const t=Kh(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},qP=vn("Date"),GP=vn("File"),XP=vn("Blob"),JP=vn("FileList"),YP=e=>$u(e)&&Cr(e.pipe),ZP=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Cr(e.append)&&((t=Iu(e))==="formdata"||t==="object"&&Cr(e.toString)&&e.toString()==="[object FormData]"))},QP=vn("URLSearchParams"),[eO,tO,rO,nO]=["ReadableStream","Request","Response","Headers"].map(vn),iO=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ma(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),lo(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function zw(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const Ts=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qw=e=>!ba(e)&&e!==Ts;function jh(){const{caseless:e}=qw(this)&&this||{},t={},r=(n,i)=>{const o=e&&zw(t,i)||i;Cu(t[o])&&Cu(n)?t[o]=jh(t[o],n):Cu(n)?t[o]=jh({},n):lo(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&ma(arguments[n],r);return t}const sO=(e,t,r,{allOwnKeys:n}={})=>(ma(t,(i,o)=>{r&&Cr(i)?e[o]=Fw(i,r):e[o]=i},{allOwnKeys:n}),e),oO=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),aO=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},cO=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&Kh(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},uO=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},lO=e=>{if(!e)return null;if(lo(e))return e;let t=e.length;if(!Ww(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},fO=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Kh(Uint8Array)),hO=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},dO=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},pO=vn("HTMLFormElement"),yO=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),Gw=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gO=vn("RegExp"),Xw=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ma(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},wO=e=>{Xw(e,(t,r)=>{if(Cr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(Cr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},bO=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return lo(e)?n(e):n(String(e).split(t)),r},mO=()=>{},vO=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Dh="abcdefghijklmnopqrstuvwxyz",Jw="0123456789",Yw={DIGIT:Jw,ALPHA:Dh,ALPHA_DIGIT:Dh+Dh.toUpperCase()+Jw},EO=(e=16,t=Yw.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function AO(e){return!!(e&&Cr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const SO=e=>{const t=new Array(10),r=(n,i)=>{if($u(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=lo(n)?[]:{};return ma(n,(s,a)=>{const u=r(s,i+1);!ba(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},TO=vn("AsyncFunction"),_O=e=>e&&($u(e)||Cr(e))&&Cr(e.then)&&Cr(e.catch),Zw=((e,t)=>e?setImmediate:t?((r,n)=>(Ts.addEventListener("message",({source:i,data:o})=>{i===Ts&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ts.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Cr(Ts.postMessage)),kO=typeof queueMicrotask<"u"?queueMicrotask.bind(Ts):typeof process<"u"&&process.nextTick||Zw,M={isArray:lo,isArrayBuffer:Vw,isBuffer:FP,isFormData:ZP,isArrayBufferView:VP,isString:WP,isNumber:Ww,isBoolean:zP,isObject:$u,isPlainObject:Cu,isReadableStream:eO,isRequest:tO,isResponse:rO,isHeaders:nO,isUndefined:ba,isDate:qP,isFile:GP,isBlob:XP,isRegExp:gO,isFunction:Cr,isStream:YP,isURLSearchParams:QP,isTypedArray:fO,isFileList:JP,forEach:ma,merge:jh,extend:sO,trim:iO,stripBOM:oO,inherits:aO,toFlatObject:cO,kindOf:Iu,kindOfTest:vn,endsWith:uO,toArray:lO,forEachEntry:hO,matchAll:dO,isHTMLForm:pO,hasOwnProperty:Gw,hasOwnProp:Gw,reduceDescriptors:Xw,freezeMethods:wO,toObjectSet:bO,toCamelCase:yO,noop:mO,toFiniteNumber:vO,findKey:zw,global:Ts,isContextDefined:qw,ALPHABET:Yw,generateString:EO,isSpecCompliantForm:AO,toJSONObject:SO,isAsyncFn:TO,isThenable:_O,setImmediate:Zw,asap:kO};function xe(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}M.inherits(xe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:M.toJSONObject(this.config),code:this.code,status:this.status}}});const Qw=xe.prototype,e2={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{e2[e]={value:e}}),Object.defineProperties(xe,e2),Object.defineProperty(Qw,"isAxiosError",{value:!0}),xe.from=(e,t,r,n,i,o)=>{const s=Object.create(Qw);return M.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),xe.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const PO=null;function Mh(e){return M.isPlainObject(e)||M.isArray(e)}function t2(e){return M.endsWith(e,"[]")?e.slice(0,-2):e}function r2(e,t,r){return e?e.concat(t).map(function(n,i){return n=t2(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function OO(e){return M.isArray(e)&&!e.some(Mh)}const IO=M.toFlatObject(M,{},null,function(e){return/^is[A-Z]/.test(e)});function Nu(e,t,r){if(!M.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=M.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!M.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||h,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&M.isSpecCompliantForm(t);if(!M.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(M.isDate(v))return v.toISOString();if(!a&&M.isBlob(v))throw new xe("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(v)||M.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function h(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(M.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(M.isArray(v)&&OO(v)||(M.isFileList(v)||M.endsWith(E,"[]"))&&(x=M.toArray(v)))return E=t2(E),x.forEach(function(N,I){!(M.isUndefined(N)||N===null)&&t.append(s===!0?r2([E],I,o):s===null?E:E+"[]",u(N))}),!1}return Mh(v)?!0:(t.append(r2(T,E,o),u(v)),!1)}const f=[],d=Object.assign(IO,{defaultVisitor:h,convertValue:u,isVisitable:Mh});function g(v,E){if(!M.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(v),M.forEach(v,function(T,x){(!(M.isUndefined(T)||T===null)&&i.call(t,T,M.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),f.pop()}}if(!M.isObject(e))throw new TypeError("data must be an object");return g(e),t}function n2(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Fh(e,t){this._pairs=[],e&&Nu(e,this,t)}const i2=Fh.prototype;i2.append=function(e,t){this._pairs.push([e,t])},i2.toString=function(e){const t=e?function(r){return e.call(this,r,n2)}:n2;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function xO(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function s2(e,t,r){if(!t)return e;const n=r&&r.encode||xO,i=r&&r.serialize;let o;if(i?o=i(t,r):o=M.isURLSearchParams(t)?t.toString():new Fh(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class o2{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){M.forEach(this.handlers,function(r){r!==null&&t(r)})}}const a2={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$O=typeof URLSearchParams<"u"?URLSearchParams:Fh,CO=typeof FormData<"u"?FormData:null,NO=typeof Blob<"u"?Blob:null,UO={isBrowser:!0,classes:{URLSearchParams:$O,FormData:CO,Blob:NO},protocols:["http","https","file","blob","url","data"]},Vh=typeof window<"u"&&typeof document<"u",Wh=typeof navigator=="object"&&navigator||void 0,RO=Vh&&(!Wh||["ReactNative","NativeScript","NS"].indexOf(Wh.product)<0),BO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",LO=Vh&&window.location.href||"http://localhost",HO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Vh,hasStandardBrowserEnv:RO,hasStandardBrowserWebWorkerEnv:BO,navigator:Wh,origin:LO},Symbol.toStringTag,{value:"Module"})),wr={...HO,...UO};function KO(e,t){return Nu(e,new wr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return wr.isNode&&M.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function jO(e){return M.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DO(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function c2(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&M.isArray(i)?i.length:s,u?(M.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!M.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&M.isArray(i[s])&&(i[s]=DO(i[s])),!a)}if(M.isFormData(e)&&M.isFunction(e.entries)){const r={};return M.forEachEntry(e,(n,i)=>{t(jO(n),i,r,0)}),r}return null}function MO(e,t,r){if(M.isString(e))try{return(t||JSON.parse)(e),M.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const va={transitional:a2,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=M.isObject(e);if(i&&M.isHTMLForm(e)&&(e=new FormData(e)),M.isFormData(e))return n?JSON.stringify(c2(e)):e;if(M.isArrayBuffer(e)||M.isBuffer(e)||M.isStream(e)||M.isFile(e)||M.isBlob(e)||M.isReadableStream(e))return e;if(M.isArrayBufferView(e))return e.buffer;if(M.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return KO(e,this.formSerializer).toString();if((o=M.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return Nu(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),MO(e)):e}],transformResponse:[function(e){const t=this.transitional||va.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(M.isResponse(e)||M.isReadableStream(e))return e;if(e&&M.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?xe.from(o,xe.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:wr.classes.FormData,Blob:wr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],e=>{va.headers[e]={}});const FO=M.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),VO=e=>{const t={};let r,n,i;return e&&e.split(`
35
- `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&FO[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},u2=Symbol("internals");function Ea(e){return e&&String(e).trim().toLowerCase()}function Uu(e){return e===!1||e==null?e:M.isArray(e)?e.map(Uu):String(e)}function WO(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const zO=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function zh(e,t,r,n,i){if(M.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!M.isString(t)){if(M.isString(n))return t.indexOf(n)!==-1;if(M.isRegExp(n))return n.test(t)}}function qO(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function GO(e,t){const r=M.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class br{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,h){const f=Ea(u);if(!f)throw new Error("header name must be a non-empty string");const d=M.findKey(i,f);(!d||i[d]===void 0||h===!0||h===void 0&&i[d]!==!1)&&(i[d||u]=Uu(a))}const s=(a,u)=>M.forEach(a,(h,f)=>o(h,f,u));if(M.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(M.isString(t)&&(t=t.trim())&&!zO(t))s(VO(t),r);else if(M.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Ea(t),t){const n=M.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return WO(i);if(M.isFunction(r))return r.call(this,i,n);if(M.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Ea(t),t){const n=M.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||zh(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Ea(s),s){const a=M.findKey(n,s);a&&(!r||zh(n,n[a],a,r))&&(delete n[a],i=!0)}}return M.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||zh(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return M.forEach(this,(i,o)=>{const s=M.findKey(n,o);if(s){r[s]=Uu(i),delete r[o];return}const a=t?qO(o):String(o).trim();a!==o&&delete r[o],r[a]=Uu(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return M.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&M.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
36
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[u2]=this[u2]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Ea(o);r[s]||(GO(n,o),r[s]=!0)}return M.isArray(t)?t.forEach(i):i(t),this}}br.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(br.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),M.freezeMethods(br);function qh(e,t){const r=this||va,n=t||r,i=br.from(n.headers);let o=n.data;return M.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function l2(e){return!!(e&&e.__CANCEL__)}function fo(e,t,r){xe.call(this,e??"canceled",xe.ERR_CANCELED,t,r),this.name="CanceledError"}M.inherits(fo,xe,{__CANCEL__:!0});function f2(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new xe("Request failed with status code "+r.status,[xe.ERR_BAD_REQUEST,xe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function XO(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function JO(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),h=n[o];s||(s=u),r[i]=a,n[i]=u;let f=o,d=0;for(;f!==i;)d+=r[f++],f=f%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=h&&u-h;return g?Math.round(d*1e3/g):void 0}}function YO(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),h=u-r;h>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-h)))},()=>i&&s(i)]}const Ru=(e,t,r=3)=>{let n=0;const i=JO(50,250);return YO(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,h=i(u),f=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:h||void 0,estimated:h&&a&&f?(a-s)/h:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},h2=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},d2=e=>(...t)=>M.asap(()=>e(...t)),ZO=wr.hasStandardBrowserEnv?function(){const e=wr.navigator&&/(msie|trident)/i.test(wr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=M.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),QO=wr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];M.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),M.isString(n)&&s.push("path="+n),M.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function eI(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function tI(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function p2(e,t){return e&&!eI(t)?tI(e,t):t}const y2=e=>e instanceof br?{...e}:e;function _s(e,t){t=t||{};const r={};function n(h,f,d){return M.isPlainObject(h)&&M.isPlainObject(f)?M.merge.call({caseless:d},h,f):M.isPlainObject(f)?M.merge({},f):M.isArray(f)?f.slice():f}function i(h,f,d){if(M.isUndefined(f)){if(!M.isUndefined(h))return n(void 0,h,d)}else return n(h,f,d)}function o(h,f){if(!M.isUndefined(f))return n(void 0,f)}function s(h,f){if(M.isUndefined(f)){if(!M.isUndefined(h))return n(void 0,h)}else return n(void 0,f)}function a(h,f,d){if(d in t)return n(h,f);if(d in e)return n(void 0,h)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(h,f)=>i(y2(h),y2(f),!0)};return M.forEach(Object.keys(Object.assign({},e,t)),function(h){const f=u[h]||i,d=f(e[h],t[h],h);M.isUndefined(d)&&f!==a||(r[h]=d)}),r}const g2=e=>{const t=_s({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=br.from(s),t.url=s2(p2(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(M.isFormData(r)){if(wr.hasStandardBrowserEnv||wr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[h,...f]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([h||"multipart/form-data",...f].join("; "))}}if(wr.hasStandardBrowserEnv&&(n&&M.isFunction(n)&&(n=n(t)),n||n!==!1&&ZO(t.url))){const h=i&&o&&QO.read(o);h&&s.set(i,h)}return t},rI=typeof XMLHttpRequest<"u",nI=rI&&function(e){return new Promise(function(t,r){const n=g2(e);let i=n.data;const o=br.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,h,f,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(h),n.signal&&n.signal.removeEventListener("abort",h)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const I=br.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:I,config:e,request:T};f2(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new xe("Request aborted",xe.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new xe("Network Error",xe.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let I=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||a2;n.timeoutErrorMessage&&(I=n.timeoutErrorMessage),r(new xe(I,k.clarifyTimeoutError?xe.ETIMEDOUT:xe.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&M.forEach(o.toJSON(),function(I,k){T.setRequestHeader(k,I)}),M.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ru(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([f,g]=Ru(a),T.upload.addEventListener("progress",f),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(h=I=>{T&&(r(!I||I.type?new fo(null,e,T):I),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(h),n.signal&&(n.signal.aborted?h():n.signal.addEventListener("abort",h)));const N=XO(n.url);if(N&&wr.protocols.indexOf(N)===-1){r(new xe("Unsupported protocol "+N+":",xe.ERR_BAD_REQUEST,e));return}T.send(i||null)})},iI=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(h){if(!i){i=!0,a();const f=h instanceof Error?h:this.reason;n.abort(f instanceof xe?f:new fo(f instanceof Error?f.message:f))}};let s=t&&setTimeout(()=>{s=null,o(new xe(`timeout ${t} of ms exceeded`,xe.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(h=>{h.unsubscribe?h.unsubscribe(o):h.removeEventListener("abort",o)}),e=null)};e.forEach(h=>h.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>M.asap(a),u}},sI=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},oI=async function*(e,t){for await(const r of aI(e))yield*sI(r,t)},aI=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},w2=(e,t,r,n)=>{const i=oI(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:h,value:f}=await i.next();if(h){a(),u.close();return}let d=f.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(f))}catch(h){throw a(h),h}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Bu=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",b2=Bu&&typeof ReadableStream=="function",cI=Bu&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),m2=(e,...t)=>{try{return!!e(...t)}catch{return!1}},uI=b2&&m2(()=>{let e=!1;const t=new Request(wr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),v2=64*1024,Gh=b2&&m2(()=>M.isReadableStream(new Response("").body)),Lu={stream:Gh&&(e=>e.body)};Bu&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Lu[t]&&(Lu[t]=M.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new xe(`Response type '${t}' is not supported`,xe.ERR_NOT_SUPPORT,n)})})})(new Response);const lI=async e=>{if(e==null)return 0;if(M.isBlob(e))return e.size;if(M.isSpecCompliantForm(e))return(await new Request(wr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(M.isArrayBufferView(e)||M.isArrayBuffer(e))return e.byteLength;if(M.isURLSearchParams(e)&&(e=e+""),M.isString(e))return(await cI(e)).byteLength},fI=async(e,t)=>M.toFiniteNumber(e.getContentLength())??lI(t),hI=Bu&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:h,headers:f,withCredentials:d="same-origin",fetchOptions:g}=g2(e);h=h?(h+"").toLowerCase():"text";let v=iI([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&uI&&r!=="get"&&r!=="head"&&(x=await fI(f,n))!==0){let z=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(M.isFormData(n)&&(V=z.headers.get("content-type"))&&f.setContentType(V),z.body){const[Ue,He]=h2(x,Ru(d2(u)));n=w2(z.body,v2,Ue,He)}}M.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:f.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let I=await fetch(E);const k=Gh&&(h==="stream"||h==="response");if(Gh&&(a||k&&T)){const z={};["status","statusText","headers"].forEach(Ge=>{z[Ge]=I[Ge]});const V=M.toFiniteNumber(I.headers.get("content-length")),[Ue,He]=a&&h2(V,Ru(d2(a),!0))||[];I=new Response(w2(I.body,v2,Ue,()=>{He&&He(),T&&T()}),z)}h=h||"text";let B=await Lu[M.findKey(Lu,h)||"text"](I,e);return!k&&T&&T(),await new Promise((z,V)=>{f2(z,V,{data:B,headers:br.from(I.headers),status:I.status,statusText:I.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new xe("Network Error",xe.ERR_NETWORK,e,E),{cause:N.cause||N}):xe.from(N,N&&N.code,e,E)}}),Xh={http:PO,xhr:nI,fetch:hI};M.forEach(Xh,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const E2=e=>`- ${e}`,dI=e=>M.isFunction(e)||e===null||e===!1,A2={getAdapter:e=>{e=M.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!dI(r)&&(n=Xh[(s=String(r)).toLowerCase()],n===void 0))throw new xe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
34
+ *********************`),a=o.hashForSignature(e,f,s)}return{script:f,sighashType:s,hash:a}}function EP(e,t,r,n){const i=[];if(t.tapInternalKey){const o=Tw(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>Uf(e,t,r,o,n)).flat()}function Tw(e,t,r){const{script:n}=Bf(e,t,r);return ow(n)?n.subarray(2,34):null}function _w(e){return e.length===64?e:e.subarray(0,64)}function Uf(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||Tt.SIGHASH_DEFAULT;kw(u,s);const f=r.map((E,T)=>Bf(T,E,i)),h=f.map(E=>E.script),d=f.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=Tw(e,t,i)||Uint8Array.from([]);if(ee(Au(n),E)===0){const T=a.hashForWitnessV1(e,h,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>Eu(n,E.script)).map(E=>{const T=li({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||ee(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,h,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function kw(e,t){if(t&&t.indexOf(e)<0){const r=_P(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function AP(e,t,r){let n;switch(t){case"multisig":const i=TP(e,r);n=lu({output:e,signatures:i});break;case"pubkey":n=y1({output:e,signature:r[0].signature});break;case"pubkeyhash":n=sa({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ua({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function SP(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=_u(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||mu(i.script))&&(i.isSegwit=!0),i}function Pw(e,t,r){const n=jt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(ee(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(ee(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function TP(e,t){return lu({output:e}).pubkeys.map(r=>(t.filter(n=>ee(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function Iw(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=oo(e,t);return t+=Vr(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function _P(e){let t=e&Tt.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case Tt.SIGHASH_ALL:t+="SIGHASH_ALL";break;case Tt.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case Tt.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Rf(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=Tt.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function Ow(e,t,r,n){let i=0n;e.forEach((u,f)=>{if(n&&u.finalScriptSig&&(t.ins[f].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[f].witness=Iw(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const h=_u(r,u,f),d=t.ins[f].index,g=h.outs[d];i+=g.value}});const o=t.outs.reduce((u,f)=>u+f.value,0n),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(Number(s/BigInt(a)))}function _u(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Rf(e,t,r),n[r]}function xw(e,t,r){const{script:n}=Bf(e,t,r);return n}function Bf(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=_u(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function kP(e,t,r,n){const i=xw(r,t,n),{meaningfulScript:o}=ku(i,r,"input",t.redeemScript,t.witnessScript);return Eu(e,o)}function PP(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=ku(i,r,"output",t.redeemScript,t.witnessScript);return Eu(e,o)}function IP(e){if(!e)return;const t=wt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||$w(r)||$P(r)||!wt(r)))return r}function OP(e){if(!e)return;const t=Iw(e),r=t[t.length-1];if(!($w(r)||!wt(r)))return r}function xP(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function $w(e){return e.length===33&&sT(e)}function $P(e){return ai(e)}function ku(e,t,r,n,i){const o=sw(e),s=o&&n&&iw(n),a=iw(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,mw(t,e,n,r),vw(t,n,i,r),Pu(u)):a?(u=i,vw(t,e,i,r),Pu(u)):o?(u=n,mw(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Pu(e){if(mu(e)||sw(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Cw(e){return mu(e)?"witnesspubkeyhash":qk(e)?"pubkeyhash":Wk(e)?"multisig":zk(e)?"pubkey":"nonstandard"}function ga(e){return[...Array(e).keys()]}const mn=new Error("The connected wallet doesn't support this method..."),CP=new Error("Wallet is not installed");class fi{constructor(t,r,n){be(this,"$store"),be(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),mn}}const Lf="BITCOIN_MAINNET",Nw="BITCOIN_TESTNET",Uw="BITCOIN_TESTNET4",Rw="BITCOIN_SIGNET",Bw="FRACTAL_BITCOIN_MAINNET",Lw="FRACTAL_BITCOIN_TESTNET",Hw="Mainnet",NP="Testnet",UP="Signet",RP="livenet",BP="testnet",Kw="livenet",LP="testnet",HP="testnet4",KP="signet",jw="Mainnet",jP="Testnet",mt="mainnet",Or="signet",Bt="testnet",xr="testnet4",uo="fractal mainnet",$r="fractal testnet",wa=e=>e===mt?Hw:e===Bt?NP:e===Or?UP:Hw,Dw=e=>e===mt?Lf:e===Bt?Nw:e===xr?Uw:e===Or?Rw:e===uo?Bw:e===$r?Lw:Lf,Iu=e=>e===mt?jw:e===Bt?jP:jw,Hf=e=>e===Lf?mt:e===Nw?Bt:e===Uw?xr:e===Rw?Or:e===Bw?uo:e===Lw?$r:mt,DP=e=>e===RP?mt:e===BP?Bt:mt,Mw=e=>e===Kw?mt:e===LP?Bt:e===HP?xr:e===KP?Or:e===$r?Bt:mt;function Fw(e,t){return function(){return e.apply(t,arguments)}}const{toString:MP}=Object.prototype,{getPrototypeOf:Kf}=Object,Ou=(e=>t=>{const r=MP.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),vn=e=>(e=e.toLowerCase(),t=>Ou(t)===e),xu=e=>t=>typeof t===e,{isArray:lo}=Array,ba=xu("undefined");function FP(e){return e!==null&&!ba(e)&&e.constructor!==null&&!ba(e.constructor)&&Cr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Vw=vn("ArrayBuffer");function VP(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Vw(e.buffer),t}const WP=xu("string"),Cr=xu("function"),Ww=xu("number"),$u=e=>e!==null&&typeof e=="object",zP=e=>e===!0||e===!1,Cu=e=>{if(Ou(e)!=="object")return!1;const t=Kf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},qP=vn("Date"),GP=vn("File"),XP=vn("Blob"),JP=vn("FileList"),YP=e=>$u(e)&&Cr(e.pipe),ZP=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Cr(e.append)&&((t=Ou(e))==="formdata"||t==="object"&&Cr(e.toString)&&e.toString()==="[object FormData]"))},QP=vn("URLSearchParams"),[eI,tI,rI,nI]=["ReadableStream","Request","Response","Headers"].map(vn),iI=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ma(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),lo(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function zw(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const Ts=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qw=e=>!ba(e)&&e!==Ts;function jf(){const{caseless:e}=qw(this)&&this||{},t={},r=(n,i)=>{const o=e&&zw(t,i)||i;Cu(t[o])&&Cu(n)?t[o]=jf(t[o],n):Cu(n)?t[o]=jf({},n):lo(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&ma(arguments[n],r);return t}const sI=(e,t,r,{allOwnKeys:n}={})=>(ma(t,(i,o)=>{r&&Cr(i)?e[o]=Fw(i,r):e[o]=i},{allOwnKeys:n}),e),oI=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),aI=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},cI=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&Kf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},uI=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},lI=e=>{if(!e)return null;if(lo(e))return e;let t=e.length;if(!Ww(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},hI=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Kf(Uint8Array)),fI=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},dI=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},pI=vn("HTMLFormElement"),yI=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),Gw=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gI=vn("RegExp"),Xw=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ma(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},wI=e=>{Xw(e,(t,r)=>{if(Cr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(Cr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},bI=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return lo(e)?n(e):n(String(e).split(t)),r},mI=()=>{},vI=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Df="abcdefghijklmnopqrstuvwxyz",Jw="0123456789",Yw={DIGIT:Jw,ALPHA:Df,ALPHA_DIGIT:Df+Df.toUpperCase()+Jw},EI=(e=16,t=Yw.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function AI(e){return!!(e&&Cr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const SI=e=>{const t=new Array(10),r=(n,i)=>{if($u(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=lo(n)?[]:{};return ma(n,(s,a)=>{const u=r(s,i+1);!ba(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},TI=vn("AsyncFunction"),_I=e=>e&&($u(e)||Cr(e))&&Cr(e.then)&&Cr(e.catch),Zw=((e,t)=>e?setImmediate:t?((r,n)=>(Ts.addEventListener("message",({source:i,data:o})=>{i===Ts&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ts.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Cr(Ts.postMessage)),kI=typeof queueMicrotask<"u"?queueMicrotask.bind(Ts):typeof process<"u"&&process.nextTick||Zw,M={isArray:lo,isArrayBuffer:Vw,isBuffer:FP,isFormData:ZP,isArrayBufferView:VP,isString:WP,isNumber:Ww,isBoolean:zP,isObject:$u,isPlainObject:Cu,isReadableStream:eI,isRequest:tI,isResponse:rI,isHeaders:nI,isUndefined:ba,isDate:qP,isFile:GP,isBlob:XP,isRegExp:gI,isFunction:Cr,isStream:YP,isURLSearchParams:QP,isTypedArray:hI,isFileList:JP,forEach:ma,merge:jf,extend:sI,trim:iI,stripBOM:oI,inherits:aI,toFlatObject:cI,kindOf:Ou,kindOfTest:vn,endsWith:uI,toArray:lI,forEachEntry:fI,matchAll:dI,isHTMLForm:pI,hasOwnProperty:Gw,hasOwnProp:Gw,reduceDescriptors:Xw,freezeMethods:wI,toObjectSet:bI,toCamelCase:yI,noop:mI,toFiniteNumber:vI,findKey:zw,global:Ts,isContextDefined:qw,ALPHABET:Yw,generateString:EI,isSpecCompliantForm:AI,toJSONObject:SI,isAsyncFn:TI,isThenable:_I,setImmediate:Zw,asap:kI};function xe(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}M.inherits(xe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:M.toJSONObject(this.config),code:this.code,status:this.status}}});const Qw=xe.prototype,e2={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{e2[e]={value:e}}),Object.defineProperties(xe,e2),Object.defineProperty(Qw,"isAxiosError",{value:!0}),xe.from=(e,t,r,n,i,o)=>{const s=Object.create(Qw);return M.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),xe.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const PI=null;function Mf(e){return M.isPlainObject(e)||M.isArray(e)}function t2(e){return M.endsWith(e,"[]")?e.slice(0,-2):e}function r2(e,t,r){return e?e.concat(t).map(function(n,i){return n=t2(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function II(e){return M.isArray(e)&&!e.some(Mf)}const OI=M.toFlatObject(M,{},null,function(e){return/^is[A-Z]/.test(e)});function Nu(e,t,r){if(!M.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=M.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!M.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||f,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&M.isSpecCompliantForm(t);if(!M.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(M.isDate(v))return v.toISOString();if(!a&&M.isBlob(v))throw new xe("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(v)||M.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(M.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(M.isArray(v)&&II(v)||(M.isFileList(v)||M.endsWith(E,"[]"))&&(x=M.toArray(v)))return E=t2(E),x.forEach(function(N,O){!(M.isUndefined(N)||N===null)&&t.append(s===!0?r2([E],O,o):s===null?E:E+"[]",u(N))}),!1}return Mf(v)?!0:(t.append(r2(T,E,o),u(v)),!1)}const h=[],d=Object.assign(OI,{defaultVisitor:f,convertValue:u,isVisitable:Mf});function g(v,E){if(!M.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));h.push(v),M.forEach(v,function(T,x){(!(M.isUndefined(T)||T===null)&&i.call(t,T,M.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),h.pop()}}if(!M.isObject(e))throw new TypeError("data must be an object");return g(e),t}function n2(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ff(e,t){this._pairs=[],e&&Nu(e,this,t)}const i2=Ff.prototype;i2.append=function(e,t){this._pairs.push([e,t])},i2.toString=function(e){const t=e?function(r){return e.call(this,r,n2)}:n2;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function xI(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function s2(e,t,r){if(!t)return e;const n=r&&r.encode||xI,i=r&&r.serialize;let o;if(i?o=i(t,r):o=M.isURLSearchParams(t)?t.toString():new Ff(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class o2{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){M.forEach(this.handlers,function(r){r!==null&&t(r)})}}const a2={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$I=typeof URLSearchParams<"u"?URLSearchParams:Ff,CI=typeof FormData<"u"?FormData:null,NI=typeof Blob<"u"?Blob:null,UI={isBrowser:!0,classes:{URLSearchParams:$I,FormData:CI,Blob:NI},protocols:["http","https","file","blob","url","data"]},Vf=typeof window<"u"&&typeof document<"u",Wf=typeof navigator=="object"&&navigator||void 0,RI=Vf&&(!Wf||["ReactNative","NativeScript","NS"].indexOf(Wf.product)<0),BI=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",LI=Vf&&window.location.href||"http://localhost",HI=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Vf,hasStandardBrowserEnv:RI,hasStandardBrowserWebWorkerEnv:BI,navigator:Wf,origin:LI},Symbol.toStringTag,{value:"Module"})),wr={...HI,...UI};function KI(e,t){return Nu(e,new wr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return wr.isNode&&M.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function jI(e){return M.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DI(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function c2(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&M.isArray(i)?i.length:s,u?(M.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!M.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&M.isArray(i[s])&&(i[s]=DI(i[s])),!a)}if(M.isFormData(e)&&M.isFunction(e.entries)){const r={};return M.forEachEntry(e,(n,i)=>{t(jI(n),i,r,0)}),r}return null}function MI(e,t,r){if(M.isString(e))try{return(t||JSON.parse)(e),M.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const va={transitional:a2,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=M.isObject(e);if(i&&M.isHTMLForm(e)&&(e=new FormData(e)),M.isFormData(e))return n?JSON.stringify(c2(e)):e;if(M.isArrayBuffer(e)||M.isBuffer(e)||M.isStream(e)||M.isFile(e)||M.isBlob(e)||M.isReadableStream(e))return e;if(M.isArrayBufferView(e))return e.buffer;if(M.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return KI(e,this.formSerializer).toString();if((o=M.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return Nu(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),MI(e)):e}],transformResponse:[function(e){const t=this.transitional||va.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(M.isResponse(e)||M.isReadableStream(e))return e;if(e&&M.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?xe.from(o,xe.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:wr.classes.FormData,Blob:wr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],e=>{va.headers[e]={}});const FI=M.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),VI=e=>{const t={};let r,n,i;return e&&e.split(`
35
+ `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&FI[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},u2=Symbol("internals");function Ea(e){return e&&String(e).trim().toLowerCase()}function Uu(e){return e===!1||e==null?e:M.isArray(e)?e.map(Uu):String(e)}function WI(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const zI=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function zf(e,t,r,n,i){if(M.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!M.isString(t)){if(M.isString(n))return t.indexOf(n)!==-1;if(M.isRegExp(n))return n.test(t)}}function qI(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function GI(e,t){const r=M.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class br{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,f){const h=Ea(u);if(!h)throw new Error("header name must be a non-empty string");const d=M.findKey(i,h);(!d||i[d]===void 0||f===!0||f===void 0&&i[d]!==!1)&&(i[d||u]=Uu(a))}const s=(a,u)=>M.forEach(a,(f,h)=>o(f,h,u));if(M.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(M.isString(t)&&(t=t.trim())&&!zI(t))s(VI(t),r);else if(M.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Ea(t),t){const n=M.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return WI(i);if(M.isFunction(r))return r.call(this,i,n);if(M.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Ea(t),t){const n=M.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||zf(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Ea(s),s){const a=M.findKey(n,s);a&&(!r||zf(n,n[a],a,r))&&(delete n[a],i=!0)}}return M.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||zf(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return M.forEach(this,(i,o)=>{const s=M.findKey(n,o);if(s){r[s]=Uu(i),delete r[o];return}const a=t?qI(o):String(o).trim();a!==o&&delete r[o],r[a]=Uu(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return M.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&M.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
36
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[u2]=this[u2]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Ea(o);r[s]||(GI(n,o),r[s]=!0)}return M.isArray(t)?t.forEach(i):i(t),this}}br.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(br.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),M.freezeMethods(br);function qf(e,t){const r=this||va,n=t||r,i=br.from(n.headers);let o=n.data;return M.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function l2(e){return!!(e&&e.__CANCEL__)}function ho(e,t,r){xe.call(this,e??"canceled",xe.ERR_CANCELED,t,r),this.name="CanceledError"}M.inherits(ho,xe,{__CANCEL__:!0});function h2(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new xe("Request failed with status code "+r.status,[xe.ERR_BAD_REQUEST,xe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function XI(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function JI(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),f=n[o];s||(s=u),r[i]=a,n[i]=u;let h=o,d=0;for(;h!==i;)d+=r[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(d*1e3/g):void 0}}function YI(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),f=u-r;f>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const Ru=(e,t,r=3)=>{let n=0;const i=JI(50,250);return YI(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,f=i(u),h=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:f||void 0,estimated:f&&a&&h?(a-s)/f:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},f2=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},d2=e=>(...t)=>M.asap(()=>e(...t)),ZI=wr.hasStandardBrowserEnv?function(){const e=wr.navigator&&/(msie|trident)/i.test(wr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=M.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),QI=wr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];M.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),M.isString(n)&&s.push("path="+n),M.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function eO(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function tO(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function p2(e,t){return e&&!eO(t)?tO(e,t):t}const y2=e=>e instanceof br?{...e}:e;function _s(e,t){t=t||{};const r={};function n(f,h,d){return M.isPlainObject(f)&&M.isPlainObject(h)?M.merge.call({caseless:d},f,h):M.isPlainObject(h)?M.merge({},h):M.isArray(h)?h.slice():h}function i(f,h,d){if(M.isUndefined(h)){if(!M.isUndefined(f))return n(void 0,f,d)}else return n(f,h,d)}function o(f,h){if(!M.isUndefined(h))return n(void 0,h)}function s(f,h){if(M.isUndefined(h)){if(!M.isUndefined(f))return n(void 0,f)}else return n(void 0,h)}function a(f,h,d){if(d in t)return n(f,h);if(d in e)return n(void 0,f)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(f,h)=>i(y2(f),y2(h),!0)};return M.forEach(Object.keys(Object.assign({},e,t)),function(f){const h=u[f]||i,d=h(e[f],t[f],f);M.isUndefined(d)&&h!==a||(r[f]=d)}),r}const g2=e=>{const t=_s({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=br.from(s),t.url=s2(p2(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(M.isFormData(r)){if(wr.hasStandardBrowserEnv||wr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[f,...h]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(wr.hasStandardBrowserEnv&&(n&&M.isFunction(n)&&(n=n(t)),n||n!==!1&&ZI(t.url))){const f=i&&o&&QI.read(o);f&&s.set(i,f)}return t},rO=typeof XMLHttpRequest<"u",nO=rO&&function(e){return new Promise(function(t,r){const n=g2(e);let i=n.data;const o=br.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,f,h,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const O=br.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:O,config:e,request:T};h2(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new xe("Request aborted",xe.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new xe("Network Error",xe.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let O=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||a2;n.timeoutErrorMessage&&(O=n.timeoutErrorMessage),r(new xe(O,k.clarifyTimeoutError?xe.ETIMEDOUT:xe.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&M.forEach(o.toJSON(),function(O,k){T.setRequestHeader(k,O)}),M.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ru(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([h,g]=Ru(a),T.upload.addEventListener("progress",h),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(f=O=>{T&&(r(!O||O.type?new ho(null,e,T):O),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const N=XI(n.url);if(N&&wr.protocols.indexOf(N)===-1){r(new xe("Unsupported protocol "+N+":",xe.ERR_BAD_REQUEST,e));return}T.send(i||null)})},iO=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,a();const h=f instanceof Error?f:this.reason;n.abort(h instanceof xe?h:new ho(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,o(new xe(`timeout ${t} of ms exceeded`,xe.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>M.asap(a),u}},sO=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},oO=async function*(e,t){for await(const r of aO(e))yield*sO(r,t)},aO=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},w2=(e,t,r,n)=>{const i=oO(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:f,value:h}=await i.next();if(f){a(),u.close();return}let d=h.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(h))}catch(f){throw a(f),f}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Bu=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",b2=Bu&&typeof ReadableStream=="function",cO=Bu&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),m2=(e,...t)=>{try{return!!e(...t)}catch{return!1}},uO=b2&&m2(()=>{let e=!1;const t=new Request(wr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),v2=64*1024,Gf=b2&&m2(()=>M.isReadableStream(new Response("").body)),Lu={stream:Gf&&(e=>e.body)};Bu&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Lu[t]&&(Lu[t]=M.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new xe(`Response type '${t}' is not supported`,xe.ERR_NOT_SUPPORT,n)})})})(new Response);const lO=async e=>{if(e==null)return 0;if(M.isBlob(e))return e.size;if(M.isSpecCompliantForm(e))return(await new Request(wr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(M.isArrayBufferView(e)||M.isArrayBuffer(e))return e.byteLength;if(M.isURLSearchParams(e)&&(e=e+""),M.isString(e))return(await cO(e)).byteLength},hO=async(e,t)=>M.toFiniteNumber(e.getContentLength())??lO(t),fO=Bu&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:f,headers:h,withCredentials:d="same-origin",fetchOptions:g}=g2(e);f=f?(f+"").toLowerCase():"text";let v=iO([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&uO&&r!=="get"&&r!=="head"&&(x=await hO(h,n))!==0){let z=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(M.isFormData(n)&&(V=z.headers.get("content-type"))&&h.setContentType(V),z.body){const[Ue,He]=f2(x,Ru(d2(u)));n=w2(z.body,v2,Ue,He)}}M.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let O=await fetch(E);const k=Gf&&(f==="stream"||f==="response");if(Gf&&(a||k&&T)){const z={};["status","statusText","headers"].forEach(Ge=>{z[Ge]=O[Ge]});const V=M.toFiniteNumber(O.headers.get("content-length")),[Ue,He]=a&&f2(V,Ru(d2(a),!0))||[];O=new Response(w2(O.body,v2,Ue,()=>{He&&He(),T&&T()}),z)}f=f||"text";let B=await Lu[M.findKey(Lu,f)||"text"](O,e);return!k&&T&&T(),await new Promise((z,V)=>{h2(z,V,{data:B,headers:br.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new xe("Network Error",xe.ERR_NETWORK,e,E),{cause:N.cause||N}):xe.from(N,N&&N.code,e,E)}}),Xf={http:PI,xhr:nO,fetch:fO};M.forEach(Xf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const E2=e=>`- ${e}`,dO=e=>M.isFunction(e)||e===null||e===!1,A2={getAdapter:e=>{e=M.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!dO(r)&&(n=Xf[(s=String(r)).toLowerCase()],n===void 0))throw new xe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
37
37
  `+o.map(E2).join(`
38
- `):" "+E2(o[0]):"as no adapter specified";throw new xe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:Xh};function Jh(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fo(null,e)}function S2(e){return Jh(e),e.headers=br.from(e.headers),e.data=qh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),A2.getAdapter(e.adapter||va.adapter)(e).then(function(t){return Jh(e),t.data=qh.call(e,e.transformResponse,t),t.headers=br.from(t.headers),t},function(t){return l2(t)||(Jh(e),t&&t.response&&(t.response.data=qh.call(e,e.transformResponse,t.response),t.response.headers=br.from(t.response.headers))),Promise.reject(t)})}const T2="1.7.7",Yh={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Yh[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _2={};Yh.transitional=function(e,t,r){function n(i,o){return"[Axios v"+T2+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new xe(n(o," has been removed"+(t?" in "+t:"")),xe.ERR_DEPRECATED);return t&&!_2[o]&&(_2[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function pI(e,t,r){if(typeof e!="object")throw new xe("options must be an object",xe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new xe("option "+o+" must be "+u,xe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new xe("Unknown option "+o,xe.ERR_BAD_OPTION)}}const Zh={assertOptions:pI,validators:Yh},qi=Zh.validators;class ks{constructor(t){this.defaults=t,this.interceptors={request:new o2,response:new o2}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
39
- `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=_s(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&Zh.assertOptions(n,{silentJSONParsing:qi.transitional(qi.boolean),forcedJSONParsing:qi.transitional(qi.boolean),clarifyTimeoutError:qi.transitional(qi.boolean)},!1),i!=null&&(M.isFunction(i)?r.paramsSerializer={serialize:i}:Zh.assertOptions(i,{encode:qi.function,serialize:qi.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&M.merge(o.common,o[r.method]);o&&M.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=br.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const h=[];this.interceptors.response.forEach(function(E){h.push(E.fulfilled,E.rejected)});let f,d=0,g;if(!u){const E=[S2.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,h),g=E.length,f=Promise.resolve(r);d<g;)f=f.then(E[d++],E[d++]);return f}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{f=S2.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=h.length;d<g;)f=f.then(h[d++],h[d++]);return f}getUri(t){t=_s(this.defaults,t);const r=p2(t.baseURL,t.url);return s2(r,t.params,t.paramsSerializer)}}M.forEach(["delete","get","head","options"],function(e){ks.prototype[e]=function(t,r){return this.request(_s(r||{},{method:e,url:t,data:(r||{}).data}))}}),M.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(_s(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}ks.prototype[e]=t(),ks.prototype[e+"Form"]=t(!0)});class Qh{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new fo(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Qh(function(r){t=r}),cancel:t}}}function yI(e){return function(t){return e.apply(null,t)}}function gI(e){return M.isObject(e)&&e.isAxiosError===!0}const ed={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ed).forEach(([e,t])=>{ed[t]=e});function k2(e){const t=new ks(e),r=Fw(ks.prototype.request,t);return M.extend(r,ks.prototype,t,{allOwnKeys:!0}),M.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return k2(_s(e,n))},r}const Je=k2(va);Je.Axios=ks,Je.CanceledError=fo,Je.CancelToken=Qh,Je.isCancel=l2,Je.VERSION=T2,Je.toFormData=Nu,Je.AxiosError=xe,Je.Cancel=Je.CanceledError,Je.all=function(e){return Promise.all(e)},Je.spread=yI,Je.isAxiosError=gI,Je.mergeConfig=_s,Je.AxiosHeaders=br,Je.formToJSON=e=>c2(M.isHTMLForm(e)?new FormData(e):e),Je.getAdapter=A2.getAdapter,Je.HttpStatusCode=ed,Je.default=Je;var P2={},ho={};ho.byteLength=mI,ho.toByteArray=EI,ho.fromByteArray=TI;for(var Dn=[],Wr=[],wI=typeof Uint8Array<"u"?Uint8Array:Array,td="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",po=0,bI=td.length;po<bI;++po)Dn[po]=td[po],Wr[td.charCodeAt(po)]=po;Wr[45]=62,Wr[95]=63;function O2(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function mI(e){var t=O2(e),r=t[0],n=t[1];return(r+n)*3/4-n}function vI(e,t,r){return(t+r)*3/4-r}function EI(e){var t,r=O2(e),n=r[0],i=r[1],o=new wI(vI(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Wr[e.charCodeAt(u)]<<18|Wr[e.charCodeAt(u+1)]<<12|Wr[e.charCodeAt(u+2)]<<6|Wr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Wr[e.charCodeAt(u)]<<2|Wr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Wr[e.charCodeAt(u)]<<10|Wr[e.charCodeAt(u+1)]<<4|Wr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function AI(e){return Dn[e>>18&63]+Dn[e>>12&63]+Dn[e>>6&63]+Dn[e&63]}function SI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(AI(n));return i.join("")}function TI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(SI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Dn[t>>2]+Dn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Dn[t>>10]+Dn[t>>4&63]+Dn[t<<2&63]+"=")),i.join("")}var rd={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */rd.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,h=u>>1,f=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-f)-1,v>>=-f,f+=a;f>0;o=o*256+e[t+d],d+=g,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=s*256+e[t+d],d+=g,f-=8);if(o===0)o=1-h;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-h}return(v?-1:1)*s*Math.pow(2,o-n)},rd.write=function(e,t,r,n,i,o){var s,a,u,h=o*8-i-1,f=(1<<h)-1,d=f>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;e[r+v]=s&255,v+=E,s/=256,h-=8);e[r+v-E]|=T*128};/*!
38
+ `):" "+E2(o[0]):"as no adapter specified";throw new xe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:Xf};function Jf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ho(null,e)}function S2(e){return Jf(e),e.headers=br.from(e.headers),e.data=qf.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),A2.getAdapter(e.adapter||va.adapter)(e).then(function(t){return Jf(e),t.data=qf.call(e,e.transformResponse,t),t.headers=br.from(t.headers),t},function(t){return l2(t)||(Jf(e),t&&t.response&&(t.response.data=qf.call(e,e.transformResponse,t.response),t.response.headers=br.from(t.response.headers))),Promise.reject(t)})}const T2="1.7.7",Yf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Yf[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _2={};Yf.transitional=function(e,t,r){function n(i,o){return"[Axios v"+T2+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new xe(n(o," has been removed"+(t?" in "+t:"")),xe.ERR_DEPRECATED);return t&&!_2[o]&&(_2[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function pO(e,t,r){if(typeof e!="object")throw new xe("options must be an object",xe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new xe("option "+o+" must be "+u,xe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new xe("Unknown option "+o,xe.ERR_BAD_OPTION)}}const Zf={assertOptions:pO,validators:Yf},qi=Zf.validators;class ks{constructor(t){this.defaults=t,this.interceptors={request:new o2,response:new o2}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
39
+ `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=_s(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&Zf.assertOptions(n,{silentJSONParsing:qi.transitional(qi.boolean),forcedJSONParsing:qi.transitional(qi.boolean),clarifyTimeoutError:qi.transitional(qi.boolean)},!1),i!=null&&(M.isFunction(i)?r.paramsSerializer={serialize:i}:Zf.assertOptions(i,{encode:qi.function,serialize:qi.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&M.merge(o.common,o[r.method]);o&&M.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=br.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let h,d=0,g;if(!u){const E=[S2.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,f),g=E.length,h=Promise.resolve(r);d<g;)h=h.then(E[d++],E[d++]);return h}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{h=S2.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=f.length;d<g;)h=h.then(f[d++],f[d++]);return h}getUri(t){t=_s(this.defaults,t);const r=p2(t.baseURL,t.url);return s2(r,t.params,t.paramsSerializer)}}M.forEach(["delete","get","head","options"],function(e){ks.prototype[e]=function(t,r){return this.request(_s(r||{},{method:e,url:t,data:(r||{}).data}))}}),M.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(_s(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}ks.prototype[e]=t(),ks.prototype[e+"Form"]=t(!0)});class Qf{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new ho(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Qf(function(r){t=r}),cancel:t}}}function yO(e){return function(t){return e.apply(null,t)}}function gO(e){return M.isObject(e)&&e.isAxiosError===!0}const ed={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ed).forEach(([e,t])=>{ed[t]=e});function k2(e){const t=new ks(e),r=Fw(ks.prototype.request,t);return M.extend(r,ks.prototype,t,{allOwnKeys:!0}),M.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return k2(_s(e,n))},r}const Je=k2(va);Je.Axios=ks,Je.CanceledError=ho,Je.CancelToken=Qf,Je.isCancel=l2,Je.VERSION=T2,Je.toFormData=Nu,Je.AxiosError=xe,Je.Cancel=Je.CanceledError,Je.all=function(e){return Promise.all(e)},Je.spread=yO,Je.isAxiosError=gO,Je.mergeConfig=_s,Je.AxiosHeaders=br,Je.formToJSON=e=>c2(M.isHTMLForm(e)?new FormData(e):e),Je.getAdapter=A2.getAdapter,Je.HttpStatusCode=ed,Je.default=Je;var P2={},fo={};fo.byteLength=mO,fo.toByteArray=EO,fo.fromByteArray=TO;for(var Dn=[],Wr=[],wO=typeof Uint8Array<"u"?Uint8Array:Array,td="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",po=0,bO=td.length;po<bO;++po)Dn[po]=td[po],Wr[td.charCodeAt(po)]=po;Wr[45]=62,Wr[95]=63;function I2(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function mO(e){var t=I2(e),r=t[0],n=t[1];return(r+n)*3/4-n}function vO(e,t,r){return(t+r)*3/4-r}function EO(e){var t,r=I2(e),n=r[0],i=r[1],o=new wO(vO(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Wr[e.charCodeAt(u)]<<18|Wr[e.charCodeAt(u+1)]<<12|Wr[e.charCodeAt(u+2)]<<6|Wr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Wr[e.charCodeAt(u)]<<2|Wr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Wr[e.charCodeAt(u)]<<10|Wr[e.charCodeAt(u+1)]<<4|Wr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function AO(e){return Dn[e>>18&63]+Dn[e>>12&63]+Dn[e>>6&63]+Dn[e&63]}function SO(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(AO(n));return i.join("")}function TO(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(SO(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Dn[t>>2]+Dn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Dn[t>>10]+Dn[t>>4&63]+Dn[t<<2&63]+"=")),i.join("")}var rd={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */rd.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,f=u>>1,h=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-h)-1,v>>=-h,h+=a;h>0;o=o*256+e[t+d],d+=g,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+d],d+=g,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(v?-1:1)*s*Math.pow(2,o-n)},rd.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(1<<f)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+v]=s&255,v+=E,s/=256,f-=8);e[r+v-E]|=T*128};/*!
40
40
  * The buffer module from node.js, for the browser.
41
41
  *
42
42
  * @author Feross Aboukhadijeh <https://feross.org>
43
43
  * @license MIT
44
- */(function(e){const t=ho,r=rd,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(We(c,ArrayBuffer)||c&&We(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(We(c,SharedArrayBuffer)||c&&We(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function h(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function f(c,l,p){return h(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return f(c,l,p)};function d(c){return h(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(We(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||or(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),We(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(We(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||We(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ht(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return _n(c).length;default:if(S)return m?-1:Ht(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return vt(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function z(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)z(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)z(this,l,l+3),z(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)z(this,l,l+7),z(this,l+1,l+6),z(this,l+2,l+5),z(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,or(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function He(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(or(ce))return U;c[p+U]=ce}return U}function Ge(c,l,p,m){return Mt(Ht(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(_n(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return He(this,c,l,p);case"utf8":case"utf-8":return Ge(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function vt(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=yi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function H(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function Le(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return H(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return Le(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return H(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return Le(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function pt(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return pt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return pt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const Et={};function Lt(c,l,p){Et[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Lt("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Lt("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Lt("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&yt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new Et.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new Et.ERR_INVALID_ARG_TYPE(l,"number",c)}function yt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new Et.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new Et.ERR_BUFFER_OUT_OF_BOUNDS:new Et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Ht(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function _n(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function We(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function or(c){return c!==c}const yi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(P2);const _I="https://mempool.space",kI="https://mempool.space/testnet",PI="https://mempool.space/testnet4",OI="https://mempool.space/signet",II="https://mempool.fractalbitcoin.io",xI="https://mempool-testnet.fractalbitcoin.io",Gi=e=>e===Bt?kI:e===xr?PI:e===Ir?OI:e===uo?II:e===$r?xI:_I;var ht={},nd={};const $I={},CI=Object.freeze(Object.defineProperty({__proto__:null,default:$I},Symbol.toStringTag,{value:"Module"})),I2=IT(CI);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=I2,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,h={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,L=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let W=H(b-K*w-q*_,y),X=H(-K*A-q*$,y);const Z=W>L,te=X>L;if(Z&&(W=y-W),te&&(X=y-X),W>L||X>L)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:W,k2neg:te,k2:X}}},f=32,d=32,g=32,v=f+1,E=2*f+1;function T(b){const{a:y,b:w}=a,A=H(b*b),_=H(A*b);return H(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y,q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q);return X===Z&&te===P}negate(){return new k(this.x,H(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=H(y*y),$=H(w*w),L=H($*$),K=y+$,q=H(i*(H(K*K)-_-L)),W=H(o*_),X=H(W*W),Z=H(X-i*q),te=H(W*(q-Z)-s*L),P=H(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y;if($===r||L===r)return this;if(w===r||A===r)return y;const q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q),j=H(Z-X),G=H(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=H(j*j),_e=H(j*ne),$e=H(X*ne),Pe=H(G*G-_e-i*$e),Oe=H(G*($e-Pe)-te*_e),Ze=H(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:L,k2:K}=h.splitScalar(A),q=w,W=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(W=W.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),L&&(W=W.negate()),W=new k(H(W.x*h.beta),W.y,W.z),q.add(W)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let L=0;L<w;L++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&z.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),z.set(w,_)));let $=k.ZERO,L=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),W=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&W);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?L=L.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:L}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:L,k1:K,k2neg:q,k2:W}=h.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(W,w);X=B(L,X),te=B(q,te),te=new k(H(te.x*h.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:L,f:K}=this.wNAF(A,w);_=L,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:pt(_));const L=y,K=H(L*L),q=H(K*L),W=H(w*K),X=H(A*q),Z=H(_*L);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(W,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const z=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,z.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!yt(A))throw new Error("Point is not on curve");const _=T(A);let $=Tn(_);const L=($&n)===n;w?L&&($=H(-$)):(y[0]&1)===1!==L&&($=H(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,f+1)),A=Ce(y.subarray(f+1,f*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===f)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const L=Lt(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,W=pt(q,K),X=H(-L*W,K),Z=H($*W,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!yt(w)||!yt(A))throw new Error(y);const _=H(A*A),$=T(w);if(H(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,H(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),L=k.fromAffine(y).multiplyUnsafe(A),K=$.add(L);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function He(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Ge(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=He(b.subarray(2)),{data:A,left:_}=He(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(vt(_.slice(0,64)),vt(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Ge(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,H(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),L=Ae(_);return`30${Ae(_+A+4)}02${L}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function vt(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return vt(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function H(b,y=a.P){const w=b%y;return w>=r?w:y+w}function Le(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Tn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),L=BigInt(44),K=BigInt(88),q=b*b*b%y,W=q*q*b%y,X=Le(W,o)*W%y,Z=Le(X,o)*W%y,te=Le(Z,i)*q%y,P=Le(te,A)*te%y,j=Le(P,_)*P%y,G=Le(j,L)*j%y,ne=Le(G,K)*G%y,_e=Le(ne,L)*j%y,$e=Le(_e,o)*W%y,Pe=Le($e,$)*P%y,Oe=Le(Pe,w)*q%y,Ze=Le(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function pt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=H(b,y),A=y,_=r,$=n;for(;w!==r;){const L=A/w,K=A%w,q=_-$*L;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return H(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,L,K)=>L===r?$:(w[K]=$,H($*L,y)),n),_=pt(A,y);return b.reduceRight(($,L,K)=>L===r?$:(w[K]=H($*w[K],y),H($*L,y)),_),w}function Et(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Lt(b,y=!1){const w=Et(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function yt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Lt(b,!0);if(!Ve($))return;const L=pt($,_),K=V.BASE.multiply($),q=H(K.x,_);if(q===r)return;const W=H(L*H(y+w*q,_),_);if(W===r)return;let X=new Fe(q,W),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=vt(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Ht(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function _n(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=_n;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function We(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Ht(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=We;function or(b){const y=b.length>f?b.slice(0,f):b;return Ce(y)}function yi(b){const y=or(b),w=H(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),yi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(f));const q=re(w);if(q.length!==f)throw new Error(`sign: Expected ${f} bytes of extra data`);$.push(q)}const L=Ye(...$),K=or(A);return{seed:L,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),L=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[L,A]:L}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);await L.reseed(A);let K;for(;!(K=Ar(await L.generate(),_,$,w.canonical));)await L.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);L.reseedSync(A);let K;for(;!(K=Ar(L.generateSync(),_,$,w.canonical));)L.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:L}=_;if(A.strict&&_.hasHighS())return!1;const K=Lt(y);let q;try{q=Ht(w)}catch{return!1}const{n:W}=a,X=pt(L,W),Z=H(K*X,W),te=H($*X,W),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?H(P.x,W)===$:!1}e.verify=S;function O(b){return H(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!yt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=H(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,H(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,L=this.initNonce(w,await $(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce(await $(kt.nonce,L,A,y)),X=O(await $(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return await rs(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,L=this.initNonce(w,$(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce($(kt.nonce,L,A,y)),X=O($(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Ht(w)}}function gi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),H(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function rs(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=O(await e.utils.taggedHash(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=O(e.utils.taggedHashSync(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:rs,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},kt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:H,invert:pt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=H(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(nd);var id={},zr={};Object.defineProperty(zr,"__esModule",{value:!0}),zr.isBytes=$2,zr.number=Hu,zr.bool=x2,zr.bytes=sd,zr.hash=C2,zr.exists=N2,zr.output=U2;function Hu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function x2(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function $2(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function sd(e,...t){if(!$2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function C2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Hu(e.outputLen),Hu(e.blockLen)}function N2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function U2(e,t){sd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const NI={number:Hu,bool:x2,bytes:sd,hash:C2,exists:N2,output:U2};zr.default=NI;var Aa={},Ku={};Object.defineProperty(Ku,"__esModule",{value:!0}),Ku.crypto=void 0,Ku.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=f,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=He,e.wrapConstructorWithOpts=Ge,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=Ku,r=zr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const h=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=h,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function f(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const vt=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(vt===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=vt*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class z{clone(){return this._cloneInto()}}e.Hash=z;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function He(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Ge(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(Aa),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=zr,r=Aa;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 h=this.blockLen,f=new Uint8Array(h);f.set(u.length>h?s.create().update(u).digest():u);for(let d=0;d<f.length;d++)f[d]^=54;this.iHash.update(f),this.oHash=s.create();for(let d=0;d<f.length;d++)f[d]^=106;this.oHash.update(f),f.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:h,destroyed:f,blockLen:d,outputLen:g}=this;return s=s,s.finished=h,s.destroyed=f,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(id);var Mn={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.HashMD=Xi.Maj=Xi.Chi=void 0;const od=zr,Sa=Aa;function UI(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,h=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+h,a,n)}const RI=(e,t,r)=>e&t^~e&r;Xi.Chi=RI;const BI=(e,t,r)=>e&t^e&r^t&r;Xi.Maj=BI;class LI extends Sa.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Sa.createView)(this.buffer)}update(t){(0,od.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Sa.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Sa.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,od.exists)(this),(0,od.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;UI(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Sa.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=u/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<h;d++)a.setUint32(4*d,f[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}}Xi.HashMD=LI,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.sha224=Mn.sha256=Mn.SHA256=void 0;const ad=Xi,qr=Aa,HI=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]),Ji=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yi=new Uint32Array(64);class cd extends ad.HashMD{constructor(){super(64,32,8,!1),this.A=Ji[0]|0,this.B=Ji[1]|0,this.C=Ji[2]|0,this.D=Ji[3]|0,this.E=Ji[4]|0,this.F=Ji[5]|0,this.G=Ji[6]|0,this.H=Ji[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Yi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Yi[d-15],v=Yi[d-2],E=(0,qr.rotr)(g,7)^(0,qr.rotr)(g,18)^g>>>3,T=(0,qr.rotr)(v,17)^(0,qr.rotr)(v,19)^v>>>10;Yi[d]=T+Yi[d-7]+E+Yi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:h,H:f}=this;for(let d=0;d<64;d++){const g=(0,qr.rotr)(a,6)^(0,qr.rotr)(a,11)^(0,qr.rotr)(a,25),v=f+g+(0,ad.Chi)(a,u,h)+HI[d]+Yi[d]|0,E=((0,qr.rotr)(n,2)^(0,qr.rotr)(n,13)^(0,qr.rotr)(n,22))+(0,ad.Maj)(n,i,o)|0;f=h,h=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,i,o,s,a,u,h,f)}roundClean(){Yi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Mn.SHA256=cd;class KI extends cd{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}}Mn.sha256=(0,qr.wrapConstructor)(()=>new cd),Mn.sha224=(0,qr.wrapConstructor)(()=>new KI);var jI=nd,DI=id,R2=Mn;function MI(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Be=MI(jI);const Zi="Expected Private",Qi="Expected Point",Ta="Expected Tweak",FI="Expected Hash",ju="Expected Signature",ud="Expected Extra Data (32 bytes)",_a="Expected Scalar",VI="Bad Recovery Id";Be.utils.hmacSha256Sync=(e,...t)=>DI.hmac(R2.sha256,e,Be.utils.concatBytes(...t)),Be.utils.sha256Sync=(...e)=>R2.sha256(Be.utils.concatBytes(...e));const ld=Be.utils._normalizePrivateKey,WI=32,zI=32,fd=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),qI=32,GI=new Uint8Array(32),XI=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function JI(e){return e instanceof Uint8Array}function ka(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function B2(e){return ka(e,GI)===0}function Pa(e){return!(!(e instanceof Uint8Array)||e.length!==zI||ka(e,fd)>=0)}function hd(e){return e instanceof Uint8Array&&e.length===64&&ka(e.subarray(0,32),fd)<0&&ka(e.subarray(32,64),fd)<0}function YI(e){return JI(e)&&e.length===64&&ka(e.subarray(0,32),XI)<0}function ZI(e){return!(B2(e.subarray(0,32))||B2(e.subarray(32,64)))}function yo(e){return e instanceof Uint8Array&&e.length===WI}function dd(e){return e===void 0||e instanceof Uint8Array&&e.length===qI}function L2(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function QI(e){return L2(Be.utils.bytesToHex(e))}function pd(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=L2(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=QI(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const ex=(e,t)=>{const r=ld(e),n=pd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r+n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},tx=(e,t)=>{const r=ld(e),n=pd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r-n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},rx=e=>{const t=ld(e),r=Be.utils._bigintTo32Bytes(Be.CURVE.n-t);return Be.utils.isValidPrivateKey(r)?r:null},H2=(e,t,r)=>{const n=Be.Point.fromHex(e),i=pd(t),o=Be.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},nx=(e,t,r)=>{const n=Be.Point.fromHex(e),i=typeof t=="string"?t:Be.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function go(e,t){return e===void 0?t!==void 0?K2(t):!0:!!e}function Ps(e){try{return e()}catch{return null}}function yd(e,t){if(e.length===32!==t)return!1;try{return!!Be.Point.fromHex(e)}catch{return!1}}function es(e){return yd(e,!1)}function K2(e){return yd(e,!1)&&e.length===33}function di(e){return Be.utils.isValidPrivateKey(e)}function Du(e){return yd(e,!0)}function ix(e,t){if(!Du(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>{const r=H2(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function j2(e){if(!es(e))throw new Error(Qi);return e.slice(1,33)}function D2(e,t){if(!di(e))throw new Error(Zi);return Ps(()=>Be.getPublicKey(e,go(t)))}function sx(e){if(!di(e))throw new Error(Zi);return j2(D2(e))}function ox(e,t){if(!es(e))throw new Error(Qi);return Be.Point.fromHex(e).toRawBytes(go(t,e))}function ax(e,t,r){if(!es(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>nx(e,t,go(r,e)))}function cx(e,t,r){if(!es(e)||!es(t))throw new Error(Qi);return Ps(()=>{const n=Be.Point.fromHex(e),i=Be.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(go(r,e))})}function ux(e,t,r){if(!es(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>H2(e,t,go(r,e)))}function lx(e,t){if(di(e)===!1)throw new Error(Zi);if(Pa(t)===!1)throw new Error(Ta);return Ps(()=>ex(e,t))}function fx(e,t){if(di(e)===!1)throw new Error(Zi);if(Pa(t)===!1)throw new Error(Ta);return Ps(()=>tx(e,t))}function hx(e){if(di(e)===!1)throw new Error(Zi);return rx(e)}function dx(e,t,r){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);return Be.signSync(e,t,{der:!1,extraEntropy:r})}function px(e,t,r){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);const[n,i]=Be.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function yx(e,t,r=Buffer.alloc(32,0)){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);return Be.schnorr.signSync(e,t,r)}function gx(e,t,r,n){if(!yo(e))throw new Error(FI);if(!hd(t)||!ZI(t))throw new Error(ju);if(r&2&&!YI(t))throw new Error(VI);if(!Du(t.subarray(0,32)))throw new Error(ju);return Be.recoverPublicKey(e,t,r,go(n))}function wx(e,t,r,n){if(!es(t))throw new Error(Qi);if(!hd(r))throw new Error(ju);if(!yo(e))throw new Error(_a);return Be.verify(r,e,t,{strict:n})}function bx(e,t,r){if(!Du(t))throw new Error(Qi);if(!hd(r))throw new Error(ju);if(!yo(e))throw new Error(_a);return Be.schnorr.verifySync(r,e,t)}var mx=ht.isPoint=es,vx=ht.isPointCompressed=K2,Ex=ht.isPrivate=di,Ax=ht.isXOnlyPoint=Du,Sx=ht.pointAdd=cx,Tx=ht.pointAddScalar=ux,_x=ht.pointCompress=ox,kx=ht.pointFromScalar=D2,Px=ht.pointMultiply=ax,Ox=ht.privateAdd=lx,Ix=ht.privateNegate=hx,xx=ht.privateSub=fx,$x=ht.recover=gx,Cx=ht.sign=dx,Nx=ht.signRecoverable=px,Ux=ht.signSchnorr=yx,Rx=ht.verify=wx,Bx=ht.verifySchnorr=bx,Lx=ht.xOnlyPointAddTweak=ix,Hx=ht.xOnlyPointFromPoint=j2,Kx=ht.xOnlyPointFromScalar=sx;UT(S5({__proto__:null,default:ht,isPoint:mx,isPointCompressed:vx,isPrivate:Ex,isXOnlyPoint:Ax,pointAdd:Sx,pointAddScalar:Tx,pointCompress:_x,pointFromScalar:kx,pointMultiply:Px,privateAdd:Ox,privateNegate:Ix,privateSub:xx,recover:$x,sign:Cx,signRecoverable:Nx,signSchnorr:Ux,verify:Rx,verifySchnorr:Bx,xOnlyPointAddTweak:Lx,xOnlyPointFromPoint:Hx,xOnlyPointFromScalar:Kx},[ht]));const nr=e=>e===Bt||e===xr||e===Ir?O5:pn,gd=e=>e.find(({purpose:t})=>t==="ordinals"),wd=e=>e.find(({purpose:t})=>t==="payment"),ir=async(e,t)=>{try{const r=await M2(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},jx=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),Dx=e=>/^[a-fA-F0-9]+$/.test(e);function Mx(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function M2(e,t){if(e.startsWith("t")){if(t===mt)return[];if(t===uo)return[];if(t===$r)return[]}return await Je.get(`${Gi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function F2(e,t,r,n,i,o,s=7){const a=e===t,u=await M2(t,o);if(!u)throw new Error("No UTXOs found");const h=u.sort((T,x)=>x.value-T.value),f=new bt({network:nr(o)}),d=Mx(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of h){const{txid:x,vout:N,value:I}=T,k=M1(t,nr(o));if(f.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=Fx(i,o);f.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return f.addOutput({address:r,value:BigInt(n)}),v>g&&f.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:f.toBase64(),psbtHex:f.toHex()}}function Fx(e,t){var r;const n=ua({pubkey:P2.Buffer.from(e,"hex"),network:nr(t)}),i=io({redeem:n,network:nr(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}class Vx extends hi{constructor(){super(...arguments),be(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Hi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{if(t.provider!==Hi){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Hi):this.parent.disconnect())}handleNetworkChanged(t){const r=Hh(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Hi)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Hi),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),ir(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Hh(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=bt.fromHex(a);if(i&&o){const h=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Dw(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}function Wx(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function zx(){return{$store:Lg({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[Hi]:!1,[ri]:!1,[ws]:!1,[ni]:!1,[Hg]:!1,[ms]:!1,[bs]:!1,[Ki]:!1,[vs]:!1,[ji]:!1}}),$network:Zf(mt),$library:Zf(void 0)}}function qx({network:e}){return{network:e}}function Gx(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Mu(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function mr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Mu(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},h=e.kind==="schema",f=(i==null?void 0:i.message)??e.message??Gx(e.reference,u.lang)??(h?(u.lang,void 0):null)??n.message??(u.lang,void 0);f&&(u.message=typeof f=="function"?f(u):f),h&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Xx(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function V2(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function W2(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function En(e,t){return{kind:"schema",type:"array",reference:En,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const h={type:"array",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else mr(this,"type",r,n);return r}}}function z2(e){return{kind:"schema",type:"boolean",reference:z2,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:mr(this,"type",t,r),t}}}function Os(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:Os,expects:r.map(Mu).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:mr(this,"type",n,i),n}}}function dt(e,t){return{kind:"schema",type:"literal",reference:dt,expects:Mu(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:mr(this,"type",r,n),r}}}function q2(e,t){return{kind:"schema",type:"loose_object",reference:q2,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"object",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)Xx(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else mr(this,"type",r,n);return r}}}function bd(e,t){return{kind:"schema",type:"non_optional",reference:bd,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(mr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function Is(e){return{kind:"schema",type:"null",reference:Is,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:mr(this,"type",t,r),t}}}function xs(e,...t){const r={kind:"schema",type:"nullish",reference:xs,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=V2(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Fn(e){return{kind:"schema",type:"number",reference:Fn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:mr(this,"type",t,r),t}}}function he(e,t){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const h={type:"object",origin:"value",input:o,key:s,value:a};for(const f of u.issues)f.path?f.path.unshift(h):f.path=[h],(i=r.issues)==null||i.push(f);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else mr(this,"type",r,n);return r}}}function An(e,...t){const r={kind:"schema",type:"optional",reference:An,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=V2(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function G2(e,t){return{kind:"schema",type:"picklist",reference:G2,expects:e.map(Mu).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:mr(this,"type",r,n),r}}}function ge(e){return{kind:"schema",type:"string",reference:ge,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:mr(this,"type",t,r),t}}}function md(e){return{kind:"schema",type:"undefined",reference:md,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:mr(this,"type",t,r),t}}}function X2(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function Fu(e,t){return{kind:"schema",type:"union",reference:Fu,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];mr(this,"type",r,n,{issues:X2(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];mr(this,"type",r,n,{issues:X2(s)})}return r}}}function Vu(){return{kind:"schema",type:"unknown",reference:Vu,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Gr={},wo={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.decode=sr.encode=sr.unescape=sr.escape=sr.pad=void 0;const J2=ho;function vd(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}sr.pad=vd;function Y2(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}sr.escape=Y2;function Z2(e){return vd(e).replace(/-/g,"+").replace(/_/g,"/")}sr.unescape=Z2;function Jx(e){return Y2((0,J2.fromByteArray)(new TextEncoder().encode(e)))}sr.encode=Jx;function Yx(e){return new TextDecoder().decode((0,J2.toByteArray)(vd(Z2(e))))}sr.decode=Yx;var Wu={},zu={},bo={};Object.defineProperty(bo,"__esModule",{value:!0}),bo.joseToDer=bo.derToJose=void 0;const Q2=ho,eb=sr;function Ed(e){return(e/8|0)+(e%8===0?0:1)}const Zx={ES256:Ed(256),ES384:Ed(384),ES512:Ed(521)};function tb(e){const t=Zx[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const qu=128,rb=0,Qx=32,e7=16,t7=2,nb=e7|Qx|rb<<6,Gu=t7|rb<<6;function ib(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Q2.toByteArray)((0,eb.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function r7(e,t){const r=ib(e),n=tb(t),i=n+1,o=r.length;let s=0;if(r[s++]!==nb)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(qu|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Gu)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const h=s;if(s+=u,r[s++]!==Gu)throw new Error('Could not find expected "int" for "s"');const f=r[s++];if(o-s!==f)throw new Error(`"s" specified length of "${f}", expected "${o-s}"`);if(i<f)throw new Error(`"s" specified length of "${f}", max of "${i}" is acceptable`);const d=s;if(s+=f,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-f,E=new Uint8Array(g+u+v+f);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(h+Math.max(-g,0),h+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+f),s),(0,eb.escape)((0,Q2.fromByteArray)(E))}bo.derToJose=r7;function sb(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=qu&&--n,n}function n7(e,t){e=ib(e);const r=tb(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=sb(e,0,r),o=sb(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,h=u<qu,f=new Uint8Array((h?2:3)+u);let d=0;return f[d++]=nb,h?f[d++]=u:(f[d++]=qu|1,f[d++]=u&255),f[d++]=Gu,f[d++]=s,i<0?(f[d++]=0,f.set(e.subarray(0,r),d),d+=r):(f.set(e.subarray(i,r),d),d+=r-i),f[d++]=Gu,f[d++]=a,o<0?(f[d++]=0,f.set(e.subarray(r),d)):f.set(e.subarray(r+o),d),f}bo.joseToDer=n7;var pi={};Object.defineProperty(pi,"__esModule",{value:!0}),pi.InvalidTokenError=pi.MissingParametersError=void 0;class i7 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}pi.MissingParametersError=i7;class s7 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}pi.InvalidTokenError=s7,Object.defineProperty(zu,"__esModule",{value:!0}),zu.SECP256K1Client=void 0;const o7=id,a7=Mn,Xu=nd,ob=bo,ab=pi,cb=Aa;Xu.utils.hmacSha256Sync=(e,...t)=>{const r=o7.hmac.create(a7.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};class ub{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,cb.bytesToHex)(Xu.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new ab.MissingParametersError("a signing input hash and private key are all required");const i=Xu.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,cb.bytesToHex)(i);if(n==="jose")return(0,ob.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,ob.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new ab.MissingParametersError("a signing input hash, der signature, and public key are all required");return Xu.verify(r,t,n,{strict:!1})}}zu.SECP256K1Client=ub,ub.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=zu;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Wu);var $s={},c7=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(f){try{h(n.next(f))}catch(d){s(d)}}function u(f){try{h(n.throw(f))}catch(d){s(d)}}function h(f){f.done?o(f.value):i(f.value).then(a,u)}h((n=n.apply(e,t||[])).next())})};Object.defineProperty($s,"__esModule",{value:!0}),$s.hashSha256Async=$s.hashSha256=void 0;const u7=Mn;function lb(e){return(0,u7.sha256)(e)}$s.hashSha256=lb;function l7(e){return c7(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=I2;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(lb(e))}})}$s.hashSha256Async=l7;var f7=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(f){try{h(n.next(f))}catch(d){s(d)}}function u(f){try{h(n.throw(f))}catch(d){s(d)}}function h(f){f.done?o(f.value):i(f.value).then(a,u)}h((n=n.apply(e,t||[])).next())})};Object.defineProperty(wo,"__esModule",{value:!0}),wo.TokenSigner=wo.createUnsecuredToken=void 0;const Ad=sr,fb=Wu,h7=pi,hb=$s;function Sd(e,t){const r=[],n=Ad.encode(JSON.stringify(t));r.push(n);const i=Ad.encode(JSON.stringify(e));return r.push(i),r.join(".")}function d7(e){return Sd(e,{typ:"JWT",alg:"none"})+"."}wo.createUnsecuredToken=d7;class p7{constructor(t,r){if(!(t&&r))throw new h7.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!fb.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=fb.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=Sd(t,i),s=(0,hb.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return f7(this,void 0,void 0,function*(){const i=this.header(n),o=Sd(t,i),s=yield(0,hb.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Ad.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}wo.TokenSigner=p7;var Ju={};Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.TokenVerifier=void 0;const y7=sr,db=Wu,g7=pi,Yu=$s;class w7{constructor(t,r){if(!(t&&r))throw new g7.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!db.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=db.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Yu.hashSha256Async)(i).then(s=>o(s));{const s=(0,Yu.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),y7.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Yu.hashSha256Async)(n).then(s=>o(s));{const s=(0,Yu.hashSha256)(n);return o(s)}}}Ju.TokenVerifier=w7;var Zu={};Object.defineProperty(Zu,"__esModule",{value:!0}),Zu.decodeToken=void 0;const Qu=sr;function b7(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(Qu.decode(t[0])),n=JSON.parse(Qu.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=Qu.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(Qu.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Zu.decodeToken=b7,function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(wo,e),r(Ju,e),r(Zu,e),r(pi,e),r(Wu,e)}(Gr);/*! *****************************************************************************
44
+ */(function(e){const t=fo,r=rd,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=O,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(We(c,ArrayBuffer)||c&&We(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(We(c,SharedArrayBuffer)||c&&We(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(We(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||or(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function O(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),We(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,I=Math.min(p,m);S<I;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let I=c[p];if(We(I,Uint8Array))S+I.length>m.length?(a.isBuffer(I)||(I=a.from(I)),I.copy(m,S)):Uint8Array.prototype.set.call(m,I,S);else if(a.isBuffer(I))I.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=I.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||We(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ht(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return _n(c).length;default:if(S)return m?-1:Ht(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return vt(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function z(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)z(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)z(this,l,l+3),z(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)z(this,l,l+7),z(this,l+1,l+6),z(this,l+2,l+5),z(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let I=S-m,U=p-l;const ce=Math.min(I,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){I=ke[ae],U=le[ae];break}return I<U?-1:U<I?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,or(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let I=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;I=2,U/=2,ce/=2,p/=2}function ke(ae,me){return I===1?ae[me]:ae.readUInt16BE(me*I)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*I}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function He(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const I=l.length;m>I/2&&(m=I/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(or(ce))return U;c[p+U]=ce}return U}function Ge(c,l,p,m){return Mt(Ht(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(_n(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let I=!1;for(;;)switch(m){case"hex":return He(this,c,l,p);case"utf8":case"utf-8":return Ge(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),I=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const I=c[S];let U=null,ce=I>239?4:I>223?3:I>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:I<128&&(U=I);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(I&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(I&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(I&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function vt(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let I=l;I<p;++I)S+=yi[c[I]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let I=0;I<m.length-1;I+=2)S+=String.fromCharCode(m[I]+m[I+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,I=this[c+--m];for(;m>0&&(S*=256);)I+=this[c+--m]*S;return S*=128,I>=S&&(I-=Math.pow(2,8*l)),I},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,I){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<I)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,I=0;for(this[l]=c&255;++I<p&&(S*=256);)this[l+I]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,I=1;for(this[l+S]=c&255;--S>=0&&(I*=256);)this[l+S]=c/I&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function H(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function Le(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p+7]=I,I=I>>8,c[p+6]=I,I=I>>8,c[p+5]=I,I=I>>8,c[p+4]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return H(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return Le(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,I=1,U=0;for(this[l]=c&255;++S<p&&(I*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,I=1,U=0;for(this[l+S]=c&255;--S>=0&&(I*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return H(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return Le(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tn(c,l,p,m,S,I){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function pt(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return pt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return pt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const I=c.charCodeAt(0);(m==="utf8"&&I<128||m==="latin1")&&(c=I)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const I=a.isBuffer(c)?c:a.from(c,m),U=I.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=I[S%U]}return this};const Et={};function Lt(c,l,p){Et[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Lt("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Lt("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Lt("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&yt(l,c.length-(p+1))}function Er(c,l,p,m,S,I){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(I+1)*8}${U}`:ce=`>= -(2${U} ** ${(I+1)*8-1}${U}) and < 2 ** ${(I+1)*8-1}${U}`,new Et.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,I)}function Ve(c,l){if(typeof c!="number")throw new Et.ERR_INVALID_ARG_TYPE(l,"number",c)}function yt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new Et.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new Et.ERR_BUFFER_OUT_OF_BOUNDS:new Et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Ht(c,l){l=l||1/0;let p;const m=c.length;let S=null;const I=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&I.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&I.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&I.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&I.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;I.push(p)}else if(p<2048){if((l-=2)<0)break;I.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;I.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;I.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return I}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const I=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,I.push(S),I.push(m);return I}function _n(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function We(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function or(c){return c!==c}const yi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(P2);const _O="https://mempool.space",kO="https://mempool.space/testnet",PO="https://mempool.space/testnet4",IO="https://mempool.space/signet",OO="https://mempool.fractalbitcoin.io",xO="https://mempool-testnet.fractalbitcoin.io",Gi=e=>e===Bt?kO:e===xr?PO:e===Or?IO:e===uo?OO:e===$r?xO:_O;var ft={},nd={};const $O={},CO=Object.freeze(Object.defineProperty({__proto__:null,default:$O},Symbol.toStringTag,{value:"Module"})),O2=OT(CO);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=O2,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,L=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let W=H(b-K*w-q*_,y),X=H(-K*A-q*$,y);const Z=W>L,te=X>L;if(Z&&(W=y-W),te&&(X=y-X),W>L||X>L)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:W,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=H(b*b),_=H(A*b);return H(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function O(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y,q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q);return X===Z&&te===P}negate(){return new k(this.x,H(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=H(y*y),$=H(w*w),L=H($*$),K=y+$,q=H(i*(H(K*K)-_-L)),W=H(o*_),X=H(W*W),Z=H(X-i*q),te=H(W*(q-Z)-s*L),P=H(i*w*A);return new k(Z,te,P)}add(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y;if($===r||L===r)return this;if(w===r||A===r)return y;const q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q),j=H(Z-X),G=H(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=H(j*j),_e=H(j*ne),$e=H(X*ne),Pe=H(G*G-_e-i*$e),Ie=H(G*($e-Pe)-te*_e),Ze=H(_*K*j);return new k(Pe,Ie,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:L,k2:K}=f.splitScalar(A),q=w,W=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(W=W.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),L&&(W=W.negate()),W=new k(H(W.x*f.beta),W.y,W.z),q.add(W)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let L=0;L<w;L++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&z.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),z.set(w,_)));let $=k.ZERO,L=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),W=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&W);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?L=L.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:L}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:L,k1:K,k2neg:q,k2:W}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(W,w);X=B(L,X),te=B(q,te),te=new k(H(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:L,f:K}=this.wNAF(A,w);_=L,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:pt(_));const L=y,K=H(L*L),q=H(K*L),W=H(w*K),X=H(A*q),Z=H(_*L);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(W,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const z=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,z.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!yt(A))throw new Error("Point is not on curve");const _=T(A);let $=Tn(_);const L=($&n)===n;w?L&&($=H(-$)):(y[0]&1)===1!==L&&($=H(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const L=Lt(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,W=pt(q,K),X=H(-L*W,K),Z=H($*W,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!yt(w)||!yt(A))throw new Error(y);const _=H(A*A),$=T(w);if(H(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,H(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),L=k.fromAffine(y).multiplyUnsafe(A),K=$.add(L);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function He(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Ge(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=He(b.subarray(2)),{data:A,left:_}=He(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(vt(_.slice(0,64)),vt(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Ge(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,H(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),L=Ae(_);return`30${Ae(_+A+4)}02${L}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function vt(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return vt(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function H(b,y=a.P){const w=b%y;return w>=r?w:y+w}function Le(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Tn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),L=BigInt(44),K=BigInt(88),q=b*b*b%y,W=q*q*b%y,X=Le(W,o)*W%y,Z=Le(X,o)*W%y,te=Le(Z,i)*q%y,P=Le(te,A)*te%y,j=Le(P,_)*P%y,G=Le(j,L)*j%y,ne=Le(G,K)*G%y,_e=Le(ne,L)*j%y,$e=Le(_e,o)*W%y,Pe=Le($e,$)*P%y,Ie=Le(Pe,w)*q%y,Ze=Le(Ie,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function pt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=H(b,y),A=y,_=r,$=n;for(;w!==r;){const L=A/w,K=A%w,q=_-$*L;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return H(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,L,K)=>L===r?$:(w[K]=$,H($*L,y)),n),_=pt(A,y);return b.reduceRight(($,L,K)=>L===r?$:(w[K]=H($*w[K],y),H($*L,y)),_),w}function Et(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Lt(b,y=!1){const w=Et(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function yt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Lt(b,!0);if(!Ve($))return;const L=pt($,_),K=V.BASE.multiply($),q=H(K.x,_);if(q===r)return;const W=H(L*H(y+w*q,_),_);if(W===r)return;let X=new Fe(q,W),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=vt(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Ht(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function _n(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=_n;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function We(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Ht(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=We;function or(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function yi(b){const y=or(b),w=H(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),yi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const L=Ye(...$),K=or(A);return{seed:L,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),L=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[L,A]:L}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);await L.reseed(A);let K;for(;!(K=Ar(await L.generate(),_,$,w.canonical));)await L.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);L.reseedSync(A);let K;for(;!(K=Ar(L.generateSync(),_,$,w.canonical));)L.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:L}=_;if(A.strict&&_.hasHighS())return!1;const K=Lt(y);let q;try{q=Ht(w)}catch{return!1}const{n:W}=a,X=pt(L,W),Z=H(K*X,W),te=H($*X,W),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?H(P.x,W)===$:!1}e.verify=S;function I(b){return H(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!yt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=H(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,H(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,L=this.initNonce(w,await $(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce(await $(kt.nonce,L,A,y)),X=I(await $(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return await rs(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,L=this.initNonce(w,$(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce($(kt.nonce,L,A,y)),X=I($(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Ht(w)}}function gi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),H(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function rs(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(await e.utils.taggedHash(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(e.utils.taggedHashSync(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:rs,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},kt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:H,invert:pt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=H(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(nd);var id={},zr={};Object.defineProperty(zr,"__esModule",{value:!0}),zr.isBytes=$2,zr.number=Hu,zr.bool=x2,zr.bytes=sd,zr.hash=C2,zr.exists=N2,zr.output=U2;function Hu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function x2(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function $2(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function sd(e,...t){if(!$2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function C2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Hu(e.outputLen),Hu(e.blockLen)}function N2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function U2(e,t){sd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const NO={number:Hu,bool:x2,bytes:sd,hash:C2,exists:N2,output:U2};zr.default=NO;var Aa={},Ku={};Object.defineProperty(Ku,"__esModule",{value:!0}),Ku.crypto=void 0,Ku.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=O,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=He,e.wrapConstructorWithOpts=Ge,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=Ku,r=zr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const vt=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(vt===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=vt*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function O(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=O(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class z{clone(){return this._cloneInto()}}e.Hash=z;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function He(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Ge(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(Aa),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=zr,r=Aa;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(id);var Mn={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.HashMD=Xi.Maj=Xi.Chi=void 0;const od=zr,Sa=Aa;function UO(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const RO=(e,t,r)=>e&t^~e&r;Xi.Chi=RO;const BO=(e,t,r)=>e&t^e&r^t&r;Xi.Maj=BO;class LO extends Sa.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Sa.createView)(this.buffer)}update(t){(0,od.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Sa.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Sa.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,od.exists)(this),(0,od.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;UO(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Sa.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}}Xi.HashMD=LO,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.sha224=Mn.sha256=Mn.SHA256=void 0;const ad=Xi,qr=Aa,HO=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]),Ji=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yi=new Uint32Array(64);class cd extends ad.HashMD{constructor(){super(64,32,8,!1),this.A=Ji[0]|0,this.B=Ji[1]|0,this.C=Ji[2]|0,this.D=Ji[3]|0,this.E=Ji[4]|0,this.F=Ji[5]|0,this.G=Ji[6]|0,this.H=Ji[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Yi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Yi[d-15],v=Yi[d-2],E=(0,qr.rotr)(g,7)^(0,qr.rotr)(g,18)^g>>>3,T=(0,qr.rotr)(v,17)^(0,qr.rotr)(v,19)^v>>>10;Yi[d]=T+Yi[d-7]+E+Yi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,qr.rotr)(a,6)^(0,qr.rotr)(a,11)^(0,qr.rotr)(a,25),v=h+g+(0,ad.Chi)(a,u,f)+HO[d]+Yi[d]|0,E=((0,qr.rotr)(n,2)^(0,qr.rotr)(n,13)^(0,qr.rotr)(n,22))+(0,ad.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Yi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Mn.SHA256=cd;class KO extends cd{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}}Mn.sha256=(0,qr.wrapConstructor)(()=>new cd),Mn.sha224=(0,qr.wrapConstructor)(()=>new KO);var jO=nd,DO=id,R2=Mn;function MO(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Be=MO(jO);const Zi="Expected Private",Qi="Expected Point",Ta="Expected Tweak",FO="Expected Hash",ju="Expected Signature",ud="Expected Extra Data (32 bytes)",_a="Expected Scalar",VO="Bad Recovery Id";Be.utils.hmacSha256Sync=(e,...t)=>DO.hmac(R2.sha256,e,Be.utils.concatBytes(...t)),Be.utils.sha256Sync=(...e)=>R2.sha256(Be.utils.concatBytes(...e));const ld=Be.utils._normalizePrivateKey,WO=32,zO=32,hd=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),qO=32,GO=new Uint8Array(32),XO=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function JO(e){return e instanceof Uint8Array}function ka(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function B2(e){return ka(e,GO)===0}function Pa(e){return!(!(e instanceof Uint8Array)||e.length!==zO||ka(e,hd)>=0)}function fd(e){return e instanceof Uint8Array&&e.length===64&&ka(e.subarray(0,32),hd)<0&&ka(e.subarray(32,64),hd)<0}function YO(e){return JO(e)&&e.length===64&&ka(e.subarray(0,32),XO)<0}function ZO(e){return!(B2(e.subarray(0,32))||B2(e.subarray(32,64)))}function yo(e){return e instanceof Uint8Array&&e.length===WO}function dd(e){return e===void 0||e instanceof Uint8Array&&e.length===qO}function L2(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function QO(e){return L2(Be.utils.bytesToHex(e))}function pd(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=L2(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=QO(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const ex=(e,t)=>{const r=ld(e),n=pd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r+n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},tx=(e,t)=>{const r=ld(e),n=pd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r-n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},rx=e=>{const t=ld(e),r=Be.utils._bigintTo32Bytes(Be.CURVE.n-t);return Be.utils.isValidPrivateKey(r)?r:null},H2=(e,t,r)=>{const n=Be.Point.fromHex(e),i=pd(t),o=Be.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},nx=(e,t,r)=>{const n=Be.Point.fromHex(e),i=typeof t=="string"?t:Be.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function go(e,t){return e===void 0?t!==void 0?K2(t):!0:!!e}function Ps(e){try{return e()}catch{return null}}function yd(e,t){if(e.length===32!==t)return!1;try{return!!Be.Point.fromHex(e)}catch{return!1}}function es(e){return yd(e,!1)}function K2(e){return yd(e,!1)&&e.length===33}function di(e){return Be.utils.isValidPrivateKey(e)}function Du(e){return yd(e,!0)}function ix(e,t){if(!Du(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>{const r=H2(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function j2(e){if(!es(e))throw new Error(Qi);return e.slice(1,33)}function D2(e,t){if(!di(e))throw new Error(Zi);return Ps(()=>Be.getPublicKey(e,go(t)))}function sx(e){if(!di(e))throw new Error(Zi);return j2(D2(e))}function ox(e,t){if(!es(e))throw new Error(Qi);return Be.Point.fromHex(e).toRawBytes(go(t,e))}function ax(e,t,r){if(!es(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>nx(e,t,go(r,e)))}function cx(e,t,r){if(!es(e)||!es(t))throw new Error(Qi);return Ps(()=>{const n=Be.Point.fromHex(e),i=Be.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(go(r,e))})}function ux(e,t,r){if(!es(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>H2(e,t,go(r,e)))}function lx(e,t){if(di(e)===!1)throw new Error(Zi);if(Pa(t)===!1)throw new Error(Ta);return Ps(()=>ex(e,t))}function hx(e,t){if(di(e)===!1)throw new Error(Zi);if(Pa(t)===!1)throw new Error(Ta);return Ps(()=>tx(e,t))}function fx(e){if(di(e)===!1)throw new Error(Zi);return rx(e)}function dx(e,t,r){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);return Be.signSync(e,t,{der:!1,extraEntropy:r})}function px(e,t,r){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);const[n,i]=Be.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function yx(e,t,r=Buffer.alloc(32,0)){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);return Be.schnorr.signSync(e,t,r)}function gx(e,t,r,n){if(!yo(e))throw new Error(FO);if(!fd(t)||!ZO(t))throw new Error(ju);if(r&2&&!YO(t))throw new Error(VO);if(!Du(t.subarray(0,32)))throw new Error(ju);return Be.recoverPublicKey(e,t,r,go(n))}function wx(e,t,r,n){if(!es(t))throw new Error(Qi);if(!fd(r))throw new Error(ju);if(!yo(e))throw new Error(_a);return Be.verify(r,e,t,{strict:n})}function bx(e,t,r){if(!Du(t))throw new Error(Qi);if(!fd(r))throw new Error(ju);if(!yo(e))throw new Error(_a);return Be.schnorr.verifySync(r,e,t)}var mx=ft.isPoint=es,vx=ft.isPointCompressed=K2,Ex=ft.isPrivate=di,Ax=ft.isXOnlyPoint=Du,Sx=ft.pointAdd=cx,Tx=ft.pointAddScalar=ux,_x=ft.pointCompress=ox,kx=ft.pointFromScalar=D2,Px=ft.pointMultiply=ax,Ix=ft.privateAdd=lx,Ox=ft.privateNegate=fx,xx=ft.privateSub=hx,$x=ft.recover=gx,Cx=ft.sign=dx,Nx=ft.signRecoverable=px,Ux=ft.signSchnorr=yx,Rx=ft.verify=wx,Bx=ft.verifySchnorr=bx,Lx=ft.xOnlyPointAddTweak=ix,Hx=ft.xOnlyPointFromPoint=j2,Kx=ft.xOnlyPointFromScalar=sx;UT(S5({__proto__:null,default:ft,isPoint:mx,isPointCompressed:vx,isPrivate:Ex,isXOnlyPoint:Ax,pointAdd:Sx,pointAddScalar:Tx,pointCompress:_x,pointFromScalar:kx,pointMultiply:Px,privateAdd:Ix,privateNegate:Ox,privateSub:xx,recover:$x,sign:Cx,signRecoverable:Nx,signSchnorr:Ux,verify:Rx,verifySchnorr:Bx,xOnlyPointAddTweak:Lx,xOnlyPointFromPoint:Hx,xOnlyPointFromScalar:Kx},[ft]));const nr=e=>e===Bt||e===xr||e===Or?I5:pn,gd=e=>e.find(({purpose:t})=>t==="ordinals"),wd=e=>e.find(({purpose:t})=>t==="payment"),ir=async(e,t)=>{try{const r=await M2(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},jx=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),Dx=e=>/^[a-fA-F0-9]+$/.test(e);function Mx(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function M2(e,t){if(e.startsWith("t")){if(t===mt)return[];if(t===uo)return[];if(t===$r)return[]}return await Je.get(`${Gi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function F2(e,t,r,n,i,o,s=7){const a=e===t,u=await M2(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new bt({network:nr(o)}),d=Mx(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:O}=T,k=M1(t,nr(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(O)}}),!a){const B=Fx(i,o);h.updateInput(E,{redeemScript:B})}if(v+=O,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function Fx(e,t){var r;const n=ua({pubkey:P2.Buffer.from(e,"hex"),network:nr(t)}),i=io({redeem:n,network:nr(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}class Vx extends fi{constructor(){super(...arguments),be(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Hi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{if(t.provider!==Hi){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Hi):this.parent.disconnect())}handleNetworkChanged(t){const r=Hf(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Hi)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Hi),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),ir(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Hf(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=bt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Dw(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}function Wx(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function zx(){return{$store:Lg({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[Hi]:!1,[ri]:!1,[ws]:!1,[ni]:!1,[Hg]:!1,[ms]:!1,[bs]:!1,[Ki]:!1,[vs]:!1,[ji]:!1}}),$network:Yh(mt),$library:Yh(void 0)}}function qx({network:e}){return{network:e}}function Gx(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Mu(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function mr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Mu(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Gx(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Xx(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function V2(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function W2(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function En(e,t){return{kind:"schema",type:"array",reference:En,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else mr(this,"type",r,n);return r}}}function z2(e){return{kind:"schema",type:"boolean",reference:z2,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:mr(this,"type",t,r),t}}}function Is(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:Is,expects:r.map(Mu).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:mr(this,"type",n,i),n}}}function dt(e,t){return{kind:"schema",type:"literal",reference:dt,expects:Mu(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:mr(this,"type",r,n),r}}}function q2(e,t){return{kind:"schema",type:"loose_object",reference:q2,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)Xx(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else mr(this,"type",r,n);return r}}}function bd(e,t){return{kind:"schema",type:"non_optional",reference:bd,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(mr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function Os(e){return{kind:"schema",type:"null",reference:Os,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:mr(this,"type",t,r),t}}}function xs(e,...t){const r={kind:"schema",type:"nullish",reference:xs,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=V2(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Fn(e){return{kind:"schema",type:"number",reference:Fn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:mr(this,"type",t,r),t}}}function fe(e,t){return{kind:"schema",type:"object",reference:fe,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else mr(this,"type",r,n);return r}}}function An(e,...t){const r={kind:"schema",type:"optional",reference:An,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=V2(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function G2(e,t){return{kind:"schema",type:"picklist",reference:G2,expects:e.map(Mu).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:mr(this,"type",r,n),r}}}function ge(e){return{kind:"schema",type:"string",reference:ge,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:mr(this,"type",t,r),t}}}function md(e){return{kind:"schema",type:"undefined",reference:md,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:mr(this,"type",t,r),t}}}function X2(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function Fu(e,t){return{kind:"schema",type:"union",reference:Fu,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];mr(this,"type",r,n,{issues:X2(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];mr(this,"type",r,n,{issues:X2(s)})}return r}}}function Vu(){return{kind:"schema",type:"unknown",reference:Vu,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Gr={},wo={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.decode=sr.encode=sr.unescape=sr.escape=sr.pad=void 0;const J2=fo;function vd(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}sr.pad=vd;function Y2(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}sr.escape=Y2;function Z2(e){return vd(e).replace(/-/g,"+").replace(/_/g,"/")}sr.unescape=Z2;function Jx(e){return Y2((0,J2.fromByteArray)(new TextEncoder().encode(e)))}sr.encode=Jx;function Yx(e){return new TextDecoder().decode((0,J2.toByteArray)(vd(Z2(e))))}sr.decode=Yx;var Wu={},zu={},bo={};Object.defineProperty(bo,"__esModule",{value:!0}),bo.joseToDer=bo.derToJose=void 0;const Q2=fo,eb=sr;function Ed(e){return(e/8|0)+(e%8===0?0:1)}const Zx={ES256:Ed(256),ES384:Ed(384),ES512:Ed(521)};function tb(e){const t=Zx[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const qu=128,rb=0,Qx=32,e7=16,t7=2,nb=e7|Qx|rb<<6,Gu=t7|rb<<6;function ib(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Q2.toByteArray)((0,eb.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function r7(e,t){const r=ib(e),n=tb(t),i=n+1,o=r.length;let s=0;if(r[s++]!==nb)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(qu|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Gu)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Gu)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,eb.escape)((0,Q2.fromByteArray)(E))}bo.derToJose=r7;function sb(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=qu&&--n,n}function n7(e,t){e=ib(e);const r=tb(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=sb(e,0,r),o=sb(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<qu,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=nb,f?h[d++]=u:(h[d++]=qu|1,h[d++]=u&255),h[d++]=Gu,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Gu,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}bo.joseToDer=n7;var pi={};Object.defineProperty(pi,"__esModule",{value:!0}),pi.InvalidTokenError=pi.MissingParametersError=void 0;class i7 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}pi.MissingParametersError=i7;class s7 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}pi.InvalidTokenError=s7,Object.defineProperty(zu,"__esModule",{value:!0}),zu.SECP256K1Client=void 0;const o7=id,a7=Mn,Xu=nd,ob=bo,ab=pi,cb=Aa;Xu.utils.hmacSha256Sync=(e,...t)=>{const r=o7.hmac.create(a7.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};class ub{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,cb.bytesToHex)(Xu.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new ab.MissingParametersError("a signing input hash and private key are all required");const i=Xu.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,cb.bytesToHex)(i);if(n==="jose")return(0,ob.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,ob.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new ab.MissingParametersError("a signing input hash, der signature, and public key are all required");return Xu.verify(r,t,n,{strict:!1})}}zu.SECP256K1Client=ub,ub.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=zu;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Wu);var $s={},c7=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty($s,"__esModule",{value:!0}),$s.hashSha256Async=$s.hashSha256=void 0;const u7=Mn;function lb(e){return(0,u7.sha256)(e)}$s.hashSha256=lb;function l7(e){return c7(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=O2;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(lb(e))}})}$s.hashSha256Async=l7;var h7=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(wo,"__esModule",{value:!0}),wo.TokenSigner=wo.createUnsecuredToken=void 0;const Ad=sr,hb=Wu,f7=pi,fb=$s;function Sd(e,t){const r=[],n=Ad.encode(JSON.stringify(t));r.push(n);const i=Ad.encode(JSON.stringify(e));return r.push(i),r.join(".")}function d7(e){return Sd(e,{typ:"JWT",alg:"none"})+"."}wo.createUnsecuredToken=d7;class p7{constructor(t,r){if(!(t&&r))throw new f7.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!hb.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=hb.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=Sd(t,i),s=(0,fb.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return h7(this,void 0,void 0,function*(){const i=this.header(n),o=Sd(t,i),s=yield(0,fb.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Ad.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}wo.TokenSigner=p7;var Ju={};Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.TokenVerifier=void 0;const y7=sr,db=Wu,g7=pi,Yu=$s;class w7{constructor(t,r){if(!(t&&r))throw new g7.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!db.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=db.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Yu.hashSha256Async)(i).then(s=>o(s));{const s=(0,Yu.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),y7.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Yu.hashSha256Async)(n).then(s=>o(s));{const s=(0,Yu.hashSha256)(n);return o(s)}}}Ju.TokenVerifier=w7;var Zu={};Object.defineProperty(Zu,"__esModule",{value:!0}),Zu.decodeToken=void 0;const Qu=sr;function b7(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(Qu.decode(t[0])),n=JSON.parse(Qu.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=Qu.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(Qu.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Zu.decodeToken=b7,function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(wo,e),r(Ju,e),r(Zu,e),r(pi,e),r(Wu,e)}(Gr);/*! *****************************************************************************
45
45
  Copyright (c) Microsoft Corporation.
46
46
 
47
47
  Permission to use, copy, modify, and/or distribute this software for any
@@ -54,7 +54,7 @@ PROCEED WITH CAUTION!
54
54
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
55
55
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
56
56
  PERFORMANCE OF THIS SOFTWARE.
57
- ***************************************************************************** */var pb="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<pb.length;++t)e[pb.charCodeAt(t)]=t})();var yb,Td,el,_d=(yb=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,I=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,I.push(T>>x&N);if(E)x>0&&I.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return I}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function h(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function f(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const I=(E=x).lastIndexOf("1");if(I===-1)return"No separator character for "+E;if(I===0)return"Missing prefix for "+E;const k=E.slice(0,I),B=E.slice(I+1);if(B.length<6)return"Data too short";let z=o(k);if(typeof z=="string")return z;const V=[];for(let Ue=0;Ue<B.length;++Ue){const He=B.charAt(Ue),Ge=n[He];if(Ge===void 0)return"Unknown character "+He;z=i(z)^Ge,Ue+6>=B.length||V.push(Ge)}return z!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let I=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,I+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)I+=r.charAt(N>>5*(5-k)&31);return I},toWords:a,fromWordsUnsafe:u,fromWords:h}}t.bech32=f("bech32"),t.bech32m=f("bech32m")},yb(Td={exports:{}},Td.exports),Td.exports);(el=_d)&&el.__esModule&&Object.prototype.hasOwnProperty.call(el,"default")&&el.default,_d.bech32m,_d.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var mo,vo;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(mo||(mo={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(vo||(vo={})),vo.p2pkh,mo.mainnet,vo.p2pkh,mo.testnet,vo.p2sh,mo.mainnet,vo.p2sh,mo.testnet;var m7="accountChange";he({type:dt(m7)});var v7="networkChange";he({type:dt(v7)});var E7="disconnect";he({type:dt(E7)});async function kd(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var gb=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(gb||{}),Pd=An(Fu([ge(),Fn(),Is()])),vr=he({jsonrpc:dt("2.0"),method:ge(),params:An(Fu([En(Vu()),q2({}),Is()])),id:Pd}),tl=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(tl||{}),wb=he({jsonrpc:dt("2.0"),result:bd(Vu()),id:Pd}),bb=he({jsonrpc:dt("2.0"),error:bd(Vu()),id:Pd});Fu([wb,bb]);var rl=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(rl||{}),mb=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(mb||{}),A7=he({address:ge(),publicKey:ge(),purpose:Os(rl),addressType:Os(mb)}),vb=async e=>{var t,r;const n=await kd(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Gr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},S7="stx_getAddresses",T7=xs(he({message:An(ge())}));he({...vr.entries,...he({method:dt(S7),params:T7,id:ge()}).entries});var _7="stx_signTransaction",k7=he({transaction:ge(),pubkey:An(ge()),broadcast:An(z2())});he({...vr.entries,...he({method:dt(_7),params:k7,id:ge()}).entries});var P7=["software","ledger"],O7=G2(P7),I7="getInfo",x7=xs(Is());he({version:ge(),methods:An(En(ge())),supports:En(ge())}),he({...vr.entries,...he({method:dt(I7),params:x7,id:ge()}).entries});var $7="getAddresses",C7=he({purposes:En(Os(rl)),message:An(ge())});he({...vr.entries,...he({method:dt($7),params:C7,id:ge()}).entries});var N7="signMessage",nl=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(nl||{}),U7=he({address:ge(),message:ge(),protocol:An(Os(nl))});he({signature:ge(),messageHash:ge(),address:ge(),protocol:Os(nl)}),he({...vr.entries,...he({method:dt(N7),params:U7,id:ge()}).entries});var R7="getAccounts",B7=he({purposes:En(Os(rl)),message:An(ge())});En(he({...A7.entries,...he({walletType:O7}).entries})),he({...vr.entries,...he({method:dt(R7),params:B7,id:ge()}).entries});var L7="getBalance";xs(Is()),he({...vr.entries,...he({method:dt(L7),id:ge()}).entries});var H7="wallet_requestPermissions",K7=md();dt(!0),he({...vr.entries,...he({method:dt(H7),params:K7,id:ge()}).entries});var j7="wallet_renouncePermissions",D7=md();dt(!0),he({...vr.entries,...he({method:dt(j7),params:D7,id:ge()}).entries});var M7="wallet_getWalletType";xs(Is()),he({...vr.entries,...he({method:dt(M7),id:ge()}).entries});var F7="runes_getBalance",V7=xs(Is());he({balances:En(he({runeName:ge(),amount:ge(),divisibility:Fn(),symbol:ge(),inscriptionId:xs(ge())}))}),he({...vr.entries,...he({method:dt(F7),params:V7,id:ge()}).entries});var W7="runes_transfer",z7=he({recipients:En(he({runeName:ge(),amount:ge(),address:ge()}))});he({...vr.entries,...he({method:dt(W7),params:z7,id:ge()}).entries});var q7="ord_getInscriptions",G7=he({offset:Fn(),limit:Fn()});he({total:Fn(),limit:Fn(),offset:Fn(),inscriptions:En(he({inscriptionId:ge(),inscriptionNumber:ge(),address:ge(),collectionName:An(ge()),postage:ge(),contentLength:ge(),contentType:ge(),timestamp:Fn(),offset:Fn(),genesisTransaction:ge(),output:ge()}))}),he({...vr.entries,...he({method:dt(q7),params:G7,id:ge()}).entries});var X7="ord_sendInscriptions",J7=he({transfers:En(he({address:ge(),inscriptionId:ge()}))});he({...vr.entries,...he({method:dt(X7),params:J7,id:ge()}).entries});var Eb=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return W2(bb,o)?{status:"error",error:o.error}:W2(wb,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},Y7=async e=>{var t,r;const n=await kd(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Gr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},Z7=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),Q7=async e=>{var t,r;const n=await kd(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=Z7(i),h={network:s,senderAddress:o,message:a,recipients:u},f=Gr.createUnsecuredToken(h),d=await n.sendBtcTransaction(f);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let Ab=e=>e,Oa={},ts={addEventListener(){},removeEventListener(){}};function e$(){try{return typeof localStorage<"u"}catch{return!1}}e$()&&(Oa=localStorage),typeof window<"u"&&(ts={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function Eo(e,t={},r={}){let n=r.encode||Ab,i=r.decode||Ab,o=Lg(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&ts.perKey&&ts.removeEventListener(e+d,h,f),delete Oa[e+d]):(r.listen!==!1&&ts.perKey&&!(d in o.value)&&ts.addEventListener(e+d,h,f),Oa[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function h(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function f(){let d={...t};for(let g in Oa)g.startsWith(e)&&(d[g.slice(e.length)]=i(Oa[g]));for(let g in d)o.setKey(g,d[g])}return P5(o,()=>{if(f(),r.listen!==!1)return ts.addEventListener(e,h,f),()=>{ts.removeEventListener(e,h,f);for(let d in o.value)ts.removeEventListener(e+d,h,f)}}),o}const Sb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],t$="XVERSE_CONNECTED_WALLET_STATE";class r$ extends hi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(t$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Sb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ri&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Sb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){Bn(this.$store,["provider"],t=>{t.provider!==ri?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ri]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=wa(this.network||mt);await vb({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=gd(o.addresses),a=wd(o.addresses);s&&a&&(this.$store.setKey("provider",ri),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),ir(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ri} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ri} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Ir,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){const n=await Eb("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await Eb("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromBase64(String(n),{network:nr(this.network)}),h=u.data.inputs,f=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let I of h){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=da(k,nr(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&f.push(d),g.signingIndexes.length>0&&f.push(g);let E,T,x;const N={payload:{network:{type:wa(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:f},onFinish:I=>{if(I.txId)E=I.txId;else if(I.psbtBase64){const k=bt.fromBase64(String(I.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw mn}}class n$ extends hi{constructor(){super(...arguments),be(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(vs)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){Bn(this.$store,["provider"],t=>{t.provider===vs?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw CP;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",vs),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?Mw(r):void 0}async switchNetwork(t){var r;if(t===$r||t===uo)return await this.library.switchNetwork(Kw);const n=Mw(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=bt.fromHex(a);let h;return i&&o&&(h=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}async pushPsbt(t){return await Je.post(`${Gi(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const Tb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],i$="OYL_CONNECTED_WALLET_STATE";class s$ extends hi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(i$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Tb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ws&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Tb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ws]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==ws?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",ws),ir(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await F2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=bt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw mn}}const _b=["address","paymentAddress","publicKey","paymentPublicKey","balance"],o$="LEATHER_CONNECTED_WALLET_STATE";class a$ extends hi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(o$,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of _b)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===bs&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):_b.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[bs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==bs?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Qf),a=i.find(u=>u.type===Kg);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==Bt&&this.network!==xr&&this.network!==Ir)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",bs),ir(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Qf:Kg;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=bt.fromHex(String(a));if(i&&o){const h=u.finalizeAllInputs(),f=await this.pushPsbt(h.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}else if(i){const h=u.finalizeAllInputs();return{signedPsbtHex:h.toHex(),signedPsbtBase64:h.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=bt.fromHex(t).extractTransaction();return await Je.post(`${Gi(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Qf);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await ir(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw mn}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw mn}}var Od={},kb={},Sn={},Pb={};Object.defineProperty(Pb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const f=await s();if(f)return f}const h=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!h)throw new Error("No Orange Bitcoin wallet installed");return h}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(h=>h.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((h,f)=>h==null?void 0:h[f],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(Pb,e)}(Sn);var Ob={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(Ob),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Gr,i=Sn,o=async s=>{var a,u;const h=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:f}=s.payload;if(!f)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await h.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(Ob,e)}(kb);var Ib={},xb={},$b={};Object.defineProperty($b,"__esModule",{value:!0});var Cb={};Object.defineProperty(Cb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r($b,e),r(Cb,e)}(xb),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=Sn,i=async(s,a,u)=>{var h;let f=((h=window.OrangecryptoProviders)==null?void 0:h.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(f=await(0,n.getProviderById)(u)),!f)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await f.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(xb,e)}(Ib);var Nb={},Ub={};Object.defineProperty(Ub,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(a,u,h,f){f===void 0&&(f=h);var d=Object.getOwnPropertyDescriptor(u,h);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[h]}}),Object.defineProperty(a,f,d)}:function(a,u,h,f){f===void 0&&(f=h),a[f]=u[h]}),r=Te&&Te.__exportStar||function(a,u){for(var h in a)h!=="default"&&!Object.prototype.hasOwnProperty.call(u,h)&&t(u,a,h)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Gr,i=Sn,o=(a,u)=>{const h=d=>!(!a[d]||u&&!u.has(d)),f={request:h("request"),connect:h("connect"),signMessage:h("signMessage"),signTransaction:h("signTransaction"),sendBtcTransaction:h("sendBtcTransaction"),createInscription:h("createInscription"),createRepeatInscriptions:h("createRepeatInscriptions"),signMultipleTransactions:h("signMultipleTransactions")};return Object.entries(f).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,h,f;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(h=a.onFinish)==null||h.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(f=a.onCancel)==null||f.call(a)}};e.getCapabilities=s,r(Ub,e)}(Nb);var Rb={},il={},Ia={};Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.validateInscriptionPayload=void 0;const c$=4e5,u$=6e4,l$=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?c$:u$))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Ia.validateInscriptionPayload=l$,Object.defineProperty(il,"__esModule",{value:!0}),il.createInscription=void 0;const f$=Gr,h$=Sn,d$=Ia,p$=async e=>{var t,r;const{getProvider:n}=e,i=await(0,h$.getProviderOrThrow)(n);(0,d$.validateInscriptionPayload)(e.payload);try{const o=(0,f$.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};il.createInscription=p$;var sl={};Object.defineProperty(sl,"__esModule",{value:!0}),sl.createRepeatInscriptions=void 0;const y$=Sn,g$=Gr,w$=Ia,b$=async e=>{var t,r;const{getProvider:n}=e,i=await(0,y$.getProviderOrThrow)(n);(0,w$.validateInscriptionPayload)(e.payload);try{const o=(0,g$.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};sl.createRepeatInscriptions=b$;var Bb={};Object.defineProperty(Bb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(il,e),r(sl,e),r(Bb,e)}(Rb);var Lb={},Hb={};Object.defineProperty(Hb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,h){h===void 0&&(h=u);var f=Object.getOwnPropertyDescriptor(a,u);(!f||("get"in f?!a.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,h,f)}:function(s,a,u,h){h===void 0&&(h=u),s[h]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Gr,i=Sn,o=async s=>{var a,u;const h=await(0,i.getProviderOrThrow)(s.getProvider),{address:f,message:d}=s.payload;if(!f)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await h.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Hb,e)}(Lb);var Kb={},ol={};Object.defineProperty(ol,"__esModule",{value:!0}),ol.sendBtcTransaction=void 0;const m$=Gr,v$=Sn,E$=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),A$=async e=>{var t,r;const n=await(0,v$.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=E$(i),h={network:s,senderAddress:o,message:a,recipients:u},f=(0,m$.createUnsecuredToken)(h),d=await n.sendBtcTransaction(f);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};ol.sendBtcTransaction=A$;var al={};Object.defineProperty(al,"__esModule",{value:!0}),al.signTransaction=void 0;const S$=Gr,T$=Sn,_$=async e=>{var t,r;const n=await(0,T$.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,S$.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};al.signTransaction=_$;var cl={};Object.defineProperty(cl,"__esModule",{value:!0}),cl.signMultipleTransactions=void 0;const k$=Gr,P$=Sn,O$=async e=>{var t,r;const n=await(0,P$.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,k$.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};cl.signMultipleTransactions=O$;var jb={};Object.defineProperty(jb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(ol,e),r(al,e),r(cl,e),r(jb,e)}(Kb);var Db={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Db),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(kb,e),r(Ib,e),r(Nb,e),r(Rb,e),r(Lb,e),r(Sn,e),r(Kb,e),r(Db,e)}(Od);const I$=OT(Od),Mb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:x$,sendBtcTransaction:$$,signTransaction:C$}=I$,N$="ORANGE_CONNECTED_WALLET_STATE";class U$ extends hi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(N$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Mb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ji&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Mb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ji]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],r=>{r.provider!==ji?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Ou(this.network||mt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=gd(s.addresses),u=wd(s.addresses);a&&u&&(this.$store.setKey("publicKey",String(s.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(s.addresses[1].publicKey)),this.$store.setKey("provider",ji),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),ir(u.address,this.network).then(h=>{this.$store.setKey("balance",h)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ji} wallet`)}};await Od.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Ir,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){let n="";const i={payload:{network:{type:Ou(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{console.log(o),n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await $$(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Ou(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await x$(o),n}async signPsbt(t,r,n,i,o){const s=bt.fromBase64(String(n),{network:nr(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,h=s.data.inputs,f=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let I of h){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=da(k,nr(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&f.push(d),g.signingIndexes.length>0&&f.push(g);let E,T,x;const N={payload:{network:{type:Ou(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:f},onFinish:I=>{if(console.log(I),I.txId)E=I.txId;else if(I.psbtBase64){const k=bt.fromBase64(String(I.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await C$(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=bt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Je.post(`${Gi(this.network)}/api/tx`,r).then(n=>n.data)}}const Fb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R$="OKX_CONNECTED_WALLET_STATE";class B$ extends hi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(R$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===Bt||this.network===xr||this.network===Ir||this.network===$r?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===mt||this.network===uo)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Fb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ms&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Fb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ms]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],r=>{r.provider!==ms?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ms),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===Bt||r===xr||r===$r?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===Bt?Bt:r===xr?xr:r===Ir?Ir:r===$r?$r:Bt;const n=await this.library.getNetwork();return DP(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=bt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}}const Vb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],L$="MAGIC_EDEN_CONNECTED_WALLET_STATE";class H$ extends hi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(L$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Vb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ni&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Vb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ni]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==ni?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=wa(this.network||mt);await vb({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=gd(o.addresses),a=wd(o.addresses);s&&a&&(this.$store.setKey("provider",ni),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),ir(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ni} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ni} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Ir,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){let n;if(await Q7({getProvider:async()=>this.library,payload:{network:{type:wa(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await Y7({getProvider:async()=>this.library,payload:{network:{type:gb.Mainnet},address:n,message:t,protocol:nl.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromBase64(String(n),{network:nr(this.network)}),h=u.data.inputs,f=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of h){const{script:B}=k.witnessUtxo,z=da(B,nr(this.network));z===a?g.signingIndexes.push(Number(v)):z===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&f.push(d),g.signingIndexes.length>0&&f.push(g);let E,T,x;const N=wa(this.network),I={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:f},onFinish:k=>{if(k.psbtBase64){const B=bt.fromBase64(String(k.psbtBase64),{network:nr(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(I),o){const k=bt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}}class K$ extends hi{constructor(){super(...arguments),be(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ki]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{if(t.provider!==Ki){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Ki):this.parent.disconnect())}handleNetworkChanged(t){const r=Hh(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Ki)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",Ki),ir(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?Bt:mt}async sendBTC(t,r){const{psbtHex:n}=await F2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromHex(String(r),{network:nr(this.network)}).data.inputs,h=[],f={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=da(x,nr(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&f.signingIndexes.push(Number(g)),g++}f.signingIndexes.length>0&&h.push(f),d.signingIndexes.length>0&&h.push(d);const v=await this.library.signPsbt(r,{inputsToSign:h}),E=bt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Dw(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class j${constructor(t,r){be(this,"$store"),be(this,"$network"),be(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[bs]:new a$(t,this,r),[ni]:new H$(t,this,r),[ms]:new B$(t,this,r),[ji]:new U$(t,this,r),[ws]:new s$(t,this,r),[Ki]:new K$(t,this,r),[Hi]:new Vx(t,this,r),[ri]:new r$(t,this,r),[vs]:new n$(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Bg(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Bg(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),Wx()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(eh);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(eh,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(eh)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(Dx(t))s=bt.fromHex(t).toBase64(),o=t;else if(jx(t))s=t,o=bt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}}const D$={hasUnisat:!1,hasXverse:!1,hasOyl:!1,hasMagicEden:!1,hasOkx:!1,hasOrange:!1,hasOpNet:!1,hasLeather:!1,hasPhantom:!1,hasWizz:!1,isInitializing:!0,connected:!1,isConnecting:!1,publicKey:"",address:"",paymentAddress:"",paymentPublicKey:"",balance:void 0,network:mt,library:null,provider:null,accounts:[],connect:async e=>{},disconnect:()=>{},requestAccounts:async()=>[],getNetwork:async()=>mt,switchNetwork:async e=>{},getPublicKey:async()=>"",getBalance:async()=>"",getInscriptions:async()=>[],sendBTC:async(e,t)=>"",signMessage:async e=>"",signPsbt:async e=>({signedPsbtHex:"",signedPsbtBase64:"",txId:""}),pushPsbt:async e=>"",inscribe:async e=>"",isCreatingCommit:!1,isInscribing:!1},Wb=tn.createContext(D$),M$=()=>tn.useContext(Wb);var Id={exports:{}},xa={};/**
57
+ ***************************************************************************** */var pb="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<pb.length;++t)e[pb.charCodeAt(t)]=t})();var yb,Td,el,_d=(yb=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,O=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,O.push(T>>x&N);if(E)x>0&&O.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return O}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function f(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function h(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const O=(E=x).lastIndexOf("1");if(O===-1)return"No separator character for "+E;if(O===0)return"Missing prefix for "+E;const k=E.slice(0,O),B=E.slice(O+1);if(B.length<6)return"Data too short";let z=o(k);if(typeof z=="string")return z;const V=[];for(let Ue=0;Ue<B.length;++Ue){const He=B.charAt(Ue),Ge=n[He];if(Ge===void 0)return"Unknown character "+He;z=i(z)^Ge,Ue+6>=B.length||V.push(Ge)}return z!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let O=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,O+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)O+=r.charAt(N>>5*(5-k)&31);return O},toWords:a,fromWordsUnsafe:u,fromWords:f}}t.bech32=h("bech32"),t.bech32m=h("bech32m")},yb(Td={exports:{}},Td.exports),Td.exports);(el=_d)&&el.__esModule&&Object.prototype.hasOwnProperty.call(el,"default")&&el.default,_d.bech32m,_d.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var mo,vo;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(mo||(mo={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(vo||(vo={})),vo.p2pkh,mo.mainnet,vo.p2pkh,mo.testnet,vo.p2sh,mo.mainnet,vo.p2sh,mo.testnet;var m7="accountChange";fe({type:dt(m7)});var v7="networkChange";fe({type:dt(v7)});var E7="disconnect";fe({type:dt(E7)});async function kd(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var gb=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(gb||{}),Pd=An(Fu([ge(),Fn(),Os()])),vr=fe({jsonrpc:dt("2.0"),method:ge(),params:An(Fu([En(Vu()),q2({}),Os()])),id:Pd}),tl=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(tl||{}),wb=fe({jsonrpc:dt("2.0"),result:bd(Vu()),id:Pd}),bb=fe({jsonrpc:dt("2.0"),error:bd(Vu()),id:Pd});Fu([wb,bb]);var rl=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(rl||{}),mb=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(mb||{}),A7=fe({address:ge(),publicKey:ge(),purpose:Is(rl),addressType:Is(mb)}),vb=async e=>{var t,r;const n=await kd(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Gr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},S7="stx_getAddresses",T7=xs(fe({message:An(ge())}));fe({...vr.entries,...fe({method:dt(S7),params:T7,id:ge()}).entries});var _7="stx_signTransaction",k7=fe({transaction:ge(),pubkey:An(ge()),broadcast:An(z2())});fe({...vr.entries,...fe({method:dt(_7),params:k7,id:ge()}).entries});var P7=["software","ledger"],I7=G2(P7),O7="getInfo",x7=xs(Os());fe({version:ge(),methods:An(En(ge())),supports:En(ge())}),fe({...vr.entries,...fe({method:dt(O7),params:x7,id:ge()}).entries});var $7="getAddresses",C7=fe({purposes:En(Is(rl)),message:An(ge())});fe({...vr.entries,...fe({method:dt($7),params:C7,id:ge()}).entries});var N7="signMessage",nl=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(nl||{}),U7=fe({address:ge(),message:ge(),protocol:An(Is(nl))});fe({signature:ge(),messageHash:ge(),address:ge(),protocol:Is(nl)}),fe({...vr.entries,...fe({method:dt(N7),params:U7,id:ge()}).entries});var R7="getAccounts",B7=fe({purposes:En(Is(rl)),message:An(ge())});En(fe({...A7.entries,...fe({walletType:I7}).entries})),fe({...vr.entries,...fe({method:dt(R7),params:B7,id:ge()}).entries});var L7="getBalance";xs(Os()),fe({...vr.entries,...fe({method:dt(L7),id:ge()}).entries});var H7="wallet_requestPermissions",K7=md();dt(!0),fe({...vr.entries,...fe({method:dt(H7),params:K7,id:ge()}).entries});var j7="wallet_renouncePermissions",D7=md();dt(!0),fe({...vr.entries,...fe({method:dt(j7),params:D7,id:ge()}).entries});var M7="wallet_getWalletType";xs(Os()),fe({...vr.entries,...fe({method:dt(M7),id:ge()}).entries});var F7="runes_getBalance",V7=xs(Os());fe({balances:En(fe({runeName:ge(),amount:ge(),divisibility:Fn(),symbol:ge(),inscriptionId:xs(ge())}))}),fe({...vr.entries,...fe({method:dt(F7),params:V7,id:ge()}).entries});var W7="runes_transfer",z7=fe({recipients:En(fe({runeName:ge(),amount:ge(),address:ge()}))});fe({...vr.entries,...fe({method:dt(W7),params:z7,id:ge()}).entries});var q7="ord_getInscriptions",G7=fe({offset:Fn(),limit:Fn()});fe({total:Fn(),limit:Fn(),offset:Fn(),inscriptions:En(fe({inscriptionId:ge(),inscriptionNumber:ge(),address:ge(),collectionName:An(ge()),postage:ge(),contentLength:ge(),contentType:ge(),timestamp:Fn(),offset:Fn(),genesisTransaction:ge(),output:ge()}))}),fe({...vr.entries,...fe({method:dt(q7),params:G7,id:ge()}).entries});var X7="ord_sendInscriptions",J7=fe({transfers:En(fe({address:ge(),inscriptionId:ge()}))});fe({...vr.entries,...fe({method:dt(X7),params:J7,id:ge()}).entries});var Eb=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return W2(bb,o)?{status:"error",error:o.error}:W2(wb,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},Y7=async e=>{var t,r;const n=await kd(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Gr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},Z7=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),Q7=async e=>{var t,r;const n=await kd(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=Z7(i),f={network:s,senderAddress:o,message:a,recipients:u},h=Gr.createUnsecuredToken(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let Ab=e=>e,Ia={},ts={addEventListener(){},removeEventListener(){}};function e$(){try{return typeof localStorage<"u"}catch{return!1}}e$()&&(Ia=localStorage),typeof window<"u"&&(ts={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function Eo(e,t={},r={}){let n=r.encode||Ab,i=r.decode||Ab,o=Lg(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&ts.perKey&&ts.removeEventListener(e+d,f,h),delete Ia[e+d]):(r.listen!==!1&&ts.perKey&&!(d in o.value)&&ts.addEventListener(e+d,f,h),Ia[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function f(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function h(){let d={...t};for(let g in Ia)g.startsWith(e)&&(d[g.slice(e.length)]=i(Ia[g]));for(let g in d)o.setKey(g,d[g])}return P5(o,()=>{if(h(),r.listen!==!1)return ts.addEventListener(e,f,h),()=>{ts.removeEventListener(e,f,h);for(let d in o.value)ts.removeEventListener(e+d,f,h)}}),o}const Sb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],t$="XVERSE_CONNECTED_WALLET_STATE";class r$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(t$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Sb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ri&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Sb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){Bn(this.$store,["provider"],t=>{t.provider!==ri?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ri]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=wa(this.network||mt);await vb({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=gd(o.addresses),a=wd(o.addresses);if(!s||!a)throw new Error("Could not find the addresses");s&&a&&(this.$store.setKey("provider",ri),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),ir(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ri} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ri} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Or,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){const n=await Eb("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await Eb("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromBase64(String(n),{network:nr(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=da(k,nr(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:wa(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=bt.fromBase64(String(O.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw mn}}class n$ extends fi{constructor(){super(...arguments),be(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(vs)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){Bn(this.$store,["provider"],t=>{t.provider===vs?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw CP;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",vs),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?Mw(r):void 0}async switchNetwork(t){var r;if(t===$r||t===uo)return await this.library.switchNetwork(Kw);const n=Mw(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=bt.fromHex(a);let f;return i&&o&&(f=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}async pushPsbt(t){return await Je.post(`${Gi(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const Tb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],i$="OYL_CONNECTED_WALLET_STATE";class s$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(i$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Tb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ws&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Tb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ws]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==ws?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",ws),ir(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await F2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=bt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw mn}}const _b=["address","paymentAddress","publicKey","paymentPublicKey","balance"],o$="LEATHER_CONNECTED_WALLET_STATE";class a$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(o$,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of _b)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===bs&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):_b.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[bs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==bs?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Zh),a=i.find(u=>u.type===Kg);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==Bt&&this.network!==xr&&this.network!==Or)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",bs),ir(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Zh:Kg;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=bt.fromHex(String(a));if(i&&o){const f=u.finalizeAllInputs(),h=await this.pushPsbt(f.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}else if(i){const f=u.finalizeAllInputs();return{signedPsbtHex:f.toHex(),signedPsbtBase64:f.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=bt.fromHex(t).extractTransaction();return await Je.post(`${Gi(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Zh);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await ir(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw mn}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw mn}}var Id={},kb={},Sn={},Pb={};Object.defineProperty(Pb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const h=await s();if(h)return h}const f=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!f)throw new Error("No Orange Bitcoin wallet installed");return f}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(f=>f.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((f,h)=>f==null?void 0:f[h],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(Pb,e)}(Sn);var Ib={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(Ib),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Gr,i=Sn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:h}=s.payload;if(!h)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await f.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(Ib,e)}(kb);var Ob={},xb={},$b={};Object.defineProperty($b,"__esModule",{value:!0});var Cb={};Object.defineProperty(Cb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r($b,e),r(Cb,e)}(xb),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=Sn,i=async(s,a,u)=>{var f;let h=((f=window.OrangecryptoProviders)==null?void 0:f.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(h=await(0,n.getProviderById)(u)),!h)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await h.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(xb,e)}(Ob);var Nb={},Ub={};Object.defineProperty(Ub,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(a,u,f,h){h===void 0&&(h=f);var d=Object.getOwnPropertyDescriptor(u,f);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[f]}}),Object.defineProperty(a,h,d)}:function(a,u,f,h){h===void 0&&(h=f),a[h]=u[f]}),r=Te&&Te.__exportStar||function(a,u){for(var f in a)f!=="default"&&!Object.prototype.hasOwnProperty.call(u,f)&&t(u,a,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Gr,i=Sn,o=(a,u)=>{const f=d=>!(!a[d]||u&&!u.has(d)),h={request:f("request"),connect:f("connect"),signMessage:f("signMessage"),signTransaction:f("signTransaction"),sendBtcTransaction:f("sendBtcTransaction"),createInscription:f("createInscription"),createRepeatInscriptions:f("createRepeatInscriptions"),signMultipleTransactions:f("signMultipleTransactions")};return Object.entries(h).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,f,h;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(f=a.onFinish)==null||f.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(h=a.onCancel)==null||h.call(a)}};e.getCapabilities=s,r(Ub,e)}(Nb);var Rb={},il={},Oa={};Object.defineProperty(Oa,"__esModule",{value:!0}),Oa.validateInscriptionPayload=void 0;const c$=4e5,u$=6e4,l$=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?c$:u$))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Oa.validateInscriptionPayload=l$,Object.defineProperty(il,"__esModule",{value:!0}),il.createInscription=void 0;const h$=Gr,f$=Sn,d$=Oa,p$=async e=>{var t,r;const{getProvider:n}=e,i=await(0,f$.getProviderOrThrow)(n);(0,d$.validateInscriptionPayload)(e.payload);try{const o=(0,h$.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};il.createInscription=p$;var sl={};Object.defineProperty(sl,"__esModule",{value:!0}),sl.createRepeatInscriptions=void 0;const y$=Sn,g$=Gr,w$=Oa,b$=async e=>{var t,r;const{getProvider:n}=e,i=await(0,y$.getProviderOrThrow)(n);(0,w$.validateInscriptionPayload)(e.payload);try{const o=(0,g$.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};sl.createRepeatInscriptions=b$;var Bb={};Object.defineProperty(Bb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(il,e),r(sl,e),r(Bb,e)}(Rb);var Lb={},Hb={};Object.defineProperty(Hb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Gr,i=Sn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{address:h,message:d}=s.payload;if(!h)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await f.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Hb,e)}(Lb);var Kb={},ol={};Object.defineProperty(ol,"__esModule",{value:!0}),ol.sendBtcTransaction=void 0;const m$=Gr,v$=Sn,E$=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),A$=async e=>{var t,r;const n=await(0,v$.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=E$(i),f={network:s,senderAddress:o,message:a,recipients:u},h=(0,m$.createUnsecuredToken)(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};ol.sendBtcTransaction=A$;var al={};Object.defineProperty(al,"__esModule",{value:!0}),al.signTransaction=void 0;const S$=Gr,T$=Sn,_$=async e=>{var t,r;const n=await(0,T$.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,S$.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};al.signTransaction=_$;var cl={};Object.defineProperty(cl,"__esModule",{value:!0}),cl.signMultipleTransactions=void 0;const k$=Gr,P$=Sn,I$=async e=>{var t,r;const n=await(0,P$.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,k$.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};cl.signMultipleTransactions=I$;var jb={};Object.defineProperty(jb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(ol,e),r(al,e),r(cl,e),r(jb,e)}(Kb);var Db={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Db),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(kb,e),r(Ob,e),r(Nb,e),r(Rb,e),r(Lb,e),r(Sn,e),r(Kb,e),r(Db,e)}(Id);const O$=IT(Id),Mb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:x$,sendBtcTransaction:$$,signTransaction:C$}=O$,N$="ORANGE_CONNECTED_WALLET_STATE";class U$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(N$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Mb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ji&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Mb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ji]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],r=>{r.provider!==ji?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Iu(this.network||mt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=gd(s.addresses),u=wd(s.addresses);if(!a||!(u!=null&&u.address))throw new Error("Could not find addresses");a&&u&&(this.$store.setKey("provider",ji),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),this.$store.setKey("publicKey",String(a.publicKey)),this.$store.setKey("paymentPublicKey",String(u.publicKey)),ir(String(u==null?void 0:u.address),this.network).then(f=>{this.$store.setKey("balance",f)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ji} wallet`)}};await Id.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Or,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){let n="";const i={payload:{network:{type:Iu(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await $$(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Iu(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await x$(o),n}async signPsbt(t,r,n,i,o){const s=bt.fromBase64(String(n),{network:nr(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,f=s.data.inputs,h=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=da(k,nr(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Iu(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=bt.fromBase64(String(O.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await C$(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=bt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Je.post(`${Gi(this.network)}/api/tx`,r).then(n=>n.data)}}const Fb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R$="OKX_CONNECTED_WALLET_STATE";class B$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(R$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===Bt||this.network===xr||this.network===Or||this.network===$r?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===mt||this.network===uo)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Fb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ms&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Fb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ms]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],r=>{r.provider!==ms?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ms),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===Bt||r===xr||r===$r?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===Bt?Bt:r===xr?xr:r===Or?Or:r===$r?$r:Bt;const n=await this.library.getNetwork();return DP(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=bt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}}const Vb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],L$="MAGIC_EDEN_CONNECTED_WALLET_STATE";class H$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(L$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Vb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ni&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Vb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ni]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==ni?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=wa(this.network||mt);await vb({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=gd(o.addresses),a=wd(o.addresses);if(!s||!a)throw new Error("No address found");s&&a&&(this.$store.setKey("provider",ni),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),ir(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ni} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ni} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Or,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){let n;if(await Q7({getProvider:async()=>this.library,payload:{network:{type:wa(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await Y7({getProvider:async()=>this.library,payload:{network:{type:gb.Mainnet},address:n,message:t,protocol:nl.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromBase64(String(n),{network:nr(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of f){const{script:B}=k.witnessUtxo,z=da(B,nr(this.network));z===a?g.signingIndexes.push(Number(v)):z===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N=wa(this.network),O={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:k=>{if(k.psbtBase64){const B=bt.fromBase64(String(k.psbtBase64),{network:nr(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(O),o){const k=bt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}}class K$ extends fi{constructor(){super(...arguments),be(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ki]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{if(t.provider!==Ki){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Ki):this.parent.disconnect())}handleNetworkChanged(t){const r=Hf(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Ki)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",Ki),ir(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?Bt:mt}async sendBTC(t,r){const{psbtHex:n}=await F2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromHex(String(r),{network:nr(this.network)}).data.inputs,f=[],h={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=da(x,nr(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&h.signingIndexes.push(Number(g)),g++}h.signingIndexes.length>0&&f.push(h),d.signingIndexes.length>0&&f.push(d);const v=await this.library.signPsbt(r,{inputsToSign:f}),E=bt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Dw(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class j${constructor(t,r){be(this,"$store"),be(this,"$network"),be(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[bs]:new a$(t,this,r),[ni]:new H$(t,this,r),[ms]:new B$(t,this,r),[ji]:new U$(t,this,r),[ws]:new s$(t,this,r),[Ki]:new K$(t,this,r),[Hi]:new Vx(t,this,r),[ri]:new r$(t,this,r),[vs]:new n$(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Bg(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Bg(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),Wx()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(Qh);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(Qh,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(Qh)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(Dx(t))s=bt.fromHex(t).toBase64(),o=t;else if(jx(t))s=t,o=bt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}}const D$={hasUnisat:!1,hasXverse:!1,hasOyl:!1,hasMagicEden:!1,hasOkx:!1,hasOrange:!1,hasOpNet:!1,hasLeather:!1,hasPhantom:!1,hasWizz:!1,isInitializing:!0,connected:!1,isConnecting:!1,publicKey:"",address:"",paymentAddress:"",paymentPublicKey:"",balance:void 0,network:mt,library:null,provider:null,accounts:[],connect:async e=>{},disconnect:()=>{},requestAccounts:async()=>[],getNetwork:async()=>mt,switchNetwork:async e=>{},getPublicKey:async()=>"",getBalance:async()=>"",getInscriptions:async()=>[],sendBTC:async(e,t)=>"",signMessage:async e=>"",signPsbt:async e=>({signedPsbtHex:"",signedPsbtBase64:"",txId:""}),pushPsbt:async e=>"",inscribe:async e=>"",isCreatingCommit:!1,isInscribing:!1},Wb=tn.createContext(D$),M$=()=>tn.useContext(Wb);var Od={exports:{}},xa={};/**
58
58
  * @license React
59
59
  * react-jsx-runtime.production.min.js
60
60
  *
@@ -62,7 +62,7 @@ PROCEED WITH CAUTION!
62
62
  *
63
63
  * This source code is licensed under the MIT license found in the
64
64
  * LICENSE file in the root directory of this source tree.
65
- */var zb;function F$(){if(zb)return xa;zb=1;var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(a,u,h){var f,d={},g=null,v=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(v=u.ref);for(f in u)n.call(u,f)&&!o.hasOwnProperty(f)&&(d[f]=u[f]);if(a&&a.defaultProps)for(f in u=a.defaultProps,u)d[f]===void 0&&(d[f]=u[f]);return{$$typeof:t,type:a,key:g,ref:v,props:d,_owner:i.current}}return xa.Fragment=r,xa.jsx=s,xa.jsxs=s,xa}var ul={};/**
65
+ */var zb;function F$(){if(zb)return xa;zb=1;var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(a,u,f){var h,d={},g=null,v=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(v=u.ref);for(h in u)n.call(u,h)&&!o.hasOwnProperty(h)&&(d[h]=u[h]);if(a&&a.defaultProps)for(h in u=a.defaultProps,u)d[h]===void 0&&(d[h]=u[h]);return{$$typeof:t,type:a,key:g,ref:v,props:d,_owner:i.current}}return xa.Fragment=r,xa.jsx=s,xa.jsxs=s,xa}var ul={};/**
66
66
  * @license React
67
67
  * react-jsx-runtime.development.js
68
68
  *
@@ -70,17 +70,17 @@ PROCEED WITH CAUTION!
70
70
  *
71
71
  * This source code is licensed under the MIT license found in the
72
72
  * LICENSE file in the root directory of this source tree.
73
- */var qb;function V$(){return qb||(qb=1,process.env.NODE_ENV!=="production"&&function(){var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),E=Symbol.iterator,T="@@iterator";function x(P){if(P===null||typeof P!="object")return null;var j=E&&P[E]||P[T];return typeof j=="function"?j:null}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function I(P){{for(var j=arguments.length,G=new Array(j>1?j-1:0),ne=1;ne<j;ne++)G[ne-1]=arguments[ne];k("error",P,G)}}function k(P,j,G){{var ne=N.ReactDebugCurrentFrame,_e=ne.getStackAddendum();_e!==""&&(j+="%s",G=G.concat([_e]));var $e=G.map(function(Pe){return String(Pe)});$e.unshift("Warning: "+j),Function.prototype.apply.call(console[P],console,$e)}}var B=!1,z=!1,V=!1,Ue=!1,He=!1,Ge;Ge=Symbol.for("react.module.reference");function Fe(P){return!!(typeof P=="string"||typeof P=="function"||P===n||P===o||He||P===i||P===h||P===f||Ue||P===v||B||z||V||typeof P=="object"&&P!==null&&(P.$$typeof===g||P.$$typeof===d||P.$$typeof===s||P.$$typeof===a||P.$$typeof===u||P.$$typeof===Ge||P.getModuleId!==void 0))}function Ye(P,j,G){var ne=P.displayName;if(ne)return ne;var _e=j.displayName||j.name||"";return _e!==""?G+"("+_e+")":G}function C(P){return P.displayName||"Context"}function F(P){if(P==null)return null;if(typeof P.tag=="number"&&I("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof P=="function")return P.displayName||P.name||null;if(typeof P=="string")return P;switch(P){case n:return"Fragment";case r:return"Portal";case o:return"Profiler";case i:return"StrictMode";case h:return"Suspense";case f:return"SuspenseList"}if(typeof P=="object")switch(P.$$typeof){case a:var j=P;return C(j)+".Consumer";case s:var G=P;return C(G._context)+".Provider";case u:return Ye(P,P.render,"ForwardRef");case d:var ne=P.displayName||null;return ne!==null?ne:F(P.type)||"Memo";case g:{var _e=P,$e=_e._payload,Pe=_e._init;try{return F(Pe($e))}catch{return null}}}return null}var oe=Object.assign,J=0,ue,Ae,vt,je,Ce,re,Ne;function H(){}H.__reactDisabledLog=!0;function Le(){{if(J===0){ue=console.log,Ae=console.info,vt=console.warn,je=console.error,Ce=console.group,re=console.groupCollapsed,Ne=console.groupEnd;var P={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:P,log:P,warn:P,error:P,group:P,groupCollapsed:P,groupEnd:P})}J++}}function Tn(){{if(J--,J===0){var P={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:oe({},P,{value:ue}),info:oe({},P,{value:Ae}),warn:oe({},P,{value:vt}),error:oe({},P,{value:je}),group:oe({},P,{value:Ce}),groupCollapsed:oe({},P,{value:re}),groupEnd:oe({},P,{value:Ne})})}J<0&&I("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pt=N.ReactCurrentDispatcher,Nr;function Et(P,j,G){{if(Nr===void 0)try{throw Error()}catch(_e){var ne=_e.stack.trim().match(/\n( *(at )?)/);Nr=ne&&ne[1]||""}return`
74
- `+Nr+P}}var Lt=!1,st;{var Dt=typeof WeakMap=="function"?WeakMap:Map;st=new Dt}function Er(P,j){if(!P||Lt)return"";{var G=st.get(P);if(G!==void 0)return G}var ne;Lt=!0;var _e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=pt.current,pt.current=null,Le();try{if(j){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(Sr){ne=Sr}Reflect.construct(P,[],Pe)}else{try{Pe.call()}catch(Sr){ne=Sr}P.call(Pe.prototype)}}else{try{throw Error()}catch(Sr){ne=Sr}P()}}catch(Sr){if(Sr&&ne&&typeof Sr.stack=="string"){for(var Oe=Sr.stack.split(`
73
+ */var qb;function V$(){return qb||(qb=1,process.env.NODE_ENV!=="production"&&function(){var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),E=Symbol.iterator,T="@@iterator";function x(P){if(P===null||typeof P!="object")return null;var j=E&&P[E]||P[T];return typeof j=="function"?j:null}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(P){{for(var j=arguments.length,G=new Array(j>1?j-1:0),ne=1;ne<j;ne++)G[ne-1]=arguments[ne];k("error",P,G)}}function k(P,j,G){{var ne=N.ReactDebugCurrentFrame,_e=ne.getStackAddendum();_e!==""&&(j+="%s",G=G.concat([_e]));var $e=G.map(function(Pe){return String(Pe)});$e.unshift("Warning: "+j),Function.prototype.apply.call(console[P],console,$e)}}var B=!1,z=!1,V=!1,Ue=!1,He=!1,Ge;Ge=Symbol.for("react.module.reference");function Fe(P){return!!(typeof P=="string"||typeof P=="function"||P===n||P===o||He||P===i||P===f||P===h||Ue||P===v||B||z||V||typeof P=="object"&&P!==null&&(P.$$typeof===g||P.$$typeof===d||P.$$typeof===s||P.$$typeof===a||P.$$typeof===u||P.$$typeof===Ge||P.getModuleId!==void 0))}function Ye(P,j,G){var ne=P.displayName;if(ne)return ne;var _e=j.displayName||j.name||"";return _e!==""?G+"("+_e+")":G}function C(P){return P.displayName||"Context"}function F(P){if(P==null)return null;if(typeof P.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof P=="function")return P.displayName||P.name||null;if(typeof P=="string")return P;switch(P){case n:return"Fragment";case r:return"Portal";case o:return"Profiler";case i:return"StrictMode";case f:return"Suspense";case h:return"SuspenseList"}if(typeof P=="object")switch(P.$$typeof){case a:var j=P;return C(j)+".Consumer";case s:var G=P;return C(G._context)+".Provider";case u:return Ye(P,P.render,"ForwardRef");case d:var ne=P.displayName||null;return ne!==null?ne:F(P.type)||"Memo";case g:{var _e=P,$e=_e._payload,Pe=_e._init;try{return F(Pe($e))}catch{return null}}}return null}var oe=Object.assign,J=0,ue,Ae,vt,je,Ce,re,Ne;function H(){}H.__reactDisabledLog=!0;function Le(){{if(J===0){ue=console.log,Ae=console.info,vt=console.warn,je=console.error,Ce=console.group,re=console.groupCollapsed,Ne=console.groupEnd;var P={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:P,log:P,warn:P,error:P,group:P,groupCollapsed:P,groupEnd:P})}J++}}function Tn(){{if(J--,J===0){var P={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:oe({},P,{value:ue}),info:oe({},P,{value:Ae}),warn:oe({},P,{value:vt}),error:oe({},P,{value:je}),group:oe({},P,{value:Ce}),groupCollapsed:oe({},P,{value:re}),groupEnd:oe({},P,{value:Ne})})}J<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pt=N.ReactCurrentDispatcher,Nr;function Et(P,j,G){{if(Nr===void 0)try{throw Error()}catch(_e){var ne=_e.stack.trim().match(/\n( *(at )?)/);Nr=ne&&ne[1]||""}return`
74
+ `+Nr+P}}var Lt=!1,st;{var Dt=typeof WeakMap=="function"?WeakMap:Map;st=new Dt}function Er(P,j){if(!P||Lt)return"";{var G=st.get(P);if(G!==void 0)return G}var ne;Lt=!0;var _e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=pt.current,pt.current=null,Le();try{if(j){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(Sr){ne=Sr}Reflect.construct(P,[],Pe)}else{try{Pe.call()}catch(Sr){ne=Sr}P.call(Pe.prototype)}}else{try{throw Error()}catch(Sr){ne=Sr}P()}}catch(Sr){if(Sr&&ne&&typeof Sr.stack=="string"){for(var Ie=Sr.stack.split(`
75
75
  `),Ze=ne.stack.split(`
76
- `),Pt=Oe.length-1,xt=Ze.length-1;Pt>=1&&xt>=0&&Oe[Pt]!==Ze[xt];)xt--;for(;Pt>=1&&xt>=0;Pt--,xt--)if(Oe[Pt]!==Ze[xt]){if(Pt!==1||xt!==1)do if(Pt--,xt--,xt<0||Oe[Pt]!==Ze[xt]){var en=`
77
- `+Oe[Pt].replace(" at new "," at ");return P.displayName&&en.includes("<anonymous>")&&(en=en.replace("<anonymous>",P.displayName)),typeof P=="function"&&st.set(P,en),en}while(Pt>=1&&xt>=0);break}}}finally{Lt=!1,pt.current=$e,Tn(),Error.prepareStackTrace=_e}var Ao=P?P.displayName||P.name:"",Cs=Ao?Et(Ao):"";return typeof P=="function"&&st.set(P,Cs),Cs}function Ve(P,j,G){return Er(P,!1)}function yt(P){var j=P.prototype;return!!(j&&j.isReactComponent)}function Ar(P,j,G){if(P==null)return"";if(typeof P=="function")return Er(P,yt(P));if(typeof P=="string")return Et(P);switch(P){case h:return Et("Suspense");case f:return Et("SuspenseList")}if(typeof P=="object")switch(P.$$typeof){case u:return Ve(P.render);case d:return Ar(P.type,j,G);case g:{var ne=P,_e=ne._payload,$e=ne._init;try{return Ar($e(_e),j,G)}catch{}}}return""}var nt=Object.prototype.hasOwnProperty,Ht={},Xr=N.ReactDebugCurrentFrame;function Jr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);Xr.setExtraStackFrame(G)}else Xr.setExtraStackFrame(null)}function _n(P,j,G,ne,_e){{var $e=Function.call.bind(nt);for(var Pe in P)if($e(P,Pe)){var Oe=void 0;try{if(typeof P[Pe]!="function"){var Ze=Error((ne||"React class")+": "+G+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof P[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ze.name="Invariant Violation",Ze}Oe=P[Pe](j,Pe,ne,G,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Pt){Oe=Pt}Oe&&!(Oe instanceof Error)&&(Jr(_e),I("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ne||"React class",G,Pe,typeof Oe),Jr(null)),Oe instanceof Error&&!(Oe.message in Ht)&&(Ht[Oe.message]=!0,Jr(_e),I("Failed %s type: %s",G,Oe.message),Jr(null))}}}var Mt=Array.isArray;function We(P){return Mt(P)}function or(P){{var j=typeof Symbol=="function"&&Symbol.toStringTag,G=j&&P[Symbol.toStringTag]||P.constructor.name||"Object";return G}}function yi(P){try{return rt(P),!1}catch{return!0}}function rt(P){return""+P}function Yr(P){if(yi(P))return I("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",or(P)),rt(P)}var c=N.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0},p,m,S;S={};function O(P){if(nt.call(P,"ref")){var j=Object.getOwnPropertyDescriptor(P,"ref").get;if(j&&j.isReactWarning)return!1}return P.ref!==void 0}function U(P){if(nt.call(P,"key")){var j=Object.getOwnPropertyDescriptor(P,"key").get;if(j&&j.isReactWarning)return!1}return P.key!==void 0}function ce(P,j){if(typeof P.ref=="string"&&c.current&&j&&c.current.stateNode!==j){var G=F(c.current.type);S[G]||(I('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(c.current.type),P.ref),S[G]=!0)}}function ke(P,j){{var G=function(){p||(p=!0,I("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"key",{get:G,configurable:!0})}}function le(P,j){{var G=function(){m||(m=!0,I("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"ref",{get:G,configurable:!0})}}var ae=function(P,j,G,ne,_e,$e,Pe){var Oe={$$typeof:t,type:P,key:j,ref:G,props:Pe,_owner:$e};return Oe._store={},Object.defineProperty(Oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ne}),Object.defineProperty(Oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_e}),Object.freeze&&(Object.freeze(Oe.props),Object.freeze(Oe)),Oe};function me(P,j,G,ne,_e){{var $e,Pe={},Oe=null,Ze=null;G!==void 0&&(Yr(G),Oe=""+G),U(j)&&(Yr(j.key),Oe=""+j.key),O(j)&&(Ze=j.ref,ce(j,_e));for($e in j)nt.call(j,$e)&&!l.hasOwnProperty($e)&&(Pe[$e]=j[$e]);if(P&&P.defaultProps){var Pt=P.defaultProps;for($e in Pt)Pe[$e]===void 0&&(Pe[$e]=Pt[$e])}if(Oe||Ze){var xt=typeof P=="function"?P.displayName||P.name||"Unknown":P;Oe&&ke(Pe,xt),Ze&&le(Pe,xt)}return ae(P,Oe,Ze,_e,ne,c.current,Pe)}}var gi=N.ReactCurrentOwner,rs=N.ReactDebugCurrentFrame;function Zr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);rs.setExtraStackFrame(G)}else rs.setExtraStackFrame(null)}var Ke;Ke=!1;function kt(P){return typeof P=="object"&&P!==null&&P.$$typeof===t}function Qr(){{if(gi.current){var P=F(gi.current.type);if(P)return`
76
+ `),Pt=Ie.length-1,xt=Ze.length-1;Pt>=1&&xt>=0&&Ie[Pt]!==Ze[xt];)xt--;for(;Pt>=1&&xt>=0;Pt--,xt--)if(Ie[Pt]!==Ze[xt]){if(Pt!==1||xt!==1)do if(Pt--,xt--,xt<0||Ie[Pt]!==Ze[xt]){var en=`
77
+ `+Ie[Pt].replace(" at new "," at ");return P.displayName&&en.includes("<anonymous>")&&(en=en.replace("<anonymous>",P.displayName)),typeof P=="function"&&st.set(P,en),en}while(Pt>=1&&xt>=0);break}}}finally{Lt=!1,pt.current=$e,Tn(),Error.prepareStackTrace=_e}var Ao=P?P.displayName||P.name:"",Cs=Ao?Et(Ao):"";return typeof P=="function"&&st.set(P,Cs),Cs}function Ve(P,j,G){return Er(P,!1)}function yt(P){var j=P.prototype;return!!(j&&j.isReactComponent)}function Ar(P,j,G){if(P==null)return"";if(typeof P=="function")return Er(P,yt(P));if(typeof P=="string")return Et(P);switch(P){case f:return Et("Suspense");case h:return Et("SuspenseList")}if(typeof P=="object")switch(P.$$typeof){case u:return Ve(P.render);case d:return Ar(P.type,j,G);case g:{var ne=P,_e=ne._payload,$e=ne._init;try{return Ar($e(_e),j,G)}catch{}}}return""}var nt=Object.prototype.hasOwnProperty,Ht={},Xr=N.ReactDebugCurrentFrame;function Jr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);Xr.setExtraStackFrame(G)}else Xr.setExtraStackFrame(null)}function _n(P,j,G,ne,_e){{var $e=Function.call.bind(nt);for(var Pe in P)if($e(P,Pe)){var Ie=void 0;try{if(typeof P[Pe]!="function"){var Ze=Error((ne||"React class")+": "+G+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof P[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ze.name="Invariant Violation",Ze}Ie=P[Pe](j,Pe,ne,G,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Pt){Ie=Pt}Ie&&!(Ie instanceof Error)&&(Jr(_e),O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ne||"React class",G,Pe,typeof Ie),Jr(null)),Ie instanceof Error&&!(Ie.message in Ht)&&(Ht[Ie.message]=!0,Jr(_e),O("Failed %s type: %s",G,Ie.message),Jr(null))}}}var Mt=Array.isArray;function We(P){return Mt(P)}function or(P){{var j=typeof Symbol=="function"&&Symbol.toStringTag,G=j&&P[Symbol.toStringTag]||P.constructor.name||"Object";return G}}function yi(P){try{return rt(P),!1}catch{return!0}}function rt(P){return""+P}function Yr(P){if(yi(P))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",or(P)),rt(P)}var c=N.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0},p,m,S;S={};function I(P){if(nt.call(P,"ref")){var j=Object.getOwnPropertyDescriptor(P,"ref").get;if(j&&j.isReactWarning)return!1}return P.ref!==void 0}function U(P){if(nt.call(P,"key")){var j=Object.getOwnPropertyDescriptor(P,"key").get;if(j&&j.isReactWarning)return!1}return P.key!==void 0}function ce(P,j){if(typeof P.ref=="string"&&c.current&&j&&c.current.stateNode!==j){var G=F(c.current.type);S[G]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(c.current.type),P.ref),S[G]=!0)}}function ke(P,j){{var G=function(){p||(p=!0,O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"key",{get:G,configurable:!0})}}function le(P,j){{var G=function(){m||(m=!0,O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"ref",{get:G,configurable:!0})}}var ae=function(P,j,G,ne,_e,$e,Pe){var Ie={$$typeof:t,type:P,key:j,ref:G,props:Pe,_owner:$e};return Ie._store={},Object.defineProperty(Ie._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ie,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ne}),Object.defineProperty(Ie,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_e}),Object.freeze&&(Object.freeze(Ie.props),Object.freeze(Ie)),Ie};function me(P,j,G,ne,_e){{var $e,Pe={},Ie=null,Ze=null;G!==void 0&&(Yr(G),Ie=""+G),U(j)&&(Yr(j.key),Ie=""+j.key),I(j)&&(Ze=j.ref,ce(j,_e));for($e in j)nt.call(j,$e)&&!l.hasOwnProperty($e)&&(Pe[$e]=j[$e]);if(P&&P.defaultProps){var Pt=P.defaultProps;for($e in Pt)Pe[$e]===void 0&&(Pe[$e]=Pt[$e])}if(Ie||Ze){var xt=typeof P=="function"?P.displayName||P.name||"Unknown":P;Ie&&ke(Pe,xt),Ze&&le(Pe,xt)}return ae(P,Ie,Ze,_e,ne,c.current,Pe)}}var gi=N.ReactCurrentOwner,rs=N.ReactDebugCurrentFrame;function Zr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);rs.setExtraStackFrame(G)}else rs.setExtraStackFrame(null)}var Ke;Ke=!1;function kt(P){return typeof P=="object"&&P!==null&&P.$$typeof===t}function Qr(){{if(gi.current){var P=F(gi.current.type);if(P)return`
78
78
 
79
79
  Check the render method of \``+P+"`."}return""}}function b(P){return""}var y={};function w(P){{var j=Qr();if(!j){var G=typeof P=="string"?P:P.displayName||P.name;G&&(j=`
80
80
 
81
- Check the top-level render call using <`+G+">.")}return j}}function A(P,j){{if(!P._store||P._store.validated||P.key!=null)return;P._store.validated=!0;var G=w(j);if(y[G])return;y[G]=!0;var ne="";P&&P._owner&&P._owner!==gi.current&&(ne=" It was passed a child from "+F(P._owner.type)+"."),Zr(P),I('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',G,ne),Zr(null)}}function _(P,j){{if(typeof P!="object")return;if(We(P))for(var G=0;G<P.length;G++){var ne=P[G];kt(ne)&&A(ne,j)}else if(kt(P))P._store&&(P._store.validated=!0);else if(P){var _e=x(P);if(typeof _e=="function"&&_e!==P.entries)for(var $e=_e.call(P),Pe;!(Pe=$e.next()).done;)kt(Pe.value)&&A(Pe.value,j)}}}function $(P){{var j=P.type;if(j==null||typeof j=="string")return;var G;if(typeof j=="function")G=j.propTypes;else if(typeof j=="object"&&(j.$$typeof===u||j.$$typeof===d))G=j.propTypes;else return;if(G){var ne=F(j);_n(G,P.props,"prop",ne,P)}else if(j.PropTypes!==void 0&&!Ke){Ke=!0;var _e=F(j);I("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_e||"Unknown")}typeof j.getDefaultProps=="function"&&!j.getDefaultProps.isReactClassApproved&&I("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function L(P){{for(var j=Object.keys(P.props),G=0;G<j.length;G++){var ne=j[G];if(ne!=="children"&&ne!=="key"){Zr(P),I("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ne),Zr(null);break}}P.ref!==null&&(Zr(P),I("Invalid attribute `ref` supplied to `React.Fragment`."),Zr(null))}}var K={};function q(P,j,G,ne,_e,$e){{var Pe=Fe(P);if(!Pe){var Oe="";(P===void 0||typeof P=="object"&&P!==null&&Object.keys(P).length===0)&&(Oe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ze=b();Ze?Oe+=Ze:Oe+=Qr();var Pt;P===null?Pt="null":We(P)?Pt="array":P!==void 0&&P.$$typeof===t?(Pt="<"+(F(P.type)||"Unknown")+" />",Oe=" Did you accidentally export a JSX literal instead of a component?"):Pt=typeof P,I("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Pt,Oe)}var xt=me(P,j,G,_e,$e);if(xt==null)return xt;if(Pe){var en=j.children;if(en!==void 0)if(ne)if(We(en)){for(var Ao=0;Ao<en.length;Ao++)_(en[Ao],P);Object.freeze&&Object.freeze(en)}else I("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _(en,P)}if(nt.call(j,"key")){var Cs=F(P),Sr=Object.keys(j).filter(function(i9){return i9!=="key"}),xd=Sr.length>0?"{key: someKey, "+Sr.join(": ..., ")+": ...}":"{key: someKey}";if(!K[Cs+xd]){var n9=Sr.length>0?"{"+Sr.join(": ..., ")+": ...}":"{}";I(`A props object containing a "key" prop is being spread into JSX:
81
+ Check the top-level render call using <`+G+">.")}return j}}function A(P,j){{if(!P._store||P._store.validated||P.key!=null)return;P._store.validated=!0;var G=w(j);if(y[G])return;y[G]=!0;var ne="";P&&P._owner&&P._owner!==gi.current&&(ne=" It was passed a child from "+F(P._owner.type)+"."),Zr(P),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',G,ne),Zr(null)}}function _(P,j){{if(typeof P!="object")return;if(We(P))for(var G=0;G<P.length;G++){var ne=P[G];kt(ne)&&A(ne,j)}else if(kt(P))P._store&&(P._store.validated=!0);else if(P){var _e=x(P);if(typeof _e=="function"&&_e!==P.entries)for(var $e=_e.call(P),Pe;!(Pe=$e.next()).done;)kt(Pe.value)&&A(Pe.value,j)}}}function $(P){{var j=P.type;if(j==null||typeof j=="string")return;var G;if(typeof j=="function")G=j.propTypes;else if(typeof j=="object"&&(j.$$typeof===u||j.$$typeof===d))G=j.propTypes;else return;if(G){var ne=F(j);_n(G,P.props,"prop",ne,P)}else if(j.PropTypes!==void 0&&!Ke){Ke=!0;var _e=F(j);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_e||"Unknown")}typeof j.getDefaultProps=="function"&&!j.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function L(P){{for(var j=Object.keys(P.props),G=0;G<j.length;G++){var ne=j[G];if(ne!=="children"&&ne!=="key"){Zr(P),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ne),Zr(null);break}}P.ref!==null&&(Zr(P),O("Invalid attribute `ref` supplied to `React.Fragment`."),Zr(null))}}var K={};function q(P,j,G,ne,_e,$e){{var Pe=Fe(P);if(!Pe){var Ie="";(P===void 0||typeof P=="object"&&P!==null&&Object.keys(P).length===0)&&(Ie+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ze=b();Ze?Ie+=Ze:Ie+=Qr();var Pt;P===null?Pt="null":We(P)?Pt="array":P!==void 0&&P.$$typeof===t?(Pt="<"+(F(P.type)||"Unknown")+" />",Ie=" Did you accidentally export a JSX literal instead of a component?"):Pt=typeof P,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Pt,Ie)}var xt=me(P,j,G,_e,$e);if(xt==null)return xt;if(Pe){var en=j.children;if(en!==void 0)if(ne)if(We(en)){for(var Ao=0;Ao<en.length;Ao++)_(en[Ao],P);Object.freeze&&Object.freeze(en)}else O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _(en,P)}if(nt.call(j,"key")){var Cs=F(P),Sr=Object.keys(j).filter(function(i9){return i9!=="key"}),xd=Sr.length>0?"{key: someKey, "+Sr.join(": ..., ")+": ...}":"{key: someKey}";if(!K[Cs+xd]){var n9=Sr.length>0?"{"+Sr.join(": ..., ")+": ...}":"{}";O(`A props object containing a "key" prop is being spread into JSX:
82
82
  let props = %s;
83
83
  <%s {...props} />
84
84
  React keys must be passed directly to JSX without using spread:
85
85
  let props = %s;
86
- <%s key={someKey} {...props} />`,xd,Cs,n9,Cs),K[Cs+xd]=!0}}return P===n?L(xt):$(xt),xt}}function W(P,j,G){return q(P,j,G,!0)}function X(P,j,G){return q(P,j,G,!1)}var Z=X,te=W;ul.Fragment=n,ul.jsx=Z,ul.jsxs=te}()),ul}process.env.NODE_ENV==="production"?Id.exports=F$():Id.exports=V$();var R=Id.exports;function W$(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Gb(e,t={}){let r=tn.useCallback(i=>t.keys?W$(e,t.keys,i):e.listen(i),[t.keys,e]),n=e.get.bind(e);return tn.useSyncExternalStore(r,n,n)}function z$({config:e,children:t}){const r=tn.useMemo(()=>new j$(zx(),qx(e??{network:mt})),[e]),{address:n,paymentAddress:i,publicKey:o,paymentPublicKey:s,accounts:a,balance:u,connected:h,hasProvider:f,isConnecting:d,isInitializing:g,provider:v}=Gb(r.$store),E={},T=Gb(r.$network);return R.jsx(Wb.Provider,{value:{paymentAddress:i,address:n,publicKey:o,paymentPublicKey:s,library:E,network:T,accounts:a,balance:Number(u),connected:h,isConnecting:d,isInitializing:g,provider:v,hasLeather:f.leather??!1,hasMagicEden:f["magic-eden"]??!1,hasOkx:f.okx??!1,hasOyl:f.oyl??!1,hasOrange:f.orange??!1,hasOpNet:f.op_net??!1,hasPhantom:f.phantom??!1,hasUnisat:f.unisat??!1,hasWizz:f.wizz??!1,hasXverse:f.xverse??!1,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),getBalance:async()=>(await r.getBalance.call(r)??"").toString(),getInscriptions:async()=>await r.getInscriptions.call(r)??[],getNetwork:r.getNetwork.bind(r),getPublicKey:async()=>await r.getPublicKey.call(r)??"",pushPsbt:r.pushPsbt.bind(r),signMessage:async(x,N)=>await r.signMessage.call(r,x,N)??"",requestAccounts:async()=>await r.requestAccounts.call(r)??[],sendBTC:async(x,N)=>await r.sendBTC.call(r,x,N)??"",signPsbt:async(x,N,I)=>await r.signPsbt.call(r,x,N,I)??{signedPsbtBase64:"",signedPsbtHex:""},switchNetwork:async x=>{await r.switchNetwork.call(r,x)}},children:t})}const q$=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"white",style:{fill:"white",fillOpacity:1}})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"white",style:{fill:"white",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}})]}),Xb=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#12100F"}),R.jsx("path",{d:"M74.9171 52.7114C82.4766 51.5408 93.4087 43.5804 93.4087 37.3761C93.4087 35.5031 91.8968 34.2154 89.6871 34.2154C85.5004 34.2154 78.4061 40.5368 74.9171 52.7114ZM39.911 83.4991C30.0256 83.4991 29.2115 93.3324 39.0969 93.3324C43.5163 93.3324 48.8661 91.5764 51.6573 88.4157C47.5868 84.9038 44.2141 83.4991 39.911 83.4991ZM102.829 79.2848C103.41 95.7907 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.0249C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8463 40.0273 72.8463C45.3771 72.8463 49.9128 74.2511 55.7277 77.88L59.5656 64.4177C43.7489 60.0864 35.8405 47.9118 43.6326 30.4693H56.1929C49.215 42.0586 53.9832 51.6578 62.822 52.7114C67.5903 35.7372 77.8246 22.509 91.4316 22.509C99.1074 22.509 105.155 27.5428 105.155 36.6737C105.155 51.3066 86.0819 63.2471 71.6607 64.4177L65.7295 85.3721C72.4748 93.2153 91.199 100.824 91.199 79.2848H102.829Z",fill:"#F5F1ED"})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#F5F1ED"}),R.jsx("path",{d:"M74.9171 52.7115C82.4766 51.5409 93.4087 43.5806 93.4087 37.3762C93.4087 35.5032 91.8968 34.2155 89.6871 34.2155C85.5004 34.2155 78.4061 40.5369 74.9171 52.7115ZM39.911 83.4992C30.0256 83.4992 29.2115 93.3325 39.0969 93.3325C43.5163 93.3325 48.8661 91.5766 51.6573 88.4159C47.5868 84.904 44.2141 83.4992 39.911 83.4992ZM102.829 79.2849C103.41 95.7908 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.025C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8464 40.0273 72.8464C45.3771 72.8464 49.9128 74.2512 55.7277 77.8801L59.5656 64.4179C43.7489 60.0865 35.8405 47.9119 43.6326 30.4695H56.1929C49.215 42.0587 53.9832 51.6579 62.822 52.7115C67.5903 35.7373 77.8246 22.5092 91.4316 22.5092C99.1074 22.5092 105.155 27.5429 105.155 36.6738C105.155 51.3068 86.0819 63.2472 71.6607 64.4179L65.7295 85.3722C72.4748 93.2155 91.199 100.825 91.199 79.2849H102.829Z",fill:"#12100F"})]}),G$=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#AB9FF2",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#FFFDF8",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}):R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#FFFDF8",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#AB9FF2",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}),X$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_3_53)",children:[R.jsx("path",{d:"M32 0H10C4.47715 0 0 4.47715 0 10V32C0 37.5228 4.47715 42 10 42H32C37.5228 42 42 37.5228 42 32V10C42 4.47715 37.5228 0 32 0Z",fill:"#181818"}),R.jsx("path",{d:"M32 31.6745V27.6829C32 27.5233 31.9203 27.3636 31.8406 27.2438L14.8225 10.1597C14.7029 10.0399 14.5435 10 14.3841 10H10.3986C10.1993 10 10.0399 10.1597 10.0399 10.3592V14.0715C10.0399 14.2311 10.1196 14.3908 10.1993 14.5105L16.2971 20.6177C16.4565 20.7774 16.4565 20.977 16.2971 21.1366L10.1196 27.3237C10.0399 27.4035 10 27.4834 10 27.5632V31.6346C10 31.8342 10.1594 31.9939 10.3587 31.9939H17.0544C17.2536 31.9939 17.413 31.8342 17.413 31.6346V29.2396C17.413 29.1598 17.4529 29.0401 17.5326 29.0002L20.8406 25.6871C21 25.5275 21.1993 25.5275 21.3587 25.6871L27.4964 31.8342C27.6159 31.954 27.7753 31.9939 27.9348 31.9939H31.6413C31.8406 32.0337 32 31.8741 32 31.6745Z",fill:"white"}),R.jsx("path",{d:"M23.3406 15.0793H26.5592C26.7507 15.0793 26.9039 15.2333 26.9039 15.4257V18.658C26.9039 18.9658 27.2871 19.1197 27.4788 18.8888L31.8851 14.4637C31.9617 14.3867 32 14.3097 32 14.2328V10.3463C32 10.1539 31.8468 10 31.6552 10H27.7469C27.6703 10 27.5554 10.0385 27.5171 10.1154L23.1107 14.5021C22.8808 14.6945 23.0341 15.0793 23.3406 15.0793Z",fill:"#EE7A30"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"clip0_3_53",children:R.jsx("rect",{width:"42",height:"42",fill:"white"})})})]}),J$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#b)",d:"m25.517 9.483 5.759 5.611c.49.477.731.959.724 1.445-.008.486-.219.929-.631 1.33-.431.421-.897.634-1.395.644-.497.007-.992-.228-1.482-.705l-5.89-5.738c-.669-.652-1.315-1.114-1.936-1.385a2.873 2.873 0 0 0-1.96-.127c-.685.185-1.42.662-2.21 1.428-1.086 1.06-1.605 2.054-1.552 2.983.053.929.593 1.893 1.617 2.89l5.938 5.786c.496.482.74.964.732 1.443-.008.48-.22.923-.64 1.332-.419.408-.88.62-1.382.638-.502.016-1.001-.217-1.495-.7l-5.76-5.61c-.936-.912-1.613-1.776-2.029-2.59-.416-.815-.572-1.737-.464-2.765.097-.88.384-1.732.863-2.558.477-.827 1.161-1.671 2.048-2.537C15.43 9.268 16.438 8.48 17.4 7.93c.96-.55 1.889-.854 2.786-.917.899-.064 1.784.112 2.66.527.876.415 1.765 1.061 2.67 1.943h.002Z"}),R.jsx("path",{fill:"url(#c)",d:"m16.482 32.123-5.758-5.611c-.49-.479-.731-.959-.724-1.445.008-.486.219-.929.631-1.33.431-.421.897-.634 1.395-.644.498-.007.992.227 1.482.705l5.888 5.738c.671.652 1.315 1.114 1.936 1.385.622.27 1.276.312 1.962.127.685-.185 1.42-.662 2.21-1.43 1.086-1.06 1.605-2.054 1.552-2.983-.053-.929-.593-1.893-1.617-2.891l-3.164-3.056c-.496-.482-.74-.964-.732-1.443.008-.48.22-.923.64-1.332.419-.408.88-.62 1.382-.638.502-.016 1.002.217 1.496.7l2.983 2.88c.936.912 1.613 1.775 2.03 2.59.415.815.571 1.736.463 2.764a6.477 6.477 0 0 1-.863 2.559c-.477.826-1.16 1.67-2.048 2.536-1.057 1.03-2.066 1.819-3.027 2.368-.962.55-1.89.856-2.79.92-.898.063-1.784-.113-2.66-.527-.876-.415-1.765-1.062-2.67-1.944l.003.002Z"}),R.jsx("path",{fill:"url(#d)",d:"M20.073 17.645c1.168 0 2.115-.93 2.115-2.08 0-1.149-.947-2.08-2.115-2.08-1.168 0-2.115.931-2.115 2.08 0 1.15.947 2.08 2.115 2.08Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"b",x1:30.329,x2:12.579,y1:12.752,y2:20.772,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#201C1B"}),R.jsx("stop",{offset:.36,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4B852"})]}),R.jsxs("linearGradient",{id:"c",x1:12.163,x2:32.789,y1:29.085,y2:22.844,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#1F1D1C"}),R.jsx("stop",{offset:.37,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4FB52"})]}),R.jsxs("radialGradient",{id:"d",cx:0,cy:0,r:1,gradientTransform:"matrix(2.11484 0 0 2.08019 20.073 15.567)",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#F4B852"}),R.jsx("stop",{offset:.33,stopColor:"#EA8101"}),R.jsx("stop",{offset:.64,stopColor:"#77390D"}),R.jsx("stop",{offset:1,stopColor:"#211C1D"})]}),R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Y$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsxs("g",{fillRule:"evenodd",clipPath:"url(#b)",clipRule:"evenodd",children:[R.jsx("path",{fill:"#FFD815",d:"m26.507 17.74-1.623-1.623-1.624 1.623 1.623 1.623 1.624 1.624 1.623-1.624-1.623-1.623Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 8-1.624 1.623 1.624 1.624 1.623-1.624L26.507 8ZM33 14.493l-1.623-1.623-1.624 1.623 1.624 1.623L33 14.493ZM23.26 27.48l1.623 1.623 1.624-1.623-1.623-1.624-1.624 1.624ZM11.897 16.117l1.623 1.623 1.623-1.623-1.623-1.624-1.623 1.624ZM20.014 8 18.39 9.623l1.624 1.624 1.623-1.624L20.014 8ZM13.52 11.247l1.624 1.623 1.623-1.623-1.623-1.624-1.624 1.624ZM31.377 19.363l-1.624 1.623 1.624 1.624L33 20.987l-1.623-1.624ZM28.13 25.856l1.623 1.624 1.624-1.624-1.624-1.623-1.623 1.623Z"}),R.jsx("path",{fill:"#5B5B72",d:"m26.507 20.986-1.624-1.623-1.623 1.623-1.623-1.623-1.623-1.623 1.623-1.624-1.623-1.623-1.624-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623 1.623-.812-.811-1.623 1.623 1.623 1.623-1.623 1.624-1.543 1.542-1.542 1.543-1.624 1.623L8 31.377 9.623 33l1.624-1.623 1.623-1.624 1.543-1.542.08-.08 1.462-1.463.08-.08 1.544-1.543 1.623 1.623 1.623-1.623-.811-.812 1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 14.493-1.624-1.623-1.623 1.623-1.623-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623 1.623 1.623 1.623-1.623-1.623-1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"})]})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M8 8h25v25H8z"})})]})]}),Z$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("g",{fill:"#fff",clipPath:"url(#b)",children:R.jsx("path",{d:"M24.578 17.052h-6.787a.523.523 0 0 0-.52.52v6.788c0 .286.235.52.52.52h6.787c.286 0 .521-.234.521-.52v-6.787a.523.523 0 0 0-.52-.521ZM16.733 9.223H9.946a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.285 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM32.424 9.223h-6.787a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.286 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM16.733 24.898H9.946a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.285 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52ZM32.424 24.898h-6.787a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.286 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52Z"})})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Q$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,className:r,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_17_93)",children:[R.jsx("path",{fill:"#070C34",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#paint0_linear_17_93)",d:"m27.666 16.837 1.874 2.177c.215.245.404.446.483.562.56.55.874 1.293.874 2.07-.053.915-.657 1.54-1.213 2.205l-1.311 1.521-.685.79a.184.184 0 0 0 .046.281c.033.02.07.028.107.026h6.835c1.045 0 2.36.868 2.283 2.184 0 .597-.247 1.171-.68 1.595a2.36 2.36 0 0 1-1.637.664H23.936c-.704 0-2.598.076-3.128-1.521a1.841 1.841 0 0 1-.043-1.035 4.5 4.5 0 0 1 .72-1.404 65.543 65.543 0 0 1 1.695-2.343c.741-1.002 1.503-1.971 2.251-2.992a.19.19 0 0 0 .04-.116.19.19 0 0 0-.04-.116l-2.72-3.156a.192.192 0 0 0-.153-.073.192.192 0 0 0-.152.073c-.728.96-3.917 5.203-4.598 6.063-.68.86-2.355.907-3.283 0l-4.255-4.161a.197.197 0 0 0-.1-.053.195.195 0 0 0-.2.082.192.192 0 0 0-.032.106v8a2.678 2.678 0 0 1-.494 1.594c-.33.466-.804.823-1.352 1.014a2.375 2.375 0 0 1-2.111-.293 2.271 2.271 0 0 1-.72-.805A2.22 2.22 0 0 1 5 28.736V14.349a2.416 2.416 0 0 1 .548-1.422c.33-.406.785-.7 1.298-.841a2.632 2.632 0 0 1 2.502.664l6.54 6.381c.019.02.043.034.07.043a.197.197 0 0 0 .161-.013.188.188 0 0 0 .061-.054l4.646-6.27c.215-.254.485-.46.79-.601.304-.142.636-.217.976-.221H34.68c.33 0 .657.07.959.204a2.31 2.31 0 0 1 1.263 1.409c.096.309.122.633.079.952a2.288 2.288 0 0 1-.813 1.42c-.439.364-.996.56-1.572.551h-6.768a.188.188 0 0 0-.163.099.187.187 0 0 0-.022.095c0 .032.013.065.032.093h-.008Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"paint0_linear_17_93",x1:"-0.315",x2:"35.366",y1:"9.343",y2:"30.176",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{offset:"0.23",stopColor:"#FF0074"}),R.jsx("stop",{offset:"0.26",stopColor:"#FF0068"}),R.jsx("stop",{offset:"0.32",stopColor:"#FF0048"}),R.jsx("stop",{offset:"0.39",stopColor:"#FF0015"}),R.jsx("stop",{offset:"0.41",stopColor:"#FF0009"}),R.jsx("stop",{offset:"0.43",stopColor:"#FF0908"}),R.jsx("stop",{offset:"0.54",stopColor:"#FF4003"}),R.jsx("stop",{offset:"0.62",stopColor:"#FF6201"}),R.jsx("stop",{offset:"0.66",stopColor:"#FF6F00"}),R.jsx("stop",{offset:"0.72",stopColor:"#FF8700"}),R.jsx("stop",{offset:"0.83",stopColor:"#FFAB00"}),R.jsx("stop",{offset:"0.92",stopColor:"#FFC100"}),R.jsx("stop",{offset:"0.98",stopColor:"#FFCA00"})]}),R.jsx("clipPath",{id:"clip0_17_93",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),e9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:e,height:e,viewBox:"0 0 42 42",...n,children:[R.jsxs("defs",{children:[R.jsx("clipPath",{id:"clip1",children:R.jsx("path",{d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "})}),R.jsxs("radialGradient",{id:"radial0",gradientUnits:"userSpaceOnUse",cx:0,cy:0,fx:0,fy:0,r:1,gradientTransform:"matrix(0.000000000000001938,31.643555,-31.643555,0.000000000000001938,21,5.578125)",children:[R.jsx("stop",{offset:0,style:{stopColor:"rgb(5.098039%,5.490196%,7.058824%)",stopOpacity:1}}),R.jsx("stop",{offset:1,style:{stopColor:"rgb(0%,0%,0%)",stopOpacity:1}})]}),R.jsx("image",{id:"image91",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAIOUlEQVRYhe2YW4jcVx3HP+fyv8785z+XveUm040xaWraitaHFmkfpKCI6LMgLWq9IUUpiA9CwRdfiqBPtbbWy5MKhRbxnuZFRUSMxhBr2nR6Sdrd2ezOzs7szP9yzvFhdus2TEzWJD7l+zQw53/Oh+/vcjg/uKmbuqmbuqlrkbhB+8o2+CFUUoj6EEWgAQ/Ah2IMpQcbS5C9CkMg/3+Cyjb4GpIE4gLSCsROkyKJLCilAEHpWwbS0M8LNvrQG0KvAxngbiTo2wBzaISahpGknqTxxGE1RLoPSCkWcIwN7p9hYX/54Asc0YKLOuPNElYL6P0J+jcCVLQhKCFOoQo0Ak3NSGaUZPbJI2qolXvECXHnlG83TemeeOxf9jcvlXh+zvk+LC9B9wJsXk9Qrw2VBsQWGnriYAvJ7FOH6ChfPSIE91/pDGF57tNnzO8Cy8tRxusZLGdw8Y8wulZQeRgqGioGalWol4pZJ5n77iKnKon6jIVPAuHVbmgL99jDZ+252PCyzni1AW8uwvBRGL916G4A2xC+E1oRtBTsjTW3FB6HF2PUj2+TrShRz1p4aDeQANITn/pWmxdKzXwY0ahCDISnwd9eo69iH9HeysPKVh4qTVNK5oxg9odH1UUh3TecELfvBu4S1YUv3++UHStHWvjUKj7ZiQHl821k0sJcCVQuQpJCRUBqoYnPjJPMf+8Q5zxfPegE94O45u4h4BCWV0pN4kHse4RH6+TeALHBf3fU2w+JDzULc2I7D2/hVCVRH7aObztBcK2Ab4EKAqEIlCASkghDMLJ4PeBjUFwO1HsHVJtQk7BgfPYeDBl//aDcJ6X4poW5631VGMuKAO05VAAq9FAzErWi4LfruKmg+0HLSagXrE/7+0c47/nqMeCu64s3kXMUFPaMZ2kriUsDpK/xuhnBLGSHUsTUqs8gDaFlFXuevJVz2lc/uFGQAM7y+6+8xj2BoKhpjK9xkUMuhojcw39hk2AqaAoVH1KjWQi0+pqAW24UJM69bo15JpYM6ophYskrAtP0EP0YX1nkYnwZR0tIjKLxs8P8A8FHbhikdWeKsf3OV1/mfVXJeiLpJyGjhocFSD1EWIdzGj01R32olpJ6oeSt8up67a7kHD1n3XOPv277ZzPuqCuWZwQrDUV/XrM5F5LrEreaIRohbHqoqRAStIVQKnHg+hKSO2uP58Yd//JL3BspaGi6s4qlpsdaXdGvK8ZNR+4iysEIt33FTQV1IAVojSvK69OHnLXur6a0z37hJe6OFXc1PN6oC1Ybkm7dY63hc3HWsZEKRmODnSsxmcD1AJddpj0BTkgsjrPXymmte8VYnvn8WXssktzRUlxINOtVyWoq6DV91usevaZjY49g5DvyekzZHeH2B+QXMhziMo7mYHxLMSrsSc9T6wjSXRM61p11P3/8Nds/NeJgy+N8LOinirUU1hKf/oxgPQgYzVoGM5KRceR7fcbnR7h9AdmFDOfJSWFN9esgvNdTvKsQvPund8hEC/GlXQDmztrj49I9//A57qsq1iqKfl2ylkCv7rOeKjbSkEHdMYgtxYJi2DeYGUeWCdzMDsh2SNEdgpp2VgqpllSlJPzbqjv/waasIK/YSx2WvxSlefJzL3LgxDozDc1KU9KdlSzNKJZnQ7rzMavzgn7VMJqHYaoZeZBXLIWRGOnIhxa7GJMXGbZbQCZwU0FjiJRDe4JwxdL+eOCekr6QUoojTEsX614sS55+6KxNjq9TTxUXm5qVumKppVieDViZ16w0fQZzJcMFGLY8htKjqOdkQzCxIyvAlAo7YykubAFmY+xRTT419A1IF2DOwn5f0baKtpXs/dERfq2Q9wopDipBaKy9WFpx5osv2veEgmGsGMSCjZpmvQ69xKdfE6zXAsbzgmFLMKpCtiGxiaUsS8y+kHFnDEphZg1FF7ACl4+wx0KKHtDpXCZH2xCOoNaA+QjmpWKfUewVihaCVAgCZVFK4gJJEQpGFcFmRdBvSjZqIesVwaAZMW5YhrGjmFcMNkpsVVEGhtJITGgphhLbsuTbgGYTl4wpjMD1etADhmCnVn0HsvugfxrkASi1wcSKgRDMCEcqJaH2UNpCJCgriix1jFKPfkMxjAKyBclAG0wDxqEm146iBWbksB7kpcO1KmR2CF2gGGG3AZfWcUvgMnAJuHugvGyXdCCOQLU+eb/Uqh71miIpJUkoCYXDqypcoBBVQdHyGDcjxg1N5hlMXTD2FIUwmKqlGEnsnE/+5iVh3gm40ns74F1QdoBT4K7UzsV9UGmDthE1rYlSjR8pvMwQxwEqFbhEYGcEpe9jW4rCCRyWMjGUmcDtD8gul4cHxhSdHnTBbYDdBjwBbOyYmlzVvfMohBF4pkqofIKaRYceXsUhIx9RGHTFh5ai9H3IczBbDo7HMJTYd0Tk3eFkyFSMsEcj8k4POr1JDvpgpwGubv2+6gvyNPjLILsQHAKxXMXfHyHXSvy4jhAjRBhOkj9k8iBXCgMwrZpPdiZrV8Fsu/jcFMBdOfoW7G348RD59w6eraOCEM8ZVJvJW7pSgXMZej6gXMrQSUkJb3dxu910JyBmZx5eCrlnt6HfqZ/chj88jXygDb/o4++xyDvr8Ac1GRYoO9lTOoQVk4N29sSTnUmoE3C3Q3GC/4R6p4vbkJ+FAnY3KQFgMcS9AvbpDnyoRv6GxJ7swdGE/O6EPFdYI3GFwuYj7GFHdiycFMyfO7gh2E9AXtuCnKZLIeF/HJI9Dl4G8hiIB9rwqwHeG1VUfev/+iXrOz0oBW5zDftRKDrANuSlbk6DBPg3vtO3svqbCX0AAAAASUVORK5CYII="}),R.jsx("filter",{id:"alpha",filterUnits:"objectBoundingBox",x:"0%",y:"0%",width:"100%",height:"100%",children:R.jsx("feColorMatrix",{type:"matrix",in:"SourceGraphic",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"})}),R.jsx("image",{id:"image170",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACtklEQVRYhWNgGAWjYBSMglEwCkYcmGslLagZ26TedkTUMOD/H11nY2a5Sb+/sJBiBiOtHMfAwMCg73JCaNrNdN2kh/eF0eXKFXf+qZBhvfbqqMkdYsxior7zGBjUK65yXtwsbBq4/7wDNkcyMDAwdN53ZxE87KQX4tNtRIyZVA1Rc3M7ZpZn5eoNd1lVc1hCmInVJ7ov4fwRl0n38amhWoiyP3kmPbfVyfXNw0gNUhzJwMDA8D/3q1bnt2a8bqE4RFPWPhRMLPDTwxXFxIKtN84cUdFSe4VLnuwQhaVDmbBtjpQ6koGBgWHPo6d8+ORJKiIYGBDp0CgsQTXM4Dczw+9y8l2HBB4kJFEv6p2NmeVYi1m170ewcVLmLEzw6HHhye/yjU9xyRMV9XaXNnLcmHTA9slpbhNaONLtgvpfZV5TnOmTgYGIEP3LGciWdPSB/QmDu7zUcxoquNv66c6fWoZL+NQQDNFwZysdWjpS8mnzhzsL664RUoc3M9ld2sixVWiFvBz13IUC2HjqXtzv4z+jcCf/DyG1eKOeb66bnGTiCRPqOQ0Ccpjzvq3gTr5y9IviE2L14I163YZ8HsqdhQDP3hn9vf8m5tq3r+y7SHEkAwOBqH/ncPYvZU6DgEjWToYZ/8UefWbsusrwd9p3ckpevCEqdNL9E5lug4N58opvn6zy2v/iX/AZhr8nv5NrDl6H7vx0/ZXyhqBf5BisuOLXdxnTr2esH188OCdY/j15zkMAguUoX8haFclViXrEGvjsndHfn/+0bjbzSN4q56r9R5nzEICoKlQvzsrk54IreEspWDp8wdh1lZIoxgWIrusrJBTVpl6R15QSOofR1qzc+eH1kW+Pr1AjiqkCJv3+wuJszCwnwaeq23ZE1JC9Q0ktq+09/0C7axSMglEwCkbBKKA/AABq8ekilgplTAAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask0",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("use",{xlinkHref:"#image170"})})}),R.jsx("image",{id:"image125",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEF0lEQVRYhe2WTYscVRSGn3NvVXdPzySabwQN2SlGkQgjCC4EFWMU/A+CG925EhN0JSiof8BtxC8SSVZZiK7MRjRElPwEF8Ik0z3d9XXPOS6qJhM1pHucGXHRLxRFN9Sth/d977kFCy200EILLfR/kvwXL/n69NFvs6Y56MmGjUIlsU55TK9998eT866xp6DfvHTkcm9Snop1epBkqDuNQulCHWNT9Xq/s5FOv/7rxo1Za2V7AXjhzLEv+pPy5ODm+KSoSlQDdZI5GCQVCtdcKzuuw/5V4MCsNXfV0S9feeD8YKM4vlKVq5J0kJsR3Ajq4JAcygSjBOMkbEhEl3Ky+5dGb/6wdt+91t41Ry8+f+jS8tr6M3nTHNwEjO5EBxdwQFwIAcBxcxSjqY1Q6vKs9XcMevHMka+WxtPV/mh8IqiSWwcISJdXCIFkYIB5+5/jaHJSdIJa3DPQCy8f+3w4nj7auzl6PDYq0YzMncwcCYBDkIAByaAxaBxq2/pdG6iC2ez3bRv0dg/X1p8KSfu5GcGMgBMFEBAEFyG1ewg1qB3qBJVCqU6lLbDOCbEt0AvPHbyyf219Nd7Rw+BOJrQOGnjnYrfRW/e8A0zOVJ0iQaFQK7hu1WHHoJ+9ePTKynjy8HC0cSIzpff3HhpICLc7qNbu8Mah0TbmonEKc6YJxg1MGiikBWiH1g5Bz79w7Pul9Y3Hsro+nJkykLv38E4HN11sNmO21sVJgo0E0wSlQQpCiELMg+4Y1CfFQxTN4dyULBhBWhfv1sOmm5W1Qp2c0pxSaSEVyqaNfCqCBSH2I/kg03wQZ87ze4J++uzhn8NocsJUMTcQcAOTgPtfY07eRlwlpzYo7ujitLuXBjWCx0DWjwxX8rRvf+5vXV3r7Qg01WlfXVmM6m2sgAQB6SB9K+5aodqMWWHadIDWXgnBsoDkgf4g08Ew0+u/jT++DO/MgpwJqrUNK3OkcfIAwQR1QLbibiHbmKvOvYlCqVAZ1CZoDHge6PWi5ctZWh5mcvanW/15AOcCTU5UBVOQbozkAuCdm23MlbbRFtqe5UWCMggmAoNA7EUfLGVpaZhx7tr6tgDnArUQaFyoVUjm1Or0usPuzsgLawHL7rSpRPAQyHqRwXKWloaZvXt99K8A5wINecg0hFQgWZmEQpzYQOiiT9qC1d7GnOSfPfzlxviDS8Z7O4GEOT7z3n9i/6hcr/bV0wZJRugect8aRykIEgOSBXr9aPnwdg9n7uZdA3018MapR1Y+KTaaflMlUmrnknePexQkD/Ty6P1hloZLkXPX1ncNcG5QgI+ePlSMxrVURerVlYl3oCEIsRfo92MaDqKf3QPAbYFu6sPVA1XdKEk9OEgWxXt54O0fb+V7BbjQQgsttNBC/0/9CbvrotNPsOneAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image142",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAAmklEQVRYhe2U0QqAIBAE1/7/n+tFIaQyur21aAdEX4RhDgWMMemUul7BkciZ3JopMqKXGhWcJltOzldMkS3dfhe5bOTBSGWXwF3pjxARBYSyUVFAJMsQBQSyLNF0mKKpVdlF02R/OfpGStWsonTZX4++Qa3qohVaVRfdQanqoh3hqi7KRikaGr+LslGLPh6/i7KxKBuLsvmM6AZK+AVU/UCtAQAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask1",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.6,stroke:"none"}})})}),R.jsx("image",{id:"image148",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEI0lEQVRYhe3XTW4kuREF4I9kZqX+7B61gAFGR5CWPsucZ9zn6Sv4Ct5ZfQAv1IABuaftaUlVmWR4kZS6tPKitBjDegCRZBaT9RA/Lxi84Q1veMMbDkF6msTTPPChz28kP+NTX99+3/+MSwGuhI+47utfhETS169BNEgvCF5JPkluJZeSO8lF/+3rHtl3ncSdcCHcCpfCjXAtXpPs8ILkjeRa8kVyJ7uUkE0SknvJuz2idzgWJg3hUkNzLlxpPiBEJOlQsilI/txJnu+RI7tXJPl5TJKtZJaMwiRshdCE5lhF8141aT4LNL+IlA4jml+QnGRfFQwejE6Mso1qMplwpDl2tj6POTKZVJNs49GIwd8NPituJVfSc0gdgAFcd9d+lb1T/GpwrPhmlAyKwaKoiiy7lxTxsNX626paDDJmZ9At/hd80Q4lmt30pCErsgdFMUg2Tm1kR5IjyYlwKpwa+zOcSk40xzbdst9sMLhXDD2Ufj6UJsOe/GRniq3BHwxmG4uNbFKMFhvJICua1L+omA3mHsfJpsflieY3zZ32LG8HEf0keS/5Z0+gSTEbVWNfTZpJ6cRDUSRNqKowS7bmrh5VM/dwyKqLZ48dSPR2T3pWCsXOIPdEaibVUSe9urVKslAsmkHuKlBVG7MHA93Kt3KXrQOJ/gnfJA/dootiUIRBMqg2hp75q2WH7vjAIssDbVlUYbE1SP2cU0k93Jor0c/doqw2mCRNlrtMMQijbBRGYUDWRElSJRYWydzTsXhUjJLHfu7d4WTz8+xYspEsUo/B78KvOzo6kbyGSE2KppT9fbV/v3StuH8di+b/vuX3ge9EH4SdMAhVyF1mnsYabVXrI9QSa2bX/X2lfz8Ij8LJ69yesp+EP/bDRmHutbuqWDzFXzMXdpoZO9murlV/HWHp9WmVplk46udevMLtyV+td8roFhlUO1W2CItit+a2VJNQ1C74a9aHnWRnsFN7mZi79R+Ef4leUg8keim8F/4h/KiiShbVjNKTg6RZVHlP8Jsqm4WtpRN+tGiq0ndcam5fw6JXwifhx27RrWoy00siqxgtandz2RP8JptVs9HWbKeYHVlQewmN5y7gIKIfcd4vvb+piuTfXU/HnhBh0SxjUebaLVp7smXLJsy7MCt2dmajxb2qai6Eq9cguvY4659WyZnqV0kI30SX/8Fonmu/SDdPJaIJdRe95ofFqRmLE9Vd99LHQ2k+ydNN73cWzVfVD6sFLXaKrerR4MHkXnP/4jl4UD0abTU7T0qxhlF77p8OxP9QK8La2l6LfhNvflLdqU7Mjs0WO5Ote1uTrTOPJlt3/f1i57i7nMXfNOf9rN6JHoohWbtEIXwA4Vzq7W9yqdlKziQnXrbLT0K+Fc722uUvXUleubd/wxve8IY3/B/gP+5/MI8x65+AAAAAAElFTkSuQmCC"}),R.jsx("mask",{id:"mask2",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.701961,stroke:"none"}})})}),R.jsx("image",{id:"image154",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAA/ElEQVRYhe2VwW7DIAxAn9M0qcSN///G3JDaFEIPwRvqoUHdWKXJT/IhMokeNiZgGIZhGIZh/EPkVTLnLGWNxvD0Ti6xAVlEtk6eDA1rBDgBZ2ACZu/9DMzleSz5lm+9zVFFh0pyrELYK5m89/dlWSIQRWT9lOipiE1VnCvRCKwaInLtJXrULj2Xdesn4EJpvXPuT1o/NqxR2Vp4YB+gLYSgki+781PeqUL+dYsGWkT1+tmAxH4uNZJzLpVc1w0ctV4lE3Dne4i+himEEEu+2x0KxxV9Fr0B1ypu3vuVvbpdRVv+TDpEGvXmdBMJ2EQkdvI0DMMwDMMwjI/yAInrT4nWGUiJAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image160",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("mask",{id:"mask3",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.2,stroke:"none"}})})}),R.jsx("image",{id:"image166",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("clipPath",{id:"clip2",children:R.jsx("rect",{x:0,y:0,width:42,height:42})}),R.jsxs("g",{id:"surface169",clipPath:"url(#clip2)",children:[R.jsx("use",{xlinkHref:"#image125"}),R.jsx("use",{xlinkHref:"#image142"}),R.jsx("use",{xlinkHref:"#image148",mask:"url(#mask1)"}),R.jsx("use",{xlinkHref:"#image154",mask:"url(#mask2)"}),R.jsx("use",{xlinkHref:"#image160"}),R.jsx("use",{xlinkHref:"#image166",mask:"url(#mask3)"})]})]}),R.jsx("g",{id:"surface1",children:R.jsxs("g",{clipPath:"url(#clip1)",clipRule:"nonzero",children:[R.jsx("path",{style:{stroke:"none",fillRule:"nonzero",fill:"url(#radial0)"},d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "}),R.jsx("use",{xlinkHref:"#image42"}),R.jsx("use",{xlinkHref:"#image91"}),R.jsx("use",{xlinkHref:"#surface169",mask:"url(#mask0)"})]})})]}),t9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",id:"Ebene_2","data-name":"Ebene 2",viewBox:"0 0 314.29 111.66",width:e,height:e,...n,children:[R.jsx("defs",{children:R.jsx("style",{children:".cls-1{fill:#fff;stroke-width:0}"})}),R.jsxs("g",{id:"Ebene_1-2","data-name":"Ebene 1",children:[R.jsx("path",{d:"M118.13 0c-8.69-.1-16.81 2.21-23.8 6.26-2.57 1.49-3.29 4.91-1.55 7.33 3.44 4.8 6.15 10.15 7.97 15.9 1.01 3.2 4.82 4.23 7.65 2.43 3.55-2.25 7.97-3.25 12.67-2.33 6.53 1.27 11.95 6.44 13.44 12.93 2.61 11.39-5.97 21.5-16.91 21.5-3.41 0-6.58-.99-9.24-2.7-2.82-1.8-6.61-.66-7.63 2.53-4.48 14.04-14.26 25.71-27.02 32.66-1.67.91-2.75 2.6-2.75 4.5v5.58c0 2.8 2.27 5.07 5.07 5.07h19.13c2.8 0 5.07-2.27 5.07-5.07v-9.76c0-3.35 3.16-5.67 6.42-4.87 3.52.86 7.18 1.32 10.96 1.32 26.19 0 47.34-21.59 46.62-47.95C163.55 20.67 142.8.28 118.13 0Z",style:{fill:"#ff7900",strokeWidth:0}}),R.jsx("path",{d:"M46.64 0C20.88 0 0 20.88 0 46.64s20.88 46.64 46.64 46.64S93.28 72.4 93.28 46.64 72.4 0 46.64 0Zm0 64.03c-9.6 0-17.38-7.78-17.38-17.39s7.78-17.39 17.38-17.39 17.39 7.78 17.39 17.39-7.78 17.39-17.39 17.39ZM188.46 41.7l20.14 33.14h11.26V18.5h-13.02v34.05L185.9 18.5h-10.38v56.34h12.94V41.7zM265.74 63.57h-24.29V51.9h15.46V40.8h-15.46V29.77h24.29V18.5h-37.88v56.34h37.88V63.57zM286.16 74.84h14.06V29.77h14.07V18.5H272.1v11.27h14.06v45.07z",className:"cls-1"})]})]}),r9=({size:e,className:t,variant:r,walletName:n})=>n===ri?R.jsx(X$,{size:e,className:t,variant:r}):n===vs?R.jsx(Y$,{size:e,className:t,variant:r}):n===bs?R.jsx(Xb,{size:e,className:t,variant:r}):n===ni?R.jsx(Q$,{size:e,className:t,variant:r}):n===ms?R.jsx(Z$,{size:e,className:t,variant:r}):n===Ki?R.jsx(G$,{size:e,className:t,variant:r}):n===Hi?R.jsx(J$,{size:e,className:t,variant:r}):n===ws?R.jsx(q$,{size:e,className:t,variant:r}):n===ji?R.jsx(e9,{size:e,className:t,variant:r}):n===Hg?R.jsx(t9,{size:e,className:t,variant:r}):R.jsx(Xb,{size:e,className:t,variant:r});Y.FRACTAL_MAINNET=cs,Y.FRACTAL_TESTNET=Zt,Y.LEATHER=vi,Y.LEATHER_MAINNET=pc,Y.LEATHER_TESTNET=sf,Y.LOCAL_STORAGE_DEFAULT_WALLET=Ua,Y.LaserEyesClient=v5,Y.LaserEyesProvider=z$,Y.MAGIC_EDEN=Wn,Y.MAINNET=tt,Y.OKX=ns,Y.OKX_MAINNET=x0,Y.OKX_TESTNET=$0,Y.OP_NET=Ud,Y.OP_WALLET_MAINNET=p3,Y.OP_WALLET_TESTNET=y3,Y.ORANGE=Ei,Y.ORANGE_MAINNET=nf,Y.ORANGE_TESTNET=C0,Y.OYL=bi,Y.P2PKH=im,Y.P2PSH=sm,Y.P2SH=am,Y.P2TR=Na,Y.P2WPKH=hl,Y.P2WSH=om,Y.PHANTOM=mi,Y.REGTEST=g3,Y.SIGNET=Jt,Y.TESTNET=it,Y.TESTNET4=Yt,Y.UNISAT=Vn,Y.UNISAT_FRACTAL_MAINNET=Zl,Y.UNISAT_FRACTAL_TESTNET=Ql,Y.UNISAT_MAINNET=fc,Y.UNISAT_SIGNET=Yl,Y.UNISAT_TESTNET=Xl,Y.UNISAT_TESTNET4=Jl,Y.UNSUPPORTED_PROVIDER_METHOD_ERROR=Lr,Y.WALLETS=cm,Y.WALLET_NOT_INSTALLED_ERROR=O0,Y.WIZZ=is,Y.WIZZ_MAINNET=jo,Y.WIZZ_SIGNET=rf,Y.WIZZ_TESTNET=dc,Y.WIZZ_TESTNET4=tf,Y.WalletIcon=r9,Y.WalletProvider=Cn,Y.XVERSE=Pn,Y.XVERSE_MAINNET=hc,Y.XVERSE_NETWORK=d3,Y.XVERSE_SIGNET=I0,Y.XVERSE_TESTNET=ef,Y.createConfig=P8,Y.createStores=k8,Y.getLeatherNetwork=w3,Y.getNetworkForLeather=v3,Y.getNetworkForOkx=N0,Y.getNetworkForUnisat=yc,Y.getNetworkForWizz=af,Y.getNetworkForXverse=m3,Y.getOrangeNetwork=Do,Y.getSatsConnectNetwork=Ms,Y.getUnisatNetwork=of,Y.getWizzNetwork=b3,Y.useLaserEyes=M$,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
86
+ <%s key={someKey} {...props} />`,xd,Cs,n9,Cs),K[Cs+xd]=!0}}return P===n?L(xt):$(xt),xt}}function W(P,j,G){return q(P,j,G,!0)}function X(P,j,G){return q(P,j,G,!1)}var Z=X,te=W;ul.Fragment=n,ul.jsx=Z,ul.jsxs=te}()),ul}process.env.NODE_ENV==="production"?Od.exports=F$():Od.exports=V$();var R=Od.exports;function W$(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Gb(e,t={}){let r=tn.useCallback(i=>t.keys?W$(e,t.keys,i):e.listen(i),[t.keys,e]),n=e.get.bind(e);return tn.useSyncExternalStore(r,n,n)}function z$({config:e,children:t}){const r=tn.useMemo(()=>new j$(zx(),qx(e??{network:mt})),[e]),{address:n,paymentAddress:i,publicKey:o,paymentPublicKey:s,accounts:a,balance:u,connected:f,hasProvider:h,isConnecting:d,isInitializing:g,provider:v}=Gb(r.$store),E={},T=Gb(r.$network);return R.jsx(Wb.Provider,{value:{paymentAddress:i,address:n,publicKey:o,paymentPublicKey:s,library:E,network:T,accounts:a,balance:Number(u),connected:f,isConnecting:d,isInitializing:g,provider:v,hasLeather:h.leather??!1,hasMagicEden:h["magic-eden"]??!1,hasOkx:h.okx??!1,hasOyl:h.oyl??!1,hasOrange:h.orange??!1,hasOpNet:h.op_net??!1,hasPhantom:h.phantom??!1,hasUnisat:h.unisat??!1,hasWizz:h.wizz??!1,hasXverse:h.xverse??!1,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),getBalance:async()=>(await r.getBalance.call(r)??"").toString(),getInscriptions:async()=>await r.getInscriptions.call(r)??[],getNetwork:r.getNetwork.bind(r),getPublicKey:async()=>await r.getPublicKey.call(r)??"",pushPsbt:r.pushPsbt.bind(r),signMessage:async(x,N)=>await r.signMessage.call(r,x,N)??"",requestAccounts:async()=>await r.requestAccounts.call(r)??[],sendBTC:async(x,N)=>await r.sendBTC.call(r,x,N)??"",signPsbt:async(x,N,O)=>await r.signPsbt.call(r,x,N,O)??{signedPsbtBase64:"",signedPsbtHex:""},switchNetwork:async x=>{await r.switchNetwork.call(r,x)}},children:t})}const q$=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"white",style:{fill:"white",fillOpacity:1}})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"white",style:{fill:"white",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}})]}),Xb=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#12100F"}),R.jsx("path",{d:"M74.9171 52.7114C82.4766 51.5408 93.4087 43.5804 93.4087 37.3761C93.4087 35.5031 91.8968 34.2154 89.6871 34.2154C85.5004 34.2154 78.4061 40.5368 74.9171 52.7114ZM39.911 83.4991C30.0256 83.4991 29.2115 93.3324 39.0969 93.3324C43.5163 93.3324 48.8661 91.5764 51.6573 88.4157C47.5868 84.9038 44.2141 83.4991 39.911 83.4991ZM102.829 79.2848C103.41 95.7907 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.0249C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8463 40.0273 72.8463C45.3771 72.8463 49.9128 74.2511 55.7277 77.88L59.5656 64.4177C43.7489 60.0864 35.8405 47.9118 43.6326 30.4693H56.1929C49.215 42.0586 53.9832 51.6578 62.822 52.7114C67.5903 35.7372 77.8246 22.509 91.4316 22.509C99.1074 22.509 105.155 27.5428 105.155 36.6737C105.155 51.3066 86.0819 63.2471 71.6607 64.4177L65.7295 85.3721C72.4748 93.2153 91.199 100.824 91.199 79.2848H102.829Z",fill:"#F5F1ED"})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#F5F1ED"}),R.jsx("path",{d:"M74.9171 52.7115C82.4766 51.5409 93.4087 43.5806 93.4087 37.3762C93.4087 35.5032 91.8968 34.2155 89.6871 34.2155C85.5004 34.2155 78.4061 40.5369 74.9171 52.7115ZM39.911 83.4992C30.0256 83.4992 29.2115 93.3325 39.0969 93.3325C43.5163 93.3325 48.8661 91.5766 51.6573 88.4159C47.5868 84.904 44.2141 83.4992 39.911 83.4992ZM102.829 79.2849C103.41 95.7908 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.025C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8464 40.0273 72.8464C45.3771 72.8464 49.9128 74.2512 55.7277 77.8801L59.5656 64.4179C43.7489 60.0865 35.8405 47.9119 43.6326 30.4695H56.1929C49.215 42.0587 53.9832 51.6579 62.822 52.7115C67.5903 35.7373 77.8246 22.5092 91.4316 22.5092C99.1074 22.5092 105.155 27.5429 105.155 36.6738C105.155 51.3068 86.0819 63.2472 71.6607 64.4179L65.7295 85.3722C72.4748 93.2155 91.199 100.825 91.199 79.2849H102.829Z",fill:"#12100F"})]}),G$=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#AB9FF2",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#FFFDF8",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}):R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#FFFDF8",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#AB9FF2",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}),X$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_3_53)",children:[R.jsx("path",{d:"M32 0H10C4.47715 0 0 4.47715 0 10V32C0 37.5228 4.47715 42 10 42H32C37.5228 42 42 37.5228 42 32V10C42 4.47715 37.5228 0 32 0Z",fill:"#181818"}),R.jsx("path",{d:"M32 31.6745V27.6829C32 27.5233 31.9203 27.3636 31.8406 27.2438L14.8225 10.1597C14.7029 10.0399 14.5435 10 14.3841 10H10.3986C10.1993 10 10.0399 10.1597 10.0399 10.3592V14.0715C10.0399 14.2311 10.1196 14.3908 10.1993 14.5105L16.2971 20.6177C16.4565 20.7774 16.4565 20.977 16.2971 21.1366L10.1196 27.3237C10.0399 27.4035 10 27.4834 10 27.5632V31.6346C10 31.8342 10.1594 31.9939 10.3587 31.9939H17.0544C17.2536 31.9939 17.413 31.8342 17.413 31.6346V29.2396C17.413 29.1598 17.4529 29.0401 17.5326 29.0002L20.8406 25.6871C21 25.5275 21.1993 25.5275 21.3587 25.6871L27.4964 31.8342C27.6159 31.954 27.7753 31.9939 27.9348 31.9939H31.6413C31.8406 32.0337 32 31.8741 32 31.6745Z",fill:"white"}),R.jsx("path",{d:"M23.3406 15.0793H26.5592C26.7507 15.0793 26.9039 15.2333 26.9039 15.4257V18.658C26.9039 18.9658 27.2871 19.1197 27.4788 18.8888L31.8851 14.4637C31.9617 14.3867 32 14.3097 32 14.2328V10.3463C32 10.1539 31.8468 10 31.6552 10H27.7469C27.6703 10 27.5554 10.0385 27.5171 10.1154L23.1107 14.5021C22.8808 14.6945 23.0341 15.0793 23.3406 15.0793Z",fill:"#EE7A30"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"clip0_3_53",children:R.jsx("rect",{width:"42",height:"42",fill:"white"})})})]}),J$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#b)",d:"m25.517 9.483 5.759 5.611c.49.477.731.959.724 1.445-.008.486-.219.929-.631 1.33-.431.421-.897.634-1.395.644-.497.007-.992-.228-1.482-.705l-5.89-5.738c-.669-.652-1.315-1.114-1.936-1.385a2.873 2.873 0 0 0-1.96-.127c-.685.185-1.42.662-2.21 1.428-1.086 1.06-1.605 2.054-1.552 2.983.053.929.593 1.893 1.617 2.89l5.938 5.786c.496.482.74.964.732 1.443-.008.48-.22.923-.64 1.332-.419.408-.88.62-1.382.638-.502.016-1.001-.217-1.495-.7l-5.76-5.61c-.936-.912-1.613-1.776-2.029-2.59-.416-.815-.572-1.737-.464-2.765.097-.88.384-1.732.863-2.558.477-.827 1.161-1.671 2.048-2.537C15.43 9.268 16.438 8.48 17.4 7.93c.96-.55 1.889-.854 2.786-.917.899-.064 1.784.112 2.66.527.876.415 1.765 1.061 2.67 1.943h.002Z"}),R.jsx("path",{fill:"url(#c)",d:"m16.482 32.123-5.758-5.611c-.49-.479-.731-.959-.724-1.445.008-.486.219-.929.631-1.33.431-.421.897-.634 1.395-.644.498-.007.992.227 1.482.705l5.888 5.738c.671.652 1.315 1.114 1.936 1.385.622.27 1.276.312 1.962.127.685-.185 1.42-.662 2.21-1.43 1.086-1.06 1.605-2.054 1.552-2.983-.053-.929-.593-1.893-1.617-2.891l-3.164-3.056c-.496-.482-.74-.964-.732-1.443.008-.48.22-.923.64-1.332.419-.408.88-.62 1.382-.638.502-.016 1.002.217 1.496.7l2.983 2.88c.936.912 1.613 1.775 2.03 2.59.415.815.571 1.736.463 2.764a6.477 6.477 0 0 1-.863 2.559c-.477.826-1.16 1.67-2.048 2.536-1.057 1.03-2.066 1.819-3.027 2.368-.962.55-1.89.856-2.79.92-.898.063-1.784-.113-2.66-.527-.876-.415-1.765-1.062-2.67-1.944l.003.002Z"}),R.jsx("path",{fill:"url(#d)",d:"M20.073 17.645c1.168 0 2.115-.93 2.115-2.08 0-1.149-.947-2.08-2.115-2.08-1.168 0-2.115.931-2.115 2.08 0 1.15.947 2.08 2.115 2.08Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"b",x1:30.329,x2:12.579,y1:12.752,y2:20.772,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#201C1B"}),R.jsx("stop",{offset:.36,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4B852"})]}),R.jsxs("linearGradient",{id:"c",x1:12.163,x2:32.789,y1:29.085,y2:22.844,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#1F1D1C"}),R.jsx("stop",{offset:.37,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4FB52"})]}),R.jsxs("radialGradient",{id:"d",cx:0,cy:0,r:1,gradientTransform:"matrix(2.11484 0 0 2.08019 20.073 15.567)",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#F4B852"}),R.jsx("stop",{offset:.33,stopColor:"#EA8101"}),R.jsx("stop",{offset:.64,stopColor:"#77390D"}),R.jsx("stop",{offset:1,stopColor:"#211C1D"})]}),R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Y$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsxs("g",{fillRule:"evenodd",clipPath:"url(#b)",clipRule:"evenodd",children:[R.jsx("path",{fill:"#FFD815",d:"m26.507 17.74-1.623-1.623-1.624 1.623 1.623 1.623 1.624 1.624 1.623-1.624-1.623-1.623Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 8-1.624 1.623 1.624 1.624 1.623-1.624L26.507 8ZM33 14.493l-1.623-1.623-1.624 1.623 1.624 1.623L33 14.493ZM23.26 27.48l1.623 1.623 1.624-1.623-1.623-1.624-1.624 1.624ZM11.897 16.117l1.623 1.623 1.623-1.623-1.623-1.624-1.623 1.624ZM20.014 8 18.39 9.623l1.624 1.624 1.623-1.624L20.014 8ZM13.52 11.247l1.624 1.623 1.623-1.623-1.623-1.624-1.624 1.624ZM31.377 19.363l-1.624 1.623 1.624 1.624L33 20.987l-1.623-1.624ZM28.13 25.856l1.623 1.624 1.624-1.624-1.624-1.623-1.623 1.623Z"}),R.jsx("path",{fill:"#5B5B72",d:"m26.507 20.986-1.624-1.623-1.623 1.623-1.623-1.623-1.623-1.623 1.623-1.624-1.623-1.623-1.624-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623 1.623-.812-.811-1.623 1.623 1.623 1.623-1.623 1.624-1.543 1.542-1.542 1.543-1.624 1.623L8 31.377 9.623 33l1.624-1.623 1.623-1.624 1.543-1.542.08-.08 1.462-1.463.08-.08 1.544-1.543 1.623 1.623 1.623-1.623-.811-.812 1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 14.493-1.624-1.623-1.623 1.623-1.623-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623 1.623 1.623 1.623-1.623-1.623-1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"})]})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M8 8h25v25H8z"})})]})]}),Z$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("g",{fill:"#fff",clipPath:"url(#b)",children:R.jsx("path",{d:"M24.578 17.052h-6.787a.523.523 0 0 0-.52.52v6.788c0 .286.235.52.52.52h6.787c.286 0 .521-.234.521-.52v-6.787a.523.523 0 0 0-.52-.521ZM16.733 9.223H9.946a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.285 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM32.424 9.223h-6.787a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.286 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM16.733 24.898H9.946a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.285 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52ZM32.424 24.898h-6.787a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.286 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52Z"})})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Q$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,className:r,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_17_93)",children:[R.jsx("path",{fill:"#070C34",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#paint0_linear_17_93)",d:"m27.666 16.837 1.874 2.177c.215.245.404.446.483.562.56.55.874 1.293.874 2.07-.053.915-.657 1.54-1.213 2.205l-1.311 1.521-.685.79a.184.184 0 0 0 .046.281c.033.02.07.028.107.026h6.835c1.045 0 2.36.868 2.283 2.184 0 .597-.247 1.171-.68 1.595a2.36 2.36 0 0 1-1.637.664H23.936c-.704 0-2.598.076-3.128-1.521a1.841 1.841 0 0 1-.043-1.035 4.5 4.5 0 0 1 .72-1.404 65.543 65.543 0 0 1 1.695-2.343c.741-1.002 1.503-1.971 2.251-2.992a.19.19 0 0 0 .04-.116.19.19 0 0 0-.04-.116l-2.72-3.156a.192.192 0 0 0-.153-.073.192.192 0 0 0-.152.073c-.728.96-3.917 5.203-4.598 6.063-.68.86-2.355.907-3.283 0l-4.255-4.161a.197.197 0 0 0-.1-.053.195.195 0 0 0-.2.082.192.192 0 0 0-.032.106v8a2.678 2.678 0 0 1-.494 1.594c-.33.466-.804.823-1.352 1.014a2.375 2.375 0 0 1-2.111-.293 2.271 2.271 0 0 1-.72-.805A2.22 2.22 0 0 1 5 28.736V14.349a2.416 2.416 0 0 1 .548-1.422c.33-.406.785-.7 1.298-.841a2.632 2.632 0 0 1 2.502.664l6.54 6.381c.019.02.043.034.07.043a.197.197 0 0 0 .161-.013.188.188 0 0 0 .061-.054l4.646-6.27c.215-.254.485-.46.79-.601.304-.142.636-.217.976-.221H34.68c.33 0 .657.07.959.204a2.31 2.31 0 0 1 1.263 1.409c.096.309.122.633.079.952a2.288 2.288 0 0 1-.813 1.42c-.439.364-.996.56-1.572.551h-6.768a.188.188 0 0 0-.163.099.187.187 0 0 0-.022.095c0 .032.013.065.032.093h-.008Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"paint0_linear_17_93",x1:"-0.315",x2:"35.366",y1:"9.343",y2:"30.176",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{offset:"0.23",stopColor:"#FF0074"}),R.jsx("stop",{offset:"0.26",stopColor:"#FF0068"}),R.jsx("stop",{offset:"0.32",stopColor:"#FF0048"}),R.jsx("stop",{offset:"0.39",stopColor:"#FF0015"}),R.jsx("stop",{offset:"0.41",stopColor:"#FF0009"}),R.jsx("stop",{offset:"0.43",stopColor:"#FF0908"}),R.jsx("stop",{offset:"0.54",stopColor:"#FF4003"}),R.jsx("stop",{offset:"0.62",stopColor:"#FF6201"}),R.jsx("stop",{offset:"0.66",stopColor:"#FF6F00"}),R.jsx("stop",{offset:"0.72",stopColor:"#FF8700"}),R.jsx("stop",{offset:"0.83",stopColor:"#FFAB00"}),R.jsx("stop",{offset:"0.92",stopColor:"#FFC100"}),R.jsx("stop",{offset:"0.98",stopColor:"#FFCA00"})]}),R.jsx("clipPath",{id:"clip0_17_93",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),e9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:e,height:e,viewBox:"0 0 42 42",...n,children:[R.jsxs("defs",{children:[R.jsx("clipPath",{id:"clip1",children:R.jsx("path",{d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "})}),R.jsxs("radialGradient",{id:"radial0",gradientUnits:"userSpaceOnUse",cx:0,cy:0,fx:0,fy:0,r:1,gradientTransform:"matrix(0.000000000000001938,31.643555,-31.643555,0.000000000000001938,21,5.578125)",children:[R.jsx("stop",{offset:0,style:{stopColor:"rgb(5.098039%,5.490196%,7.058824%)",stopOpacity:1}}),R.jsx("stop",{offset:1,style:{stopColor:"rgb(0%,0%,0%)",stopOpacity:1}})]}),R.jsx("image",{id:"image91",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAIOUlEQVRYhe2YW4jcVx3HP+fyv8785z+XveUm040xaWraitaHFmkfpKCI6LMgLWq9IUUpiA9CwRdfiqBPtbbWy5MKhRbxnuZFRUSMxhBr2nR6Sdrd2ezOzs7szP9yzvFhdus2TEzWJD7l+zQw53/Oh+/vcjg/uKmbuqmbuqlrkbhB+8o2+CFUUoj6EEWgAQ/Ah2IMpQcbS5C9CkMg/3+Cyjb4GpIE4gLSCsROkyKJLCilAEHpWwbS0M8LNvrQG0KvAxngbiTo2wBzaISahpGknqTxxGE1RLoPSCkWcIwN7p9hYX/54Asc0YKLOuPNElYL6P0J+jcCVLQhKCFOoQo0Ak3NSGaUZPbJI2qolXvECXHnlG83TemeeOxf9jcvlXh+zvk+LC9B9wJsXk9Qrw2VBsQWGnriYAvJ7FOH6ChfPSIE91/pDGF57tNnzO8Cy8tRxusZLGdw8Y8wulZQeRgqGioGalWol4pZJ5n77iKnKon6jIVPAuHVbmgL99jDZ+252PCyzni1AW8uwvBRGL916G4A2xC+E1oRtBTsjTW3FB6HF2PUj2+TrShRz1p4aDeQANITn/pWmxdKzXwY0ahCDISnwd9eo69iH9HeysPKVh4qTVNK5oxg9odH1UUh3TecELfvBu4S1YUv3++UHStHWvjUKj7ZiQHl821k0sJcCVQuQpJCRUBqoYnPjJPMf+8Q5zxfPegE94O45u4h4BCWV0pN4kHse4RH6+TeALHBf3fU2w+JDzULc2I7D2/hVCVRH7aObztBcK2Ab4EKAqEIlCASkghDMLJ4PeBjUFwO1HsHVJtQk7BgfPYeDBl//aDcJ6X4poW5631VGMuKAO05VAAq9FAzErWi4LfruKmg+0HLSagXrE/7+0c47/nqMeCu64s3kXMUFPaMZ2kriUsDpK/xuhnBLGSHUsTUqs8gDaFlFXuevJVz2lc/uFGQAM7y+6+8xj2BoKhpjK9xkUMuhojcw39hk2AqaAoVH1KjWQi0+pqAW24UJM69bo15JpYM6ophYskrAtP0EP0YX1nkYnwZR0tIjKLxs8P8A8FHbhikdWeKsf3OV1/mfVXJeiLpJyGjhocFSD1EWIdzGj01R32olpJ6oeSt8up67a7kHD1n3XOPv277ZzPuqCuWZwQrDUV/XrM5F5LrEreaIRohbHqoqRAStIVQKnHg+hKSO2uP58Yd//JL3BspaGi6s4qlpsdaXdGvK8ZNR+4iysEIt33FTQV1IAVojSvK69OHnLXur6a0z37hJe6OFXc1PN6oC1Ybkm7dY63hc3HWsZEKRmODnSsxmcD1AJddpj0BTkgsjrPXymmte8VYnvn8WXssktzRUlxINOtVyWoq6DV91usevaZjY49g5DvyekzZHeH2B+QXMhziMo7mYHxLMSrsSc9T6wjSXRM61p11P3/8Nds/NeJgy+N8LOinirUU1hKf/oxgPQgYzVoGM5KRceR7fcbnR7h9AdmFDOfJSWFN9esgvNdTvKsQvPund8hEC/GlXQDmztrj49I9//A57qsq1iqKfl2ylkCv7rOeKjbSkEHdMYgtxYJi2DeYGUeWCdzMDsh2SNEdgpp2VgqpllSlJPzbqjv/waasIK/YSx2WvxSlefJzL3LgxDozDc1KU9KdlSzNKJZnQ7rzMavzgn7VMJqHYaoZeZBXLIWRGOnIhxa7GJMXGbZbQCZwU0FjiJRDe4JwxdL+eOCekr6QUoojTEsX614sS55+6KxNjq9TTxUXm5qVumKppVieDViZ16w0fQZzJcMFGLY8htKjqOdkQzCxIyvAlAo7YykubAFmY+xRTT419A1IF2DOwn5f0baKtpXs/dERfq2Q9wopDipBaKy9WFpx5osv2veEgmGsGMSCjZpmvQ69xKdfE6zXAsbzgmFLMKpCtiGxiaUsS8y+kHFnDEphZg1FF7ACl4+wx0KKHtDpXCZH2xCOoNaA+QjmpWKfUewVihaCVAgCZVFK4gJJEQpGFcFmRdBvSjZqIesVwaAZMW5YhrGjmFcMNkpsVVEGhtJITGgphhLbsuTbgGYTl4wpjMD1etADhmCnVn0HsvugfxrkASi1wcSKgRDMCEcqJaH2UNpCJCgriix1jFKPfkMxjAKyBclAG0wDxqEm146iBWbksB7kpcO1KmR2CF2gGGG3AZfWcUvgMnAJuHugvGyXdCCOQLU+eb/Uqh71miIpJUkoCYXDqypcoBBVQdHyGDcjxg1N5hlMXTD2FIUwmKqlGEnsnE/+5iVh3gm40ns74F1QdoBT4K7UzsV9UGmDthE1rYlSjR8pvMwQxwEqFbhEYGcEpe9jW4rCCRyWMjGUmcDtD8gul4cHxhSdHnTBbYDdBjwBbOyYmlzVvfMohBF4pkqofIKaRYceXsUhIx9RGHTFh5ai9H3IczBbDo7HMJTYd0Tk3eFkyFSMsEcj8k4POr1JDvpgpwGubv2+6gvyNPjLILsQHAKxXMXfHyHXSvy4jhAjRBhOkj9k8iBXCgMwrZpPdiZrV8Fsu/jcFMBdOfoW7G348RD59w6eraOCEM8ZVJvJW7pSgXMZej6gXMrQSUkJb3dxu910JyBmZx5eCrlnt6HfqZ/chj88jXygDb/o4++xyDvr8Ac1GRYoO9lTOoQVk4N29sSTnUmoE3C3Q3GC/4R6p4vbkJ+FAnY3KQFgMcS9AvbpDnyoRv6GxJ7swdGE/O6EPFdYI3GFwuYj7GFHdiycFMyfO7gh2E9AXtuCnKZLIeF/HJI9Dl4G8hiIB9rwqwHeG1VUfev/+iXrOz0oBW5zDftRKDrANuSlbk6DBPg3vtO3svqbCX0AAAAASUVORK5CYII="}),R.jsx("filter",{id:"alpha",filterUnits:"objectBoundingBox",x:"0%",y:"0%",width:"100%",height:"100%",children:R.jsx("feColorMatrix",{type:"matrix",in:"SourceGraphic",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"})}),R.jsx("image",{id:"image170",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACtklEQVRYhWNgGAWjYBSMglEwCkYcmGslLagZ26TedkTUMOD/H11nY2a5Sb+/sJBiBiOtHMfAwMCg73JCaNrNdN2kh/eF0eXKFXf+qZBhvfbqqMkdYsxior7zGBjUK65yXtwsbBq4/7wDNkcyMDAwdN53ZxE87KQX4tNtRIyZVA1Rc3M7ZpZn5eoNd1lVc1hCmInVJ7ov4fwRl0n38amhWoiyP3kmPbfVyfXNw0gNUhzJwMDA8D/3q1bnt2a8bqE4RFPWPhRMLPDTwxXFxIKtN84cUdFSe4VLnuwQhaVDmbBtjpQ6koGBgWHPo6d8+ORJKiIYGBDp0CgsQTXM4Dczw+9y8l2HBB4kJFEv6p2NmeVYi1m170ewcVLmLEzw6HHhye/yjU9xyRMV9XaXNnLcmHTA9slpbhNaONLtgvpfZV5TnOmTgYGIEP3LGciWdPSB/QmDu7zUcxoquNv66c6fWoZL+NQQDNFwZysdWjpS8mnzhzsL664RUoc3M9ld2sixVWiFvBz13IUC2HjqXtzv4z+jcCf/DyG1eKOeb66bnGTiCRPqOQ0Ccpjzvq3gTr5y9IviE2L14I163YZ8HsqdhQDP3hn9vf8m5tq3r+y7SHEkAwOBqH/ncPYvZU6DgEjWToYZ/8UefWbsusrwd9p3ckpevCEqdNL9E5lug4N58opvn6zy2v/iX/AZhr8nv5NrDl6H7vx0/ZXyhqBf5BisuOLXdxnTr2esH188OCdY/j15zkMAguUoX8haFclViXrEGvjsndHfn/+0bjbzSN4q56r9R5nzEICoKlQvzsrk54IreEspWDp8wdh1lZIoxgWIrusrJBTVpl6R15QSOofR1qzc+eH1kW+Pr1AjiqkCJv3+wuJszCwnwaeq23ZE1JC9Q0ktq+09/0C7axSMglEwCkbBKKA/AABq8ekilgplTAAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask0",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("use",{xlinkHref:"#image170"})})}),R.jsx("image",{id:"image125",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEF0lEQVRYhe2WTYscVRSGn3NvVXdPzySabwQN2SlGkQgjCC4EFWMU/A+CG925EhN0JSiof8BtxC8SSVZZiK7MRjRElPwEF8Ik0z3d9XXPOS6qJhM1pHucGXHRLxRFN9Sth/d977kFCy200EILLfR/kvwXL/n69NFvs6Y56MmGjUIlsU55TK9998eT866xp6DfvHTkcm9Snop1epBkqDuNQulCHWNT9Xq/s5FOv/7rxo1Za2V7AXjhzLEv+pPy5ODm+KSoSlQDdZI5GCQVCtdcKzuuw/5V4MCsNXfV0S9feeD8YKM4vlKVq5J0kJsR3Ajq4JAcygSjBOMkbEhEl3Ky+5dGb/6wdt+91t41Ry8+f+jS8tr6M3nTHNwEjO5EBxdwQFwIAcBxcxSjqY1Q6vKs9XcMevHMka+WxtPV/mh8IqiSWwcISJdXCIFkYIB5+5/jaHJSdIJa3DPQCy8f+3w4nj7auzl6PDYq0YzMncwcCYBDkIAByaAxaBxq2/pdG6iC2ez3bRv0dg/X1p8KSfu5GcGMgBMFEBAEFyG1ewg1qB3qBJVCqU6lLbDOCbEt0AvPHbyyf219Nd7Rw+BOJrQOGnjnYrfRW/e8A0zOVJ0iQaFQK7hu1WHHoJ+9ePTKynjy8HC0cSIzpff3HhpICLc7qNbu8Mah0TbmonEKc6YJxg1MGiikBWiH1g5Bz79w7Pul9Y3Hsro+nJkykLv38E4HN11sNmO21sVJgo0E0wSlQQpCiELMg+4Y1CfFQxTN4dyULBhBWhfv1sOmm5W1Qp2c0pxSaSEVyqaNfCqCBSH2I/kg03wQZ87ze4J++uzhn8NocsJUMTcQcAOTgPtfY07eRlwlpzYo7ujitLuXBjWCx0DWjwxX8rRvf+5vXV3r7Qg01WlfXVmM6m2sgAQB6SB9K+5aodqMWWHadIDWXgnBsoDkgf4g08Ew0+u/jT++DO/MgpwJqrUNK3OkcfIAwQR1QLbibiHbmKvOvYlCqVAZ1CZoDHge6PWi5ctZWh5mcvanW/15AOcCTU5UBVOQbozkAuCdm23MlbbRFtqe5UWCMggmAoNA7EUfLGVpaZhx7tr6tgDnArUQaFyoVUjm1Or0usPuzsgLawHL7rSpRPAQyHqRwXKWloaZvXt99K8A5wINecg0hFQgWZmEQpzYQOiiT9qC1d7GnOSfPfzlxviDS8Z7O4GEOT7z3n9i/6hcr/bV0wZJRugect8aRykIEgOSBXr9aPnwdg9n7uZdA3018MapR1Y+KTaaflMlUmrnknePexQkD/Ty6P1hloZLkXPX1ncNcG5QgI+ePlSMxrVURerVlYl3oCEIsRfo92MaDqKf3QPAbYFu6sPVA1XdKEk9OEgWxXt54O0fb+V7BbjQQgsttNBC/0/9CbvrotNPsOneAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image142",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAAmklEQVRYhe2U0QqAIBAE1/7/n+tFIaQyur21aAdEX4RhDgWMMemUul7BkciZ3JopMqKXGhWcJltOzldMkS3dfhe5bOTBSGWXwF3pjxARBYSyUVFAJMsQBQSyLNF0mKKpVdlF02R/OfpGStWsonTZX4++Qa3qohVaVRfdQanqoh3hqi7KRikaGr+LslGLPh6/i7KxKBuLsvmM6AZK+AVU/UCtAQAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask1",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.6,stroke:"none"}})})}),R.jsx("image",{id:"image148",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEI0lEQVRYhe3XTW4kuREF4I9kZqX+7B61gAFGR5CWPsucZ9zn6Sv4Ct5ZfQAv1IABuaftaUlVmWR4kZS6tPKitBjDegCRZBaT9RA/Lxi84Q1veMMbDkF6msTTPPChz28kP+NTX99+3/+MSwGuhI+47utfhETS169BNEgvCF5JPkluJZeSO8lF/+3rHtl3ncSdcCHcCpfCjXAtXpPs8ILkjeRa8kVyJ7uUkE0SknvJuz2idzgWJg3hUkNzLlxpPiBEJOlQsilI/txJnu+RI7tXJPl5TJKtZJaMwiRshdCE5lhF8141aT4LNL+IlA4jml+QnGRfFQwejE6Mso1qMplwpDl2tj6POTKZVJNs49GIwd8NPituJVfSc0gdgAFcd9d+lb1T/GpwrPhmlAyKwaKoiiy7lxTxsNX626paDDJmZ9At/hd80Q4lmt30pCErsgdFMUg2Tm1kR5IjyYlwKpwa+zOcSk40xzbdst9sMLhXDD2Ufj6UJsOe/GRniq3BHwxmG4uNbFKMFhvJICua1L+omA3mHsfJpsflieY3zZ32LG8HEf0keS/5Z0+gSTEbVWNfTZpJ6cRDUSRNqKowS7bmrh5VM/dwyKqLZ48dSPR2T3pWCsXOIPdEaibVUSe9urVKslAsmkHuKlBVG7MHA93Kt3KXrQOJ/gnfJA/dootiUIRBMqg2hp75q2WH7vjAIssDbVlUYbE1SP2cU0k93Jor0c/doqw2mCRNlrtMMQijbBRGYUDWRElSJRYWydzTsXhUjJLHfu7d4WTz8+xYspEsUo/B78KvOzo6kbyGSE2KppT9fbV/v3StuH8di+b/vuX3ge9EH4SdMAhVyF1mnsYabVXrI9QSa2bX/X2lfz8Ij8LJ69yesp+EP/bDRmHutbuqWDzFXzMXdpoZO9murlV/HWHp9WmVplk46udevMLtyV+td8roFhlUO1W2CItit+a2VJNQ1C74a9aHnWRnsFN7mZi79R+Ef4leUg8keim8F/4h/KiiShbVjNKTg6RZVHlP8Jsqm4WtpRN+tGiq0ndcam5fw6JXwifhx27RrWoy00siqxgtandz2RP8JptVs9HWbKeYHVlQewmN5y7gIKIfcd4vvb+piuTfXU/HnhBh0SxjUebaLVp7smXLJsy7MCt2dmajxb2qai6Eq9cguvY4659WyZnqV0kI30SX/8Fonmu/SDdPJaIJdRe95ofFqRmLE9Vd99LHQ2k+ydNN73cWzVfVD6sFLXaKrerR4MHkXnP/4jl4UD0abTU7T0qxhlF77p8OxP9QK8La2l6LfhNvflLdqU7Mjs0WO5Ote1uTrTOPJlt3/f1i57i7nMXfNOf9rN6JHoohWbtEIXwA4Vzq7W9yqdlKziQnXrbLT0K+Fc722uUvXUleubd/wxve8IY3/B/gP+5/MI8x65+AAAAAAElFTkSuQmCC"}),R.jsx("mask",{id:"mask2",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.701961,stroke:"none"}})})}),R.jsx("image",{id:"image154",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAA/ElEQVRYhe2VwW7DIAxAn9M0qcSN///G3JDaFEIPwRvqoUHdWKXJT/IhMokeNiZgGIZhGIZh/EPkVTLnLGWNxvD0Ti6xAVlEtk6eDA1rBDgBZ2ACZu/9DMzleSz5lm+9zVFFh0pyrELYK5m89/dlWSIQRWT9lOipiE1VnCvRCKwaInLtJXrULj2Xdesn4EJpvXPuT1o/NqxR2Vp4YB+gLYSgki+781PeqUL+dYsGWkT1+tmAxH4uNZJzLpVc1w0ctV4lE3Dne4i+himEEEu+2x0KxxV9Fr0B1ypu3vuVvbpdRVv+TDpEGvXmdBMJ2EQkdvI0DMMwDMMwjI/yAInrT4nWGUiJAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image160",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("mask",{id:"mask3",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.2,stroke:"none"}})})}),R.jsx("image",{id:"image166",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("clipPath",{id:"clip2",children:R.jsx("rect",{x:0,y:0,width:42,height:42})}),R.jsxs("g",{id:"surface169",clipPath:"url(#clip2)",children:[R.jsx("use",{xlinkHref:"#image125"}),R.jsx("use",{xlinkHref:"#image142"}),R.jsx("use",{xlinkHref:"#image148",mask:"url(#mask1)"}),R.jsx("use",{xlinkHref:"#image154",mask:"url(#mask2)"}),R.jsx("use",{xlinkHref:"#image160"}),R.jsx("use",{xlinkHref:"#image166",mask:"url(#mask3)"})]})]}),R.jsx("g",{id:"surface1",children:R.jsxs("g",{clipPath:"url(#clip1)",clipRule:"nonzero",children:[R.jsx("path",{style:{stroke:"none",fillRule:"nonzero",fill:"url(#radial0)"},d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "}),R.jsx("use",{xlinkHref:"#image42"}),R.jsx("use",{xlinkHref:"#image91"}),R.jsx("use",{xlinkHref:"#surface169",mask:"url(#mask0)"})]})})]}),t9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",id:"Ebene_2","data-name":"Ebene 2",viewBox:"0 0 314.29 111.66",width:e,height:e,...n,children:[R.jsx("defs",{children:R.jsx("style",{children:".cls-1{fill:#fff;stroke-width:0}"})}),R.jsxs("g",{id:"Ebene_1-2","data-name":"Ebene 1",children:[R.jsx("path",{d:"M118.13 0c-8.69-.1-16.81 2.21-23.8 6.26-2.57 1.49-3.29 4.91-1.55 7.33 3.44 4.8 6.15 10.15 7.97 15.9 1.01 3.2 4.82 4.23 7.65 2.43 3.55-2.25 7.97-3.25 12.67-2.33 6.53 1.27 11.95 6.44 13.44 12.93 2.61 11.39-5.97 21.5-16.91 21.5-3.41 0-6.58-.99-9.24-2.7-2.82-1.8-6.61-.66-7.63 2.53-4.48 14.04-14.26 25.71-27.02 32.66-1.67.91-2.75 2.6-2.75 4.5v5.58c0 2.8 2.27 5.07 5.07 5.07h19.13c2.8 0 5.07-2.27 5.07-5.07v-9.76c0-3.35 3.16-5.67 6.42-4.87 3.52.86 7.18 1.32 10.96 1.32 26.19 0 47.34-21.59 46.62-47.95C163.55 20.67 142.8.28 118.13 0Z",style:{fill:"#ff7900",strokeWidth:0}}),R.jsx("path",{d:"M46.64 0C20.88 0 0 20.88 0 46.64s20.88 46.64 46.64 46.64S93.28 72.4 93.28 46.64 72.4 0 46.64 0Zm0 64.03c-9.6 0-17.38-7.78-17.38-17.39s7.78-17.39 17.38-17.39 17.39 7.78 17.39 17.39-7.78 17.39-17.39 17.39ZM188.46 41.7l20.14 33.14h11.26V18.5h-13.02v34.05L185.9 18.5h-10.38v56.34h12.94V41.7zM265.74 63.57h-24.29V51.9h15.46V40.8h-15.46V29.77h24.29V18.5h-37.88v56.34h37.88V63.57zM286.16 74.84h14.06V29.77h14.07V18.5H272.1v11.27h14.06v45.07z",className:"cls-1"})]})]}),r9=({size:e,className:t,variant:r,walletName:n})=>n===ri?R.jsx(X$,{size:e,className:t,variant:r}):n===vs?R.jsx(Y$,{size:e,className:t,variant:r}):n===bs?R.jsx(Xb,{size:e,className:t,variant:r}):n===ni?R.jsx(Q$,{size:e,className:t,variant:r}):n===ms?R.jsx(Z$,{size:e,className:t,variant:r}):n===Ki?R.jsx(G$,{size:e,className:t,variant:r}):n===Hi?R.jsx(J$,{size:e,className:t,variant:r}):n===ws?R.jsx(q$,{size:e,className:t,variant:r}):n===ji?R.jsx(e9,{size:e,className:t,variant:r}):n===Hg?R.jsx(t9,{size:e,className:t,variant:r}):R.jsx(Xb,{size:e,className:t,variant:r});Y.FRACTAL_MAINNET=cs,Y.FRACTAL_TESTNET=Zt,Y.LEATHER=vi,Y.LEATHER_MAINNET=pc,Y.LEATHER_TESTNET=ih,Y.LOCAL_STORAGE_DEFAULT_WALLET=Ua,Y.LaserEyesClient=v5,Y.LaserEyesProvider=z$,Y.MAGIC_EDEN=Wn,Y.MAINNET=tt,Y.OKX=ns,Y.OKX_MAINNET=x0,Y.OKX_TESTNET=$0,Y.OP_NET=Ud,Y.OP_WALLET_MAINNET=p3,Y.OP_WALLET_TESTNET=y3,Y.ORANGE=Ei,Y.ORANGE_MAINNET=nh,Y.ORANGE_TESTNET=C0,Y.OYL=bi,Y.P2PKH=im,Y.P2PSH=sm,Y.P2SH=am,Y.P2TR=Na,Y.P2WPKH=fl,Y.P2WSH=om,Y.PHANTOM=mi,Y.REGTEST=g3,Y.SIGNET=Jt,Y.TESTNET=it,Y.TESTNET4=Yt,Y.UNISAT=Vn,Y.UNISAT_FRACTAL_MAINNET=Zl,Y.UNISAT_FRACTAL_TESTNET=Ql,Y.UNISAT_MAINNET=hc,Y.UNISAT_SIGNET=Yl,Y.UNISAT_TESTNET=Xl,Y.UNISAT_TESTNET4=Jl,Y.UNSUPPORTED_PROVIDER_METHOD_ERROR=Lr,Y.WALLETS=cm,Y.WALLET_NOT_INSTALLED_ERROR=I0,Y.WIZZ=is,Y.WIZZ_MAINNET=jo,Y.WIZZ_SIGNET=rh,Y.WIZZ_TESTNET=dc,Y.WIZZ_TESTNET4=th,Y.WalletIcon=r9,Y.WalletProvider=Cn,Y.XVERSE=Pn,Y.XVERSE_MAINNET=fc,Y.XVERSE_NETWORK=d3,Y.XVERSE_SIGNET=O0,Y.XVERSE_TESTNET=eh,Y.createConfig=P8,Y.createStores=k8,Y.getLeatherNetwork=w3,Y.getNetworkForLeather=v3,Y.getNetworkForOkx=N0,Y.getNetworkForUnisat=yc,Y.getNetworkForWizz=oh,Y.getNetworkForXverse=m3,Y.getOrangeNetwork=Do,Y.getSatsConnectNetwork=Ms,Y.getUnisatNetwork=sh,Y.getWizzNetwork=b3,Y.useLaserEyes=M$,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});