@clarify-labs/renderer 0.10.3 → 0.11.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.
Files changed (80) hide show
  1. package/output/{ClarifyShell-UsefuuLS.cjs → ClarifyShell-BAjq876Z.cjs} +85 -82
  2. package/output/ClarifyShell-BAjq876Z.cjs.map +1 -0
  3. package/output/{ClarifyShell-Cq5Af46F.js → ClarifyShell-GoSXvgMg.js} +85 -82
  4. package/output/ClarifyShell-GoSXvgMg.js.map +1 -0
  5. package/output/{MermaidViewer-Db7qsyVk.cjs → MermaidViewer-BZ8ghcFP.cjs} +2 -2
  6. package/output/{MermaidViewer-Db7qsyVk.cjs.map → MermaidViewer-BZ8ghcFP.cjs.map} +1 -1
  7. package/output/{MermaidViewer-Bc9H25yK.js → MermaidViewer-CkIxyqtf.js} +2 -2
  8. package/output/{MermaidViewer-Bc9H25yK.js.map → MermaidViewer-CkIxyqtf.js.map} +1 -1
  9. package/output/{OpenApiOperation-BZWeCbvy.js → OpenApiOperation-C2vJztWZ.js} +1536 -211
  10. package/output/OpenApiOperation-C2vJztWZ.js.map +1 -0
  11. package/output/{OpenApiOperation-DbZjxIuj.cjs → OpenApiOperation-D-5uE5v7.cjs} +1539 -208
  12. package/output/OpenApiOperation-D-5uE5v7.cjs.map +1 -0
  13. package/output/{PageActions-Dg1l9KB1.cjs → PageActions-DJRXlGhz.cjs} +16 -16
  14. package/output/PageActions-DJRXlGhz.cjs.map +1 -0
  15. package/output/{PageActions-BQeEmXbT.js → PageActions-bugd7GZh.js} +16 -16
  16. package/output/PageActions-bugd7GZh.js.map +1 -0
  17. package/output/{SearchDialog-DjKvqN7p.cjs → SearchDialog-8AdCRp6K.cjs} +3 -3
  18. package/output/{SearchDialog-DjKvqN7p.cjs.map → SearchDialog-8AdCRp6K.cjs.map} +1 -1
  19. package/output/{SearchDialog-B67VA0Ut.js → SearchDialog-CBJjDs_9.js} +3 -3
  20. package/output/{SearchDialog-B67VA0Ut.js.map → SearchDialog-CBJjDs_9.js.map} +1 -1
  21. package/output/app/PageFooter.d.ts +1 -1
  22. package/output/client.cjs +3 -3
  23. package/output/client.js +3 -3
  24. package/output/components/Tooltip.d.ts +1 -0
  25. package/output/core/i18n.d.ts +1 -1
  26. package/output/core/types.d.ts +37 -19
  27. package/output/{i18n-Bqth9d6Q.js → i18n-BPrC45nD.js} +98 -2
  28. package/output/i18n-BPrC45nD.js.map +1 -0
  29. package/output/{i18n-C-fReCj-.cjs → i18n-wXINKKV0.cjs} +98 -2
  30. package/output/i18n-wXINKKV0.cjs.map +1 -0
  31. package/output/index.cjs +26 -5
  32. package/output/index.cjs.map +1 -1
  33. package/output/index.d.ts +3 -3
  34. package/output/index.js +26 -6
  35. package/output/index.js.map +1 -1
  36. package/output/mdx/components.d.ts +2 -1
  37. package/output/openapi/components/EndpointMethodBadge.d.ts +6 -0
  38. package/output/openapi/components/EndpointSections.d.ts +2 -2
  39. package/output/openapi/components/ExamplePanels.d.ts +2 -2
  40. package/output/openapi/components/InlineListbox.d.ts +13 -0
  41. package/output/openapi/components/OpenApiAuthPanel.d.ts +12 -0
  42. package/output/openapi/components/OpenApiOperation.d.ts +1 -9
  43. package/output/openapi/components/OpenApiOperation.state.d.ts +4 -2
  44. package/output/openapi/components/OpenApiRequest.d.ts +18 -0
  45. package/output/openapi/components/OpenApiRequestFields.d.ts +25 -0
  46. package/output/openapi/components/OpenApiResponseViewer.d.ts +8 -0
  47. package/output/openapi/components/SendRequestButton.d.ts +9 -0
  48. package/output/openapi/components/helpers.d.ts +6 -1
  49. package/output/openapi/components/useOpenApiRequestState.d.ts +41 -0
  50. package/output/openapi/entry.d.ts +2 -0
  51. package/output/openapi/index.d.ts +2 -2
  52. package/output/openapi/lib/api-exchange-code.d.ts +8 -0
  53. package/output/openapi/lib/api-exchange.d.ts +30 -0
  54. package/output/openapi/lib/api-request.d.ts +24 -0
  55. package/output/openapi/lib/request-code.d.ts +2 -2
  56. package/output/openapi/lib/request-parameters.d.ts +5 -0
  57. package/output/openapi/store.d.ts +10 -0
  58. package/output/openapi/types.d.ts +4 -0
  59. package/output/preview.cjs +37 -27
  60. package/output/preview.cjs.map +1 -1
  61. package/output/preview.js +37 -27
  62. package/output/preview.js.map +1 -1
  63. package/output/{render-Dc9wxg_r.cjs → render-FICIzeXz.cjs} +2 -2
  64. package/output/{render-Dc9wxg_r.cjs.map → render-FICIzeXz.cjs.map} +1 -1
  65. package/output/{render-aS-w4fK4.js → render-XQiw_48i.js} +2 -2
  66. package/output/{render-aS-w4fK4.js.map → render-XQiw_48i.js.map} +1 -1
  67. package/output/renderer.css +547 -150
  68. package/output/server.cjs +2 -2
  69. package/output/server.js +2 -2
  70. package/output/theme/ThemeEditor.d.ts +8 -4
  71. package/output/theme/variables.d.ts +8 -4
  72. package/package.json +1 -1
  73. package/output/ClarifyShell-Cq5Af46F.js.map +0 -1
  74. package/output/ClarifyShell-UsefuuLS.cjs.map +0 -1
  75. package/output/OpenApiOperation-BZWeCbvy.js.map +0 -1
  76. package/output/OpenApiOperation-DbZjxIuj.cjs.map +0 -1
  77. package/output/PageActions-BQeEmXbT.js.map +0 -1
  78. package/output/PageActions-Dg1l9KB1.cjs.map +0 -1
  79. package/output/i18n-Bqth9d6Q.js.map +0 -1
  80. package/output/i18n-C-fReCj-.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
2
- const require_i18n = require("./i18n-C-fReCj-.cjs");
3
- const require_PageActions = require("./PageActions-Dg1l9KB1.cjs");
2
+ const require_i18n = require("./i18n-wXINKKV0.cjs");
3
+ const require_PageActions = require("./PageActions-DJRXlGhz.cjs");
4
4
  const require_remark = require("./remark-DTLbG8PK.cjs");
5
5
  let clsx = require("clsx");
6
6
  clsx = require_rolldown_runtime.__toESM(clsx, 1);
@@ -244,7 +244,7 @@ function Card(arg0) {
244
244
  }
245
245
  //#endregion
246
246
  //#region source/components/Mermaid.tsx
247
- var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-Db7qsyVk.cjs")));
247
+ var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-BZ8ghcFP.cjs")));
248
248
  var mermaidModulePromise;
249
249
  async function loadMermaid() {
250
250
  mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
@@ -391,7 +391,7 @@ function getCodePanelTitle(node, fallbackTitle) {
391
391
  fallbackTitle
392
392
  });
393
393
  }
394
- function CopyButton(arg0) {
394
+ function CopyButton$1(arg0) {
395
395
  const { code } = arg0;
396
396
  const t = require_i18n.useBuiltInText();
397
397
  const [copyCount, setCopyCount] = (0, react.useState)(0);
@@ -452,7 +452,7 @@ function CodePanel(arg0) {
452
452
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
453
453
  className: "clarify-code-pre overflow-x-auto p-4 text-xs text-(--clarify-code-text)",
454
454
  children
455
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { code: copyText })]
455
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton$1, { code: copyText })]
456
456
  })]
457
457
  });
458
458
  }
@@ -1049,28 +1049,61 @@ function Tabs(arg0) {
1049
1049
  //#endregion
1050
1050
  //#region source/components/Tooltip.tsx
1051
1051
  function Tooltip(arg0) {
1052
- const { content, children, side = "top", className, ...props } = arg0;
1052
+ const { content, children, side = "top", className, triggerClassName, ...props } = arg0;
1053
1053
  const contentId = (0, react.useId)();
1054
1054
  const [open, setOpen] = (0, react.useState)(false);
1055
+ const triggerRef = (0, react.useRef)(null);
1056
+ const tooltipRef = (0, react.useRef)(null);
1057
+ const [position, setPosition] = (0, react.useState)();
1058
+ (0, react.useEffect)(() => {
1059
+ if (!open) return;
1060
+ function updatePosition() {
1061
+ const bounds = triggerRef.current?.getBoundingClientRect();
1062
+ if (!bounds) return;
1063
+ setPosition({
1064
+ left: bounds.left + bounds.width / 2,
1065
+ top: side === "top" ? bounds.top - 8 : bounds.bottom + 8
1066
+ });
1067
+ }
1068
+ updatePosition();
1069
+ window.addEventListener("resize", updatePosition);
1070
+ window.addEventListener("scroll", updatePosition, true);
1071
+ return () => {
1072
+ window.removeEventListener("resize", updatePosition);
1073
+ window.removeEventListener("scroll", updatePosition, true);
1074
+ };
1075
+ }, [open, side]);
1076
+ (0, react.useEffect)(() => {
1077
+ const tooltip = tooltipRef.current;
1078
+ if (!tooltip || typeof tooltip.showPopover !== "function") return;
1079
+ if (open) tooltip.showPopover();
1080
+ else if (tooltip.matches(":popover-open")) tooltip.hidePopover();
1081
+ }, [open]);
1055
1082
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1056
- className: (0, clsx.default)("clarify-tooltip group relative inline-flex align-baseline", className),
1083
+ className: (0, clsx.default)("clarify-tooltip group inline-flex align-baseline", className),
1057
1084
  onMouseEnter: () => setOpen(true),
1058
1085
  onMouseLeave: () => setOpen(false),
1059
1086
  ...props,
1060
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1061
- tabIndex: 0,
1087
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1088
+ type: "button",
1089
+ ref: triggerRef,
1062
1090
  "aria-describedby": contentId,
1063
- className: "cursor-help rounded-sm border-b border-dotted border-current focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
1091
+ "aria-expanded": open,
1092
+ className: (0, clsx.default)("cursor-help appearance-none rounded-sm border-0 border-b border-dotted border-current bg-transparent p-0 font-inherit text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", triggerClassName),
1064
1093
  onFocus: () => setOpen(true),
1065
1094
  onBlur: () => setOpen(false),
1095
+ onClick: () => setOpen(true),
1066
1096
  onKeyDown: (event) => {
1067
1097
  if (event.key === "Escape") setOpen(false);
1068
1098
  },
1069
1099
  children
1070
1100
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1101
+ ref: tooltipRef,
1071
1102
  id: contentId,
1072
1103
  role: "tooltip",
1073
- className: (0, clsx.default)("pointer-events-none absolute left-1/2 z-30 w-max max-w-64 -translate-x-1/2 rounded-md bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", open ? "opacity-100" : "opacity-0", side === "top" ? "bottom-[calc(100%+0.5rem)]" : "top-[calc(100%+0.5rem)]"),
1104
+ popover: "manual",
1105
+ style: position,
1106
+ className: (0, clsx.default)("pointer-events-none fixed right-auto bottom-auto z-60 m-0 w-max max-w-64 -translate-x-1/2 rounded-md border-0 bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", side === "top" && "-translate-y-full", open && position ? "visible opacity-100" : "invisible opacity-0"),
1074
1107
  children: content
1075
1108
  })]
