@clarify-labs/renderer 0.10.0 → 0.10.2

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 (91) hide show
  1. package/output/{ClarifyShell-CxhXBtsR.js → ClarifyShell-1LuBliwt.js} +124 -40
  2. package/output/ClarifyShell-1LuBliwt.js.map +1 -0
  3. package/output/{ClarifyShell-DjLRRW8T.cjs → ClarifyShell-C6li72Ce.cjs} +136 -52
  4. package/output/ClarifyShell-C6li72Ce.cjs.map +1 -0
  5. package/output/MermaidViewer-B6-BMCJG.cjs +101 -0
  6. package/output/MermaidViewer-B6-BMCJG.cjs.map +1 -0
  7. package/output/MermaidViewer-dXsomvM7.js +98 -0
  8. package/output/MermaidViewer-dXsomvM7.js.map +1 -0
  9. package/output/{OpenApiOperation-qp5tFaWP.cjs → OpenApiOperation-B52IWlKb.cjs} +405 -243
  10. package/output/OpenApiOperation-B52IWlKb.cjs.map +1 -0
  11. package/output/{OpenApiOperation-CyBkzvob.js → OpenApiOperation-DgrqzeiS.js} +377 -228
  12. package/output/OpenApiOperation-DgrqzeiS.js.map +1 -0
  13. package/output/{PageActions-GS_cxeJN.cjs → PageActions-BjB6PYmL.cjs} +73 -734
  14. package/output/PageActions-BjB6PYmL.cjs.map +1 -0
  15. package/output/{PageActions-Dn8IGWoL.js → PageActions-D7K9LDGf.js} +67 -680
  16. package/output/PageActions-D7K9LDGf.js.map +1 -0
  17. package/output/SearchDialog-CIPvXMT3.cjs +414 -0
  18. package/output/SearchDialog-CIPvXMT3.cjs.map +1 -0
  19. package/output/SearchDialog-CxYLjRi5.js +411 -0
  20. package/output/SearchDialog-CxYLjRi5.js.map +1 -0
  21. package/output/app/AppShell.d.ts +2 -2
  22. package/output/app/SectionHashSync.d.ts +6 -0
  23. package/output/client.cjs +3 -3
  24. package/output/client.js +3 -3
  25. package/output/components/HighlightedCode.d.ts +7 -0
  26. package/output/components/MermaidViewer.d.ts +7 -0
  27. package/output/context.d.ts +1 -1
  28. package/output/core/context.d.ts +3 -4
  29. package/output/core/i18n.d.ts +1 -1
  30. package/output/core/index.d.ts +1 -1
  31. package/output/core/types.d.ts +36 -19
  32. package/output/i18n-DnqZHFT7.js +247 -0
  33. package/output/i18n-DnqZHFT7.js.map +1 -0
  34. package/output/i18n-b4iTLeia.cjs +294 -0
  35. package/output/i18n-b4iTLeia.cjs.map +1 -0
  36. package/output/index.cjs +91 -94
  37. package/output/index.cjs.map +1 -1
  38. package/output/index.d.ts +7 -7
  39. package/output/index.js +83 -87
  40. package/output/index.js.map +1 -1
  41. package/output/markdown.cjs +2 -1
  42. package/output/markdown.d.ts +1 -1
  43. package/output/markdown.js +2 -2
  44. package/output/mdx/remark.d.ts +1 -0
  45. package/output/openapi/components/EndpointSections.d.ts +3 -1
  46. package/output/openapi/components/ExamplePanels.d.ts +5 -2
  47. package/output/openapi/components/OpenApiOperation.d.ts +3 -1
  48. package/output/openapi/components/OpenApiOperation.state.d.ts +3 -3
  49. package/output/openapi/components/SchemaProperties.d.ts +1 -0
  50. package/output/openapi/components/helpers.d.ts +2 -2
  51. package/output/openapi/entry.d.ts +0 -1
  52. package/output/openapi/lib/helpers.d.ts +5 -3
  53. package/output/openapi/lib/request-code.d.ts +2 -1
  54. package/output/openapi/lib/spec-path.d.ts +6 -1
  55. package/output/openapi/lib/utils.d.ts +10 -4
  56. package/output/preview.cjs +7 -5
  57. package/output/preview.cjs.map +1 -1
  58. package/output/preview.js +5 -3
  59. package/output/preview.js.map +1 -1
  60. package/output/{remark-Dd2WU50s.js → remark-C9iRQM0R.js} +4 -3
  61. package/output/remark-C9iRQM0R.js.map +1 -0
  62. package/output/{remark-zSQT0MBv.cjs → remark-DTLbG8PK.cjs} +9 -2
  63. package/output/remark-DTLbG8PK.cjs.map +1 -0
  64. package/output/{render-CV0a-qtD.js → render-DKj24Jqw.js} +15 -8
  65. package/output/render-DKj24Jqw.js.map +1 -0
  66. package/output/{render-CCCoUWDP.cjs → render-Di5B6Zc0.cjs} +15 -8
  67. package/output/render-Di5B6Zc0.cjs.map +1 -0
  68. package/output/renderer.css +234 -20
  69. package/output/runtime/ClarifyShell.d.ts +5 -6
  70. package/output/server.cjs +4 -4
  71. package/output/server.cjs.map +1 -1
  72. package/output/server.js +4 -4
  73. package/output/server.js.map +1 -1
  74. package/output/shell/Navigation.d.ts +1 -0
  75. package/output/shell/search/SearchDialog.d.ts +1 -1
  76. package/output/slots/RuntimeSlot.d.ts +7 -7
  77. package/output/slots/context.d.ts +5 -5
  78. package/output/slots/index.d.ts +2 -2
  79. package/output/slots/types.d.ts +1 -1
  80. package/output/utils/path.d.ts +1 -1
  81. package/package.json +3 -1
  82. package/output/ClarifyShell-CxhXBtsR.js.map +0 -1
  83. package/output/ClarifyShell-DjLRRW8T.cjs.map +0 -1
  84. package/output/OpenApiOperation-CyBkzvob.js.map +0 -1
  85. package/output/OpenApiOperation-qp5tFaWP.cjs.map +0 -1
  86. package/output/PageActions-Dn8IGWoL.js.map +0 -1
  87. package/output/PageActions-GS_cxeJN.cjs.map +0 -1
  88. package/output/remark-Dd2WU50s.js.map +0 -1
  89. package/output/remark-zSQT0MBv.cjs.map +0 -1
  90. package/output/render-CCCoUWDP.cjs.map +0 -1
  91. package/output/render-CV0a-qtD.js.map +0 -1
@@ -1,249 +1,13 @@
1
+ import { t as useBuiltInText } from "./i18n-DnqZHFT7.js";
1
2
  import clsx from "clsx";
