@apiboost/omnispec 1.0.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 (347) hide show
  1. package/LICENSE.md +202 -0
  2. package/README.md +166 -0
  3. package/core/package.json +5 -0
  4. package/dist/cjs/asyncapi/index.js +17 -0
  5. package/dist/cjs/asyncapi/index.js.map +1 -0
  6. package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js +819 -0
  7. package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js.map +1 -0
  8. package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js +7527 -0
  9. package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js.map +1 -0
  10. package/dist/cjs/chunks/ErrorBoundary-c1piU8da.js +36 -0
  11. package/dist/cjs/chunks/ErrorBoundary-c1piU8da.js.map +1 -0
  12. package/dist/cjs/chunks/OmniSpecRenderer-CE4wxVTL.js +104 -0
  13. package/dist/cjs/chunks/OmniSpecRenderer-CE4wxVTL.js.map +1 -0
  14. package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js +3157 -0
  15. package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js.map +1 -0
  16. package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js +2416 -0
  17. package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js.map +1 -0
  18. package/dist/cjs/chunks/RendererRegistry-DQ7JBLMT.js +24 -0
  19. package/dist/cjs/chunks/RendererRegistry-DQ7JBLMT.js.map +1 -0
  20. package/dist/cjs/chunks/binary-response-CSrPCI-1.js +77 -0
  21. package/dist/cjs/chunks/binary-response-CSrPCI-1.js.map +1 -0
  22. package/dist/cjs/chunks/ref-resolver-DWu6Q6E5.js +7108 -0
  23. package/dist/cjs/chunks/ref-resolver-DWu6Q6E5.js.map +1 -0
  24. package/dist/cjs/chunks/ssrf-guard-B6T2A7Ho.js +25 -0
  25. package/dist/cjs/chunks/ssrf-guard-B6T2A7Ho.js.map +1 -0
  26. package/dist/cjs/chunks/useSpecDetector-A4OwYrmY.js +252 -0
  27. package/dist/cjs/chunks/useSpecDetector-A4OwYrmY.js.map +1 -0
  28. package/dist/cjs/chunks/useSpecFetcher-BKz1jHTV.js +13669 -0
  29. package/dist/cjs/chunks/useSpecFetcher-BKz1jHTV.js.map +1 -0
  30. package/dist/cjs/core/public.js +198 -0
  31. package/dist/cjs/core/public.js.map +1 -0
  32. package/dist/cjs/index.js +36 -0
  33. package/dist/cjs/index.js.map +1 -0
  34. package/dist/cjs/openapi/index.js +19 -0
  35. package/dist/cjs/openapi/index.js.map +1 -0
  36. package/dist/cjs/server/index.js +154 -0
  37. package/dist/cjs/server/index.js.map +1 -0
  38. package/dist/cjs/wc/index.js +428 -0
  39. package/dist/cjs/wc/index.js.map +1 -0
  40. package/dist/esm/asyncapi/index.js +11 -0
  41. package/dist/esm/asyncapi/index.js.map +1 -0
  42. package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js +817 -0
  43. package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js.map +1 -0
  44. package/dist/esm/chunks/Collapsible-DA6-nS46.js +7482 -0
  45. package/dist/esm/chunks/Collapsible-DA6-nS46.js.map +1 -0
  46. package/dist/esm/chunks/ErrorBoundary-posRNrbt.js +34 -0
  47. package/dist/esm/chunks/ErrorBoundary-posRNrbt.js.map +1 -0
  48. package/dist/esm/chunks/OmniSpecRenderer-MqsQFXro.js +102 -0
  49. package/dist/esm/chunks/OmniSpecRenderer-MqsQFXro.js.map +1 -0
  50. package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js +3153 -0
  51. package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js.map +1 -0
  52. package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js +2393 -0
  53. package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js.map +1 -0
  54. package/dist/esm/chunks/RendererRegistry-zlh-WYbU.js +21 -0
  55. package/dist/esm/chunks/RendererRegistry-zlh-WYbU.js.map +1 -0
  56. package/dist/esm/chunks/binary-response-Cre_H-Rt.js +72 -0
  57. package/dist/esm/chunks/binary-response-Cre_H-Rt.js.map +1 -0
  58. package/dist/esm/chunks/ref-resolver-BIrHJOjz.js +7105 -0
  59. package/dist/esm/chunks/ref-resolver-BIrHJOjz.js.map +1 -0
  60. package/dist/esm/chunks/ssrf-guard-CsZoYdEq.js +23 -0
  61. package/dist/esm/chunks/ssrf-guard-CsZoYdEq.js.map +1 -0
  62. package/dist/esm/chunks/useSpecDetector-5SGcKnJx.js +248 -0
  63. package/dist/esm/chunks/useSpecDetector-5SGcKnJx.js.map +1 -0
  64. package/dist/esm/chunks/useSpecFetcher-CZvAnU7Z.js +13625 -0
  65. package/dist/esm/chunks/useSpecFetcher-CZvAnU7Z.js.map +1 -0
  66. package/dist/esm/core/public.js +102 -0
  67. package/dist/esm/core/public.js.map +1 -0
  68. package/dist/esm/index.js +17 -0
  69. package/dist/esm/index.js.map +1 -0
  70. package/dist/esm/openapi/index.js +13 -0
  71. package/dist/esm/openapi/index.js.map +1 -0
  72. package/dist/esm/server/index.js +152 -0
  73. package/dist/esm/server/index.js.map +1 -0
  74. package/dist/esm/wc/index.js +403 -0
  75. package/dist/esm/wc/index.js.map +1 -0
  76. package/dist/types/asyncapi/AsyncApiSpec.d.ts +12 -0
  77. package/dist/types/asyncapi/AsyncApiSpec.d.ts.map +1 -0
  78. package/dist/types/asyncapi/components/AsyncOverview.d.ts +16 -0
  79. package/dist/types/asyncapi/components/AsyncOverview.d.ts.map +1 -0
  80. package/dist/types/asyncapi/components/ChannelDetail.d.ts +19 -0
  81. package/dist/types/asyncapi/components/ChannelDetail.d.ts.map +1 -0
  82. package/dist/types/asyncapi/components/ComponentsSection.d.ts +16 -0
  83. package/dist/types/asyncapi/components/ComponentsSection.d.ts.map +1 -0
  84. package/dist/types/asyncapi/components/ProtocolBadge.d.ts +16 -0
  85. package/dist/types/asyncapi/components/ProtocolBadge.d.ts.map +1 -0
  86. package/dist/types/asyncapi/components/ServerList.d.ts +16 -0
  87. package/dist/types/asyncapi/components/ServerList.d.ts.map +1 -0
  88. package/dist/types/asyncapi/hooks/useAsyncApiSpec.d.ts +12 -0
  89. package/dist/types/asyncapi/hooks/useAsyncApiSpec.d.ts.map +1 -0
  90. package/dist/types/asyncapi/index.d.ts +11 -0
  91. package/dist/types/asyncapi/index.d.ts.map +1 -0
  92. package/dist/types/asyncapi/parser/asyncapi-parser.d.ts +12 -0
  93. package/dist/types/asyncapi/parser/asyncapi-parser.d.ts.map +1 -0
  94. package/dist/types/asyncapi/types/asyncapi.types.d.ts +125 -0
  95. package/dist/types/asyncapi/types/asyncapi.types.d.ts.map +1 -0
  96. package/dist/types/core/components/Auth/ApiKeyAuth.d.ts +30 -0
  97. package/dist/types/core/components/Auth/ApiKeyAuth.d.ts.map +1 -0
  98. package/dist/types/core/components/Auth/AuthPanel.d.ts +18 -0
  99. package/dist/types/core/components/Auth/AuthPanel.d.ts.map +1 -0
  100. package/dist/types/core/components/Auth/AuthPanelModal.d.ts +24 -0
  101. package/dist/types/core/components/Auth/AuthPanelModal.d.ts.map +1 -0
  102. package/dist/types/core/components/Auth/BasicAuth.d.ts +20 -0
  103. package/dist/types/core/components/Auth/BasicAuth.d.ts.map +1 -0
  104. package/dist/types/core/components/Auth/BearerAuth.d.ts +20 -0
  105. package/dist/types/core/components/Auth/BearerAuth.d.ts.map +1 -0
  106. package/dist/types/core/components/Auth/OAuth2AuthManual.d.ts +37 -0
  107. package/dist/types/core/components/Auth/OAuth2AuthManual.d.ts.map +1 -0
  108. package/dist/types/core/components/Auth/OpenIdConnectManual.d.ts +33 -0
  109. package/dist/types/core/components/Auth/OpenIdConnectManual.d.ts.map +1 -0
  110. package/dist/types/core/components/Auth/SecretInput.d.ts +27 -0
  111. package/dist/types/core/components/Auth/SecretInput.d.ts.map +1 -0
  112. package/dist/types/core/components/Auth/index.d.ts +16 -0
  113. package/dist/types/core/components/Auth/index.d.ts.map +1 -0
  114. package/dist/types/core/components/CodeBlock/CodeBlock.d.ts +32 -0
  115. package/dist/types/core/components/CodeBlock/CodeBlock.d.ts.map +1 -0
  116. package/dist/types/core/components/CodeBlock/index.d.ts +12 -0
  117. package/dist/types/core/components/CodeBlock/index.d.ts.map +1 -0
  118. package/dist/types/core/components/Layout/DocLayout.d.ts +24 -0
  119. package/dist/types/core/components/Layout/DocLayout.d.ts.map +1 -0
  120. package/dist/types/core/components/Layout/MobileDrawerDismissContext.d.ts +20 -0
  121. package/dist/types/core/components/Layout/MobileDrawerDismissContext.d.ts.map +1 -0
  122. package/dist/types/core/components/Layout/SpecStatusScreen.d.ts +38 -0
  123. package/dist/types/core/components/Layout/SpecStatusScreen.d.ts.map +1 -0
  124. package/dist/types/core/components/Layout/index.d.ts +11 -0
  125. package/dist/types/core/components/Layout/index.d.ts.map +1 -0
  126. package/dist/types/core/components/MarkdownRenderer/MarkdownRenderer.d.ts +16 -0
  127. package/dist/types/core/components/MarkdownRenderer/MarkdownRenderer.d.ts.map +1 -0
  128. package/dist/types/core/components/MarkdownRenderer/index.d.ts +11 -0
  129. package/dist/types/core/components/MarkdownRenderer/index.d.ts.map +1 -0
  130. package/dist/types/core/components/Navigation/CustomNavSection.d.ts +16 -0
  131. package/dist/types/core/components/Navigation/CustomNavSection.d.ts.map +1 -0
  132. package/dist/types/core/components/Navigation/NavTree.d.ts +32 -0
  133. package/dist/types/core/components/Navigation/NavTree.d.ts.map +1 -0
  134. package/dist/types/core/components/Navigation/SearchBar.d.ts +16 -0
  135. package/dist/types/core/components/Navigation/SearchBar.d.ts.map +1 -0
  136. package/dist/types/core/components/Navigation/buildSidebar.d.ts +13 -0
  137. package/dist/types/core/components/Navigation/buildSidebar.d.ts.map +1 -0
  138. package/dist/types/core/components/Navigation/index.d.ts +13 -0
  139. package/dist/types/core/components/Navigation/index.d.ts.map +1 -0
  140. package/dist/types/core/components/Reference/ReferenceLayout.d.ts +19 -0
  141. package/dist/types/core/components/Reference/ReferenceLayout.d.ts.map +1 -0
  142. package/dist/types/core/components/Reference/ReferenceOperationDetail.d.ts +42 -0
  143. package/dist/types/core/components/Reference/ReferenceOperationDetail.d.ts.map +1 -0
  144. package/dist/types/core/components/Reference/SamplesPanel.d.ts +33 -0
  145. package/dist/types/core/components/Reference/SamplesPanel.d.ts.map +1 -0
  146. package/dist/types/core/components/SchemaViewer/SchemaPresentation.d.ts +147 -0
  147. package/dist/types/core/components/SchemaViewer/SchemaPresentation.d.ts.map +1 -0
  148. package/dist/types/core/components/SchemaViewer/SchemaPrimitives.d.ts +66 -0
  149. package/dist/types/core/components/SchemaViewer/SchemaPrimitives.d.ts.map +1 -0
  150. package/dist/types/core/components/SchemaViewer/SchemaTable.d.ts +16 -0
  151. package/dist/types/core/components/SchemaViewer/SchemaTable.d.ts.map +1 -0
  152. package/dist/types/core/components/SchemaViewer/SchemaTree.d.ts +26 -0
  153. package/dist/types/core/components/SchemaViewer/SchemaTree.d.ts.map +1 -0
  154. package/dist/types/core/components/SchemaViewer/index.d.ts +16 -0
  155. package/dist/types/core/components/SchemaViewer/index.d.ts.map +1 -0
  156. package/dist/types/core/components/SchemaViewer/schema-style.d.ts +45 -0
  157. package/dist/types/core/components/SchemaViewer/schema-style.d.ts.map +1 -0
  158. package/dist/types/core/components/SchemaViewer/schema-utils.d.ts +83 -0
  159. package/dist/types/core/components/SchemaViewer/schema-utils.d.ts.map +1 -0
  160. package/dist/types/core/components/TryIt/CodeSamples.d.ts +26 -0
  161. package/dist/types/core/components/TryIt/CodeSamples.d.ts.map +1 -0
  162. package/dist/types/core/components/TryIt/CustomHeaders.d.ts +24 -0
  163. package/dist/types/core/components/TryIt/CustomHeaders.d.ts.map +1 -0
  164. package/dist/types/core/components/TryIt/InlineTryIt.d.ts +26 -0
  165. package/dist/types/core/components/TryIt/InlineTryIt.d.ts.map +1 -0
  166. package/dist/types/core/components/TryIt/ParameterForm.d.ts +34 -0
  167. package/dist/types/core/components/TryIt/ParameterForm.d.ts.map +1 -0
  168. package/dist/types/core/components/TryIt/RequestBodyEditor.d.ts +34 -0
  169. package/dist/types/core/components/TryIt/RequestBodyEditor.d.ts.map +1 -0
  170. package/dist/types/core/components/TryIt/ResponseViewer.d.ts +18 -0
  171. package/dist/types/core/components/TryIt/ResponseViewer.d.ts.map +1 -0
  172. package/dist/types/core/components/TryIt/TryItPanel.d.ts +38 -0
  173. package/dist/types/core/components/TryIt/TryItPanel.d.ts.map +1 -0
  174. package/dist/types/core/components/TryIt/code-generators.d.ts +23 -0
  175. package/dist/types/core/components/TryIt/code-generators.d.ts.map +1 -0
  176. package/dist/types/core/components/TryIt/curl-generator.d.ts +12 -0
  177. package/dist/types/core/components/TryIt/curl-generator.d.ts.map +1 -0
  178. package/dist/types/core/components/TryIt/index.d.ts +16 -0
  179. package/dist/types/core/components/TryIt/index.d.ts.map +1 -0
  180. package/dist/types/core/components/common/Badge.d.ts +19 -0
  181. package/dist/types/core/components/common/Badge.d.ts.map +1 -0
  182. package/dist/types/core/components/common/Button.d.ts +44 -0
  183. package/dist/types/core/components/common/Button.d.ts.map +1 -0
  184. package/dist/types/core/components/common/Collapsible.d.ts +23 -0
  185. package/dist/types/core/components/common/Collapsible.d.ts.map +1 -0
  186. package/dist/types/core/components/common/CopyButton.d.ts +16 -0
  187. package/dist/types/core/components/common/CopyButton.d.ts.map +1 -0
  188. package/dist/types/core/components/common/ErrorBoundary.d.ts +40 -0
  189. package/dist/types/core/components/common/ErrorBoundary.d.ts.map +1 -0
  190. package/dist/types/core/components/common/ErrorMessage.d.ts +16 -0
  191. package/dist/types/core/components/common/ErrorMessage.d.ts.map +1 -0
  192. package/dist/types/core/components/common/ExampleSelector.d.ts +29 -0
  193. package/dist/types/core/components/common/ExampleSelector.d.ts.map +1 -0
  194. package/dist/types/core/components/common/ExpandableCard.d.ts +27 -0
  195. package/dist/types/core/components/common/ExpandableCard.d.ts.map +1 -0
  196. package/dist/types/core/components/common/Icon.d.ts +53 -0
  197. package/dist/types/core/components/common/Icon.d.ts.map +1 -0
  198. package/dist/types/core/components/common/LinkableHeading.d.ts +19 -0
  199. package/dist/types/core/components/common/LinkableHeading.d.ts.map +1 -0
  200. package/dist/types/core/components/common/LoadingScreen.d.ts +13 -0
  201. package/dist/types/core/components/common/LoadingScreen.d.ts.map +1 -0
  202. package/dist/types/core/components/common/MethodBar.d.ts +18 -0
  203. package/dist/types/core/components/common/MethodBar.d.ts.map +1 -0
  204. package/dist/types/core/components/common/Modal.d.ts +19 -0
  205. package/dist/types/core/components/common/Modal.d.ts.map +1 -0
  206. package/dist/types/core/components/common/ResponsiveColumns.d.ts +17 -0
  207. package/dist/types/core/components/common/ResponsiveColumns.d.ts.map +1 -0
  208. package/dist/types/core/components/common/SpecToolbar.d.ts +27 -0
  209. package/dist/types/core/components/common/SpecToolbar.d.ts.map +1 -0
  210. package/dist/types/core/components/common/Tabs.d.ts +29 -0
  211. package/dist/types/core/components/common/Tabs.d.ts.map +1 -0
  212. package/dist/types/core/components/common/Tooltip.d.ts +17 -0
  213. package/dist/types/core/components/common/Tooltip.d.ts.map +1 -0
  214. package/dist/types/core/components/common/UpgradePrompt.d.ts +18 -0
  215. package/dist/types/core/components/common/UpgradePrompt.d.ts.map +1 -0
  216. package/dist/types/core/components/common/index.d.ts +18 -0
  217. package/dist/types/core/components/common/index.d.ts.map +1 -0
  218. package/dist/types/core/context/AuthContext.d.ts +35 -0
  219. package/dist/types/core/context/AuthContext.d.ts.map +1 -0
  220. package/dist/types/core/context/ConfigContext.d.ts +55 -0
  221. package/dist/types/core/context/ConfigContext.d.ts.map +1 -0
  222. package/dist/types/core/context/ExpandContext.d.ts +33 -0
  223. package/dist/types/core/context/ExpandContext.d.ts.map +1 -0
  224. package/dist/types/core/context/RendererRegistry.d.ts +24 -0
  225. package/dist/types/core/context/RendererRegistry.d.ts.map +1 -0
  226. package/dist/types/core/context/index.d.ts +14 -0
  227. package/dist/types/core/context/index.d.ts.map +1 -0
  228. package/dist/types/core/hooks/index.d.ts +12 -0
  229. package/dist/types/core/hooks/index.d.ts.map +1 -0
  230. package/dist/types/core/hooks/useHashScroll.d.ts +15 -0
  231. package/dist/types/core/hooks/useHashScroll.d.ts.map +1 -0
  232. package/dist/types/core/hooks/useScrollSpy.d.ts +33 -0
  233. package/dist/types/core/hooks/useScrollSpy.d.ts.map +1 -0
  234. package/dist/types/core/hooks/useSegmentedRouter.d.ts +19 -0
  235. package/dist/types/core/hooks/useSegmentedRouter.d.ts.map +1 -0
  236. package/dist/types/core/hooks/useSpecDetector.d.ts +13 -0
  237. package/dist/types/core/hooks/useSpecDetector.d.ts.map +1 -0
  238. package/dist/types/core/hooks/useSpecFetcher.d.ts +17 -0
  239. package/dist/types/core/hooks/useSpecFetcher.d.ts.map +1 -0
  240. package/dist/types/core/public.d.ts +86 -0
  241. package/dist/types/core/public.d.ts.map +1 -0
  242. package/dist/types/core/styles/breakpoints.d.ts +33 -0
  243. package/dist/types/core/styles/breakpoints.d.ts.map +1 -0
  244. package/dist/types/core/styles/css.d.ts +17 -0
  245. package/dist/types/core/styles/css.d.ts.map +1 -0
  246. package/dist/types/core/styles/styled.d.ts +25 -0
  247. package/dist/types/core/styles/styled.d.ts.map +1 -0
  248. package/dist/types/core/themes/ThemeProvider.d.ts +25 -0
  249. package/dist/types/core/themes/ThemeProvider.d.ts.map +1 -0
  250. package/dist/types/core/themes/index.d.ts +12 -0
  251. package/dist/types/core/themes/index.d.ts.map +1 -0
  252. package/dist/types/core/themes/tokens.d.ts +13 -0
  253. package/dist/types/core/themes/tokens.d.ts.map +1 -0
  254. package/dist/types/core/types/auth.types.d.ts +83 -0
  255. package/dist/types/core/types/auth.types.d.ts.map +1 -0
  256. package/dist/types/core/types/common.types.d.ts +141 -0
  257. package/dist/types/core/types/common.types.d.ts.map +1 -0
  258. package/dist/types/core/types/index.d.ts +16 -0
  259. package/dist/types/core/types/index.d.ts.map +1 -0
  260. package/dist/types/core/types/interactive-auth.types.d.ts +37 -0
  261. package/dist/types/core/types/interactive-auth.types.d.ts.map +1 -0
  262. package/dist/types/core/types/sidebar-nav.types.d.ts +41 -0
  263. package/dist/types/core/types/sidebar-nav.types.d.ts.map +1 -0
  264. package/dist/types/core/types/spec-detection.types.d.ts +26 -0
  265. package/dist/types/core/types/spec-detection.types.d.ts.map +1 -0
  266. package/dist/types/core/types/theme.types.d.ts +119 -0
  267. package/dist/types/core/types/theme.types.d.ts.map +1 -0
  268. package/dist/types/core/types/try-it.types.d.ts +50 -0
  269. package/dist/types/core/types/try-it.types.d.ts.map +1 -0
  270. package/dist/types/core/utils/binary-response.d.ts +24 -0
  271. package/dist/types/core/utils/binary-response.d.ts.map +1 -0
  272. package/dist/types/core/utils/detect-spec.d.ts +12 -0
  273. package/dist/types/core/utils/detect-spec.d.ts.map +1 -0
  274. package/dist/types/core/utils/direct-client.d.ts +20 -0
  275. package/dist/types/core/utils/direct-client.d.ts.map +1 -0
  276. package/dist/types/core/utils/fetch-spec.d.ts +15 -0
  277. package/dist/types/core/utils/fetch-spec.d.ts.map +1 -0
  278. package/dist/types/core/utils/index.d.ts +14 -0
  279. package/dist/types/core/utils/index.d.ts.map +1 -0
  280. package/dist/types/core/utils/proxy-client.d.ts +19 -0
  281. package/dist/types/core/utils/proxy-client.d.ts.map +1 -0
  282. package/dist/types/core/utils/ref-security.d.ts +78 -0
  283. package/dist/types/core/utils/ref-security.d.ts.map +1 -0
  284. package/dist/types/core/utils/resolve-download-link.d.ts +23 -0
  285. package/dist/types/core/utils/resolve-download-link.d.ts.map +1 -0
  286. package/dist/types/core/utils/sanitize-html.d.ts +16 -0
  287. package/dist/types/core/utils/sanitize-html.d.ts.map +1 -0
  288. package/dist/types/core/utils/tryit-storage.d.ts +45 -0
  289. package/dist/types/core/utils/tryit-storage.d.ts.map +1 -0
  290. package/dist/types/index.d.ts +29 -0
  291. package/dist/types/index.d.ts.map +1 -0
  292. package/dist/types/openapi/OpenApiSpec.d.ts +12 -0
  293. package/dist/types/openapi/OpenApiSpec.d.ts.map +1 -0
  294. package/dist/types/openapi/components/ApiOverview.d.ts +19 -0
  295. package/dist/types/openapi/components/ApiOverview.d.ts.map +1 -0
  296. package/dist/types/openapi/components/CallbacksSection.d.ts +19 -0
  297. package/dist/types/openapi/components/CallbacksSection.d.ts.map +1 -0
  298. package/dist/types/openapi/components/ComponentsSection.d.ts +19 -0
  299. package/dist/types/openapi/components/ComponentsSection.d.ts.map +1 -0
  300. package/dist/types/openapi/components/EndpointCard.d.ts +20 -0
  301. package/dist/types/openapi/components/EndpointCard.d.ts.map +1 -0
  302. package/dist/types/openapi/components/OperationDetail.d.ts +28 -0
  303. package/dist/types/openapi/components/OperationDetail.d.ts.map +1 -0
  304. package/dist/types/openapi/components/OperationView.d.ts +19 -0
  305. package/dist/types/openapi/components/OperationView.d.ts.map +1 -0
  306. package/dist/types/openapi/components/SegmentedContent.d.ts +22 -0
  307. package/dist/types/openapi/components/SegmentedContent.d.ts.map +1 -0
  308. package/dist/types/openapi/components/ServerSelector.d.ts +18 -0
  309. package/dist/types/openapi/components/ServerSelector.d.ts.map +1 -0
  310. package/dist/types/openapi/components/TagGroup.d.ts +19 -0
  311. package/dist/types/openapi/components/TagGroup.d.ts.map +1 -0
  312. package/dist/types/openapi/hooks/useOpenApiSpec.d.ts +13 -0
  313. package/dist/types/openapi/hooks/useOpenApiSpec.d.ts.map +1 -0
  314. package/dist/types/openapi/index.d.ts +11 -0
  315. package/dist/types/openapi/index.d.ts.map +1 -0
  316. package/dist/types/openapi/parser/openapi-parser.d.ts +13 -0
  317. package/dist/types/openapi/parser/openapi-parser.d.ts.map +1 -0
  318. package/dist/types/openapi/parser/ref-resolver.d.ts +18 -0
  319. package/dist/types/openapi/parser/ref-resolver.d.ts.map +1 -0
  320. package/dist/types/openapi/search.d.ts +16 -0
  321. package/dist/types/openapi/search.d.ts.map +1 -0
  322. package/dist/types/openapi/types/openapi.types.d.ts +139 -0
  323. package/dist/types/openapi/types/openapi.types.d.ts.map +1 -0
  324. package/dist/types/server/index.d.ts +12 -0
  325. package/dist/types/server/index.d.ts.map +1 -0
  326. package/dist/types/server/proxy-router.d.ts +44 -0
  327. package/dist/types/server/proxy-router.d.ts.map +1 -0
  328. package/dist/types/server/ssrf-guard.d.ts +20 -0
  329. package/dist/types/server/ssrf-guard.d.ts.map +1 -0
  330. package/dist/types/test-setup.d.ts +11 -0
  331. package/dist/types/test-setup.d.ts.map +1 -0
  332. package/dist/types/unified/OmniSpecRenderer.d.ts +18 -0
  333. package/dist/types/unified/OmniSpecRenderer.d.ts.map +1 -0
  334. package/dist/types/unified/index.d.ts +12 -0
  335. package/dist/types/unified/index.d.ts.map +1 -0
  336. package/dist/types/wc/OmniSpecRendererElement.d.ts +48 -0
  337. package/dist/types/wc/OmniSpecRendererElement.d.ts.map +1 -0
  338. package/dist/types/wc/attribute-bridge.d.ts +96 -0
  339. package/dist/types/wc/attribute-bridge.d.ts.map +1 -0
  340. package/dist/types/wc/index.d.ts +42 -0
  341. package/dist/types/wc/index.d.ts.map +1 -0
  342. package/dist/types/wc/style-injection.d.ts +24 -0
  343. package/dist/types/wc/style-injection.d.ts.map +1 -0
  344. package/dist/wc/standalone.js +3 -0
  345. package/dist/wc/standalone.js.LICENSE.txt +65 -0
  346. package/dist/wc/standalone.js.map +1 -0
  347. package/package.json +167 -0
