@terra-symposium/docs 0.1.17 → 0.1.71

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 (560) hide show
  1. package/README.md +3 -3
  2. package/lib-dist/assets/fonts/AUTHENTICSans-130.woff +0 -0
  3. package/lib-dist/assets/fonts/AUTHENTICSans-130.woff2 +0 -0
  4. package/lib-dist/assets/fonts/AUTHENTICSans-150.woff +0 -0
  5. package/lib-dist/assets/fonts/AUTHENTICSans-150.woff2 +0 -0
  6. package/lib-dist/assets/fonts/AUTHENTICSans-90.woff +0 -0
  7. package/lib-dist/assets/fonts/AUTHENTICSans-90.woff2 +0 -0
  8. package/lib-dist/assets/fonts/Avara-Bold.woff +0 -0
  9. package/lib-dist/assets/fonts/Avara-BoldItalic.woff +0 -0
  10. package/lib-dist/assets/fonts/InterVariable-Italic-latin-20260728.woff2 +0 -0
  11. package/lib-dist/assets/fonts/InterVariable-latin-20260728.woff2 +0 -0
  12. package/lib-dist/assets/fonts/README.md +7 -0
  13. package/lib-dist/assets/fonts/licenses/Inter-OFL-1.1.txt +92 -0
  14. package/lib-dist/assets/fonts/licenses/OFL-1.1.txt +93 -0
  15. package/lib-dist/{Docs.d.ts → components/Docs.d.ts} +1 -1
  16. package/lib-dist/components/Docs.d.ts.map +1 -0
  17. package/lib-dist/components/Docs.js +9 -0
  18. package/lib-dist/components/Docs.js.map +1 -0
  19. package/lib-dist/{LocalDocsWorkspace.d.ts → components/LocalDocsWorkspace.d.ts} +9 -2
  20. package/lib-dist/components/LocalDocsWorkspace.d.ts.map +1 -0
  21. package/lib-dist/{LocalDocsWorkspace.js → components/LocalDocsWorkspace.js} +83 -24
  22. package/lib-dist/components/LocalDocsWorkspace.js.map +1 -0
  23. package/lib-dist/components/NotFound.d.ts +8 -0
  24. package/lib-dist/components/NotFound.d.ts.map +1 -0
  25. package/lib-dist/components/NotFound.js +6 -0
  26. package/lib-dist/components/NotFound.js.map +1 -0
  27. package/lib-dist/components/SiteLayout.d.ts +25 -0
  28. package/lib-dist/components/SiteLayout.d.ts.map +1 -0
  29. package/lib-dist/components/SiteLayout.js +12 -0
  30. package/lib-dist/components/SiteLayout.js.map +1 -0
  31. package/lib-dist/{StaticWorkspace.d.ts → components/StaticWorkspace.d.ts} +7 -3
  32. package/lib-dist/components/StaticWorkspace.d.ts.map +1 -0
  33. package/lib-dist/{StaticWorkspace.js → components/StaticWorkspace.js} +100 -34
  34. package/lib-dist/components/StaticWorkspace.js.map +1 -0
  35. package/lib-dist/components/StrictLocalWorkspaceHarness.d.ts +10 -0
  36. package/lib-dist/components/StrictLocalWorkspaceHarness.d.ts.map +1 -0
  37. package/lib-dist/components/StrictLocalWorkspaceHarness.js +12 -0
  38. package/lib-dist/components/StrictLocalWorkspaceHarness.js.map +1 -0
  39. package/lib-dist/components/blocks.d.ts.map +1 -0
  40. package/lib-dist/{blocks.js → components/blocks.js} +88 -13
  41. package/lib-dist/components/blocks.js.map +1 -0
  42. package/lib-dist/{navigation.d.ts → components/navigation.d.ts} +2 -1
  43. package/lib-dist/components/navigation.d.ts.map +1 -0
  44. package/lib-dist/components/navigation.js.map +1 -0
  45. package/lib-dist/{terra → components/terra}/Workspace.d.ts +1 -1
  46. package/lib-dist/components/terra/Workspace.d.ts.map +1 -0
  47. package/lib-dist/components/terra/Workspace.js +190 -0
  48. package/lib-dist/components/terra/Workspace.js.map +1 -0
  49. package/lib-dist/components/terra/editor/TerraContentEditor.d.ts +15 -0
  50. package/lib-dist/components/terra/editor/TerraContentEditor.d.ts.map +1 -0
  51. package/lib-dist/components/terra/editor/TerraContentEditor.js +358 -0
  52. package/lib-dist/components/terra/editor/TerraContentEditor.js.map +1 -0
  53. package/lib-dist/{terra → components/terra}/editor/_blocks.d.ts +3 -4
  54. package/lib-dist/components/terra/editor/_blocks.d.ts.map +1 -0
  55. package/lib-dist/components/terra/editor/_blocks.js +120 -0
  56. package/lib-dist/components/terra/editor/_blocks.js.map +1 -0
  57. package/lib-dist/components/terra/editor/docs/BlockContext.d.ts +7 -0
  58. package/lib-dist/components/terra/editor/docs/BlockContext.d.ts.map +1 -0
  59. package/lib-dist/components/terra/editor/docs/BlockContext.js +60 -0
  60. package/lib-dist/components/terra/editor/docs/BlockContext.js.map +1 -0
  61. package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.d.ts +12 -0
  62. package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.d.ts.map +1 -0
  63. package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.js +66 -0
  64. package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.js.map +1 -0
  65. package/lib-dist/components/terra/editor/docs/TerraToolbar.d.ts +12 -0
  66. package/lib-dist/components/terra/editor/docs/TerraToolbar.d.ts.map +1 -0
  67. package/lib-dist/components/terra/editor/docs/TerraToolbar.js +169 -0
  68. package/lib-dist/components/terra/editor/docs/TerraToolbar.js.map +1 -0
  69. package/lib-dist/{terra → components/terra}/editor/docs/_Callout.d.ts +1 -1
  70. package/lib-dist/components/terra/editor/docs/_Callout.d.ts.map +1 -0
  71. package/lib-dist/{terra → components/terra}/editor/docs/_Callout.js +10 -6
  72. package/lib-dist/components/terra/editor/docs/_Callout.js.map +1 -0
  73. package/lib-dist/components/terra/editor/docs/_CodeBlock.d.ts.map +1 -0
  74. package/lib-dist/{terra → components/terra}/editor/docs/_CodeBlock.js +110 -44
  75. package/lib-dist/components/terra/editor/docs/_CodeBlock.js.map +1 -0
  76. package/lib-dist/{terra → components/terra}/editor/docs/_DocsCode.d.ts +1 -1
  77. package/lib-dist/components/terra/editor/docs/_DocsCode.d.ts.map +1 -0
  78. package/lib-dist/{terra → components/terra}/editor/docs/_DocsCode.js +44 -11
  79. package/lib-dist/components/terra/editor/docs/_DocsCode.js.map +1 -0
  80. package/lib-dist/{terra → components/terra}/editor/docs/_DocsImage.d.ts +1 -1
  81. package/lib-dist/components/terra/editor/docs/_DocsImage.d.ts.map +1 -0
  82. package/lib-dist/components/terra/editor/docs/_DocsImage.js +62 -0
  83. package/lib-dist/components/terra/editor/docs/_DocsImage.js.map +1 -0
  84. package/lib-dist/{terra → components/terra}/editor/docs/_Embed.d.ts +3 -1
  85. package/lib-dist/components/terra/editor/docs/_Embed.d.ts.map +1 -0
  86. package/lib-dist/components/terra/editor/docs/_Embed.js +73 -0
  87. package/lib-dist/components/terra/editor/docs/_Embed.js.map +1 -0
  88. package/lib-dist/{terra → components/terra}/editor/docs/_Math.d.ts +2 -2
  89. package/lib-dist/components/terra/editor/docs/_Math.d.ts.map +1 -0
  90. package/lib-dist/{terra → components/terra}/editor/docs/_Math.js +26 -14
  91. package/lib-dist/components/terra/editor/docs/_Math.js.map +1 -0
  92. package/lib-dist/{terra → components/terra}/editor/docs/_Nodes.d.ts +1 -1
  93. package/lib-dist/components/terra/editor/docs/_Nodes.d.ts.map +1 -0
  94. package/lib-dist/components/terra/editor/docs/_Nodes.js +62 -0
  95. package/lib-dist/components/terra/editor/docs/_Nodes.js.map +1 -0
  96. package/lib-dist/{terra → components/terra}/editor/docs/_Raw.d.ts +1 -1
  97. package/lib-dist/components/terra/editor/docs/_Raw.d.ts.map +1 -0
  98. package/lib-dist/{terra → components/terra}/editor/docs/_Raw.js +8 -3
  99. package/lib-dist/components/terra/editor/docs/_Raw.js.map +1 -0
  100. package/lib-dist/{terra → components/terra}/editor/docs/_Table.d.ts +1 -1
  101. package/lib-dist/components/terra/editor/docs/_Table.d.ts.map +1 -0
  102. package/lib-dist/components/terra/editor/docs/_Table.js +99 -0
  103. package/lib-dist/components/terra/editor/docs/_Table.js.map +1 -0
  104. package/lib-dist/{terra → components/terra}/editor/docs/_Tabs.d.ts +1 -1
  105. package/lib-dist/components/terra/editor/docs/_Tabs.d.ts.map +1 -0
  106. package/lib-dist/{terra → components/terra}/editor/docs/_Tabs.js +35 -14
  107. package/lib-dist/components/terra/editor/docs/_Tabs.js.map +1 -0
  108. package/lib-dist/{terra → components/terra}/editor/docs/_TsDocs.d.ts +1 -1
  109. package/lib-dist/components/terra/editor/docs/_TsDocs.d.ts.map +1 -0
  110. package/lib-dist/{terra → components/terra}/editor/docs/_TsDocs.js +15 -13
  111. package/lib-dist/components/terra/editor/docs/_TsDocs.js.map +1 -0
  112. package/lib-dist/{terra → components/terra}/editor/docs/_math_inline.d.ts +1 -1
  113. package/lib-dist/components/terra/editor/docs/_math_inline.d.ts.map +1 -0
  114. package/lib-dist/{terra → components/terra}/editor/docs/_math_inline.js +2 -2
  115. package/lib-dist/components/terra/editor/docs/_math_inline.js.map +1 -0
  116. package/lib-dist/{terra → components/terra}/editor/docs/heading.d.ts +1 -1
  117. package/lib-dist/components/terra/editor/docs/heading.d.ts.map +1 -0
  118. package/lib-dist/{terra → components/terra}/editor/docs/heading.js +8 -5
  119. package/lib-dist/components/terra/editor/docs/heading.js.map +1 -0
  120. package/lib-dist/components/terra/editor/docs/index.d.ts.map +1 -0
  121. package/lib-dist/components/terra/editor/docs/index.js.map +1 -0
  122. package/lib-dist/components/terra/editor/terra-content.styles.d.ts +3 -0
  123. package/lib-dist/components/terra/editor/terra-content.styles.d.ts.map +1 -0
  124. package/lib-dist/components/terra/editor/terra-content.styles.js +3 -0
  125. package/lib-dist/components/terra/editor/terra-content.styles.js.map +1 -0
  126. package/lib-dist/{terra → components/terra}/editor/types.d.ts +2 -2
  127. package/lib-dist/components/terra/editor/types.d.ts.map +1 -0
  128. package/lib-dist/{terra → components/terra}/editor/types.js +1 -1
  129. package/lib-dist/components/terra/editor/types.js.map +1 -0
  130. package/lib-dist/{terra → components/terra}/flow/Nodes.d.ts +3 -3
  131. package/lib-dist/components/terra/flow/Nodes.d.ts.map +1 -0
  132. package/lib-dist/{terra → components/terra}/flow/Nodes.js +211 -104
  133. package/lib-dist/components/terra/flow/Nodes.js.map +1 -0
  134. package/lib-dist/{terra → components/terra}/flow/_chrome.d.ts +9 -9
  135. package/lib-dist/components/terra/flow/_chrome.d.ts.map +1 -0
  136. package/lib-dist/{terra → components/terra}/flow/_chrome.js +325 -114
  137. package/lib-dist/components/terra/flow/_chrome.js.map +1 -0
  138. package/lib-dist/components/terra/flow/menuContext.d.ts.map +1 -0
  139. package/lib-dist/components/terra/flow/menuContext.js.map +1 -0
  140. package/lib-dist/{terra → components/terra}/pages/docs/_attachments.d.ts +1 -1
  141. package/lib-dist/components/terra/pages/docs/_attachments.d.ts.map +1 -0
  142. package/lib-dist/{terra → components/terra}/pages/docs/_attachments.js +371 -127
  143. package/lib-dist/components/terra/pages/docs/_attachments.js.map +1 -0
  144. package/lib-dist/components/terra/pages/docs/_blocks.d.ts.map +1 -0
  145. package/lib-dist/{terra → components/terra}/pages/docs/_blocks.js +39 -28
  146. package/lib-dist/components/terra/pages/docs/_blocks.js.map +1 -0
  147. package/lib-dist/{terra → components/terra}/pages/docs/_editable.d.ts +3 -3
  148. package/lib-dist/components/terra/pages/docs/_editable.d.ts.map +1 -0
  149. package/lib-dist/{terra → components/terra}/pages/docs/_editable.js +81 -43
  150. package/lib-dist/components/terra/pages/docs/_editable.js.map +1 -0
  151. package/lib-dist/{terra → components/terra}/pages/docs/_export-dialog.d.ts +1 -1
  152. package/lib-dist/components/terra/pages/docs/_export-dialog.d.ts.map +1 -0
  153. package/lib-dist/{terra → components/terra}/pages/docs/_export-dialog.js +13 -13
  154. package/lib-dist/components/terra/pages/docs/_export-dialog.js.map +1 -0
  155. package/lib-dist/components/terra/pages/docs/_icons.d.ts.map +1 -0
  156. package/lib-dist/components/terra/pages/docs/_icons.js.map +1 -0
  157. package/lib-dist/{terra → components/terra}/pages/docs/_main.d.ts +10 -7
  158. package/lib-dist/components/terra/pages/docs/_main.d.ts.map +1 -0
  159. package/lib-dist/components/terra/pages/docs/_main.js +710 -0
  160. package/lib-dist/components/terra/pages/docs/_main.js.map +1 -0
  161. package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.d.ts +10 -0
  162. package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.d.ts.map +1 -0
  163. package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.js +597 -0
  164. package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.js.map +1 -0
  165. package/lib-dist/{terra → components/terra}/pages/docs/_sidebar.d.ts +3 -12
  166. package/lib-dist/components/terra/pages/docs/_sidebar.d.ts.map +1 -0
  167. package/lib-dist/components/terra/pages/docs/_sidebar.js +1437 -0
  168. package/lib-dist/components/terra/pages/docs/_sidebar.js.map +1 -0
  169. package/lib-dist/components/terra/pages/docs/_toc.d.ts +4 -0
  170. package/lib-dist/components/terra/pages/docs/_toc.d.ts.map +1 -0
  171. package/lib-dist/components/terra/pages/docs/_toc.js +212 -0
  172. package/lib-dist/components/terra/pages/docs/_toc.js.map +1 -0
  173. package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.d.ts +15 -0
  174. package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.d.ts.map +1 -0
  175. package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.js +207 -0
  176. package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.js.map +1 -0
  177. package/lib-dist/{terra → components/terra}/pages/docs/_toolbar.d.ts +4 -5
  178. package/lib-dist/components/terra/pages/docs/_toolbar.d.ts.map +1 -0
  179. package/lib-dist/{terra → components/terra}/pages/docs/_toolbar.js +312 -343
  180. package/lib-dist/components/terra/pages/docs/_toolbar.js.map +1 -0
  181. package/lib-dist/{terra → components/terra}/pages/docs/_tree.d.ts +4 -4
  182. package/lib-dist/components/terra/pages/docs/_tree.d.ts.map +1 -0
  183. package/lib-dist/{terra → components/terra}/pages/docs/_tree.js +219 -264
  184. package/lib-dist/components/terra/pages/docs/_tree.js.map +1 -0
  185. package/lib-dist/components/terra/pages/docs/use-block-nav.d.ts +5 -0
  186. package/lib-dist/components/terra/pages/docs/use-block-nav.d.ts.map +1 -0
  187. package/lib-dist/components/terra/pages/docs/use-block-nav.js +1306 -0
  188. package/lib-dist/components/terra/pages/docs/use-block-nav.js.map +1 -0
  189. package/lib-dist/components/terra/pages/docs/use-media-paste.d.ts +5 -0
  190. package/lib-dist/components/terra/pages/docs/use-media-paste.d.ts.map +1 -0
  191. package/lib-dist/components/terra/pages/docs/use-media-paste.js +391 -0
  192. package/lib-dist/components/terra/pages/docs/use-media-paste.js.map +1 -0
  193. package/lib-dist/components/terra/pages/docs/use-render-tripwire.d.ts +2 -0
  194. package/lib-dist/components/terra/pages/docs/use-render-tripwire.d.ts.map +1 -0
  195. package/lib-dist/components/terra/pages/docs/use-render-tripwire.js +25 -0
  196. package/lib-dist/components/terra/pages/docs/use-render-tripwire.js.map +1 -0
  197. package/lib-dist/{terra/runtime → components/terra}/ui.d.ts +2 -5
  198. package/lib-dist/components/terra/ui.d.ts.map +1 -0
  199. package/lib-dist/components/terra/ui.js +20 -0
  200. package/lib-dist/components/terra/ui.js.map +1 -0
  201. package/lib-dist/components/workspace-demo-fixture.d.ts +35 -0
  202. package/lib-dist/components/workspace-demo-fixture.d.ts.map +1 -0
  203. package/lib-dist/components/workspace-demo-fixture.js +820 -0
  204. package/lib-dist/components/workspace-demo-fixture.js.map +1 -0
  205. package/lib-dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  206. package/lib-dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  207. package/lib-dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  208. package/lib-dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  209. package/lib-dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  210. package/lib-dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  211. package/lib-dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  212. package/lib-dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  213. package/lib-dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  214. package/lib-dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  215. package/lib-dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  216. package/lib-dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  217. package/lib-dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  218. package/lib-dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  219. package/lib-dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  220. package/lib-dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  221. package/lib-dist/fonts/KaTeX_Main-Bold.woff +0 -0
  222. package/lib-dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  223. package/lib-dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  224. package/lib-dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  225. package/lib-dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  226. package/lib-dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  227. package/lib-dist/fonts/KaTeX_Main-Italic.woff +0 -0
  228. package/lib-dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  229. package/lib-dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  230. package/lib-dist/fonts/KaTeX_Main-Regular.woff +0 -0
  231. package/lib-dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  232. package/lib-dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  233. package/lib-dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  234. package/lib-dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  235. package/lib-dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  236. package/lib-dist/fonts/KaTeX_Math-Italic.woff +0 -0
  237. package/lib-dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  238. package/lib-dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  239. package/lib-dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  240. package/lib-dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  241. package/lib-dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  242. package/lib-dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  243. package/lib-dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  244. package/lib-dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  245. package/lib-dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  246. package/lib-dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  247. package/lib-dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  248. package/lib-dist/fonts/KaTeX_Script-Regular.woff +0 -0
  249. package/lib-dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  250. package/lib-dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  251. package/lib-dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  252. package/lib-dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  253. package/lib-dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  254. package/lib-dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  255. package/lib-dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  256. package/lib-dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  257. package/lib-dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  258. package/lib-dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  259. package/lib-dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  260. package/lib-dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  261. package/lib-dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  262. package/lib-dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  263. package/lib-dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  264. package/lib-dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  265. package/lib-dist/lib/astro.d.ts +8 -0
  266. package/lib-dist/lib/astro.d.ts.map +1 -0
  267. package/lib-dist/lib/astro.js +27 -0
  268. package/lib-dist/lib/astro.js.map +1 -0
  269. package/lib-dist/{docs-catalog.d.ts → lib/docs-catalog.d.ts} +1 -1
  270. package/lib-dist/lib/docs-catalog.d.ts.map +1 -0
  271. package/lib-dist/lib/docs-catalog.js +75 -0
  272. package/lib-dist/lib/docs-catalog.js.map +1 -0
  273. package/lib-dist/lib/docs-theme.d.ts +7 -0
  274. package/lib-dist/lib/docs-theme.d.ts.map +1 -0
  275. package/lib-dist/lib/docs-theme.js +51 -0
  276. package/lib-dist/lib/docs-theme.js.map +1 -0
  277. package/lib-dist/lib/host-runtime.d.ts.map +1 -0
  278. package/lib-dist/{host-runtime.js → lib/host-runtime.js} +4 -2
  279. package/lib-dist/lib/host-runtime.js.map +1 -0
  280. package/lib-dist/{host.d.ts → lib/host.d.ts} +20 -0
  281. package/lib-dist/lib/host.d.ts.map +1 -0
  282. package/lib-dist/lib/host.js.map +1 -0
  283. package/lib-dist/lib/index.d.ts +34 -0
  284. package/lib-dist/lib/index.d.ts.map +1 -0
  285. package/lib-dist/lib/index.js +27 -0
  286. package/lib-dist/lib/index.js.map +1 -0
  287. package/lib-dist/{markdown-model.d.ts → lib/markdown-model.d.ts} +3 -3
  288. package/lib-dist/lib/markdown-model.d.ts.map +1 -0
  289. package/lib-dist/lib/markdown-model.js +2031 -0
  290. package/lib-dist/lib/markdown-model.js.map +1 -0
  291. package/lib-dist/lib/markdown.d.ts +3 -0
  292. package/lib-dist/lib/markdown.d.ts.map +1 -0
  293. package/lib-dist/lib/markdown.js +222 -0
  294. package/lib-dist/lib/markdown.js.map +1 -0
  295. package/lib-dist/{schema.d.ts → lib/schema.d.ts} +55 -23
  296. package/lib-dist/lib/schema.d.ts.map +1 -0
  297. package/lib-dist/{schema.js → lib/schema.js} +26 -18
  298. package/lib-dist/lib/schema.js.map +1 -0
  299. package/lib-dist/{terra/pages/docs/_custom.d.ts → lib/terra/custom-components.d.ts} +2 -2
  300. package/lib-dist/lib/terra/custom-components.d.ts.map +1 -0
  301. package/lib-dist/{terra/pages/docs/_custom.js → lib/terra/custom-components.js} +1 -1
  302. package/lib-dist/lib/terra/custom-components.js.map +1 -0
  303. package/lib-dist/lib/terra/docs/archive.d.ts +3 -0
  304. package/lib-dist/lib/terra/docs/archive.d.ts.map +1 -0
  305. package/lib-dist/lib/terra/docs/archive.js +654 -0
  306. package/lib-dist/lib/terra/docs/archive.js.map +1 -0
  307. package/lib-dist/lib/terra/docs/assets.d.ts +26 -0
  308. package/lib-dist/lib/terra/docs/assets.d.ts.map +1 -0
  309. package/lib-dist/lib/terra/docs/assets.js +74 -0
  310. package/lib-dist/lib/terra/docs/assets.js.map +1 -0
  311. package/lib-dist/lib/terra/docs/attachments.d.ts +4 -0
  312. package/lib-dist/lib/terra/docs/attachments.d.ts.map +1 -0
  313. package/lib-dist/lib/terra/docs/attachments.js +5 -0
  314. package/lib-dist/lib/terra/docs/attachments.js.map +1 -0
  315. package/lib-dist/lib/terra/docs/editor-dom.d.ts +50 -0
  316. package/lib-dist/lib/terra/docs/editor-dom.d.ts.map +1 -0
  317. package/lib-dist/lib/terra/docs/editor-dom.js +236 -0
  318. package/lib-dist/lib/terra/docs/editor-dom.js.map +1 -0
  319. package/lib-dist/lib/terra/docs/mutations.d.ts +10 -0
  320. package/lib-dist/lib/terra/docs/mutations.d.ts.map +1 -0
  321. package/lib-dist/lib/terra/docs/mutations.js +105 -0
  322. package/lib-dist/lib/terra/docs/mutations.js.map +1 -0
  323. package/lib-dist/lib/terra/docs/navigation.d.ts +6 -0
  324. package/lib-dist/lib/terra/docs/navigation.d.ts.map +1 -0
  325. package/lib-dist/lib/terra/docs/navigation.js +21 -0
  326. package/lib-dist/lib/terra/docs/navigation.js.map +1 -0
  327. package/lib-dist/lib/terra/docs/state.d.ts +186 -0
  328. package/lib-dist/lib/terra/docs/state.d.ts.map +1 -0
  329. package/lib-dist/lib/terra/docs/state.js +255 -0
  330. package/lib-dist/lib/terra/docs/state.js.map +1 -0
  331. package/lib-dist/lib/terra/docs/toolbar.d.ts +11 -0
  332. package/lib-dist/lib/terra/docs/toolbar.d.ts.map +1 -0
  333. package/lib-dist/lib/terra/docs/toolbar.js +41 -0
  334. package/lib-dist/lib/terra/docs/toolbar.js.map +1 -0
  335. package/lib-dist/lib/terra/docs/tree.d.ts +15 -0
  336. package/lib-dist/lib/terra/docs/tree.d.ts.map +1 -0
  337. package/lib-dist/lib/terra/docs/tree.js +61 -0
  338. package/lib-dist/lib/terra/docs/tree.js.map +1 -0
  339. package/lib-dist/{terra/pages/docs/_helpers.d.ts → lib/terra/docs/workspace.d.ts} +7 -6
  340. package/lib-dist/lib/terra/docs/workspace.d.ts.map +1 -0
  341. package/lib-dist/{terra/pages/docs/_helpers.js → lib/terra/docs/workspace.js} +39 -27
  342. package/lib-dist/lib/terra/docs/workspace.js.map +1 -0
  343. package/lib-dist/lib/terra/flow/_layout.d.ts.map +1 -0
  344. package/lib-dist/{terra → lib/terra}/flow/_layout.js +16 -6
  345. package/lib-dist/lib/terra/flow/_layout.js.map +1 -0
  346. package/lib-dist/lib/terra/flow/powerSource.d.ts.map +1 -0
  347. package/lib-dist/{terra → lib/terra}/flow/powerSource.js +10 -4
  348. package/lib-dist/lib/terra/flow/powerSource.js.map +1 -0
  349. package/lib-dist/{terra → lib/terra}/regex.mjs +11 -6
  350. package/lib-dist/lib/terra/runtime/action-proxy.d.ts +45 -0
  351. package/lib-dist/lib/terra/runtime/action-proxy.d.ts.map +1 -0
  352. package/lib-dist/{terra → lib/terra}/runtime/action-proxy.js +1 -1
  353. package/lib-dist/lib/terra/runtime/action-proxy.js.map +1 -0
  354. package/lib-dist/lib/terra/runtime/content/block-jsx.d.ts +23 -0
  355. package/lib-dist/lib/terra/runtime/content/block-jsx.d.ts.map +1 -0
  356. package/lib-dist/lib/terra/runtime/content/block-jsx.js +225 -0
  357. package/lib-dist/lib/terra/runtime/content/block-jsx.js.map +1 -0
  358. package/lib-dist/lib/terra/runtime/content/document-markdown.d.ts +41 -0
  359. package/lib-dist/lib/terra/runtime/content/document-markdown.d.ts.map +1 -0
  360. package/lib-dist/lib/terra/runtime/content/document-markdown.js +536 -0
  361. package/lib-dist/lib/terra/runtime/content/document-markdown.js.map +1 -0
  362. package/lib-dist/lib/terra/runtime/content/markdown.d.ts +109 -0
  363. package/lib-dist/lib/terra/runtime/content/markdown.d.ts.map +1 -0
  364. package/lib-dist/lib/terra/runtime/content/markdown.js +428 -0
  365. package/lib-dist/lib/terra/runtime/content/markdown.js.map +1 -0
  366. package/lib-dist/lib/terra/runtime/content.d.ts.map +1 -0
  367. package/lib-dist/{terra → lib/terra}/runtime/content.js +147 -62
  368. package/lib-dist/lib/terra/runtime/content.js.map +1 -0
  369. package/lib-dist/lib/terra/runtime/leaf.d.ts.map +1 -0
  370. package/lib-dist/{terra → lib/terra}/runtime/leaf.js +1 -1
  371. package/lib-dist/lib/terra/runtime/leaf.js.map +1 -0
  372. package/lib-dist/lib/terra/runtime/nodes.d.ts.map +1 -0
  373. package/lib-dist/{terra → lib/terra}/runtime/nodes.js +103 -31
  374. package/lib-dist/lib/terra/runtime/nodes.js.map +1 -0
  375. package/lib-dist/{terra → lib/terra}/runtime/runtime.d.ts +8 -2
  376. package/lib-dist/lib/terra/runtime/runtime.d.ts.map +1 -0
  377. package/lib-dist/lib/terra/runtime/runtime.js +86 -0
  378. package/lib-dist/lib/terra/runtime/runtime.js.map +1 -0
  379. package/lib-dist/lib/terra/runtime/shared.d.ts.map +1 -0
  380. package/lib-dist/{terra → lib/terra}/runtime/shared.js +56 -11
  381. package/lib-dist/lib/terra/runtime/shared.js.map +1 -0
  382. package/lib-dist/lib/terra/runtime/types.d.ts +529 -0
  383. package/lib-dist/lib/terra/runtime/types.d.ts.map +1 -0
  384. package/lib-dist/{terra → lib/terra}/runtime/types.js +28 -2
  385. package/lib-dist/lib/terra/runtime/types.js.map +1 -0
  386. package/lib-dist/lib/workspace-types.d.ts +29 -0
  387. package/lib-dist/lib/workspace-types.d.ts.map +1 -0
  388. package/lib-dist/lib/workspace-types.js +2 -0
  389. package/lib-dist/lib/workspace-types.js.map +1 -0
  390. package/lib-dist/style.css +237 -1
  391. package/package.json +34 -16
  392. package/src/components/NotFound.astro +6 -0
  393. package/src/components/NotFound.tsx +48 -0
  394. package/src/{SiteLayout.astro → components/SiteLayout.astro} +8 -4
  395. package/src/{navigation.tsx → components/navigation.tsx} +2 -1
  396. package/lib-dist/Docs.d.ts.map +0 -1
  397. package/lib-dist/Docs.js +0 -60
  398. package/lib-dist/Docs.js.map +0 -1
  399. package/lib-dist/LocalDocsWorkspace.d.ts.map +0 -1
  400. package/lib-dist/LocalDocsWorkspace.js.map +0 -1
  401. package/lib-dist/SiteLayout.d.ts +0 -30
  402. package/lib-dist/SiteLayout.d.ts.map +0 -1
  403. package/lib-dist/SiteLayout.js +0 -34
  404. package/lib-dist/SiteLayout.js.map +0 -1
  405. package/lib-dist/StaticWorkspace.d.ts.map +0 -1
  406. package/lib-dist/StaticWorkspace.js.map +0 -1
  407. package/lib-dist/_Toolbar.d.ts +0 -7
  408. package/lib-dist/_Toolbar.d.ts.map +0 -1
  409. package/lib-dist/_Toolbar.js +0 -85
  410. package/lib-dist/_Toolbar.js.map +0 -1
  411. package/lib-dist/blocks.d.ts.map +0 -1
  412. package/lib-dist/blocks.js.map +0 -1
  413. package/lib-dist/docs-catalog.d.ts.map +0 -1
  414. package/lib-dist/docs-catalog.js +0 -38
  415. package/lib-dist/docs-catalog.js.map +0 -1
  416. package/lib-dist/docs-style.css +0 -31
  417. package/lib-dist/fonts/README.md +0 -5
  418. package/lib-dist/host-runtime.d.ts.map +0 -1
  419. package/lib-dist/host-runtime.js.map +0 -1
  420. package/lib-dist/host.d.ts.map +0 -1
  421. package/lib-dist/host.js.map +0 -1
  422. package/lib-dist/index.d.ts +0 -35
  423. package/lib-dist/index.d.ts.map +0 -1
  424. package/lib-dist/index.js +0 -28
  425. package/lib-dist/index.js.map +0 -1
  426. package/lib-dist/markdown-model.d.ts.map +0 -1
  427. package/lib-dist/markdown-model.js +0 -181
  428. package/lib-dist/markdown-model.js.map +0 -1
  429. package/lib-dist/markdown.d.ts +0 -3
  430. package/lib-dist/markdown.d.ts.map +0 -1
  431. package/lib-dist/markdown.js +0 -83
  432. package/lib-dist/markdown.js.map +0 -1
  433. package/lib-dist/navigation.d.ts.map +0 -1
  434. package/lib-dist/navigation.js.map +0 -1
  435. package/lib-dist/schema.d.ts.map +0 -1
  436. package/lib-dist/schema.js.map +0 -1
  437. package/lib-dist/terra/Workspace.d.ts.map +0 -1
  438. package/lib-dist/terra/Workspace.js +0 -9
  439. package/lib-dist/terra/Workspace.js.map +0 -1
  440. package/lib-dist/terra/editor/TerraContentEditor.d.ts +0 -10
  441. package/lib-dist/terra/editor/TerraContentEditor.d.ts.map +0 -1
  442. package/lib-dist/terra/editor/TerraContentEditor.js +0 -47
  443. package/lib-dist/terra/editor/TerraContentEditor.js.map +0 -1
  444. package/lib-dist/terra/editor/_blocks.d.ts.map +0 -1
  445. package/lib-dist/terra/editor/_blocks.js +0 -110
  446. package/lib-dist/terra/editor/_blocks.js.map +0 -1
  447. package/lib-dist/terra/editor/docs/_Callout.d.ts.map +0 -1
  448. package/lib-dist/terra/editor/docs/_Callout.js.map +0 -1
  449. package/lib-dist/terra/editor/docs/_CodeBlock.d.ts.map +0 -1
  450. package/lib-dist/terra/editor/docs/_CodeBlock.js.map +0 -1
  451. package/lib-dist/terra/editor/docs/_DocsCode.d.ts.map +0 -1
  452. package/lib-dist/terra/editor/docs/_DocsCode.js.map +0 -1
  453. package/lib-dist/terra/editor/docs/_DocsImage.d.ts.map +0 -1
  454. package/lib-dist/terra/editor/docs/_DocsImage.js +0 -62
  455. package/lib-dist/terra/editor/docs/_DocsImage.js.map +0 -1
  456. package/lib-dist/terra/editor/docs/_Embed.d.ts.map +0 -1
  457. package/lib-dist/terra/editor/docs/_Embed.js +0 -27
  458. package/lib-dist/terra/editor/docs/_Embed.js.map +0 -1
  459. package/lib-dist/terra/editor/docs/_Math.d.ts.map +0 -1
  460. package/lib-dist/terra/editor/docs/_Math.js.map +0 -1
  461. package/lib-dist/terra/editor/docs/_Nodes.d.ts.map +0 -1
  462. package/lib-dist/terra/editor/docs/_Nodes.js +0 -52
  463. package/lib-dist/terra/editor/docs/_Nodes.js.map +0 -1
  464. package/lib-dist/terra/editor/docs/_Raw.d.ts.map +0 -1
  465. package/lib-dist/terra/editor/docs/_Raw.js.map +0 -1
  466. package/lib-dist/terra/editor/docs/_Table.d.ts.map +0 -1
  467. package/lib-dist/terra/editor/docs/_Table.js +0 -71
  468. package/lib-dist/terra/editor/docs/_Table.js.map +0 -1
  469. package/lib-dist/terra/editor/docs/_Tabs.d.ts.map +0 -1
  470. package/lib-dist/terra/editor/docs/_Tabs.js.map +0 -1
  471. package/lib-dist/terra/editor/docs/_TsDocs.d.ts.map +0 -1
  472. package/lib-dist/terra/editor/docs/_TsDocs.js.map +0 -1
  473. package/lib-dist/terra/editor/docs/_math_inline.d.ts.map +0 -1
  474. package/lib-dist/terra/editor/docs/_math_inline.js.map +0 -1
  475. package/lib-dist/terra/editor/docs/heading.d.ts.map +0 -1
  476. package/lib-dist/terra/editor/docs/heading.js.map +0 -1
  477. package/lib-dist/terra/editor/docs/index.d.ts.map +0 -1
  478. package/lib-dist/terra/editor/docs/index.js.map +0 -1
  479. package/lib-dist/terra/editor/types.d.ts.map +0 -1
  480. package/lib-dist/terra/editor/types.js.map +0 -1
  481. package/lib-dist/terra/flow/Nodes.d.ts.map +0 -1
  482. package/lib-dist/terra/flow/Nodes.js.map +0 -1
  483. package/lib-dist/terra/flow/_chrome.d.ts.map +0 -1
  484. package/lib-dist/terra/flow/_chrome.js.map +0 -1
  485. package/lib-dist/terra/flow/_layout.d.ts.map +0 -1
  486. package/lib-dist/terra/flow/_layout.js.map +0 -1
  487. package/lib-dist/terra/flow/menuContext.d.ts.map +0 -1
  488. package/lib-dist/terra/flow/menuContext.js.map +0 -1
  489. package/lib-dist/terra/flow/powerSource.d.ts.map +0 -1
  490. package/lib-dist/terra/flow/powerSource.js.map +0 -1
  491. package/lib-dist/terra/pages/docs/_attachments.d.ts.map +0 -1
  492. package/lib-dist/terra/pages/docs/_attachments.js.map +0 -1
  493. package/lib-dist/terra/pages/docs/_blocks.d.ts.map +0 -1
  494. package/lib-dist/terra/pages/docs/_blocks.js.map +0 -1
  495. package/lib-dist/terra/pages/docs/_custom.d.ts.map +0 -1
  496. package/lib-dist/terra/pages/docs/_custom.js.map +0 -1
  497. package/lib-dist/terra/pages/docs/_editable.d.ts.map +0 -1
  498. package/lib-dist/terra/pages/docs/_editable.js.map +0 -1
  499. package/lib-dist/terra/pages/docs/_export-dialog.d.ts.map +0 -1
  500. package/lib-dist/terra/pages/docs/_export-dialog.js.map +0 -1
  501. package/lib-dist/terra/pages/docs/_helpers.d.ts.map +0 -1
  502. package/lib-dist/terra/pages/docs/_helpers.js.map +0 -1
  503. package/lib-dist/terra/pages/docs/_icons.d.ts.map +0 -1
  504. package/lib-dist/terra/pages/docs/_icons.js.map +0 -1
  505. package/lib-dist/terra/pages/docs/_main.d.ts.map +0 -1
  506. package/lib-dist/terra/pages/docs/_main.js +0 -1959
  507. package/lib-dist/terra/pages/docs/_main.js.map +0 -1
  508. package/lib-dist/terra/pages/docs/_sidebar.d.ts.map +0 -1
  509. package/lib-dist/terra/pages/docs/_sidebar.js +0 -2450
  510. package/lib-dist/terra/pages/docs/_sidebar.js.map +0 -1
  511. package/lib-dist/terra/pages/docs/_toolbar.d.ts.map +0 -1
  512. package/lib-dist/terra/pages/docs/_toolbar.js.map +0 -1
  513. package/lib-dist/terra/pages/docs/_tree.d.ts.map +0 -1
  514. package/lib-dist/terra/pages/docs/_tree.js.map +0 -1
  515. package/lib-dist/terra/runtime/action-proxy.d.ts +0 -5
  516. package/lib-dist/terra/runtime/action-proxy.d.ts.map +0 -1
  517. package/lib-dist/terra/runtime/action-proxy.js.map +0 -1
  518. package/lib-dist/terra/runtime/content.d.ts.map +0 -1
  519. package/lib-dist/terra/runtime/content.js.map +0 -1
  520. package/lib-dist/terra/runtime/leaf.d.ts.map +0 -1
  521. package/lib-dist/terra/runtime/leaf.js.map +0 -1
  522. package/lib-dist/terra/runtime/nodes.d.ts.map +0 -1
  523. package/lib-dist/terra/runtime/nodes.js.map +0 -1
  524. package/lib-dist/terra/runtime/runtime.d.ts.map +0 -1
  525. package/lib-dist/terra/runtime/runtime.js +0 -50
  526. package/lib-dist/terra/runtime/runtime.js.map +0 -1
  527. package/lib-dist/terra/runtime/shared.d.ts.map +0 -1
  528. package/lib-dist/terra/runtime/shared.js.map +0 -1
  529. package/lib-dist/terra/runtime/types.d.ts +0 -266
  530. package/lib-dist/terra/runtime/types.d.ts.map +0 -1
  531. package/lib-dist/terra/runtime/types.js.map +0 -1
  532. package/lib-dist/terra/runtime/ui.d.ts.map +0 -1
  533. package/lib-dist/terra/runtime/ui.js +0 -16
  534. package/lib-dist/terra/runtime/ui.js.map +0 -1
  535. package/lib-dist/workspace.d.ts +0 -78
  536. package/lib-dist/workspace.d.ts.map +0 -1
  537. package/lib-dist/workspace.js +0 -151
  538. package/lib-dist/workspace.js.map +0 -1
  539. package/src/style.css +0 -733
  540. /package/lib-dist/{fonts → assets/fonts}/Avara-Bold.woff2 +0 -0
  541. /package/lib-dist/{fonts → assets/fonts}/Avara-BoldItalic.woff2 +0 -0
  542. /package/lib-dist/{fonts → assets/fonts}/OFL-1.1.txt +0 -0
  543. /package/lib-dist/{blocks.d.ts → components/blocks.d.ts} +0 -0
  544. /package/lib-dist/{navigation.js → components/navigation.js} +0 -0
  545. /package/lib-dist/{terra → components/terra}/editor/docs/_CodeBlock.d.ts +0 -0
  546. /package/lib-dist/{terra → components/terra}/editor/docs/index.d.ts +0 -0
  547. /package/lib-dist/{terra → components/terra}/editor/docs/index.js +0 -0
  548. /package/lib-dist/{terra → components/terra}/flow/menuContext.d.ts +0 -0
  549. /package/lib-dist/{terra → components/terra}/flow/menuContext.js +0 -0
  550. /package/lib-dist/{terra → components/terra}/pages/docs/_blocks.d.ts +0 -0
  551. /package/lib-dist/{terra → components/terra}/pages/docs/_icons.d.ts +0 -0
  552. /package/lib-dist/{terra → components/terra}/pages/docs/_icons.js +0 -0
  553. /package/lib-dist/{host-runtime.d.ts → lib/host-runtime.d.ts} +0 -0
  554. /package/lib-dist/{host.js → lib/host.js} +0 -0
  555. /package/lib-dist/{terra → lib/terra}/flow/_layout.d.ts +0 -0
  556. /package/lib-dist/{terra → lib/terra}/flow/powerSource.d.ts +0 -0
  557. /package/lib-dist/{terra → lib/terra}/runtime/content.d.ts +0 -0
  558. /package/lib-dist/{terra → lib/terra}/runtime/leaf.d.ts +0 -0
  559. /package/lib-dist/{terra → lib/terra}/runtime/nodes.d.ts +0 -0
  560. /package/lib-dist/{terra → lib/terra}/runtime/shared.d.ts +0 -0