2
- import { Fragment, Suspense, createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
3
- import { Link, useLocation, useNavigate } from "react-router-dom";
3
+ import { Suspense, createContext, forwardRef, lazy, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { Link, useLocation } from "react-router-dom";
4
5
  import { CloseButton, Dialog, DialogBackdrop, DialogPanel, Menu, MenuButton, MenuItem, MenuItems, TransitionChild } from "@headlessui/react";
5
6
  import * as LucideIcons from "lucide-react";
6
- import { Check, ChevronDown, Copy, ExternalLink, FileText, Globe2, Link2, LoaderCircle, Menu as Menu$1, Monitor, Moon, MoreHorizontal, PencilLine, Search, SearchX, Sun, X } from "lucide-react";
7
+ import { Check, ChevronDown, Copy, ExternalLink, FileText, Globe2, Link2, Menu as Menu$1, Monitor, Moon, MoreHorizontal, PencilLine, Search, Sun, X } from "lucide-react";
7
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
9
  import { AnimatePresence, motion, useIsPresent, useScroll, useTransform } from "framer-motion";
9
10
  import { create, createStore, useStore } from "zustand";
10
- //#region source/core/context.tsx
11
- var ConfigContext = createContext(null);
12
- var LocaleContext = createContext(void 0);
13
- var OpenApisContext = createContext({});
14
- function useConfig() {
15
- const config = useContext(ConfigContext);
16
- if (!config) throw new Error("[clarify] useConfig must be used within a ConfigContext.Provider");
17
- return config;
18
- }
19
- function useConfigOptional() {
20
- return useContext(ConfigContext);
21
- }
22
- function useLocale() {
23
- return useContext(LocaleContext);
24
- }
25
- function useOpenApis() {
26
- return useContext(OpenApisContext);
27
- }
28
- //#endregion
29
- //#region source/core/i18n.ts
30
- var builtInText = {
31
- en: {
32
- "actions.code": "Code",
33
- "actions.copy": "Copy",
34
- "actions.copied": "Copied!",
35
- "builtWith.label": "Built with Clarify",
36
- "builtWith.prefix": "Built with",
37
- "callout.danger": "Danger",
38
- "callout.info": "Info",
39
- "callout.note": "Note",
40
- "callout.success": "Success",
41
- "callout.tip": "Tip",
42
- "callout.warning": "Warning",
43
- "contentActions.copyContent": "Copy page",
44
- "contentActions.copyContentDescription": "Copy this page as {contentType} for LLMs",
45
- "contentActions.copyLink": "Copy {contentType} link",
46
- "contentActions.copyLinkDescription": "Copy the raw {contentType} content link for this page",
47
- "contentActions.copyLlms": "Copy llms.txt",
48
- "contentActions.copyLlmsDescription": "Copy the llms.txt link for this site",
49
- "contentActions.copiedLlms": "Copied llms.txt",
50
- "contentActions.editPage": "Edit this page",
51
- "contentActions.editPageDescription": "Open the source file for this page",
52
- "contentActions.copyOptions": "Choose copy option",
53
- "contentActions.copiedContent": "Copied page",
54
- "contentActions.copiedLink": "Copied link",
55
- "contentActions.viewMarkdown": "View as Markdown",
56
- "contentActions.viewMarkdownDescription": "View this page as plain text",
57
- "contentActions.viewOpenApi": "View raw OpenAPI",
58
- "contentActions.viewOpenApiDescription": "Open the API description file in a new tab",
59
- "feedback.no": "No",
60
- "feedback.prompt": "Was this page helpful?",
61
- "feedback.thanks": "Thanks for your feedback!",
62
- "feedback.yes": "Yes",
63
- "navigation.documentation": "Documentation",
64
- "navigation.next": "Next",
65
- "navigation.previous": "Previous",
66
- "navigation.previousNext": "Previous and next pages",
67
- "navigation.toggle": "Toggle navigation",
68
- "navbar.home": "Home",
69
- "navbar.openLinks": "Open navigation links",
70
- "navbar.sections": "Documentation sections",
71
- "notFound.description": "The page may have moved, been renamed, or never existed. Check the address or return to the homepage.",
72
- "notFound.home": "Back to homepage",
73
- "notFound.label": "404",
74
- "notFound.title": "Page not found",
75
- "openapi.apiDocumentation": "API Documentation",
76
- "openapi.bodyProperties": "Body properties",
77
- "openapi.collapse": "Collapse",
78
- "openapi.endpointNotFound": "Endpoint not found: {endpoint}",
79
- "openapi.example": "Example",
80
- "openapi.expand": "Expand",
81
- "openapi.headers": "Headers",
82
- "openapi.language": "Language",
83
- "openapi.client": "Client",
84
- "openapi.mediaType": "Media type",
85
- "openapi.none": "None",
86
- "openapi.openApiReference": "OpenAPI Reference",
87
- "openapi.operationParameter": "Operation parameter.",
88
- "openapi.optional": "Optional.",
89
- "openapi.parameter": "parameter",
90
- "openapi.pathParameters": "Path parameters",
91
- "openapi.queryParameters": "Query parameters",
92
- "openapi.request": "Request",
93
- "openapi.requestBody": "Request body",
94
- "openapi.requestBodyEmpty": "No request body",
95
- "openapi.responseBodyProperties": "Response body properties",
96
- "openapi.required": "Required.",
97
- "openapi.requiredBadge": "required",
98
- "openapi.response": "Response",
99
- "openapi.responses": "Responses",
100
- "openapi.schemaExample": "Schema example",
101
- "openapi.scrollExamplesLeft": "Scroll examples left",
102
- "openapi.scrollExamplesRight": "Scroll examples right",
103
- "openapi.specNotFound": "OpenAPI spec not found: {specPath}",
104
- "openapi.specPathMissing": "spec or specPath was not provided",
105
- "openapi.status": "Status",
106
- "openapi.version": "Version {version}",
107
- "search.button": "Search...",
108
- "search.noResults": "Nothing found for {query}.",
109
- "search.placeholder": "Find something...",
110
- "search.shortcutCtrl": "Ctrl ",
111
- "renderError.componentStack": "React component stack",
112
- "renderError.description": "Clarify stopped rendering this route to keep the rest of the shell responsive. Review the diagnostics below, fix the page source, then reload the route.",
113
- "renderError.details": "Runtime diagnostics",
114
- "renderError.message": "Message",
115
- "renderError.path": "Route",
116
- "renderError.reload": "Reload route",
117
- "renderError.stack": "JavaScript stack trace",
118
- "renderError.title": "Route render failed",
119
- "renderError.type": "Error type",
120
- "renderError.version": "Clarify version",
121
- "theme.switchToDark": "Switch to dark theme",
122
- "theme.switchToLight": "Switch to light theme",
123
- "theme.switchToSystem": "Follow system theme",
124
- "language.switch": "Switch language",
125
- "mermaid.zoomIn": "Zoom in",
126
- "mermaid.zoomOut": "Zoom out",
127
- "mermaid.resetZoom": "Reset zoom",
128
- "mermaid.renderError": "Mermaid render error",
129
- "mermaid.scrollHint": "Click the diagram to enable scroll-to-zoom"
130
- },
131
- "zh-CN": {
132
- "actions.code": "代码",
133
- "actions.copy": "复制",
134
- "actions.copied": "已复制!",
135
- "builtWith.label": "由 Clarify 构建",
136
- "builtWith.prefix": "构建来自",
137
- "callout.danger": "危险",
138
- "callout.info": "信息",
139
- "callout.note": "注意",
140
- "callout.success": "成功",
141
- "callout.tip": "提示",
142
- "callout.warning": "警告",
143
- "contentActions.copyContent": "复制页面",
144
- "contentActions.copyContentDescription": "将页面以 {contentType} 格式复制给 LLMs",
145
- "contentActions.copyLink": "复制 {contentType} 链接",
146
- "contentActions.copyLinkDescription": "复制当前页面的 {contentType} 原始内容链接",
147
- "contentActions.copyLlms": "复制 llms.txt",
148
- "contentActions.copyLlmsDescription": "复制此站点的 llms.txt 链接",
149
- "contentActions.copiedLlms": "已复制 llms.txt",
150
- "contentActions.editPage": "编辑此页面",
151
- "contentActions.editPageDescription": "打开当前页面的源文件",
152
- "contentActions.copyOptions": "选择复制选项",
153
- "contentActions.copiedContent": "已复制页面",
154
- "contentActions.copiedLink": "已复制链接",
155
- "contentActions.viewMarkdown": "以 Markdown 格式查看",
156
- "contentActions.viewMarkdownDescription": "以纯文本查看此页面",
157
- "contentActions.viewOpenApi": "查看 OpenAPI 原始内容",
158
- "contentActions.viewOpenApiDescription": "在新标签页打开 API 描述文件",
159
- "feedback.no": "否",
160
- "feedback.prompt": "这个页面有帮助吗?",
161
- "feedback.thanks": "感谢你的反馈!",
162
- "feedback.yes": "是",
163
- "navigation.documentation": "文档",
164
- "navigation.next": "下一页",
165
- "navigation.previous": "上一页",
166
- "navigation.previousNext": "上一页和下一页",
167
- "navigation.toggle": "切换导航",
168
- "navbar.home": "首页",
169
- "navbar.openLinks": "打开导航链接",
170
- "navbar.sections": "文档栏目",
171
- "notFound.description": "页面可能已移动、重命名或不存在。请检查地址,或返回首页继续浏览。",
172
- "notFound.home": "返回首页",
173
- "notFound.label": "404",
174
- "notFound.title": "页面未找到",
175
- "openapi.apiDocumentation": "API 文档",
176
- "openapi.bodyProperties": "请求体属性",
177
- "openapi.collapse": "收起",
178
- "openapi.endpointNotFound": "未找到端点:{endpoint}",
179
- "openapi.example": "示例",
180
- "openapi.expand": "展开",
181
- "openapi.headers": "请求头",
182
- "openapi.language": "语言",
183
- "openapi.client": "客户端",
184
- "openapi.mediaType": "媒体类型",
185
- "openapi.none": "无",
186
- "openapi.openApiReference": "OpenAPI 参考",
187
- "openapi.operationParameter": "操作参数。",
188
- "openapi.optional": "可选。",
189
- "openapi.parameter": "参数",
190
- "openapi.pathParameters": "路径参数",
191
- "openapi.queryParameters": "查询参数",
192
- "openapi.request": "请求",
193
- "openapi.requestBody": "请求体",
194
- "openapi.requestBodyEmpty": "暂无请求体",
195
- "openapi.responseBodyProperties": "响应体属性",
196
- "openapi.required": "必填。",
197
- "openapi.requiredBadge": "必填",
198
- "openapi.response": "响应",
199
- "openapi.responses": "响应",
200
- "openapi.schemaExample": "Schema 示例",
201
- "openapi.scrollExamplesLeft": "向左滚动示例",
202
- "openapi.scrollExamplesRight": "向右滚动示例",
203
- "openapi.specNotFound": "未找到 OpenAPI 描述文件:{specPath}",
204
- "openapi.specPathMissing": "未提供 spec 或 specPath",
205
- "openapi.status": "状态",
206
- "openapi.version": "版本 {version}",
207
- "search.button": "搜索...",
208
- "search.noResults": "没有找到与 {query} 相关的结果。",
209
- "search.placeholder": "搜索内容...",
210
- "search.shortcutCtrl": "Ctrl ",
211
- "renderError.componentStack": "React 组件栈",
212
- "renderError.description": "Clarify 已停止渲染此路由,以保证文档 Shell 仍可响应。请查看下方诊断信息,修复页面源码后重新加载路由。",
213
- "renderError.details": "运行时诊断",
214
- "renderError.message": "错误消息",
215
- "renderError.path": "路由",
216
- "renderError.reload": "重新加载路由",
217
- "renderError.stack": "JavaScript 堆栈",
218
- "renderError.title": "路由渲染失败",
219
- "renderError.type": "错误类型",
220
- "renderError.version": "Clarify 版本",
221
- "theme.switchToDark": "切换到深色主题",
222
- "theme.switchToLight": "切换到浅色主题",
223
- "theme.switchToSystem": "跟随系统主题",
224
- "language.switch": "切换语言",
225
- "mermaid.zoomIn": "放大",
226
- "mermaid.zoomOut": "缩小",
227
- "mermaid.resetZoom": "重置缩放",
228
- "mermaid.renderError": "Mermaid 渲染错误",
229
- "mermaid.scrollHint": "点击图表后即可滚轮缩放"
230
- }
231
- };
232
- function resolveBuiltInLocale(locale) {
233
- return locale === "zh-CN" || locale?.toLowerCase().startsWith("zh") ? "zh-CN" : "en";
234
- }
235
- function translateBuiltInText(locale, key, replacements = {}) {
236
- let value = builtInText[resolveBuiltInLocale(locale)]?.[key] ?? builtInText.en[key];
237
- for (const [name, replacement] of Object.entries(replacements)) value = value.replaceAll(`{${name}}`, replacement);
238
- return value;
239
- }
240
- function useBuiltInText(locale) {
241
- const config = useContext(ConfigContext);
242
- const currentLocale = useContext(LocaleContext);
243
- const resolvedLocale = locale ?? currentLocale ?? config?.i18n?.defaultLocale;
244
- return (key, replacements) => translateBuiltInText(resolvedLocale, key, replacements);
245
- }
246
- //#endregion
247
11
  //#region source/utils/clipboard.ts
248
12
  async function copyTextToClipboard(text) {
249
13
  if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) try {
@@ -305,7 +69,7 @@ function ContentActions(arg0) {
305
69
  const { route, routePrefix } = arg0;
306
70
  const t = useBuiltInText();
307
71
  const [copied, setCopied] = useState("idle");
308
- if (!route?.contentArtifactUrl && !route?.sourceUrl) return null;
72
+ if (!route?.contentArtifactUrl && !route?.sourceEditUrl) return null;
309
73
  const contentArtifactUrl = route.contentArtifactUrl ? resolveContentArtifactUrl(route.contentArtifactUrl, routePrefix) : void 0;
310
74
  const isOpenApi = route.kind === "openapi";
311
75
  const replacements = { contentType: isOpenApi ? "OpenAPI" : "Markdown" };
@@ -313,7 +77,7 @@ function ContentActions(arg0) {
313
77
  const viewDescription = isOpenApi ? t("contentActions.viewOpenApiDescription") : t("contentActions.viewMarkdownDescription");
314
78
  function markCopied(state) {
315
79
  setCopied(state);
316
- window.setTimeout(() => setCopied("idle"), 1600);
80
+ setTimeout(() => setCopied("idle"), 1600);
317
81
  }
318
82
  async function handleCopyContent() {
319
83
  if (!contentArtifactUrl) return;
@@ -368,7 +132,7 @@ function ContentActions(arg0) {
368
132
  children: copied === primaryAction.key ? t("actions.copied") : primaryAction.label
369
133
  })]
370
134
  }) : /* @__PURE__ */ jsxs("a", {
371
- href: route.sourceUrl,
135
+ href: route.sourceEditUrl,
372
136
  target: "_blank",
373
137
  rel: "noreferrer",
374
138
  className: "clarify-content-actions-primary clarify-ui-control inline-flex h-8 min-w-0 items-center gap-1.5 px-2.5 no-underline transition sm:px-3",
@@ -386,8 +150,8 @@ function ContentActions(arg0) {
386
150
  anchor: "bottom end",
387
151
  className: "clarify-content-actions-list clarify-ui-menu z-30 mt-2 w-(--clarify-ui-action-menu-width) origin-top-right rounded-(--clarify-theme-tokens-radius-xl) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1.5 shadow-xl shadow-zinc-900/5 transition [--anchor-gap:--spacing(2)] focus:outline-none data-closed:scale-95 data-closed:opacity-0",
388
152
  children: [
389
- route.sourceUrl ? /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsxs("a", {
390
- href: route.sourceUrl,
153
+ route.sourceEditUrl ? /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsxs("a", {
154
+ href: route.sourceEditUrl,
391
155
  target: "_blank",
392
156
  rel: "noreferrer",
393
157
  className: "clarify-content-actions-item clarify-ui-menu-item group flex w-full items-center gap-2 rounded-(--clarify-theme-tokens-radius-lg) px-1.5 py-1.5 text-left no-underline transition",
@@ -712,9 +476,19 @@ function normalizeRoutePath(path) {
712
476
  const [pathname, suffix = ""] = path.split(/([?#].*)/, 2);
713
477
  return `${pathname.replace(/^\/+/, "/").replace(/\/+$/, "") || "/"}${suffix}`;
714
478
  }
715
- function isSameRoutePath(a, b) {
479
+ function stripLocalePathPrefix(path, locale) {
480
+ if (!locale) return normalizeRoutePath(path);
481
+ const [pathname, suffix = ""] = normalizeRoutePath(path).split(/([?#].*)/, 2);
482
+ const localePrefix = `/${locale}`;
483
+ if (pathname === localePrefix) return `/${suffix}`.replace(/^\/$/, "/");
484
+ if (!pathname.startsWith(`${localePrefix}/`)) return `${pathname}${suffix}`;
485
+ return `${pathname.slice(localePrefix.length) || "/"}${suffix}`;
486
+ }
487
+ function isSameRoutePath(a, b, locale) {
716
488
  if (!a || !b) return false;
717
- return normalizeRoutePath(a) === normalizeRoutePath(b);
489
+ const normalizedA = normalizeRoutePath(a);
490
+ const normalizedB = normalizeRoutePath(b);
491
+ return normalizedA === normalizedB || stripLocalePathPrefix(normalizedA, locale) === normalizedB || normalizedA === stripLocalePathPrefix(normalizedB, locale);
718
492
  }
719
493
  //#endregion
720
494
  //#region source/utils/lucide.ts
@@ -799,7 +573,7 @@ function computeVisibleSections(sections, scrollY, viewportTop, viewportBottom)
799
573
  }
800
574
  return visibleSections;
801
575
  }
802
- function useSectionVisibilityDebug(headerTopAreaRef) {
576
+ function useSectionVisibilityDebug(_headerTopAreaRef) {
803
577
  const lastDebugSignatureRef = useRef("");
804
578
  return (snapshot) => {
805
579
  const { scrollY, innerHeight, blockedTop, visibleSections } = snapshot;
@@ -811,14 +585,11 @@ function useSectionVisibilityDebug(headerTopAreaRef) {
811
585
  ].join("|");
812
586
  if (lastDebugSignatureRef.current === debugSignature) return;
813
587
  lastDebugSignatureRef.current = debugSignature;
814
- console.info("[clarify][section-visibility]", {
815
- ...snapshot,
816
- topAreaHeight: headerTopAreaRef?.current?.offsetHeight ?? 0
817
- });
818
588
  };
819
589
  }
820
590
  function useSectionVisibilityObserver(checkVisibleSections, headerTopAreaRef) {
821
591
  useEffect(() => {
592
+ if (typeof window === "undefined") return void 0;
822
593
  const raf = window.requestAnimationFrame(() => checkVisibleSections());
823
594
  window.addEventListener("scroll", checkVisibleSections, { passive: true });
824
595
  window.addEventListener("resize", checkVisibleSections);
@@ -839,6 +610,7 @@ function useVisibleSections(sectionStore, headerTopAreaRef) {
839
610
  const sections = useStore(sectionStore, (state) => state.sections);
840
611
  const emitVisibilityDebug = useSectionVisibilityDebug(headerTopAreaRef);
841
612
  useSectionVisibilityObserver(useCallback(() => {
613
+ if (typeof window === "undefined") return;
842
614
  const { innerHeight, scrollY } = window;
843
615
  const viewportTop = getVisibleViewportTop(scrollY, innerHeight, headerTopAreaRef);
844
616
  const viewportBottom = getVisibleViewportBottom(scrollY, innerHeight, headerTopAreaRef);
@@ -923,7 +695,8 @@ var sectionBadgeColorStyles = {
923
695
  DELETE: "text-red-500 dark:text-rose-500",
924
696
  OPTIONS: "text-violet-500 dark:text-violet-400",
925
697
  HEAD: "text-zinc-500 dark:text-zinc-400",
926
- TRACE: "text-fuchsia-500 dark:text-fuchsia-400"
698
+ TRACE: "text-fuchsia-500 dark:text-fuchsia-400",
699
+ WEBHOOK: "text-violet-500 dark:text-violet-400"
927
700
  };
928
701
  function SectionBadge(arg0) {
929
702
  const { children } = arg0;
@@ -957,13 +730,13 @@ function NavLink(arg0) {
957
730
  });
958
731
  }
959
732
  function VisibleSectionHighlight(arg0) {
960
- const { group, pathname } = arg0;
733
+ const { group, pathname, currentLocale } = arg0;
961
734
  const [sections, visibleSections] = useInitialValue([useSectionStore((s) => s.sections), useSectionStore((s) => s.visibleSections)], useIsInsideMobileNavigation());
962
735
  const isPresent = useIsPresent();
963
736
  const firstVisibleSectionIndex = Math.max(0, [{ id: "_top" }, ...sections].findIndex((section) => section.id === visibleSections[0]));
964
737
  const itemHeight = remToPx(2);
965
738
  const height = isPresent ? Math.max(1, visibleSections.length) * itemHeight : itemHeight;
966
- const top = group.links.findIndex((link) => isSameRoutePath(link.href, pathname)) * itemHeight + firstVisibleSectionIndex * itemHeight;
739
+ const top = group.links.findIndex((link) => isSameRoutePath(link.href, pathname, currentLocale)) * itemHeight + firstVisibleSectionIndex * itemHeight;
967
740
  return /* @__PURE__ */ jsx(motion.div, {
968
741
  initial: {
969
742
  opacity: 0,
@@ -995,9 +768,9 @@ function VisibleSectionHighlight(arg0) {
995
768
  });
996
769
  }
997
770
  function ActivePageMarker(arg0) {
998
- const { group, pathname } = arg0;
771
+ const { group, pathname, currentLocale } = arg0;
999
772
  const itemHeight = remToPx(2);
1000
- const top = remToPx(.25) + group.links.findIndex((link) => isSameRoutePath(link.href, pathname)) * itemHeight;
773
+ const top = remToPx(.25) + group.links.findIndex((link) => isSameRoutePath(link.href, pathname, currentLocale)) * itemHeight;
1001
774
  return /* @__PURE__ */ jsx(motion.div, {
1002
775
  className: "absolute left-2 h-6 w-px bg-(--clarify-theme-tokens-colors-primary)",
1003
776
  initial: {
@@ -1023,10 +796,10 @@ function ActivePageMarker(arg0) {
1023
796
  });
1024
797
  }
1025
798
  function NavigationGroup(arg0) {
1026
- const { group, className } = arg0;
799
+ const { group, className, currentLocale } = arg0;
1027
800
  const isInsideMobileNavigation = useIsInsideMobileNavigation();
1028
801
  const [pathname, sections] = useInitialValue([normalizeRoutePath(useLocation().pathname), useSectionStore((s) => s.sections)], isInsideMobileNavigation);
1029
- const isActiveGroup = group.links.findIndex((link) => isSameRoutePath(link.href, pathname)) !== -1;
802
+ const isActiveGroup = group.links.findIndex((link) => isSameRoutePath(link.href, pathname, currentLocale)) !== -1;
1030
803
  return /* @__PURE__ */ jsxs("li", {
1031
804
  className: clsx("clarify-navigation-group relative mb-6", className),
1032
805
  children: [/* @__PURE__ */ jsxs("h2", {
@@ -1042,7 +815,8 @@ function NavigationGroup(arg0) {
1042
815
  initial: !isInsideMobileNavigation,
1043
816
  children: isActiveGroup ? /* @__PURE__ */ jsx(VisibleSectionHighlight, {
1044
817
  group,
1045
- pathname
818
+ pathname,
819
+ currentLocale
1046
820
  }) : null
1047
821
  }),
1048
822
  /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-2 w-px bg-(--clarify-theme-tokens-colors-border) dark:bg-white/5" }),
@@ -1050,14 +824,15 @@ function NavigationGroup(arg0) {
1050
824
  initial: false,
1051
825
  children: isActiveGroup ? /* @__PURE__ */ jsx(ActivePageMarker, {
1052
826
  group,
1053
- pathname
827
+ pathname,
828
+ currentLocale
1054
829
  }) : null
1055
830
  }),
1056
831
  /* @__PURE__ */ jsx("ul", {
1057
832
  role: "list",
1058
833
  className: "border-l border-transparent",
1059
834
  children: group.links.map((link) => {
1060
- const active = isSameRoutePath(link.href, pathname);
835
+ const active = isSameRoutePath(link.href, pathname, currentLocale);
1061
836
  return /* @__PURE__ */ jsxs("li", {
1062
837
  className: "relative",
1063
838
  children: [/* @__PURE__ */ jsx(NavLink, {
@@ -1096,7 +871,7 @@ function NavigationGroup(arg0) {
1096
871
  });
1097
872
  }
1098
873
  function Navigation(arg0) {
1099
- const { navigation, className } = arg0;
874
+ const { navigation, className, currentLocale } = arg0;
1100
875
  const groups = navigationToGroups(navigation, useBuiltInText()("navigation.documentation"));
1101
876
  return /* @__PURE__ */ jsx("nav", {
1102
877
  className: clsx("clarify-navigation", className),
@@ -1105,7 +880,8 @@ function Navigation(arg0) {
1105
880
  className: "clarify-navigation-list",
1106
881
  children: groups.map((group, groupIndex) => /* @__PURE__ */ jsx(NavigationGroup, {
1107
882
  group,
1108
- className: groupIndex === 0 ? "mt-0" : ""
883
+ className: groupIndex === 0 ? "mt-0" : "",
884
+ currentLocale
1109
885
  }, group.title))
1110
886
  })
1111
887
  });
@@ -1113,17 +889,17 @@ function Navigation(arg0) {
1113
889
  //#endregion
1114
890
  //#region source/shell/mobile.tsx
1115
891
  var IsInsideMobileNavigationContext = createContext(false);
1116
- function hasPath$1(nodes, pathname) {
1117
- return nodes.some((node) => isSameRoutePath(node.path, pathname) || hasPath$1(node.children ?? [], pathname));
892
+ function hasPath$1(nodes, pathname, currentLocale) {
893
+ return nodes.some((node) => isSameRoutePath(node.path, pathname, currentLocale) || hasPath$1(node.children ?? [], pathname, currentLocale));
1118
894
  }
1119
- function isActiveTab$1(tab, pathname) {
1120
- return isSameRoutePath(tab.path, pathname) || hasPath$1(tab.children, pathname);
895
+ function isActiveTab$1(tab, pathname, currentLocale) {
896
+ return isSameRoutePath(tab.path, pathname, currentLocale) || hasPath$1(tab.children, pathname, currentLocale);
1121
897
  }
1122
898
  function MobileTabsSelect(arg0) {
1123
- const { tabs } = arg0;
899
+ const { tabs, currentLocale } = arg0;
1124
900
  const pathname = normalizeRoutePath(useLocation().pathname);
1125
901
  if (!tabs?.length) return null;
1126
- const activeTab = tabs.find((tab) => isActiveTab$1(tab, pathname)) ?? tabs[0];
902
+ const activeTab = tabs.find((tab) => isActiveTab$1(tab, pathname, currentLocale)) ?? tabs[0];
1127
903
  return /* @__PURE__ */ jsxs(Menu, {
1128
904
  as: "div",
1129
905
  className: "clarify-mobile-tabs-select mb-6",
@@ -1142,7 +918,7 @@ function MobileTabsSelect(arg0) {
1142
918
  }), /* @__PURE__ */ jsx(MenuItems, {
1143
919
  className: "clarify-mobile-tabs-select-list clarify-ui-menu mt-2 flex flex-col gap-1 rounded-(--clarify-theme-tokens-radius-xl) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 shadow-lg shadow-zinc-900/5 focus:outline-none dark:border-white/10 dark:bg-zinc-900 dark:shadow-none",
1144
920
  children: tabs.map((tab) => {
1145
- const active = isActiveTab$1(tab, pathname);
921
+ const active = isActiveTab$1(tab, pathname, currentLocale);
1146
922
  return /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsxs(Link, {
1147
923
  to: tab.path,
1148
924
  className: clsx("clarify-mobile-tabs-select-item clarify-ui-menu-item flex items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-lg) px-3 py-2.5 no-underline transition", active && "clarify-ui-menu-item-active"),
@@ -1183,7 +959,13 @@ function MobileNavigationDialog(arg0) {
1183
959
  }) }), /* @__PURE__ */ jsx(TransitionChild, { children: /* @__PURE__ */ jsxs(motion.div, {
1184
960
  layoutScroll: true,
1185
961
  className: "clarify-mobile-navigation-panel fixed top-14 bottom-0 left-0 w-full max-w-sm overflow-y-auto bg-(--clarify-theme-tokens-colors-background) px-4 pt-6 pb-4 shadow-lg ring-1 shadow-zinc-900/10 ring-(--clarify-theme-tokens-colors-border) duration-500 ease-in-out data-closed:-translate-x-full sm:px-6 sm:pb-10 dark:bg-zinc-950 dark:ring-zinc-800",
1186
- children: [/* @__PURE__ */ jsx(MobileTabsSelect, { tabs }), /* @__PURE__ */ jsx(Navigation, { navigation })]
962
+ children: [/* @__PURE__ */ jsx(MobileTabsSelect, {
963
+ tabs,
964
+ currentLocale
965
+ }), /* @__PURE__ */ jsx(Navigation, {
966
+ navigation,
967
+ currentLocale
968
+ })]
1187
969
  }) })] })]
1188
970
  });
1189
971
  }
@@ -1226,405 +1008,6 @@ function MobileNavigation(arg0) {
1226
1008
  });
1227
1009
  }
1228
1010
  //#endregion
1229
- //#region source/shell/search/items.ts
1230
- function routeGroupTitles(navigation) {
1231
- const titles = /* @__PURE__ */ new Map();
1232
- for (const node of navigation) if (node.children?.length) for (const child of node.children) titles.set(child.path, node.title);
1233
- else titles.set(node.path, node.title);
1234
- return titles;
1235
- }
1236
- function buildSearchItems(routes, navigation) {
1237
- const groupTitles = routeGroupTitles(navigation);
1238
- return routes.flatMap((route) => {
1239
- if (route.isBareAlias) return [];
1240
- const groupTitle = groupTitles.get(route.path);
1241
- return [{
1242
- title: route.title,
1243
- pageTitle: route.title,
1244
- sectionTitle: groupTitle,
1245
- url: route.path,
1246
- keywords: [
1247
- groupTitle,
1248
- route.title,
1249
- route.path,
1250
- route.kind
1251
- ].filter(Boolean).join(" ").toLowerCase()
1252
- }, ...route.sections?.map((section) => ({
1253
- title: section.title,
1254
- pageTitle: route.title,
1255
- sectionTitle: groupTitle,
1256
- url: `${route.path}#${section.id}`,
1257
- keywords: [
1258
- groupTitle,
1259
- route.title,
1260
- section.title,
1261
- route.path,
1262
- section.id
1263
- ].filter(Boolean).join(" ").toLowerCase()
1264
- })) ?? []];
1265
- });
1266
- }
1267
- //#endregion
1268
- //#region source/shell/search/pagefind.ts
1269
- var pagefindPromises = /* @__PURE__ */ new Map();
1270
- function pagefindCacheKey(routePrefix, locale) {
1271
- return `${routePrefix || "/"}:${locale || "default"}`;
1272
- }
1273
- function loadPagefind(routePrefix, locale) {
1274
- if (typeof window === "undefined") return Promise.resolve(null);
1275
- const language = locale ?? document.documentElement.lang;
1276
- const cacheKey = pagefindCacheKey(routePrefix, language);
1277
- const cachedPagefind = pagefindPromises.get(cacheKey);
1278
- if (cachedPagefind) return cachedPagefind;
1279
- const pagefindPromise = import(
1280
- /* @vite-ignore */
1281
- prefixHref("/pagefind/pagefind.js", routePrefix)
1282
- ).then(async (module) => {
1283
- const previousLanguage = document.documentElement.lang;
1284
- if (language) document.documentElement.lang = language;
1285
- const pagefind = module.createInstance();
1286
- if (previousLanguage && previousLanguage !== language) document.documentElement.lang = previousLanguage;
1287
- await pagefind.init?.();
1288
- return pagefind;
1289
- }).catch((error) => {
1290
- pagefindPromises.delete(cacheKey);
1291
- console.warn("[clarify:search] Pagefind instance failed", {
1292
- cacheKey,
1293
- language,
1294
- error
1295
- });
1296
- return null;
1297
- });
1298
- pagefindPromises.set(cacheKey, pagefindPromise);
1299
- return pagefindPromise;
1300
- }
1301
- function normalizePagefindUrl(url, routePrefix) {
1302
- const parsedUrl = new URL(url, window.location.origin);
1303
- let pathname = parsedUrl.pathname;
1304
- const prefix = routePrefix && routePrefix !== "/" ? `/${routePrefix.replace(/^\/+|\/+$/g, "")}` : "";
1305
- if (prefix && (pathname === prefix || pathname.startsWith(`${prefix}/`))) pathname = pathname.slice(prefix.length) || "/";
1306
- return `${pathname}${parsedUrl.search}${parsedUrl.hash}`;
1307
- }
1308
- //#endregion
1309
- //#region source/shell/search/SearchInput.tsx
1310
- var SearchInput = forwardRef(function SearchInput(arg0, inputRef) {
1311
- const { query, setQuery, onClose, onSubmit, activeDescendantId, loading = false } = arg0;
1312
- const t = useBuiltInText();
1313
- return /* @__PURE__ */ jsxs("div", {
1314
- className: "clarify-search-input group relative flex h-12",
1315
- children: [/* @__PURE__ */ jsx(loading ? LoaderCircle : Search, {
1316
- "aria-hidden": "true",
1317
- className: clsx("pointer-events-none absolute top-0 left-3 h-full w-5 stroke-(--clarify-theme-tokens-colors-muted)", loading && "animate-spin")
1318
- }), /* @__PURE__ */ jsx("input", {
1319
- ref: inputRef,
1320
- "data-autofocus": true,
1321
- role: "combobox",
1322
- "aria-expanded": query !== "",
1323
- "aria-controls": "clarify-search-results",
1324
- "aria-activedescendant": activeDescendantId,
1325
- value: query,
1326
- onChange: (event) => setQuery(event.currentTarget.value),
1327
- onKeyDown: (event) => {
1328
- if (event.key === "Escape") if (query) setQuery("");
1329
- else onClose();
1330
- if (event.key === "Enter") {
1331
- event.preventDefault();
1332
- onSubmit();
1333
- }
1334
- },
1335
- placeholder: t("search.placeholder"),
1336
- className: "clarify-search-field flex-auto appearance-none bg-transparent pr-4 pl-10 outline-hidden focus:w-full focus:flex-none [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden"
1337
- })]
1338
- });
1339
- });
1340
- //#endregion
1341
- //#region source/shell/search/Highlight.tsx
1342
- function stripHtml(value) {
1343
- if (typeof document === "undefined") return value.replace(/<[^>]*>/g, "");
1344
- const template = document.createElement("template");
1345
- template.innerHTML = value;
1346
- return template.content.textContent ?? "";
1347
- }
1348
- function escapeRegExp(value) {
1349
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1350
- }
1351
- function HighlightQuery(arg0) {
1352
- const { text, query } = arg0;
1353
- if (!query) return text;
1354
- return /* @__PURE__ */ jsx(Fragment$1, { children: text.split(new RegExp(`(${escapeRegExp(query)})`, "ig")).map((part, index) => part.toLowerCase() === query.toLowerCase() ? /* @__PURE__ */ jsx("mark", {
1355
- className: "bg-transparent text-(--clarify-theme-tokens-colors-primary) underline",
1356
- children: part
1357
- }, index) : /* @__PURE__ */ jsx(Fragment, { children: part }, index)) });
1358
- }
1359
- function renderExcerptNode(node, key) {
1360
- if (node.nodeType === Node.TEXT_NODE) return node.textContent;
1361
- if (node.nodeType !== Node.ELEMENT_NODE) return null;
1362
- const element = node;
1363
- const children = Array.from(element.childNodes).map((child, index) => renderExcerptNode(child, `${key}-${index}`));
1364
- if (element.tagName.toLowerCase() === "mark") return /* @__PURE__ */ jsx("mark", {
1365
- className: "bg-transparent text-(--clarify-theme-tokens-colors-primary) underline",
1366
- children
1367
- }, key);
1368
- return /* @__PURE__ */ jsx(Fragment, { children }, key);
1369
- }
1370
- function HighlightExcerpt(arg0) {
1371
- const { excerpt, query } = arg0;
1372
- if (typeof document === "undefined" || !excerpt.includes("<mark")) return /* @__PURE__ */ jsx(HighlightQuery, {
1373
- text: stripHtml(excerpt),
1374
- query
1375
- });
1376
- const template = document.createElement("template");
1377
- template.innerHTML = excerpt;
1378
- return /* @__PURE__ */ jsx(Fragment$1, { children: Array.from(template.content.childNodes).map((node, index) => renderExcerptNode(node, String(index))) });
1379
- }
1380
- //#endregion
1381
- //#region source/shell/search/SearchResult.tsx
1382
- function SearchResult(arg0) {
1383
- const { result, query, active, onActive, onSelect } = arg0;
1384
- const id = useId();
1385
- const hierarchy = result.type === "quick" ? [result.sectionTitle, result.pageTitle].filter((value) => typeof value === "string") : [];
1386
- return /* @__PURE__ */ jsxs("li", {
1387
- id,
1388
- className: clsx("clarify-search-result group block cursor-pointer px-4 py-3", active && "clarify-search-result-active"),
1389
- "aria-selected": active,
1390
- onMouseEnter: onActive,
1391
- onMouseMove: onActive,
1392
- onMouseDown: (event) => {
1393
- event.preventDefault();
1394
- onSelect();
1395
- },
1396
- children: [
1397
- /* @__PURE__ */ jsx("div", {
1398
- className: "clarify-search-result-title",
1399
- children: /* @__PURE__ */ jsx(HighlightQuery, {
1400
- text: result.title,
1401
- query
1402
- })
1403
- }),
1404
- hierarchy.length > 0 ? /* @__PURE__ */ jsx("div", {
1405
- className: "clarify-search-result-hierarchy mt-1 truncate whitespace-nowrap",
1406
- children: hierarchy.map((item, itemIndex, items) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(HighlightQuery, {
1407
- text: item,
1408
- query
1409
- }), /* @__PURE__ */ jsx("span", {
1410
- className: itemIndex === items.length - 1 ? "sr-only" : "clarify-search-result-separator mx-2",
1411
- children: "/"
1412
- })] }, `${item}-${itemIndex}`))
1413
- }) : null,
1414
- result.type === "full-text" && result.excerpt ? /* @__PURE__ */ jsx("p", {
1415
- className: "clarify-search-result-excerpt mt-1 line-clamp-2 text-xs leading-5 text-(--clarify-theme-tokens-colors-muted)",
1416
- children: /* @__PURE__ */ jsx(HighlightExcerpt, {
1417
- excerpt: result.excerpt,
1418
- query
1419
- })
1420
- }) : null
1421
- ]
1422
- });
1423
- }
1424
- //#endregion
1425
- //#region source/shell/search/SearchDialog.tsx
1426
- function useSearchDialogLifecycle(arg0) {
1427
- const { open, setOpen } = arg0;
1428
- const location = useLocation();
1429
- useEffect(() => {
1430
- setOpen(false);
1431
- }, [
1432
- location.pathname,
1433
- location.search,
1434
- location.hash,
1435
- setOpen
1436
- ]);
1437
- useEffect(() => {
1438
- if (open) return void 0;
1439
- function onKeyDown(event) {
1440
- if (event.key === "k" && (event.metaKey || event.ctrlKey)) {
1441
- event.preventDefault();
1442
- setOpen(true);
1443
- }
1444
- }
1445
- window.addEventListener("keydown", onKeyDown);
1446
- return () => window.removeEventListener("keydown", onKeyDown);
1447
- }, [open, setOpen]);
1448
- }
1449
- function useSearchData(arg0) {
1450
- const { query, searchItems, routePrefix, currentLocale } = arg0;
1451
- const [fullTextState, setFullTextState] = useState(null);
1452
- const [pagefindState, setPagefindState] = useState(null);
1453
- const quickResults = useMemo(() => {
1454
- const normalizedQuery = query.trim().toLowerCase();
1455
- if (!normalizedQuery) return [];
1456
- return searchItems.filter((item) => item.keywords.includes(normalizedQuery)).slice(0, 8).map((item) => ({
1457
- ...item,
1458
- type: "quick"
1459
- }));
1460
- }, [query, searchItems]);
1461
- const pagefindKey = pagefindCacheKey(routePrefix, currentLocale);
1462
- const activePagefindState = pagefindState?.key === pagefindKey ? pagefindState : null;
1463
- const pagefind = activePagefindState?.pagefind ?? null;
1464
- const pagefindAvailable = activePagefindState?.available ?? null;
1465
- const trimmedQuery = query.trim();
1466
- const fullTextKey = `${pagefindKey}:${trimmedQuery}`;
1467
- const results = (fullTextState?.key === fullTextKey ? fullTextState.results : null) ?? quickResults;
1468
- const searchInputLoading = pagefindAvailable === null || Boolean(trimmedQuery && pagefind && fullTextState?.key !== fullTextKey);
1469
- const showNoResults = Boolean(query.trim()) && results.length === 0 && pagefindAvailable !== null;
1470
- useEffect(() => {
1471
- let cancelled = false;
1472
- loadPagefind(routePrefix, currentLocale).then((loadedPagefind) => {
1473
- if (cancelled) return;
1474
- setPagefindState({
1475
- key: pagefindKey,
1476
- pagefind: loadedPagefind,
1477
- available: Boolean(loadedPagefind)
1478
- });
1479
- });
1480
- return () => {
1481
- cancelled = true;
1482
- };
1483
- }, [
1484
- currentLocale,
1485
- pagefindKey,
1486
- routePrefix
1487
- ]);
1488
- useEffect(() => {
1489
- let cancelled = false;
1490
- if (!trimmedQuery || !pagefind) return void 0;
1491
- Promise.resolve().then(async () => {
1492
- if (cancelled) return;
1493
- try {
1494
- const search = await pagefind.search(trimmedQuery, { limit: 8 });
1495
- const data = await Promise.all(search.results.map(async (result) => ({
1496
- id: result.id,
1497
- data: await result.data()
1498
- })));
1499
- if (cancelled) return;
1500
- setFullTextState({
1501
- key: fullTextKey,
1502
- results: data.map(({ id, data }) => ({
1503
- type: "full-text",
1504
- id,
1505
- title: data.meta.title || data.url,
1506
- url: normalizePagefindUrl(data.url, routePrefix),
1507
- excerpt: data.excerpt
1508
- }))
1509
- });
1510
- } catch (error) {
1511
- console.warn("[clarify:search] Pagefind search failed", {
1512
- currentLocale,
1513
- query: trimmedQuery,
1514
- error
1515
- });
1516
- if (!cancelled) setFullTextState({
1517
- key: fullTextKey,
1518
- results: null
1519
- });
1520
- }
1521
- });
1522
- return () => {
1523
- cancelled = true;
1524
- };
1525
- }, [
1526
- currentLocale,
1527
- fullTextKey,
1528
- pagefind,
1529
- routePrefix,
1530
- trimmedQuery
1531
- ]);
1532
- return {
1533
- results,
1534
- searchInputLoading,
1535
- showNoResults
1536
- };
1537
- }
1538
- function SearchDialog(arg0) {
1539
- const { open, setOpen, routes, navigation, routePrefix = "/", currentLocale, className, onNavigate = () => {} } = arg0;
1540
- const t = useBuiltInText();
1541
- const navigate = useNavigate();
1542
- const inputRef = useRef(null);
1543
- const [query, setQuery] = useState("");
1544
- const [activeIndex, setActiveIndex] = useState(0);
1545
- const searchItems = useMemo(() => buildSearchItems(routes, navigation), [navigation, routes]);
1546
- useSearchDialogLifecycle({
1547
- open,
1548
- setOpen
1549
- });
1550
- const { results, searchInputLoading, showNoResults } = useSearchData({
1551
- query,
1552
- searchItems,
1553
- routePrefix,
1554
- currentLocale
1555
- });
1556
- const updateQuery = (value) => {
1557
- setQuery(value);
1558
- setActiveIndex(0);
1559
- };
1560
- function closeDialog() {
1561
- updateQuery("");
1562
- setOpen(false);
1563
- }
1564
- function selectResult(result = results[activeIndex]) {
1565
- if (!result) return;
1566
- navigate(result.url);
1567
- onNavigate();
1568
- closeDialog();
1569
- }
1570
- function renderResultsPanel() {
1571
- return /* @__PURE__ */ jsxs("div", {
1572
- className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) empty:hidden dark:border-zinc-100/5 dark:bg-white/2.5",
1573
- children: [showNoResults ? /* @__PURE__ */ jsxs("div", {
1574
- className: "p-6 text-center",
1575
- children: [/* @__PURE__ */ jsx(SearchX, { className: "mx-auto h-5 w-5 stroke-(--clarify-theme-tokens-colors-foreground) dark:stroke-zinc-600" }), /* @__PURE__ */ jsx("p", {
1576
- className: "mt-2 text-xs text-(--clarify-theme-tokens-colors-muted) dark:text-zinc-400",
1577
- children: t("search.noResults", { query })
1578
- })]
1579
- }) : null, results.length ? /* @__PURE__ */ jsx("ul", {
1580
- id: "clarify-search-results",
1581
- className: "clarify-search-results",
1582
- role: "listbox",
1583
- children: results.map((result, resultIndex) => /* @__PURE__ */ jsx(SearchResult, {
1584
- result,
1585
- query,
1586
- active: resultIndex === activeIndex,
1587
- onActive: () => setActiveIndex(resultIndex),
1588
- onSelect: () => selectResult(result)
1589
- }, result.type === "full-text" ? result.id : result.url))
1590
- }) : null]
1591
- });
1592
- }
1593
- return /* @__PURE__ */ jsxs(Dialog, {
1594
- open,
1595
- onClose: closeDialog,
1596
- className: clsx("clarify-search-dialog fixed inset-0 z-50", className),
1597
- children: [/* @__PURE__ */ jsx(DialogBackdrop, {
1598
- transition: true,
1599
- className: "clarify-search-backdrop clarify-ui-backdrop fixed inset-0 backdrop-blur-xs data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in"
1600
- }), /* @__PURE__ */ jsx("div", {
1601
- className: "fixed inset-0 overflow-y-auto px-4 py-4 sm:px-6 sm:py-20 md:py-32 lg:px-8 lg:py-(--clarify-search-dialog-padding-block-lg)",
1602
- children: /* @__PURE__ */ jsxs(DialogPanel, {
1603
- transition: true,
1604
- className: "clarify-search-panel mx-auto transform-gpu overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-theme-tokens-colors-surface) shadow-xl ring-1 ring-(--clarify-theme-tokens-colors-border) data-closed:scale-95 data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in sm:max-w-xl dark:bg-zinc-900 dark:ring-zinc-800",
1605
- onKeyDown: (event) => {
1606
- if (event.key === "ArrowDown") {
1607
- event.preventDefault();
1608
- setActiveIndex((index) => results.length ? (index + 1) % results.length : 0);
1609
- }
1610
- if (event.key === "ArrowUp") {
1611
- event.preventDefault();
1612
- setActiveIndex((index) => results.length ? (index - 1 + results.length) % results.length : 0);
1613
- }
1614
- },
1615
- children: [/* @__PURE__ */ jsx(SearchInput, {
1616
- ref: inputRef,
1617
- query,
1618
- setQuery: updateQuery,
1619
- onClose: closeDialog,
1620
- onSubmit: () => selectResult(),
1621
- loading: searchInputLoading
1622
- }), renderResultsPanel()]
1623
- })
1624
- })]
1625
- });
1626
- }
1627
- //#endregion
1628
1011
  //#region source/shell/search/useSearchProps.ts
1629
1012
  function useSearchProps() {
1630
1013
  const buttonRef = useRef(null);
@@ -1644,6 +1027,7 @@ function useSearchProps() {
1644
1027
  }
1645
1028
  //#endregion
1646
1029
  //#region source/shell/Search.tsx
1030
+ var SearchDialog = lazy(() => import("./SearchDialog-CxYLjRi5.js"));
1647
1031
  function getModifierKey() {
1648
1032
  if (typeof navigator === "undefined") return "Ctrl ";
1649
1033
  return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) ? "⌘" : "Ctrl ";
@@ -1850,14 +1234,14 @@ function MobileNavbarMenu(arg0) {
1850
1234
  })]
1851
1235
  });
1852
1236
  }
1853
- function hasPath(nodes, pathname) {
1854
- return nodes.some((node) => isSameRoutePath(node.path, pathname) || hasPath(node.children ?? [], pathname));
1237
+ function hasPath(nodes, pathname, currentLocale) {
1238
+ return nodes.some((node) => isSameRoutePath(node.path, pathname, currentLocale) || hasPath(node.children ?? [], pathname, currentLocale));
1855
1239
  }
1856
- function isActiveTab(tab, pathname) {
1857
- return isSameRoutePath(tab.path, pathname) || hasPath(tab.children, pathname);
1240
+ function isActiveTab(tab, pathname, currentLocale) {
1241
+ return isSameRoutePath(tab.path, pathname, currentLocale) || hasPath(tab.children, pathname, currentLocale);
1858
1242
  }
1859
1243
  function ProductTabs(arg0) {
1860
- const { tabs } = arg0;
1244
+ const { tabs, currentLocale } = arg0;
1861
1245
  const t = useBuiltInText();
1862
1246
  const pathname = normalizeRoutePath(useLocation().pathname);
1863
1247
  if (!tabs?.length) return null;
@@ -1868,7 +1252,7 @@ function ProductTabs(arg0) {
1868
1252
  className: "clarify-product-tabs-nav mx-auto flex h-full w-full max-w-(--clarify-theme-layout-max-width) items-stretch gap-6 overflow-x-auto px-5",
1869
1253
  "aria-label": t("navbar.sections"),
1870
1254
  children: tabs.map((tab) => {
1871
- const active = isActiveTab(tab, pathname);
1255
+ const active = isActiveTab(tab, pathname, currentLocale);
1872
1256
  return /* @__PURE__ */ jsxs(Link, {
1873
1257
  to: tab.path,
1874
1258
  "aria-current": active ? "page" : void 0,
@@ -2014,7 +1398,10 @@ var Header = forwardRef(function Header(arg0, ref) {
2014
1398
  "data-clarify-header-banner": true,
2015
1399
  children: banner
2016
1400
  }),
2017
- /* @__PURE__ */ jsx(ProductTabs, { tabs })
1401
+ /* @__PURE__ */ jsx(ProductTabs, {
1402
+ tabs,
1403
+ currentLocale
1404
+ })
2018
1405
  ]
2019
1406
  });
2020
1407
  }
@@ -2051,6 +1438,6 @@ function PageTitleActions() {
2051
1438
  });
2052
1439
  }
2053
1440
  //#endregion
2054
- export { OpenApisContext as A, isExternalHref as C, useBuiltInText as D, copyTextToClipboard as E, useConfigOptional as M, useLocale as N, ConfigContext as O, useOpenApis as P, themeCookieName as S, prefixHref as T, getStoredThemePreference as _, SectionProvider as a, storeLocalePreference as b, lucideIconRegistry as c, normalizeRoutePath as d, resolveLocalizedText as f, getStoredLocalePreference as g, useTheme as h, Navigation as i, useConfig as j, LocaleContext as k, resolveLucideIconName as l, ThemeProvider as m, PageTitleActions as n, useSectionStore as o, ThemeToggle as p, Header as r, remToPx as s, PageActionsProvider as t, isSameRoutePath as u, localeCookieName as v, localizeHref as w, storeThemePreference as x, readLocaleCookie as y };
1441
+ export { isExternalHref as C, copyTextToClipboard as E, themeCookieName as S, prefixHref as T, getStoredThemePreference as _, SectionProvider as a, storeLocalePreference as b, lucideIconRegistry as c, normalizeRoutePath as d, resolveLocalizedText as f, getStoredLocalePreference as g, useTheme as h, Navigation as i, resolveLucideIconName as l, ThemeProvider as m, PageTitleActions as n, useSectionStore as o, ThemeToggle as p, Header as r, remToPx as s, PageActionsProvider as t, isSameRoutePath as u, localeCookieName as v, localizeHref as w, storeThemePreference as x, readLocaleCookie as y };
2055
1442
 
2056
- //# sourceMappingURL=PageActions-Dn8IGWoL.js.map
1443
+ //# sourceMappingURL=PageActions-D7K9LDGf.js.map