@vertesia/ui 0.65.0 → 0.67.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 (234) hide show
  1. package/lib/esm/core/components/EmptyCollection.js +2 -2
  2. package/lib/esm/core/components/EmptyCollection.js.map +1 -1
  3. package/lib/esm/core/components/InputList.js +2 -2
  4. package/lib/esm/core/components/InputList.js.map +1 -1
  5. package/lib/esm/core/components/SidePanel.js +1 -1
  6. package/lib/esm/core/components/SidePanel.js.map +1 -1
  7. package/lib/esm/core/components/Switch.js +2 -2
  8. package/lib/esm/core/components/Switch.js.map +1 -1
  9. package/lib/esm/core/components/shadcn/calendar.js +0 -1
  10. package/lib/esm/core/components/shadcn/calendar.js.map +1 -1
  11. package/lib/esm/core/components/shadcn/checkbox.js +0 -1
  12. package/lib/esm/core/components/shadcn/checkbox.js.map +1 -1
  13. package/lib/esm/core/components/shadcn/command.js +0 -1
  14. package/lib/esm/core/components/shadcn/command.js.map +1 -1
  15. package/lib/esm/core/components/shadcn/dialog.js +0 -1
  16. package/lib/esm/core/components/shadcn/dialog.js.map +1 -1
  17. package/lib/esm/core/components/shadcn/filters/comboBox.js +18 -0
  18. package/lib/esm/core/components/shadcn/filters/comboBox.js.map +1 -1
  19. package/lib/esm/core/components/shadcn/filters/filterBar.js +38 -17
  20. package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -1
  21. package/lib/esm/core/components/shadcn/filters/filters.js +11 -5
  22. package/lib/esm/core/components/shadcn/filters/filters.js.map +1 -1
  23. package/lib/esm/core/components/shadcn/filters/selectFilter.js +1 -1
  24. package/lib/esm/core/components/shadcn/filters/selectFilter.js.map +1 -1
  25. package/lib/esm/core/components/shadcn/filters/stringListFilter.js +24 -0
  26. package/lib/esm/core/components/shadcn/filters/stringListFilter.js.map +1 -0
  27. package/lib/esm/core/components/shadcn/filters/textFilter.js +2 -1
  28. package/lib/esm/core/components/shadcn/filters/textFilter.js.map +1 -1
  29. package/lib/esm/core/components/shadcn/label.js +0 -1
  30. package/lib/esm/core/components/shadcn/label.js.map +1 -1
  31. package/lib/esm/features/agent/PayloadBuilder.js +27 -0
  32. package/lib/esm/features/agent/PayloadBuilder.js.map +1 -1
  33. package/lib/esm/features/agent/chat/ModernAgentConversation.js +1 -1
  34. package/lib/esm/features/agent/chat/ModernAgentConversation.js.map +1 -1
  35. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js +3 -3
  36. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  37. package/lib/esm/features/facets/VEnvironmentFacet.js +24 -0
  38. package/lib/esm/features/facets/VEnvironmentFacet.js.map +1 -0
  39. package/lib/esm/features/facets/VFacetsNav.js +69 -26
  40. package/lib/esm/features/facets/VFacetsNav.js.map +1 -1
  41. package/lib/esm/features/facets/VInteractionFacet.js +45 -0
  42. package/lib/esm/features/facets/VInteractionFacet.js.map +1 -0
  43. package/lib/esm/features/facets/VStringFacet.js +6 -5
  44. package/lib/esm/features/facets/VStringFacet.js.map +1 -1
  45. package/lib/esm/features/facets/VUserFacet.js +6 -6
  46. package/lib/esm/features/facets/VUserFacet.js.map +1 -1
  47. package/lib/esm/features/layout/GenericPageNavHeader.js +1 -1
  48. package/lib/esm/features/magic-pdf/TextPageView.js +1 -2
  49. package/lib/esm/features/magic-pdf/TextPageView.js.map +1 -1
  50. package/lib/esm/features/store/collections/CollectionsTable.js +9 -5
  51. package/lib/esm/features/store/collections/CollectionsTable.js.map +1 -1
  52. package/lib/esm/features/store/collections/{CollectionsView.js → CreateCollection.js} +6 -14
  53. package/lib/esm/features/store/collections/CreateCollection.js.map +1 -0
  54. package/lib/esm/features/store/collections/EditCollectionView.js +1 -1
  55. package/lib/esm/features/store/collections/EditCollectionView.js.map +1 -1
  56. package/lib/esm/features/store/collections/SelectCollection.js +24 -0
  57. package/lib/esm/features/store/collections/SelectCollection.js.map +1 -0
  58. package/lib/esm/features/store/collections/index.js +2 -2
  59. package/lib/esm/features/store/collections/index.js.map +1 -1
  60. package/lib/esm/features/store/objects/DocumentSearchResults.js +6 -3
  61. package/lib/esm/features/store/objects/DocumentSearchResults.js.map +1 -1
  62. package/lib/esm/features/store/objects/components/ContentOverview.js +17 -16
  63. package/lib/esm/features/store/objects/components/ContentOverview.js.map +1 -1
  64. package/lib/esm/features/store/objects/components/DocumentIcon.js +7 -10
  65. package/lib/esm/features/store/objects/components/DocumentIcon.js.map +1 -1
  66. package/lib/esm/features/store/objects/components/DocumentInput.js +1 -2
  67. package/lib/esm/features/store/objects/components/DocumentInput.js.map +1 -1
  68. package/lib/esm/features/store/objects/components/PropertiesEditorModal.js +4 -2
  69. package/lib/esm/features/store/objects/components/PropertiesEditorModal.js.map +1 -1
  70. package/lib/esm/features/store/objects/components/SaveVersionConfirmModal.js +1 -2
  71. package/lib/esm/features/store/objects/components/SaveVersionConfirmModal.js.map +1 -1
  72. package/lib/esm/features/store/objects/components/SelectDocument.js +9 -3
  73. package/lib/esm/features/store/objects/components/SelectDocument.js.map +1 -1
  74. package/lib/esm/features/store/objects/components/SelectDocumentModal.js +2 -2
  75. package/lib/esm/features/store/objects/components/SelectDocumentModal.js.map +1 -1
  76. package/lib/esm/features/store/objects/layout/documentLayout.js +2 -2
  77. package/lib/esm/features/store/objects/layout/documentLayout.js.map +1 -1
  78. package/lib/esm/features/store/objects/search/DocumentSearchContext.js +4 -2
  79. package/lib/esm/features/store/objects/search/DocumentSearchContext.js.map +1 -1
  80. package/lib/esm/features/store/objects/selection/SelectionActions.js +1 -1
  81. package/lib/esm/features/store/objects/selection/SelectionActions.js.map +1 -1
  82. package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js +7 -10
  83. package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js.map +1 -1
  84. package/lib/esm/features/store/objects/selection/actions/ChangeTypeAction.js +1 -1
  85. package/lib/esm/features/store/objects/selection/actions/ChangeTypeAction.js.map +1 -1
  86. package/lib/esm/features/store/objects/selection/actions/DeleteObjectsAction.js +2 -2
  87. package/lib/esm/features/store/objects/selection/actions/DeleteObjectsAction.js.map +1 -1
  88. package/lib/esm/features/store/objects/selection/actions/ExportPropertiesAction.js +1 -1
  89. package/lib/esm/features/store/objects/selection/actions/ExportPropertiesAction.js.map +1 -1
  90. package/lib/esm/features/store/objects/selection/actions/RemoveFromCollectionAction.js +1 -1
  91. package/lib/esm/features/store/objects/selection/actions/RemoveFromCollectionAction.js.map +1 -1
  92. package/lib/esm/features/store/types/ContentObjectTypesSearch.js +2 -3
  93. package/lib/esm/features/store/types/ContentObjectTypesSearch.js.map +1 -1
  94. package/lib/esm/features/store/types/ContentObjectTypesTable.js +1 -1
  95. package/lib/esm/features/store/types/ContentObjectTypesTable.js.map +1 -1
  96. package/lib/esm/features/store/types/CreateOrUpdateTypeModal.js +2 -2
  97. package/lib/esm/features/store/types/CreateOrUpdateTypeModal.js.map +1 -1
  98. package/lib/esm/features/store/types/ObjectSchemaEditor.js +2 -3
  99. package/lib/esm/features/store/types/ObjectSchemaEditor.js.map +1 -1
  100. package/lib/esm/features/store/types/TableLayoutEditor.js +1 -1
  101. package/lib/esm/features/store/types/TableLayoutEditor.js.map +1 -1
  102. package/lib/esm/features/store/types/index.js +0 -2
  103. package/lib/esm/features/store/types/index.js.map +1 -1
  104. package/lib/esm/features/user/UserInfo.js +1 -2
  105. package/lib/esm/features/user/UserInfo.js.map +1 -1
  106. package/lib/esm/features/utils/rendition.js +22 -2
  107. package/lib/esm/features/utils/rendition.js.map +1 -1
  108. package/lib/esm/layout/FullHeightLayout.js +2 -4
  109. package/lib/esm/layout/FullHeightLayout.js.map +1 -1
  110. package/lib/esm/session/UserSession.js +2 -2
  111. package/lib/esm/session/UserSession.js.map +1 -1
  112. package/lib/esm/session/auth/composable.js +1 -1
  113. package/lib/esm/session/auth/composable.js.map +1 -1
  114. package/lib/esm/session/constants.js +3 -0
  115. package/lib/esm/session/constants.js.map +1 -0
  116. package/lib/esm/widgets/codemirror/CodeMirrorEditor.js +2 -2
  117. package/lib/esm/widgets/codemirror/CodeMirrorEditor.js.map +1 -1
  118. package/lib/esm/widgets/properties/PropertiesView.js +4 -2
  119. package/lib/esm/widgets/properties/PropertiesView.js.map +1 -1
  120. package/lib/esm/widgets/schema-editor/editor/SchemaEditor.js +1 -1
  121. package/lib/esm/widgets/schema-editor/editor/SchemaEditor.js.map +1 -1
  122. package/lib/tsconfig.tsbuildinfo +1 -1
  123. package/lib/types/core/components/InputList.d.ts +2 -1
  124. package/lib/types/core/components/Switch.d.ts +2 -1
  125. package/lib/types/core/components/shadcn/filters/comboBox.d.ts +5 -0
  126. package/lib/types/core/components/shadcn/filters/stringListFilter.d.ts +10 -0
  127. package/lib/types/core/components/shadcn/filters/types.d.ts +3 -3
  128. package/lib/types/features/agent/PayloadBuilder.d.ts +8 -1
  129. package/lib/types/features/facets/VEnvironmentFacet.d.ts +11 -0
  130. package/lib/types/features/facets/VFacetsNav.d.ts +9 -1
  131. package/lib/types/features/facets/VInteractionFacet.d.ts +14 -0
  132. package/lib/types/features/facets/VStringFacet.d.ts +3 -2
  133. package/lib/types/features/facets/VUserFacet.d.ts +3 -2
  134. package/lib/types/features/store/collections/{CollectionsView.d.ts → CreateCollection.d.ts} +5 -3
  135. package/lib/types/features/store/collections/SelectCollection.d.ts +14 -0
  136. package/lib/types/features/store/collections/index.d.ts +2 -2
  137. package/lib/types/features/store/objects/components/ContentOverview.d.ts +2 -1
  138. package/lib/types/features/store/objects/components/DocumentIcon.d.ts +2 -1
  139. package/lib/types/features/store/objects/components/PropertiesEditorModal.d.ts +2 -1
  140. package/lib/types/features/store/objects/layout/documentLayout.d.ts +1 -1
  141. package/lib/types/features/store/objects/search/DocumentSearchContext.d.ts +3 -2
  142. package/lib/types/features/store/objects/selection/actions/DeleteObjectsAction.d.ts +2 -1
  143. package/lib/types/features/store/objects/selection/actions/RemoveFromCollectionAction.d.ts +2 -1
  144. package/lib/types/features/store/types/index.d.ts +0 -2
  145. package/lib/types/features/utils/rendition.d.ts +1 -1
  146. package/lib/types/session/UserSession.d.ts +2 -2
  147. package/lib/types/session/constants.d.ts +2 -0
  148. package/lib/vertesia-ui-core.js +1 -1
  149. package/lib/vertesia-ui-core.js.map +1 -1
  150. package/lib/vertesia-ui-features.js +1 -1
  151. package/lib/vertesia-ui-features.js.map +1 -1
  152. package/lib/vertesia-ui-layout.js +1 -1
  153. package/lib/vertesia-ui-layout.js.map +1 -1
  154. package/lib/vertesia-ui-session.js +1 -1
  155. package/lib/vertesia-ui-session.js.map +1 -1
  156. package/lib/vertesia-ui-widgets.js +1 -1
  157. package/lib/vertesia-ui-widgets.js.map +1 -1
  158. package/package.json +4 -4
  159. package/src/core/components/EmptyCollection.tsx +26 -24
  160. package/src/core/components/InputList.tsx +3 -1
  161. package/src/core/components/SidePanel.tsx +2 -2
  162. package/src/core/components/Switch.tsx +4 -3
  163. package/src/core/components/shadcn/calendar.tsx +0 -2
  164. package/src/core/components/shadcn/checkbox.tsx +0 -2
  165. package/src/core/components/shadcn/command.tsx +0 -2
  166. package/src/core/components/shadcn/dialog.tsx +0 -2
  167. package/src/core/components/shadcn/filters/comboBox.tsx +73 -0
  168. package/src/core/components/shadcn/filters/filterBar.tsx +41 -17
  169. package/src/core/components/shadcn/filters/filters.tsx +30 -14
  170. package/src/core/components/shadcn/filters/selectFilter.tsx +3 -3
  171. package/src/core/components/shadcn/filters/stringListFilter.tsx +58 -0
  172. package/src/core/components/shadcn/filters/textFilter.tsx +2 -1
  173. package/src/core/components/shadcn/filters/types.ts +3 -3
  174. package/src/core/components/shadcn/label.tsx +0 -2
  175. package/src/features/agent/PayloadBuilder.tsx +34 -1
  176. package/src/features/agent/chat/ModernAgentConversation.tsx +639 -639
  177. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +12 -13
  178. package/src/features/facets/VEnvironmentFacet.tsx +42 -0
  179. package/src/features/facets/VFacetsNav.tsx +87 -29
  180. package/src/features/facets/VInteractionFacet.tsx +73 -0
  181. package/src/features/facets/VStringFacet.tsx +7 -6
  182. package/src/features/facets/VUserFacet.tsx +7 -6
  183. package/src/features/layout/GenericPageNavHeader.tsx +1 -1
  184. package/src/features/magic-pdf/TextPageView.tsx +1 -2
  185. package/src/features/store/collections/CollectionsTable.tsx +49 -40
  186. package/src/features/store/collections/{CollectionsView.tsx → CreateCollection.tsx} +15 -42
  187. package/src/features/store/collections/EditCollectionView.tsx +1 -1
  188. package/src/features/store/collections/SelectCollection.tsx +46 -0
  189. package/src/features/store/collections/index.ts +2 -2
  190. package/src/features/store/objects/DocumentSearchResults.tsx +6 -3
  191. package/src/features/store/objects/components/ContentOverview.tsx +38 -98
  192. package/src/features/store/objects/components/DocumentIcon.tsx +27 -14
  193. package/src/features/store/objects/components/DocumentInput.tsx +1 -2
  194. package/src/features/store/objects/components/PropertiesEditorModal.tsx +7 -3
  195. package/src/features/store/objects/components/SaveVersionConfirmModal.tsx +2 -2
  196. package/src/features/store/objects/components/SelectDocument.tsx +18 -3
  197. package/src/features/store/objects/components/SelectDocumentModal.tsx +6 -6
  198. package/src/features/store/objects/layout/documentLayout.tsx +2 -2
  199. package/src/features/store/objects/search/DocumentSearchContext.ts +6 -3
  200. package/src/features/store/objects/selection/ObjectsActionContext.tsx +1 -1
  201. package/src/features/store/objects/selection/SelectionActions.tsx +0 -1
  202. package/src/features/store/objects/selection/actions/AddToCollectionAction.tsx +10 -21
  203. package/src/features/store/objects/selection/actions/ChangeTypeAction.tsx +1 -1
  204. package/src/features/store/objects/selection/actions/DeleteObjectsAction.tsx +2 -2
  205. package/src/features/store/objects/selection/actions/ExportPropertiesAction.tsx +1 -1
  206. package/src/features/store/objects/selection/actions/RemoveFromCollectionAction.tsx +1 -1
  207. package/src/features/store/types/ContentObjectTypesSearch.tsx +3 -4
  208. package/src/features/store/types/ContentObjectTypesTable.tsx +3 -1
  209. package/src/features/store/types/CreateOrUpdateTypeModal.tsx +2 -9
  210. package/src/features/store/types/ObjectSchemaEditor.tsx +4 -5
  211. package/src/features/store/types/TableLayoutEditor.tsx +4 -4
  212. package/src/features/store/types/index.ts +0 -2
  213. package/src/features/user/UserInfo.tsx +1 -2
  214. package/src/features/utils/rendition.ts +23 -1
  215. package/src/layout/FullHeightLayout.tsx +2 -2
  216. package/src/session/UserSession.ts +2 -2
  217. package/src/session/auth/composable.ts +1 -1
  218. package/src/session/constants.ts +2 -0
  219. package/src/widgets/codemirror/CodeMirrorEditor.tsx +2 -2
  220. package/src/widgets/properties/PropertiesView.tsx +10 -2
  221. package/src/widgets/schema-editor/editor/SchemaEditor.tsx +1 -1
  222. package/lib/esm/features/store/collections/CollectionView.js +0 -53
  223. package/lib/esm/features/store/collections/CollectionView.js.map +0 -1
  224. package/lib/esm/features/store/collections/CollectionsView.js.map +0 -1
  225. package/lib/esm/features/store/types/ContentObjectTypeView.js +0 -158
  226. package/lib/esm/features/store/types/ContentObjectTypeView.js.map +0 -1
  227. package/lib/esm/features/store/types/ContentObjectTypesView.js +0 -55
  228. package/lib/esm/features/store/types/ContentObjectTypesView.js.map +0 -1
  229. package/lib/types/features/store/collections/CollectionView.d.ts +0 -5
  230. package/lib/types/features/store/types/ContentObjectTypeView.d.ts +0 -5
  231. package/lib/types/features/store/types/ContentObjectTypesView.d.ts +0 -8
  232. package/src/features/store/collections/CollectionView.tsx +0 -94
  233. package/src/features/store/types/ContentObjectTypeView.tsx +0 -244
  234. package/src/features/store/types/ContentObjectTypesView.tsx +0 -71
