@prisma-next/cli 0.16.0-dev.6 → 0.16.0-dev.8
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/dist/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { createDbSchemaCommand } from "./commands/db-schema.mjs";
|
|
|
7
7
|
import { createDbSignCommand } from "./commands/db-sign.mjs";
|
|
8
8
|
import { createDbUpdateCommand } from "./commands/db-update.mjs";
|
|
9
9
|
import { t as createDbVerifyCommand } from "./db-verify-BpwCMyWJ.mjs";
|
|
10
|
-
import { t as createFormatCommand } from "./format-
|
|
10
|
+
import { t as createFormatCommand } from "./format-CFLZv_zU.mjs";
|
|
11
11
|
import { t as createMigrationListCommand } from "./migration-list-cnSKilYH.mjs";
|
|
12
12
|
import { createMigrateCommand } from "./commands/migrate.mjs";
|
|
13
13
|
import { t as createMigrationCheckCommand } from "./migration-check-Biu1YZXu.mjs";
|
|
@@ -25,7 +25,7 @@ import { ensureInstallationId, readUserConfig, resolveGating, runTelemetry, user
|
|
|
25
25
|
import { distance } from "closest-match";
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
27
27
|
//#region package.json
|
|
28
|
-
var version = "0.16.0-dev.
|
|
28
|
+
var version = "0.16.0-dev.8";
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/commands/init/templates/code-templates.ts
|
|
31
31
|
function targetPackageName(target) {
|
package/dist/exports/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as createContractEmitCommand } from "../contract-emit-DzOkTs11.mjs";
|
|
2
|
-
import { t as createFormatCommand } from "../format-
|
|
2
|
+
import { t as createFormatCommand } from "../format-CFLZv_zU.mjs";
|
|
3
3
|
import { join, resolve } from "pathe";
|
|
4
4
|
import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
@@ -6,7 +6,8 @@ import { notOk, ok } from "@prisma-next/utils/result";
|
|
|
6
6
|
import { relative, resolve } from "pathe";
|
|
7
7
|
import { readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import { EOL } from "node:os";
|
|
9
|
-
import {
|
|
9
|
+
import { format } from "@prisma-next/psl-parser/format";
|
|
10
|
+
import { isStructuredError } from "@prisma-next/utils/structured-error";
|
|
10
11
|
//#region src/control-api/operations/format.ts
|
|
11
12
|
function resolveNewline(formatterNewline, eol) {
|
|
12
13
|
if (formatterNewline !== void 0) return formatterNewline;
|
|
@@ -42,10 +43,10 @@ async function executeFormat(options) {
|
|
|
42
43
|
try {
|
|
43
44
|
formatted = format(contents, formatOptions);
|
|
44
45
|
} catch (error) {
|
|
45
|
-
if (error
|
|
46
|
+
if (isStructuredError(error) && error.code === "PSL.PARSE_FAILED") return notOk(errorRuntime("Cannot format PSL with parse errors", {
|
|
46
47
|
why: error.message,
|
|
47
48
|
fix: "Fix the parse errors in your schema and try again.",
|
|
48
|
-
meta: { diagnostics: error.diagnostics }
|
|
49
|
+
meta: { diagnostics: error.meta?.["diagnostics"] }
|
|
49
50
|
}));
|
|
50
51
|
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));
|
|
51
52
|
}
|
|
@@ -99,4 +100,4 @@ function createFormatCommand() {
|
|
|
99
100
|
//#endregion
|
|
100
101
|
export { createFormatCommand as t };
|
|
101
102
|
|
|
102
|
-
//# sourceMappingURL=format-
|
|
103
|
+
//# sourceMappingURL=format-CFLZv_zU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-CFLZv_zU.mjs","names":[],"sources":["../src/control-api/operations/format.ts","../src/commands/format.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { EOL } from 'node:os';\nimport { loadConfig } from '@prisma-next/config-loader';\nimport { type FormatOptions, format } from '@prisma-next/psl-parser/format';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { isStructuredError } from '@prisma-next/utils/structured-error';\nimport { CliStructuredError, errorRuntime, errorUnexpected } from '../../utils/cli-errors';\n\nexport interface FormatOperationOptions {\n readonly configPath?: string;\n readonly eol?: string;\n}\n\nexport interface FormatOperationResult {\n readonly formatted: boolean;\n readonly path?: string;\n}\n\nexport function resolveNewline(\n formatterNewline: 'LF' | 'CRLF' | undefined,\n eol: string,\n): 'LF' | 'CRLF' {\n if (formatterNewline !== undefined) {\n return formatterNewline;\n }\n return eol === '\\r\\n' ? 'CRLF' : 'LF';\n}\n\nexport async function executeFormat(\n options: FormatOperationOptions,\n): Promise<Result<FormatOperationResult, CliStructuredError>> {\n const eol = options.eol ?? EOL;\n\n let config: Awaited<ReturnType<typeof loadConfig>>;\n try {\n config = await loadConfig(options.configPath);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n const source = config.contract?.source;\n if (source?.sourceFormat !== 'psl') {\n return ok({ formatted: false });\n }\n\n const inputPath = source.inputs?.[0];\n if (inputPath === undefined) {\n return ok({ formatted: false });\n }\n\n let contents: string;\n try {\n contents = await readFile(inputPath, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to read contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} exists and is readable.`,\n }),\n );\n }\n\n const formatOptions: FormatOptions = {\n indent: config.formatter?.indent ?? 2,\n newline: resolveNewline(config.formatter?.newline, eol),\n };\n\n let formatted: string;\n try {\n formatted = format(contents, formatOptions);\n } catch (error) {\n if (isStructuredError(error) && error.code === 'PSL.PARSE_FAILED') {\n return notOk(\n errorRuntime('Cannot format PSL with parse errors', {\n why: error.message,\n fix: 'Fix the parse errors in your schema and try again.',\n meta: { diagnostics: error.meta?.['diagnostics'] },\n }),\n );\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n try {\n await writeFile(inputPath, formatted, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to write formatted contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} is writable.`,\n }),\n );\n }\n\n return ok({ formatted: true, path: inputPath });\n}\n","import { ifDefined } from '@prisma-next/utils/defined';\nimport { Command } from 'commander';\nimport { relative, resolve } from 'pathe';\nimport { executeFormat } from '../control-api/operations/format';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI } from '../utils/terminal-ui';\n\ninterface FormatCommandOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nexport function createFormatCommand(): Command {\n const command = new Command('format');\n setCommandDescriptions(\n command,\n 'Format your PSL contract source',\n 'Formats the Prisma schema (PSL) contract source declared in your config\\n' +\n '(contract.source.inputs[0]) in place. Only runs when contract.source.sourceFormat\\n' +\n \"is 'psl'; a TypeScript or unset source is left untouched. Indent and newline are\\n\" +\n 'read from the optional formatter config section, defaulting to two spaces and the\\n' +\n 'system newline.',\n );\n setCommandExamples(command, [\n 'prisma-next format',\n 'prisma-next format --config ./custom-config.ts',\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: FormatCommandOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n\n if (!flags.json && !flags.quiet) {\n const displayConfigPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n ui.stderr(\n formatStyledHeader({\n command: 'format',\n description: 'Format your PSL contract source',\n details: [{ label: 'config', value: displayConfigPath }],\n flags,\n }),\n );\n }\n\n const result = await executeFormat({ ...ifDefined('configPath', options.config) });\n\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n return;\n }\n if (flags.quiet) {\n return;\n }\n if (value.formatted) {\n ui.success(`Formatted ${relative(process.cwd(), value.path ?? '')}`);\n } else {\n ui.info('Nothing to format (contract source is not PSL).');\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,eACd,kBACA,KACe;CACf,IAAI,qBAAqB,KAAA,GACvB,OAAO;CAET,OAAO,QAAQ,SAAS,SAAS;AACnC;AAEA,eAAsB,cACpB,SAC4D;CAC5D,MAAM,MAAM,QAAQ,OAAO;CAE3B,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,WAAW,QAAQ,UAAU;CAC9C,SAAS,OAAO;EACd,IAAI,mBAAmB,GAAG,KAAK,GAC7B,OAAO,MAAM,KAAK;EAEpB,OAAO,MAAM,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,CAAC;CACtF;CAEA,MAAM,SAAS,OAAO,UAAU;CAChC,IAAI,QAAQ,iBAAiB,OAC3B,OAAO,GAAG,EAAE,WAAW,MAAM,CAAC;CAGhC,MAAM,YAAY,OAAO,SAAS;CAClC,IAAI,cAAc,KAAA,GAChB,OAAO,GAAG,EAAE,WAAW,MAAM,CAAC;CAGhC,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,SAAS,WAAW,OAAO;CAC9C,SAAS,OAAO;EACd,OAAO,MACL,aAAa,uCAAuC;GAClD,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAC1D,KAAK,cAAc,UAAU;EAC/B,CAAC,CACH;CACF;CAEA,MAAM,gBAA+B;EACnC,QAAQ,OAAO,WAAW,UAAU;EACpC,SAAS,eAAe,OAAO,WAAW,SAAS,GAAG;CACxD;CAEA,IAAI;CACJ,IAAI;EACF,YAAY,OAAO,UAAU,aAAa;CAC5C,SAAS,OAAO;EACd,IAAI,kBAAkB,KAAK,KAAK,MAAM,SAAS,oBAC7C,OAAO,MACL,aAAa,uCAAuC;GAClD,KAAK,MAAM;GACX,KAAK;GACL,MAAM,EAAE,aAAa,M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Q,EAAE,GAAG;QAEnE,GAAG,KAAK,iDAAiD;EAE7D,CAAC;EACD,QAAQ,KAAK,QAAQ;CACvB,CAAC;CAEH,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/cli",
|
|
3
|
-
"version": "0.16.0-dev.
|
|
3
|
+
"version": "0.16.0-dev.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@clack/prompts": "^1.7.0",
|
|
12
|
-
"@prisma-next/config": "0.16.0-dev.
|
|
13
|
-
"@prisma-next/config-loader": "0.16.0-dev.
|
|
14
|
-
"@prisma-next/contract": "0.16.0-dev.
|
|
15
|
-
"@prisma-next/emitter": "0.16.0-dev.
|
|
16
|
-
"@prisma-next/errors": "0.16.0-dev.
|
|
17
|
-
"@prisma-next/framework-components": "0.16.0-dev.
|
|
18
|
-
"@prisma-next/language-server": "0.16.0-dev.
|
|
19
|
-
"@prisma-next/migration-tools": "0.16.0-dev.
|
|
20
|
-
"@prisma-next/psl-parser": "0.16.0-dev.
|
|
21
|
-
"@prisma-next/psl-printer": "0.16.0-dev.
|
|
22
|
-
"@prisma-next/cli-telemetry": "0.16.0-dev.
|
|
23
|
-
"@prisma-next/utils": "0.16.0-dev.
|
|
12
|
+
"@prisma-next/config": "0.16.0-dev.8",
|
|
13
|
+
"@prisma-next/config-loader": "0.16.0-dev.8",
|
|
14
|
+
"@prisma-next/contract": "0.16.0-dev.8",
|
|
15
|
+
"@prisma-next/emitter": "0.16.0-dev.8",
|
|
16
|
+
"@prisma-next/errors": "0.16.0-dev.8",
|
|
17
|
+
"@prisma-next/framework-components": "0.16.0-dev.8",
|
|
18
|
+
"@prisma-next/language-server": "0.16.0-dev.8",
|
|
19
|
+
"@prisma-next/migration-tools": "0.16.0-dev.8",
|
|
20
|
+
"@prisma-next/psl-parser": "0.16.0-dev.8",
|
|
21
|
+
"@prisma-next/psl-printer": "0.16.0-dev.8",
|
|
22
|
+
"@prisma-next/cli-telemetry": "0.16.0-dev.8",
|
|
23
|
+
"@prisma-next/utils": "0.16.0-dev.8",
|
|
24
24
|
"arktype": "^2.2.2",
|
|
25
25
|
"ci-info": "^4.3.1",
|
|
26
26
|
"clipanion": "4.0.0-rc.4",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"wrap-ansi": "^10.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@prisma-next/sql-contract": "0.16.0-dev.
|
|
40
|
-
"@prisma-next/sql-contract-emitter": "0.16.0-dev.
|
|
41
|
-
"@prisma-next/sql-contract-ts": "0.16.0-dev.
|
|
42
|
-
"@prisma-next/sql-operations": "0.16.0-dev.
|
|
43
|
-
"@prisma-next/sql-runtime": "0.16.0-dev.
|
|
44
|
-
"@prisma-next/test-utils": "0.16.0-dev.
|
|
45
|
-
"@prisma-next/tsconfig": "0.16.0-dev.
|
|
46
|
-
"@prisma-next/tsdown": "0.16.0-dev.
|
|
39
|
+
"@prisma-next/sql-contract": "0.16.0-dev.8",
|
|
40
|
+
"@prisma-next/sql-contract-emitter": "0.16.0-dev.8",
|
|
41
|
+
"@prisma-next/sql-contract-ts": "0.16.0-dev.8",
|
|
42
|
+
"@prisma-next/sql-operations": "0.16.0-dev.8",
|
|
43
|
+
"@prisma-next/sql-runtime": "0.16.0-dev.8",
|
|
44
|
+
"@prisma-next/test-utils": "0.16.0-dev.8",
|
|
45
|
+
"@prisma-next/tsconfig": "0.16.0-dev.8",
|
|
46
|
+
"@prisma-next/tsdown": "0.16.0-dev.8",
|
|
47
47
|
"@types/node": "25.9.4",
|
|
48
48
|
"tsdown": "0.22.8",
|
|
49
49
|
"typescript": "5.9.3",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { EOL } from 'node:os';
|
|
3
3
|
import { loadConfig } from '@prisma-next/config-loader';
|
|
4
|
-
import { type FormatOptions, format
|
|
4
|
+
import { type FormatOptions, format } from '@prisma-next/psl-parser/format';
|
|
5
5
|
import { notOk, ok, type Result } from '@prisma-next/utils/result';
|
|
6
|
+
import { isStructuredError } from '@prisma-next/utils/structured-error';
|
|
6
7
|
import { CliStructuredError, errorRuntime, errorUnexpected } from '../../utils/cli-errors';
|
|
7
8
|
|
|
8
9
|
export interface FormatOperationOptions {
|
|
@@ -71,12 +72,12 @@ export async function executeFormat(
|
|
|
71
72
|
try {
|
|
72
73
|
formatted = format(contents, formatOptions);
|
|
73
74
|
} catch (error) {
|
|
74
|
-
if (error
|
|
75
|
+
if (isStructuredError(error) && error.code === 'PSL.PARSE_FAILED') {
|
|
75
76
|
return notOk(
|
|
76
77
|
errorRuntime('Cannot format PSL with parse errors', {
|
|
77
78
|
why: error.message,
|
|
78
79
|
fix: 'Fix the parse errors in your schema and try again.',
|
|
79
|
-
meta: { diagnostics: error.diagnostics },
|
|
80
|
+
meta: { diagnostics: error.meta?.['diagnostics'] },
|
|
80
81
|
}),
|
|
81
82
|
);
|
|
82
83
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-CefCDzkw.mjs","names":[],"sources":["../src/control-api/operations/format.ts","../src/commands/format.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { EOL } from 'node:os';\nimport { loadConfig } from '@prisma-next/config-loader';\nimport { type FormatOptions, format, PslFormatError } from '@prisma-next/psl-parser/format';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { CliStructuredError, errorRuntime, errorUnexpected } from '../../utils/cli-errors';\n\nexport interface FormatOperationOptions {\n readonly configPath?: string;\n readonly eol?: string;\n}\n\nexport interface FormatOperationResult {\n readonly formatted: boolean;\n readonly path?: string;\n}\n\nexport function resolveNewline(\n formatterNewline: 'LF' | 'CRLF' | undefined,\n eol: string,\n): 'LF' | 'CRLF' {\n if (formatterNewline !== undefined) {\n return formatterNewline;\n }\n return eol === '\\r\\n' ? 'CRLF' : 'LF';\n}\n\nexport async function executeFormat(\n options: FormatOperationOptions,\n): Promise<Result<FormatOperationResult, CliStructuredError>> {\n const eol = options.eol ?? EOL;\n\n let config: Awaited<ReturnType<typeof loadConfig>>;\n try {\n config = await loadConfig(options.configPath);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n const source = config.contract?.source;\n if (source?.sourceFormat !== 'psl') {\n return ok({ formatted: false });\n }\n\n const inputPath = source.inputs?.[0];\n if (inputPath === undefined) {\n return ok({ formatted: false });\n }\n\n let contents: string;\n try {\n contents = await readFile(inputPath, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to read contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} exists and is readable.`,\n }),\n );\n }\n\n const formatOptions: FormatOptions = {\n indent: config.formatter?.indent ?? 2,\n newline: resolveNewline(config.formatter?.newline, eol),\n };\n\n let formatted: string;\n try {\n formatted = format(contents, formatOptions);\n } catch (error) {\n if (error instanceof PslFormatError) {\n return notOk(\n errorRuntime('Cannot format PSL with parse errors', {\n why: error.message,\n fix: 'Fix the parse errors in your schema and try again.',\n meta: { diagnostics: error.diagnostics },\n }),\n );\n }\n return notOk(errorUnexpected(error instanceof Error ? error.message : String(error)));\n }\n\n try {\n await writeFile(inputPath, formatted, 'utf-8');\n } catch (error) {\n return notOk(\n errorRuntime('Failed to write formatted contract source file', {\n why: error instanceof Error ? error.message : String(error),\n fix: `Check that ${inputPath} is writable.`,\n }),\n );\n }\n\n return ok({ formatted: true, path: inputPath });\n}\n","import { ifDefined } from '@prisma-next/utils/defined';\nimport { Command } from 'commander';\nimport { relative, resolve } from 'pathe';\nimport { executeFormat } from '../control-api/operations/format';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI } from '../utils/terminal-ui';\n\ninterface FormatCommandOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nexport function createFormatCommand(): Command {\n const command = new Command('format');\n setCommandDescriptions(\n command,\n 'Format your PSL contract source',\n 'Formats the Prisma schema (PSL) contract source declared in your config\\n' +\n '(contract.source.inputs[0]) in place. Only runs when contract.source.sourceFormat\\n' +\n \"is 'psl'; a TypeScript or unset source is left untouched. Indent and newline are\\n\" +\n 'read from the optional formatter config section, defaulting to two spaces and the\\n' +\n 'system newline.',\n );\n setCommandExamples(command, [\n 'prisma-next format',\n 'prisma-next format --config ./custom-config.ts',\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: FormatCommandOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n\n if (!flags.json && !flags.quiet) {\n const displayConfigPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n ui.stderr(\n formatStyledHeader({\n command: 'format',\n description: 'Format your PSL contract source',\n details: [{ label: 'config', value: displayConfigPath }],\n flags,\n }),\n );\n }\n\n const result = await executeFormat({ ...ifDefined('configPath', options.config) });\n\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n return;\n }\n if (flags.quiet) {\n return;\n }\n if (value.formatted) {\n ui.success(`Formatted ${relative(process.cwd(), value.path ?? '')}`);\n } else {\n ui.info('Nothing to format (contract source is not PSL).');\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,eACd,kBACA,KACe;CACf,IAAI,qBAAqB,KAAA,GACvB,O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