@vertesia/ui 0.67.0 → 0.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/lib/esm/core/components/Badge.js +1 -1
  2. package/lib/esm/core/components/Badge.js.map +1 -1
  3. package/lib/esm/core/components/FormItem.js +2 -2
  4. package/lib/esm/core/components/FormItem.js.map +1 -1
  5. package/lib/esm/core/components/InputList.js +2 -2
  6. package/lib/esm/core/components/InputList.js.map +1 -1
  7. package/lib/esm/core/components/shadcn/checkbox.js +1 -1
  8. package/lib/esm/core/components/shadcn/checkbox.js.map +1 -1
  9. package/lib/esm/core/components/shadcn/command.js +1 -1
  10. package/lib/esm/core/components/shadcn/command.js.map +1 -1
  11. package/lib/esm/core/components/shadcn/dialog.js +6 -6
  12. package/lib/esm/core/components/shadcn/dialog.js.map +1 -1
  13. package/lib/esm/core/components/shadcn/filters/DynamicLabel.js.map +1 -1
  14. package/lib/esm/core/components/shadcn/filters/comboBox/DateCombobox.js +129 -0
  15. package/lib/esm/core/components/shadcn/filters/comboBox/DateCombobox.js.map +1 -0
  16. package/lib/esm/core/components/shadcn/filters/comboBox/SelectCombobox.js +46 -0
  17. package/lib/esm/core/components/shadcn/filters/comboBox/SelectCombobox.js.map +1 -0
  18. package/lib/esm/core/components/shadcn/filters/comboBox/StringListCombobox.js +23 -0
  19. package/lib/esm/core/components/shadcn/filters/comboBox/StringListCombobox.js.map +1 -0
  20. package/lib/esm/core/components/shadcn/filters/comboBox/TextCombobox.js +28 -0
  21. package/lib/esm/core/components/shadcn/filters/comboBox/TextCombobox.js.map +1 -0
  22. package/lib/esm/core/components/shadcn/filters/comboBox/comboBox.js +5 -0
  23. package/lib/esm/core/components/shadcn/filters/comboBox/comboBox.js.map +1 -0
  24. package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js +101 -0
  25. package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js.map +1 -0
  26. package/lib/esm/core/components/shadcn/filters/{stringListFilter.js → filter/StringListFilter.js} +3 -3
  27. package/lib/esm/core/components/shadcn/filters/filter/StringListFilter.js.map +1 -0
  28. package/lib/esm/core/components/shadcn/filters/{textFilter.js → filter/TextFilter.js} +4 -4
  29. package/lib/esm/core/components/shadcn/filters/filter/TextFilter.js.map +1 -0
  30. package/lib/esm/core/components/shadcn/filters/filter/dateFilter.js +161 -0
  31. package/lib/esm/core/components/shadcn/filters/filter/dateFilter.js.map +1 -0
  32. package/lib/esm/core/components/shadcn/filters/filter-styles.js +88 -0
  33. package/lib/esm/core/components/shadcn/filters/filter-styles.js.map +1 -0
  34. package/lib/esm/core/components/shadcn/filters/filterBar.js +128 -87
  35. package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -1
  36. package/lib/esm/core/components/shadcn/filters/filters.js +7 -6
  37. package/lib/esm/core/components/shadcn/filters/filters.js.map +1 -1
  38. package/lib/esm/core/components/shadcn/filters/index.js +1 -1
  39. package/lib/esm/core/components/shadcn/filters/index.js.map +1 -1
  40. package/lib/esm/core/components/shadcn/filters/types.js.map +1 -1
  41. package/lib/esm/core/components/toast/NotificationPanel.js +24 -18
  42. package/lib/esm/core/components/toast/NotificationPanel.js.map +1 -1
  43. package/lib/esm/features/agent/PayloadBuilder.js +47 -27
  44. package/lib/esm/features/agent/PayloadBuilder.js.map +1 -1
  45. package/lib/esm/features/agent/chat/ModernAgentConversation.js +9 -3
  46. package/lib/esm/features/agent/chat/ModernAgentConversation.js.map +1 -1
  47. package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +7 -6
  48. package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  49. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js +12 -1
  50. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  51. package/lib/esm/features/agent/chat/ModernAgentOutput/SlidingMessages.js +2 -1
  52. package/lib/esm/features/agent/chat/ModernAgentOutput/SlidingMessages.js.map +1 -1
  53. package/lib/esm/features/agent/chat/ModernAgentOutput/utils.js +10 -4
  54. package/lib/esm/features/agent/chat/ModernAgentOutput/utils.js.map +1 -1
  55. package/lib/esm/features/facets/DocumentsFacetsNav.js +133 -0
  56. package/lib/esm/features/facets/DocumentsFacetsNav.js.map +1 -0
  57. package/lib/esm/features/facets/RunsFacetsNav.js +125 -0
  58. package/lib/esm/features/facets/RunsFacetsNav.js.map +1 -0
  59. package/lib/esm/features/facets/VFacetsNav.js +4 -113
  60. package/lib/esm/features/facets/VFacetsNav.js.map +1 -1
  61. package/lib/esm/features/facets/VStringFacet.js +6 -4
  62. package/lib/esm/features/facets/VStringFacet.js.map +1 -1
  63. package/lib/esm/features/facets/VTypeFacet.js +4 -5
  64. package/lib/esm/features/facets/VTypeFacet.js.map +1 -1
  65. package/lib/esm/features/facets/VUserFacet.js +1 -1
  66. package/lib/esm/features/facets/VUserFacet.js.map +1 -1
  67. package/lib/esm/features/facets/WorkflowExecutionsFacetsNav.js +98 -0
  68. package/lib/esm/features/facets/WorkflowExecutionsFacetsNav.js.map +1 -0
  69. package/lib/esm/features/facets/index.js +3 -2
  70. package/lib/esm/features/facets/index.js.map +1 -1
  71. package/lib/esm/features/store/collections/CollectionsTable.js +1 -1
  72. package/lib/esm/features/store/collections/CollectionsTable.js.map +1 -1
  73. package/lib/esm/features/store/collections/CreateCollection.js +10 -9
  74. package/lib/esm/features/store/collections/CreateCollection.js.map +1 -1
  75. package/lib/esm/features/store/collections/EditCollectionView.js +10 -9
  76. package/lib/esm/features/store/collections/EditCollectionView.js.map +1 -1
  77. package/lib/esm/features/store/collections/SelectCollection.js +1 -1
  78. package/lib/esm/features/store/collections/SelectCollection.js.map +1 -1
  79. package/lib/esm/features/store/objects/DocumentPreviewPanel.js +0 -1
  80. package/lib/esm/features/store/objects/DocumentPreviewPanel.js.map +1 -1
  81. package/lib/esm/features/store/objects/DocumentSearchResults.js +37 -2
  82. package/lib/esm/features/store/objects/DocumentSearchResults.js.map +1 -1
  83. package/lib/esm/features/store/objects/components/ContentOverview.js +0 -2
  84. package/lib/esm/features/store/objects/components/ContentOverview.js.map +1 -1
  85. package/lib/esm/features/store/objects/components/SelectDocument.js +2 -2
  86. package/lib/esm/features/store/objects/components/SelectDocument.js.map +1 -1
  87. package/lib/esm/features/store/objects/components/VectorSearchWidget.js +1 -1
  88. package/lib/esm/features/store/objects/components/VectorSearchWidget.js.map +1 -1
  89. package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js +16 -4
  90. package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js.map +1 -1
  91. package/lib/esm/features/store/objects/upload/DocumentUploadModal.js +72 -37
  92. package/lib/esm/features/store/objects/upload/DocumentUploadModal.js.map +1 -1
  93. package/lib/esm/features/store/types/ObjectSchemaEditor.js +15 -0
  94. package/lib/esm/features/store/types/ObjectSchemaEditor.js.map +1 -1
  95. package/lib/esm/features/user/UserInfo.js +8 -8
  96. package/lib/esm/features/user/UserInfo.js.map +1 -1
  97. package/lib/esm/router/HistoryNavigator.js +2 -2
  98. package/lib/esm/router/HistoryNavigator.js.map +1 -1
  99. package/lib/esm/shell/SplashScreen.js +19 -0
  100. package/lib/esm/shell/SplashScreen.js.map +1 -0
  101. package/lib/esm/shell/VertesiaShell.js +10 -0
  102. package/lib/esm/shell/VertesiaShell.js.map +1 -0
  103. package/lib/esm/shell/index.js +7 -0
  104. package/lib/esm/shell/index.js.map +1 -0
  105. package/lib/esm/shell/login/EnterpriseSigninButton.js +81 -0
  106. package/lib/esm/shell/login/EnterpriseSigninButton.js.map +1 -0
  107. package/lib/esm/shell/login/GitHubSignInButton.js +24 -0
  108. package/lib/esm/shell/login/GitHubSignInButton.js.map +1 -0
  109. package/lib/esm/shell/login/GoogleSignInButton.js +25 -0
  110. package/lib/esm/shell/login/GoogleSignInButton.js.map +1 -0
  111. package/lib/esm/shell/login/InviteAcceptModal.js +45 -0
  112. package/lib/esm/shell/login/InviteAcceptModal.js.map +1 -0
  113. package/lib/esm/shell/login/MicrosoftSigninButton.js +19 -0
  114. package/lib/esm/shell/login/MicrosoftSigninButton.js.map +1 -0
  115. package/lib/esm/shell/login/PreviewIcon.js +23 -0
  116. package/lib/esm/shell/login/PreviewIcon.js.map +1 -0
  117. package/lib/esm/shell/login/SignInModal.js +9 -0
  118. package/lib/esm/shell/login/SignInModal.js.map +1 -0
  119. package/lib/esm/shell/login/SigninScreen.js +64 -0
  120. package/lib/esm/shell/login/SigninScreen.js.map +1 -0
  121. package/lib/esm/shell/login/SignupForm.js +91 -0
  122. package/lib/esm/shell/login/SignupForm.js.map +1 -0
  123. package/lib/esm/shell/login/TerminalLogin.js +179 -0
  124. package/lib/esm/shell/login/TerminalLogin.js.map +1 -0
  125. package/lib/esm/shell/login/UserInfo.js +40 -0
  126. package/lib/esm/shell/login/UserInfo.js.map +1 -0
  127. package/lib/esm/shell/login/UserSessionMenu.js +31 -0
  128. package/lib/esm/shell/login/UserSessionMenu.js.map +1 -0
  129. package/lib/esm/shell/utils.js +6 -0
  130. package/lib/esm/shell/utils.js.map +1 -0
  131. package/lib/esm/widgets/SvgIcon.js +36 -0
  132. package/lib/esm/widgets/SvgIcon.js.map +1 -0
  133. package/lib/esm/widgets/index.js +7 -6
  134. package/lib/esm/widgets/index.js.map +1 -1
  135. package/lib/esm/widgets/upload/UploadSummary.js +1 -1
  136. package/lib/esm/widgets/upload/UploadSummary.js.map +1 -1
  137. package/lib/tsconfig.tsbuildinfo +1 -1
  138. package/lib/types/core/components/FormItem.d.ts +2 -1
  139. package/lib/types/core/components/shadcn/dialog.d.ts +2 -1
  140. package/lib/types/core/components/shadcn/filters/DynamicLabel.d.ts +1 -1
  141. package/lib/types/core/components/shadcn/filters/comboBox/DateCombobox.d.ts +5 -0
  142. package/lib/types/core/components/shadcn/filters/comboBox/SelectCombobox.d.ts +8 -0
  143. package/lib/types/core/components/shadcn/filters/comboBox/StringListCombobox.d.ts +5 -0
  144. package/lib/types/core/components/shadcn/filters/comboBox/TextCombobox.d.ts +5 -0
  145. package/lib/types/core/components/shadcn/filters/comboBox/comboBox.d.ts +4 -0
  146. package/lib/types/core/components/shadcn/filters/{selectFilter.d.ts → filter/SelectFilter.d.ts} +2 -2
  147. package/lib/types/core/components/shadcn/filters/{stringListFilter.d.ts → filter/StringListFilter.d.ts} +1 -1
  148. package/lib/types/core/components/shadcn/filters/{textFilter.d.ts → filter/TextFilter.d.ts} +1 -1
  149. package/lib/types/core/components/shadcn/filters/{dateFilter.d.ts → filter/dateFilter.d.ts} +1 -1
  150. package/lib/types/core/components/shadcn/filters/filter-styles.d.ts +1 -0
  151. package/lib/types/core/components/shadcn/filters/filterBar.d.ts +14 -4
  152. package/lib/types/core/components/shadcn/filters/index.d.ts +1 -1
  153. package/lib/types/core/components/shadcn/filters/types.d.ts +2 -0
  154. package/lib/types/features/agent/PayloadBuilder.d.ts +17 -8
  155. package/lib/types/features/agent/chat/ModernAgentOutput/utils.d.ts +2 -1
  156. package/lib/types/features/facets/DocumentsFacetsNav.d.ts +16 -0
  157. package/lib/types/features/facets/RunsFacetsNav.d.ts +18 -0
  158. package/lib/types/features/facets/VFacetsNav.d.ts +1 -1
  159. package/lib/types/features/facets/VStringFacet.d.ts +6 -2
  160. package/lib/types/features/facets/VTypeFacet.d.ts +3 -1
  161. package/lib/types/features/facets/WorkflowExecutionsFacetsNav.d.ts +13 -0
  162. package/lib/types/features/facets/index.d.ts +3 -2
  163. package/lib/types/shell/SplashScreen.d.ts +4 -0
  164. package/lib/types/shell/VertesiaShell.d.ts +7 -0
  165. package/lib/types/shell/index.d.ts +6 -0
  166. package/lib/types/shell/login/EnterpriseSigninButton.d.ts +5 -0
  167. package/lib/types/shell/login/GitHubSignInButton.d.ts +5 -0
  168. package/lib/types/shell/login/GoogleSignInButton.d.ts +5 -0
  169. package/lib/types/shell/login/InviteAcceptModal.d.ts +1 -0
  170. package/lib/types/shell/login/MicrosoftSigninButton.d.ts +5 -0
  171. package/lib/types/shell/login/PreviewIcon.d.ts +5 -0
  172. package/lib/types/shell/login/SignInModal.d.ts +6 -0
  173. package/lib/types/shell/login/SigninScreen.d.ts +8 -0
  174. package/lib/types/shell/login/SignupForm.d.ts +7 -0
  175. package/lib/types/shell/login/TerminalLogin.d.ts +1 -0
  176. package/lib/types/shell/login/UserInfo.d.ts +5 -0
  177. package/lib/types/shell/login/UserSessionMenu.d.ts +8 -0
  178. package/lib/types/shell/utils.d.ts +1 -0
  179. package/lib/types/widgets/SvgIcon.d.ts +6 -0
  180. package/lib/types/widgets/index.d.ts +7 -6
  181. package/lib/vertesia-ui-core.js +1 -1
  182. package/lib/vertesia-ui-core.js.map +1 -1
  183. package/lib/vertesia-ui-features.js +1 -1
  184. package/lib/vertesia-ui-features.js.map +1 -1
  185. package/lib/vertesia-ui-router.js +1 -1
  186. package/lib/vertesia-ui-router.js.map +1 -1
  187. package/lib/vertesia-ui-shell.js +2 -0
  188. package/lib/vertesia-ui-shell.js.map +1 -0
  189. package/lib/vertesia-ui-widgets.js +1 -1
  190. package/lib/vertesia-ui-widgets.js.map +1 -1
  191. package/package.json +14 -6
  192. package/src/core/components/Badge.tsx +12 -8
  193. package/src/core/components/FormItem.tsx +4 -3
  194. package/src/core/components/InputList.tsx +21 -17
  195. package/src/core/components/shadcn/checkbox.tsx +2 -2
  196. package/src/core/components/shadcn/command.tsx +1 -1
  197. package/src/core/components/shadcn/dialog.tsx +18 -9
  198. package/src/core/components/shadcn/filters/DynamicLabel.tsx +1 -2
  199. package/src/core/components/shadcn/filters/comboBox/DateCombobox.tsx +211 -0
  200. package/src/core/components/shadcn/filters/{comboBox.tsx → comboBox/SelectCombobox.tsx} +8 -192
  201. package/src/core/components/shadcn/filters/comboBox/StringListCombobox.tsx +76 -0
  202. package/src/core/components/shadcn/filters/comboBox/TextCombobox.tsx +81 -0
  203. package/src/core/components/shadcn/filters/comboBox/comboBox.tsx +4 -0
  204. package/src/core/components/shadcn/filters/filter/SelectFilter.tsx +161 -0
  205. package/src/core/components/shadcn/filters/{stringListFilter.tsx → filter/StringListFilter.tsx} +7 -7
  206. package/src/core/components/shadcn/filters/{textFilter.tsx → filter/TextFilter.tsx} +17 -11
  207. package/src/core/components/shadcn/filters/filter/dateFilter.tsx +256 -0
  208. package/src/core/components/shadcn/filters/filter-styles.ts +87 -0
  209. package/src/core/components/shadcn/filters/filterBar.tsx +208 -152
  210. package/src/core/components/shadcn/filters/filters.tsx +7 -5
  211. package/src/core/components/shadcn/filters/index.ts +1 -1
  212. package/src/core/components/shadcn/filters/types.ts +2 -0
  213. package/src/core/components/toast/NotificationPanel.tsx +38 -22
  214. package/src/features/agent/PayloadBuilder.tsx +56 -31
  215. package/src/features/agent/chat/ModernAgentConversation.tsx +10 -4
  216. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +7 -6
  217. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +12 -1
  218. package/src/features/agent/chat/ModernAgentOutput/SlidingMessages.tsx +2 -1
  219. package/src/features/agent/chat/ModernAgentOutput/utils.ts +12 -4
  220. package/src/features/facets/DocumentsFacetsNav.tsx +171 -0
  221. package/src/features/facets/RunsFacetsNav.tsx +166 -0
  222. package/src/features/facets/VFacetsNav.tsx +10 -126
  223. package/src/features/facets/VStringFacet.tsx +10 -4
  224. package/src/features/facets/VTypeFacet.tsx +6 -5
  225. package/src/features/facets/VUserFacet.tsx +5 -3
  226. package/src/features/facets/WorkflowExecutionsFacetsNav.tsx +132 -0
  227. package/src/features/facets/index.ts +5 -2
  228. package/src/features/store/collections/CollectionsTable.tsx +3 -2
  229. package/src/features/store/collections/CreateCollection.tsx +17 -15
  230. package/src/features/store/collections/EditCollectionView.tsx +19 -16
  231. package/src/features/store/collections/SelectCollection.tsx +1 -1
  232. package/src/features/store/objects/DocumentPreviewPanel.tsx +0 -1
  233. package/src/features/store/objects/DocumentSearchResults.tsx +80 -11
  234. package/src/features/store/objects/components/ContentOverview.tsx +0 -2
  235. package/src/features/store/objects/components/SelectDocument.tsx +2 -2
  236. package/src/features/store/objects/components/VectorSearchWidget.tsx +2 -2
  237. package/src/features/store/objects/selection/actions/AddToCollectionAction.tsx +40 -19
  238. package/src/features/store/objects/upload/DocumentUploadModal.tsx +160 -214
  239. package/src/features/store/types/ObjectSchemaEditor.tsx +15 -0
  240. package/src/features/user/UserInfo.tsx +17 -14
  241. package/src/router/HistoryNavigator.ts +2 -2
  242. package/src/shell/SplashScreen.tsx +41 -0
  243. package/src/shell/VertesiaShell.tsx +27 -0
  244. package/src/shell/index.tsx +6 -0
  245. package/src/shell/login/EnterpriseSigninButton.tsx +106 -0
  246. package/src/shell/login/GitHubSignInButton.tsx +40 -0
  247. package/src/shell/login/GoogleSignInButton.tsx +36 -0
  248. package/src/shell/login/InviteAcceptModal.tsx +78 -0
  249. package/src/shell/login/MicrosoftSigninButton.tsx +30 -0
  250. package/src/shell/login/PreviewIcon.tsx +29 -0
  251. package/src/shell/login/SignInModal.tsx +28 -0
  252. package/src/shell/login/SigninScreen.tsx +162 -0
  253. package/src/shell/login/SignupForm.tsx +178 -0
  254. package/src/shell/login/TerminalLogin.tsx +299 -0
  255. package/src/shell/login/UserInfo.tsx +76 -0
  256. package/src/shell/login/UserSessionMenu.tsx +81 -0
  257. package/src/shell/utils.tsx +7 -0
  258. package/src/widgets/SvgIcon.tsx +44 -0
  259. package/src/widgets/index.ts +7 -6
  260. package/src/widgets/upload/UploadSummary.tsx +3 -4
  261. package/lib/esm/core/components/shadcn/filters/comboBox.js +0 -101
  262. package/lib/esm/core/components/shadcn/filters/comboBox.js.map +0 -1
  263. package/lib/esm/core/components/shadcn/filters/dateFilter.js +0 -36
  264. package/lib/esm/core/components/shadcn/filters/dateFilter.js.map +0 -1
  265. package/lib/esm/core/components/shadcn/filters/selectFilter.js +0 -67
  266. package/lib/esm/core/components/shadcn/filters/selectFilter.js.map +0 -1
  267. package/lib/esm/core/components/shadcn/filters/stringListFilter.js.map +0 -1
  268. package/lib/esm/core/components/shadcn/filters/textFilter.js.map +0 -1
  269. package/lib/esm/features/facets/InteractionFacet.js +0 -39
  270. package/lib/esm/features/facets/InteractionFacet.js.map +0 -1
  271. package/lib/esm/features/facets/TypeOptions.js +0 -19
  272. package/lib/esm/features/facets/TypeOptions.js.map +0 -1
  273. package/lib/esm/features/facets/UserFacet.js +0 -33
  274. package/lib/esm/features/facets/UserFacet.js.map +0 -1
  275. package/lib/types/core/components/shadcn/filters/comboBox.d.ts +0 -22
  276. package/lib/types/features/facets/InteractionFacet.d.ts +0 -9
  277. package/lib/types/features/facets/TypeOptions.d.ts +0 -3
  278. package/lib/types/features/facets/UserFacet.d.ts +0 -11
  279. package/src/core/components/shadcn/filters/dateFilter.tsx +0 -82
  280. package/src/core/components/shadcn/filters/selectFilter.tsx +0 -110
  281. package/src/features/facets/InteractionFacet.tsx +0 -53
  282. package/src/features/facets/TypeOptions.tsx +0 -22
  283. package/src/features/facets/UserFacet.tsx +0 -61
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{isNil as n,omit as s,isEqual as i}from"lodash-es";import a,{createContext as o,useContext as l,useMemo as c,useState as d,useEffect as h,useRef as u,Children as p,isValidElement as m}from"react";import{XMLParser as f,XMLValidator as g}from"fast-xml-parser";import{ObjectWalker as y}from"@vertesia/json";import{DotBadge as v,useSafeLayoutEffect as b,useToast as x,VModal as w,VModalTitle as N,VModalBody as k,VModalFooter as C,Button as j,Styles as S,VSelectBox as O,ModalBody as A,ModalFooter as P,useFlag as $,useClickOutside as E,Table as I,VTooltip as T}from"@vertesia/ui/core";import q from"clsx";import M from"ajv";import{json as L}from"@codemirror/lang-json";import D from"debounce";import{EditorView as F}from"@codemirror/view";import{Text as R,EditorState as V}from"@codemirror/state";import{basicSetup as _}from"codemirror";import{AlignLeft as z,Trash2 as U,SquarePen as K,Plus as B,ChevronDown as W,ChevronRight as H,Info as J,UploadIcon as G,CheckCircleIcon as X,AlertCircleIcon as Z,XCircleIcon as Y}from"lucide-react";import{offset as Q,shift as ee,flip as te}from"@floating-ui/dom";import{useFloating as re,autoUpdate as ne,useDismiss as se,useClick as ie,useHover as ae,useInteractions as oe,useTransitionStyles as le,FloatingPortal as ce,FloatingFocusManager as de,safePolygon as he}from"@floating-ui/react";const ue="#text",pe="#comment",me="#cdata",fe="DECLARATION_TAG",ge={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},ye=o({theme:ge,collapsible:!1,indentSize:2}),ve=()=>l(ye),be=new f({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:pe,cdataPropName:me,parseTagValue:!1});function xe(r){const{indentation:n,children:s,isInline:i}=r,{theme:a}=ve();return e("div",{style:{color:a.cdataColor},children:[t("span",{children:`${n}<![CDATA[`}),s,t("span",{children:`${i?"":n}]]>`})]})}function we(e){const{collapsible:r,theme:n}=ve(),{collapsed:s}=e;return r?t("span",{style:{position:"relative"},children:t("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:t(Ne,{fill:n.separatorColor,style:{transform:`rotate(${s?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function Ne({...e}){return t("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",...e,children:t("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 ke(e){const{collapsible:t,initialCollapsedDepth:r}=ve(),[s,i]=d((()=>!(n(r)||!t)&&e>=r));return h((()=>{i(!(n(r)||!t)&&e>=r)}),[r,e,t]),{collapsed:s,buttonProps:t?{onClick:()=>i((e=>!e)),role:"button",style:{cursor:"pointer"}}:{}}}function Ce(r){const{indentation:n,children:s,isInline:i,level:a}=r,{theme:o}=ve(),{collapsed:l,buttonProps:c}=ke(a);return e("div",{style:{color:o.commentColor},children:[e("span",{...c,children:[t("span",{children:n}),t(we,{collapsed:l}),t("span",{children:"\x3c!-- "})]}),!l&&s,l&&"...",t("span",{children:`${i||l?" ":n}--\x3e`})]})}function je(r){const{attributes:n}=r,{theme:s}=ve();return n?t("span",{children:Object.entries(n).map((([r,n])=>e("span",{children:[t("span",{style:{color:s.attributeKeyColor},children:` ${r}`}),t("span",{style:{color:s.separatorColor},children:"="}),t("span",{style:{color:s.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`)))}):null}function Se(r){const{indentation:n,tagKey:s,attributes:i}=r,{theme:a}=ve();return e("div",{children:[t("span",{style:{color:a.separatorColor},children:`${n}<?`}),t("span",{style:{color:a.tagColor},children:`${s.slice(1)}`}),t(je,{attributes:i}),t("span",{style:{color:a.separatorColor},children:"?>"})]})}function Oe(e){return"string"==typeof e&&e.includes("\n")}function Ae(e){const t=e[":@"],r=s(e,":@"),[[n,i]]=Object.entries(r),a=function(e){switch(e){case ue:case me:case pe:return e;default:return e.startsWith("?")?fe:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:i,type:a}}function Pe(e){return!!e&&Object.keys(e).length>0}function $e(n){const{indentation:s,tagKey:i,attributes:a,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:h,buttonProps:u}=ke(d),{theme:p}=ve();return e("div",{children:[e("span",{...u,children:[t("span",{children:s}),t(we,{collapsed:h}),t("span",{style:{color:p.separatorColor},children:"<"}),t("span",{style:{color:p.tagColor},children:`${i}`}),!h&&t(je,{attributes:a}),h&&Pe(a)&&" ...",t("span",{style:{color:p.separatorColor},children:c?">":" />"})]}),c&&e(r,{children:[!h&&o,h&&"...",t("span",{style:{color:p.separatorColor},children:`${l||h?"":s}</`}),t("span",{style:{color:p.tagColor},children:`${i}`}),t("span",{style:{color:p.separatorColor},children:">"})]})]})}function Ee(e){const{hasSiblings:r,text:n,indentation:s,isText:i}=e,{theme:a}=ve(),o=i?{color:a.textColor}:void 0;return Oe(n)||r?t("div",{style:o,children:n.split("\n").filter((e=>!!e.trim())).map(((e,r)=>t("div",{children:`${s}${e.trim()}`},`${r}`)))}):t("span",{style:o,children:n})}function Ie(e){const{elements:n,level:s=0,isText:i=!0}=e,{indentSize:a}=ve();return Array.isArray(n)&&0!==n.length?t(r,{children:n.map(((e,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=Ae(e),h=n.length>1,u=function(e,t){return new Array(t*e+1).join(" ")}(a,s),p=`${s}-${r}`,m=function(e){return"string"!=typeof e&&1===e.length&&ue in e[0]&&!Oe(e[0][ue])}(c);switch(d){case ue:return t(Ee,{text:c,indentation:u,hasSiblings:h,isText:i},p);case pe:return t(Ce,{isInline:m,indentation:u,level:s,children:t(Ie,{elements:c,level:s+1,isText:!1})},p);case me:return t(xe,{indentation:u,isInline:m,children:t(Ie,{elements:c,level:s+1,isText:!1})},p);case fe:return t(Se,{indentation:u,tagKey:o,attributes:l},p);default:return t($e,{indentation:u,tagKey:o,attributes:l,isInline:m,hasChildren:c.length>0,level:s,children:t(Ie,{elements:c,level:s+1})},p)}}))}):null}function Te(){return t("div",{children:"Invalid XML!"})}function qe(e){const{theme:r,xml:n,collapsible:s=!1,indentSize:a=2,invalidXml:o,initalCollapsedDepth:l,initialCollapsedDepth:u}=e,[p,m]=d((()=>({...ge,...r}))),{json:f,valid:y}=function(e){return c((()=>{try{if(!g.validate(e))throw new Error("Invalid XML!");const t=be.parse(e);if("string"==typeof e&&e.trim().length>0&&0===t.length)throw new Error("Invalid XML!");return{json:t,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}}),[e])}(n),v=c((()=>({theme:p,collapsible:s,indentSize:a,initialCollapsedDepth:u??l})),[p,s,a,l,u]);return h((()=>{m((e=>{const t={...ge,...r};return i(t,e)?e:t}))}),[r]),y?t(ye.Provider,{value:v,children:t("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:p.fontFamily,overflowWrap:"break-word"},children:t(Ie,{elements:f})})}):o||t(Te,{})}const Me="text-pink-500 dark:text-pink-400",Le="text-purple-500 dark:text-purple-400",De="text-blue-500 dark:text-blue-400",Fe={code:"bg-gray-100 dark:bg-slate-800 whitespace-pre-wrap p-4 rounded-lg font-mono",comma:Me,assign:Me,startObject:Me,endObject:Me,startArray:Me,endArray:Me,boolean:Le,null:Le,key:De,index:De,string:"text-orange-500 dark:text-orange-400",number:"text-green-500 dark:text-green-400"};class Re{renderer;parent;key;indent;result=[];constructor(e,t,r,n){this.renderer=e,this.parent=t,this.key=r,this.indent=n}get classMap(){return this.renderer.classMap}writeKey(e){const t=typeof e;"string"===t?(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent),this.result.push(`<span class="${this.classMap.key}">"${e}"</span><span class='${this.classMap.assign}'>: </span>`)):"number"===t&&(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent))}pushValue(e,t){if(this.writeKey(e),null===t)this.result.push(`<span class='${this.classMap.null}'>null</span>`);else if(t instanceof Re)this.result.push(t.renderStart()+t.renderValue()+t.renderEnd());else{let e;const r=typeof t;"string"===r?(t=(t=`"${t}"`).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e=this.classMap.string):"number"===r?e=this.classMap.number:"boolean"===r&&(e=this.classMap.boolean),this.result.push(`<span class='${e}'>${t}</span>`)}}renderValue(){return this.result.join("")}}class Ve extends Re{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startObject}'>{\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endObject}'>${e}${this.parent?.indent||""}}</span>`}}class _e extends Re{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startArray}'>[\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endArray}'>${e}${this.parent?.indent||""}]</span>`}}class ze{classMap;tab;stack=[];block=new Ve(this,void 0,"","");constructor(e=Fe,t=" "){this.classMap=e,this.tab=t}onStartObject(e){const t=new Ve(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndObject(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onStartIteration(e){const t=new _e(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndIteration(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onValue(e,t){this.block.pushValue(e,t)}}function Ue({data:e,className:r,classMap:n}){const[s,i]=d();return h((()=>{i(function(e,r,n){const s=new ze(r);(new y).walk(e,s);const i=s.block.renderValue();return t("div",{className:n,dangerouslySetInnerHTML:{__html:`<div class='${s.classMap.code}' style='overflow-x: scroll'>${i}</div>`}})}(e,n,r))}),[e]),s}class Ke{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new M({allErrors:!0,strict:!1});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(){return this.schema.title||this.schema.name}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new We(this,e,t):new Be(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"===(s=t)?{type:"object",properties:{}}:"array"===s?{type:"array",items:{}}:{type:s}:t;var s;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 this.schema.editor}}class Be extends Ke{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 We extends Be{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 He(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function Je(e,t){if(t.editor)return t.editor;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class Ge{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||He(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class Xe extends Ge{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new et(this,t,this.getOrInitArrayProperty(e)):t.isObject?new Ye(this,t,t.name,this.getOrInitObjectProperty(e)):new Qe(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 et(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new Ye(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Qe(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Ze extends Xe{value;constructor(e,t={}){super(null,e instanceof Ke?e:new Ke(e),"#root"),this.value=t}}class Ye extends Xe{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class Qe extends Ge{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 Je(this.name,this.schema)}}class et extends Ge{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 tt(this,e):new rt(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 Ye(this,this.schema,String(e),t):new rt(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class tt extends Xe{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 rt extends Ge{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 Je(this.name,this.schema)}}function nt({value:e}){return t("div",{className:"flex flex-col gap-4",children:Object.entries(e).map((([e,r])=>t(at,{name:e,value:r},e)))})}function st({name:e}){return t("div",{className:"text-md font-semibold",children:He(e)})}function it({children:e,className:r}){return t("div",{className:q("flex flex-col gap-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",r),children:e})}function at({name:r,value:n}){const s=dt(n);switch(s.type){case ct.Inline:return e("div",{className:"w-full flex gap-2",children:[t(st,{name:r+":"}),t("p",{children:s.value})]});case ct.Paragraph:return e("div",{children:[t(st,{name:r}),t("p",{children:s.value})]});case ct.Prose:return e("div",{className:"prose dark:prose-invert",children:[t(st,{name:r}),t("div",{className:"vprose dark:prose-invert",children:s.value})]});case ct.Array:return t(ot,{name:r,value:n});case ct.Object:return e("div",{children:[t(st,{name:r}),t(it,{className:"mt-2",children:Object.entries(n).map((([e,r])=>t(at,{name:e,value:r},e)))})]})}}function ot({name:r,value:n}){const s=n.join(" ").length,i=s/n.length,a="string"==typeof n[0]&&(s<80||s<400&&i<32),o=n.length>9;return e("div",a?{className:"flex gap-2 flex-wrap",children:[r&&t(st,{name:r+":"}),n.map(((e,r)=>t(v,{children:String(e)},r)))]}:{children:[r&&t(st,{name:r}),t("div",{className:"flex flex-col gap-2",children:n.map(((e,r)=>t(lt,{index:r,value:e,useBullet:o},r)))})]})}function lt({index:r,value:n,useBullet:s}){const i=s?t("span",{className:"text-xl",children:"•"}):e("span",{children:[r+1,"."]}),a=dt(n);let o;switch(a.type){case ct.Object:o=t(it,{children:Object.entries(n).map((([e,r])=>t(at,{name:e,value:r},e)))});break;case ct.Array:o=t(ot,{value:n});break;case ct.Prose:o=t("div",{className:"prose dark:prose-invert",children:a.value});break;default:o=t("div",{children:a.value})}return e("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pr-2 pl-4",children:[t("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),t("div",{children:o})]})}var ct;function dt(e){if(null==e)return{value:"-",type:ct.Inline};if(Array.isArray(e))return{value:e,type:ct.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=ct.Inline:t>400?r=ct.Prose:(r=ct.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:ct.Inline}:{value:e,type:ct.Object}}function ht({value:e,viewCode:r=!1}){return e?t("div",{className:"relative w-full",children:r?t(Ue,{data:e}):t(nt,{value:e})}):t("pre",{className:"whitespace-pre-wrap",children:"No Data to display"})}!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"}(ct||(ct={}));let ut=null;class pt{editor;constructor(e){this.editor=e}setValue(e){this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:e||""}})}getValue(){return this.editor.state.doc.toString()}}const mt=[F.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{fontFamily:"inherit"},".cm-scroller":{fontFamily:"inherit"},".cm-gutters":{backgroundColor:"transparent",color:"#ddd"},".cm-focused":{outline:"none"},".cm-cursor":{borderLeft:"2px solid #808080",borderLeftColor:"#808080",animation:"blink 1.2s step-start infinite"},"@keyframes blink":{"50%":{opacity:0}}}),F.lineWrapping];function ft({onChange:e,value:r,className:n,editorRef:s,extensions:i,debounceTimeout:a=0}){const o=u(null),l=u(void 0);h((()=>{if(e)return l.current=a>0?D(e,a):e,()=>{l.current=void 0}}),[e,a]);const d=c((()=>t("div",{ref:o,className:n})),[n]);return b((()=>{if(o.current){let t=[...mt,(e=e=>{l.current?.(e)},F.updateListener.of((t=>{t.docChanged&&e(t)})))];Array.isArray(i)?t=t.concat(i):i&&t.push(i);const n=((e="",t=[])=>{const r="string"==typeof e?R.of(e.split("\n")):e;return ut?ut.doc.toString()!==r.toString()&&(ut=V.create({doc:r,extensions:t})):ut=V.create({doc:r,extensions:t}),ut})(r,t),a=new F({state:n,parent:o.current}),c=new pt(a);return s&&(s.current=c),()=>{a.destroy(),s&&(s.current=void 0)}}var e}),[d,i]),d}const gt=[_,L()];function yt({schema:r,isOpen:n,onClose:s,readonly:i=!1}){const a=u(void 0),o=x(),l=c((()=>function(e){return e?JSON.stringify(e,null,2):""}(r.schema)),[r]);return e(w,{onClose:s,isOpen:!!n,className:"min-w-[60vw]",children:[t(N,{children:"JSON Schema Editor"}),t(k,{children:i?t(Ue,{data:r.schema||{}}):t(ft,{value:l,extensions:gt,editorRef:a})}),t(C,{children:i?null:t(j,{onClick:()=>{if(a.current){const e=a.current.getValue();try{const t=function(e){if(e&&(e=e.trim()))return JSON.parse(e)}(e);r.replaceSchema(t),s()}catch(e){o({status:"error",title:"Invalid JSON Schema",description:e.message,duration:5e3})}}},children:"Save changes"})})]})}var vt;function bt(e,t){let 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 xt(e){let t,r=!1,n=!1;const s=e.type;if(Array.isArray(s))for(const e of s)"null"===e?r=!0:t||(t=e);else t=s;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?wt(e[0].type):wt(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor||e.format){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 wt(e){return e?Array.isArray(e)?e.find((e=>"null"!==e))||"any":e:"any"}!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"}(vt||(vt={}));let Nt=0;class kt{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 Ct("",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 Ct("",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 kt(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Ct{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=xt(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return this.schema.title}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=[],this.schema.items&&this.schema.items.properties?this._loadChildren(this.schema.items.properties):this.schema.properties&&this._loadChildren(this.schema.properties)}_loadChildren(e){for(const t of Object.keys(e)){const r=e[t],n=new Ct(t,r,this.loader,this);this.children.push(n),n.isParent&&n.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+ ++Nt}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 s={};return bt(s,r),e.properties[t]=s,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),s}(this._getPropertiesSchema(),e,t,r),s=new Ct(e,n,this.loader,this);return this.children.push(s),s}remove(){if(this.parent&&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,s={};for(const e of Object.keys(n)){const i=n[e];e===t?s[r]=i:s[e]=i}e.properties=s}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&&(bt(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,this.schema.format=void 0,t=!0):e.editor?(this.schema.editor=e.editor,this.schema.format=e.editor,t=!0):n&&(this.schema.editor=void 0,this.schema.format=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 s=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=vt[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===vt.object}}(t);let i;return"text"===s.name?(s.name=vt.string,i="textarea"):"media"===s.name?(s.name=vt.any,i="media"):"document"===s.name?(s.name=vt.any,i="document"):i=null,{name:r,type:s,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 jt(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const St=function(){const e=Object.values(vt),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function Ot({value:r,onChange:n,onCancel:s,onSave:i}){const[a,o]=d(!1);if(!r)return null;return e("div",{className:"flex items-center",children:[t("div",{className:"flex-1",children:t(At,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:s,onSave:i})}),t("div",{className:"px-1 font-semibold",children:":"}),t("div",{className:"flex-1",children:t(Pt,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:s,onSave:i})}),e("div",{children:[t(j,{variant:"ghost",size:"xs",onClick:()=>o(!0),title:"Edit description",children:t(z,{className:"size-4"})}),t($t,{value:r.description,isOpen:a,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),o(!1)}})]})]})}function At({value:e,onChange:r,onCancel:n,onSave:s}){const i=u(null);h((()=>{i.current?.focus()}),[]);return t("input",{onKeyUp:e=>{switch(e.key){case"Enter":s?.();break;case"Escape":n?.()}},ref:i,value:e,onChange:e=>{r(e.target.value)},className:S.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function Pt({value:e,onChange:r,onCancel:n,onSave:s}){return t(O,{className:S.INPUT_UNSTYLED,options:St,value:e||"",onBlur:()=>{s?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?s?.():"Escape"===e.key&&n?.())},popupClass:"schema-type-suggest-popup z-90"})}function $t({value:r,isOpen:n,onClose:s}){return e(w,{isOpen:n,onClose:s,children:[t(N,{children:"Edit description"}),t(Et,{value:r,onSave:s})]})}function Et({value:n,onSave:s}){const i=u(null),[a,o]=d(n||"");return h((()=>{i.current&&i.current.focus()}),[i.current]),e(r,{children:[t(A,{className:"h-max",children:t("textarea",{ref:i,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:a,onChange:e=>o(e.target.value)})}),t(P,{children:t(j,{onClick:()=>s(a),children:"Save Changes"})})]})}function It({value:r}){return r?e("div",{className:"w-full flex items-baseline",children:[t("div",{children:r.name||""}),t("div",{className:"ml-2 text-sm text-muted",children:r.type||""})]}):null}function Tt(e){const[t,r]=d(new kt(e||{type:"object",properties:{}}).withChangeListener((e=>{r(e.clone())})));return t}const qt="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Mt=`${qt} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,Lt=`${qt} shadow-xs ring-1 ring-inset ring-ring`;function Dt({value:r,onChange:n,onDelete:s,outlineOnHover:i=!1,editOnClick:a=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:h,isEditing:u=!1,readonly:p=!1,onValidate:m}){const{on:f,off:g,isOn:y}=$(u),[v,b]=d();return e("div",{className:"",children:[y&&!p?t(Rt,{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=>!!h&&h(e)}):t(Ft,{value:r,onEdit:f,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:a,onDelete:s,readonly:p}),v&&t("div",{className:"text-red-500 text-sm",children:v})]})}function Ft({viewer:r,value:n,onEdit:s,editOnClick:i,outlineOnHover:a,placeholder:o,onDelete:l,readonly:c}){const d="invisible group-hover:visible";return e("div",{tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&s()},onClick:()=>{i&&s()},className:q("flex justify-start items-center group",a?Mt:qt,{"cursor-pointer":i}),children:[t(r,{value:n,placeholder:o}),e("div",{className:"ml-auto flex space-x-2",children:[!c&&l&&t(j,{variant:"ghost",size:"sm",className:d,onClick:l,children:t(U,{className:"size-4"})}),c?null:t(j,{variant:"ghost",size:"sm",className:d,onClick:s,children:t(K,{className:"size-4"})})]})]})}function Rt({editor:e,value:r,onSave:n,onCancel:s,skipClickOutside:i}){const[a,o]=d(r),l=u(r),[c,h]=d(null),p=()=>{n(l.current)},m=E(p,i);return t("div",{ref:m,children:t("div",{className:Lt,children:t("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:t(e,{value:a,onChange:(e,t=!1)=>{o(e),l.current=e,t&&(c&&clearTimeout(c),h(setTimeout((()=>{n(e)}),500)))},onSave:p,onCancel:s})})})})}function Vt(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function _t({schema:r,readonly:n=!1}){return e("ul",{className:"",children:[r.children.map((e=>zt(e,n))),n?null:t(Ht,{parent:r.root})]})}function zt(e,r){return e.isParent?t(Kt,{property:e,readonly:r},e.name):t(Ut,{node:e,readonly:r},e.name)}function Ut({node:e,readonly:r}){return t("li",{children:t(Wt,{property:e,readonly:r})})}function Kt({property:r,readonly:n}){const[s,i]=d(!0);return e("li",{children:[e("div",{className:"flex items-center w-full",children:[t("button",{onClick:()=>i(!s),children:t(s?W:H,{className:"size-4"})}),t("div",{className:"flex-1",children:t(Wt,{property:r,readonly:n})})]}),s&&e("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map((e=>zt(e,n))),n?null:t(Ht,{parent:r})]})]})}function Bt(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 Wt({property:e,readonly:r}){const n=x(),s=e.resetIsNew(),i=jt(e);return t(Dt,{value:i,onChange:t=>{try{t.description&&"string"!=typeof t.description&&(t.description=void 0);const r=e.getUpdateFromNameAndTypeSignature(t.name,t.type);e.update({...r,description:t.description})&&e.reloadTree()}catch(e){return n({status:"error",title:"Invalid property declaration",description:e.message,duration:9e3}),!1}return!0},onDelete:()=>{e.remove(),e.reloadTree()},editor:Ot,viewer:It,outlineOnHover:!0,isEditing:s,skipClickOutside:Vt,readonly:r,onValidate:e=>Bt(e.name)})}function Ht({parent:r}){return e(j,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:vt.string},!0).isNew=!0,r.reloadTree()},children:[t(B,{className:"size-4"}),"Add property"]})}const Jt=o(void 0),Gt=Jt.Provider;function Xt(){const e=l(Jt);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}const Zt=o(void 0);function Yt(){const e=l(Zt);if(!e)throw new Error("useForm must be used within a Form element");return e}const Qt=Zt.Provider;function er({htmlFor:r,required:n,children:s}){return e("label",{htmlFor:r,className:"block text-sm font-medium leading-6 text-gray-900 dark:text-gray-200",children:[s,n&&t("sup",{className:"text-red-600",children:"*"})]})}function tr({children:e}){return t("p",{className:"mt-2 text-sm text-gray-500",children:e})}function rr({children:e}){return t("p",{className:"mt-2 text-sm text-red-600",children:e})}const nr=a.forwardRef((({object:e,type:r="text",onChange:n,...s},i)=>{const[a,o]=d(null!=e.value?String(e.value):""),[l,c]=d(e.schema.isBoolean&&!0===e.value);s.className?s.className=q(S.INPUT,s.className):s.className=S.INPUT;const h=t=>{o(t.target.value),e.schema.isBoolean?(e.value=t.target.checked,c(e.value)):e.value=t.target.value,n&&n(t)};return"textarea"===r?t("textarea",{ref:i,...s,value:a,onChange:h}):t("input","checkbox"===r?{ref:i,...s,type:"checkbox",checked:l,onChange:h,className:"form-check-input"}:{ref:i,...s,type:r,value:a,onChange:h})}));function sr({object:e,components:r,onSubmit:n,children:s,onChange:i}){return e.observer=i,t(Qt,{value:{object:e,components:r||{}},children:t("form",{className:"w-full",onSubmit:t=>{t.stopPropagation(),t.preventDefault(),n&&n(e.value)},children:s})})}function ir(){const e=Yt();return t("div",{className:"flex flex-col gap-4 w-full",children:e.object.properties.map(or)})}function ar({children:r,...n}){return e(sr,{...n,children:[t(ir,{}),r]})}function or(e){return e.isList?t(dr,{object:e},e.name):e.isObject?t(cr,{object:e},e.name):t(lr,{object:e},e.name)}function lr({object:r,editor:n,inline:s=!1}){n||(n=r.schema.editor);const{components:i}=Yt(),a=n&&i[n]||nr,o=r.getInputType();"checkbox"===o&&(s=!0);return e("div",{className:"",children:[e("div",{className:q("flex gap-2",s?"flex-row items-center":"flex-col"),children:[!r.isListItem&&t(er,{required:r.schema.isRequired,children:r.title}),t(a,{object:r,type:o,onChange:e=>{const{value:t}=e.target;r.value=r.schema.isNumber?parseFloat(t):t}})]}),r.schema.description&&t(tr,{children:r.schema.description})]})}function cr({object:r}){return e("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",children:[!r.isListItem&&t("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(or)]})}function dr({object:r}){const[n,s]=d(r.value||[]);return e("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 darK:border-l-slate-600",children:[!r.isListItem&&t("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map(((e,i)=>t(hr,{object:e,list:r,onDelete:()=>(e=>{r.remove(e),s([...r.value])})(i)},`${i}-${n[i]??""}`))),t("div",{children:e(j,{variant:"secondary",onClick:()=>{r.add(),s([...r.value])},children:[t(B,{className:"size-6"})," Add"]})})]})}function hr({list:r,object:n,onDelete:s}){return e("div",{className:"flex gap-2 w-full",children:[t("div",{className:"flex-1",children:(i=n,a=r.schema.arraySchema.editor,i.isList?t(dr,{object:i}):i.isObject?t(cr,{object:i}):t(lr,{object:i,editor:a}))}),t(j,{variant:"secondary",onClick:s,children:t(U,{className:"size-4"})})]});var i,a}function ur({className:r,properties:n}){return t(I,{className:r,children:t("tbody",{children:n.map((r=>e("tr",{children:[e("td",{className:"w-1/3 font-semibold gap-2",children:[t("span",{children:r.name}),r.description&&t(T,{description:r.description,placement:"top",children:t(J,{className:"size-3 ml-2 text-muted-foreground"})})]}),t("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name)))})})}const pr=o(void 0);function mr(){return l(pr)}const fr=Symbol("__SLOT_NAME");function gr(e,t){const r=[];return p.forEach(e,(e=>{!function(e,t,r){let n;m(e)&&(n=e.type[fr])?r[n]=e:t.push(e)}(e,r,t)})),r.length>1?r:r[0]}function yr(e,t){t[fr]=e}function vr(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function br(e){const r={};if(gr(e.children,r),!r.content)throw new Error("Popover must provide a content slot");const n=r.trigger?.props,s=r.content.props;return t(xr,{...e,trigger:n,content:s})}function xr({middleware:r,offset:n,trigger:s,dismiss:i=!0,content:a,placement:o,strategy:l,zIndex:c=40}){const[h,u]=d(!1),p=re({open:h,placement:o,strategy:l,onOpenChange:u,middleware:r||[Q(n||4),ee(),te()],whileElementsMounted:ne}),{floatingStyles:m,refs:{setReference:f,setFloating:g},context:y}=p,v=se(y,vr(i)),b=ie(y,vr(!(x=s)||x.hover||x.click?x?.click:{enabled:!0}));var x;const w=ae(y,vr(function(e){return!0===e?.hover?{enabled:!0,handleClose:he({blockPointerEvents:!0}),restMs:0}:e?.hover}(s))),{getReferenceProps:N,getFloatingProps:k}=oe([v,b,w]),{isMounted:C,styles:j}=le(y,a.transition);return e(pr.Provider,{value:{...p,close:()=>u(!1)},children:[s&&t("div",{className:q(s.className,"inline-block"),ref:f,...N(),children:s.children}),t(ce,{children:C&&t("div",{ref:g,style:{...m,zIndex:c},...k(),children:t(de,{context:y,children:t("div",{className:q(a.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:j,children:a.children})})})})]})}function wr(e){return null}function Nr(e){return null}function kr({onDrop:r,message:n,buttonLabel:s="Upload Files",allowFolders:i=!0,className:a=""}){const[o,l]=d(!1),c=u(null),h=u(null);return e("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${o?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${a}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&l(!0)},onDragLeave:e=>{e.preventDefault(),h.current&&!h.current.contains(e.relatedTarget)&&l(!1)},onDrop:async e=>{if(e.preventDefault(),l(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],s=new Set,i=async e=>{if(e.isFile){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&&s.add(r)}else if(e.isDirectory){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&&s.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(s).map((e=>e.split("/")[0])).filter(Boolean)).size,t=n.length;let i="";i=e>0?1===e?`Preparing to upload 1 folder with ${t} files...`:`Preparing to upload ${e} folders with ${t} files...`:`Preparing to upload ${t} file${1===t?"":"s"}...`,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:[t(G,{className:"h-12 w-12 mb-3 transition-colors "+(o?"text-primary":"text-muted/50")}),t("p",{className:"text-color-muted-foreground",children:n}),e("div",{className:"mt-4 text-center",children:[e("div",{className:"text-sm text-muted mb-2",children:["Drag and drop files",i?" or folders":""," here, or"]}),e(j,{onClick:()=>{c.current&&c.current.click()},children:[t(G,{className:"h-4 w-4 mr-2"}),s]}),t("input",{type:"file",ref:c,onChange:e=>{if(e.target.files&&e.target.files.length>0){const t=Array.from(e.target.files);if(t.some((e=>e.webkitRelativePath&&e.webkitRelativePath.includes("/")))){const e=new Set(t.map((e=>e.webkitRelativePath?.split("/")[0])).filter(Boolean)).size,n=t.length,s=1===e?`Preparing to upload 1 folder with ${n} files...`:`Preparing to upload ${e} folders with ${n} files...`,i={count:t.length,message:s};r(t,i)}else{const e={count:t.length,message:`Preparing to upload ${t.length} file${1===t.length?"":"s"}...`};r(t,e)}}},multiple:!0,webkitdirectory:i?"":void 0,directory:i?"":void 0,className:"hidden"})]})]})}function Cr({title:r,count:n,icon:s=t(X,{className:"h-4 w-4 text-green-500"}),items:i}){const[a,o]=d(!1);return e("div",{className:"border border-color-border rounded-md overflow-hidden",children:[e("div",{className:"flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer",onClick:()=>o(!a),children:[e("div",{className:"flex items-center",children:[t("span",{className:"mr-2",children:s}),t("span",{className:"font-medium",children:r}),t("span",{className:"ml-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),t("button",{className:"text-muted",children:t("svg",{className:"h-5 w-5 transition-transform "+(a?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),a&&t("div",{className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?t("ul",{className:"space-y-1",children:i.map(((e,r)=>t("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:e},r)))}):t("div",{className:"text-sm text-muted py-2",children:"No items to display"})})]})}function jr({files:r,className:n="",location:s,collection:i}){const a=r.filter((e=>"success"===e.status)),o=r.filter((e=>"updated"===e.status)),l=r.filter((e=>"skipped"===e.status)),c=r.filter((e=>"failed"===e.status)),d=a.length,h=o.length,u=l.length,p=c.length,m=r.length;return e("div",{className:`flex flex-col py-6 ${n}`,children:[e("div",{className:"flex items-center mb-4",children:[t("div",{className:"w-12 h-12 mr-4 rounded-full bg-color-success/10 flex items-center justify-center",children:t(X,{className:"h-6 w-6 text-color-success"})}),e("div",{children:[t("p",{className:"text-lg font-medium text-color-success",children:"Upload Complete"}),e("p",{className:"text-muted",children:[m," file",1!==m?"s":""," processed",i?` in collection '${i}'`:"",s?` in folder '${s}'`:""]})]})]}),e("div",{className:"space-y-3 mt-2",children:[d>0&&t(Cr,{title:"Successfully Uploaded",count:d,icon:t(X,{className:"h-4 w-4 text-green-500"}),items:a.map((e=>e.name))}),h>0&&t(Cr,{title:"Successfully Updated",count:h,icon:t(X,{className:"h-4 w-4 text-blue-500"}),items:o.map((e=>e.name))}),u>0&&t(Cr,{title:"Skipped (Already Existed)",count:u,icon:t(Z,{className:"h-4 w-4 text-amber-500"}),items:l.map((e=>e.name))}),p>0&&t(Cr,{title:"Failed to Upload",count:p,icon:t(Y,{className:"h-4 w-4 text-red-500"}),items:c.map((e=>e.name))})]})]})}function Sr({percent:e}){return t("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:t("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${e}%`}})})}yr("trigger",wr),yr("content",Nr),br.Trigger=wr,br.Content=Nr;export{We as ArrayPropertySchema,ft as CodeMirrorEditor,kr as DropZone,pt as EditorApi,Gt as FieldSetContextProvider,sr as Form,Qt as FormContextProvider,rr as FormError,tr as FormHelper,er as FormLabel,ar as GeneratedForm,nr as Input,Ue as JSONCode,ht as JSONDisplay,yt as JSONSchemaEditorModal,nt as JSONView,tt as ManageObjectEntry,et as ManagedListProperty,Ze as ManagedObject,Xe as ManagedObjectBase,Ye as ManagedObjectProperty,Qe as ManagedProperty,rt as ManagedScalarEntry,kt as ManagedSchema,Ge as Node,br as Popover,pr as PopoverContext,Sr as Progress,ur as PropertiesView,Ot as PropertyEditor,At as PropertyNameEditor,Be as PropertySchema,It as PropertyViewer,lr as ScalarField,Ke as Schema,_t as SchemaEditor,Ct as SchemaNode,Cr as UploadResultCategory,jr as UploadSummary,qe as XMLViewer,He as computeTitleFromName,jt as getEditableSchemaProperty,Xt as useFieldSet,Yt as useForm,mr as usePopoverContext,Tt as useSchema,Bt as validatePropertyName};
1
+ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"debounce";import s,{useRef as i,useEffect as a,useMemo as o,createContext as l,useContext as c,useState as d,Children as h,isValidElement as u}from"react";import{EditorView as p}from"@codemirror/view";import{useSafeLayoutEffect as m,Styles as f,Button as g,DotBadge as y,Table as v,VTooltip as b,useToast as x,VModal as w,VModalTitle as N,VModalBody as k,VModalFooter as C,VSelectBox as j,ModalBody as S,ModalFooter as O,useFlag as A,useClickOutside as P}from"@vertesia/ui/core";import{Text as $,EditorState as E}from"@codemirror/state";import{Plus as T,Trash2 as I,Info as q,AlignLeft as M,SquarePen as L,ChevronDown as D,ChevronRight as F,UploadIcon as z,CheckCircleIcon as R,AlertCircleIcon as V,XCircleIcon as _}from"lucide-react";import U from"clsx";import K from"ajv";import{ObjectWalker as B}from"@vertesia/json";import{offset as W,shift as H,flip as J}from"@floating-ui/dom";import{useFloating as G,autoUpdate as X,useDismiss as Z,useClick as Y,useHover as Q,useInteractions as ee,useTransitionStyles as te,FloatingPortal as re,FloatingFocusManager as ne,safePolygon as se}from"@floating-ui/react";import{json as ie}from"@codemirror/lang-json";import{basicSetup as ae}from"codemirror";import{isNil as oe,omit as le,isEqual as ce}from"lodash-es";import{XMLParser as de,XMLValidator as he}from"fast-xml-parser";let ue=null;class pe{editor;constructor(e){this.editor=e}setValue(e){this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:e||""}})}getValue(){return this.editor.state.doc.toString()}}const me=[p.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{fontFamily:"inherit"},".cm-scroller":{fontFamily:"inherit"},".cm-gutters":{backgroundColor:"transparent",color:"#ddd"},".cm-focused":{outline:"none"},".cm-cursor":{borderLeft:"2px solid #808080",borderLeftColor:"#808080",animation:"blink 1.2s step-start infinite"},"@keyframes blink":{"50%":{opacity:0}}}),p.lineWrapping];function fe({onChange:t,value:r,className:s,editorRef:l,extensions:c,debounceTimeout:d=0}){const h=i(null),u=i(void 0);a((()=>{if(t)return u.current=d>0?n(t,d):t,()=>{u.current=void 0}}),[t,d]);const f=o((()=>e("div",{ref:h,className:s})),[s]);return m((()=>{if(h.current){let t=[...me,(e=e=>{u.current?.(e)},p.updateListener.of((t=>{t.docChanged&&e(t)})))];Array.isArray(c)?t=t.concat(c):c&&t.push(c);const n=((e="",t=[])=>{const r="string"==typeof e?$.of(e.split("\n")):e;return ue?ue.doc.toString()!==r.toString()&&(ue=E.create({doc:r,extensions:t})):ue=E.create({doc:r,extensions:t}),ue})(r,t),s=new p({state:n,parent:h.current}),i=new pe(s);return l&&(l.current=i),()=>{s.destroy(),l&&(l.current=void 0)}}var e}),[f,c]),f}const ge=l(void 0),ye=ge.Provider;function ve(){const e=c(ge);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}const be=l(void 0);function xe(){const e=c(be);if(!e)throw new Error("useForm must be used within a Form element");return e}const we=be.Provider;function Ne({htmlFor:r,required:n,children:s}){return t("label",{htmlFor:r,className:"block text-sm font-medium leading-6 text-gray-900 dark:text-gray-200",children:[s,n&&e("sup",{className:"text-red-600",children:"*"})]})}function ke({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Ce({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}const je=s.forwardRef((({object:t,type:r="text",onChange:n,...s},i)=>{const[a,o]=d(null!=t.value?String(t.value):""),[l,c]=d(t.schema.isBoolean&&!0===t.value);s.className?s.className=U(f.INPUT,s.className):s.className=f.INPUT;const h=e=>{o(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,c(t.value)):t.value=e.target.value,n&&n(e)};return"textarea"===r?e("textarea",{ref:i,...s,value:a,onChange:h}):e("input","checkbox"===r?{ref:i,...s,type:"checkbox",checked:l,onChange:h,className:"form-check-input"}:{ref:i,...s,type:r,value:a,onChange:h})}));function Se({object:t,components:r,onSubmit:n,children:s,onChange:i}){return t.observer=i,e(we,{value:{object:t,components:r||{}},children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n&&n(t.value)},children:s})})}function Oe(){const t=xe();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(Pe)})}function Ae({children:r,...n}){return t(Se,{...n,children:[e(Oe,{}),r]})}function Pe(t){return t.isList?e(Te,{object:t},t.name):t.isObject?e(Ee,{object:t},t.name):e($e,{object:t},t.name)}function $e({object:r,editor:n,inline:s=!1}){n||(n=r.schema.editor);const{components:i}=xe(),a=n&&i[n]||je,o=r.getInputType();"checkbox"===o&&(s=!0);return t("div",{className:"",children:[t("div",{className:U("flex gap-2",s?"flex-row items-center":"flex-col"),children:[!r.isListItem&&e(Ne,{required:r.schema.isRequired,children:r.title}),e(a,{object:r,type:o,onChange:e=>{const{value:t}=e.target;r.value=r.schema.isNumber?parseFloat(t):t}})]}),r.schema.description&&e(ke,{children:r.schema.description})]})}function Ee({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(Pe)]})}function Te({object:r}){const[n,s]=d(r.value||[]);return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 darK:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map(((t,i)=>e(Ie,{object:t,list:r,onDelete:()=>(e=>{r.remove(e),s([...r.value])})(i)},`${i}-${n[i]??""}`))),e("div",{children:t(g,{variant:"secondary",onClick:()=>{r.add(),s([...r.value])},children:[e(T,{className:"size-6"})," Add"]})})]})}function Ie({list:r,object:n,onDelete:s}){return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:(i=n,a=r.schema.arraySchema.editor,i.isList?e(Te,{object:i}):i.isObject?e(Ee,{object:i}):e($e,{object:i,editor:a}))}),e(g,{variant:"secondary",onClick:s,children:e(I,{className:"size-4"})})]});var i,a}class qe{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new K({allErrors:!0,strict:!1});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(){return this.schema.title||this.schema.name}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new Le(this,e,t):new Me(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"===(s=t)?{type:"object",properties:{}}:"array"===s?{type:"array",items:{}}:{type:s}:t;var s;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 this.schema.editor}}class Me 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 Le extends Me{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 De(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function Fe(e,t){if(t.editor)return t.editor;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class ze{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||De(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class Re extends ze{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new Ke(this,t,this.getOrInitArrayProperty(e)):t.isObject?new _e(this,t,t.name,this.getOrInitObjectProperty(e)):new Ue(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 Ke(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new _e(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Ue(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Ve extends Re{value;constructor(e,t={}){super(null,e instanceof qe?e:new qe(e),"#root"),this.value=t}}class _e extends Re{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class Ue extends ze{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 Fe(this.name,this.schema)}}class Ke extends ze{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 Be(this,e):new We(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 _e(this,this.schema,String(e),t):new We(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class Be extends Re{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 We extends ze{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 Fe(this.name,this.schema)}}const He="text-pink-500 dark:text-pink-400",Je="text-purple-500 dark:text-purple-400",Ge="text-blue-500 dark:text-blue-400",Xe={code:"bg-gray-100 dark:bg-slate-800 whitespace-pre-wrap p-4 rounded-lg font-mono",comma:He,assign:He,startObject:He,endObject:He,startArray:He,endArray:He,boolean:Je,null:Je,key:Ge,index:Ge,string:"text-orange-500 dark:text-orange-400",number:"text-green-500 dark:text-green-400"};class Ze{renderer;parent;key;indent;result=[];constructor(e,t,r,n){this.renderer=e,this.parent=t,this.key=r,this.indent=n}get classMap(){return this.renderer.classMap}writeKey(e){const t=typeof e;"string"===t?(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent),this.result.push(`<span class="${this.classMap.key}">"${e}"</span><span class='${this.classMap.assign}'>: </span>`)):"number"===t&&(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent))}pushValue(e,t){if(this.writeKey(e),null===t)this.result.push(`<span class='${this.classMap.null}'>null</span>`);else if(t instanceof Ze)this.result.push(t.renderStart()+t.renderValue()+t.renderEnd());else{let e;const r=typeof t;"string"===r?(t=(t=`"${t}"`).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e=this.classMap.string):"number"===r?e=this.classMap.number:"boolean"===r&&(e=this.classMap.boolean),this.result.push(`<span class='${e}'>${t}</span>`)}}renderValue(){return this.result.join("")}}class Ye extends Ze{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startObject}'>{\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endObject}'>${e}${this.parent?.indent||""}}</span>`}}class Qe extends Ze{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startArray}'>[\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endArray}'>${e}${this.parent?.indent||""}]</span>`}}class et{classMap;tab;stack=[];block=new Ye(this,void 0,"","");constructor(e=Xe,t=" "){this.classMap=e,this.tab=t}onStartObject(e){const t=new Ye(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndObject(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onStartIteration(e){const t=new Qe(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndIteration(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onValue(e,t){this.block.pushValue(e,t)}}function tt({data:t,className:r,classMap:n}){const[s,i]=d();return a((()=>{i(function(t,r,n){const s=new et(r);(new B).walk(t,s);const i=s.block.renderValue();return e("div",{className:n,dangerouslySetInnerHTML:{__html:`<div class='${s.classMap.code}' style='overflow-x: scroll'>${i}</div>`}})}(t,n,r))}),[t]),s}function rt({value:t}){return e("div",{className:"flex flex-col gap-4",children:Object.entries(t).map((([t,r])=>e(it,{name:t,value:r},t)))})}function nt({name:t}){return e("div",{className:"text-md font-semibold",children:De(t)})}function st({children:t,className:r}){return e("div",{className:U("flex flex-col gap-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",r),children:t})}function it({name:r,value:n}){const s=ct(n);switch(s.type){case lt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(nt,{name:r+":"}),e("p",{children:s.value})]});case lt.Paragraph:return t("div",{children:[e(nt,{name:r}),e("p",{children:s.value})]});case lt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(nt,{name:r}),e("div",{className:"vprose dark:prose-invert",children:s.value})]});case lt.Array:return e(at,{name:r,value:n});case lt.Object:return t("div",{children:[e(nt,{name:r}),e(st,{className:"mt-2",children:Object.entries(n).map((([t,r])=>e(it,{name:t,value:r},t)))})]})}}function at({name:r,value:n}){const s=n.join(" ").length,i=s/n.length,a="string"==typeof n[0]&&(s<80||s<400&&i<32),o=n.length>9;return t("div",a?{className:"flex gap-2 flex-wrap",children:[r&&e(nt,{name:r+":"}),n.map(((t,r)=>e(y,{children:String(t)},r)))]}:{children:[r&&e(nt,{name:r}),e("div",{className:"flex flex-col gap-2",children:n.map(((t,r)=>e(ot,{index:r,value:t,useBullet:o},r)))})]})}function ot({index:r,value:n,useBullet:s}){const i=s?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),a=ct(n);let o;switch(a.type){case lt.Object:o=e(st,{children:Object.entries(n).map((([t,r])=>e(it,{name:t,value:r},t)))});break;case lt.Array:o=e(at,{value:n});break;case lt.Prose:o=e("div",{className:"prose dark:prose-invert",children:a.value});break;default:o=e("div",{children:a.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pr-2 pl-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var lt;function ct(e){if(null==e)return{value:"-",type:lt.Inline};if(Array.isArray(e))return{value:e,type:lt.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=lt.Inline:t>400?r=lt.Prose:(r=lt.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:lt.Inline}:{value:e,type:lt.Object}}function dt({value:t,viewCode:r=!1}){return t?e("div",{className:"relative w-full",children:r?e(tt,{data:t}):e(rt,{value:t})}):e("pre",{className:"whitespace-pre-wrap",children:"No Data to display"})}!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"}(lt||(lt={}));const ht=l(void 0);function ut(){return c(ht)}const pt=Symbol("__SLOT_NAME");function mt(e,t){const r=[];return h.forEach(e,(e=>{!function(e,t,r){let n;u(e)&&(n=e.type[pt])?r[n]=e:t.push(e)}(e,r,t)})),r.length>1?r:r[0]}function ft(e,t){t[pt]=e}function gt(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function yt(t){const r={};if(mt(t.children,r),!r.content)throw new Error("Popover must provide a content slot");const n=r.trigger?.props,s=r.content.props;return e(vt,{...t,trigger:n,content:s})}function vt({middleware:r,offset:n,trigger:s,dismiss:i=!0,content:a,placement:o,strategy:l,zIndex:c=40}){const[h,u]=d(!1),p=G({open:h,placement:o,strategy:l,onOpenChange:u,middleware:r||[W(n||4),H(),J()],whileElementsMounted:X}),{floatingStyles:m,refs:{setReference:f,setFloating:g},context:y}=p,v=Z(y,gt(i)),b=Y(y,gt(!(x=s)||x.hover||x.click?x?.click:{enabled:!0}));var x;const w=Q(y,gt(function(e){return!0===e?.hover?{enabled:!0,handleClose:se({blockPointerEvents:!0}),restMs:0}:e?.hover}(s))),{getReferenceProps:N,getFloatingProps:k}=ee([v,b,w]),{isMounted:C,styles:j}=te(y,a.transition);return t(ht.Provider,{value:{...p,close:()=>u(!1)},children:[s&&e("div",{className:U(s.className,"inline-block"),ref:f,...N(),children:s.children}),e(re,{children:C&&e("div",{ref:g,style:{...m,zIndex:c},...k(),children:e(ne,{context:y,children:e("div",{className:U(a.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:j,children:a.children})})})})]})}function bt(e){return null}function xt(e){return null}function wt({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 Nt({className:r,properties:n}){return e(v,{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(b,{description:r.description,placement:"top",children:e(q,{className:"size-3 ml-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name)))})})}ft("trigger",bt),ft("content",xt),yt.Trigger=bt,yt.Content=xt;const kt=[ae,ie()];function Ct({schema:r,isOpen:n,onClose:s,readonly:a=!1}){const l=i(void 0),c=x(),d=o((()=>function(e){return e?JSON.stringify(e,null,2):""}(r.schema)),[r]);return t(w,{onClose:s,isOpen:!!n,className:"min-w-[60vw]",children:[e(N,{children:"JSON Schema Editor"}),e(k,{children:a?e(tt,{data:r.schema||{}}):e(fe,{value:d,extensions:kt,editorRef:l})}),e(C,{children:a?null:e(g,{onClick:()=>{if(l.current){const e=l.current.getValue();try{const t=function(e){if(e&&(e=e.trim()))return JSON.parse(e)}(e);r.replaceSchema(t),s()}catch(e){c({status:"error",title:"Invalid JSON Schema",description:e.message,duration:5e3})}}},children:"Save changes"})})]})}var jt;function St(e,t){let 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 Ot(e){let t,r=!1,n=!1;const s=e.type;if(Array.isArray(s))for(const e of s)"null"===e?r=!0:t||(t=e);else t=s;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?At(e[0].type):At(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor||e.format){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 At(e){return e?Array.isArray(e)?e.find((e=>"null"!==e))||"any":e:"any"}!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"}(jt||(jt={}));let Pt=0;class $t{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 Et("",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 Et("",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 $t(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Et{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=Ot(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return this.schema.title}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=[],this.schema.items&&this.schema.items.properties?this._loadChildren(this.schema.items.properties):this.schema.properties&&this._loadChildren(this.schema.properties)}_loadChildren(e){for(const t of Object.keys(e)){const r=e[t],n=new Et(t,r,this.loader,this);this.children.push(n),n.isParent&&n.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+ ++Pt}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 s={};return St(s,r),e.properties[t]=s,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),s}(this._getPropertiesSchema(),e,t,r),s=new Et(e,n,this.loader,this);return this.children.push(s),s}remove(){if(this.parent&&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,s={};for(const e of Object.keys(n)){const i=n[e];e===t?s[r]=i:s[e]=i}e.properties=s}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&&(St(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,this.schema.format=void 0,t=!0):e.editor?(this.schema.editor=e.editor,this.schema.format=e.editor,t=!0):n&&(this.schema.editor=void 0,this.schema.format=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 s=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=jt[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===jt.object}}(t);let i;return"text"===s.name?(s.name=jt.string,i="textarea"):"media"===s.name?(s.name=jt.any,i="media"):"document"===s.name?(s.name=jt.any,i="document"):i=null,{name:r,type:s,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 Tt(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const It=function(){const e=Object.values(jt),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function qt({value:r,onChange:n,onCancel:s,onSave:i}){const[a,o]=d(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(Mt,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:s,onSave:i})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(Lt,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:s,onSave:i})}),t("div",{children:[e(g,{variant:"ghost",size:"xs",onClick:()=>o(!0),title:"Edit description",children:e(M,{className:"size-4"})}),e(Dt,{value:r.description,isOpen:a,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),o(!1)}})]})]})}function Mt({value:t,onChange:r,onCancel:n,onSave:s}){const o=i(null);a((()=>{o.current?.focus()}),[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":s?.();break;case"Escape":n?.()}},ref:o,value:t,onChange:e=>{r(e.target.value)},className:f.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function Lt({value:t,onChange:r,onCancel:n,onSave:s}){return e(j,{className:f.INPUT_UNSTYLED,options:It,value:t||"",onBlur:()=>{s?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?s?.():"Escape"===e.key&&n?.())},popupClass:"schema-type-suggest-popup z-90"})}function Dt({value:r,isOpen:n,onClose:s}){return t(w,{isOpen:n,onClose:s,children:[e(N,{children:"Edit description"}),e(Ft,{value:r,onSave:s})]})}function Ft({value:n,onSave:s}){const o=i(null),[l,c]=d(n||"");return a((()=>{o.current&&o.current.focus()}),[o.current]),t(r,{children:[e(S,{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(O,{children:e(g,{onClick:()=>s(l),children:"Save Changes"})})]})}function zt({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ml-2 text-sm text-muted",children:r.type||""})]}):null}function Rt(e){const[t,r]=d(new $t(e||{type:"object",properties:{}}).withChangeListener((e=>{r(e.clone())})));return t}const Vt="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",_t=`${Vt} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,Ut=`${Vt} shadow-xs ring-1 ring-inset ring-ring`;function Kt({value:r,onChange:n,onDelete:s,outlineOnHover:i=!1,editOnClick:a=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:h,isEditing:u=!1,readonly:p=!1,onValidate:m}){const{on:f,off:g,isOn:y}=A(u),[v,b]=d();return t("div",{className:"",children:[y&&!p?e(Wt,{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=>!!h&&h(e)}):e(Bt,{value:r,onEdit:f,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:a,onDelete:s,readonly:p}),v&&e("div",{className:"text-red-500 text-sm",children:v})]})}function Bt({viewer:r,value:n,onEdit:s,editOnClick:i,outlineOnHover:a,placeholder:o,onDelete:l,readonly:c}){const d="invisible group-hover:visible";return t("div",{tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&s()},onClick:()=>{i&&s()},className:U("flex justify-start items-center group",a?_t:Vt,{"cursor-pointer":i}),children:[e(r,{value:n,placeholder:o}),t("div",{className:"ml-auto flex space-x-2",children:[!c&&l&&e(g,{variant:"ghost",size:"sm",className:d,onClick:l,children:e(I,{className:"size-4"})}),c?null:e(g,{variant:"ghost",size:"sm",className:d,onClick:s,children:e(L,{className:"size-4"})})]})]})}function Wt({editor:t,value:r,onSave:n,onCancel:s,skipClickOutside:a}){const[o,l]=d(r),c=i(r),[h,u]=d(null),p=()=>{n(c.current)},m=P(p,a);return e("div",{ref:m,children:e("div",{className:Ut,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:o,onChange:(e,t=!1)=>{l(e),c.current=e,t&&(h&&clearTimeout(h),u(setTimeout((()=>{n(e)}),500)))},onSave:p,onCancel:s})})})})}function Ht(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function Jt({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map((e=>Gt(e,n))),n?null:e(er,{parent:r.root})]})}function Gt(t,r){return t.isParent?e(Zt,{property:t,readonly:r},t.name):e(Xt,{node:t,readonly:r},t.name)}function Xt({node:t,readonly:r}){return e("li",{children:e(Qt,{property:t,readonly:r})})}function Zt({property:r,readonly:n}){const[s,i]=d(!0);return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e("button",{onClick:()=>i(!s),children:e(s?D:F,{className:"size-4"})}),e("div",{className:"flex-1",children:e(Qt,{property:r,readonly:n})})]}),s&&t("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map((e=>Gt(e,n))),n?null:e(er,{parent:r})]})]})}function Yt(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 Qt({property:t,readonly:r}){const n=x(),s=t.resetIsNew(),i=Tt(t);return e(Kt,{value:i,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 n({status:"error",title:"Invalid property declaration",description:e.message,duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:qt,viewer:zt,outlineOnHover:!0,isEditing:s,skipClickOutside:Ht,readonly:r,onValidate:e=>Yt(e.name)})}function er({parent:r}){return t(g,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:jt.string},!0).isNew=!0,r.reloadTree()},children:[e(T,{className:"size-4"}),"Add property"]})}function tr({content:t,...r}){const n=i(null);return a((()=>{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="");r&&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)}),[t,r]),e("span",{ref:n})}function rr(t){return r=>e(tr,{content:t,...r})}function nr({onDrop:r,message:n,buttonLabel:s="Upload Files",allowFolders:a=!0,className:o=""}){const[l,c]=d(!1),h=i(null),u=i(null);return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${l?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${o}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&c(!0)},onDragLeave:e=>{e.preventDefault(),u.current&&!u.current.contains(e.relatedTarget)&&c(!1)},onDrop:async e=>{if(e.preventDefault(),c(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],s=new Set,i=async e=>{if(e.isFile){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&&s.add(r)}else if(e.isDirectory){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&&s.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(s).map((e=>e.split("/")[0])).filter(Boolean)).size,t=n.length;let i="";i=e>0?1===e?`Preparing to upload 1 folder with ${t} files...`:`Preparing to upload ${e} folders with ${t} files...`:`Preparing to upload ${t} file${1===t?"":"s"}...`,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(z,{className:"h-12 w-12 mb-3 transition-colors "+(l?"text-primary":"text-muted/50")}),e("p",{className:"text-color-muted-foreground",children:n}),t("div",{className:"mt-4 text-center",children:[t("div",{className:"text-sm text-muted mb-2",children:["Drag and drop files",a?" or folders":""," here, or"]}),t(g,{onClick:()=>{h.current&&h.current.click()},children:[e(z,{className:"h-4 w-4 mr-2"}),s]}),e("input",{type:"file",ref:h,onChange:e=>{if(e.target.files&&e.target.files.length>0){const t=Array.from(e.target.files);if(t.some((e=>e.webkitRelativePath&&e.webkitRelativePath.includes("/")))){const e=new Set(t.map((e=>e.webkitRelativePath?.split("/")[0])).filter(Boolean)).size,n=t.length,s=1===e?`Preparing to upload 1 folder with ${n} files...`:`Preparing to upload ${e} folders with ${n} files...`,i={count:t.length,message:s};r(t,i)}else{const e={count:t.length,message:`Preparing to upload ${t.length} file${1===t.length?"":"s"}...`};r(t,e)}}},multiple:!0,webkitdirectory:a?"":void 0,directory:a?"":void 0,className:"hidden"})]})]})}function sr({title:r,count:n,icon:s=e(R,{className:"h-4 w-4 text-green-500"}),items:i}){const[a,o]=d(!1);return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("div",{className:"flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer",onClick:()=>o(!a),children:[t("div",{className:"flex items-center",children:[e("span",{className:"mr-2",children:s}),e("span",{className:"font-medium",children:r}),e("span",{className:"ml-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("button",{className:"text-muted",children:e("svg",{className:"h-5 w-5 transition-transform "+(a?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),a&&e("div",{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:"No items to display"})})]})}function ir({files:r,className:n="",location:s,collection:i}){const a=r.filter((e=>"success"===e.status)),o=r.filter((e=>"updated"===e.status)),l=r.filter((e=>"skipped"===e.status)),c=r.filter((e=>"failed"===e.status)),d=a.length,h=o.length,u=l.length,p=c.length,m=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 mr-4 rounded-full bg-success/10 flex items-center justify-center",children:e(R,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[m," file",1!==m?"s":""," processed",i?` in collection '${i}'`:"",s?` in folder '${s}'`:""]})})]}),t("div",{className:"space-y-3 mt-2",children:[d>0&&e(sr,{title:"Successfully Uploaded",count:d,icon:e(R,{className:"h-4 w-4 text-green-500"}),items:a.map((e=>e.name))}),h>0&&e(sr,{title:"Successfully Updated",count:h,icon:e(R,{className:"h-4 w-4 text-blue-500"}),items:o.map((e=>e.name))}),u>0&&e(sr,{title:"Skipped (Already Existed)",count:u,icon:e(V,{className:"h-4 w-4 text-amber-500"}),items:l.map((e=>e.name))}),p>0&&e(sr,{title:"Failed to Upload",count:p,icon:e(_,{className:"h-4 w-4 text-red-500"}),items:c.map((e=>e.name))})]})]})}const ar="#text",or="#comment",lr="#cdata",cr="DECLARATION_TAG",dr={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},hr=l({theme:dr,collapsible:!1,indentSize:2}),ur=()=>c(hr),pr=new de({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:or,cdataPropName:lr,parseTagValue:!1});function mr(r){const{indentation:n,children:s,isInline:i}=r,{theme:a}=ur();return t("div",{style:{color:a.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),s,e("span",{children:`${i?"":n}]]>`})]})}function fr(t){const{collapsible:r,theme:n}=ur(),{collapsed:s}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(gr,{fill:n.separatorColor,style:{transform:`rotate(${s?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function gr({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",...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 yr(e){const{collapsible:t,initialCollapsedDepth:r}=ur(),[n,s]=d((()=>!(oe(r)||!t)&&e>=r));return a((()=>{s(!(oe(r)||!t)&&e>=r)}),[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>s((e=>!e)),role:"button",style:{cursor:"pointer"}}:{}}}function vr(r){const{indentation:n,children:s,isInline:i,level:a}=r,{theme:o}=ur(),{collapsed:l,buttonProps:c}=yr(a);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(fr,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&s,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function br(r){const{attributes:n}=r,{theme:s}=ur();return n?e("span",{children:Object.entries(n).map((([r,n])=>t("span",{children:[e("span",{style:{color:s.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:s.separatorColor},children:"="}),e("span",{style:{color:s.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`)))}):null}function xr(r){const{indentation:n,tagKey:s,attributes:i}=r,{theme:a}=ur();return t("div",{children:[e("span",{style:{color:a.separatorColor},children:`${n}<?`}),e("span",{style:{color:a.tagColor},children:`${s.slice(1)}`}),e(br,{attributes:i}),e("span",{style:{color:a.separatorColor},children:"?>"})]})}function wr(e){return"string"==typeof e&&e.includes("\n")}function Nr(e){const t=e[":@"],r=le(e,":@"),[[n,s]]=Object.entries(r),i=function(e){switch(e){case ar:case lr:case or:return e;default:return e.startsWith("?")?cr:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:s,type:i}}function kr(e){return!!e&&Object.keys(e).length>0}function Cr(n){const{indentation:s,tagKey:i,attributes:a,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:h,buttonProps:u}=yr(d),{theme:p}=ur();return t("div",{children:[t("span",{...u,children:[e("span",{children:s}),e(fr,{collapsed:h}),e("span",{style:{color:p.separatorColor},children:"<"}),e("span",{style:{color:p.tagColor},children:`${i}`}),!h&&e(br,{attributes:a}),h&&kr(a)&&" ...",e("span",{style:{color:p.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!h&&o,h&&"...",e("span",{style:{color:p.separatorColor},children:`${l||h?"":s}</`}),e("span",{style:{color:p.tagColor},children:`${i}`}),e("span",{style:{color:p.separatorColor},children:">"})]})]})}function jr(t){const{hasSiblings:r,text:n,indentation:s,isText:i}=t,{theme:a}=ur(),o=i?{color:a.textColor}:void 0;return wr(n)||r?e("div",{style:o,children:n.split("\n").filter((e=>!!e.trim())).map(((t,r)=>e("div",{children:`${s}${t.trim()}`},`${r}`)))}):e("span",{style:o,children:n})}function Sr(t){const{elements:n,level:s=0,isText:i=!0}=t,{indentSize:a}=ur();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map(((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=Nr(t),h=n.length>1,u=function(e,t){return new Array(t*e+1).join(" ")}(a,s),p=`${s}-${r}`,m=function(e){return"string"!=typeof e&&1===e.length&&ar in e[0]&&!wr(e[0][ar])}(c);switch(d){case ar:return e(jr,{text:c,indentation:u,hasSiblings:h,isText:i},p);case or:return e(vr,{isInline:m,indentation:u,level:s,children:e(Sr,{elements:c,level:s+1,isText:!1})},p);case lr:return e(mr,{indentation:u,isInline:m,children:e(Sr,{elements:c,level:s+1,isText:!1})},p);case cr:return e(xr,{indentation:u,tagKey:o,attributes:l},p);default:return e(Cr,{indentation:u,tagKey:o,attributes:l,isInline:m,hasChildren:c.length>0,level:s,children:e(Sr,{elements:c,level:s+1})},p)}}))}):null}function Or(){return e("div",{children:"Invalid XML!"})}function Ar(t){const{theme:r,xml:n,collapsible:s=!1,indentSize:i=2,invalidXml:l,initalCollapsedDepth:c,initialCollapsedDepth:h}=t,[u,p]=d((()=>({...dr,...r}))),{json:m,valid:f}=function(e){return o((()=>{try{if(!he.validate(e))throw new Error("Invalid XML!");const t=pr.parse(e);if("string"==typeof e&&e.trim().length>0&&0===t.length)throw new Error("Invalid XML!");return{json:t,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}}),[e])}(n),g=o((()=>({theme:u,collapsible:s,indentSize:i,initialCollapsedDepth:h??c})),[u,s,i,c,h]);return a((()=>{p((e=>{const t={...dr,...r};return ce(t,e)?e:t}))}),[r]),f?e(hr.Provider,{value:g,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(Sr,{elements:m})})}):l||e(Or,{})}export{Le as ArrayPropertySchema,fe as CodeMirrorEditor,nr as DropZone,pe as EditorApi,ye as FieldSetContextProvider,Se as Form,we as FormContextProvider,Ce as FormError,ke as FormHelper,Ne as FormLabel,Ae as GeneratedForm,je as Input,tt as JSONCode,dt as JSONDisplay,Ct as JSONSchemaEditorModal,rt as JSONView,Be as ManageObjectEntry,Ke as ManagedListProperty,Ve as ManagedObject,Re as ManagedObjectBase,_e as ManagedObjectProperty,Ue as ManagedProperty,We as ManagedScalarEntry,$t as ManagedSchema,ze as Node,yt as Popover,ht as PopoverContext,wt as Progress,Nt as PropertiesView,qt as PropertyEditor,Mt as PropertyNameEditor,Me as PropertySchema,zt as PropertyViewer,$e as ScalarField,qe as Schema,Jt as SchemaEditor,Et as SchemaNode,tr as SvgIcon,sr as UploadResultCategory,ir as UploadSummary,Ar as XMLViewer,De as computeTitleFromName,rr as createSvgIcon,Tt as getEditableSchemaProperty,ve as useFieldSet,xe as useForm,ut as usePopoverContext,Rt as useSchema,Yt as validatePropertyName};
2
2
  //# sourceMappingURL=vertesia-ui-widgets.js.map