export declare const apiSnippetsTemplate = "// Pure, isomorphic request-to-snippet generators for the API playground.\n// Given the fully-resolved request, produce copy-pasteable cURL / fetch /\n// requests examples. Secret redaction is the caller's responsibility: pass\n// already-redacted header values when secrets should not appear.\n\nexport interface SnippetRequest {\n method: string;\n url: string;\n headers: Record;\n body?: string | null;\n}\n\nexport type SnippetLanguage = \"curl\" | \"javascript\" | \"python\";\n\nexport interface SnippetTab {\n label: string;\n code: string;\n language: string;\n}\n\n// A literal backslash, built without writing one (keeps escaping simple).\nconst BACKSLASH = String.fromCharCode(92);\n\n// POSIX single-quote a shell argument: wrap in quotes, and represent any inner\n// single quote as '\\'' by ending the quote, adding an escaped quote, reopening.\nfunction shellQuote(value: string): string {\n const escaped = value.split(\"'\").join(\"'\" + BACKSLASH + \"''\");\n return \"'\" + escaped + \"'\";\n}\n\nfunction toCurl(req: SnippetRequest): string {\n const parts: string[] = [\"curl\", \"-X\", req.method, shellQuote(req.url)];\n for (const [key, value] of Object.entries(req.headers)) {\n parts.push(\"-H\", shellQuote(key + \": \" + value));\n }\n if (req.body) {\n parts.push(\"--data\", shellQuote(req.body));\n }\n return parts.join(\" \");\n}\n\nfunction toFetch(req: SnippetRequest): string {\n const options: {\n method: string;\n headers?: Record;\n body?: string;\n } = { method: req.method };\n if (Object.keys(req.headers).length > 0) options.headers = req.headers;\n if (req.body) options.body = req.body;\n return (\n \"const response = await fetch(\" +\n JSON.stringify(req.url) +\n \", \" +\n JSON.stringify(options, null, 2) +\n \");\"\n );\n}\n\nfunction toPython(req: SnippetRequest): string {\n const lines: string[] = [\"import requests\", \"\"];\n lines.push(\"response = requests.\" + req.method.toLowerCase() + \"(\");\n lines.push(\" \" + JSON.stringify(req.url) + \",\");\n if (Object.keys(req.headers).length > 0) {\n lines.push(\" headers=\" + JSON.stringify(req.headers) + \",\");\n }\n if (req.body) {\n lines.push(\" data=\" + JSON.stringify(req.body) + \",\");\n }\n lines.push(\")\");\n lines.push(\"print(response.status_code, response.text)\");\n return lines.join(\"\\n\");\n}\n\nexport function buildSnippets(\n req: SnippetRequest,\n languages: SnippetLanguage[],\n): SnippetTab[] {\n const tabs: SnippetTab[] = [];\n for (const language of languages) {\n if (language === \"curl\") {\n tabs.push({ label: \"cURL\", code: toCurl(req), language: \"bash\" });\n } else if (language === \"javascript\") {\n tabs.push({\n label: \"JavaScript\",\n code: toFetch(req),\n language: \"javascript\",\n });\n } else if (language === \"python\") {\n tabs.push({ label: \"Python\", code: toPython(req), language: \"python\" });\n }\n }\n return tabs;\n}\n";