1076
1109
  });
@@ -1649,6 +1682,23 @@ function listOpenApiOperations(spec) {
1649
1682
  return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
1650
1683
  }
1651
1684
  //#endregion
1685
+ //#region source/openapi/components/EndpointMethodBadge.tsx
1686
+ var endpointMethodStyleVars = {
1687
+ GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
1688
+ POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
1689
+ PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
1690
+ PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
1691
+ DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
1692
+ WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
1693
+ };
1694
+ function EndpointMethodBadge(arg0) {
1695
+ const { method } = arg0;
1696
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1697
+ className: (0, clsx.default)("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
1698
+ children: method
1699
+ });
1700
+ }
1701
+ //#endregion
1652
1702
  //#region source/components/HighlightedCode.tsx
1653
1703
  var cssVariablesTheme = (0, shiki.createCssVariablesTheme)();
1654
1704
  function HighlightedCode(arg0) {
@@ -1706,6 +1756,15 @@ var snippetControlCharacters = [
1706
1756
  }
1707
1757
  ];
1708
1758
  var snippetGenerator = (0, _scalar_snippetz.snippetz)();
1759
+ function getAuthPlaceholder(name) {
1760
+ return `YOUR_${name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").toUpperCase() || "CREDENTIAL"}`;
1761
+ }
1762
+ function redactAuth(auth = []) {
1763
+ return auth.map((input) => ({
1764
+ ...input,
1765
+ value: getAuthPlaceholder(input.name)
1766
+ }));
1767
+ }
1709
1768
  function protectSnippetControlCharacters(value) {
1710
1769
  if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
1711
1770
  if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
@@ -1724,7 +1783,7 @@ function getDefaultServer(spec) {
1724
1783
  function getDefaultWebhookServer() {
1725
1784
  return { url: "https://webhook.example.com" };
1726
1785
  }
1727
- function expandServerUrl(server, serverVariables = {}) {
1786
+ function expandServerUrl$1(server, serverVariables = {}) {
1728
1787
  return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
1729
1788
  const fallback = server.variables?.[name]?.default ?? name;
1730
1789
  return serverVariables[name] ?? fallback;
@@ -1732,16 +1791,16 @@ function expandServerUrl(server, serverVariables = {}) {
1732
1791
  }
1733
1792
  function buildOperationUrl(input) {
1734
1793
  const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
1735
- return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
1794
+ return joinPath(expandServerUrl$1(input.server ?? defaultServer, input.serverVariables), input.path);
1736
1795
  }
1737
- function getQueryString(parameters, auth) {
1796
+ function getQueryString(parameters, auth = []) {
1738
1797
  const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
1739
1798
  name: parameter.name,
1740
1799
  value: encodeUrlPlaceholders(`{${parameter.name}}`)
1741
1800
  }));
1742
- if (auth?.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) queryString.push({
1743
- name: auth.scheme.name,
1744
- value: auth.value
1801
+ for (const input of auth) if (input.scheme.type === "apiKey" && input.scheme.in === "query" && input.scheme.name) queryString.push({
1802
+ name: input.scheme.name,
1803
+ value: input.value
1745
1804
  });
1746
1805
  return queryString;
1747
1806
  }
@@ -1789,15 +1848,14 @@ function getAuthorizationValue(auth) {
1789
1848
  if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
1790
1849
  if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
1791
1850
  }
1792
- function getAuthHeaders(auth) {
1793
- if (!auth) return {};
1851
+ function getAuthHeader(auth) {
1794
1852
  if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
1795
1853
  const authorization = getAuthorizationValue(auth);
1796
1854
  return authorization ? { Authorization: authorization } : {};
1797
1855
  }
1798
- function getRequestHeaders(requestContent, auth) {
1856
+ function getRequestHeaders(requestContent, auth = []) {
1799
1857
  return {
1800
- ...getAuthHeaders(auth),
1858
+ ...Object.assign({}, ...auth.map(getAuthHeader)),
1801
1859
  Accept: "application/json",
1802
1860
  ...requestContent ? { "Content-Type": requestContent.mediaType } : {}
1803
1861
  };
@@ -2115,6 +2173,10 @@ var requestSnippetOptions = [
2115
2173
  }
2116
2174
  ];
2117
2175
  function buildRequestCodeExamples(input) {
2176
+ const redactedInput = {
2177
+ ...input,
2178
+ auth: redactAuth(input.auth)
2179
+ };
2118
2180
  return requestSnippetOptions.map((option) => ({
2119
2181
  key: `${option.languageKey}:${option.client}`,
2120
2182
  title: option.title,
@@ -2122,7 +2184,7 @@ function buildRequestCodeExamples(input) {
2122
2184
  languageKey: option.languageKey,
2123
2185
  clientKey: option.client,
2124
2186
  clientTitle: option.clientTitle,
2125
- code: buildSnippet(input, option)
2187
+ code: buildSnippet(redactedInput, option)
2126
2188
  }));
2127
2189
  }
2128
2190
  //#endregion
@@ -2144,7 +2206,7 @@ function SelectControl(arg0) {
2144
2206
  className: wrapperClassName,
2145
2207
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
2146
2208
  "aria-label": label,
2147
- className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-control-background) px-2.5 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:border-white/20 hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-white/20 data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
2209
+ className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-code-border) bg-(--clarify-code-control-background) px-2.5 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:border-(--clarify-code-border) hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-(--clarify-code-border) data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
2148
2210
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2149
2211
  className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
2150
2212
  children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -2160,10 +2222,10 @@ function SelectControl(arg0) {
2160
2222
  })]
2161
2223
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
2162
2224
  anchor: "bottom end",
2163
- className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-code-surface) p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-(--clarify-code-border) [--anchor-gap:--spacing(1)] focus:outline-none",
2225
+ className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-code-surface) p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-(--clarify-code-border) [--anchor-gap:--spacing(1)] focus:outline-none",
2164
2226
  children: normalizedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
2165
2227
  value: option.value,
2166
- className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-control-text) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:bg-(--clarify-code-accent-background) data-selected:text-(--clarify-code-accent-text)",
2228
+ className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-control-text) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:bg-(--clarify-code-accent-background) data-selected:text-(--clarify-code-accent-text)",
2167
2229
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
2168
2230
  className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
2169
2231
  "aria-hidden": "true"
@@ -2277,12 +2339,17 @@ function getSecurityRequirements(spec, operation) {
2277
2339
  }
2278
2340
  function getAuthOptions(spec, operation) {
2279
2341
  const schemes = getSecuritySchemes(spec);
2280
- const requirements = getSecurityRequirements(spec, operation);
2281
- const names = new Set(requirements.flatMap((requirement) => Object.keys(requirement)));
2282
- return Array.from(names).map((name) => ({
2283
- name,
2284
- scheme: schemes[name]
2285
- })).filter((option) => Boolean(option.scheme));
2342
+ return getSecurityRequirements(spec, operation).map((requirement, index) => {
2343
+ const requirementSchemes = Object.keys(requirement).map((name) => ({
2344
+ name,
2345
+ scheme: schemes[name]
2346
+ })).filter((option) => Boolean(option.scheme));
2347
+ return {
2348
+ key: `requirement:${index}`,
2349
+ label: requirementSchemes.map((option) => option.name).join(" + "),
2350
+ schemes: requirementSchemes
2351
+ };
2352
+ });
2286
2353
  }
2287
2354
  function authPlaceholder(auth) {
2288
2355
  if (!auth) return "";
@@ -2315,7 +2382,7 @@ function getClientOptions(codeOptions, languageKey) {
2315
2382
  function ApiExampleCodeGroup(arg0) {
2316
2383
  const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, metaInToolbar = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
2317
2384
  const t = require_i18n.useBuiltInText();
2318
- const metaClassName = comfortableMeta ? "flex min-h-11 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4 py-2" : "flex h-9 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4";
2385
+ const metaClassName = comfortableMeta ? "flex min-h-10 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5 py-2" : "flex h-9 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5";
2319
2386
  const meta = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2320
2387
  tag ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
2321
2388
  label: t("openapi.status"),
@@ -2334,14 +2401,14 @@ function ApiExampleCodeGroup(arg0) {
2334
2401
  }) : null
2335
2402
  ] });
2336
2403
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2337
- className: "clarify-openai-example my-6 overflow-hidden rounded-2xl bg-(--clarify-code-background) shadow-md ring-1 ring-(--clarify-code-border)",
2404
+ className: "clarify-openai-example my-6 overflow-hidden rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-background) shadow-sm",
2338
2405
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2339
2406
  className: "not-prose",
2340
2407
  children: [
2341
2408
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2342
- className: "clarify-openai-example-header flex min-h-(--clarify-code-header-min-height) items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-4 py-2",
2409
+ className: "clarify-openai-example-header flex min-h-11 items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-3.5 py-1.5",
2343
2410
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2344
- className: "mr-auto min-w-16 truncate py-1 text-xs font-semibold text-(--clarify-code-text)",
2411
+ className: "mr-auto min-w-16 truncate py-1 text-sm font-semibold text-(--clarify-code-text)",
2345
2412
  children: title
2346
2413
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2347
2414
  className: "clarify-openai-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
@@ -2778,11 +2845,11 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
2778
2845
  };
2779
2846
  }
2780
2847
  function EnumValueNode(arg0) {
2781
- const { node, depth = 0 } = arg0;
2848
+ const { node } = arg0;
2782
2849
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
2783
- className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
2850
+ className: "clarify-schema-node m-0 p-0",
2784
2851
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2785
- className: (0, clsx.default)("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-(--clarify-schema-row-nested-width) px-2" : "w-full px-1"),
2852
+ className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
2786
2853
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2787
2854
  className: "min-w-0 flex-1",
2788
2855
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2816,7 +2883,7 @@ function SchemaNode(arg0) {
2816
2883
  });
2817
2884
  const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
2818
2885
  const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
2819
- const rowClassName = (0, clsx.default)("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-(--clarify-schema-row-nested-width) px-2" : "w-full px-1");
2886
+ const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
2820
2887
  const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2821
2888
  className: "min-w-0 flex-1",
2822
2889
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2844,7 +2911,7 @@ function SchemaNode(arg0) {
2844
2911
  children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-4 w-4" })
2845
2912
  }) : null] });
2846
2913
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
2847
- className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
2914
+ className: "clarify-schema-node m-0 p-0",
2848
2915
  children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2849
2916
  type: "button",
2850
2917
  "aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
@@ -2866,7 +2933,7 @@ function SchemaTree(arg0) {
2866
2933
  if (nodes.length === 0) return null;
2867
2934
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2868
2935
  role: "list",
2869
- className: (0, clsx.default)("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border) p-0", depth > 0 && "mt-2 rounded-lg bg-(--clarify-ui-subtle-background) px-2 py-1"),
2936
+ className: (0, clsx.default)("m-0 list-none p-0", depth === 0 ? "divide-y divide-(--clarify-theme-tokens-colors-border)" : "ml-2 border-l border-(--clarify-theme-tokens-colors-border) pl-2"),
2870
2937
  children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
2871
2938
  node,
2872
2939
  depth,
@@ -2879,7 +2946,7 @@ function SchemaProperties(arg0) {
2879
2946
  const root = getRootSchemaNode(spec, schema, defaultExpanded);
2880
2947
  if (!root || root.children.length === 0) return null;
2881
2948
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2882
- className: "clarify-schema-properties my-6",
2949
+ className: "clarify-schema-properties not-prose my-6",
2883
2950
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, { nodes: root.children })
2884
2951
  })] });
2885
2952
  }
@@ -2964,7 +3031,8 @@ function ResponseList(arg0) {
2964
3031
  response
2965
3032
  })
2966
3033
  })),
2967
- panelsClassName: "mt-4"
3034
+ className: "mt-4 mb-6",
3035
+ panelsClassName: "mt-5"
2968
3036
  })] });
2969
3037
  }
2970
3038
  //#endregion
@@ -2989,7 +3057,7 @@ function EndpointRequest(arg0) {
2989
3057
  })] });
