@vertesia/ui 1.4.0-dev.20260615.042549Z → 1.4.0-dev.20260629.130134Z

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 (337) hide show
  1. package/lib/core/components/shadcn/dropdown.d.ts.map +1 -1
  2. package/lib/core/components/shadcn/dropdown.js +6 -2
  3. package/lib/core/components/shadcn/dropdown.js.map +1 -1
  4. package/lib/core/components/shadcn/filters/filterBar.d.ts.map +1 -1
  5. package/lib/core/components/shadcn/filters/filterBar.js +9 -2
  6. package/lib/core/components/shadcn/filters/filterBar.js.map +1 -1
  7. package/lib/core/components/shadcn/modal/ConfirmModal.d.ts +16 -1
  8. package/lib/core/components/shadcn/modal/ConfirmModal.d.ts.map +1 -1
  9. package/lib/core/components/shadcn/modal/ConfirmModal.js +25 -3
  10. package/lib/core/components/shadcn/modal/ConfirmModal.js.map +1 -1
  11. package/lib/core/components/shadcn/modal/dialog.js +1 -1
  12. package/lib/core/components/shadcn/modal/dialog.js.map +1 -1
  13. package/lib/core/components/shadcn/popover.d.ts.map +1 -1
  14. package/lib/core/components/shadcn/popover.js +3 -1
  15. package/lib/core/components/shadcn/popover.js.map +1 -1
  16. package/lib/core/components/shadcn/switch.js +3 -3
  17. package/lib/core/components/shadcn/switch.js.map +1 -1
  18. package/lib/core/components/shadcn/tabs.js +1 -1
  19. package/lib/core/components/shadcn/tabs.js.map +1 -1
  20. package/lib/core/components/shadcn/tooltip.d.ts.map +1 -1
  21. package/lib/core/components/shadcn/tooltip.js +3 -1
  22. package/lib/core/components/shadcn/tooltip.js.map +1 -1
  23. package/lib/env/index.d.ts +0 -19
  24. package/lib/env/index.d.ts.map +1 -1
  25. package/lib/env/index.js +0 -6
  26. package/lib/env/index.js.map +1 -1
  27. package/lib/features/agent/PayloadBuilder.d.ts +4 -0
  28. package/lib/features/agent/PayloadBuilder.d.ts.map +1 -1
  29. package/lib/features/agent/PayloadBuilder.js +16 -0
  30. package/lib/features/agent/PayloadBuilder.js.map +1 -1
  31. package/lib/features/agent/chat/AgentApprovalModeSelector.d.ts +10 -0
  32. package/lib/features/agent/chat/AgentApprovalModeSelector.d.ts.map +1 -0
  33. package/lib/features/agent/chat/AgentApprovalModeSelector.js +50 -0
  34. package/lib/features/agent/chat/AgentApprovalModeSelector.js.map +1 -0
  35. package/lib/features/agent/chat/AgentChatFixtureReplay.d.ts +2 -1
  36. package/lib/features/agent/chat/AgentChatFixtureReplay.d.ts.map +1 -1
  37. package/lib/features/agent/chat/AgentChatFixtureReplay.js +3 -3
  38. package/lib/features/agent/chat/AgentChatFixtureReplay.js.map +1 -1
  39. package/lib/features/agent/chat/AgentRequestInputOverlay.d.ts +5 -2
  40. package/lib/features/agent/chat/AgentRequestInputOverlay.d.ts.map +1 -1
  41. package/lib/features/agent/chat/AgentRequestInputOverlay.js +41 -7
  42. package/lib/features/agent/chat/AgentRequestInputOverlay.js.map +1 -1
  43. package/lib/features/agent/chat/AgentRightPanel.d.ts.map +1 -1
  44. package/lib/features/agent/chat/AgentRightPanel.js +133 -12
  45. package/lib/features/agent/chat/AgentRightPanel.js.map +1 -1
  46. package/lib/features/agent/chat/AnimatedThinkingDots.js +1 -1
  47. package/lib/features/agent/chat/AnimatedThinkingDots.js.map +1 -1
  48. package/lib/features/agent/chat/ArtifactsTab.d.ts.map +1 -1
  49. package/lib/features/agent/chat/ArtifactsTab.js +11 -65
  50. package/lib/features/agent/chat/ArtifactsTab.js.map +1 -1
  51. package/lib/features/agent/chat/AskUserWidget.d.ts +3 -1
  52. package/lib/features/agent/chat/AskUserWidget.d.ts.map +1 -1
  53. package/lib/features/agent/chat/AskUserWidget.js +4 -3
  54. package/lib/features/agent/chat/AskUserWidget.js.map +1 -1
  55. package/lib/features/agent/chat/ModernAgentConversation.d.ts +10 -2
  56. package/lib/features/agent/chat/ModernAgentConversation.d.ts.map +1 -1
  57. package/lib/features/agent/chat/ModernAgentConversation.js +526 -117
  58. package/lib/features/agent/chat/ModernAgentConversation.js.map +1 -1
  59. package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.d.ts +8 -0
  60. package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.d.ts.map +1 -0
  61. package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.js +19 -0
  62. package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.js.map +1 -0
  63. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts +8 -2
  64. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
  65. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +551 -92
  66. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  67. package/lib/features/agent/chat/ModernAgentOutput/AttachmentPreview.d.ts.map +1 -1
  68. package/lib/features/agent/chat/ModernAgentOutput/AttachmentPreview.js +7 -6
  69. package/lib/features/agent/chat/ModernAgentOutput/AttachmentPreview.js.map +1 -1
  70. package/lib/features/agent/chat/ModernAgentOutput/Header.js +2 -2
  71. package/lib/features/agent/chat/ModernAgentOutput/Header.js.map +1 -1
  72. package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.d.ts +8 -0
  73. package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.d.ts.map +1 -0
  74. package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.js +61 -0
  75. package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.js.map +1 -0
  76. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts +15 -2
  77. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
  78. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js +28 -38
  79. package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
  80. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts +1 -1
  81. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
  82. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js +3 -2
  83. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  84. package/lib/features/agent/chat/ModernAgentOutput/SlideInPanel.js +2 -1
  85. package/lib/features/agent/chat/ModernAgentOutput/SlideInPanel.js.map +1 -1
  86. package/lib/features/agent/chat/ModernAgentOutput/SlidingMessages.js +1 -1
  87. package/lib/features/agent/chat/ModernAgentOutput/SlidingMessages.js.map +1 -1
  88. package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.d.ts +5 -0
  89. package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.d.ts.map +1 -1
  90. package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.js +59 -4
  91. package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.js.map +1 -1
  92. package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js +2 -2
  93. package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js.map +1 -1
  94. package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.d.ts +9 -0
  95. package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.d.ts.map +1 -1
  96. package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.js +180 -0
  97. package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.js.map +1 -1
  98. package/lib/features/agent/chat/ModernAgentOutput/utils.d.ts +6 -0
  99. package/lib/features/agent/chat/ModernAgentOutput/utils.d.ts.map +1 -1
  100. package/lib/features/agent/chat/ModernAgentOutput/utils.js +92 -2
  101. package/lib/features/agent/chat/ModernAgentOutput/utils.js.map +1 -1
  102. package/lib/features/agent/chat/clipboardFiles.d.ts +15 -0
  103. package/lib/features/agent/chat/clipboardFiles.d.ts.map +1 -0
  104. package/lib/features/agent/chat/clipboardFiles.js +35 -0
  105. package/lib/features/agent/chat/clipboardFiles.js.map +1 -0
  106. package/lib/features/agent/chat/hooks/useAgentStream.d.ts +6 -0
  107. package/lib/features/agent/chat/hooks/useAgentStream.d.ts.map +1 -1
  108. package/lib/features/agent/chat/hooks/useAgentStream.js +218 -37
  109. package/lib/features/agent/chat/hooks/useAgentStream.js.map +1 -1
  110. package/lib/features/agent/chat/hooks/useArtifacts.d.ts +1 -8
  111. package/lib/features/agent/chat/hooks/useArtifacts.d.ts.map +1 -1
  112. package/lib/features/agent/chat/hooks/useArtifacts.js +10 -28
  113. package/lib/features/agent/chat/hooks/useArtifacts.js.map +1 -1
  114. package/lib/features/agent/chat/index.d.ts +2 -1
  115. package/lib/features/agent/chat/index.d.ts.map +1 -1
  116. package/lib/features/agent/chat/index.js +2 -1
  117. package/lib/features/agent/chat/index.js.map +1 -1
  118. package/lib/features/agent/chat/workstreams.d.ts +1 -0
  119. package/lib/features/agent/chat/workstreams.d.ts.map +1 -1
  120. package/lib/features/agent/chat/workstreams.js +28 -0
  121. package/lib/features/agent/chat/workstreams.js.map +1 -1
  122. package/lib/features/facets/AgentRunnerFacetsNav.d.ts +10 -1
  123. package/lib/features/facets/AgentRunnerFacetsNav.d.ts.map +1 -1
  124. package/lib/features/facets/AgentRunnerFacetsNav.js +6 -3
  125. package/lib/features/facets/AgentRunnerFacetsNav.js.map +1 -1
  126. package/lib/features/facets/CollectionsFacetsNav.d.ts +10 -1
  127. package/lib/features/facets/CollectionsFacetsNav.d.ts.map +1 -1
  128. package/lib/features/facets/CollectionsFacetsNav.js +14 -5
  129. package/lib/features/facets/CollectionsFacetsNav.js.map +1 -1
  130. package/lib/features/facets/PromptsFacetsNav.d.ts +10 -1
  131. package/lib/features/facets/PromptsFacetsNav.d.ts.map +1 -1
  132. package/lib/features/facets/PromptsFacetsNav.js +14 -5
  133. package/lib/features/facets/PromptsFacetsNav.js.map +1 -1
  134. package/lib/features/facets/RunsFacetsNav.d.ts +10 -1
  135. package/lib/features/facets/RunsFacetsNav.d.ts.map +1 -1
  136. package/lib/features/facets/RunsFacetsNav.js +14 -5
  137. package/lib/features/facets/RunsFacetsNav.js.map +1 -1
  138. package/lib/features/index.d.ts +0 -1
  139. package/lib/features/index.d.ts.map +1 -1
  140. package/lib/features/index.js +0 -1
  141. package/lib/features/index.js.map +1 -1
  142. package/lib/features/oauth/McpConnectionsButton.d.ts +30 -0
  143. package/lib/features/oauth/McpConnectionsButton.d.ts.map +1 -0
  144. package/lib/features/oauth/McpConnectionsButton.js +70 -0
  145. package/lib/features/oauth/McpConnectionsButton.js.map +1 -0
  146. package/lib/features/oauth/McpConnectionsDialog.d.ts +25 -0
  147. package/lib/features/oauth/McpConnectionsDialog.d.ts.map +1 -0
  148. package/lib/features/oauth/McpConnectionsDialog.js +26 -0
  149. package/lib/features/oauth/McpConnectionsDialog.js.map +1 -0
  150. package/lib/features/oauth/RemoteMcpConnectionButton.d.ts.map +1 -1
  151. package/lib/features/oauth/RemoteMcpConnectionButton.js +14 -6
  152. package/lib/features/oauth/RemoteMcpConnectionButton.js.map +1 -1
  153. package/lib/features/oauth/index.d.ts +3 -0
  154. package/lib/features/oauth/index.d.ts.map +1 -1
  155. package/lib/features/oauth/index.js +3 -0
  156. package/lib/features/oauth/index.js.map +1 -1
  157. package/lib/features/oauth/useMcpConnections.d.ts +44 -0
  158. package/lib/features/oauth/useMcpConnections.d.ts.map +1 -0
  159. package/lib/features/oauth/useMcpConnections.js +168 -0
  160. package/lib/features/oauth/useMcpConnections.js.map +1 -0
  161. package/lib/features/permissions/UserPermissionsProvider.d.ts +4 -6
  162. package/lib/features/permissions/UserPermissionsProvider.d.ts.map +1 -1
  163. package/lib/features/permissions/UserPermissionsProvider.js +40 -42
  164. package/lib/features/permissions/UserPermissionsProvider.js.map +1 -1
  165. package/lib/features/store/objects/DocumentPreviewPanel.d.ts.map +1 -1
  166. package/lib/features/store/objects/DocumentPreviewPanel.js +2 -1
  167. package/lib/features/store/objects/DocumentPreviewPanel.js.map +1 -1
  168. package/lib/features/store/objects/DocumentQuickFilter.d.ts +23 -0
  169. package/lib/features/store/objects/DocumentQuickFilter.d.ts.map +1 -0
  170. package/lib/features/store/objects/DocumentQuickFilter.js +30 -0
  171. package/lib/features/store/objects/DocumentQuickFilter.js.map +1 -0
  172. package/lib/features/store/objects/DocumentSearchResults.d.ts.map +1 -1
  173. package/lib/features/store/objects/DocumentSearchResults.js +17 -1
  174. package/lib/features/store/objects/DocumentSearchResults.js.map +1 -1
  175. package/lib/features/store/objects/components/ContentOverview.d.ts.map +1 -1
  176. package/lib/features/store/objects/components/ContentOverview.js +17 -74
  177. package/lib/features/store/objects/components/ContentOverview.js.map +1 -1
  178. package/lib/features/store/objects/layout/DocumentTableColumn.d.ts +7 -1
  179. package/lib/features/store/objects/layout/DocumentTableColumn.d.ts.map +1 -1
  180. package/lib/features/store/objects/layout/DocumentTableColumn.js +27 -3
  181. package/lib/features/store/objects/layout/DocumentTableColumn.js.map +1 -1
  182. package/lib/features/store/objects/layout/documentLayout.js +1 -1
  183. package/lib/features/store/objects/layout/renderers.d.ts +2 -1
  184. package/lib/features/store/objects/layout/renderers.d.ts.map +1 -1
  185. package/lib/features/store/objects/layout/renderers.js +27 -20
  186. package/lib/features/store/objects/layout/renderers.js.map +1 -1
  187. package/lib/features/store/types/ContentObjectTypesSearch.d.ts.map +1 -1
  188. package/lib/features/store/types/ContentObjectTypesSearch.js +4 -1
  189. package/lib/features/store/types/ContentObjectTypesSearch.js.map +1 -1
  190. package/lib/features/store/types/ContentObjectTypesTable.d.ts +2 -1
  191. package/lib/features/store/types/ContentObjectTypesTable.d.ts.map +1 -1
  192. package/lib/features/store/types/ContentObjectTypesTable.js +8 -3
  193. package/lib/features/store/types/ContentObjectTypesTable.js.map +1 -1
  194. package/lib/i18n/instance.d.ts.map +1 -1
  195. package/lib/i18n/instance.js +1 -0
  196. package/lib/i18n/instance.js.map +1 -1
  197. package/lib/i18n/locales/ar.json +72 -45
  198. package/lib/i18n/locales/de.json +65 -34
  199. package/lib/i18n/locales/en.json +63 -47
  200. package/lib/i18n/locales/es.json +65 -35
  201. package/lib/i18n/locales/fr.json +65 -35
  202. package/lib/i18n/locales/it.json +72 -42
  203. package/lib/i18n/locales/ja.json +72 -41
  204. package/lib/i18n/locales/ko.json +72 -41
  205. package/lib/i18n/locales/pt.json +72 -42
  206. package/lib/i18n/locales/ru.json +72 -43
  207. package/lib/i18n/locales/tr.json +72 -41
  208. package/lib/i18n/locales/zh-TW.json +72 -41
  209. package/lib/i18n/locales/zh.json +72 -41
  210. package/lib/session/UserSession.d.ts +0 -6
  211. package/lib/session/UserSession.d.ts.map +1 -1
  212. package/lib/session/UserSession.js +0 -15
  213. package/lib/session/UserSession.js.map +1 -1
  214. package/lib/session/UserSessionProvider.d.ts.map +1 -1
  215. package/lib/session/UserSessionProvider.js +39 -98
  216. package/lib/session/UserSessionProvider.js.map +1 -1
  217. package/lib/session/auth/composable.d.ts.map +1 -1
  218. package/lib/session/auth/composable.js +3 -33
  219. package/lib/session/auth/composable.js.map +1 -1
  220. package/lib/shell/login/SignInPrimitives.d.ts.map +1 -1
  221. package/lib/shell/login/SignInPrimitives.js +3 -2
  222. package/lib/shell/login/SignInPrimitives.js.map +1 -1
  223. package/lib/vertesia-ui-core.js +1 -1
  224. package/lib/vertesia-ui-core.js.map +1 -1
  225. package/lib/vertesia-ui-env.js +1 -1
  226. package/lib/vertesia-ui-env.js.map +1 -1
  227. package/lib/vertesia-ui-features.js +1 -1
  228. package/lib/vertesia-ui-features.js.map +1 -1
  229. package/lib/vertesia-ui-i18n.js +1 -1
  230. package/lib/vertesia-ui-i18n.js.map +1 -1
  231. package/lib/vertesia-ui-session.js +1 -1
  232. package/lib/vertesia-ui-session.js.map +1 -1
  233. package/lib/vertesia-ui-shell.js +1 -1
  234. package/lib/vertesia-ui-shell.js.map +1 -1
  235. package/lib/vertesia-ui-widgets.js +1 -1
  236. package/lib/vertesia-ui-widgets.js.map +1 -1
  237. package/lib/widgets/schema-editor/editor/Editable.js +1 -1
  238. package/lib/widgets/schema-editor/editor/Editable.js.map +1 -1
  239. package/llms.txt +70 -70
  240. package/package.json +35 -32
  241. package/src/core/components/shadcn/dropdown.tsx +2 -0
  242. package/src/core/components/shadcn/filters/filterBar.tsx +9 -2
  243. package/src/core/components/shadcn/modal/ConfirmModal.tsx +65 -3
  244. package/src/core/components/shadcn/modal/dialog.tsx +1 -1
  245. package/src/core/components/shadcn/popover.tsx +1 -0
  246. package/src/core/components/shadcn/switch.tsx +4 -4
  247. package/src/core/components/shadcn/tabs.tsx +1 -1
  248. package/src/core/components/shadcn/tooltip.tsx +1 -0
  249. package/src/env/index.ts +0 -24
  250. package/src/features/agent/PayloadBuilder.tsx +18 -0
  251. package/src/features/agent/chat/AgentApprovalModeSelector.tsx +130 -0
  252. package/src/features/agent/chat/AgentChatFixtureReplay.test.tsx +22 -2
  253. package/src/features/agent/chat/AgentChatFixtureReplay.tsx +33 -27
  254. package/src/features/agent/chat/AgentRequestInputOverlay.test.tsx +122 -0
  255. package/src/features/agent/chat/AgentRequestInputOverlay.tsx +91 -17
  256. package/src/features/agent/chat/AgentRightPanel.tsx +238 -50
  257. package/src/features/agent/chat/AnimatedThinkingDots.tsx +1 -1
  258. package/src/features/agent/chat/ArtifactsTab.tsx +21 -155
  259. package/src/features/agent/chat/AskUserWidget.tsx +6 -2
  260. package/src/features/agent/chat/ModernAgentConversation.test.tsx +1157 -47
  261. package/src/features/agent/chat/ModernAgentConversation.tsx +703 -136
  262. package/src/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.tsx +74 -0
  263. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.test.tsx +1420 -126
  264. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +934 -111
  265. package/src/features/agent/chat/ModernAgentOutput/AttachmentPreview.tsx +31 -40
  266. package/src/features/agent/chat/ModernAgentOutput/Header.tsx +28 -28
  267. package/src/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.tsx +83 -0
  268. package/src/features/agent/chat/ModernAgentOutput/MessageInput.test.tsx +38 -2
  269. package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +121 -98
  270. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +7 -1
  271. package/src/features/agent/chat/ModernAgentOutput/SlideInPanel.tsx +3 -3
  272. package/src/features/agent/chat/ModernAgentOutput/SlidingMessages.tsx +1 -1
  273. package/src/features/agent/chat/ModernAgentOutput/SummaryConversation.ts +82 -2
  274. package/src/features/agent/chat/ModernAgentOutput/WorkstreamTabs.tsx +2 -2
  275. package/src/features/agent/chat/ModernAgentOutput/requestInputMessages.ts +216 -0
  276. package/src/features/agent/chat/ModernAgentOutput/utils.test.ts +149 -0
  277. package/src/features/agent/chat/ModernAgentOutput/utils.ts +103 -2
  278. package/src/features/agent/chat/clipboardFiles.ts +33 -0
  279. package/src/features/agent/chat/hooks/useAgentStream.test.tsx +355 -4
  280. package/src/features/agent/chat/hooks/useAgentStream.ts +270 -43
  281. package/src/features/agent/chat/hooks/useArtifacts.ts +11 -44
  282. package/src/features/agent/chat/index.ts +10 -1
  283. package/src/features/agent/chat/workstreams.ts +42 -0
  284. package/src/features/facets/AgentRunnerFacetsNav.tsx +23 -3
  285. package/src/features/facets/CollectionsFacetsNav.tsx +30 -5
  286. package/src/features/facets/PromptsFacetsNav.tsx +30 -5
  287. package/src/features/facets/RunsFacetsNav.tsx +32 -5
  288. package/src/features/index.ts +0 -1
  289. package/src/features/oauth/McpConnectionsButton.test.tsx +248 -0
  290. package/src/features/oauth/McpConnectionsButton.tsx +269 -0
  291. package/src/features/oauth/McpConnectionsDialog.tsx +142 -0
  292. package/src/features/oauth/RemoteMcpConnectionButton.tsx +37 -14
  293. package/src/features/oauth/index.ts +3 -0
  294. package/src/features/oauth/useMcpConnections.test.ts +94 -0
  295. package/src/features/oauth/useMcpConnections.ts +210 -0
  296. package/src/features/permissions/UserPermissionsProvider.tsx +41 -59
  297. package/src/features/store/objects/DocumentPreviewPanel.tsx +4 -2
  298. package/src/features/store/objects/DocumentQuickFilter.tsx +72 -0
  299. package/src/features/store/objects/DocumentSearchResults.tsx +30 -11
  300. package/src/features/store/objects/components/ContentOverview.tsx +30 -99
  301. package/src/features/store/objects/layout/DocumentTableColumn.tsx +29 -4
  302. package/src/features/store/objects/layout/documentLayout.tsx +1 -1
  303. package/src/features/store/objects/layout/renderers.tsx +80 -20
  304. package/src/features/store/types/ContentObjectTypesSearch.tsx +7 -1
  305. package/src/features/store/types/ContentObjectTypesTable.tsx +34 -4
  306. package/src/i18n/instance.ts +1 -0
  307. package/src/i18n/locales/ar.json +72 -45
  308. package/src/i18n/locales/de.json +65 -34
  309. package/src/i18n/locales/en.json +63 -47
  310. package/src/i18n/locales/es.json +65 -35
  311. package/src/i18n/locales/fr.json +65 -35
  312. package/src/i18n/locales/it.json +72 -42
  313. package/src/i18n/locales/ja.json +72 -41
  314. package/src/i18n/locales/ko.json +72 -41
  315. package/src/i18n/locales/pt.json +72 -42
  316. package/src/i18n/locales/ru.json +72 -43
  317. package/src/i18n/locales/tr.json +72 -41
  318. package/src/i18n/locales/zh-TW.json +72 -41
  319. package/src/i18n/locales/zh.json +72 -41
  320. package/src/i18n/rtl.test.ts +57 -1
  321. package/src/session/UserSession.ts +0 -16
  322. package/src/session/UserSessionProvider.tsx +51 -123
  323. package/src/session/auth/composable.ts +3 -34
  324. package/src/shell/login/SignInPrimitives.tsx +3 -2
  325. package/src/widgets/schema-editor/editor/Editable.tsx +1 -1
  326. package/lib/features/document-viewer/UniversalDocumentViewer.d.ts +0 -73
  327. package/lib/features/document-viewer/UniversalDocumentViewer.d.ts.map +0 -1
  328. package/lib/features/document-viewer/UniversalDocumentViewer.js +0 -415
  329. package/lib/features/document-viewer/UniversalDocumentViewer.js.map +0 -1
  330. package/lib/features/document-viewer/index.d.ts +0 -2
  331. package/lib/features/document-viewer/index.d.ts.map +0 -1
  332. package/lib/features/document-viewer/index.js +0 -2
  333. package/lib/features/document-viewer/index.js.map +0 -1
  334. package/src/features/document-viewer/UniversalDocumentViewer.test.tsx +0 -123
  335. package/src/features/document-viewer/UniversalDocumentViewer.tsx +0 -746
  336. package/src/features/document-viewer/index.ts +0 -1
  337. package/src/session/auth/composable.test.ts +0 -79
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Styles as n,FormItem as a,Button as i,DotBadge as s,useTheme as o,Table as l,VTooltip as c,SelectBox as d,Modal as u,ModalTitle as h,ModalBody as m,ModalFooter as p,useFlag as f,useClickOutside as g,useToast as y,errorMessage as v}from"@vertesia/ui/core";import b,{clsx as x}from"clsx";import{Plus as w,Trash2 as N,Loader2 as k,Check as C,Copy as S,Download as A,Minimize2 as j,Maximize2 as O,X as $,Code as I,FileText as P,Table as R,Link as L,Image as F,MessageSquare as T,GitBranch as E,BarChart3 as D,Info as V,AlignLeft as z,SquarePen as M,ChevronDown as q,ChevronRight as _,UploadIcon as U,CheckCircleIcon as W,AlertCircleIcon as J,XCircleIcon as H}from"lucide-react";import B,{createContext as K,useContext as G,useState as Z,useRef as X,useMemo as Y,useEffect as Q,useCallback as ee,memo as te,useId as re}from"react";import ne from"ajv";import ae from"ajv-formats";import{useUITranslation as ie}from"@vertesia/ui/i18n";import{Editor as se}from"@monaco-editor/react";import oe from"debounce";import{FusionFragmentProvider as le,FusionFragmentHandler as ce}from"@vertesia/fusion-ux";import de from"dompurify";import*as ue from"@radix-ui/react-dialog";import{useUserSession as he}from"@vertesia/ui/session";import me from"papaparse";import{VegaEmbed as pe}from"react-vega";import{twMerge as fe}from"tailwind-merge";import ge from"mermaid";import ye,{defaultUrlTransform as ve}from"react-markdown";import be from"rehype-katex";import{remarkDefinitionList as xe,defListHastHandlers as we}from"remark-definition-list";import Ne from"remark-directive";import ke from"remark-gfm";import Ce from"remark-github-blockquote-alert";import Se from"remark-math";import Ae from"remark-supersub";import{visit as je,SKIP as Oe}from"unist-util-visit";import{XMLParser as $e}from"fast-xml-parser";import{SyntaxValidator as Ie}from"fast-xml-validator";import{isNil as Pe,omit as Re}from"lodash-es";const Le=K(void 0),Fe=Le.Provider;function Te(){const e=G(Le);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class Ee{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const De=K(void 0);function Ve(){const e=G(De);if(!e)throw new Error("useForm must be used within a Form element");return e}const ze=De.Provider,Me=B.forwardRef(({object:t,type:r="text",onChange:a,...i},s)=>{const[o,l]=Z(null!=t.value?String(t.value):""),[c,d]=Z(t.schema.isBoolean&&!0===t.value);i.className?i.className=b(n.INPUT,i.className):i.className=n.INPUT;const u=e=>{i.disabled||(l(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,d(t.value)):t.value=e.target.value,a?.(e))};return"textarea"===r?e("textarea",{ref:s,...i,value:o,onChange:u}):e("input","checkbox"===r?{ref:s,...i,type:"checkbox",checked:c,onChange:u,className:"form-check-input"}:{ref:s,...i,type:r,value:o,onChange:u})});function qe({object:t,components:r,onSubmit:n,children:a,onChange:i,disabled:s}){return t.observer=i,e(ze,{value:new Ee(t,r||{},s??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n?.(t.value)},children:a})})}function _e(){const t=Ve();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(We)})}function Ue({children:r,...n}){return t(qe,{...n,children:[e(_e,{}),r]})}function We(t){return t.isList?e(Ke,{object:t},t.name):t.isObject?e(Be,{object:t},t.name):e(He,{object:t},t.name)}function Je(t,r){return t.isList?e(Ke,{object:t}):t.isObject?e(Be,{object:t}):e(He,{object:t,editor:r})}function He({object:t,editor:r,inline:n=!1}){r||(r=t.schema.editor);const{components:i,disabled:s}=Ve(),o=r&&i[r]||Me,l=t.getInputType();"checkbox"===l&&(n=!0);const c=e=>{s||(t.schema.isBoolean?t.value=e.target instanceof HTMLInputElement&&e.target.checked:t.schema.isNumber?t.value=parseFloat(e.target.value):t.value=e.target.value)};return t.isListItem?e(o,{object:t,type:l,onChange:c,disabled:s}):e(a,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:b("flex",n?"flex-row items-center":"flex-col"),children:e(o,{object:t,type:l,onChange:c,disabled:s})})}function Be({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(We)]})}function Ke({object:r}){const{disabled:n}=Ve(),a=X((r.value??[]).length),[s,o]=Z(()=>(r.value??[]).map((e,t)=>t));return t("div",{className:"flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 darK:border-s-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map((t,a)=>{const i=s[a];return e(Ge,{object:t,list:r,onDelete:()=>(e=>{n||(r.remove(e),o(t=>t.filter((t,r)=>r!==e)))})(a),disabled:n},i)}),e("div",{children:t(i,{variant:"outline",onClick:()=>{n||(r.add(),o(e=>[...e,a.current++]))},disabled:n,children:[e(w,{className:"size-6"})," Add"]})})]})}function Ge({list:r,object:n,onDelete:a,disabled:s}){const o="string"==typeof r.schema.arraySchema.editor?r.schema.arraySchema.editor:void 0;return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:Je(n,o)}),e(i,{variant:"ghost",onClick:a,disabled:s,alt:"Delete",children:e(N,{className:"size-4 text-destructive"})})]})}function Ze({label:t,required:r,children:n}){return e(a,{label:t,required:r,children:n})}function Xe({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Ye({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}class Qe{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new ne({allErrors:!0,strict:!1});ae(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){const e=this.schema.title;if("string"==typeof e)return e;const t=this.schema.name;return"string"==typeof t?t:void 0}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new tt(this,e,t):new et(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const n="string"==typeof t?"object"===(a=t)?{type:"object",properties:{}}:"array"===a?{type:"array",items:{}}:{type:a}:t;var a;const i=this.loadProperty(e,n);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return"string"==typeof this.schema.editor?this.schema.editor:void 0}}class et extends Qe{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class tt extends et{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function rt(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function nt(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class at{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||rt(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent?.onChange(e)}}class it extends at{get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new ct(this,t,this.getOrInitArrayProperty(e)):t.isObject?new ot(this,t,t.name,this.getOrInitObjectProperty(e)):new lt(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new ct(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new ot(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new lt(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class st extends it{value;constructor(e,t={}){super(null,e instanceof Qe?e:new Qe(e),"#root"),this.value=t}}class ot extends it{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class lt extends at{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return nt(this.name,this.schema)}}class ct extends at{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new dt(this,e):new ut(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new ot(this,this.schema,String(e),t):new ut(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class dt extends it{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=`${this.name}@${Date.now()}`}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class ut extends at{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=`${this.name}@${Date.now()}`}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return nt(this.name,this.schema)}}function ht({data:r,className:n}){const a=Y(()=>{try{return JSON.stringify(r,null,2)}catch(e){return console.error("Failed to stringify JSON:",e),"{}"}},[r]),i=Y(()=>a.split("\n"),[a]);return e("pre",{className:`h-full overflow-auto rounded-md border bg-background p-3 font-mono text-xs leading-5 text-foreground ${n||""}`,children:e("code",{children:i.map((e,r)=>t("span",{children:[ft(e),r<i.length-1?"\n":null]},r))})})}const mt=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,pt=/^\s*:/;function ft(t){mt.lastIndex=0;const r=[];let n=0,a=mt.exec(t);for(;null!==a;){a.index>n&&r.push(t.slice(n,a.index));const[i,s,o,l]=a,c=void 0!==s&&pt.test(t.slice(a.index+i.length))?"text-info":s?"text-success":o?"text-primary":l?"text-attention":void 0;r.push(e("span",{className:c,children:i},`${a.index}-${i}`)),n=a.index+i.length,a=mt.exec(t)}return n<t.length&&r.push(t.slice(n)),r.length?r:t}function gt({value:t}){return Array.isArray(t)?e("div",{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:e(xt,{value:t})}):e("div","object"!=typeof t||null==t?{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:e(bt,{name:"value",value:t})}:{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:Object.entries(t).map(([t,r])=>e(bt,{name:t,value:r},t))})}function yt({name:t}){return e("div",{className:"text-md font-semibold",children:rt(t)})}function vt({children:t,className:r}){return e("div",{className:b("flex flex-col gap-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600",r),children:t})}function bt({name:r,value:n}){const a=kt(n);switch(a.type){case Nt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(yt,{name:`${r}:`}),e("p",{children:a.value})]});case Nt.Paragraph:return t("div",{children:[e(yt,{name:r}),e("p",{children:a.value})]});case Nt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(yt,{name:r}),e("div",{className:"vprose dark:prose-invert",children:a.value})]});case Nt.Array:return e(xt,{name:r,value:n});case Nt.Object:return t("div",{children:[e(yt,{name:r}),e(vt,{className:"mt-2",children:Object.entries(n).map(([t,r])=>e(bt,{name:t,value:r},t))})]})}}function xt({name:r,value:n}){const a=n.join(" ").length,i=a/n.length,o="string"==typeof n[0]&&(a<80||a<400&&i<32),l=n.length>9,c=n.map((e,t)=>({item:e,index:t,key:`${t}-${JSON.stringify(e)}`}));return t("div",o?{className:"flex gap-2 flex-wrap",children:[r&&e(yt,{name:`${r}:`}),c.map(({item:t,key:r})=>e(s,{children:String(t)},r))]}:{children:[r&&e(yt,{name:r}),e("div",{className:"flex flex-col gap-2",children:c.map(({item:t,index:r,key:n})=>e(wt,{index:r,value:t,useBullet:l},n))})]})}function wt({index:r,value:n,useBullet:a}){const i=a?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),s=kt(n);let o;switch(s.type){case Nt.Object:o=e(vt,{children:Object.entries(n).map(([t,r])=>e(bt,{name:t,value:r},t))});break;case Nt.Array:o=e(xt,{value:n});break;case Nt.Prose:o=e("div",{className:"prose dark:prose-invert",children:s.value});break;default:o=e("div",{children:s.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pe-2 ps-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var Nt;function kt(e){if(null==e)return{value:"-",type:Nt.Inline};if(Array.isArray(e))return{value:e,type:Nt.Array};if("string"==typeof e){const t=e.length;let r,n=e;return t<80?r=Nt.Inline:t>400?r=Nt.Prose:(r=Nt.Paragraph,n=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:n}}return"number"==typeof e||"boolean"==typeof e?{value:String(e),type:Nt.Inline}:{value:e,type:Nt.Object}}function Ct({value:t,viewCode:r=!1}){const{t:n}=ie();return t?e("div",{className:"relative w-full h-full flex flex-col",children:r||!St(t)?e(ht,{data:t}):e("div",{className:"flex-1 min-h-0 overflow-auto",children:e(gt,{value:t})})}):e("pre",{className:"whitespace-pre-wrap",children:n("misc.noData")})}function St(e){return null==e||("string"==typeof e||"number"==typeof e||"boolean"==typeof e||(Array.isArray(e)?e.every(St):"object"==typeof e&&Object.values(e).every(St)))}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(Nt||(Nt={}));const At=new Set;class jt{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||"")}}function Ot({onChange:t,value:r,className:n,editorRef:a,language:i="javascript",path:s,debounceTimeout:l=0,options:c={},beforeMount:d,onMount:u,defaultValue:h,useCustomFolding:m=!1}){const[p,f]=Z(r||h||""),g=X(null),y=X(null),{theme:v}=o(),x="system"===v?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":v,w=r||h||"",N=X(()=>p),k=X(e=>{f(e),g.current&&g.current.setValue(e)});Q(()=>{N.current=()=>p},[p]),Q(()=>(a&&(a.current=new jt(()=>N.current(),e=>k.current(e))),()=>{a&&(a.current=void 0)}),[a]);const C=Y(()=>{if(t)return l>0?oe(e=>t(e),l):t},[t,l]),S=ee(async(e,t)=>{const r=e.getModel();if(!r)return;const n=/```[\s\S]*?```/g;for(const a of r.getValue().matchAll(n)){const n=r.getPositionAt(a.index).lineNumber,i=r.getPositionAt(a.index+a[0].length).lineNumber;e.setSelection(new t.Selection(n,1,i,1)),await(e.getAction("editor.createFoldingRangeFromSelection")?.run())}},[]),A=ee(e=>{const t=e||"";if(f(t),C){const e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};C(e)}},[C]),j=ee((e,t)=>{g.current=e,y.current=t,m&&function(e){At.has("markdown")||(At.add("markdown"),e.languages.registerFoldingRangeProvider("markdown",{provideFoldingRanges(e){const t=[],r=e.getLinesContent(),n=/^(#{1,6})\s/,a=[];for(let e=0;e<r.length;e++){const i=e+1,s=n.exec(r[e]);if(s){const e=s[1].length;for(;a.length>0&&a[a.length-1].level>=e;){const e=a.pop();i-1>e.line&&t.push({start:e.line,end:i-1})}a.push({level:e,line:i})}}const i=r.length;for(;a.length>0;){const e=a.pop();i>e.line&&t.push({start:e.line,end:i})}return t}}));for(const t of["javascript","typescript"])At.has(t)||(At.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){const t=e.getLinesContent(),r=/^(#{1,6})\s/,n=[],a=[],i=[],s=[];let o=!1,l=!1,c="";for(let e=0;e<t.length;e++){const d=e+1,u=t[e],h=o;for(let e=0;e<u.length;e++){const t=u[e];if("\\"!==t)if(l)t===c&&(l=!1);else if(o)"`"===t&&(o=!1);else if("`"!==t)if('"'!==t&&"'"!==t){if("{"===t&&i.push(d),"}"===t&&i.length>0){const t=i.pop(),r=u.slice(e+1).trimStart().length>0?d-1:d;r>t&&n.push({start:t,end:r})}}else l=!0,c=t;else o=!0;else e++}if(h){const e=r.exec(u);if(e){const t=e[1].length;for(;s.length>0&&s[s.length-1].level>=t;){const e=s.pop();d-1>e.line&&a.push({start:e.line,end:d-1})}s.push({level:t,line:d})}if(!o)for(;s.length>0;){const e=s.pop();d>e.line&&a.push({start:e.line,end:d})}}}return[...n,...a]}}))}(t),k.current=t=>{f(t),e.setValue(t)},t.editor.defineTheme("errorLineTheme",{base:"dark"===x?"vs-dark":"vs",inherit:!0,rules:[],colors:{"editorError.background":"#ffebee","editorError.border":"#f44336"}}),t.editor.setTheme("errorLineTheme"),m&&setTimeout(()=>S(e,t),300),u?.(e,t)},[u,x,m,S]);Q(()=>{f(e=>w===e?e:(g.current&&g.current.setValue(w),w))},[w]),Q(()=>{if(!(w&&m&&g.current&&y.current))return;const e=g.current,t=y.current,r=setTimeout(()=>S(e,t),300);return()=>clearTimeout(r)},[w,m,S]);const O={fontSize:14,fontFamily:"monospace",minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,glyphMargin:!0,renderValidationDecorations:"on",renderLineHighlight:"line",hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return e("div",{className:b(n,"w-full h-full!"),children:e(se,{className:"h-full w-full",height:"100%",theme:"dark"===x?"vs-dark":"light",language:i,path:s,value:p,onChange:A,onMount:j,beforeMount:d,options:O,defaultValue:h||""})})}function $t({value:r,onChange:n,onValidChange:a,readonly:i=!1,height:s="200px",placeholder:l,className:c}){const{theme:d}=o(),u=X(void 0),[h,m]=Z(null),p=Y(()=>{if(null==r)return l??"{}";try{return JSON.stringify(r,null,2)}catch{return"{}"}},[r,l]),f=ee(()=>{if(!u.current||i)return;const e=u.current.getValue();try{const t=JSON.parse(e);m(null),a?.(t)}catch{m("Invalid JSON")}},[i,a]);return t("div",{className:c,children:[e("div",{className:"border rounded overflow-hidden",style:{height:s},children:e(Ot,{defaultValue:p,editorRef:u,language:"json",theme:"dark"===d?"vs-dark":"vs",onChange:f,options:i?{readOnly:!0,domReadOnly:!0}:void 0})}),h&&e("p",{className:"text-xs text-destructive mt-1",children:h})]})}function It(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function Pt({title:r,viewCode:n,setViewCode:a}){return t("div",{className:"flex items-center gap-1 bg-muted mb-2 p-1 rounded",children:[e(i,{variant:n?"ghost":"primary",size:"sm",alt:"Preview properties",onClick:()=>a(!1),children:r}),e(i,{variant:n?"primary":"ghost",size:"sm",alt:"View in JSON format",onClick:()=>a(!0),children:"JSON"})]})}function Rt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/^./,e=>e.toUpperCase())}function Lt(n){if(null==n)return"Failed to query";if("string"==typeof n)return n;if(Array.isArray(n)){if(0===n.length)return"None";return n.some(e=>e&&"object"==typeof e)?e(r,{children:n.map((r,n)=>t("div",{className:"flex gap-1",children:[t("span",{className:"text-xs align-top pe-2 font-medium",children:[n+1,":"]}),e("span",{className:"text-xs",children:Lt(r)})]},n))}):n.map(e=>String(e)).join(", ")}return"object"==typeof n?e(r,{children:Object.entries(n).map(([r,n])=>t("div",{className:"flex gap-1",children:[t("span",{className:"text-xs align-top pe-2 font-medium",children:[Rt(r),":"]}),e("span",{className:"text-xs",children:Lt(n)})]},r))}):String(n)}function Ft({data:r,className:n}){const a=r?Object.entries(r):[];return e("table",{className:n||"mb-2 text-xs bg-muted rounded-sm w-full",children:e("tbody",{children:a.map(([r,n])=>t("tr",{className:"align-top hover:bg-background border-y",children:[e("td",{className:"align-top pe-4 p-2",children:Rt(r)}),e("td",{className:"p-2",children:Lt(n)})]},r))})})}function Tt(...e){return fe(x(e))}const Et=K(null);function Dt(){return G(Et)}function Vt(e){return e.startsWith("agents/")||e.startsWith("documents/")}function zt(e,t,r="inline"){return`artifact:${e}:${t}:${r}`}function Mt(e){return`file:${e}`}function qt({error:r,chartTitle:n}){return e("div",{className:"flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4",children:t("div",{className:"text-center",children:[t("p",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:["Cannot render ",n||"Vega-Lite"," chart"]}),e("p",{className:"text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate",children:r})]})})}function _t({isOpen:r,onClose:n,title:a,description:s,children:o}){const{t:l}=ie();return e(ue.Root,{open:r,onOpenChange:e=>!e&&n(),children:t(ue.Portal,{children:[e(ue.Overlay,{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t(ue.Content,{className:"fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2",onEscapeKeyDown:n,children:[e(ue.Close,{asChild:!0,children:e(i,{variant:"unstyled",onClick:n,className:"absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm","aria-label":l("agent.closeFullscreen"),children:e($,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"})})}),e("div",{className:"flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150",children:o}),e("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl",children:t("div",{className:"flex flex-col",children:[e(ue.Title,{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:a||l("agent.dashboard")}),s&&e(ue.Description,{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:s})]})})]})]})})}const Ut={categorical:["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],blues:["#dbeafe","#93c5fd","#3b82f6","#1d4ed8","#1e3a8a"],purples:["#f3e8ff","#c4b5fd","#8b5cf6","#6d28d9","#4c1d95"],diverging:["#ef4444","#fca5a5","#fef3c7","#86efac","#22c55e"]};function Wt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Jt(e){return Wt(e)}function Ht(e,t){if(!e?.encoding)return!1;for(const r of t)for(const t of Object.values(e.encoding))if(t.field===r)return!0;if(Array.isArray(e.layer))for(const r of e.layer)if(Ht(r,t))return!0;return!1}function Bt(e,t){if(!e)return!1;const r=e=>{if(!e)return!1;const r=e.color?.field;return!!r&&t.includes(r)};if(r(e.encoding))return!0;if(Array.isArray(e.layer))for(const t of e.layer)if(r(t.encoding))return!0;return!1}function Kt(e,t=[]){const r=[];if(!e||"object"!=typeof e)return r;if(e.data&&"object"==typeof e.data){const n=e.data.url;"string"==typeof n&&n.startsWith("artifact:")&&r.push({path:[...t,"data"],artifactPath:n.replace(/^artifact:/,"").trim()})}const n=["layer","vconcat","hconcat","concat","spec","repeat","facet"];for(const a of n)if(a in e){const n=e[a];Array.isArray(n)?n.forEach((e,n)=>{Jt(e)&&r.push(...Kt(e,[...t,a,String(n)]))}):Jt(n)&&r.push(...Kt(n,[...t,a]))}return r}const Gt=te(function({spec:n,artifactRunId:a}){const{t:s}=ie(),{title:o,description:l,options:c}=n,d=n.spec,[u,h]=Z(!1),[m,p]=Z(!1),[f,g]=Z(null),[y,v]=Z(!1),b=X(null),x=X(null),w=X(null),{client:N}=he(),$=Dt(),I=X(N);I.current=N;const P=X($);P.current=$;const[R,L]=Z(null),[F,T]=Z(!1),[E,D]=Z(null),V=c?.mode||"chart",z="dashboard"===V,M=c?.enableFullscreen??z,q=c?.height||function(e,t){if("chart"===t)return 280;let r=1;if(e.vconcat)r=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){const t=e.columns||2,n=Array.isArray(e.concat)?e.concat.length:1;r=Math.ceil(n/t)}else e.facet&&(r=2);return Math.max(500,280*r+40)}(d,V);Q(()=>{const e=Kt(d);if(0===e.length)return L(d),T(!1),void D(null);a?console.info("[VegaLiteChart] resolving artifacts with runId:",a,e.map(e=>e.artifactPath)):console.warn("[VegaLiteChart] artifact references found but artifactRunId is missing!",{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;T(!0),D(null);return(async()=>{const r=new Map,n=I.current,i=P.current;for(const s of e)try{const e=s.path.join(".");let t;if(a&&!Vt(s.artifactPath)){const e=zt(a,s.artifactPath,"inline");if(i)t=await i.getOrFetch(e,async()=>(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url);else{t=(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url}}else{const e=Mt(s.artifactPath);if(i)t=await i.getOrFetch(e,async()=>(await n.files.getDownloadUrl(s.artifactPath)).url);else{t=(await n.files.getDownloadUrl(s.artifactPath)).url}}const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch artifact data: ${o.statusText}`);let l;if(s.artifactPath.toLowerCase().endsWith(".csv")){const e=await o.text();l=me.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{const e=await o.json();l=Array.isArray(e)?e:[e]}r.set(e,l)}catch(e){return console.error(`Failed to resolve artifact: ${s.artifactPath}`,e),void(t||D(`Failed to load data from artifact: ${s.artifactPath}`))}if(!t){const e=function(e,t){const r=JSON.parse(JSON.stringify(e));for(const[e,n]of t){const t=e.split(".");let a=r;for(let e=0;e<t.length-1;e++){const r=a[t[e]];if(!Wt(r))break;a=r}const i=a[t[t.length-1]];Wt(i)&&(delete i.url,i.values=n)}return r}(d,r);L(e),T(!1)}})(),()=>{t=!0}},[d,a]);const[_,U]=Z(!1),W=X(!1);Q(()=>{const e=()=>{const e=document.documentElement.classList.contains("dark");e!==W.current&&(W.current=e,U(e))};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const[J,H]=Z(0),B=X(0);Q(()=>{if(!w.current)return;let e;const t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{const e=t[0]?.contentRect.width;e&&e!==B.current&&(B.current=e,H(e))},100)});t.observe(w.current);const r=w.current.clientWidth;return B.current=r,H(r),()=>{clearTimeout(e),t.disconnect()}},[]);const K=Y(()=>Kt(d).length>0,[d]),G=Y(()=>{if(K&&!R)return null;let e=R||d;return e?(c?.parameterValues&&(e=function(e,t){if(!t||0===Object.keys(t).length)return e;const r=JSON.parse(JSON.stringify(e)),n=e=>{for(const r of e)r.name&&r.name in t&&(r.value=t[r.name])};Array.isArray(r.params)&&n(r.params);const a=e=>{if(Array.isArray(e))for(const t of e)if(Array.isArray(t.params)&&n(t.params),t.vconcat&&a(t.vconcat),t.hconcat&&a(t.hconcat),t.concat&&a(t.concat),Array.isArray(t.layer))for(const e of t.layer)Array.isArray(e.params)&&n(e.params)};if(r.vconcat&&a(r.vconcat),r.hconcat&&a(r.hconcat),r.concat&&a(r.concat),Array.isArray(r.layer))for(const e of r.layer)e&&Array.isArray(e.params)&&n(e.params);return r}(e,c.parameterValues)),function(e){const t=JSON.parse(JSON.stringify(e)),r=["vconcat","hconcat","concat"];if(!r.some(e=>Array.isArray(t[e])))return t;const n=[];if(Array.isArray(t.params))for(const e of t.params)e&&"object"==typeof e&&e.name&&e.select&&n.push({name:e.name,param:e});if(0===n.length)return t;for(const{name:e,param:a}of n){const n=a.select?.fields||[],i="legend"===a.select?.bind;let s=null;for(const e of r)if(Array.isArray(t[e])){s=t[e];break}if(!s||0===s.length)continue;let o=0;for(let e=0;e<s.length;e++){const t=s[e];if(Ht(t,n)||i&&Bt(t,n)){o=e;break}}const l=s[o];l.params||(l.params=[]),l.params.push(a);const c=t.params??[];t.params=c.filter(t=>t.name!==e)}return Array.isArray(t.params)&&0===t.params.length&&delete t.params,t}(e)):null},[R,d,K,c?.parameterValues]),te=ee((e,t)=>{if(!e||"object"!=typeof e)return e;if(e.hconcat&&Array.isArray(e.hconcat)){const r=e.hconcat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,hconcat:e.hconcat.map(e=>te(e,a))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>te(e,t))};if(e.concat&&Array.isArray(e.concat)){const r=e.columns??e.concat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,concat:e.concat.map(e=>te(e,a))}}const r=e.width;return"container"===r||"number"==typeof r&&r>t?{...e,width:t}:e},[]),re=ee((e,t=!1)=>{if(!G)return null;const r=function(e){const t={background:"transparent",view:{stroke:"transparent"},range:{category:Ut.categorical,diverging:Ut.diverging,heatmap:Ut.purples,ramp:Ut.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:"round"},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:"#a1a1aa",titleColor:"#e4e4e7",gridColor:"#3f3f46",domainColor:"#52525b",tickColor:"#52525b",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:"#a1a1aa",titleColor:"#e4e4e7",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:"#fafafa",font:"Inter, system-ui, sans-serif",fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:"#71717a",titleColor:"#3f3f46",gridColor:"#e4e4e7",domainColor:"#d4d4d8",tickColor:"#d4d4d8",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:"#71717a",titleColor:"#3f3f46",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:"#18181b",font:"Inter, system-ui, sans-serif",fontSize:14,fontWeight:600}}}(_),n=t?"undefined"!=typeof window?Math.min(window.innerWidth-80,1400):1200:J>0?J-24:500,a="vconcat"in G||"hconcat"in G||"concat"in G,i=a?{type:"pad",contains:"padding"}:{type:"fit",contains:"padding"};let s=G;a&&n&&(s=te(G,n));const l=s.width,c=a?void 0:"container"===l?n:l??n,{width:d,...u}=s;return{$schema:"https://vega.github.io/schema/vega-lite/v6.json",...!a&&c?{width:c}:{},height:t?void 0:e,autosize:i,...a?s:u,...o&&!G.title?{title:o}:{},config:{...r,...G.config}}},[G,o,_,J,te]),ne=ee(async()=>{const e=y?x.current:b.current;if(e&&!m)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),p(!0),setTimeout(()=>p(!1),2e3))},"image/png")}catch(e){console.error("Failed to copy chart:",e)}},[m,y]),ae=ee(async()=>{const e=y?x.current:b.current;if(e&&!u){h(!0);try{const t=await e.toImageURL("png",2),r=document.createElement("a");r.download=`${o||"chart"}.png`,r.href=t,r.click()}catch(e){console.error("Failed to export chart:",e)}finally{h(!1)}}},[o,u,y]),se=ee(e=>{b.current=e,g(null)},[]),oe=ee(e=>{x.current=e},[]),le=ee(e=>{console.error("Vega-Lite rendering error:",e),g(e instanceof Error?e.message:"Unknown error")},[]),ce=ee(()=>{v(e=>!e)},[]);Q(()=>{g(null)},[d]);const de=({className:r})=>t("div",{className:Tt("flex items-center gap-2",r),children:[t(i,{variant:"unstyled",onClick:ne,disabled:m,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1",title:s("agent.copyToClipboard"),children:[e(m?C:S,{className:"w-3 h-3"}),s(m?"agent.copied":"agent.copy")]}),t(i,{variant:"unstyled",onClick:ae,disabled:u,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1",title:s("agent.exportAsPng"),children:[e(A,{className:"w-3 h-3"}),s(u?"agent.exporting":"agent.export")]}),M&&t(i,{variant:"unstyled",onClick:ce,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1",title:s(y?"agent.exitFullscreen":"agent.fullscreen"),children:[e(y?j:O,{className:"w-3 h-3"}),s(y?"agent.exit":"agent.fullscreen")]})]});if(F||K&&!R)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{className:"flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded",style:{width:"100%",height:q},children:t("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e(k,{className:"w-5 h-5 animate-spin"}),e("span",{className:"text-sm",children:"Loading data from artifacts..."})]})})]})});if(E)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{style:{width:"100%",height:q},children:e(qt,{error:E,chartTitle:o})})]})});if(f)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{style:{width:"100%",height:q},children:e(qt,{error:f,chartTitle:o})})]})});const ue=re(q),fe=re(0,!0);return ue?("undefined"!=typeof window&&localStorage.getItem("DEBUG_VEGA_RENDERS")&&console.log("VegaLite rendering with spec:",{title:o,hasData:!!ue.data?.values,dataLength:ue.data?.values?.length}),t(r,{children:[e("div",{className:Tt("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",z&&"border-2"),children:t("div",{className:"flex flex-col gap-2 p-3",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||(z?"Dashboard":"Chart")}),z&&e("span",{className:"text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300",children:"Interactive"})]}),e(de,{})]}),l&&e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:l}),e("div",{ref:w,className:"bg-white dark:bg-gray-900 rounded overflow-hidden",style:{width:"100%",height:q,minWidth:0},children:e(pe,{spec:ue,onEmbed:e=>se(e.view),onError:le,options:{renderer:c?.renderer||"canvas",actions:!1}})})]})}),t(_t,{isOpen:y,onClose:()=>v(!1),title:o||(z?"Dashboard":"Chart"),description:l,children:[e("div",{className:"w-full h-full min-h-[calc(100vh-200px)]",children:fe&&e(pe,{spec:fe,onEmbed:e=>oe(e.view),onError:le,options:{renderer:c?.renderer||"canvas",actions:!1}})}),e("div",{className:"absolute bottom-6 end-6",children:e(de,{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700"})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),Zt=B.createContext({});function Xt({children:t,artifactRunId:r,onProposalSelect:n,onProposalSubmit:a,MarkdownRenderer:i}){const s=Y(()=>({artifactRunId:r,onProposalSelect:n,onProposalSubmit:a,MarkdownRenderer:i}),[r,n,a,i]);return e(Zt.Provider,{value:s,children:t})}function Yt(){return B.useContext(Zt)}const Qt={chart:{icon:D,label:"chart",defaultHeight:200},mermaid:{icon:E,label:"diagram",defaultHeight:150},proposal:{icon:T,label:"options",defaultHeight:100},code:{icon:I,label:"code",defaultHeight:80},image:{icon:F,label:"image",defaultHeight:150},link:{icon:L,label:"link",defaultHeight:24},expand:{icon:A,label:"content",defaultHeight:100},table:{icon:R,label:"table",defaultHeight:150},markdown:{icon:P,label:"content",defaultHeight:100},"fusion-fragment":{icon:I,label:"fragment",defaultHeight:150}};function er({type:r,error:n,onRetry:a,message:s,height:o}){const l=Qt[r],c=o??l.defaultHeight,d="link"===r;if(n)return t("div",{className:"flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive "+(d?"inline-flex px-2 py-1 text-sm":"p-4"),style:d?void 0:{minHeight:c},children:[t("span",{className:"text-destructive",children:["Failed to load ",l.label]}),a&&e(i,{variant:"unstyled",onClick:a,className:"ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive",children:"Retry"})]});const u=l.icon;return d?t("span",{className:"inline-flex items-center gap-1 text-muted animate-pulse",children:[e(u,{className:"h-3 w-3"}),e("span",{children:s||`Loading ${l.label}...`})]}):t("div",{className:"flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse",style:{minHeight:c},children:[e(u,{className:"h-8 w-8 text-muted"}),e("span",{className:"text-sm text-muted",children:s||`Loading ${l.label}...`}),e("div",{className:"flex gap-1",children:[...Array(3)].map((t,r)=>e("div",{className:"h-2 w-2 rounded-full bg-muted animate-bounce",style:{animationDelay:150*r+"ms"}},r))})]})}class tr extends B.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){const{type:r,fallbackCode:n}=this.props;return t("div",{className:"space-y-2",children:[e(er,{type:r,error:this.state.error?.message||"Rendering failed",onRetry:this.handleRetry}),n&&t("details",{className:"text-sm",children:[e("summary",{className:"cursor-pointer text-muted hover:text-foreground",children:"Show raw content"}),e("pre",{className:"mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs",children:e("code",{children:n})})]})]})}return this.props.children}}function rr(e){if("object"!=typeof e||null===e)return null;const t=e;return"vega-lite"===t.library&&"spec"in t&&"object"==typeof t.spec&&null!==t.spec?t:"string"==typeof t.$schema&&t.$schema.includes("vega")?{library:"vega-lite",spec:t}:null}function nr({content:r}){const{headers:n,rows:a}=Y(()=>{if(!Array.isArray(r)||0===r.length)return{headers:[],rows:[]};const e=r[0];if("object"!=typeof e||null===e)return{headers:[],rows:[]};const t=Object.keys(e),n=r.map(e=>t.map(t=>{const r=e[t];return null==r?"":"object"==typeof r?JSON.stringify(r):String(r)}));return{headers:t,rows:n}},[r]);return 0===n.length?e(er,{type:"table",error:"No table data found"}):t("div",{className:"overflow-x-auto",children:[t("table",{className:"min-w-full text-sm border-collapse",children:[e("thead",{children:e("tr",{className:"border-b",children:n.map((t,r)=>e("th",{className:"px-3 py-2 text-start font-medium text-muted",children:t},r))})}),e("tbody",{children:a.slice(0,100).map((t,r)=>e("tr",{className:"border-b border-muted/20",children:t.map((t,r)=>e("td",{className:"px-3 py-2",children:t},r))},r))})]}),a.length>100&&t("div",{className:"text-sm text-muted py-2",children:["Showing 100 of ",a.length," rows"]})]})}function ar({content:t,path:r}){const n=r.split(".").pop()?.toLowerCase()||"",a="string"==typeof t?t:JSON.stringify(t,null,2);return e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{className:`language-${n}`,children:a})})}function ir(e){return de.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:["use"],FORBID_TAGS:["foreignObject"]})}function sr(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;if(!/viewBox/i.test(r)){const e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r);e&&t&&(r+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return r=r.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,"").replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,""),/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}function or({content:t}){const r=Y(()=>{const e="string"==typeof t?t.trim():"";return e?sr(ir(e)):null},[t]);return r?e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}}):e(er,{type:"expand",error:"Empty mockup"})}function lr({content:t,path:r}){const n="string"==typeof t?t:"",a=r.split("/").pop()||"Artifact image";return e("img",{src:n,alt:a,className:"max-w-full h-auto rounded",loading:"lazy"})}function cr({content:t,renderType:r,path:n,runId:a,contentType:i}){const{MarkdownRenderer:s}=Yt(),o=Y(()=>"auto"!==r?r:function(e,t,r){const n=t.split(".").pop()?.toLowerCase();if("svg"===n)return"mockup";if(["png","jpg","jpeg","gif","webp"].includes(n||""))return"image";if("md"===n)return"markdown";if("csv"===n)return"table";if("json"===r&&"object"==typeof e&&null!==e){const t=e;if("string"==typeof t.$schema&&t.$schema.includes("vega"))return"vega-lite";if("vega-lite"===t.library&&"spec"in t)return"vega-lite";if("template"in t&&"data"in t)return"fusion-fragment";if(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])return"table"}return"code"}(t,n,i),[t,n,i,r]);switch(o){case"chart":{const r=rr(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Gt,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Only Vega-Lite charts are supported. Recharts rendering has been retired."})}case"vega-lite":{const r=rr(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Gt,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}case"fusion-fragment":{const r=t;return console.log("[ArtifactContentRenderer] fusion-fragment:",{hasTemplate:!!r.template,hasData:!!r.data,runId:a,hasVegaLiteChart:!!Gt}),r.template&&r.data?e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(le,{data:r.data,ChartComponent:Gt,artifactRunId:a,children:e(ce,{code:JSON.stringify(r.template),data:r.data})})}):e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(ce,{code:JSON.stringify(t)})})}case"table":return e(tr,{type:"table",fallbackCode:JSON.stringify(t,null,2),children:e(nr,{content:t})});case"markdown":{const r="string"==typeof t?t:String(t);return e(tr,{type:"markdown",fallbackCode:r,children:s?e(s,{artifactRunId:a,children:r}):e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{children:r})})})}case"mockup":return e(tr,{type:"expand",fallbackCode:"string"==typeof t?t:n,children:e(or,{content:t})});case"image":return e(tr,{type:"image",fallbackCode:n,children:e(lr,{content:t,path:n})});default:return e(ar,{content:t,path:n})}}class dr{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}}const ur=K(null);function hr({components:t,children:r}){const n=Y(()=>{const e=new dr;for(const[r,n]of Object.entries(t))e.registerComponent(r,n);return e},[t]);return e(ur.Provider,{value:n,children:r})}function mr(){return G(ur)}function pr(e){const t=G(ur);if(t)return t.getComponent(e)}const fr='Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function gr({code:t,className:r}){const n=X(null),[a,i]=Z(null),[s,o]=Z(null),l=re().replace(/:/g,"_");return Q(()=>{let e=!1;return(async()=>{if(!t.trim())return i(null),void o(null);try{o(null);const r=`mermaid-${l}-${Date.now()}`,n=function(e){const t=e.trim();let r="",n=!1,a=!1;for(let e=0;e<t.length;e++){const i=t[e],s=e>0?t[e-1]:"";if('"'!==i||a||"\\"===s)if("'"!==i||n||"\\"===s){if((n||a)&&"\\"===i){let n=e;for(;"\\"===t[n];)n++;if("n"===t[n]){r+="<br/>",e=n;continue}}r+=i}else a=!a,r+=i;else n=!n,r+=i}return r}(t),{svg:a}=await ge.render(r,n),s=function(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let r=t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"");return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}(a);e||i(s)}catch(t){if(!e){const e=t instanceof Error?t.message:"Failed to render mermaid diagram";o(e),i(null)}}})(),()=>{e=!0}},[t,l]),s?null:e("div",a?{ref:n,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${r||""}`,dangerouslySetInnerHTML:{__html:a}}:{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${r||""}`,children:e("div",{className:"h-32 bg-gray-200 dark:bg-gray-700 rounded"})})}function yr({runId:e,path:t,parseJson:r=!0}){const{client:n}=he(),a=Dt(),i=X(n);i.current=n;const s=X(a);s.current=a;const[o,l]=Z({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),c=ee(async()=>{if(!e)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No run ID provided",contentType:void 0});if(!t)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No artifact path provided",contentType:void 0});l(e=>({...e,isLoading:!0,error:void 0}));const n=i.current,a=s.current,o=function(e){const t=e.split(".").pop()?.toLowerCase();switch(t){case"json":return"json";case"md":case"txt":case"csv":case"yaml":case"yml":default:return"text";case"png":case"jpg":case"jpeg":case"gif":case"webp":case"pdf":return"binary"}}(t);try{const i=zt(e,t,"inline");let s;if(a)s=await a.getOrFetch(i,async()=>(await n.files.getArtifactDownloadUrl(e,t,"inline")).url);else{s=(await n.files.getArtifactDownloadUrl(e,t,"inline")).url}const c=await fetch(s);if(!c.ok)throw new Error(`Failed to fetch artifact: ${c.status} ${c.statusText}`);if("binary"===o)return void l({data:s,rawContent:void 0,isLoading:!1,error:void 0,contentType:o});const d=await c.text();let u;if(r&&"json"===o)try{u=JSON.parse(d)}catch{u=d}else u=d;l({data:u,rawContent:d,isLoading:!1,error:void 0,contentType:o})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch artifact";console.error("Failed to fetch artifact content:",t,e),l({data:void 0,rawContent:void 0,isLoading:!1,error:r,contentType:o})}},[e,t,r]);Q(()=>{c()},[c]);const d=ee(()=>{l({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),c()},[c]);return{data:o.data,rawContent:o.rawContent,isLoading:o.isLoading,error:o.error,contentType:o.contentType,retry:d}}function vr(e){const t=e.trim();if(t.length<2)return!0;if(!t.startsWith("{"))return!1;try{return JSON.parse(t),!1}catch(e){const r=["unexpected end","unterminated string","expected","unexpected token"],n=(e instanceof Error?e.message:"").toLowerCase();if(r.some(e=>n.includes(e))){let e=0,r=0,n=!1,a=!1;for(const i of t)a?a=!1:"\\"!==i?'"'!==i?n||("{"===i?e++:"}"===i?e--:"["===i?r++:"]"===i&&r--):n=!n:a=!0;return e>0||r>0||n}return!1}}function br(e){try{let t=e.trim();const r=t.indexOf("{"),n=t.lastIndexOf("}");return-1!==r&&n>r&&(t=t.slice(r,n+1)),JSON.parse(t)}catch{return null}}function xr({code:t}){const{artifactRunId:r}=Yt();r||console.warn("[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext");const n=Y(()=>vr(t),[t]),a=Y(()=>{if(n)return null;const e=br(t);return e?{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(Gt,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}function wr({code:t}){const{artifactRunId:r}=Yt();r||console.warn("[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext");const n=Y(()=>vr(t),[t]),a=Y(()=>{if(n)return null;const e=br(t);if(!e)return null;const r=function(e){const t="string"==typeof e.$schema&&e.$schema.includes("vega"),r="vega-lite"===e.library&&"spec"in e;return t||r?"vega-lite":null}(e);return r?"vega-lite"===e.library&&"spec"in e&&"object"==typeof e.spec?e:{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(Gt,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite chart specification"})}function Nr({code:t}){const r=t.trim();return r?e(tr,{type:"mermaid",fallbackCode:t,children:e(gr,{code:r})}):e(er,{type:"mermaid",error:"Empty diagram"})}function kr({code:t}){const r=Y(()=>{const e=t.trim();return e?sr(ir(e)):null},[t]);return r?e(tr,{type:"code",fallbackCode:t,children:e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}})}):e(er,{type:"code",error:"Empty mockup"})}function Cr({code:t,language:r}){const{artifactRunId:n}=Yt(),a=t.trim(),i=Y(()=>{if(!r?.includes(":"))return"auto";const e=r.split(":")[1];return["chart","vega-lite","table","markdown","fusion-fragment","mockup","code","image","auto"].includes(e)?e:"auto"},[r]),{data:s,isLoading:o,error:l,contentType:c}=yr({runId:n,path:a});return n?o?e(er,{type:"expand",message:`Loading ${a}...`}):l?e(er,{type:"expand",error:`Failed to load artifact: ${l}`}):void 0===s?e(er,{type:"expand",error:"No content found in artifact"}):e(cr,{content:s,renderType:i,path:a,runId:n,contentType:c}):e(er,{type:"expand",error:"No artifact run ID available"})}function Sr(e){return e?.startsWith("expand")??!1}function Ar(){return{chart:wr,"vega-lite":xr,vegalite:xr,mermaid:Nr,mockup:kr,svg:kr}}function jr(e){return e.trim().replace(/^\/+/,"")}function Or(e){return e.startsWith("artifact:")?{scheme:"artifact",path:e.slice(9).trim()}:e.startsWith("image:")?{scheme:"image",path:e.slice(6).trim()}:e.startsWith("store:")?{scheme:"store",path:jr(e.slice(6))}:e.startsWith("document:")?{scheme:"document",path:jr(e.slice(9))}:e.startsWith("collection:")?{scheme:"collection",path:jr(e.slice(11))}:{scheme:"standard",path:e}}function $r(e,t){switch(e){case"store":case"document":return t?`/store/objects/${t}`:null;case"collection":return t?`/store/collections/${t}`:null;default:return null}}function Ir({rawUrl:e,artifactRunId:t,disposition:r="inline"}){const{client:n}=he(),a=Dt(),i=X(n);i.current=n;const s=X(a);s.current=a;const{scheme:o,path:l}=Or(e),c=$r(o,l),[d,u]=Z(()=>{if(c)return{url:c,isLoading:!1,error:void 0};if("standard"===o)return{url:e,isLoading:!1,error:void 0};if(a&&("artifact"===o||"image"===o)){let e;e="artifact"===o&&t&&!Vt(l)?zt(t,l,r):Mt(l);const n=a.getUrl(e);if(n)return{url:n,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),h=ee(async()=>{if(c||"standard"===o)return;if("artifact"!==o&&"image"!==o)return void u({url:void 0,isLoading:!1,error:`Unknown scheme: ${o}`});u(e=>({...e,isLoading:!0,error:void 0}));const e=i.current,n=s.current;try{let a;if("artifact"===o)if(t&&!Vt(l)){const i=zt(t,l,r);if(n)a=await n.getOrFetch(i,async()=>(await e.files.getArtifactDownloadUrl(t,l,r)).url);else{a=(await e.files.getArtifactDownloadUrl(t,l,r)).url}}else{const t=Mt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}else{const t=Mt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}u({url:a,isLoading:!1,error:void 0})}catch(e){const t=e instanceof Error?e.message:"Failed to resolve URL";console.error("Failed to resolve URL:",l,e),u({url:void 0,isLoading:!1,error:t})}},[o,l,t,r,c]);Q(()=>{if(d.url&&!d.error)return;let e=!1;return e||(async()=>{await h()})(),()=>{e=!0}},[h,d.url,d.error]);const m=ee(()=>{u({url:void 0,isLoading:!0,error:void 0}),h()},[h]);return{url:d.url,isLoading:d.isLoading,error:d.error,scheme:o,retry:m}}function Pr({src:r,alt:n,caption:a,className:i,artifactRunId:s}){const o=r||"",{scheme:l}=Or(o);return"standard"===l?t("figure",{className:"my-4",children:[e("img",{src:r,alt:n,className:i}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):e(Rr,{rawSrc:o,alt:n,caption:a,artifactRunId:s,className:i})}function Rr({rawSrc:r,alt:n,caption:a,artifactRunId:i,className:s}){const{url:o,isLoading:l,error:c,retry:d}=Ir({rawUrl:r,artifactRunId:i,disposition:"inline"});return l?e(er,{type:"image",message:n?`Loading ${n}...`:void 0}):c?e(er,{type:"image",error:c,onRetry:d}):o?t("figure",{className:"my-4",children:[e("img",{src:o,alt:n,className:s}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):null}function Lr({node:t,src:r,alt:n,className:a,artifactRunId:i,ExistingImg:s,...o}){const l=r||"",{scheme:c}=Or(l);return"standard"===c?"function"==typeof s?e(s,{node:t,src:r,alt:n,...o}):e("img",{src:r,alt:n,className:a,...o}):e(Fr,{rawSrc:l,alt:n,artifactRunId:i,className:a,rest:o})}function Fr({rawSrc:t,alt:r,artifactRunId:n,className:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Ir({rawUrl:t,artifactRunId:n,disposition:"inline"});return o?e(er,{type:"image",message:r?`Loading ${r}...`:void 0}):l?e(er,{type:"image",error:l,onRetry:c}):s?e("img",{src:s,alt:r,className:a,...i}):null}function Tr({node:t,href:r,children:n,className:a,artifactRunId:i,ExistingLink:s,...o}){const l=r||"",{scheme:c,path:d}=Or(l),u=$r(c,d);return u?"function"==typeof s?e(s,{node:t,href:u,...o,children:n}):e("a",{href:u,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):"standard"===c?"function"==typeof s?e(s,{node:t,href:r,...o,children:n}):e("a",{href:r,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):e(Er,{rawHref:l,artifactRunId:i,className:a,rest:o,children:n})}function Er({rawHref:t,artifactRunId:r,className:n,children:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Ir({rawUrl:t,artifactRunId:r,disposition:"attachment"});return o?e("span",{className:"inline-flex items-center gap-1 text-muted",children:e(er,{type:"link"})}):l?e("span",{className:"inline-flex items-center gap-1",children:e(er,{type:"link",error:l,onRetry:c})}):e("a",{href:s||"#",...i,className:n,target:"_blank",rel:"noopener noreferrer",children:a})}ge.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:fr,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:fr}});const Dr=["artifact:","image:","store:","document://","collection:"],Vr=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,zr=/`[^`\n]*`/g,Mr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,qr=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function _r(e){return Dr.some(t=>e.startsWith(t))}function Ur(e){return e.replace(Vr,(e,t,r,n)=>`${t}${function(e){const t=e.trim();if(t.startsWith("<")){const r=t.indexOf(">");if(r>0&&_r(t.slice(1,r).trim()))return e}const r=t.match(qr),n=r?.index??-1,a=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):"";return _r(a)?`<${a}>${i}`:e}(r)}${n}`)}function Wr(e){let t="",r=0;for(const n of e.matchAll(zr))t+=Ur(e.slice(r,n.index)),t+=n[0],r=n.index+n[0].length;return t+=Ur(e.slice(r)),t}const Jr=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,Hr=/^\w+/;const Br=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,Kr=/`[^`\n]*`/g,Gr=/\\\$/g,Zr=/\\[^\s]/,Xr=/[{}]/,Yr=/[_^][\w{]/,Qr=/^[a-zA-Z]$/,en=/^[a-zA-Z]\s*=/,tn=/^\s/,rn=/\s$/,nn=/[+*/-]$/,an=/\^[+-]$/;function sn(e){return Zr.test(e)||Xr.test(e)||Yr.test(e)||Qr.test(e)||en.test(e)}function on(e){return!!tn.test(e)||(!!rn.test(e)||!(!nn.test(e)||an.test(e)))}function ln(e,t,r){const n=e.slice(t+1,r);return 0===n.length||n.includes("\n")?null:n}function cn(e){const t=function(e){const t=[];for(let r=0;r<e.length;r++)"$"===e[r]&&(r>0&&"\\"===e[r-1]||(r+1<e.length&&"$"===e[r+1]?r++:r>0&&"$"===e[r-1]&&(r<2||"\\"!==e[r-2])||t.push(r)));return t}(e);if(t.length<2)return e;const r=new Set,n=new Set,a=new Array(t.length-1);for(let r=0;r<t.length-1;r++)a[r]=ln(e,t[r],t[r+1]);const i=[];for(let e=0;e<t.length-1;e++){if(r.has(e))continue;const n=a[e];null!==n&&sn(n)&&(r.add(e),r.add(e+1),i.push([t[e],t[e+1]]))}let s=0;for(;s<t.length;){if(r.has(s)){s++;continue}let e=s+1;for(;e<t.length&&r.has(e);)e++;if(e>=t.length)break;if(e>s+1){n.add(t[s]),s++;continue}const i=a[s];null!==i?(on(i)&&(n.add(t[s]),n.add(t[e])),r.add(s),r.add(e),s=e+1):s++}for(let e=0;e<t.length;e++)r.has(e)||e+1<t.length&&r.has(e+1)&&n.add(t[e]);if(0===n.size&&0===i.length)return e;const o=[];let l=0;const c=Array.from(n).sort((e,t)=>e-t);let d=0,u=0;for(;d<c.length||u<i.length;){const t=d<c.length?c[d]:1/0;if(t<(u<i.length?i[u][0]:1/0))t>l&&o.push(e.slice(l,t)),o.push("\\$"),l=t+1,d++;else{const[t,r]=i[u];t>l&&o.push(e.slice(l,t));const n=e.slice(t,r+1);for(o.push(n.replace(Gr,"\\text{\\textdollar}")),l=r+1;d<c.length&&c[d]<=r;)d++;u++}}return l<e.length&&o.push(e.slice(l)),o.join("")}function dn(e){const t=[];let r=0;for(const n of e.matchAll(Kr))t.push(cn(e.slice(r,n.index))),t.push(n[0]),r=n.index+n[0].length;return t.push(cn(e.slice(r))),t.join("")}const un={note:"md-callout-info",tip:"md-callout-info",warning:"md-callout-attention",important:"md-callout-attention",caution:"md-callout-destructive"},hn={note:"Note",tip:"Tip",warning:"Warning",important:"Important",caution:"Caution"};function mn(){return e=>{je(e,e=>{if("containerDirective"!==e.type&&"leafDirective"!==e.type&&"textDirective"!==e.type)return;const t=e;t.data||(t.data={});const r=t.data,n=t.attributes||{},a=t.name;if("pagebreak"===a)return r.hName="hr",void(r.hProperties={className:"md-pagebreak"});if("columns"===a)return r.hName="div",void(r.hProperties={className:"md-columns"});if("column"===a){r.hName="div";const e={className:"md-column"};return n.width&&(e.style=`flex-basis:${n.width};flex-grow:0;flex-shrink:0`),void(r.hProperties=e)}if(a in un){r.hName="div",r.hProperties={className:`md-callout ${un[a]}`,"data-callout-type":a};const e=hn[a];if(e&&t.children){const r={type:"paragraph",data:{hName:"p",hProperties:{className:"md-callout-title"}},children:[{type:"text",value:e}]};t.children.unshift(r)}return}r.hName="div",r.hProperties={className:`md-${a}`,...Object.fromEntries(Object.entries(n).filter(([e])=>"class"!==e))},n.class&&(r.hProperties.className+=` ${n.class}`)})}}const pn=["artifact:","image:","store:","document:","document://","collection:"];function fn(e){return pn.some(t=>e.startsWith(t))?e:ve(e)}function gn(){return e=>{je(e,"html",(e,t,r)=>{const n=e,a=r;if("string"==typeof n.value&&/<!--[\s\S]*?-->/.test(n.value)&&a?.children&&"number"==typeof t)return a.children.splice(t,1),[Oe,t]})}}const yn=Ar();function vn({children:t,components:r,remarkPlugins:n=[],removeComments:a=!0,artifactRunId:i,className:s,codeClassName:o,inlineCodeClassName:l,linkClassName:c,imageClassName:d,onProposalSelect:u,onProposalSubmit:h}){const m=mr(),p=B.useMemo(()=>{return e=function(e){if(!e||!Dr.some(t=>e.includes(t)))return e;let t="",r=0;for(const n of e.matchAll(Mr))t+=Wr(e.slice(r,n.index)),t+=n[0],r=n.index+n[0].length;return t+=Wr(e.slice(r)),t}(function(e){if(!e?.includes("$"))return e;const t=[];let r=0;for(const n of e.matchAll(Br))t.push(dn(e.slice(r,n.index))),t.push(n[0]),r=n.index+n[0].length;return t.push(dn(e.slice(r))),t.join("")}(t)),e?.includes(":::")?e.replace(Jr,(e,t,r)=>{const n=r.trim(),a=Hr.exec(n);if(!a)return e;const i=a[0],s=n.slice(i.length).trim();return s?`${t}:::${i}\n${t}${s}\n${t}:::`:`${t}::${i}`}):e;var e},[t]),f=B.useMemo(()=>{const e=[ke,Ne,mn,Ce,xe,Ae,Se,...n];return a&&e.push(gn),e},[n,a]),g=B.useMemo(()=>[be],[]),y=B.useMemo(()=>({handlers:{...we}}),[]),v=B.useMemo(()=>{const t=r||{},n=t.code,a=t.a,s=t.img;return{...t,code:({node:t,className:r,children:a,...i})=>{const s=/language-([\w-]+)/.exec(r||""),c=!s,d=s?s[1]:"";if(!c&&d){if(m){const t=m.getComponent(d);if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if(Sr(d)){const t=String(a||"").trim();return e(Cr,{code:t,language:d})}const t=yn[d];if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if("function"==typeof n)return e(n,{node:t,className:r,...i,children:a});return e("code",{...i,className:c?`px-1.5 py-0.5 rounded ${l||""}`:` ${o||""}`,children:a})},a:t=>{const{node:r,href:n,children:s,...o}=t;return e(Tr,{node:r,href:n,className:c,artifactRunId:i,ExistingLink:"function"==typeof a?a:void 0,...o,children:s})},img:t=>{const{node:r,src:n,alt:a,title:o,...l}=t;return o?e(Pr,{src:n,alt:a,caption:o,className:d,artifactRunId:i}):e(Lr,{node:r,src:n,alt:a,className:d,artifactRunId:i,ExistingImg:"function"==typeof s?s:void 0,...l})}}},[r,i,m,o,l,c,d]),b=e(Xt,{artifactRunId:i,onProposalSelect:u,onProposalSubmit:h,MarkdownRenderer:vn,children:e(ye,{remarkPlugins:f,rehypePlugins:g,remarkRehypeOptions:y,components:v,urlTransform:fn,children:p})});return e("div",s?{className:`md-content ${s}`,children:b}:{className:"md-content",children:b})}function bn({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function xn({className:r,properties:n}){return e(l,{className:r,children:e("tbody",{children:n.map(r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(c,{description:r.description,placement:"top",children:e(V,{className:"size-3 ms-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name))})})}function wn({content:t,...r}){const n=X(null);return Q(()=>{if(!n.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(n.current.innerHTML="");Object.entries(r).forEach(([t,r])=>{if(null==r)return;const n="className"===t?"class":t;e.setAttribute(n,String(r))}),n.current.innerHTML="",n.current.appendChild(e)}),e("span",{ref:n})}function Nn(t){return r=>e(wn,{content:t,...r})}function kn(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}var Cn;!function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(Cn||(Cn={}));const Sn=function(){const e=Object.values(Cn),t=[...e];for(const r of e)t.push(`${r}[]`);return e.sort(),t}();function An({value:r,onChange:n,onCancel:a,onSave:s}){const{t:o}=ie(),[l,c]=Z(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(jn,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:a,onSave:s})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(On,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:a,onSave:s})}),t("div",{children:[e(i,{variant:"ghost",size:"xs",onClick:()=>c(!0),title:o("widgets.schema.editDescription"),children:e(z,{className:"size-4"})}),e($n,{value:r.description,isOpen:l,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),c(!1)}})]})]})}function jn({value:t,onChange:r,onCancel:a,onSave:i}){const s=X(null);Q(()=>{s.current?.focus()},[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":i?.();break;case"Escape":a?.()}},ref:s,value:t,onChange:e=>{r(e.target.value)},className:n.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function On({value:t,onChange:r,onCancel:a,onSave:i}){return e(d,{className:n.INPUT_UNSTYLED,options:Sn,value:t||"",onBlur:()=>{i?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?i?.():"Escape"===e.key&&a?.())},popupClass:"schema-type-suggest-popup z-90"})}function $n({value:r,isOpen:n,onClose:a}){const{t:i}=ie();return t(u,{isOpen:n,onClose:a,children:[e(h,{children:i("widgets.schema.editDescription")}),e(In,{value:r,onSave:a})]})}function In({value:n,onSave:a}){const{t:s}=ie(),o=X(null),[l,c]=Z(n||"");return Q(()=>{o.current?.focus()},[]),t(r,{children:[e(m,{className:"h-max",children:e("textarea",{ref:o,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:l,onChange:e=>c(e.target.value)})}),e(p,{children:e(i,{onClick:()=>a(l),children:s("store.saveChanges")})})]})}function Pn({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ms-2 text-sm text-muted",children:r.type||""})]}):null}function Rn(e,t){const r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const n=e.items;n.type=r,t.isObject&&!n.properties&&(n.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function Ln(e){let t,r=!1,n=!1;const a=e.type;if(Array.isArray(a))for(const e of a)"null"===e?r=!0:t||(t=e);else t=a;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?Fn(e[0].type):Fn(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:n,isObject:"object"===t,name:i}}function Fn(e){return e?Array.isArray(e)?e.find(e=>"null"!==e)||"any":e:"any"}let Tn=0;class En{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new Dn("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new Dn("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new En(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Dn{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,n){if(this.schema=t,this.loader=r,this.parent=n,this.name=e,this.type=Ln(t),this.parent){const t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return"string"==typeof this.schema.title?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];const e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(e,t){for(const r of Object.keys(e)){const n=e[r],a=new Dn(r,n,this.loader,this);t.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++Tn}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const n=function(e,t,r,n=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const a={};return Rn(a,r),e.properties[t]=a,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),a}(this._getPropertiesSchema(),e,t,r),a=new Dn(e,n,this.loader,this);return this.children.push(a),a}remove(){if(this.parent?.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const n=e.properties,a={};for(const e of Object.keys(n)){const i=n[e];e===t?a[r]=i:a[e]=i}e.properties=a}e.required&&(e.required=e.required.map(e=>e===t?r:e))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const n=e.required.indexOf(t);r?n<0&&e.required.push(t):n>-1&&e.required.splice(n,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const n=r!==this.schema.type;return e.type&&(Rn(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):n&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),n=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),n=!1);const a=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const n=Cn[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===Cn.object}}(t);let i;return"text"===a.name?(a.name=Cn.string,i="textarea"):"media"===a.name?(a.name=Cn.any,i="media"):"document"===a.name?(a.name=Cn.any,i="document"):i=null,{name:r,type:a,isRequired:n,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),n=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,n)}}function Vn(e){const[t,r]=Z(new En(e||{type:"object",properties:{}}).withChangeListener(e=>{r(e.clone())}));return t}const zn="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Mn=`${zn} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,qn=`${zn} shadow-xs ring-1 ring-inset ring-ring`;function _n({value:r,onChange:n,onDelete:a,outlineOnHover:i=!1,editOnClick:s=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:d,isEditing:u=!1,readonly:h=!1,onValidate:m}){const{on:p,off:g,isOn:y}=f(u),[v,b]=Z();return t("div",{className:"",children:[y&&!h?e(Wn,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void b(t);b(void 0)}n(e)&&g()},onCancel:g,editor:c,skipClickOutside:e=>!!d&&d(e)}):e(Un,{value:r,onEdit:p,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:s,onDelete:a,readonly:h}),v&&e("div",{className:"text-red-500 text-sm",children:v})]})}function Un({viewer:r,value:n,onEdit:a,editOnClick:s,outlineOnHover:o,placeholder:l,onDelete:c,readonly:d}){const u="invisible group-hover:visible";return t("div",{role:s?"button":void 0,tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&a()},onClick:()=>{s&&a()},className:b("flex justify-start items-center group",o?Mn:zn,{"cursor-pointer":s}),children:[e(r,{value:n,placeholder:l}),t("div",{className:"ms-auto flex space-x-2",children:[!d&&c&&e(i,{variant:"ghost",size:"sm",className:u,onClick:c,children:e(N,{className:"size-4"})}),d?null:e(i,{variant:"ghost",size:"sm",className:u,onClick:a,children:e(M,{className:"size-4"})})]})]})}function Wn({editor:t,value:r,onSave:n,onCancel:a,skipClickOutside:i}){const[s,o]=Z(r),l=X(r),[c,d]=Z(null),u=()=>{n(l.current)},h=g(u,i);return e("div",{ref:h,children:e("div",{className:qn,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:s,onChange:(e,t=!1)=>{o(e),l.current=e,t&&(c&&clearTimeout(c),d(setTimeout(()=>{n(e)},500)))},onSave:u,onCancel:a})})})})}function Jn(e){const t=e.target;return!!t.closest?.(".schema-type-suggest-popup")}function Hn({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map(e=>Bn(e,n)),n?null:e(Yn,{parent:r.root})]})}function Bn(t,r){return t.isParent?e(Gn,{property:t,readonly:r},t.name):e(Kn,{node:t,readonly:r},t.name)}function Kn({node:t,readonly:r}){return e("li",{children:e(Xn,{property:t,readonly:r})})}function Gn({property:r,readonly:n}){const[a,s]=Z(!0),o=a?q:_;return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e(i,{variant:"ghost",size:"icon",onClick:()=>s(!a),"aria-label":a?`Collapse ${r.name}`:`Expand ${r.name}`,"aria-expanded":a,children:e(o,{className:"size-4 cn-rtl-flip"})}),e("div",{className:"flex-1",children:e(Xn,{property:r,readonly:n})})]}),a&&t("ul",{className:"ms-4 border-s border-gray-400 border-dashed",children:[(r.children||[]).map(e=>Bn(e,n)),n?null:e(Yn,{parent:r})]})]})}function Zn(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function Xn({property:t,readonly:r}){const{t:n}=ie(),a=y(),i=t.resetIsNew(),s=kn(t);return e(_n,{value:s,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return a({status:"error",title:n("widgets.schema.invalidPropertyDeclaration"),description:v(e),duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:An,viewer:Pn,outlineOnHover:!0,isEditing:i,skipClickOutside:Jn,readonly:r,onValidate:e=>Zn(e.name)})}function Yn({parent:r}){return t(i,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:Cn.string},!0).isNew=!0,r.reloadTree()},children:[e(w,{className:"size-4"}),"Add property"]})}function Qn({onDrop:r,message:n,buttonLabel:a,allowFolders:s=!0,className:o=""}){const{t:l}=ie(),c=a??l("upload.uploadFiles"),[d,u]=Z(!1),h=X(null),m=e=>{if(e&&e.length>0){const t=Array.from(e);if(t.some(e=>e.webkitRelativePath?.includes("/"))){const e=new Set(t.map(e=>e.webkitRelativePath.split("/")[0]).filter(Boolean)).size,n=t.length,a=l("upload.preparingFolder",{count:e,folderCount:e,fileCount:n}),i={count:t.length,message:a};r(t,i)}else{const e={count:t.length,message:l("upload.preparingFiles",{count:t.length})};r(t,e)}}};return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${d?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${o}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&u(!0)},onDragLeave:e=>{e.preventDefault(),h.current&&!h.current.contains(e.relatedTarget)&&u(!1)},onDrop:async e=>{if(e.preventDefault(),u(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],a=new Set,i=async e=>{if(function(e){return e.isFile}(e)){const t=await new Promise(t=>{e.file(r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)})});!t.name.startsWith(".")&&t.size>0&&n.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&a.add(r)}else if(function(e){return e.isDirectory}(e)){const t=e.createReader(),r=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(r.map(i));const n=e.fullPath.substring(1);n&&a.add(n)}};try{if(await Promise.all(t.map(e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()})),n.length>0){const e=new Set(Array.from(a).map(e=>e.split("/")[0]).filter(Boolean)).size,t=n.length;let i="";i=e>0?l("upload.preparingFolder",{count:e,folderCount:e,fileCount:t}):l("upload.preparingFiles",{count:t}),r(n,{count:n.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const n=Array.from(e.dataTransfer.files);n.length>0&&r(n)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(U,{className:"h-12 w-12 mb-3 transition-colors "+(d?"text-primary":"text-muted/50")}),e("p",{className:"text-muted",children:n}),t("div",{className:"flex gap-2 justify-center mt-2",children:[e(i,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e?.click(),e.onchange=()=>{m(e.files)}},children:c}),s&&e(i,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e.webkitdirectory=!0,e?.click(),e.onchange=()=>{m(e.files)}},children:l("upload.selectFolder")})]})]})}function ea({title:r,count:n,icon:a=e(W,{className:"h-4 w-4 text-green-500"}),items:i}){const{t:s}=ie(),[o,l]=Z(!1),c=re();return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("button",{type:"button","aria-expanded":o,"aria-controls":c,className:"w-full flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:()=>l(!o),children:[t("span",{className:"flex items-center",children:[e("span",{className:"me-2",children:a}),e("span",{className:"font-medium",children:r}),e("span",{className:"ms-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("span",{className:"text-muted","aria-hidden":"true",children:e("svg",{className:"h-5 w-5 transition-transform "+(o?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),o&&e("div",{id:c,className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r))}):e("div",{className:"text-sm text-muted py-2",children:s("upload.noItems")})})]})}function ta({files:r,className:n="",location:a,collection:i}){const{t:s}=ie(),o=r.filter(e=>"success"===e.status),l=r.filter(e=>"updated"===e.status),c=r.filter(e=>"skipped"===e.status),d=r.filter(e=>"failed"===e.status),u=o.length,h=l.length,m=c.length,p=d.length,f=r.length;return t("div",{className:`flex flex-col py-2 ${n}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 me-4 rounded-full bg-success/10 flex items-center justify-center",children:e(W,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[s("upload.filesProcessed",{count:f}),i?s("upload.inCollection",{collection:i}):"",a?s("upload.inFolder",{location:a}):""]})})]}),t("div",{className:"space-y-3 mt-2",children:[u>0&&e(ea,{title:s("upload.successfullyUploaded"),count:u,icon:e(W,{className:"h-4 w-4 text-green-500"}),items:o.map(e=>e.name)}),h>0&&e(ea,{title:s("upload.successfullyUpdated"),count:h,icon:e(W,{className:"h-4 w-4 text-blue-500"}),items:l.map(e=>e.name)}),m>0&&e(ea,{title:s("upload.skippedAlreadyExisted"),count:m,icon:e(J,{className:"h-4 w-4 text-amber-500"}),items:c.map(e=>e.name)}),p>0&&e(ea,{title:s("upload.failedToUpload"),count:p,icon:e(H,{className:"h-4 w-4 text-red-500"}),items:d.map(e=>e.name)})]})]})}const ra="#text",na="#comment",aa="#cdata",ia="DECLARATION_TAG",sa={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},oa={attributeKeyColor:"#FFD700",attributeValueColor:"#FF4500",tagColor:"#87CEFA",textColor:"#00FF00",separatorColor:"#FFD700",commentColor:"#BEBEBE",cdataColor:"#33CC66",fontFamily:"monospace"},la=K({theme:sa,collapsible:!1,indentSize:2}),ca=()=>G(la),da=new $e({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:na,cdataPropName:aa,parseTagValue:!1});function ua(r){const{indentation:n,children:a,isInline:i}=r,{theme:s}=ca();return t("div",{style:{color:s.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),a,e("span",{children:`${i?"":n}]]>`})]})}function ha(t){const{collapsible:r,theme:n}=ca(),{collapsed:a}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(ma,{fill:n.separatorColor,style:{transform:`rotate(${a?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function ma({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24","aria-hidden":"true",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function pa(e){const{collapsible:t,initialCollapsedDepth:r}=ca(),[n,a]=Z(()=>!(Pe(r)||!t)&&e>=r);return Q(()=>{a(!(Pe(r)||!t)&&e>=r)},[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>a(e=>!e),role:"button",style:{cursor:"pointer"}}:{}}}function fa(r){const{indentation:n,children:a,isInline:i,level:s}=r,{theme:o}=ca(),{collapsed:l,buttonProps:c}=pa(s);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(ha,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&a,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function ga(r){const{attributes:n}=r,{theme:a}=ca();return n?e("span",{children:Object.entries(n).map(([r,n])=>t("span",{children:[e("span",{style:{color:a.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:a.separatorColor},children:"="}),e("span",{style:{color:a.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`))}):null}function ya(r){const{indentation:n,tagKey:a,attributes:i}=r,{theme:s}=ca();return t("div",{children:[e("span",{style:{color:s.separatorColor},children:`${n}<?`}),e("span",{style:{color:s.tagColor},children:`${a.slice(1)}`}),e(ga,{attributes:i}),e("span",{style:{color:s.separatorColor},children:"?>"})]})}function va(e){return"string"==typeof e&&e.includes("\n")}function ba(e){const t=e[":@"],r=Re(e,":@"),[[n,a]]=Object.entries(r),i=function(e){switch(e){case ra:case aa:case na:return e;default:return e.startsWith("?")?ia:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:a,type:i}}function xa(e){return!!e&&Object.keys(e).length>0}function wa(n){const{indentation:a,tagKey:i,attributes:s,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:u,buttonProps:h}=pa(d),{theme:m}=ca();return t("div",{children:[t("span",{...h,children:[e("span",{children:a}),e(ha,{collapsed:u}),e("span",{style:{color:m.separatorColor},children:"<"}),e("span",{style:{color:m.tagColor},children:`${i}`}),!u&&e(ga,{attributes:s}),u&&xa(s)&&" ...",e("span",{style:{color:m.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!u&&o,u&&"...",e("span",{style:{color:m.separatorColor},children:`${l||u?"":a}</`}),e("span",{style:{color:m.tagColor},children:`${i}`}),e("span",{style:{color:m.separatorColor},children:">"})]})]})}function Na(t){const{hasSiblings:r,text:n,indentation:a,isText:i}=t,{theme:s}=ca(),o=i?{color:s.textColor}:void 0;return va(n)||r?e("div",{style:o,children:n.split("\n").filter(e=>!!e.trim()).map((t,r)=>e("div",{children:`${a}${t.trim()}`},`${r}`))}):e("span",{style:o,children:n})}function ka(t){const{elements:n,level:a=0,isText:i=!0}=t,{indentSize:s}=ca();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=ba(t),u=n.length>1,h=function(e,t){return new Array(t*e+1).join(" ")}(s,a),m=`${a}-${r}`,p=function(e){return"string"!=typeof e&&1===e.length&&ra in e[0]&&!va(e[0][ra])}(c);switch(d){case ra:return e(Na,{text:c,indentation:h,hasSiblings:u,isText:i},m);case na:return e(fa,{isInline:p,indentation:h,level:a,children:e(ka,{elements:c,level:a+1,isText:!1})},m);case aa:return e(ua,{indentation:h,isInline:p,children:e(ka,{elements:c,level:a+1,isText:!1})},m);case ia:return e(ya,{indentation:h,tagKey:o,attributes:l},m);default:return e(wa,{indentation:h,tagKey:o,attributes:l,isInline:p,hasChildren:c.length>0,level:a,children:e(ka,{elements:c,level:a+1})},m)}})}):null}function Ca(){return e("div",{children:"Invalid XML!"})}function Sa(t){const{theme:r,xml:n,collapsible:a=!1,indentSize:i=2,invalidXml:s,initalCollapsedDepth:o,initialCollapsedDepth:l}=t,[c,d]=Z(()=>document.documentElement.classList.contains("dark"));Q(()=>{const e=document.documentElement,t=new MutationObserver(()=>{d(e.classList.contains("dark"))});return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const u=Y(()=>({...c?oa:sa,...r}),[c,r]),{json:h,valid:m}=function(e){return Y(()=>{try{const t=Ie.validate(e);if(!0!==t)throw new Error(t.err.msg||"Invalid XML!");const r=da.parse(e);if("string"==typeof e&&e.trim().length>0&&0===r.length)throw new Error("Invalid XML!");return{json:r,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}(n),p=Y(()=>({theme:u,collapsible:a,indentSize:i,initialCollapsedDepth:l??o}),[u,a,i,o,l]);return m?e(la.Provider,{value:p,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(ka,{elements:h})})}):s||e(Ca,{})}export{tt as ArrayPropertySchema,cr as ArtifactContentRenderer,wr as ChartCodeBlockHandler,tr as CodeBlockErrorBoundary,Xt as CodeBlockHandlerProvider,er as CodeBlockPlaceholder,hr as CodeBlockRendererProvider,Qn as DropZone,Cr as ExpandCodeBlockHandler,Fe as FieldSetContextProvider,qe as Form,Ee as FormContext,ze as FormContextProvider,Ye as FormError,Xe as FormHelper,Ze as FormLabel,Ue as GeneratedForm,Me as Input,ht as JSONCode,Ct as JSONDisplay,$t as JSONEditor,Pt as JSONSwitcher,Ft as JSONTable,gt as JSONView,dt as ManageObjectEntry,ct as ManagedListProperty,st as ManagedObject,it as ManagedObjectBase,ot as ManagedObjectProperty,lt as ManagedProperty,ut as ManagedScalarEntry,En as ManagedSchema,Pr as MarkdownFigure,Lr as MarkdownImage,Tr as MarkdownLink,vn as MarkdownRenderer,Nr as MermaidCodeBlockHandler,gr as MermaidDiagram,Ot as MonacoEditor,at as Node,bn as Progress,xn as PropertiesView,An as PropertyEditor,jn as PropertyNameEditor,et as PropertySchema,Pn as PropertyViewer,He as ScalarField,Qe as Schema,Hn as SchemaEditor,Dn as SchemaNode,wn as SvgIcon,ea as UploadResultCategory,ta as UploadSummary,jt as VEditorApi,Sa as XMLViewer,rt as computeTitleFromName,Ar as createDefaultCodeBlockHandlers,Nn as createSvgIcon,kn as getEditableSchemaProperty,It as getJSONEditorValue,Sr as isExpandLanguage,vr as isIncompleteJson,$r as mapSchemeToRoute,Or as parseUrlScheme,ft as renderJsonLine,yr as useArtifactContent,pr as useCodeBlockComponent,Yt as useCodeBlockContext,mr as useCodeBlockRendererRegistry,Te as useFieldSet,Ve as useForm,Ir as useResolvedUrl,Vn as useSchema,Zn as validatePropertyName};
1
+ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Styles as n,FormItem as a,Button as i,DotBadge as s,useTheme as o,Table as l,VTooltip as c,SelectBox as d,Modal as u,ModalTitle as h,ModalBody as m,ModalFooter as p,useFlag as f,useClickOutside as g,useToast as y,errorMessage as v}from"@vertesia/ui/core";import b,{clsx as x}from"clsx";import{Plus as w,Trash2 as N,Loader2 as k,Check as C,Copy as S,Download as A,Minimize2 as j,Maximize2 as O,X as $,Code as I,FileText as P,Table as R,Link as L,Image as F,MessageSquare as T,GitBranch as E,BarChart3 as D,Info as V,AlignLeft as z,SquarePen as M,ChevronDown as q,ChevronRight as _,UploadIcon as U,CheckCircleIcon as W,AlertCircleIcon as J,XCircleIcon as H}from"lucide-react";import B,{createContext as K,useContext as G,useState as Z,useRef as X,useMemo as Y,useEffect as Q,useCallback as ee,memo as te,useId as re}from"react";import ne from"ajv";import ae from"ajv-formats";import{useUITranslation as ie}from"@vertesia/ui/i18n";import{Editor as se}from"@monaco-editor/react";import oe from"debounce";import{FusionFragmentProvider as le,FusionFragmentHandler as ce}from"@vertesia/fusion-ux";import de from"dompurify";import*as ue from"@radix-ui/react-dialog";import{useUserSession as he}from"@vertesia/ui/session";import me from"papaparse";import{VegaEmbed as pe}from"react-vega";import{twMerge as fe}from"tailwind-merge";import ge from"mermaid";import ye,{defaultUrlTransform as ve}from"react-markdown";import be from"rehype-katex";import{remarkDefinitionList as xe,defListHastHandlers as we}from"remark-definition-list";import Ne from"remark-directive";import ke from"remark-gfm";import Ce from"remark-github-blockquote-alert";import Se from"remark-math";import Ae from"remark-supersub";import{visit as je,SKIP as Oe}from"unist-util-visit";import{XMLParser as $e}from"fast-xml-parser";import{SyntaxValidator as Ie}from"fast-xml-validator";import{isNil as Pe,omit as Re}from"lodash-es";const Le=K(void 0),Fe=Le.Provider;function Te(){const e=G(Le);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class Ee{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const De=K(void 0);function Ve(){const e=G(De);if(!e)throw new Error("useForm must be used within a Form element");return e}const ze=De.Provider,Me=B.forwardRef(({object:t,type:r="text",onChange:a,...i},s)=>{const[o,l]=Z(null!=t.value?String(t.value):""),[c,d]=Z(t.schema.isBoolean&&!0===t.value);i.className?i.className=b(n.INPUT,i.className):i.className=n.INPUT;const u=e=>{i.disabled||(l(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,d(t.value)):t.value=e.target.value,a?.(e))};return"textarea"===r?e("textarea",{ref:s,...i,value:o,onChange:u}):e("input","checkbox"===r?{ref:s,...i,type:"checkbox",checked:c,onChange:u,className:"form-check-input"}:{ref:s,...i,type:r,value:o,onChange:u})});function qe({object:t,components:r,onSubmit:n,children:a,onChange:i,disabled:s}){return t.observer=i,e(ze,{value:new Ee(t,r||{},s??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n?.(t.value)},children:a})})}function _e(){const t=Ve();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(We)})}function Ue({children:r,...n}){return t(qe,{...n,children:[e(_e,{}),r]})}function We(t){return t.isList?e(Ke,{object:t},t.name):t.isObject?e(Be,{object:t},t.name):e(He,{object:t},t.name)}function Je(t,r){return t.isList?e(Ke,{object:t}):t.isObject?e(Be,{object:t}):e(He,{object:t,editor:r})}function He({object:t,editor:r,inline:n=!1}){r||(r=t.schema.editor);const{components:i,disabled:s}=Ve(),o=r&&i[r]||Me,l=t.getInputType();"checkbox"===l&&(n=!0);const c=e=>{s||(t.schema.isBoolean?t.value=e.target instanceof HTMLInputElement&&e.target.checked:t.schema.isNumber?t.value=parseFloat(e.target.value):t.value=e.target.value)};return t.isListItem?e(o,{object:t,type:l,onChange:c,disabled:s}):e(a,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:b("flex",n?"flex-row items-center":"flex-col"),children:e(o,{object:t,type:l,onChange:c,disabled:s})})}function Be({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(We)]})}function Ke({object:r}){const{disabled:n}=Ve(),a=X((r.value??[]).length),[s,o]=Z(()=>(r.value??[]).map((e,t)=>t));return t("div",{className:"flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 darK:border-s-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map((t,a)=>{const i=s[a];return e(Ge,{object:t,list:r,onDelete:()=>(e=>{n||(r.remove(e),o(t=>t.filter((t,r)=>r!==e)))})(a),disabled:n},i)}),e("div",{children:t(i,{variant:"outline",onClick:()=>{n||(r.add(),o(e=>[...e,a.current++]))},disabled:n,children:[e(w,{className:"size-6"})," Add"]})})]})}function Ge({list:r,object:n,onDelete:a,disabled:s}){const o="string"==typeof r.schema.arraySchema.editor?r.schema.arraySchema.editor:void 0;return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:Je(n,o)}),e(i,{variant:"ghost",onClick:a,disabled:s,alt:"Delete",children:e(N,{className:"size-4 text-destructive"})})]})}function Ze({label:t,required:r,children:n}){return e(a,{label:t,required:r,children:n})}function Xe({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Ye({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}class Qe{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new ne({allErrors:!0,strict:!1});ae(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){const e=this.schema.title;if("string"==typeof e)return e;const t=this.schema.name;return"string"==typeof t?t:void 0}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new tt(this,e,t):new et(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const n="string"==typeof t?"object"===(a=t)?{type:"object",properties:{}}:"array"===a?{type:"array",items:{}}:{type:a}:t;var a;const i=this.loadProperty(e,n);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return"string"==typeof this.schema.editor?this.schema.editor:void 0}}class et extends Qe{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class tt extends et{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function rt(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function nt(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class at{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||rt(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent?.onChange(e)}}class it extends at{get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new ct(this,t,this.getOrInitArrayProperty(e)):t.isObject?new ot(this,t,t.name,this.getOrInitObjectProperty(e)):new lt(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new ct(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new ot(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new lt(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class st extends it{value;constructor(e,t={}){super(null,e instanceof Qe?e:new Qe(e),"#root"),this.value=t}}class ot extends it{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class lt extends at{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return nt(this.name,this.schema)}}class ct extends at{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new dt(this,e):new ut(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new ot(this,this.schema,String(e),t):new ut(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class dt extends it{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=`${this.name}@${Date.now()}`}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class ut extends at{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=`${this.name}@${Date.now()}`}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return nt(this.name,this.schema)}}function ht({data:r,className:n}){const a=Y(()=>{try{return JSON.stringify(r,null,2)}catch(e){return console.error("Failed to stringify JSON:",e),"{}"}},[r]),i=Y(()=>a.split("\n"),[a]);return e("pre",{className:`h-full overflow-auto rounded-md border bg-background p-3 font-mono text-xs leading-5 text-foreground ${n||""}`,children:e("code",{children:i.map((e,r)=>t("span",{children:[ft(e),r<i.length-1?"\n":null]},r))})})}const mt=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,pt=/^\s*:/;function ft(t){mt.lastIndex=0;const r=[];let n=0,a=mt.exec(t);for(;null!==a;){a.index>n&&r.push(t.slice(n,a.index));const[i,s,o,l]=a,c=void 0!==s&&pt.test(t.slice(a.index+i.length))?"text-info":s?"text-success":o?"text-primary":l?"text-attention":void 0;r.push(e("span",{className:c,children:i},`${a.index}-${i}`)),n=a.index+i.length,a=mt.exec(t)}return n<t.length&&r.push(t.slice(n)),r.length?r:t}function gt({value:t}){return Array.isArray(t)?e("div",{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:e(xt,{value:t})}):e("div","object"!=typeof t||null==t?{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:e(bt,{name:"value",value:t})}:{className:"flex flex-col gap-4 px-2 h-full overflow-auto",children:Object.entries(t).map(([t,r])=>e(bt,{name:t,value:r},t))})}function yt({name:t}){return e("div",{className:"text-md font-semibold",children:rt(t)})}function vt({children:t,className:r}){return e("div",{className:b("flex flex-col gap-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600",r),children:t})}function bt({name:r,value:n}){const a=kt(n);switch(a.type){case Nt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(yt,{name:`${r}:`}),e("p",{children:a.value})]});case Nt.Paragraph:return t("div",{children:[e(yt,{name:r}),e("p",{children:a.value})]});case Nt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(yt,{name:r}),e("div",{className:"vprose dark:prose-invert",children:a.value})]});case Nt.Array:return e(xt,{name:r,value:n});case Nt.Object:return t("div",{children:[e(yt,{name:r}),e(vt,{className:"mt-2",children:Object.entries(n).map(([t,r])=>e(bt,{name:t,value:r},t))})]})}}function xt({name:r,value:n}){const a=n.join(" ").length,i=a/n.length,o="string"==typeof n[0]&&(a<80||a<400&&i<32),l=n.length>9,c=n.map((e,t)=>({item:e,index:t,key:`${t}-${JSON.stringify(e)}`}));return t("div",o?{className:"flex gap-2 flex-wrap",children:[r&&e(yt,{name:`${r}:`}),c.map(({item:t,key:r})=>e(s,{children:String(t)},r))]}:{children:[r&&e(yt,{name:r}),e("div",{className:"flex flex-col gap-2",children:c.map(({item:t,index:r,key:n})=>e(wt,{index:r,value:t,useBullet:l},n))})]})}function wt({index:r,value:n,useBullet:a}){const i=a?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),s=kt(n);let o;switch(s.type){case Nt.Object:o=e(vt,{children:Object.entries(n).map(([t,r])=>e(bt,{name:t,value:r},t))});break;case Nt.Array:o=e(xt,{value:n});break;case Nt.Prose:o=e("div",{className:"prose dark:prose-invert",children:s.value});break;default:o=e("div",{children:s.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pe-2 ps-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var Nt;function kt(e){if(null==e)return{value:"-",type:Nt.Inline};if(Array.isArray(e))return{value:e,type:Nt.Array};if("string"==typeof e){const t=e.length;let r,n=e;return t<80?r=Nt.Inline:t>400?r=Nt.Prose:(r=Nt.Paragraph,n=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:n}}return"number"==typeof e||"boolean"==typeof e?{value:String(e),type:Nt.Inline}:{value:e,type:Nt.Object}}function Ct({value:t,viewCode:r=!1}){const{t:n}=ie();return t?e("div",{className:"relative w-full h-full flex flex-col",children:r||!St(t)?e(ht,{data:t}):e("div",{className:"flex-1 min-h-0 overflow-auto",children:e(gt,{value:t})})}):e("pre",{className:"whitespace-pre-wrap",children:n("misc.noData")})}function St(e){return null==e||("string"==typeof e||"number"==typeof e||"boolean"==typeof e||(Array.isArray(e)?e.every(St):"object"==typeof e&&Object.values(e).every(St)))}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(Nt||(Nt={}));const At=new Set;class jt{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||"")}}function Ot({onChange:t,value:r,className:n,editorRef:a,language:i="javascript",path:s,debounceTimeout:l=0,options:c={},beforeMount:d,onMount:u,defaultValue:h,useCustomFolding:m=!1}){const[p,f]=Z(r||h||""),g=X(null),y=X(null),{theme:v}=o(),x="system"===v?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":v,w=r||h||"",N=X(()=>p),k=X(e=>{f(e),g.current&&g.current.setValue(e)});Q(()=>{N.current=()=>p},[p]),Q(()=>(a&&(a.current=new jt(()=>N.current(),e=>k.current(e))),()=>{a&&(a.current=void 0)}),[a]);const C=Y(()=>{if(t)return l>0?oe(e=>t(e),l):t},[t,l]),S=ee(async(e,t)=>{const r=e.getModel();if(!r)return;const n=/```[\s\S]*?```/g;for(const a of r.getValue().matchAll(n)){const n=r.getPositionAt(a.index).lineNumber,i=r.getPositionAt(a.index+a[0].length).lineNumber;e.setSelection(new t.Selection(n,1,i,1)),await(e.getAction("editor.createFoldingRangeFromSelection")?.run())}},[]),A=ee(e=>{const t=e||"";if(f(t),C){const e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};C(e)}},[C]),j=ee((e,t)=>{g.current=e,y.current=t,m&&function(e){At.has("markdown")||(At.add("markdown"),e.languages.registerFoldingRangeProvider("markdown",{provideFoldingRanges(e){const t=[],r=e.getLinesContent(),n=/^(#{1,6})\s/,a=[];for(let e=0;e<r.length;e++){const i=e+1,s=n.exec(r[e]);if(s){const e=s[1].length;for(;a.length>0&&a[a.length-1].level>=e;){const e=a.pop();i-1>e.line&&t.push({start:e.line,end:i-1})}a.push({level:e,line:i})}}const i=r.length;for(;a.length>0;){const e=a.pop();i>e.line&&t.push({start:e.line,end:i})}return t}}));for(const t of["javascript","typescript"])At.has(t)||(At.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){const t=e.getLinesContent(),r=/^(#{1,6})\s/,n=[],a=[],i=[],s=[];let o=!1,l=!1,c="";for(let e=0;e<t.length;e++){const d=e+1,u=t[e],h=o;for(let e=0;e<u.length;e++){const t=u[e];if("\\"!==t)if(l)t===c&&(l=!1);else if(o)"`"===t&&(o=!1);else if("`"!==t)if('"'!==t&&"'"!==t){if("{"===t&&i.push(d),"}"===t&&i.length>0){const t=i.pop(),r=u.slice(e+1).trimStart().length>0?d-1:d;r>t&&n.push({start:t,end:r})}}else l=!0,c=t;else o=!0;else e++}if(h){const e=r.exec(u);if(e){const t=e[1].length;for(;s.length>0&&s[s.length-1].level>=t;){const e=s.pop();d-1>e.line&&a.push({start:e.line,end:d-1})}s.push({level:t,line:d})}if(!o)for(;s.length>0;){const e=s.pop();d>e.line&&a.push({start:e.line,end:d})}}}return[...n,...a]}}))}(t),k.current=t=>{f(t),e.setValue(t)},t.editor.defineTheme("errorLineTheme",{base:"dark"===x?"vs-dark":"vs",inherit:!0,rules:[],colors:{"editorError.background":"#ffebee","editorError.border":"#f44336"}}),t.editor.setTheme("errorLineTheme"),m&&setTimeout(()=>S(e,t),300),u?.(e,t)},[u,x,m,S]);Q(()=>{f(e=>w===e?e:(g.current&&g.current.setValue(w),w))},[w]),Q(()=>{if(!(w&&m&&g.current&&y.current))return;const e=g.current,t=y.current,r=setTimeout(()=>S(e,t),300);return()=>clearTimeout(r)},[w,m,S]);const O={fontSize:14,fontFamily:"monospace",minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,glyphMargin:!0,renderValidationDecorations:"on",renderLineHighlight:"line",hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return e("div",{className:b(n,"w-full h-full!"),children:e(se,{className:"h-full w-full",height:"100%",theme:"dark"===x?"vs-dark":"light",language:i,path:s,value:p,onChange:A,onMount:j,beforeMount:d,options:O,defaultValue:h||""})})}function $t({value:r,onChange:n,onValidChange:a,readonly:i=!1,height:s="200px",placeholder:l,className:c}){const{theme:d}=o(),u=X(void 0),[h,m]=Z(null),p=Y(()=>{if(null==r)return l??"{}";try{return JSON.stringify(r,null,2)}catch{return"{}"}},[r,l]),f=ee(()=>{if(!u.current||i)return;const e=u.current.getValue();try{const t=JSON.parse(e);m(null),a?.(t)}catch{m("Invalid JSON")}},[i,a]);return t("div",{className:c,children:[e("div",{className:"border rounded overflow-hidden",style:{height:s},children:e(Ot,{defaultValue:p,editorRef:u,language:"json",theme:"dark"===d?"vs-dark":"vs",onChange:f,options:i?{readOnly:!0,domReadOnly:!0}:void 0})}),h&&e("p",{className:"text-xs text-destructive mt-1",children:h})]})}function It(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function Pt({title:r,viewCode:n,setViewCode:a}){return t("div",{className:"flex items-center gap-1 bg-muted mb-2 p-1 rounded",children:[e(i,{variant:n?"ghost":"primary",size:"sm",alt:"Preview properties",onClick:()=>a(!1),children:r}),e(i,{variant:n?"primary":"ghost",size:"sm",alt:"View in JSON format",onClick:()=>a(!0),children:"JSON"})]})}function Rt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/^./,e=>e.toUpperCase())}function Lt(n){if(null==n)return"Failed to query";if("string"==typeof n)return n;if(Array.isArray(n)){if(0===n.length)return"None";return n.some(e=>e&&"object"==typeof e)?e(r,{children:n.map((r,n)=>t("div",{className:"flex gap-1",children:[t("span",{className:"text-xs align-top pe-2 font-medium",children:[n+1,":"]}),e("span",{className:"text-xs",children:Lt(r)})]},n))}):n.map(e=>String(e)).join(", ")}return"object"==typeof n?e(r,{children:Object.entries(n).map(([r,n])=>t("div",{className:"flex gap-1",children:[t("span",{className:"text-xs align-top pe-2 font-medium",children:[Rt(r),":"]}),e("span",{className:"text-xs",children:Lt(n)})]},r))}):String(n)}function Ft({data:r,className:n}){const a=r?Object.entries(r):[];return e("table",{className:n||"mb-2 text-xs bg-muted rounded-sm w-full",children:e("tbody",{children:a.map(([r,n])=>t("tr",{className:"align-top hover:bg-background border-y",children:[e("td",{className:"align-top pe-4 p-2",children:Rt(r)}),e("td",{className:"p-2",children:Lt(n)})]},r))})})}function Tt(...e){return fe(x(e))}const Et=K(null);function Dt(){return G(Et)}function Vt(e){return e.startsWith("agents/")||e.startsWith("documents/")}function zt(e,t,r="inline"){return`artifact:${e}:${t}:${r}`}function Mt(e){return`file:${e}`}function qt({error:r,chartTitle:n}){return e("div",{className:"flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4",children:t("div",{className:"text-center",children:[t("p",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:["Cannot render ",n||"Vega-Lite"," chart"]}),e("p",{className:"text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate",children:r})]})})}function _t({isOpen:r,onClose:n,title:a,description:s,children:o}){const{t:l}=ie();return e(ue.Root,{open:r,onOpenChange:e=>!e&&n(),children:t(ue.Portal,{children:[e(ue.Overlay,{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t(ue.Content,{className:"fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2",onEscapeKeyDown:n,children:[e(ue.Close,{asChild:!0,children:e(i,{variant:"unstyled",onClick:n,className:"absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm","aria-label":l("agent.closeFullscreen"),children:e($,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"})})}),e("div",{className:"flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150",children:o}),e("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl",children:t("div",{className:"flex flex-col",children:[e(ue.Title,{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:a||l("agent.dashboard")}),s&&e(ue.Description,{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:s})]})})]})]})})}const Ut={categorical:["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],blues:["#dbeafe","#93c5fd","#3b82f6","#1d4ed8","#1e3a8a"],purples:["#f3e8ff","#c4b5fd","#8b5cf6","#6d28d9","#4c1d95"],diverging:["#ef4444","#fca5a5","#fef3c7","#86efac","#22c55e"]};function Wt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Jt(e){return Wt(e)}function Ht(e,t){if(!e?.encoding)return!1;for(const r of t)for(const t of Object.values(e.encoding))if(t.field===r)return!0;if(Array.isArray(e.layer))for(const r of e.layer)if(Ht(r,t))return!0;return!1}function Bt(e,t){if(!e)return!1;const r=e=>{if(!e)return!1;const r=e.color?.field;return!!r&&t.includes(r)};if(r(e.encoding))return!0;if(Array.isArray(e.layer))for(const t of e.layer)if(r(t.encoding))return!0;return!1}function Kt(e,t=[]){const r=[];if(!e||"object"!=typeof e)return r;if(e.data&&"object"==typeof e.data){const n=e.data.url;"string"==typeof n&&n.startsWith("artifact:")&&r.push({path:[...t,"data"],artifactPath:n.replace(/^artifact:/,"").trim()})}const n=["layer","vconcat","hconcat","concat","spec","repeat","facet"];for(const a of n)if(a in e){const n=e[a];Array.isArray(n)?n.forEach((e,n)=>{Jt(e)&&r.push(...Kt(e,[...t,a,String(n)]))}):Jt(n)&&r.push(...Kt(n,[...t,a]))}return r}const Gt=te(function({spec:n,artifactRunId:a}){const{t:s}=ie(),{title:o,description:l,options:c}=n,d=n.spec,[u,h]=Z(!1),[m,p]=Z(!1),[f,g]=Z(null),[y,v]=Z(!1),b=X(null),x=X(null),w=X(null),{client:N}=he(),$=Dt(),I=X(N);I.current=N;const P=X($);P.current=$;const[R,L]=Z(null),[F,T]=Z(!1),[E,D]=Z(null),V=c?.mode||"chart",z="dashboard"===V,M=c?.enableFullscreen??z,q=c?.height||function(e,t){if("chart"===t)return 280;let r=1;if(e.vconcat)r=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){const t=e.columns||2,n=Array.isArray(e.concat)?e.concat.length:1;r=Math.ceil(n/t)}else e.facet&&(r=2);return Math.max(500,280*r+40)}(d,V);Q(()=>{const e=Kt(d);if(0===e.length)return L(d),T(!1),void D(null);a?console.info("[VegaLiteChart] resolving artifacts with runId:",a,e.map(e=>e.artifactPath)):console.warn("[VegaLiteChart] artifact references found but artifactRunId is missing!",{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;T(!0),D(null);return(async()=>{const r=new Map,n=I.current,i=P.current;for(const s of e)try{const e=s.path.join(".");let t;if(a&&!Vt(s.artifactPath)){const e=zt(a,s.artifactPath,"inline");if(i)t=await i.getOrFetch(e,async()=>(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url);else{t=(await n.files.getArtifactDownloadUrl(a,s.artifactPath,"inline")).url}}else{const e=Mt(s.artifactPath);if(i)t=await i.getOrFetch(e,async()=>(await n.files.getDownloadUrl(s.artifactPath)).url);else{t=(await n.files.getDownloadUrl(s.artifactPath)).url}}const o=await fetch(t);if(!o.ok)throw new Error(`Failed to fetch artifact data: ${o.statusText}`);let l;if(s.artifactPath.toLowerCase().endsWith(".csv")){const e=await o.text();l=me.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{const e=await o.json();l=Array.isArray(e)?e:[e]}r.set(e,l)}catch(e){return console.error(`Failed to resolve artifact: ${s.artifactPath}`,e),void(t||D(`Failed to load data from artifact: ${s.artifactPath}`))}if(!t){const e=function(e,t){const r=JSON.parse(JSON.stringify(e));for(const[e,n]of t){const t=e.split(".");let a=r;for(let e=0;e<t.length-1;e++){const r=a[t[e]];if(!Wt(r))break;a=r}const i=a[t[t.length-1]];Wt(i)&&(delete i.url,i.values=n)}return r}(d,r);L(e),T(!1)}})(),()=>{t=!0}},[d,a]);const[_,U]=Z(!1),W=X(!1);Q(()=>{const e=()=>{const e=document.documentElement.classList.contains("dark");e!==W.current&&(W.current=e,U(e))};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const[J,H]=Z(0),B=X(0);Q(()=>{if(!w.current)return;let e;const t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{const e=t[0]?.contentRect.width;e&&e!==B.current&&(B.current=e,H(e))},100)});t.observe(w.current);const r=w.current.clientWidth;return B.current=r,H(r),()=>{clearTimeout(e),t.disconnect()}},[]);const K=Y(()=>Kt(d).length>0,[d]),G=Y(()=>{if(K&&!R)return null;let e=R||d;return e?(c?.parameterValues&&(e=function(e,t){if(!t||0===Object.keys(t).length)return e;const r=JSON.parse(JSON.stringify(e)),n=e=>{for(const r of e)r.name&&r.name in t&&(r.value=t[r.name])};Array.isArray(r.params)&&n(r.params);const a=e=>{if(Array.isArray(e))for(const t of e)if(Array.isArray(t.params)&&n(t.params),t.vconcat&&a(t.vconcat),t.hconcat&&a(t.hconcat),t.concat&&a(t.concat),Array.isArray(t.layer))for(const e of t.layer)Array.isArray(e.params)&&n(e.params)};if(r.vconcat&&a(r.vconcat),r.hconcat&&a(r.hconcat),r.concat&&a(r.concat),Array.isArray(r.layer))for(const e of r.layer)e&&Array.isArray(e.params)&&n(e.params);return r}(e,c.parameterValues)),function(e){const t=JSON.parse(JSON.stringify(e)),r=["vconcat","hconcat","concat"];if(!r.some(e=>Array.isArray(t[e])))return t;const n=[];if(Array.isArray(t.params))for(const e of t.params)e&&"object"==typeof e&&e.name&&e.select&&n.push({name:e.name,param:e});if(0===n.length)return t;for(const{name:e,param:a}of n){const n=a.select?.fields||[],i="legend"===a.select?.bind;let s=null;for(const e of r)if(Array.isArray(t[e])){s=t[e];break}if(!s||0===s.length)continue;let o=0;for(let e=0;e<s.length;e++){const t=s[e];if(Ht(t,n)||i&&Bt(t,n)){o=e;break}}const l=s[o];l.params||(l.params=[]),l.params.push(a);const c=t.params??[];t.params=c.filter(t=>t.name!==e)}return Array.isArray(t.params)&&0===t.params.length&&delete t.params,t}(e)):null},[R,d,K,c?.parameterValues]),te=ee((e,t)=>{if(!e||"object"!=typeof e)return e;if(e.hconcat&&Array.isArray(e.hconcat)){const r=e.hconcat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,hconcat:e.hconcat.map(e=>te(e,a))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>te(e,t))};if(e.concat&&Array.isArray(e.concat)){const r=e.columns??e.concat.length,n=(e.spacing??10)*(r-1),a=Math.floor((t-n)/r);return{...e,concat:e.concat.map(e=>te(e,a))}}const r=e.width;return"container"===r||"number"==typeof r&&r>t?{...e,width:t}:e},[]),re=ee((e,t=!1)=>{if(!G)return null;const r=function(e){const t={background:"transparent",view:{stroke:"transparent"},range:{category:Ut.categorical,diverging:Ut.diverging,heatmap:Ut.purples,ramp:Ut.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:"round"},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:"#a1a1aa",titleColor:"#e4e4e7",gridColor:"#3f3f46",domainColor:"#52525b",tickColor:"#52525b",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:"#a1a1aa",titleColor:"#e4e4e7",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:"#fafafa",font:"Inter, system-ui, sans-serif",fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:"#71717a",titleColor:"#3f3f46",gridColor:"#e4e4e7",domainColor:"#d4d4d8",tickColor:"#d4d4d8",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:"#71717a",titleColor:"#3f3f46",labelFont:"Inter, system-ui, sans-serif",titleFont:"Inter, system-ui, sans-serif",labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:"#18181b",font:"Inter, system-ui, sans-serif",fontSize:14,fontWeight:600}}}(_),n=t?"undefined"!=typeof window?Math.min(window.innerWidth-80,1400):1200:J>0?J-24:500,a="vconcat"in G||"hconcat"in G||"concat"in G,i=a?{type:"pad",contains:"padding"}:{type:"fit",contains:"padding"};let s=G;a&&n&&(s=te(G,n));const l=s.width,c=a?void 0:"container"===l?n:l??n,{width:d,...u}=s;return{$schema:"https://vega.github.io/schema/vega-lite/v6.json",...!a&&c?{width:c}:{},height:t?void 0:e,autosize:i,...a?s:u,...o&&!G.title?{title:o}:{},config:{...r,...G.config}}},[G,o,_,J,te]),ne=ee(async()=>{const e=y?x.current:b.current;if(e&&!m)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),p(!0),setTimeout(()=>p(!1),2e3))},"image/png")}catch(e){console.error("Failed to copy chart:",e)}},[m,y]),ae=ee(async()=>{const e=y?x.current:b.current;if(e&&!u){h(!0);try{const t=await e.toImageURL("png",2),r=document.createElement("a");r.download=`${o||"chart"}.png`,r.href=t,r.click()}catch(e){console.error("Failed to export chart:",e)}finally{h(!1)}}},[o,u,y]),se=ee(e=>{b.current=e,g(null)},[]),oe=ee(e=>{x.current=e},[]),le=ee(e=>{console.error("Vega-Lite rendering error:",e),g(e instanceof Error?e.message:"Unknown error")},[]),ce=ee(()=>{v(e=>!e)},[]);Q(()=>{g(null)},[d]);const de=({className:r})=>t("div",{className:Tt("flex items-center gap-2",r),children:[t(i,{variant:"unstyled",onClick:ne,disabled:m,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1",title:s("agent.copyToClipboard"),children:[e(m?C:S,{className:"w-3 h-3"}),s(m?"agent.copied":"agent.copy")]}),t(i,{variant:"unstyled",onClick:ae,disabled:u,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1",title:s("agent.exportAsPng"),children:[e(A,{className:"w-3 h-3"}),s(u?"agent.exporting":"agent.export")]}),M&&t(i,{variant:"unstyled",onClick:ce,className:"text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1",title:s(y?"agent.exitFullscreen":"agent.fullscreen"),children:[e(y?j:O,{className:"w-3 h-3"}),s(y?"agent.exit":"agent.fullscreen")]})]});if(F||K&&!R)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{className:"flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded",style:{width:"100%",height:q},children:t("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e(k,{className:"w-5 h-5 animate-spin"}),e("span",{className:"text-sm",children:"Loading data from artifacts..."})]})})]})});if(E)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{style:{width:"100%",height:q},children:e(qt,{error:E,chartTitle:o})})]})});if(f)return e("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",children:t("div",{className:"flex flex-col gap-2 p-3",children:[e("div",{className:"flex items-center justify-between",children:e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||"Chart"})}),e("div",{style:{width:"100%",height:q},children:e(qt,{error:f,chartTitle:o})})]})});const ue=re(q),fe=re(0,!0);return ue?("undefined"!=typeof window&&localStorage.getItem("DEBUG_VEGA_RENDERS")&&console.log("VegaLite rendering with spec:",{title:o,hasData:!!ue.data?.values,dataLength:ue.data?.values?.length}),t(r,{children:[e("div",{className:Tt("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm",z&&"border-2"),children:t("div",{className:"flex flex-col gap-2 p-3",children:[t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100",children:o||(z?"Dashboard":"Chart")}),z&&e("span",{className:"text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300",children:"Interactive"})]}),e(de,{})]}),l&&e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:l}),e("div",{ref:w,className:"bg-white dark:bg-gray-900 rounded overflow-hidden",style:{width:"100%",height:q,minWidth:0},children:e(pe,{spec:ue,onEmbed:e=>se(e.view),onError:le,options:{renderer:c?.renderer||"canvas",actions:!1}})})]})}),t(_t,{isOpen:y,onClose:()=>v(!1),title:o||(z?"Dashboard":"Chart"),description:l,children:[e("div",{className:"w-full h-full min-h-[calc(100vh-200px)]",children:fe&&e(pe,{spec:fe,onEmbed:e=>oe(e.view),onError:le,options:{renderer:c?.renderer||"canvas",actions:!1}})}),e("div",{className:"absolute bottom-6 end-6",children:e(de,{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700"})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),Zt=B.createContext({});function Xt({children:t,artifactRunId:r,onProposalSelect:n,onProposalSubmit:a,MarkdownRenderer:i}){const s=Y(()=>({artifactRunId:r,onProposalSelect:n,onProposalSubmit:a,MarkdownRenderer:i}),[r,n,a,i]);return e(Zt.Provider,{value:s,children:t})}function Yt(){return B.useContext(Zt)}const Qt={chart:{icon:D,label:"chart",defaultHeight:200},mermaid:{icon:E,label:"diagram",defaultHeight:150},proposal:{icon:T,label:"options",defaultHeight:100},code:{icon:I,label:"code",defaultHeight:80},image:{icon:F,label:"image",defaultHeight:150},link:{icon:L,label:"link",defaultHeight:24},expand:{icon:A,label:"content",defaultHeight:100},table:{icon:R,label:"table",defaultHeight:150},markdown:{icon:P,label:"content",defaultHeight:100},"fusion-fragment":{icon:I,label:"fragment",defaultHeight:150}};function er({type:r,error:n,onRetry:a,message:s,height:o}){const l=Qt[r],c=o??l.defaultHeight,d="link"===r;if(n)return t("div",{className:"flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive "+(d?"inline-flex px-2 py-1 text-sm":"p-4"),style:d?void 0:{minHeight:c},children:[t("span",{className:"text-destructive",children:["Failed to load ",l.label]}),a&&e(i,{variant:"unstyled",onClick:a,className:"ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive",children:"Retry"})]});const u=l.icon;return d?t("span",{className:"inline-flex items-center gap-1 text-muted animate-pulse",children:[e(u,{className:"h-3 w-3"}),e("span",{children:s||`Loading ${l.label}...`})]}):t("div",{className:"flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse",style:{minHeight:c},children:[e(u,{className:"h-8 w-8 text-muted"}),e("span",{className:"text-sm text-muted",children:s||`Loading ${l.label}...`}),e("div",{className:"flex gap-1",children:[...Array(3)].map((t,r)=>e("div",{className:"h-2 w-2 rounded-full bg-muted animate-bounce",style:{animationDelay:150*r+"ms"}},r))})]})}class tr extends B.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){const{type:r,fallbackCode:n}=this.props;return t("div",{className:"space-y-2",children:[e(er,{type:r,error:this.state.error?.message||"Rendering failed",onRetry:this.handleRetry}),n&&t("details",{className:"text-sm",children:[e("summary",{className:"cursor-pointer text-muted hover:text-foreground",children:"Show raw content"}),e("pre",{className:"mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs",children:e("code",{children:n})})]})]})}return this.props.children}}function rr(e){if("object"!=typeof e||null===e)return null;const t=e;return"vega-lite"===t.library&&"spec"in t&&"object"==typeof t.spec&&null!==t.spec?t:"string"==typeof t.$schema&&t.$schema.includes("vega")?{library:"vega-lite",spec:t}:null}function nr({content:r}){const{headers:n,rows:a}=Y(()=>{if(!Array.isArray(r)||0===r.length)return{headers:[],rows:[]};const e=r[0];if("object"!=typeof e||null===e)return{headers:[],rows:[]};const t=Object.keys(e),n=r.map(e=>t.map(t=>{const r=e[t];return null==r?"":"object"==typeof r?JSON.stringify(r):String(r)}));return{headers:t,rows:n}},[r]);return 0===n.length?e(er,{type:"table",error:"No table data found"}):t("div",{className:"overflow-x-auto",children:[t("table",{className:"min-w-full text-sm border-collapse",children:[e("thead",{children:e("tr",{className:"border-b",children:n.map((t,r)=>e("th",{className:"px-3 py-2 text-start font-medium text-muted",children:t},r))})}),e("tbody",{children:a.slice(0,100).map((t,r)=>e("tr",{className:"border-b border-muted/20",children:t.map((t,r)=>e("td",{className:"px-3 py-2",children:t},r))},r))})]}),a.length>100&&t("div",{className:"text-sm text-muted py-2",children:["Showing 100 of ",a.length," rows"]})]})}function ar({content:t,path:r}){const n=r.split(".").pop()?.toLowerCase()||"",a="string"==typeof t?t:JSON.stringify(t,null,2);return e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{className:`language-${n}`,children:a})})}function ir(e){return de.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:["use"],FORBID_TAGS:["foreignObject"]})}function sr(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;if(!/viewBox/i.test(r)){const e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(r);e&&t&&(r+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return r=r.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,"").replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,""),/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}function or({content:t}){const r=Y(()=>{const e="string"==typeof t?t.trim():"";return e?sr(ir(e)):null},[t]);return r?e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}}):e(er,{type:"expand",error:"Empty mockup"})}function lr({content:t,path:r}){const n="string"==typeof t?t:"",a=r.split("/").pop()||"Artifact image";return e("img",{src:n,alt:a,className:"max-w-full h-auto rounded",loading:"lazy"})}function cr({content:t,renderType:r,path:n,runId:a,contentType:i}){const{MarkdownRenderer:s}=Yt(),o=Y(()=>"auto"!==r?r:function(e,t,r){const n=t.split(".").pop()?.toLowerCase();if("svg"===n)return"mockup";if(["png","jpg","jpeg","gif","webp"].includes(n||""))return"image";if("md"===n)return"markdown";if("csv"===n)return"table";if("json"===r&&"object"==typeof e&&null!==e){const t=e;if("string"==typeof t.$schema&&t.$schema.includes("vega"))return"vega-lite";if("vega-lite"===t.library&&"spec"in t)return"vega-lite";if("template"in t&&"data"in t)return"fusion-fragment";if(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])return"table"}return"code"}(t,n,i),[t,n,i,r]);switch(o){case"chart":{const r=rr(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Gt,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Only Vega-Lite charts are supported. Recharts rendering has been retired."})}case"vega-lite":{const r=rr(t);return r?e(tr,{type:"chart",fallbackCode:JSON.stringify(t,null,2),children:e(Gt,{spec:r,artifactRunId:a})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}case"fusion-fragment":{const r=t;return console.log("[ArtifactContentRenderer] fusion-fragment:",{hasTemplate:!!r.template,hasData:!!r.data,runId:a,hasVegaLiteChart:!!Gt}),r.template&&r.data?e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(le,{data:r.data,ChartComponent:Gt,artifactRunId:a,children:e(ce,{code:JSON.stringify(r.template),data:r.data})})}):e(tr,{type:"fusion-fragment",fallbackCode:JSON.stringify(t,null,2),children:e(ce,{code:JSON.stringify(t)})})}case"table":return e(tr,{type:"table",fallbackCode:JSON.stringify(t,null,2),children:e(nr,{content:t})});case"markdown":{const r="string"==typeof t?t:String(t);return e(tr,{type:"markdown",fallbackCode:r,children:s?e(s,{artifactRunId:a,children:r}):e("pre",{className:"overflow-x-auto p-3 bg-muted/10 rounded text-sm",children:e("code",{children:r})})})}case"mockup":return e(tr,{type:"expand",fallbackCode:"string"==typeof t?t:n,children:e(or,{content:t})});case"image":return e(tr,{type:"image",fallbackCode:n,children:e(lr,{content:t,path:n})});default:return e(ar,{content:t,path:n})}}class dr{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}}const ur=K(null);function hr({components:t,children:r}){const n=Y(()=>{const e=new dr;for(const[r,n]of Object.entries(t))e.registerComponent(r,n);return e},[t]);return e(ur.Provider,{value:n,children:r})}function mr(){return G(ur)}function pr(e){const t=G(ur);if(t)return t.getComponent(e)}const fr='Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function gr({code:t,className:r}){const n=X(null),[a,i]=Z(null),[s,o]=Z(null),l=re().replace(/:/g,"_");return Q(()=>{let e=!1;return(async()=>{if(!t.trim())return i(null),void o(null);try{o(null);const r=`mermaid-${l}-${Date.now()}`,n=function(e){const t=e.trim();let r="",n=!1,a=!1;for(let e=0;e<t.length;e++){const i=t[e],s=e>0?t[e-1]:"";if('"'!==i||a||"\\"===s)if("'"!==i||n||"\\"===s){if((n||a)&&"\\"===i){let n=e;for(;"\\"===t[n];)n++;if("n"===t[n]){r+="<br/>",e=n;continue}}r+=i}else a=!a,r+=i;else n=!n,r+=i}return r}(t),{svg:a}=await ge.render(r,n),s=function(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let r=t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"");return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):r+=' style="width:100%;height:auto;display:block;max-width:100%;"',/preserveAspectRatio=/i.test(r)||(r+=' preserveAspectRatio="xMidYMid meet"'),`<svg${r}>`})}(a);e||i(s)}catch(t){if(!e){const e=t instanceof Error?t.message:"Failed to render mermaid diagram";o(e),i(null)}}})(),()=>{e=!0}},[t,l]),s?null:e("div",a?{ref:n,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${r||""}`,dangerouslySetInnerHTML:{__html:a}}:{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${r||""}`,children:e("div",{className:"h-32 bg-gray-200 dark:bg-gray-700 rounded"})})}function yr({runId:e,path:t,parseJson:r=!0}){const{client:n}=he(),a=Dt(),i=X(n);i.current=n;const s=X(a);s.current=a;const[o,l]=Z({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),c=ee(async()=>{if(!e)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No run ID provided",contentType:void 0});if(!t)return void l({data:void 0,rawContent:void 0,isLoading:!1,error:"No artifact path provided",contentType:void 0});l(e=>({...e,isLoading:!0,error:void 0}));const n=i.current,a=s.current,o=function(e){const t=e.split(".").pop()?.toLowerCase();switch(t){case"json":return"json";case"md":case"txt":case"csv":case"yaml":case"yml":default:return"text";case"png":case"jpg":case"jpeg":case"gif":case"webp":case"pdf":return"binary"}}(t);try{const i=zt(e,t,"inline");let s;if(a)s=await a.getOrFetch(i,async()=>(await n.files.getArtifactDownloadUrl(e,t,"inline")).url);else{s=(await n.files.getArtifactDownloadUrl(e,t,"inline")).url}const c=await fetch(s);if(!c.ok)throw new Error(`Failed to fetch artifact: ${c.status} ${c.statusText}`);if("binary"===o)return void l({data:s,rawContent:void 0,isLoading:!1,error:void 0,contentType:o});const d=await c.text();let u;if(r&&"json"===o)try{u=JSON.parse(d)}catch{u=d}else u=d;l({data:u,rawContent:d,isLoading:!1,error:void 0,contentType:o})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch artifact";console.error("Failed to fetch artifact content:",t,e),l({data:void 0,rawContent:void 0,isLoading:!1,error:r,contentType:o})}},[e,t,r]);Q(()=>{c()},[c]);const d=ee(()=>{l({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),c()},[c]);return{data:o.data,rawContent:o.rawContent,isLoading:o.isLoading,error:o.error,contentType:o.contentType,retry:d}}function vr(e){const t=e.trim();if(t.length<2)return!0;if(!t.startsWith("{"))return!1;try{return JSON.parse(t),!1}catch(e){const r=["unexpected end","unterminated string","expected","unexpected token"],n=(e instanceof Error?e.message:"").toLowerCase();if(r.some(e=>n.includes(e))){let e=0,r=0,n=!1,a=!1;for(const i of t)a?a=!1:"\\"!==i?'"'!==i?n||("{"===i?e++:"}"===i?e--:"["===i?r++:"]"===i&&r--):n=!n:a=!0;return e>0||r>0||n}return!1}}function br(e){try{let t=e.trim();const r=t.indexOf("{"),n=t.lastIndexOf("}");return-1!==r&&n>r&&(t=t.slice(r,n+1)),JSON.parse(t)}catch{return null}}function xr({code:t}){const{artifactRunId:r}=Yt();r||console.warn("[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext");const n=Y(()=>vr(t),[t]),a=Y(()=>{if(n)return null;const e=br(t);return e?{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(Gt,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite specification"})}function wr({code:t}){const{artifactRunId:r}=Yt();r||console.warn("[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext");const n=Y(()=>vr(t),[t]),a=Y(()=>{if(n)return null;const e=br(t);if(!e)return null;const r=function(e){const t="string"==typeof e.$schema&&e.$schema.includes("vega"),r="vega-lite"===e.library&&"spec"in e;return t||r?"vega-lite":null}(e);return r?"vega-lite"===e.library&&"spec"in e&&"object"==typeof e.spec?e:{library:"vega-lite",spec:e}:null},[t,n]);return n?e(er,{type:"chart",message:"Loading chart..."}):a?e(tr,{type:"chart",fallbackCode:t,children:e(Gt,{spec:a,artifactRunId:r})}):e(er,{type:"chart",error:"Invalid Vega-Lite chart specification"})}function Nr({code:t}){const r=t.trim();return r?e(tr,{type:"mermaid",fallbackCode:t,children:e(gr,{code:r})}):e(er,{type:"mermaid",error:"Empty diagram"})}function kr({code:t}){const r=Y(()=>{const e=t.trim();return e?sr(ir(e)):null},[t]);return r?e(tr,{type:"code",fallbackCode:t,children:e("div",{style:{margin:"16px 0",width:"100%",overflowX:"auto"},dangerouslySetInnerHTML:{__html:r}})}):e(er,{type:"code",error:"Empty mockup"})}function Cr({code:t,language:r}){const{artifactRunId:n}=Yt(),a=t.trim(),i=Y(()=>{if(!r?.includes(":"))return"auto";const e=r.split(":")[1];return["chart","vega-lite","table","markdown","fusion-fragment","mockup","code","image","auto"].includes(e)?e:"auto"},[r]),{data:s,isLoading:o,error:l,contentType:c}=yr({runId:n,path:a});return n?o?e(er,{type:"expand",message:`Loading ${a}...`}):l?e(er,{type:"expand",error:`Failed to load artifact: ${l}`}):void 0===s?e(er,{type:"expand",error:"No content found in artifact"}):e(cr,{content:s,renderType:i,path:a,runId:n,contentType:c}):e(er,{type:"expand",error:"No artifact run ID available"})}function Sr(e){return e?.startsWith("expand")??!1}function Ar(){return{chart:wr,"vega-lite":xr,vegalite:xr,mermaid:Nr,mockup:kr,svg:kr}}function jr(e){return e.trim().replace(/^\/+/,"")}function Or(e){return e.startsWith("artifact:")?{scheme:"artifact",path:e.slice(9).trim()}:e.startsWith("image:")?{scheme:"image",path:e.slice(6).trim()}:e.startsWith("store:")?{scheme:"store",path:jr(e.slice(6))}:e.startsWith("document:")?{scheme:"document",path:jr(e.slice(9))}:e.startsWith("collection:")?{scheme:"collection",path:jr(e.slice(11))}:{scheme:"standard",path:e}}function $r(e,t){switch(e){case"store":case"document":return t?`/store/objects/${t}`:null;case"collection":return t?`/store/collections/${t}`:null;default:return null}}function Ir({rawUrl:e,artifactRunId:t,disposition:r="inline"}){const{client:n}=he(),a=Dt(),i=X(n);i.current=n;const s=X(a);s.current=a;const{scheme:o,path:l}=Or(e),c=$r(o,l),[d,u]=Z(()=>{if(c)return{url:c,isLoading:!1,error:void 0};if("standard"===o)return{url:e,isLoading:!1,error:void 0};if(a&&("artifact"===o||"image"===o)){let e;e="artifact"===o&&t&&!Vt(l)?zt(t,l,r):Mt(l);const n=a.getUrl(e);if(n)return{url:n,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),h=ee(async()=>{if(c||"standard"===o)return;if("artifact"!==o&&"image"!==o)return void u({url:void 0,isLoading:!1,error:`Unknown scheme: ${o}`});u(e=>({...e,isLoading:!0,error:void 0}));const e=i.current,n=s.current;try{let a;if("artifact"===o)if(t&&!Vt(l)){const i=zt(t,l,r);if(n)a=await n.getOrFetch(i,async()=>(await e.files.getArtifactDownloadUrl(t,l,r)).url);else{a=(await e.files.getArtifactDownloadUrl(t,l,r)).url}}else{const t=Mt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}else{const t=Mt(l);if(n)a=await n.getOrFetch(t,async()=>(await e.files.getDownloadUrl(l)).url);else{a=(await e.files.getDownloadUrl(l)).url}}u({url:a,isLoading:!1,error:void 0})}catch(e){const t=e instanceof Error?e.message:"Failed to resolve URL";console.error("Failed to resolve URL:",l,e),u({url:void 0,isLoading:!1,error:t})}},[o,l,t,r,c]);Q(()=>{if(d.url&&!d.error)return;let e=!1;return e||(async()=>{await h()})(),()=>{e=!0}},[h,d.url,d.error]);const m=ee(()=>{u({url:void 0,isLoading:!0,error:void 0}),h()},[h]);return{url:d.url,isLoading:d.isLoading,error:d.error,scheme:o,retry:m}}function Pr({src:r,alt:n,caption:a,className:i,artifactRunId:s}){const o=r||"",{scheme:l}=Or(o);return"standard"===l?t("figure",{className:"my-4",children:[e("img",{src:r,alt:n,className:i}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):e(Rr,{rawSrc:o,alt:n,caption:a,artifactRunId:s,className:i})}function Rr({rawSrc:r,alt:n,caption:a,artifactRunId:i,className:s}){const{url:o,isLoading:l,error:c,retry:d}=Ir({rawUrl:r,artifactRunId:i,disposition:"inline"});return l?e(er,{type:"image",message:n?`Loading ${n}...`:void 0}):c?e(er,{type:"image",error:c,onRetry:d}):o?t("figure",{className:"my-4",children:[e("img",{src:o,alt:n,className:s}),e("figcaption",{className:"mt-2 text-sm text-muted text-center italic",children:a})]}):null}function Lr({node:t,src:r,alt:n,className:a,artifactRunId:i,ExistingImg:s,...o}){const l=r||"",{scheme:c}=Or(l);return"standard"===c?"function"==typeof s?e(s,{node:t,src:r,alt:n,...o}):e("img",{src:r,alt:n,className:a,...o}):e(Fr,{rawSrc:l,alt:n,artifactRunId:i,className:a,rest:o})}function Fr({rawSrc:t,alt:r,artifactRunId:n,className:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Ir({rawUrl:t,artifactRunId:n,disposition:"inline"});return o?e(er,{type:"image",message:r?`Loading ${r}...`:void 0}):l?e(er,{type:"image",error:l,onRetry:c}):s?e("img",{src:s,alt:r,className:a,...i}):null}function Tr({node:t,href:r,children:n,className:a,artifactRunId:i,ExistingLink:s,...o}){const l=r||"",{scheme:c,path:d}=Or(l),u=$r(c,d);return u?"function"==typeof s?e(s,{node:t,href:u,...o,children:n}):e("a",{href:u,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):"standard"===c?"function"==typeof s?e(s,{node:t,href:r,...o,children:n}):e("a",{href:r,...o,className:a,target:"_blank",rel:"noopener noreferrer",children:n}):e(Er,{rawHref:l,artifactRunId:i,className:a,rest:o,children:n})}function Er({rawHref:t,artifactRunId:r,className:n,children:a,rest:i}){const{url:s,isLoading:o,error:l,retry:c}=Ir({rawUrl:t,artifactRunId:r,disposition:"attachment"});return o?e("span",{className:"inline-flex items-center gap-1 text-muted",children:e(er,{type:"link"})}):l?e("span",{className:"inline-flex items-center gap-1",children:e(er,{type:"link",error:l,onRetry:c})}):e("a",{href:s||"#",...i,className:n,target:"_blank",rel:"noopener noreferrer",children:a})}ge.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:fr,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:fr}});const Dr=["artifact:","image:","store:","document://","collection:"],Vr=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,zr=/`[^`\n]*`/g,Mr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,qr=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function _r(e){return Dr.some(t=>e.startsWith(t))}function Ur(e){return e.replace(Vr,(e,t,r,n)=>`${t}${function(e){const t=e.trim();if(t.startsWith("<")){const r=t.indexOf(">");if(r>0&&_r(t.slice(1,r).trim()))return e}const r=t.match(qr),n=r?.index??-1,a=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):"";return _r(a)?`<${a}>${i}`:e}(r)}${n}`)}function Wr(e){let t="",r=0;for(const n of e.matchAll(zr))t+=Ur(e.slice(r,n.index)),t+=n[0],r=n.index+n[0].length;return t+=Ur(e.slice(r)),t}const Jr=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,Hr=/^\w+/;const Br=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,Kr=/`[^`\n]*`/g,Gr=/\\\$/g,Zr=/\\[^\s]/,Xr=/[{}]/,Yr=/[_^][\w{]/,Qr=/^[a-zA-Z]$/,en=/^[a-zA-Z]\s*=/,tn=/^\s/,rn=/\s$/,nn=/[+*/-]$/,an=/\^[+-]$/;function sn(e){return Zr.test(e)||Xr.test(e)||Yr.test(e)||Qr.test(e)||en.test(e)}function on(e){return!!tn.test(e)||(!!rn.test(e)||!(!nn.test(e)||an.test(e)))}function ln(e,t,r){const n=e.slice(t+1,r);return 0===n.length||n.includes("\n")?null:n}function cn(e){const t=function(e){const t=[];for(let r=0;r<e.length;r++)"$"===e[r]&&(r>0&&"\\"===e[r-1]||(r+1<e.length&&"$"===e[r+1]?r++:r>0&&"$"===e[r-1]&&(r<2||"\\"!==e[r-2])||t.push(r)));return t}(e);if(t.length<2)return e;const r=new Set,n=new Set,a=new Array(t.length-1);for(let r=0;r<t.length-1;r++)a[r]=ln(e,t[r],t[r+1]);const i=[];for(let e=0;e<t.length-1;e++){if(r.has(e))continue;const n=a[e];null!==n&&sn(n)&&(r.add(e),r.add(e+1),i.push([t[e],t[e+1]]))}let s=0;for(;s<t.length;){if(r.has(s)){s++;continue}let e=s+1;for(;e<t.length&&r.has(e);)e++;if(e>=t.length)break;if(e>s+1){n.add(t[s]),s++;continue}const i=a[s];null!==i?(on(i)&&(n.add(t[s]),n.add(t[e])),r.add(s),r.add(e),s=e+1):s++}for(let e=0;e<t.length;e++)r.has(e)||e+1<t.length&&r.has(e+1)&&n.add(t[e]);if(0===n.size&&0===i.length)return e;const o=[];let l=0;const c=Array.from(n).sort((e,t)=>e-t);let d=0,u=0;for(;d<c.length||u<i.length;){const t=d<c.length?c[d]:1/0;if(t<(u<i.length?i[u][0]:1/0))t>l&&o.push(e.slice(l,t)),o.push("\\$"),l=t+1,d++;else{const[t,r]=i[u];t>l&&o.push(e.slice(l,t));const n=e.slice(t,r+1);for(o.push(n.replace(Gr,"\\text{\\textdollar}")),l=r+1;d<c.length&&c[d]<=r;)d++;u++}}return l<e.length&&o.push(e.slice(l)),o.join("")}function dn(e){const t=[];let r=0;for(const n of e.matchAll(Kr))t.push(cn(e.slice(r,n.index))),t.push(n[0]),r=n.index+n[0].length;return t.push(cn(e.slice(r))),t.join("")}const un={note:"md-callout-info",tip:"md-callout-info",warning:"md-callout-attention",important:"md-callout-attention",caution:"md-callout-destructive"},hn={note:"Note",tip:"Tip",warning:"Warning",important:"Important",caution:"Caution"};function mn(){return e=>{je(e,e=>{if("containerDirective"!==e.type&&"leafDirective"!==e.type&&"textDirective"!==e.type)return;const t=e;t.data||(t.data={});const r=t.data,n=t.attributes||{},a=t.name;if("pagebreak"===a)return r.hName="hr",void(r.hProperties={className:"md-pagebreak"});if("columns"===a)return r.hName="div",void(r.hProperties={className:"md-columns"});if("column"===a){r.hName="div";const e={className:"md-column"};return n.width&&(e.style=`flex-basis:${n.width};flex-grow:0;flex-shrink:0`),void(r.hProperties=e)}if(a in un){r.hName="div",r.hProperties={className:`md-callout ${un[a]}`,"data-callout-type":a};const e=hn[a];if(e&&t.children){const r={type:"paragraph",data:{hName:"p",hProperties:{className:"md-callout-title"}},children:[{type:"text",value:e}]};t.children.unshift(r)}return}r.hName="div",r.hProperties={className:`md-${a}`,...Object.fromEntries(Object.entries(n).filter(([e])=>"class"!==e))},n.class&&(r.hProperties.className+=` ${n.class}`)})}}const pn=["artifact:","image:","store:","document:","document://","collection:"];function fn(e){return pn.some(t=>e.startsWith(t))?e:ve(e)}function gn(){return e=>{je(e,"html",(e,t,r)=>{const n=e,a=r;if("string"==typeof n.value&&/<!--[\s\S]*?-->/.test(n.value)&&a?.children&&"number"==typeof t)return a.children.splice(t,1),[Oe,t]})}}const yn=Ar();function vn({children:t,components:r,remarkPlugins:n=[],removeComments:a=!0,artifactRunId:i,className:s,codeClassName:o,inlineCodeClassName:l,linkClassName:c,imageClassName:d,onProposalSelect:u,onProposalSubmit:h}){const m=mr(),p=B.useMemo(()=>{return e=function(e){if(!e||!Dr.some(t=>e.includes(t)))return e;let t="",r=0;for(const n of e.matchAll(Mr))t+=Wr(e.slice(r,n.index)),t+=n[0],r=n.index+n[0].length;return t+=Wr(e.slice(r)),t}(function(e){if(!e?.includes("$"))return e;const t=[];let r=0;for(const n of e.matchAll(Br))t.push(dn(e.slice(r,n.index))),t.push(n[0]),r=n.index+n[0].length;return t.push(dn(e.slice(r))),t.join("")}(t)),e?.includes(":::")?e.replace(Jr,(e,t,r)=>{const n=r.trim(),a=Hr.exec(n);if(!a)return e;const i=a[0],s=n.slice(i.length).trim();return s?`${t}:::${i}\n${t}${s}\n${t}:::`:`${t}::${i}`}):e;var e},[t]),f=B.useMemo(()=>{const e=[ke,Ne,mn,Ce,xe,Ae,Se,...n];return a&&e.push(gn),e},[n,a]),g=B.useMemo(()=>[be],[]),y=B.useMemo(()=>({handlers:{...we}}),[]),v=B.useMemo(()=>{const t=r||{},n=t.code,a=t.a,s=t.img;return{...t,code:({node:t,className:r,children:a,...i})=>{const s=/language-([\w-]+)/.exec(r||""),c=!s,d=s?s[1]:"";if(!c&&d){if(m){const t=m.getComponent(d);if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if(Sr(d)){const t=String(a||"").trim();return e(Cr,{code:t,language:d})}const t=yn[d];if(t){const r=String(a||"").trim();return e(t,{code:r,language:d})}}if("function"==typeof n)return e(n,{node:t,className:r,...i,children:a});return e("code",{...i,className:c?`px-1.5 py-0.5 rounded ${l||""}`:` ${o||""}`,children:a})},a:t=>{const{node:r,href:n,children:s,...o}=t;return e(Tr,{node:r,href:n,className:c,artifactRunId:i,ExistingLink:"function"==typeof a?a:void 0,...o,children:s})},img:t=>{const{node:r,src:n,alt:a,title:o,...l}=t;return o?e(Pr,{src:n,alt:a,caption:o,className:d,artifactRunId:i}):e(Lr,{node:r,src:n,alt:a,className:d,artifactRunId:i,ExistingImg:"function"==typeof s?s:void 0,...l})}}},[r,i,m,o,l,c,d]),b=e(Xt,{artifactRunId:i,onProposalSelect:u,onProposalSubmit:h,MarkdownRenderer:vn,children:e(ye,{remarkPlugins:f,rehypePlugins:g,remarkRehypeOptions:y,components:v,urlTransform:fn,children:p})});return e("div",s?{className:`md-content ${s}`,children:b}:{className:"md-content",children:b})}function bn({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function xn({className:r,properties:n}){return e(l,{className:r,children:e("tbody",{children:n.map(r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(c,{description:r.description,placement:"top",children:e(V,{className:"size-3 ms-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name))})})}function wn({content:t,...r}){const n=X(null);return Q(()=>{if(!n.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(n.current.innerHTML="");Object.entries(r).forEach(([t,r])=>{if(null==r)return;const n="className"===t?"class":t;e.setAttribute(n,String(r))}),n.current.innerHTML="",n.current.appendChild(e)}),e("span",{ref:n})}function Nn(t){return r=>e(wn,{content:t,...r})}function kn(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}var Cn;!function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(Cn||(Cn={}));const Sn=function(){const e=Object.values(Cn),t=[...e];for(const r of e)t.push(`${r}[]`);return e.sort(),t}();function An({value:r,onChange:n,onCancel:a,onSave:s}){const{t:o}=ie(),[l,c]=Z(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(jn,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:a,onSave:s})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(On,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:a,onSave:s})}),t("div",{children:[e(i,{variant:"ghost",size:"xs",onClick:()=>c(!0),title:o("widgets.schema.editDescription"),children:e(z,{className:"size-4"})}),e($n,{value:r.description,isOpen:l,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),c(!1)}})]})]})}function jn({value:t,onChange:r,onCancel:a,onSave:i}){const s=X(null);Q(()=>{s.current?.focus()},[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":i?.();break;case"Escape":a?.()}},ref:s,value:t,onChange:e=>{r(e.target.value)},className:n.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function On({value:t,onChange:r,onCancel:a,onSave:i}){return e(d,{className:n.INPUT_UNSTYLED,options:Sn,value:t||"",onBlur:()=>{i?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?i?.():"Escape"===e.key&&a?.())},popupClass:"schema-type-suggest-popup z-90"})}function $n({value:r,isOpen:n,onClose:a}){const{t:i}=ie();return t(u,{isOpen:n,onClose:a,children:[e(h,{children:i("widgets.schema.editDescription")}),e(In,{value:r,onSave:a})]})}function In({value:n,onSave:a}){const{t:s}=ie(),o=X(null),[l,c]=Z(n||"");return Q(()=>{o.current?.focus()},[]),t(r,{children:[e(m,{className:"h-max",children:e("textarea",{ref:o,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:l,onChange:e=>c(e.target.value)})}),e(p,{children:e(i,{onClick:()=>a(l),children:s("store.saveChanges")})})]})}function Pn({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ms-2 text-sm text-muted",children:r.type||""})]}):null}function Rn(e,t){const r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const n=e.items;n.type=r,t.isObject&&!n.properties&&(n.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function Ln(e){let t,r=!1,n=!1;const a=e.type;if(Array.isArray(a))for(const e of a)"null"===e?r=!0:t||(t=e);else t=a;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?Fn(e[0].type):Fn(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:n,isObject:"object"===t,name:i}}function Fn(e){return e?Array.isArray(e)?e.find(e=>"null"!==e)||"any":e:"any"}let Tn=0;class En{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new Dn("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new Dn("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new En(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Dn{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,n){if(this.schema=t,this.loader=r,this.parent=n,this.name=e,this.type=Ln(t),this.parent){const t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return"string"==typeof this.schema.title?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];const e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(e,t){for(const r of Object.keys(e)){const n=e[r],a=new Dn(r,n,this.loader,this);t.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++Tn}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const n=function(e,t,r,n=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const a={};return Rn(a,r),e.properties[t]=a,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),a}(this._getPropertiesSchema(),e,t,r),a=new Dn(e,n,this.loader,this);return this.children.push(a),a}remove(){if(this.parent?.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const n=e.properties,a={};for(const e of Object.keys(n)){const i=n[e];e===t?a[r]=i:a[e]=i}e.properties=a}e.required&&(e.required=e.required.map(e=>e===t?r:e))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const n=e.required.indexOf(t);r?n<0&&e.required.push(t):n>-1&&e.required.splice(n,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const n=r!==this.schema.type;return e.type&&(Rn(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):n&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),n=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),n=!1);const a=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const n=Cn[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===Cn.object}}(t);let i;return"text"===a.name?(a.name=Cn.string,i="textarea"):"media"===a.name?(a.name=Cn.any,i="media"):"document"===a.name?(a.name=Cn.any,i="document"):i=null,{name:r,type:a,isRequired:n,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),n=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,n)}}function Vn(e){const[t,r]=Z(new En(e||{type:"object",properties:{}}).withChangeListener(e=>{r(e.clone())}));return t}const zn="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Mn=`${zn} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,qn=`${zn} shadow-xs ring-1 ring-inset ring-ring`;function _n({value:r,onChange:n,onDelete:a,outlineOnHover:i=!1,editOnClick:s=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:d,isEditing:u=!1,readonly:h=!1,onValidate:m}){const{on:p,off:g,isOn:y}=f(u),[v,b]=Z();return t("div",{className:"",children:[y&&!h?e(Wn,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void b(t);b(void 0)}n(e)&&g()},onCancel:g,editor:c,skipClickOutside:e=>!!d&&d(e)}):e(Un,{value:r,onEdit:p,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:s,onDelete:a,readonly:h}),v&&e("div",{className:"text-red-500 text-sm",children:v})]})}function Un({viewer:r,value:n,onEdit:a,editOnClick:s,outlineOnHover:o,placeholder:l,onDelete:c,readonly:d}){const u="invisible group-hover:visible";return t("div",{role:s?"button":void 0,tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&a()},onClick:()=>{s&&a()},className:b("flex justify-start items-center group",o?Mn:zn,{"cursor-pointer":s}),children:[e(r,{value:n,placeholder:l}),t("div",{className:"ms-auto flex gap-2",children:[!d&&c&&e(i,{variant:"ghost",size:"sm",className:u,onClick:c,children:e(N,{className:"size-4"})}),d?null:e(i,{variant:"ghost",size:"sm",className:u,onClick:a,children:e(M,{className:"size-4"})})]})]})}function Wn({editor:t,value:r,onSave:n,onCancel:a,skipClickOutside:i}){const[s,o]=Z(r),l=X(r),[c,d]=Z(null),u=()=>{n(l.current)},h=g(u,i);return e("div",{ref:h,children:e("div",{className:qn,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:s,onChange:(e,t=!1)=>{o(e),l.current=e,t&&(c&&clearTimeout(c),d(setTimeout(()=>{n(e)},500)))},onSave:u,onCancel:a})})})})}function Jn(e){const t=e.target;return!!t.closest?.(".schema-type-suggest-popup")}function Hn({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map(e=>Bn(e,n)),n?null:e(Yn,{parent:r.root})]})}function Bn(t,r){return t.isParent?e(Gn,{property:t,readonly:r},t.name):e(Kn,{node:t,readonly:r},t.name)}function Kn({node:t,readonly:r}){return e("li",{children:e(Xn,{property:t,readonly:r})})}function Gn({property:r,readonly:n}){const[a,s]=Z(!0),o=a?q:_;return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e(i,{variant:"ghost",size:"icon",onClick:()=>s(!a),"aria-label":a?`Collapse ${r.name}`:`Expand ${r.name}`,"aria-expanded":a,children:e(o,{className:"size-4 cn-rtl-flip"})}),e("div",{className:"flex-1",children:e(Xn,{property:r,readonly:n})})]}),a&&t("ul",{className:"ms-4 border-s border-gray-400 border-dashed",children:[(r.children||[]).map(e=>Bn(e,n)),n?null:e(Yn,{parent:r})]})]})}function Zn(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function Xn({property:t,readonly:r}){const{t:n}=ie(),a=y(),i=t.resetIsNew(),s=kn(t);return e(_n,{value:s,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return a({status:"error",title:n("widgets.schema.invalidPropertyDeclaration"),description:v(e),duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:An,viewer:Pn,outlineOnHover:!0,isEditing:i,skipClickOutside:Jn,readonly:r,onValidate:e=>Zn(e.name)})}function Yn({parent:r}){return t(i,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:Cn.string},!0).isNew=!0,r.reloadTree()},children:[e(w,{className:"size-4"}),"Add property"]})}function Qn({onDrop:r,message:n,buttonLabel:a,allowFolders:s=!0,className:o=""}){const{t:l}=ie(),c=a??l("upload.uploadFiles"),[d,u]=Z(!1),h=X(null),m=e=>{if(e&&e.length>0){const t=Array.from(e);if(t.some(e=>e.webkitRelativePath?.includes("/"))){const e=new Set(t.map(e=>e.webkitRelativePath.split("/")[0]).filter(Boolean)).size,n=t.length,a=l("upload.preparingFolder",{count:e,folderCount:e,fileCount:n}),i={count:t.length,message:a};r(t,i)}else{const e={count:t.length,message:l("upload.preparingFiles",{count:t.length})};r(t,e)}}};return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${d?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${o}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&u(!0)},onDragLeave:e=>{e.preventDefault(),h.current&&!h.current.contains(e.relatedTarget)&&u(!1)},onDrop:async e=>{if(e.preventDefault(),u(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],a=new Set,i=async e=>{if(function(e){return e.isFile}(e)){const t=await new Promise(t=>{e.file(r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)})});!t.name.startsWith(".")&&t.size>0&&n.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&a.add(r)}else if(function(e){return e.isDirectory}(e)){const t=e.createReader(),r=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(r.map(i));const n=e.fullPath.substring(1);n&&a.add(n)}};try{if(await Promise.all(t.map(e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()})),n.length>0){const e=new Set(Array.from(a).map(e=>e.split("/")[0]).filter(Boolean)).size,t=n.length;let i="";i=e>0?l("upload.preparingFolder",{count:e,folderCount:e,fileCount:t}):l("upload.preparingFiles",{count:t}),r(n,{count:n.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const n=Array.from(e.dataTransfer.files);n.length>0&&r(n)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(U,{className:"h-12 w-12 mb-3 transition-colors "+(d?"text-primary":"text-muted/50")}),e("p",{className:"text-muted",children:n}),t("div",{className:"flex gap-2 justify-center mt-2",children:[e(i,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e?.click(),e.onchange=()=>{m(e.files)}},children:c}),s&&e(i,{onClick:()=>{const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="*",e.webkitdirectory=!0,e?.click(),e.onchange=()=>{m(e.files)}},children:l("upload.selectFolder")})]})]})}function ea({title:r,count:n,icon:a=e(W,{className:"h-4 w-4 text-green-500"}),items:i}){const{t:s}=ie(),[o,l]=Z(!1),c=re();return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("button",{type:"button","aria-expanded":o,"aria-controls":c,className:"w-full flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:()=>l(!o),children:[t("span",{className:"flex items-center",children:[e("span",{className:"me-2",children:a}),e("span",{className:"font-medium",children:r}),e("span",{className:"ms-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("span",{className:"text-muted","aria-hidden":"true",children:e("svg",{className:"h-5 w-5 transition-transform "+(o?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),o&&e("div",{id:c,className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r))}):e("div",{className:"text-sm text-muted py-2",children:s("upload.noItems")})})]})}function ta({files:r,className:n="",location:a,collection:i}){const{t:s}=ie(),o=r.filter(e=>"success"===e.status),l=r.filter(e=>"updated"===e.status),c=r.filter(e=>"skipped"===e.status),d=r.filter(e=>"failed"===e.status),u=o.length,h=l.length,m=c.length,p=d.length,f=r.length;return t("div",{className:`flex flex-col py-2 ${n}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 me-4 rounded-full bg-success/10 flex items-center justify-center",children:e(W,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[s("upload.filesProcessed",{count:f}),i?s("upload.inCollection",{collection:i}):"",a?s("upload.inFolder",{location:a}):""]})})]}),t("div",{className:"space-y-3 mt-2",children:[u>0&&e(ea,{title:s("upload.successfullyUploaded"),count:u,icon:e(W,{className:"h-4 w-4 text-green-500"}),items:o.map(e=>e.name)}),h>0&&e(ea,{title:s("upload.successfullyUpdated"),count:h,icon:e(W,{className:"h-4 w-4 text-blue-500"}),items:l.map(e=>e.name)}),m>0&&e(ea,{title:s("upload.skippedAlreadyExisted"),count:m,icon:e(J,{className:"h-4 w-4 text-amber-500"}),items:c.map(e=>e.name)}),p>0&&e(ea,{title:s("upload.failedToUpload"),count:p,icon:e(H,{className:"h-4 w-4 text-red-500"}),items:d.map(e=>e.name)})]})]})}const ra="#text",na="#comment",aa="#cdata",ia="DECLARATION_TAG",sa={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},oa={attributeKeyColor:"#FFD700",attributeValueColor:"#FF4500",tagColor:"#87CEFA",textColor:"#00FF00",separatorColor:"#FFD700",commentColor:"#BEBEBE",cdataColor:"#33CC66",fontFamily:"monospace"},la=K({theme:sa,collapsible:!1,indentSize:2}),ca=()=>G(la),da=new $e({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:na,cdataPropName:aa,parseTagValue:!1});function ua(r){const{indentation:n,children:a,isInline:i}=r,{theme:s}=ca();return t("div",{style:{color:s.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),a,e("span",{children:`${i?"":n}]]>`})]})}function ha(t){const{collapsible:r,theme:n}=ca(),{collapsed:a}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(ma,{fill:n.separatorColor,style:{transform:`rotate(${a?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function ma({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24","aria-hidden":"true",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function pa(e){const{collapsible:t,initialCollapsedDepth:r}=ca(),[n,a]=Z(()=>!(Pe(r)||!t)&&e>=r);return Q(()=>{a(!(Pe(r)||!t)&&e>=r)},[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>a(e=>!e),role:"button",style:{cursor:"pointer"}}:{}}}function fa(r){const{indentation:n,children:a,isInline:i,level:s}=r,{theme:o}=ca(),{collapsed:l,buttonProps:c}=pa(s);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(ha,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&a,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function ga(r){const{attributes:n}=r,{theme:a}=ca();return n?e("span",{children:Object.entries(n).map(([r,n])=>t("span",{children:[e("span",{style:{color:a.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:a.separatorColor},children:"="}),e("span",{style:{color:a.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`))}):null}function ya(r){const{indentation:n,tagKey:a,attributes:i}=r,{theme:s}=ca();return t("div",{children:[e("span",{style:{color:s.separatorColor},children:`${n}<?`}),e("span",{style:{color:s.tagColor},children:`${a.slice(1)}`}),e(ga,{attributes:i}),e("span",{style:{color:s.separatorColor},children:"?>"})]})}function va(e){return"string"==typeof e&&e.includes("\n")}function ba(e){const t=e[":@"],r=Re(e,":@"),[[n,a]]=Object.entries(r),i=function(e){switch(e){case ra:case aa:case na:return e;default:return e.startsWith("?")?ia:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:a,type:i}}function xa(e){return!!e&&Object.keys(e).length>0}function wa(n){const{indentation:a,tagKey:i,attributes:s,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:u,buttonProps:h}=pa(d),{theme:m}=ca();return t("div",{children:[t("span",{...h,children:[e("span",{children:a}),e(ha,{collapsed:u}),e("span",{style:{color:m.separatorColor},children:"<"}),e("span",{style:{color:m.tagColor},children:`${i}`}),!u&&e(ga,{attributes:s}),u&&xa(s)&&" ...",e("span",{style:{color:m.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!u&&o,u&&"...",e("span",{style:{color:m.separatorColor},children:`${l||u?"":a}</`}),e("span",{style:{color:m.tagColor},children:`${i}`}),e("span",{style:{color:m.separatorColor},children:">"})]})]})}function Na(t){const{hasSiblings:r,text:n,indentation:a,isText:i}=t,{theme:s}=ca(),o=i?{color:s.textColor}:void 0;return va(n)||r?e("div",{style:o,children:n.split("\n").filter(e=>!!e.trim()).map((t,r)=>e("div",{children:`${a}${t.trim()}`},`${r}`))}):e("span",{style:o,children:n})}function ka(t){const{elements:n,level:a=0,isText:i=!0}=t,{indentSize:s}=ca();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=ba(t),u=n.length>1,h=function(e,t){return new Array(t*e+1).join(" ")}(s,a),m=`${a}-${r}`,p=function(e){return"string"!=typeof e&&1===e.length&&ra in e[0]&&!va(e[0][ra])}(c);switch(d){case ra:return e(Na,{text:c,indentation:h,hasSiblings:u,isText:i},m);case na:return e(fa,{isInline:p,indentation:h,level:a,children:e(ka,{elements:c,level:a+1,isText:!1})},m);case aa:return e(ua,{indentation:h,isInline:p,children:e(ka,{elements:c,level:a+1,isText:!1})},m);case ia:return e(ya,{indentation:h,tagKey:o,attributes:l},m);default:return e(wa,{indentation:h,tagKey:o,attributes:l,isInline:p,hasChildren:c.length>0,level:a,children:e(ka,{elements:c,level:a+1})},m)}})}):null}function Ca(){return e("div",{children:"Invalid XML!"})}function Sa(t){const{theme:r,xml:n,collapsible:a=!1,indentSize:i=2,invalidXml:s,initalCollapsedDepth:o,initialCollapsedDepth:l}=t,[c,d]=Z(()=>document.documentElement.classList.contains("dark"));Q(()=>{const e=document.documentElement,t=new MutationObserver(()=>{d(e.classList.contains("dark"))});return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const u=Y(()=>({...c?oa:sa,...r}),[c,r]),{json:h,valid:m}=function(e){return Y(()=>{try{const t=Ie.validate(e);if(!0!==t)throw new Error(t.err.msg||"Invalid XML!");const r=da.parse(e);if("string"==typeof e&&e.trim().length>0&&0===r.length)throw new Error("Invalid XML!");return{json:r,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}(n),p=Y(()=>({theme:u,collapsible:a,indentSize:i,initialCollapsedDepth:l??o}),[u,a,i,o,l]);return m?e(la.Provider,{value:p,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(ka,{elements:h})})}):s||e(Ca,{})}export{tt as ArrayPropertySchema,cr as ArtifactContentRenderer,wr as ChartCodeBlockHandler,tr as CodeBlockErrorBoundary,Xt as CodeBlockHandlerProvider,er as CodeBlockPlaceholder,hr as CodeBlockRendererProvider,Qn as DropZone,Cr as ExpandCodeBlockHandler,Fe as FieldSetContextProvider,qe as Form,Ee as FormContext,ze as FormContextProvider,Ye as FormError,Xe as FormHelper,Ze as FormLabel,Ue as GeneratedForm,Me as Input,ht as JSONCode,Ct as JSONDisplay,$t as JSONEditor,Pt as JSONSwitcher,Ft as JSONTable,gt as JSONView,dt as ManageObjectEntry,ct as ManagedListProperty,st as ManagedObject,it as ManagedObjectBase,ot as ManagedObjectProperty,lt as ManagedProperty,ut as ManagedScalarEntry,En as ManagedSchema,Pr as MarkdownFigure,Lr as MarkdownImage,Tr as MarkdownLink,vn as MarkdownRenderer,Nr as MermaidCodeBlockHandler,gr as MermaidDiagram,Ot as MonacoEditor,at as Node,bn as Progress,xn as PropertiesView,An as PropertyEditor,jn as PropertyNameEditor,et as PropertySchema,Pn as PropertyViewer,He as ScalarField,Qe as Schema,Hn as SchemaEditor,Dn as SchemaNode,wn as SvgIcon,ea as UploadResultCategory,ta as UploadSummary,jt as VEditorApi,Sa as XMLViewer,rt as computeTitleFromName,Ar as createDefaultCodeBlockHandlers,Nn as createSvgIcon,kn as getEditableSchemaProperty,It as getJSONEditorValue,Sr as isExpandLanguage,vr as isIncompleteJson,$r as mapSchemeToRoute,Or as parseUrlScheme,ft as renderJsonLine,yr as useArtifactContent,pr as useCodeBlockComponent,Yt as useCodeBlockContext,mr as useCodeBlockRendererRegistry,Te as useFieldSet,Ve as useForm,Ir as useResolvedUrl,Vn as useSchema,Zn as validatePropertyName};
2
2
  //# sourceMappingURL=vertesia-ui-widgets.js.map