{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/create.ts","../../src/cli/generators/controller.ts","../../src/cli/generators/repository.ts","../../src/cli/generators/service.ts","../../src/cli/commands/make-docs.ts"],"sourcesContent":["#!/usr/bin/env bun\n\nimport { createCommand } from \"./commands/create.js\";\nimport { makeDocsCommand } from \"./commands/make-docs.js\";\n\nfunction printBanner() {\n\tconsole.log(`\n\\x1b[36m  Buntok CLI v0.3.0\\x1b[0m\n`);\n}\n\nfunction printUsage() {\n\tconsole.log(`\n\\x1b[36mUsage:\\x1b[0m\n  buntok <command> [arguments] [options]\n\n\\x1b[36mCommands:\\x1b[0m\n  create <entity>        Generate all files for entity (repo, service, controller)\n  make:docs              Generate OpenAPI documentation automatically\n\n\\x1b[36mOptions (for create command):\\x1b[0m\n  --repo                 Generate only repository\n  --service              Generate only service\n  --controller           Generate only controller\n\n\\x1b[36mExamples:\\x1b[0m\n  buntok create user                    # Generate all files for user entity\n  buntok create user --repo --service   # Generate repository and service only\n  buntok make:docs                      # Generate OpenAPI documentation\n`);\n}\n\nexport async function main() {\n\tconst args = process.argv.slice(2);\n\tconst command = args[0];\n\tconst arg1 = args[1];\n\n\tif (!command) {\n\t\tprintBanner();\n\t\tprintUsage();\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tswitch (command) {\n\t\tcase \"create\":\n\t\t\tif (!arg1) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t\"\\x1b[31mError: entity name is required for create command\\x1b[0m\",\n\t\t\t\t);\n\t\t\t\tprocess.exitCode = 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait createCommand(arg1, args.slice(2));\n\t\t\tbreak;\n\t\tcase \"make:docs\":\n\t\t\tawait makeDocsCommand();\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tconsole.error(`\\x1b[31mUnknown command: ${command}\\x1b[0m`);\n\t\t\tprintUsage();\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn;\n\t}\n}\n\nmain();\n","import { existsSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { generateController } from \"../generators/controller.js\";\nimport { generateRepository } from \"../generators/repository.js\";\nimport { generateService } from \"../generators/service.js\";\n\ninterface CreateOptions {\n\trepo: boolean;\n\tservice: boolean;\n\tcontroller: boolean;\n\tall: boolean;\n}\n\nfunction parseOptions(args: string[]): CreateOptions {\n\tconst options: CreateOptions = {\n\t\trepo: false,\n\t\tservice: false,\n\t\tcontroller: false,\n\t\tall: true,\n\t};\n\n\tfor (const arg of args) {\n\t\tswitch (arg) {\n\t\t\tcase \"--repo\":\n\t\t\t\toptions.repo = true;\n\t\t\t\toptions.all = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--service\":\n\t\t\t\toptions.service = true;\n\t\t\t\toptions.all = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--controller\":\n\t\t\t\toptions.controller = true;\n\t\t\t\toptions.all = false;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// If any specific option is set, don't generate all\n\tif (!options.all) {\n\t\treturn options;\n\t}\n\n\t// Generate all by default\n\treturn {\n\t\trepo: true,\n\t\tservice: true,\n\t\tcontroller: true,\n\t\tall: false,\n\t};\n}\n\nasync function ensureDirectories(_entityName: string) {\n\tconst dirs = [\"src/repositories\", \"src/services\", \"src/controllers\"];\n\n\tawait Promise.all(\n\t\tdirs.map(async (dir) => {\n\t\t\tif (!existsSync(dir)) {\n\t\t\t\tawait fs.mkdir(dir, { recursive: true });\n\t\t\t}\n\t\t}),\n\t);\n}\n\nfunction toPascalCase(str: string): string {\n\treturn str\n\t\t.split(/[-_]/)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\n}\n\nexport async function createCommand(entityName: string, args: string[]) {\n\tconst options = parseOptions(args);\n\tconst pascalName = toPascalCase(entityName);\n\n\tconsole.log(`\\n\\x1b[36mCreating ${pascalName} entity...\\x1b[0m\\n`);\n\n\t// Ensure directories exist\n\tawait ensureDirectories(entityName);\n\n\tconst results: string[] = [];\n\tconst generatedFiles: string[] = [];\n\tconst tasks: Promise<void>[] = [];\n\n\t// Helper to generate file asynchronously\n\tconst generateFile = async (\n\t\tpath: string,\n\t\tcontentGenerator: () => string,\n\t\ttype: string,\n\t) => {\n\t\tif (!existsSync(path)) {\n\t\t\tawait fs.writeFile(path, contentGenerator());\n\t\t\tresults.push(`✓ ${type}: ${path}`);\n\t\t\tgeneratedFiles.push(path);\n\t\t} else {\n\t\t\tresults.push(`• ${type}: ${path} (already exists)`);\n\t\t}\n\t};\n\n\tif (options.repo) {\n\t\ttasks.push(\n\t\t\tgenerateFile(\n\t\t\t\tjoin(\"src/repositories\", `${entityName}.repository.ts`),\n\t\t\t\t() => generateRepository(entityName, pascalName),\n\t\t\t\t\"Repository\",\n\t\t\t),\n\t\t);\n\t}\n\n\tif (options.service) {\n\t\ttasks.push(\n\t\t\tgenerateFile(\n\t\t\t\tjoin(\"src/services\", `${entityName}.service.ts`),\n\t\t\t\t() => generateService(entityName, pascalName, options.repo),\n\t\t\t\t\"Service\",\n\t\t\t),\n\t\t);\n\t}\n\n\tif (options.controller) {\n\t\ttasks.push(\n\t\t\tgenerateFile(\n\t\t\t\tjoin(\"src/controllers\", `${entityName}.controller.ts`),\n\t\t\t\t() => generateController(entityName, pascalName, options.service),\n\t\t\t\t\"Controller\",\n\t\t\t),\n\t\t);\n\t}\n\n\t// Execute all file generations concurrently\n\tawait Promise.all(tasks);\n\n\t// Auto-format generated files with Biome if available\n\tif (generatedFiles.length > 0) {\n\t\tconst biomeProc = Bun.spawnSync(\n\t\t\t[\"bunx\", \"biome\", \"format\", \"--write\", ...generatedFiles],\n\t\t\t{\n\t\t\t\tstdio: [\"ignore\", \"ignore\", \"ignore\"],\n\t\t\t},\n\t\t);\n\t\tif (biomeProc.exitCode === 0) {\n\t\t\tconsole.log(\n\t\t\t\t\"\\x1b[90m✨ Auto-formatted generated files with Biome\\x1b[0m\\n\",\n\t\t\t);\n\t\t}\n\t}\n\n\t// Print results\n\tconsole.log(\"\\x1b[32mGenerated files:\\x1b[0m\");\n\tfor (const result of results.sort()) {\n\t\tconsole.log(`  ${result}`);\n\t}\n\n\tconsole.log(`\n\\x1b[36mNext steps:\\x1b[0m\n  1. Register your controller in src/index.ts:\n     \\x1b[32mimport { ${pascalName}Controller } from \"./controllers/${entityName}.controller\";\\x1b[0m\n     \\x1b[32mapp.registerController(${pascalName}Controller);\\x1b[0m\n  2. Start dev server: \\x1b[33mbun run dev\\x1b[0m\n`);\n}\n","export function generateController(\n\tentityName: string,\n\tpascalName: string,\n\twithService: boolean = true,\n): string {\n\tif (withService) {\n\t\treturn `import { Controller, Get, Post, Put, Delete, Use, zResponse, z } from \"@buntok/core\";\nimport type { Context } from \"@buntok/core\";\nimport { ${pascalName}Service } from \"../services/${entityName}.service\";\n\n@Controller(\"/${entityName}s\")\nexport class ${pascalName}Controller {\n  private service: ${pascalName}Service;\n\n  constructor() {\n    this.service = new ${pascalName}Service();\n  }\n\n  @Get(\"/\")\n  async getAll(ctx: Context) {\n    const items = await this.service.getAll();\n    return ctx.success(items, \"Records retrieved successfully\");\n  }\n\n  @Get(\"/:id\")\n  async getById(ctx: Context) {\n    const item = await this.service.getById(ctx.params.id);\n    return ctx.success(item, \"Record retrieved successfully\");\n  }\n\n  @Post(\"/\")\n  async create(ctx: Context) {\n    const data = await ctx.body<any>();\n    const item = await this.service.create(data);\n    return ctx.success(item, \"Record created successfully\", 201);\n  }\n\n  @Put(\"/:id\")\n  async update(ctx: Context) {\n    const data = await ctx.body<any>();\n    const item = await this.service.update(ctx.params.id, data);\n    return ctx.success(item, \"Record updated successfully\");\n  }\n\n  @Delete(\"/:id\")\n  async delete(ctx: Context) {\n    await this.service.delete(ctx.params.id);\n    return ctx.success(null, \"Record deleted successfully\");\n  }\n}\n`;\n\t}\n\n\treturn `import { Controller, Get, Post, Put, Delete, zResponse, z } from \"@buntok/core\";\nimport type { Context } from \"@buntok/core\";\n\n@Controller(\"/${entityName}s\")\nexport class ${pascalName}Controller {\n  @Get(\"/\")\n  async getAll(ctx: Context) {\n    return ctx.success([], \"Records retrieved successfully\");\n  }\n\n  @Get(\"/:id\")\n  async getById(ctx: Context) {\n    return ctx.success({ id: ctx.params.id }, \"Record retrieved successfully\");\n  }\n\n  @Post(\"/\")\n  async create(ctx: Context) {\n    const data = await ctx.body<any>();\n    return ctx.success(data, \"Record created successfully\", 201);\n  }\n\n  @Put(\"/:id\")\n  async update(ctx: Context) {\n    const data = await ctx.body<any>();\n    return ctx.success({ id: ctx.params.id, ...data }, \"Record updated successfully\");\n  }\n\n  @Delete(\"/:id\")\n  async delete(ctx: Context) {\n    return ctx.success(null, \"Record deleted successfully\");\n  }\n}\n`;\n}\n","export function generateRepository(\n\tentityName: string,\n\tpascalName: string,\n): string {\n\treturn `import { BaseRepository } from \"@buntok/prisma\";\nimport type { ${pascalName} } from \"../types/${entityName}\";\n\nexport class ${pascalName}Repository extends BaseRepository<${pascalName}> {\n  // Define your table name and methods here\n  // Example:\n  // async findAll(): Promise<${pascalName}[]> {\n  //   return this.delegate.findMany();\n  // }\n}\n`;\n}\n","export function generateService(\n\tentityName: string,\n\tpascalName: string,\n\twithRepo: boolean = true,\n): string {\n\tif (withRepo) {\n\t\treturn `import { BaseService } from \"@buntok/core\";\nimport { ${pascalName}Repository } from \"../repositories/${entityName}.repository\";\nimport type { ${pascalName} } from \"../types/${entityName}\";\nimport { NotFoundError } from \"@buntok/core\";\n\nexport class ${pascalName}Service extends BaseService<${pascalName}> {\n  private repository: ${pascalName}Repository;\n\n  constructor() {\n    super();\n    this.repository = new ${pascalName}Repository();\n  }\n\n  async getAll(): Promise<${pascalName}[]> {\n    return this.repository.findAll();\n  }\n\n  async getById(id: string): Promise<${pascalName}> {\n    const ${entityName} = await this.repository.findById(id);\n    if (!${entityName}) {\n      throw new NotFoundError(\"${pascalName} not found\");\n    }\n    return ${entityName};\n  }\n\n  async create(data: ${pascalName}): Promise<${pascalName}> {\n    return this.repository.create(data);\n  }\n\n  async update(id: string, data: Partial<${pascalName}>): Promise<${pascalName}> {\n    const ${entityName} = await this.repository.update(id, data);\n    if (!${entityName}) {\n      throw new NotFoundError(\"${pascalName} not found\");\n    }\n    return ${entityName};\n  }\n\n  async delete(id: string): Promise<boolean> {\n    const deleted = await this.repository.delete(id);\n    if (!deleted) {\n      throw new NotFoundError(\"${pascalName} not found\");\n    }\n    return true;\n  }\n}\n`;\n\t}\n\n\treturn `export class ${pascalName}Service {\n  async getAll(): Promise<any[]> {\n    return [];\n  }\n\n  async getById(id: string): Promise<any> {\n    return { id };\n  }\n\n  async create(data: any): Promise<any> {\n    return data;\n  }\n\n  async update(id: string, data: any): Promise<any> {\n    return { id, ...data };\n  }\n\n  async delete(id: string): Promise<boolean> {\n    return true;\n  }\n}\n`;\n}\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n\textendZodWithOpenApi,\n\tOpenAPIRegistry,\n\tOpenApiGeneratorV3,\n} from \"@asteasolutions/zod-to-openapi\";\nimport { z } from \"zod\";\n\nextendZodWithOpenApi(z);\n\n/**\n * Recursively walk a Zod schema and replace any type that zod-to-openapi\n * cannot handle (e.g. ZodFile from Zod v4) with a safe fallback so that\n * docs generation never crashes on an unsupported schema node.\n */\n// biome-ignore lint/suspicious/noExplicitAny: schema introspection requires any\nfunction sanitizeSchema(schema: any): any {\n\tif (!schema || typeof schema !== \"object\" || !schema._def) return schema;\n\n\tconst typeName: string = schema._def?.typeName ?? schema._def?.type ?? \"\";\n\n\t// ZodFile (Zod v4) → OpenAPI string format:binary\n\tif (typeName === \"ZodFile\" || typeName === \"file\") {\n\t\treturn z.string().openapi({ format: \"binary\", description: \"Binary file\" });\n\t}\n\n\t// For all other types, return as-is — zod-to-openapi handles them\n\t// Only recurse into containers we know how to handle safely\n\tif (typeName === \"ZodObject\" || typeName === \"object\") {\n\t\tconst shape =\n\t\t\ttypeof schema._def.shape === \"function\"\n\t\t\t\t? schema._def.shape()\n\t\t\t\t: (schema._def.shape ?? {});\n\t\tconst newShape: Record<string, unknown> = {};\n\t\tfor (const [key, value] of Object.entries(shape)) {\n\t\t\tnewShape[key] = sanitizeSchema(value);\n\t\t}\n\t\treturn z.object(newShape as Record<string, z.ZodTypeAny>);\n\t}\n\n\tif (typeName === \"ZodArray\" || typeName === \"array\") {\n\t\tconst element = schema._def?.element ?? schema._def?.type;\n\t\treturn z.array(sanitizeSchema(element));\n\t}\n\n\tif (typeName === \"ZodOptional\" || typeName === \"optional\") {\n\t\treturn sanitizeSchema(schema._def.innerType).optional();\n\t}\n\tif (typeName === \"ZodNullable\" || typeName === \"nullable\") {\n\t\treturn sanitizeSchema(schema._def.innerType).nullable();\n\t}\n\n\t// Default: return original schema (don't reconstruct unknown types)\n\treturn schema;\n}\n\nexport async function makeDocsCommand() {\n\tconsole.log(\"\\x1b[36mGenerating OpenAPI documentation...\\x1b[0m\");\n\n\t// Prevent the user's app from starting its HTTP server during import\n\tprocess.env.BUNTOK_DOCS_BUILD = \"1\";\n\n\tconst entryPath = resolve(process.cwd(), \"src/index.ts\");\n\n\ttry {\n\t\tconsole.log(`\\x1b[90mLoading app from ${entryPath}...\\x1b[0m`);\n\n\t\tconst userApp = await import(pathToFileURL(entryPath).href);\n\t\tconst appInstance = userApp.app || userApp.default;\n\n\t\tif (!appInstance?.openApiDocs) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Could not find an exported 'app' instance in src/index.ts. Make sure you export your app: `export const app = new App();`\",\n\t\t\t);\n\t\t}\n\n\t\tconst registry = new OpenAPIRegistry();\n\n\t\tlet skipped = 0;\n\n\t\tfor (const doc of appInstance.openApiDocs) {\n\t\t\t// Convert express-style params /users/:id → OpenAPI /users/{id}\n\t\t\tconst openapiPath = doc.path.replace(/:([a-zA-Z0-9_]+)/g, \"{$1}\");\n\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: RouteConfig populated dynamically\n\t\t\tconst routeConfig: any = {\n\t\t\t\tmethod: doc.method,\n\t\t\t\tpath: openapiPath,\n\t\t\t\tresponses: {},\n\t\t\t};\n\n\t\t\tif (doc.request.params || doc.request.query || doc.request.body) {\n\t\t\t\trouteConfig.request = {};\n\t\t\t\tif (doc.request.params)\n\t\t\t\t\trouteConfig.request.params = sanitizeSchema(doc.request.params);\n\t\t\t\tif (doc.request.query)\n\t\t\t\t\trouteConfig.request.query = sanitizeSchema(doc.request.query);\n\t\t\t\tif (doc.request.body) {\n\t\t\t\t\tconst contentType = doc.request.bodyContentType || \"application/json\";\n\t\t\t\t\trouteConfig.request.body = {\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t[contentType]: { schema: sanitizeSchema(doc.request.body) },\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (doc.responses.length > 0) {\n\t\t\t\tfor (const res of doc.responses) {\n\t\t\t\t\trouteConfig.responses[res.status.toString()] = {\n\t\t\t\t\t\tdescription: res.description,\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\"application/json\": { schema: sanitizeSchema(res.schema) },\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trouteConfig.responses[\"200\"] = { description: \"Success\" };\n\t\t\t}\n\n\t\t\t// Per-route error handling: one bad schema should not abort everything\n\t\t\ttry {\n\t\t\t\tregistry.registerPath(routeConfig);\n\t\t\t} catch (err) {\n\t\t\t\tskipped++;\n\t\t\t\tconst label = `${doc.method.toUpperCase()} ${doc.path}`;\n\t\t\t\tif (err instanceof Error) {\n\t\t\t\t\tconsole.warn(`\\x1b[33m  ⚠ Skipping ${label}: ${err.message}\\x1b[0m`);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(`\\x1b[33m  ⚠ Skipping ${label}: unknown error\\x1b[0m`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst generator = new OpenApiGeneratorV3(registry.definitions);\n\t\tconst document = generator.generateDocument({\n\t\t\topenapi: \"3.0.0\",\n\t\t\tinfo: {\n\t\t\t\tversion: \"1.0.0\",\n\t\t\t\ttitle: \"Buntok API Documentation\",\n\t\t\t\tdescription: \"Auto-generated OpenAPI docs from Zod schemas\",\n\t\t\t},\n\t\t});\n\n\t\t// Output directory: public/docs/\n\t\tconst docsDir = resolve(process.cwd(), \"public/docs\");\n\t\tmkdirSync(docsDir, { recursive: true });\n\n\t\tconst swaggerPath = resolve(docsDir, \"swagger.json\");\n\t\twriteFileSync(swaggerPath, JSON.stringify(document, null, 2));\n\t\tconsole.log(\n\t\t\t`\\x1b[32m✔ OpenAPI JSON generated at public/docs/swagger.json\\x1b[0m`,\n\t\t);\n\n\t\t// Scalar UI — index.html so app.static(\"/docs\", \"./public/docs\") just works\n\t\tconst htmlPath = resolve(docsDir, \"index.html\");\n\t\tconst html = `<!doctype html>\n<html>\n  <head>\n    <title>API Reference</title>\n    <meta charset=\"utf-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n  </head>\n  <body>\n    <script id=\"api-reference\" data-url=\"/docs/swagger.json\"></script>\n    <script src=\"https://cdn.jsdelivr.net/npm/@scalar/api-reference\"></script>\n  </body>\n</html>`;\n\t\twriteFileSync(htmlPath, html);\n\t\tconsole.log(\n\t\t\t`\\x1b[32m✔ Scalar UI generated at public/docs/index.html\\x1b[0m`,\n\t\t);\n\n\t\tif (skipped > 0) {\n\t\t\tconsole.log(\n\t\t\t\t`\\x1b[33m  ${skipped} route(s) were skipped due to unsupported schema types.\\x1b[0m`,\n\t\t\t);\n\t\t\tconsole.log(\n\t\t\t\t`\\x1b[33m  Tip: annotate unsupported types with .openapi({ ... }) from @asteasolutions/zod-to-openapi.\\x1b[0m`,\n\t\t\t);\n\t\t}\n\n\t\tconsole.log(`\\n\\x1b[36mNext steps:\\x1b[0m`);\n\t\tconsole.log(\n\t\t\t`  1. Serve the docs directory: \\x1b[90mapp.static(\"/docs\", \"./public/docs\")\\x1b[0m`,\n\t\t);\n\t\tconsole.log(\n\t\t\t`  2. Visit \\x1b[90mhttp://localhost:1212/docs\\x1b[0m to view your API documentation`,\n\t\t);\n\t} catch (error) {\n\t\tconsole.error(\"\\x1b[31mFailed to generate docs:\\x1b[0m\");\n\t\tconsole.error(error);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA2B;AAC3B,sBAAe;AACf,uBAAqB;;;ACFd,SAAS,mBACf,YACA,YACA,cAAuB,MACd;AACT,MAAI,aAAa;AAChB,WAAO;AAAA;AAAA,WAEE,UAAU,+BAA+B,UAAU;AAAA;AAAA,gBAE9C,UAAU;AAAA,eACX,UAAU;AAAA,qBACJ,UAAU;AAAA;AAAA;AAAA,yBAGN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoClC;AAEA,SAAO;AAAA;AAAA;AAAA,gBAGQ,UAAU;AAAA,eACX,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BzB;;;ACtFO,SAAS,mBACf,YACA,YACS;AACT,SAAO;AAAA,gBACQ,UAAU,qBAAqB,UAAU;AAAA;AAAA,eAE1C,UAAU,qCAAqC,UAAU;AAAA;AAAA;AAAA,gCAGxC,UAAU;AAAA;AAAA;AAAA;AAAA;AAK1C;;;ACfO,SAAS,gBACf,YACA,YACA,WAAoB,MACX;AACT,MA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