2990
3058
  };
2991
3059
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderDescription(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2992
- className: "relative mt-6",
3060
+ className: "clarify-openapi-request-workspace relative mt-8 pt-6",
2993
3061
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2994
3062
  className: "w-full",
2995
3063
  children: [
@@ -3036,9 +3104,9 @@ function EndpointResponse(arg0) {
3036
3104
  const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
3037
3105
  const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
3038
3106
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3039
- className: "mt-6",
3107
+ className: "mt-10 pt-6",
3040
3108
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
3041
- className: "relative",
3109
+ className: "clarify-openapi-response-workspace relative",
3042
3110
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3043
3111
  className: "w-full",
3044
3112
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
@@ -3068,49 +3136,128 @@ function EndpointResponse(arg0) {
3068
3136
  }
3069
3137
  //#endregion
3070
3138
  //#region source/openapi/components/InlineListbox.tsx
3139
+ var defaultButtonClassName = "inline-flex min-w-0 items-center justify-between gap-1 border-0 bg-transparent font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-disabled:cursor-not-allowed data-open:bg-(--clarify-ui-active-background)";
3140
+ var optionsClassName = "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 [--anchor-gap:--spacing(1)] focus:outline-none";
3141
+ var optionClassName = "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-focus:text-(--clarify-ui-text-strong) data-selected:bg-(--clarify-ui-active-background) data-selected:text-(--clarify-ui-accent-text)";
3142
+ function OptionContent(arg0) {
3143
+ const { option } = arg0;
3144
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3145
+ className: "min-w-0",
3146
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3147
+ className: "block truncate",
3148
+ children: option.label
3149
+ }), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3150
+ className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
3151
+ children: option.description
3152
+ }) : null]
3153
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
3154
+ className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
3155
+ "aria-hidden": "true"
3156
+ })] });
3157
+ }
3071
3158
  function InlineListbox(arg0) {
3072
- const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className } = arg0;
3073
- const selected = options.find((option) => option.value === value) ?? options[0];
3159
+ const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false } = arg0;
3160
+ const selected = options.find((option) => option.value === value);
3074
3161
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
3075
- value: selected?.value ?? value,
3162
+ value,
3076
3163
  onChange,
3164
+ disabled,
3077
3165
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3078
- className: (0, clsx.default)("pointer-events-auto relative inline-flex min-w-0", className),
3166
+ className: (0, clsx.default)("pointer-events-auto relative inline-flex min-w-0 w-full", className),
3079
3167
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxButton, {
3080
3168
  "aria-label": label,
3081
- className: (0, clsx.default)(buttonClassName ?? "inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-ui-text-strong) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) data-open:border-(--clarify-ui-accent-border) data-open:bg-(--clarify-ui-active-background) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)", buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2.5 py-1.5 text-xs"),
3169
+ "aria-invalid": invalid || void 0,
3170
+ "aria-describedby": describedBy,
3171
+ className: (0, clsx.default)(buttonClassName ?? defaultButtonClassName, buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2 text-xs"),
3082
3172
  children: buttonContent ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3083
3173
  className: "truncate",
3084
- children: selected?.label ?? value
3174
+ children: selected?.label ?? (value || label)
3085
3175
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
3086
3176
  className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
3087
3177
  "aria-hidden": "true"
3088
3178
  })] })
3089
3179
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
3090
3180
  anchor: "bottom start",
3091
- className: "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 ring-1 ring-(--clarify-theme-tokens-colors-border) [--anchor-gap:--spacing(1)] focus:outline-none",
3092
- children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
3181
+ className: optionsClassName,
3182
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOption, {
3093
3183
  value: option.value,
3094
- className: "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-focus:text-(--clarify-ui-text-strong) data-selected:bg-(--clarify-ui-active-background) data-selected:text-(--clarify-ui-accent-text)",
3095
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3096
- className: "min-w-0",
3097
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3098
- className: "block truncate",
3099
- children: option.label
3100
- }), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3101
- className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
3102
- children: option.description
3103
- }) : null]
3104
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
3105
- className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
3106
- "aria-hidden": "true"
3107
- })]
3184
+ className: optionClassName,
3185
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionContent, { option })
3186
+ }, option.value))
3187
+ })]
3188
+ })
3189
+ });
3190
+ }
3191
+ function MultiInlineListbox(arg0) {
3192
+ const { label, value, options, onChange, disabled = false, invalid, describedBy } = arg0;
3193
+ const selectedLabel = options.filter((option) => value.includes(option.value)).map((option) => option.label).join(", ");
3194
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
3195
+ value,
3196
+ onChange,
3197
+ multiple: true,
3198
+ disabled,
3199
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3200
+ className: "pointer-events-auto relative inline-flex min-w-0 w-full",
3201
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
3202
+ "aria-label": label,
3203
+ "aria-invalid": invalid || void 0,
3204
+ "aria-describedby": describedBy,
3205
+ className: (0, clsx.default)(defaultButtonClassName, "min-h-8 w-full px-2 text-xs"),
3206
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3207
+ className: "truncate",
3208
+ children: selectedLabel || label
3209
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
3210
+ className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
3211
+ "aria-hidden": "true"
3212
+ })]
3213
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
3214
+ anchor: "bottom start",
3215
+ className: optionsClassName,
3216
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOption, {
3217
+ value: option.value,
3218
+ className: optionClassName,
3219
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionContent, { option })
3108
3220
  }, option.value))
3109
3221
  })]
3110
3222
  })
3111
3223
  });
3112
3224
  }
3113
3225
  //#endregion
3226
+ //#region source/openapi/store.ts
3227
+ var credentialScopes = /* @__PURE__ */ new WeakMap();
3228
+ var emptyOpenApiCredentials = Object.freeze({});
3229
+ var nextCredentialScope = 0;
3230
+ function getOpenApiCredentialScope(spec) {
3231
+ const current = credentialScopes.get(spec);
3232
+ if (current) return current;
3233
+ const scope = `openapi-${nextCredentialScope += 1}`;
3234
+ credentialScopes.set(spec, scope);
3235
+ return scope;
3236
+ }
3237
+ var useOpenApiStore = (0, zustand.create)()((set) => ({
3238
+ credentials: {},
3239
+ setCredential: (scope, name, value) => set((state) => ({ credentials: {
3240
+ ...state.credentials,
3241
+ [scope]: {
3242
+ ...state.credentials[scope],
3243
+ [name]: value
3244
+ }
3245
+ } })),
3246
+ clearCredential: (scope, name) => set((state) => {
3247
+ const scoped = { ...state.credentials[scope] };
3248
+ delete scoped[name];
3249
+ return { credentials: {
3250
+ ...state.credentials,
3251
+ [scope]: scoped
3252
+ } };
3253
+ }),
3254
+ clearCredentials: (scope) => set((state) => {
3255
+ const credentials = { ...state.credentials };
3256
+ delete credentials[scope];
3257
+ return { credentials };
3258
+ })
3259
+ }));
3260
+ //#endregion
3114
3261
  //#region source/openapi/components/OpenApiOperation.state.ts
3115
3262
  function useOperationRequestState(spec, path, operation, source = "path") {
3116
3263
  const parameters = getOperationParameters(spec, path, operation, source);
@@ -3161,9 +3308,13 @@ function useOperationServerState(spec, operation, path, source = "path") {
3161
3308
  }
3162
3309
  function useOperationAuthState(spec, operation) {
3163
3310
  const authOptions = getAuthOptions(spec, operation);
3164
- const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.name ?? "");
3165
- const selectedAuth = authOptions.find((option) => option.name === selectedAuthName);
3166
- const [authValues, setAuthValues] = (0, react.useState)({});
3311
+ const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.key ?? "");
3312
+ const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
3313
+ const credentialScope = getOpenApiCredentialScope(spec);
3314
+ const authValues = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
3315
+ const setCredential = useOpenApiStore((state) => state.setCredential);
3316
+ const clearCredential = useOpenApiStore((state) => state.clearCredential);
3317
+ const clearCredentials = useOpenApiStore((state) => state.clearCredentials);
3167
3318
  const [authOpen, setAuthOpen] = (0, react.useState)(false);
3168
3319
  return {
3169
3320
  authOptions,
@@ -3171,37 +3322,1277 @@ function useOperationAuthState(spec, operation) {
3171
3322
  selectedAuth,
3172
3323
  authValues,
3173
3324
  authOpen,
3174
- authInput: selectedAuth ? {
3175
- name: selectedAuth.name,
3176
- scheme: selectedAuth.scheme,
3177
- value: authValues[selectedAuth.name] ?? authPlaceholder(selectedAuth)
3178
- } : void 0,
3325
+ authInput: selectedAuth ? selectedAuth.schemes.map((option) => ({
3326
+ name: option.name,
3327
+ scheme: option.scheme,
3328
+ value: authValues[option.name] ?? ""
3329
+ })) : void 0,
3179
3330
  onSelectAuth: setSelectedAuthName,
3180
- onChangeAuthValue: (name, value) => setAuthValues((current) => ({
3181
- ...current,
3182
- [name]: value
3183
- })),
3331
+ onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
3332
+ onClearAuthValue: (name) => clearCredential(credentialScope, name),
3333
+ onClearAuthValues: () => clearCredentials(credentialScope),
3184
3334
  onToggleAuth: () => setAuthOpen((current) => !current),
3185
3335
  closeAuth: () => setAuthOpen(false)
3186
3336
  };
3187
3337
  }
3188
3338
  //#endregion
