@bwalletx/connect 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +175 -2
- package/dist/bwalletx-connect.global.js +8 -0
- package/dist/bwalletx-connect.global.js.map +1 -0
- package/dist/index.cjs +526 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +486 -0
- package/dist/index.js.map +1 -0
- package/dist/server.cjs +150 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +64 -0
- package/dist/server.d.ts +64 -0
- package/dist/server.js +118 -0
- package/dist/server.js.map +1 -0
- package/package.json +70 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The Bitcoin Corporation Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,176 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bwalletx/connect
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Add "Sign in with bWalletX" to a website.
|
|
4
|
+
|
|
5
|
+
The user's wallet signs a one-time challenge from your server with a key derived from its identity key. Your server checks the signature and signs the user in as that identity key. You don't need an API key or an account with us, and nothing passes through bwalletx.com. The only service of ours involved is the encrypted pairing relay (`relay.bwallet.space`), and only when the user signs in from a phone or the web wallet.
|
|
6
|
+
|
|
7
|
+
The full protocol is described at https://bwalletx.com/connect.md. This package is the same code, packaged.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @bwalletx/connect @bsv/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`@bsv/sdk` (2.2 or later, 2.x or 3.x) is a peer dependency.
|
|
16
|
+
|
|
17
|
+
## Server
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createChallenge, verifySignIn, originAllowed, memoryStore } from '@bwalletx/connect/server';
|
|
21
|
+
|
|
22
|
+
const ORIGIN = 'https://example.com'; // your site, from config. Never from the request.
|
|
23
|
+
const store = memoryStore(); // dev only. See "Nonce store" below.
|
|
24
|
+
|
|
25
|
+
// POST /auth/bwalletx/challenge body: { identityKey }
|
|
26
|
+
app.post('/auth/bwalletx/challenge', async (req, res) => {
|
|
27
|
+
if (!originAllowed(req.get('origin'), ORIGIN)) return res.status(403).end();
|
|
28
|
+
try {
|
|
29
|
+
res.json(await createChallenge({ origin: ORIGIN, identityKey: req.body?.identityKey, store }));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
res.status(400).json({ error: (e as Error).message });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// POST /auth/bwalletx/verify body: { identityKey, nonce, signature }
|
|
36
|
+
app.post('/auth/bwalletx/verify', async (req, res) => {
|
|
37
|
+
if (!originAllowed(req.get('origin'), ORIGIN)) return res.status(403).end();
|
|
38
|
+
const identityKey = await verifySignIn({ origin: ORIGIN, store, ...req.body });
|
|
39
|
+
if (!identityKey) return res.status(401).json({ error: 'That signature was not accepted. Start again.' });
|
|
40
|
+
// Find or create the user keyed on identityKey, then start your own session.
|
|
41
|
+
res.json({ identityKey });
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`verifySignIn` returns the identity key (66 lowercase hex characters) or `null`. It refuses a nonce that was already used, has expired (2 minutes), was issued for another origin or another identity key, or whose signature doesn't verify.
|
|
46
|
+
|
|
47
|
+
The text the wallet signs:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Sign in to example.com with bWallet
|
|
51
|
+
|
|
52
|
+
This proves you hold this wallet. It does not spend anything.
|
|
53
|
+
|
|
54
|
+
Origin: https://example.com
|
|
55
|
+
Nonce: <nonce>
|
|
56
|
+
Expires: <ISO time>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
It is signed with BRC-100 `createSignature`, protocol `[2, 'bwallet sign in']`, keyID = the nonce, counterparty `'anyone'`. bChat and bit-sign use the same format.
|
|
60
|
+
|
|
61
|
+
### Nonce store
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
interface NonceStore {
|
|
65
|
+
put(nonce: string, c: PendingChallenge): Promise<void> | void;
|
|
66
|
+
take(nonce: string): Promise<PendingChallenge | null> | PendingChallenge | null; // read AND delete
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`take` must read and delete in one step. `verifySignIn` calls it before checking anything else, so each nonce gets exactly one attempt.
|
|
71
|
+
|
|
72
|
+
`memoryStore()` keeps challenges in the process. It is lost on restart and isn't shared between processes or serverless instances, so it prints a warning the first time it is used. If you leave out `store`, a shared in-memory store is used and you get the same warning. In production, use Redis (`GETDEL`) or a database row you delete with `DELETE ... RETURNING`.
|
|
73
|
+
|
|
74
|
+
Also rate-limit the challenge route per IP. It is unauthenticated.
|
|
75
|
+
|
|
76
|
+
## Browser
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { signInWithBwalletX, renderButton } from '@bwalletx/connect';
|
|
80
|
+
import QRCode from 'qrcode'; // any QR library
|
|
81
|
+
|
|
82
|
+
const panel = document.getElementById('bwx-pair')!;
|
|
83
|
+
|
|
84
|
+
renderButton('#bwx-button', {
|
|
85
|
+
onClick: async (button) => {
|
|
86
|
+
button.disabled = true;
|
|
87
|
+
try {
|
|
88
|
+
const r = await signInWithBwalletX({
|
|
89
|
+
challenge: (identityKey) => post('/auth/bwalletx/challenge', { identityKey }),
|
|
90
|
+
pairing: {
|
|
91
|
+
onLink: async (link) => {
|
|
92
|
+
panel.innerHTML = `<img src="${await QRCode.toDataURL(link)}" alt="Scan with bWalletX">`;
|
|
93
|
+
},
|
|
94
|
+
onCode: (code) => panel.append(`Check bWalletX shows ${code}, then tap Connect.`),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
await post('/auth/bwalletx/verify', { identityKey: r.identityKey, nonce: r.nonce, signature: r.signature });
|
|
98
|
+
// r.method is 'extension', 'in-app' or 'pairing'
|
|
99
|
+
} finally {
|
|
100
|
+
button.disabled = false;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
async function post(url: string, body: unknown) {
|
|
106
|
+
const res = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
107
|
+
if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error ?? `HTTP ${res.status}`);
|
|
108
|
+
return res.json();
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`signInWithBwalletX` finds a wallet in this order:
|
|
113
|
+
|
|
114
|
+
1. The bWalletX Chrome extension: BRC-100 discovery, `rdns` `com.bwalletx.extension`. Gives `method: 'extension'`.
|
|
115
|
+
2. The bWalletX app's in-app browser: `rdns` `space.bwallet.mobile`, or `window.CWI` if nothing announced. Gives `method: 'in-app'`. Note that `window.CWI` can also be set by another wallet.
|
|
116
|
+
3. A pairing stored by an earlier sign-in on this browser (`reusePairing`, default on).
|
|
117
|
+
4. A new pairing, if you passed `pairing`. Show the link as a QR code for the phone, and as text the user can paste into web.bwalletx.com. Both screens show the same 4-digit code. Gives `method: 'pairing'`.
|
|
118
|
+
|
|
119
|
+
If none of these works, it throws an error with `code: 'NOT_FOUND'`.
|
|
120
|
+
|
|
121
|
+
It returns `{ identityKey, signature, nonce, method, wallet }`. Post the first three to your verify route. `wallet` is a BRC-100 `WalletInterface` you can keep using.
|
|
122
|
+
|
|
123
|
+
### Lower-level pieces
|
|
124
|
+
|
|
125
|
+
| Export | What it does |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `findBwalletX(ms?)` | The extension or in-app wallet, or `null`. |
|
|
128
|
+
| `discoverBwalletX(ms?)` | The same, plus `method` and `rdns`. |
|
|
129
|
+
| `pairBwalletX({ onLink, onCode, storage?, signal?, socket?, origin?, relay? })` | Pair over the relay. Resolves with a wallet when the user taps Connect. |
|
|
130
|
+
| `restorePairing({ storage? })` | The wallet from a stored pairing, or `null`. It connects on the first call. |
|
|
131
|
+
| `clearPairing()` | Delete the stored pairing without telling the wallet. |
|
|
132
|
+
| `wallet.close()` / `wallet.forget()` | On a paired wallet: close the socket, or unpair and delete it. |
|
|
133
|
+
| `connectBwalletX(opts)` | The wallet-finding half of `signInWithBwalletX`. |
|
|
134
|
+
| `renderButton(el, { onClick?, subtitle? })` | Draws the gold button into `el`. |
|
|
135
|
+
| `inOrder(handler)` | Wraps an async WebSocket handler so frames run one at a time, in order. |
|
|
136
|
+
|
|
137
|
+
### Pairing storage
|
|
138
|
+
|
|
139
|
+
The pairing is saved under `bwalletx.connect.pairing.v1` in `localStorage` by default. It holds a random pairing key (not a wallet key), the wallet's pairing public key, the channel, and the message counters. To store it elsewhere, pass `storage` (anything with `getItem`, `setItem` and `removeItem`, sync or async). Pass `storage: null` to keep it in memory only.
|
|
140
|
+
|
|
141
|
+
### Frame order
|
|
142
|
+
|
|
143
|
+
The phone sends a plain `hello` and then, as soon as the user taps Connect, an encrypted `ready`. An async `onmessage` handler that is still deriving the key from `hello` when `ready` arrives drops `ready`, and pairing never finishes. This package handles frames one at a time in arrival order (`inOrder`). `test/pair.test.ts` reproduces the race.
|
|
144
|
+
|
|
145
|
+
## One script tag
|
|
146
|
+
|
|
147
|
+
```html
|
|
148
|
+
<script src="https://unpkg.com/@bwalletx/connect/dist/bwalletx-connect.global.js"></script>
|
|
149
|
+
<script>
|
|
150
|
+
const { signInWithBwalletX, renderButton } = window.bWalletXConnect;
|
|
151
|
+
</script>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
This build includes `@bsv/sdk` (about 125 KB minified). The server functions are not in it.
|
|
155
|
+
|
|
156
|
+
## Limits
|
|
157
|
+
|
|
158
|
+
- You get the identity key and nothing else: no handle, paymail or name.
|
|
159
|
+
- The identity key is the same on every site that uses this method, so two sites can tell it is the same wallet.
|
|
160
|
+
- `relay.bwallet.space` is run by The Bitcoin Corporation. It has no published uptime guarantee and allows about 60 frames a minute per channel.
|
|
161
|
+
- There is no hosted sign-in page or OAuth-style redirect. You run the two routes yourself.
|
|
162
|
+
|
|
163
|
+
## Testing
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
pnpm test # unit tests: challenge/verify, frame order, reload, sign-in paths
|
|
167
|
+
pnpm test:live # pairs with a simulated phone over the real relay.bwallet.space
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
To test your own server without a wallet, sign with `new ProtoWallet(PrivateKey.fromRandom()).createSignature(...)` using the same arguments. That is the signature bWalletX makes.
|
|
171
|
+
|
|
172
|
+
`src/protocol.ts` is copied unchanged from bWalletX `src/pair/protocol.ts`. Don't edit it; the app must understand every byte.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";var bWalletXConnect=(()=>{var ct=Object.defineProperty;var Vr=Object.getOwnPropertyDescriptor;var Gr=Object.getOwnPropertyNames;var $r=Object.prototype.hasOwnProperty;var Rn=r=>{throw TypeError(r)};var Yr=(r,e,t)=>e in r?ct(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var jr=(r,e)=>{for(var t in e)ct(r,t,{get:e[t],enumerable:!0})},Jr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gr(e))!$r.call(r,i)&&i!==t&&ct(r,i,{get:()=>e[i],enumerable:!(n=Vr(e,i))||n.enumerable});return r};var Qr=r=>Jr(ct({},"__esModule",{value:!0}),r);var b=(r,e,t)=>Yr(r,typeof e!="symbol"?e+"":e,t),Dt=(r,e,t)=>e.has(r)||Rn("Cannot "+t);var p=(r,e,t)=>(Dt(r,e,"read from private field"),t?t.call(r):e.get(r)),C=(r,e,t)=>e.has(r)?Rn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),I=(r,e,t,n)=>(Dt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),h=(r,e,t)=>(Dt(r,e,"access private method"),t);var Ns={};jr(Ns,{BWALLETX_RDNS:()=>Kt,LOGIN_PROTOCOL:()=>An,LOGO_URL:()=>Nn,RDNS_EXTENSION:()=>at,RDNS_MOBILE:()=>Zt,clearPairing:()=>qr,connectBwalletX:()=>Bn,discoverBwalletX:()=>Ce,findBwalletX:()=>kn,inOrder:()=>rt,pairBwalletX:()=>Ot,renderButton:()=>Zr,restorePairing:()=>zt,signInWithBwalletX:()=>Dr});var at="com.bwalletx.extension",Zt="space.bwallet.mobile",Kt=[at,Zt];function Ce(r=1200){return typeof window>"u"?Promise.resolve(null):new Promise(e=>{let t=!1,n=s=>{t||(t=!0,window.removeEventListener("brc100:announceWallet",i),e(s))},i=s=>{let o=s.detail,c=o?.info?.rdns??"";o?.wallet&&Kt.includes(c)&&n({wallet:o.wallet,method:c===at?"extension":"in-app",rdns:c})};window.addEventListener("brc100:announceWallet",i),window.dispatchEvent(new Event("brc100:requestWallet")),setTimeout(()=>{let s=window.CWI;n(s?{wallet:s,method:"in-app",rdns:null}:null)},r)})}async function kn(r=1200){return(await Ce(r))?.wallet??null}var Vt=globalThis.Buffer,ei=Vt!=null&&typeof Vt.from=="function",Fe=new Int8Array(256).fill(-1);for(let r=0;r<10;r++)Fe[48+r]=r;for(let r=0;r<6;r++)Fe[65+r]=10+r,Fe[97+r]=10+r;var We,Xe,dt,ht,se,lt,qe,x,E,R,d,Tn,Ln,Pn,Hn,Un,Cn,Gt,K,j,A,_n,_e,Oe,On,zn,be,Fn,Wn,Xn,L,_,ze,ft,ue,$t,qn,Yt,v=class v{constructor(e=0,t=10,n="be"){C(this,d);C(this,x,0n);C(this,E,0);C(this,R,1);b(this,"red",null);if(e??(e=0),typeof e=="bigint"){h(this,d,K).call(this,e<0n?-e:e,e<0n?1:0),this.normSign();return}let i=t==="le"||t==="be",s=i?10:t,o=i?t:n;if(typeof e=="number"){h(this,d,_n).call(this,e,o);return}if(Array.isArray(e)){h(this,d,_e).call(this,e,o);return}if(typeof e=="string"){h(this,d,Ln).call(this,e,s,o);return}e!==0?h(this,d,A).call(this,!1,"Unsupported input type for BigNumber constructor"):h(this,d,K).call(this,0n,0)}get negative(){return p(this,E)}set negative(e){h(this,d,A).call(this,e===0||e===1,"Negative property must be 0 or 1");let t=e===1?1:0;p(this,x)===0n?I(this,E,0):I(this,E,t)}get words(){if(!Number.isSafeInteger(p(this,R))||p(this,R)<1||p(this,R)>p(v,qe))throw new Error("BigNumber word length exceeds the supported limit");let e=p(this,d,Tn);if(p(this,R)<=e.length)return e;let t=Array.from({length:p(this,R)}).fill(0);for(let n=0;n<e.length;n++)t[n]=e[n];return t}set words(e){let t=p(this,E),n=0n,i=e.length>0?e.length:1;for(let s=i-1;s>=0;s--){let o=e[s]??0;n=n<<p(v,We)|BigInt(o&Number(p(v,Xe)))}I(this,x,n),I(this,E,t),I(this,R,i),this.normSign()}get length(){return Math.max(1,p(this,R))}static isBN(e){return e instanceof v?!0:e!==null&&typeof e=="object"&&e.constructor?.wordSize===v.wordSize&&Array.isArray(e.words)}static max(e,t){return e.cmp(t)>0?e:t}static min(e,t){return e.cmp(t)<0?e:t}copy(e){I(e,x,p(this,x)),I(e,E,p(this,E)),I(e,R,p(this,R)),e.red=this.red}static move(e,t){I(e,x,p(t,x)),I(e,E,p(t,E)),I(e,R,p(t,R)),e.red=t.red}clone(){let e=new v(0n);return this.copy(e),e}expand(e){return h(this,d,A).call(this,Number.isSafeInteger(e)&&e>=0&&e<=p(v,qe),"Expand size must be a non-negative safe integer within the supported word limit"),I(this,R,Math.max(p(this,R),e,1)),this}strip(){return h(this,d,j).call(this),this.normSign()}normSign(){return p(this,x)===0n&&I(this,E,0),this}inspect(){return(this.red===null?"<BN: ":"<BN-R: ")+this.toString(16)+">"}toString(e=10,t=1){if(e===16||e==="hex")return h(this,d,On).call(this,t);if(typeof e!="number"||e<2||e>36||e%1!==0)throw new Error("Base should be an integer between 2 and 36");return h(this,d,zn).call(this,e,t)}toNumber(){let e=h(this,d,L).call(this);if(e>p(v,dt)||e<p(v,ht))throw new Error("Number can only safely store up to 53 bits");return Number(e)}toBigInt(){return h(this,d,L).call(this)}toJSON(){let e=h(this,d,Oe).call(this);return(this.isNeg()?"-":"")+e}toArray(e="be",t){this.strip();let n=this.byteLength(),i=t??Math.max(1,n);h(this,d,A).call(this,n<=i,"byte array longer than desired length"),h(this,d,A).call(this,i>0,"Requested array length <= 0");let s=Array.from({length:i}).fill(0);return p(this,x)===0n&&i>0?s:p(this,x)===0n&&i===0?[]:(h(this,d,Xn).call(this,s,e==="le"),s)}bitLength(){return p(this,x)===0n?0:p(this,x).toString(2).length}static toBitArray(e){let t=e.bitLength();if(t===0)return[];let n=Array.from({length:t}),i=p(e,x);for(let s=0;s<t;s++)n[s]=(i>>BigInt(s)&1n)===0n?0:1;return n}toBitArray(){return v.toBitArray(this)}zeroBits(){if(p(this,x)===0n)return 0;let e=0,t=p(this,x);for(;(t&1n)===0n&&t!==0n;)e++,t>>=1n;return e}byteLength(){return p(this,x)===0n?0:Math.ceil(this.bitLength()/8)}toTwos(e){var o;h(this,d,A).call(this,e>=0);let t=BigInt(e),n=h(this,d,L).call(this);p(this,E)===1&&p(this,x)!==0n&&(n=(1n<<t)+n);let i=(1n<<t)-1n;n&=i;let s=new v(0n);return h(o=s,d,K).call(o,n,0),s}fromTwos(e){var i;h(this,d,A).call(this,e>=0);let t=BigInt(e),n=p(this,x);if(e>0&&(n>>t-1n&1n)!==0n&&p(this,E)===0){let s=n-(1n<<t),o=new v(0n);return h(i=o,d,_).call(i,s),o}return this.clone()}isNeg(){return p(this,E)===1&&p(this,x)!==0n}neg(){return this.clone().ineg()}ineg(){return p(this,x)!==0n&&I(this,E,p(this,E)===1?0:1),this}iuor(e){return h(this,d,ze).call(this,e,(t,n)=>t|n)}iuand(e){return h(this,d,ze).call(this,e,(t,n)=>t&n)}iuxor(e){return h(this,d,ze).call(this,e,(t,n)=>t^n,!0)}ior(e){return h(this,d,ft).call(this,e,(t,n)=>t|n)}iand(e){return h(this,d,ft).call(this,e,(t,n)=>t&n)}ixor(e){return h(this,d,ft).call(this,e,(t,n)=>t^n,!0)}or(e){return h(this,d,A).call(this,p(this,E)===0&&p(e,E)===0),h(this,d,ue).call(this,e,"iuor")}uor(e){return h(this,d,ue).call(this,e,"iuor")}and(e){return h(this,d,A).call(this,p(this,E)===0&&p(e,E)===0),h(this,d,ue).call(this,e,"iuand")}uand(e){return h(this,d,ue).call(this,e,"iuand")}xor(e){return h(this,d,A).call(this,p(this,E)===0&&p(e,E)===0),h(this,d,ue).call(this,e,"iuxor")}uxor(e){return h(this,d,ue).call(this,e,"iuxor")}inotn(e){h(this,d,A).call(this,typeof e=="number"&&e>=0);let n=(1n<<BigInt(e))-1n;I(this,x,~p(this,x)&n);let i=e===0?1:Math.ceil(e/v.wordSize);return I(this,R,Math.max(1,i)),this.strip(),I(this,R,Math.max(p(this,R),Math.max(1,i))),this}notn(e){return this.clone().inotn(e)}setn(e,t){h(this,d,A).call(this,typeof e=="number"&&e>=0);let n=BigInt(e);t===1||t===!0?I(this,x,p(this,x)|1n<<n):I(this,x,p(this,x)&~(1n<<n));let i=Math.floor(e/v.wordSize)+1;return I(this,R,Math.max(p(this,R),i)),h(this,d,j).call(this),this.strip()}iadd(e){var t;return h(this,d,_).call(this,h(this,d,L).call(this)+h(t=e,d,L).call(t)),this}add(e){var n,i;let t=new v(0n);return h(i=t,d,_).call(i,h(this,d,L).call(this)+h(n=e,d,L).call(n)),t}isub(e){var t;return h(this,d,_).call(this,h(this,d,L).call(this)-h(t=e,d,L).call(t)),this}sub(e){var n,i;let t=new v(0n);return h(i=t,d,_).call(i,h(this,d,L).call(this)-h(n=e,d,L).call(n)),t}mul(e){let t=new v(0n);return I(t,x,p(this,x)*p(e,x)),I(t,E,p(t,x)===0n?0:p(this,E)^p(e,E)),I(t,R,this.length+e.length),t.red=null,t.normSign()}imul(e){return I(this,x,p(this,x)*p(e,x)),I(this,E,p(this,x)===0n?0:p(this,E)^p(e,E)),I(this,R,this.length+e.length),this.red=null,this.normSign()}imuln(e){return h(this,d,A).call(this,typeof e=="number","Assertion failed"),h(this,d,A).call(this,Math.abs(e)<=p(v,se),"Assertion failed"),h(this,d,_).call(this,h(this,d,L).call(this)*BigInt(e)),this}muln(e){return this.clone().imuln(e)}sqr(){let e=new v(0n);return I(e,x,p(this,x)*p(this,x)),I(e,E,0),I(e,R,this.length*2),e.red=null,e}isqr(){return I(this,x,p(this,x)*p(this,x)),I(this,E,0),I(this,R,this.length*2),this.red=null,this}pow(e){if(h(this,d,A).call(this,p(e,E)===0,"Exponent for pow must be non-negative"),e.isZero())return new v(1n);let t=new v(1n),n=this.clone(),i=e.clone(),s=n.isNeg(),o=i.isOdd();for(s&&n.ineg();!i.isZero();)i.isOdd()&&t.imul(n),n.isqr(),i.iushrn(1);return s&&o&&t.ineg(),t}iushln(e){var n;let t=h(n=v,be,$t).call(n,e,"Shift bits");return t===0n?this:(I(this,x,p(this,x)<<t),h(this,d,j).call(this),this.strip())}ishln(e){return h(this,d,A).call(this,p(this,E)===0,"ishln requires positive number"),this.iushln(e)}iushrn(e,t,n){var s,o,c;let i=h(s=v,be,$t).call(s,e,"Shift bits");if(i===0n)return n!=null&&h(o=n,d,K).call(o,0n,0),this;if(n!=null){let a=(1n<<i)-1n,f=p(this,x)&a;h(c=n,d,K).call(c,f,0)}return I(this,x,p(this,x)>>i),h(this,d,j).call(this),this.strip()}ishrn(e,t,n){return h(this,d,A).call(this,p(this,E)===0,"ishrn requires positive number"),this.iushrn(e,t,n)}shln(e){return this.clone().ishln(e)}ushln(e){return this.clone().iushln(e)}shrn(e){return this.clone().ishrn(e)}ushrn(e){return this.clone().iushrn(e)}testn(e){return h(this,d,A).call(this,typeof e=="number"&&e>=0),(p(this,x)>>BigInt(e)&1n)!==0n}imaskn(e){h(this,d,A).call(this,typeof e=="number"&&e>=0),h(this,d,A).call(this,p(this,E)===0,"imaskn works only with positive numbers");let t=BigInt(e),n=t===0n?0n:(1n<<t)-1n;I(this,x,p(this,x)&n);let i=e===0?1:Math.max(1,Math.ceil(e/v.wordSize));return I(this,R,i),h(this,d,j).call(this),I(this,R,Math.max(p(this,R),i)),this.strip()}maskn(e){return this.clone().imaskn(e)}iaddn(e){return h(this,d,A).call(this,typeof e=="number"),h(this,d,A).call(this,Math.abs(e)<=p(v,se),"num is too large"),h(this,d,_).call(this,h(this,d,L).call(this)+BigInt(e)),this}_iaddn(e){return this.iaddn(e)}isubn(e){return h(this,d,A).call(this,typeof e=="number"),h(this,d,A).call(this,Math.abs(e)<=p(v,se),"Assertion failed"),h(this,d,_).call(this,h(this,d,L).call(this)-BigInt(e)),this}addn(e){return this.clone().iaddn(e)}subn(e){return this.clone().isubn(e)}iabs(){return I(this,E,0),this}abs(){return this.clone().iabs()}divmod(e,t,n){var a;if(h(this,d,A).call(this,!e.isZero(),"Division by zero"),this.isZero()){let f=new v(0n);return{div:t==="mod"?null:f,mod:t==="div"?null:f}}let i=h(this,d,L).call(this),s=h(a=e,d,L).call(a),o=t!=="mod"?i/s:null,c=h(this,d,qn).call(this,i,s,t,n);return{div:h(this,d,Yt).call(this,o),mod:h(this,d,Yt).call(this,c)}}div(e){return this.divmod(e,"div",!1).div}mod(e){return this.divmod(e,"mod",!1).mod}umod(e){return this.divmod(e,"mod",!0).mod}divRound(e){var f,l,u;h(this,d,A).call(this,!e.isZero());let t=h(this,d,L).call(this),n=h(f=e,d,L).call(f),i=t/n,s=t%n;if(s===0n){let g=new v(0n);return h(l=g,d,_).call(l,i),g}let o=s<0n?-s:s,c=n<0n?-n:n;o*2n>=c&&(t>0n&&n>0n||t<0n&&n<0n?i+=1n:i-=1n);let a=new v(0n);return h(u=a,d,_).call(u,i),a}modrn(e){h(this,d,A).call(this,e!==0,"Division by zero in modrn");let t=BigInt(Math.abs(e));if(t===0n)throw new Error("Division by zero in modrn");let n=p(this,x)%t;return e<0?Number(-n):Number(n)}idivn(e){return h(this,d,A).call(this,e!==0),h(this,d,A).call(this,Math.abs(e)<=p(v,se),"num is too large"),h(this,d,_).call(this,h(this,d,L).call(this)/BigInt(e)),this}divn(e){return this.clone().idivn(e)}egcd(e){var u,g,y;h(this,d,A).call(this,e.negative===0,"p must not be negative"),h(this,d,A).call(this,!e.isZero(),"p must not be zero");let t=h(this,d,L).call(this),n=p(e,x),i=1n,s=0n,o=0n,c=1n;for(;n!==0n;){let w=t/n,S=n;n=t%n,t=S,S=s,s=i-w*s,i=S,S=c,c=o-w*c,o=S}let a=new v(0n);h(u=a,d,_).call(u,i);let f=new v(0n);h(g=f,d,_).call(g,o);let l=new v(0n);return h(y=l,d,K).call(y,t<0n?-t:t,0),{a,b:f,gcd:l}}gcd(e){var s,o,c;let t=p(this,x),n=p(e,x);if(t===0n){let a=new v(0n);return h(s=a,d,_).call(s,n),a.iabs()}if(n===0n){let a=new v(0n);return h(o=a,d,_).call(o,t),a.iabs()}for(;n!==0n;){let a=t%n;t=n,n=a}let i=new v(0n);return h(c=i,d,K).call(c,t,0),i}invm(e){h(this,d,A).call(this,!e.isZero()&&p(e,E)===0,"Modulus for invm must be positive and non-zero");let t=this.egcd(e);if(!t.gcd.eqn(1))throw new Error("Inverse does not exist (numbers are not coprime).");return t.a.umod(e)}isEven(){return p(this,x)%2n===0n}isOdd(){return p(this,x)%2n===1n}andln(e){return h(this,d,A).call(this,e>=0),Number(p(this,x)&BigInt(e))}bincn(e){h(this,d,A).call(this,typeof e=="number"&&e>=0);let t=1n<<BigInt(e);return h(this,d,_).call(this,h(this,d,L).call(this)+t),this}isZero(){return p(this,x)===0n}cmpn(e){h(this,d,A).call(this,Math.abs(e)<=p(v,se),"Number is too big");let t=h(this,d,L).call(this),n=BigInt(e);return t<n?-1:t>n?1:0}cmp(e){var i;let t=h(this,d,L).call(this),n=h(i=e,d,L).call(i);return t<n?-1:t>n?1:0}ucmp(e){return p(this,x)<p(e,x)?-1:p(this,x)>p(e,x)?1:0}gtn(e){return this.cmpn(e)===1}gt(e){return this.cmp(e)===1}gten(e){return this.cmpn(e)>=0}gte(e){return this.cmp(e)>=0}ltn(e){return this.cmpn(e)===-1}lt(e){return this.cmp(e)===-1}lten(e){return this.cmpn(e)<=0}lte(e){return this.cmp(e)<=0}eqn(e){return this.cmpn(e)===0}eq(e){return this.cmp(e)===0}toRed(e){return h(this,d,A).call(this,this.red==null,"Already a number in reduction context"),h(this,d,A).call(this,p(this,E)===0,"toRed works only with positives"),e.convertTo(this).forceRed(e)}fromRed(){return h(this,d,A).call(this,this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)}forceRed(e){return this.red=e,this}redAdd(e){return h(this,d,A).call(this,this.red,"redAdd works only with red numbers"),this.red.add(this,e)}redIAdd(e){return h(this,d,A).call(this,this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)}redSub(e){return h(this,d,A).call(this,this.red,"redSub works only with red numbers"),this.red.sub(this,e)}redISub(e){return h(this,d,A).call(this,this.red,"redISub works only with red numbers"),this.red.isub(this,e)}redShl(e){return h(this,d,A).call(this,this.red,"redShl works only with red numbers"),this.red.shl(this,e)}redMul(e){return h(this,d,A).call(this,this.red,"redMul works only with red numbers"),this.red.verify2(this,e),this.red.mul(this,e)}redIMul(e){return h(this,d,A).call(this,this.red,"redIMul works only with red numbers"),this.red.verify2(this,e),this.red.imul(this,e)}redSqr(){return h(this,d,A).call(this,this.red,"redSqr works only with red numbers"),this.red.verify1(this),this.red.sqr(this)}redISqr(){return h(this,d,A).call(this,this.red,"redISqr works only with red numbers"),this.red.verify1(this),this.red.isqr(this)}redSqrt(){return h(this,d,A).call(this,this.red,"redSqrt works only with red numbers"),this.red.verify1(this),this.red.sqrt(this)}redInvm(){return h(this,d,A).call(this,this.red,"redInvm works only with red numbers"),this.red.verify1(this),this.red.invm(this)}redNeg(){return h(this,d,A).call(this,this.red,"redNeg works only with red numbers"),this.red.verify1(this),this.red.neg(this)}redPow(e){return h(this,d,A).call(this,this.red!=null&&e.red==null,"redPow(normalNum)"),this.red.verify1(this),this.red.pow(this,e)}static fromHex(e,t){let n="be";return(t==="little"||t==="le")&&(n="le"),new v(e,16,n)}toHex(e=0){if(this.isZero()&&e===0)return"";let t=h(this,d,Oe).call(this);t!=="0"&&t.length%2!==0&&(t="0"+t);let n=e*2;for(;t.length<n;)t="0"+t;return(this.isNeg()?"-":"")+t}static fromJSON(e){return new v(e,16)}static fromNumber(e){return new v(e)}static fromString(e,t){return new v(e,t)}static fromSm(e,t="big"){var a;if(e.length===0)return new v(0n);let n=e.slice();t==="little"&&n.reverse();let i=0;n.length>0&&(n[0]&128)!==0&&(i=1,n[0]&=127);let s;if(ei)s=Vt.from(n).toString("hex");else{s="";for(let f of n)s+=f<16?"0"+f.toString(16):f.toString(16)}let o=s.length===0?0n:BigInt("0x"+s),c=new v(0n);return h(a=c,d,K).call(a,o,i),c}toSm(e="big"){if(p(this,x)===0n)return p(this,E)===1?[128]:[];let t=h(this,d,Oe).call(this);t.length%2!==0&&(t="0"+t);let n=t.length/2,i=Array.from({length:n});for(let o=0,c=0;o<t.length;o+=2){let a=Fe[t.codePointAt(o)],f=Fe[t.codePointAt(o+1)];i[c++]=(a&15)<<4|f&15}let s;return p(this,E)===1?(i[0]&128)===0?(s=i.slice(),s[0]|=128):s=[128,...i]:(i[0]&128)===0?s=i.slice():s=[0,...i],e==="little"?s.reverse():s}static fromBits(e,t=!1){let n=e>>>24,i=e&8388607,s=(e&8388608)!==0;if(t&&s)throw new Error("negative bit set");if(n===0&&i===0){if(s&&t)throw new Error("negative bit set for zero value");return new v(0n)}let o=new v(i);return n<=3?o.iushrn((3-n)*8):o.iushln((n-3)*8),s&&o.ineg(),o}toBits(){if(this.strip(),this.isZero()&&!this.isNeg())return 0;let e=this.isNeg(),n=this.abs().toArray("be"),i=0;for(;i<n.length-1&&n[i]===0;)i++;n=n.slice(i);let s=n.length,o;if(s===0)o=0;else if(s<=3){o=0;for(let a=0;a<s;a++)o=o<<8|n[a]}else o=n[0]<<16|n[1]<<8|n[2];(o&8388608)!==0&&s<=255&&(o>>>=8,s++);let c=s<<24|o;return e&&(c|=8388608),c>>>0}static fromScriptNum(e,t=!1,n){if(n!==void 0&&e.length>n)throw new Error("script number overflow");if(e.length===0)return new v(0n);if(t&&(e.at(-1)&127)===0&&(e.length<=1||(e.at(-2)&128)===0))throw new Error("non-minimally encoded script number");return v.fromSm(e,"little")}toScriptNum(){return this.toSm("little")}_invmp(e){h(this,d,A).call(this,p(e,E)===0,"p must not be negative for _invmp"),h(this,d,A).call(this,!e.isZero(),"p must not be zero for _invmp");let t=this.umod(e),n=e.subn(2);if(t.red!==null)return t.redPow(n);let i=new v(1n),s=t.clone(),o=n.clone();for(;!o.isZero();)o.isOdd()&&(i=i.mul(s).umod(e)),s=s.sqr().umod(e),o.iushrn(1);return i}mulTo(e,t){return I(t,x,p(this,x)*p(e,x)),I(t,E,p(t,x)===0n?0:p(this,E)^p(e,E)),I(t,R,this.length+e.length),t.red=null,t.normSign(),t}};We=new WeakMap,Xe=new WeakMap,dt=new WeakMap,ht=new WeakMap,se=new WeakMap,lt=new WeakMap,qe=new WeakMap,x=new WeakMap,E=new WeakMap,R=new WeakMap,d=new WeakSet,Tn=function(){if(p(this,x)===0n)return[0];let e=[],t=p(this,x);for(;t>0n;)e.push(Number(t&p(v,Xe))),t>>=p(v,We);return e.length>0?e:[0]},Ln=function(e,t,n){t==="hex"&&(t=16),h(this,d,A).call(this,typeof t=="number"&&t===Math.trunc(t)&&t>=2&&t<=36,"Base must be an integer between 2 and 36");let i=e.toString().replace(/\s+/g,""),s=0,o=0;i.startsWith("-")?(s++,o=1):i.startsWith("+")&&s++;let c=i.substring(s);if(c.length===0){h(this,d,K).call(this,0n,o===1&&i.startsWith("-")?1:0),this.normSign();return}t===16?h(this,d,Pn).call(this,c,o,n):h(this,d,Hn).call(this,c,t,o,n)},Pn=function(e,t,n){if(n==="le"){let i=[],s=e;s.length%2!==0&&(s="0"+s);for(let o=0;o<s.length;o+=2){let c=s.substring(o,o+2),a=Number.parseInt(c,16);if(Number.isNaN(a))throw new Error("Invalid character in "+s);i.push(a)}h(this,d,_e).call(this,i,"le"),I(this,E,t),this.normSign()}else{let i;try{i=BigInt("0x"+e)}catch{throw new Error("Invalid character in "+e)}h(this,d,K).call(this,i,t),this.normSign()}},Hn=function(e,t,n,i){try{if(h(this,d,Cn).call(this,e,t),I(this,E,n),this.normSign(),i==="le"){let s=p(this,E);h(this,d,_e).call(this,this.toArray("be"),"le"),I(this,E,s),this.normSign()}}catch(s){let o=s;throw o.message.includes("Invalid character in string")||o.message.includes("Invalid digit for base")||o.message.startsWith("Invalid character:")?new Error("Invalid character"):o}},Un=function(e,t){if(e===0n)return"0";if(t<2||t>36)throw new Error("Base must be between 2 and 36");let n="0123456789abcdefghijklmnopqrstuvwxyz",i="",s=e>0n?e:-e,o=BigInt(t);for(;s>0n;)i=n[Number(s%o)]+i,s/=o;return i},Cn=function(e,t){I(this,x,0n);let n=BigInt(t),i=v.groupSizes[t],s=BigInt(v.groupBases[t]);(i===0||s===0n)&&(i=Math.floor(Math.log(67108863)/Math.log(t)),i===0&&(i=1),s=n**BigInt(i));let o=0,c=e.length,a=c%i;if(a===0&&c>0&&(a=i),a>0){let f=e.substring(o,o+a);I(this,x,BigInt(h(this,d,Gt).call(this,f,t))),o+=a}for(;o<c;){let f=e.substring(o,o+i),l=BigInt(h(this,d,Gt).call(this,f,t));I(this,x,p(this,x)*s+l),o+=i}h(this,d,j).call(this)},Gt=function(e,t){let n=0;for(let i=0;i<e.length;i++){let s=e.codePointAt(i),o;if(s>=48&&s<=57)o=s-48;else if(s>=65&&s<=90)o=s-65+10;else if(s>=97&&s<=122)o=s-97+10;else throw new Error("Invalid character: "+e[i]);if(o>=t)throw new Error("Invalid character");n=n*t+o}return n},K=function(e,t){I(this,x,e),I(this,E,e===0n?0:t),h(this,d,j).call(this)},j=function(){if(p(this,x)===0n)I(this,R,1),I(this,E,0);else{let e=p(this,x).toString(2).length;I(this,R,Math.max(1,Math.ceil(e/v.wordSize)))}},A=function(e,t="Assertion failed"){if(!e)throw new Error(t)},_n=function(e,t="be"){if(h(this,d,A).call(this,BigInt(Math.abs(e))<=p(v,lt),"The number is larger than 2 ^ 53 (unsafe)"),h(this,d,A).call(this,e%1===0,"Number must be an integer for BigNumber conversion"),h(this,d,K).call(this,BigInt(Math.abs(e)),e<0?1:0),t==="le"){let n=p(this,E),i=this.toArray("be");h(this,d,_e).call(this,i,"le"),I(this,E,n),this.normSign()}return this},_e=function(e,t){if(e.length===0)return h(this,d,K).call(this,0n,0),this;let n=0n;if(t==="be")for(let i of e)n=n<<8n|BigInt(i&255);else for(let i=e.length-1;i>=0;i--)n=n<<8n|BigInt(e[i]&255);return h(this,d,K).call(this,n,0),this},Oe=function(){return p(this,x)===0n?"0":p(this,x).toString(16)},On=function(e){let t=h(this,d,Oe).call(this);if(e>1)for(t!=="0"&&t.length%2!==0&&(t="0"+t);t.length%e!==0;)t="0"+t;return(this.isNeg()?"-":"")+t},zn=function(e,t){var c;if(p(this,x)===0n)return h(c=v,be,Fn).call(c,t);let n=v.groupSizes[e],i=BigInt(v.groupBases[e]);(n===0||i===0n)&&(n=Math.floor(Math.log(Number.MAX_SAFE_INTEGER)/Math.log(e)),n===0&&(n=1),i=BigInt(e)**BigInt(n));let s="",o=p(this,x);for(;o>0n;){let a=o%i;o/=i;let f=h(this,d,Un).call(this,a,e);s=(o>0n?h(this,d,Wn).call(this,f,n):f)+s}if(t>0)for(;s.length<t;)s="0"+s;return(p(this,E)===1?"-":"")+s},be=new WeakSet,Fn=function(e){let t="0";if(e>1)for(;t.length<e;)t="0"+t;return t},Wn=function(e,t){let n=t-e.length;return n<=0?e:n<v.zeros.length?v.zeros[n]+e:"0".repeat(n)+e},Xn=function(e,t){let n=p(this,x),i=t?0:e.length-1,s=t?1:-1;for(let o of e){if(n===0n&&i>=0&&i<e.length)e[i]=0;else if(i>=0&&i<e.length)e[i]=Number(n&0xffn);else break;n>>=8n,i+=s}},L=function(){return p(this,E)===1?-p(this,x):p(this,x)},_=function(e){e<0n?(I(this,x,-e),I(this,E,1)):(I(this,x,e),I(this,E,0)),h(this,d,j).call(this),this.normSign()},ze=function(e,t,n=!1){let i=t(p(this,x),p(e,x)),s=p(this,R);return n&&(s=Math.max(this.length,e.length)),I(this,x,i),h(this,d,j).call(this),n&&I(this,R,Math.max(p(this,R),s)),this.strip()},ft=function(e,t,n=!1){return h(this,d,A).call(this,p(this,E)===0&&p(e,E)===0),h(this,d,ze).call(this,e,t,n)},ue=function(e,t){return this.length>=e.length?this.clone()[t](e):e.clone()[t](this)},$t=function(e,t){if(typeof e=="number"){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a non-negative integer`);return BigInt(e)}if(e<0n)throw new Error(`${t} must be a non-negative integer`);return e},qn=function(e,t,n,i){if(n==="div")return null;let s=e%t;return i===!0&&s<0n&&(s+=t<0n?-t:t),s},Yt=function(e){var n;if(e===null)return null;let t=new v(0n);return h(n=t,d,_).call(n,e),t},C(v,be),b(v,"zeros",["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"]),b(v,"groupSizes",[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]),b(v,"groupBases",[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176]),b(v,"wordSize",26),C(v,We,26n),C(v,Xe,(1n<<26n)-1n),C(v,dt,BigInt(Number.MAX_SAFE_INTEGER)),C(v,ht,BigInt(Number.MIN_SAFE_INTEGER)),C(v,se,67108863),C(v,lt,(1n<<53n)-1n),C(v,qe,1048576);var m=v;var De=class{constructor(e,t){b(this,"name");b(this,"p");b(this,"k");b(this,"n");b(this,"tmp");this.name=e,this.p=new m(t,16),this.n=this.p.bitLength(),this.k=new m(BigInt(1)).iushln(this.n).isub(this.p),this.tmp=this._tmp()}_tmp(){let e=new m(BigInt(0)),t=Math.ceil(this.n/m.wordSize);return e.expand(Math.max(1,t)),e}ireduce(e){let t=e,n;do this.split(t,this.tmp),this.imulK(t),t.iadd(this.tmp),n=t.bitLength();while(n>this.n);let i=n<this.n?-1:t.ucmp(this.p);return i===0?t.words=[0]:i>0&&t.isub(this.p),t.strip(),t}split(e,t){e.iushrn(this.n,0,t)}imulK(e){return e.imul(this.k)}};var Ze=class extends De{constructor(){super("k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}split(e,t){let i=e.words,s=e.length,o=Math.min(s,9),c=Array.from({length:o+(s>9?1:0)},()=>0);for(let w=0;w<o;w++)c[w]=i[w];let a=o;if(s<=9){let w=Array.from({length:a},()=>0);for(let S=0;S<a;++S)w[S]=c[S];t.words=w,e.words=[0];return}let f=i[9];c[a++]=f&4194303;let l=Array.from({length:a},()=>0);for(let w=0;w<a;++w)l[w]=c[w];t.words=l;let u=Array.from({length:Math.max(1,s-9)},()=>0),g=0;for(let w=10;w<s;w++){let S=Math.trunc(i[w]);g<u.length&&(u[g++]=(S&4194303)<<4|f>>>22),f=S}f>>>=22,g<u.length?u[g++]=f:f!==0&&u.length>0;let y=Array.from({length:g},()=>0);for(let w=0;w<g;++w)y[w]=u[w];e.words=y}imulK(e){let t=e.words,n=e.length,i=n+2,s=Array.from({length:i},()=>0);for(let c=0;c<n;c++)s[c]=t[c];let o=0;for(let c=0;c<i;c++){let a=Math.trunc(s[c]);o+=a*977,s[c]=o&67108863,o=a*64+Math.trunc(o/67108864)}return e.words=s,e}};var pe=class{constructor(e){b(this,"prime");b(this,"m");if(e==="k256"){let t=new Ze;this.m=t.p,this.prime=t}else this.assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}assert(e,t="Assertion failed"){if(!e)throw new Error(t)}verify1(e){this.assert(e.negative===0,"red works only with positives"),this.assert(e.red,"red works only with red numbers")}verify2(e,t){this.assert((e.negative|t.negative)===0,"red works only with positives"),this.assert(e.red!=null&&e.red===t.red,"red works only with red numbers")}imod(e){return this.prime!=null?this.prime.ireduce(e).forceRed(this):(m.move(e,e.umod(this.m).forceRed(this)),e)}neg(e){return e.isZero()?e.clone():this.m.sub(e).forceRed(this)}add(e,t){this.verify2(e,t);let n=e.clone();return n.iadd(t),n.isub(this.m),n.isNeg()&&n.iadd(this.m),n}iadd(e,t){return this.verify2(e,t),e.iadd(t),e.isub(this.m),e.isNeg()&&e.iadd(this.m),e}sub(e,t){this.verify2(e,t);let n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n.forceRed(this)}isub(e,t){this.verify2(e,t);let n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n}shl(e,t){return this.verify1(e),this.imod(e.ushln(t))}imul(e,t){return this.verify2(e,t),this.imod(e.imul(t))}mul(e,t){return this.verify2(e,t),this.imod(e.mul(t))}isqr(e){return this.imul(e,e.clone())}sqr(e){return this.mul(e,e)}sqrt(e){if(e.isZero())return e.clone();let t=this.m.andln(3);if(this.assert(t%2===1),t===3){let w=this.m.add(new m(1)).iushrn(2);return this.pow(e,w)}let n=this.m.subn(1),i=0;for(;!n.isZero()&&n.andln(1)===0;)i++,n.iushrn(1);this.assert(!n.isZero());let s=new m(1).toRed(this),o=s.redNeg(),c=this.m.subn(1).iushrn(1),a=this.m.bitLength(),f=new m(2*a*a).toRed(this);for(;this.pow(f,c).cmp(o)!==0;)f.redIAdd(o);let l=this.pow(f,n),u=this.pow(e,n.addn(1).iushrn(1)),g=this.pow(e,n),y=i;for(;g.cmp(s)!==0;){let w=g,S=0;for(;w.cmp(s)!==0;)w=w.redSqr(),S++;this.assert(S<y);let M=this.pow(l,new m(1).iushln(y-S-1));u=u.redMul(M),l=M.redSqr(),g=g.redMul(l),y=S}return u}invm(e){let t=e._invmp(this.m);return t.negative!==0?(t.negative=0,this.imod(t).redNeg()):this.imod(t)}pow(e,t){if(this.verify1(e),t.isZero())return new m(1).toRed(this);let n=new m(1).toRed(this),i=e.clone(),s=t.bitLength();for(let o=s-1;o>=0;o--)n=this.sqr(n),t.testn(o)&&(n=this.mul(n,i));return n}convertTo(e){let t=e.umod(this.m);return t===e?t.clone():t}convertFrom(e){let t=e.clone();return t.red=null,t}};var Ke=class extends pe{constructor(t){super(t);b(this,"shift");b(this,"r");b(this,"r2");b(this,"rinv");b(this,"minv");this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new m(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}convertTo(t){return this.imod(t.ushln(this.shift))}convertFrom(t){let n=this.imod(t.mul(this.rinv));return n.red=null,n}imul(t,n){if(t.isZero()||n.isZero())return t.words[0]=0,t.length=1,t;let i=t.imul(n),s=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=i.isub(s).iushrn(this.shift),c=o;return o.cmp(this.m)>=0?c=o.isub(this.m):o.cmpn(0)<0&&(c=o.iadd(this.m)),c.forceRed(this)}mul(t,n){if(t.isZero()||n.isZero())return new m(0).forceRed(this);let i=t.mul(n),s=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=i.isub(s).iushrn(this.shift),c=o;return o.cmp(this.m)>=0?c=o.isub(this.m):o.cmpn(0)<0&&(c=o.iadd(this.m)),c.forceRed(this)}invm(t){return this.imod(t._invmp(this.m).mul(this.r2)).forceRed(this)}};var ti=new TextEncoder;function ut(r){return ti.encode(r)}var ni=/^[0-9a-fA-F]*$/;function Ve(r){if(typeof r!="string")throw new TypeError("Invalid hex string");if(r.length!==0&&!ni.test(r))throw new Error("Invalid hex string")}function Dn(r){if(Ve(r),r.length===0)return"";let e=r.toLowerCase();return e.length%2!==0&&(e="0"+e),e}var Jt=(r,e="Hash assertion failed")=>{if(!r)throw new Error(e)},Qt=class{constructor(e,t,n,i){b(this,"pending",null);b(this,"pendingTotal",0);b(this,"blockSize");b(this,"outSize");b(this,"endian");b(this,"_delta8");b(this,"_delta32");b(this,"padLength");b(this,"hmacStrength");this.blockSize=e,this.outSize=t,this.hmacStrength=n,this.padLength=i/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}_update(e,t){throw new Error("Not implemented")}_digest(){throw new Error("Not implemented")}_digestHex(){throw new Error("Not implemented")}update(e,t){if(e=Jn(e,t),this.pending==null?this.pending=e:this.pending=this.pending.concat(e),this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;let n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=ui(e,0,e.length-n,this.endian);for(let i=0;i<e.length;i+=this._delta32)this._update(e,i)}return this}digest(){return this.update(this._pad()),Jt(this.pending===null),this._digest()}digestHex(){return this.update(this._pad()),Jt(this.pending===null),this._digestHex()}_pad(){let e=this.pendingTotal;if(!Number.isSafeInteger(e)||e<0)throw new Error("Message too long for this hash function");let t=this._delta8,n=t-(e+this.padLength)%t,i=Array.from({length:n+this.padLength});i[0]=128;let s;for(s=1;s<n;s++)i[s]=0;let o=this.padLength,c=1n<<BigInt(o*8),a=BigInt(e)*8n;if(a>=c)throw new Error("Message too long for this hash function");if(this.endian==="big"){let f=Array.from({length:o});for(let l=o-1;l>=0;l--)f[l]=Number(a&0xffn),a>>=8n;for(let l=0;l<o;l++)i[s++]=f[l]}else for(let f=0;f<o;f++)i[s++]=Number(a&0xffn),a>>=8n;return i}};function ri(r,e,t){let n=r.codePointAt(e);return n<128?(t.push(n),e):n<2048?(t.push(n>>6|192,n&63|128),e):n>65535?(t.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128),e+1):(t.push(n>>12|224,n>>6&63|128,n&63|128),e)}function ii(r){let e=[],t=0;for(;t<r.length;)t=ri(r,t,e)+1;return e}function si(r){Ve(r);let e=Dn(r),t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e[n]+e[n+1],16));return t}function oi(r){let e=[];for(let t=0;t<r.length;t++)e[t]=Math.trunc(r[t]);return e}function Jn(r,e){return Array.isArray(r)?r.slice():r?typeof r=="string"?e==="hex"?si(r):ii(r):oi(r):[]}function ci(r){return Gi(r)}function ai(r,e){let t="";for(let n of r)e==="little"&&(n=ci(n)),t+=fi(n.toString(16));return t}function fi(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}var en=typeof globalThis>"u"?void 0:globalThis.Buffer,di=en!=null&&typeof en.from=="function",Zn="0123456789abcdef",tn=Array.from({length:256});for(let r=0;r<tn.length;r++)tn[r]=Zn[r>>4&15]+Zn[r&15];function hi(r){if(di)return en.from(r).toString("hex");let e=Array.from({length:r.length});for(let t=0;t<r.length;t++)e[t]=tn[r[t]];return e.join("")}var Qn=(()=>{let r=typeof globalThis>"u"?void 0:globalThis.process,e=r?.getBuiltinModule;if(typeof e=="function")try{let t=e.call(r,"node:crypto");if(t!=null)return t}catch{}})();function we(r,e){return r instanceof Uint8Array?r:Array.isArray(r)?new Uint8Array(r):Uint8Array.from(Jn(r,e))}function on(r){return typeof r=="string"?we(r,"hex"):we(r)}function er(r,e,t){r!=null?r.update(t):e?.update(t)}function tr(r,e){return r!=null?Array.from(r.digest()):e!=null?Array.from(e.digest()):[]}function nr(r,e){return r!=null?r.digest("hex"):e!=null?hi(e.digest()):""}function li(r){let e=Qn?.createHash;if(typeof e=="function")try{return e(r)}catch{return}}function cn(r,e){let t=Qn?.createHmac;if(typeof t=="function")try{return t(r,e)}catch{return}}function rr(r,e,t){let n=li(r);if(n!=null)return n.update(we(e,t)),n.digest()}function ir(r,e,t,n){let i=cn(r,on(e));if(i!=null)return i.update(we(t,n)),i.digest()}function ui(r,e,t,n){let i=t-e;Jt(i%4===0);let s=Array.from({length:i/4});for(let o=0,c=e;o<s.length;o++,c+=4){let a;n==="big"?a=r[c]<<24|r[c+1]<<16|r[c+2]<<8|r[c+3]:a=r[c+3]<<24|r[c+2]<<16|r[c+1]<<8|r[c],s[o]=a>>>0}return s}function bi(r,e){let t=Array.from({length:r.length*4});for(let n=0,i=0;n<r.length;n++,i+=4){let s=r[n];e==="big"?(t[i]=s>>>24,t[i+1]=s>>>16&255,t[i+2]=s>>>8&255,t[i+3]=s&255):(t[i+3]=s>>>24,t[i+2]=s>>>16&255,t[i+1]=s>>>8&255,t[i]=s&255)}return t}function J(r,e){return r>>>e|r<<32-e}function bt(r,e){return r<<e|r>>>32-e}function F(r,e){return r+e>>>0}function Ge(r,e,t){return r+e+t>>>0}function Kn(r,e,t,n){return r+e+t+n>>>0}function pi(r,e,t,n,i){return r+e+t+n+i>>>0}function gi(r,e,t){return r&e^~r&t}function mi(r,e,t){return r&e^r&t^e&t}function wi(r){return J(r,2)^J(r,13)^J(r,22)}function xi(r){return J(r,6)^J(r,11)^J(r,25)}function yi(r){return J(r,7)^J(r,18)^r>>>3}function Si(r){return J(r,17)^J(r,19)^r>>>10}var vi=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Ii=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Ei=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Ai=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];function Vn(r,e,t,n){return r<=15?e^t^n:r<=31?e&t|~e&n:r<=47?(e|~t)^n:r<=63?e&n|t&~n:e^(t|~n)}function Bi(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function Ni(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var nn=class extends Qt{constructor(){super(512,160,192,64);b(this,"h");this.endian="little",this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}_update(t,n){let i=this.h[0],s=this.h[1],o=this.h[2],c=this.h[3],a=this.h[4],f=i,l=s,u=o,g=c,y=a,w;for(let S=0;S<80;S++)w=F(bt(Kn(i,Vn(S,s,o,c),t[vi[S]+n],Bi(S)),Ei[S]),a),i=a,a=c,c=bt(o,10),o=s,s=w,w=F(bt(Kn(f,Vn(79-S,l,u,g),t[Ii[S]+n],Ni(S)),Ai[S]),y),f=y,y=g,g=bt(u,10),u=l,l=w;w=Ge(this.h[1],o,g),this.h[1]=Ge(this.h[2],c,y),this.h[2]=Ge(this.h[3],a,f),this.h[3]=Ge(this.h[4],i,l),this.h[4]=Ge(this.h[0],s,u),this.h[0]=w}_digest(){return bi(this.h,"little")}_digestHex(){return ai(this.h,"little")}};var ge,de,$e=class{constructor(e){C(this,ge);C(this,de);b(this,"blockSize",64);b(this,"outSize",32);let t=on(e);I(this,de,cn("sha256",t)),p(this,de)==null&&I(this,ge,new Te(qi,t))}update(e,t){return er(p(this,de),p(this,ge),we(e,t)),this}digest(){return tr(p(this,de),p(this,ge))}digestHex(){return nr(p(this,de),p(this,ge))}};ge=new WeakMap,de=new WeakMap;var me,he,rn=class{constructor(e){C(this,me);C(this,he);b(this,"blockSize",128);b(this,"outSize",32);let t=on(e);I(this,he,cn("sha512",t)),p(this,he)==null&&I(this,me,new Te(Ki,t))}update(e,t){return er(p(this,he),p(this,me),we(e,t)),this}digest(){return tr(p(this,he),p(this,me))}digestHex(){return nr(p(this,he),p(this,me))}};me=new WeakMap,he=new WeakMap;function wt(r,e){let t=rr("sha256",r,e);return t??new vt().update(we(r,e)).digest()}function Mi(r,e){return rr("ripemd160",r,e)}var xe=(r,e)=>Array.from(wt(r,e));var an=(r,e)=>Array.from(wt(wt(r,e))),sr=(r,e)=>{let t=wt(r,e),n=Mi(t);return n!=null?Array.from(n):new nn().update(t).digest()},It=(r,e,t)=>{let n=ir("sha256",r,e,t);return n!=null?Array.from(n):new $e(r).update(e,t).digest()},or=(r,e,t)=>{let n=ir("sha512",r,e,t);return n!=null?Array.from(n):new rn(r).update(e,t).digest()};function Ri(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Gn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, got ${r}`)}function Et(r,...e){if(!Ri(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length)){let t=e.join(",");throw new Error(`Uint8Array expected of length ${t}, got length=${r.length}`)}}function ki(r){if(typeof r!="function"||typeof r.create!="function")throw new TypeError("Hash should be wrapped by utils.createHasher");Gn(r.outputLen),Gn(r.blockLen)}function xt(r,e=!0){if(r.destroyed===!0)throw new Error("Hash instance has been destroyed");if(e&&r.finished===!0)throw new Error("Hash#digest() has already been called")}function Ti(r,e){Et(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}function ke(...r){for(let e of r)e.fill(0)}function jt(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function fn(r){return typeof r=="string"&&(r=Li(r)),Et(r),r}function Li(r){if(typeof r!="string")throw new Error("string expected");return ut(r)}var yt=class{};function cr(r){let e=n=>r().update(fn(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}var pt=BigInt(2**32-1),$n=BigInt(32);function Pi(r,e=!1){return e?{h:Number(r&pt),l:Number(r>>$n&pt)}:{h:Number(r>>$n&pt)|0,l:Number(r&pt)|0}}function Hi(r,e=!1){let t=r.length,n=new Uint32Array(t),i=new Uint32Array(t);for(let s=0;s<t;s++){let{h:o,l:c}=Pi(r[s],e);n[s]=o,i[s]=c}return[n,i]}var Yn=(r,e,t)=>r>>>t,jn=(r,e,t)=>r<<32-t|e>>>t,Me=(r,e,t)=>r>>>t|e<<32-t,Re=(r,e,t)=>r<<32-t|e>>>t,gt=(r,e,t)=>r<<64-t|e>>>t-32,mt=(r,e,t)=>r>>>t-32|e<<64-t;function ie(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var Ui=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Ci=(r,e,t,n)=>Math.trunc(e+t+n+Math.trunc(r/2**32)),_i=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Oi=(r,e,t,n,i)=>Math.trunc(e+t+n+i+Math.trunc(r/2**32)),zi=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),Fi=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,St=class extends yt{constructor(t,n,i,s){super();b(this,"blockLen");b(this,"outputLen");b(this,"padOffset");b(this,"isLE");b(this,"buffer");b(this,"view");b(this,"finished",!1);b(this,"length",0);b(this,"pos",0);b(this,"destroyed",!1);this.blockLen=t,this.outputLen=n,this.padOffset=i,this.isLE=s,this.buffer=new Uint8Array(t),this.view=jt(this.buffer)}update(t){xt(this),t=fn(t),Et(t);let{view:n,buffer:i,blockLen:s}=this,o=t.length;for(let c=0;c<o;){let a=Math.min(s-this.pos,o-c);if(a===s){let f=jt(t);for(;s<=o-c;c+=s)this.process(f,c);continue}i.set(t.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xt(this),Ti(t,this),this.finished=!0;let{buffer:n,view:i,blockLen:s,isLE:o}=this,{pos:c}=this;n[c++]=128,ke(this.buffer.subarray(c)),this.padOffset>s-c&&(this.process(i,0),c=0);for(let g=c;g<s;g++)n[g]=0;Wi(i,s-8,BigInt(this.length*8),o),this.process(i,0);let a=jt(t),f=this.outputLen;if(f%4!==0)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=f/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,u[g],o)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let i=t.slice(0,n);return this.destroy(),i}_cloneInto(t){t??(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:i,length:s,finished:o,destroyed:c,pos:a}=this;return t.destroyed=c,t.finished=o,t.length=s,t.pos=a,s%n!==0&&t.buffer.set(i),t}clone(){return this._cloneInto()}};function Wi(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),c=Number(t&s),a=n?4:0,f=n?0:4;r.setUint32(e+a,o,n),r.setUint32(e+f,c,n)}var oe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xi=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ce=new Uint32Array(64),vt=class extends St{constructor(t=32){super(64,t,8,!1);b(this,"A",oe[0]|0);b(this,"B",oe[1]|0);b(this,"C",oe[2]|0);b(this,"D",oe[3]|0);b(this,"E",oe[4]|0);b(this,"F",oe[5]|0);b(this,"G",oe[6]|0);b(this,"H",oe[7]|0)}get(){let{A:t,B:n,C:i,D:s,E:o,F:c,G:a,H:f}=this;return[t,n,i,s,o,c,a,f]}set(...[t,n,i,s,o,c,a,f]){this.A=t|0,this.B=n|0,this.C=i|0,this.D=s|0,this.E=o|0,this.F=c|0,this.G=a|0,this.H=f|0}process(t,n){for(let g=0;g<16;g++,n+=4)ce[g]=t.getUint32(n);for(let g=16;g<64;g++){let y=ce[g-15],w=ce[g-2],S=yi(y),M=Si(w);ce[g]=F(F(S,ce[g-7]),F(M,ce[g-16]))}let{A:i,B:s,C:o,D:c,E:a,F:f,G:l,H:u}=this;for(let g=0;g<64;g++){let y=pi(u,xi(a),gi(a,f,l),Xi[g],ce[g]),w=F(wi(i),mi(i,s,o));u=l,l=f,f=a,a=F(c,y),c=o,o=s,s=i,i=F(y,w)}this.A=F(this.A,i),this.B=F(this.B,s),this.C=F(this.C,o),this.D=F(this.D,c),this.E=F(this.E,a),this.F=F(this.F,f),this.G=F(this.G,l),this.H=F(this.H,u)}roundClean(){ke(ce)}destroy(){ke(this.buffer),this.set(0,0,0,0,0,0,0,0)}},qi=cr(()=>new vt),z=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ar=Hi(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(BigInt)),Di=ar[0],Zi=ar[1],ae=new Uint32Array(80),fe=new Uint32Array(80),sn=class extends St{constructor(t=64){super(128,t,16,!1);b(this,"Ah",z[0]|0);b(this,"Al",z[1]|0);b(this,"Bh",z[2]|0);b(this,"Bl",z[3]|0);b(this,"Ch",z[4]|0);b(this,"Cl",z[5]|0);b(this,"Dh",z[6]|0);b(this,"Dl",z[7]|0);b(this,"Eh",z[8]|0);b(this,"El",z[9]|0);b(this,"Fh",z[10]|0);b(this,"Fl",z[11]|0);b(this,"Gh",z[12]|0);b(this,"Gl",z[13]|0);b(this,"Hh",z[14]|0);b(this,"Hl",z[15]|0)}get(){let{Ah:t,Al:n,Bh:i,Bl:s,Ch:o,Cl:c,Dh:a,Dl:f,Eh:l,El:u,Fh:g,Fl:y,Gh:w,Gl:S,Hh:M,Hl:N}=this;return[t,n,i,s,o,c,a,f,l,u,g,y,w,S,M,N]}set(...[t,n,i,s,o,c,a,f,l,u,g,y,w,S,M,N]){this.Ah=t|0,this.Al=n|0,this.Bh=i|0,this.Bl=s|0,this.Ch=o|0,this.Cl=c|0,this.Dh=a|0,this.Dl=f|0,this.Eh=l|0,this.El=u|0,this.Fh=g|0,this.Fl=y|0,this.Gh=w|0,this.Gl=S|0,this.Hh=M|0,this.Hl=N|0}process(t,n){for(let T=0;T<16;T++,n+=8)ae[T]=t.getUint32(n),fe[T]=t.getUint32(n+4);for(let T=16;T<80;T++){let X=ae[T-15]|0,Y=fe[T-15]|0,Ft=Me(X,Y,1)^Me(X,Y,8)^Yn(X,Y,7),Wt=Re(X,Y,1)^Re(X,Y,8)^jn(X,Y,7),ne=ae[T-2]|0,re=fe[T-2]|0,st=Me(ne,re,19)^gt(ne,re,61)^Yn(ne,re,6),Xt=Re(ne,re,19)^mt(ne,re,61)^jn(ne,re,6),ot=_i(Wt,Xt,fe[T-7],fe[T-16]),qt=Oi(ot,Ft,st,ae[T-7],ae[T-16]);ae[T]=qt|0,fe[T]=ot|0}let{Ah:i,Al:s,Bh:o,Bl:c,Ch:a,Cl:f,Dh:l,Dl:u,Eh:g,El:y,Fh:w,Fl:S,Gh:M,Gl:N,Hh:H,Hl:Z}=this;for(let T=0;T<80;T++){let X=Me(g,y,14)^Me(g,y,18)^gt(g,y,41),Y=Re(g,y,14)^Re(g,y,18)^mt(g,y,41),Ft=g&w^~g&M,Wt=y&S^~y&N,ne=zi(Z,Y,Wt,Zi[T],fe[T]),re=Fi(ne,H,X,Ft,Di[T],ae[T]),st=ne|0,Xt=Me(i,s,28)^gt(i,s,34)^gt(i,s,39),ot=Re(i,s,28)^mt(i,s,34)^mt(i,s,39),qt=i&o^i&a^o&a,Kr=s&c^s&f^c&f;H=M|0,Z=N|0,M=w|0,N=S|0,w=g|0,S=y|0,{h:g,l:y}=ie(l|0,u|0,re|0,st|0),l=a|0,u=f|0,a=o|0,f=c|0,o=i|0,c=s|0;let Mn=Ui(ot,Kr,st);i=Ci(Mn,Xt,qt,re),s=Mn|0}({h:i,l:s}=ie(i,s,this.Ah,this.Al)),{h:o,l:c}=ie(o,c,this.Bh,this.Bl),{h:a,l:f}=ie(a,f,this.Ch,this.Cl),{h:l,l:u}=ie(l,u,this.Dh,this.Dl),{h:g,l:y}=ie(g,y,this.Eh,this.El),{h:w,l:S}=ie(w,S,this.Fh,this.Fl),{h:M,l:N}=ie(M,N,this.Gh,this.Gl),{h:H,l:Z}=ie(H,Z,this.Hh,this.Hl),this.set(i,s,o,c,a,f,l,u,g,y,w,S,M,N,H,Z)}roundClean(){ke(ae,fe)}destroy(){ke(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Ki=cr(()=>new sn),Te=class extends yt{constructor(t,n){super();b(this,"oHash");b(this,"iHash");b(this,"blockLen");b(this,"outputLen");b(this,"finished",!1);b(this,"destroyed",!1);ki(t);let i=fn(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(i.length>s?t.create().update(i).digest():i);for(let c=0;c<o.length;c++)o[c]^=54;this.iHash.update(o),this.oHash=t.create();for(let c=0;c<o.length;c++)o[c]^=106;this.oHash.update(o),ke(o)}update(t){return xt(this),this.iHash.update(t),this}digestInto(t){xt(this),Et(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t??(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:n,iHash:i,finished:s,destroyed:o,blockLen:c,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=c,t.outputLen=a,t.oHash=n._cloneInto(t.oHash??void 0),t.iHash=i._cloneInto(t.iHash??void 0),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};var Vi=(r,e,t)=>new Te(r,e).update(t).digest();Vi.create=(r,e)=>new Te(r,e);function Gi(r){return(r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24)>>>0}var $s=(()=>{let r=new ArrayBuffer(4),e=new Uint32Array(r),t=new Uint8Array(r);return e[0]=16909060,t[0]===4})();var At=globalThis.Buffer,dr=At!=null&&typeof At.from=="function";var fr="0123456789abcdef",hr=Array.from({length:256},()=>"");for(let r=0;r<256;r++)hr[r]=fr[r>>4&15]+fr[r&15];var G=r=>dr?At.from(r).toString("hex"):r.length===0?"":Array.from(r,e=>hr[e&255]).join("");var q=(r,e)=>{if(Array.isArray(r))return r.slice();if(r===void 0)return[];if(typeof r!="string")return Array.from(r,t=>Math.trunc(t));switch(e){case"hex":return $i(r);case"base64":return Qi(r);default:return es(r)}},je=new Int8Array(256).fill(-1);for(let r=0;r<10;r++)je[48+r]=r;for(let r=0;r<6;r++)je[65+r]=10+r,je[97+r]=10+r;var $i=r=>Array.from(Yi(r)),Yi=r=>{Ve(r);let e=r.length%2===0?r:"0"+r;if(dr){let i=At.from(e,"hex");return new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let t=new Uint8Array(e.length/2),n=0;for(let i=0;i<e.length;i+=2){let s=je[e.codePointAt(i)],o=je[e.codePointAt(i+1)];t[n++]=s<<4|o}return t},ji=r=>{if(typeof r!="string")throw new TypeError("msg must be a string");let e=r.trim().replaceAll(/[\r\n\t\f\v ]+/g,"").replaceAll("-","+").replaceAll("_","/"),t=e.indexOf("=");if(t===-1)return e;let n=e.slice(t);if(!/^={1,2}$/.test(n)||e.slice(0,t).includes("="))throw new Error("Invalid base64 padding");return e.slice(0,t)},Ji=(r,e)=>{if(r>=65&&r<=90)return r-65;if(r>=97&&r<=122)return r-97+26;if(r>=48&&r<=57)return r-48+52;if(r===43)return 62;if(r===47)return 63;throw new Error(`Invalid base64 character at index ${e}`)};function Qi(r){let e=ji(r),t=[],n=0,i=0;for(let s=0;s<e.length;s++){let o=e.codePointAt(s),c=Ji(o,s);for(n=n<<6|c,i+=6;i>=8;)i-=8,t.push(n>>i&255),n&=(1<<i)-1}return t}function es(r){return Array.from(ut(r))}function dn(r){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t="",n;for(n=0;n<r.length;n+=3){let i=r[n],s=n+1<r.length?r[n+1]:0,o=n+2<r.length?r[n+2]:0,c=i>>2,a=(i&3)<<4|s>>4,f=(s&15)<<2|o>>6,l=o&63;t+=e.charAt(c)+e.charAt(a),t+=n+1<r.length?e.charAt(f):"=",t+=n+2<r.length?e.charAt(l):"="}return t}var Ye="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Bt=r=>{if(r===""||typeof r!="string")throw new Error(`Expected base58 string but got \u201C${r}\u201D`);let e=r.match(/[^1-9A-HJ-NP-Za-km-z]/gmu);if(e!==null)throw new Error(`Invalid base58 character \u201C${e.join("")}\u201D`);let t=r.match(/^1+/gmu),n=t===null?0:t[0].length,i=(r.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return[...new Uint8Array([...new Uint8Array(n),...Array.from(r).map(o=>Ye.indexOf(o)).reduce((o,c)=>(o=o.map(a=>{let f=a*58+c;return c=f>>8,f}),o),new Uint8Array(i)).reverse().filter((o=>c=>o=o||c)(!1))])]},Nt=r=>{let e=Array.from({length:256},()=>-1);for(let n=0;n<Ye.length;++n)e[Ye.codePointAt(n)]=n;let t=[];for(let n of r){let i=n;for(let s=0;s<t.length;++s){let o=(e[t[s]]<<8)+i,c=Math.trunc(o/58),a=o-c*58;t[s]=Ye.codePointAt(a),i=c}for(;i!==0;){let s=Math.trunc(i/58),o=i-s*58;t.push(Ye.codePointAt(o)),i=s}}for(let n of r)if(n===0)t.push("1".codePointAt(0));else break;return t.reverse(),String.fromCodePoint(...t)},Mt=(r,e=[0])=>{let t=an([...e,...r]);return t=[...e,...r,...t.slice(0,4)],Nt(t)},lr=(r,e,t=1)=>{let n=Bt(r),i=n.slice(0,t),s=n.slice(t,-4),o=[...i,...s];return o=an(o),n.slice(-4).forEach((c,a)=>{if(c!==o[a])throw new Error("Invalid checksum")}),e==="hex"&&(i=G(i),s=G(s)),{prefix:i,data:s}};var no=new m(2).pow(new m(63)),ro=new m(2).pow(new m(64));var hn;function ur(r,e){let t=r.andln(3)+e&3;return t===3?-1:t}function br(r,e,t,n){if((t&1)===0)return 0;let i=r.andln(7)+e&7;return(i===3||i===5)&&n===2?-t:t}function pr(r,e){return 2*r===e+1?1-r:r}var Rt,gr,ln=class ln{constructor(){C(this,Rt);b(this,"p");b(this,"red");b(this,"redN");b(this,"zero");b(this,"one");b(this,"two");b(this,"g");b(this,"n");b(this,"a");b(this,"b");b(this,"tinv");b(this,"zeroA");b(this,"threeA");b(this,"endo");b(this,"_endoWnafT1");b(this,"_endoWnafT2");b(this,"_wnafT1");b(this,"_wnafT2");b(this,"_wnafT3");b(this,"_wnafT4");b(this,"_bitLength");if(hn===void 0)hn=this;else return hn;let t={prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",{doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}]};this.p=new m(t.p,16),this.red=new pe(t.prime),this.zero=new m(0).toRed(this.red),this.one=new m(1).toRed(this.red),this.two=new m(2).toRed(this.red),this.n=new m(t.n,16),this.g=D.fromJSON(t.g,t.gRed),this._wnafT1=Array.from({length:4},()=>{}),this._wnafT2=Array.from({length:4},()=>{}),this._wnafT3=Array.from({length:4},()=>{}),this._wnafT4=Array.from({length:4},()=>{}),this._bitLength=this.n.bitLength(),this.redN=this.n.toRed(this.red),this.a=new m(t.a,16).toRed(this.red),this.b=new m(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=Array.from({length:4},()=>{}),this._endoWnafT2=Array.from({length:4},()=>{})}static assert(e,t="Elliptic curve assertion failed"){if(!e)throw new Error(t)}getNAF(e,t,n){let i=Array.from({length:Math.max(e.bitLength(),n)+1},()=>0);i.fill(0);let s=1<<t+1,o=e.clone();for(let c=0;c<i.length;c++){let a,f=o.andln(s-1);o.isOdd()?(f>(s>>1)-1?a=(s>>1)-f:a=f,o.isubn(a)):a=0,i[c]=a,o.iushrn(1)}return i}getJSF(e,t){let n=[[],[]];e=e.clone(),t=t.clone();let i=0,s=0;for(;e.cmpn(-i)>0||t.cmpn(-s)>0;){let o=ur(e,i),c=ur(t,s),a=br(e,i,o,c);n[0].push(a);let f=br(t,s,c,o);n[1].push(f),i=pr(i,a),s=pr(s,f),e.iushrn(1),t.iushrn(1)}return n}static cachedProperty(e,t,n){let i="_"+t;e.prototype[t]=function(){return this[i]===void 0&&(this[i]=n.call(this)),this[i]}}static parseBytes(e){return typeof e=="string"?q(e,"hex"):e}static intFromLE(e){return new m(e,"hex","le")}_getEndomorphism(e){if(!this.zeroA||this.p.modrn(3)!==1)return;let t=this._resolveEndomorphismBeta(e),n=this._resolveEndomorphismLambda(e,t);return{beta:t,lambda:n,basis:h(this,Rt,gr).call(this,e,n)}}_resolveEndomorphismBeta(e){if(e.beta!==void 0)return new m(e.beta,16).toRed(this.red);let t=this._getEndoRoots(this.p);if(t==null)throw new Error("Failed to get endomorphism roots for beta.");return(t[0].cmp(t[1])<0?t[0]:t[1]).toRed(this.red)}_endomorphismLambdaMatches(e,t,n=!1){if(this.g==null)throw new Error("Curve generator point (g) is not defined.");let i=this.g.mul(e)?.x,s=this.g.x==null?void 0:this.g.x.redMul(t);if(i==null||s==null){if(n)throw new Error("Lambda computation failed: g.mul(lambda).x or g.x.redMul(beta) is undefined.");return!1}return i.cmp(s)===0}_resolveEndomorphismLambda(e,t){if(e.lambda!==void 0)return new m(e.lambda,16);let n=this._getEndoRoots(this.n);if(n==null)throw new Error("Failed to get endomorphism roots for lambda.");return this._endomorphismLambdaMatches(n[0],t)?n[0]:(ln.assert(this._endomorphismLambdaMatches(n[1],t,!0),"Lambda selection does not match computed beta."),n[1])}_getEndoRoots(e){let t=e===this.p?this.red:new Ke(e),n=new m(2).toRed(t).redInvm(),i=n.redNeg(),s=new m(3).toRed(t).redNeg().redSqrt().redMul(n),o=i.redAdd(s).fromRed(),c=i.redSub(s).fromRed();return[o,c]}_getEndoBasis(e){let t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),s=new m(1),o=new m(0),c=new m(0),a=new m(1),f,l,u,g,y,w,S=new m(0),M=0,N=new m(0),H=new m(0);for(;n.cmpn(0)!==0;){let X=i.div(n);N=i.sub(X.mul(n)),H=c.sub(X.mul(s));let Y=a.sub(X.mul(o));if(u===void 0&&N.cmp(t)<0)f=S.neg(),l=s,u=N.neg(),g=H;else if(u!==void 0&&++M===2)break;S=N,i=n,n=N,c=s,s=H,a=o,o=Y}if(f===void 0||l===void 0||u===void 0||g===void 0)throw new Error("Failed to compute Endo Basis values");y=N.neg(),w=H;let Z=u.sqr().add(g.sqr());return y.sqr().add(w.sqr()).cmp(Z)>=0&&(y=f,w=l),u.negative!==0&&(u=u.neg(),g=g.neg()),y.negative!==0&&(y=y.neg(),w=w.neg()),[{a:u,b:g},{a:y,b:w}]}_endoSplit(e){if(this.endo==null)throw new Error("Endomorphism is not defined.");let t=this.endo.basis,n=t[0],i=t[1],s=i.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),c=s.mul(n.a),a=o.mul(i.a),f=s.mul(n.b),l=o.mul(i.b),u=e.sub(c).sub(a),g=f.add(l).neg();return{k1:u,k2:g}}validate(e){if(e.inf)return!0;let t=e.x,n=e.y;if(t===null||n===null)throw new Error("Point coordinates cannot be null");let i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0}};Rt=new WeakSet,gr=function(e,t){return typeof e.basis!="object"||e.basis===null?this._getEndoBasis(t):e.basis.map(n=>({a:new m(n.a,16),b:new m(n.b,16)}))};var U=ln;var ye=class{constructor(e){b(this,"curve");b(this,"type");b(this,"precomputed");this.curve=new U,this.type=e,this.precomputed=null}};var Se=class r extends ye{constructor(t,n,i){super("jacobian");b(this,"x");b(this,"y");b(this,"z");b(this,"zOne");t===null&&n===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new m(0)):(m.isBN(t)||(t=new m(t,16)),this.x=t,m.isBN(n)||(n=new m(n,16)),this.y=n,m.isBN(i)||(i=new m(i,16)),this.z=i),this.x.red==null&&(this.x=this.x.toRed(this.curve.red)),this.y.red==null&&(this.y=this.y.toRed(this.curve.red)),this.z.red==null&&(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.isInfinity()&&(this.x=this.curve.one,this.y=this.curve.one,this.z=new m(0).toRed(this.curve.red),this.zOne=!1)}toP(){if(this.isInfinity())return new D(null,null);let t=this.z.redInvm(),n=t.redSqr(),i=this.x.redMul(n),s=this.y.redMul(n).redMul(t);return new D(i,s)}neg(){return new r(this.x,this.y.redNeg(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;let n=t.z.redSqr(),i=this.z.redSqr(),s=this.x.redMul(n),o=t.x.redMul(i),c=this.y.redMul(n.redMul(t.z)),a=t.y.redMul(i.redMul(this.z)),f=s.redSub(o),l=c.redSub(a);if(f.cmpn(0)===0)return l.cmpn(0)===0?this.dbl():new r(null,null,null);let u=f.redSqr(),g=u.redMul(f),y=s.redMul(u),w=l.redSqr().redIAdd(g).redISub(y).redISub(y),S=l.redMul(y.redISub(w)).redISub(c.redMul(g)),M=this.z.redMul(t.z).redMul(f);return new r(w,S,M)}mixedAdd(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;if(t.x===null||t.y===null)throw new Error("Point coordinates cannot be null");let n=this.z.redSqr(),i=this.x,s=t.x.redMul(n),o=this.y,c=t.y.redMul(n).redMul(this.z),a=i.redSub(s),f=o.redSub(c);if(a.cmpn(0)===0)return f.cmpn(0)===0?this.dbl():new r(null,null,null);let l=a.redSqr(),u=l.redMul(a),g=i.redMul(l),y=f.redSqr().redIAdd(u).redISub(g).redISub(g),w=f.redMul(g.redISub(y)).redISub(o.redMul(u)),S=this.z.redMul(a);return new r(y,w,S)}dblp(t){if(t===0)return this;if(this.isInfinity())return this;if(t===void 0)return this.dbl();let n=this;for(let i=0;i<t;i++)n=n.dbl();return n}dbl(){if(this.isInfinity())return this;let t,n,i;if(this.zOne){let s=this.x.redSqr(),o=this.y.redSqr(),c=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(s).redISub(c);a=a.redIAdd(a);let f=s.redAdd(s).redIAdd(s),l=f.redSqr().redISub(a).redISub(a),u=c.redIAdd(c);u=u.redIAdd(u),u=u.redIAdd(u),t=l,n=f.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{let s=this.x.redSqr(),o=this.y.redSqr(),c=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(s).redISub(c);a=a.redIAdd(a);let f=s.redAdd(s).redIAdd(s),l=f.redSqr(),u=c.redIAdd(c);u=u.redIAdd(u),u=u.redIAdd(u),t=l.redISub(a).redISub(a),n=f.redMul(a.redISub(t)).redISub(u),i=this.y.redMul(this.z),i=i.redIAdd(i)}return new r(t,n,i)}eq(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t||(t=t,this.isInfinity()&&t.isInfinity()))return!0;if(this.isInfinity()!==t.isInfinity())return!1;let n=this.z.redSqr(),i=t.z.redSqr();if(this.x.redMul(i).redISub(t.x.redMul(n)).cmpn(0)!==0)return!1;let s=n.redMul(this.z),o=i.redMul(t.z);return this.y.redMul(o).redISub(t.y.redMul(s)).cmpn(0)===0}eqXToP(t){let n=this.z.redSqr(),i=t.toRed(this.curve?.red).redMul(n);if(this.x.cmp(i)===0)return!0;let s=t.clone();if(this.curve?.redN==null)throw new Error("Curve or redN is not initialized.");let o=this.curve.redN.redMul(n);for(;s.cmp(this.curve.p)<0;){if(s.iadd(this.curve.n),s.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(o),this.x.cmp(i)===0)return!0}return!1}inspect(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"}isInfinity(){return this.z.cmpn(0)===0}};function mr(r,e,t){let n=-r,i=(e.X^t.X)&n,s=(e.Y^t.Y)&n,o=(e.Z^t.Z)&n;e.X^=i,t.X^=i,e.Y^=s,t.Y^=s,e.Z^=o,t.Z^=o}var P=0n,V=1n,un=2n,ts=3n,ns=4n,rs=8n,ee=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,le=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,wr=(1n<<256n)-1n;function pn(r){let e=r>>256n;return r=(r&wr)+(e<<32n)+e*977n,e=r>>256n,r=(r&wr)+(e<<32n)+e*977n,r>=ee&&(r-=ee),r}var ve=r=>pn((r%ee+ee)%ee),Q=(r,e)=>r>=e?r-e:ee-(e-r),B=(r,e)=>pn(r*e),xr=(r,e)=>pn(r+e),Le=r=>{let e=V,t=P,n=ve(r),i=ee;for(;n>V;){let s=i/n;[e,t]=[t-e*s,e],[n,i]=[i-n*s,n]}return ve(e)},is=r=>B(r,r),ss=(r,e)=>{let t=1n;for(r=ve(r);e>0n;)(e&1n)!==0n&&(t=B(t,r)),r=B(r,r),e>>=1n;return t},os=ee+1n>>2n,cs=r=>{let e=ss(r,os);return B(e,e)!==ve(r)?null:e},as=r=>m.isBN(r)?BigInt("0x"+r.toString(16)):typeof r=="string"?BigInt("0x"+r):Array.isArray(r)?BigInt("0x"+G(r)):BigInt(r),kt=BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Tt=BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),yr=new Map,Je=r=>{let{X:e,Y:t,Z:n}=r;if(t===P)return{X:P,Y:V,Z:P};let i=B(t,t),s=B(ns,B(e,i)),o=B(ts,B(e,e)),c=Q(B(o,o),B(un,s)),a=Q(B(o,Q(s,c)),B(rs,B(i,i))),f=B(un,B(t,n));return{X:c,Y:a,Z:f}},Pe=(r,e)=>{if(r.Z===P)return e;if(e.Z===P)return r;let t=B(r.Z,r.Z),n=B(e.Z,e.Z),i=B(r.X,n),s=B(e.X,t),o=B(r.Y,B(n,e.Z)),c=B(e.Y,B(t,r.Z)),a=Q(s,i),f=Q(c,o);if(a===P)return f===P?Je(r):{X:P,Y:V,Z:P};let l=B(a,a),u=B(a,l),g=B(i,l),y=Q(Q(B(f,f),u),B(un,g)),w=Q(B(f,Q(g,y)),B(o,u)),S=B(a,B(r.Z,e.Z));return{X:y,Y:w,Z:S}},fs=r=>r.Z===P?r:{X:r.X,Y:ee-r.Y,Z:r.Z},ds=(r,e)=>{let t=`${r}:${e.x.toString(16)}:${e.y.toString(16)}`,n=yr.get(t);if(n!==void 0)return n;let i=Array.from({length:1<<r-1},()=>({X:P,Y:V,Z:P})),s={X:e.x,Y:e.y,Z:V};i[0]=s;let o=Je(s);for(let c=1;c<i.length;c++)i[c]=Pe(i[c-1],o);return yr.set(t,i),i},hs=(r,e)=>{let t=[],n=1n<<BigInt(e),i=n>>1n,s=r;for(;s>0n;){if((s&V)===P)t.push(0);else{let o=s&n-1n;o>i&&(o-=n),t.push(Number(o)),s-=o}s>>=V}return t},Lt=(r,e,t=5)=>{let n=ds(t,e),i=hs(r,t),s={X:P,Y:V,Z:P};for(let o=i.length-1;o>=0;o--){s=Je(s);let c=i[o];if(c!==0){let a=Math.abs(c)>>1,f=c>0?n[a]:fs(n[a]);s=Pe(s,f)}}return s},Ie=r=>{let e=r%le;return e<0n&&(e+=le),e},Qe=(r,e)=>Ie(r*e),gn=r=>{let e=1n,t=0n,n=Ie(r),i=le;for(;n>1n;){let s=i/n;[e,t]=[t-e*s,e],[n,i]=[i-n*s,n]}return Ie(e)},O,Sr,vr,Ir,Er,Ar,bn,Br,k=class k extends ye{constructor(t,n,i=!0){super("affine");C(this,O);b(this,"x");b(this,"y");b(this,"inf");this.precomputed=null,t===null&&n===null?(this.x=null,this.y=null,this.inf=!0):(m.isBN(t)||(t=new m(t,16)),this.x=t,m.isBN(n)||(n=new m(n,16)),this.y=n,i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red===null&&(this.x=this.x.toRed(this.curve.red)),this.y.red===null&&(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}static _assertOnCurve(t){if(!t.validate())throw new Error("Invalid point");return t}static fromDER(t){if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===64){if(t[0]===6){if(t.at(-1)%2!==0)throw new Error("Point string value is wrong length")}else if(t[0]===7&&t.at(-1)%2!==1)throw new Error("Point string value is wrong length");let i=new k(t.slice(1,33),t.slice(33,65));return k._assertOnCurve(i)}else if((t[0]===2||t[0]===3)&&t.length-1===32)return k._assertOnCurve(k.fromX(t.slice(1,33),t[0]===3));throw new Error("Unknown point format")}static fromString(t){let n=q(t,"hex");return k._assertOnCurve(k.fromDER(n))}static fromX(t,n){let i=as(t);i=ve(i);let s=xr(B(is(i),i),7n),o=cs(s);if(o===null)throw new Error("Invalid point");let c=o;(c&V)!==(n?V:P)&&(c=Q(ee,c));let a=new m(i.toString(16),16),f=new m(c.toString(16),16);return k._assertOnCurve(new k(a,f))}static fromJSON(t,n){typeof t=="string"&&(t=JSON.parse(t));let i=new k(t[0],t[1],n);if(i=k._assertOnCurve(i),typeof t[2]!="object"||t[2]===null)return i;let s=t[2],o=c=>{let a=new k(c[0],c[1],n);return k._assertOnCurve(a)};return i.precomputed={beta:null,doubles:typeof s.doubles=="object"&&s.doubles!==null?{step:s.doubles.step,points:[i].concat(s.doubles.points.map(o))}:void 0,naf:typeof s.naf=="object"&&s.naf!==null?{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(o))}:void 0},i}validate(){if(this.inf||this.x==null||this.y==null)return!1;try{let t=BigInt("0x"+this.x.fromRed().toString(16)),n=BigInt("0x"+this.y.fromRed().toString(16)),i=B(n,n),s=xr(B(B(t,t),t),7n);return i===s}catch{return!1}}encode(t=!0,n){if(this.inf)return n==="hex"?"00":[0];let i=this.curve.p.byteLength(),s=this.getX().toArray("be",i),o;return t?o=[this.getY().isEven()?2:3].concat(s):o=[4].concat(s,this.getY().toArray("be",i)),n==="hex"?G(o):o}toString(){return this.encode(!0,"hex")}toJSON(){return this.precomputed==null?[this.x,this.y]:[this.x,this.y,typeof this.precomputed=="object"&&this.precomputed!==null?{doubles:this.precomputed.doubles==null?void 0:{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf==null?void 0:{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}:void 0]}inspect(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+(this.x?.fromRed()?.toString(16,2)??"undefined")+" y: "+(this.y?.fromRed()?.toString(16,2)??"undefined")+">"}isInfinity(){return this.inf}add(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return new k(null,null);if(this.x?.cmp(t.x??new m(0))===0)return new k(null,null);let n={X:BigInt("0x"+this.x.fromRed().toString(16)),Y:BigInt("0x"+this.y.fromRed().toString(16)),Z:V},i={X:BigInt("0x"+t.x.fromRed().toString(16)),Y:BigInt("0x"+t.y.fromRed().toString(16)),Z:V},s=Pe(n,i);if(s.Z===P)return new k(null,null);let o=Le(s.Z),c=B(o,o),a=B(s.X,c),f=B(s.Y,B(c,o));return new k(a.toString(16),f.toString(16))}dbl(){if(this.inf)return this;if(this.x===null||this.y===null)throw new Error("Point coordinates cannot be null");let t=BigInt("0x"+this.x.fromRed().toString(16)),n=BigInt("0x"+this.y.fromRed().toString(16));if(n===P)return new k(null,null);let i=Je({X:t,Y:n,Z:V}),s=Le(i.Z),o=B(s,s),c=B(i.X,o),a=B(i.Y,B(o,s));return new k(c.toString(16),a.toString(16))}getX(){return(this.x??new m(0)).fromRed()}getY(){return(this.y??new m(0)).fromRed()}mul(t){if(m.isBN(t)||(t=new m(t,16)),t=t,this.inf)return this;let n=t.isNeg(),i=n?t.neg():t,s=BigInt("0x"+i.toString(16));if(s=ve(s),s===P)return new k(null,null);if(s===P)return new k(null,null);if(this.x===null||this.y===null)throw new Error("Point coordinates cannot be null");let o,c;this===this.curve.g?(o=kt,c=Tt):(o=BigInt("0x"+this.x.fromRed().toString(16)),c=BigInt("0x"+this.y.fromRed().toString(16)));let a=Lt(s,{x:o,y:c});if(a.Z===P)return new k(null,null);let f=Le(a.Z),l=B(f,f),u=B(a.X,l),g=B(a.Y,B(l,f)),y=new m(u.toString(16),16),w=new m(g.toString(16),16),S=new k(y,w);return n?S.neg():S}mulCT(t){if(m.isBN(t)||(t=new m(t,16)),t=t,this.inf)return new k(null,null);let n=t.isNeg(),i=n?t.neg():t,s=BigInt("0x"+i.toString(16));if(s=ve(s),s===0n)return new k(null,null);let o=this===this.curve.g?kt:BigInt("0x"+this.getX().toString(16)),c=this===this.curve.g?Tt:BigInt("0x"+this.getY().toString(16)),a={X:0n,Y:1n,Z:0n},f={X:o,Y:c,Z:1n},l=s.toString(2);for(let M of l){let N=M==="1"?1n:0n;mr(N,a,f),f=Pe(a,f),a=Je(a),mr(N,a,f)}if(a.Z===0n)return new k(null,null);let u=Le(a.Z),g=B(u,u),y=B(a.X,g),w=B(a.Y,B(g,u)),S=new k(y.toString(16),w.toString(16));return n?S.neg():S}mulAdd(t,n,i){let s=[this,n],o=[t,i];return h(this,O,bn).call(this,s,o)}jmulAdd(t,n,i){let s=[this,n],o=[t,i];return h(this,O,bn).call(this,s,o,!0)}eq(t){return this===t||this.inf===t.inf&&(this.inf||(this.x??new m(0)).cmp(t.x??new m(0))===0&&(this.y??new m(0)).cmp(t.y??new m(0))===0)}neg(t){if(this.inf)return this;let n=new k(this.x,(this.y??new m(0)).redNeg());if(t===!0&&this.precomputed!=null){let i=this.precomputed,s=o=>o.neg();n.precomputed={naf:i.naf==null?void 0:{wnd:i.naf.wnd,points:i.naf.points.map(s)},doubles:i.doubles==null?void 0:{step:i.doubles.step,points:i.doubles.points.map(o=>o.neg())},beta:void 0}}return n}dblp(t){let n;for(let i=0;i<t;i++)n=(n??this).dbl();return n??this}toJ(){return this.inf?new Se(null,null,null):new Se(this.x,this.y,this.curve.one)}_combineWnafPair(t,n,i){let{points:s,coeffs:o,wndWidth:c,wnd:a,naf:f,currentMax:l}=i;if(c[t]!==1||c[n]!==1)return f[t]=this.curve.getNAF(o[t],c[t],this.curve._bitLength),f[n]=this.curve.getNAF(o[n],c[n],this.curve._bitLength),Math.max(l,f[t].length,f[n].length);let u=[s[t],null,null,s[n]],g=s[t].y??new m(0),y=s[n].y??new m(0);g.cmp(y)===0?(u[1]=s[t].add(s[n]),u[2]=s[t].toJ().mixedAdd(s[n].neg())):g.cmp(y.redNeg())===0?(u[1]=s[t].toJ().mixedAdd(s[n]),u[2]=s[t].add(s[n].neg())):(u[1]=s[t].toJ().mixedAdd(s[n]),u[2]=s[t].toJ().mixedAdd(s[n].neg()));let w=[-3,-1,-5,-7,0,7,5,1,3],S=this.curve.getJSF(o[t],o[n]),M=Math.max(l,S[0].length);f[t]=Array.from({length:M}),f[n]=Array.from({length:M});for(let N=0;N<M;N++){let H=Math.trunc(S[0][N]),Z=Math.trunc(S[1][N]);f[t][N]=w[(H+1)*3+(Z+1)],f[n][N]=0,a[t]=u}return M}_collectWnafStep(t,n,i,s){let o=t,c=0;for(;o>=0;){let a=!0;for(let f=0;f<n;f++)s[f]=new m(typeof i[f][o]=="number"?i[f][o]:0),s[f].isZero()||(a=!1);if(!a)break;c++,o--}return o>=0&&c++,{index:o,doubles:c}}_getDoubles(t,n){if(typeof this.precomputed=="object"&&this.precomputed!==null&&typeof this.precomputed.doubles=="object"&&this.precomputed.doubles!==null)return this.precomputed.doubles;let i=[this],s;for(let o=0;o<(n??0);o+=t??1){for(let c=0;c<(t??1);c++)s=(s??this).dbl();i.push(s)}return{step:t??1,points:i}}};O=new WeakSet,Sr=function(){if(typeof this.curve.endo!="object")return;let t=this.precomputed;if(typeof t=="object"&&t!==null&&typeof t.beta=="object"&&t.beta!==null)return t.beta;let n=new k((this.x??new m(0)).redMul(this.curve.endo.beta),this.y);if(t!=null){let i=this.curve,s=o=>{let c=o;if(c.x===null)throw new Error("p.x is null");if(i.endo===void 0||i.endo===null)throw new Error("curve.endo is undefined");return new k(c.x.redMul(i.endo.beta),c.y)};t.beta=n,n.precomputed={beta:null,naf:t.naf==null?void 0:{wnd:t.naf.wnd,points:t.naf.points.map(s)},doubles:t.doubles==null?void 0:{step:t.doubles.step,points:t.doubles.points.map(s)}}}return n},vr=function(t,n,i,s,o){var c;for(let a=0;a<i;a++){let f=h(c=n[a],O,Br).call(c,t);s[a]=f.wnd,o[a]=f.points}},Ir=function(t,n,i,s,o,c){let a=0;for(let f=i-1;f>=1;f-=2)a=this._combineWnafPair(f-1,f,{points:t,coeffs:n,wndWidth:s,wnd:o,naf:c,currentMax:a});return a},Er=function(t,n,i,s){let o=new m(1),c=new m(2),a=t;for(let f=0;f<n;f++){let l=i[f];if(l.cmpn(0)===0)continue;let u=l.isNeg()?s[f][l.neg().sub(o).div(c).toNumber()].neg():s[f][l.sub(o).div(c).toNumber()];a=u.type==="affine"?a.mixedAdd(u):a.add(u)}return a},Ar=function(t,n,i,s,o){let c=this.curve._wnafT1.length,a=Array.from({length:c}),f=Array.from({length:c},()=>[]),l=Array.from({length:c},()=>[]);h(this,O,vr).call(this,t,n,s,a,f);let u=h(this,O,Ir).call(this,n,i,s,a,f,l),g=new Se(null,null,null),y=this.curve._wnafT4,w=u;for(;w>=0;){let S=this._collectWnafStep(w,s,l,y);if(w=S.index,g=g.dblp(S.doubles),w<0)break;g=h(this,O,Er).call(this,g,s,y,f),w--}for(let S=0;S<s;S++)f[S]=[];return o===!0?g:g.toP()},bn=function(t,n,i){var f;let s=Array.from({length:t.length*2}),o=Array.from({length:t.length*2}),c;for(c=0;c<t.length;c++){let l=this.curve._endoSplit(n[c]),u=t[c],g=h(f=u,O,Sr).call(f)??new k(null,null);l.k1.negative!==0&&(l.k1.ineg(),u=u.neg(!0)),l.k2.negative!==0&&(l.k2.ineg(),g=g.neg(!0)),s[c*2]=u,s[c*2+1]=g,o[c*2]=l.k1,o[c*2+1]=l.k2}let a=h(this,O,Ar).call(this,1,s,o,c*2,i);for(let l=0;l<c*2;l++)s[l]=null,o[l]=null;return a},Br=function(t){if(typeof this.precomputed=="object"&&this.precomputed!==null&&typeof this.precomputed.naf=="object"&&this.precomputed.naf!==null)return this.precomputed.naf;let n=[this],i=(1<<t)-1,s=i===1?null:this.dbl();for(let o=1;o<i;o++)s!==null&&(n[o]=n[o-1].add(s));return{wnd:t,points:n}};var D=k;var te=class r extends D{static fromPrivateKey(e){let n=new U().g.mul(e);return new r(n.x,n.y)}static fromString(e){let t=D.fromString(e);return new r(t.x,t.y)}static fromDER(e){let t=D.fromDER(e);return new r(t.x,t.y)}constructor(e,t=null,n=!0){if(e instanceof D)super(e.getX(),e.getY());else{if(t===null&&n&&typeof e=="string"&&(e.length===66||e.length===130))throw new Error('You are using the "new PublicKey()" constructor with a DER hex string. You need to use "PublicKey.fromString()" instead.');super(e,t,n)}}deriveSharedSecret(e){if(!this.validate())throw new Error("Public key not valid for ECDH secret derivation");return this.mulCT(e)}verify(e,t,n){let i=new m(xe(e,n),16);return He(i,t,this)}toDER(e){return e==="hex"?this.encode(!0,e):this.encode(!0)}toHash(e){let t=sr(this.encode(!0));return e==="hex"?G(t):t}toAddress(e=[0]){if(typeof e=="string")if(e==="testnet"||e==="test")e=[111];else if(e==="mainnet"||e==="main")e=[0];else throw new Error(`Invalid prefix ${e}`);return Mt(this.toHash(),e)}deriveChild(e,t,n,i){let s;if(typeof i=="function"){let u=i(e,this);u===void 0?(s=this.deriveSharedSecret(e),typeof n=="function"&&n(e,this,s)):s=u}else s=this.deriveSharedSecret(e);let o=q(t,"utf8"),c=It(s.encode(!0),o),f=new U().g.mul(new m(c)),l=this.add(f);return new r(l.x,l.y)}static fromMsgHashAndCompactSignature(e,t,n){let i=q(t,n);if(i.length!==65)throw new Error("Invalid Compact Signature");let s=i[0];if(s<27||s>=35)throw new Error("Invalid Compact Byte");let o=i[0]-27;return o>3&&(o-=4),new Ee(new m(i.slice(1,33)),new m(i.slice(33,65))).RecoverPublicKey(o,e)}};var Ee=class r{constructor(e,t){b(this,"r");b(this,"s");this.r=e,this.s=t}static fromDER(e,t){let n=(u,g)=>{let y=u[g.place++];if((y&128)===0)return y;throw new Error("Invalid DER entity length")};class i{constructor(){b(this,"place",0)}}e=q(e,t);let s=new i;if(e[s.place++]!==48)throw new Error("Signature DER must start with 0x30");if(n(e,s)+s.place!==e.length)throw new Error("Signature DER invalid");if(e[s.place++]!==2)throw new Error("Signature DER invalid");let c=n(e,s),a=e.slice(s.place,c+s.place);if(s.place+=c,e[s.place++]!==2)throw new Error("Signature DER invalid");let f=n(e,s);if(e.length!==f+s.place)throw new Error("Invalid R-length in signature DER");let l=e.slice(s.place,f+s.place);if(a[0]===0){if((a[1]&128)===0)throw new Error("Invalid R-value in signature DER");a=a.slice(1)}if(l[0]===0){if((l[1]&128)===0)throw new Error("Invalid S-value in signature DER");l=l.slice(1)}return new r(new m(a),new m(l))}static fromCompact(e,t){if(e=q(e,t),e.length!==65)throw new Error("Invalid Compact Signature");let n=e[0];if(n<27||n>=35)throw new Error("Invalid Compact Byte");return new r(new m(e.slice(1,33)),new m(e.slice(33,65)))}verify(e,t,n){let i=new m(xe(e,n),16);return He(i,this,t)}toString(e){return this.toDER(e)}toDER(e){let t=(f,l)=>{if(l<128)f.push(l);else throw new Error("len must be < 0x80")},n=f=>{let l=0,u=f.length-1;for(;f[l]===0&&(f[l+1]&128)===0&&l<u;)l++;return l===0?f:f.slice(l)},i=this.r.toArray(),s=this.s.toArray();for((i[0]&128)!==0&&(i=[0].concat(i)),(s[0]&128)!==0&&(s=[0].concat(s)),i=n(i),s=n(s);s[0]===0&&(s[1]&128)===0;)s=s.slice(1);let o=[2];t(o,i.length),o=o.concat(i),o.push(2),t(o,s.length);let c=o.concat(s),a=[48];return t(a,c.length),a=a.concat(c),e==="hex"?G(a):e==="base64"?dn(a):a}toCompact(e,t,n){if(e<0||e>3)throw new Error("Invalid recovery param");if(typeof t!="boolean")throw new TypeError("Invalid compressed param");let i=27+e;t&&(i+=4);let s=[i];return s=s.concat(this.r.toArray("be",32)),s=s.concat(this.s.toArray("be",32)),n==="hex"?G(s):n==="base64"?dn(s):s}RecoverPublicKey(e,t){let n=this.r,i=this.s,s=(e&1)!==0,o=e>>1,c=new U,a=c.n,f=c.g,l=o===0?n:n.add(a),u=D.fromX(l,s);if(!u.mul(a).isInfinity())throw new Error("nR is not at infinity");let y=t.neg().umod(a),w=n.invm(a),S=w.mul(i).umod(a),M=w.mul(y).umod(a),N=f.mul(M).add(u.mul(S)),H=new te(N);return H.validate(),H}CalculateRecoveryFactor(e,t){for(let n=0;n<4;n++){let i;try{i=this.RecoverPublicKey(n,t)}catch{continue}if(e.eq(i))return n}throw new Error("Unable to find valid recovery factor")}};var et=class{constructor(e,t){b(this,"K");b(this,"V");let n=q(e,"hex"),i=q(t,"hex");if(n.length!==32)throw new Error("Entropy must be exactly 32 bytes (256 bits)");if(i.length!==32)throw new Error("Nonce must be exactly 32 bytes (256 bits)");let s=n.concat(i);this.K=Array.from({length:32}),this.V=Array.from({length:32});for(let o=0;o<32;o++)this.K[o]=0,this.V[o]=1;this.update(s)}hmac(){return new $e(this.K)}update(e){let t=this.hmac().update(this.V).update([0]);e!==void 0&&(t=t.update(e)),this.K=t.digest(),this.V=this.hmac().update(this.V).digest(),e!==void 0&&(this.K=this.hmac().update(this.V).update([1]).update(e).digest(),this.V=this.hmac().update(this.V).digest())}generate(e){let t=[];for(;t.length<e;)this.V=this.hmac().update(this.V).digest(),t=t.concat(this.V);let n=t.slice(0,e);return this.update(),G(n)}};function Nr(r,e,t=new U){let n=r.byteLength()*8-t.n.bitLength();return n>0&&r.iushrn(n),e!==!0&&r.cmp(t.n)>=0?r.sub(t.n):r}function Ae(r){let e=r.toArray("be"),t=0n;for(let n of e)t=t<<8n|BigInt(n);return t}var tt=new U,mn=tt.n.byteLength(),ls=tt.n.subn(1),us=le>>1n;function bs(r,e,t){let n;if(typeof r=="function"?n=r(e):r!==void 0&&m.isBN(r)?n=r:n=new m(t.generate(mn),16),n==null)throw new Error("k is undefined");return Nr(n,!0)}function Pt(r,e){if(r)throw new Error(e)}function ps(r,e,t,n,i){if(r.cmpn(1)<0||r.cmp(ls)>0)return Pt(i,"Invalid fixed custom K value (must be >1 and <N-1)");let s=tt.g.mulCT(r);if(s.isInfinity())return Pt(i,"Invalid fixed custom K value (k\xB7G at infinity)");let o=Ie(BigInt("0x"+s.getX().toString(16)));if(o===0n)return Pt(i,"Invalid fixed custom K value (r == 0)");let c=gn(BigInt("0x"+r.toString(16))),a=Ie(e+Qe(o,t)),f=Qe(c,a);return f===0n?Pt(i,"Invalid fixed custom K value (s == 0)"):(n&&f>us&&(f=le-f),new Ee(new m(o.toString(16),16),new m(f.toString(16),16)))}var Mr=(r,e,t=!1,n)=>{let i=tt.n.bitLength();if(r.bitLength()>i)throw new Error(`ECDSA message is too large: expected <= ${i} bits. Callers must hash messages before signing.`);r=Nr(r);let s=Ae(r),o=Ae(e),c=e.toArray("be",mn),a=r.toArray("be",mn),f=new et(c,a),l=m.isBN(n);for(let u=0;;u++){let g=ps(bs(n,u,f),s,o,t,l);if(g!=null)return g}},He=(r,e,t)=>{let n=tt.n.bitLength();if(r.bitLength()>n)return!1;let i=Ae(r);if(t.x==null||t.y==null)throw new Error("Invalid public key: missing coordinates.");let s={x:Ae(t.x),y:Ae(t.y)},o={r:Ae(e.r),s:Ae(e.s)},{r:c,s:a}=o,f=i;if(c<=P||c>=le||a<=P||a>=le)return!1;let l=gn(a);if(l===0n)return!1;let u=Qe(f,l),g=Qe(c,l),y=Lt(u,{x:kt,y:Tt}),w=Lt(g,s),S=Pe(y,w);if(S.Z===0n)return!1;let M=Le(S.Z),N=B(M,M),H=B(S.X,N);return Ie(H)===c};var wn=class{constructor(){b(this,"_rand");let e=()=>{throw new Error("No secure random number generator is available in this environment.")};if(this._rand=e,typeof globalThis<"u"&&typeof globalThis.crypto?.getRandomValues=="function"){this._rand=t=>this.getRandomValues(globalThis,t);return}if(globalThis.self!==void 0&&typeof globalThis.self.crypto?.getRandomValues=="function"){this._rand=t=>this.getRandomValues(globalThis.self,t);return}if(globalThis.window!==void 0&&typeof globalThis.window.crypto?.getRandomValues=="function"){this._rand=t=>this.getRandomValues(globalThis.window,t);return}if(typeof process<"u"&&typeof process.getBuiltinModule=="function"){let t=process.getBuiltinModule("node:crypto");if(typeof t?.randomBytes=="function"){this._rand=n=>Array.from(t.randomBytes(n));return}}this._rand=e}getRandomValues(e,t){let n=new Uint8Array(t);return e.crypto.getRandomValues(n),Array.from(n)}generate(e){return this._rand(e)}},Rr=null,gs=r=>(Rr??(Rr=new wn),Rr.generate(r)),Be=gs;var W=255,ms=129,kr=/^[1-9A-HJ-NP-Za-km-z]{1,64}$/;function Tr(r,e,t){if(!Number.isSafeInteger(r)||r<t||r>W)throw new TypeError(`threshold must be a safe integer from ${t} to ${W}`);if(r>e)throw new Error("threshold cannot exceed the number of points")}var $=class r{constructor(e,t){b(this,"x");b(this,"y");let n=new U().p;this.x=e.umod(n),this.y=t.umod(n)}toString(){return Nt(this.x.toArray())+"."+Nt(this.y.toArray())}static fromString(e){if(typeof e!="string"||e.length>ms)throw new TypeError("Finite-field point must use a bounded canonical Base58 representation");let[t,n,i]=e.split(".");if(i!==void 0||t===void 0||n===void 0||!kr.test(t)||!kr.test(n))throw new TypeError("Finite-field point must use a bounded canonical Base58 representation");let s=new r(new m(Bt(t)),new m(Bt(n)));if(s.toString()!==e)throw new TypeError("Finite-field point must use a bounded canonical Base58 representation");return s}},Ue=class r{constructor(e,t){b(this,"points");b(this,"threshold");if(!Array.isArray(e)||e.length===0||e.length>W)throw new TypeError(`points must contain from 1 to ${W} entries`);let n=t??e.length;Tr(n,e.length,1),this.points=e.slice(),this.threshold=n}static fromPrivateKey(e,t){if(!Number.isSafeInteger(t)||t<2||t>W)throw new TypeError(`threshold must be a safe integer from 2 to ${W}`);let n=new U().p,i=[new $(new m(0),new m(e.toArray()))];for(let s=1;s<t;s++){let o=new m(Be(32)).umod(n),c=new m(Be(32)).umod(n);i.push(new $(o,c))}return new r(i)}valueAt(e){if(Tr(this.threshold,this.points.length,1),!(e instanceof m))throw new TypeError("x must be a BigNumber");let t=new U().p,n=new Set;for(let o=0;o<this.threshold;o++){let c=this.points[o];if(!(c instanceof $)||!(c.x instanceof m)||!(c.y instanceof m))throw new TypeError("points must contain finite-field points");if(c.x.isNeg()||c.y.isNeg()||c.x.gte(t)||c.y.gte(t))throw new TypeError("point coordinates must be canonical field elements");let a=c.x.toString(16);if(n.has(a))throw new Error("Polynomial points must have unique x coordinates");n.add(a)}let i=e.umod(t),s=new m(0);for(let o=0;o<this.threshold;o++){let c=this.points[o].y;for(let a=0;a<this.threshold;a++)if(o!==a){let f=this.points[a].x,l=this.points[o].x,u=i.sub(f).umod(t),y=l.sub(f).umod(t).invm(t),w=u.mul(y).umod(t);c=c.mul(w).umod(t)}s=s.add(c).umod(t)}return s}};var ws=256,Lr=/^[1-9A-HJ-NP-Za-km-z]{1,64}$/,xs=/^(?:[2-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/,Pr=/^[0-9a-f]{8}$/;function xn(r,e,t){if(!Array.isArray(r)||r.length===0||r.length>W)throw new TypeError(`shares must contain from 1 to ${W} entries`);if(!Number.isSafeInteger(e)||e<2||e>W)throw new TypeError(`threshold must be a safe integer from 2 to ${W}`);if(typeof t!="string"||!Pr.test(t))throw new TypeError("integrity must be an 8-character lowercase hexadecimal string")}var nt=class r{constructor(e,t,n){b(this,"points");b(this,"threshold");b(this,"integrity");this.points=e,this.threshold=t,this.integrity=n}static fromBackupFormat(e){if(!Array.isArray(e)||e.length===0||e.length>W)throw new TypeError(`shares must contain from 1 to ${W} entries`);let t=0,n="",i=[];for(let s=0;s<e.length;s++){if(!Object.prototype.hasOwnProperty.call(e,s))throw new TypeError("shares must be a dense array");let o=e[s];if(typeof o!="string"||o.length>ws)throw new TypeError(`Invalid share format in share ${s.toString()}`);let c=o.split(".");if(c.length!==4)throw new Error(`Invalid share format in share ${s.toString()}. Expected format: "x.y.t.i"`);let[a,f,l,u]=c;if(a===void 0||f===void 0||l===void 0||u===void 0||!Lr.test(a)||!Lr.test(f)||!xs.test(l)||!Pr.test(u))throw new TypeError(`Invalid canonical share data in share ${s.toString()}`);let g=Number(l);if(s!==0&&t!==g)throw new Error("Threshold mismatch in share "+s.toString());if(s!==0&&n!==u)throw new Error("Integrity mismatch in share "+s.toString());t=g,n=u,i.push($.fromString(`${a}.${f}`))}return xn(i,t,n),new r(i,t,n)}toBackupFormat(){xn(this.points,this.threshold,this.integrity);let e=[];for(let t=0;t<this.points.length;t++){if(!Object.prototype.hasOwnProperty.call(this.points,t))throw new TypeError("shares must be a dense array");let n=this.points[t];if(!(n instanceof $))throw new TypeError("shares must contain finite-field points");let i=n.toString();if($.fromString(i).toString()!==i)throw new TypeError("shares must contain canonical finite-field points");e.push(`${i}.${this.threshold.toString()}.${this.integrity}`)}return e}},Ne=class r extends m{static fromRandom(){return new r(Be(32))}static fromString(e,t="hex"){return new r(super.fromString(e,t).toArray())}static fromHex(e){return new r(super.fromHex(e,"big"))}static fromWif(e,t=1){let n=lr(e,void 0,t);if(n.data.length!==33)throw new Error("Invalid WIF length");if(n.data[32]!==1)throw new Error("Invalid WIF padding");return new r(n.data.slice(0,32))}constructor(e=0,t=10,n="be",i="apply"){if(e instanceof m?(super(),e.copy(this)):super(e,t,n),i!=="nocheck"){let s=this.checkInField();if(!s.inField){if(i==="error")throw new Error("Input is out of field");m.move(this,s.modN)}}}checkInField(){let e=new U,t=this.mod(e.n);return{inField:this.cmp(t)===0,modN:t}}isValid(){return this.checkInField().inField}sign(e,t,n=!0,i){let s=new m(xe(e,t),16);return Mr(s,this,n,i)}verify(e,t,n){let i=new m(xe(e,n),16);return He(i,t,this.toPublicKey())}toPublicKey(){let t=new U().g.mulCT(this);return new te(t.x,t.y)}toWif(e=[128]){if(!this.isValid())throw new Error("Value is out of field");return Mt([...this.toArray("be",32),1],e)}toAddress(e=[0]){return this.toPublicKey().toAddress(e)}toHex(){return super.toHex(32)}toString(e="hex",t=64){return super.toString(e,t)}deriveSharedSecret(e){if(!e.validate())throw new Error("Public key not valid for ECDH secret derivation");return e.mulCT(this)}deriveChild(e,t,n,i){let s;if(typeof i=="function"){let f=i(this,e);f===void 0?(s=this.deriveSharedSecret(e),typeof n=="function"&&n(this,e,s)):s=f}else s=this.deriveSharedSecret(e);let o=q(t,"utf8"),c=It(s.encode(!0),o),a=new U;return new r(this.add(new m(c)).mod(a.n).toArray())}toKeyShares(e,t){if(typeof e!="number"||typeof t!="number")throw new TypeError("threshold and totalShares must be numbers");if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t))throw new TypeError("threshold and totalShares must be safe integers");if(e<2)throw new Error("threshold must be at least 2");if(t<2)throw new Error("totalShares must be at least 2");if(e>t)throw new Error("threshold should be less than or equal to totalShares");if(e>W||t>W)throw new RangeError(`threshold and totalShares cannot exceed ${W}`);let n=Ue.fromPrivateKey(this,e),i=[],s=new Set,o=new U,c=Be(64);for(let f=0;f<t;f++){let l,u=0;do{let y=[f,u,...Be(32)],w=or(c,y);if(l=new m(w).umod(o.p),u++,u>5)throw new Error("Failed to generate unique x coordinate after 5 attempts")}while(l.isZero()||s.has(l.toString()));s.add(l.toString());let g=n.valueAt(l);i.push(new $(l,g))}let a=this.toPublicKey().toHash("hex").slice(0,8);return new nt(i,e,a)}toBackupShares(e,t){return this.toKeyShares(e,t).toBackupFormat()}static fromBackupShares(e){return r.fromKeyShares(nt.fromBackupFormat(e))}static fromKeyShares(e){if(e===null||typeof e!="object")throw new TypeError("keyShares must be an object");let t=e.points,n=e.threshold,i=e.integrity;if(xn(t,n,i),t.length<n)throw new Error(`At least ${n} shares are required to reconstruct the private key`);let s=[],o=new U().p;for(let l=0;l<n;l++){if(!Object.prototype.hasOwnProperty.call(t,l))throw new TypeError("shares must be a dense array");let u=t[l];if(!(u instanceof $)||!(u.x instanceof m)||!(u.y instanceof m))throw new TypeError("shares must contain finite-field points");if(u.x.isNeg()||u.y.isNeg()||u.x.gte(o)||u.y.gte(o))throw new TypeError("share coordinates must be canonical field elements");s.push(new $(new m(u.x.toArray()),new m(u.y.toArray())))}for(let l=0;l<n;l++)for(let u=l+1;u<n;u++)if(s[l].x.eq(s[u].x))throw new Error("Duplicate share detected, each must be unique.");let c=new Ue(s,n),a=new r(c.valueAt(new m(0)).toArray());if(a.toPublicKey().toHash("hex").slice(0,8)!==i)throw new Error("Integrity hash mismatch");return a}};function rt(r,e){let t=Promise.resolve();return n=>(t=t.then(()=>r(n)).catch(i=>e?.(i)),t)}var Cr="1",ys="bwallet-pair-v1",Ss="www.bwallet.space";var _r="relay.bwallet.space",Ut=120,Ht=new TextEncoder,vs=new TextDecoder,Or=r=>{let e="";for(let t=0;t<r.length;t+=32768)e+=String.fromCharCode(...r.subarray(t,t+32768));return e},Is=r=>btoa(Or(r)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Es=r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=atob(e+"=".repeat((4-e.length%4)%4));return Uint8Array.from(t,n=>n.charCodeAt(0))},Hr=r=>btoa(Or(r)),Ur=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),zr=()=>Is(crypto.getRandomValues(new Uint8Array(16)));function Fr(r){let e=new URLSearchParams({v:r.v,r:r.r,c:r.c,k:r.k,o:r.o,e:String(r.e)});return`https://${Ss}/pair?${e}`}var yn=(r,e,t,n)=>{let i=/^(localhost|127\.0\.0\.1)(:\d+)?$/.test(r),s=new URLSearchParams({role:t});return n&&s.set("e",String(n)),`${i?"ws":"wss"}://${r}/v1/c/${e}?${s}`};async function Sn(r,e,t){let n=r.deriveSharedSecret(te.fromString(e)),i=new Uint8Array(n.encode(!0)),s=await crypto.subtle.importKey("raw",i,"HKDF",!1,["deriveBits"]),o=new Uint8Array(await crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:Es(t),info:Ht.encode(ys)},s,256)),c=await crypto.subtle.importKey("raw",o,"AES-GCM",!1,["encrypt","decrypt"]),a=new Uint8Array(await crypto.subtle.digest("SHA-256",o)),f=String((a[0]<<8|a[1])%1e4).padStart(4,"0");return{key:c,code:f}}var it=class{constructor(e,t){b(this,"key",e);b(this,"me",t);b(this,"sent",0);b(this,"lastSeen",0)}async seal(e){let t=++this.sent,n=crypto.getRandomValues(new Uint8Array(12)),i=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:n,additionalData:Ht.encode(`${this.me}|${t}`)},this.key,Ht.encode(JSON.stringify(e))));return{s:t,n:Hr(n),d:Hr(i)}}async open(e){if(!Number.isInteger(e.s)||e.s<=this.lastSeen)return null;let t=this.me==="site"?"wallet":"site";try{let n=await crypto.subtle.decrypt({name:"AES-GCM",iv:Ur(e.n),additionalData:Ht.encode(`${t}|${e.s}`)},this.key,Ur(e.d));return this.lastSeen=e.s,JSON.parse(vs.decode(n))}catch{return null}}get counters(){return{sent:this.sent,lastSeen:this.lastSeen}}restore(e){this.sent=e.sent,this.lastSeen=e.lastSeen}},vn=r=>!!r&&typeof r=="object"&&"d"in r&&"n"in r&&"s"in r;var In="bwalletx.connect.pairing.v1",Wr=1;function _t(){let r=new Map;return{getItem:e=>r.get(e)??null,setItem:(e,t)=>{r.set(e,t)},removeItem:e=>{r.delete(e)}}}function En(){try{if(typeof localStorage<"u")return localStorage}catch{}return _t()}function Xr(){return r=>{if(typeof WebSocket>"u")throw new Error("No WebSocket here. Pass options.socket.");return new WebSocket(r)}}function As(r){if(!r)return null;try{let e=JSON.parse(r),t=n=>Number.isInteger(n)&&n>=0;return e.v!==1||typeof e.c!="string"||!/^[A-Za-z0-9_-]{22}$/.test(e.c)||typeof e.r!="string"||!/^[a-z0-9.-]+(:\d+)?$/i.test(e.r)||typeof e.s!="string"||!/^[0-9a-f]{64}$/i.test(e.s)||typeof e.k!="string"||!/^0[23][0-9a-f]{64}$/i.test(e.k)||!t(e.sent)||!t(e.lastSeen)||!t(e.pairedAt)?null:e}catch{return null}}var Ct=class{constructor(e,t,n,i,s,o){b(this,"p",e);b(this,"sealer",t);b(this,"storage",n);b(this,"key",i);b(this,"socket",s);b(this,"timeoutMs",o);b(this,"ws",null);b(this,"opening",null);b(this,"waiting",new Map);b(this,"forgotten",!1)}adopt(e){this.ws=e,this.wire(e)}wire(e){e.onmessage=rt(t=>this.onFrame(String(t.data))),e.onerror=null,e.onclose=()=>{this.ws===e&&(this.ws=null),this.failAll(new Error("The connection to bWalletX closed"))}}persist(){this.forgotten||(this.p={...this.p,...this.sealer.counters},Promise.resolve(this.storage.setItem(this.key,JSON.stringify(this.p))).catch(()=>{}))}failAll(e){for(let t of this.waiting.values())clearTimeout(t.timer),t.reject(e);this.waiting.clear()}async ensure(){if(this.forgotten)throw new Error("This pairing was removed. Pair again.");this.ws&&this.ws.readyState===Wr||(this.opening??(this.opening=this.reopen().finally(()=>this.opening=null)),await this.opening)}reopen(){let e=this.socket(yn(this.p.r,this.p.c,"site",Math.floor(Date.now()/1e3)+Ut-10));return new Promise((t,n)=>{e.onopen=()=>{this.ws=e,this.wire(e),t()},e.onerror=()=>n(new Error("Could not reach the bWalletX pairing service")),e.onclose=()=>n(new Error("Could not reach the bWalletX pairing service"))})}async onFrame(e){let t;try{t=JSON.parse(e)}catch{return}if(t.t==="relay"&&t.error)return this.failAll(new Error(`bWalletX pairing service: ${t.error}`));if(!vn(t))return;let i=await this.sealer.open(t);if(i)if(this.persist(),i.t==="res"){let s=this.waiting.get(i.id);if(!s)return;clearTimeout(s.timer),this.waiting.delete(i.id),i.error?s.reject(Object.assign(new Error(i.error.message),{code:i.error.code})):s.resolve(i.result)}else i.t==="close"&&(this.drop(),this.failAll(new Error("bWalletX disconnected this site. Pair again.")))}async call(e,t){await this.ensure();let n=this.ws,i=`${e}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,s=new Promise((o,c)=>{let a=setTimeout(()=>{this.waiting.delete(i)&&c(new Error("No answer from bWalletX. Open it, unlocked, and approve."))},this.timeoutMs);this.waiting.set(i,{resolve:o,reject:c,timer:a})});return n.send(JSON.stringify(await this.sealer.seal({t:"req",id:i,action:e,params:t}))),this.persist(),s}close(){let e=this.ws;this.ws=null,e?.close()}drop(){this.forgotten=!0,Promise.resolve(this.storage.removeItem(this.key)).catch(()=>{}),this.close()}async forget(){if(!this.forgotten){try{this.ws&&this.ws.readyState===Wr&&this.ws.send(JSON.stringify(await this.sealer.seal({t:"close",reason:"site unpaired"})))}catch{}this.drop()}}wallet(){return new Proxy({},{get:(e,t)=>{if(t==="close")return()=>this.close();if(t==="forget")return()=>this.forget();if(!(typeof t!="string"||t==="then"||t==="toJSON"))return n=>this.call(t,n??{})}})}};function Ot(r){let e=r.storage===void 0?En():r.storage??_t(),t=r.storageKey??In,n=r.socket??Xr(),i=r.relay??_r,s=r.origin??(typeof location<"u"?location.origin:"");if(!s)return Promise.reject(new Error("pairBwalletX needs options.origin outside a browser"));let o=Ne.fromRandom(),c=zr(),a=Math.floor(Date.now()/1e3)+Ut;return new Promise((f,l)=>{if(r.signal?.aborted)return l(new Error("cancelled"));let u;try{u=n(yn(i,c,"site",a))}catch(N){return l(N)}let g=null,y="",w=!1,S=N=>{w||(w=!0,clearTimeout(M),u.close(),l(N))},M=setTimeout(()=>S(new Error("The pairing code expired. Show a new one.")),Ut*1e3);r.signal?.addEventListener("abort",()=>S(new Error("cancelled"))),u.onerror=()=>S(new Error("Could not reach the bWalletX pairing service")),u.onclose=()=>S(new Error("The connection to bWalletX closed before pairing finished")),u.onmessage=rt(async N=>{if(w)return;let H;try{H=JSON.parse(String(N.data))}catch{return}if(H.t==="hello"&&!g){y=H.k;let T=await Sn(o,y,c);g=new it(T.key,"site"),r.onCode(T.code);return}if(!g||!vn(H))return;let Z=await g.open(H);if(Z)if(Z.t==="ready"){w=!0,clearTimeout(M);let T={v:1,c,r:i,s:o.toHex(),k:y,...g.counters,pairedAt:Date.now()};await Promise.resolve(e.setItem(t,JSON.stringify(T))).catch(()=>{});let X=new Ct(T,g,e,t,n,r.callTimeoutMs??12e4);X.adopt(u),f(X.wallet())}else Z.t==="close"&&S(new Error("Pairing was declined in bWalletX"))}),r.onLink(Fr({v:Cr,r:i,c,k:o.toPublicKey().toString(),o:s,e:a}))})}async function zt(r={}){let e=r.storage===void 0?En():r.storage??_t(),t=r.storageKey??In,n=As(await Promise.resolve(e.getItem(t)).catch(()=>null));if(!n)return null;let{key:i}=await Sn(Ne.fromHex(n.s),n.k,n.c),s=new it(i,"site");return s.restore({sent:n.sent,lastSeen:n.lastSeen}),new Ct(n,s,e,t,r.socket??Xr(),r.callTimeoutMs??12e4).wallet()}async function qr(r={}){let e=r.storage===void 0?En():r.storage??_t();await Promise.resolve(e.removeItem(r.storageKey??In)).catch(()=>{})}var An=[2,"bwallet sign in"];async function Bn(r={}){if(r.wallet)return{wallet:r.wallet,method:"wallet"};let e=await Ce(r.discoverMs);if(e)return{wallet:e.wallet,method:e.method};if(r.reusePairing!==!1){let t=await zt(r.pairing??{});if(t)return{wallet:t,method:"pairing"}}if(!r.pairing)throw Object.assign(new Error("bWalletX was not found in this browser"),{code:"NOT_FOUND"});return{wallet:await Ot(r.pairing),method:"pairing"}}async function Dr(r){let{wallet:e,method:t}=await Bn(r);t!=="pairing"&&await e.waitForAuthentication({}).catch(()=>{});let{publicKey:n}=await e.getPublicKey({identityKey:!0}),i=await r.challenge(n),{signature:s}=await e.createSignature({protocolID:i.protocolID??An,keyID:i.keyID,counterparty:"anyone",data:Array.from(new TextEncoder().encode(i.message))});return{identityKey:n,signature:Array.from(s),nonce:i.nonce,method:t,wallet:e}}var Bs=`
|
|
2
|
+
.bwx-signin{display:inline-flex;align-items:center;gap:12px;min-height:48px;padding:10px 22px 10px 10px;border:0;border-radius:12px;cursor:pointer;background:linear-gradient(180deg,#fcd34d,#f59e0b);color:#000;text-align:left;font:700 16px/1.2 system-ui,-apple-system,"Segoe UI",sans-serif;box-shadow:0 8px 24px rgba(245,158,11,.2)}
|
|
3
|
+
.bwx-signin:hover{background:linear-gradient(180deg,#fde68a,#fbbf24)}
|
|
4
|
+
.bwx-signin:focus-visible{outline:2px solid #ffd24d;outline-offset:3px}
|
|
5
|
+
.bwx-signin:disabled{opacity:.6;cursor:wait}
|
|
6
|
+
.bwx-signin .bwx-mark{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;background:#000;flex:none}
|
|
7
|
+
.bwx-signin small{display:block;font-size:11px;font-weight:500;color:rgba(0,0,0,.6)}`,Nn="https://bwalletx.com/logo.svg";function Zr(r,e={}){let t=typeof r=="string"?document.querySelector(r):r;if(!t)throw new Error(`renderButton: no element ${String(r)}`);if(!document.getElementById("bwx-signin-css")){let a=document.createElement("style");a.id="bwx-signin-css",a.textContent=Bs,document.head.appendChild(a)}let n=document.createElement("button");n.type="button",n.className="bwx-signin";let i=document.createElement("span");i.className="bwx-mark";let s=document.createElement("img");s.src=Nn,s.alt="",s.width=15,s.height=20,i.appendChild(s);let o=document.createElement("span");o.className="bwx-label",o.textContent="Sign in with bWalletX";let c=e.subtitle===void 0?"also works with bWallet":e.subtitle;if(c){let a=document.createElement("small");a.textContent=c,o.appendChild(a)}return n.append(i,o),e.onClick&&n.addEventListener("click",()=>e.onClick(n)),t.replaceChildren(n),n}return Qr(Ns);})();
|
|
8
|
+
//# sourceMappingURL=bwalletx-connect.global.js.map
|