@webiny/project 6.6.0-alpha.13 → 6.6.0-alpha.14
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/extensions/FeatureFlags.d.ts +1 -0
- package/extensions/FeatureFlags.js +2 -1
- package/extensions/FeatureFlags.js.map +1 -1
- package/extensions/index.d.ts +1 -0
- package/package.json +8 -8
- package/tenantStorages/index.d.ts +1 -0
- package/tenantStorages/index.js +1 -0
- package/tenantStorages/tenantStorageDeclarations.d.ts +42 -0
- package/tenantStorages/tenantStorageDeclarations.js +33 -0
- package/tenantStorages/tenantStorageDeclarations.js.map +1 -0
|
@@ -38,5 +38,6 @@ export declare const FeatureFlags: import("~/defineExtension/index.js").Extensio
|
|
|
38
38
|
activityLog: z.ZodOptional<z.ZodBoolean>;
|
|
39
39
|
}, z.core.$strip>]>>;
|
|
40
40
|
webhooks: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
perTenantStorage: z.ZodOptional<z.ZodBoolean>;
|
|
41
42
|
}, z.core.$strip>;
|
|
42
43
|
}, z.core.$strip>>;
|
|
@@ -58,7 +58,8 @@ const FeatureFlags = defineExtension({
|
|
|
58
58
|
activityLog: z.boolean().optional()
|
|
59
59
|
})
|
|
60
60
|
]).optional(),
|
|
61
|
-
webhooks: z.boolean().optional()
|
|
61
|
+
webhooks: z.boolean().optional(),
|
|
62
|
+
perTenantStorage: z.boolean().optional()
|
|
62
63
|
})
|
|
63
64
|
}),
|
|
64
65
|
render: ({ features = {} })=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/FeatureFlags.js","sources":["../../src/extensions/FeatureFlags.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { BuildParam } from \"./ApiBuildParam.js\";\nimport { AdminBuildParam } from \"./AdminBuildParam.js\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { setProjectFeatureFlags } from \"~/services/GetProjectConfigService/FeatureFlagsContext.js\";\n\nexport const FeatureFlags = defineExtension({\n type: \"FeatureFlags\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Enable or disable features.\",\n paramsSchema: z.object({\n // Follows `IFeatureFlagsDto` from `packages/feature-flags/src/types.ts`.\n features: z.object({\n multiTenancy: z.boolean().optional(),\n languages: z.boolean().optional(),\n advancedPublishingWorkflow: z.boolean().optional(),\n advancedAccessControlLayer: z\n .union([\n z.boolean(),\n z.object({\n teams: z.boolean().optional(),\n privateFiles: z.boolean().optional(),\n folderLevelPermissions: z.boolean().optional(),\n hcmsFieldPermissions: z.boolean().optional()\n })\n ])\n .optional(),\n auditLogs: z.boolean().optional(),\n recordLocking: z.boolean().optional(),\n fileManager: z\n .object({\n threatDetection: z.boolean().optional()\n })\n .optional(),\n aiPowerups: z\n .union([\n z.boolean(),\n z.object({\n websiteBuilder: z\n .object({\n pageGeneration: z.boolean().optional(),\n pageTranslation: z.boolean().optional()\n })\n .optional(),\n fileManager: z\n .object({\n imageEnrichment: z.boolean().optional()\n })\n .optional(),\n lexicalGeneration: z.boolean().optional(),\n adminAssistant: z.boolean().optional(),\n remoteComponents: z.boolean().optional(),\n cms: z\n .object({\n entryGeneration: z.boolean().optional(),\n entryComparison: z.boolean().optional(),\n entryTranslation: z.boolean().optional()\n })\n .optional()\n })\n ])\n .optional(),\n abTesting: z.boolean().optional(),\n collaboration: z\n .union([\n z.boolean(),\n z.object({\n comments: z.boolean().optional(),\n activityLog: z.boolean().optional()\n })\n ])\n .optional(),\n webhooks: z.boolean().optional()\n })\n }),\n render: ({ features = {} }) => {\n setProjectFeatureFlags(features);\n return (\n <>\n <BuildParam paramName=\"FeatureFlags\" value={features} />\n <AdminBuildParam paramName=\"FeatureFlags\" value={features} />\n </>\n );\n }\n});\n"],"names":["FeatureFlags","defineExtension","z","features","setProjectFeatureFlags","BuildParam","AdminBuildParam"],"mappings":";;;;;;AAOO,MAAMA,eAAeC,gBAAgB;IACxC,MAAM;IACN,MAAM;QAA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O,GAAG,QAAQ;oBAC1C,GACC,QAAQ;gBACjB;aACH,EACA,QAAQ;YACb,WAAWA,EAAE,OAAO,GAAG,QAAQ;YAC/B,eAAeA,EAAAA,KACL,CAAC;gBACHA,EAAE,OAAO;gBACTA,EAAE,MAAM,CAAC;oBACL,UAAUA,EAAE,OAAO,GAAG,QAAQ;oBAC9B,aAAaA,EAAE,OAAO,GAAG,QAAQ;gBACrC;aACH,EACA,QAAQ;YACb,UAAUA,EAAE,OAAO,GAAG,QAAQ;
|
|
1
|
+
{"version":3,"file":"extensions/FeatureFlags.js","sources":["../../src/extensions/FeatureFlags.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { BuildParam } from \"./ApiBuildParam.js\";\nimport { AdminBuildParam } from \"./AdminBuildParam.js\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { setProjectFeatureFlags } from \"~/services/GetProjectConfigService/FeatureFlagsContext.js\";\n\nexport const FeatureFlags = defineExtension({\n type: \"FeatureFlags\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Enable or disable features.\",\n paramsSchema: z.object({\n // Follows `IFeatureFlagsDto` from `packages/feature-flags/src/types.ts`.\n features: z.object({\n multiTenancy: z.boolean().optional(),\n languages: z.boolean().optional(),\n advancedPublishingWorkflow: z.boolean().optional(),\n advancedAccessControlLayer: z\n .union([\n z.boolean(),\n z.object({\n teams: z.boolean().optional(),\n privateFiles: z.boolean().optional(),\n folderLevelPermissions: z.boolean().optional(),\n hcmsFieldPermissions: z.boolean().optional()\n })\n ])\n .optional(),\n auditLogs: z.boolean().optional(),\n recordLocking: z.boolean().optional(),\n fileManager: z\n .object({\n threatDetection: z.boolean().optional()\n })\n .optional(),\n aiPowerups: z\n .union([\n z.boolean(),\n z.object({\n websiteBuilder: z\n .object({\n pageGeneration: z.boolean().optional(),\n pageTranslation: z.boolean().optional()\n })\n .optional(),\n fileManager: z\n .object({\n imageEnrichment: z.boolean().optional()\n })\n .optional(),\n lexicalGeneration: z.boolean().optional(),\n adminAssistant: z.boolean().optional(),\n remoteComponents: z.boolean().optional(),\n cms: z\n .object({\n entryGeneration: z.boolean().optional(),\n entryComparison: z.boolean().optional(),\n entryTranslation: z.boolean().optional()\n })\n .optional()\n })\n ])\n .optional(),\n abTesting: z.boolean().optional(),\n collaboration: z\n .union([\n z.boolean(),\n z.object({\n comments: z.boolean().optional(),\n activityLog: z.boolean().optional()\n })\n ])\n .optional(),\n webhooks: z.boolean().optional(),\n perTenantStorage: z.boolean().optional()\n })\n }),\n render: ({ features = {} }) => {\n setProjectFeatureFlags(features);\n return (\n <>\n <BuildParam paramName=\"FeatureFlags\" value={features} />\n <AdminBuildParam paramName=\"FeatureFlags\" value={features} />\n </>\n );\n }\n});\n"],"names":["FeatureFlags","defineExtension","z","features","setProjectFeatureFlags","BuildParam","AdminBuildParam"],"mappings":";;;;;;AAOO,MAAMA,eAAeC,gBAAgB;IACxC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QAEnB,UAAUA,EAAE,MAAM,CAAC;YACf,cAAcA,EAAE,OAAO,GAAG,QAAQ;YAClC,WAAWA,EAAE,OAAO,GAAG,QAAQ;YAC/B,4BAA4BA,EAAE,OAAO,GAAG,QAAQ;YAChD,4BAA4BA,EAAAA,KAClB,CAAC;gBACHA,EAAE,OAAO;gBACTA,EAAE,MAAM,CAAC;oBACL,OAAOA,EAAE,OAAO,GAAG,QAAQ;oBAC3B,cAAcA,EAAE,OAAO,GAAG,QAAQ;oBAClC,wBAAwBA,EAAE,OAAO,GAAG,QAAQ;oBAC5C,sBAAsBA,EAAE,OAAO,GAAG,QAAQ;gBAC9C;aACH,EACA,QAAQ;YACb,WAAWA,EAAE,OAAO,GAAG,QAAQ;YAC/B,eAAeA,EAAE,OAAO,GAAG,QAAQ;YACnC,aAAaA,EAAAA,MACF,CAAC;gBACJ,iBAAiBA,EAAE,OAAO,GA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("./index.js").ExtensionDefinitionModel
|
|
|
87
87
|
activityLog: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
88
88
|
}, import("zod/v4/core").$strip>]>>;
|
|
89
89
|
webhooks: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
90
|
+
perTenantStorage: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
90
91
|
}, import("zod/v4/core").$strip>;
|
|
91
92
|
}, import("zod/v4/core").$strip>> | import("./index.js").ExtensionDefinitionModel<import("zod").ZodObject<{
|
|
92
93
|
src: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/project",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"description": "An SDK for managing Webiny projects.",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
16
|
+
"@webiny/build-tools": "6.6.0-alpha.14",
|
|
17
17
|
"@webiny/di": "2.0.0",
|
|
18
|
-
"@webiny/feature-flags": "6.6.0-alpha.
|
|
19
|
-
"@webiny/global-config": "6.6.0-alpha.
|
|
20
|
-
"@webiny/react-properties": "6.6.0-alpha.
|
|
21
|
-
"@webiny/system-requirements": "6.6.0-alpha.
|
|
22
|
-
"@webiny/telemetry": "6.6.0-alpha.
|
|
23
|
-
"@webiny/wcp": "6.6.0-alpha.
|
|
18
|
+
"@webiny/feature-flags": "6.6.0-alpha.14",
|
|
19
|
+
"@webiny/global-config": "6.6.0-alpha.14",
|
|
20
|
+
"@webiny/react-properties": "6.6.0-alpha.14",
|
|
21
|
+
"@webiny/system-requirements": "6.6.0-alpha.14",
|
|
22
|
+
"@webiny/telemetry": "6.6.0-alpha.14",
|
|
23
|
+
"@webiny/wcp": "6.6.0-alpha.14",
|
|
24
24
|
"chalk": "6.0.1",
|
|
25
25
|
"chokidar": "6.0.0",
|
|
26
26
|
"ci-info": "4.5.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_TENANT_STORAGE_ID, tenantStorageIdentitySchema, assertTenantStorageIds, formatStoragesLine, type TenantStorageDeclaration, type StoragesLineParams } from "./tenantStorageDeclarations.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_TENANT_STORAGE_ID, assertTenantStorageIds, formatStoragesLine, tenantStorageIdentitySchema } from "./tenantStorageDeclarations.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The id of the deploy's own storage, as the API knows it. The default storage has no component of
|
|
4
|
+
* its own (it's whichever database the config picks), so no `Infra.TenantStorage.*` may take it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_TENANT_STORAGE_ID = "default";
|
|
7
|
+
/**
|
|
8
|
+
* The params every `Infra.TenantStorage.*` component takes, next to its connection. A tenant's
|
|
9
|
+
* `settings.storage` stores the `id`, so it can't change once a tenant runs on it.
|
|
10
|
+
*/
|
|
11
|
+
export declare const tenantStorageIdentitySchema: {
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
label: z.ZodString;
|
|
14
|
+
retired: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
};
|
|
16
|
+
/** One extra storage, as the config declares it. */
|
|
17
|
+
export interface TenantStorageDeclaration {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
retired: boolean;
|
|
21
|
+
/** The storage's family as a person reads it: "Postgres", "PGlite", "Aurora Postgres". */
|
|
22
|
+
family: string;
|
|
23
|
+
/** The component that declares it, for error messages: `<Infra.TenantStorage.Postgres>`. */
|
|
24
|
+
component: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every declared storage needs an id of its own that a tenant's `settings.storage` can hold: a
|
|
28
|
+
* lowercase slug, not the default storage's id, and not another storage's. Checked across all
|
|
29
|
+
* `Infra.TenantStorage.*` components, so a Postgres and a PGlite storage can't share one either.
|
|
30
|
+
*/
|
|
31
|
+
export declare const assertTenantStorageIds: (declarations: TenantStorageDeclaration[]) => void;
|
|
32
|
+
export interface StoragesLineParams {
|
|
33
|
+
/** The default storage's family: "SQLite", "DynamoDB + OpenSearch", ... */
|
|
34
|
+
defaultFamily: string;
|
|
35
|
+
storages: Pick<TenantStorageDeclaration, "id" | "label" | "retired" | "family">[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The one line the CLI prints at start, so the config's storages can be read at a glance:
|
|
39
|
+
* `Storages: default = SQLite (root); local-pg = PGlite "Local Postgres"`. Retired storages are
|
|
40
|
+
* marked `(retired)`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const formatStoragesLine: (params: StoragesLineParams) => string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { GracefulError } from "../GracefulError.js";
|
|
3
|
+
const DEFAULT_TENANT_STORAGE_ID = "default";
|
|
4
|
+
const TENANT_STORAGE_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
5
|
+
const tenantStorageIdentitySchema = {
|
|
6
|
+
id: z.string().describe('The storage\'s id, stored in each tenant placed on it. A lowercase slug (e.g. "pg-eu"); never "default", which is the default storage\'s. Can\'t change once tenants run on it.'),
|
|
7
|
+
label: z.string().describe("The name the Tenant Manager shows for the storage."),
|
|
8
|
+
retired: z.boolean().optional().describe("A retired storage is no longer offered for new tenants, and tenants already on it keep running. Retire a storage before removing its declaration.")
|
|
9
|
+
};
|
|
10
|
+
const assertTenantStorageIds = (declarations)=>{
|
|
11
|
+
const seen = new Map();
|
|
12
|
+
for (const declaration of declarations){
|
|
13
|
+
const { id, component } = declaration;
|
|
14
|
+
if (id === DEFAULT_TENANT_STORAGE_ID) throw new GracefulError(`${component} can't use the id "${DEFAULT_TENANT_STORAGE_ID}": it is the default storage's, the database the config picks with its own component. Give the storage another id.`);
|
|
15
|
+
if (!TENANT_STORAGE_ID.test(id)) throw new GracefulError(`${component} has the id "${id}", which isn't a lowercase slug. Use lowercase letters, digits and single dashes, e.g. "pg-eu".`);
|
|
16
|
+
const other = seen.get(id);
|
|
17
|
+
if (other) throw new GracefulError(`${other} and ${component} both have the id "${id}". Each storage needs an id of its own.`);
|
|
18
|
+
seen.set(id, component);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const formatStoragesLine = (params)=>{
|
|
22
|
+
const parts = [
|
|
23
|
+
`${DEFAULT_TENANT_STORAGE_ID} = ${params.defaultFamily} (root)`
|
|
24
|
+
];
|
|
25
|
+
for (const storage of params.storages){
|
|
26
|
+
const retired = storage.retired ? " (retired)" : "";
|
|
27
|
+
parts.push(`${storage.id} = ${storage.family} "${storage.label}"${retired}`);
|
|
28
|
+
}
|
|
29
|
+
return `Storages: ${parts.join("; ")}`;
|
|
30
|
+
};
|
|
31
|
+
export { DEFAULT_TENANT_STORAGE_ID, assertTenantStorageIds, formatStoragesLine, tenantStorageIdentitySchema };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=tenantStorageDeclarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenantStorages/tenantStorageDeclarations.js","sources":["../../src/tenantStorages/tenantStorageDeclarations.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { GracefulError } from \"~/GracefulError.js\";\n\n/**\n * The id of the deploy's own storage, as the API knows it. The default storage has no component of\n * its own (it's whichever database the config picks), so no `Infra.TenantStorage.*` may take it.\n */\nexport const DEFAULT_TENANT_STORAGE_ID = \"default\";\n\n/** A lowercase slug: letters, digits and single dashes between them. */\nconst TENANT_STORAGE_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * The params every `Infra.TenantStorage.*` component takes, next to its connection. A tenant's\n * `settings.storage` stores the `id`, so it can't change once a tenant runs on it.\n */\nexport const tenantStorageIdentitySchema = {\n id: z\n .string()\n .describe(\n 'The storage\\'s id, stored in each tenant placed on it. A lowercase slug (e.g. \"pg-eu\"); never \"default\", which is the default storage\\'s. Can\\'t change once tenants run on it.'\n ),\n label: z.string().describe(\"The name the Tenant Manager shows for the storage.\"),\n retired: z\n .boolean()\n .optional()\n .describe(\n \"A retired storage is no longer offered for new tenants, and tenants already on it keep running. Retire a storage before removing its declaration.\"\n )\n};\n\n/** One extra storage, as the config declares it. */\nexport interface TenantStorageDeclaration {\n id: string;\n label: string;\n retired: boolean;\n /** The storage's family as a person reads it: \"Postgres\", \"PGlite\", \"Aurora Postgres\". */\n family: string;\n /** The component that declares it, for error messages: `<Infra.TenantStorage.Postgres>`. */\n component: string;\n}\n\n/**\n * Every declared storage needs an id of its own that a tenant's `settings.storage` can hold: a\n * lowercase slug, not the default storage's id, and not another storage's. Checked across all\n * `Infra.TenantStorage.*` components, so a Postgres and a PGlite storage can't share one either.\n */\nexport const assertTenantStorageIds = (declarations: TenantStorageDeclaration[]): void => {\n const seen = new Map<string, string>();\n for (const declaration of declarations) {\n const { id, component } = declaration;\n if (id === DEFAULT_TENANT_STORAGE_ID) {\n throw new GracefulError(\n `${component} can't use the id \"${DEFAULT_TENANT_STORAGE_ID}\": it is the default storage's, the database the config picks with its own component. Give the storage another id.`\n );\n }\n if (!TENANT_STORAGE_ID.test(id)) {\n throw new GracefulError(\n `${component} has the id \"${id}\", which isn't a lowercase slug. Use lowercase letters, digits and single dashes, e.g. \"pg-eu\".`\n );\n }\n const other = seen.get(id);\n if (other) {\n throw new GracefulError(\n `${other} and ${component} both have the id \"${id}\". Each storage needs an id of its own.`\n );\n }\n seen.set(id, component);\n }\n};\n\nexport interface StoragesLineParams {\n /** The default storage's family: \"SQLite\", \"DynamoDB + OpenSearch\", ... */\n defaultFamily: string;\n storages: Pick<TenantStorageDeclaration, \"id\" | \"label\" | \"retired\" | \"family\">[];\n}\n\n/**\n * The one line the CLI prints at start, so the config's storages can be read at a glance:\n * `Storages: default = SQLite (root); local-pg = PGlite \"Local Postgres\"`. Retired storages are\n * marked `(retired)`.\n */\nexport const formatStoragesLine = (params: StoragesLineParams): string => {\n const parts = [`${DEFAULT_TENANT_STORAGE_ID} = ${params.defaultFamily} (root)`];\n for (const storage of params.storages) {\n const retired = storage.retired ? \" (retired)\" : \"\";\n parts.push(`${storage.id} = ${storage.family} \"${storage.label}\"${retired}`);\n }\n return `Storages: ${parts.join(\"; \")}`;\n};\n"],"names":["DEFAULT_TENANT_STORAGE_ID","TENANT_STORAGE_ID","tenantStorageIdentitySchema","z","assertTenantStorageIds","declarations","seen","Map","declaration","id","component","GracefulError","other","formatStoragesLine","params","parts","storage","retired"],"mappings":";;AAOO,MAAMA,4BAA4B;AAGzC,MAAMC,oBAAoB;AAMnB,MAAMC,8BAA8B;IACvC,IAAIC,EAAAA,MACO,GACN,QAAQ,CACL;IAER,OAAOA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,SAASA,EAAAA,OACG,GACP,QAAQ,GACR,QAAQ,CACL;AAEZ;AAkBO,MAAMC,yBAAyB,CAACC;IACnC,MAAMC,OAAO,IAAIC;IACjB,KAAK,MAAMC,eAAeH,aAAc;QACpC,MAAM,EAAEI,EAAE,EAAEC,SAAS,EAAE,GAAGF;QAC1B,IAAIC,OAAOT,2BACP,MAAM,IAAIW,cACN,GAAGD,UAAU,mBAAmB,EAAEV,0BAA0B,kHAAkH,CAAC;QAGvL,IAAI,CAACC,kBAAkB,IAAI,CAACQ,KACxB,MAAM,IAAIE,cACN,GAAGD,UAAU,aAAa,EAAED,GAAG,+FAA+F,CAAC;QAGvI,MAAMG,QAAQN,KAAK,GAAG,CAACG;QACvB,IAAIG,OACA,MAAM,IAAID,cACN,GAAGC,MAAM,KAAK,EAAEF,UAAU,mBAAmB,EAAED,GAAG,uCAAuC,CAAC;QAGlGH,KAAK,GAAG,CAACG,IAAIC;IACjB;AACJ;AAaO,MAAMG,qBAAqB,CAACC;IAC/B,MAAMC,QAAQ;QAAC,GAAGf,0BAA0B,GAAG,EAAEc,OAAO,aAAa,CAAC,OAAO,CAAC;KAAC;IAC/E,KAAK,MAAME,WAAWF,OAAO,QAAQ,CAAE;QACnC,MAAMG,UAAUD,QAAQ,OAAO,GAAG,eAAe;QACjDD,MAAM,IAAI,CAAC,GAAGC,QAAQ,EAAE,CAAC,GAAG,EAAEA,QAAQ,MAAM,CAAC,EAAE,EAAEA,QAAQ,KAAK,CAAC,CAAC,EAAEC,SAAS;IAC/E;IACA,OAAO,CAAC,UAAU,EAAEF,MAAM,IAAI,CAAC,OAAO;AAC1C"}
|