3189
- //#region source/openapi/components/OpenApiOperation.tsx
3190
- var endpointMethodStyleVars = {
3191
- GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
3192
- POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
3193
- PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
3194
- PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
3195
- DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
3196
- WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
3197
- };
3198
- function EndpointMethodBadge(arg0) {
3199
- const { method } = arg0;
3339
+ //#region source/openapi/lib/api-request.ts
3340
+ function parseBodyObject(body) {
3341
+ try {
3342
+ const parsed = JSON.parse(body);
3343
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
3344
+ } catch {
3345
+ return;
3346
+ }
3347
+ }
3348
+ function buildRequestBody(body, mediaType) {
3349
+ const values = parseBodyObject(body);
3350
+ if (mediaType.includes("application/x-www-form-urlencoded") && values) {
3351
+ const params = new URLSearchParams();
3352
+ Object.entries(values).forEach(([name, value]) => params.append(name, typeof value === "string" ? value : JSON.stringify(value)));
3353
+ return params;
3354
+ }
3355
+ if (mediaType.includes("multipart/form-data") && values) {
3356
+ const form = new FormData();
3357
+ Object.entries(values).forEach(([name, value]) => form.append(name, typeof value === "string" ? value : JSON.stringify(value)));
3358
+ return form;
3359
+ }
3360
+ return body;
3361
+ }
3362
+ function expandServerUrl(server, variables) {
3363
+ return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
3364
+ }
3365
+ function authorizationValue(auth) {
3366
+ const scheme = auth.scheme.scheme?.toLowerCase();
3367
+ if (auth.scheme.type === "http" && scheme === "basic") return `Basic ${auth.value}`;
3368
+ if (auth.scheme.type === "http" && scheme === "bearer") return `Bearer ${auth.value}`;
3369
+ if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
3370
+ }
3371
+ function parameterKey(parameter) {
3372
+ return `${parameter.in ?? "query"}:${parameter.name ?? ""}`;
3373
+ }
3374
+ function parseParameterValue(value) {
3375
+ const trimmed = value.trim();
3376
+ if (!trimmed || !trimmed.startsWith("[") && !trimmed.startsWith("{")) return value;
3377
+ try {
3378
+ return JSON.parse(trimmed);
3379
+ } catch {
3380
+ return value;
3381
+ }
3382
+ }
3383
+ function primitiveValue(value) {
3384
+ if (typeof value === "string") return value;
3385
+ if (value === null || typeof value === "undefined") return "";
3386
+ return String(value);
3387
+ }
3388
+ function serializedParameterValues(parameter, rawValue) {
3389
+ const value = parseParameterValue(rawValue);
3390
+ const style = parameter.style ?? (parameter.in === "query" || parameter.in === "cookie" ? "form" : "simple");
3391
+ const explode = parameter.explode ?? style === "form";
3392
+ if (Array.isArray(value)) {
3393
+ if (explode) return value.map((item) => [parameter.name ?? "", primitiveValue(item)]);
3394
+ const delimiter = style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",";
3395
+ return [[parameter.name ?? "", value.map(primitiveValue).join(delimiter)]];
3396
+ }
3397
+ if (typeof value === "object" && value !== null) {
3398
+ const entries = Object.entries(value);
3399
+ if (parameter.style === "deepObject") return entries.map(([key, item]) => [`${parameter.name}[${key}]`, primitiveValue(item)]);
3400
+ if (explode) return entries.map(([key, item]) => [key, primitiveValue(item)]);
3401
+ return [[parameter.name ?? "", entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",")]];
3402
+ }
3403
+ return [[parameter.name ?? "", primitiveValue(value)]];
3404
+ }
3405
+ function pathParameterValue(parameter, rawValue) {
3406
+ const value = parseParameterValue(rawValue);
3407
+ const style = parameter.style ?? "simple";
3408
+ const explode = parameter.explode ?? false;
3409
+ const encode = (item) => encodeURIComponent(primitiveValue(item));
3410
+ if (Array.isArray(value)) {
3411
+ if (style === "label") return `.${value.map(encode).join(explode ? "." : ",")}`;
3412
+ if (style === "matrix") return explode ? value.map((item) => `;${parameter.name}=${encode(item)}`).join("") : `;${parameter.name}=${value.map(encode).join(",")}`;
3413
+ return value.map(encode).join(",");
3414
+ }
3415
+ if (typeof value === "object" && value !== null) {
3416
+ const entries = Object.entries(value);
3417
+ if (style === "label") return explode ? `.${entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(".")}` : `.${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
3418
+ if (style === "matrix") return explode ? entries.map(([key, item]) => `;${encode(key)}=${encode(item)}`).join("") : `;${parameter.name}=${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
3419
+ return explode ? entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(",") : entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",");
3420
+ }
3421
+ const encoded = encode(value);
3422
+ if (style === "label") return `.${encoded}`;
3423
+ if (style === "matrix") return `;${parameter.name}=${encoded}`;
3424
+ return encoded;
3425
+ }
3426
+ function headerParameterValue(parameter, rawValue) {
3427
+ const value = parseParameterValue(rawValue);
3428
+ if (Array.isArray(value)) return value.map(primitiveValue).join(",");
3429
+ if (typeof value === "object" && value !== null) {
3430
+ const entries = Object.entries(value);
3431
+ return parameter.explode ? entries.map(([key, item]) => `${key}=${primitiveValue(item)}`).join(",") : entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",");
3432
+ }
3433
+ return primitiveValue(value);
3434
+ }
3435
+ function buildApiRequest(input) {
3436
+ const headers = new Headers({ Accept: "application/json" });
3437
+ const query = new URLSearchParams();
3438
+ let path = input.path;
3439
+ for (const parameter of input.parameters) {
3440
+ if (!parameter.name) continue;
3441
+ const key = parameterKey(parameter);
3442
+ if (input.parameterEnabled?.[key] === false) continue;
3443
+ const value = input.parameterValues[key] ?? "";
3444
+ if (!value && !parameter.allowEmptyValue) continue;
3445
+ if (parameter.in === "path") path = path.replaceAll(`{${parameter.name}}`, pathParameterValue(parameter, value));
3446
+ if (parameter.in === "query") serializedParameterValues(parameter, value).forEach(([name, item]) => query.append(name, item));
3447
+ if (parameter.in === "header") headers.set(parameter.name, headerParameterValue(parameter, value));
3448
+ }
3449
+ for (const auth of input.auth ?? []) {
3450
+ if (!auth.value) continue;
3451
+ if (auth.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) query.set(auth.scheme.name, auth.value);
3452
+ else if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) headers.set(auth.scheme.name, auth.value);
3453
+ else {
3454
+ const authorization = authorizationValue(auth);
3455
+ if (authorization) headers.set("Authorization", authorization);
3456
+ }
3457
+ }
3458
+ const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
3459
+ query.forEach((value, key) => url.searchParams.append(key, value));
3460
+ const body = input.body?.trim();
3461
+ const mediaType = input.mediaType || "application/json";
3462
+ const requestBody = body && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType) : void 0;
3463
+ if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
3464
+ return {
3465
+ url: url.toString(),
3466
+ init: {
3467
+ method: input.method.toUpperCase(),
3468
+ headers,
3469
+ credentials: "include",
3470
+ ...requestBody ? { body: requestBody } : {}
3471
+ }
3472
+ };
3473
+ }
3474
+ //#endregion
3475
+ //#region source/openapi/components/OpenApiAuthPanel.tsx
3476
+ function OpenApiAuthPanel(arg0) {
3477
+ const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue, onClearAuthValue } = arg0;
3478
+ const t = require_i18n.useBuiltInText();
3479
+ if (authOptions.length === 0) return null;
3480
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3481
+ className: "grid divide-y divide-(--clarify-theme-tokens-colors-border)",
3482
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3483
+ className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
3484
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3485
+ className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
3486
+ children: "Auth"
3487
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3488
+ label: "Auth",
3489
+ value: selectedAuthName,
3490
+ options: authOptions.map((option) => ({
3491
+ value: option.key,
3492
+ label: option.label || t("openapi.none")
3493
+ })),
3494
+ onChange: onSelectAuth
3495
+ })]
3496
+ }), selectedAuth?.schemes.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3497
+ className: "group grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
3498
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3499
+ className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
3500
+ children: authLabel(option.name, option.scheme)
3501
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3502
+ className: "flex min-w-0 items-center focus-within:bg-(--clarify-ui-hover-background)",
3503
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3504
+ type: "password",
3505
+ value: authValues[option.name] ?? "",
3506
+ placeholder: authPlaceholder(option),
3507
+ onChange: (event) => onChangeAuthValue(option.name, event.target.value),
3508
+ autoComplete: "off",
3509
+ className: "h-8 min-w-0 flex-1 border-0 bg-transparent px-2 text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
3510
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3511
+ type: "button",
3512
+ onClick: () => onClearAuthValue(option.name),
3513
+ className: "mr-1 h-6 shrink-0 rounded-(--clarify-theme-tokens-radius-md) px-1 text-2xs font-medium text-(--clarify-ui-text-faint) opacity-0 transition-opacity hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) group-hover:opacity-100",
3514
+ children: t("openapi.clear")
3515
+ })]
3516
+ })]
3517
+ }, option.name))]
3518
+ });
3519
+ }
3520
+ //#endregion
3521
+ //#region source/openapi/components/OpenApiRequestFields.tsx
3522
+ function RequestField(arg0) {
3523
+ const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
3524
+ const t = require_i18n.useBuiltInText();
3525
+ const schema = resolveSchema(spec, parameter.schema);
3526
+ const schemaRecord = isRecord$1(schema) ? schema : void 0;
3527
+ const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
3528
+ const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
3529
+ const itemOptions = Array.isArray(itemSchema?.enum) ? itemSchema.enum.map(String) : [];
3530
+ const type = schemaToType(schema) ?? "string";
3531
+ const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
3532
+ const structured = type.includes("[]") || type.includes("object");
3533
+ const boolean = type.includes("boolean");
3534
+ const numeric = type.includes("integer") || type.includes("number");
3535
+ const fieldId = `openapi-parameter-${parameter.in ?? "query"}-${parameter.name ?? ""}`.replace(/[^a-zA-Z0-9_-]/g, "-");
3536
+ const issueText = issue === "required" ? t("openapi.required") : issue ? t(`openapi.parameter${issue[0].toUpperCase()}${issue.slice(1)}`) : void 0;
3537
+ const controlProps = {
3538
+ "aria-label": parameter.name,
3539
+ "aria-invalid": issue ? true : void 0,
3540
+ "aria-describedby": issue ? `${fieldId}-issue` : void 0,
3541
+ disabled: !enabled
3542
+ };
3543
+ const arrayValue = (() => {
3544
+ try {
3545
+ const parsed = JSON.parse(value);
3546
+ return Array.isArray(parsed) ? parsed.map(String) : [];
3547
+ } catch {
3548
+ return [];
3549
+ }
3550
+ })();
3551
+ const descriptionTip = description ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, {
3552
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
3553
+ className: "max-w-80 text-left *:first:mt-0 *:last:mb-0",
3554
+ children: description
3555
+ }),
3556
+ side: "bottom",
3557
+ className: "mr-1 shrink-0 [&>[role=tooltip]]:w-80 [&>[role=tooltip]]:max-w-[min(20rem,calc(100vw-2rem))] [&>[role=tooltip]]:border [&>[role=tooltip]]:border-(--clarify-theme-tokens-colors-border) [&>[role=tooltip]]:bg-(--clarify-theme-tokens-colors-surface) [&>[role=tooltip]]:p-3 [&>[role=tooltip]]:text-(--clarify-ui-text) [&>[role=tooltip]]:shadow-xl",
3558
+ triggerClassName: "clarify-field-description-trigger clarify-ui-control inline-flex size-7 items-center justify-center rounded-md !border-b-0 text-(--clarify-ui-text-faint) transition-colors",
3559
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.InfoIcon, {
3560
+ className: "size-4",
3561
+ "aria-hidden": "true"
3562
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3563
+ className: "sr-only",
3564
+ children: t("openapi.fieldDescription")
3565
+ })]
3566
+ }) : null;
3567
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3568
+ className: "group grid min-w-0 grid-cols-[2rem_minmax(0,1fr)] sm:grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)] sm:items-stretch",
3569
+ children: [
3570
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3571
+ className: "flex min-h-8 items-center justify-center border-r border-(--clarify-theme-tokens-colors-border)",
3572
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3573
+ type: "checkbox",
3574
+ checked: enabled,
3575
+ disabled: parameter.required,
3576
+ onChange: (event) => onEnabledChange(event.target.checked),
3577
+ "aria-label": `${t("openapi.includeParameter")}: ${parameter.name ?? ""}`,
3578
+ className: "size-3.5 shrink-0 accent-(--clarify-theme-tokens-colors-primary) disabled:cursor-not-allowed"
3579
+ })
3580
+ }),
3581
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3582
+ className: "flex min-h-8 min-w-0 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2",
3583
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3584
+ htmlFor: fieldId,
3585
+ className: "flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-(--clarify-ui-text-strong)",
3586
+ children: [
3587
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3588
+ className: "truncate font-mono",
3589
+ children: parameter.name
3590
+ }),
3591
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3592
+ className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
3593
+ children: type
3594
+ }),
3595
+ parameter.required ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3596
+ className: "text-(--clarify-error-accent-text)",
3597
+ children: "*"
3598
+ }) : null
3599
+ ]
3600
+ })
3601
+ }),
3602
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3603
+ className: (0, clsx.default)("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "opacity-45"),
3604
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3605
+ className: "min-w-0 flex-1",
3606
+ children: itemOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiInlineListbox, {
3607
+ label: parameter.name ?? "",
3608
+ value: arrayValue,
3609
+ options: itemOptions.map((option) => ({
3610
+ value: option,
3611
+ label: option
3612
+ })),
3613
+ onChange: (next) => onChange(JSON.stringify(next)),
3614
+ invalid: Boolean(issue),
3615
+ describedBy: issue ? `${fieldId}-issue` : void 0,
3616
+ disabled: !enabled
3617
+ }) : options.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3618
+ label: parameter.name ?? "",
3619
+ value,
3620
+ options: [...parameter.required ? [] : [{
3621
+ value: "",
3622
+ label: t("openapi.none")
3623
+ }], ...options.map((option) => ({
3624
+ value: option,
3625
+ label: option
3626
+ }))],
3627
+ onChange,
3628
+ invalid: Boolean(issue),
3629
+ describedBy: issue ? `${fieldId}-issue` : void 0,
3630
+ disabled: !enabled
3631
+ }) : boolean ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3632
+ ...controlProps,
3633
+ id: fieldId,
3634
+ type: "checkbox",
3635
+ checked: value === "true",
3636
+ onChange: (event) => onChange(String(event.target.checked)),
3637
+ className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
3638
+ }) : structured ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
3639
+ ...controlProps,
3640
+ id: fieldId,
3641
+ value,
3642
+ required: parameter.required,
3643
+ onChange: (event) => onChange(event.target.value),
3644
+ rows: 3,
3645
+ spellCheck: false,
3646
+ placeholder: type.includes("[]") ? "[]" : "{}",
3647
+ className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden aria-invalid:text-(--clarify-error-accent-text) focus:bg-(--clarify-ui-hover-background)"
3648
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3649
+ ...controlProps,
3650
+ id: fieldId,
3651
+ value,
3652
+ type: numeric ? "number" : schemaRecord?.format === "date" ? "date" : schemaRecord?.format === "date-time" ? "datetime-local" : "text",
3653
+ required: parameter.required,
3654
+ onChange: (event) => onChange(event.target.value),
3655
+ className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden transition placeholder:text-(--clarify-ui-text-faint) focus:bg-(--clarify-ui-hover-background) aria-invalid:text-(--clarify-error-accent-text)"
3656
+ })
3657
+ }), descriptionTip]
3658
+ }),
3659
+ issueText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3660
+ id: `${fieldId}-issue`,
3661
+ className: "col-start-2 border-t border-(--clarify-theme-tokens-colors-border) px-2 py-1 text-xs/5 font-medium text-(--clarify-error-accent-text) sm:col-start-3",
3662
+ children: issueText
3663
+ }) : null
3664
+ ]
3665
+ });
3666
+ }
3667
+ function RequestSection(arg0) {
3668
+ const { title, count, defaultOpen, actions, className, contentClassName, children } = arg0;
3669
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3670
+ open: defaultOpen,
3671
+ className: (0, clsx.default)("group shrink-0 border-b border-(--clarify-theme-tokens-colors-border)", className),
3672
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
3673
+ className: "flex min-h-11 cursor-pointer list-none items-center gap-2 bg-(--clarify-ui-subtle-background) px-2.5 text-sm font-medium text-(--clarify-ui-text-strong) hover:bg-(--clarify-ui-hover-background) group-open:border-b group-open:border-(--clarify-theme-tokens-colors-border)",
3674
+ children: [
3675
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
3676
+ className: "size-4 shrink-0 -rotate-90 transition group-open:rotate-0",
3677
+ "aria-hidden": "true"
3678
+ }),
3679
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3680
+ className: "flex-1",
3681
+ children: title
3682
+ }),
3683
+ typeof count === "number" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3684
+ className: "font-mono text-xs text-(--clarify-ui-text-faint)",
3685
+ children: count
3686
+ }) : null,
3687
+ actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3688
+ className: "flex items-center gap-1",
3689
+ onClick: (event) => {
3690
+ event.preventDefault();
3691
+ event.stopPropagation();
3692
+ },
3693
+ children: actions
3694
+ }) : null
3695
+ ]
3696
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3697
+ className: (0, clsx.default)("divide-y divide-(--clarify-theme-tokens-colors-border)", contentClassName),
3698
+ children
3699
+ })]
3700
+ });
3701
+ }
3702
+ //#endregion
3703
+ //#region source/openapi/components/OpenApiResponseViewer.tsx
3704
+ function formatBytes(size) {
3705
+ if (size < 1024) return `${size} B`;
3706
+ if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
3707
+ return `${(size / (1024 * 1024)).toFixed(1)} MB`;
3708
+ }
3709
+ function parseJson(value) {
3710
+ try {
3711
+ return JSON.parse(value);
3712
+ } catch {
3713
+ return;
3714
+ }
3715
+ }
3716
+ function ResponseState(arg0) {
3717
+ const { icon: Icon, title, description, tone = "default" } = arg0;
3718
+ const error = tone === "error";
3719
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3720
+ className: "grid min-h-56 flex-1 place-items-center px-6 py-10 text-center",
3721
+ role: error ? "alert" : "status",
3722
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3723
+ className: "max-w-sm",
3724
+ children: [
3725
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3726
+ className: (0, clsx.default)("mx-auto mb-3 grid size-10 place-items-center rounded-full border", error ? "border-(--clarify-code-danger-border) bg-(--clarify-code-danger-background) text-(--clarify-code-danger)" : "border-(--clarify-code-border) bg-(--clarify-code-control-background) text-(--clarify-code-muted)"),
3727
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
3728
+ className: "size-4.5",
3729
+ "aria-hidden": "true"
3730
+ })
3731
+ }),
3732
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3733
+ className: (0, clsx.default)("text-sm font-semibold", error ? "text-(--clarify-code-danger)" : "text-(--clarify-code-text)"),
3734
+ children: title
3735
+ }),
3736
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3737
+ className: "mt-1 text-xs/5 text-(--clarify-code-faint)",
3738
+ children: description
3739
+ })
3740
+ ]
3741
+ })
3742
+ });
3743
+ }
3744
+ function JsonPreview(arg0) {
3745
+ const { value } = arg0;
3746
+ if (Array.isArray(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3747
+ className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
3748
+ children: value.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3749
+ className: "mr-2 text-(--clarify-code-faint)",
3750
+ children: index
3751
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: item })] }, index))
3752
+ });
3753
+ if (isRecord$1(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3754
+ className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
3755
+ children: Object.entries(value).map(([key, item]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3756
+ className: "grid grid-cols-[minmax(5rem,auto)_1fr] gap-3",
3757
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3758
+ className: "text-(--clarify-code-property)",
3759
+ children: key
3760
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: item })]
3761
+ }, key))
3762
+ });
3763
+ if (value === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3764
+ className: "text-(--clarify-code-faint)",
3765
+ children: "null"
3766
+ });
3767
+ if (typeof value === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3768
+ className: "wrap-break-word text-(--clarify-code-string)",
3769
+ children: value
3770
+ });
3200
3771
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3201
- className: (0, clsx.default)("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
3202
- children: method
3772
+ className: "text-(--clarify-code-number)",
3773
+ children: String(value)
3774
+ });
3775
+ }
3776
+ function CopyButton(arg0) {
3777
+ const { value } = arg0;
3778
+ const t = require_i18n.useBuiltInText();
3779
+ const [copied, setCopied] = (0, react.useState)(false);
3780
+ async function copy() {
3781
+ const success = await require_PageActions.copyTextToClipboard(value);
3782
+ setCopied(success);
3783
+ if (success) window.setTimeout(() => setCopied(false), 1600);
3784
+ }
3785
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3786
+ type: "button",
3787
+ onClick: copy,
3788
+ "aria-label": copied ? t("actions.copied") : t("actions.copy"),
3789
+ title: copied ? t("actions.copied") : t("actions.copy"),
3790
+ className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
3791
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
3792
+ className: "size-4 text-(--clarify-code-success)",
3793
+ "aria-hidden": "true"
3794
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
3795
+ className: "size-4",
3796
+ "aria-hidden": "true"
3797
+ })
3798
+ });
3799
+ }
3800
+ function ResponseMedia(arg0) {
3801
+ const { blob, type } = arg0;
3802
+ const elementRef = (0, react.useRef)(null);
3803
+ (0, react.useEffect)(() => {
3804
+ const element = elementRef.current;
3805
+ if (!element) return;
3806
+ const url = URL.createObjectURL(blob);
3807
+ element.src = url;
3808
+ return () => {
3809
+ element.removeAttribute("src");
3810
+ URL.revokeObjectURL(url);
3811
+ };
3812
+ }, [blob]);
3813
+ if (type === "image") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
3814
+ ref: elementRef,
3815
+ alt: "",
3816
+ className: "max-h-128 max-w-full object-contain"
3817
+ });
3818
+ if (type === "audio") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
3819
+ ref: elementRef,
3820
+ controls: true,
3821
+ className: "w-full"
3822
+ });
3823
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("video", {
3824
+ ref: elementRef,
3825
+ controls: true,
3826
+ className: "max-h-128 max-w-full"
3203
3827
  });
