@dynamic-labs-wallet/node-midnight 0.0.0 → 1.0.115

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/package.json CHANGED
@@ -1 +1,38 @@
1
- { "name": "@dynamic-labs-wallet/node-midnight ", "version": "0.0.0" }
1
+ {
2
+ "name": "@dynamic-labs-wallet/node-midnight",
3
+ "version": "1.0.115",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "@dynamic-labs-wallet/node": "1.0.115",
8
+ "@midnight-ntwrk/ledger-v8": "^8.1.0",
9
+ "@midnight-ntwrk/wallet-sdk-address-format": "3.1.2",
10
+ "@scure/bip32": "^2.0.1",
11
+ "bech32": "^2.0.0"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "nx": {
17
+ "sourceRoot": "packages/node-midnight/src",
18
+ "projectType": "library",
19
+ "name": "node-midnight",
20
+ "targets": {
21
+ "build": {}
22
+ }
23
+ },
24
+ "main": "./index.cjs",
25
+ "module": "./index.esm.js",
26
+ "types": "./index.esm.d.ts",
27
+ "exports": {
28
+ "./package.json": "./package.json",
29
+ ".": {
30
+ "types": "./index.esm.d.ts",
31
+ "import": "./index.esm.js",
32
+ "require": "./index.cjs"
33
+ }
34
+ },
35
+ "devDependencies": {
36
+ "@types/http-errors": "^2.0.0"
37
+ }
38
+ }
@@ -0,0 +1,193 @@
1
+ import { DynamicWalletClient, type DynamicWalletClientProps, type BIP340KeygenResult, type ServerKeyShare, type ThresholdSignatureScheme, type WalletMetadata } from '@dynamic-labs-wallet/node';
2
+ import { type MidnightNetwork } from '../utils/address/index.js';
3
+ export type DynamicMidnightWalletClientProps = DynamicWalletClientProps & {
4
+ /** Network whose bech32m HRP addresses are encoded with. Defaults to 'preview'. */
5
+ network?: MidnightNetwork;
6
+ };
7
+ /** Credentials every key-material operation needs. */
8
+ export type MidnightWalletAccess = {
9
+ walletMetadata: WalletMetadata;
10
+ password?: string;
11
+ externalServerKeyShares?: ServerKeyShare[];
12
+ elevatedAccessToken?: string;
13
+ /** 0/'preview' (default) or 1/'mainnet'. */
14
+ networkId?: number | string;
15
+ };
16
+ /**
17
+ * Midnight's three key roles, each derived from the same MPC master xprv.
18
+ * Secret material — hold in memory only, never log or persist.
19
+ */
20
+ export type MidnightRoleKeys = {
21
+ /** Role 0 (NightExternal) — public transfers, MPC-signed. */
22
+ unshielded: string;
23
+ /** Role 3 (Zswap) — private transfers, signed client-side. */
24
+ shielded: string;
25
+ /** Role 2 (Dust) — gas/fee management, signed client-side. */
26
+ dust: string;
27
+ };
28
+ export declare class DynamicMidnightWalletClient extends DynamicWalletClient {
29
+ readonly chainName = "MIDNIGHT";
30
+ private readonly network;
31
+ constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, enableMPCAccelerator, logger, network, }: DynamicMidnightWalletClientProps);
32
+ /**
33
+ * Creates a new wallet account.
34
+ * @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
35
+ * @param password - The password to use for the wallet.
36
+ * @param onError - The function to call if an error occurs.
37
+ * @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
38
+ * @returns The walletMetadata, public key hex, raw public key, and external server key shares.
39
+ */
40
+ createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic, }: {
41
+ thresholdSignatureScheme: ThresholdSignatureScheme;
42
+ password?: string;
43
+ onError?: (error: Error) => void;
44
+ backUpToDynamic?: boolean;
45
+ }): Promise<{
46
+ walletMetadata: WalletMetadata;
47
+ publicKeyHex: string;
48
+ rawPublicKey: Uint8Array | string;
49
+ externalServerKeyShares: ServerKeyShare[];
50
+ externalKeySharesWithBackupStatus: Array<{
51
+ share: ServerKeyShare;
52
+ backedUpToClientKeyShareService: boolean;
53
+ }>;
54
+ }>;
55
+ /**
56
+ * Signs a message using MPC
57
+ * @param message - The message to sign
58
+ * @param walletMetadata - Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
59
+ * @param password - The password for encrypted backup shares
60
+ * @param externalServerKeyShares - The external server key shares
61
+ * @param onError - The function to call if an error occurs
62
+ * @returns The signature as a base64 string
63
+ */
64
+ signMessage({ message, walletMetadata, password, externalServerKeyShares, onError, }: {
65
+ message: string;
66
+ walletMetadata: WalletMetadata;
67
+ password?: string;
68
+ externalServerKeyShares?: ServerKeyShare[];
69
+ onError?: (error: Error) => void;
70
+ }): Promise<string>;
71
+ /**
72
+ * Exports the private key for a given wallet.
73
+ *
74
+ * Returns the unshielded (role 0) key at the wallet's derivation path. The
75
+ * shielded and dust role keys need the master xprv, which `exportKey` does
76
+ * not surface — see the package README.
77
+ *
78
+ * @param walletMetadata - Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
79
+ * @param password - The password for encrypted backup shares
80
+ * @param externalServerKeyShares - The external server key shares
81
+ * @returns The private key as a hex string
82
+ */
83
+ exportPrivateKey({ walletMetadata, password, externalServerKeyShares, }: {
84
+ walletMetadata: WalletMetadata;
85
+ password?: string;
86
+ externalServerKeyShares?: ServerKeyShare[];
87
+ }): Promise<string>;
88
+ /**
89
+ * Exports the private key offline using key shares
90
+ * @param keyShares - The key shares to export the private key for
91
+ * @param derivationPath - The derivation path
92
+ * @returns The derived private key
93
+ *
94
+ * `derivationPath` is the JSON-serialized index map that
95
+ * `walletMetadata.derivationPath` carries (e.g. `'{"0":44,"1":2400,"2":0,"3":0,"4":0}'`
96
+ * or `'[44,2400,0,0,0]'`). BIP-32 strings such as `"m/44'/2400'/0'/0/0"` are rejected.
97
+ * Omit it to export without path derivation.
98
+ */
99
+ offlineExportPrivateKey({ keyShares, derivationPath, }: {
100
+ keyShares: BIP340KeygenResult[];
101
+ derivationPath?: string;
102
+ }): Promise<{
103
+ derivedPrivateKey: string | undefined;
104
+ }>;
105
+ /**
106
+ * Imports a private key.
107
+ * @param privateKey - The private key to import.
108
+ * @param chainName - The chain name to use for the wallet.
109
+ * @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
110
+ * @param password - The password to use for the wallet.
111
+ * @param onError - The function to call if an error occurs.
112
+ * @param backUpToDynamic - Whether to back up the external server key shares to the client share service.
113
+ * @param publicAddressCheck - Optional public address to verify against the derived address.
114
+ * @returns The walletMetadata, public key hex, raw public key, and external server key shares.
115
+ */
116
+ importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, backUpToDynamic, publicAddressCheck, }: {
117
+ privateKey: string;
118
+ chainName: string;
119
+ thresholdSignatureScheme: ThresholdSignatureScheme;
120
+ password?: string;
121
+ onError?: (error: Error) => void;
122
+ backUpToDynamic?: boolean;
123
+ publicAddressCheck?: string;
124
+ }): Promise<{
125
+ walletMetadata: WalletMetadata;
126
+ publicKeyHex: string;
127
+ rawPublicKey: Uint8Array | string | undefined;
128
+ externalServerKeyShares: ServerKeyShare[];
129
+ externalKeySharesWithBackupStatus: Array<{
130
+ share: ServerKeyShare;
131
+ backedUpToClientKeyShareService: boolean;
132
+ }>;
133
+ }>;
134
+ /**
135
+ * Derives the BIP340 verifying key from a private key
136
+ * @param privateKeyHex - The private key as a hex string
137
+ * @returns The verifying key as a hex string
138
+ */
139
+ getPublicKeyFromPrivateKey(privateKeyHex: string): string;
140
+ /**
141
+ * Derives the bech32m unshielded account address from a BIP340 public key.
142
+ * The address is the Poseidon hash of the verifying key, not the key itself.
143
+ */
144
+ deriveAccountAddress: ({ publicKeyHex, network }: {
145
+ publicKeyHex: string;
146
+ network?: MidnightNetwork;
147
+ }) => string;
148
+ /**
149
+ * Derives the unshielded, shielded, and dust role keys from the wallet's MPC
150
+ * master xprv.
151
+ *
152
+ * Deliberately not persisted: these are plaintext secrets, and writing them
153
+ * to disk or a cache would trade a per-session MPC export for a durable
154
+ * exfiltration target. Callers should hold the result only as long as the
155
+ * operation needs it.
156
+ *
157
+ * @returns The three role private keys as hex strings
158
+ */
159
+ protected getRoleKeys({ walletMetadata, password, externalServerKeyShares, elevatedAccessToken, }: {
160
+ walletMetadata: WalletMetadata;
161
+ password?: string;
162
+ externalServerKeyShares?: ServerKeyShare[];
163
+ elevatedAccessToken?: string;
164
+ }): Promise<MidnightRoleKeys>;
165
+ /**
166
+ * Derives the wallet's three receiving addresses.
167
+ *
168
+ * Only the unshielded address comes from the MPC keygen (secp256k1/BIP340);
169
+ * shielded uses JubJub and dust BLS12-381, so both are derived client-side
170
+ * from the role keys. Requires an MPC export, but no facade or sync.
171
+ *
172
+ * @returns bech32m addresses for the requested network
173
+ */
174
+ getAddresses(access: MidnightWalletAccess): Promise<{
175
+ unshielded: string;
176
+ shielded: string;
177
+ dust?: string;
178
+ }>;
179
+ /**
180
+ * Gets all Midnight wallets
181
+ * @returns Array of Midnight wallets
182
+ */
183
+ getMidnightWallets(): Promise<{
184
+ walletId: string;
185
+ chainName: string;
186
+ accountAddress: string;
187
+ externalServerKeySharesBackupInfo: import("@dynamic-labs-wallet/core").KeyShareBackupInfo;
188
+ externalServerKeyShares: never[];
189
+ derivationPath: string | undefined;
190
+ thresholdSignatureScheme: ThresholdSignatureScheme;
191
+ }[]>;
192
+ }
193
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AAqBnC,OAAO,EAAyB,KAAK,eAAe,EAAuB,MAAM,2BAA2B,CAAC;AAI7G,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG;IACxE,mFAAmF;IACnF,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,QA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AC;QAC9C,uBAAuB,EAAE,cAAc,EAAE,CAAC;QAC1C,iCAAiC,EAAE,KAAK,CAAC;YACvC,KAAK,EAAE,cAAc,CAAC;YACtB,+BAA+B,EAAE,OAAO,CAAC;SAC1C,CAAC,CAAC;KACJ,CAAC;IAqGF;;;;OAIG;IACH,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAkBzD;;;OAGG;IACH,oBAAoB,8BAA+B;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,eAAe,CAAA;KAAE,KAAG,MAAM,CAG7G;IAEF;;;;;;;;;;OAUG;cACa,WAAW,CAAC,EAC1B,cAAc,EACd,QAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GACpB,EAAE;QACD,cAAc,EAAE,cAAc,CAAC;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3C,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuB7B;;;;;;;;OAQG;IACG,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC;QACxD,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IA6BF;;;OAGG;IACG,kBAAkB;;;;;;;;;CAIzB"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Facade network tag: which Midnight network the wallet runtime (relay, indexer,
3
+ * proof server, sync state) operates against. Distinct from the numeric
4
+ * replay-protection id below.
5
+ */
6
+ export type MidnightNetworkTag = 'preview' | 'mainnet';
7
+ export declare const MIDNIGHT_NETWORK_IDS: {
8
+ readonly mainnet: 1;
9
+ readonly preview: 0;
10
+ readonly preprod: 0;
11
+ readonly undeployed: 0;
12
+ };
13
+ export type MidnightNetworkName = keyof typeof MIDNIGHT_NETWORK_IDS;
14
+ /**
15
+ * Resolves a caller-supplied network identifier (numeric 0/1, network name, or
16
+ * `midnight:<network>` chainId) to the facade network tag. Defaults to 'preview'.
17
+ */
18
+ export declare const resolveMidnightNetworkTag: (networkId?: number | string) => MidnightNetworkTag;
19
+ export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
20
+ export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating midnight wallet account";
21
+ export declare const ERROR_IMPORT_PRIVATE_KEY = "Error importing private key";
22
+ export declare const ERROR_EXPORT_PRIVATE_KEY = "Error exporting private key";
23
+ export declare const ERROR_SIGN_MESSAGE = "Error signing message";
24
+ export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
25
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAC;AAIvD,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,eAAgB,MAAM,GAAG,MAAM,KAAG,kBAKvE,CAAC;AAEF,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,2CAA2C,CAAC;AAEpF,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { DynamicMidnightWalletClient, type DynamicMidnightWalletClientProps, type MidnightRoleKeys, type MidnightWalletAccess, } from './client.js';
2
+ export { ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_EXPORT_PRIVATE_KEY, ERROR_IMPORT_PRIVATE_KEY, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, MIDNIGHT_NETWORK_IDS, resolveMidnightNetworkTag, type MidnightNetworkName, type MidnightNetworkTag, } from './constants.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,KAAK,gCAAgC,EACrC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { DynamicMidnightWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_EXPORT_PRIVATE_KEY, ERROR_IMPORT_PRIVATE_KEY, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, MIDNIGHT_NETWORK_IDS, resolveMidnightNetworkTag, type DynamicMidnightWalletClientProps, type MidnightNetworkName, type MidnightNetworkTag, type MidnightRoleKeys, type MidnightWalletAccess, } from './client/index.js';
2
+ export { decodeMidnightAddress, deriveMidnightAddress, getNetworkFromAddress, isValidMidnightAddress, toXOnlyPublicKeyHex, type MidnightNetwork, } from './utils/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,gCAAgC,EACrC,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** Bech32m HRPs (BIP-0350) for Midnight unshielded addresses, per network. */
2
+ declare const ADDRESS_PREFIXES: {
3
+ readonly mainnet: "mn_addr";
4
+ readonly preview: "mn_addr_preview";
5
+ readonly preprod: "mn_addr_preprod";
6
+ readonly undeployed: "mn_addr_undeployed";
7
+ };
8
+ export type MidnightNetwork = keyof typeof ADDRESS_PREFIXES;
9
+ /**
10
+ * Encodes a 32-byte Midnight address hash as a bech32m address.
11
+ *
12
+ * The input is the *address hash* (`ledger.addressFromKey()` — a Poseidon hash
13
+ * of the verifying key), not the raw public key. Use {@link addressHashFromPublicKey}
14
+ * to produce it.
15
+ */
16
+ export declare const deriveMidnightAddress: ({ addressHashHex, network, }: {
17
+ addressHashHex: string;
18
+ network?: MidnightNetwork;
19
+ }) => string;
20
+ export declare const isValidMidnightAddress: (address: string) => boolean;
21
+ export declare const decodeMidnightAddress: (address: string) => Buffer;
22
+ export declare const getNetworkFromAddress: (address: string) => MidnightNetwork;
23
+ /**
24
+ * Normalizes an MPC-returned BIP340 public key to the 32-byte x-only hex form
25
+ * that `ledger.addressFromKey()` expects, dropping the 02/03 parity byte if the
26
+ * key arrived in 33-byte compressed form.
27
+ */
28
+ export declare const toXOnlyPublicKeyHex: (publicKeyHex: string) => string;
29
+ export {};
30
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/utils/address/address.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,QAAA,MAAM,gBAAgB;;;;;CAKZ,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,iCAG/B;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,KAAG,MAQH,CAAC;AAWF,eAAO,MAAM,sBAAsB,YAAa,MAAM,KAAG,OAUxD,CAAC;AAEF,eAAO,MAAM,qBAAqB,YAAa,MAAM,KAAG,MAMvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,YAAa,MAAM,KAAG,eAOvD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,KAAG,MAU1D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { decodeMidnightAddress, deriveMidnightAddress, getNetworkFromAddress, isValidMidnightAddress, toXOnlyPublicKeyHex, type MidnightNetwork, } from './address.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/address/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { decodeMidnightAddress, deriveMidnightAddress, getNetworkFromAddress, isValidMidnightAddress, toXOnlyPublicKeyHex, type MidnightNetwork, } from './address/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC"}