@maci-protocol/core 0.0.0-ci.f9da2fc → 0.0.0-ci.fc91dc9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/build/ts/MaciState.d.ts +7 -7
- package/build/ts/MaciState.d.ts.map +1 -1
- package/build/ts/MaciState.js +17 -17
- package/build/ts/MaciState.js.map +1 -1
- package/build/ts/Poll.d.ts +27 -28
- package/build/ts/Poll.d.ts.map +1 -1
- package/build/ts/Poll.js +118 -117
- package/build/ts/Poll.js.map +1 -1
- package/build/ts/index.d.ts +2 -2
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +5 -5
- package/build/ts/index.js.map +1 -1
- package/build/ts/utils/constants.d.ts +1 -0
- package/build/ts/utils/constants.d.ts.map +1 -1
- package/build/ts/utils/constants.js +2 -1
- package/build/ts/utils/constants.js.map +1 -1
- package/build/ts/utils/types.d.ts +28 -26
- package/build/ts/utils/types.d.ts.map +1 -1
- package/build/ts/utils/utils.d.ts +16 -16
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +21 -21
- package/build/ts/utils/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
4
|
-
Cory Dickson, Han Jian, Chih-Cheng Liang, and Koh Wei Jie
|
|
3
|
+
Copyright (c) 2025 Ethereum Foundation
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/build/ts/MaciState.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { IncrementalQuinTree } from "@maci-protocol/crypto";
|
|
2
|
-
import {
|
|
3
|
-
import type { IJsonMaciState, IMaciState,
|
|
2
|
+
import { PublicKey, type Keypair } from "@maci-protocol/domainobjs";
|
|
3
|
+
import type { IJsonMaciState, IMaciState, ITreeDepths } from "./utils/types";
|
|
4
4
|
import { Poll } from "./Poll";
|
|
5
5
|
/**
|
|
6
6
|
* A representation of the MACI contract.
|
|
7
7
|
*/
|
|
8
8
|
export declare class MaciState implements IMaciState {
|
|
9
9
|
polls: Map<bigint, Poll>;
|
|
10
|
-
|
|
10
|
+
publicKeys: PublicKey[];
|
|
11
11
|
stateTreeDepth: number;
|
|
12
12
|
stateTree?: IncrementalQuinTree;
|
|
13
|
-
|
|
13
|
+
totalSignups: number;
|
|
14
14
|
pollBeingProcessed?: boolean;
|
|
15
15
|
currentPollBeingProcessed?: bigint;
|
|
16
16
|
/**
|
|
@@ -20,10 +20,10 @@ export declare class MaciState implements IMaciState {
|
|
|
20
20
|
constructor(stateTreeDepth: number);
|
|
21
21
|
/**
|
|
22
22
|
* Sign up a user with the given public key.
|
|
23
|
-
* @param
|
|
23
|
+
* @param publicKey - The public key of the user.
|
|
24
24
|
* @returns The index of the newly signed-up user in the state tree.
|
|
25
25
|
*/
|
|
26
|
-
signUp(
|
|
26
|
+
signUp(publicKey: PublicKey): number;
|
|
27
27
|
/**
|
|
28
28
|
* Deploy a new poll with the given parameters.
|
|
29
29
|
* @param pollEndTimestamp - The Unix timestamp at which the poll ends.
|
|
@@ -33,7 +33,7 @@ export declare class MaciState implements IMaciState {
|
|
|
33
33
|
* @param voteOptions - The number of vote options for this poll.
|
|
34
34
|
* @returns The index of the newly deployed poll.
|
|
35
35
|
*/
|
|
36
|
-
deployPoll(pollEndTimestamp: bigint, treeDepths:
|
|
36
|
+
deployPoll(pollEndTimestamp: bigint, treeDepths: ITreeDepths, messageBatchSize: number, coordinatorKeypair: Keypair, voteOptions: bigint): bigint;
|
|
37
37
|
/**
|
|
38
38
|
* Deploy a null poll.
|
|
39
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaciState.d.ts","sourceRoot":"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;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS;CAgBjD"}
|
package/build/ts/MaciState.js
CHANGED
|
@@ -16,15 +16,15 @@ class MaciState {
|
|
|
16
16
|
// a MaciState can hold multiple polls
|
|
17
17
|
this.polls = new Map();
|
|
18
18
|
// the public keys of the users
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
19
|
+
this.publicKeys = [];
|
|
20
|
+
this.totalSignups = 0;
|
|
21
21
|
/**
|
|
22
22
|
* Create a deep copy of the MaciState object.
|
|
23
23
|
* @returns A new instance of the MaciState object with the same properties.
|
|
24
24
|
*/
|
|
25
25
|
this.copy = () => {
|
|
26
26
|
const copied = new MaciState(this.stateTreeDepth);
|
|
27
|
-
copied.
|
|
27
|
+
copied.publicKeys = this.publicKeys.map((x) => x.copy());
|
|
28
28
|
copied.polls = new Map(Array.from(this.polls, ([key, value]) => [key, value.copy()]));
|
|
29
29
|
return copied;
|
|
30
30
|
};
|
|
@@ -36,7 +36,7 @@ class MaciState {
|
|
|
36
36
|
this.equals = (m) => {
|
|
37
37
|
const result = this.stateTreeDepth === m.stateTreeDepth &&
|
|
38
38
|
this.polls.size === m.polls.size &&
|
|
39
|
-
this.
|
|
39
|
+
this.publicKeys.length === m.publicKeys.length;
|
|
40
40
|
if (!result) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
@@ -45,8 +45,8 @@ class MaciState {
|
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
for (let i = 0; i < this.
|
|
49
|
-
if (!this.
|
|
48
|
+
for (let i = 0; i < this.publicKeys.length; i += 1) {
|
|
49
|
+
if (!this.publicKeys[i].equals(m.publicKeys[i])) {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -54,20 +54,20 @@ class MaciState {
|
|
|
54
54
|
};
|
|
55
55
|
this.stateTreeDepth = stateTreeDepth;
|
|
56
56
|
// we put a blank state leaf to prevent a DoS attack
|
|
57
|
-
this.
|
|
57
|
+
this.publicKeys.push(domainobjs_1.padKey);
|
|
58
58
|
// we need to increase the number of signups by one given
|
|
59
59
|
// that we already added the blank leaf
|
|
60
|
-
this.
|
|
60
|
+
this.totalSignups += 1;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Sign up a user with the given public key.
|
|
64
|
-
* @param
|
|
64
|
+
* @param publicKey - The public key of the user.
|
|
65
65
|
* @returns The index of the newly signed-up user in the state tree.
|
|
66
66
|
*/
|
|
67
|
-
signUp(
|
|
68
|
-
this.
|
|
69
|
-
this.stateTree?.insert(
|
|
70
|
-
return this.
|
|
67
|
+
signUp(publicKey) {
|
|
68
|
+
this.totalSignups += 1;
|
|
69
|
+
this.stateTree?.insert(publicKey.hash());
|
|
70
|
+
return this.publicKeys.push(publicKey.copy()) - 1;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Deploy a new poll with the given parameters.
|
|
@@ -100,10 +100,10 @@ class MaciState {
|
|
|
100
100
|
return {
|
|
101
101
|
stateTreeDepth: this.stateTreeDepth,
|
|
102
102
|
polls: Array.from(this.polls.values()).map((poll) => poll.toJSON()),
|
|
103
|
-
|
|
103
|
+
publicKeys: this.publicKeys.map((publicKey) => publicKey.toJSON()),
|
|
104
104
|
pollBeingProcessed: Boolean(this.pollBeingProcessed),
|
|
105
105
|
currentPollBeingProcessed: this.currentPollBeingProcessed ? this.currentPollBeingProcessed.toString() : "",
|
|
106
|
-
|
|
106
|
+
totalSignups: this.totalSignups,
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
@@ -114,10 +114,10 @@ class MaciState {
|
|
|
114
114
|
static fromJSON(json) {
|
|
115
115
|
const maciState = new MaciState(json.stateTreeDepth);
|
|
116
116
|
// assign the json values to the new instance
|
|
117
|
-
maciState.
|
|
117
|
+
maciState.publicKeys = json.publicKeys.map((publicKey) => domainobjs_1.PublicKey.fromJSON(publicKey));
|
|
118
118
|
maciState.pollBeingProcessed = json.pollBeingProcessed;
|
|
119
119
|
maciState.currentPollBeingProcessed = BigInt(json.currentPollBeingProcessed);
|
|
120
|
-
maciState.
|
|
120
|
+
maciState.totalSignups = json.totalSignups;
|
|
121
121
|
// re-generate the polls and set the maci state reference
|
|
122
122
|
maciState.polls = new Map(json.polls.map((jsonPoll, index) => [BigInt(index), Poll_1.Poll.fromJSON(jsonPoll, maciState)]));
|
|
123
123
|
return maciState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaciState.js","sourceRoot":"","sources":["../../ts/MaciState.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"MaciState.js","sourceRoot":"","sources":["../../ts/MaciState.ts"],"names":[],"mappings":";;;AACA,0DAA4E;AAI5E,iCAA8B;AAC9B,iDAAqD;AAErD;;GAEG;AACH,MAAa,SAAS;IAoBpB;;;OAGG;IACH,YAAY,cAAsB;QAvBlC,sCAAsC;QACtC,UAAK,GAAsB,IAAI,GAAG,EAAgB,CAAC;QAEnD,+BAA+B;QAC/B,eAAU,GAAgB,EAAE,CAAC;QAQ7B,iBAAY,GAAG,CAAC,CAAC;QAwEjB;;;WAGG;QACH,SAAI,GAAG,GAAc,EAAE;YACrB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAElD,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAEpE,MAAM,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAEtF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;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Ballot, PublicKey, Message, StateLeaf } from "@maci-protocol/domainobjs";
|
|
3
3
|
import { LeanIMT } from "@zk-kit/lean-imt";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ITreeDepths, IBatchSizes, IPoll, IJsonPoll, IProcessMessagesOutput, ITallyCircuitInputs, IProcessMessagesCircuitInputs, IPollJoiningCircuitInputs, IJoiningCircuitArgs } from "./index";
|
|
5
5
|
import type { MaciState } from "./MaciState";
|
|
6
6
|
import type { IJoinedCircuitArgs, IPollJoinedCircuitInputs } from "./utils/types";
|
|
7
7
|
/**
|
|
@@ -9,20 +9,19 @@ import type { IJoinedCircuitArgs, IPollJoinedCircuitInputs } from "./utils/types
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class Poll implements IPoll {
|
|
11
11
|
coordinatorKeypair: Keypair;
|
|
12
|
-
treeDepths:
|
|
13
|
-
batchSizes:
|
|
12
|
+
treeDepths: ITreeDepths;
|
|
13
|
+
batchSizes: IBatchSizes;
|
|
14
14
|
voteOptions: bigint;
|
|
15
15
|
maxVoteOptions: number;
|
|
16
|
-
stateTreeDepth: number;
|
|
17
16
|
actualStateTreeDepth: number;
|
|
18
17
|
pollEndTimestamp: bigint;
|
|
19
18
|
ballots: Ballot[];
|
|
20
19
|
ballotTree?: IncrementalQuinTree;
|
|
21
20
|
messages: Message[];
|
|
22
21
|
commands: PCommand[];
|
|
23
|
-
|
|
22
|
+
encryptionPublicKeys: PublicKey[];
|
|
24
23
|
stateCopied: boolean;
|
|
25
|
-
|
|
24
|
+
publicKeys: PublicKey[];
|
|
26
25
|
stateTree?: LeanIMT;
|
|
27
26
|
numBatchesProcessed: number;
|
|
28
27
|
currentMessageBatchIndex: number;
|
|
@@ -33,7 +32,7 @@ export declare class Poll implements IPoll {
|
|
|
33
32
|
preVOSpentVoiceCreditsRootSalts: Record<number | string, bigint>;
|
|
34
33
|
spentVoiceCreditSubtotalSalts: Record<number | string, bigint>;
|
|
35
34
|
tallyResult: bigint[];
|
|
36
|
-
|
|
35
|
+
perVoteOptionSpentVoiceCredits: bigint[];
|
|
37
36
|
numBatchesTallied: number;
|
|
38
37
|
totalSpentVoiceCredits: bigint;
|
|
39
38
|
emptyBallot: Ballot;
|
|
@@ -43,7 +42,7 @@ export declare class Poll implements IPoll {
|
|
|
43
42
|
pollStateLeaves: StateLeaf[];
|
|
44
43
|
pollStateTree?: IncrementalQuinTree;
|
|
45
44
|
pollNullifiers: Map<bigint, boolean>;
|
|
46
|
-
private
|
|
45
|
+
private totalSignups;
|
|
47
46
|
/**
|
|
48
47
|
* Constructs a new Poll object.
|
|
49
48
|
* @param pollEndTimestamp - The Unix timestamp at which the poll ends.
|
|
@@ -53,7 +52,7 @@ export declare class Poll implements IPoll {
|
|
|
53
52
|
* @param maciStateRef - The reference to the MACI state.
|
|
54
53
|
* @param pollId - The poll id
|
|
55
54
|
*/
|
|
56
|
-
constructor(pollEndTimestamp: bigint, coordinatorKeypair: Keypair, treeDepths:
|
|
55
|
+
constructor(pollEndTimestamp: bigint, coordinatorKeypair: Keypair, treeDepths: ITreeDepths, batchSizes: IBatchSizes, maciStateRef: MaciState, voteOptions: bigint);
|
|
57
56
|
/**
|
|
58
57
|
* Check if user has already joined the poll by checking if the nullifier is registered
|
|
59
58
|
*/
|
|
@@ -61,37 +60,37 @@ export declare class Poll implements IPoll {
|
|
|
61
60
|
/**
|
|
62
61
|
* Join the anonymous user to the Poll (to the tree)
|
|
63
62
|
* @param nullifier - Hashed private key used as nullifier
|
|
64
|
-
* @param
|
|
63
|
+
* @param publicKey - The poll public key.
|
|
65
64
|
* @param newVoiceCreditBalance - New voice credit balance of the user.
|
|
66
65
|
* @returns The index of added state leaf
|
|
67
66
|
*/
|
|
68
|
-
joinPoll: (nullifier: bigint,
|
|
67
|
+
joinPoll: (nullifier: bigint, publicKey: PublicKey, newVoiceCreditBalance: bigint) => number;
|
|
69
68
|
/**
|
|
70
69
|
* Update a Poll with data from MaciState.
|
|
71
70
|
* This is the step where we copy the state from the MaciState instance,
|
|
72
71
|
* and set the number of signups we have so far.
|
|
73
|
-
* @note It should be called to generate the state for poll joining with
|
|
74
|
-
* the number of signups in the MaciState. For message processing, you should set
|
|
72
|
+
* @note It should be called to generate the state for poll joining with totalSignups set as
|
|
73
|
+
* the number of signups in the MaciState. For message processing, you should set totalSignups as
|
|
75
74
|
* the number of users who joined the poll.
|
|
76
75
|
*/
|
|
77
|
-
updatePoll: (
|
|
76
|
+
updatePoll: (totalSignups: bigint) => void;
|
|
78
77
|
/**
|
|
79
78
|
* Process one message.
|
|
80
79
|
* @param message - The message to process.
|
|
81
|
-
* @param
|
|
80
|
+
* @param encryptionPublicKey - The public key associated with the encryption private key.
|
|
82
81
|
* @returns A number of variables which will be used in the zk-SNARK circuit.
|
|
83
82
|
*/
|
|
84
|
-
processMessage: (message: Message,
|
|
83
|
+
processMessage: (message: Message, encryptionPublicKey: PublicKey, qv?: boolean) => IProcessMessagesOutput;
|
|
85
84
|
/**
|
|
86
85
|
* Inserts a Message and the corresponding public key used to generate the
|
|
87
86
|
* ECDH shared key which was used to encrypt said message.
|
|
88
87
|
* @param message - The message to insert
|
|
89
|
-
* @param
|
|
88
|
+
* @param encryptionPublicKey - The public key used to encrypt the message
|
|
90
89
|
*/
|
|
91
|
-
publishMessage: (message: Message,
|
|
90
|
+
publishMessage: (message: Message, encryptionPublicKey: PublicKey) => void;
|
|
92
91
|
/**
|
|
93
92
|
* Updates message chain hash
|
|
94
|
-
* @param messageHash hash of message with
|
|
93
|
+
* @param messageHash hash of message with encryptionPublicKey
|
|
95
94
|
*/
|
|
96
95
|
updateChainHash: (messageHash: bigint) => void;
|
|
97
96
|
/**
|
|
@@ -99,13 +98,13 @@ export declare class Poll implements IPoll {
|
|
|
99
98
|
* @param args Poll joining circuit inputs
|
|
100
99
|
* @returns stringified circuit inputs
|
|
101
100
|
*/
|
|
102
|
-
joiningCircuitInputs: ({
|
|
101
|
+
joiningCircuitInputs: ({ maciPrivateKey, stateLeafIndex, pollPublicKey, }: IJoiningCircuitArgs) => IPollJoiningCircuitInputs;
|
|
103
102
|
/**
|
|
104
103
|
* Create circuit input for pollJoined
|
|
105
104
|
* @param args Poll joined circuit inputs
|
|
106
105
|
* @returns stringified circuit inputs
|
|
107
106
|
*/
|
|
108
|
-
joinedCircuitInputs: ({
|
|
107
|
+
joinedCircuitInputs: ({ maciPrivateKey, stateLeafIndex, voiceCreditsBalance, }: IJoinedCircuitArgs) => IPollJoinedCircuitInputs;
|
|
109
108
|
/**
|
|
110
109
|
* Pad last unclosed batch
|
|
111
110
|
*/
|
|
@@ -136,7 +135,7 @@ export declare class Poll implements IPoll {
|
|
|
136
135
|
* @param index - The index of the partial batch.
|
|
137
136
|
* @returns stringified partial circuit inputs
|
|
138
137
|
*/
|
|
139
|
-
private
|
|
138
|
+
private generateProcessMessagesCircuitInputsPartial;
|
|
140
139
|
/**
|
|
141
140
|
* Process all messages. This function does not update the ballots or state
|
|
142
141
|
* leaves; rather, it copies and then updates them. This makes it possible
|
|
@@ -185,10 +184,10 @@ export declare class Poll implements IPoll {
|
|
|
185
184
|
copy: () => Poll;
|
|
186
185
|
/**
|
|
187
186
|
* Check if the Poll object is equal to another Poll object.
|
|
188
|
-
* @param
|
|
187
|
+
* @param poll - The Poll object to compare.
|
|
189
188
|
* @returns True if the two Poll objects are equal, false otherwise.
|
|
190
189
|
*/
|
|
191
|
-
equals: (
|
|
190
|
+
equals: (poll: Poll) => boolean;
|
|
192
191
|
/**
|
|
193
192
|
* Serialize the Poll object to a JSON object
|
|
194
193
|
* @returns a JSON object
|
|
@@ -208,13 +207,13 @@ export declare class Poll implements IPoll {
|
|
|
208
207
|
setCoordinatorKeypair: (serializedPrivateKey: string) => void;
|
|
209
208
|
/**
|
|
210
209
|
* Set the number of signups to match the ones from the contract
|
|
211
|
-
* @param
|
|
210
|
+
* @param totalSignups - the number of signups
|
|
212
211
|
*/
|
|
213
|
-
|
|
212
|
+
settotalSignups: (totalSignups: bigint) => void;
|
|
214
213
|
/**
|
|
215
214
|
* Get the number of signups
|
|
216
215
|
* @returns The number of signups
|
|
217
216
|
*/
|
|
218
|
-
|
|
217
|
+
gettotalSignups: () => bigint;
|
|
219
218
|
}
|
|
220
219
|
//# sourceMappingURL=Poll.d.ts.map
|
package/build/ts/Poll.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Poll.d.ts","sourceRoot":"","sources":["../../ts/Poll.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAYpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"Poll.d.ts","sourceRoot":"","sources":["../../ts/Poll.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAYpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,EAET,OAAO,EACP,SAAS,EAMV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAuB,MAAM,kBAAkB,CAAC;AAIhE,OAAO,KAAK,EAEV,WAAW,EACX,WAAW,EACX,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAMlF;;GAEG;AACH,qBAAa,IAAK,YAAW,KAAK;IAGhC,kBAAkB,EAAE,OAAO,CAAC;IAE5B,UAAU,EAAE,WAAW,CAAC;IAExB,UAAU,EAAE,WAAW,CAAC;IAExB,WAAW,EAAE,MAAM,CAAC;IAEpB,cAAc,EAAE,MAAM,CAAC;IAGvB,oBAAoB,EAAE,MAAM,CAAC;IAE7B,gBAAgB,EAAE,MAAM,CAAC;I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