3204
3828
  }
3829
+ function ResponsePreview(arg0) {
3830
+ const { exchange } = arg0;
3831
+ const t = require_i18n.useBuiltInText();
3832
+ const contentType = exchange.contentType.toLowerCase();
3833
+ if (!exchange.size) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
3834
+ icon: lucide_react.FileX2Icon,
3835
+ title: t("openapi.responseBodyEmptyTitle"),
3836
+ description: t("openapi.responseBodyEmpty")
3837
+ });
3838
+ if (contentType.includes("json")) {
3839
+ const parsed = parseJson(exchange.body);
3840
+ return typeof parsed === "undefined" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
3841
+ className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
3842
+ children: exchange.body
3843
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3844
+ className: "overflow-auto font-mono text-xs/5",
3845
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: parsed })
3846
+ });
3847
+ }
3848
+ if (contentType.startsWith("image/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
3849
+ blob: exchange.blob,
3850
+ type: "image"
3851
+ });
3852
+ if (contentType.startsWith("audio/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
3853
+ blob: exchange.blob,
3854
+ type: "audio"
3855
+ });
3856
+ if (contentType.startsWith("video/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
3857
+ blob: exchange.blob,
3858
+ type: "video"
3859
+ });
3860
+ if (contentType.includes("html")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
3861
+ srcDoc: exchange.body,
3862
+ sandbox: "",
3863
+ title: "Response preview",
3864
+ className: "h-96 w-full border-0 bg-white"
3865
+ });
3866
+ if (contentType.startsWith("text/") || contentType.includes("xml") || contentType.includes("yaml")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
3867
+ className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
3868
+ children: exchange.body
3869
+ });
3870
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3871
+ className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
3872
+ children: t("openapi.binaryPreview")
3873
+ });
3874
+ }
3875
+ function ResponseHeaders(arg0) {
3876
+ const { headers: sourceHeaders } = arg0;
3877
+ const t = require_i18n.useBuiltInText();
3878
+ const [query, setQuery] = (0, react.useState)("");
3879
+ const normalizedQuery = query.trim().toLowerCase();
3880
+ const headers = normalizedQuery ? sourceHeaders.filter(([name, value]) => `${name} ${value}`.toLowerCase().includes(normalizedQuery)) : sourceHeaders;
3881
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
3882
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3883
+ className: "flex h-9 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-control-background) px-3",
3884
+ children: [
3885
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
3886
+ className: "size-4 shrink-0 text-(--clarify-code-muted)",
3887
+ "aria-hidden": "true"
3888
+ }),
3889
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3890
+ className: "sr-only",
3891
+ children: t("openapi.searchHeaders")
3892
+ }),
3893
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3894
+ value: query,
3895
+ onChange: (event) => setQuery(event.target.value),
3896
+ placeholder: t("openapi.searchHeaders"),
3897
+ className: "min-w-0 flex-1 bg-transparent text-xs text-(--clarify-code-text) outline-none placeholder:text-(--clarify-code-faint)"
3898
+ })
3899
+ ]
3900
+ }),
3901
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3902
+ className: "overflow-x-auto",
3903
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
3904
+ className: "w-full min-w-96 table-fixed border-collapse text-left font-mono text-xs/5",
3905
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
3906
+ className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
3907
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3908
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3909
+ className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
3910
+ children: t("openapi.headerName")
3911
+ }),
3912
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3913
+ className: "px-3 py-2 font-semibold",
3914
+ children: t("openapi.headerValue")
3915
+ }),
3916
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3917
+ className: "w-10",
3918
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3919
+ className: "sr-only",
3920
+ children: t("actions.copy")
3921
+ })
3922
+ })
3923
+ ] })
3924
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: headers.map(([name, value], index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
3925
+ className: "border-t border-(--clarify-code-border) hover:bg-(--clarify-code-control-background)",
3926
+ children: [
3927
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3928
+ className: "break-all border-r border-(--clarify-code-border) px-3 py-2 align-top text-(--clarify-code-property)",
3929
+ children: name
3930
+ }),
3931
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3932
+ className: "break-all px-3 py-2 align-top text-(--clarify-code-text)",
3933
+ children: value
3934
+ }),
3935
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3936
+ className: "pr-1",
3937
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: `${name}: ${value}` })
3938
+ })
3939
+ ]
3940
+ }, `${name}:${index}`)) })]
3941
+ })
3942
+ }),
3943
+ headers.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3944
+ className: "border-t border-(--clarify-code-border) py-8 text-center text-xs text-(--clarify-code-faint)",
3945
+ children: t("openapi.noHeaders")
3946
+ }) : null
3947
+ ] });
3948
+ }
3949
+ function HiddenCookies() {
3950
+ const t = require_i18n.useBuiltInText();
3951
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
3952
+ className: "w-full table-fixed border-collapse text-left text-xs/5",
3953
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
3954
+ className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
3955
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3956
+ className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
3957
+ children: t("openapi.headerName")
3958
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3959
+ className: "px-3 py-2 font-semibold",
3960
+ children: t("openapi.headerValue")
3961
+ })] })
3962
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
3963
+ className: "border-t border-(--clarify-code-border)",
3964
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3965
+ colSpan: 2,
3966
+ className: "px-3 py-5 text-center text-(--clarify-code-faint)",
3967
+ children: t("openapi.cookiesBrowserHidden")
3968
+ })
3969
+ }) })]
3970
+ });
3971
+ }
3972
+ function OpenApiResponseViewer(arg0) {
3973
+ const { exchange, error } = arg0;
3974
+ const t = require_i18n.useBuiltInText();
3975
+ const [bodyMode, setBodyMode] = (0, react.useState)("preview");
3976
+ function downloadBody() {
3977
+ if (!exchange) return;
3978
+ const url = URL.createObjectURL(exchange.blob);
3979
+ const anchor = document.createElement("a");
3980
+ anchor.href = url;
3981
+ anchor.download = `response.${exchange.contentType.includes("json") ? "json" : "bin"}`;
3982
+ anchor.click();
3983
+ URL.revokeObjectURL(url);
3984
+ }
3985
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3986
+ className: "clarify-api-response flex h-full min-h-96 min-w-0 flex-col bg-(--clarify-code-background) text-(--clarify-code-text)",
3987
+ "aria-label": t("openapi.response"),
3988
+ children: [
3989
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3990
+ className: "sticky top-0 z-10 flex min-h-11 flex-wrap items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-2.5 text-sm font-medium",
3991
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3992
+ className: "mr-auto text-(--clarify-code-text)",
3993
+ children: t("openapi.response")
3994
+ }), exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3995
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3996
+ className: "text-xs font-semibold text-(--clarify-code-muted)",
3997
+ children: [exchange.duration, " ms"]
3998
+ }),
3999
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4000
+ className: "text-xs text-(--clarify-code-faint)",
4001
+ children: formatBytes(exchange.size)
4002
+ }),
4003
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: (0, clsx.default)("size-2 rounded-full", exchange.status < 400 ? "bg-(--clarify-code-success)" : "bg-(--clarify-code-danger)") }),
4004
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4005
+ className: (0, clsx.default)("text-xs font-semibold", exchange.status < 400 ? "text-(--clarify-code-success)" : "text-(--clarify-code-danger)"),
4006
+ children: [
4007
+ exchange.status,
4008
+ " ",
4009
+ exchange.statusText
4010
+ ]
4011
+ })
4012
+ ] }) : null]
4013
+ }),
4014
+ error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
4015
+ icon: lucide_react.CircleAlertIcon,
4016
+ title: t("openapi.responseErrorTitle"),
4017
+ description: error,
4018
+ tone: "error"
4019
+ }) : null,
4020
+ !error && !exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
4021
+ icon: lucide_react.SendIcon,
4022
+ title: t("openapi.responseEmptyTitle"),
4023
+ description: t("openapi.responseEmpty")
4024
+ }) : null,
4025
+ exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4026
+ className: "min-h-0 flex-1 overflow-auto",
4027
+ children: [
4028
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4029
+ title: t("openapi.cookies"),
4030
+ count: 0,
4031
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HiddenCookies, {})
4032
+ }),
4033
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4034
+ title: t("openapi.requestHeaders"),
4035
+ count: exchange.request.headers.length,
4036
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseHeaders, { headers: exchange.request.headers })
4037
+ }),
4038
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4039
+ title: t("openapi.responseHeaders"),
4040
+ count: exchange.headers.length,
4041
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseHeaders, { headers: exchange.headers })
4042
+ }),
4043
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4044
+ title: t("openapi.body"),
4045
+ defaultOpen: true,
4046
+ actions: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4047
+ className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
4048
+ children: exchange.contentType || t("openapi.unknownContentType")
4049
+ }),
4050
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4051
+ className: "min-h-72",
4052
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4053
+ className: "flex h-10 items-center justify-between border-b border-(--clarify-code-border) px-3",
4054
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4055
+ role: "tablist",
4056
+ className: "flex",
4057
+ children: ["preview", "raw"].map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4058
+ type: "button",
4059
+ role: "tab",
4060
+ "aria-selected": bodyMode === mode,
4061
+ onClick: () => setBodyMode(mode),
4062
+ className: (0, clsx.default)("border-b-2 px-2.5 py-1 text-2xs font-semibold", bodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
4063
+ children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
4064
+ }, mode))
4065
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4066
+ className: "flex",
4067
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: exchange.body }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4068
+ type: "button",
4069
+ onClick: downloadBody,
4070
+ "aria-label": t("openapi.downloadBody"),
4071
+ title: t("openapi.downloadBody"),
4072
+ className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4073
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.DownloadIcon, {
4074
+ className: "size-4",
4075
+ "aria-hidden": "true"
4076
+ })
4077
+ })]
4078
+ })]
4079
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4080
+ className: "p-4",
4081
+ children: bodyMode === "preview" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
4082
+ className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
4083
+ children: exchange.body
4084
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4085
+ className: "py-8 text-center text-xs text-(--clarify-code-faint)",
4086
+ children: t("openapi.responseBodyEmpty")
4087
+ })
4088
+ })]
4089
+ })
4090
+ })
4091
+ ]
4092
+ }) : null
4093
+ ]
4094
+ });
4095
+ }
4096
+ //#endregion
4097
+ //#region source/openapi/components/SendRequestButton.tsx
4098
+ function SendRequestButton(arg0) {
4099
+ const { label, busy = false, text, onClick } = arg0;
4100
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
4101
+ type: "button",
4102
+ disabled: busy,
4103
+ "aria-label": label,
4104
+ title: label,
4105
+ onClick,
4106
+ className: Boolean(text) ? "flex h-8 shrink-0 items-center gap-1.5 rounded bg-(--clarify-theme-tokens-colors-foreground) px-3 text-xs font-semibold text-(--clarify-theme-tokens-colors-background) transition hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60" : "grid size-7 shrink-0 place-items-center rounded bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors hover:bg-(--clarify-theme-tokens-colors-foreground) hover:text-(--clarify-theme-tokens-colors-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60",
4107
+ children: [busy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LoaderCircleIcon, {
4108
+ className: "size-4 animate-spin",
4109
+ "aria-hidden": "true"
4110
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SendIcon, {
4111
+ className: "size-4",
4112
+ "aria-hidden": "true"
4113
+ }), text]
4114
+ });
4115
+ }
4116
+ //#endregion
4117
+ //#region source/openapi/lib/api-exchange.ts
4118
+ var ApiRequestError = class extends Error {
4119
+ category;
4120
+ constructor(message, options) {
4121
+ super(message, options);
4122
+ this.name = "ApiRequestError";
4123
+ this.category = "network";
4124
+ }
4125
+ };
4126
+ function requestBodySnapshot(body) {
4127
+ if (typeof body === "string") return body;
4128
+ if (body instanceof URLSearchParams) return body.toString();
4129
+ }
4130
+ function requestSnapshot(request) {
4131
+ return {
4132
+ url: request.url,
4133
+ method: request.init.method ?? "GET",
4134
+ headers: Array.from(new Headers(request.init.headers).entries()),
4135
+ body: requestBodySnapshot(request.init.body)
4136
+ };
4137
+ }
4138
+ async function executeApiRequest(request, options = {}) {
4139
+ const fetchRequest = options.fetch ?? fetch;
4140
+ const now = options.now ?? (() => performance.now());
4141
+ const startedAt = now();
4142
+ let response;
4143
+ try {
4144
+ response = await fetchRequest(request.url, {
4145
+ ...request.init,
4146
+ signal: options.signal
4147
+ });
4148
+ } catch (cause) {
4149
+ if (cause instanceof DOMException && cause.name === "AbortError") throw cause;
4150
+ throw new ApiRequestError(cause instanceof Error ? cause.message : String(cause), { cause });
4151
+ }
4152
+ const blob = await response.blob();
4153
+ return {
4154
+ request: requestSnapshot(request),
4155
+ status: response.status,
4156
+ statusText: response.statusText,
4157
+ url: response.url || request.url,
4158
+ redirected: response.redirected,
4159
+ duration: Math.round(now() - startedAt),
4160
+ size: blob.size,
4161
+ headers: Array.from(response.headers.entries()),
4162
+ contentType: response.headers.get("content-type") ?? blob.type,
4163
+ body: await blob.text(),
4164
+ blob
4165
+ };
4166
+ }
4167
+ //#endregion
4168
+ //#region source/openapi/lib/request-parameters.ts
4169
+ function structuredIssue(value, type) {
4170
+ if (!type.includes("[]") && !type.includes("object")) return void 0;
4171
+ try {
4172
+ const parsed = JSON.parse(value);
4173
+ if (type.includes("[]") && !Array.isArray(parsed)) return "invalidArray";
4174
+ if (type.includes("object") && !isRecord$1(parsed)) return "invalidObject";
4175
+ } catch {
4176
+ return type.includes("[]") ? "invalidArray" : "invalidObject";
4177
+ }
4178
+ }
4179
+ function scalarIssue(value, type, format) {
4180
+ if (type.includes("integer") && !Number.isInteger(Number(value))) return "invalidInteger";
4181
+ if (type.includes("number") && !Number.isFinite(Number(value))) return "invalidNumber";
4182
+ if (format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return "invalidDate";
4183
+ if (format === "date-time" && Number.isNaN(Date.parse(value))) return "invalidDateTime";
4184
+ }
4185
+ function validateRequestParameter(spec, parameter, value) {
4186
+ if (!value) return parameter.required ? "required" : void 0;
4187
+ const schema = resolveSchema(spec, parameter.schema);
4188
+ const schemaRecord = isRecord$1(schema) ? schema : void 0;
4189
+ const type = schemaToType(schema) ?? "string";
4190
+ const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
4191
+ if (options.length > 0 && !options.includes(value)) return "invalidEnum";
4192
+ return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
4193
+ }
4194
+ function validateRequestParameters(spec, parameters, values) {
4195
+ return Object.fromEntries(parameters.filter((parameter) => parameter.in !== "cookie").flatMap((parameter) => {
4196
+ const key = parameterKey(parameter);
4197
+ const issue = validateRequestParameter(spec, parameter, values[key] ?? "");
4198
+ return issue ? [[key, issue]] : [];
4199
+ }));
4200
+ }
4201
+ //#endregion
4202
+ //#region source/openapi/components/useOpenApiRequestState.ts
4203
+ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
4204
+ const servers = getServers(spec, operation, path, operationSource);
4205
+ const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
4206
+ const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
4207
+ const [serverVariables, setServerVariables] = (0, react.useState)(defaultServerVariables(selectedServer));
4208
+ const authOptions = getAuthOptions(spec, operation);
4209
+ const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.key ?? "");
4210
+ const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
4211
+ const credentialScope = getOpenApiCredentialScope(spec);
4212
+ const credentials = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
4213
+ const setCredential = useOpenApiStore((state) => state.setCredential);
4214
+ const clearCredential = useOpenApiStore((state) => state.clearCredential);
4215
+ const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
4216
+ const [mediaType, setMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
4217
+ const [body, setBody] = (0, react.useState)(stringifyExample(getExampleEntries((requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0])?.value, spec)[0]?.value));
4218
+ function selectServer(value) {
4219
+ const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
4220
+ setSelectedServerKey(value);
4221
+ setServerVariables(defaultServerVariables(nextServer));
4222
+ }
4223
+ function selectMediaType(value) {
4224
+ const content = requestContents.find((entry) => entry.mediaType === value)?.value;
4225
+ setMediaType(value);
4226
+ setBody(stringifyExample(getExampleEntries(content, spec)[0]?.value));
4227
+ }
4228
+ return {
4229
+ servers,
4230
+ selectedServer,
4231
+ selectedServerKey,
4232
+ serverVariables,
4233
+ setServerVariables,
4234
+ serverVariableEntries: Object.entries(selectedServer.variables ?? {}),
4235
+ selectServer,
4236
+ authOptions,
4237
+ selectedAuthName,
4238
+ setSelectedAuthName,
4239
+ selectedAuth,
4240
+ credentialScope,
4241
+ credentials,
4242
+ setCredential,
4243
+ clearCredential,
4244
+ requestContents,
4245
+ mediaType,
4246
+ body,
4247
+ setBody,
4248
+ selectMediaType
4249
+ };
4250
+ }
4251
+ function useOpenApiParameterState(spec, parameters, initialParameterValue) {
4252
+ const [parameterValues, setParameterValues] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), initialParameterValue(parameter)])));
4253
+ const [parameterEnabled, setParameterEnabled] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
4254
+ const [parameterIssues, setParameterIssues] = (0, react.useState)({});
4255
+ function setParameterGroupValues(grouped, mode) {
4256
+ const keys = new Set(grouped.map(parameterKey));
4257
+ setParameterValues((current) => ({
4258
+ ...current,
4259
+ ...Object.fromEntries(grouped.map((parameter) => [parameterKey(parameter), mode === "reset" ? initialParameterValue(parameter) : ""]))
4260
+ }));
4261
+ setParameterIssues((current) => Object.fromEntries(Object.entries(current).filter(([key]) => !keys.has(key))));
4262
+ }
4263
+ function setParameterIncluded(parameter, enabled) {
4264
+ const key = parameterKey(parameter);
4265
+ setParameterEnabled((current) => ({
4266
+ ...current,
4267
+ [key]: enabled
4268
+ }));
4269
+ if (!enabled) setParameterIssues((current) => {
4270
+ const next = { ...current };
4271
+ delete next[key];
4272
+ return next;
4273
+ });
4274
+ }
4275
+ function updateParameterValue(parameter, value) {
4276
+ const key = parameterKey(parameter);
4277
+ setParameterValues((current) => ({
4278
+ ...current,
4279
+ [key]: value
4280
+ }));
4281
+ setParameterIssues((current) => {
4282
+ const next = { ...current };
4283
+ delete next[key];
4284
+ return next;
4285
+ });
4286
+ }
4287
+ function validate(parametersToValidate) {
4288
+ const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
4289
+ setParameterIssues(issues);
4290
+ return issues;
4291
+ }
4292
+ return {
4293
+ parameterValues,
4294
+ parameterEnabled,
4295
+ parameterIssues,
4296
+ setParameterGroupValues,
4297
+ setParameterIncluded,
4298
+ updateParameterValue,
4299
+ validate
4300
+ };
4301
+ }
4302
+ function useOpenApiRequestExecution() {
4303
+ const [exchange, setExchange] = (0, react.useState)();
4304
+ const [error, setError] = (0, react.useState)("");
4305
+ const [sending, setSending] = (0, react.useState)(false);
4306
+ const requestController = (0, react.useRef)(null);
4307
+ (0, react.useEffect)(() => () => requestController.current?.abort(), []);
4308
+ async function execute(request, corsHint) {
4309
+ requestController.current?.abort();
4310
+ const controller = new AbortController();
4311
+ requestController.current = controller;
4312
+ setSending(true);
4313
+ setError("");
4314
+ setExchange(void 0);
4315
+ try {
4316
+ setExchange(await executeApiRequest(request, { signal: controller.signal }));
4317
+ } catch (cause) {
4318
+ if (cause instanceof DOMException && cause.name === "AbortError") return;
4319
+ const message = cause instanceof Error ? cause.message : String(cause);
4320
+ setError(`${message}. ${corsHint}`);
4321
+ } finally {
4322
+ if (requestController.current === controller) {
4323
+ requestController.current = null;
4324
+ setSending(false);
4325
+ }
4326
+ }
4327
+ }
4328
+ return {
4329
+ exchange,
4330
+ error,
4331
+ sending,
4332
+ execute
4333
+ };
4334
+ }
4335
+ //#endregion
4336
+ //#region source/openapi/components/OpenApiRequest.tsx
4337
+ function initialParameterValue(spec, parameter) {
4338
+ const schema = resolveSchema(spec, parameter.schema);
4339
+ if (!isRecord$1(schema)) return "";
4340
+ return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
4341
+ }
4342
+ function parameterGroupLabel(location, t) {
4343
+ if (location === "path") return t("openapi.pathParameters");
4344
+ if (location === "header") return t("openapi.headers");
4345
+ if (location === "cookie") return t("openapi.cookies");
4346
+ return t("openapi.queryParameters");
4347
+ }
4348
+ function OpenApiRequestWorkbench(arg0) {
4349
+ const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
4350
+ const t = require_i18n.useBuiltInText();
4351
+ const parameters = getOperationParameters(spec, path, operation, operationSource);
4352
+ const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, body, setBody, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
4353
+ const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter));
4354
+ const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue } = parameterState;
4355
+ const { exchange, error, sending, execute } = useOpenApiRequestExecution();
4356
+ const parameterGroups = [
4357
+ "cookie",
4358
+ "header",
4359
+ "query"
4360
+ ].map((location) => ({
4361
+ location,
4362
+ parameters: parameters.filter((parameter) => parameter.in === location)
4363
+ })).filter((group) => group.parameters.length > 0);
4364
+ const pathParameters = parameters.filter((parameter) => parameter.in === "path");
4365
+ const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
4366
+ async function sendRequest() {
4367
+ const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
4368
+ const issues = parameterState.validate(enabledParameters);
4369
+ if (Object.keys(issues).length > 0) return;
4370
+ await execute(buildApiRequest({
4371
+ method,
4372
+ path,
4373
+ server: selectedServer,
4374
+ serverVariables,
4375
+ parameters,
4376
+ parameterValues,
4377
+ parameterEnabled,
4378
+ auth: selectedAuth?.schemes.map((option) => ({
4379
+ scheme: option.scheme,
4380
+ value: credentials[option.name] ?? ""
4381
+ })),
4382
+ mediaType,
4383
+ body,
4384
+ baseUrl: window.location.href
4385
+ }), t("openapi.requestCorsHint"));
4386
+ }
4387
+ function renderParameterField(parameter) {
4388
+ const key = parameterKey(parameter);
4389
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestField, {
4390
+ spec,
4391
+ parameter,
4392
+ value: parameterValues[key] ?? "",
4393
+ enabled: parameterEnabled[key] !== false,
4394
+ issue: parameterIssues[key],
4395
+ onEnabledChange: (enabled) => setParameterIncluded(parameter, enabled),
4396
+ onChange: (value) => updateParameterValue(parameter, value)
4397
+ }, key);
4398
+ }
4399
+ function renderParameterGroup(group) {
4400
+ const { location, parameters: grouped } = group;
4401
+ const actions = location === "cookie" ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4402
+ type: "button",
4403
+ title: t("openapi.resetToExample"),
4404
+ "aria-label": t("openapi.resetToExample"),
4405
+ onClick: () => setParameterGroupValues(grouped, "reset"),
4406
+ className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4407
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RotateCcwIcon, {
4408
+ className: "size-3.5",
4409
+ "aria-hidden": "true"
4410
+ })
4411
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4412
+ type: "button",
4413
+ title: t("openapi.clear"),
4414
+ "aria-label": t("openapi.clear"),
4415
+ onClick: () => setParameterGroupValues(grouped, "clear"),
4416
+ className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4417
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EraserIcon, {
4418
+ className: "size-3.5",
4419
+ "aria-hidden": "true"
4420
+ })
4421
+ })] });
4422
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4423
+ title: parameterGroupLabel(location, t),
4424
+ count: grouped.length,
4425
+ defaultOpen: true,
4426
+ actions,
4427
+ children: location === "cookie" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4428
+ className: "px-3 py-4 text-xs/5 text-(--clarify-ui-text-faint)",
4429
+ children: t("openapi.cookieParametersBrowserManaged")
4430
+ }) : grouped.map(renderParameterField)
4431
+ }, location);
4432
+ }
4433
+ function renderHeader() {
4434
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4435
+ className: "flex min-w-0 items-center gap-1.5 border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-2",
4436
+ children: [
4437
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: method.toUpperCase() }),
4438
+ servers.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
4439
+ label: t("openapi.server"),
4440
+ value: selectedServerKey,
4441
+ options: servers.map((server, index) => ({
4442
+ value: getServerKey(server, index),
4443
+ label: server.url ?? `Server ${index + 1}`,
4444
+ description: server.description
4445
+ })),
4446
+ onChange: selectServer,
4447
+ className: "min-w-0 max-w-48 shrink sm:max-w-48",
4448
+ buttonClassName: "flex h-8 min-w-0 max-w-full items-center gap-1 rounded-(--clarify-theme-tokens-radius-md) px-2 text-xs font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)"
4449
+ }) : null,
4450
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4451
+ className: "min-w-0 flex-1 overflow-x-auto border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
4452
+ children: path || "/"
4453
+ }),
4454
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
4455
+ label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
4456
+ busy: sending,
4457
+ text: t("openapi.sendRequest"),
4458
+ onClick: sendRequest
4459
+ }),
4460
+ onClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4461
+ type: "button",
4462
+ onClick: onClose,
4463
+ "aria-label": t("openapi.closeRequest"),
4464
+ title: t("openapi.closeRequest"),
4465
+ className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4466
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XIcon, {
4467
+ className: "size-4",
4468
+ "aria-hidden": "true"
4469
+ })
4470
+ }) : null
4471
+ ]
4472
+ });
4473
+ }
4474
+ function renderVariables() {
4475
+ if (serverVariableEntries.length === 0) return null;
4476
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4477
+ title: t("openapi.variables"),
4478
+ count: serverVariableEntries.length,
4479
+ defaultOpen: true,
4480
+ children: serverVariableEntries.map(([name, variable]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
4481
+ className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
4482
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4483
+ className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
4484
+ children: name
4485
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4486
+ value: serverVariables[name] ?? variable.default ?? "",
4487
+ onChange: (event) => setServerVariables((current) => ({
4488
+ ...current,
4489
+ [name]: event.target.value
4490
+ })),
4491
+ className: "h-8 min-w-0 border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background) focus:ring-0"
4492
+ })]
4493
+ }, name))
4494
+ });
4495
+ }
4496
+ function renderRequestBody() {
4497
+ if (requestContents.length === 0) return null;
4498
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RequestSection, {
4499
+ title: t("openapi.requestBody"),
4500
+ count: 1,
4501
+ defaultOpen: true,
4502
+ className: "open:grid open:min-h-55 open:grow open:shrink open:basis-55 open:grid-rows-[auto_minmax(11rem,1fr)]",
4503
+ contentClassName: (0, clsx.default)("grid h-full min-h-0", requestContents.length > 1 ? "grid-rows-[auto_minmax(11rem,1fr)]" : "grid-rows-[minmax(11rem,1fr)]"),
4504
+ children: [requestContents.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
4505
+ label: t("openapi.mediaType"),
4506
+ value: mediaType,
4507
+ options: requestContents.map((entry) => ({
4508
+ value: entry.mediaType,
4509
+ label: entry.mediaType
4510
+ })),
4511
+ onChange: selectMediaType
4512
+ }) }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
4513
+ "aria-label": t("openapi.requestBody"),
4514
+ value: body,
4515
+ onChange: (event) => setBody(event.target.value),
4516
+ spellCheck: false,
4517
+ className: "block h-full min-h-44 w-full resize-none border-0 bg-(--clarify-code-background) p-3 font-mono text-xs/5 text-(--clarify-code-text) outline-hidden focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary)"
4518
+ })]
4519
+ });
4520
+ }
4521
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4522
+ className: (0, clsx.default)("clarify-api-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-theme-tokens-radius-lg:6px] [--clarify-theme-tokens-radius-md:4px] [--clarify-theme-tokens-radius-sm:2px] [--clarify-theme-tokens-radius-xl:8px] [--clarify-ui-accent-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_10%,transparent)] [--clarify-ui-accent-border:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_22%,transparent)] [--clarify-ui-accent-text:var(--clarify-theme-tokens-colors-foreground)] [--clarify-ui-active-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_12%,transparent)] [--clarify-ui-subtle-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_5%,transparent)]", compact ? "h-full" : "my-6"),
4523
+ children: [renderHeader(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4524
+ className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
4525
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4526
+ className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
4527
+ children: [
4528
+ authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4529
+ title: t("openapi.authentication"),
4530
+ count: selectedAuth?.schemes.length ?? 0,
4531
+ defaultOpen: true,
4532
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiAuthPanel, {
4533
+ authOptions,
4534
+ selectedAuthName,
4535
+ selectedAuth,
4536
+ authValues: credentials,
4537
+ onSelectAuth: setSelectedAuthName,
4538
+ onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
4539
+ onClearAuthValue: (name) => clearCredential(credentialScope, name)
4540
+ })
4541
+ }) : null,
4542
+ renderVariables(),
4543
+ pathParameters.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4544
+ title: t("openapi.pathParameters"),
4545
+ count: pathParameters.length,
4546
+ defaultOpen: true,
4547
+ children: pathParameters.map(renderParameterField)
4548
+ }) : null,
4549
+ parameterGroups.map(renderParameterGroup),
4550
+ renderRequestBody(),
4551
+ !hasRequestConfiguration ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4552
+ title: t("openapi.requestConfiguration"),
4553
+ count: 0,
4554
+ defaultOpen: true,
4555
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4556
+ className: "px-3 py-5 text-xs/5 text-(--clarify-ui-text-faint)",
4557
+ children: t("openapi.noRequestConfiguration")
4558
+ })
4559
+ }) : null
4560
+ ]
4561
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4562
+ className: "h-full min-h-0 min-w-0 overflow-hidden border-t border-(--clarify-theme-tokens-colors-border) lg:border-t-0 lg:border-l",
4563
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiResponseViewer, {
4564
+ exchange,
4565
+ error
4566
+ })
4567
+ })]
4568
+ })]
4569
+ });
4570
+ }
4571
+ function OpenApiRequestDialog(arg0) {
4572
+ const { open, onClose, ...workbenchProps } = arg0;
4573
+ const t = require_i18n.useBuiltInText();
4574
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.Dialog, {
4575
+ open,
4576
+ onClose: () => {},
4577
+ className: "relative z-50",
4578
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4579
+ className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
4580
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.DialogPanel, {
4581
+ className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-lg border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
4582
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogTitle, {
4583
+ className: "sr-only",
4584
+ children: t("openapi.tryRequest")
4585
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestWorkbench, {
4586
+ ...workbenchProps,
4587
+ compact: true,
4588
+ onClose
4589
+ })]
4590
+ })
4591
+ })]
4592
+ });
4593
+ }
4594
+ //#endregion
4595
+ //#region source/openapi/components/OpenApiOperation.tsx
3205
4596
  function EndpointPath(arg0) {
3206
4597
  const { path, copied = false, onCopy } = arg0;
3207
4598
  const t = require_i18n.useBuiltInText();
@@ -3401,51 +4792,9 @@ function ServerPanel(arg0) {
3401
4792
  })
