@aibtc/mcp-server 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -171,6 +171,20 @@ export declare class MempoolApi {
171
171
  * ```
172
172
  */
173
173
  broadcastTransaction(txHex: string): Promise<string>;
174
+ /**
175
+ * Get raw transaction hex by txid
176
+ *
177
+ * @param txid - Transaction ID
178
+ * @returns Transaction as hex string
179
+ * @throws Error if API request fails
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const api = new MempoolApi('mainnet');
184
+ * const txHex = await api.getTxHex('abc123...');
185
+ * ```
186
+ */
187
+ getTxHex(txid: string): Promise<string>;
174
188
  /**
175
189
  * Get the network this client is configured for
176
190
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mempool-api.d.ts","sourceRoot":"","sources":["../../src/services/mempool-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;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AAgB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAE7D"}
1
+ {"version":3,"file":"mempool-api.d.ts","sourceRoot":"","sources":["../../src/services/mempool-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAIzD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAI9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAEtE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAE9E;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEtB,OAAO,EAAE,OAAO;IAK5B;;;;;;;;;;;;;OAaG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAchD;;;;;;;;;;;;OAYG;IACG,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAc9C;;;;;;;;;;OAUG;IACG,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAStC;;;;;;OAMG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKlD;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3D;;;;;;;;;;;;;OAaG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB1D;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc7C;;OAEG;IACH,UAAU,IAAI,OAAO;CAGtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAE7D"}
@@ -163,6 +163,28 @@ export class MempoolApi {
163
163
  const txid = await response.text();
164
164
  return txid.trim();
165
165
  }
166
+ /**
167
+ * Get raw transaction hex by txid
168
+ *
169
+ * @param txid - Transaction ID
170
+ * @returns Transaction as hex string
171
+ * @throws Error if API request fails
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const api = new MempoolApi('mainnet');
176
+ * const txHex = await api.getTxHex('abc123...');
177
+ * ```
178
+ */
179
+ async getTxHex(txid) {
180
+ const response = await fetch(`${this.baseUrl}/tx/${txid}/hex`);
181
+ if (!response.ok) {
182
+ const errorText = await response.text().catch(() => "Unknown error");
183
+ throw new Error(`Failed to fetch transaction hex for ${txid}: ${response.status} ${response.statusText} - ${errorText}`);
184
+ }
185
+ const txHex = await response.text();
186
+ return txHex.trim();
187
+ }
166
188
  /**
167
189
  * Get the network this client is configured for
168
190
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mempool-api.js","sourceRoot":"","sources":["../../src/services/mempool-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2EH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,2BAA2B;QAC7B,CAAC,CAAC,mCAAmC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,+BAA+B,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,OAAgB;IAC5D,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,OAAgB;IACpE,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,YAAY,OAAO,EAAE,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,UAAU;IACJ,OAAO,CAAS;IAChB,OAAO,CAAU;IAElC,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC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,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,OAAO,IAAI,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;YACrE,MAAM,IAAI,KAAK,CACb,uCAAuC,IAAI,KAAK,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACxG,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,246 @@
1
+ /**
2
+ * sBTC Deposit Service
3
+ *
4
+ * Handles Bitcoin → sBTC deposits using the sbtc library
5
+ *
6
+ * Flow:
7
+ * 1. Generate a deposit address (with reclaim script for recovery)
8
+ * 2. Build and sign a Bitcoin transaction to deposit BTC
9
+ * 3. Broadcast the transaction and notify the sBTC system
10
+ * 4. sBTC tokens are minted on Stacks L2 after confirmation
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const service = getSbtcDepositService('mainnet');
15
+ *
16
+ * // Step 1: Get signers public key and build deposit address
17
+ * const signersPublicKey = await service.getSignersPublicKey();
18
+ * const depositAddressInfo = await service.buildDepositAddress(
19
+ * 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK', // Stacks address
20
+ * 'abc123...', // Reclaim public key (32-byte x-only)
21
+ * 80000, // Max signer fee
22
+ * 950 // Reclaim lock time (blocks)
23
+ * );
24
+ *
25
+ * // Step 2: Build deposit transaction
26
+ * const depositResult = await service.buildDepositTransaction(
27
+ * 100000, // Amount in sats
28
+ * 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK',
29
+ * 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
30
+ * 'abc123...', // Reclaim public key (32-byte x-only)
31
+ * 10 // Fee rate sat/vB
32
+ * );
33
+ *
34
+ * // Step 3: Sign the transaction with user's private key
35
+ * // (signing logic handled by caller)
36
+ *
37
+ * // Step 4: Broadcast and notify
38
+ * const { txid, notification } = await service.broadcastAndNotify(
39
+ * signedTxHex,
40
+ * depositResult.depositScript,
41
+ * depositResult.reclaimScript,
42
+ * 0 // vout
43
+ * );
44
+ *
45
+ * // Step 5: Poll for completion
46
+ * const finalStatus = await service.pollDepositStatus(txid, 0);
47
+ *
48
+ * // OR use the high-level helper that chains all steps:
49
+ * const result = await service.deposit(
50
+ * 100000,
51
+ * 'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK',
52
+ * 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
53
+ * '03abc123...',
54
+ * 10,
55
+ * async (txHex) => {
56
+ * // Sign transaction and return signed hex
57
+ * return signedTxHex;
58
+ * }
59
+ * );
60
+ * ```
61
+ */
62
+ import type { Network } from "../config/networks.js";
63
+ /**
64
+ * Result from generating a deposit address
65
+ */
66
+ export interface DepositAddressResult {
67
+ /**
68
+ * Bitcoin Taproot address to send BTC to
69
+ */
70
+ depositAddress: string;
71
+ /**
72
+ * Deposit script (hex) - proves deposit to sBTC system
73
+ */
74
+ depositScript: string;
75
+ /**
76
+ * Reclaim script (hex) - allows recovery if deposit fails
77
+ */
78
+ reclaimScript: string;
79
+ /**
80
+ * Max fee the sBTC system will charge (satoshis)
81
+ */
82
+ maxFee: number;
83
+ /**
84
+ * Lock time for the deposit (blocks)
85
+ */
86
+ lockTime: number;
87
+ }
88
+ /**
89
+ * Result from building a deposit transaction
90
+ */
91
+ export interface DepositTransactionResult {
92
+ /**
93
+ * Signed transaction hex
94
+ */
95
+ txHex: string;
96
+ /**
97
+ * Transaction ID
98
+ */
99
+ txid: string;
100
+ /**
101
+ * Deposit amount in satoshis
102
+ */
103
+ amount: number;
104
+ /**
105
+ * Output index containing the deposit
106
+ */
107
+ vout: number;
108
+ }
109
+ /**
110
+ * Complete deposit result (transaction + scripts)
111
+ */
112
+ export interface DepositResult extends DepositTransactionResult {
113
+ depositScript: string;
114
+ reclaimScript: string;
115
+ }
116
+ /**
117
+ * sBTC Deposit Service
118
+ */
119
+ export declare class SbtcDepositService {
120
+ private readonly apiClient;
121
+ private readonly mempoolApi;
122
+ private readonly network;
123
+ constructor(network: Network);
124
+ /**
125
+ * Get Bitcoin network constants for the configured network
126
+ */
127
+ private getBitcoinNetwork;
128
+ /**
129
+ * Convert MempoolApi UTXOs to sbtc's UtxoWithTx format
130
+ *
131
+ * The sbtc package requires UTXOs with raw transaction hex attached.
132
+ * This method fetches the tx hex for each UTXO via mempool.space API.
133
+ */
134
+ private convertUtxos;
135
+ /**
136
+ * Get the signers aggregate public key from the sBTC registry contract
137
+ *
138
+ * The signers public key is used to build the deposit address script.
139
+ * This is fetched from the sbtc-registry contract on Stacks L2.
140
+ */
141
+ getSignersPublicKey(): Promise<string>;
142
+ /**
143
+ * Build a Taproot deposit address for sBTC deposits
144
+ *
145
+ * The deposit address contains two spending paths:
146
+ * 1. Deposit script - sBTC signers can spend to mint sBTC on Stacks
147
+ * 2. Reclaim script - User can reclaim BTC after lockTime if deposit fails
148
+ *
149
+ * @param stacksAddress - Stacks L2 address to receive sBTC (SP... or ST...)
150
+ * @param reclaimPublicKey - Public key for reclaim path (hex, 32-byte x-only Taproot internal public key)
151
+ * @param maxSignerFee - Max fee sBTC system can charge in satoshis (default: 80000)
152
+ * @param reclaimLockTime - Block height when reclaim becomes available (default: 950 blocks)
153
+ * @returns Deposit address and scripts
154
+ */
155
+ buildDepositAddress(stacksAddress: string, reclaimPublicKey: string, maxSignerFee?: number, reclaimLockTime?: number): Promise<DepositAddressResult>;
156
+ /**
157
+ * Build an sBTC deposit transaction, optionally signed
158
+ *
159
+ * This method:
160
+ * 1. Fetches UTXOs for the Bitcoin address
161
+ * 2. Builds a deposit address with deposit/reclaim scripts
162
+ * 3. Constructs a transaction that sends BTC to the deposit address
163
+ * 4. If `privateKey` is provided, signs and finalizes the transaction
164
+ * 5. Returns the transaction hex (signed or unsigned), txid, and deposit details
165
+ *
166
+ * @param amountSats - Amount to deposit in satoshis
167
+ * @param stacksAddress - Stacks L2 address to receive sBTC
168
+ * @param bitcoinAddress - Bitcoin L1 address to send from (for UTXOs and change)
169
+ * @param reclaimPublicKey - Public key for reclaim path (hex, 32-byte x-only Taproot internal public key)
170
+ * @param feeRate - Fee rate in sat/vB
171
+ * @param maxSignerFee - Max fee sBTC system can charge (default: 80000 sats)
172
+ * @param reclaimLockTime - Block height when reclaim becomes available (default: 950)
173
+ * @param privateKey - Optional BTC private key (Uint8Array) to sign the transaction.
174
+ * When provided, signs using the sbtc package's internal @scure/btc-signer
175
+ * to avoid version mismatch issues. The inputs are P2WPKH from the user's address.
176
+ * @param includeOrdinals - Include UTXOs with inscriptions (default: false for safety).
177
+ * WARNING: Setting this to true may destroy valuable inscriptions!
178
+ * @returns Transaction hex (signed if privateKey provided), txid, and deposit details
179
+ */
180
+ buildDepositTransaction(amountSats: number, stacksAddress: string, bitcoinAddress: string, reclaimPublicKey: string, feeRate: number, maxSignerFee?: number, reclaimLockTime?: number, privateKey?: Uint8Array, includeOrdinals?: boolean): Promise<DepositResult>;
181
+ /**
182
+ * Get deposit status from Emily API
183
+ *
184
+ * @param txid - Bitcoin transaction ID
185
+ * @param vout - Output index (optional, defaults to 0)
186
+ * @returns Deposit status and details
187
+ */
188
+ getDepositStatus(txid: string, vout?: number): Promise<unknown>;
189
+ /**
190
+ * Broadcast signed transaction and notify Emily API
191
+ *
192
+ * This method:
193
+ * 1. Broadcasts the signed Bitcoin transaction to the mempool
194
+ * 2. Notifies the Emily API about the deposit (required for sBTC minting)
195
+ *
196
+ * @param signedTxHex - Signed transaction hex string
197
+ * @param depositScript - Deposit script hex (from buildDepositTransaction)
198
+ * @param reclaimScript - Reclaim script hex (from buildDepositTransaction)
199
+ * @param vout - Output index containing the deposit (default: 0)
200
+ * @returns Transaction ID and notification response
201
+ */
202
+ broadcastAndNotify(signedTxHex: string, depositScript: string, reclaimScript: string, vout?: number): Promise<{
203
+ txid: string;
204
+ notification: unknown;
205
+ }>;
206
+ /**
207
+ * Poll Emily API for deposit status until completed or timeout
208
+ *
209
+ * Terminal states:
210
+ * - "completed" - Deposit successful, sBTC minted
211
+ * - "failed" - Deposit failed
212
+ *
213
+ * @param txid - Bitcoin transaction ID
214
+ * @param vout - Output index (default: 0)
215
+ * @param pollIntervalMs - Polling interval in milliseconds (default: 30000 / 30 seconds)
216
+ * @param timeoutMs - Max wait time in milliseconds (default: 7200000 / 2 hours)
217
+ * @returns Final deposit status
218
+ * @throws Error if deposit fails or polling times out
219
+ */
220
+ pollDepositStatus(txid: string, vout?: number, pollIntervalMs?: number, timeoutMs?: number): Promise<unknown>;
221
+ /**
222
+ * High-level deposit helper that chains all steps
223
+ *
224
+ * This method:
225
+ * 1. Builds the deposit transaction
226
+ * 2. Calls the provided signTransaction callback to sign it
227
+ * 3. Broadcasts the signed transaction and notifies Emily API
228
+ *
229
+ * @param amountSats - Amount to deposit in satoshis
230
+ * @param stacksAddress - Stacks L2 address to receive sBTC
231
+ * @param bitcoinAddress - Bitcoin L1 address to send from
232
+ * @param reclaimPublicKey - Public key for reclaim path (hex, 32-byte x-only Taproot internal public key)
233
+ * @param feeRate - Fee rate in sat/vB
234
+ * @param signTransaction - Callback function to sign the transaction hex
235
+ * @param maxSignerFee - Max fee sBTC system can charge (default: 80000 sats)
236
+ * @param reclaimLockTime - Block height when reclaim becomes available (default: 950)
237
+ * @param includeOrdinals - Include UTXOs with inscriptions (default: false for safety)
238
+ * @returns Broadcast result with txid and notification
239
+ */
240
+ deposit(amountSats: number, stacksAddress: string, bitcoinAddress: string, reclaimPublicKey: string, feeRate: number, signTransaction: (txHex: string) => Promise<string>, maxSignerFee?: number, reclaimLockTime?: number, includeOrdinals?: boolean): Promise<{
241
+ txid: string;
242
+ notification: unknown;
243
+ }>;
244
+ }
245
+ export declare function getSbtcDepositService(network: Network): SbtcDepositService;
246
+ //# sourceMappingURL=sbtc-deposit.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sbtc-deposit.service.d.ts","sourceRoot":"","sources":["../../src/services/sbtc-deposit.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAYH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMrD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,w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