@@ -0,0 +1,1437 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // @ts-nocheck -- source-preserving extraction; public host contracts are typed in src/host.ts.
3
+ /**
4
+ * astro/src/pages/docs/_sidebar.tsx
5
+ * Docs sidebar entrypoint, state management, and unified dialog orchestrators.
6
+ * Folder boundary: sidebar navigation and its dialogs; the recursive tree structure remains in `_tree.tsx`.
7
+ */
8
+ /*//////////////////////////////////////////////////
9
+ IMPORTS
10
+ //////////////////////////////////////////////////*/
11
+ // API
12
+ import { $leafTitle, $mode, $transition, $unsavedDrafts, memoryDrafts, useAtom, } from '../../../../lib/terra/docs/state.js';
13
+ import { extractAllNodeIds, getSiblings as getSibs, parseDocsRoute as route, getStableKey, sanitizeName, } from '../../../../lib/terra/docs/tree.js';
14
+ import { navigateDocs as navigate } from '../../../../lib/terra/docs/navigation.js';
15
+ import { runMutation } from '../../../../lib/terra/docs/mutations.js';
16
+ import { getHue } from '@terra-symposium/styling';
17
+ import { actions } from '../../../../lib/terra/runtime/action-proxy.js';
18
+ import { archiveDocs } from '../../../../lib/terra/docs/archive.js';
19
+ import { ManageAttachmentsDialog } from './_manage-attachments-dialog.js';
20
+ import { useRenderTripwire } from './use-render-tripwire.js';
21
+ import { bName, buildRoute as buildRoute, cTitle, dirname, docsPath, docsRootPath, FILES, toNodeLabel, toPaths, } from '../../../../lib/terra/runtime/shared.js';
22
+ import { cn, createTrace, notify } from '../../../../lib/terra/runtime/runtime.js';
23
+ import { isDevOrigin } from '../../../../lib/terra/runtime/runtime.js';
24
+ import { components as repoComponents } from '../../../../lib/terra/custom-components.js';
25
+ import { currLeafSrc } from '../../../../lib/terra/runtime/leaf.js';
26
+ import { toast } from 'sonner';
27
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
28
+ // COMPONENTS
29
+ import * as TerraQualityRegex from '../../../../lib/terra/regex.mjs';
30
+ import React from 'react';
31
+ import Tree, { Menu } from './_tree.js';
32
+ import User from '../../ui.js';
33
+ import { Add as AddIcon, ArrowUpRight as PopOutIcon, Box as BoxIcon, ColorPalette as ColorIcon, Download as DownloadIcon, Edit as EditIcon, Link as LinkIcon, TrashCan as TrashIcon, } from '@carbon/icons-react';
34
+ import { AlertError } from '@terra-symposium/styling/ui/terra-original';
35
+ import { Button } from '@terra-symposium/styling/ui/terra-original';
36
+ import { ContextMenu, ContextMenuContent, ContextMenuTrigger, } from '@terra-symposium/styling/ui/terra-original';
37
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@terra-symposium/styling/ui/terra-original';
38
+ import { ErrorBoundary } from '../../ui.js';
39
+ import { ExportDialog as SharedExportDialog } from './_export-dialog.js';
40
+ import { Input } from '@terra-symposium/styling/ui/terra-original';
41
+ import { Label } from '@terra-symposium/styling/ui/terra-original';
42
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@terra-symposium/styling/ui/terra-original';
43
+ import { Separator } from '@terra-symposium/styling/ui/terra-original';
44
+ import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarRail, } from '@terra-symposium/styling/ui/terra-original';
45
+ import { Slider } from '@terra-symposium/styling/ui/terra-original';
46
+ // prettier-ignore
47
+ /*//////////////////////////////////////////////////
48
+ CONFIG
49
+ //////////////////////////////////////////////////*/
50
+ /**
51
+ * SANITY MANY-TO-MANY ROUTING ARCHITECTURE
52
+ *
53
+ * Parses explicit Sanity IDs directly from the URL.
54
+ * A single leaf or group can belong to multiple parents. Canonical routing keeps the active
55
+ * section anchored to the first path segment so the sidebar select never drifts.
56
+ *
57
+ * @param pathname - Current browser pathname used to mark the active route.
58
+ */
59
+ /**
60
+ * Reads the typed detail payload from a DOM event.
61
+ *
62
+ * @param e - DOM event carrying the custom payload.
63
+ * @returns The event detail payload.
64
+ */
65
+ const eDetail = (e) => e.detail;
66
+ /**
67
+ * Handles latest content.
68
+ *
69
+ * @param content - Docs content used to derive the sidebar structure.
70
+ */
71
+ const latestContent = (content) => {
72
+ if (typeof content === 'string')
73
+ return content;
74
+ return Array.isArray(content) ? currLeafSrc(content, 'sidebar.latestContent') : '';
75
+ };
76
+ /*//////////////////////////////////////////////////
77
+ FUNCTIONS
78
+ //////////////////////////////////////////////////*/
79
+ /**
80
+ * Handles archive.
81
+ *
82
+ * @param v - Paths input supplied to archive's operation.
83
+ * @param r - Root dir input supplied to archive's operation.
84
+ * @param f - Filename base input supplied to archive's operation.
85
+ * @param o - Opts input supplied to archive's operation.
86
+ * @param d - Callback invoked for progress.
87
+ * @param n - Node ids input supplied to archive's operation.
88
+ */
89
+ const SidebarComponents = {};
90
+ /**
91
+ * RENDER TRIPWIRE
92
+ * A diagnostic tool to catch and analyze React infinite loops.
93
+ *
94
+ * @param componentName - Component name input supplied to use render tripwire's operation.
95
+ * @param trackedVars - Tracked vars input supplied to use render tripwire's operation.
96
+ */
97
+ /*//////////////////////////////////////////////////
98
+ COMPONENTS
99
+ //////////////////////////////////////////////////*/
100
+ /*
101
+ * Dialog component for selecting and managing all attachments across a section tree.
102
+ *
103
+ * @param props - Active attachment target, state setter, disabled state, and Docs tree for browsing and managing related assets.
104
+ * @param tgt - The specific target node (Leaf, Group, or Section) receiving the attachment modifications.
105
+ * @param setTgt - State dispatcher to clear or update the active target boundary, closing the dialog.
106
+ * @param disabled - Master lock preventing interactions while network mutations or animations are active.
107
+ * @param tree - Tree input supplied to manage attchs dialog's operation.
108
+ *
109
+ * @return The interactive modal overlay containing the attachment dashboard.
110
+ *
111
+ * @remarks
112
+ * Provides a unified interface for uploading raw media, scraping external web links, linking YouTube videos,
113
+ * and directly associating existing or new internal documentation pages as relational attachments.
114
+ */
115
+ SidebarComponents.PromptDialog = function PromptDialog({ state: s, setState: setS, disabled, }) {
116
+ if (!s)
117
+ return null;
118
+ return (_jsx(Dialog, { open: s.open, onOpenChange: (o) => {
119
+ if (!o) {
120
+ s.onCancel?.();
121
+ setS(null);
122
+ }
123
+ }, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: s.title }), _jsx(DialogDescription, { children: s.description || `Enter a new ${s.label.toLowerCase()}.` })] }), _jsx("div", { className: "py-4", children: _jsx(Input, { autoFocus: true, "aria-label": s.label, value: s.value, onChange: (e) => {
124
+ setS({ ...s, value: e.target.value });
125
+ }, className: "w-full focus:ring-0", disabled: disabled, onKeyDown: (e) => {
126
+ if (e.key === 'Enter') {
127
+ e.preventDefault();
128
+ if (s.value.trim()) {
129
+ s.onSave(s.value.trim());
130
+ setS(null);
131
+ }
132
+ }
133
+ } }) }), _jsx(DialogFooter, { children: _jsx(Button, { disabled: disabled || !s.value.trim(), onClick: () => {
134
+ if (s.value.trim()) {
135
+ s.onSave(s.value.trim());
136
+ setS(null);
137
+ }
138
+ }, children: "Save" }) })] }) }));
139
+ };
140
+ /*
141
+ * Renders the delete dialog component.
142
+ *
143
+ * @param props - The selected deletion target, state setter, confirmation callback, and disabled state for the delete confirmation.
144
+ * @param setTgt - Clears or updates the active target.
145
+ * @param tgt - Tgt input supplied to delete dialog's operation.
146
+ * @param disabled - Disabled state controlling whether delete dialog accepts interaction.
147
+ * @param onConfirm - Callback invoked for confirm.
148
+ *
149
+ * @return The delete dialog or nothing when no target is selected.
150
+ *
151
+ * @remarks Renders the delete confirmation dialog for sidebar content.
152
+ */
153
+ SidebarComponents.DeleteDialog = function DeleteDialog({ tgt, setTgt, onConfirm, disabled, }) {
154
+ if (!tgt)
155
+ return null;
156
+ return (_jsx(Dialog, { open: !!tgt, onOpenChange: (o) => {
157
+ if (!o)
158
+ setTgt(null);
159
+ }, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: ["Delete ", tgt.kind === 'leaf' ? 'page' : tgt.kind === 'branch' ? 'group' : 'section', "?"] }), _jsxs(DialogDescription, { children: ["Delete ", _jsx("code", { children: tgt.title || tgt.path }), ' ', tgt.kind !== 'leaf' ? ' and its nested docs.' : '.', " This action cannot be undone."] })] }), _jsx(DialogFooter, { children: _jsx(Button, { variant: "destructive", disabled: disabled, onClick: () => {
160
+ onConfirm();
161
+ }, children: "Delete" }) })] }) }));
162
+ };
163
+ /**
164
+ * Renders the top collapsed header boundary on mobile-view structurally isolating context safely cleanly.
165
+ *
166
+ * @return {JSX.Element} Visual mobile heading frame.
167
+ */
168
+ /**
169
+ * Main sidebar controller connecting context providers natively driving application visual trees.
170
+ *
171
+ * @param {object} props - Input definitions matching specific nav tree routes.
172
+ * @param docs - Docs input supplied to nav's operation.
173
+ * @param pathname - Pathname input supplied to nav's operation.
174
+ * @param permission - Permission input supplied to nav's operation.
175
+ * @param userData - user record supplied to nav.
176
+ *
177
+ * @return {JSX.Element} Fully formatted UI sidebar assembly correctly binding handlers.
178
+ */
179
+ export default (function Nav({ docs: items, pathname, permission, userData, siteTitle = 'Terra Symposium', siteDescription, homePath = '/', ...props }) {
180
+ // STATES
181
+ const leafTitle = useAtom($leafTitle);
182
+ const curMode = useAtom($mode);
183
+ const transitioning = useAtom($transition);
184
+ const [creating, setCreating] = useState(false);
185
+ const [loading, setLoading] = useState(false);
186
+ const [drag, setDrag] = useState(null);
187
+ const [dState, setDState] = useState(null);
188
+ const [hovered, setHovered] = useState(null);
189
+ const [cPathname, setCPathname] = useState(() => route(pathname || '').pathname);
190
+ const urlIds = useMemo(() => route(cPathname), [cPathname]);
191
+ const [viewedSecId, setViewedSecId] = useState(() => route(pathname || '').sectionId || null);
192
+ const [sectionOpen, setSectionOpen] = useState(false);
193
+ const [tree, setTree] = useState(items);
194
+ const prevTree = useRef(items);
195
+ const [selLeaves, setSelLeaves] = useState([]);
196
+ const [lastSel, setLastSel] = useState(null);
197
+ // DIALOG STATES
198
+ const [manageAttTgt, setManageAttTgt] = useState(null);
199
+ const [exportTgt, setExportTgt] = useState(null);
200
+ const [assetTgt, setAssetTgt] = useState(null);
201
+ const [assetDialogOpen, setAssetDialogOpen] = useState(false);
202
+ const [assetBusy, setAssetBusy] = useState(false);
203
+ const [assetComponent, setAssetComponent] = useState(repoComponents.find((c) => c.name !== 'Leaf' && c.name !== 'Visualize')?.name ??
204
+ repoComponents[0]?.name ??
205
+ '');
206
+ const [hueDlg, setHueDlg] = useState(null);
207
+ const [inputDlg, setInputDlg] = useState(null);
208
+ const [delTgt, setDelTgt] = useState(null);
209
+ // INJECT TRIPWIRE TO CATCH STATE THRASHING
210
+ useRenderTripwire('Nav', {
211
+ curMode,
212
+ transitioning,
213
+ creating,
214
+ loading,
215
+ drag,
216
+ dState,
217
+ hovered,
218
+ cPathname,
219
+ urlSectionId: urlIds.sectionId,
220
+ viewedSecId,
221
+ sectionOpen,
222
+ treeHash: tree.length,
223
+ selLeavesCount: selLeaves.length,
224
+ lastSel,
225
+ manageAttTgtScope: manageAttTgt?.scope,
226
+ exportTargetPresent: !!exportTgt,
227
+ assetTargetPresent: !!assetTgt,
228
+ hueDlgOpen: hueDlg?.open,
229
+ inputDlgOpen: inputDlg?.open,
230
+ delTargetPresent: !!delTgt,
231
+ });
232
+ // Keep both the active tree route and section selector aligned with host
233
+ // navigation. Repository adapters can route every page through `/#id`, so
234
+ // parsing the cached cPathname can temporarily resolve the previous section.
235
+ // Resolve the incoming pathname itself before updating both pieces of state.
236
+ useEffect(() => {
237
+ const currentRoute = route(pathname || '');
238
+ setCPathname(currentRoute.pathname);
239
+ if (currentRoute.sectionId)
240
+ setViewedSecId(currentRoute.sectionId);
241
+ }, [pathname]);
242
+ const sects = useMemo(() => {
243
+ let s = Array.isArray(tree) ? tree.filter((d) => d.type === 'branch') : [];
244
+ // 1. Deduplicate by origName to prevent React key collisions and redundant entries
245
+ const uniqueMap = new Map();
246
+ s.forEach((n) => {
247
+ if (!uniqueMap.has(n.origName))
248
+ uniqueMap.set(n.origName, n);
249
+ });
250
+ s = Array.from(uniqueMap.values());
251
+ // 2. Filter out top-level nodes that are actually children of another top-level node.
252
+ // (This happens if the API returns explicit warrants for both a Section and its inner Group).
253
+ const nestedBranchIds = new Set();
254
+ s.forEach((n) => {
255
+ if (n.children)
256
+ (function walk(children) {
257
+ children.forEach((c) => {
258
+ if (c.type === 'branch') {
259
+ nestedBranchIds.add(c.origName);
260
+ if (c.children)
261
+ walk(c.children);
262
+ }
263
+ });
264
+ })(n.children);
265
+ });
266
+ s = s.filter((n) => !nestedBranchIds.has(n.origName));
267
+ // prettier-ignore
268
+ if ( /**
269
+ * SIMULATED SECTION WRAPPER
270
+ *
271
+ * If a user accesses a group directly (e.g., via granular permission /docs/{groupId}/{leafId}),
272
+ * the nav tree will return Groups as the top-level branches instead of Sections.
273
+ * The sidebar structurally expects Sections at the top level. We intercept this and wrap
274
+ * the Groups in a simulated "Shared Context" Section to render the tree seamlessly.
275
+ */(s.length > 0 && s.every(b => b.children?.every(c => c.type === 'leaf'))) && s[0]?.origName !== urlIds.sectionId)
276
+ s = [{ type: 'branch', origName: urlIds.sectionId, permission: 'read', simulated: true, title: s[0]?.title || 'Shared Context', url: docsPath(urlIds.sectionId), children: s }];
277
+ // prettier-ignore
278
+ if (s.length === 0 && permission === 'write')
279
+ s.push({ type: 'branch', origName: 'new-section', permission: 'read', simulated: true, url: docsPath('new-section'), children: [{ type: 'leaf', origName: 'index', path: 'index.mdx', url: docsRootPath(), permission: 'read', title: 'Untitled', fileType: 'mdx' }] });
280
+ return s;
281
+ }, [tree, permission, urlIds.sectionId]);
282
+ const sectsMap = useMemo(() => {
283
+ const map = new Map();
284
+ for (const s of sects)
285
+ map.set(s.origName, s);
286
+ return map;
287
+ }, [sects]);
288
+ const aViewed = useMemo(() => {
289
+ if (viewedSecId) {
290
+ const match = sectsMap.get(viewedSecId);
291
+ if (match)
292
+ return match;
293
+ }
294
+ if (urlIds.sectionId) {
295
+ const fallback = sectsMap.get(urlIds.sectionId);
296
+ if (fallback)
297
+ return fallback;
298
+ }
299
+ return sects[0];
300
+ }, [sects, sectsMap, viewedSecId, urlIds.sectionId]);
301
+ const children = useMemo(() => {
302
+ return aViewed?.type === 'branch' ? aViewed.children : [];
303
+ }, [aViewed]);
304
+ // INIT / MOUNT
305
+ useEffect(() => {
306
+ if (JSON.stringify(items) !== JSON.stringify(prevTree.current)) {
307
+ setTree(items);
308
+ prevTree.current = items;
309
+ }
310
+ }, [items]);
311
+ const refreshTree = useCallback(async () => {
312
+ try {
313
+ const { data, error: err } = (await actions.read.doc.list({
314
+ type: 'nav',
315
+ pathname: docsRootPath(),
316
+ full: true,
317
+ }));
318
+ if (!err && Array.isArray(data) && data.length !== 0)
319
+ setTree(data);
320
+ }
321
+ catch (err) {
322
+ console.error('[DEBUG:Sidebar] refreshTree err: ', err);
323
+ }
324
+ }, []);
325
+ useEffect(() => {
326
+ /*
327
+ * Handles update sidebar node title.
328
+ *
329
+ * @param nodes - Sidebar nodes containing the document to rename.
330
+ * @param targetPath - Path of the document whose title should change.
331
+ * @param newTitle - New title assigned to the matching document.
332
+ */
333
+ if (leafTitle?.path)
334
+ setTree((nodes) => {
335
+ /** Normalize full storage paths before matching a local title update. */
336
+ const cPath = (value) => value
337
+ .replace(/\\/g, '/')
338
+ .split(/[?#]/, 1)[0]
339
+ .replace(TerraQualityRegex.REGEX_DRAFTS_REGEX(), '')
340
+ .replace(TerraQualityRegex.REGEX_MD_MDX_PDF_I_REGEX(), '')
341
+ .replace(/^\/+|\/+$/g, '');
342
+ const targetPath = cPath(leafTitle.path);
343
+ const targetBasename = targetPath.split('/').at(-1)?.toLowerCase() ?? '';
344
+ const countBasename = (items) => items.reduce((count, item) => {
345
+ if (item.type === 'leaf') {
346
+ const basename = cPath(item.path || '')
347
+ .split('/')
348
+ .at(-1)
349
+ ?.toLowerCase();
350
+ return count + Number(basename === targetBasename);
351
+ }
352
+ return count + countBasename(item.children ?? []);
353
+ }, 0);
354
+ // Many repository documents are named index.md. A basename fallback
355
+ // would rename every such leaf, so only allow it for a unique filename.
356
+ const canMatchBasename = targetBasename !== 'index' && targetBasename !== '' && countBasename(nodes) === 1;
357
+ const update = (items) => items.map((node) => {
358
+ const nodePath = node.type === 'leaf' ? node.path || '' : '';
359
+ const normalizedNodePath = cPath(nodePath);
360
+ if (node.type === 'leaf' &&
361
+ (nodePath === leafTitle.path ||
362
+ node.origName === leafTitle.path ||
363
+ normalizedNodePath === targetPath ||
364
+ (canMatchBasename &&
365
+ normalizedNodePath.split('/').at(-1)?.toLowerCase() === targetBasename))) {
366
+ return { ...node, title: leafTitle.title };
367
+ }
368
+ if (node.type === 'branch' && node.children)
369
+ return { ...node, children: update(node.children) };
370
+ return node;
371
+ });
372
+ return update(nodes);
373
+ });
374
+ }, [leafTitle]);
375
+ useEffect(() => {
376
+ /**
377
+ * Handles rename event.
378
+ *
379
+ * @param e - Rename event carrying the updated document path.
380
+ */
381
+ const ES = [
382
+ {
383
+ handler: (e) => {
384
+ const d = eDetail(e);
385
+ if (!d?.path || !d.nfilepath)
386
+ return;
387
+ createTrace('DOCS:shared', isDevOrigin(globalThis.location?.origin ?? ''))('rename.start', { next: d.nfilepath, previous: d.path });
388
+ setTree((current) => {
389
+ const renamed = [];
390
+ const pending = [
391
+ { source: current, target: renamed, index: 0 },
392
+ ];
393
+ while (pending.length > 0) {
394
+ const frame = pending[pending.length - 1];
395
+ if (frame.index >= frame.source.length) {
396
+ pending.pop();
397
+ continue;
398
+ }
399
+ const node = frame.source[frame.index++];
400
+ if (node.type === 'leaf' && node.path === d.path) {
401
+ const slug = d.nfilepath
402
+ .replace(TerraQualityRegex.REGEX_PATTERN_REGEX_6(), '')
403
+ .replace(FILES.markdown, '')
404
+ .replace(TerraQualityRegex.REGEX_INDEX_I_REGEX(), '');
405
+ frame.target.push({
406
+ ...node,
407
+ path: d.nfilepath,
408
+ title: d.title ?? node.title,
409
+ url: docsPath(slug),
410
+ });
411
+ continue;
412
+ }
413
+ if (node.type === 'branch') {
414
+ const children = [];
415
+ frame.target.push({ ...node, children });
416
+ pending.push({ source: node.children ?? [], target: children, index: 0 });
417
+ continue;
418
+ }
419
+ frame.target.push(node);
420
+ }
421
+ return renamed;
422
+ });
423
+ if (d.isActive)
424
+ setCPathname(route(d.pathname).pathname);
425
+ },
426
+ type: 'docs:rename',
427
+ },
428
+ {
429
+ handler: (e) => {
430
+ const d = eDetail(e);
431
+ if (d?.url || d?.pathname)
432
+ setCPathname(route(d.url || d.pathname || '').pathname);
433
+ },
434
+ type: 'docs:navigate',
435
+ },
436
+ ];
437
+ ES.forEach(({ type: t, handler: h }) => {
438
+ document.addEventListener(t, h);
439
+ });
440
+ return () => {
441
+ ES.forEach(({ type: t, handler: h }) => {
442
+ document.removeEventListener(t, h);
443
+ });
444
+ };
445
+ }, []);
446
+ const findActiveLeaf = useCallback((v, t) => {
447
+ for (const n of v) {
448
+ if (n.type === 'leaf' && n.url === t)
449
+ return n;
450
+ if (n.type === 'branch' && n.children) {
451
+ const found = findActiveLeaf(n.children, t);
452
+ if (found)
453
+ return found;
454
+ }
455
+ }
456
+ return null;
457
+ }, []);
458
+ // MULTI-SELECT HANDLERS
459
+ const handleSelect = useCallback((v, i, r) => {
460
+ setSelLeaves((s) => {
461
+ if (r) {
462
+ const anchor = lastSel || findActiveLeaf(tree, cPathname)?.path;
463
+ if (anchor) {
464
+ const allLeaves = [];
465
+ /*
466
+ * Handles walk.
467
+ *
468
+ * @param nodes - Sidebar nodes traversed while collecting leaf paths.
469
+ */
470
+ (function walk(nodes) {
471
+ nodes.forEach((n) => {
472
+ if (n.type === 'leaf' && n.path)
473
+ allLeaves.push(n.path);
474
+ if (n.type === 'branch' && n.children)
475
+ walk(n.children);
476
+ });
477
+ })(tree);
478
+ const i1 = allLeaves.indexOf(anchor);
479
+ const i2 = allLeaves.indexOf(v);
480
+ if (i1 !== -1 && i2 !== -1)
481
+ return Array.from(new Set([
482
+ ...(i ? s : []),
483
+ ...allLeaves.slice(Math.min(i1, i2), Math.max(i1, i2) + 1),
484
+ ]));
485
+ }
486
+ }
487
+ if (i) {
488
+ setLastSel(v);
489
+ if (s.includes(v))
490
+ return s.filter((p) => p !== v);
491
+ return [...s, v];
492
+ }
493
+ setLastSel(v);
494
+ return [v];
495
+ });
496
+ }, [tree, lastSel, cPathname, findActiveLeaf]);
497
+ const clearSelection = useCallback(() => {
498
+ setSelLeaves([]);
499
+ setLastSel(null);
500
+ }, []);
501
+ const mergeLeaves = useCallback((v) => {
502
+ const leafOrder = new Map();
503
+ (function walk(nodes, order = 0) {
504
+ for (const node of nodes) {
505
+ if (node.type === 'leaf' && node.path)
506
+ leafOrder.set(node.path, order++);
507
+ if (node.type === 'branch' && node.children)
508
+ order = walk(node.children, order);
509
+ }
510
+ return order;
511
+ })(tree);
512
+ const orderedPaths = Array.from(new Set(v)).sort((a, b) => (leafOrder.get(a) ?? Number.MAX_SAFE_INTEGER) -
513
+ (leafOrder.get(b) ?? Number.MAX_SAFE_INTEGER));
514
+ if (orderedPaths.length < 2)
515
+ return;
516
+ setInputDlg({
517
+ open: true,
518
+ title: 'Merge Pages',
519
+ label: 'New page title',
520
+ value: 'Merged Page',
521
+ onCancel: () => { },
522
+ onSave: (nTitle) => {
523
+ // prettier-ignore
524
+ void runMutation(async () => {
525
+ try {
526
+ const [firstPath, ...restPaths] = orderedPaths;
527
+ if (!firstPath)
528
+ throw new Error('Not enough valid documents to merge');
529
+ setTree(v => {
530
+ /*
531
+ * Handles prune.
532
+ *
533
+ * @param items - Sidebar items being pruned from the tree.
534
+ */
535
+ return (function prune(items) {
536
+ const n = [];
537
+ for (const node of items) {
538
+ if (node.type === 'leaf') {
539
+ if (!node.path || new Set(restPaths).has(node.path))
540
+ continue;
541
+ n.push(node.path === firstPath ? { ...node, title: nTitle } : node);
542
+ continue;
543
+ }
544
+ if (!node.children) {
545
+ n.push(node);
546
+ continue;
547
+ }
548
+ const children = prune(node.children);
549
+ if (children.length > 0)
550
+ n.push({ ...node, children });
551
+ }
552
+ return n;
553
+ })(v);
554
+ });
555
+ const pages = (await Promise.all(orderedPaths.map(p => actions.read.doc.get({ path: p }))))
556
+ .map((r, i) => ({ path: orderedPaths[i], doc: r?.data }))
557
+ .filter((e) => Boolean(e.doc));
558
+ if (pages.length < 2)
559
+ throw new Error('Not enough valid documents to merge');
560
+ const hoisted = new Set();
561
+ const mergedContent = (hoisted.size > 0 ? Array.from(hoisted).join('\n') + '\n\n' : '') + (pages.map(({ doc: d }) => {
562
+ let raw = (typeof d.source === 'string' ? d.source : '') || latestContent(d.content) || '';
563
+ // extract standard imports securely without collapsing body blocks
564
+ raw = raw.replace(/^import\s+[^;]+;/gm, m => {
565
+ hoisted.add(m.trim());
566
+ return '';
567
+ });
568
+ // extract generated MDX exports targeting typical runtime const outputs
569
+ raw = raw.replace(/^export\s+(const|let|var|type|interface)\s+[^;]+;/gm, m => {
570
+ hoisted.add(m.trim());
571
+ return '';
572
+ });
573
+ return `## ${d.title || 'Untitled'}\n\n${raw.trim()}`;
574
+ })).join('\n\n');
575
+ const mergedDesc = pages.map(({ doc: d }) => d.description).filter(Boolean).join(' ').substring(0, 500);
576
+ const { data: nDoc, error: createErr } = (await actions.write.doc.editor({ path: firstPath, title: nTitle, description: mergedDesc, source: mergedContent }));
577
+ if (createErr || !nDoc)
578
+ throw createErr || new Error('Failed to merge doc');
579
+ const { error: srcErr } = await actions.write.doc.retargetSources({ sourceIds: restPaths, targetId: nDoc.path || firstPath });
580
+ if (srcErr)
581
+ throw srcErr;
582
+ // pass the raw path string straight out of the selection array to the RM action to safely hit Sanity identifiers without verifyWrite injecting `.mdx`
583
+ for (const p of restPaths) {
584
+ if ((TerraQualityRegex.REGEX_INDEX_MD_MDX_I_REGEX().test(p)))
585
+ await actions.write.doc.rm({ path: dirname(p), type: 'folder' });
586
+ else
587
+ await actions.write.doc.rm({ path: p, assets: false, type: 'doc' });
588
+ }
589
+ setSelLeaves([]);
590
+ setLastSel(null);
591
+ const tgtRoute = nDoc.pathname || docsPath(dirname(firstPath).toLowerCase());
592
+ memoryDrafts.set(tgtRoute, { source: (typeof nDoc.source === 'string' ? nDoc.source : '') || latestContent(nDoc.content) || '', draft: { content: Array.isArray(nDoc.content) ? nDoc.content : [], description: nDoc.description || '', path: nDoc.path || firstPath, title: nDoc.title || nTitle }, metadata: nDoc });
593
+ $unsavedDrafts.setKey(tgtRoute, false);
594
+ const tgtUrl = new URL(tgtRoute, window.location.origin);
595
+ tgtUrl.searchParams.set('mode', 'edit');
596
+ window.history.pushState(null, '', tgtUrl.toString());
597
+ document.dispatchEvent(new CustomEvent('docs:navigate', { detail: { url: tgtRoute, pathname: tgtRoute, path: nDoc.path || firstPath, title: nDoc.title || nTitle, description: mergedDesc, source: mergedContent, content: Array.isArray(nDoc.content) ? nDoc.content : undefined, compiledMDX: '' } }));
598
+ toast.success('Pages merged successfully.');
599
+ }
600
+ catch (err) {
601
+ setTree(JSON.parse(JSON.stringify(tree)));
602
+ throw err;
603
+ }
604
+ }, 'Failed to merge pages.', () => { setLoading(true); }, () => { setLoading(false); });
605
+ },
606
+ });
607
+ }, [tree]);
608
+ const addSection = useCallback((o) => {
609
+ if ($transition.get())
610
+ return;
611
+ setInputDlg({
612
+ open: true,
613
+ title: o?.title || 'Add Section',
614
+ description: o?.description,
615
+ label: 'Section name',
616
+ value: 'Untitled Section',
617
+ onCancel: () => { },
618
+ onSave: (name) => {
619
+ setInputDlg(null);
620
+ setCreating(true);
621
+ (async () => {
622
+ // prettier-ignore
623
+ try {
624
+ const { data: sNameRes } = await actions.read.util.node({ op: 'name', val: name });
625
+ const tSectId = `temp_s_${Date.now()}`;
626
+ const tGrpId = `temp_g_${Date.now()}`;
627
+ const tLeafId = `temp_l_${Date.now()}`;
628
+ const dPath = `${(sNameRes || 'untitled')}/general/untitled`;
629
+ const url = buildRoute(tSectId, tGrpId, tLeafId);
630
+ const sectUrl = docsPath(tSectId);
631
+ setTree(c => {
632
+ const nTree = JSON.parse(JSON.stringify(c));
633
+ if (!nTree.find(n => n.type === 'branch' && 'url' in n && n.url === sectUrl))
634
+ nTree.push({
635
+ type: 'branch', origName: tSectId, permission: 'write', title: name, url: sectUrl,
636
+ children: [{
637
+ type: 'branch', origName: tGrpId, permission: 'write', title: 'General', url: buildRoute(tSectId, tGrpId),
638
+ children: [{ type: 'leaf', fileType: 'mdx', origName: tLeafId, path: dPath, permission: 'write', title: 'Untitled', description: '', url, source: '' }],
639
+ }],
640
+ firstLeafUrl: url, hue: getHue(name),
641
+ });
642
+ return nTree;
643
+ });
644
+ memoryDrafts.set(url, { source: '', draft: { content: [], description: '', path: dPath, title: 'Untitled' }, metadata: { path: dPath, title: 'Untitled', description: '', pathname: url } });
645
+ $unsavedDrafts.setKey(url, false);
646
+ const tgtUrl = new URL(url, window.location.origin);
647
+ tgtUrl.searchParams.set('mode', 'edit');
648
+ window.history.pushState(null, '', tgtUrl.toString());
649
+ document.dispatchEvent(new CustomEvent('docs:navigate', { detail: { url: url, pathname: url, path: dPath, title: 'Untitled', description: '', source: '', content: [], compiledMDX: '' } }));
650
+ const { data, error } = await actions.write.doc.createSection({ title: name });
651
+ if (error || !data)
652
+ throw new Error(error?.message || 'Failed to create section.');
653
+ setTimeout(() => {
654
+ void refreshTree();
655
+ }, 2500);
656
+ }
657
+ catch (err) {
658
+ console.error('[addSection] Creation failed:', err);
659
+ toast.error(err instanceof Error ? err.message : 'Failed to create section.');
660
+ void refreshTree();
661
+ }
662
+ finally {
663
+ setCreating(false);
664
+ }
665
+ })();
666
+ },
667
+ });
668
+ }, [refreshTree]);
669
+ const uploadAsLeaf = useCallback(async (f, t) => {
670
+ if ($transition.get() || !f || f.length === 0)
671
+ return;
672
+ runMutation(async () => {
673
+ const dir = dirname(t);
674
+ for (let i = 0; i < f.length; i++) {
675
+ const file = f[i];
676
+ if (!file || !TerraQualityRegex.REGEX_MD_MDX_I_REGEX().test(file.name)) {
677
+ toast.error(`File ${file?.name} must be a markdown document to be a page.`);
678
+ continue;
679
+ }
680
+ const baseName = sanitizeName(file.name.replace(TerraQualityRegex.REGEX_I_REGEX(), '')) || 'untitled';
681
+ const { error: wErr } = await actions.write.doc.editor({
682
+ path: `${dir && dir !== '.' ? `${dir}/` : ''}${baseName}`,
683
+ title: baseName.replace(TerraQualityRegex.REGEX_G_REGEX_2(), ' '),
684
+ source: await file.text(),
685
+ });
686
+ if (wErr)
687
+ throw wErr;
688
+ }
689
+ await refreshTree();
690
+ toast.success('Pages uploaded successfully.');
691
+ }, 'Failed to upload as page.', () => {
692
+ setLoading(true);
693
+ }, () => {
694
+ setLoading(false);
695
+ });
696
+ }, [refreshTree]);
697
+ const triggerRenameSection = useCallback((t) => {
698
+ const cName = t.type === 'branch' ? t.origName : '';
699
+ const currTitle = cTitle(toNodeLabel(t.title || cName)) || cName;
700
+ setInputDlg({
701
+ open: true,
702
+ title: 'Rename Section',
703
+ label: 'Section name',
704
+ value: currTitle,
705
+ onCancel: () => { },
706
+ onSave: (nTitle) => {
707
+ if ($transition.get() || t.type !== 'branch')
708
+ return;
709
+ if (!nTitle || nTitle === currTitle)
710
+ return;
711
+ runMutation(async () => {
712
+ const { error: err } = await actions.write.doc.retitle({
713
+ id: t.origName,
714
+ title: nTitle,
715
+ });
716
+ if (err)
717
+ throw err;
718
+ await refreshTree();
719
+ }, 'Failed to process rename.', () => {
720
+ setLoading(true);
721
+ }, () => {
722
+ setLoading(false);
723
+ });
724
+ },
725
+ });
726
+ }, [refreshTree]);
727
+ const SidebarActions = {
728
+ saveHue: useCallback(() => {
729
+ if ($transition.get() || !hueDlg?.section || hueDlg.section.type !== 'branch')
730
+ return;
731
+ runMutation(async () => {
732
+ const tgtSectId = hueDlg.section.origName;
733
+ // Apply hue mutation to Sanity
734
+ const { error: err } = await actions.write.doc.hue({ id: tgtSectId, hue: hueDlg.hue });
735
+ if (err)
736
+ throw err;
737
+ // 1. Optimistically update our local tree state so the sidebar dot updates immediately
738
+ setTree((p) => {
739
+ const n = [...p];
740
+ const idx = n.findIndex((s) => s.origName === tgtSectId);
741
+ const section = n[idx];
742
+ if (idx !== -1 && section?.type === 'branch')
743
+ n[idx] = { ...section, hue: hueDlg.hue };
744
+ return n;
745
+ });
746
+ setHueDlg(null);
747
+ // 2. Wait 2.5 seconds to allow the CDN to index the hue change so it persists properly across page loads.
748
+ await new Promise((r) => setTimeout(r, 2500));
749
+ // 3. Refresh tree so subsequent queries use the correct backend hue.
750
+ await refreshTree();
751
+ // 4. Hot-swap the CSS variables robustly
752
+ try {
753
+ const html = await (await fetch(window.location.href)).text();
754
+ const styleMatch = html.match(/<style[^>]*>([\s\S]*?--primary-1:[\s\S]*?)<\/style>/i);
755
+ if (styleMatch) {
756
+ let styleEl = document.getElementById('terra-dynamic-hue');
757
+ if (!styleEl) {
758
+ styleEl = document.createElement('style');
759
+ styleEl.id = 'terra-dynamic-hue';
760
+ document.head.appendChild(styleEl);
761
+ }
762
+ styleEl.innerHTML = styleMatch[1] || '';
763
+ document.dispatchEvent(new CustomEvent('docs:hue-change'));
764
+ }
765
+ else {
766
+ const inlineMatch = html.match(/<[^>]+style=["']([^"']*?--primary-1:[^"']*?)["']/i);
767
+ if (inlineMatch)
768
+ document.documentElement.style.cssText = inlineMatch[1] || '';
769
+ else
770
+ window.location.reload();
771
+ }
772
+ }
773
+ catch (_e) {
774
+ window.location.reload();
775
+ }
776
+ }, 'Failed to update color.', () => {
777
+ setLoading(true);
778
+ }, () => {
779
+ setLoading(false);
780
+ });
781
+ }, [hueDlg, refreshTree]),
782
+ };
783
+ const rmBranch = useCallback(async (f, _bPath, s) => {
784
+ const pNorm = dirname(f) === '.' ? '' : dirname(f);
785
+ let prevTree = [];
786
+ setTree((c) => {
787
+ prevTree = c;
788
+ const nTree = JSON.parse(JSON.stringify(c));
789
+ const sibs = getSibs(nTree, pNorm);
790
+ const idx = sibs.findIndex((n) => n.type === 'branch' && [pNorm, n.origName].filter(Boolean).join('/') === f);
791
+ if (idx !== -1)
792
+ sibs.splice(idx, 1);
793
+ return nTree;
794
+ });
795
+ const currPath = cPathname
796
+ .toLowerCase()
797
+ .replace(TerraQualityRegex.REGEX_PATTERN_REGEX_3(), '');
798
+ const currPrefix = docsPath(s)
799
+ .toLowerCase()
800
+ .replace(TerraQualityRegex.REGEX_PATTERN_REGEX_3(), '');
801
+ const nPrefix = docsPath(dirname(s));
802
+ const redirect = currPath !== currPrefix && !currPath.startsWith(`${currPrefix}/`)
803
+ ? null
804
+ : `${nPrefix.replace(TerraQualityRegex.REGEX_PATTERN_REGEX_3(), '')}${currPath.slice(currPrefix.length)}` ||
805
+ nPrefix;
806
+ try {
807
+ const { error: err } = await actions.write.doc.rm({ path: s, type: 'folder' });
808
+ if (err && !err.message?.includes('folder not found'))
809
+ throw err;
810
+ await refreshTree();
811
+ if (redirect && redirect !== cPathname)
812
+ navigate({ href: redirect, mode: 'view' });
813
+ }
814
+ catch (err) {
815
+ setTree(prevTree);
816
+ throw err;
817
+ }
818
+ }, [cPathname, refreshTree]);
819
+ const rmLeaf = useCallback(async (p, b, a) => {
820
+ const isIdx = TerraQualityRegex.REGEX_INDEX_MD_MDX_I_REGEX().test(p);
821
+ const tgtPath = isIdx ? dirname(p) : p;
822
+ const tgtType = isIdx ? 'folder' : 'doc';
823
+ let prevTree = [];
824
+ setTree((c) => {
825
+ prevTree = c;
826
+ const nTree = JSON.parse(JSON.stringify(c));
827
+ const sibs = getSibs(nTree, b);
828
+ const i = sibs.findIndex((n) => (n.type === 'leaf' ? n.path === p : false));
829
+ if (i !== -1)
830
+ sibs.splice(i, 1);
831
+ return nTree;
832
+ });
833
+ try {
834
+ const { error: err } = await actions.write.doc.rm(isIdx ? { path: tgtPath, type: tgtType } : { assets: a, path: tgtPath, type: tgtType });
835
+ if (err && !err.message?.includes('folder not found'))
836
+ throw err;
837
+ await refreshTree();
838
+ if (a)
839
+ navigate({ href: docsPath(dirname(p).replace(/^\.\/?/, '')), mode: 'view' });
840
+ }
841
+ catch (err) {
842
+ setTree(prevTree);
843
+ throw err;
844
+ }
845
+ }, [refreshTree]);
846
+ const openCreate = useCallback((p, v) => {
847
+ if ($transition.get())
848
+ return;
849
+ setInputDlg({
850
+ open: true,
851
+ title: 'Add Page',
852
+ label: 'Page title',
853
+ value: 'Untitled Page',
854
+ onCancel: () => { },
855
+ onSave: (name) => {
856
+ setInputDlg(null);
857
+ setCreating(true);
858
+ (async () => {
859
+ // prettier-ignore
860
+ try {
861
+ const { data: res, error: resErr } = await actions.read.doc.resolvePath({ path: p, title: name });
862
+ if (resErr || !res)
863
+ throw resErr || new Error('Failed to resolve path');
864
+ const dPath = (res).path;
865
+ const tLeafId = `temp_l_${Date.now()}`;
866
+ const sectId = urlIds.sectionId;
867
+ let url = '';
868
+ // safety Fallback for parentId mapping
869
+ let aParentId = v;
870
+ if (typeof window !== 'undefined' && (!aParentId || aParentId === '.' || aParentId === sectId)) {
871
+ try {
872
+ const curr = route(window.location.pathname + window.location.search);
873
+ if (curr.groupId)
874
+ aParentId = curr.groupId;
875
+ else if (curr.sectionId)
876
+ aParentId = curr.sectionId;
877
+ }
878
+ catch {
879
+ // The existing parent remains the safe fallback.
880
+ }
881
+ }
882
+ url = aParentId === sectId ? buildRoute(sectId, undefined, tLeafId) : buildRoute(sectId, aParentId, tLeafId);
883
+ setTree(v => {
884
+ const nTree = JSON.parse(JSON.stringify(v));
885
+ (function insertLeaf(nodes, tgtId) {
886
+ for (const n of nodes) {
887
+ if (n.type === 'branch') {
888
+ if (n.origName === tgtId) {
889
+ if (!n.children)
890
+ n.children = [];
891
+ // prevent duplicate pushes if it re-renders
892
+ if (!n.children.find(c => c.type === 'leaf' && c.url === url))
893
+ n.children.push({ type: 'leaf', fileType: 'mdx', origName: tLeafId, path: dPath, permission: 'write', title: name, description: '', url, source: '' });
894
+ return true;
895
+ }
896
+ if (n.children && insertLeaf(n.children, tgtId))
897
+ return true;
898
+ }
899
+ }
900
+ return false;
901
+ })(nTree, aParentId);
902
+ return nTree;
903
+ });
904
+ memoryDrafts.set(url, { source: '', draft: { content: [], description: '', path: dPath, title: name }, metadata: { path: dPath, title: name, description: '', pathname: url } });
905
+ $unsavedDrafts.setKey(url, false);
906
+ const tgtUrl = new URL(url, window.location.origin);
907
+ tgtUrl.searchParams.set('mode', 'edit');
908
+ window.history.pushState(null, '', tgtUrl.toString());
909
+ document.dispatchEvent(new CustomEvent('docs:navigate', { detail: { url: url, pathname: url, path: dPath, title: name, description: '', source: '', content: [], compiledMDX: '' } }));
910
+ const { data, error: err } = (await actions.write.doc.editor({ source: '', description: '', path: dPath, title: name, parentId: aParentId }));
911
+ if (err || !data)
912
+ throw err || new Error('Failed to create docs page.');
913
+ setTimeout(() => {
914
+ void refreshTree();
915
+ }, 2500);
916
+ }
917
+ catch (err) {
918
+ console.error('[openCreate] Creation failed:', err);
919
+ toast.error('Failed to create docs page.');
920
+ void refreshTree();
921
+ }
922
+ finally {
923
+ setCreating(false);
924
+ }
925
+ })();
926
+ },
927
+ });
928
+ }, [refreshTree, urlIds.sectionId]);
929
+ const addGroup = useCallback((p, s) => {
930
+ if ($transition.get())
931
+ return;
932
+ setInputDlg({
933
+ open: true,
934
+ title: 'Add Group',
935
+ label: 'Group name',
936
+ value: 'Untitled Group',
937
+ onCancel: () => { },
938
+ onSave: (name) => {
939
+ setInputDlg(null);
940
+ setCreating(true);
941
+ (async () => {
942
+ // prettier-ignore
943
+ try {
944
+ const { data: res, error: resErr } = await actions.read.doc.resolvePath({ path: p, title: name });
945
+ if (resErr || !res)
946
+ throw resErr || new Error('Failed to resolve path');
947
+ const dPath = `${((res).dir)}/untitled`;
948
+ const tGrpId = `temp_g_${Date.now()}`;
949
+ const tLeafId = `temp_l_${Date.now()}`;
950
+ const rootId = s || urlIds.sectionId;
951
+ const url = buildRoute(rootId, tGrpId, tLeafId);
952
+ const gUrl = buildRoute(rootId, tGrpId);
953
+ setTree(v => {
954
+ const nTree = JSON.parse(JSON.stringify(v));
955
+ (function insertGroup(nodes, tgtId) {
956
+ for (const n of nodes) {
957
+ if (n.type === 'branch') {
958
+ if (n.origName === tgtId) {
959
+ if (!n.children)
960
+ n.children = [];
961
+ if (!n.children.find(c => c.type === 'branch' && 'url' in c && c.url === gUrl))
962
+ n.children.push({
963
+ type: 'branch', origName: tGrpId, permission: 'write', title: name, url: gUrl,
964
+ children: [{ type: 'leaf', fileType: 'mdx', origName: tLeafId, path: dPath, permission: 'write', title: 'Untitled', description: '', url, source: '' }],
965
+ });
966
+ return true;
967
+ }
968
+ if (n.children && insertGroup(n.children, tgtId))
969
+ return true;
970
+ }
971
+ }
972
+ return false;
973
+ })(nTree, rootId);
974
+ return nTree;
975
+ });
976
+ memoryDrafts.set(url, { source: '', draft: { content: [], description: '', path: dPath, title: 'Untitled' }, metadata: { path: dPath, title: 'Untitled', description: '', pathname: url } });
977
+ $unsavedDrafts.setKey(url, false);
978
+ const tgtUrl = new URL(url, window.location.origin);
979
+ tgtUrl.searchParams.set('mode', 'edit');
980
+ window.history.pushState(null, '', tgtUrl.toString());
981
+ document.dispatchEvent(new CustomEvent('docs:navigate', { detail: { url: url, pathname: url, path: dPath, title: 'Untitled', description: '', source: '', content: [], compiledMDX: '' } }));
982
+ const { data: gData, error: gErr } = await actions.write.doc.createGroup({ title: name, path: gUrl, sectionId: rootId });
983
+ if (gErr || !gData)
984
+ throw gErr || new Error('Failed to create group.');
985
+ const { data, error: err } = (await actions.write.doc.editor({ source: '', description: '', path: dPath, title: 'Untitled', parentId: (typeof gData === 'object' && '_id' in gData && typeof gData._id === 'string' ? gData._id : undefined) }));
986
+ if (err || !data)
987
+ throw err || new Error('Failed to create group leaf.');
988
+ setTimeout(() => {
989
+ void refreshTree();
990
+ }, 2500);
991
+ }
992
+ catch (err) {
993
+ console.error('[addGroup] Creation failed:', err);
994
+ toast.error('Failed to create group.');
995
+ void refreshTree();
996
+ }
997
+ finally {
998
+ setCreating(false);
999
+ }
1000
+ })();
1001
+ },
1002
+ });
1003
+ }, [refreshTree, urlIds.sectionId]);
1004
+ const mvLeaf = useCallback(async ({ path: p, tTarget: tTgt, tpath: v, tPosition: r, }) => {
1005
+ console.warn('[docs:mv-leaf]', { path: p, tTarget: tTgt, tpath: v, tPosition: r });
1006
+ const prevTree = JSON.parse(JSON.stringify(tree));
1007
+ let _nPath = p;
1008
+ try {
1009
+ /**
1010
+ * Handles find parent path.
1011
+ *
1012
+ * @param nodes - Sidebar nodes searched for the target document.
1013
+ * @param tgtPath - Target document path being resolved.
1014
+ * @param currPath - Current traversal path accumulated during the search.
1015
+ */
1016
+ const pPath = (function findParentPath(nodes, tgtPath, currPath = '') {
1017
+ for (const n of nodes) {
1018
+ if (n.type === 'leaf' && n.path === tgtPath)
1019
+ return currPath || '.';
1020
+ if (n.type === 'branch' && n.children) {
1021
+ const found = findParentPath(n.children, tgtPath, currPath ? `${currPath}/${n.origName}` : n.origName);
1022
+ if (found)
1023
+ return found;
1024
+ }
1025
+ }
1026
+ return null;
1027
+ })(tree, p) || '';
1028
+ const isMovingBranch = pPath !== v;
1029
+ const nTree = JSON.parse(JSON.stringify(tree));
1030
+ const oldSibs = getSibs(nTree, pPath);
1031
+ const sIdx = oldSibs.findIndex((n) => (n.type === 'leaf' ? n.path === p : false));
1032
+ let movedNode = null;
1033
+ if (sIdx !== -1)
1034
+ movedNode = oldSibs.splice(sIdx, 1)[0];
1035
+ const tgtSibs = getSibs(nTree, v);
1036
+ let iIdx = tgtSibs.length;
1037
+ if (tTgt) {
1038
+ const tgtIdx = tgtSibs.findIndex((n) => n.type === 'leaf'
1039
+ ? n.path === tTgt
1040
+ : n.type === 'branch' && [v, n.origName].filter(Boolean).join('/') === tTgt);
1041
+ if (tgtIdx !== -1)
1042
+ iIdx = (r ?? 'before') === 'before' ? tgtIdx : tgtIdx + 1;
1043
+ }
1044
+ if (movedNode)
1045
+ tgtSibs.splice(iIdx, 0, movedNode);
1046
+ setTree(nTree);
1047
+ if (isMovingBranch) {
1048
+ const tgtNorm = v === '.' ? '' : v;
1049
+ const folderBacked = TerraQualityRegex.REGEX_INDEX_MD_MDX_I_REGEX().test(p);
1050
+ const leafDirName = folderBacked
1051
+ ? p.split('/').slice(-2)[0]
1052
+ : bName(p, p.match(TerraQualityRegex.REGEX_I_REGEX())?.[0]);
1053
+ const ext = p.match(TerraQualityRegex.REGEX_I_REGEX())?.[0] ?? '.mdx';
1054
+ const nPath = folderBacked
1055
+ ? `${tgtNorm === '.' ? '' : `${tgtNorm}/`}${leafDirName}/index${ext}`
1056
+ : `${tgtNorm === '.' ? '' : `${tgtNorm}/`}${leafDirName}${ext}`;
1057
+ if (p !== nPath) {
1058
+ const { data: docData } = await actions.read.doc.get({ path: p });
1059
+ const { data: movedDoc, error } = await actions.write.doc.commit({
1060
+ cur: p,
1061
+ next: nPath,
1062
+ source: docData &&
1063
+ typeof docData === 'object' &&
1064
+ 'source' in docData &&
1065
+ typeof docData.source === 'string'
1066
+ ? docData.source
1067
+ : '',
1068
+ });
1069
+ _nPath = movedDoc?.path || nPath;
1070
+ if (error) {
1071
+ setTree(prevTree);
1072
+ toast.error(error.message || 'Move failed');
1073
+ notify({ error: new Error(error.message), fallback: 'Failed to move docs page.' });
1074
+ return;
1075
+ }
1076
+ }
1077
+ }
1078
+ if (tgtSibs.length > 0) {
1079
+ const parentIds = v.split('/');
1080
+ const parentId = parentIds[parentIds.length - 1];
1081
+ if (parentId && parentId !== '.') {
1082
+ const { error } = await actions.write.doc.reorder({
1083
+ id: parentId,
1084
+ field:
1085
+ /* Identify whether we are patching a Group or Section natively */ parentIds.length >
1086
+ 1
1087
+ ? 'leaves'
1088
+ : 'groups',
1089
+ items: tgtSibs
1090
+ .filter((s) => s.type === 'leaf')
1091
+ .map((s) => ({ _type: 'reference', _ref: s === movedNode ? _nPath : s.origName })),
1092
+ });
1093
+ if (error)
1094
+ throw error;
1095
+ }
1096
+ }
1097
+ if (isMovingBranch && oldSibs) {
1098
+ const oldParentIds = pPath.split('/');
1099
+ const oldParentId = oldParentIds[oldParentIds.length - 1];
1100
+ if (oldParentId && oldParentId !== '.') {
1101
+ const { error } = await actions.write.doc.reorder({
1102
+ id: oldParentId,
1103
+ field: oldParentIds.length > 1 ? 'leaves' : 'groups',
1104
+ items: oldSibs
1105
+ .filter((s) => s.type === 'leaf')
1106
+ .map((s) => ({ _type: 'reference', _ref: s.origName })),
1107
+ });
1108
+ if (error)
1109
+ throw error;
1110
+ }
1111
+ }
1112
+ await refreshTree();
1113
+ }
1114
+ catch (err) {
1115
+ setTree(prevTree);
1116
+ toast.error(err instanceof Error ? err.message : 'Move failed');
1117
+ notify({
1118
+ error: err instanceof Error ? err : new Error('Move failed'),
1119
+ fallback: 'Failed to move docs page.',
1120
+ });
1121
+ void refreshTree();
1122
+ }
1123
+ }, [tree, refreshTree]);
1124
+ const mvBranch = useCallback(async ({ fPath: f, pPath: p, tpath: t, tPosition: v, tTarget: tTgt, }) => {
1125
+ if (p !== t)
1126
+ return;
1127
+ try {
1128
+ const nTree = JSON.parse(JSON.stringify(tree));
1129
+ const oldSibs = getSibs(nTree, p);
1130
+ const srcIdx = oldSibs.findIndex((n) => n.type === 'branch' ? [p, n.origName].filter(Boolean).join('/') === f : false);
1131
+ let movedNode = null;
1132
+ if (srcIdx !== -1)
1133
+ movedNode = oldSibs.splice(srcIdx, 1)[0];
1134
+ const tgtSibs = getSibs(nTree, t);
1135
+ let iIdx = tgtSibs.length;
1136
+ const tIdx = tgtSibs.findIndex((n) => n.type === 'branch' && [t, n.origName].filter(Boolean).join('/') === tTgt);
1137
+ if (tIdx !== -1)
1138
+ iIdx = (v ?? 'before') === 'before' ? tIdx : tIdx + 1;
1139
+ if (movedNode)
1140
+ tgtSibs.splice(iIdx, 0, movedNode);
1141
+ setTree(nTree);
1142
+ if (tgtSibs.length > 0) {
1143
+ const parentIds = t.split('/');
1144
+ const parentId = parentIds[parentIds.length - 1];
1145
+ if (parentId && parentId !== '.') {
1146
+ const { error } = await actions.write.doc.reorder({
1147
+ id: parentId,
1148
+ field: 'groups',
1149
+ items: tgtSibs
1150
+ .filter((s) => s.type === 'branch')
1151
+ .map((s) => ({ _type: 'reference', _ref: s.origName })),
1152
+ });
1153
+ if (error)
1154
+ throw error;
1155
+ }
1156
+ }
1157
+ await refreshTree();
1158
+ }
1159
+ catch (err) {
1160
+ setTree(JSON.parse(JSON.stringify(tree)));
1161
+ toast.error(err instanceof Error ? err.message : 'Move failed');
1162
+ notify({
1163
+ error: err instanceof Error ? err : new Error('Move failed'),
1164
+ fallback: 'Failed to reorder docs groups.',
1165
+ });
1166
+ void refreshTree();
1167
+ }
1168
+ }, [tree, refreshTree]);
1169
+ const actionDisabled = creating || loading;
1170
+ const assetChoices = useMemo(() => repoComponents
1171
+ .filter((c) => c.name !== 'Leaf' && c.name !== 'Visualize')
1172
+ .map((c) => ({ label: c.name.replace(/([a-z])([A-Z])/g, '$1 $2'), name: c.name })), []);
1173
+ useEffect(() => {
1174
+ if (!assetTgt)
1175
+ return;
1176
+ if (!assetChoices.some((c) => c.name === assetComponent))
1177
+ setAssetComponent(assetChoices[0]?.name ?? '');
1178
+ setAssetDialogOpen(true);
1179
+ }, [assetTgt, assetChoices, assetComponent]);
1180
+ SidebarActions.makeAsset = useCallback(async () => {
1181
+ if (!assetTgt || !assetComponent || assetBusy)
1182
+ return;
1183
+ try {
1184
+ setAssetBusy(true);
1185
+ const { error } = await actions.write.doc.asset({
1186
+ path: assetTgt.path,
1187
+ component: assetComponent,
1188
+ title: assetTgt.title,
1189
+ description: '',
1190
+ });
1191
+ if (error)
1192
+ throw error;
1193
+ setAssetDialogOpen(false);
1194
+ setAssetTgt(null);
1195
+ toast.success('Asset created successfully.');
1196
+ await refreshTree();
1197
+ }
1198
+ catch (err) {
1199
+ console.error('[Sidebar] Failed to convert page to asset:', err);
1200
+ notify({
1201
+ error: err instanceof Error ? err : new Error('Failed to convert page to asset.'),
1202
+ fallback: 'Failed to convert page to asset.',
1203
+ });
1204
+ }
1205
+ finally {
1206
+ setAssetBusy(false);
1207
+ }
1208
+ }, [assetBusy, assetComponent, assetTgt, refreshTree]);
1209
+ SidebarActions.renderSects = useCallback((t) => {
1210
+ const origName = t.type === 'branch' ? t.origName : '';
1211
+ const slugPath = 'url' in t && t.url ? t.url.replace(TerraQualityRegex.REGEX_DOCS_REGEX(), '') : '';
1212
+ const titleStr = cTitle(toNodeLabel(t.title || origName));
1213
+ return [
1214
+ {
1215
+ icon: _jsx(LinkIcon, {}),
1216
+ label: 'Copy link',
1217
+ disabled: actionDisabled,
1218
+ onSelect: () => {
1219
+ void navigator.clipboard.writeText(`${window.location.origin}${'url' in t && t.url ? t.url : ''}`);
1220
+ toast.success('Link copied');
1221
+ },
1222
+ },
1223
+ {
1224
+ icon: _jsx(BoxIcon, {}),
1225
+ label: 'Manage attachments',
1226
+ disabled: actionDisabled,
1227
+ onSelect: () => {
1228
+ setManageAttTgt({
1229
+ path: slugPath,
1230
+ title: titleStr || slugPath,
1231
+ scope: 'section',
1232
+ node: t,
1233
+ });
1234
+ },
1235
+ },
1236
+ {
1237
+ icon: _jsx(DownloadIcon, {}),
1238
+ label: 'Download section',
1239
+ disabled: actionDisabled,
1240
+ onSelect: ((paths, nodeIds) => () => {
1241
+ setExportTgt({
1242
+ paths,
1243
+ rootDir: slugPath,
1244
+ filename: sanitizeName(titleStr || slugPath),
1245
+ title: `${titleStr} docs`,
1246
+ nodeIds,
1247
+ });
1248
+ })(Array.from(new Set([...toPaths(t.type === 'branch' ? t.children : [])])), extractAllNodeIds([t])),
1249
+ },
1250
+ {
1251
+ icon: _jsx(PopOutIcon, {}),
1252
+ label: 'Make asset',
1253
+ disabled: actionDisabled,
1254
+ onSelect: () => {
1255
+ setAssetTgt({ path: slugPath, title: titleStr || slugPath });
1256
+ },
1257
+ },
1258
+ ...(permission === 'write'
1259
+ ? [
1260
+ {
1261
+ disabled: actionDisabled,
1262
+ icon: _jsx(EditIcon, {}),
1263
+ label: 'Rename section',
1264
+ onSelect: () => {
1265
+ triggerRenameSection(t);
1266
+ },
1267
+ },
1268
+ {
1269
+ disabled: actionDisabled,
1270
+ icon: _jsx(ColorIcon, {}),
1271
+ label: 'Change color',
1272
+ onSelect: () => {
1273
+ setHueDlg({
1274
+ open: true,
1275
+ hue: getHue(t.title || slugPath, t.type === 'branch' ? t.hue : undefined),
1276
+ section: t,
1277
+ });
1278
+ },
1279
+ },
1280
+ {
1281
+ destructive: true,
1282
+ disabled: actionDisabled,
1283
+ icon: _jsx(TrashIcon, {}),
1284
+ label: 'Delete section',
1285
+ onSelect: () => {
1286
+ setDelTgt({
1287
+ kind: 'section',
1288
+ path: origName,
1289
+ slugPath,
1290
+ title: titleStr || slugPath,
1291
+ origNode: t,
1292
+ });
1293
+ },
1294
+ },
1295
+ ]
1296
+ : []),
1297
+ ];
1298
+ }, [permission, actionDisabled, triggerRenameSection]);
1299
+ const getTree = useCallback(() => tree, [tree]);
1300
+ // CONTEXT
1301
+ const treeCtx = useMemo(() => ({
1302
+ creating,
1303
+ transitioning,
1304
+ drag,
1305
+ dState,
1306
+ mode: curMode,
1307
+ mvBranch,
1308
+ mvLeaf,
1309
+ pathname: cPathname,
1310
+ refreshTree,
1311
+ shellPermission: permission,
1312
+ openCreate,
1313
+ addGroup,
1314
+ uploadAsLeaf,
1315
+ rmBranch,
1316
+ rmLeaf,
1317
+ setDrag: (d) => {
1318
+ setDrag(d);
1319
+ if (!d)
1320
+ setDState(null);
1321
+ },
1322
+ setDState,
1323
+ setHovered,
1324
+ hovered,
1325
+ setInputDlg,
1326
+ setTree,
1327
+ getTree,
1328
+ findActiveLeaf,
1329
+ setCPathname,
1330
+ selectedLeaves: selLeaves,
1331
+ handleSelect,
1332
+ clearSelection,
1333
+ mergeLeaves,
1334
+ setDelTarget: setDelTgt,
1335
+ setExportTarget: setExportTgt,
1336
+ setManageAttTgt,
1337
+ setAssetTarget: setAssetTgt,
1338
+ }),
1339
+ // prettier-ignore
1340
+ [creating, transitioning, drag, dState, curMode, mvBranch, mvLeaf, cPathname, refreshTree, permission, openCreate, addGroup, uploadAsLeaf, rmBranch, rmLeaf, hovered, selLeaves, handleSelect, clearSelection, mergeLeaves, getTree]);
1341
+ // RENDERS
1342
+ return (_jsx(ErrorBoundary, { name: "Sidebar", fallback: () => (_jsx(Sidebar, { className: "not-prose z-50 overflow-y-auto p-4", children: _jsx(AlertError, { description: "An unexpected error occurred while rendering the sidebar panel. The remaining workspace continues to function.", title: "Sidebar render crash" }) })), children: _jsxs(Sidebar, { ...props, sticky: true, className: "not-prose bg-primary-2 p-2", onClick: () => {
1343
+ // prevent clearing if a dialog is actively open
1344
+ if (inputDlg?.open || hueDlg?.open || delTgt)
1345
+ return;
1346
+ if (selLeaves.length > 0)
1347
+ clearSelection();
1348
+ }, children: [_jsx("style", { dangerouslySetInnerHTML: { __html: ` [data-sidebar="sidebar"], [data-sidebar="sidebar"][data-mobile="true"], [data-mobile="true"] .bg-sidebar, .bg-sidebar { background-color: rgb(var(--primary-2)) !important; } ` } }), _jsx(SharedExportDialog, { target: exportTgt, setTarget: setExportTgt, disabled: loading || transitioning, onExport: (target, options, progress) => archiveDocs(target.paths, target.rootDir, target.filename, options, progress, target.nodeIds || []) }), _jsx(ManageAttachmentsDialog, { tgt: manageAttTgt, setTgt: setManageAttTgt, disabled: loading || transitioning, tree: tree }), _jsx(Dialog, { open: assetDialogOpen, onOpenChange: o => {
1349
+ if (assetBusy)
1350
+ return;
1351
+ setAssetDialogOpen(o);
1352
+ if (!o)
1353
+ setAssetTgt(null);
1354
+ }, children: _jsxs(DialogContent, { className: 'sm:max-w-lg', children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Make Asset" }), _jsx(DialogDescription, { children: "This will replace the page history with one standalone component version." })] }), _jsxs("div", { className: 'space-y-4 py-4', children: [_jsxs("div", { className: 'space-y-1.5', children: [_jsx(Label, { children: "Component" }), _jsxs(Select, { value: assetComponent, onValueChange: setAssetComponent, children: [_jsx(SelectTrigger, { "aria-label": 'Select a component...', children: _jsx(SelectValue, { placeholder: 'Select a component...' }) }), _jsx(SelectContent, { children: assetChoices.map(c => _jsx(SelectItem, { value: c.name, children: c.label }, c.name)) })] })] }), _jsx(AlertError, { title: 'Warning', description: 'Converting this page to an asset erases every existing version except the selected component.' })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: 'ghost', disabled: assetBusy, onClick: () => { setAssetTgt(null); }, children: "Cancel" }), _jsx(Button, { disabled: !assetComponent || assetBusy, loading: assetBusy, onClick: () => void SidebarActions.makeAsset(), children: "Make Asset" })] })] }) }), _jsx(SidebarComponents.PromptDialog, { state: inputDlg, setState: setInputDlg, disabled: loading || transitioning }), _jsx(SidebarComponents.DeleteDialog, { tgt: delTgt, setTgt: setDelTgt, onConfirm: () => {
1355
+ if (!delTgt || transitioning)
1356
+ return;
1357
+ const { kind, origNode, slugPath, path, bPath, active: a } = delTgt;
1358
+ setDelTgt(null);
1359
+ runMutation(async () => {
1360
+ if (kind === 'section' && origNode) {
1361
+ const sectionPath = slugPath;
1362
+ let prev = [];
1363
+ setTree((c) => {
1364
+ prev = c;
1365
+ return c.filter((n) => !(n.type === 'branch' && n.origName === origNode.origName));
1366
+ });
1367
+ const { error: err } = await actions.write.doc.rm({
1368
+ path: sectionPath,
1369
+ type: 'folder',
1370
+ });
1371
+ if (err && !err.message?.includes('folder not found')) {
1372
+ setTree(prev);
1373
+ throw err;
1374
+ }
1375
+ await refreshTree();
1376
+ if (cPathname.toLowerCase().startsWith(docsPath(sectionPath).toLowerCase()))
1377
+ navigate({ href: docsRootPath(), mode: 'view' });
1378
+ }
1379
+ else if (kind === 'branch')
1380
+ await rmBranch(path, bPath, slugPath);
1381
+ else if (kind === 'leaf')
1382
+ await rmLeaf(path, bPath, !!a);
1383
+ }, `Failed to delete ${kind}.`, () => setLoading(true), () => setLoading(false));
1384
+ }, disabled: loading || transitioning }), _jsx(Dialog, { open: hueDlg?.open ?? false, onOpenChange: (o) => {
1385
+ if (loading || transitioning)
1386
+ return;
1387
+ setHueDlg((p) => (p ? { ...p, open: o } : null));
1388
+ }, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Section Color" }), _jsx(DialogDescription, { children: "Adjust the hue for this section to customize its appearance." })] }), _jsx(Slider, { min: 0, max: 360, step: 1, value: [hueDlg?.hue ?? 0], onValueChange: ([v]) => {
1389
+ setHueDlg((p) => (p ? { ...p, hue: v ?? 0 } : null));
1390
+ }, disabled: loading || transitioning, className: "my-6 w-full [&_[data-slot=slider-range]]:bg-[color:var(--slider-color)] [&_[data-slot=slider-thumb]]:border-[color:var(--slider-color)] [&_[data-slot=slider-thumb]]:bg-[color:var(--slider-color)]", style: { '--slider-color': `hsl(${hueDlg?.hue ?? 0} 65% 55%)` } }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "ghost", disabled: loading || transitioning, onClick: () => {
1391
+ if (hueDlg?.section)
1392
+ setHueDlg({
1393
+ ...hueDlg,
1394
+ hue: getHue(hueDlg.section.title ||
1395
+ (hueDlg.section.type === 'branch' ? hueDlg.section.origName : '')),
1396
+ });
1397
+ }, children: "Reset" }), _jsx(Button, { disabled: loading || transitioning, loading: loading, onClick: () => {
1398
+ SidebarActions.saveHue();
1399
+ }, children: "Save" })] })] }) }), _jsxs(SidebarHeader, { className: "print:hidden", "data-docs-navigation": "true", children: [_jsx("a", { className: "font-serif text-2xl hover:italic hover:tracking-tight", href: homePath, children: siteTitle }), siteDescription && _jsx("p", { className: "m-0 mt-1 text-sm text-primary-11", children: siteDescription }), _jsx("div", { className: "mt-2 flex items-center", children: _jsx("div", { className: cn('block min-w-0 flex-1 rounded-md transition-opacity'), children: _jsxs(Select, { disabled: transitioning, open: sectionOpen, onOpenChange: setSectionOpen, value: aViewed ? aViewed.origName : '', onValueChange: async (v) => {
1400
+ if (v === '__add_section__') {
1401
+ setTimeout(() => {
1402
+ addSection();
1403
+ }, 0);
1404
+ return;
1405
+ }
1406
+ if (aViewed?.origName === v)
1407
+ return;
1408
+ setViewedSecId(v);
1409
+ }, children: [_jsx(SelectTrigger, { className: "w-full", "aria-label": "Section", "data-docs-navigation": "true", onPointerDown: (e) => {
1410
+ if (e.button === 0)
1411
+ setSectionOpen(true);
1412
+ }, children: _jsx(SelectValue, { placeholder: "Section" }) }), _jsxs(SelectContent, { className: "w-[var(--radix-select-trigger-width)]", children: [sects.map((s) => {
1413
+ if (s.simulated) {
1414
+ return (_jsx(SelectItem, { value: s.origName, icon: _jsx("span", { "aria-hidden": "true", className: "size-3.5 rounded-[3px]", style: {
1415
+ backgroundColor: `hsl(${getHue(s.title || 'New Section')} 65% 55%)`,
1416
+ } }), className: "data-[state=checked]:text-primary-10 dark:data-[state=checked]:text-primary-12", children: s.title || 'New Section' }, s.origName));
1417
+ }
1418
+ // prettier-ignore
1419
+ return (_jsx(SelectItem, { value: s.origName, icon: _jsx("span", { "aria-hidden": 'true', className: 'size-3.5 rounded-[3px]', style: { backgroundColor: `hsl(${hueDlg?.open && hueDlg.section.origName === s.origName ? hueDlg.hue : getHue(s.title || s.origName, s.hue)} 65% 55%)` } }), className: 'data-[state=checked]:text-primary-10 dark:data-[state=checked]:text-primary-12', children: _jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { className: 'flex w-full items-center justify-between', children: _jsx("span", { className: 'line-clamp-1', children: cTitle(toNodeLabel(s.title || s.origName)) }) }), _jsx(ContextMenuContent, { children: _jsx(Menu, { actions: SidebarActions.renderSects(s) }) })] }) }, s.origName));
1420
+ }), permission === 'write' && (_jsxs(_Fragment, { children: [sects.length > 0 && !sects[0]?.simulated && _jsx(Separator, { className: "my-1" }), _jsx(SelectItem, { value: "__add_section__", icon: _jsx(AddIcon, { className: "size-4" }), className: "font-medium text-primary-11 data-[state=checked]:text-primary-10 dark:data-[state=checked]:text-primary-12", children: _jsx("span", { children: "Add section" }) })] }))] })] }) }) })] }), _jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { className: "flex min-h-0 flex-1 flex-col outline-none", children: _jsx(SidebarContent, { className: "min-h-0 flex-1 overflow-y-auto", children: _jsx(SidebarMenu, { children: children.map((n) => (_jsx(Tree, { bPath: aViewed?.origName ?? '', node: n, ctx: treeCtx, siblings: children }, getStableKey(n)))) }) }) }), permission === 'write' && aViewed && (_jsx(ContextMenuContent, { children: _jsx(Menu, { actions: [
1421
+ {
1422
+ disabled: actionDisabled,
1423
+ icon: _jsx(AddIcon, {}),
1424
+ label: 'Add group',
1425
+ onSelect: () => {
1426
+ if (aViewed.simulated)
1427
+ addSection({
1428
+ title: 'Create Section',
1429
+ description: 'A section must be created first to hold your new group.',
1430
+ });
1431
+ else
1432
+ treeCtx.addGroup(aViewed.origName, aViewed.origName);
1433
+ },
1434
+ },
1435
+ ] }) }))] }), _jsx(SidebarFooter, { children: userData && _jsx(User, { user: userData, className: "mr-auto pl-0" }) }), _jsx(SidebarRail, {})] }) }));
1436
+ });
1437
+ //# sourceMappingURL=_sidebar.js.map