3402
4793
  });
3403
4794
  }
3404
- function AuthPanel(arg0) {
3405
- const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
3406
- if (authOptions.length === 0) return null;
3407
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3408
- className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) p-3",
3409
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3410
- className: "grid gap-3 sm:grid-cols-(--clarify-openapi-control-grid)",
3411
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3412
- className: "flex min-w-0 flex-col gap-1.5",
3413
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3414
- className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
3415
- children: "Auth"
3416
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3417
- label: "Auth",
3418
- value: selectedAuthName,
3419
- options: authOptions.map(({ name, scheme }) => ({
3420
- value: name,
3421
- label: name,
3422
- description: authLabel(name, scheme)
3423
- })),
3424
- onChange: onSelectAuth
3425
- })]
3426
- }), selectedAuth ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3427
- className: "flex min-w-0 flex-col gap-1.5",
3428
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3429
- className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
3430
- children: "Credential"
3431
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3432
- className: "flex min-w-0 items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 shadow-xs",
3433
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3434
- className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
3435
- children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
3436
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3437
- value: authValues[selectedAuth.name] ?? "",
3438
- placeholder: authPlaceholder(selectedAuth),
3439
- onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
3440
- className: "min-w-0 flex-1 border-0 bg-transparent px-0 py-0 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
3441
- })]
3442
- })]
3443
- }) : null]
3444
- })
3445
- });
3446
- }
3447
4795
  function EndpointIdentity(arg0) {
3448
- const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
4796
+ const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, onSelectServer, onChangeServerVariable, onToggleServer, onTryRequest } = arg0;
4797
+ const t = require_i18n.useBuiltInText();
3449
4798
  const directServerSelect = servers.length > 1 && servers.every((server) => Object.keys(server.variables ?? {}).length === 0);
