@imtbl/wallet 2.10.7-alpha.2
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/.eslintrc.cjs +18 -0
- package/LICENSE.md +176 -0
- package/dist/browser/index.mjs +21 -0
- package/dist/node/index.js +71 -0
- package/dist/node/index.mjs +22 -0
- package/dist/types/config.d.ts +13 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/guardian/index.d.ts +57 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/magic/index.d.ts +1 -0
- package/dist/types/magic/magicTEESigner.d.ts +24 -0
- package/dist/types/network/chains.d.ts +32 -0
- package/dist/types/network/constants.d.ts +3 -0
- package/dist/types/network/retry.d.ts +8 -0
- package/dist/types/provider/eip6963.d.ts +3 -0
- package/dist/types/types.d.ts +163 -0
- package/dist/types/utils/metrics.d.ts +3 -0
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/typedEventEmitter.d.ts +6 -0
- package/dist/types/zkEvm/JsonRpcError.d.ts +25 -0
- package/dist/types/zkEvm/index.d.ts +2 -0
- package/dist/types/zkEvm/personalSign.d.ts +15 -0
- package/dist/types/zkEvm/provider/eip6963.d.ts +3 -0
- package/dist/types/zkEvm/relayerClient.d.ts +60 -0
- package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.d.ts +6 -0
- package/dist/types/zkEvm/sendTransaction.d.ts +6 -0
- package/dist/types/zkEvm/sessionActivity/errorBoundary.d.ts +1 -0
- package/dist/types/zkEvm/sessionActivity/request.d.ts +15 -0
- package/dist/types/zkEvm/sessionActivity/sessionActivity.d.ts +2 -0
- package/dist/types/zkEvm/signEjectionTransaction.d.ts +6 -0
- package/dist/types/zkEvm/signTypedDataV4.d.ts +14 -0
- package/dist/types/zkEvm/transactionHelpers.d.ts +31 -0
- package/dist/types/zkEvm/types.d.ts +120 -0
- package/dist/types/zkEvm/user/index.d.ts +1 -0
- package/dist/types/zkEvm/user/registerZkEvmUser.d.ts +13 -0
- package/dist/types/zkEvm/walletHelpers.d.ts +33 -0
- package/dist/types/zkEvm/zkEvmProvider.d.ts +25 -0
- package/package.json +55 -0
- package/src/config.ts +51 -0
- package/src/errors.ts +33 -0
- package/src/guardian/index.ts +358 -0
- package/src/index.ts +27 -0
- package/src/magic/index.ts +1 -0
- package/src/magic/magicTEESigner.ts +214 -0
- package/src/network/chains.ts +33 -0
- package/src/network/constants.ts +28 -0
- package/src/network/retry.ts +37 -0
- package/src/provider/eip6963.ts +25 -0
- package/src/types.ts +192 -0
- package/src/utils/metrics.ts +57 -0
- package/src/utils/string.ts +12 -0
- package/src/utils/typedEventEmitter.ts +26 -0
- package/src/zkEvm/JsonRpcError.ts +33 -0
- package/src/zkEvm/index.ts +2 -0
- package/src/zkEvm/personalSign.ts +62 -0
- package/src/zkEvm/provider/eip6963.ts +25 -0
- package/src/zkEvm/relayerClient.ts +216 -0
- package/src/zkEvm/sendDeployTransactionAndPersonalSign.ts +44 -0
- package/src/zkEvm/sendTransaction.ts +34 -0
- package/src/zkEvm/sessionActivity/errorBoundary.ts +33 -0
- package/src/zkEvm/sessionActivity/request.ts +62 -0
- package/src/zkEvm/sessionActivity/sessionActivity.ts +140 -0
- package/src/zkEvm/signEjectionTransaction.ts +33 -0
- package/src/zkEvm/signTypedDataV4.ts +103 -0
- package/src/zkEvm/transactionHelpers.ts +295 -0
- package/src/zkEvm/types.ts +136 -0
- package/src/zkEvm/user/index.ts +1 -0
- package/src/zkEvm/user/registerZkEvmUser.ts +75 -0
- package/src/zkEvm/walletHelpers.ts +243 -0
- package/src/zkEvm/zkEvmProvider.ts +453 -0
- package/tsconfig.json +15 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['../../.eslintrc'],
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: './tsconfig.json',
|
|
5
|
+
tsconfigRootDir: __dirname,
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
// Disable all import plugin rules due to stack overflow with auth package structure
|
|
9
|
+
'import/order': 'off',
|
|
10
|
+
'import/no-unresolved': 'off',
|
|
11
|
+
'import/named': 'off',
|
|
12
|
+
'import/default': 'off',
|
|
13
|
+
'import/namespace': 'off',
|
|
14
|
+
'import/no-cycle': 'off',
|
|
15
|
+
'import/no-named-as-default': 'off',
|
|
16
|
+
'import/no-named-as-default-member': 'off',
|
|
17
|
+
},
|
|
18
|
+
};
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { utils, trackFlow, trackError, identify, trackDuration } from '@imtbl/metrics';
|
|
2
|
+
import { ZeroAddress, AbiCoder, keccak256, Contract, isError, solidityPacked, getBytes, Interface, TypedDataEncoder, hashMessage, JsonRpcProvider, toBeHex, AbstractSigner, stripZerosLeft, toUtf8String } from 'ethers';
|
|
3
|
+
import { isUserImx, isUserZkEvm } from '@imtbl/auth';
|
|
4
|
+
export { isUserImx, isUserZkEvm } from '@imtbl/auth';
|
|
5
|
+
import { walletContracts } from '@0xsequence/abi';
|
|
6
|
+
import { v1 } from '@0xsequence/core';
|
|
7
|
+
import * as xr from '@imtbl/generated-clients';
|
|
8
|
+
import Hn, { isAxiosError } from 'axios';
|
|
9
|
+
import { Environment } from '@imtbl/config';
|
|
10
|
+
import { v4 } from 'uuid';
|
|
11
|
+
|
|
12
|
+
var fi=Object.create;var nr=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var ci=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,pi=Object.prototype.hasOwnProperty;var ir=(s,i)=>()=>(s&&(i=s(s=0)),i);var jt=(s,i)=>()=>(i||s((i={exports:{}}).exports,i),i.exports),mi=(s,i)=>{for(var u in i)nr(s,u,{get:i[u],enumerable:!0});},gi=(s,i,u,y)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of ci(i))!pi.call(s,a)&&a!==u&&nr(s,a,{get:()=>i[a],enumerable:!(y=li(i,a))||y.enumerable});return s};var or=(s,i,u)=>(u=s!=null?fi(di(s)):{},gi(i||!s||!s.__esModule?nr(u,"default",{value:s,enumerable:!0}):u,s));var x=ir(()=>{});function yi(){if($r)return ee;$r=!0,ee.byteLength=I,ee.toByteArray=k,ee.fromByteArray=X;for(var s=[],i=[],u=typeof Uint8Array<"u"?Uint8Array:Array,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,T=y.length;a<T;++a)s[a]=y[a],i[y.charCodeAt(a)]=a;i[45]=62,i[95]=63;function d(N){var G=N.length;if(G%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var W=N.indexOf("=");W===-1&&(W=G);var z=W===G?0:4-W%4;return [W,z]}function I(N){var G=d(N),W=G[0],z=G[1];return (W+z)*3/4-z}function b(N,G,W){return (G+W)*3/4-W}function k(N){var G,W=d(N),z=W[0],St=W[1],ot=new u(b(N,z,St)),Pt=0,it=St>0?z-4:z,Bt;for(Bt=0;Bt<it;Bt+=4)G=i[N.charCodeAt(Bt)]<<18|i[N.charCodeAt(Bt+1)]<<12|i[N.charCodeAt(Bt+2)]<<6|i[N.charCodeAt(Bt+3)],ot[Pt++]=G>>16&255,ot[Pt++]=G>>8&255,ot[Pt++]=G&255;return St===2&&(G=i[N.charCodeAt(Bt)]<<2|i[N.charCodeAt(Bt+1)]>>4,ot[Pt++]=G&255),St===1&&(G=i[N.charCodeAt(Bt)]<<10|i[N.charCodeAt(Bt+1)]<<4|i[N.charCodeAt(Bt+2)]>>2,ot[Pt++]=G>>8&255,ot[Pt++]=G&255),ot}function L(N){return s[N>>18&63]+s[N>>12&63]+s[N>>6&63]+s[N&63]}function H(N,G,W){for(var z,St=[],ot=G;ot<W;ot+=3)z=(N[ot]<<16&16711680)+(N[ot+1]<<8&65280)+(N[ot+2]&255),St.push(L(z));return St.join("")}function X(N){for(var G,W=N.length,z=W%3,St=[],ot=16383,Pt=0,it=W-z;Pt<it;Pt+=ot)St.push(H(N,Pt,Pt+ot>it?it:Pt+ot));return z===1?(G=N[W-1],St.push(s[G>>2]+s[G<<4&63]+"==")):z===2&&(G=(N[W-2]<<8)+N[W-1],St.push(s[G>>10]+s[G>>4&63]+s[G<<2&63]+"=")),St.join("")}return ee}function vi(){if(Hr)return ce;Hr=!0;return ce.read=function(s,i,u,y,a){var T,d,I=a*8-y-1,b=(1<<I)-1,k=b>>1,L=-7,H=u?a-1:0,X=u?-1:1,N=s[i+H];for(H+=X,T=N&(1<<-L)-1,N>>=-L,L+=I;L>0;T=T*256+s[i+H],H+=X,L-=8);for(d=T&(1<<-L)-1,T>>=-L,L+=y;L>0;d=d*256+s[i+H],H+=X,L-=8);if(T===0)T=1-k;else {if(T===b)return d?NaN:(N?-1:1)*(1/0);d=d+Math.pow(2,y),T=T-k;}return (N?-1:1)*d*Math.pow(2,T-y)},ce.write=function(s,i,u,y,a,T){var d,I,b,k=T*8-a-1,L=(1<<k)-1,H=L>>1,X=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=y?0:T-1,G=y?1:-1,W=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(I=isNaN(i)?1:0,d=L):(d=Math.floor(Math.log(i)/Math.LN2),i*(b=Math.pow(2,-d))<1&&(d--,b*=2),d+H>=1?i+=X/b:i+=X*Math.pow(2,1-H),i*b>=2&&(d++,b/=2),d+H>=L?(I=0,d=L):d+H>=1?(I=(i*b-1)*Math.pow(2,a),d=d+H):(I=i*Math.pow(2,H-1)*Math.pow(2,a),d=0));a>=8;s[u+N]=I&255,N+=G,I/=256,a-=8);for(d=d<<a|I,k+=a;k>0;s[u+N]=d&255,N+=G,d/=256,k-=8);s[u+N-G]|=W*128;},ce}function wi(){if(Wr)return Ht;Wr=!0;let s=yi(),i=vi(),u=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ht.Buffer=d,Ht.SlowBuffer=St,Ht.INSPECT_MAX_BYTES=50;let y=2147483647;Ht.kMaxLength=y,d.TYPED_ARRAY_SUPPORT=a(),!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{let h=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(h,e),h.foo()===42}catch{return !1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function T(h){if(h>y)throw new RangeError('The value "'+h+'" is invalid for option "size"');let e=new Uint8Array(h);return Object.setPrototypeOf(e,d.prototype),e}function d(h,e,r){if(typeof h=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return L(h)}return I(h,e,r)}d.poolSize=8192;function I(h,e,r){if(typeof h=="string")return H(h,e);if(ArrayBuffer.isView(h))return N(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(j(h,ArrayBuffer)||h&&j(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(j(h,SharedArrayBuffer)||h&&j(h.buffer,SharedArrayBuffer)))return G(h,e,r);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let c=h.valueOf&&h.valueOf();if(c!=null&&c!==h)return d.from(c,e,r);let w=W(h);if(w)return w;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return d.from(h[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}d.from=function(h,e,r){return I(h,e,r)},Object.setPrototypeOf(d.prototype,Uint8Array.prototype),Object.setPrototypeOf(d,Uint8Array);function b(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function k(h,e,r){return b(h),h<=0?T(h):e!==void 0?typeof r=="string"?T(h).fill(e,r):T(h).fill(e):T(h)}d.alloc=function(h,e,r){return k(h,e,r)};function L(h){return b(h),T(h<0?0:z(h)|0)}d.allocUnsafe=function(h){return L(h)},d.allocUnsafeSlow=function(h){return L(h)};function H(h,e){if((typeof e!="string"||e==="")&&(e="utf8"),!d.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=ot(h,e)|0,c=T(r),w=c.write(h,e);return w!==r&&(c=c.slice(0,w)),c}function X(h){let e=h.length<0?0:z(h.length)|0,r=T(e);for(let c=0;c<e;c+=1)r[c]=h[c]&255;return r}function N(h){if(j(h,Uint8Array)){let e=new Uint8Array(h);return G(e.buffer,e.byteOffset,e.byteLength)}return X(h)}function G(h,e,r){if(e<0||h.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let c;return e===void 0&&r===void 0?c=new Uint8Array(h):r===void 0?c=new Uint8Array(h,e):c=new Uint8Array(h,e,r),Object.setPrototypeOf(c,d.prototype),c}function W(h){if(d.isBuffer(h)){let e=z(h.length)|0,r=T(e);return r.length===0||h.copy(r,0,0,e),r}if(h.length!==void 0)return typeof h.length!="number"||Jt(h.length)?T(0):X(h);if(h.type==="Buffer"&&Array.isArray(h.data))return X(h.data)}function z(h){if(h>=y)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+y.toString(16)+" bytes");return h|0}function St(h){return +h!=h&&(h=0),d.alloc(+h)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype},d.compare=function(e,r){if(j(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),j(r,Uint8Array)&&(r=d.from(r,r.offset,r.byteLength)),!d.isBuffer(e)||!d.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let c=e.length,w=r.length;for(let A=0,R=Math.min(c,w);A<R;++A)if(e[A]!==r[A]){c=e[A],w=r[A];break}return c<w?-1:w<c?1:0},d.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},d.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return d.alloc(0);let c;if(r===void 0)for(r=0,c=0;c<e.length;++c)r+=e[c].length;let w=d.allocUnsafe(r),A=0;for(c=0;c<e.length;++c){let R=e[c];if(j(R,Uint8Array))A+R.length>w.length?(d.isBuffer(R)||(R=d.from(R)),R.copy(w,A)):Uint8Array.prototype.set.call(w,R,A);else if(d.isBuffer(R))R.copy(w,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=R.length;}return w};function ot(h,e){if(d.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||j(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);let r=h.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&r===0)return 0;let w=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Vt(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return te(h).length;default:if(w)return c?-1:Vt(h).length;e=(""+e).toLowerCase(),w=!0;}}d.byteLength=ot;function Pt(h,e,r){let c=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return "";for(h||(h="utf8");;)switch(h){case"hex":return m(this,e,r);case"utf8":case"utf-8":return v(this,e,r);case"ascii":return f(this,e,r);case"latin1":case"binary":return l(this,e,r);case"base64":return Dt(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,r);default:if(c)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),c=!0;}}d.prototype._isBuffer=!0;function it(h,e,r){let c=h[e];h[e]=h[r],h[r]=c;}d.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)it(this,r,r+1);return this},d.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)it(this,r,r+3),it(this,r+1,r+2);return this},d.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)it(this,r,r+7),it(this,r+1,r+6),it(this,r+2,r+5),it(this,r+3,r+4);return this},d.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?v(this,0,e):Pt.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:d.compare(this,e)===0},d.prototype.inspect=function(){let e="",r=Ht.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},u&&(d.prototype[u]=d.prototype.inspect),d.prototype.compare=function(e,r,c,w,A){if(j(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),c===void 0&&(c=e?e.length:0),w===void 0&&(w=0),A===void 0&&(A=this.length),r<0||c>e.length||w<0||A>this.length)throw new RangeError("out of range index");if(w>=A&&r>=c)return 0;if(w>=A)return -1;if(r>=c)return 1;if(r>>>=0,c>>>=0,w>>>=0,A>>>=0,this===e)return 0;let R=A-w,B=c-r,nt=Math.min(R,B),F=this.slice(w,A),q=e.slice(r,c);for(let Y=0;Y<nt;++Y)if(F[Y]!==q[Y]){R=F[Y],B=q[Y];break}return R<B?-1:B<R?1:0};function Bt(h,e,r,c,w){if(h.length===0)return -1;if(typeof r=="string"?(c=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Jt(r)&&(r=w?0:h.length-1),r<0&&(r=h.length+r),r>=h.length){if(w)return -1;r=h.length-1;}else if(r<0)if(w)r=0;else return -1;if(typeof e=="string"&&(e=d.from(e,c)),d.isBuffer(e))return e.length===0?-1:Nt(h,e,r,c,w);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?w?Uint8Array.prototype.indexOf.call(h,e,r):Uint8Array.prototype.lastIndexOf.call(h,e,r):Nt(h,[e],r,c,w);throw new TypeError("val must be string, number or Buffer")}function Nt(h,e,r,c,w){let A=1,R=h.length,B=e.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(h.length<2||e.length<2)return -1;A=2,R/=2,B/=2,r/=2;}function nt(q,Y){return A===1?q[Y]:q.readUInt16BE(Y*A)}let F;if(w){let q=-1;for(F=r;F<R;F++)if(nt(h,F)===nt(e,q===-1?0:F-q)){if(q===-1&&(q=F),F-q+1===B)return q*A}else q!==-1&&(F-=F-q),q=-1;}else for(r+B>R&&(r=R-B),F=r;F>=0;F--){let q=!0;for(let Y=0;Y<B;Y++)if(nt(h,F+Y)!==nt(e,Y)){q=!1;break}if(q)return F}return -1}d.prototype.includes=function(e,r,c){return this.indexOf(e,r,c)!==-1},d.prototype.indexOf=function(e,r,c){return Bt(this,e,r,c,!0)},d.prototype.lastIndexOf=function(e,r,c){return Bt(this,e,r,c,!1)};function Zt(h,e,r,c){r=Number(r)||0;let w=h.length-r;c?(c=Number(c),c>w&&(c=w)):c=w;let A=e.length;c>A/2&&(c=A/2);let R;for(R=0;R<c;++R){let B=parseInt(e.substr(R*2,2),16);if(Jt(B))return R;h[r+R]=B;}return R}function he(h,e,r,c){return rt(Vt(e,h.length-r),h,r,c)}function fe(h,e,r,c){return rt(ht(e),h,r,c)}function Qt(h,e,r,c){return rt(te(e),h,r,c)}function st(h,e,r,c){return rt(ft(e,h.length-r),h,r,c)}d.prototype.write=function(e,r,c,w){if(r===void 0)w="utf8",c=this.length,r=0;else if(c===void 0&&typeof r=="string")w=r,c=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(c)?(c=c>>>0,w===void 0&&(w="utf8")):(w=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let A=this.length-r;if((c===void 0||c>A)&&(c=A),e.length>0&&(c<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");w||(w="utf8");let R=!1;for(;;)switch(w){case"hex":return Zt(this,e,r,c);case"utf8":case"utf-8":return he(this,e,r,c);case"ascii":case"latin1":case"binary":return fe(this,e,r,c);case"base64":return Qt(this,e,r,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return st(this,e,r,c);default:if(R)throw new TypeError("Unknown encoding: "+w);w=(""+w).toLowerCase(),R=!0;}},d.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Dt(h,e,r){return e===0&&r===h.length?s.fromByteArray(h):s.fromByteArray(h.slice(e,r))}function v(h,e,r){r=Math.min(h.length,r);let c=[],w=e;for(;w<r;){let A=h[w],R=null,B=A>239?4:A>223?3:A>191?2:1;if(w+B<=r){let nt,F,q,Y;switch(B){case 1:A<128&&(R=A);break;case 2:nt=h[w+1],(nt&192)===128&&(Y=(A&31)<<6|nt&63,Y>127&&(R=Y));break;case 3:nt=h[w+1],F=h[w+2],(nt&192)===128&&(F&192)===128&&(Y=(A&15)<<12|(nt&63)<<6|F&63,Y>2047&&(Y<55296||Y>57343)&&(R=Y));break;case 4:nt=h[w+1],F=h[w+2],q=h[w+3],(nt&192)===128&&(F&192)===128&&(q&192)===128&&(Y=(A&15)<<18|(nt&63)<<12|(F&63)<<6|q&63,Y>65535&&Y<1114112&&(R=Y));}}R===null?(R=65533,B=1):R>65535&&(R-=65536,c.push(R>>>10&1023|55296),R=56320|R&1023),c.push(R),w+=B;}return o(c)}let t=4096;function o(h){let e=h.length;if(e<=t)return String.fromCharCode.apply(String,h);let r="",c=0;for(;c<e;)r+=String.fromCharCode.apply(String,h.slice(c,c+=t));return r}function f(h,e,r){let c="";r=Math.min(h.length,r);for(let w=e;w<r;++w)c+=String.fromCharCode(h[w]&127);return c}function l(h,e,r){let c="";r=Math.min(h.length,r);for(let w=e;w<r;++w)c+=String.fromCharCode(h[w]);return c}function m(h,e,r){let c=h.length;(!e||e<0)&&(e=0),(!r||r<0||r>c)&&(r=c);let w="";for(let A=e;A<r;++A)w+=lt[h[A]];return w}function E(h,e,r){let c=h.slice(e,r),w="";for(let A=0;A<c.length-1;A+=2)w+=String.fromCharCode(c[A]+c[A+1]*256);return w}d.prototype.slice=function(e,r){let c=this.length;e=~~e,r=r===void 0?c:~~r,e<0?(e+=c,e<0&&(e=0)):e>c&&(e=c),r<0?(r+=c,r<0&&(r=0)):r>c&&(r=c),r<e&&(r=e);let w=this.subarray(e,r);return Object.setPrototypeOf(w,d.prototype),w};function M(h,e,r){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+e>r)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,r,c){e=e>>>0,r=r>>>0,c||M(e,r,this.length);let w=this[e],A=1,R=0;for(;++R<r&&(A*=256);)w+=this[e+R]*A;return w},d.prototype.readUintBE=d.prototype.readUIntBE=function(e,r,c){e=e>>>0,r=r>>>0,c||M(e,r,this.length);let w=this[e+--r],A=1;for(;r>0&&(A*=256);)w+=this[e+--r]*A;return w},d.prototype.readUint8=d.prototype.readUInt8=function(e,r){return e=e>>>0,r||M(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||M(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||M(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||M(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=tt(function(e){e=e>>>0,J(e,"offset");let r=this[e],c=this[e+7];(r===void 0||c===void 0)&&Ft(e,this.length-8);let w=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,A=this[++e]+this[++e]*2**8+this[++e]*2**16+c*2**24;return BigInt(w)+(BigInt(A)<<BigInt(32))}),d.prototype.readBigUInt64BE=tt(function(e){e=e>>>0,J(e,"offset");let r=this[e],c=this[e+7];(r===void 0||c===void 0)&&Ft(e,this.length-8);let w=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],A=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+c;return (BigInt(w)<<BigInt(32))+BigInt(A)}),d.prototype.readIntLE=function(e,r,c){e=e>>>0,r=r>>>0,c||M(e,r,this.length);let w=this[e],A=1,R=0;for(;++R<r&&(A*=256);)w+=this[e+R]*A;return A*=128,w>=A&&(w-=Math.pow(2,8*r)),w},d.prototype.readIntBE=function(e,r,c){e=e>>>0,r=r>>>0,c||M(e,r,this.length);let w=r,A=1,R=this[e+--w];for(;w>0&&(A*=256);)R+=this[e+--w]*A;return A*=128,R>=A&&(R-=Math.pow(2,8*r)),R},d.prototype.readInt8=function(e,r){return e=e>>>0,r||M(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,r){e=e>>>0,r||M(e,2,this.length);let c=this[e]|this[e+1]<<8;return c&32768?c|4294901760:c},d.prototype.readInt16BE=function(e,r){e=e>>>0,r||M(e,2,this.length);let c=this[e+1]|this[e]<<8;return c&32768?c|4294901760:c},d.prototype.readInt32LE=function(e,r){return e=e>>>0,r||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},d.prototype.readInt32BE=function(e,r){return e=e>>>0,r||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=tt(function(e){e=e>>>0,J(e,"offset");let r=this[e],c=this[e+7];(r===void 0||c===void 0)&&Ft(e,this.length-8);let w=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(c<<24);return (BigInt(w)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),d.prototype.readBigInt64BE=tt(function(e){e=e>>>0,J(e,"offset");let r=this[e],c=this[e+7];(r===void 0||c===void 0)&&Ft(e,this.length-8);let w=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(w)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+c)}),d.prototype.readFloatLE=function(e,r){return e=e>>>0,r||M(e,4,this.length),i.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,r){return e=e>>>0,r||M(e,4,this.length),i.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||M(e,8,this.length),i.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||M(e,8,this.length),i.read(this,e,!1,52,8)};function p(h,e,r,c,w,A){if(!d.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>w||e<A)throw new RangeError('"value" argument is out of bounds');if(r+c>h.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,r,c,w){if(e=+e,r=r>>>0,c=c>>>0,!w){let B=Math.pow(2,8*c)-1;p(this,e,r,c,B,0);}let A=1,R=0;for(this[r]=e&255;++R<c&&(A*=256);)this[r+R]=e/A&255;return r+c},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,r,c,w){if(e=+e,r=r>>>0,c=c>>>0,!w){let B=Math.pow(2,8*c)-1;p(this,e,r,c,B,0);}let A=c-1,R=1;for(this[r+A]=e&255;--A>=0&&(R*=256);)this[r+A]=e/R&255;return r+c},d.prototype.writeUint8=d.prototype.writeUInt8=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,1,255,0),this[r]=e&255,r+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function n(h,e,r,c,w){Q(e,c,w,h,r,7);let A=Number(e&BigInt(4294967295));h[r++]=A,A=A>>8,h[r++]=A,A=A>>8,h[r++]=A,A=A>>8,h[r++]=A;let R=Number(e>>BigInt(32)&BigInt(4294967295));return h[r++]=R,R=R>>8,h[r++]=R,R=R>>8,h[r++]=R,R=R>>8,h[r++]=R,r}function g(h,e,r,c,w){Q(e,c,w,h,r,7);let A=Number(e&BigInt(4294967295));h[r+7]=A,A=A>>8,h[r+6]=A,A=A>>8,h[r+5]=A,A=A>>8,h[r+4]=A;let R=Number(e>>BigInt(32)&BigInt(4294967295));return h[r+3]=R,R=R>>8,h[r+2]=R,R=R>>8,h[r+1]=R,R=R>>8,h[r]=R,r+8}d.prototype.writeBigUInt64LE=tt(function(e,r=0){return n(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=tt(function(e,r=0){return g(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(e,r,c,w){if(e=+e,r=r>>>0,!w){let nt=Math.pow(2,8*c-1);p(this,e,r,c,nt-1,-nt);}let A=0,R=1,B=0;for(this[r]=e&255;++A<c&&(R*=256);)e<0&&B===0&&this[r+A-1]!==0&&(B=1),this[r+A]=(e/R>>0)-B&255;return r+c},d.prototype.writeIntBE=function(e,r,c,w){if(e=+e,r=r>>>0,!w){let nt=Math.pow(2,8*c-1);p(this,e,r,c,nt-1,-nt);}let A=c-1,R=1,B=0;for(this[r+A]=e&255;--A>=0&&(R*=256);)e<0&&B===0&&this[r+A+1]!==0&&(B=1),this[r+A]=(e/R>>0)-B&255;return r+c},d.prototype.writeInt8=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1},d.prototype.writeInt16LE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2},d.prototype.writeInt16BE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2},d.prototype.writeInt32LE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4},d.prototype.writeInt32BE=function(e,r,c){return e=+e,r=r>>>0,c||p(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4},d.prototype.writeBigInt64LE=tt(function(e,r=0){return n(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=tt(function(e,r=0){return g(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function _(h,e,r,c,w,A){if(r+c>h.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S(h,e,r,c,w){return e=+e,r=r>>>0,w||_(h,e,r,4),i.write(h,e,r,c,23,4),r+4}d.prototype.writeFloatLE=function(e,r,c){return S(this,e,r,!0,c)},d.prototype.writeFloatBE=function(e,r,c){return S(this,e,r,!1,c)};function P(h,e,r,c,w){return e=+e,r=r>>>0,w||_(h,e,r,8),i.write(h,e,r,c,52,8),r+8}d.prototype.writeDoubleLE=function(e,r,c){return P(this,e,r,!0,c)},d.prototype.writeDoubleBE=function(e,r,c){return P(this,e,r,!1,c)},d.prototype.copy=function(e,r,c,w){if(!d.isBuffer(e))throw new TypeError("argument should be a Buffer");if(c||(c=0),!w&&w!==0&&(w=this.length),r>=e.length&&(r=e.length),r||(r=0),w>0&&w<c&&(w=c),w===c||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(w<0)throw new RangeError("sourceEnd out of bounds");w>this.length&&(w=this.length),e.length-r<w-c&&(w=e.length-r+c);let A=w-c;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,c,w):Uint8Array.prototype.set.call(e,this.subarray(c,w),r),A},d.prototype.fill=function(e,r,c,w){if(typeof e=="string"){if(typeof r=="string"?(w=r,r=0,c=this.length):typeof c=="string"&&(w=c,c=this.length),w!==void 0&&typeof w!="string")throw new TypeError("encoding must be a string");if(typeof w=="string"&&!d.isEncoding(w))throw new TypeError("Unknown encoding: "+w);if(e.length===1){let R=e.charCodeAt(0);(w==="utf8"&&R<128||w==="latin1")&&(e=R);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<c)throw new RangeError("Out of range index");if(c<=r)return this;r=r>>>0,c=c===void 0?this.length:c>>>0,e||(e=0);let A;if(typeof e=="number")for(A=r;A<c;++A)this[A]=e;else {let R=d.isBuffer(e)?e:d.from(e,w),B=R.length;if(B===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(A=0;A<c-r;++A)this[A+r]=R[A%B];}return this};let D={};function Z(h,e,r){D[h]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name;}get code(){return h}set code(w){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:w,writable:!0});}toString(){return `${this.name} [${h}]: ${this.message}`}};}Z("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Z("ERR_INVALID_ARG_TYPE",function(h,e){return `The "${h}" argument must be of type number. Received type ${typeof e}`},TypeError),Z("ERR_OUT_OF_RANGE",function(h,e,r){let c=`The value of "${h}" is out of range.`,w=r;return Number.isInteger(r)&&Math.abs(r)>2**32?w=K(String(r)):typeof r=="bigint"&&(w=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(w=K(w)),w+="n"),c+=` It must be ${e}. Received ${w}`,c},RangeError);function K(h){let e="",r=h.length,c=h[0]==="-"?1:0;for(;r>=c+4;r-=3)e=`_${h.slice(r-3,r)}${e}`;return `${h.slice(0,r)}${e}`}function kt(h,e,r){J(e,"offset"),(h[e]===void 0||h[e+r]===void 0)&&Ft(e,h.length-(r+1));}function Q(h,e,r,c,w,A){if(h>r||h<e){let R=typeof e=="bigint"?"n":"",B;throw e===0||e===BigInt(0)?B=`>= 0${R} and < 2${R} ** ${(A+1)*8}${R}`:B=`>= -(2${R} ** ${(A+1)*8-1}${R}) and < 2 ** ${(A+1)*8-1}${R}`,new D.ERR_OUT_OF_RANGE("value",B,h)}kt(c,w,A);}function J(h,e){if(typeof h!="number")throw new D.ERR_INVALID_ARG_TYPE(e,"number",h)}function Ft(h,e,r){throw Math.floor(h)!==h?(J(h,r),new D.ERR_OUT_OF_RANGE("offset","an integer",h)):e<0?new D.ERR_BUFFER_OUT_OF_BOUNDS:new D.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${e}`,h)}let at=/[^+/0-9A-Za-z-_]/g;function ut(h){if(h=h.split("=")[0],h=h.trim().replace(at,""),h.length<2)return "";for(;h.length%4!==0;)h=h+"=";return h}function Vt(h,e){e=e||1/0;let r,c=h.length,w=null,A=[];for(let R=0;R<c;++R){if(r=h.charCodeAt(R),r>55295&&r<57344){if(!w){if(r>56319){(e-=3)>-1&&A.push(239,191,189);continue}else if(R+1===c){(e-=3)>-1&&A.push(239,191,189);continue}w=r;continue}if(r<56320){(e-=3)>-1&&A.push(239,191,189),w=r;continue}r=(w-55296<<10|r-56320)+65536;}else w&&(e-=3)>-1&&A.push(239,191,189);if(w=null,r<128){if((e-=1)<0)break;A.push(r);}else if(r<2048){if((e-=2)<0)break;A.push(r>>6|192,r&63|128);}else if(r<65536){if((e-=3)<0)break;A.push(r>>12|224,r>>6&63|128,r&63|128);}else if(r<1114112){if((e-=4)<0)break;A.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128);}else throw new Error("Invalid code point")}return A}function ht(h){let e=[];for(let r=0;r<h.length;++r)e.push(h.charCodeAt(r)&255);return e}function ft(h,e){let r,c,w,A=[];for(let R=0;R<h.length&&!((e-=2)<0);++R)r=h.charCodeAt(R),c=r>>8,w=r%256,A.push(w),A.push(c);return A}function te(h){return s.toByteArray(ut(h))}function rt(h,e,r,c){let w;for(w=0;w<c&&!(w+r>=e.length||w>=h.length);++w)e[w+r]=h[w];return w}function j(h,e){return h instanceof e||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===e.name}function Jt(h){return h!==h}let lt=function(){let h="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let c=r*16;for(let w=0;w<16;++w)e[c+w]=h[r]+h[w];}return e}();function tt(h){return typeof BigInt>"u"?le:h}function le(){throw new Error("BigInt not supported")}return Ht}var ee,$r,ce,Hr,Ht,Wr,Wt,$,Zr=ir(()=>{C();x();ee={},$r=!1;ce={},Hr=!1;Ht={},Wr=!1;Wt=wi();Wt.Buffer;Wt.SlowBuffer;Wt.INSPECT_MAX_BYTES;Wt.kMaxLength;$=Wt.Buffer,Wt.INSPECT_MAX_BYTES,Wt.kMaxLength;});var C=ir(()=>{Zr();});var rn=jt((ws,sr)=>{C();x();var zt=typeof Reflect=="object"?Reflect:null,Vr=zt&&typeof zt.apply=="function"?zt.apply:function(i,u,y){return Function.prototype.apply.call(i,u,y)},de;zt&&typeof zt.ownKeys=="function"?de=zt.ownKeys:Object.getOwnPropertySymbols?de=function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:de=function(i){return Object.getOwnPropertyNames(i)};function Ei(s){console&&console.warn&&console.warn(s);}var jr=Number.isNaN||function(i){return i!==i};function et(){et.init.call(this);}sr.exports=et;sr.exports.once=Ri;et.EventEmitter=et;et.prototype._events=void 0;et.prototype._eventsCount=0;et.prototype._maxListeners=void 0;var Jr=10;function pe(s){if(typeof s!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof s)}Object.defineProperty(et,"defaultMaxListeners",{enumerable:!0,get:function(){return Jr},set:function(s){if(typeof s!="number"||s<0||jr(s))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+s+".");Jr=s;}});et.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0;};et.prototype.setMaxListeners=function(i){if(typeof i!="number"||i<0||jr(i))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+i+".");return this._maxListeners=i,this};function zr(s){return s._maxListeners===void 0?et.defaultMaxListeners:s._maxListeners}et.prototype.getMaxListeners=function(){return zr(this)};et.prototype.emit=function(i){for(var u=[],y=1;y<arguments.length;y++)u.push(arguments[y]);var a=i==="error",T=this._events;if(T!==void 0)a=a&&T.error===void 0;else if(!a)return !1;if(a){var d;if(u.length>0&&(d=u[0]),d instanceof Error)throw d;var I=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw I.context=d,I}var b=T[i];if(b===void 0)return !1;if(typeof b=="function")Vr(b,this,u);else for(var k=b.length,L=tn(b,k),y=0;y<k;++y)Vr(L[y],this,u);return !0};function Yr(s,i,u,y){var a,T,d;if(pe(u),T=s._events,T===void 0?(T=s._events=Object.create(null),s._eventsCount=0):(T.newListener!==void 0&&(s.emit("newListener",i,u.listener?u.listener:u),T=s._events),d=T[i]),d===void 0)d=T[i]=u,++s._eventsCount;else if(typeof d=="function"?d=T[i]=y?[u,d]:[d,u]:y?d.unshift(u):d.push(u),a=zr(s),a>0&&d.length>a&&!d.warned){d.warned=!0;var I=new Error("Possible EventEmitter memory leak detected. "+d.length+" "+String(i)+" listeners added. Use emitter.setMaxListeners() to increase limit");I.name="MaxListenersExceededWarning",I.emitter=s,I.type=i,I.count=d.length,Ei(I);}return s}et.prototype.addListener=function(i,u){return Yr(this,i,u,!1)};et.prototype.on=et.prototype.addListener;et.prototype.prependListener=function(i,u){return Yr(this,i,u,!0)};function Mi(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Xr(s,i,u){var y={fired:!1,wrapFn:void 0,target:s,type:i,listener:u},a=Mi.bind(y);return a.listener=u,y.wrapFn=a,a}et.prototype.once=function(i,u){return pe(u),this.on(i,Xr(this,i,u)),this};et.prototype.prependOnceListener=function(i,u){return pe(u),this.prependListener(i,Xr(this,i,u)),this};et.prototype.removeListener=function(i,u){var y,a,T,d,I;if(pe(u),a=this._events,a===void 0)return this;if(y=a[i],y===void 0)return this;if(y===u||y.listener===u)--this._eventsCount===0?this._events=Object.create(null):(delete a[i],a.removeListener&&this.emit("removeListener",i,y.listener||u));else if(typeof y!="function"){for(T=-1,d=y.length-1;d>=0;d--)if(y[d]===u||y[d].listener===u){I=y[d].listener,T=d;break}if(T<0)return this;T===0?y.shift():Ti(y,T),y.length===1&&(a[i]=y[0]),a.removeListener!==void 0&&this.emit("removeListener",i,I||u);}return this};et.prototype.off=et.prototype.removeListener;et.prototype.removeAllListeners=function(i){var u,y,a;if(y=this._events,y===void 0)return this;if(y.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):y[i]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete y[i]),this;if(arguments.length===0){var T=Object.keys(y),d;for(a=0;a<T.length;++a)d=T[a],d!=="removeListener"&&this.removeAllListeners(d);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(u=y[i],typeof u=="function")this.removeListener(i,u);else if(u!==void 0)for(a=u.length-1;a>=0;a--)this.removeListener(i,u[a]);return this};function Kr(s,i,u){var y=s._events;if(y===void 0)return [];var a=y[i];return a===void 0?[]:typeof a=="function"?u?[a.listener||a]:[a]:u?Ai(a):tn(a,a.length)}et.prototype.listeners=function(i){return Kr(this,i,!0)};et.prototype.rawListeners=function(i){return Kr(this,i,!1)};et.listenerCount=function(s,i){return typeof s.listenerCount=="function"?s.listenerCount(i):Qr.call(s,i)};et.prototype.listenerCount=Qr;function Qr(s){var i=this._events;if(i!==void 0){var u=i[s];if(typeof u=="function")return 1;if(u!==void 0)return u.length}return 0}et.prototype.eventNames=function(){return this._eventsCount>0?de(this._events):[]};function tn(s,i){for(var u=new Array(i),y=0;y<i;++y)u[y]=s[y];return u}function Ti(s,i){for(;i+1<s.length;i++)s[i]=s[i+1];s.pop();}function Ai(s){for(var i=new Array(s.length),u=0;u<i.length;++u)i[u]=s[u].listener||s[u];return i}function Ri(s,i){return new Promise(function(u,y){function a(d){s.removeListener(i,T),y(d);}function T(){typeof s.removeListener=="function"&&s.removeListener("error",a),u([].slice.call(arguments));}en(s,i,T,{once:!0}),i!=="error"&&Ii(s,a,{once:!0});})}function Ii(s,i,u){typeof s.on=="function"&&en(s,"error",i,u);}function en(s,i,u,y){if(typeof s.on=="function")y.once?s.once(i,u):s.on(i,u);else if(typeof s.addEventListener=="function")s.addEventListener(i,function a(T){y.once&&s.removeEventListener(i,a),u(T);});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof s)}});var vn=jt((Ws,yn)=>{C();x();yn.exports={};});var En=jt((wn,cr)=>{C();x();(function(s,i){function u(v,t){if(!v)throw new Error(t||"Assertion failed")}function y(v,t){v.super_=t;var o=function(){};o.prototype=t.prototype,v.prototype=new o,v.prototype.constructor=v;}function a(v,t,o){if(a.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((t==="le"||t==="be")&&(o=t,t=10),this._init(v||0,t||10,o||"be"));}typeof s=="object"?s.exports=a:i.BN=a,a.BN=a,a.wordSize=26;var T;try{typeof window<"u"&&typeof window.Buffer<"u"?T=window.Buffer:T=vn().Buffer;}catch{}a.isBN=function(t){return t instanceof a?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,o){return t.cmp(o)>0?t:o},a.min=function(t,o){return t.cmp(o)<0?t:o},a.prototype._init=function(t,o,f){if(typeof t=="number")return this._initNumber(t,o,f);if(typeof t=="object")return this._initArray(t,o,f);o==="hex"&&(o=16),u(o===(o|0)&&o>=2&&o<=36),t=t.toString().replace(/\s+/g,"");var l=0;t[0]==="-"&&(l++,this.negative=1),l<t.length&&(o===16?this._parseHex(t,l,f):(this._parseBase(t,o,l),f==="le"&&this._initArray(this.toArray(),o,f)));},a.prototype._initNumber=function(t,o,f){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(u(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),f==="le"&&this._initArray(this.toArray(),o,f);},a.prototype._initArray=function(t,o,f){if(u(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var l=0;l<this.length;l++)this.words[l]=0;var m,E,M=0;if(f==="be")for(l=t.length-1,m=0;l>=0;l-=3)E=t[l]|t[l-1]<<8|t[l-2]<<16,this.words[m]|=E<<M&67108863,this.words[m+1]=E>>>26-M&67108863,M+=24,M>=26&&(M-=26,m++);else if(f==="le")for(l=0,m=0;l<t.length;l+=3)E=t[l]|t[l+1]<<8|t[l+2]<<16,this.words[m]|=E<<M&67108863,this.words[m+1]=E>>>26-M&67108863,M+=24,M>=26&&(M-=26,m++);return this._strip()};function d(v,t){var o=v.charCodeAt(t);if(o>=48&&o<=57)return o-48;if(o>=65&&o<=70)return o-55;if(o>=97&&o<=102)return o-87;u(!1,"Invalid character in "+v);}function I(v,t,o){var f=d(v,o);return o-1>=t&&(f|=d(v,o-1)<<4),f}a.prototype._parseHex=function(t,o,f){this.length=Math.ceil((t.length-o)/6),this.words=new Array(this.length);for(var l=0;l<this.length;l++)this.words[l]=0;var m=0,E=0,M;if(f==="be")for(l=t.length-1;l>=o;l-=2)M=I(t,o,l)<<m,this.words[E]|=M&67108863,m>=18?(m-=18,E+=1,this.words[E]|=M>>>26):m+=8;else {var p=t.length-o;for(l=p%2===0?o+1:o;l<t.length;l+=2)M=I(t,o,l)<<m,this.words[E]|=M&67108863,m>=18?(m-=18,E+=1,this.words[E]|=M>>>26):m+=8;}this._strip();};function b(v,t,o,f){for(var l=0,m=0,E=Math.min(v.length,o),M=t;M<E;M++){var p=v.charCodeAt(M)-48;l*=f,p>=49?m=p-49+10:p>=17?m=p-17+10:m=p,u(p>=0&&m<f,"Invalid character"),l+=m;}return l}a.prototype._parseBase=function(t,o,f){this.words=[0],this.length=1;for(var l=0,m=1;m<=67108863;m*=o)l++;l--,m=m/o|0;for(var E=t.length-f,M=E%l,p=Math.min(E,E-M)+f,n=0,g=f;g<p;g+=l)n=b(t,g,g+l,o),this.imuln(m),this.words[0]+n<67108864?this.words[0]+=n:this._iaddn(n);if(M!==0){var _=1;for(n=b(t,g,t.length,o),g=0;g<M;g++)_*=o;this.imuln(_),this.words[0]+n<67108864?this.words[0]+=n:this._iaddn(n);}this._strip();},a.prototype.copy=function(t){t.words=new Array(this.length);for(var o=0;o<this.length;o++)t.words[o]=this.words[o];t.length=this.length,t.negative=this.negative,t.red=this.red;};function k(v,t){v.words=t.words,v.length=t.length,v.negative=t.negative,v.red=t.red;}if(a.prototype._move=function(t){k(t,this);},a.prototype.clone=function(){var t=new a(null);return this.copy(t),t},a.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=L;}catch{a.prototype.inspect=L;}else a.prototype.inspect=L;function L(){return (this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var H=["","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"],X=[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],N=[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];a.prototype.toString=function(t,o){t=t||10,o=o|0||1;var f;if(t===16||t==="hex"){f="";for(var l=0,m=0,E=0;E<this.length;E++){var M=this.words[E],p=((M<<l|m)&16777215).toString(16);m=M>>>24-l&16777215,l+=2,l>=26&&(l-=26,E--),m!==0||E!==this.length-1?f=H[6-p.length]+p+f:f=p+f;}for(m!==0&&(f=m.toString(16)+f);f.length%o!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(t===(t|0)&&t>=2&&t<=36){var n=X[t],g=N[t];f="";var _=this.clone();for(_.negative=0;!_.isZero();){var S=_.modrn(g).toString(t);_=_.idivn(g),_.isZero()?f=S+f:f=H[n-S.length]+S+f;}for(this.isZero()&&(f="0"+f);f.length%o!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}u(!1,"Base should be between 2 and 36");},a.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&u(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},a.prototype.toJSON=function(){return this.toString(16,2)},T&&(a.prototype.toBuffer=function(t,o){return this.toArrayLike(T,t,o)}),a.prototype.toArray=function(t,o){return this.toArrayLike(Array,t,o)};var G=function(t,o){return t.allocUnsafe?t.allocUnsafe(o):new t(o)};a.prototype.toArrayLike=function(t,o,f){this._strip();var l=this.byteLength(),m=f||Math.max(1,l);u(l<=m,"byte array longer than desired length"),u(m>0,"Requested array length <= 0");var E=G(t,m),M=o==="le"?"LE":"BE";return this["_toArrayLike"+M](E,l),E},a.prototype._toArrayLikeLE=function(t,o){for(var f=0,l=0,m=0,E=0;m<this.length;m++){var M=this.words[m]<<E|l;t[f++]=M&255,f<t.length&&(t[f++]=M>>8&255),f<t.length&&(t[f++]=M>>16&255),E===6?(f<t.length&&(t[f++]=M>>24&255),l=0,E=0):(l=M>>>24,E+=2);}if(f<t.length)for(t[f++]=l;f<t.length;)t[f++]=0;},a.prototype._toArrayLikeBE=function(t,o){for(var f=t.length-1,l=0,m=0,E=0;m<this.length;m++){var M=this.words[m]<<E|l;t[f--]=M&255,f>=0&&(t[f--]=M>>8&255),f>=0&&(t[f--]=M>>16&255),E===6?(f>=0&&(t[f--]=M>>24&255),l=0,E=0):(l=M>>>24,E+=2);}if(f>=0)for(t[f--]=l;f>=0;)t[f--]=0;},Math.clz32?a.prototype._countBits=function(t){return 32-Math.clz32(t)}:a.prototype._countBits=function(t){var o=t,f=0;return o>=4096&&(f+=13,o>>>=13),o>=64&&(f+=7,o>>>=7),o>=8&&(f+=4,o>>>=4),o>=2&&(f+=2,o>>>=2),f+o},a.prototype._zeroBits=function(t){if(t===0)return 26;var o=t,f=0;return o&8191||(f+=13,o>>>=13),o&127||(f+=7,o>>>=7),o&15||(f+=4,o>>>=4),o&3||(f+=2,o>>>=2),o&1||f++,f},a.prototype.bitLength=function(){var t=this.words[this.length-1],o=this._countBits(t);return (this.length-1)*26+o};function W(v){for(var t=new Array(v.bitLength()),o=0;o<t.length;o++){var f=o/26|0,l=o%26;t[o]=v.words[f]>>>l&1;}return t}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,o=0;o<this.length;o++){var f=this._zeroBits(this.words[o]);if(t+=f,f!==26)break}return t},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},a.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var o=0;o<t.length;o++)this.words[o]=this.words[o]|t.words[o];return this._strip()},a.prototype.ior=function(t){return u((this.negative|t.negative)===0),this.iuor(t)},a.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var o;this.length>t.length?o=t:o=this;for(var f=0;f<o.length;f++)this.words[f]=this.words[f]&t.words[f];return this.length=o.length,this._strip()},a.prototype.iand=function(t){return u((this.negative|t.negative)===0),this.iuand(t)},a.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var o,f;this.length>t.length?(o=this,f=t):(o=t,f=this);for(var l=0;l<f.length;l++)this.words[l]=o.words[l]^f.words[l];if(this!==o)for(;l<o.length;l++)this.words[l]=o.words[l];return this.length=o.length,this._strip()},a.prototype.ixor=function(t){return u((this.negative|t.negative)===0),this.iuxor(t)},a.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){u(typeof t=="number"&&t>=0);var o=Math.ceil(t/26)|0,f=t%26;this._expand(o),f>0&&o--;for(var l=0;l<o;l++)this.words[l]=~this.words[l]&67108863;return f>0&&(this.words[l]=~this.words[l]&67108863>>26-f),this._strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,o){u(typeof t=="number"&&t>=0);var f=t/26|0,l=t%26;return this._expand(f+1),o?this.words[f]=this.words[f]|1<<l:this.words[f]=this.words[f]&~(1<<l),this._strip()},a.prototype.iadd=function(t){var o;if(this.negative!==0&&t.negative===0)return this.negative=0,o=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,o=this.isub(t),t.negative=1,o._normSign();var f,l;this.length>t.length?(f=this,l=t):(f=t,l=this);for(var m=0,E=0;E<l.length;E++)o=(f.words[E]|0)+(l.words[E]|0)+m,this.words[E]=o&67108863,m=o>>>26;for(;m!==0&&E<f.length;E++)o=(f.words[E]|0)+m,this.words[E]=o&67108863,m=o>>>26;if(this.length=f.length,m!==0)this.words[this.length]=m,this.length++;else if(f!==this)for(;E<f.length;E++)this.words[E]=f.words[E];return this},a.prototype.add=function(t){var o;return t.negative!==0&&this.negative===0?(t.negative=0,o=this.sub(t),t.negative^=1,o):t.negative===0&&this.negative!==0?(this.negative=0,o=t.sub(this),this.negative=1,o):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var o=this.iadd(t);return t.negative=1,o._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var f=this.cmp(t);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var l,m;f>0?(l=this,m=t):(l=t,m=this);for(var E=0,M=0;M<m.length;M++)o=(l.words[M]|0)-(m.words[M]|0)+E,E=o>>26,this.words[M]=o&67108863;for(;E!==0&&M<l.length;M++)o=(l.words[M]|0)+E,E=o>>26,this.words[M]=o&67108863;if(E===0&&M<l.length&&l!==this)for(;M<l.length;M++)this.words[M]=l.words[M];return this.length=Math.max(this.length,M),l!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(t){return this.clone().isub(t)};function z(v,t,o){o.negative=t.negative^v.negative;var f=v.length+t.length|0;o.length=f,f=f-1|0;var l=v.words[0]|0,m=t.words[0]|0,E=l*m,M=E&67108863,p=E/67108864|0;o.words[0]=M;for(var n=1;n<f;n++){for(var g=p>>>26,_=p&67108863,S=Math.min(n,t.length-1),P=Math.max(0,n-v.length+1);P<=S;P++){var D=n-P|0;l=v.words[D]|0,m=t.words[P]|0,E=l*m+_,g+=E/67108864|0,_=E&67108863;}o.words[n]=_|0,p=g|0;}return p!==0?o.words[n]=p|0:o.length--,o._strip()}var St=function(t,o,f){var l=t.words,m=o.words,E=f.words,M=0,p,n,g,_=l[0]|0,S=_&8191,P=_>>>13,D=l[1]|0,Z=D&8191,K=D>>>13,kt=l[2]|0,Q=kt&8191,J=kt>>>13,Ft=l[3]|0,at=Ft&8191,ut=Ft>>>13,Vt=l[4]|0,ht=Vt&8191,ft=Vt>>>13,te=l[5]|0,rt=te&8191,j=te>>>13,Jt=l[6]|0,lt=Jt&8191,tt=Jt>>>13,le=l[7]|0,h=le&8191,e=le>>>13,r=l[8]|0,c=r&8191,w=r>>>13,A=l[9]|0,R=A&8191,B=A>>>13,nt=m[0]|0,F=nt&8191,q=nt>>>13,Y=m[1]|0,ct=Y&8191,dt=Y>>>13,Ur=m[2]|0,pt=Ur&8191,mt=Ur>>>13,Lr=m[3]|0,gt=Lr&8191,yt=Lr>>>13,kr=m[4]|0,vt=kr&8191,wt=kr>>>13,Dr=m[5]|0,Et=Dr&8191,Mt=Dr>>>13,Or=m[6]|0,Tt=Or&8191,At=Or>>>13,Fr=m[7]|0,Rt=Fr&8191,It=Fr>>>13,Gr=m[8]|0,xt=Gr&8191,Ct=Gr>>>13,qr=m[9]|0,bt=qr&8191,_t=qr>>>13;f.negative=t.negative^o.negative,f.length=19,p=Math.imul(S,F),n=Math.imul(S,q),n=n+Math.imul(P,F)|0,g=Math.imul(P,q);var Oe=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,p=Math.imul(Z,F),n=Math.imul(Z,q),n=n+Math.imul(K,F)|0,g=Math.imul(K,q),p=p+Math.imul(S,ct)|0,n=n+Math.imul(S,dt)|0,n=n+Math.imul(P,ct)|0,g=g+Math.imul(P,dt)|0;var Fe=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,p=Math.imul(Q,F),n=Math.imul(Q,q),n=n+Math.imul(J,F)|0,g=Math.imul(J,q),p=p+Math.imul(Z,ct)|0,n=n+Math.imul(Z,dt)|0,n=n+Math.imul(K,ct)|0,g=g+Math.imul(K,dt)|0,p=p+Math.imul(S,pt)|0,n=n+Math.imul(S,mt)|0,n=n+Math.imul(P,pt)|0,g=g+Math.imul(P,mt)|0;var Ge=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,p=Math.imul(at,F),n=Math.imul(at,q),n=n+Math.imul(ut,F)|0,g=Math.imul(ut,q),p=p+Math.imul(Q,ct)|0,n=n+Math.imul(Q,dt)|0,n=n+Math.imul(J,ct)|0,g=g+Math.imul(J,dt)|0,p=p+Math.imul(Z,pt)|0,n=n+Math.imul(Z,mt)|0,n=n+Math.imul(K,pt)|0,g=g+Math.imul(K,mt)|0,p=p+Math.imul(S,gt)|0,n=n+Math.imul(S,yt)|0,n=n+Math.imul(P,gt)|0,g=g+Math.imul(P,yt)|0;var qe=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(qe>>>26)|0,qe&=67108863,p=Math.imul(ht,F),n=Math.imul(ht,q),n=n+Math.imul(ft,F)|0,g=Math.imul(ft,q),p=p+Math.imul(at,ct)|0,n=n+Math.imul(at,dt)|0,n=n+Math.imul(ut,ct)|0,g=g+Math.imul(ut,dt)|0,p=p+Math.imul(Q,pt)|0,n=n+Math.imul(Q,mt)|0,n=n+Math.imul(J,pt)|0,g=g+Math.imul(J,mt)|0,p=p+Math.imul(Z,gt)|0,n=n+Math.imul(Z,yt)|0,n=n+Math.imul(K,gt)|0,g=g+Math.imul(K,yt)|0,p=p+Math.imul(S,vt)|0,n=n+Math.imul(S,wt)|0,n=n+Math.imul(P,vt)|0,g=g+Math.imul(P,wt)|0;var $e=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+($e>>>26)|0,$e&=67108863,p=Math.imul(rt,F),n=Math.imul(rt,q),n=n+Math.imul(j,F)|0,g=Math.imul(j,q),p=p+Math.imul(ht,ct)|0,n=n+Math.imul(ht,dt)|0,n=n+Math.imul(ft,ct)|0,g=g+Math.imul(ft,dt)|0,p=p+Math.imul(at,pt)|0,n=n+Math.imul(at,mt)|0,n=n+Math.imul(ut,pt)|0,g=g+Math.imul(ut,mt)|0,p=p+Math.imul(Q,gt)|0,n=n+Math.imul(Q,yt)|0,n=n+Math.imul(J,gt)|0,g=g+Math.imul(J,yt)|0,p=p+Math.imul(Z,vt)|0,n=n+Math.imul(Z,wt)|0,n=n+Math.imul(K,vt)|0,g=g+Math.imul(K,wt)|0,p=p+Math.imul(S,Et)|0,n=n+Math.imul(S,Mt)|0,n=n+Math.imul(P,Et)|0,g=g+Math.imul(P,Mt)|0;var He=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(He>>>26)|0,He&=67108863,p=Math.imul(lt,F),n=Math.imul(lt,q),n=n+Math.imul(tt,F)|0,g=Math.imul(tt,q),p=p+Math.imul(rt,ct)|0,n=n+Math.imul(rt,dt)|0,n=n+Math.imul(j,ct)|0,g=g+Math.imul(j,dt)|0,p=p+Math.imul(ht,pt)|0,n=n+Math.imul(ht,mt)|0,n=n+Math.imul(ft,pt)|0,g=g+Math.imul(ft,mt)|0,p=p+Math.imul(at,gt)|0,n=n+Math.imul(at,yt)|0,n=n+Math.imul(ut,gt)|0,g=g+Math.imul(ut,yt)|0,p=p+Math.imul(Q,vt)|0,n=n+Math.imul(Q,wt)|0,n=n+Math.imul(J,vt)|0,g=g+Math.imul(J,wt)|0,p=p+Math.imul(Z,Et)|0,n=n+Math.imul(Z,Mt)|0,n=n+Math.imul(K,Et)|0,g=g+Math.imul(K,Mt)|0,p=p+Math.imul(S,Tt)|0,n=n+Math.imul(S,At)|0,n=n+Math.imul(P,Tt)|0,g=g+Math.imul(P,At)|0;var We=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(We>>>26)|0,We&=67108863,p=Math.imul(h,F),n=Math.imul(h,q),n=n+Math.imul(e,F)|0,g=Math.imul(e,q),p=p+Math.imul(lt,ct)|0,n=n+Math.imul(lt,dt)|0,n=n+Math.imul(tt,ct)|0,g=g+Math.imul(tt,dt)|0,p=p+Math.imul(rt,pt)|0,n=n+Math.imul(rt,mt)|0,n=n+Math.imul(j,pt)|0,g=g+Math.imul(j,mt)|0,p=p+Math.imul(ht,gt)|0,n=n+Math.imul(ht,yt)|0,n=n+Math.imul(ft,gt)|0,g=g+Math.imul(ft,yt)|0,p=p+Math.imul(at,vt)|0,n=n+Math.imul(at,wt)|0,n=n+Math.imul(ut,vt)|0,g=g+Math.imul(ut,wt)|0,p=p+Math.imul(Q,Et)|0,n=n+Math.imul(Q,Mt)|0,n=n+Math.imul(J,Et)|0,g=g+Math.imul(J,Mt)|0,p=p+Math.imul(Z,Tt)|0,n=n+Math.imul(Z,At)|0,n=n+Math.imul(K,Tt)|0,g=g+Math.imul(K,At)|0,p=p+Math.imul(S,Rt)|0,n=n+Math.imul(S,It)|0,n=n+Math.imul(P,Rt)|0,g=g+Math.imul(P,It)|0;var Ze=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,p=Math.imul(c,F),n=Math.imul(c,q),n=n+Math.imul(w,F)|0,g=Math.imul(w,q),p=p+Math.imul(h,ct)|0,n=n+Math.imul(h,dt)|0,n=n+Math.imul(e,ct)|0,g=g+Math.imul(e,dt)|0,p=p+Math.imul(lt,pt)|0,n=n+Math.imul(lt,mt)|0,n=n+Math.imul(tt,pt)|0,g=g+Math.imul(tt,mt)|0,p=p+Math.imul(rt,gt)|0,n=n+Math.imul(rt,yt)|0,n=n+Math.imul(j,gt)|0,g=g+Math.imul(j,yt)|0,p=p+Math.imul(ht,vt)|0,n=n+Math.imul(ht,wt)|0,n=n+Math.imul(ft,vt)|0,g=g+Math.imul(ft,wt)|0,p=p+Math.imul(at,Et)|0,n=n+Math.imul(at,Mt)|0,n=n+Math.imul(ut,Et)|0,g=g+Math.imul(ut,Mt)|0,p=p+Math.imul(Q,Tt)|0,n=n+Math.imul(Q,At)|0,n=n+Math.imul(J,Tt)|0,g=g+Math.imul(J,At)|0,p=p+Math.imul(Z,Rt)|0,n=n+Math.imul(Z,It)|0,n=n+Math.imul(K,Rt)|0,g=g+Math.imul(K,It)|0,p=p+Math.imul(S,xt)|0,n=n+Math.imul(S,Ct)|0,n=n+Math.imul(P,xt)|0,g=g+Math.imul(P,Ct)|0;var Ve=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,p=Math.imul(R,F),n=Math.imul(R,q),n=n+Math.imul(B,F)|0,g=Math.imul(B,q),p=p+Math.imul(c,ct)|0,n=n+Math.imul(c,dt)|0,n=n+Math.imul(w,ct)|0,g=g+Math.imul(w,dt)|0,p=p+Math.imul(h,pt)|0,n=n+Math.imul(h,mt)|0,n=n+Math.imul(e,pt)|0,g=g+Math.imul(e,mt)|0,p=p+Math.imul(lt,gt)|0,n=n+Math.imul(lt,yt)|0,n=n+Math.imul(tt,gt)|0,g=g+Math.imul(tt,yt)|0,p=p+Math.imul(rt,vt)|0,n=n+Math.imul(rt,wt)|0,n=n+Math.imul(j,vt)|0,g=g+Math.imul(j,wt)|0,p=p+Math.imul(ht,Et)|0,n=n+Math.imul(ht,Mt)|0,n=n+Math.imul(ft,Et)|0,g=g+Math.imul(ft,Mt)|0,p=p+Math.imul(at,Tt)|0,n=n+Math.imul(at,At)|0,n=n+Math.imul(ut,Tt)|0,g=g+Math.imul(ut,At)|0,p=p+Math.imul(Q,Rt)|0,n=n+Math.imul(Q,It)|0,n=n+Math.imul(J,Rt)|0,g=g+Math.imul(J,It)|0,p=p+Math.imul(Z,xt)|0,n=n+Math.imul(Z,Ct)|0,n=n+Math.imul(K,xt)|0,g=g+Math.imul(K,Ct)|0,p=p+Math.imul(S,bt)|0,n=n+Math.imul(S,_t)|0,n=n+Math.imul(P,bt)|0,g=g+Math.imul(P,_t)|0;var Je=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Je>>>26)|0,Je&=67108863,p=Math.imul(R,ct),n=Math.imul(R,dt),n=n+Math.imul(B,ct)|0,g=Math.imul(B,dt),p=p+Math.imul(c,pt)|0,n=n+Math.imul(c,mt)|0,n=n+Math.imul(w,pt)|0,g=g+Math.imul(w,mt)|0,p=p+Math.imul(h,gt)|0,n=n+Math.imul(h,yt)|0,n=n+Math.imul(e,gt)|0,g=g+Math.imul(e,yt)|0,p=p+Math.imul(lt,vt)|0,n=n+Math.imul(lt,wt)|0,n=n+Math.imul(tt,vt)|0,g=g+Math.imul(tt,wt)|0,p=p+Math.imul(rt,Et)|0,n=n+Math.imul(rt,Mt)|0,n=n+Math.imul(j,Et)|0,g=g+Math.imul(j,Mt)|0,p=p+Math.imul(ht,Tt)|0,n=n+Math.imul(ht,At)|0,n=n+Math.imul(ft,Tt)|0,g=g+Math.imul(ft,At)|0,p=p+Math.imul(at,Rt)|0,n=n+Math.imul(at,It)|0,n=n+Math.imul(ut,Rt)|0,g=g+Math.imul(ut,It)|0,p=p+Math.imul(Q,xt)|0,n=n+Math.imul(Q,Ct)|0,n=n+Math.imul(J,xt)|0,g=g+Math.imul(J,Ct)|0,p=p+Math.imul(Z,bt)|0,n=n+Math.imul(Z,_t)|0,n=n+Math.imul(K,bt)|0,g=g+Math.imul(K,_t)|0;var je=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(je>>>26)|0,je&=67108863,p=Math.imul(R,pt),n=Math.imul(R,mt),n=n+Math.imul(B,pt)|0,g=Math.imul(B,mt),p=p+Math.imul(c,gt)|0,n=n+Math.imul(c,yt)|0,n=n+Math.imul(w,gt)|0,g=g+Math.imul(w,yt)|0,p=p+Math.imul(h,vt)|0,n=n+Math.imul(h,wt)|0,n=n+Math.imul(e,vt)|0,g=g+Math.imul(e,wt)|0,p=p+Math.imul(lt,Et)|0,n=n+Math.imul(lt,Mt)|0,n=n+Math.imul(tt,Et)|0,g=g+Math.imul(tt,Mt)|0,p=p+Math.imul(rt,Tt)|0,n=n+Math.imul(rt,At)|0,n=n+Math.imul(j,Tt)|0,g=g+Math.imul(j,At)|0,p=p+Math.imul(ht,Rt)|0,n=n+Math.imul(ht,It)|0,n=n+Math.imul(ft,Rt)|0,g=g+Math.imul(ft,It)|0,p=p+Math.imul(at,xt)|0,n=n+Math.imul(at,Ct)|0,n=n+Math.imul(ut,xt)|0,g=g+Math.imul(ut,Ct)|0,p=p+Math.imul(Q,bt)|0,n=n+Math.imul(Q,_t)|0,n=n+Math.imul(J,bt)|0,g=g+Math.imul(J,_t)|0;var ze=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(ze>>>26)|0,ze&=67108863,p=Math.imul(R,gt),n=Math.imul(R,yt),n=n+Math.imul(B,gt)|0,g=Math.imul(B,yt),p=p+Math.imul(c,vt)|0,n=n+Math.imul(c,wt)|0,n=n+Math.imul(w,vt)|0,g=g+Math.imul(w,wt)|0,p=p+Math.imul(h,Et)|0,n=n+Math.imul(h,Mt)|0,n=n+Math.imul(e,Et)|0,g=g+Math.imul(e,Mt)|0,p=p+Math.imul(lt,Tt)|0,n=n+Math.imul(lt,At)|0,n=n+Math.imul(tt,Tt)|0,g=g+Math.imul(tt,At)|0,p=p+Math.imul(rt,Rt)|0,n=n+Math.imul(rt,It)|0,n=n+Math.imul(j,Rt)|0,g=g+Math.imul(j,It)|0,p=p+Math.imul(ht,xt)|0,n=n+Math.imul(ht,Ct)|0,n=n+Math.imul(ft,xt)|0,g=g+Math.imul(ft,Ct)|0,p=p+Math.imul(at,bt)|0,n=n+Math.imul(at,_t)|0,n=n+Math.imul(ut,bt)|0,g=g+Math.imul(ut,_t)|0;var Ye=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,p=Math.imul(R,vt),n=Math.imul(R,wt),n=n+Math.imul(B,vt)|0,g=Math.imul(B,wt),p=p+Math.imul(c,Et)|0,n=n+Math.imul(c,Mt)|0,n=n+Math.imul(w,Et)|0,g=g+Math.imul(w,Mt)|0,p=p+Math.imul(h,Tt)|0,n=n+Math.imul(h,At)|0,n=n+Math.imul(e,Tt)|0,g=g+Math.imul(e,At)|0,p=p+Math.imul(lt,Rt)|0,n=n+Math.imul(lt,It)|0,n=n+Math.imul(tt,Rt)|0,g=g+Math.imul(tt,It)|0,p=p+Math.imul(rt,xt)|0,n=n+Math.imul(rt,Ct)|0,n=n+Math.imul(j,xt)|0,g=g+Math.imul(j,Ct)|0,p=p+Math.imul(ht,bt)|0,n=n+Math.imul(ht,_t)|0,n=n+Math.imul(ft,bt)|0,g=g+Math.imul(ft,_t)|0;var Xe=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Xe>>>26)|0,Xe&=67108863,p=Math.imul(R,Et),n=Math.imul(R,Mt),n=n+Math.imul(B,Et)|0,g=Math.imul(B,Mt),p=p+Math.imul(c,Tt)|0,n=n+Math.imul(c,At)|0,n=n+Math.imul(w,Tt)|0,g=g+Math.imul(w,At)|0,p=p+Math.imul(h,Rt)|0,n=n+Math.imul(h,It)|0,n=n+Math.imul(e,Rt)|0,g=g+Math.imul(e,It)|0,p=p+Math.imul(lt,xt)|0,n=n+Math.imul(lt,Ct)|0,n=n+Math.imul(tt,xt)|0,g=g+Math.imul(tt,Ct)|0,p=p+Math.imul(rt,bt)|0,n=n+Math.imul(rt,_t)|0,n=n+Math.imul(j,bt)|0,g=g+Math.imul(j,_t)|0;var Ke=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,p=Math.imul(R,Tt),n=Math.imul(R,At),n=n+Math.imul(B,Tt)|0,g=Math.imul(B,At),p=p+Math.imul(c,Rt)|0,n=n+Math.imul(c,It)|0,n=n+Math.imul(w,Rt)|0,g=g+Math.imul(w,It)|0,p=p+Math.imul(h,xt)|0,n=n+Math.imul(h,Ct)|0,n=n+Math.imul(e,xt)|0,g=g+Math.imul(e,Ct)|0,p=p+Math.imul(lt,bt)|0,n=n+Math.imul(lt,_t)|0,n=n+Math.imul(tt,bt)|0,g=g+Math.imul(tt,_t)|0;var Qe=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,p=Math.imul(R,Rt),n=Math.imul(R,It),n=n+Math.imul(B,Rt)|0,g=Math.imul(B,It),p=p+Math.imul(c,xt)|0,n=n+Math.imul(c,Ct)|0,n=n+Math.imul(w,xt)|0,g=g+Math.imul(w,Ct)|0,p=p+Math.imul(h,bt)|0,n=n+Math.imul(h,_t)|0,n=n+Math.imul(e,bt)|0,g=g+Math.imul(e,_t)|0;var tr=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(tr>>>26)|0,tr&=67108863,p=Math.imul(R,xt),n=Math.imul(R,Ct),n=n+Math.imul(B,xt)|0,g=Math.imul(B,Ct),p=p+Math.imul(c,bt)|0,n=n+Math.imul(c,_t)|0,n=n+Math.imul(w,bt)|0,g=g+Math.imul(w,_t)|0;var er=(M+p|0)+((n&8191)<<13)|0;M=(g+(n>>>13)|0)+(er>>>26)|0,er&=67108863,p=Math.imul(R,bt),n=Math.imul(R,_t),n=n+Math.imul(B,bt)|0,g=Math.imul(B,_t);var rr=(M+p|0)+((n&8191)<<13)|0;return M=(g+(n>>>13)|0)+(rr>>>26)|0,rr&=67108863,E[0]=Oe,E[1]=Fe,E[2]=Ge,E[3]=qe,E[4]=$e,E[5]=He,E[6]=We,E[7]=Ze,E[8]=Ve,E[9]=Je,E[10]=je,E[11]=ze,E[12]=Ye,E[13]=Xe,E[14]=Ke,E[15]=Qe,E[16]=tr,E[17]=er,E[18]=rr,M!==0&&(E[19]=M,f.length++),f};Math.imul||(St=z);function ot(v,t,o){o.negative=t.negative^v.negative,o.length=v.length+t.length;for(var f=0,l=0,m=0;m<o.length-1;m++){var E=l;l=0;for(var M=f&67108863,p=Math.min(m,t.length-1),n=Math.max(0,m-v.length+1);n<=p;n++){var g=m-n,_=v.words[g]|0,S=t.words[n]|0,P=_*S,D=P&67108863;E=E+(P/67108864|0)|0,D=D+M|0,M=D&67108863,E=E+(D>>>26)|0,l+=E>>>26,E&=67108863;}o.words[m]=M,f=E,E=l;}return f!==0?o.words[m]=f:o.length--,o._strip()}function Pt(v,t,o){return ot(v,t,o)}a.prototype.mulTo=function(t,o){var f,l=this.length+t.length;return this.length===10&&t.length===10?f=St(this,t,o):l<63?f=z(this,t,o):l<1024?f=ot(this,t,o):f=Pt(this,t,o),f};a.prototype.mul=function(t){var o=new a(null);return o.words=new Array(this.length+t.length),this.mulTo(t,o)},a.prototype.mulf=function(t){var o=new a(null);return o.words=new Array(this.length+t.length),Pt(this,t,o)},a.prototype.imul=function(t){return this.clone().mulTo(t,this)},a.prototype.imuln=function(t){var o=t<0;o&&(t=-t),u(typeof t=="number"),u(t<67108864);for(var f=0,l=0;l<this.length;l++){var m=(this.words[l]|0)*t,E=(m&67108863)+(f&67108863);f>>=26,f+=m/67108864|0,f+=E>>>26,this.words[l]=E&67108863;}return f!==0&&(this.words[l]=f,this.length++),o?this.ineg():this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var o=W(t);if(o.length===0)return new a(1);for(var f=this,l=0;l<o.length&&o[l]===0;l++,f=f.sqr());if(++l<o.length)for(var m=f.sqr();l<o.length;l++,m=m.sqr())o[l]!==0&&(f=f.mul(m));return f},a.prototype.iushln=function(t){u(typeof t=="number"&&t>=0);var o=t%26,f=(t-o)/26,l=67108863>>>26-o<<26-o,m;if(o!==0){var E=0;for(m=0;m<this.length;m++){var M=this.words[m]&l,p=(this.words[m]|0)-M<<o;this.words[m]=p|E,E=M>>>26-o;}E&&(this.words[m]=E,this.length++);}if(f!==0){for(m=this.length-1;m>=0;m--)this.words[m+f]=this.words[m];for(m=0;m<f;m++)this.words[m]=0;this.length+=f;}return this._strip()},a.prototype.ishln=function(t){return u(this.negative===0),this.iushln(t)},a.prototype.iushrn=function(t,o,f){u(typeof t=="number"&&t>=0);var l;o?l=(o-o%26)/26:l=0;var m=t%26,E=Math.min((t-m)/26,this.length),M=67108863^67108863>>>m<<m,p=f;if(l-=E,l=Math.max(0,l),p){for(var n=0;n<E;n++)p.words[n]=this.words[n];p.length=E;}if(E!==0)if(this.length>E)for(this.length-=E,n=0;n<this.length;n++)this.words[n]=this.words[n+E];else this.words[0]=0,this.length=1;var g=0;for(n=this.length-1;n>=0&&(g!==0||n>=l);n--){var _=this.words[n]|0;this.words[n]=g<<26-m|_>>>m,g=_&M;}return p&&g!==0&&(p.words[p.length++]=g),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(t,o,f){return u(this.negative===0),this.iushrn(t,o,f)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){u(typeof t=="number"&&t>=0);var o=t%26,f=(t-o)/26,l=1<<o;if(this.length<=f)return !1;var m=this.words[f];return !!(m&l)},a.prototype.imaskn=function(t){u(typeof t=="number"&&t>=0);var o=t%26,f=(t-o)/26;if(u(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(o!==0&&f++,this.length=Math.min(f,this.length),o!==0){var l=67108863^67108863>>>o<<o;this.words[this.length-1]&=l;}return this._strip()},a.prototype.maskn=function(t){return this.clone().imaskn(t)},a.prototype.iaddn=function(t){return u(typeof t=="number"),u(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<=t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},a.prototype._iaddn=function(t){this.words[0]+=t;for(var o=0;o<this.length&&this.words[o]>=67108864;o++)this.words[o]-=67108864,o===this.length-1?this.words[o+1]=1:this.words[o+1]++;return this.length=Math.max(this.length,o+1),this},a.prototype.isubn=function(t){if(u(typeof t=="number"),u(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var o=0;o<this.length&&this.words[o]<0;o++)this.words[o]+=67108864,this.words[o+1]-=1;return this._strip()},a.prototype.addn=function(t){return this.clone().iaddn(t)},a.prototype.subn=function(t){return this.clone().isubn(t)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(t,o,f){var l=t.length+f,m;this._expand(l);var E,M=0;for(m=0;m<t.length;m++){E=(this.words[m+f]|0)+M;var p=(t.words[m]|0)*o;E-=p&67108863,M=(E>>26)-(p/67108864|0),this.words[m+f]=E&67108863;}for(;m<this.length-f;m++)E=(this.words[m+f]|0)+M,M=E>>26,this.words[m+f]=E&67108863;if(M===0)return this._strip();for(u(M===-1),M=0,m=0;m<this.length;m++)E=-(this.words[m]|0)+M,M=E>>26,this.words[m]=E&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(t,o){var f=this.length-t.length,l=this.clone(),m=t,E=m.words[m.length-1]|0,M=this._countBits(E);f=26-M,f!==0&&(m=m.ushln(f),l.iushln(f),E=m.words[m.length-1]|0);var p=l.length-m.length,n;if(o!=="mod"){n=new a(null),n.length=p+1,n.words=new Array(n.length);for(var g=0;g<n.length;g++)n.words[g]=0;}var _=l.clone()._ishlnsubmul(m,1,p);_.negative===0&&(l=_,n&&(n.words[p]=1));for(var S=p-1;S>=0;S--){var P=(l.words[m.length+S]|0)*67108864+(l.words[m.length+S-1]|0);for(P=Math.min(P/E|0,67108863),l._ishlnsubmul(m,P,S);l.negative!==0;)P--,l.negative=0,l._ishlnsubmul(m,1,S),l.isZero()||(l.negative^=1);n&&(n.words[S]=P);}return n&&n._strip(),l._strip(),o!=="div"&&f!==0&&l.iushrn(f),{div:n||null,mod:l}},a.prototype.divmod=function(t,o,f){if(u(!t.isZero()),this.isZero())return {div:new a(0),mod:new a(0)};var l,m,E;return this.negative!==0&&t.negative===0?(E=this.neg().divmod(t,o),o!=="mod"&&(l=E.div.neg()),o!=="div"&&(m=E.mod.neg(),f&&m.negative!==0&&m.iadd(t)),{div:l,mod:m}):this.negative===0&&t.negative!==0?(E=this.divmod(t.neg(),o),o!=="mod"&&(l=E.div.neg()),{div:l,mod:E.mod}):this.negative&t.negative?(E=this.neg().divmod(t.neg(),o),o!=="div"&&(m=E.mod.neg(),f&&m.negative!==0&&m.isub(t)),{div:E.div,mod:m}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:t.length===1?o==="div"?{div:this.divn(t.words[0]),mod:null}:o==="mod"?{div:null,mod:new a(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modrn(t.words[0]))}:this._wordDiv(t,o)},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var o=this.divmod(t);if(o.mod.isZero())return o.div;var f=o.div.negative!==0?o.mod.isub(t):o.mod,l=t.ushrn(1),m=t.andln(1),E=f.cmp(l);return E<0||m===1&&E===0?o.div:o.div.negative!==0?o.div.isubn(1):o.div.iaddn(1)},a.prototype.modrn=function(t){var o=t<0;o&&(t=-t),u(t<=67108863);for(var f=(1<<26)%t,l=0,m=this.length-1;m>=0;m--)l=(f*l+(this.words[m]|0))%t;return o?-l:l},a.prototype.modn=function(t){return this.modrn(t)},a.prototype.idivn=function(t){var o=t<0;o&&(t=-t),u(t<=67108863);for(var f=0,l=this.length-1;l>=0;l--){var m=(this.words[l]|0)+f*67108864;this.words[l]=m/t|0,f=m%t;}return this._strip(),o?this.ineg():this},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){u(t.negative===0),u(!t.isZero());var o=this,f=t.clone();o.negative!==0?o=o.umod(t):o=o.clone();for(var l=new a(1),m=new a(0),E=new a(0),M=new a(1),p=0;o.isEven()&&f.isEven();)o.iushrn(1),f.iushrn(1),++p;for(var n=f.clone(),g=o.clone();!o.isZero();){for(var _=0,S=1;!(o.words[0]&S)&&_<26;++_,S<<=1);if(_>0)for(o.iushrn(_);_-- >0;)(l.isOdd()||m.isOdd())&&(l.iadd(n),m.isub(g)),l.iushrn(1),m.iushrn(1);for(var P=0,D=1;!(f.words[0]&D)&&P<26;++P,D<<=1);if(P>0)for(f.iushrn(P);P-- >0;)(E.isOdd()||M.isOdd())&&(E.iadd(n),M.isub(g)),E.iushrn(1),M.iushrn(1);o.cmp(f)>=0?(o.isub(f),l.isub(E),m.isub(M)):(f.isub(o),E.isub(l),M.isub(m));}return {a:E,b:M,gcd:f.iushln(p)}},a.prototype._invmp=function(t){u(t.negative===0),u(!t.isZero());var o=this,f=t.clone();o.negative!==0?o=o.umod(t):o=o.clone();for(var l=new a(1),m=new a(0),E=f.clone();o.cmpn(1)>0&&f.cmpn(1)>0;){for(var M=0,p=1;!(o.words[0]&p)&&M<26;++M,p<<=1);if(M>0)for(o.iushrn(M);M-- >0;)l.isOdd()&&l.iadd(E),l.iushrn(1);for(var n=0,g=1;!(f.words[0]&g)&&n<26;++n,g<<=1);if(n>0)for(f.iushrn(n);n-- >0;)m.isOdd()&&m.iadd(E),m.iushrn(1);o.cmp(f)>=0?(o.isub(f),l.isub(m)):(f.isub(o),m.isub(l));}var _;return o.cmpn(1)===0?_=l:_=m,_.cmpn(0)<0&&_.iadd(t),_},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var o=this.clone(),f=t.clone();o.negative=0,f.negative=0;for(var l=0;o.isEven()&&f.isEven();l++)o.iushrn(1),f.iushrn(1);do{for(;o.isEven();)o.iushrn(1);for(;f.isEven();)f.iushrn(1);var m=o.cmp(f);if(m<0){var E=o;o=f,f=E;}else if(m===0||f.cmpn(1)===0)break;o.isub(f);}while(!0);return f.iushln(l)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return (this.words[0]&1)===0},a.prototype.isOdd=function(){return (this.words[0]&1)===1},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){u(typeof t=="number");var o=t%26,f=(t-o)/26,l=1<<o;if(this.length<=f)return this._expand(f+1),this.words[f]|=l,this;for(var m=l,E=f;m!==0&&E<this.length;E++){var M=this.words[E]|0;M+=m,m=M>>>26,M&=67108863,this.words[E]=M;}return m!==0&&(this.words[E]=m,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(t){var o=t<0;if(this.negative!==0&&!o)return -1;if(this.negative===0&&o)return 1;this._strip();var f;if(this.length>1)f=1;else {o&&(t=-t),u(t<=67108863,"Number is too big");var l=this.words[0]|0;f=l===t?0:l<t?-1:1;}return this.negative!==0?-f|0:f},a.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return -1;if(this.negative===0&&t.negative!==0)return 1;var o=this.ucmp(t);return this.negative!==0?-o|0:o},a.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return -1;for(var o=0,f=this.length-1;f>=0;f--){var l=this.words[f]|0,m=t.words[f]|0;if(l!==m){l<m?o=-1:l>m&&(o=1);break}}return o},a.prototype.gtn=function(t){return this.cmpn(t)===1},a.prototype.gt=function(t){return this.cmp(t)===1},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return this.cmpn(t)===-1},a.prototype.lt=function(t){return this.cmp(t)===-1},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return this.cmpn(t)===0},a.prototype.eq=function(t){return this.cmp(t)===0},a.red=function(t){return new st(t)},a.prototype.toRed=function(t){return u(!this.red,"Already a number in reduction context"),u(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return u(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return u(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return u(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return u(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return u(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return u(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return u(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return u(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return u(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return u(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return u(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return u(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return u(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return u(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return u(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var Bt={k256:null,p224:null,p192:null,p25519:null};function Nt(v,t){this.name=v,this.p=new a(t,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp();}Nt.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},Nt.prototype.ireduce=function(t){var o=t,f;do this.split(o,this.tmp),o=this.imulK(o),o=o.iadd(this.tmp),f=o.bitLength();while(f>this.n);var l=f<this.n?-1:o.ucmp(this.p);return l===0?(o.words[0]=0,o.length=1):l>0?o.isub(this.p):o.strip!==void 0?o.strip():o._strip(),o},Nt.prototype.split=function(t,o){t.iushrn(this.n,0,o);},Nt.prototype.imulK=function(t){return t.imul(this.k)};function Zt(){Nt.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f");}y(Zt,Nt),Zt.prototype.split=function(t,o){for(var f=4194303,l=Math.min(t.length,9),m=0;m<l;m++)o.words[m]=t.words[m];if(o.length=l,t.length<=9){t.words[0]=0,t.length=1;return}var E=t.words[9];for(o.words[o.length++]=E&f,m=10;m<t.length;m++){var M=t.words[m]|0;t.words[m-10]=(M&f)<<4|E>>>22,E=M;}E>>>=22,t.words[m-10]=E,E===0&&t.length>10?t.length-=10:t.length-=9;},Zt.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var o=0,f=0;f<t.length;f++){var l=t.words[f]|0;o+=l*977,t.words[f]=o&67108863,o=l*64+(o/67108864|0);}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function he(){Nt.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001");}y(he,Nt);function fe(){Nt.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff");}y(fe,Nt);function Qt(){Nt.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed");}y(Qt,Nt),Qt.prototype.imulK=function(t){for(var o=0,f=0;f<t.length;f++){var l=(t.words[f]|0)*19+o,m=l&67108863;l>>>=26,t.words[f]=m,o=l;}return o!==0&&(t.words[t.length++]=o),t},a._prime=function(t){if(Bt[t])return Bt[t];var o;if(t==="k256")o=new Zt;else if(t==="p224")o=new he;else if(t==="p192")o=new fe;else if(t==="p25519")o=new Qt;else throw new Error("Unknown prime "+t);return Bt[t]=o,o};function st(v){if(typeof v=="string"){var t=a._prime(v);this.m=t.p,this.prime=t;}else u(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null;}st.prototype._verify1=function(t){u(t.negative===0,"red works only with positives"),u(t.red,"red works only with red numbers");},st.prototype._verify2=function(t,o){u((t.negative|o.negative)===0,"red works only with positives"),u(t.red&&t.red===o.red,"red works only with red numbers");},st.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(k(t,t.umod(this.m)._forceRed(this)),t)},st.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},st.prototype.add=function(t,o){this._verify2(t,o);var f=t.add(o);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},st.prototype.iadd=function(t,o){this._verify2(t,o);var f=t.iadd(o);return f.cmp(this.m)>=0&&f.isub(this.m),f},st.prototype.sub=function(t,o){this._verify2(t,o);var f=t.sub(o);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},st.prototype.isub=function(t,o){this._verify2(t,o);var f=t.isub(o);return f.cmpn(0)<0&&f.iadd(this.m),f},st.prototype.shl=function(t,o){return this._verify1(t),this.imod(t.ushln(o))},st.prototype.imul=function(t,o){return this._verify2(t,o),this.imod(t.imul(o))},st.prototype.mul=function(t,o){return this._verify2(t,o),this.imod(t.mul(o))},st.prototype.isqr=function(t){return this.imul(t,t.clone())},st.prototype.sqr=function(t){return this.mul(t,t)},st.prototype.sqrt=function(t){if(t.isZero())return t.clone();var o=this.m.andln(3);if(u(o%2===1),o===3){var f=this.m.add(new a(1)).iushrn(2);return this.pow(t,f)}for(var l=this.m.subn(1),m=0;!l.isZero()&&l.andln(1)===0;)m++,l.iushrn(1);u(!l.isZero());var E=new a(1).toRed(this),M=E.redNeg(),p=this.m.subn(1).iushrn(1),n=this.m.bitLength();for(n=new a(2*n*n).toRed(this);this.pow(n,p).cmp(M)!==0;)n.redIAdd(M);for(var g=this.pow(n,l),_=this.pow(t,l.addn(1).iushrn(1)),S=this.pow(t,l),P=m;S.cmp(E)!==0;){for(var D=S,Z=0;D.cmp(E)!==0;Z++)D=D.redSqr();u(Z<P);var K=this.pow(g,new a(1).iushln(P-Z-1));_=_.redMul(K),g=K.redSqr(),S=S.redMul(g),P=Z;}return _},st.prototype.invm=function(t){var o=t._invmp(this.m);return o.negative!==0?(o.negative=0,this.imod(o).redNeg()):this.imod(o)},st.prototype.pow=function(t,o){if(o.isZero())return new a(1).toRed(this);if(o.cmpn(1)===0)return t.clone();var f=4,l=new Array(1<<f);l[0]=new a(1).toRed(this),l[1]=t;for(var m=2;m<l.length;m++)l[m]=this.mul(l[m-1],t);var E=l[0],M=0,p=0,n=o.bitLength()%26;for(n===0&&(n=26),m=o.length-1;m>=0;m--){for(var g=o.words[m],_=n-1;_>=0;_--){var S=g>>_&1;if(E!==l[0]&&(E=this.sqr(E)),S===0&&M===0){p=0;continue}M<<=1,M|=S,p++,!(p!==f&&(m!==0||_!==0))&&(E=this.mul(E,l[M]),p=0,M=0);}n=26;}return E},st.prototype.convertTo=function(t){var o=t.umod(this.m);return o===t?o.clone():o},st.prototype.convertFrom=function(t){var o=t.clone();return o.red=null,o},a.mont=function(t){return new Dt(t)};function Dt(v){st.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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);}y(Dt,st),Dt.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},Dt.prototype.convertFrom=function(t){var o=this.imod(t.mul(this.rinv));return o.red=null,o},Dt.prototype.imul=function(t,o){if(t.isZero()||o.isZero())return t.words[0]=0,t.length=1,t;var f=t.imul(o),l=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=f.isub(l).iushrn(this.shift),E=m;return m.cmp(this.m)>=0?E=m.isub(this.m):m.cmpn(0)<0&&(E=m.iadd(this.m)),E._forceRed(this)},Dt.prototype.mul=function(t,o){if(t.isZero()||o.isZero())return new a(0)._forceRed(this);var f=t.mul(o),l=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=f.isub(l).iushrn(this.shift),E=m;return m.cmp(this.m)>=0?E=m.isub(this.m):m.cmpn(0)<0&&(E=m.iadd(this.m)),E._forceRed(this)},Dt.prototype.invm=function(t){var o=this.imod(t._invmp(this.m).mul(this.r2));return o._forceRed(this)};})(typeof cr>"u"||cr,wn);});var pr=jt((zs,An)=>{C();x();An.exports=dr;dr.strict=Mn;dr.loose=Tn;var Fi=Object.prototype.toString,Gi={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function dr(s){return Mn(s)||Tn(s)}function Mn(s){return s instanceof Int8Array||s instanceof Int16Array||s instanceof Int32Array||s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Uint16Array||s instanceof Uint32Array||s instanceof Float32Array||s instanceof Float64Array}function Tn(s){return Gi[Fi.call(s)]}});var In=jt((Ks,Rn)=>{C();x();var qi=pr().strict;Rn.exports=function(i){if(qi(i)){var u=$.from(i.buffer);return i.byteLength!==i.buffer.byteLength&&(u=u.slice(i.byteOffset,i.byteOffset+i.byteLength)),u}else return $.from(i)};});var Gn=jt(U=>{C();x();var xn=U&&U.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(U,"__esModule",{value:!0});var $i=xn(pr()),Hi=xn(In()),mr="hex",gr="utf8",Wi="binary",Zi="buffer",Vi="array",Ji="typed-array",ji="array-buffer",ie="0";function Me(s){return new Uint8Array(s)}U.bufferToArray=Me;function yr(s,i=!1){let u=s.toString(mr);return i?xe(u):u}U.bufferToHex=yr;function vr(s){return s.toString(gr)}U.bufferToUtf8=vr;function Cn(s){return s.readUIntBE(0,s.length)}U.bufferToNumber=Cn;function zi(s){return Te(Me(s))}U.bufferToBinary=zi;function oe(s){return Hi.default(s)}U.arrayToBuffer=oe;function bn(s,i=!1){return yr(oe(s),i)}U.arrayToHex=bn;function _n(s){return vr(oe(s))}U.arrayToUtf8=_n;function wr(s){return Cn(oe(s))}U.arrayToNumber=wr;function Te(s){return Array.from(s).map(se).join("")}U.arrayToBinary=Te;function Er(s){return $.from(Ie(s),mr)}U.hexToBuffer=Er;function Mr(s){return Me(Er(s))}U.hexToArray=Mr;function Yi(s){return vr(Er(s))}U.hexToUtf8=Yi;function Xi(s){return wr(Mr(s))}U.hexToNumber=Xi;function Sn(s){return Te(Mr(s))}U.hexToBinary=Sn;function Tr(s){return $.from(s,gr)}U.utf8ToBuffer=Tr;function Bn(s){return Me(Tr(s))}U.utf8ToArray=Bn;function Ki(s,i=!1){return yr(Tr(s),i)}U.utf8ToHex=Ki;function Qi(s){let i=parseInt(s,10);return Eo(wo(i),"Number can only safely store up to 53 bits"),i}U.utf8ToNumber=Qi;function to(s){return Te(Bn(s))}U.utf8ToBinary=to;function eo(s){return Pn(se(s))}U.numberToBuffer=eo;function ro(s){return Xt(se(s))}U.numberToArray=ro;function no(s,i){return Ar(se(s),i)}U.numberToHex=no;function io(s){return `${s}`}U.numberToUtf8=io;function se(s){let i=(s>>>0).toString(2);return Re(i)}U.numberToBinary=se;function Pn(s){return oe(Xt(s))}U.binaryToBuffer=Pn;function Xt(s){return new Uint8Array(Ir(s).map(i=>parseInt(i,2)))}U.binaryToArray=Xt;function Ar(s,i){return bn(Xt(s),i)}U.binaryToHex=Ar;function oo(s){return _n(Xt(s))}U.binaryToUtf8=oo;function so(s){return wr(Xt(s))}U.binaryToNumber=so;function Nn(s){return !(typeof s!="string"||!new RegExp(/^[01]+$/).test(s)||s.length%8!==0)}U.isBinaryString=Nn;function Un(s,i){return !(typeof s!="string"||!s.match(/^0x[0-9A-Fa-f]*$/)||i&&s.length!==2+2*i)}U.isHexString=Un;function Ae(s){return $.isBuffer(s)}U.isBuffer=Ae;function Rr(s){return $i.default.strict(s)&&!Ae(s)}U.isTypedArray=Rr;function Ln(s){return !Rr(s)&&!Ae(s)&&typeof s.byteLength<"u"}U.isArrayBuffer=Ln;function ao(s){return Ae(s)?Zi:Rr(s)?Ji:Ln(s)?ji:Array.isArray(s)?Vi:typeof s}U.getType=ao;function uo(s){return Nn(s)?Wi:Un(s)?mr:gr}U.getEncoding=uo;function ho(...s){return $.concat(s)}U.concatBuffers=ho;function fo(...s){let i=[];return s.forEach(u=>i=i.concat(Array.from(u))),new Uint8Array([...i])}U.concatArrays=fo;function lo(s,i){let u=s.length-i;return u>0&&(s=s.slice(u)),s}U.trimLeft=lo;function co(s,i){return s.slice(0,i)}U.trimRight=co;function kn(s,i=8){let u=s%i;return u?(s-u)/i*i+i:s}U.calcByteLength=kn;function Ir(s,i=8){let u=Re(s).match(new RegExp(`.{${i}}`,"gi"));return Array.from(u||[])}U.splitBytes=Ir;function Dn(s){return Ir(s).map(Mo).join("")}U.swapBytes=Dn;function po(s){return Ar(Dn(Sn(s)))}U.swapHex=po;function Re(s,i=8,u=ie){return On(s,kn(s.length,i),u)}U.sanitizeBytes=Re;function On(s,i,u=ie){return Fn(s,i,!0,u)}U.padLeft=On;function mo(s,i,u=ie){return Fn(s,i,!1,u)}U.padRight=mo;function Ie(s){return s.replace(/^0x/,"")}U.removeHexPrefix=Ie;function xe(s){return s.startsWith("0x")?s:`0x${s}`}U.addHexPrefix=xe;function go(s){return s=Ie(s),s=Re(s,2),s&&(s=xe(s)),s}U.sanitizeHex=go;function yo(s){let i=s.startsWith("0x");return s=Ie(s),s=s.startsWith(ie)?s.substring(1):s,i?xe(s):s}U.removeHexLeadingZeros=yo;function vo(s){return typeof s>"u"}function wo(s){return !vo(s)}function Eo(s,i){if(!s)throw new Error(i)}function Mo(s){return s.split("").reverse().join("")}function Fn(s,i,u,y=ie){let a=i-s.length,T=s;if(a>0){let d=y.repeat(a);T=u?d+s:s+d;}return T}});C();x();C();x();C();x();C();x();var nn=or(rn()),Yt=class{emitter=new nn.EventEmitter;emit(i,...u){this.emitter.emit(i,...u);}on(i,u){this.emitter.on(i,u);}removeListener(i,u){this.emitter.removeListener(i,u);}};C();x();var on=(y=>(y.LOGGED_OUT="loggedOut",y.LOGGED_IN="loggedIn",y.ACCOUNTS_REQUESTED="accountsRequested",y))(on||{}),xi=(i=>(i.ACCOUNTS_CHANGED="accountsChanged",i))(xi||{}),Ci=(d=>(d.PENDING="PENDING",d.SUBMITTED="SUBMITTED",d.SUCCESSFUL="SUCCESSFUL",d.REVERTED="REVERTED",d.FAILED="FAILED",d.CANCELLED="CANCELLED",d))(Ci||{});C();x();var gn={};mi(gn,{coerceNonceSpace:()=>pn,digestOfTransactionsAndNonce:()=>dn,encodeMessageSubDigest:()=>ye,encodeNonce:()=>mn,encodedTransactions:()=>hr,getEip155ChainId:()=>Ut,getNonce:()=>re,getNormalisedTransactions:()=>ge,packSignatures:()=>we,signAndPackTypedData:()=>fr,signERC191Message:()=>lr,signMetaTransactions:()=>ve});C();x();var fn=1,Li=1,ki=2,ln="02",Di="",cn=`tuple(
|
|
13
|
+
bool delegateCall,
|
|
14
|
+
bool revertOnError,
|
|
15
|
+
uint256 gasLimit,
|
|
16
|
+
address target,
|
|
17
|
+
uint256 value,
|
|
18
|
+
bytes data
|
|
19
|
+
)[]`,ge=s=>s.map(i=>({delegateCall:i.delegateCall===!0,revertOnError:i.revertOnError===!0,gasLimit:i.gasLimit??BigInt(0),target:i.to??ZeroAddress,value:i.value??BigInt(0),data:i.data??"0x"})),dn=(s,i)=>{let u=AbiCoder.defaultAbiCoder().encode(["uint256",cn],[s,i]);return keccak256(u)},hr=s=>AbiCoder.defaultAbiCoder().encode([cn],[s]),pn=s=>s||0n,mn=(s,i)=>{let u=BigInt(s)*2n**96n;return BigInt(i)+u},re=async(s,i,u)=>{try{let y=new Contract(i,walletContracts.mainModule.abi,s),a=pn(u),T=await y.readNonce(a);if(typeof T=="bigint")return mn(a,T);throw new Error("Unexpected result from contract.nonce() call.")}catch(y){if(isError(y,"BAD_DATA"))return BigInt(0);throw y}},ye=(s,i,u)=>solidityPacked(["string","uint256","address","bytes32"],[Di,s,i,u]),ve=async(s,i,u,y,a)=>{let T=ge(s),d=dn(i,T),I=ye(u,y,d),b=keccak256(I),k=getBytes(b),H=`${await a.signMessage(k)}${ln}`,X=v1.signature.encodeSignature({version:1,threshold:Li,signers:[{isDynamic:!1,unrecovered:!0,weight:fn,signature:H}]}),N=new Interface(walletContracts.mainModule.abi);return N.encodeFunctionData(N.getFunction("execute")??"",[T,i,X])},Oi=s=>{let i=`0x0000${s}`;return v1.signature.decodeSignature(i)},we=(s,i,u)=>{let y=`${s}${ln}`,{signers:a}=Oi(u),d=[...a,{isDynamic:!1,unrecovered:!0,weight:fn,signature:y,address:i}].sort((I,b)=>{let k=BigInt(I.address??0),L=BigInt(b.address??0);return k<=L?-1:k===L?0:1});return v1.signature.encodeSignature({version:1,threshold:ki,signers:d})},fr=async(s,i,u,y,a)=>{let T={...s.types};delete T.EIP712Domain;let d=TypedDataEncoder.hash(s.domain,T,s.message),I=ye(u,y,d),b=keccak256(I),k=getBytes(b),L=await a.signMessage(k),H=await a.getAddress();return we(L,H,i)},lr=async(s,i,u,y)=>{let a=hashMessage(i),T=ye(s,y,a),d=keccak256(T),I=getBytes(d);return u.signMessage(I)},Ut=s=>`eip155:${s}`;var ne=class s{config;rpcProvider;authManager;constructor({config:i,rpcProvider:u,authManager:y}){this.config=i,this.rpcProvider=u,this.authManager=y;}static getResponsePreview(i){return i.length>100?`${i.substring(0,50)}...${i.substring(i.length-50)}`:i}async postToRelayer(i){let u={id:1,jsonrpc:"2.0",...i},y=await this.authManager.getUserZkEvm(),a=await fetch(`${this.config.relayerUrl}/v1/transactions`,{method:"POST",headers:{Authorization:`Bearer ${y.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(u)}),T=await a.text();if(!a.ok){let I=s.getResponsePreview(T);throw new Error(`Relayer HTTP error: ${a.status}. Content: "${I}"`)}let d;try{d=JSON.parse(T);}catch(I){let b=s.getResponsePreview(T);throw new Error(`Relayer JSON parse error: ${I instanceof Error?I.message:"Unknown error"}. Content: "${b}"`)}if(d.error)throw new Error(d.error);return d}async ethSendTransaction(i,u){let{chainId:y}=await this.rpcProvider.getNetwork(),a={method:"eth_sendTransaction",params:[{to:i,data:u,chainId:Ut(Number(y))}]},{result:T}=await this.postToRelayer(a);return T}async imGetTransactionByHash(i){let u={method:"im_getTransactionByHash",params:[i]},{result:y}=await this.postToRelayer(u);return y}async imGetFeeOptions(i,u){let{chainId:y}=await this.rpcProvider.getNetwork(),a={method:"im_getFeeOptions",params:[{userAddress:i,data:u,chainId:Ut(Number(y))}]},{result:T}=await this.postToRelayer(a);return T}async imSignTypedData(i,u){let{chainId:y}=await this.rpcProvider.getNetwork(),a={method:"im_signTypedData",params:[{address:i,eip712Payload:u,chainId:Ut(Number(y))}]},{result:T}=await this.postToRelayer(a);return T}async imSign(i,u){let{chainId:y}=await this.rpcProvider.getNetwork(),a={method:"im_sign",params:[{address:i,message:u,chainId:Ut(Number(y))}]},{result:T}=await this.postToRelayer(a);return T}};C();x();var Ee=(a=>(a[a.USER_REJECTED_REQUEST=4001]="USER_REJECTED_REQUEST",a[a.UNAUTHORIZED=4100]="UNAUTHORIZED",a[a.UNSUPPORTED_METHOD=4200]="UNSUPPORTED_METHOD",a[a.DISCONNECTED=4900]="DISCONNECTED",a))(Ee||{}),Ot=(I=>(I[I.RPC_SERVER_ERROR=-32e3]="RPC_SERVER_ERROR",I[I.INVALID_REQUEST=-32600]="INVALID_REQUEST",I[I.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",I[I.INVALID_PARAMS=-32602]="INVALID_PARAMS",I[I.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",I[I.PARSE_ERROR=-32700]="PARSE_ERROR",I[I.TRANSACTION_REJECTED=-32003]="TRANSACTION_REJECTED",I))(Ot||{}),O=class extends Error{message;code;constructor(i,u){super(u),this.message=u,this.code=i;}};C();x();C();x();C();x();var Gt=or(En(),1),qt=or(Gn(),1);function To(s){return qt.addHexPrefix(qt.padLeft(s.r.toString(16),64)+qt.padLeft(s.s.toString(16),64)+qt.padLeft(s.recoveryParam?.toString(16)||"",2))}function Ao(s){let i=new Gt.default(s,16).cmp(new Gt.default(27))!==-1?new Gt.default(s,16).sub(new Gt.default(27)).toNumber():new Gt.default(s,16).toNumber();return s.trim()?i:void 0}function Ro(s,i=64){let u=qt.removeHexPrefix(s);return {r:new Gt.default(u.substring(0,i),"hex"),s:new Gt.default(u.substring(i,i*2),"hex"),recoveryParam:Ao(u.substring(i*2,i*2+2))}}async function qn(s,i){let u=Ro(await i.signMessage(s));return To(u)}var Io="Only sign this message from Immutable Passport";async function $n({authManager:s,ethSigner:i,multiRollupApiClients:u,accessToken:y,rpcProvider:a,flow:T}){let d=i.getAddress();d.then(()=>T.addEvent("endGetAddress"));let I=qn(Io,i);I.then(()=>T.addEvent("endSignRaw"));let b=a.getNetwork();b.then(()=>T.addEvent("endDetectNetwork"));let k=u.chainsApi.listChains();k.then(()=>T.addEvent("endListChains"));let[L,H,X,N]=await Promise.all([d,I,b,k]),G=Ut(Number(X.chainId)),W=N.data?.result?.find(z=>z.id===G)?.name;if(!W)throw new O(-32603,`Chain name does not exist on for chain id ${X.chainId}`);try{let z=await u.passportApi.createCounterfactualAddressV2({chainName:W,createCounterfactualAddressRequest:{ethereum_address:L,ethereum_signature:H}},{headers:{Authorization:`Bearer ${y}`}});return T.addEvent("endCreateCounterfactualAddress"),s.forceUserRefreshInBackground(),z.data.counterfactual_address}catch(z){throw new O(-32603,`Failed to create counterfactual address: ${z}`)}}C();x();C();x();C();x();C();x();var xo=s=>new Promise(i=>{setTimeout(()=>i(),s);}),Kt=async(s,i)=>{let{retries:u=3,interval:y=1e3,finalErr:a=Error("Retry failed"),finallyFn:T=()=>{}}=i||{};try{return await s()}catch{return u<=0?Promise.reject(a):(await xo(y),Kt(s,{retries:u-1,finalErr:a,finallyFn:T}))}finally{u<=0&&T();}};C();x();var Ce=(I=>(I.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",I.TRANSACTION_REJECTED="TRANSACTION_REJECTED",I.INVALID_CONFIGURATION="INVALID_CONFIGURATION",I.UNAUTHORIZED="UNAUTHORIZED",I.GUARDIAN_ERROR="GUARDIAN_ERROR",I.SERVICE_UNAVAILABLE_ERROR="SERVICE_UNAVAILABLE_ERROR",I.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",I))(Ce||{}),Lt=class extends Error{type;constructor(i,u){super(i),this.name="WalletError",this.type=u;}};var be="Transaction requires confirmation but this functionality is not supported in this environment. Please contact Immutable support if you need to enable this feature.",_e=s=>BigInt(s).toString(),bo=s=>{try{return s.map(i=>({delegateCall:i.delegateCall===!0,revertOnError:i.revertOnError===!0,gasLimit:i.gasLimit?_e(i.gasLimit):"0",target:i.to??ZeroAddress,value:i.value?_e(i.value):"0",data:i.data?i.data.toString():"0x"}))}catch(i){let u=i instanceof Error?i.message:String(i);throw new O(-32602,`Transaction failed to parsing: ${u}`)}},Se=class{guardianApi;confirmationScreen;crossSdkBridgeEnabled;authManager;constructor({confirmationScreen:i,config:u,authManager:y,guardianApi:a}){this.confirmationScreen=i,this.crossSdkBridgeEnabled=u.crossSdkBridgeEnabled,this.guardianApi=a,this.authManager=y;}withConfirmationScreen(i){return u=>this.withConfirmationScreenTask(i)(u)()}withConfirmationScreenTask(i){return u=>async()=>{this.confirmationScreen.loading(i);try{return await u()}catch(y){throw y instanceof Lt&&y.type==="SERVICE_UNAVAILABLE_ERROR"?(await this.confirmationScreen.showServiceUnavailable(),y):(this.confirmationScreen.closeWindow(),y)}}}withDefaultConfirmationScreenTask(i){return this.withConfirmationScreenTask()(i)}async evaluateImxTransaction({payloadHash:i}){try{let u=()=>{this.confirmationScreen.closeWindow();},y=await this.authManager.getUserImx(),a={Authorization:`Bearer ${y.accessToken}`};if(!(await Kt(async()=>this.guardianApi.getTransactionByID({transactionID:i,chainType:"starkex"},{headers:a}),{finallyFn:u})).data.id)throw new Error("Transaction doesn't exists");let d=await this.guardianApi.evaluateTransaction({id:i,transactionEvaluationRequest:{chainType:"starkex"}},{headers:a}),{confirmationRequired:I}=d.data;if(I){if(this.crossSdkBridgeEnabled)throw new Error(be);if(!(await this.confirmationScreen.requestConfirmation(i,y.imx.ethAddress,xr.mr.TransactionApprovalRequestChainTypeEnum.Starkex)).confirmed)throw new Error("Transaction rejected by user")}else this.confirmationScreen.closeWindow();}catch(u){throw Hn.isAxiosError(u)&&u.response?.status===403?new Lt("Service unavailable","SERVICE_UNAVAILABLE_ERROR"):u}}async evaluateEVMTransaction({chainId:i,nonce:u,metaTransactions:y}){let a=await this.authManager.getUserZkEvm(),T={Authorization:`Bearer ${a.accessToken}`},d=bo(y);try{return (await this.guardianApi.evaluateTransaction({id:"evm",transactionEvaluationRequest:{chainType:"evm",chainId:i,transactionData:{nonce:u,userAddress:a.zkEvm.ethAddress,metaTransactions:d}}},{headers:T})).data}catch(I){if(Hn.isAxiosError(I)&&I.response?.status===403)throw new Lt("Service unavailable","SERVICE_UNAVAILABLE_ERROR");let b=I instanceof Error?I.message:String(I);throw new O(-32603,`Transaction failed to validate with error: ${b}`)}}async validateEVMTransaction({chainId:i,nonce:u,metaTransactions:y,isBackgroundTransaction:a}){let T=await this.evaluateEVMTransaction({chainId:i,nonce:u,metaTransactions:y}),{confirmationRequired:d,transactionId:I}=T;if(d&&this.crossSdkBridgeEnabled)throw new O(-32003,be);if(d&&I){let b=await this.authManager.getUserZkEvm();if(!(await this.confirmationScreen.requestConfirmation(I,b.zkEvm.ethAddress,xr.mr.TransactionApprovalRequestChainTypeEnum.Evm,i)).confirmed)throw new O(-32003,"Transaction rejected by user")}else a||this.confirmationScreen.closeWindow();}async handleEIP712MessageEvaluation({chainID:i,payload:u}){try{let y=await this.authManager.getUserZkEvm();if(y===null)throw new O(4100,"User not logged in. Please log in first.");return (await this.guardianApi.evaluateMessage({messageEvaluationRequest:{chainID:i,payload:u}},{headers:{Authorization:`Bearer ${y.accessToken}`}})).data}catch(y){let a=y instanceof Error?y.message:String(y);throw new O(-32603,`Message failed to validate with error: ${a}`)}}async evaluateEIP712Message({chainID:i,payload:u}){let{messageId:y,confirmationRequired:a}=await this.handleEIP712MessageEvaluation({chainID:i,payload:u});if(a&&this.crossSdkBridgeEnabled)throw new O(-32003,be);if(a&&y){let T=await this.authManager.getUserZkEvm();if(!(await this.confirmationScreen.requestMessageConfirmation(y,T.zkEvm.ethAddress,"eip712")).confirmed)throw new O(-32003,"Signature rejected by user")}else this.confirmationScreen.closeWindow();}async handleERC191MessageEvaluation({chainID:i,payload:u}){try{let y=await this.authManager.getUserZkEvm();if(y===null)throw new O(4100,"User not logged in. Please log in first.");return (await this.guardianApi.evaluateErc191Message({eRC191MessageEvaluationRequest:{chainID:Ut(Number(i)),payload:u}},{headers:{Authorization:`Bearer ${y.accessToken}`}})).data}catch(y){let a=y instanceof Error?y.message:String(y);throw new O(-32603,`Message failed to validate with error: ${a}`)}}async evaluateERC191Message({chainID:i,payload:u}){let{messageId:y,confirmationRequired:a}=await this.handleERC191MessageEvaluation({chainID:i,payload:u});if(a&&this.crossSdkBridgeEnabled)throw new O(-32003,be);if(a&&y){let T=await this.authManager.getUserZkEvm();if(!(await this.confirmationScreen.requestMessageConfirmation(y,T.zkEvm.ethAddress,"erc191")).confirmed)throw new O(-32003,"Signature rejected by user")}else this.confirmationScreen.closeWindow();}};var _o=30,So=1e3,Bo=async(s,i,u)=>{let y=ge([s]),a=hr(y),T=await u.imGetFeeOptions(i,a);if(!T||!Array.isArray(T))throw new Error("Invalid fee options received from relayer");let d=T.find(I=>I.tokenSymbol==="IMX");if(!d)throw new Error("Failed to retrieve fees for IMX token");return d},Po=async(s,i,u,y,a)=>{if(!s.to)throw new O(-32602,'eth_sendTransaction requires a "to" field');let T={to:s.to.toString(),data:s.data,nonce:BigInt(0),value:s.value,revertOnError:!0},[d,I]=await Promise.all([re(i,y,a),Bo(T,y,u)]),b=[{...T,nonce:d}],k=BigInt(I.tokenPrice);return k!==BigInt(0)&&b.push({nonce:d,to:I.recipientAddress,value:k,revertOnError:!0}),b},Be=async(s,i,u)=>{let a=await Kt(async()=>{let T=await s.imGetTransactionByHash(i);if(T.status==="PENDING")throw new Error;return T},{retries:_o,interval:So,finalErr:new O(-32e3,"transaction hash not generated in time")});if(u.addEvent("endRetrieveRelayerTransaction"),!["SUBMITTED","SUCCESSFUL"].includes(a.status)){let T=`Transaction failed to submit with status ${a.status}.`;throw a.statusMessage&&(T+=` Error message: ${a.statusMessage}`),new O(-32e3,T)}return a},Pe=async({transactionRequest:s,ethSigner:i,rpcProvider:u,guardianClient:y,relayerClient:a,zkEvmAddress:T,flow:d,nonceSpace:I,isBackgroundTransaction:b})=>{let{chainId:k}=await u.getNetwork(),L=BigInt(k);d.addEvent("endDetectNetwork");let H=await Po(s,u,a,T,I);d.addEvent("endBuildMetaTransactions");let{nonce:X}=H[0];if(typeof X>"u")throw new Error("Failed to retrieve nonce from the smart wallet");let N=async()=>{await y.validateEVMTransaction({chainId:Ut(Number(k)),nonce:_e(X),metaTransactions:H,isBackgroundTransaction:b}),d.addEvent("endValidateEVMTransaction");},G=async()=>{let St=await ve(H,X,L,T,i);return d.addEvent("endGetSignedMetaTransactions"),St},[,W]=await Promise.all([N(),G()]),z=await a.ethSendTransaction(T,W);return d.addEvent("endRelayerSendTransaction"),{signedTransactions:W,relayerId:z,nonce:X}},No=async s=>{if(!s.to)throw new O(-32602,'im_signEjectionTransaction requires a "to" field');if(typeof s.nonce>"u")throw new O(-32602,'im_signEjectionTransaction requires a "nonce" field');if(!s.chainId)throw new O(-32602,'im_signEjectionTransaction requires a "chainId" field');return [{to:s.to.toString(),data:s.data,nonce:s.nonce??void 0,value:s.value,revertOnError:!0}]},Wn=async({transactionRequest:s,ethSigner:i,zkEvmAddress:u,flow:y})=>{let a=await No(s);y.addEvent("endBuildMetaTransactions");let T=await ve(a,s.nonce,BigInt(s.chainId??0),u,i);return y.addEvent("endGetSignedMetaTransactions"),{to:u,data:T,chainId:Ut(Number(s.chainId??0))}};var Cr=async({params:s,ethSigner:i,rpcProvider:u,relayerClient:y,guardianClient:a,zkEvmAddress:T,flow:d,nonceSpace:I,isBackgroundTransaction:b=!1})=>{let k=s[0],{relayerId:L}=await Pe({transactionRequest:k,ethSigner:i,rpcProvider:u,guardianClient:a,relayerClient:y,zkEvmAddress:T,flow:d,nonceSpace:I,isBackgroundTransaction:b}),{hash:H}=await Be(y,L,d);return H};C();x();var Zn=["types","domain","primaryType","message"],Uo=s=>Zn.every(i=>i in s),Lo=(s,i)=>{let u;if(typeof s=="string")try{u=JSON.parse(s);}catch(a){throw new O(-32602,`Failed to parse typed data JSON: ${a}`)}else if(typeof s=="object")u=s;else throw new O(-32602,`Invalid typed data argument: ${s}`);if(!Uo(u))throw new O(-32602,`Invalid typed data argument. The following properties are required: ${Zn.join(", ")}`);let y=u.domain?.chainId;if(y&&(typeof y=="string"&&(y.startsWith("0x")?u.domain.chainId=parseInt(y,16).toString():u.domain.chainId=parseInt(y,10).toString()),BigInt(u.domain.chainId??0)!==i))throw new O(-32602,`Invalid chainId, expected ${i}`);return u},Vn=async({params:s,method:i,ethSigner:u,rpcProvider:y,relayerClient:a,guardianClient:T,flow:d})=>{let I=s[0],b=s[1];if(!I||!b)throw new O(-32602,`${i} requires an address and a typed data JSON`);let{chainId:k}=await y.getNetwork(),L=Lo(b,k);d.addEvent("endDetectNetwork"),await T.evaluateEIP712Message({chainID:String(k),payload:L}),d.addEvent("endValidateMessage");let H=await a.imSignTypedData(I,L);d.addEvent("endRelayerSignTypedData");let X=await fr(L,H,BigInt(k),I,u);return d.addEvent("getSignedTypedData"),X};C();x();C();x();var Jn=s=>{if(!s)return s;try{let i=stripZerosLeft(getBytes(s));return toUtf8String(i)}catch{return s}};var Ne=async({params:s,ethSigner:i,zkEvmAddress:u,rpcProvider:y,guardianClient:a,relayerClient:T,flow:d})=>{let I=s[0],b=s[1];if(!b||!I)throw new O(-32602,"personal_sign requires an address and a message");if(b.toLowerCase()!==u.toLowerCase())throw new O(-32602,"personal_sign requires the signer to be the from address");let k=Jn(I),{chainId:L}=await y.getNetwork();d.addEvent("endDetectNetwork");let H=BigInt(L),X=lr(H,k,i,b);X.then(()=>d.addEvent("endEOASignature")),await a.evaluateERC191Message({chainID:L,payload:k}),d.addEvent("endEvaluateERC191Message");let[N,G]=await Promise.all([X,T.imSign(b,k)]);d.addEvent("endRelayerSign");let W=await i.getAddress();return d.addEvent("endGetEOAAddress"),we(N,W,G)};C();x();C();x();var Go="https://api.immutable.com",qo="https://api.sandbox.immutable.com",$o="/v1/sdk/session-activity/check",Ho=s=>{switch(s){case Environment.SANDBOX:return qo;case Environment.PRODUCTION:return Go;default:throw new Error("Environment not supported")}},Ue,zn=s=>{Ue||(Ue=Hn.create({baseURL:Ho(s)}));};async function Yn(s){if(!Ue)throw new Error("Client not initialised");return Ue.get($o,{params:s}).then(i=>i.data).catch(i=>{if(i.response.status!==404)throw i})}C();x();function Kn(s,i){return (...u)=>{try{let y=s(...u);return y instanceof Promise?y.catch(a=>(a instanceof Error&&trackError("passport","sessionActivityError",a),i)):y}catch(y){return y instanceof Error&&trackError("passport","sessionActivityError",y),i}}}var{getItem:Qn,setItem:br}=utils.localStorage,_r="sessionActivitySendCount",ti="sessionActivityDate",Sr={},$t={},Le={},ei=()=>{$t=Qn(_r)||{};let s=Qn(ti),i=new Date,u=i.getFullYear(),y=`${i.getMonth()+1}`.padStart(2,"0"),a=`${i.getDate()}`.padStart(2,"0"),T=`${u}-${y}-${a}`;(!s||s!==T)&&($t={}),br(ti,T),br(_r,$t);};ei();var jo=s=>{ei(),$t[s]||($t[s]=0),$t[s]++,br(_r,$t),Sr[s]=0;},zo=async s=>new Promise(i=>{setTimeout(i,s*1e3);}),Yo=async s=>{let i=s.flow||trackFlow("passport","sendSessionActivity"),u=s.passportClient;if(!u)throw i.addEvent("No Passport Client ID"),new Error("No Passport Client ID provided");if(Le[u])return;Le[u]=!0;let{sendTransaction:y,environment:a}=s;if(!y)throw new Error("No sendTransaction function provided");if(!a)throw new Error("No environment provided");zn(a);let T=s.walletAddress;if(!T)throw i.addEvent("No Passport Wallet Address"),new Error("No wallet address");let d;try{if(d=await Yn({clientId:u,wallet:T,checkCount:Sr[u]||0,sendCount:$t[u]||0}),Sr[u]++,!d)return}catch(I){throw i.addEvent("Failed to fetch details"),new Error("Failed to get details",{cause:I})}if(d&&d.contractAddress&&d.functionName){let b=new Interface([`function ${d.functionName}()`]).encodeFunctionData(d.functionName),k=d.contractAddress;try{i.addEvent("Start Sending Transaction");let L=await s.sendTransaction([{to:k,from:T,data:b}],i);jo(u),i.addEvent("Transaction Sent",{tx:L});}catch(L){i.addEvent("Failed to send Transaction");let H=new Error("Failed to send transaction",{cause:L});trackError("passport","sessionActivityError",H,{flowId:i.details.flowId});}}d&&d.delay&&d.delay>0&&(i.addEvent("Delaying Transaction",{delay:d.delay}),await zo(d.delay),setTimeout(()=>{i.addEvent("Retrying after Delay"),Le[u]=!1,ri({...s,flow:i});},0));},ri=s=>Kn(Yo)(s).then(()=>{Le[s.passportClient]=!1;}),ni=ri;C();x();var ii=async({params:s,ethSigner:i,rpcProvider:u,relayerClient:y,guardianClient:a,zkEvmAddress:T,flow:d})=>{let I={to:T,value:0},{relayerId:b}=await Pe({transactionRequest:I,ethSigner:i,rpcProvider:u,guardianClient:a,relayerClient:y,zkEvmAddress:T,flow:d});return a.withConfirmationScreen()(async()=>{let k=await Ne({params:s,ethSigner:i,zkEvmAddress:T,rpcProvider:u,guardianClient:a,relayerClient:y,flow:d});return await Be(y,b,d),k})};C();x();var oi=async({params:s,ethSigner:i,zkEvmAddress:u,flow:y})=>{if(!s||s.length!==1)throw new O(-32602,"im_signEjectionTransaction requires a singular param (hash)");let a=s[0];return await Wn({transactionRequest:a,ethSigner:i,zkEvmAddress:u,flow:y})};var ke=s=>"zkEvm"in s,Br=class{#o;#s;#a;#h;#e;#t;#f;#i;#r;isPassport=!0;constructor({authManager:i,config:u,multiRollupApiClients:y,passportEventEmitter:a,guardianClient:T,ethSigner:d,user:I}){this.#o=i,this.#s=u,this.#e=T,this.#h=a,this.#r=d,this.#t=new JsonRpcProvider(this.#s.zkEvmRpcUrl,void 0,{staticNetwork:!0}),this.#i=new ne({config:this.#s,rpcProvider:this.#t,authManager:this.#o}),this.#f=y,this.#a=new Yt,I&&ke(I)&&this.#u(I.zkEvm.ethAddress),a.on("loggedIn",b=>{ke(b)&&this.#u(b.zkEvm.ethAddress);}),a.on("loggedOut",this.#l),a.on("accountsRequested",ni);}#l=()=>{this.#a.emit("accountsChanged",[]);};async#u(i,u){let y=BigInt(1),a=async(T,d)=>await Cr({params:T,ethSigner:this.#r,guardianClient:this.#e,rpcProvider:this.#t,relayerClient:this.#i,zkEvmAddress:i,flow:d,nonceSpace:y,isBackgroundTransaction:!0});this.#h.emit("accountsRequested",{environment:this.#s.environment,sendTransaction:a,walletAddress:i,passportClient:u||"wallet"});}async#n(){try{let i=await this.#o.getUser();return i&&ke(i)?i.zkEvm.ethAddress:void 0}catch{return}}async#c(i){switch(i.method){case"eth_requestAccounts":{let u=await this.#n();if(u)return [u];let y=trackFlow("passport","ethRequestAccounts");try{let a=await this.#o.getUserOrLogin();y.addEvent("endGetUserOrLogin");let T;return ke(a)?T=a.zkEvm.ethAddress:(y.addEvent("startUserRegistration"),T=await $n({ethSigner:this.#r,authManager:this.#o,multiRollupApiClients:this.#f,accessToken:a.accessToken,rpcProvider:this.#t,flow:y}),y.addEvent("endUserRegistration")),this.#a.emit("accountsChanged",[T]),identify({passportId:a.profile.sub}),this.#u(T),[T]}catch(a){throw a instanceof Error?trackError("passport","ethRequestAccounts",a,{flowId:y.details.flowId}):y.addEvent("errored"),a}finally{y.addEvent("End");}}case"eth_sendTransaction":{let u=await this.#n();if(!u)throw new O(4100,"Unauthorised - call eth_requestAccounts first");let y=trackFlow("passport","ethSendTransaction");try{return await this.#e.withConfirmationScreen({width:480,height:720})(async()=>await Cr({params:i.params||[],ethSigner:this.#r,guardianClient:this.#e,rpcProvider:this.#t,relayerClient:this.#i,zkEvmAddress:u,flow:y}))}catch(a){throw a instanceof Error?trackError("passport","eth_sendTransaction",a,{flowId:y.details.flowId}):y.addEvent("errored"),a}finally{y.addEvent("End");}}case"eth_accounts":{let u=await this.#n();return u?[u]:[]}case"personal_sign":{let u=await this.#n();if(!u)throw new O(4100,"Unauthorised - call eth_requestAccounts first");let y=trackFlow("passport","personalSign");try{return await this.#e.withConfirmationScreen({width:480,height:720})(async()=>this.#s.forceScwDeployBeforeMessageSignature&&!(await re(this.#t,u)>BigInt(0))?await ii({params:i.params||[],zkEvmAddress:u,ethSigner:this.#r,rpcProvider:this.#t,guardianClient:this.#e,relayerClient:this.#i,flow:y}):await Ne({params:i.params||[],zkEvmAddress:u,ethSigner:this.#r,rpcProvider:this.#t,guardianClient:this.#e,relayerClient:this.#i,flow:y}))}catch(a){throw a instanceof Error?trackError("passport","personal_sign",a,{flowId:y.details.flowId}):y.addEvent("errored"),a}finally{y.addEvent("End");}}case"eth_signTypedData":case"eth_signTypedData_v4":{if(!await this.#n())throw new O(4100,"Unauthorised - call eth_requestAccounts first");let y=trackFlow("passport","ethSignTypedDataV4");try{return await this.#e.withConfirmationScreen({width:480,height:720})(async()=>await Vn({method:i.method,params:i.params||[],ethSigner:this.#r,rpcProvider:this.#t,relayerClient:this.#i,guardianClient:this.#e,flow:y}))}catch(a){throw a instanceof Error?trackError("passport","eth_signTypedData",a,{flowId:y.details.flowId}):y.addEvent("errored"),a}finally{y.addEvent("End");}}case"eth_chainId":{let{chainId:u}=await this.#t.getNetwork();return toBeHex(u)}case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":{let[u,y]=i.params||[];return this.#t.send(i.method,[u,y||"latest"])}case"eth_getStorageAt":{let[u,y,a]=i.params||[];return this.#t.send(i.method,[u,y,a||"latest"])}case"eth_call":case"eth_estimateGas":{let[u,y]=i.params||[];return this.#t.send(i.method,[u,y||"latest"])}case"eth_gasPrice":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":return this.#t.send(i.method,i.params||[]);case"im_signEjectionTransaction":{let u=await this.#n();if(!u)throw new O(4100,"Unauthorised - call eth_requestAccounts first");let y=trackFlow("passport","imSignEjectionTransaction");try{return await oi({params:i.params||[],ethSigner:this.#r,zkEvmAddress:u,flow:y})}catch(a){throw a instanceof Error?trackError("passport","imSignEjectionTransaction",a,{flowId:y.details.flowId}):y.addEvent("errored"),a}finally{y.addEvent("End");}}case"im_addSessionActivity":{let[u]=i.params||[],y=await this.#n();return y&&this.#u(y,u),null}default:throw new O(4200,"Method not supported")}}async request(i){try{return this.#c(i)}catch(u){throw u instanceof O?u:u instanceof Error?new O(-32603,u.message):new O(-32603,"Internal error")}}on(i,u){this.#a.on(i,u);}removeListener(i,u){this.#a.removeListener(i,u);}};C();x();var Pr=class{environment;passportDomain;zkEvmRpcUrl;relayerUrl;indexerMrBasePath;jsonRpcReferrer;forceScwDeployBeforeMessageSignature;crossSdkBridgeEnabled;constructor(i){if(this.environment=i.baseConfig.environment,this.jsonRpcReferrer=i.jsonRpcReferrer,this.forceScwDeployBeforeMessageSignature=i.forceScwDeployBeforeMessageSignature||!1,this.crossSdkBridgeEnabled=i.crossSdkBridgeEnabled||!1,i.overrides)this.passportDomain=i.overrides.passportDomain,this.zkEvmRpcUrl=i.overrides.zkEvmRpcUrl,this.relayerUrl=i.overrides.relayerUrl,this.indexerMrBasePath=i.overrides.indexerMrBasePath;else switch(i.baseConfig.environment){case Environment.PRODUCTION:this.passportDomain="https://passport.immutable.com",this.zkEvmRpcUrl="https://rpc.immutable.com",this.relayerUrl="https://api.immutable.com/relayer-mr",this.indexerMrBasePath="https://api.immutable.com";break;case Environment.SANDBOX:this.passportDomain="https://passport.sandbox.immutable.com",this.zkEvmRpcUrl="https://rpc.testnet.immutable.com",this.relayerUrl="https://api.sandbox.immutable.com/relayer-mr",this.indexerMrBasePath="https://api.sandbox.immutable.com";break;default:throw new Error(`Unsupported environment: ${i.baseConfig.environment}`)}}};C();x();C();x();var Nr=async(s,i,u=!0,y=!0)=>{let a=trackFlow("passport",i,u);try{return await s(a)}catch(T){throw T instanceof Error?trackError("passport",i,T,{flowId:a.details.flowId}):a.addEvent("errored"),T}finally{y&&a.addEvent("End");}};var hi="ETH",De=class s extends AbstractSigner{authManager;magicTeeApiClient;userWallet=null;createWalletPromise=null;constructor(i,u){super(),this.authManager=i,this.magicTeeApiClient=u;}async getUserWallet(){let{userWallet:i}=this;i||(i=await this.createWallet());let u=await this.getUserOrThrow();if(u.profile.sub!==i.userIdentifier&&(i=await this.createWallet(u)),isUserImx(u)&&u.imx.userAdminAddress.toLowerCase()!==i.walletAddress.toLowerCase())throw new Lt(`Wallet address mismatch.Rollup: IMX, TEE address: ${i.walletAddress}, profile address: ${u.imx.userAdminAddress}`,"WALLET_CONNECTION_ERROR");if(isUserZkEvm(u)&&u.zkEvm.userAdminAddress.toLowerCase()!==i.walletAddress.toLowerCase())throw new Lt(`Wallet address mismatch.Rollup: zkEVM, TEE address: ${i.walletAddress}, profile address: ${u.zkEvm.userAdminAddress}`,"WALLET_CONNECTION_ERROR");return i}async createWallet(i){return this.createWalletPromise?this.createWalletPromise:(this.createWalletPromise=new Promise(async(u,y)=>{try{this.userWallet=null;let a=i||await this.getUserOrThrow(),T=s.getHeaders(a);await Nr(async d=>{try{let I=performance.now(),b=await this.magicTeeApiClient.walletApi.createWalletV1WalletPost({xMagicChain:hi},{headers:T});return trackDuration("passport",d.details.flowName,Math.round(performance.now()-I)),this.userWallet={userIdentifier:a.profile.sub,walletAddress:b.data.public_address},u(this.userWallet)}catch(I){let b="MagicTEE: Failed to initialise EOA";return isAxiosError(I)?I.response?b+=` with status ${I.response.status}: ${JSON.stringify(I.response.data)}`:b+=`: ${I.message}`:b+=`: ${I.message}`,y(new Error(b))}},"magicCreateWallet");}catch(a){y(a);}finally{this.createWalletPromise=null;}}),this.createWalletPromise)}async getUserOrThrow(){let i=await this.authManager.getUser();if(!i)throw new Lt("User has been logged out","NOT_LOGGED_IN_ERROR");return i}static getHeaders(i){if(!i)throw new Lt("User has been logged out","NOT_LOGGED_IN_ERROR");return {Authorization:`Bearer ${i.idToken}`}}async getAddress(){return (await this.getUserWallet()).walletAddress}async signMessage(i){await this.getUserWallet();let u=i instanceof Uint8Array?`0x${$.from(i).toString("hex")}`:i,y=await this.getUserOrThrow(),a=await s.getHeaders(y);return Nr(async T=>{try{let d=performance.now(),I=await this.magicTeeApiClient.signOperationsApi.signMessageV1WalletSignMessagePost({signMessageRequest:{message_base64:$.from(u,"utf-8").toString("base64")},xMagicChain:hi},{headers:a});return trackDuration("passport",T.details.flowName,Math.round(performance.now()-d)),I.data.signature}catch(d){let I="MagicTEE: Failed to sign message using EOA";throw isAxiosError(d)?d.response?I+=` with status ${d.response.status}: ${JSON.stringify(d.response.data)}`:I+=`: ${d.message}`:I+=`: ${d.message}`,new Error(I)}},"magicSignMessage")}connect(){throw new Error("Method not implemented.")}signTransaction(){throw new Error("Method not implemented.")}signTypedData(){throw new Error("Method not implemented.")}};C();x();var is={icon:'data:image/svg+xml,<svg viewBox="0 0 48 48" class="SvgIcon undefined Logo Logo--PassportSymbolOutlined css-1dn9atd" xmlns="http://www.w3.org/2000/svg"><g data-testid="undefined__g"><circle cx="24" cy="24" r="22.5" fill="url(%23paint0_radial_6324_83922)"></circle><circle cx="24" cy="24" r="22.5" fill="url(%23paint1_radial_6324_83922)"></circle><path d="M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24C48 10.7452 37.2548 0 24 0ZM23.0718 9.16608C23.7383 8.83951 24.4406 8.86188 25.087 9.2287C27.3282 10.5059 29.5627 11.7942 31.786 13.096C32.5018 13.5165 32.8686 14.1897 32.8708 15.0173C32.8843 17.9184 32.8798 20.8171 32.8708 23.7182C32.8708 23.8255 32.8015 23.9821 32.7143 24.0335C31.8531 24.548 30.9808 25.0423 30.0347 25.5881V25.1318C30.0347 22.148 30.0257 19.1664 30.0414 16.1827C30.0436 15.6101 29.8468 15.241 29.339 14.9525C26.7377 13.474 24.1499 11.9687 21.5575 10.4723C21.4457 10.4075 21.3361 10.3381 21.1661 10.2352C21.8326 9.85722 22.4321 9.47698 23.0673 9.16608H23.0718ZM22.5953 38.8451C22.45 38.7713 22.3426 38.7198 22.2375 38.6595C18.8041 36.68 15.3752 34.687 11.9307 32.7232C10.9644 32.173 10.5238 31.3879 10.5349 30.2852C10.5551 27.9411 10.5484 25.597 10.5372 23.2507C10.5327 22.1927 10.9622 21.4255 11.8926 20.8977C14.3105 19.5221 16.715 18.1264 19.1195 16.7284C19.3275 16.6076 19.4796 16.5875 19.6965 16.7172C20.5264 17.216 21.3719 17.6924 22.2554 18.2024C22.0876 18.3031 21.9601 18.3791 21.8304 18.4552C19.2268 19.9582 16.6278 21.4658 14.0175 22.9599C13.5903 23.2037 13.3912 23.5213 13.3957 24.0179C13.4091 25.8654 13.4114 27.713 13.3957 29.5605C13.3912 30.0705 13.5948 30.3948 14.0332 30.6453C16.7866 32.2199 19.5288 33.8125 22.28 35.3916C22.5126 35.5258 22.611 35.6645 22.6065 35.9418C22.5864 36.888 22.5998 37.8363 22.5998 38.8473L22.5953 38.8451ZM22.5953 33.553C22.356 33.4166 22.1838 33.3204 22.0116 33.2198C19.8285 31.9605 17.6477 30.6967 15.4602 29.4464C15.2231 29.3122 15.1359 29.1668 15.1381 28.8917C15.1538 27.4714 15.1471 26.0511 15.1426 24.6308C15.1426 24.4384 15.1717 24.3064 15.3618 24.1991C16.167 23.7495 16.9633 23.2798 17.7618 22.8212C17.8199 22.7877 17.8826 22.7631 17.9877 22.7116V24.3064C17.9877 25.1698 18.0011 26.0354 17.9832 26.8988C17.972 27.3909 18.1622 27.7241 18.5916 27.9657C19.8285 28.6636 21.0498 29.3883 22.2867 30.0839C22.5305 30.2203 22.6043 30.3724 22.5998 30.6408C22.5842 31.5847 22.5931 32.5308 22.5931 33.5508L22.5953 33.553ZM20.0746 14.91C19.6116 14.6371 19.2157 14.6393 18.7527 14.91C16.1581 16.4265 13.5523 17.9228 10.9487 19.4259C10.8391 19.4908 10.7251 19.5489 10.5305 19.6541C10.5998 18.6654 10.3873 17.7327 10.7251 16.8291C10.9085 16.3348 11.2529 15.9635 11.7092 15.6995C13.8811 14.4447 16.0507 13.1877 18.227 11.9396C19.0211 11.4833 19.8308 11.4945 20.6248 11.953C23.0964 13.3756 25.5657 14.8026 28.0306 16.2341C28.1357 16.2945 28.2677 16.4309 28.2677 16.5338C28.2856 17.5493 28.2788 18.567 28.2788 19.6563C27.3819 19.1396 26.5543 18.6609 25.7267 18.1823C23.8412 17.093 21.9512 16.0149 20.0746 14.91ZM37.4427 30.8779C37.3778 31.6764 36.9103 32.2423 36.2192 32.6404C33.5732 34.1614 30.9294 35.6913 28.2856 37.2168C27.4557 37.6954 26.6259 38.1741 25.7938 38.6527C25.6932 38.7109 25.5903 38.7601 25.4539 38.8317C25.4449 38.693 25.4337 38.5924 25.4337 38.4917C25.4337 37.6149 25.4382 36.7404 25.4293 35.8636C25.4293 35.6645 25.4762 35.5437 25.6596 35.4386C29.5157 33.2198 33.3696 30.9942 37.2212 28.7709C37.2794 28.7374 37.3443 28.7105 37.4539 28.6591C37.4539 29.4375 37.4986 30.1622 37.4427 30.8779ZM37.4628 25.3577C37.4561 26.2658 36.9663 26.9033 36.1901 27.3506C33.175 29.0841 30.1622 30.8265 27.1493 32.5666C26.5991 32.8842 26.0466 33.1996 25.4561 33.5396C25.4472 33.3897 25.436 33.2913 25.436 33.1907C25.436 32.3273 25.4449 31.4617 25.4293 30.5983C25.4248 30.3523 25.5075 30.2226 25.72 30.0995C28.46 28.5271 31.1911 26.9368 33.9355 25.3733C34.4231 25.096 34.6378 24.7538 34.6334 24.1812C34.6132 21.1974 34.6244 18.2136 34.6244 15.2298V14.7087C35.3402 15.1404 36.0112 15.496 36.624 15.9299C37.1832 16.3258 37.465 16.9253 37.4673 17.6164C37.4762 20.1976 37.4829 22.7788 37.465 25.3599L37.4628 25.3577Z" fill="%230D0D0D"></path><path fill-rule="evenodd" d="M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24C48 10.7452 37.2548 0 24 0ZM24 2C11.8497 2 2 11.8497 2 24C2 36.1503 11.8497 46 24 46C36.1503 46 46 36.1503 46 24C46 11.8497 36.1503 2 24 2Z" fill="url(%23paint2_radial_6324_83922)"></path><path fill-rule="evenodd" d="M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24C48 10.7452 37.2548 0 24 0ZM24 2C11.8497 2 2 11.8497 2 24C2 36.1503 11.8497 46 24 46C36.1503 46 46 36.1503 46 24C46 11.8497 36.1503 2 24 2Z" fill="url(%23paint3_radial_6324_83922)"></path><defs><radialGradient id="paint0_radial_6324_83922" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(13.4442 13.3899) rotate(44.9817) scale(46.7487 99.1435)"><stop stop-color="%23A3EEF8"></stop><stop offset="0.177083" stop-color="%23A4DCF5"></stop><stop offset="0.380208" stop-color="%23A6AEEC"></stop><stop offset="1" stop-color="%23ECBEE1"></stop></radialGradient><radialGradient id="paint1_radial_6324_83922" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(25.9515 43.7068) rotate(84.265) scale(24.2138 46.3215)"><stop stop-color="%23FCF5EE"></stop><stop offset="0.715135" stop-color="%23ECBEE1" stop-opacity="0"></stop></radialGradient><radialGradient id="paint2_radial_6324_83922" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(12.7405 12.6825) rotate(44.9817) scale(49.8653 105.753)"><stop stop-color="%23A3EEF8"></stop><stop offset="0.177083" stop-color="%23A4DCF5"></stop><stop offset="0.380208" stop-color="%23A6AEEC"></stop><stop offset="1" stop-color="%23ECBEE1"></stop></radialGradient><radialGradient id="paint3_radial_6324_83922" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(26.0816 45.0206) rotate(84.265) scale(25.828 49.4096)"><stop stop-color="%23FCF5EE"></stop><stop offset="0.715135" stop-color="%23ECBEE1" stop-opacity="0"></stop></radialGradient></defs></g></svg>',name:"Immutable Passport",rdns:"com.immutable.passport",uuid:v4()};function os(s){if(typeof window>"u")return;let i=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(s)});window.dispatchEvent(i);let u=()=>window.dispatchEvent(i);window.addEventListener("eip6963:requestProvider",u);}/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
20
|
+
|
|
21
|
+
export { Se as GuardianClient, O as JsonRpcError, De as MagicTEESigner, on as PassportEvents, Ee as ProviderErrorCode, xi as ProviderEvent, ne as RelayerClient, Ci as RelayerTransactionStatus, Ot as RpcErrorCode, Yt as TypedEventEmitter, Pr as WalletConfiguration, Lt as WalletError, Ce as WalletErrorType, Br as ZkEvmProvider, os as announceProvider, is as passportProviderInfo, Kt as retryWithDelay, gn as walletHelpers };
|