@@ -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}from"@vertesia/ui/core";import T from"clsx";import q from"ajv";import{json as M}from"@codemirror/lang-json";import L from"debounce";import{EditorView as D}from"@codemirror/view";import{Text as F,EditorState as R}from"@codemirror/state";import{basicSetup as V}from"codemirror";import{AlignLeft as _,Trash2 as z,SquarePen as U,Plus as K,ChevronDown as B,ChevronRight as W,UploadIcon as H,CheckCircleIcon as J,AlertCircleIcon as G,XCircleIcon as X}from"lucide-react";import{offset as Z,shift as Y,flip as Q}from"@floating-ui/dom";import{useFloating as ee,autoUpdate as te,useDismiss as re,useClick as ne,useHover as se,useInteractions as ie,useTransitionStyles as ae,FloatingPortal as oe,FloatingFocusManager as le,safePolygon as ce}from"@floating-ui/react";const de="#text",he="#comment",ue="#cdata",pe="DECLARATION_TAG",me={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},fe=o({theme:me,collapsible:!1,indentSize:2}),ge=()=>l(fe),ye=new f({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:he,cdataPropName:ue,parseTagValue:!1});function ve(r){const{indentation:n,children:s,isInline:i}=r,{theme:a}=ge();return e("div",{style:{color:a.cdataColor},children:[t("span",{children:`${n}<![CDATA[`}),s,t("span",{children:`${i?"":n}]]>`})]})}function be(e){const{collapsible:r,theme:n}=ge(),{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(xe,{fill:n.separatorColor,style:{transform:`rotate(${s?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function xe({...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 we(e){const{collapsible:t,initialCollapsedDepth:r}=ge(),[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 Ne(r){const{indentation:n,children:s,isInline:i,level:a}=r,{theme:o}=ge(),{collapsed:l,buttonProps:c}=we(a);return e("div",{style:{color:o.commentColor},children:[e("span",{...c,children:[t("span",{children:n}),t(be,{collapsed:l}),t("span",{children:"\x3c!-- "})]}),!l&&s,l&&"...",t("span",{children:`${i||l?" ":n}--\x3e`})]})}function ke(r){const{attributes:n}=r,{theme:s}=ge();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 Ce(r){const{indentation:n,tagKey:s,attributes:i}=r,{theme:a}=ge();return e("div",{children:[t("span",{style:{color:a.separatorColor},children:`${n}<?`}),t("span",{style:{color:a.tagColor},children:`${s.slice(1)}`}),t(ke,{attributes:i}),t("span",{style:{color:a.separatorColor},children:"?>"})]})}function je(e){return"string"==typeof e&&e.includes("\n")}function Se(e){const t=e[":@"],r=s(e,":@"),[[n,i]]=Object.entries(r),a=function(e){switch(e){case de:case ue:case he:return e;default:return e.startsWith("?")?pe:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:i,type:a}}function Oe(e){return!!e&&Object.keys(e).length>0}function Ae(n){const{indentation:s,tagKey:i,attributes:a,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:h,buttonProps:u}=we(d),{theme:p}=ge();return e("div",{children:[e("span",{...u,children:[t("span",{children:s}),t(be,{collapsed:h}),t("span",{style:{color:p.separatorColor},children:"<"}),t("span",{style:{color:p.tagColor},children:`${i}`}),!h&&t(ke,{attributes:a}),h&&Oe(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 Pe(e){const{hasSiblings:r,text:n,indentation:s,isText:i}=e,{theme:a}=ge(),o=i?{color:a.textColor}:void 0;return je(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 $e(e){const{elements:n,level:s=0,isText:i=!0}=e,{indentSize:a}=ge();return Array.isArray(n)&&0!==n.length?t(r,{children:n.map(((e,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=Se(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&&de in e[0]&&!je(e[0][de])}(c);switch(d){case de:return t(Pe,{text:c,indentation:u,hasSiblings:h,isText:i},p);case he:return t(Ne,{isInline:m,indentation:u,level:s,children:t($e,{elements:c,level:s+1,isText:!1})},p);case ue:return t(ve,{indentation:u,isInline:m,children:t($e,{elements:c,level:s+1,isText:!1})},p);case pe:return t(Ce,{indentation:u,tagKey:o,attributes:l},p);default:return t(Ae,{indentation:u,tagKey:o,attributes:l,isInline:m,hasChildren:c.length>0,level:s,children:t($e,{elements:c,level:s+1})},p)}}))}):null}function Ee(){return t("div",{children:"Invalid XML!"})}function Ie(e){const{theme:r,xml:n,collapsible:s=!1,indentSize:a=2,invalidXml:o,initalCollapsedDepth:l,initialCollapsedDepth:u}=e,[p,m]=d((()=>({...me,...r}))),{json:f,valid:y}=function(e){return c((()=>{try{if(!g.validate(e))throw new Error("Invalid XML!");const t=ye.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={...me,...r};return i(t,e)?e:t}))}),[r]),y?t(fe.Provider,{value:v,children:t("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:p.fontFamily,overflowWrap:"break-word"},children:t($e,{elements:f})})}):o||t(Ee,{})}const Te="text-pink-500 dark:text-pink-400",qe="text-purple-500 dark:text-purple-400",Me="text-blue-500 dark:text-blue-400",Le={code:"bg-gray-100 dark:bg-slate-800 whitespace-pre-wrap p-4 rounded-lg font-mono",comma:Te,assign:Te,startObject:Te,endObject:Te,startArray:Te,endArray:Te,boolean:qe,null:qe,key:Me,index:Me,string:"text-orange-500 dark:text-orange-400",number:"text-green-500 dark:text-green-400"};class De{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 De)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 Fe extends De{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 Re extends De{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 Ve{classMap;tab;stack=[];block=new Fe(this,void 0,"","");constructor(e=Le,t=" "){this.classMap=e,this.tab=t}onStartObject(e){const t=new Fe(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 Re(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 _e({data:e,className:r,classMap:n}){const[s,i]=d();return h((()=>{i(function(e,r,n){const s=new Ve(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 ze{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new q({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 Ke(this,e,t):new Ue(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 Ue extends ze{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 Ke extends Ue{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 Be(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function We(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 He{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||Be(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class Je extends He{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new Ye(this,t,this.getOrInitArrayProperty(e)):t.isObject?new Xe(this,t,t.name,this.getOrInitObjectProperty(e)):new Ze(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 Ye(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new Xe(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Ze(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Ge extends Je{value;constructor(e,t={}){super(null,e instanceof ze?e:new ze(e),"#root"),this.value=t}}class Xe extends Je{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class Ze extends He{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 We(this.name,this.schema)}}class Ye extends He{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 Qe(this,e):new et(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 Xe(this,this.schema,String(e),t):new et(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class Qe extends Je{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 et extends He{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 We(this.name,this.schema)}}function tt({value:e}){return t("div",{className:"flex flex-col gap-4",children:Object.entries(e).map((([e,r])=>t(st,{name:e,value:r},e)))})}function rt({name:e}){return t("div",{className:"text-md font-semibold",children:Be(e)})}function nt({children:e,className:r}){return t("div",{className:T("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 st({name:r,value:n}){const s=lt(n);switch(s.type){case ot.Inline:return e("div",{className:"w-full flex gap-2",children:[t(rt,{name:r+":"}),t("p",{children:s.value})]});case ot.Paragraph:return e("div",{children:[t(rt,{name:r}),t("p",{children:s.value})]});case ot.Prose:return e("div",{className:"prose dark:prose-invert",children:[t(rt,{name:r}),t("div",{className:"vprose dark:prose-invert",children:s.value})]});case ot.Array:return t(it,{name:r,value:n});case ot.Object:return e("div",{children:[t(rt,{name:r}),t(nt,{className:"mt-2",children:Object.entries(n).map((([e,r])=>t(st,{name:e,value:r},e)))})]})}}function it({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(rt,{name:r+":"}),n.map(((e,r)=>t(v,{children:String(e)},r)))]}:{children:[r&&t(rt,{name:r}),t("div",{className:"flex flex-col gap-2",children:n.map(((e,r)=>t(at,{index:r,value:e,useBullet:o},r)))})]})}function at({index:r,value:n,useBullet:s}){const i=s?t("span",{className:"text-xl",children:"•"}):e("span",{children:[r+1,"."]}),a=lt(n);let o;switch(a.type){case ot.Object:o=t(nt,{children:Object.entries(n).map((([e,r])=>t(st,{name:e,value:r},e)))});break;case ot.Array:o=t(it,{value:n});break;case ot.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 ot;function lt(e){if(null==e)return{value:"-",type:ot.Inline};if(Array.isArray(e))return{value:e,type:ot.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=ot.Inline:t>400?r=ot.Prose:(r=ot.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:ot.Inline}:{value:e,type:ot.Object}}function ct({value:e,viewCode:r=!1}){return e?t("div",{className:"relative w-full",children:r?t(_e,{data:e}):t(tt,{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"}(ot||(ot={}));let dt=null;class ht{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 ut=[D.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 #000",borderLeftColor:"#000",animation:"blink 1.2s step-start infinite"},"@keyframes blink":{"50%":{opacity:0}}}),D.lineWrapping];function pt({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?L(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=[...ut,(e=e=>{l.current?.(e)},D.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?F.of(e.split("\n")):e;return dt?dt.doc.toString()!==r.toString()&&(dt=R.create({doc:r,extensions:t})):dt=R.create({doc:r,extensions:t}),dt})(r,t),a=new D({state:n,parent:o.current}),c=new ht(a);return s&&(s.current=c),()=>{a.destroy(),s&&(s.current=void 0)}}var e}),[d,i]),d}const mt=[V,M()];function ft({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(_e,{data:r.schema||{}}):t(pt,{value:l,extensions:mt,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 gt;function yt(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 vt(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)?bt(e[0].type):bt(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 bt(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"}(gt||(gt={}));let xt=0;class wt{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 Nt("",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 Nt("",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 wt(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class Nt{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=vt(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 Nt(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+ ++xt}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 yt(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 Nt(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&&(yt(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=gt[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===gt.object}}(t);let i;return"text"===s.name?(s.name=gt.string,i="textarea"):"media"===s.name?(s.name=gt.any,i="media"):"document"===s.name?(s.name=gt.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 kt(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const Ct=function(){const e=Object.values(gt),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function jt({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(St,{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(Ot,{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(_,{className:"size-4"})}),t(At,{value:r.description,isOpen:a,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),o(!1)}})]})]})}function St({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 Ot({value:e,onChange:r,onCancel:n,onSave:s}){return t(O,{className:S.INPUT_UNSTYLED,options:Ct,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 At({value:r,isOpen:n,onClose:s}){return e(w,{isOpen:n,onClose:s,children:[t(N,{children:"Edit description"}),t(Pt,{value:r,onSave:s})]})}function Pt({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 $t({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 Et(e){const[t,r]=d(new wt(e||{type:"object",properties:{}}).withChangeListener((e=>{r(e.clone())})));return t}const It="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Tt=`${It} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,qt=`${It} shadow-xs ring-1 ring-inset ring-ring`;function Mt({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(Dt,{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(Lt,{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 Lt({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:T("flex justify-start items-center group",a?Tt:It,{"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(z,{className:"size-4"})}),c?null:t(j,{variant:"ghost",size:"sm",className:d,onClick:s,children:t(U,{className:"size-4"})})]})]})}function Dt({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:qt,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 Ft(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function Rt({schema:r,readonly:n=!1}){return e("ul",{className:"",children:[r.children.map((e=>Vt(e,n))),n?null:t(Bt,{parent:r.root})]})}function Vt(e,r){return e.isParent?t(zt,{property:e,readonly:r},e.name):t(_t,{node:e,readonly:r},e.name)}function _t({node:e,readonly:r}){return t("li",{children:t(Kt,{property:e,readonly:r})})}function zt({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?B:W,{className:"size-4"})}),t("div",{className:"flex-1",children:t(Kt,{property:r,readonly:n})})]}),s&&e("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map((e=>Vt(e,n))),n?null:t(Bt,{parent:r})]})]})}function Ut(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 Kt({property:e,readonly:r}){const n=x(),s=e.resetIsNew(),i=kt(e);return t(Mt,{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:jt,viewer:$t,outlineOnHover:!0,isEditing:s,skipClickOutside:Ft,readonly:r,onValidate:e=>Ut(e.name)})}function Bt({parent:r}){return e(j,{variant:"outline",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:gt.string},!0).isNew=!0,r.reloadTree()},children:[t(K,{className:"size-4"}),"Add property"]})}const Wt=o(void 0),Ht=Wt.Provider;function Jt(){const e=l(Wt);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}const Gt=o(void 0);function Xt(){const e=l(Gt);if(!e)throw new Error("useForm must be used within a Form element");return e}const Zt=Gt.Provider;function Yt({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 Qt({children:e}){return t("p",{className:"mt-2 text-sm text-gray-500",children:e})}function er({children:e}){return t("p",{className:"mt-2 text-sm text-red-600",children:e})}const tr=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=T(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 rr({object:e,components:r,onSubmit:n,children:s,onChange:i}){return e.observer=i,t(Zt,{value:{object:e,components:r||{}},children:t("form",{className:"w-full",onSubmit:t=>{t.stopPropagation(),t.preventDefault(),n&&n(e.value)},children:s})})}function nr(){const e=Xt();return t("div",{className:"flex flex-col gap-4 w-full",children:e.object.properties.map(ir)})}function sr({children:r,...n}){return e(rr,{...n,children:[t(nr,{}),r]})}function ir(e){return e.isList?t(lr,{object:e},e.name):e.isObject?t(or,{object:e},e.name):t(ar,{object:e},e.name)}function ar({object:r,editor:n,inline:s=!1}){n||(n=r.schema.editor);const{components:i}=Xt(),a=n&&i[n]||tr,o=r.getInputType();"checkbox"===o&&(s=!0);return e("div",{className:"",children:[e("div",{className:T("flex gap-2",s?"flex-row items-center":"flex-col"),children:[!r.isListItem&&t(Yt,{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(Qt,{children:r.schema.description})]})}function or({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(ir)]})}function lr({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(cr,{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(K,{className:"size-6"})," Add"]})})]})}function cr({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(lr,{object:i}):i.isObject?t(or,{object:i}):t(ar,{object:i,editor:a}))}),t(j,{variant:"secondary",onClick:s,children:t(z,{className:"size-4"})})]});var i,a}function dr({className:r,properties:n}){return t(I,{className:r,children:t("tbody",{children:n.map((r=>e("tr",{children:[t("td",{className:"w-1/3 font-semibold",children:t("span",{children:r.name})}),t("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name)))})})}const hr=o(void 0);function ur(){return l(hr)}const pr=Symbol("__SLOT_NAME");function mr(e,t){const r=[];return p.forEach(e,(e=>{!function(e,t,r){let n;m(e)&&(n=e.type[pr])?r[n]=e:t.push(e)}(e,r,t)})),r.length>1?r:r[0]}function fr(e,t){t[pr]=e}function gr(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function yr(e){const r={};if(mr(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(vr,{...e,trigger:n,content:s})}function vr({middleware:r,offset:n,trigger:s,dismiss:i=!0,content:a,placement:o,strategy:l,zIndex:c=40}){const[h,u]=d(!1),p=ee({open:h,placement:o,strategy:l,onOpenChange:u,middleware:r||[Z(n||4),Y(),Q()],whileElementsMounted:te}),{floatingStyles:m,refs:{setReference:f,setFloating:g},context:y}=p,v=re(y,gr(i)),b=ne(y,gr(!(x=s)||x.hover||x.click?x?.click:{enabled:!0}));var x;const w=se(y,gr(function(e){return!0===e?.hover?{enabled:!0,handleClose:ce({blockPointerEvents:!0}),restMs:0}:e?.hover}(s))),{getReferenceProps:N,getFloatingProps:k}=ie([v,b,w]),{isMounted:C,styles:j}=ae(y,a.transition);return e(hr.Provider,{value:{...p,close:()=>u(!1)},children:[s&&t("div",{className:T(s.className,"inline-block"),ref:f,...N(),children:s.children}),t(oe,{children:C&&t("div",{ref:g,style:{...m,zIndex:c},...k(),children:t(le,{context:y,children:t("div",{className:T(a.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:j,children:a.children})})})})]})}function br(e){return null}function xr(e){return null}function wr({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(H,{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(H,{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 Nr({title:r,count:n,icon:s=t(J,{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 kr({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(J,{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(Nr,{title:"Successfully Uploaded",count:d,icon:t(J,{className:"h-4 w-4 text-green-500"}),items:a.map((e=>e.name))}),h>0&&t(Nr,{title:"Successfully Updated",count:h,icon:t(J,{className:"h-4 w-4 text-blue-500"}),items:o.map((e=>e.name))}),u>0&&t(Nr,{title:"Skipped (Already Existed)",count:u,icon:t(G,{className:"h-4 w-4 text-amber-500"}),items:l.map((e=>e.name))}),p>0&&t(Nr,{title:"Failed to Upload",count:p,icon:t(X,{className:"h-4 w-4 text-red-500"}),items:c.map((e=>e.name))})]})]})}function Cr({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}%`}})})}fr("trigger",br),fr("content",xr),yr.Trigger=br,yr.Content=xr;export{Ke as ArrayPropertySchema,pt as CodeMirrorEditor,wr as DropZone,ht as EditorApi,Ht as FieldSetContextProvider,rr as Form,Zt as FormContextProvider,er as FormError,Qt as FormHelper,Yt as FormLabel,sr as GeneratedForm,tr as Input,_e as JSONCode,ct as JSONDisplay,ft as JSONSchemaEditorModal,tt as JSONView,Qe as ManageObjectEntry,Ye as ManagedListProperty,Ge as ManagedObject,Je as ManagedObjectBase,Xe as ManagedObjectProperty,Ze as ManagedProperty,et as ManagedScalarEntry,wt as ManagedSchema,He as Node,yr as Popover,hr as PopoverContext,Cr as Progress,dr as PropertiesView,jt as PropertyEditor,St as PropertyNameEditor,Ue as PropertySchema,$t as PropertyViewer,ar as ScalarField,ze as Schema,Rt as SchemaEditor,Nt as SchemaNode,Nr as UploadResultCategory,kr as UploadSummary,Ie as XMLViewer,Be as computeTitleFromName,kt as getEditableSchemaProperty,Jt as useFieldSet,Xt as useForm,ur as usePopoverContext,Et as useSchema,Ut as validatePropertyName};
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};
2
2
  //# sourceMappingURL=vertesia-ui-widgets.js.map