3450
4799
  const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
3451
4800
  const [copiedUrl, setCopiedUrl] = (0, react.useState)(false);
@@ -3460,61 +4809,40 @@ function EndpointIdentity(arg0) {
3460
4809
  }
3461
4810
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3462
4811
  className: "clarify-openai-endpoint-identity not-prose flex w-full flex-col overflow-hidden rounded-xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-xs",
3463
- children: [
3464
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3465
- className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
3466
- children: [
3467
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
3468
- operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
3469
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
3470
- servers,
3471
- selectedKey: selectedServerKey,
3472
- server: selectedServer,
3473
- variables: serverVariables,
3474
- open: serverOpen,
3475
- interactive: serverInteractive,
3476
- directSelect: directServerSelect,
3477
- onSelect: onSelectServer,
3478
- onToggle: onToggleServer
3479
- }),
3480
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, {
3481
- path,
3482
- copied: copiedUrl,
3483
- onCopy: handleCopyUrl
3484
- }),
3485
- authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3486
- type: "button",
3487
- "aria-expanded": authOpen,
3488
- "aria-label": "Auth",
3489
- onClick: onToggleAuth,
3490
- className: (0, clsx.default)("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
3491
- children: authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.UnlockKeyholeIcon, {
3492
- className: "h-4 w-4",
3493
- "aria-hidden": "true"
3494
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LockKeyholeIcon, {
3495
- className: "h-4 w-4",
3496
- "aria-hidden": "true"
3497
- })
3498
- }) : null
3499
- ]
3500
- }),
3501
- serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
3502
- servers,
3503
- selectedKey: selectedServerKey,
3504
- selectedServer,
3505
- variables: serverVariables,
3506
- onSelectServer,
3507
- onChangeVariable: onChangeServerVariable
3508
- }) : null,
3509
- authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AuthPanel, {
3510
- authOptions,
3511
- selectedAuthName,
3512
- selectedAuth,
3513
- authValues,
3514
- onSelectAuth,
3515
- onChangeAuthValue
3516
- }) : null
3517
- ]
4812
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4813
+ className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
4814
+ children: [
4815
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
4816
+ operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
4817
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
4818
+ servers,
4819
+ selectedKey: selectedServerKey,
4820
+ server: selectedServer,
4821
+ variables: serverVariables,
4822
+ open: serverOpen,
4823
+ interactive: serverInteractive,
4824
+ directSelect: directServerSelect,
4825
+ onSelect: onSelectServer,
4826
+ onToggle: onToggleServer
4827
+ }),
4828
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, {
4829
+ path,
4830
+ copied: copiedUrl,
4831
+ onCopy: handleCopyUrl
4832
+ }),
4833
+ onTryRequest ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
4834
+ label: t("openapi.tryRequest"),
4835
+ onClick: onTryRequest
4836
+ }) : null
4837
+ ]
4838
+ }), serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
4839
+ servers,
4840
+ selectedKey: selectedServerKey,
4841
+ selectedServer,
4842
+ variables: serverVariables,
4843
+ onSelectServer,
4844
+ onChangeVariable: onChangeServerVariable
4845
+ }) : null]
3518
4846
  });