@@ -0,0 +1,2416 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var useSpecFetcher = require('./useSpecFetcher-BKz1jHTV.js');
6
+ var css = require('@emotion/css');
7
+ var Collapsible = require('./Collapsible-BHAHk_Ep.js');
8
+ var binaryResponse = require('./binary-response-CSrPCI-1.js');
9
+
10
+ const AUTH_KEY_PREFIX = "omnispec:auth";
11
+ function getStorage$1() {
12
+ try {
13
+ if (typeof window === "undefined" || !window.localStorage) return null;
14
+ if (typeof window.localStorage.setItem !== "function" || typeof window.localStorage.getItem !== "function") {
15
+ return null;
16
+ }
17
+ return window.localStorage;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function persistEnabled(ttlSeconds) {
23
+ return typeof ttlSeconds === "number" && Number.isFinite(ttlSeconds) && ttlSeconds > 0;
24
+ }
25
+ function authStorageKey(specKey) {
26
+ return `${AUTH_KEY_PREFIX}:${specKey}`;
27
+ }
28
+ function loadPersistedAuth(specKey, ttlSeconds) {
29
+ if (!specKey || !persistEnabled(ttlSeconds)) return /* @__PURE__ */ new Map();
30
+ const storage = getStorage$1();
31
+ if (!storage) return /* @__PURE__ */ new Map();
32
+ const key = authStorageKey(specKey);
33
+ try {
34
+ const raw = storage.getItem(key);
35
+ if (!raw) return /* @__PURE__ */ new Map();
36
+ const parsed = JSON.parse(raw);
37
+ if (!parsed || typeof parsed.savedAt !== "number" || !Array.isArray(parsed.values)) {
38
+ storage.removeItem(key);
39
+ return /* @__PURE__ */ new Map();
40
+ }
41
+ if (Date.now() - parsed.savedAt > ttlSeconds * 1e3) {
42
+ storage.removeItem(key);
43
+ return /* @__PURE__ */ new Map();
44
+ }
45
+ return new Map(parsed.values.filter((v) => v && v.schemeId).map((v) => [v.schemeId, v]));
46
+ } catch {
47
+ return /* @__PURE__ */ new Map();
48
+ }
49
+ }
50
+ function persistAuth(auth, specKey, ttlSeconds) {
51
+ if (!specKey) return;
52
+ const storage = getStorage$1();
53
+ if (!storage) return;
54
+ const key = authStorageKey(specKey);
55
+ try {
56
+ if (!persistEnabled(ttlSeconds) || auth.size === 0) {
57
+ storage.removeItem(key);
58
+ return;
59
+ }
60
+ const envelope = { savedAt: Date.now(), values: Array.from(auth.values()) };
61
+ storage.setItem(key, JSON.stringify(envelope));
62
+ } catch {
63
+ }
64
+ }
65
+ const AuthContext = React.createContext({
66
+ appliedAuth: /* @__PURE__ */ new Map(),
67
+ applyAuth: () => {
68
+ },
69
+ removeAuth: () => {
70
+ },
71
+ clearAuth: () => {
72
+ },
73
+ getAuthHeaders: () => ({}),
74
+ schemes: [],
75
+ hasAuth: false,
76
+ authPanelOpen: false,
77
+ openAuthPanel: () => {
78
+ },
79
+ closeAuthPanel: () => {
80
+ }
81
+ });
82
+ function useAuth() {
83
+ return React.useContext(AuthContext);
84
+ }
85
+ function AuthProvider({ children, schemes = [] }) {
86
+ const { specKey, tryItPersistTtl } = useSpecFetcher.useConfig();
87
+ const [appliedAuth, setAppliedAuth] = React.useState(
88
+ () => loadPersistedAuth(specKey, tryItPersistTtl)
89
+ );
90
+ const [authPanelOpen, setAuthPanelOpen] = React.useState(false);
91
+ React.useEffect(() => {
92
+ persistAuth(appliedAuth, specKey, tryItPersistTtl);
93
+ }, [appliedAuth, specKey, tryItPersistTtl]);
94
+ const applyAuth = React.useCallback((value2) => {
95
+ setAppliedAuth((prev) => {
96
+ const next = new Map(prev);
97
+ next.set(value2.schemeId, value2);
98
+ return next;
99
+ });
100
+ }, []);
101
+ const removeAuth = React.useCallback((schemeId) => {
102
+ setAppliedAuth((prev) => {
103
+ const next = new Map(prev);
104
+ next.delete(schemeId);
105
+ return next;
106
+ });
107
+ }, []);
108
+ const clearAuth = React.useCallback(() => {
109
+ setAppliedAuth(/* @__PURE__ */ new Map());
110
+ }, []);
111
+ const getAuthHeaders = React.useCallback(() => {
112
+ const headers = {};
113
+ for (const auth of appliedAuth.values()) {
114
+ headers[auth.headerName] = auth.headerValue;
115
+ }
116
+ return headers;
117
+ }, [appliedAuth]);
118
+ const openAuthPanel = React.useCallback(() => setAuthPanelOpen(true), []);
119
+ const closeAuthPanel = React.useCallback(() => setAuthPanelOpen(false), []);
120
+ const value = React.useMemo(() => ({
121
+ appliedAuth,
122
+ applyAuth,
123
+ removeAuth,
124
+ clearAuth,
125
+ getAuthHeaders,
126
+ schemes,
127
+ hasAuth: schemes.length > 0,
128
+ authPanelOpen,
129
+ openAuthPanel,
130
+ closeAuthPanel
131
+ }), [appliedAuth, applyAuth, removeAuth, clearAuth, getAuthHeaders, schemes, authPanelOpen, openAuthPanel, closeAuthPanel]);
132
+ return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
133
+ }
134
+
135
+ const MOBILE_TABS = [
136
+ { id: "schema", label: "Schema" },
137
+ { id: "samples", label: "Samples" },
138
+ { id: "try-it", label: "Try It" }
139
+ ];
140
+ const RIGHT_TABS = [
141
+ { id: "samples", label: "Samples" },
142
+ { id: "try-it", label: "Try It" }
143
+ ];
144
+ function ReferenceLayout({ schema, samples, tryIt, operationId }) {
145
+ const [rightTab, setRightTab] = React.useState("samples");
146
+ const [mobileTab, setMobileTab] = React.useState("schema");
147
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
148
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: mobileWrapperStyle, children: [
149
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: mobileTabBarStyle, role: "tablist", children: MOBILE_TABS.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(
150
+ "button",
151
+ {
152
+ type: "button",
153
+ role: "tab",
154
+ "aria-selected": mobileTab === tab.id,
155
+ "aria-controls": `mobile-panel-${operationId}-${tab.id}`,
156
+ onClick: () => setMobileTab(tab.id),
157
+ className: css.cx(mobileTabStyle, mobileTab === tab.id ? mobileTabActiveStyle : void 0),
158
+ children: tab.label
159
+ },
160
+ tab.id
161
+ )) }),
162
+ /* @__PURE__ */ jsxRuntime.jsxs(
163
+ "div",
164
+ {
165
+ id: `mobile-panel-${operationId}-${mobileTab}`,
166
+ className: mobileContentStyle,
167
+ role: "tabpanel",
168
+ children: [
169
+ mobileTab === "schema" && schema,
170
+ mobileTab === "samples" && samples,
171
+ mobileTab === "try-it" && tryIt
172
+ ]
173
+ }
174
+ )
175
+ ] }, `mobile-${operationId}`),
176
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: desktopWrapperStyle, children: [
177
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: leftColumnStyle$1, children: schema }),
178
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rightColumnStyle$1, children: [
179
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: rightTabBarStyle, role: "tablist", children: RIGHT_TABS.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(
180
+ "button",
181
+ {
182
+ type: "button",
183
+ role: "tab",
184
+ "aria-selected": rightTab === tab.id,
185
+ "aria-controls": `right-panel-${operationId}-${tab.id}`,
186
+ onClick: () => setRightTab(tab.id),
187
+ className: css.cx(rightTabStyle, rightTab === tab.id ? rightTabActiveStyle : void 0),
188
+ children: tab.label
189
+ },
190
+ tab.id
191
+ )) }),
192
+ /* @__PURE__ */ jsxRuntime.jsxs(
193
+ "div",
194
+ {
195
+ id: `right-panel-${operationId}-${rightTab}`,
196
+ className: rightContentStyle,
197
+ role: "tabpanel",
198
+ children: [
199
+ rightTab === "samples" && samples,
200
+ rightTab === "try-it" && tryIt
201
+ ]
202
+ }
203
+ )
204
+ ] })
205
+ ] }, `desktop-${operationId}`)
206
+ ] });
207
+ }
208
+ const mobileWrapperStyle = css.css({
209
+ display: "block",
210
+ [useSpecFetcher.mq.desktop]: {
211
+ display: "none"
212
+ }
213
+ });
214
+ const mobileTabBarStyle = css.css({
215
+ display: "flex",
216
+ borderBottom: "1px solid var(--omnispec-border-color)"
217
+ });
218
+ const mobileTabStyle = css.css({
219
+ flex: 1,
220
+ textAlign: "center",
221
+ padding: "0.625rem 0.5rem",
222
+ background: "none",
223
+ border: "none",
224
+ borderBottom: "0.125rem solid transparent",
225
+ cursor: "pointer",
226
+ fontSize: "var(--omnispec-font-size-xs)",
227
+ fontWeight: 600,
228
+ letterSpacing: "0.04em",
229
+ textTransform: "uppercase",
230
+ color: "var(--omnispec-fg-secondary)",
231
+ "&:hover": {
232
+ color: "var(--omnispec-fg-primary)"
233
+ }
234
+ });
235
+ const mobileTabActiveStyle = css.css({
236
+ borderBottom: "0.125rem solid var(--omnispec-color-primary)",
237
+ color: "var(--omnispec-color-primary)"
238
+ });
239
+ const mobileContentStyle = css.css({
240
+ padding: "1rem 0"
241
+ });
242
+ const desktopWrapperStyle = css.css({
243
+ display: "none",
244
+ [useSpecFetcher.mq.desktop]: {
245
+ display: "flex",
246
+ alignItems: "flex-start"
247
+ }
248
+ });
249
+ const leftColumnStyle$1 = css.css({
250
+ flex: 1,
251
+ minWidth: 0,
252
+ padding: "1rem 1.5rem"
253
+ });
254
+ const rightColumnStyle$1 = css.css({
255
+ width: "26rem",
256
+ flexShrink: 0,
257
+ borderLeft: "1px solid var(--omnispec-border-color)",
258
+ position: "sticky",
259
+ top: "calc(var(--omnispec-offset-top, 0px) + 1rem)",
260
+ alignSelf: "flex-start",
261
+ maxHeight: "calc(100vh - var(--omnispec-offset-top, 0px) - 2rem)",
262
+ overflowY: "auto"
263
+ });
264
+ const rightTabBarStyle = css.css({
265
+ display: "flex",
266
+ borderBottom: "1px solid var(--omnispec-border-color)"
267
+ });
268
+ const rightTabStyle = css.css({
269
+ flex: 1,
270
+ textAlign: "center",
271
+ padding: "0.625rem 0.5rem",
272
+ background: "none",
273
+ border: "none",
274
+ borderBottom: "0.125rem solid transparent",
275
+ cursor: "pointer",
276
+ fontSize: "var(--omnispec-font-size-xs)",
277
+ fontWeight: 600,
278
+ letterSpacing: "0.04em",
279
+ textTransform: "uppercase",
280
+ color: "var(--omnispec-fg-secondary)",
281
+ "&:hover": {
282
+ color: "var(--omnispec-fg-primary)"
283
+ }
284
+ });
285
+ const rightTabActiveStyle = css.css({
286
+ borderBottom: "0.125rem solid var(--omnispec-color-primary)",
287
+ color: "var(--omnispec-color-primary)"
288
+ });
289
+ const rightContentStyle = css.css({
290
+ padding: "1rem"
291
+ });
292
+
293
+ function buildParamSchemaNodes(parameters) {
294
+ return parameters.map((p) => ({
295
+ name: p.name,
296
+ type: p.schema?.type ?? "any",
297
+ format: p.schema?.format,
298
+ description: p.description,
299
+ required: p.required,
300
+ enum: p.schema?.enum,
301
+ default: p.schema?.default,
302
+ constraints: []
303
+ }));
304
+ }
305
+ function getStatusColor$2(code) {
306
+ const num = parseInt(code, 10);
307
+ if (num >= 200 && num < 300) return "var(--omnispec-color-success)";
308
+ if (num >= 400 && num < 500) return "var(--omnispec-color-warning)";
309
+ if (num >= 500) return "var(--omnispec-color-error)";
310
+ return "var(--omnispec-fg-primary)";
311
+ }
312
+ function getStatusBg$1(code) {
313
+ const num = parseInt(code, 10);
314
+ if (num >= 200 && num < 300) return "rgba(26, 127, 55, 0.08)";
315
+ if (num >= 400 && num < 500) return "rgba(191, 135, 0, 0.08)";
316
+ if (num >= 500) return "rgba(207, 34, 46, 0.08)";
317
+ return "var(--omnispec-bg-tertiary)";
318
+ }
319
+ function ResponseCard({ response }) {
320
+ const [expanded, setExpanded] = React.useState(false);
321
+ const { expandAll, expandGeneration } = Collapsible.useExpandAll();
322
+ React.useEffect(() => {
323
+ if (expandGeneration > 0) {
324
+ setExpanded(!!expandAll);
325
+ }
326
+ }, [expandAll, expandGeneration]);
327
+ const statusColor = getStatusColor$2(response.statusCode);
328
+ const statusBg = getStatusBg$1(response.statusCode);
329
+ const hasContent = response.content && Object.keys(response.content).length > 0;
330
+ const header = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
331
+ /* @__PURE__ */ jsxRuntime.jsx(
332
+ "span",
333
+ {
334
+ className: css.cx(
335
+ statusPillStyle,
336
+ css.css({ color: statusColor, backgroundColor: "transparent" })
337
+ ),
338
+ children: response.statusCode
339
+ }
340
+ ),
341
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: responseDescStyle, children: response.description })
342
+ ] });
343
+ return /* @__PURE__ */ jsxRuntime.jsxs(
344
+ "div",
345
+ {
346
+ className: css.cx(
347
+ responseCardStyle,
348
+ css.css({
349
+ borderLeft: `0.1875rem solid ${statusColor}`,
350
+ backgroundColor: statusBg
351
+ })
352
+ ),
353
+ children: [
354
+ hasContent ? /* @__PURE__ */ jsxRuntime.jsxs(
355
+ "button",
356
+ {
357
+ type: "button",
358
+ className: responseCardHeaderStyle,
359
+ onClick: () => setExpanded((prev) => !prev),
360
+ "aria-expanded": expanded,
361
+ children: [
362
+ /* @__PURE__ */ jsxRuntime.jsx(
363
+ "span",
364
+ {
365
+ className: css.cx(
366
+ chevronStyle,
367
+ css.css({ transform: expanded ? "rotate(90deg)" : "rotate(0deg)" })
368
+ ),
369
+ children: /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.Icon, { name: "chevron-right", size: "0.875rem" })
370
+ }
371
+ ),
372
+ header
373
+ ]
374
+ }
375
+ ) : (
376
+ // No response schema — render a static, non-interactive row. The left
377
+ // inset keeps the status pill aligned with the expandable rows' pills.
378
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: responseCardStaticHeaderStyle, children: header })
379
+ ),
380
+ expanded && hasContent && /* @__PURE__ */ jsxRuntime.jsx("div", { className: responseBodyStyle, children: Object.entries(response.content).map(([contentType, media]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
381
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: schemaHeaderRowStyle, children: [
382
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: sectionLabelStyle, children: "Response Schema" }),
383
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: contentTypeBadgeStyle$1, children: contentType })
384
+ ] }),
385
+ media.schema && /* @__PURE__ */ jsxRuntime.jsx(Collapsible.SchemaTree, { nodes: Collapsible.schemaToNodes(media.schema), context: "response" })
386
+ ] }, contentType)) })
387
+ ]
388
+ }
389
+ );
390
+ }
391
+ function ParamSection({ title, params }) {
392
+ if (params.length === 0) return null;
393
+ const nodes = buildParamSchemaNodes(params);
394
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle$1, children: [
395
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: sectionTitleStyle$1, children: title }),
396
+ /* @__PURE__ */ jsxRuntime.jsx(Collapsible.SchemaTree, { nodes })
397
+ ] });
398
+ }
399
+ function ReferenceOperationDetail({
400
+ description,
401
+ parameters,
402
+ requestBody,
403
+ responses,
404
+ security
405
+ }) {
406
+ const pathParams = parameters.filter((p) => p.in === "path");
407
+ const queryParams = parameters.filter((p) => p.in === "query");
408
+ const headerParams = parameters.filter((p) => p.in === "header");
409
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerStyle$4, children: [
410
+ description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionStyle$1, children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: description }) }),
411
+ security && security.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle$1, children: [
412
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: sectionTitleStyle$1, children: "Security" }),
413
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: securityListStyle, children: security.map((schemes, idx) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: securityRowStyle, children: schemes.map((scheme) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: securityBadgeStyle, children: [
414
+ /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.Icon, { name: "lock", size: "0.625rem", strokeWidth: 2.5 }),
415
+ scheme
416
+ ] }, scheme)) }, idx)) })
417
+ ] }),
418
+ /* @__PURE__ */ jsxRuntime.jsx(ParamSection, { title: "Path Parameters", params: pathParams }),
419
+ /* @__PURE__ */ jsxRuntime.jsx(ParamSection, { title: "Query Parameters", params: queryParams }),
420
+ /* @__PURE__ */ jsxRuntime.jsx(ParamSection, { title: "Header Parameters", params: headerParams }),
421
+ requestBody && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle$1, children: [
422
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: schemaHeaderRowStyle, children: [
423
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: sectionTitleStyle$1, children: "Request Body" }),
424
+ requestBody.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: requiredTagStyle, children: "Required" })
425
+ ] }),
426
+ Object.entries(requestBody.content).map(([contentType, media]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
427
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: contentTypeBadgeStyle$1, children: contentType }),
428
+ media.schema && /* @__PURE__ */ jsxRuntime.jsx(Collapsible.SchemaTree, { nodes: Collapsible.schemaToNodes(media.schema), context: "request" })
429
+ ] }, contentType))
430
+ ] }),
431
+ responses.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle$1, children: [
432
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: responsesHeaderRowStyle, children: [
433
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: sectionTitleStyle$1, children: "Responses" }),
434
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: statusPillsRowStyle, children: responses.map((r) => /* @__PURE__ */ jsxRuntime.jsx(
435
+ "span",
436
+ {
437
+ className: css.cx(
438
+ statusPillStyle,
439
+ css.css({
440
+ color: getStatusColor$2(r.statusCode),
441
+ backgroundColor: getStatusBg$1(r.statusCode)
442
+ })
443
+ ),
444
+ children: r.statusCode
445
+ },
446
+ r.statusCode
447
+ )) })
448
+ ] }),
449
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: responseListStyle, children: responses.map((r) => /* @__PURE__ */ jsxRuntime.jsx(ResponseCard, { response: r }, r.statusCode)) })
450
+ ] })
451
+ ] });
452
+ }
453
+ const containerStyle$4 = css.css({
454
+ display: "flex",
455
+ flexDirection: "column"
456
+ });
457
+ const sectionStyle$1 = css.css({
458
+ marginBottom: "1.5rem"
459
+ });
460
+ const sectionTitleStyle$1 = css.css({
461
+ margin: "0 0 0.75rem",
462
+ fontSize: "var(--omnispec-font-size-xs)",
463
+ fontWeight: 700,
464
+ letterSpacing: "0.06em",
465
+ textTransform: "uppercase",
466
+ color: "var(--omnispec-fg-muted)"
467
+ });
468
+ const sectionLabelStyle = css.css({
469
+ fontSize: "var(--omnispec-font-size-xs)",
470
+ fontWeight: 700,
471
+ letterSpacing: "0.06em",
472
+ textTransform: "uppercase",
473
+ color: "var(--omnispec-fg-muted)"
474
+ });
475
+ const securityListStyle = css.css({
476
+ display: "flex",
477
+ flexDirection: "column",
478
+ gap: "0.375rem"
479
+ });
480
+ const securityRowStyle = css.css({
481
+ display: "flex",
482
+ alignItems: "center",
483
+ gap: "0.375rem",
484
+ flexWrap: "wrap"
485
+ });
486
+ const securityBadgeStyle = css.css({
487
+ display: "inline-flex",
488
+ alignItems: "center",
489
+ gap: "0.3125rem",
490
+ fontSize: "var(--omnispec-font-size-xs)",
491
+ fontFamily: "var(--omnispec-font-mono)",
492
+ color: "var(--omnispec-fg-primary)",
493
+ backgroundColor: "var(--omnispec-bg-tertiary)",
494
+ padding: "0.1875rem 0.625rem",
495
+ borderRadius: "0.25rem",
496
+ fontWeight: 500
497
+ });
498
+ const schemaHeaderRowStyle = css.css({
499
+ display: "flex",
500
+ alignItems: "center",
501
+ gap: "0.5rem",
502
+ marginBottom: "0.5rem",
503
+ flexWrap: "wrap"
504
+ });
505
+ const contentTypeBadgeStyle$1 = css.css({
506
+ display: "inline-block",
507
+ fontFamily: "var(--omnispec-font-mono)",
508
+ fontSize: "var(--omnispec-font-size-xs)",
509
+ color: "var(--omnispec-fg-muted)",
510
+ backgroundColor: "var(--omnispec-bg-tertiary)",
511
+ padding: "0.125rem 0.5rem",
512
+ borderRadius: "0.25rem"
513
+ });
514
+ const requiredTagStyle = css.css({
515
+ fontSize: "var(--omnispec-font-size-xxs)",
516
+ fontWeight: 600,
517
+ color: "var(--omnispec-color-error)",
518
+ textTransform: "uppercase",
519
+ letterSpacing: "0.05em"
520
+ });
521
+ const responsesHeaderRowStyle = css.css({
522
+ display: "flex",
523
+ alignItems: "center",
524
+ gap: "0.75rem",
525
+ marginBottom: "0.75rem",
526
+ flexWrap: "wrap"
527
+ });
528
+ const statusPillsRowStyle = css.css({
529
+ display: "flex",
530
+ gap: "0.375rem",
531
+ flexWrap: "wrap"
532
+ });
533
+ const statusPillStyle = css.css({
534
+ display: "inline-block",
535
+ fontFamily: "var(--omnispec-font-mono)",
536
+ fontWeight: 700,
537
+ fontSize: "var(--omnispec-font-size-xs)",
538
+ padding: "0.125rem 0.5rem",
539
+ borderRadius: "0.25rem"
540
+ });
541
+ const responseListStyle = css.css({
542
+ display: "flex",
543
+ flexDirection: "column",
544
+ gap: "0.5rem"
545
+ });
546
+ const responseCardStyle = css.css({
547
+ borderRadius: "var(--omnispec-border-radius)",
548
+ overflow: "hidden"
549
+ });
550
+ const responseCardHeaderStyle = css.css({
551
+ display: "flex",
552
+ alignItems: "center",
553
+ gap: "0.5rem",
554
+ width: "100%",
555
+ padding: "0.625rem 0.75rem",
556
+ background: "none",
557
+ border: "none",
558
+ cursor: "pointer",
559
+ textAlign: "left",
560
+ color: "inherit"
561
+ });
562
+ const responseCardStaticHeaderStyle = css.css({
563
+ display: "flex",
564
+ alignItems: "center",
565
+ gap: "0.5rem",
566
+ width: "100%",
567
+ padding: "0.625rem 0.75rem 0.625rem 2.125rem",
568
+ color: "inherit"
569
+ });
570
+ const chevronStyle = css.css({
571
+ display: "inline-flex",
572
+ alignItems: "center",
573
+ flexShrink: 0,
574
+ transition: "transform 0.15s ease",
575
+ color: "var(--omnispec-fg-muted)"
576
+ });
577
+ const responseDescStyle = css.css({
578
+ fontSize: "var(--omnispec-font-size-sm)",
579
+ color: "var(--omnispec-fg-secondary)",
580
+ flex: 1
581
+ });
582
+ const responseBodyStyle = css.css({
583
+ padding: "0 0.75rem 0.75rem"
584
+ });
585
+
586
+ function generateCurl(request, serverUrl) {
587
+ const parts = ["curl"];
588
+ if (request.method.toUpperCase() !== "GET") {
589
+ parts.push(`-X ${request.method.toUpperCase()}`);
590
+ }
591
+ let url = serverUrl + request.url;
592
+ for (const [key, value] of Object.entries(request.pathParams)) {
593
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
594
+ }
595
+ const queryEntries = Object.entries(request.queryParams);
596
+ if (queryEntries.length > 0) {
597
+ const params = new URLSearchParams();
598
+ for (const [key, value] of queryEntries) {
599
+ if (Array.isArray(value)) {
600
+ for (const v of value) params.append(key, v);
601
+ } else {
602
+ params.set(key, value);
603
+ }
604
+ }
605
+ url += `?${params.toString()}`;
606
+ }
607
+ parts.push(`'${url}'`);
608
+ for (const [key, value] of Object.entries(request.headers)) {
609
+ parts.push(`-H '${key}: ${value}'`);
610
+ }
611
+ if (request.body && typeof request.body !== "string") {
612
+ request.body.forEach((value, key) => {
613
+ if (typeof value === "string") {
614
+ parts.push(`-F '${key}=${value.replace(/'/g, "'\\''")}'`);
615
+ } else {
616
+ parts.push(`-F '${key}=@${value.name || "file"}'`);
617
+ }
618
+ });
619
+ return parts.join(" \\\n ");
620
+ }
621
+ if (request.body && typeof request.body === "string") {
622
+ if (request.bodyType === "application/x-www-form-urlencoded") {
623
+ try {
624
+ const parsed = JSON.parse(request.body);
625
+ for (const [key, value] of Object.entries(parsed)) {
626
+ parts.push(`--data-urlencode '${key}=${String(value)}'`);
627
+ }
628
+ } catch {
629
+ const escaped = request.body.replace(/'/g, "'\\''");
630
+ parts.push(`-d '${escaped}'`);
631
+ }
632
+ } else {
633
+ const escaped = request.body.replace(/'/g, "'\\''");
634
+ parts.push(`-d '${escaped}'`);
635
+ }
636
+ }
637
+ return parts.join(" \\\n ");
638
+ }
639
+
640
+ function buildUrl(request, serverUrl) {
641
+ let url = serverUrl + request.url;
642
+ for (const [key, value] of Object.entries(request.pathParams)) {
643
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
644
+ }
645
+ const queryEntries = Object.entries(request.queryParams);
646
+ if (queryEntries.length > 0) {
647
+ const params = new URLSearchParams();
648
+ for (const [key, value] of queryEntries) {
649
+ if (Array.isArray(value)) {
650
+ for (const v of value) params.append(key, v);
651
+ } else {
652
+ params.set(key, value);
653
+ }
654
+ }
655
+ url += `?${params.toString()}`;
656
+ }
657
+ return url;
658
+ }
659
+ function generateJavaScript(request, serverUrl) {
660
+ const url = buildUrl(request, serverUrl);
661
+ const method = request.method.toUpperCase();
662
+ const headers = Object.entries(request.headers);
663
+ const hasBody = request.body && typeof request.body === "string";
664
+ const lines = [];
665
+ lines.push(`const response = await fetch('${url}', {`);
666
+ lines.push(` method: '${method}',`);
667
+ if (headers.length > 0) {
668
+ lines.push(" headers: {");
669
+ for (const [key, value] of headers) {
670
+ lines.push(` '${key}': '${value}',`);
671
+ }
672
+ lines.push(" },");
673
+ }
674
+ if (hasBody) {
675
+ lines.push(` body: JSON.stringify(${request.body}),`);
676
+ }
677
+ lines.push("})");
678
+ lines.push("");
679
+ lines.push("const data = await response.json()");
680
+ lines.push("console.log(data)");
681
+ return lines.join("\n");
682
+ }
683
+ function generatePython(request, serverUrl) {
684
+ const url = buildUrl(request, serverUrl);
685
+ const method = request.method.toLowerCase();
686
+ const headers = Object.entries(request.headers);
687
+ const hasBody = request.body && typeof request.body === "string";
688
+ const lines = [];
689
+ lines.push("import requests");
690
+ lines.push("");
691
+ if (headers.length > 0) {
692
+ lines.push("headers = {");
693
+ for (const [key, value] of headers) {
694
+ lines.push(` '${key}': '${value}',`);
695
+ }
696
+ lines.push("}");
697
+ lines.push("");
698
+ }
699
+ if (hasBody) {
700
+ lines.push(`payload = ${request.body}`);
701
+ lines.push("");
702
+ }
703
+ const args = [`'${url}'`];
704
+ if (headers.length > 0) args.push("headers=headers");
705
+ if (hasBody) args.push("json=payload");
706
+ lines.push(`response = requests.${method}(${args.join(", ")})`);
707
+ lines.push("print(response.json())");
708
+ return lines.join("\n");
709
+ }
710
+ function generateGo(request, serverUrl) {
711
+ const url = buildUrl(request, serverUrl);
712
+ const method = request.method.toUpperCase();
713
+ const headers = Object.entries(request.headers);
714
+ const hasBody = request.body && typeof request.body === "string";
715
+ const lines = [];
716
+ lines.push("package main");
717
+ lines.push("");
718
+ lines.push("import (");
719
+ lines.push(' "fmt"');
720
+ lines.push(' "io"');
721
+ lines.push(' "net/http"');
722
+ if (hasBody) lines.push(' "strings"');
723
+ lines.push(")");
724
+ lines.push("");
725
+ lines.push("func main() {");
726
+ if (hasBody) {
727
+ lines.push(` body := strings.NewReader(\`${request.body}\`)`);
728
+ lines.push(` req, err := http.NewRequest("${method}", "${url}", body)`);
729
+ } else {
730
+ lines.push(` req, err := http.NewRequest("${method}", "${url}", nil)`);
731
+ }
732
+ lines.push(" if err != nil {");
733
+ lines.push(" panic(err)");
734
+ lines.push(" }");
735
+ for (const [key, value] of headers) {
736
+ lines.push(` req.Header.Set("${key}", "${value}")`);
737
+ }
738
+ lines.push("");
739
+ lines.push(" resp, err := http.DefaultClient.Do(req)");
740
+ lines.push(" if err != nil {");
741
+ lines.push(" panic(err)");
742
+ lines.push(" }");
743
+ lines.push(" defer resp.Body.Close()");
744
+ lines.push("");
745
+ lines.push(" resBody, _ := io.ReadAll(resp.Body)");
746
+ lines.push(" fmt.Println(string(resBody))");
747
+ lines.push("}");
748
+ return lines.join("\n");
749
+ }
750
+ function generateJava(request, serverUrl) {
751
+ const url = buildUrl(request, serverUrl);
752
+ const method = request.method.toUpperCase();
753
+ const headers = Object.entries(request.headers);
754
+ const hasBody = request.body && typeof request.body === "string";
755
+ const lines = [];
756
+ lines.push("import java.net.URI;");
757
+ lines.push("import java.net.http.HttpClient;");
758
+ lines.push("import java.net.http.HttpRequest;");
759
+ lines.push("import java.net.http.HttpResponse;");
760
+ lines.push("");
761
+ lines.push("HttpClient client = HttpClient.newHttpClient();");
762
+ if (hasBody) {
763
+ lines.push("");
764
+ lines.push('String body = """');
765
+ lines.push(` ${request.body}""";`);
766
+ }
767
+ lines.push("");
768
+ lines.push("HttpRequest request = HttpRequest.newBuilder()");
769
+ lines.push(` .uri(URI.create("${url}"))`);
770
+ if (hasBody) {
771
+ lines.push(` .method("${method}", HttpRequest.BodyPublishers.ofString(body))`);
772
+ } else if (method !== "GET") {
773
+ lines.push(` .method("${method}", HttpRequest.BodyPublishers.noBody())`);
774
+ }
775
+ for (const [key, value] of headers) {
776
+ lines.push(` .header("${key}", "${value}")`);
777
+ }
778
+ lines.push(" .build();");
779
+ lines.push("");
780
+ lines.push("HttpResponse<String> response = client.send(");
781
+ lines.push(" request, HttpResponse.BodyHandlers.ofString());");
782
+ lines.push("System.out.println(response.body());");
783
+ return lines.join("\n");
784
+ }
785
+ function generateCSharp(request, serverUrl) {
786
+ const url = buildUrl(request, serverUrl);
787
+ const method = request.method.toUpperCase();
788
+ const headers = Object.entries(request.headers);
789
+ const hasBody = request.body && typeof request.body === "string";
790
+ const contentType = request.headers["Content-Type"] ?? "application/json";
791
+ const lines = [];
792
+ lines.push("using var client = new HttpClient();");
793
+ lines.push("");
794
+ if (hasBody) {
795
+ lines.push("var content = new StringContent(");
796
+ lines.push(` @"${request.body.replace(/"/g, '""')}",`);
797
+ lines.push(" System.Text.Encoding.UTF8,");
798
+ lines.push(` "${contentType}");`);
799
+ lines.push("");
800
+ }
801
+ const nonContentHeaders = headers.filter(([k]) => k !== "Content-Type");
802
+ for (const [key, value] of nonContentHeaders) {
803
+ lines.push(`client.DefaultRequestHeaders.Add("${key}", "${value}");`);
804
+ }
805
+ if (nonContentHeaders.length > 0) lines.push("");
806
+ const methodMap = {
807
+ GET: "GetAsync",
808
+ POST: "PostAsync",
809
+ PUT: "PutAsync",
810
+ DELETE: "DeleteAsync",
811
+ PATCH: "PatchAsync"
812
+ };
813
+ const asyncMethod = methodMap[method] ?? "SendAsync";
814
+ if (hasBody && (method === "POST" || method === "PUT" || method === "PATCH")) {
815
+ lines.push(`var response = await client.${asyncMethod}("${url}", content);`);
816
+ } else if (method === "GET" || method === "DELETE") {
817
+ lines.push(`var response = await client.${asyncMethod}("${url}");`);
818
+ } else {
819
+ lines.push(`var request = new HttpRequestMessage(HttpMethod.${method.charAt(0) + method.slice(1).toLowerCase()}, "${url}");`);
820
+ if (hasBody) lines.push("request.Content = content;");
821
+ lines.push("var response = await client.SendAsync(request);");
822
+ }
823
+ lines.push("var body = await response.Content.ReadAsStringAsync();");
824
+ lines.push("Console.WriteLine(body);");
825
+ return lines.join("\n");
826
+ }
827
+ const CODE_LANGUAGES = [
828
+ { id: "curl", label: "cURL", prismLanguage: "bash" },
829
+ { id: "javascript", label: "JavaScript", prismLanguage: "javascript" },
830
+ { id: "python", label: "Python", prismLanguage: "python" },
831
+ { id: "go", label: "Go", prismLanguage: "go" },
832
+ { id: "java", label: "Java", prismLanguage: "java" },
833
+ { id: "csharp", label: "C#", prismLanguage: "csharp" }
834
+ ];
835
+
836
+ function ExampleSelector({
837
+ examples,
838
+ selectedName,
839
+ onSelect
840
+ }) {
841
+ if (examples.length <= 1) {
842
+ return null;
843
+ }
844
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerStyle$3, children: [
845
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "example-selector", className: labelStyle, children: "Example:" }),
846
+ /* @__PURE__ */ jsxRuntime.jsx(
847
+ "select",
848
+ {
849
+ id: "example-selector",
850
+ value: selectedName,
851
+ onChange: (e) => onSelect(e.target.value),
852
+ className: selectStyle,
853
+ children: examples.map((example) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: example.name, children: example.summary ? `${example.name} - ${example.summary}` : example.name }, example.name))
854
+ }
855
+ )
856
+ ] });
857
+ }
858
+ function getNamedExamples(media) {
859
+ if (media.example !== void 0) {
860
+ return [{ name: "default", value: media.example }];
861
+ }
862
+ if (media.examples && typeof media.examples === "object") {
863
+ return Object.entries(media.examples).map(([name, example]) => ({
864
+ name,
865
+ summary: example.summary,
866
+ value: example.value
867
+ }));
868
+ }
869
+ return [];
870
+ }
871
+ const containerStyle$3 = css.css({
872
+ display: "flex",
873
+ alignItems: "center",
874
+ gap: "0.5rem",
875
+ marginBottom: "0.75rem"
876
+ });
877
+ const labelStyle = css.css({
878
+ fontSize: "var(--omnispec-font-size-xs)",
879
+ fontWeight: 600,
880
+ color: "var(--omnispec-fg-muted)",
881
+ textTransform: "uppercase",
882
+ letterSpacing: "0.5px",
883
+ whiteSpace: "nowrap"
884
+ });
885
+ const selectStyle = css.css({
886
+ padding: "0.375rem 0.625rem",
887
+ border: "1px solid var(--omnispec-input-border)",
888
+ borderRadius: "var(--omnispec-border-radius)",
889
+ backgroundColor: "var(--omnispec-input-bg)",
890
+ color: "var(--omnispec-fg-primary)",
891
+ fontSize: "var(--omnispec-font-size-sm)",
892
+ fontFamily: "var(--omnispec-font-mono)"
893
+ });
894
+
895
+ const generators$1 = {
896
+ curl: generateCurl,
897
+ javascript: generateJavaScript,
898
+ python: generatePython,
899
+ go: generateGo,
900
+ java: generateJava,
901
+ csharp: generateCSharp
902
+ };
903
+ function getStatusColor$1(statusCode) {
904
+ const code = parseInt(statusCode, 10);
905
+ if (code >= 200 && code < 300) return "var(--omnispec-color-success)";
906
+ if (code >= 400 && code < 500) return "var(--omnispec-color-warning)";
907
+ if (code >= 500) return "var(--omnispec-color-error)";
908
+ return "var(--omnispec-fg-muted)";
909
+ }
910
+ function getStatusBg(statusCode) {
911
+ const code = parseInt(statusCode, 10);
912
+ if (code >= 200 && code < 300) return "rgba(26, 127, 55, 0.15)";
913
+ if (code >= 400 && code < 500) return "rgba(191, 135, 0, 0.15)";
914
+ if (code >= 500) return "rgba(207, 34, 46, 0.15)";
915
+ return "var(--omnispec-bg-secondary)";
916
+ }
917
+ function SamplesPanel({
918
+ method,
919
+ path,
920
+ serverUrl,
921
+ requestBodySchema,
922
+ requestBodyContentType = "application/json",
923
+ responses
924
+ }) {
925
+ const [selectedLang, setSelectedLang] = React.useState("curl");
926
+ const [selectedResponseIndex, setSelectedResponseIndex] = React.useState(0);
927
+ const [selectedExampleName, setSelectedExampleName] = React.useState("");
928
+ const request = React.useMemo(() => {
929
+ const headers = {};
930
+ const hasBody = requestBodySchema && ["post", "put", "patch", "delete"].includes(method.toLowerCase());
931
+ if (hasBody) {
932
+ headers["Content-Type"] = requestBodyContentType;
933
+ }
934
+ const body = hasBody ? JSON.stringify(Collapsible.generateExample(requestBodySchema), null, 2) : void 0;
935
+ return {
936
+ url: path,
937
+ method: method.toUpperCase(),
938
+ headers,
939
+ queryParams: {},
940
+ pathParams: {},
941
+ body
942
+ };
943
+ }, [method, path, requestBodySchema, requestBodyContentType]);
944
+ const requestCode = React.useMemo(() => {
945
+ const generator = generators$1[selectedLang];
946
+ return generator ? generator(request, serverUrl) : "";
947
+ }, [request, serverUrl, selectedLang]);
948
+ const langOption = CODE_LANGUAGES.find((l) => l.id === selectedLang);
949
+ const prismLang = langOption?.prismLanguage ?? "text";
950
+ const activeResponse = responses[selectedResponseIndex] ?? null;
951
+ const { namedExamples, responseContentType } = React.useMemo(() => {
952
+ if (!activeResponse?.content) return { namedExamples: [], responseContentType: null };
953
+ const firstContentType = Object.keys(activeResponse.content)[0];
954
+ const firstMedia = activeResponse.content[firstContentType];
955
+ if (!firstMedia) return { namedExamples: [], responseContentType: firstContentType };
956
+ const examples = getNamedExamples(firstMedia);
957
+ if (examples.length === 0 && firstMedia.schema) {
958
+ return {
959
+ namedExamples: [{ name: "generated", value: Collapsible.generateExample(firstMedia.schema) }],
960
+ responseContentType: firstContentType
961
+ };
962
+ }
963
+ return { namedExamples: examples, responseContentType: firstContentType };
964
+ }, [activeResponse]);
965
+ const responseExampleCode = React.useMemo(() => {
966
+ if (namedExamples.length === 0) return null;
967
+ const target = selectedExampleName ? namedExamples.find((ex) => ex.name === selectedExampleName) : namedExamples[0];
968
+ const value = target?.value ?? namedExamples[0]?.value ?? null;
969
+ if (value === null) return null;
970
+ return typeof value === "string" ? value : JSON.stringify(value, null, 2);
971
+ }, [namedExamples, selectedExampleName]);
972
+ const languageTabs = /* @__PURE__ */ jsxRuntime.jsx("div", { className: languageBarStyle$1, children: CODE_LANGUAGES.map((lang) => /* @__PURE__ */ jsxRuntime.jsx(
973
+ "button",
974
+ {
975
+ type: "button",
976
+ onClick: () => setSelectedLang(lang.id),
977
+ className: css.cx(langBtnStyle$1, selectedLang === lang.id && langBtnActiveStyle$1),
978
+ children: lang.label
979
+ },
980
+ lang.id
981
+ )) });
982
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: panelStyle, children: [
983
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle, children: [
984
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionHeaderStyle, children: [
985
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: sectionTitleStyle, children: "Request samples" }),
986
+ requestBodyContentType && /* @__PURE__ */ jsxRuntime.jsx("code", { className: contentTypeBadgeStyle, children: requestBodyContentType })
987
+ ] }),
988
+ /* @__PURE__ */ jsxRuntime.jsx(
989
+ Collapsible.CodeBlock,
990
+ {
991
+ code: requestCode,
992
+ language: prismLang,
993
+ showCopy: true,
994
+ headerLeft: languageTabs
995
+ }
996
+ )
997
+ ] }),
998
+ responses.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle, children: [
999
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: sectionTitleStyle, children: "Response samples" }) }),
1000
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: statusTabsStyle, children: responses.map((res, idx) => {
1001
+ const color = getStatusColor$1(res.statusCode);
1002
+ const bg = getStatusBg(res.statusCode);
1003
+ const isActive = idx === selectedResponseIndex;
1004
+ return /* @__PURE__ */ jsxRuntime.jsx(
1005
+ "button",
1006
+ {
1007
+ type: "button",
1008
+ onClick: () => {
1009
+ setSelectedResponseIndex(idx);
1010
+ setSelectedExampleName("");
1011
+ },
1012
+ className: css.cx(statusTabStyle, isActive && statusTabActiveStyle),
1013
+ style: {
1014
+ "--status-color": color,
1015
+ "--status-bg": bg
1016
+ },
1017
+ title: res.description,
1018
+ children: res.statusCode
1019
+ },
1020
+ res.statusCode
1021
+ );
1022
+ }) }),
1023
+ responseExampleCode !== null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1024
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: contentTypeLabelStyle, children: /* @__PURE__ */ jsxRuntime.jsx("code", { className: contentTypeBadgeStyle, children: responseContentType }) }),
1025
+ namedExamples.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
1026
+ ExampleSelector,
1027
+ {
1028
+ examples: namedExamples,
1029
+ selectedName: selectedExampleName || namedExamples[0]?.name,
1030
+ onSelect: setSelectedExampleName
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ jsxRuntime.jsx(
1034
+ Collapsible.CodeBlock,
1035
+ {
1036
+ code: responseExampleCode,
1037
+ language: "json",
1038
+ showCopy: true
1039
+ }
1040
+ )
1041
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: emptyStateStyle, children: "No response sample available." })
1042
+ ] })
1043
+ ] });
1044
+ }
1045
+ const panelStyle = css.css({
1046
+ display: "flex",
1047
+ flexDirection: "column",
1048
+ gap: "1.5rem"
1049
+ });
1050
+ const sectionStyle = css.css({
1051
+ display: "flex",
1052
+ flexDirection: "column",
1053
+ gap: "0.5rem"
1054
+ });
1055
+ const sectionHeaderStyle = css.css({
1056
+ display: "flex",
1057
+ alignItems: "center",
1058
+ gap: "0.5rem",
1059
+ flexWrap: "wrap"
1060
+ });
1061
+ const sectionTitleStyle = css.css({
1062
+ fontSize: "var(--omnispec-font-size-sm)",
1063
+ fontWeight: 600,
1064
+ color: "var(--omnispec-fg-primary)",
1065
+ [useSpecFetcher.mq.desktop]: {
1066
+ fontSize: "var(--omnispec-font-size-base)"
1067
+ }
1068
+ });
1069
+ const contentTypeBadgeStyle = css.css({
1070
+ fontSize: "var(--omnispec-font-size-xs)",
1071
+ fontFamily: "var(--omnispec-font-mono)",
1072
+ color: "var(--omnispec-fg-muted)",
1073
+ backgroundColor: "var(--omnispec-bg-secondary)",
1074
+ padding: "0.125rem 0.375rem",
1075
+ borderRadius: "var(--omnispec-border-radius)"
1076
+ });
1077
+ const languageBarStyle$1 = css.css({
1078
+ display: "flex",
1079
+ gap: "0.125rem",
1080
+ overflowX: "auto",
1081
+ scrollbarWidth: "none",
1082
+ "&::-webkit-scrollbar": {
1083
+ display: "none"
1084
+ }
1085
+ });
1086
+ const langBtnStyle$1 = css.css({
1087
+ padding: "0.25rem 0.5rem",
1088
+ background: "none",
1089
+ border: "none",
1090
+ cursor: "pointer",
1091
+ fontSize: "var(--omnispec-font-size-xs)",
1092
+ fontWeight: 500,
1093
+ color: "var(--omnispec-fg-muted)",
1094
+ whiteSpace: "nowrap",
1095
+ borderRadius: "var(--omnispec-border-radius)",
1096
+ "&:hover": {
1097
+ color: "var(--omnispec-fg-primary)",
1098
+ backgroundColor: "var(--omnispec-bg-secondary)"
1099
+ }
1100
+ });
1101
+ const langBtnActiveStyle$1 = css.css({
1102
+ color: "var(--omnispec-color-primary)",
1103
+ backgroundColor: "var(--omnispec-bg-secondary)",
1104
+ fontWeight: 600
1105
+ });
1106
+ const statusTabsStyle = css.css({
1107
+ display: "flex",
1108
+ flexWrap: "wrap",
1109
+ gap: "0.375rem"
1110
+ });
1111
+ const statusTabStyle = css.css({
1112
+ padding: "0.25rem 0.625rem",
1113
+ border: "none",
1114
+ borderRadius: "var(--omnispec-border-radius)",
1115
+ cursor: "pointer",
1116
+ fontSize: "var(--omnispec-font-size-xs)",
1117
+ fontWeight: 600,
1118
+ fontFamily: "var(--omnispec-font-mono)",
1119
+ opacity: 0.65,
1120
+ backgroundColor: "var(--status-bg)",
1121
+ color: "var(--status-color)",
1122
+ transition: "opacity 0.15s, box-shadow 0.15s",
1123
+ "&:hover": {
1124
+ opacity: 0.85
1125
+ }
1126
+ });
1127
+ const statusTabActiveStyle = css.css({
1128
+ opacity: 1,
1129
+ boxShadow: "0 0 0 1px var(--status-color)"
1130
+ });
1131
+ const contentTypeLabelStyle = css.css({
1132
+ marginBottom: "0.25rem"
1133
+ });
1134
+ const emptyStateStyle = css.css({
1135
+ fontSize: "var(--omnispec-font-size-sm)",
1136
+ color: "var(--omnispec-fg-muted)",
1137
+ padding: "0.75rem 0"
1138
+ });
1139
+
1140
+ function LinkableHeading({ id, as: Tag = "h3", className, children }) {
1141
+ const [copied, setCopied] = React.useState(false);
1142
+ const handleCopy = React.useCallback((e) => {
1143
+ e.preventDefault();
1144
+ const url = `${window.location.origin}${window.location.pathname}#${id}`;
1145
+ navigator.clipboard.writeText(url).then(() => {
1146
+ setCopied(true);
1147
+ setTimeout(() => setCopied(false), 1500);
1148
+ });
1149
+ }, [id]);
1150
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tag, { id, className: `${containerStyle$2} ${className ?? ""}`, children: [
1151
+ children,
1152
+ /* @__PURE__ */ jsxRuntime.jsx(
1153
+ "a",
1154
+ {
1155
+ href: `#${id}`,
1156
+ onClick: handleCopy,
1157
+ className: linkIconStyle,
1158
+ "aria-label": "Copy link to section",
1159
+ title: copied ? "Copied!" : "Copy link",
1160
+ children: /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.Icon, { name: "link", size: "0.75em" })
1161
+ }
1162
+ )
1163
+ ] });
1164
+ }
1165
+ const containerStyle$2 = css.css({
1166
+ position: "relative",
1167
+ display: "flex",
1168
+ alignItems: "center",
1169
+ gap: "0.5rem",
1170
+ "&:hover a": {
1171
+ opacity: 1
1172
+ }
1173
+ });
1174
+ const linkIconStyle = css.css({
1175
+ opacity: 0,
1176
+ color: "var(--omnispec-fg-muted)",
1177
+ transition: "opacity 0.15s",
1178
+ flexShrink: 0,
1179
+ lineHeight: 1,
1180
+ textDecoration: "none",
1181
+ "&:hover": {
1182
+ color: "var(--omnispec-color-primary)"
1183
+ }
1184
+ });
1185
+
1186
+ function Modal({ open, onClose, title, children }) {
1187
+ React.useEffect(() => {
1188
+ if (!open) return void 0;
1189
+ const handleKey = (e) => {
1190
+ if (e.key === "Escape") onClose();
1191
+ };
1192
+ document.addEventListener("keydown", handleKey);
1193
+ document.body.style.overflow = "hidden";
1194
+ return () => {
1195
+ document.removeEventListener("keydown", handleKey);
1196
+ document.body.style.overflow = "";
1197
+ };
1198
+ }, [open, onClose]);
1199
+ if (!open) return null;
1200
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1201
+ /* @__PURE__ */ jsxRuntime.jsx(
1202
+ "div",
1203
+ {
1204
+ className: backdropStyle,
1205
+ onClick: onClose,
1206
+ "aria-hidden": "true"
1207
+ }
1208
+ ),
1209
+ /* @__PURE__ */ jsxRuntime.jsxs(
1210
+ "div",
1211
+ {
1212
+ className: dialogStyle,
1213
+ role: "dialog",
1214
+ "aria-modal": "true",
1215
+ "aria-label": title,
1216
+ children: [
1217
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: headerStyle, children: [
1218
+ title && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: titleStyle, children: title }),
1219
+ /* @__PURE__ */ jsxRuntime.jsx(
1220
+ "button",
1221
+ {
1222
+ type: "button",
1223
+ onClick: onClose,
1224
+ className: closeBtnStyle,
1225
+ "aria-label": "Close",
1226
+ children: "\xD7"
1227
+ }
1228
+ )
1229
+ ] }),
1230
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: bodyStyle, children })
1231
+ ]
1232
+ }
1233
+ )
1234
+ ] });
1235
+ }
1236
+ const backdropStyle = css.css({
1237
+ position: "fixed",
1238
+ inset: 0,
1239
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
1240
+ zIndex: 1100
1241
+ });
1242
+ const dialogStyle = css.css({
1243
+ position: "fixed",
1244
+ top: "50%",
1245
+ left: "50%",
1246
+ transform: "translate(-50%, -50%)",
1247
+ width: "90%",
1248
+ maxWidth: "768px",
1249
+ maxHeight: "85vh",
1250
+ backgroundColor: "var(--omnispec-bg-primary)",
1251
+ borderRadius: "12px",
1252
+ boxShadow: "0 20px 60px rgba(0, 0, 0, 0.2)",
1253
+ zIndex: 1101,
1254
+ display: "flex",
1255
+ flexDirection: "column",
1256
+ overflow: "hidden"
1257
+ });
1258
+ const headerStyle = css.css({
1259
+ display: "flex",
1260
+ alignItems: "center",
1261
+ justifyContent: "space-between",
1262
+ padding: "16px 20px",
1263
+ borderBottom: "1px solid var(--omnispec-border-color)"
1264
+ });
1265
+ const titleStyle = css.css({
1266
+ margin: 0,
1267
+ fontSize: "var(--omnispec-h3-font-size)",
1268
+ fontWeight: 600,
1269
+ color: "var(--omnispec-color-primary)"
1270
+ });
1271
+ const closeBtnStyle = css.css({
1272
+ background: "none",
1273
+ border: "none",
1274
+ cursor: "pointer",
1275
+ fontSize: "24px",
1276
+ lineHeight: 1,
1277
+ color: "var(--omnispec-fg-muted)",
1278
+ padding: "4px 8px",
1279
+ borderRadius: "4px",
1280
+ "&:hover": {
1281
+ color: "var(--omnispec-fg-primary)",
1282
+ backgroundColor: "var(--omnispec-bg-secondary)"
1283
+ }
1284
+ });
1285
+ const bodyStyle = css.css({
1286
+ padding: "20px",
1287
+ overflowY: "auto",
1288
+ flex: 1
1289
+ });
1290
+
1291
+ const PREFIX = "omnispec:tryit";
1292
+ function storageKey(specKey, operationKey) {
1293
+ return `${PREFIX}:${specKey}:${operationKey}`;
1294
+ }
1295
+ function isEnvelope(value) {
1296
+ return typeof value === "object" && value !== null && typeof value.savedAt === "number" && typeof value.state === "object" && value.state !== null;
1297
+ }
1298
+ function getStorage() {
1299
+ try {
1300
+ if (typeof window === "undefined" || !window.localStorage) return null;
1301
+ if (typeof window.localStorage.setItem !== "function" || typeof window.localStorage.getItem !== "function") {
1302
+ return null;
1303
+ }
1304
+ return window.localStorage;
1305
+ } catch {
1306
+ return null;
1307
+ }
1308
+ }
1309
+ function loadTryItState(specKey, operationKey, ttlSeconds) {
1310
+ if (!specKey) return null;
1311
+ if (ttlSeconds === 0) return null;
1312
+ const storage = getStorage();
1313
+ if (!storage) return null;
1314
+ const key = storageKey(specKey, operationKey);
1315
+ try {
1316
+ const raw = storage.getItem(key);
1317
+ if (!raw) return null;
1318
+ const parsed = JSON.parse(raw);
1319
+ if (isEnvelope(parsed)) {
1320
+ if (ttlSeconds !== void 0 && Date.now() - parsed.savedAt > ttlSeconds * 1e3) {
1321
+ storage.removeItem(key);
1322
+ return null;
1323
+ }
1324
+ return parsed.state;
1325
+ }
1326
+ if (parsed && typeof parsed === "object") {
1327
+ if (ttlSeconds !== void 0) {
1328
+ storage.removeItem(key);
1329
+ return null;
1330
+ }
1331
+ return parsed;
1332
+ }
1333
+ return null;
1334
+ } catch {
1335
+ return null;
1336
+ }
1337
+ }
1338
+ function saveTryItState(specKey, operationKey, state) {
1339
+ if (!specKey) return;
1340
+ const storage = getStorage();
1341
+ if (!storage) return;
1342
+ try {
1343
+ const envelope = { savedAt: Date.now(), state };
1344
+ storage.setItem(storageKey(specKey, operationKey), JSON.stringify(envelope));
1345
+ } catch {
1346
+ }
1347
+ }
1348
+ const PANEL_WIDTH_KEY = `${PREFIX}:panel-width`;
1349
+ function loadPanelWidth() {
1350
+ const storage = getStorage();
1351
+ if (!storage) return null;
1352
+ try {
1353
+ const raw = storage.getItem(PANEL_WIDTH_KEY);
1354
+ if (!raw) return null;
1355
+ const value = Number(raw);
1356
+ return Number.isFinite(value) && value > 0 ? value : null;
1357
+ } catch {
1358
+ return null;
1359
+ }
1360
+ }
1361
+ function savePanelWidth(width) {
1362
+ const storage = getStorage();
1363
+ if (!storage) return;
1364
+ try {
1365
+ storage.setItem(PANEL_WIDTH_KEY, String(Math.round(width)));
1366
+ } catch {
1367
+ }
1368
+ }
1369
+ function clearTryItState(specKey, operationKey) {
1370
+ if (!specKey) return;
1371
+ const storage = getStorage();
1372
+ if (!storage) return;
1373
+ try {
1374
+ storage.removeItem(storageKey(specKey, operationKey));
1375
+ } catch {
1376
+ }
1377
+ }
1378
+
1379
+ const MIN_RIGHT_WIDTH = 320;
1380
+ const MAX_RIGHT_FRACTION = 0.65;
1381
+ const singleColumnStyle = css.css({
1382
+ padding: "0.75rem 0",
1383
+ minWidth: 0,
1384
+ [useSpecFetcher.mq.desktop]: {
1385
+ padding: "1rem 1.25rem"
1386
+ }
1387
+ });
1388
+ const gridStyle = css.css({
1389
+ maxWidth: "100%",
1390
+ [useSpecFetcher.mq.desktop]: {
1391
+ display: "grid",
1392
+ // The custom property is set inline while a user-chosen width is active;
1393
+ // it falls back to a 65/35 split (content-heavy left, Try-It on the right).
1394
+ gridTemplateColumns: "1fr 0.375rem var(--omnispec-tryit-col, calc(35% - 0.375rem))"
1395
+ }
1396
+ });
1397
+ const leftColumnStyle = css.css({
1398
+ padding: "0.75rem 0",
1399
+ minWidth: 0,
1400
+ [useSpecFetcher.mq.desktop]: {
1401
+ padding: "1rem 1.25rem"
1402
+ }
1403
+ });
1404
+ const toggleButtonStyle = css.css({
1405
+ display: "block",
1406
+ width: "100%",
1407
+ padding: "10px 16px",
1408
+ marginTop: "12px",
1409
+ borderRadius: "var(--omnispec-border-radius)",
1410
+ background: "var(--omnispec-color-primary, #1a1a2e)",
1411
+ color: "#fff",
1412
+ border: "none",
1413
+ cursor: "pointer",
1414
+ fontSize: "var(--omnispec-font-size-base)",
1415
+ fontWeight: 500,
1416
+ textAlign: "center",
1417
+ [useSpecFetcher.mq.desktop]: {
1418
+ display: "none"
1419
+ }
1420
+ });
1421
+ const rightColumnStyle = css.css({
1422
+ padding: "0.75rem 0",
1423
+ background: "var(--omnispec-bg-secondary)",
1424
+ minWidth: 0,
1425
+ display: "none",
1426
+ "&[data-mobile-visible]": {
1427
+ display: "block",
1428
+ borderTop: "1px solid var(--omnispec-border-color)"
1429
+ },
1430
+ [useSpecFetcher.mq.desktop]: {
1431
+ display: "block",
1432
+ padding: "1rem 1.25rem",
1433
+ borderTop: "none"
1434
+ }
1435
+ });
1436
+ const resizeHandleStyle = css.css({
1437
+ display: "none",
1438
+ [useSpecFetcher.mq.desktop]: {
1439
+ display: "block",
1440
+ cursor: "col-resize",
1441
+ backgroundColor: "var(--omnispec-border-color)",
1442
+ borderRadius: "0.1875rem",
1443
+ transition: "background-color 0.15s ease",
1444
+ marginTop: "1rem",
1445
+ marginBottom: "1rem",
1446
+ "&:hover, &[data-dragging]": {
1447
+ backgroundColor: "var(--omnispec-color-primary)"
1448
+ }
1449
+ }
1450
+ });
1451
+ const draggingContainerStyle = css.css({
1452
+ userSelect: "none"
1453
+ });
1454
+ function ResponsiveColumns({ left, right, rightLabel = "Try It" }) {
1455
+ const [showRight, setShowRight] = React.useState(false);
1456
+ const [rightWidth, setRightWidth] = React.useState(() => loadPanelWidth());
1457
+ const [dragging, setDragging] = React.useState(false);
1458
+ const containerRef = React.useRef(null);
1459
+ const startDrag = (e) => {
1460
+ e.preventDefault();
1461
+ setDragging(true);
1462
+ const onMove = (ev) => {
1463
+ const rect = containerRef.current?.getBoundingClientRect();
1464
+ if (!rect) return;
1465
+ const raw = rect.right - ev.clientX;
1466
+ const max = rect.width * MAX_RIGHT_FRACTION;
1467
+ setRightWidth(Math.min(max, Math.max(MIN_RIGHT_WIDTH, raw)));
1468
+ };
1469
+ const onUp = () => {
1470
+ window.removeEventListener("pointermove", onMove);
1471
+ window.removeEventListener("pointerup", onUp);
1472
+ setDragging(false);
1473
+ setRightWidth((width) => {
1474
+ if (width !== null) savePanelWidth(width);
1475
+ return width;
1476
+ });
1477
+ };
1478
+ window.addEventListener("pointermove", onMove);
1479
+ window.addEventListener("pointerup", onUp);
1480
+ };
1481
+ if (!right) {
1482
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: singleColumnStyle, children: left });
1483
+ }
1484
+ const containerStyle = rightWidth !== null ? { "--omnispec-tryit-col": `${rightWidth}px` } : void 0;
1485
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1486
+ "div",
1487
+ {
1488
+ ref: containerRef,
1489
+ className: `${gridStyle} ${dragging ? draggingContainerStyle : ""}`,
1490
+ style: containerStyle,
1491
+ children: [
1492
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: leftColumnStyle, children: [
1493
+ left,
1494
+ /* @__PURE__ */ jsxRuntime.jsx(
1495
+ "button",
1496
+ {
1497
+ type: "button",
1498
+ className: toggleButtonStyle,
1499
+ onClick: () => setShowRight((prev) => !prev),
1500
+ children: showRight ? "Hide" : rightLabel
1501
+ }
1502
+ )
1503
+ ] }),
1504
+ /* @__PURE__ */ jsxRuntime.jsx(
1505
+ "div",
1506
+ {
1507
+ className: resizeHandleStyle,
1508
+ role: "separator",
1509
+ "aria-orientation": "vertical",
1510
+ "aria-label": `Resize ${rightLabel} panel`,
1511
+ onPointerDown: startDrag,
1512
+ ...dragging ? { "data-dragging": "" } : {}
1513
+ }
1514
+ ),
1515
+ /* @__PURE__ */ jsxRuntime.jsx(
1516
+ "div",
1517
+ {
1518
+ className: rightColumnStyle,
1519
+ ...showRight ? { "data-mobile-visible": "" } : {},
1520
+ children: right
1521
+ }
1522
+ )
1523
+ ]
1524
+ }
1525
+ );
1526
+ }
1527
+
1528
+ async function sendProxiedRequest(proxyUrl, request, proxyHeaders) {
1529
+ const targetUrl = buildTargetUrl$1(request);
1530
+ const proxyPayload = {
1531
+ url: targetUrl,
1532
+ method: request.method,
1533
+ headers: request.headers,
1534
+ timeout: 3e4
1535
+ };
1536
+ if (request.body) {
1537
+ if (typeof request.body === "string") {
1538
+ proxyPayload.body = request.body;
1539
+ proxyPayload.bodyEncoding = "utf-8";
1540
+ } else {
1541
+ const { body, contentType } = await encodeMultipartBody(request.body);
1542
+ proxyPayload.body = body;
1543
+ proxyPayload.bodyEncoding = "base64";
1544
+ proxyPayload.headers = { ...proxyPayload.headers, "Content-Type": contentType };
1545
+ }
1546
+ }
1547
+ const startTime = performance.now();
1548
+ const response = await fetch(proxyUrl, {
1549
+ method: "POST",
1550
+ headers: { "Content-Type": "application/json", ...proxyHeaders },
1551
+ body: JSON.stringify(proxyPayload)
1552
+ });
1553
+ if (!response.ok) {
1554
+ throw new Error(`Proxy request failed: ${response.status} ${response.statusText}`);
1555
+ }
1556
+ const proxyResponse = await response.json();
1557
+ const duration = performance.now() - startTime;
1558
+ return {
1559
+ status: proxyResponse.status,
1560
+ statusText: proxyResponse.statusText,
1561
+ headers: proxyResponse.headers,
1562
+ body: proxyResponse.body,
1563
+ bodyEncoding: proxyResponse.bodyEncoding ?? "utf-8",
1564
+ contentType: proxyResponse.headers["content-type"] ?? "text/plain",
1565
+ duration: proxyResponse.duration ?? duration
1566
+ };
1567
+ }
1568
+ async function blobToBytes(value) {
1569
+ if (typeof value.arrayBuffer === "function") {
1570
+ return new Uint8Array(await value.arrayBuffer());
1571
+ }
1572
+ return new Promise((resolve, reject) => {
1573
+ const reader = new FileReader();
1574
+ reader.onload = () => resolve(new Uint8Array(reader.result));
1575
+ reader.onerror = () => reject(reader.error);
1576
+ reader.readAsArrayBuffer(value);
1577
+ });
1578
+ }
1579
+ async function encodeMultipartBody(formData) {
1580
+ const boundary = `----omnispec${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
1581
+ const encoder = new TextEncoder();
1582
+ const chunks = [];
1583
+ const push = (s) => chunks.push(encoder.encode(s));
1584
+ const entries = [];
1585
+ formData.forEach((value, key) => entries.push([key, value]));
1586
+ for (const [key, value] of entries) {
1587
+ push(`--${boundary}\r
1588
+ `);
1589
+ if (typeof value === "string") {
1590
+ push(`Content-Disposition: form-data; name="${key}"\r
1591
+ \r
1592
+ `);
1593
+ push(`${value}\r
1594
+ `);
1595
+ } else {
1596
+ const filename = value.name || "file";
1597
+ const fileType = value.type || "application/octet-stream";
1598
+ push(`Content-Disposition: form-data; name="${key}"; filename="${filename}"\r
1599
+ `);
1600
+ push(`Content-Type: ${fileType}\r
1601
+ \r
1602
+ `);
1603
+ chunks.push(await blobToBytes(value));
1604
+ push("\r\n");
1605
+ }
1606
+ }
1607
+ push(`--${boundary}--\r
1608
+ `);
1609
+ const total = chunks.reduce((n, c) => n + c.length, 0);
1610
+ const bytes = new Uint8Array(total);
1611
+ let offset = 0;
1612
+ for (const c of chunks) {
1613
+ bytes.set(c, offset);
1614
+ offset += c.length;
1615
+ }
1616
+ let binary = "";
1617
+ const CHUNK = 32768;
1618
+ for (let i = 0; i < bytes.length; i += CHUNK) {
1619
+ binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
1620
+ }
1621
+ return { body: btoa(binary), contentType: `multipart/form-data; boundary=${boundary}` };
1622
+ }
1623
+ function buildTargetUrl$1(request) {
1624
+ let url = request.url;
1625
+ for (const [key, value] of Object.entries(request.pathParams)) {
1626
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
1627
+ }
1628
+ const queryEntries = Object.entries(request.queryParams);
1629
+ if (queryEntries.length > 0) {
1630
+ const params = new URLSearchParams();
1631
+ for (const [key, value] of queryEntries) {
1632
+ if (Array.isArray(value)) {
1633
+ for (const v of value) {
1634
+ params.append(key, v);
1635
+ }
1636
+ } else {
1637
+ params.set(key, value);
1638
+ }
1639
+ }
1640
+ const separator = url.includes("?") ? "&" : "?";
1641
+ url = `${url}${separator}${params.toString()}`;
1642
+ }
1643
+ return url;
1644
+ }
1645
+
1646
+ async function sendDirectRequest(request) {
1647
+ const url = upgradeMixedContent(buildTargetUrl(request));
1648
+ const init = {
1649
+ method: request.method,
1650
+ headers: request.headers
1651
+ };
1652
+ if (request.body) {
1653
+ init.body = typeof request.body === "string" ? request.body : request.body;
1654
+ }
1655
+ const startTime = performance.now();
1656
+ const response = await fetch(url, init);
1657
+ const duration = performance.now() - startTime;
1658
+ const contentType = response.headers.get("content-type") ?? "text/plain";
1659
+ let body;
1660
+ let bodyEncoding = "utf-8";
1661
+ if (binaryResponse.isBinaryContentType(contentType)) {
1662
+ body = binaryResponse.bytesToBase64(new Uint8Array(await response.arrayBuffer()));
1663
+ bodyEncoding = "base64";
1664
+ } else {
1665
+ body = await response.text();
1666
+ }
1667
+ const headers = {};
1668
+ response.headers.forEach((value, key) => {
1669
+ headers[key] = value;
1670
+ });
1671
+ return {
1672
+ status: response.status,
1673
+ statusText: response.statusText,
1674
+ headers,
1675
+ body,
1676
+ bodyEncoding,
1677
+ contentType,
1678
+ duration
1679
+ };
1680
+ }
1681
+ function upgradeMixedContent(url) {
1682
+ if (typeof window !== "undefined" && window.location?.protocol === "https:" && url.startsWith("http://")) {
1683
+ return `https://${url.slice("http://".length)}`;
1684
+ }
1685
+ return url;
1686
+ }
1687
+ function buildTargetUrl(request) {
1688
+ let url = request.url;
1689
+ for (const [key, value] of Object.entries(request.pathParams)) {
1690
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
1691
+ }
1692
+ const queryEntries = Object.entries(request.queryParams);
1693
+ if (queryEntries.length > 0) {
1694
+ const params = new URLSearchParams();
1695
+ for (const [key, value] of queryEntries) {
1696
+ if (Array.isArray(value)) {
1697
+ for (const v of value) {
1698
+ params.append(key, v);
1699
+ }
1700
+ } else {
1701
+ params.set(key, value);
1702
+ }
1703
+ }
1704
+ const separator = url.includes("?") ? "&" : "?";
1705
+ url = `${url}${separator}${params.toString()}`;
1706
+ }
1707
+ return url;
1708
+ }
1709
+
1710
+ const generators = {
1711
+ curl: generateCurl,
1712
+ javascript: generateJavaScript,
1713
+ python: generatePython,
1714
+ go: generateGo,
1715
+ java: generateJava,
1716
+ csharp: generateCSharp
1717
+ };
1718
+ function CodeSamples({
1719
+ request,
1720
+ serverUrl,
1721
+ selectedLanguage,
1722
+ onLanguageChange,
1723
+ xCodeSamples
1724
+ }) {
1725
+ const code = React.useMemo(() => {
1726
+ if (xCodeSamples) {
1727
+ const custom = xCodeSamples.find(
1728
+ (s) => s.lang.toLowerCase() === selectedLanguage || s.label?.toLowerCase() === selectedLanguage
1729
+ );
1730
+ if (custom) return custom.source;
1731
+ }
1732
+ const generator = generators[selectedLanguage];
1733
+ return generator ? generator(request, serverUrl) : "";
1734
+ }, [request, serverUrl, selectedLanguage, xCodeSamples]);
1735
+ const langOption = CODE_LANGUAGES.find((l) => l.id === selectedLanguage);
1736
+ const prismLang = langOption?.prismLanguage ?? "text";
1737
+ const languageTabs = /* @__PURE__ */ jsxRuntime.jsx("div", { className: languageBarStyle, children: CODE_LANGUAGES.map((lang) => /* @__PURE__ */ jsxRuntime.jsx(
1738
+ "button",
1739
+ {
1740
+ type: "button",
1741
+ onClick: () => onLanguageChange(lang.id),
1742
+ className: css.cx(langBtnStyle, selectedLanguage === lang.id && langBtnActiveStyle),
1743
+ children: lang.label
1744
+ },
1745
+ lang.id
1746
+ )) });
1747
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: containerStyle$1, children: /* @__PURE__ */ jsxRuntime.jsx(
1748
+ Collapsible.CodeBlock,
1749
+ {
1750
+ code,
1751
+ language: prismLang,
1752
+ showCopy: true,
1753
+ headerLeft: languageTabs
1754
+ }
1755
+ ) });
1756
+ }
1757
+ const containerStyle$1 = css.css({
1758
+ marginTop: "0.75rem"
1759
+ });
1760
+ const languageBarStyle = css.css({
1761
+ display: "flex",
1762
+ gap: "0.125rem",
1763
+ overflowX: "auto",
1764
+ scrollbarWidth: "none",
1765
+ "&::-webkit-scrollbar": {
1766
+ display: "none"
1767
+ }
1768
+ });
1769
+ const langBtnStyle = css.css({
1770
+ padding: "0.25rem 0.5rem",
1771
+ background: "none",
1772
+ border: "none",
1773
+ cursor: "pointer",
1774
+ fontSize: "var(--omnispec-font-size-xs)",
1775
+ fontWeight: 500,
1776
+ color: "var(--omnispec-fg-muted)",
1777
+ whiteSpace: "nowrap",
1778
+ borderRadius: "var(--omnispec-border-radius)",
1779
+ "&:hover": {
1780
+ color: "var(--omnispec-fg-primary)",
1781
+ backgroundColor: "var(--omnispec-bg-secondary)"
1782
+ }
1783
+ });
1784
+ const langBtnActiveStyle = css.css({
1785
+ color: "var(--omnispec-color-primary)",
1786
+ backgroundColor: "var(--omnispec-bg-secondary)",
1787
+ fontWeight: 600
1788
+ });
1789
+
1790
+ const containerStyle = css.css({
1791
+ marginTop: "12px",
1792
+ border: "1px solid var(--omnispec-border-color)",
1793
+ borderRadius: "var(--omnispec-border-radius)",
1794
+ padding: "12px",
1795
+ backgroundColor: "var(--omnispec-bg-secondary)"
1796
+ });
1797
+ const statusBarStyle = css.css({
1798
+ display: "flex",
1799
+ justifyContent: "space-between",
1800
+ alignItems: "center",
1801
+ marginBottom: "12px"
1802
+ });
1803
+ const statusCodeBaseStyle = css.css({
1804
+ fontFamily: "var(--omnispec-font-mono)",
1805
+ fontWeight: 700,
1806
+ fontSize: "var(--omnispec-font-size-base)"
1807
+ });
1808
+ const durationStyle = css.css({
1809
+ color: "var(--omnispec-fg-muted)",
1810
+ fontSize: "var(--omnispec-font-size-xs)"
1811
+ });
1812
+ const loadingStyle = css.css({
1813
+ color: "var(--omnispec-fg-muted)",
1814
+ textAlign: "center",
1815
+ padding: "24px"
1816
+ });
1817
+ const errorStyle$1 = css.css({
1818
+ color: "var(--omnispec-color-error)",
1819
+ padding: "12px"
1820
+ });
1821
+ const headersStyle = css.css({
1822
+ fontFamily: "var(--omnispec-font-mono)",
1823
+ fontSize: "var(--omnispec-font-size-xs)"
1824
+ });
1825
+ const headerRowStyle = css.css({
1826
+ display: "flex",
1827
+ gap: "8px",
1828
+ padding: "2px 0"
1829
+ });
1830
+ const headerKeyStyle = css.css({
1831
+ color: "var(--omnispec-fg-secondary)",
1832
+ fontWeight: 600
1833
+ });
1834
+ const headerValueStyle = css.css({
1835
+ color: "var(--omnispec-fg-primary)",
1836
+ wordBreak: "break-all"
1837
+ });
1838
+ function ResponseViewer({ response, loading, error }) {
1839
+ if (loading) {
1840
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: containerStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: loadingStyle, children: "Sending request..." }) });
1841
+ }
1842
+ if (error) {
1843
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: containerStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: errorStyle$1, children: error }) });
1844
+ }
1845
+ if (!response) return null;
1846
+ const statusColor = getStatusColor(response.status);
1847
+ const isBinary = response.bodyEncoding === "base64";
1848
+ const bodyLanguage = detectLanguage(response.contentType);
1849
+ const formattedBody = isBinary ? "" : formatBody(response.body, bodyLanguage);
1850
+ const handleDownload = () => {
1851
+ const blob = binaryResponse.base64ToBlob(response.body, response.contentType);
1852
+ const url = URL.createObjectURL(blob);
1853
+ const anchor = document.createElement("a");
1854
+ anchor.href = url;
1855
+ anchor.download = binaryResponse.filenameForResponse(response.headers, response.contentType);
1856
+ document.body.appendChild(anchor);
1857
+ anchor.click();
1858
+ anchor.remove();
1859
+ URL.revokeObjectURL(url);
1860
+ };
1861
+ const binarySize = isBinary ? Math.floor(response.body.length * 3 / 4) : 0;
1862
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `adr-response ${containerStyle}`, children: [
1863
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: statusBarStyle, children: [
1864
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: css.css(statusCodeBaseStyle, { color: statusColor }), children: [
1865
+ response.status,
1866
+ " ",
1867
+ response.statusText
1868
+ ] }),
1869
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: durationStyle, children: [
1870
+ response.duration.toFixed(0),
1871
+ "ms"
1872
+ ] })
1873
+ ] }),
1874
+ /* @__PURE__ */ jsxRuntime.jsx(
1875
+ Collapsible.Tabs,
1876
+ {
1877
+ tabs: [
1878
+ {
1879
+ id: "body",
1880
+ label: "Response Body",
1881
+ content: isBinary ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: binaryPanelStyle, children: [
1882
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: binaryInfoStyle, children: [
1883
+ "Binary response \u2014 ",
1884
+ response.contentType.split(";")[0],
1885
+ " (",
1886
+ formatSize(binarySize),
1887
+ ")"
1888
+ ] }),
1889
+ /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.Button, { variant: "secondary", onClick: handleDownload, children: "Download" })
1890
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
1891
+ Collapsible.CodeBlock,
1892
+ {
1893
+ code: formattedBody,
1894
+ language: bodyLanguage,
1895
+ title: response.contentType,
1896
+ maxHeight: "300px"
1897
+ }
1898
+ )
1899
+ },
1900
+ {
1901
+ id: "headers",
1902
+ label: "Headers",
1903
+ content: /* @__PURE__ */ jsxRuntime.jsx("div", { className: headersStyle, children: Object.entries(response.headers).map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: headerRowStyle, children: [
1904
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: headerKeyStyle, children: [
1905
+ key,
1906
+ ":"
1907
+ ] }),
1908
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: headerValueStyle, children: value })
1909
+ ] }, key)) })
1910
+ }
1911
+ ]
1912
+ }
1913
+ )
1914
+ ] });
1915
+ }
1916
+ const binaryPanelStyle = css.css({
1917
+ display: "flex",
1918
+ flexDirection: "column",
1919
+ alignItems: "flex-start",
1920
+ gap: "0.75rem",
1921
+ padding: "1rem"
1922
+ });
1923
+ const binaryInfoStyle = css.css({
1924
+ fontSize: "var(--omnispec-font-size-sm)",
1925
+ color: "var(--omnispec-fg-secondary)",
1926
+ fontFamily: "var(--omnispec-font-mono)",
1927
+ wordBreak: "break-all"
1928
+ });
1929
+ function formatSize(bytes) {
1930
+ if (bytes < 1024) return `${bytes} B`;
1931
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
1932
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1933
+ }
1934
+ function getStatusColor(status) {
1935
+ if (status >= 200 && status < 300) return "var(--omnispec-color-success)";
1936
+ if (status >= 300 && status < 400) return "var(--omnispec-color-info)";
1937
+ if (status >= 400 && status < 500) return "var(--omnispec-color-warning)";
1938
+ return "var(--omnispec-color-error)";
1939
+ }
1940
+ function detectLanguage(contentType) {
1941
+ if (contentType.includes("json")) return "json";
1942
+ if (contentType.includes("xml") || contentType.includes("html")) return "xml";
1943
+ if (contentType.includes("yaml") || contentType.includes("yml")) return "yaml";
1944
+ return "text";
1945
+ }
1946
+ function formatBody(body, language) {
1947
+ if (language === "json") {
1948
+ try {
1949
+ return JSON.stringify(JSON.parse(body), null, 2);
1950
+ } catch {
1951
+ return body;
1952
+ }
1953
+ }
1954
+ return body;
1955
+ }
1956
+
1957
+ function SecretInput({
1958
+ value,
1959
+ onChange,
1960
+ placeholder,
1961
+ className,
1962
+ autoComplete,
1963
+ "aria-label": ariaLabel
1964
+ }) {
1965
+ const [revealed, setRevealed] = React.useState(false);
1966
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapStyle, children: [
1967
+ /* @__PURE__ */ jsxRuntime.jsx(
1968
+ "input",
1969
+ {
1970
+ type: revealed ? "text" : "password",
1971
+ value,
1972
+ onChange: (e) => onChange(e.target.value),
1973
+ placeholder,
1974
+ className,
1975
+ autoComplete,
1976
+ "aria-label": ariaLabel,
1977
+ style: { width: "100%", paddingRight: "2.25rem" }
1978
+ }
1979
+ ),
1980
+ /* @__PURE__ */ jsxRuntime.jsx(
1981
+ "button",
1982
+ {
1983
+ type: "button",
1984
+ onClick: () => setRevealed((v) => !v),
1985
+ className: toggleStyle,
1986
+ "aria-label": revealed ? "Hide value" : "Show value",
1987
+ "aria-pressed": revealed,
1988
+ title: revealed ? "Hide" : "Show",
1989
+ children: /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.Icon, { name: revealed ? "eye-off" : "eye", size: "1rem" })
1990
+ }
1991
+ )
1992
+ ] });
1993
+ }
1994
+ const wrapStyle = css.css({
1995
+ position: "relative",
1996
+ flex: 1,
1997
+ display: "flex",
1998
+ alignItems: "stretch"
1999
+ });
2000
+ const toggleStyle = css.css({
2001
+ position: "absolute",
2002
+ right: "4px",
2003
+ top: "50%",
2004
+ transform: "translateY(-50%)",
2005
+ display: "inline-flex",
2006
+ alignItems: "center",
2007
+ justifyContent: "center",
2008
+ width: "1.75rem",
2009
+ height: "1.75rem",
2010
+ padding: 0,
2011
+ border: "none",
2012
+ background: "transparent",
2013
+ cursor: "pointer",
2014
+ color: "var(--omnispec-fg-muted)",
2015
+ borderRadius: "var(--omnispec-border-radius)",
2016
+ "&:hover": {
2017
+ color: "var(--omnispec-fg-primary)"
2018
+ },
2019
+ "&:focus-visible": {
2020
+ outline: "2px solid var(--omnispec-color-primary)",
2021
+ outlineOffset: "1px"
2022
+ }
2023
+ });
2024
+
2025
+ const authStyles = {
2026
+ section: css.css({
2027
+ padding: "0.75rem 0",
2028
+ borderBottom: "1px solid var(--omnispec-border-color)",
2029
+ "&:last-child": {
2030
+ borderBottom: "none"
2031
+ }
2032
+ }),
2033
+ label: css.css({
2034
+ fontWeight: 600,
2035
+ fontSize: "var(--omnispec-font-size-sm)",
2036
+ color: "var(--omnispec-fg-primary)",
2037
+ marginBottom: "4px",
2038
+ display: "flex",
2039
+ alignItems: "center",
2040
+ gap: "8px"
2041
+ }),
2042
+ hint: css.css({
2043
+ fontWeight: 400,
2044
+ fontSize: "var(--omnispec-font-size-xs)",
2045
+ color: "var(--omnispec-fg-muted)"
2046
+ }),
2047
+ description: css.css({
2048
+ fontSize: "var(--omnispec-font-size-xs)",
2049
+ color: "var(--omnispec-fg-secondary)",
2050
+ margin: "4px 0 8px"
2051
+ }),
2052
+ inputRow: css.css({
2053
+ display: "flex",
2054
+ gap: "8px",
2055
+ alignItems: "center"
2056
+ }),
2057
+ input: css.css({
2058
+ flex: 1,
2059
+ padding: "6px 10px",
2060
+ border: "1px solid var(--omnispec-input-border)",
2061
+ borderRadius: "var(--omnispec-border-radius)",
2062
+ backgroundColor: "var(--omnispec-input-bg)",
2063
+ color: "var(--omnispec-fg-primary)",
2064
+ fontSize: "var(--omnispec-font-size-sm)",
2065
+ fontFamily: "var(--omnispec-font-mono)",
2066
+ "&:focus": {
2067
+ borderColor: "var(--omnispec-color-primary)",
2068
+ outline: "none"
2069
+ },
2070
+ "&:hover": {
2071
+ borderColor: "var(--omnispec-color-primary)"
2072
+ }
2073
+ }),
2074
+ applyBtn: css.css({
2075
+ padding: "6px 16px",
2076
+ backgroundColor: "var(--omnispec-color-primary)",
2077
+ color: "var(--omnispec-color-primary-text)",
2078
+ border: "none",
2079
+ borderRadius: "var(--omnispec-border-radius)",
2080
+ cursor: "pointer",
2081
+ fontSize: "var(--omnispec-font-size-sm)",
2082
+ fontWeight: 500,
2083
+ "&:hover": {
2084
+ opacity: 0.85
2085
+ }
2086
+ }),
2087
+ removeBtn: css.css({
2088
+ padding: "6px 16px",
2089
+ backgroundColor: "var(--omnispec-color-error)",
2090
+ color: "#fff",
2091
+ border: "none",
2092
+ borderRadius: "var(--omnispec-border-radius)",
2093
+ cursor: "pointer",
2094
+ fontSize: "var(--omnispec-font-size-sm)",
2095
+ fontWeight: 500,
2096
+ "&:hover": {
2097
+ opacity: 0.85
2098
+ }
2099
+ })
2100
+ };
2101
+ function ApiKeyAuth({ scheme, onApply, onRemove, applied, appliedValue }) {
2102
+ const [value, setValue] = React.useState(appliedValue?.input?.value ?? "");
2103
+ const handleApply = () => {
2104
+ if (!value.trim()) return;
2105
+ const headerName = scheme.in === "query" ? scheme.name ?? "api_key" : scheme.name ?? "X-API-Key";
2106
+ onApply({
2107
+ schemeId: scheme.id,
2108
+ headerName,
2109
+ headerValue: value,
2110
+ input: { value }
2111
+ });
2112
+ };
2113
+ const handleRemove = () => {
2114
+ setValue("");
2115
+ onRemove(scheme.id);
2116
+ };
2117
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.section, children: [
2118
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.label, children: [
2119
+ scheme.displayName,
2120
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: authStyles.hint, children: [
2121
+ "(",
2122
+ scheme.in,
2123
+ ": ",
2124
+ scheme.name,
2125
+ ")"
2126
+ ] })
2127
+ ] }),
2128
+ scheme.description && /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
2129
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.inputRow, children: [
2130
+ /* @__PURE__ */ jsxRuntime.jsx(
2131
+ SecretInput,
2132
+ {
2133
+ value,
2134
+ onChange: setValue,
2135
+ placeholder: "Enter API key",
2136
+ className: authStyles.input,
2137
+ "aria-label": `${scheme.displayName} value`
2138
+ }
2139
+ ),
2140
+ applied ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleApply, className: authStyles.applyBtn, children: "Apply" })
2141
+ ] })
2142
+ ] });
2143
+ }
2144
+
2145
+ const flowLabels = {
2146
+ authorizationCode: "Authorization Code",
2147
+ implicit: "Implicit",
2148
+ clientCredentials: "Client Credentials",
2149
+ password: "Resource Owner Password"
2150
+ };
2151
+ const flowSelectorStyle = css.css({
2152
+ display: "flex",
2153
+ gap: "4px",
2154
+ marginBottom: ".5rem"
2155
+ });
2156
+ const flowTabStyle = css.css({
2157
+ padding: "4px 10px",
2158
+ background: "var(--omnispec-bg-tertiary)",
2159
+ border: "1px solid var(--omnispec-border-color)",
2160
+ borderRadius: "var(--omnispec-border-radius)",
2161
+ cursor: "pointer",
2162
+ fontSize: "var(--omnispec-font-size-xs)",
2163
+ color: "var(--omnispec-fg-secondary)",
2164
+ "&:hover": {
2165
+ borderColor: "var(--omnispec-color-primary)"
2166
+ }
2167
+ });
2168
+ const activeFlowTabStyle = css.css({
2169
+ backgroundColor: "var(--omnispec-color-primary)",
2170
+ color: "var(--omnispec-color-primary-text)",
2171
+ borderColor: "var(--omnispec-color-primary)"
2172
+ });
2173
+ const flowDetailsStyle = css.css({
2174
+ marginBottom: "0.5rem"
2175
+ });
2176
+ const urlRowStyle$1 = css.css({
2177
+ display: "flex",
2178
+ gap: "0.5rem",
2179
+ fontSize: "var(--omnispec-font-size-sm)",
2180
+ marginBottom: "0.25rem"
2181
+ });
2182
+ const urlLabelStyle = css.css({
2183
+ color: "var(--omnispec-fg-muted)",
2184
+ fontWeight: 600,
2185
+ whiteSpace: "nowrap",
2186
+ marginBottom: ".5rem",
2187
+ display: "inline-block"
2188
+ });
2189
+ const urlValueStyle = css.css({
2190
+ color: "var(--omnispec-fg-secondary)",
2191
+ fontFamily: "var(--omnispec-font-mono)",
2192
+ fontSize: "var(--omnispec-font-size-sm)",
2193
+ wordBreak: "break-all"
2194
+ });
2195
+ const scopesStyle = css.css({
2196
+ marginTop: "0.5rem",
2197
+ fontSize: "var(--omnispec-font-size-sm)"
2198
+ });
2199
+ const scopeListStyle = css.css({
2200
+ marginTop: "0.25rem",
2201
+ display: "flex",
2202
+ flexDirection: "column",
2203
+ gap: "0.125rem"
2204
+ });
2205
+ const scopeItemStyle = css.css({
2206
+ fontSize: "var(--omnispec-font-size-sm)"
2207
+ });
2208
+ const scopeNameStyle = css.css({
2209
+ fontFamily: "var(--omnispec-font-mono)",
2210
+ color: "var(--omnispec-fg-secondary)"
2211
+ });
2212
+ const scopeDescStyle = css.css({
2213
+ color: "var(--omnispec-fg-muted)"
2214
+ });
2215
+ const tokenSectionStyle = css.css({
2216
+ marginTop: "8px"
2217
+ });
2218
+ const flowErrorStyle = css.css({
2219
+ marginTop: "8px",
2220
+ fontSize: "var(--omnispec-font-size-xs)",
2221
+ color: "var(--omnispec-color-error)"
2222
+ });
2223
+ function OAuth2AuthManual({ scheme, onApply, onRemove, applied, appliedValue }) {
2224
+ const flows = scheme.flows;
2225
+ const availableFlows = flows ? Object.entries(flows).filter(([, v]) => v) : [];
2226
+ const [activeFlow, setActiveFlow] = React.useState(availableFlows[0]?.[0] ?? "authorizationCode");
2227
+ const [token, setToken] = React.useState(appliedValue?.input?.token ?? "");
2228
+ const [applyError, setApplyError] = React.useState(void 0);
2229
+ const currentFlow = flows?.[activeFlow];
2230
+ const handleTokenChange = (value) => {
2231
+ setToken(value);
2232
+ if (applyError) setApplyError(void 0);
2233
+ };
2234
+ const handleApplyToken = () => {
2235
+ if (!token.trim()) {
2236
+ setApplyError("Enter an access token to apply.");
2237
+ return;
2238
+ }
2239
+ setApplyError(void 0);
2240
+ onApply({
2241
+ schemeId: scheme.id,
2242
+ headerName: "Authorization",
2243
+ headerValue: `Bearer ${token}`,
2244
+ input: { token }
2245
+ });
2246
+ };
2247
+ const handleRemove = () => {
2248
+ setToken("");
2249
+ setApplyError(void 0);
2250
+ onRemove(scheme.id);
2251
+ };
2252
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.section, children: [
2253
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.label, children: [
2254
+ scheme.displayName,
2255
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: authStyles.hint, children: "(OAuth 2.0)" })
2256
+ ] }),
2257
+ scheme.description && /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
2258
+ availableFlows.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: flowSelectorStyle, children: availableFlows.map(([key]) => /* @__PURE__ */ jsxRuntime.jsx(
2259
+ "button",
2260
+ {
2261
+ type: "button",
2262
+ onClick: () => setActiveFlow(key),
2263
+ className: css.cx(flowTabStyle, key === activeFlow && activeFlowTabStyle),
2264
+ children: flowLabels[key]
2265
+ },
2266
+ key
2267
+ )) }),
2268
+ currentFlow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: flowDetailsStyle, children: [
2269
+ currentFlow.authorizationUrl && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: urlRowStyle$1, children: [
2270
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: urlLabelStyle, children: "Auth URL:" }),
2271
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: urlValueStyle, children: currentFlow.authorizationUrl })
2272
+ ] }),
2273
+ currentFlow.tokenUrl && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: urlRowStyle$1, children: [
2274
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: urlLabelStyle, children: "Token URL:" }),
2275
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: urlValueStyle, children: currentFlow.tokenUrl })
2276
+ ] }),
2277
+ currentFlow.refreshUrl && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: urlRowStyle$1, children: [
2278
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: urlLabelStyle, children: "Refresh URL:" }),
2279
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: urlValueStyle, children: currentFlow.refreshUrl })
2280
+ ] }),
2281
+ currentFlow.scopes && Object.keys(currentFlow.scopes).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: scopesStyle, children: [
2282
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: urlLabelStyle, children: "Scopes:" }),
2283
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: scopeListStyle, children: Object.entries(currentFlow.scopes).map(([scope, desc]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: scopeItemStyle, children: [
2284
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: scopeNameStyle, children: scope }),
2285
+ desc && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: scopeDescStyle, children: [
2286
+ " \u2014 ",
2287
+ desc
2288
+ ] })
2289
+ ] }, scope)) })
2290
+ ] })
2291
+ ] }),
2292
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tokenSectionStyle, children: [
2293
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: authStyles.label, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: authStyles.hint, children: "Enter access token:" }) }),
2294
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.inputRow, children: [
2295
+ /* @__PURE__ */ jsxRuntime.jsx(
2296
+ SecretInput,
2297
+ {
2298
+ value: token,
2299
+ onChange: handleTokenChange,
2300
+ placeholder: "Access token",
2301
+ className: authStyles.input,
2302
+ "aria-label": `${scheme.displayName} access token`
2303
+ }
2304
+ ),
2305
+ applied ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleApplyToken, className: authStyles.applyBtn, children: "Apply" })
2306
+ ] }),
2307
+ applyError && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: flowErrorStyle, children: applyError })
2308
+ ] })
2309
+ ] });
2310
+ }
2311
+
2312
+ const errorStyle = css.css({
2313
+ fontSize: "var(--omnispec-font-size-xs)",
2314
+ color: "var(--omnispec-color-error)",
2315
+ margin: "4px 0 8px"
2316
+ });
2317
+ const urlRowStyle = css.css({
2318
+ fontSize: "var(--omnispec-font-size-xs)",
2319
+ color: "var(--omnispec-fg-secondary)",
2320
+ margin: "4px 0 8px",
2321
+ wordBreak: "break-all"
2322
+ });
2323
+ const urlLinkStyle = css.css({
2324
+ color: "var(--omnispec-color-primary)"
2325
+ });
2326
+ function OpenIdConnectManual({
2327
+ scheme,
2328
+ onApply,
2329
+ onRemove,
2330
+ applied,
2331
+ appliedValue
2332
+ }) {
2333
+ const [token, setToken] = React.useState(appliedValue?.input?.token ?? "");
2334
+ const [error, setError] = React.useState(void 0);
2335
+ const handleApply = () => {
2336
+ if (!token.trim()) {
2337
+ setError("Enter an access token to apply.");
2338
+ return;
2339
+ }
2340
+ setError(void 0);
2341
+ onApply({
2342
+ schemeId: scheme.id,
2343
+ headerName: "Authorization",
2344
+ headerValue: `Bearer ${token}`,
2345
+ input: { token }
2346
+ });
2347
+ };
2348
+ const handleRemove = () => {
2349
+ setToken("");
2350
+ setError(void 0);
2351
+ onRemove(scheme.id);
2352
+ };
2353
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.section, children: [
2354
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.label, children: [
2355
+ scheme.displayName,
2356
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: authStyles.hint, children: "(OpenID Connect)" })
2357
+ ] }),
2358
+ scheme.description && /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
2359
+ scheme.openIdConnectUrl && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: urlRowStyle, children: [
2360
+ "Discovery URL:",
2361
+ " ",
2362
+ /* @__PURE__ */ jsxRuntime.jsx(
2363
+ "a",
2364
+ {
2365
+ className: urlLinkStyle,
2366
+ href: scheme.openIdConnectUrl,
2367
+ target: "_blank",
2368
+ rel: "noreferrer noopener",
2369
+ children: scheme.openIdConnectUrl
2370
+ }
2371
+ )
2372
+ ] }),
2373
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: authStyles.label, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: authStyles.hint, children: "Enter access token directly:" }) }),
2374
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: authStyles.inputRow, children: [
2375
+ /* @__PURE__ */ jsxRuntime.jsx(
2376
+ SecretInput,
2377
+ {
2378
+ value: token,
2379
+ onChange: (value) => {
2380
+ setToken(value);
2381
+ if (error) setError(void 0);
2382
+ },
2383
+ placeholder: "Access token",
2384
+ className: authStyles.input,
2385
+ "aria-label": `${scheme.displayName} access token`
2386
+ }
2387
+ ),
2388
+ applied ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleApply, className: authStyles.applyBtn, children: "Apply" })
2389
+ ] }),
2390
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: errorStyle, children: error })
2391
+ ] });
2392
+ }
2393
+
2394
+ exports.ApiKeyAuth = ApiKeyAuth;
2395
+ exports.AuthProvider = AuthProvider;
2396
+ exports.CodeSamples = CodeSamples;
2397
+ exports.ExampleSelector = ExampleSelector;
2398
+ exports.LinkableHeading = LinkableHeading;
2399
+ exports.Modal = Modal;
2400
+ exports.OAuth2AuthManual = OAuth2AuthManual;
2401
+ exports.OpenIdConnectManual = OpenIdConnectManual;
2402
+ exports.ReferenceLayout = ReferenceLayout;
2403
+ exports.ReferenceOperationDetail = ReferenceOperationDetail;
2404
+ exports.ResponseViewer = ResponseViewer;
2405
+ exports.ResponsiveColumns = ResponsiveColumns;
2406
+ exports.SamplesPanel = SamplesPanel;
2407
+ exports.SecretInput = SecretInput;
2408
+ exports.authStyles = authStyles;
2409
+ exports.clearTryItState = clearTryItState;
2410
+ exports.getNamedExamples = getNamedExamples;
2411
+ exports.loadTryItState = loadTryItState;
2412
+ exports.saveTryItState = saveTryItState;
2413
+ exports.sendDirectRequest = sendDirectRequest;
2414
+ exports.sendProxiedRequest = sendProxiedRequest;
2415
+ exports.useAuth = useAuth;
2416
+ //# sourceMappingURL=OpenIdConnectManual-oEnN0QJ-.js.map