dfx 0.20.5 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cache/driver.d.ts +16 -16
- package/Cache/driver.js.map +1 -1
- package/Cache/index.d.ts +21 -21
- package/Cache/index.js +12 -13
- package/Cache/index.js.map +1 -1
- package/Cache/memory.d.ts +3 -3
- package/Cache/memory.js +19 -20
- package/Cache/memory.js.map +1 -1
- package/Cache/memoryTTL.d.ts +5 -5
- package/Cache/memoryTTL.js +16 -16
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +41 -41
- package/Cache/prelude.js +39 -41
- package/Cache/prelude.js.map +1 -1
- package/DiscordConfig/index.d.ts +4 -19
- package/DiscordConfig/index.js +5 -12
- package/DiscordConfig/index.js.map +1 -1
- package/DiscordGateway/DiscordWS/index.d.ts +9 -9
- package/DiscordGateway/DiscordWS/index.js +16 -20
- package/DiscordGateway/DiscordWS/index.js.map +1 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +3 -4
- package/DiscordGateway/Shard/heartbeats.js +9 -16
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +4 -4
- package/DiscordGateway/Shard/identify.js +5 -4
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/index.d.ts +8 -7
- package/DiscordGateway/Shard/index.js +17 -20
- package/DiscordGateway/Shard/index.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +2 -3
- package/DiscordGateway/Shard/invalidSession.js +5 -8
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/sendEvents.d.ts +1 -1
- package/DiscordGateway/Shard/sendEvents.js +7 -7
- package/DiscordGateway/Shard/sendEvents.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +3 -4
- package/DiscordGateway/Shard/utils.js +6 -6
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/ShardStore/index.d.ts +6 -6
- package/DiscordGateway/ShardStore/index.js +7 -10
- package/DiscordGateway/ShardStore/index.js.map +1 -1
- package/DiscordGateway/Sharder/index.d.ts +11 -11
- package/DiscordGateway/Sharder/index.js +21 -42
- package/DiscordGateway/Sharder/index.js.map +1 -1
- package/DiscordGateway/WS/index.d.ts +3 -2
- package/DiscordGateway/WS/index.js +30 -40
- package/DiscordGateway/WS/index.js.map +1 -1
- package/DiscordGateway/index.d.ts +8 -9
- package/DiscordGateway/index.js +10 -15
- package/DiscordGateway/index.js.map +1 -1
- package/DiscordREST/index.d.ts +132 -132
- package/DiscordREST/index.js +37 -40
- package/DiscordREST/index.js.map +1 -1
- package/DiscordREST/types.d.ts +6 -6
- package/DiscordREST/utils.d.ts +5 -4
- package/DiscordREST/utils.js +5 -5
- package/DiscordREST/utils.js.map +1 -1
- package/Helpers/intents.js +8 -8
- package/Helpers/intents.js.map +1 -1
- package/Helpers/interactions.d.ts +18 -19
- package/Helpers/interactions.js +22 -23
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/members.d.ts +2 -2
- package/Helpers/members.js.map +1 -1
- package/Helpers/permissions.d.ts +4 -4
- package/Helpers/permissions.js +13 -13
- package/Helpers/permissions.js.map +1 -1
- package/Http/index.d.ts +10 -9
- package/Http/index.js +7 -8
- package/Http/index.js.map +1 -1
- package/Interactions/context.d.ts +22 -23
- package/Interactions/context.js +21 -21
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts +31 -31
- package/Interactions/definitions.js +1 -2
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/gateway.d.ts +4 -3
- package/Interactions/gateway.js +6 -6
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.d.ts +3 -4
- package/Interactions/handlers.js +23 -23
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +11 -11
- package/Interactions/index.js +11 -10
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +7 -8
- package/Interactions/webhook.js +11 -12
- package/Interactions/webhook.js.map +1 -1
- package/Log/index.d.ts +8 -7
- package/Log/index.js +9 -11
- package/Log/index.js.map +1 -1
- package/RateLimit/index.d.ts +13 -12
- package/RateLimit/index.js +11 -12
- package/RateLimit/index.js.map +1 -1
- package/RateLimit/memory.d.ts +1 -1
- package/RateLimit/memory.js +7 -7
- package/RateLimit/memory.js.map +1 -1
- package/RateLimit/utils.d.ts +2 -2
- package/RateLimit/utils.js.map +1 -1
- package/_common.d.ts +19 -0
- package/_common.js +20 -0
- package/_common.js.map +1 -0
- package/gateway.d.ts +11 -10
- package/gateway.js +17 -14
- package/gateway.js.map +1 -1
- package/package.json +5 -15
- package/utils/effect.d.ts +8 -8
- package/utils/effect.js +4 -4
- package/utils/effect.js.map +1 -1
- package/webhooks.d.ts +6 -5
- package/webhooks.js +12 -8
- package/webhooks.js.map +1 -1
- package/global.d.ts +0 -21
- package/global.js +0 -2
- package/global.js.map +0 -1
- package/utils/common.d.ts +0 -18
- package/utils/common.js +0 -3
- package/utils/common.js.map +0 -1
package/DiscordREST/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@fp-ts/data/Option";
|
|
2
|
-
import
|
|
2
|
+
import { Duration, Option } from "dfx/_common";
|
|
3
3
|
const majorResources = ["channels", "guilds", "webhooks"];
|
|
4
4
|
export const routeFromConfig = (path, init) => {
|
|
5
5
|
const method = (init?.method ?? "get").toLowerCase();
|
|
@@ -11,10 +11,10 @@ export const routeFromConfig = (path, init) => {
|
|
|
11
11
|
.replace(/\/reactions\/(.*)/, "/reactions");
|
|
12
12
|
return `${method}-${routeURL}`;
|
|
13
13
|
};
|
|
14
|
-
export const numberHeader = (headers) => (key) => tsplus_module_1.filter((n) => !isNaN(n))(tsplus_module_1.map(parseFloat)(
|
|
15
|
-
export const retryAfter = (headers) => tsplus_module_1.map(
|
|
16
|
-
export const rateLimitFromHeaders = (headers) =>
|
|
17
|
-
bucket:
|
|
14
|
+
export const numberHeader = (headers) => (key) => tsplus_module_1.filter((n) => !isNaN(n))(tsplus_module_1.map(parseFloat)(Option.fromNullable(headers.get(key))));
|
|
15
|
+
export const retryAfter = (headers) => tsplus_module_1.map(Duration.seconds)(tsplus_module_1.catchAll(() => numberHeader(headers)("retry-after"))(numberHeader(headers)("x-ratelimit-reset-after")));
|
|
16
|
+
export const rateLimitFromHeaders = (headers) => Option.struct({
|
|
17
|
+
bucket: Option.fromNullable(headers.get("x-ratelimit-bucket")),
|
|
18
18
|
retryAfter: retryAfter(headers),
|
|
19
19
|
limit: numberHeader(headers)("x-ratelimit-limit"),
|
|
20
20
|
remaining: numberHeader(headers)("x-ratelimit-remaining"),
|
package/DiscordREST/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/DiscordREST/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/DiscordREST/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAA;AAElE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAiB,EAAE,EAAE;IACjE,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAEpD,uBAAuB;IACvB,MAAM,QAAQ,GAAG,IAAI;SAClB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACb,OAAO,CAAC,iCAAiC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC9D,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAC3D;QACD,kBAAkB;SACjB,OAAO,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;IAE7C,OAAO,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE,CAChE,uBAEU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAF1B,oBACO,UAAU,EADjB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACnB,CACS,CAAA;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE,CAC7C,oBAEO,QAAQ,CAAC,OAAO,EAFvB,yBACY,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EADtD,YAAY,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,CACO,CAC/B,CAAA;AAE1B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAE,EAAE,CACvD,MAAM,CAAC,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC9D,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;IACjD,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,uBAAuB,CAAC;CAC1D,CAAC,CAAA"}
|
package/Helpers/intents.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Discord, Flags } from "dfx";
|
|
2
2
|
/**
|
|
3
3
|
* All the intents
|
|
4
4
|
*/
|
|
5
|
-
export const ALL =
|
|
5
|
+
export const ALL = Flags.all(Discord.GatewayIntents);
|
|
6
6
|
/**
|
|
7
7
|
* Privileged intents
|
|
8
8
|
*/
|
|
9
|
-
export const PRIVILEGED =
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export const PRIVILEGED = Discord.GatewayIntents.GUILD_PRESENCES |
|
|
10
|
+
Discord.GatewayIntents.GUILD_MEMBERS |
|
|
11
|
+
Discord.GatewayIntents.MESSAGE_CONTENT;
|
|
12
12
|
/**
|
|
13
13
|
* Un-privileged intents
|
|
14
14
|
*/
|
|
@@ -16,13 +16,13 @@ export const UNPRIVILEGED = ALL ^ PRIVILEGED;
|
|
|
16
16
|
/**
|
|
17
17
|
* Function that converts a intents bitfield value to a list of intent names.
|
|
18
18
|
*/
|
|
19
|
-
export const toList =
|
|
19
|
+
export const toList = Flags.toList(Discord.GatewayIntents);
|
|
20
20
|
/**
|
|
21
21
|
* Function that converts a list of intent names to a bitfield value.
|
|
22
22
|
*/
|
|
23
|
-
export const fromList =
|
|
23
|
+
export const fromList = Flags.fromList(Discord.GatewayIntents);
|
|
24
24
|
/**
|
|
25
25
|
* Check if an intent flag exists in the permissions.
|
|
26
26
|
*/
|
|
27
|
-
export const has =
|
|
27
|
+
export const has = Flags.has;
|
|
28
28
|
//# sourceMappingURL=intents.js.map
|
package/Helpers/intents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intents.js","sourceRoot":"","sources":["../../src/Helpers/intents.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"intents.js","sourceRoot":"","sources":["../../src/Helpers/intents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,OAAO,CAAC,cAAc,CAAC,eAAe;IACtC,OAAO,CAAC,cAAc,CAAC,aAAa;IACpC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,GAAG,UAAU,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { Discord } from "dfx";
|
|
2
|
-
import { Maybe } from "dfx/utils/common";
|
|
1
|
+
import { Discord, HashMap, Option } from "dfx/_common";
|
|
3
2
|
/**
|
|
4
3
|
* Maybe find a sub-command within the interaction options.
|
|
5
4
|
*/
|
|
6
|
-
export declare const allSubCommands: (interaction: Discord.ApplicationCommandDatum) => readonly
|
|
5
|
+
export declare const allSubCommands: (interaction: Discord.ApplicationCommandDatum) => readonly Discord.ApplicationCommandInteractionDataOption[];
|
|
7
6
|
/**
|
|
8
7
|
* Maybe find a sub-command within the interaction options.
|
|
9
8
|
*/
|
|
10
|
-
export declare const findSubCommand: (name: string) => (interaction: Discord.ApplicationCommandDatum) =>
|
|
9
|
+
export declare const findSubCommand: (name: string) => (interaction: Discord.ApplicationCommandDatum) => Option.Option<Discord.ApplicationCommandInteractionDataOption>;
|
|
11
10
|
/**
|
|
12
11
|
* If the sub-command exists return `true`, else `false`.
|
|
13
12
|
*/
|
|
14
|
-
export declare const isSubCommand: (name: string) => (interaction:
|
|
13
|
+
export declare const isSubCommand: (name: string) => (interaction: Discord.ApplicationCommandDatum) => boolean;
|
|
15
14
|
/**
|
|
16
15
|
* Maybe get the options for a sub-command
|
|
17
16
|
*/
|
|
18
|
-
export declare const subCommandOptions: (name: string) => (interaction:
|
|
17
|
+
export declare const subCommandOptions: (name: string) => (interaction: Discord.ApplicationCommandDatum) => Option.Option<Discord.ApplicationCommandInteractionDataOption[]>;
|
|
19
18
|
/**
|
|
20
19
|
* A lens for accessing nested options in a interaction.
|
|
21
20
|
*/
|
|
@@ -23,35 +22,35 @@ export declare const optionsWithNested: (data: Pick<Discord.ApplicationCommandDa
|
|
|
23
22
|
/**
|
|
24
23
|
* Return the interaction options as a name / value map.
|
|
25
24
|
*/
|
|
26
|
-
export declare const transformOptions: (options: Discord.ApplicationCommandInteractionDataOption[]) =>
|
|
25
|
+
export declare const transformOptions: (options: Discord.ApplicationCommandInteractionDataOption[]) => HashMap.HashMap<string, string | undefined>;
|
|
27
26
|
/**
|
|
28
27
|
* Return the interaction options as a name / value map.
|
|
29
28
|
*/
|
|
30
|
-
export declare const optionsMap: (data: Pick<
|
|
29
|
+
export declare const optionsMap: (data: Pick<Discord.ApplicationCommandDatum, "options">) => HashMap.HashMap<string, string | undefined>;
|
|
31
30
|
/**
|
|
32
31
|
* Try find a matching option from the interaction.
|
|
33
32
|
*/
|
|
34
|
-
export declare const getOption: (name: string) => (data: Pick<
|
|
33
|
+
export declare const getOption: (name: string) => (data: Pick<Discord.ApplicationCommandDatum, "options">) => Option.Option<Discord.ApplicationCommandInteractionDataOption>;
|
|
35
34
|
/**
|
|
36
35
|
* Try find a matching option from the interaction.
|
|
37
36
|
*/
|
|
38
|
-
export declare const focusedOption: (data: Pick<
|
|
37
|
+
export declare const focusedOption: (data: Pick<Discord.ApplicationCommandDatum, "options">) => Option.Option<Discord.ApplicationCommandInteractionDataOption>;
|
|
39
38
|
/**
|
|
40
39
|
* Try find a matching option value from the interaction.
|
|
41
40
|
*/
|
|
42
|
-
export declare const optionValue: (name: string) => (data: Pick<
|
|
41
|
+
export declare const optionValue: (name: string) => (data: Pick<Discord.ApplicationCommandDatum, "options">) => Option.Option<string>;
|
|
43
42
|
/**
|
|
44
43
|
* Try extract resolved data
|
|
45
44
|
*/
|
|
46
|
-
export declare const resolved: (data: Discord.Interaction) =>
|
|
45
|
+
export declare const resolved: (data: Discord.Interaction) => Option.Option<Discord.ResolvedDatum>;
|
|
47
46
|
/**
|
|
48
47
|
* Try find a matching option value from the interaction.
|
|
49
48
|
*/
|
|
50
|
-
export declare const resolveOptionValue: <T>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.Interaction) =>
|
|
49
|
+
export declare const resolveOptionValue: <T>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.Interaction) => Option.Option<T>;
|
|
51
50
|
/**
|
|
52
51
|
* Try find matching option values from the interaction.
|
|
53
52
|
*/
|
|
54
|
-
export declare const resolveValues: <T>(f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.Interaction) =>
|
|
53
|
+
export declare const resolveValues: <T>(f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.Interaction) => Option.Option<readonly T[]>;
|
|
55
54
|
/**
|
|
56
55
|
* A lens for accessing the components in a interaction.
|
|
57
56
|
*/
|
|
@@ -59,23 +58,23 @@ export declare const components: (a: Discord.ModalSubmitDatum) => Discord.Compon
|
|
|
59
58
|
/**
|
|
60
59
|
* A lens for accessing the components in a interaction.
|
|
61
60
|
*/
|
|
62
|
-
export declare const componentsWithValue: (a:
|
|
61
|
+
export declare const componentsWithValue: (a: Discord.ModalSubmitDatum) => readonly Discord.Component[];
|
|
63
62
|
/**
|
|
64
63
|
* Return the interaction components as an id / value map.
|
|
65
64
|
*/
|
|
66
|
-
export declare const transformComponents: (options: Discord.Component[]) =>
|
|
65
|
+
export declare const transformComponents: (options: Discord.Component[]) => HashMap.HashMap<string, string | undefined>;
|
|
67
66
|
/**
|
|
68
67
|
* Return the interaction components as an id / value map.
|
|
69
68
|
*/
|
|
70
|
-
export declare const componentsMap: (a:
|
|
69
|
+
export declare const componentsMap: (a: Discord.ModalSubmitDatum) => HashMap.HashMap<string, string | undefined>;
|
|
71
70
|
/**
|
|
72
71
|
* Try find a matching component from the interaction.
|
|
73
72
|
*/
|
|
74
|
-
export declare const getComponent: (id: string) => (a:
|
|
73
|
+
export declare const getComponent: (id: string) => (a: Discord.ModalSubmitDatum) => Option.Option<Discord.Component>;
|
|
75
74
|
/**
|
|
76
75
|
* Try find a matching component value from the interaction.
|
|
77
76
|
*/
|
|
78
|
-
export declare const componentValue: (id: string) => (a:
|
|
77
|
+
export declare const componentValue: (id: string) => (a: Discord.ModalSubmitDatum) => Option.Option<string>;
|
|
79
78
|
export type InteractionResponse = {
|
|
80
79
|
type: Discord.InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE;
|
|
81
80
|
data: Discord.InteractionCallbackMessage;
|
package/Helpers/interactions.js
CHANGED
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "
|
|
3
|
-
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
-
import * as tsplus_module_4 from "@fp-ts/data/HashMap";
|
|
1
|
+
import * as tsplus_module_1 from "@fp-ts/data/Option";
|
|
2
|
+
import * as tsplus_module_2 from "@fp-ts/data/HashMap";
|
|
5
3
|
import * as Arr from "@fp-ts/data/ReadonlyArray";
|
|
4
|
+
import { Discord, flow, HashMap, identity, Option, pipe } from "dfx/_common";
|
|
6
5
|
/**
|
|
7
6
|
* Maybe find a sub-command within the interaction options.
|
|
8
7
|
*/
|
|
9
|
-
export const allSubCommands = (interaction) =>
|
|
8
|
+
export const allSubCommands = (interaction) => pipe(optionsWithNested(interaction), Arr.filter((o) => o.type === Discord.ApplicationCommandOptionType.SUB_COMMAND));
|
|
10
9
|
/**
|
|
11
10
|
* Maybe find a sub-command within the interaction options.
|
|
12
11
|
*/
|
|
13
|
-
export const findSubCommand = (name) => (interaction) =>
|
|
12
|
+
export const findSubCommand = (name) => (interaction) => pipe(optionsWithNested(interaction), Arr.findFirst((o) => o.type === Discord.ApplicationCommandOptionType.SUB_COMMAND &&
|
|
14
13
|
o.name === name));
|
|
15
14
|
/**
|
|
16
15
|
* If the sub-command exists return `true`, else `false`.
|
|
17
16
|
*/
|
|
18
|
-
export const isSubCommand = (name) =>
|
|
17
|
+
export const isSubCommand = (name) => flow(findSubCommand(name), (o) => tsplus_module_1.isSome(o));
|
|
19
18
|
/**
|
|
20
19
|
* Maybe get the options for a sub-command
|
|
21
20
|
*/
|
|
22
|
-
export const subCommandOptions = (name) =>
|
|
21
|
+
export const subCommandOptions = (name) => flow(findSubCommand(name), (o) => tsplus_module_1.flatMapNullable((o) => o.options)(o));
|
|
23
22
|
/**
|
|
24
23
|
* A lens for accessing nested options in a interaction.
|
|
25
24
|
*/
|
|
26
25
|
export const optionsWithNested = (data) => {
|
|
27
|
-
const optsFromOption = (opt) =>
|
|
28
|
-
return
|
|
26
|
+
const optsFromOption = (opt) => tsplus_module_1.match(() => [], identity)(tsplus_module_1.map((opts) => [...opts, ...opts.flatMap(optsFromOption)])(Option.fromNullable(opt.options)));
|
|
27
|
+
return tsplus_module_1.getOrElse(() => [])(tsplus_module_1.map((opts) => [...opts, ...opts.flatMap(optsFromOption)])(Option.fromNullable(data.options)));
|
|
29
28
|
};
|
|
30
29
|
/**
|
|
31
30
|
* Return the interaction options as a name / value map.
|
|
32
31
|
*/
|
|
33
|
-
export const transformOptions = (options) => options.reduce((map, option) =>
|
|
32
|
+
export const transformOptions = (options) => options.reduce((map, option) => tsplus_module_2.set(option.name, option.value)(map), HashMap.empty());
|
|
34
33
|
/**
|
|
35
34
|
* Return the interaction options as a name / value map.
|
|
36
35
|
*/
|
|
37
|
-
export const optionsMap =
|
|
36
|
+
export const optionsMap = flow(optionsWithNested, transformOptions);
|
|
38
37
|
/**
|
|
39
38
|
* Try find a matching option from the interaction.
|
|
40
39
|
*/
|
|
41
|
-
export const getOption = (name) =>
|
|
40
|
+
export const getOption = (name) => flow(optionsWithNested, Arr.findFirst((o) => o.name === name));
|
|
42
41
|
/**
|
|
43
42
|
* Try find a matching option from the interaction.
|
|
44
43
|
*/
|
|
45
|
-
export const focusedOption =
|
|
44
|
+
export const focusedOption = flow(optionsWithNested, Arr.findFirst((o) => o.focused === true));
|
|
46
45
|
/**
|
|
47
46
|
* Try find a matching option value from the interaction.
|
|
48
47
|
*/
|
|
49
|
-
export const optionValue = (name) =>
|
|
48
|
+
export const optionValue = (name) => flow(getOption(name), (o) => tsplus_module_1.flatMapNullable((o) => o.value)(o));
|
|
50
49
|
/**
|
|
51
50
|
* Try extract resolved data
|
|
52
51
|
*/
|
|
53
|
-
export const resolved = (data) =>
|
|
52
|
+
export const resolved = (data) => tsplus_module_1.flatMapNullable((a) => a.resolved)(Option.fromNullable(data.data));
|
|
54
53
|
/**
|
|
55
54
|
* Try find a matching option value from the interaction.
|
|
56
55
|
*/
|
|
57
|
-
export const resolveOptionValue = (name, f) => (a) =>
|
|
56
|
+
export const resolveOptionValue = (name, f) => (a) => tsplus_module_1.flatMap(data => tsplus_module_1.flatMap(id => tsplus_module_1.flatMap(r => Option.fromNullable(f(id, r)))(resolved(a)))(tsplus_module_1.flatMapNullable(({ value }) => value)(getOption(name)(data))))(Option.fromNullable(a.data));
|
|
58
57
|
/**
|
|
59
58
|
* Try find matching option values from the interaction.
|
|
60
59
|
*/
|
|
61
|
-
export const resolveValues = (f) => (a) =>
|
|
60
|
+
export const resolveValues = (f) => (a) => tsplus_module_1.flatMap(values => tsplus_module_1.flatMap(r => Option.productAll(values.map((a) => Option.fromNullable(f(a, r)))))(resolved(a)))(tsplus_module_1.flatMapNullable((a) => a.values)(Option.fromNullable(a.data)));
|
|
62
61
|
const extractComponents = (c) => {
|
|
63
62
|
if ("components" in c) {
|
|
64
63
|
return [...c.components, ...c.components.flatMap(extractComponents)];
|
|
@@ -75,22 +74,22 @@ export const components = (a) => [
|
|
|
75
74
|
/**
|
|
76
75
|
* A lens for accessing the components in a interaction.
|
|
77
76
|
*/
|
|
78
|
-
export const componentsWithValue =
|
|
77
|
+
export const componentsWithValue = flow(components, Arr.filter((c) => "value" in c && c.value !== undefined));
|
|
79
78
|
/**
|
|
80
79
|
* Return the interaction components as an id / value map.
|
|
81
80
|
*/
|
|
82
|
-
export const transformComponents = (options) => options.reduce((map, c) => (c.custom_id ?
|
|
81
|
+
export const transformComponents = (options) => options.reduce((map, c) => (c.custom_id ? tsplus_module_2.set(c.custom_id, c.value)(map) : map), HashMap.empty());
|
|
83
82
|
/**
|
|
84
83
|
* Return the interaction components as an id / value map.
|
|
85
84
|
*/
|
|
86
|
-
export const componentsMap =
|
|
85
|
+
export const componentsMap = flow(components, transformComponents);
|
|
87
86
|
/**
|
|
88
87
|
* Try find a matching component from the interaction.
|
|
89
88
|
*/
|
|
90
|
-
export const getComponent = (id) =>
|
|
89
|
+
export const getComponent = (id) => flow(components, Arr.findFirst((o) => o.custom_id === id));
|
|
91
90
|
/**
|
|
92
91
|
* Try find a matching component value from the interaction.
|
|
93
92
|
*/
|
|
94
|
-
export const componentValue = (id) =>
|
|
93
|
+
export const componentValue = (id) => flow(getComponent(id), (o) => tsplus_module_1.flatMapNullable((o) => o.value)(o));
|
|
95
94
|
export const response = (r) => r;
|
|
96
95
|
//# sourceMappingURL=interactions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.js","sourceRoot":"","sources":["../../src/Helpers/interactions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactions.js","sourceRoot":"","sources":["../../src/Helpers/interactions.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAE5E;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAA4C,EAAE,EAAE,CAC7E,IAAI,CACF,iBAAiB,CAAC,WAAW,CAAC,EAC9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E,CAC3C,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAC3B,gCAAkB,CAAC,CAAC,EAAE,EAAE,CAAE,CAAuB,CAAC,KAAK,EAAvD,CAAC,CAAuD,CACzD,CAAA;AA0BH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAsB,EAAE,EAAE,CAAC,CAAC,CAAA"}
|
package/Helpers/members.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Discord } from "dfx";
|
|
|
2
2
|
/**
|
|
3
3
|
* From a list of roles, filter out the ones the guild member has.
|
|
4
4
|
*/
|
|
5
|
-
export declare const roles: (roles: Discord.Role[]) => (member: Discord.GuildMember) =>
|
|
5
|
+
export declare const roles: (roles: Discord.Role[]) => (member: Discord.GuildMember) => Discord.Role[];
|
|
6
6
|
/**
|
|
7
7
|
* Type-guard function for checking if the object is a guild member
|
|
8
8
|
*/
|
|
9
|
-
export declare const is: (thing: unknown) => thing is
|
|
9
|
+
export declare const is: (thing: unknown) => thing is Discord.GuildMember;
|
package/Helpers/members.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/Helpers/members.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/Helpers/members.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,CAAC,MAA2B,EAAE,EAAE,CAC9E,KAAK,CAAC,MAAM,CACV,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CACtE,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAc,EAAgC,EAAE,CACjE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;IACpD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA"}
|
package/Helpers/permissions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Discord } from "dfx";
|
|
2
|
-
import { Effect } from "dfx/
|
|
2
|
+
import { Effect } from "dfx/_common";
|
|
3
3
|
/**
|
|
4
4
|
* A constant of all the permissions
|
|
5
5
|
*/
|
|
@@ -34,8 +34,8 @@ export declare const forChannel: (roles: Discord.Role[]) => ({ guild_id, permiss
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const applyOverwrites: (permissions: bigint) => (overwrites: Discord.Overwrite[]) => bigint;
|
|
36
36
|
interface RolesCache<E> {
|
|
37
|
-
getForParent: (parentId: string) => Effect<never, E, ReadonlyMap<string, Discord.Role>>;
|
|
37
|
+
getForParent: (parentId: string) => Effect.Effect<never, E, ReadonlyMap<string, Discord.Role>>;
|
|
38
38
|
}
|
|
39
|
-
export declare const hasInChannel: <E>(rolesCache: RolesCache<E>, permission: bigint) => (channel: Discord.Channel, memberOrRole: Discord.GuildMember | Discord.Role) =>
|
|
40
|
-
export declare const hasInGuild: <E>(rolesCache: RolesCache<E>, permission: bigint) => (guildId: Discord.Snowflake, member: Discord.GuildMember) =>
|
|
39
|
+
export declare const hasInChannel: <E>(rolesCache: RolesCache<E>, permission: bigint) => (channel: Discord.Channel, memberOrRole: Discord.GuildMember | Discord.Role) => Effect.Effect<never, E, boolean>;
|
|
40
|
+
export declare const hasInGuild: <E>(rolesCache: RolesCache<E>, permission: bigint) => (guildId: Discord.Snowflake, member: Discord.GuildMember) => Effect.Effect<never, E, boolean>;
|
|
41
41
|
export {};
|
package/Helpers/permissions.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import { Discord, Flags, Members } from "dfx";
|
|
3
|
+
import { pipe } from "dfx/_common";
|
|
4
4
|
/**
|
|
5
5
|
* A constant of all the permissions
|
|
6
6
|
*/
|
|
7
|
-
export const ALL =
|
|
7
|
+
export const ALL = Flags.all(Discord.PermissionFlag);
|
|
8
8
|
/**
|
|
9
9
|
* Check if a flag exists in the permissions.
|
|
10
10
|
*/
|
|
11
|
-
export const has =
|
|
11
|
+
export const has = Flags.hasBigInt;
|
|
12
12
|
/**
|
|
13
13
|
* Convert a permissions bitfield to a list of flag names.
|
|
14
14
|
*/
|
|
15
|
-
export const toList =
|
|
15
|
+
export const toList = Flags.toList(Discord.PermissionFlag);
|
|
16
16
|
/**
|
|
17
17
|
* Convert a list of flag names to a bitfield.
|
|
18
18
|
*/
|
|
19
|
-
export const fromList =
|
|
19
|
+
export const fromList = Flags.fromListBigint(Discord.PermissionFlag);
|
|
20
20
|
/**
|
|
21
21
|
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
22
22
|
*/
|
|
@@ -24,7 +24,7 @@ export const forRoles = (roles) => roles.reduce((permissions, role) => permissio
|
|
|
24
24
|
/**
|
|
25
25
|
* From a list of roles, calculate the permissions bitfield for the member.
|
|
26
26
|
*/
|
|
27
|
-
export const forMember = (roles) => (member) =>
|
|
27
|
+
export const forMember = (roles) => (member) => pipe(Members.roles(roles)(member), forRoles);
|
|
28
28
|
const overwriteIsForMember = (guildId) => (member) => (overwrite) => {
|
|
29
29
|
if (overwrite.type === 0) {
|
|
30
30
|
return overwrite.id === guildId || member.roles.includes(overwrite.id);
|
|
@@ -42,13 +42,13 @@ const overwriteIsForRole = (guildId) => (role) => (overwrite) => {
|
|
|
42
42
|
* the guild member or role for that channel.
|
|
43
43
|
*/
|
|
44
44
|
export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwrites = [] }) => (memberOrRole) => {
|
|
45
|
-
const hasAdmin = has(
|
|
45
|
+
const hasAdmin = has(Discord.PermissionFlag.ADMINISTRATOR);
|
|
46
46
|
let basePermissions;
|
|
47
47
|
let filteredOverwrites;
|
|
48
|
-
if (
|
|
48
|
+
if (Members.is(memberOrRole)) {
|
|
49
49
|
if (memberOrRole.permissions)
|
|
50
50
|
return BigInt(memberOrRole.permissions);
|
|
51
|
-
const memberRoles =
|
|
51
|
+
const memberRoles = Members.roles(roles)(memberOrRole);
|
|
52
52
|
basePermissions = forRoles(memberRoles);
|
|
53
53
|
filteredOverwrites = overwrites.filter(overwriteIsForMember(guild_id)(memberOrRole));
|
|
54
54
|
}
|
|
@@ -67,11 +67,11 @@ export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwri
|
|
|
67
67
|
* Apply permission overwrites to a bitfield.
|
|
68
68
|
*/
|
|
69
69
|
export const applyOverwrites = (permissions) => (overwrites) => overwrites.reduce((permissions, overwrite) => (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow), permissions);
|
|
70
|
-
export const hasInChannel = (rolesCache, permission) => (channel, memberOrRole) =>
|
|
70
|
+
export const hasInChannel = (rolesCache, permission) => (channel, memberOrRole) => tsplus_module_1.map(roles => {
|
|
71
71
|
const channelPerms = forChannel([...roles.values()])(channel)(memberOrRole);
|
|
72
72
|
return has(permission)(channelPerms);
|
|
73
73
|
})(rolesCache.getForParent(channel.guild_id));
|
|
74
|
-
export const hasInGuild = (rolesCache, permission) => (guildId, member) =>
|
|
74
|
+
export const hasInGuild = (rolesCache, permission) => (guildId, member) => tsplus_module_1.map(roles => {
|
|
75
75
|
const hasPerm = has(permission);
|
|
76
76
|
return member.roles.some((id) => {
|
|
77
77
|
const role = roles.get(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/Helpers/permissions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/Helpers/permissions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO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E/B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IACjD,CAAC,CAAC,CAAA;GANc,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAOhD,CAAA"}
|
package/Http/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "dfx/_common";
|
|
1
2
|
declare const make: () => {
|
|
2
|
-
request: (url: URL | string, init?: RequestInit) =>
|
|
3
|
-
requestWithJson: <A = unknown>(url: URL | string, init?: RequestInit) =>
|
|
3
|
+
request: (url: URL | string, init?: RequestInit) => Effect.Effect<never, FetchError | StatusCodeError, Response>;
|
|
4
|
+
requestWithJson: <A = unknown>(url: URL | string, init?: RequestInit) => Effect.Effect<never, FetchError | StatusCodeError, {
|
|
4
5
|
response: Response;
|
|
5
|
-
json:
|
|
6
|
-
blob:
|
|
7
|
-
text:
|
|
6
|
+
json: Effect.Effect<never, JsonParseError, A>;
|
|
7
|
+
blob: Effect.Effect<never, BlobError, Blob>;
|
|
8
|
+
text: Effect.Effect<never, never, string>;
|
|
8
9
|
}>;
|
|
9
10
|
};
|
|
10
11
|
export interface Http extends ReturnType<typeof make> {
|
|
11
12
|
}
|
|
12
|
-
export declare const Http:
|
|
13
|
-
export declare const LiveHttp:
|
|
13
|
+
export declare const Http: Context.Tag<Http>;
|
|
14
|
+
export declare const LiveHttp: Layer.Layer<never, never, Http>;
|
|
14
15
|
export declare class FetchError {
|
|
15
16
|
readonly reason: unknown;
|
|
16
17
|
readonly _tag = "FetchError";
|
|
@@ -27,11 +28,11 @@ export declare class JsonParseError {
|
|
|
27
28
|
readonly _tag = "JsonParseError";
|
|
28
29
|
constructor(reason: unknown);
|
|
29
30
|
}
|
|
30
|
-
export declare const json: <A = unknown>(r: Response) =>
|
|
31
|
+
export declare const json: <A = unknown>(r: Response) => Effect.Effect<never, JsonParseError, A>;
|
|
31
32
|
export declare class BlobError {
|
|
32
33
|
readonly reason: unknown;
|
|
33
34
|
readonly _tag = "BlobError";
|
|
34
35
|
constructor(reason: unknown);
|
|
35
36
|
}
|
|
36
|
-
export declare const blob: (r: Response) =>
|
|
37
|
+
export declare const blob: (r: Response) => Effect.Effect<never, BlobError, Blob>;
|
|
37
38
|
export {};
|
package/Http/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
-
import
|
|
3
|
-
import * as tsplus_module_3 from "@effect/io/Layer";
|
|
2
|
+
import { Context, Effect, Layer, } from "dfx/_common";
|
|
4
3
|
const make = () => {
|
|
5
|
-
const request = (url, init = {}) => tsplus_module_1.filterOrElseWith((r) => r.status < 300, (r) =>
|
|
4
|
+
const request = (url, init = {}) => tsplus_module_1.filterOrElseWith((r) => r.status < 300, (r) => Effect.fail(new StatusCodeError(r)))(Effect.tryCatchPromiseInterrupt((signal) => fetch(url, {
|
|
6
5
|
...init,
|
|
7
6
|
signal,
|
|
8
7
|
}), (e) => new FetchError(e)));
|
|
@@ -10,12 +9,12 @@ const make = () => {
|
|
|
10
9
|
response,
|
|
11
10
|
json: json(response),
|
|
12
11
|
blob: blob(response),
|
|
13
|
-
text:
|
|
12
|
+
text: Effect.promise(() => response.text()),
|
|
14
13
|
}))(request(url, init));
|
|
15
14
|
return { request, requestWithJson };
|
|
16
15
|
};
|
|
17
|
-
export const Http =
|
|
18
|
-
export const LiveHttp =
|
|
16
|
+
export const Http = Context.Tag();
|
|
17
|
+
export const LiveHttp = Layer.sync(Http)(make);
|
|
19
18
|
export class FetchError {
|
|
20
19
|
reason;
|
|
21
20
|
_tag = "FetchError";
|
|
@@ -39,7 +38,7 @@ export class JsonParseError {
|
|
|
39
38
|
this.reason = reason;
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
export const json = (r) =>
|
|
41
|
+
export const json = (r) => Effect.tryCatchPromise(() => r.json(), (reason) => new JsonParseError(reason));
|
|
43
42
|
export class BlobError {
|
|
44
43
|
reason;
|
|
45
44
|
_tag = "BlobError";
|
|
@@ -47,5 +46,5 @@ export class BlobError {
|
|
|
47
46
|
this.reason = reason;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
export const blob = (r) =>
|
|
49
|
+
export const blob = (r) => Effect.tryCatchPromise(() => r.blob(), (reason) => new BlobError(reason));
|
|
51
50
|
//# sourceMappingURL=index.js.map
|
package/Http/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGP,MAAM,EACN,KAAK,GAON,MAAM,aAAa,CAAA;AAEpB,MAAM,IAAI,GAAG,GAAG,EAAE;IAChB,MAAM,OAAO,GAAG,CAAC,GAAiB,EAAE,OAAoB,EAAE,EAAE,EAAE,CAC5D,iCAQE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,EACrB,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,EAT5C,MAAM,CAAC,wBAAwB,CAC7B,CAAC,MAAM,EAAE,EAAE,CACT,KAAK,CAAC,GAAG,EAAE;QACT,GAAG,IAAI;QACP,MAAM;KACP,CAAC,EACJ,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CACzB,CAGA,CAAA;IAEH,MAAM,eAAe,GAAG,CACtB,GAAiB,EACjB,OAAoB,EAAE,EACtB,EAAE,C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