3519
4847
  }
3520
4848
  function OpenApiOperation(arg0) {
@@ -3527,6 +4855,7 @@ function OpenApiOperation(arg0) {
3527
4855
  const authState = useOperationAuthState(spec, operation);
3528
4856
  const [linkedExampleKey, setLinkedExampleKey] = (0, react.useState)("");
3529
4857
  const [selectedResponseStatus, setSelectedResponseStatus] = (0, react.useState)(() => getDefaultResponseStatus(operation, spec));
4858
+ const [requestOpen, setRequestOpen] = (0, react.useState)(false);
3530
4859
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3531
4860
  className: "clarify-openai-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
3532
4861
  "aria-labelledby": id,
@@ -3544,23 +4873,19 @@ function OpenApiOperation(arg0) {
3544
4873
  selectedServer: serverState.selectedServer,
3545
4874
  serverVariables: serverState.serverVariables,
3546
4875
  serverOpen: serverState.serverOpen,
3547
- authOptions: authState.authOptions,
3548
- selectedAuthName: authState.selectedAuthName,
3549
- selectedAuth: authState.selectedAuth,
3550
- authValues: authState.authValues,
3551
- authOpen: authState.authOpen,
3552
4876
  onSelectServer: serverState.onSelectServer,
3553
4877
  onChangeServerVariable: serverState.onChangeServerVariable,
3554
- onToggleServer: () => {
3555
- serverState.onToggleServer();
3556
- authState.closeAuth();
3557
- },
3558
- onToggleAuth: () => {
3559
- authState.onToggleAuth();
3560
- serverState.closeServer();
3561
- },
3562
- onSelectAuth: authState.onSelectAuth,
3563
- onChangeAuthValue: authState.onChangeAuthValue
4878
+ onToggleServer: serverState.onToggleServer,
4879
+ onTryRequest: () => setRequestOpen(true)
4880
+ }),
4881
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestDialog, {
4882
+ open: requestOpen,
4883
+ onClose: () => setRequestOpen(false),
4884
+ spec,
4885
+ path,
4886
+ method,
4887
+ operation,
4888
+ operationSource
3564
4889
  }),
3565
4890
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointRequest, {
3566
4891
  spec,
@@ -3690,6 +5015,12 @@ Object.defineProperty(exports, "OpenApiOperation", {
3690
5015
  return OpenApiOperation;
3691
5016
  }
3692
5017
  });
5018
+ Object.defineProperty(exports, "OpenApiRequestWorkbench", {
5019
+ enumerable: true,
5020
+ get: function() {
5021
+ return OpenApiRequestWorkbench;
5022
+ }
5023
+ });
3693
5024
  Object.defineProperty(exports, "Pre", {
3694
5025
  enumerable: true,
3695
5026
  get: function() {
@@ -3811,4 +5142,4 @@ Object.defineProperty(exports, "primitives_exports", {
3811
5142
  }
3812
5143
  });
3813
5144
 
3814
- //# sourceMappingURL=OpenApiOperation-DbZjxIuj.cjs.map
5145
+ //# sourceMappingURL=OpenApiOperation-D-5uE5v7.cjs.map