@vertesia/ui 0.67.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/lib/esm/core/components/Badge.js +1 -1
  2. package/lib/esm/core/components/Badge.js.map +1 -1
  3. package/lib/esm/core/components/FormItem.js +2 -2
  4. package/lib/esm/core/components/FormItem.js.map +1 -1
  5. package/lib/esm/core/components/InputList.js +2 -2
  6. package/lib/esm/core/components/InputList.js.map +1 -1
  7. package/lib/esm/core/components/shadcn/checkbox.js +1 -1
  8. package/lib/esm/core/components/shadcn/checkbox.js.map +1 -1
  9. package/lib/esm/core/components/shadcn/command.js +1 -1
  10. package/lib/esm/core/components/shadcn/command.js.map +1 -1
  11. package/lib/esm/core/components/shadcn/dialog.js +6 -6
  12. package/lib/esm/core/components/shadcn/dialog.js.map +1 -1
  13. package/lib/esm/core/components/shadcn/filters/DynamicLabel.js.map +1 -1
  14. package/lib/esm/core/components/shadcn/filters/comboBox/DateCombobox.js +129 -0
  15. package/lib/esm/core/components/shadcn/filters/comboBox/DateCombobox.js.map +1 -0
  16. package/lib/esm/core/components/shadcn/filters/comboBox/SelectCombobox.js +46 -0
  17. package/lib/esm/core/components/shadcn/filters/comboBox/SelectCombobox.js.map +1 -0
  18. package/lib/esm/core/components/shadcn/filters/comboBox/StringListCombobox.js +23 -0
  19. package/lib/esm/core/components/shadcn/filters/comboBox/StringListCombobox.js.map +1 -0
  20. package/lib/esm/core/components/shadcn/filters/comboBox/TextCombobox.js +28 -0
  21. package/lib/esm/core/components/shadcn/filters/comboBox/TextCombobox.js.map +1 -0
  22. package/lib/esm/core/components/shadcn/filters/comboBox/comboBox.js +5 -0
  23. package/lib/esm/core/components/shadcn/filters/comboBox/comboBox.js.map +1 -0
  24. package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js +101 -0
  25. package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js.map +1 -0
  26. package/lib/esm/core/components/shadcn/filters/{stringListFilter.js → filter/StringListFilter.js} +3 -3
  27. package/lib/esm/core/components/shadcn/filters/filter/StringListFilter.js.map +1 -0
  28. package/lib/esm/core/components/shadcn/filters/{textFilter.js → filter/TextFilter.js} +4 -4
  29. package/lib/esm/core/components/shadcn/filters/filter/TextFilter.js.map +1 -0
  30. package/lib/esm/core/components/shadcn/filters/filter/dateFilter.js +161 -0
  31. package/lib/esm/core/components/shadcn/filters/filter/dateFilter.js.map +1 -0
  32. package/lib/esm/core/components/shadcn/filters/filter-styles.js +88 -0
  33. package/lib/esm/core/components/shadcn/filters/filter-styles.js.map +1 -0
  34. package/lib/esm/core/components/shadcn/filters/filterBar.js +128 -87
  35. package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -1
  36. package/lib/esm/core/components/shadcn/filters/filters.js +7 -6
  37. package/lib/esm/core/components/shadcn/filters/filters.js.map +1 -1
  38. package/lib/esm/core/components/shadcn/filters/index.js +1 -1
  39. package/lib/esm/core/components/shadcn/filters/index.js.map +1 -1
  40. package/lib/esm/core/components/shadcn/filters/types.js.map +1 -1
  41. package/lib/esm/core/components/toast/NotificationPanel.js +24 -18
  42. package/lib/esm/core/components/toast/NotificationPanel.js.map +1 -1
  43. package/lib/esm/features/agent/PayloadBuilder.js +47 -27
  44. package/lib/esm/features/agent/PayloadBuilder.js.map +1 -1
  45. package/lib/esm/features/agent/chat/ModernAgentConversation.js +9 -3
  46. package/lib/esm/features/agent/chat/ModernAgentConversation.js.map +1 -1
  47. package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +7 -6
  48. package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  49. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js +12 -1
  50. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  51. package/lib/esm/features/agent/chat/ModernAgentOutput/SlidingMessages.js +2 -1
  52. package/lib/esm/features/agent/chat/ModernAgentOutput/SlidingMessages.js.map +1 -1
  53. package/lib/esm/features/agent/chat/ModernAgentOutput/utils.js +10 -4
  54. package/lib/esm/features/agent/chat/ModernAgentOutput/utils.js.map +1 -1
  55. package/lib/esm/features/facets/DocumentsFacetsNav.js +133 -0
  56. package/lib/esm/features/facets/DocumentsFacetsNav.js.map +1 -0
  57. package/lib/esm/features/facets/RunsFacetsNav.js +125 -0
  58. package/lib/esm/features/facets/RunsFacetsNav.js.map +1 -0
  59. package/lib/esm/features/facets/VFacetsNav.js +4 -113
  60. package/lib/esm/features/facets/VFacetsNav.js.map +1 -1
  61. package/lib/esm/features/facets/VStringFacet.js +6 -4
  62. package/lib/esm/features/facets/VStringFacet.js.map +1 -1
  63. package/lib/esm/features/facets/VTypeFacet.js +4 -5
  64. package/lib/esm/features/facets/VTypeFacet.js.map +1 -1
  65. package/lib/esm/features/facets/VUserFacet.js +1 -1
  66. package/lib/esm/features/facets/VUserFacet.js.map +1 -1
  67. package/lib/esm/features/facets/WorkflowExecutionsFacetsNav.js +98 -0
  68. package/lib/esm/features/facets/WorkflowExecutionsFacetsNav.js.map +1 -0
  69. package/lib/esm/features/facets/index.js +3 -2
  70. package/lib/esm/features/facets/index.js.map +1 -1
  71. package/lib/esm/features/store/collections/CollectionsTable.js +1 -1
  72. package/lib/esm/features/store/collections/CollectionsTable.js.map +1 -1
  73. package/lib/esm/features/store/collections/CreateCollection.js +10 -9
  74. package/lib/esm/features/store/collections/CreateCollection.js.map +1 -1
  75. package/lib/esm/features/store/collections/EditCollectionView.js +10 -9
  76. package/lib/esm/features/store/collections/EditCollectionView.js.map +1 -1
  77. package/lib/esm/features/store/collections/SelectCollection.js +1 -1
  78. package/lib/esm/features/store/collections/SelectCollection.js.map +1 -1
  79. package/lib/esm/features/store/objects/DocumentPreviewPanel.js +0 -1
  80. package/lib/esm/features/store/objects/DocumentPreviewPanel.js.map +1 -1
  81. package/lib/esm/features/store/objects/DocumentSearchResults.js +37 -2
  82. package/lib/esm/features/store/objects/DocumentSearchResults.js.map +1 -1
  83. package/lib/esm/features/store/objects/components/ContentOverview.js +0 -2
  84. package/lib/esm/features/store/objects/components/ContentOverview.js.map +1 -1
  85. package/lib/esm/features/store/objects/components/SelectDocument.js +2 -2
  86. package/lib/esm/features/store/objects/components/SelectDocument.js.map +1 -1
  87. package/lib/esm/features/store/objects/components/VectorSearchWidget.js +1 -1
  88. package/lib/esm/features/store/objects/components/VectorSearchWidget.js.map +1 -1
  89. package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js +16 -4
  90. package/lib/esm/features/store/objects/selection/actions/AddToCollectionAction.js.map +1 -1
  91. package/lib/esm/features/store/objects/upload/DocumentUploadModal.js +72 -37
  92. package/lib/esm/features/store/objects/upload/DocumentUploadModal.js.map +1 -1
  93. package/lib/esm/features/store/types/ObjectSchemaEditor.js +15 -0
  94. package/lib/esm/features/store/types/ObjectSchemaEditor.js.map +1 -1
  95. package/lib/esm/features/user/UserInfo.js +8 -8
  96. package/lib/esm/features/user/UserInfo.js.map +1 -1
  97. package/lib/esm/router/HistoryNavigator.js +2 -2
  98. package/lib/esm/router/HistoryNavigator.js.map +1 -1
  99. package/lib/esm/shell/SplashScreen.js +19 -0
  100. package/lib/esm/shell/SplashScreen.js.map +1 -0
  101. package/lib/esm/shell/VertesiaShell.js +10 -0
  102. package/lib/esm/shell/VertesiaShell.js.map +1 -0
  103. package/lib/esm/shell/index.js +7 -0
  104. package/lib/esm/shell/index.js.map +1 -0
  105. package/lib/esm/shell/login/EnterpriseSigninButton.js +81 -0
  106. package/lib/esm/shell/login/EnterpriseSigninButton.js.map +1 -0
  107. package/lib/esm/shell/login/GitHubSignInButton.js +24 -0
  108. package/lib/esm/shell/login/GitHubSignInButton.js.map +1 -0
  109. package/lib/esm/shell/login/GoogleSignInButton.js +25 -0
  110. package/lib/esm/shell/login/GoogleSignInButton.js.map +1 -0
  111. package/lib/esm/shell/login/InviteAcceptModal.js +45 -0
  112. package/lib/esm/shell/login/InviteAcceptModal.js.map +1 -0
  113. package/lib/esm/shell/login/MicrosoftSigninButton.js +19 -0
  114. package/lib/esm/shell/login/MicrosoftSigninButton.js.map +1 -0
  115. package/lib/esm/shell/login/PreviewIcon.js +23 -0
  116. package/lib/esm/shell/login/PreviewIcon.js.map +1 -0
  117. package/lib/esm/shell/login/SignInModal.js +9 -0
  118. package/lib/esm/shell/login/SignInModal.js.map +1 -0
  119. package/lib/esm/shell/login/SigninScreen.js +64 -0
  120. package/lib/esm/shell/login/SigninScreen.js.map +1 -0
  121. package/lib/esm/shell/login/SignupForm.js +91 -0
  122. package/lib/esm/shell/login/SignupForm.js.map +1 -0
  123. package/lib/esm/shell/login/TerminalLogin.js +179 -0
  124. package/lib/esm/shell/login/TerminalLogin.js.map +1 -0
  125. package/lib/esm/shell/login/UserInfo.js +40 -0
  126. package/lib/esm/shell/login/UserInfo.js.map +1 -0
  127. package/lib/esm/shell/login/UserSessionMenu.js +31 -0
  128. package/lib/esm/shell/login/UserSessionMenu.js.map +1 -0
  129. package/lib/esm/shell/utils.js +6 -0
  130. package/lib/esm/shell/utils.js.map +1 -0
  131. package/lib/esm/widgets/SvgIcon.js +36 -0
  132. package/lib/esm/widgets/SvgIcon.js.map +1 -0
  133. package/lib/esm/widgets/index.js +7 -6
  134. package/lib/esm/widgets/index.js.map +1 -1
  135. package/lib/esm/widgets/upload/UploadSummary.js +1 -1
  136. package/lib/esm/widgets/upload/UploadSummary.js.map +1 -1
  137. package/lib/tsconfig.tsbuildinfo +1 -1
  138. package/lib/types/core/components/FormItem.d.ts +2 -1
  139. package/lib/types/core/components/shadcn/dialog.d.ts +2 -1
  140. package/lib/types/core/components/shadcn/filters/DynamicLabel.d.ts +1 -1
  141. package/lib/types/core/components/shadcn/filters/comboBox/DateCombobox.d.ts +5 -0
  142. package/lib/types/core/components/shadcn/filters/comboBox/SelectCombobox.d.ts +8 -0
  143. package/lib/types/core/components/shadcn/filters/comboBox/StringListCombobox.d.ts +5 -0
  144. package/lib/types/core/components/shadcn/filters/comboBox/TextCombobox.d.ts +5 -0
  145. package/lib/types/core/components/shadcn/filters/comboBox/comboBox.d.ts +4 -0
  146. package/lib/types/core/components/shadcn/filters/{selectFilter.d.ts → filter/SelectFilter.d.ts} +2 -2
  147. package/lib/types/core/components/shadcn/filters/{stringListFilter.d.ts → filter/StringListFilter.d.ts} +1 -1
  148. package/lib/types/core/components/shadcn/filters/{textFilter.d.ts → filter/TextFilter.d.ts} +1 -1
  149. package/lib/types/core/components/shadcn/filters/{dateFilter.d.ts → filter/dateFilter.d.ts} +1 -1
  150. package/lib/types/core/components/shadcn/filters/filter-styles.d.ts +1 -0
  151. package/lib/types/core/components/shadcn/filters/filterBar.d.ts +14 -4
  152. package/lib/types/core/components/shadcn/filters/index.d.ts +1 -1
  153. package/lib/types/core/components/shadcn/filters/types.d.ts +2 -0
  154. package/lib/types/features/agent/PayloadBuilder.d.ts +17 -8
  155. package/lib/types/features/agent/chat/ModernAgentOutput/utils.d.ts +2 -1
  156. package/lib/types/features/facets/DocumentsFacetsNav.d.ts +16 -0
  157. package/lib/types/features/facets/RunsFacetsNav.d.ts +18 -0
  158. package/lib/types/features/facets/VFacetsNav.d.ts +1 -1
  159. package/lib/types/features/facets/VStringFacet.d.ts +6 -2
  160. package/lib/types/features/facets/VTypeFacet.d.ts +3 -1
  161. package/lib/types/features/facets/WorkflowExecutionsFacetsNav.d.ts +13 -0
  162. package/lib/types/features/facets/index.d.ts +3 -2
  163. package/lib/types/shell/SplashScreen.d.ts +4 -0
  164. package/lib/types/shell/VertesiaShell.d.ts +7 -0
  165. package/lib/types/shell/index.d.ts +6 -0
  166. package/lib/types/shell/login/EnterpriseSigninButton.d.ts +5 -0
  167. package/lib/types/shell/login/GitHubSignInButton.d.ts +5 -0
  168. package/lib/types/shell/login/GoogleSignInButton.d.ts +5 -0
  169. package/lib/types/shell/login/InviteAcceptModal.d.ts +1 -0
  170. package/lib/types/shell/login/MicrosoftSigninButton.d.ts +5 -0
  171. package/lib/types/shell/login/PreviewIcon.d.ts +5 -0
  172. package/lib/types/shell/login/SignInModal.d.ts +6 -0
  173. package/lib/types/shell/login/SigninScreen.d.ts +8 -0
  174. package/lib/types/shell/login/SignupForm.d.ts +7 -0
  175. package/lib/types/shell/login/TerminalLogin.d.ts +1 -0
  176. package/lib/types/shell/login/UserInfo.d.ts +5 -0
  177. package/lib/types/shell/login/UserSessionMenu.d.ts +8 -0
  178. package/lib/types/shell/utils.d.ts +1 -0
  179. package/lib/types/widgets/SvgIcon.d.ts +6 -0
  180. package/lib/types/widgets/index.d.ts +7 -6
  181. package/lib/vertesia-ui-core.js +1 -1
  182. package/lib/vertesia-ui-core.js.map +1 -1
  183. package/lib/vertesia-ui-features.js +1 -1
  184. package/lib/vertesia-ui-features.js.map +1 -1
  185. package/lib/vertesia-ui-router.js +1 -1
  186. package/lib/vertesia-ui-router.js.map +1 -1
  187. package/lib/vertesia-ui-shell.js +2 -0
  188. package/lib/vertesia-ui-shell.js.map +1 -0
  189. package/lib/vertesia-ui-widgets.js +1 -1
  190. package/lib/vertesia-ui-widgets.js.map +1 -1
  191. package/package.json +14 -6
  192. package/src/core/components/Badge.tsx +12 -8
  193. package/src/core/components/FormItem.tsx +4 -3
  194. package/src/core/components/InputList.tsx +21 -17
  195. package/src/core/components/shadcn/checkbox.tsx +2 -2
  196. package/src/core/components/shadcn/command.tsx +1 -1
  197. package/src/core/components/shadcn/dialog.tsx +18 -9
  198. package/src/core/components/shadcn/filters/DynamicLabel.tsx +1 -2
  199. package/src/core/components/shadcn/filters/comboBox/DateCombobox.tsx +211 -0
  200. package/src/core/components/shadcn/filters/{comboBox.tsx → comboBox/SelectCombobox.tsx} +8 -192
  201. package/src/core/components/shadcn/filters/comboBox/StringListCombobox.tsx +76 -0
  202. package/src/core/components/shadcn/filters/comboBox/TextCombobox.tsx +81 -0
  203. package/src/core/components/shadcn/filters/comboBox/comboBox.tsx +4 -0
  204. package/src/core/components/shadcn/filters/filter/SelectFilter.tsx +161 -0
  205. package/src/core/components/shadcn/filters/{stringListFilter.tsx → filter/StringListFilter.tsx} +7 -7
  206. package/src/core/components/shadcn/filters/{textFilter.tsx → filter/TextFilter.tsx} +17 -11
  207. package/src/core/components/shadcn/filters/filter/dateFilter.tsx +256 -0
  208. package/src/core/components/shadcn/filters/filter-styles.ts +87 -0
  209. package/src/core/components/shadcn/filters/filterBar.tsx +208 -152
  210. package/src/core/components/shadcn/filters/filters.tsx +7 -5
  211. package/src/core/components/shadcn/filters/index.ts +1 -1
  212. package/src/core/components/shadcn/filters/types.ts +2 -0
  213. package/src/core/components/toast/NotificationPanel.tsx +38 -22
  214. package/src/features/agent/PayloadBuilder.tsx +56 -31
  215. package/src/features/agent/chat/ModernAgentConversation.tsx +10 -4
  216. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +7 -6
  217. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +12 -1
  218. package/src/features/agent/chat/ModernAgentOutput/SlidingMessages.tsx +2 -1
  219. package/src/features/agent/chat/ModernAgentOutput/utils.ts +12 -4
  220. package/src/features/facets/DocumentsFacetsNav.tsx +171 -0
  221. package/src/features/facets/RunsFacetsNav.tsx +166 -0
  222. package/src/features/facets/VFacetsNav.tsx +10 -126
  223. package/src/features/facets/VStringFacet.tsx +10 -4
  224. package/src/features/facets/VTypeFacet.tsx +6 -5
  225. package/src/features/facets/VUserFacet.tsx +5 -3
  226. package/src/features/facets/WorkflowExecutionsFacetsNav.tsx +132 -0
  227. package/src/features/facets/index.ts +5 -2
  228. package/src/features/store/collections/CollectionsTable.tsx +3 -2
  229. package/src/features/store/collections/CreateCollection.tsx +17 -15
  230. package/src/features/store/collections/EditCollectionView.tsx +19 -16
  231. package/src/features/store/collections/SelectCollection.tsx +1 -1
  232. package/src/features/store/objects/DocumentPreviewPanel.tsx +0 -1
  233. package/src/features/store/objects/DocumentSearchResults.tsx +80 -11
  234. package/src/features/store/objects/components/ContentOverview.tsx +0 -2
  235. package/src/features/store/objects/components/SelectDocument.tsx +2 -2
  236. package/src/features/store/objects/components/VectorSearchWidget.tsx +2 -2
  237. package/src/features/store/objects/selection/actions/AddToCollectionAction.tsx +40 -19
  238. package/src/features/store/objects/upload/DocumentUploadModal.tsx +160 -214
  239. package/src/features/store/types/ObjectSchemaEditor.tsx +15 -0
  240. package/src/features/user/UserInfo.tsx +17 -14
  241. package/src/router/HistoryNavigator.ts +2 -2
  242. package/src/shell/SplashScreen.tsx +41 -0
  243. package/src/shell/VertesiaShell.tsx +27 -0
  244. package/src/shell/index.tsx +6 -0
  245. package/src/shell/login/EnterpriseSigninButton.tsx +106 -0
  246. package/src/shell/login/GitHubSignInButton.tsx +40 -0
  247. package/src/shell/login/GoogleSignInButton.tsx +36 -0
  248. package/src/shell/login/InviteAcceptModal.tsx +78 -0
  249. package/src/shell/login/MicrosoftSigninButton.tsx +30 -0
  250. package/src/shell/login/PreviewIcon.tsx +29 -0
  251. package/src/shell/login/SignInModal.tsx +28 -0
  252. package/src/shell/login/SigninScreen.tsx +162 -0
  253. package/src/shell/login/SignupForm.tsx +178 -0
  254. package/src/shell/login/TerminalLogin.tsx +299 -0
  255. package/src/shell/login/UserInfo.tsx +76 -0
  256. package/src/shell/login/UserSessionMenu.tsx +81 -0
  257. package/src/shell/utils.tsx +7 -0
  258. package/src/widgets/SvgIcon.tsx +44 -0
  259. package/src/widgets/index.ts +7 -6
  260. package/src/widgets/upload/UploadSummary.tsx +3 -4
  261. package/lib/esm/core/components/shadcn/filters/comboBox.js +0 -101
  262. package/lib/esm/core/components/shadcn/filters/comboBox.js.map +0 -1
  263. package/lib/esm/core/components/shadcn/filters/dateFilter.js +0 -36
  264. package/lib/esm/core/components/shadcn/filters/dateFilter.js.map +0 -1
  265. package/lib/esm/core/components/shadcn/filters/selectFilter.js +0 -67
  266. package/lib/esm/core/components/shadcn/filters/selectFilter.js.map +0 -1
  267. package/lib/esm/core/components/shadcn/filters/stringListFilter.js.map +0 -1
  268. package/lib/esm/core/components/shadcn/filters/textFilter.js.map +0 -1
  269. package/lib/esm/features/facets/InteractionFacet.js +0 -39
  270. package/lib/esm/features/facets/InteractionFacet.js.map +0 -1
  271. package/lib/esm/features/facets/TypeOptions.js +0 -19
  272. package/lib/esm/features/facets/TypeOptions.js.map +0 -1
  273. package/lib/esm/features/facets/UserFacet.js +0 -33
  274. package/lib/esm/features/facets/UserFacet.js.map +0 -1
  275. package/lib/types/core/components/shadcn/filters/comboBox.d.ts +0 -22
  276. package/lib/types/features/facets/InteractionFacet.d.ts +0 -9
  277. package/lib/types/features/facets/TypeOptions.d.ts +0 -3
  278. package/lib/types/features/facets/UserFacet.d.ts +0 -11
  279. package/src/core/components/shadcn/filters/dateFilter.tsx +0 -82
  280. package/src/core/components/shadcn/filters/selectFilter.tsx +0 -110
  281. package/src/features/facets/InteractionFacet.tsx +0 -53
  282. package/src/features/facets/TypeOptions.tsx +0 -22
  283. package/src/features/facets/UserFacet.tsx +0 -61
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useRef as n,useEffect as a,createContext as r,useContext as i,useState as s,useMemo as o}from"react";import{useSafeLayoutEffect as h}from"@vertesia/ui/core";function c(t){return"/"===t||""===t}function l(t,e){return e=t.endsWith("/")&&e.startsWith("/")?t+e.substring(1):t.endsWith("/")||e.startsWith("/")?t+e:t+"/"+e}function u(t){if(""===t||"/"===t)return[];let e=0,n=t.length;return t.startsWith("./")?e=2:t.startsWith("/")&&(e=1),t.endsWith("/")&&(n=t.length-1),(e>0||n<t.length?t.substring(e,n):t).split("/")}function d(t){if("string"==typeof t)return u(t);if(Array.isArray(t))return t;throw new Error(`Unsupported path object: ${t}`)}var m=Object.freeze({__proto__:null,getPathSegments:u,isRootPath:c,joinPath:l,toSegments:d});class p{path;params;hash;constructor(t){let e=t.lastIndexOf("#");e>-1?(this.hash=t.substring(e),t=t.substring(0,e)):this.hash="",e=t.indexOf("?"),e>-1?(this.path=t.substring(0,e),this.params=new URLSearchParams(t.substring(e+1))):(this.path=t,this.params=new URLSearchParams)}add(t){for(const[e,n]of Object.entries(t))this.params.set(e,n);return this}toString(){return this.path+"?"+this.params.toString()+this.hash}}const f=Symbol("BASE_PATH");class g{name;type;location;state;_canceled=!1;constructor(t,e,n,a){this.name=t,this.type=e,this.location=n,this.state=a}get isPageLoad(){return"initial"===this.type}get isBackForward(){return"popState"===this.type}get isLinkClick(){return"linkClick"===this.type}get isNavigation(){return"navigate"===this.type}get isCancelable(){return"beforeChange"===this.name}cancel(){if("afterChange"===this.name)throw new Error("Cannot cancel afterChange event");this._canceled=!0}}class w extends g{constructor(t,e,n){super("beforeChange",t,e,n)}}class v extends g{constructor(t,e,n){super("afterChange",t,e,n)}}class P{stickyParams;_popStateListener;_linkNavListener;_listeners=[];constructor(){}addListener(t){this._listeners.push(t)}fireLocationChange(t){for(const e of this._listeners)e(t)}firePageLoad(){this.fireLocationChange(new v("initial",new URL(window.location.href)))}addStickyParams(t){return this.stickyParams?new p(t).add(this.stickyParams).toString():t}navigate(t,e={}){if(e.basePath){let n=e.basePath;n.startsWith("/")||(n="/"+n),t=l(n,t)}t=this.addStickyParams(t),this._navigate(new URL(t,window.location.href),"navigate",e)}_navigate(t,e,n){const a=new w(e,t,n.state);this.fireLocationChange(a),a._canceled||(window.history[n.replace?"replaceState":"pushState"]({from:window.location.href,data:n.state||void 0},"",t.href),this.fireLocationChange(new v(e,t,n.state)))}start(){if("undefined"==typeof window)return;const t=t=>{let e=t.state?"popState":"linkClick";const n=new URL(window.location.href);let a;t.state?(e="popState",a=t.state.data):e="linkClick",this.fireLocationChange(new v(e,n,a))};this._popStateListener=t,this._linkNavListener=t=>{const e=function(t){if(t&&"a"===t.tagName.toLowerCase()){const e=t.href;if(null!=e)return new URL(e)}return null}(t.target);if(e&&e.origin===window.location.origin){t.preventDefault();const n=new URL(this.addStickyParams(e.href)),a=t[f]||t.target[f];a&&(n.pathname=l(a,n.pathname)),this._navigate(n,"linkClick",{})}},window.addEventListener("popstate",t),document.body.addEventListener("click",this._linkNavListener)}stop(){this._popStateListener&&window.removeEventListener("popstate",this._popStateListener),this._linkNavListener&&document.body.removeEventListener("click",this._linkNavListener)}}function b({basePath:e,children:r}){const i=n(null);return a((()=>{if(i.current){const t=i.current,n=t=>{"a"===t.target.tagName.toLowerCase()&&(t[f]=e)};return t.addEventListener("click",n),()=>{t.removeEventListener("click",n)}}}),[i.current]),t("div",{ref:i,className:"h-full w-full",children:r})}class L{tree=new S;loadMapping(t){for(const[e,n]of Object.entries(t))this.addSegments(u(e),n)}addPath(t,e){this.addSegments(u(t),e)}addSegments(t,e){let n=this.tree;for(let a=0,r=t.length;a<r;a++){const i=t[a];if(":"===i[0]){let e=n.wildcard;if(e){if(!(e instanceof y))throw new Error(`Failed to index path segments: ${t.join("/")}. A wildcard ":" segment will overwrite an existing wildcard segment at path: ${"/"+t.slice(0,a).join("/")}`)}else e=new y(i),n.wildcard=e;n=e}else{if("*"===i){if(n.wildcard)throw new Error(`Failed to index path segments: ${t.join("/")}. A wildcard "*" segment already exists at path: ${"/"+t.slice(0,a).join("/")}`);if(n.wildcard=new _(i,e),a<r-1)throw new Error(`Failed to index path segments: ${t.join("/")}. A wildcard segment must be the last segment`);return}{let t=n.children[i];t||(t=new C(i),n.children[i]=t),n=t}}}if(void 0!==n.value)throw new Error(`Failed to index path segments: ${t.join("/")}. A value already exists at path: ${"/"+t.join("/")}`);n.value=e}match(t){const e=d(t);if(0===e.length)return null;const n={};let a,r,i=this.tree;for(const t of e){const e=i.match(t,n);if(!e)return null;i=e}if(!i.value){if(i instanceof k&&i.wildcard instanceof _&&(i=i.wildcard.match("",n),!i.value))throw new Error("Wildcard segment node `*` must have a value");if(!i.value)return null}return n._&&n._.length>0?(a=e.slice(0,-n._.length),r=n._):a=e,{params:n,matchedSegments:a,remainingSegments:r,value:i.value}}}class k{name;value;children={};wildcard;constructor(t,e){this.name=t,this.value=e}match(t,e){let n=this.children[t];if(n)return n;if(this.wildcard){if(this.wildcard instanceof _)return this.wildcard.match(t,e);if(this.wildcard instanceof y)return e[this.wildcard.paramName]=t,this.wildcard;throw new Error("Unknown wildcard segment node type: "+this.wildcard.constructor.name)}return null}}class S extends k{constructor(){super("#root")}}class C extends k{constructor(t,e){super(t,e)}}class y extends k{paramName;constructor(t,e){super(t,e),this.paramName=t.substring(1)}}class _{name;value;constructor(t,e){this.name=t,this.value=e}match(t,e){return e._?t&&e._.push(t):e._=t?[t]:[],this}}class x{index;matcher=new L;constructor(t,e){this.index=e;for(const e of t)this.matcher.addPath(e.path,e)}match(t){const e=c(t)&&this.index;return this.matcher.match(e?this.index:t)}}class R extends x{prompt;observer;navigator=new P;constructor(t,e){super(t),this.navigator.addListener((t=>{if((!(t.isCancelable&&this.prompt&&this.prompt.when)||window.confirm(this.prompt.message))&&(this.observer&&this.observer(t),"afterChange"===t.name)){const n=this.match(t.location.pathname);n&&n.value?e({...n,state:t.state}):e(null)}}))}getTopRouter(){return this}setStickyParams(t){this.navigator.stickyParams=null!=t?t:void 0}withObserver(t){return this.observer=t,this}start(){this.navigator.start(),this.navigator.firePageLoad()}stop(){this.navigator.stop()}navigate(t,e){this.navigator.navigate(t,e)}}class E extends x{parent;basePath;constructor(t,e,n){super(n),this.parent=t,this.basePath=e}getTopRouter(){return this.parent instanceof R?this.parent:this.parent.getTopRouter()}navigate(t,e){let n;if(e?.isBasePathNested??!0){const t=e?.basePath;n=t?l(this.basePath,t):this.basePath}else n=e?.basePath??this.basePath;this.parent.navigate(t,{...e,basePath:n})}}const j=r(void 0);function N(){const t=i(j);if(!t)throw new Error("useRouter must be used within a RouterProvider");return t}function $(){const{navigate:t}=N();return t}function U(t){const{params:e}=N();return t?e[t]:e}function W(){const{location:t}=N();return t}function A(t){const{router:e}=N();a((()=>(e.getTopRouter().prompt=t,()=>{e.getTopRouter().prompt=void 0})),[]),a((()=>{if(t.when){const e=t.when,n=function(t){e&&(t.preventDefault(),t.returnValue="")};return window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}}}),[t.when])}function O({children:e,onClick:n}){const a=$();return t("span",{onClick:t=>{const e=t.target.closest("a");e&&e.href&&(t.stopPropagation(),t.preventDefault(),a(e.href),n?.(t))},children:e})}function T({children:e,href:n,className:a,topLevelNav:r}){const{router:i}=N();return t("a",{href:n,className:a,onClick:t=>{t.stopPropagation(),t.preventDefault();(r?i.getTopRouter():i).navigate(n)},children:e})}function z({spinner:e}){const n=N(),a=n.route;if(a.Component){const e=a.Component;return t(e,{...n.params})}if(a.LazyComponent)return t(F,{route:a,spinner:e});throw new Error(`Invalid route for ${a.path}. Either Component or LazyCOmponent must be specified.`)}function F({route:e,spinner:n}){const[r,i]=s(null);return a((()=>{e.LazyComponent().then((t=>{if(!t.default)throw new Error(`Lazy module for ${e.path} does not have a default export`);i((()=>t.default))}))}),[e]),r?t(r,{}):n||null}function D({basePath:e,fixLinks:n=!1,children:a}){const r=N(),i=n?e=>t(b,{basePath:r.matchedRoutePath,children:e}):t=>t;return t(j.Provider,{value:{...r,navigate:(t,n)=>{const a=n?.basePath?l(e,n.basePath):e;return r.navigate(t,{...n,basePath:a})}},children:i(a||t(z,{}))})}function B(){const t=N();return e("div",{children:["Route not found for path ",t.matchedRoutePath]})}function I(){return{params:{},matchedSegments:[],state:null,value:{path:"virtual:404",Component:()=>t(B,{})}}}function H({routes:e,index:n,children:r,fixLinks:i=!1}){const h=N(),[c,l]=s(void 0),u=o((()=>{if("undefined"==typeof window)return null;const t=h.matchedRoutePath,a=new E(h.router,t,e);return a.index=n,a}),[]);a((()=>{if(u){if(h.matchedRoutePath!==u.basePath)return;const t=u.match(h.remainingPath||"/")||I();l(t)}}),[u,h.remainingPath]);const d=i?e=>t(b,{basePath:h.matchedRoutePath,children:e}):t=>t;return c&&t(j.Provider,{value:{...h,router:u,route:c.value,params:c.params,matchedRoutePath:"/"+c.matchedSegments.join("/"),remainingPath:c.remainingSegments?"/"+c.remainingSegments.join("/"):void 0,navigate:(t,e)=>u.navigate(t,e)},children:d(r||t(z,{}))})}function M({routes:e,index:n,onChange:a,children:r}){const[i,c]=s(void 0),l=o((()=>{if("undefined"==typeof window)return null;const t=new R(e,(e=>{null===e&&(e=I()),c({location:window.location,route:e.value,params:e.params,state:e.state,router:t,matchedRoutePath:"/"+e.matchedSegments.join("/"),remainingPath:e.remainingSegments?"/"+e.remainingSegments.join("/"):void 0,navigate:(e,n)=>t.navigate(e,n)})})).withObserver(a);return t.index=n,t}),[]);return h((()=>(l&&l.start(),()=>{l&&l.stop()})),[]),i&&t(j.Provider,{value:i,children:r||t(z,{})})}export{v as AfterLocationChangeEvent,f as BASE_PATH,x as BaseRouter,w as BeforeLocationChangeEvent,b as FixLinks,P as HistoryNavigator,g as LocationChangeEvent,O as Nav,T as NavLink,D as NestedNavigationContext,E as NestedRouter,H as NestedRouterProvider,m as Path,L as PathMatcher,j as ReactRouterContext,z as RouteComponent,R as Router,M as RouterProvider,W as useLocation,$ as useNavigate,A as useNavigationPrompt,U as useParams,N as useRouterContext};
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useRef as n,useEffect as a,createContext as r,useContext as i,useState as s,useMemo as o}from"react";import{useSafeLayoutEffect as h}from"@vertesia/ui/core";function c(t){return"/"===t||""===t}function l(t,e){return e=t.endsWith("/")&&e.startsWith("/")?t+e.substring(1):t.endsWith("/")||e.startsWith("/")?t+e:t+"/"+e}function u(t){if(""===t||"/"===t)return[];let e=0,n=t.length;return t.startsWith("./")?e=2:t.startsWith("/")&&(e=1),t.endsWith("/")&&(n=t.length-1),(e>0||n<t.length?t.substring(e,n):t).split("/")}function d(t){if("string"==typeof t)return u(t);if(Array.isArray(t))return t;throw new Error(`Unsupported path object: ${t}`)}var m=Object.freeze({__proto__:null,getPathSegments:u,isRootPath:c,joinPath:l,toSegments:d});class p{path;params;hash;constructor(t){let e=t.lastIndexOf("#");e>-1?(this.hash=t.substring(e),t=t.substring(0,e)):this.hash="",e=t.indexOf("?"),e>-1?(this.path=t.substring(0,e),this.params=new URLSearchParams(t.substring(e+1))):(this.path=t,this.params=new URLSearchParams)}add(t){for(const[e,n]of Object.entries(t))this.params.set(e,n);return this}toString(){return this.path+"?"+this.params.toString()+this.hash}}const f=Symbol("BASE_PATH");class g{name;type;location;state;_canceled=!1;constructor(t,e,n,a){this.name=t,this.type=e,this.location=n,this.state=a}get isPageLoad(){return"initial"===this.type}get isBackForward(){return"popState"===this.type}get isLinkClick(){return"linkClick"===this.type}get isNavigation(){return"navigate"===this.type}get isCancelable(){return"beforeChange"===this.name}cancel(){if("afterChange"===this.name)throw new Error("Cannot cancel afterChange event");this._canceled=!0}}class w extends g{constructor(t,e,n){super("beforeChange",t,e,n)}}class v extends g{constructor(t,e,n){super("afterChange",t,e,n)}}class P{stickyParams;_popStateListener;_linkNavListener;_listeners=[];constructor(){}addListener(t){this._listeners.push(t)}fireLocationChange(t){for(const e of this._listeners)e(t)}firePageLoad(){this.fireLocationChange(new v("initial",new URL(window.location.href)))}addStickyParams(t){return this.stickyParams?new p(t).add(this.stickyParams).toString():t}navigate(t,e={}){if(e.basePath){let n=e.basePath;n.startsWith("/")||(n="/"+n),t=l(n,t)}t=this.addStickyParams(t),this._navigate(new URL(t,window.location.href),"navigate",e)}_navigate(t,e,n){const a=new w(e,t,n.state);this.fireLocationChange(a),a._canceled||(window.history[n.replace?"replaceState":"pushState"]({from:window.location.href,data:n.state||void 0},"",t.href),this.fireLocationChange(new v(e,t,n.state)))}start(){if("undefined"==typeof window)return;const t=t=>{let e=t.state?"popState":"linkClick";const n=new URL(window.location.href);let a;t.state?(e="popState",a=t.state.data):e="linkClick",this.fireLocationChange(new v(e,n,a))};this._popStateListener=t,this._linkNavListener=t=>{const e=function(t){if(t&&"a"===t.tagName.toLowerCase()){const e=t?.href.trim();if("string"==typeof e&&e.length>0)return new URL(e)}return null}(t.target);if(e&&e.origin===window.location.origin){t.preventDefault();const n=new URL(this.addStickyParams(e.href)),a=t[f]||t.target[f];a&&(n.pathname=l(a,n.pathname)),this._navigate(n,"linkClick",{})}},window.addEventListener("popstate",t),document.body.addEventListener("click",this._linkNavListener)}stop(){this._popStateListener&&window.removeEventListener("popstate",this._popStateListener),this._linkNavListener&&document.body.removeEventListener("click",this._linkNavListener)}}function b({basePath:e,children:r}){const i=n(null);return a((()=>{if(i.current){const t=i.current,n=t=>{"a"===t.target.tagName.toLowerCase()&&(t[f]=e)};return t.addEventListener("click",n),()=>{t.removeEventListener("click",n)}}}),[i.current]),t("div",{ref:i,className:"h-full w-full",children:r})}class L{tree=new S;loadMapping(t){for(const[e,n]of Object.entries(t))this.addSegments(u(e),n)}addPath(t,e){this.addSegments(u(t),e)}addSegments(t,e){let n=this.tree;for(let a=0,r=t.length;a<r;a++){const i=t[a];if(":"===i[0]){let e=n.wildcard;if(e){if(!(e instanceof C))throw new Error(`Failed to index path segments: ${t.join("/")}. A wildcard ":" segment will overwrite an existing wildcard segment at path: ${"/"+t.slice(0,a).join("/")}`)}else e=new C(i),n.wildcard=e;n=e}else{if("*"===i){if(n.wildcard)throw new Error(`Failed to index path segments: ${t.join("/")}. A wildcard "*" segment already exists at path: ${"/"+t.slice(0,a).join("/")}`);if(n.wildcard=new _(i,e),a<r-1)throw new Error(`Failed to index path segments: ${t.join("/")}. A wildcard segment must be the last segment`);return}{let t=n.children[i];t||(t=new y(i),n.children[i]=t),n=t}}}if(void 0!==n.value)throw new Error(`Failed to index path segments: ${t.join("/")}. A value already exists at path: ${"/"+t.join("/")}`);n.value=e}match(t){const e=d(t);if(0===e.length)return null;const n={};let a,r,i=this.tree;for(const t of e){const e=i.match(t,n);if(!e)return null;i=e}if(!i.value){if(i instanceof k&&i.wildcard instanceof _&&(i=i.wildcard.match("",n),!i.value))throw new Error("Wildcard segment node `*` must have a value");if(!i.value)return null}return n._&&n._.length>0?(a=e.slice(0,-n._.length),r=n._):a=e,{params:n,matchedSegments:a,remainingSegments:r,value:i.value}}}class k{name;value;children={};wildcard;constructor(t,e){this.name=t,this.value=e}match(t,e){let n=this.children[t];if(n)return n;if(this.wildcard){if(this.wildcard instanceof _)return this.wildcard.match(t,e);if(this.wildcard instanceof C)return e[this.wildcard.paramName]=t,this.wildcard;throw new Error("Unknown wildcard segment node type: "+this.wildcard.constructor.name)}return null}}class S extends k{constructor(){super("#root")}}class y extends k{constructor(t,e){super(t,e)}}class C extends k{paramName;constructor(t,e){super(t,e),this.paramName=t.substring(1)}}class _{name;value;constructor(t,e){this.name=t,this.value=e}match(t,e){return e._?t&&e._.push(t):e._=t?[t]:[],this}}class x{index;matcher=new L;constructor(t,e){this.index=e;for(const e of t)this.matcher.addPath(e.path,e)}match(t){const e=c(t)&&this.index;return this.matcher.match(e?this.index:t)}}class R extends x{prompt;observer;navigator=new P;constructor(t,e){super(t),this.navigator.addListener((t=>{if((!(t.isCancelable&&this.prompt&&this.prompt.when)||window.confirm(this.prompt.message))&&(this.observer&&this.observer(t),"afterChange"===t.name)){const n=this.match(t.location.pathname);n&&n.value?e({...n,state:t.state}):e(null)}}))}getTopRouter(){return this}setStickyParams(t){this.navigator.stickyParams=null!=t?t:void 0}withObserver(t){return this.observer=t,this}start(){this.navigator.start(),this.navigator.firePageLoad()}stop(){this.navigator.stop()}navigate(t,e){this.navigator.navigate(t,e)}}class E extends x{parent;basePath;constructor(t,e,n){super(n),this.parent=t,this.basePath=e}getTopRouter(){return this.parent instanceof R?this.parent:this.parent.getTopRouter()}navigate(t,e){let n;if(e?.isBasePathNested??!0){const t=e?.basePath;n=t?l(this.basePath,t):this.basePath}else n=e?.basePath??this.basePath;this.parent.navigate(t,{...e,basePath:n})}}const j=r(void 0);function N(){const t=i(j);if(!t)throw new Error("useRouter must be used within a RouterProvider");return t}function $(){const{navigate:t}=N();return t}function U(t){const{params:e}=N();return t?e[t]:e}function W(){const{location:t}=N();return t}function A(t){const{router:e}=N();a((()=>(e.getTopRouter().prompt=t,()=>{e.getTopRouter().prompt=void 0})),[]),a((()=>{if(t.when){const e=t.when,n=function(t){e&&(t.preventDefault(),t.returnValue="")};return window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}}}),[t.when])}function O({children:e,onClick:n}){const a=$();return t("span",{onClick:t=>{const e=t.target.closest("a");e&&e.href&&(t.stopPropagation(),t.preventDefault(),a(e.href),n?.(t))},children:e})}function T({children:e,href:n,className:a,topLevelNav:r}){const{router:i}=N();return t("a",{href:n,className:a,onClick:t=>{t.stopPropagation(),t.preventDefault();(r?i.getTopRouter():i).navigate(n)},children:e})}function z({spinner:e}){const n=N(),a=n.route;if(a.Component){const e=a.Component;return t(e,{...n.params})}if(a.LazyComponent)return t(F,{route:a,spinner:e});throw new Error(`Invalid route for ${a.path}. Either Component or LazyCOmponent must be specified.`)}function F({route:e,spinner:n}){const[r,i]=s(null);return a((()=>{e.LazyComponent().then((t=>{if(!t.default)throw new Error(`Lazy module for ${e.path} does not have a default export`);i((()=>t.default))}))}),[e]),r?t(r,{}):n||null}function D({basePath:e,fixLinks:n=!1,children:a}){const r=N(),i=n?e=>t(b,{basePath:r.matchedRoutePath,children:e}):t=>t;return t(j.Provider,{value:{...r,navigate:(t,n)=>{const a=n?.basePath?l(e,n.basePath):e;return r.navigate(t,{...n,basePath:a})}},children:i(a||t(z,{}))})}function B(){const t=N();return e("div",{children:["Route not found for path ",t.matchedRoutePath]})}function I(){return{params:{},matchedSegments:[],state:null,value:{path:"virtual:404",Component:()=>t(B,{})}}}function H({routes:e,index:n,children:r,fixLinks:i=!1}){const h=N(),[c,l]=s(void 0),u=o((()=>{if("undefined"==typeof window)return null;const t=h.matchedRoutePath,a=new E(h.router,t,e);return a.index=n,a}),[]);a((()=>{if(u){if(h.matchedRoutePath!==u.basePath)return;const t=u.match(h.remainingPath||"/")||I();l(t)}}),[u,h.remainingPath]);const d=i?e=>t(b,{basePath:h.matchedRoutePath,children:e}):t=>t;return c&&t(j.Provider,{value:{...h,router:u,route:c.value,params:c.params,matchedRoutePath:"/"+c.matchedSegments.join("/"),remainingPath:c.remainingSegments?"/"+c.remainingSegments.join("/"):void 0,navigate:(t,e)=>u.navigate(t,e)},children:d(r||t(z,{}))})}function M({routes:e,index:n,onChange:a,children:r}){const[i,c]=s(void 0),l=o((()=>{if("undefined"==typeof window)return null;const t=new R(e,(e=>{null===e&&(e=I()),c({location:window.location,route:e.value,params:e.params,state:e.state,router:t,matchedRoutePath:"/"+e.matchedSegments.join("/"),remainingPath:e.remainingSegments?"/"+e.remainingSegments.join("/"):void 0,navigate:(e,n)=>t.navigate(e,n)})})).withObserver(a);return t.index=n,t}),[]);return h((()=>(l&&l.start(),()=>{l&&l.stop()})),[]),i&&t(j.Provider,{value:i,children:r||t(z,{})})}export{v as AfterLocationChangeEvent,f as BASE_PATH,x as BaseRouter,w as BeforeLocationChangeEvent,b as FixLinks,P as HistoryNavigator,g as LocationChangeEvent,O as Nav,T as NavLink,D as NestedNavigationContext,E as NestedRouter,H as NestedRouterProvider,m as Path,L as PathMatcher,j as ReactRouterContext,z as RouteComponent,R as Router,M as RouterProvider,W as useLocation,$ as useNavigate,A as useNavigationPrompt,U as useParams,N as useRouterContext};
2
2
  //# sourceMappingURL=vertesia-ui-router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vertesia-ui-router.js","sources":["esm/router/path.js","esm/router/PathWithParams.js","esm/router/HistoryNavigator.js","esm/router/FixLinks.js","esm/router/PathMatcher.js","esm/router/Router.js","esm/router/Nav.js","esm/router/RouteComponent.js","esm/router/NestedNavigationContext.js","esm/router/Route404.js","esm/router/NestedRouterProvider.js","esm/router/RouterProvider.js"],"sourcesContent":["export function isRootPath(path) {\n return path === '/' || path === '';\n}\nexport function joinPath(path1, path2) {\n if (path1.endsWith('/') && path2.startsWith('/')) {\n path2 = path1 + path2.substring(1);\n }\n else if (path1.endsWith('/')) {\n path2 = path1 + path2;\n }\n else if (path2.startsWith('/')) {\n path2 = path1 + path2;\n }\n else {\n path2 = path1 + '/' + path2;\n }\n return path2;\n}\nexport function getPathSegments(path) {\n if (path === '' || path === '/') {\n return [];\n }\n let s = 0, e = path.length;\n if (path.startsWith('./')) {\n s = 2;\n }\n else if (path.startsWith('/')) {\n s = 1;\n }\n if (path.endsWith('/')) {\n e = path.length - 1;\n }\n return (s > 0 || e < path.length ? path.substring(s, e) : path).split('/');\n}\nexport function toSegments(path) {\n if (typeof path === 'string') {\n return getPathSegments(path);\n }\n else if (Array.isArray(path)) {\n return path;\n }\n else {\n throw new Error(`Unsupported path object: ${path}`);\n }\n}\n// export class Path {\n// static parse(path: string, abs = false) {\n// if (abs !== undefined) {\n// abs = path.startsWith('/');\n// }\n// return new Path(getPathSegments(path), abs);\n// }\n// constructor(public segments: string[], public isAbsolute = false) {\n// }\n// getParameters() {\n// const out = [];\n// for (const segment of this.segments) {\n// if (segment[0] === ':') {\n// out.push(segment.substring(1));\n// }\n// }\n// if (this.segments[this.segments.length - 1] === '*') {\n// out.push('_');\n// }\n// return out;\n// }\n// resolveParameters(path: string) {\n// const params: PathMatchParams = {};\n// const resolvedSegments = getPathSegments(path);\n// if (resolvedSegments.length < this.segments.length) {\n// return null;\n// }\n// const segments = this.segments;\n// for (let i = 0, l = segments.length; i < l; i++) {\n// const seg = segments[i];\n// if (seg[0] === ':') {\n// params[seg.substring(1)] = resolvedSegments[i];\n// }\n// }\n// if (resolvedSegments.length - this.segments.length) {\n// params._ = resolvedSegments.slice(this.segments.length);\n// }\n// return params;\n// }\n// match(path: string | string[] | Path) {\n// const segments = toSegments(path);\n// if (segments.length < this.segments.length) {\n// return false;\n// }\n// let params: PathMatchParams | undefined;\n// const mySegments = this.segments;\n// for (let i = 0, l = mySegments.length; i < l; i++) {\n// const segment = mySegments[i];\n// if (segment === ':') {\n// if (!params) params = {};\n// params[segment.substring(1)] = segment;\n// } else if (segment !== segments[i]) {\n// if (i === l - 1 && segment === '*') {\n// if (!params) params = {};\n// params._ = segments.slice(i);\n// return params;\n// }\n// return false;\n// }\n// }\n// return params ? params : false;\n// }\n// join(path: Path | string | string[]) {\n// const segments = toSegments(path);\n// return new Path(this.segments.concat(segments), this.isAbsolute);\n// }\n// getRelativePath(path: Path | string | string[], asAbsolute: boolean = false) {\n// const segments = toSegments(path);\n// const extraSegmentsCount = segments.length - this.segments.length;\n// if (extraSegmentsCount <= 0) {\n// return null;\n// }\n// return new Path(segments.slice(this.segments.length), asAbsolute);\n// }\n// prependSegments(segments: string[]) {\n// this.segments = segments.concat(this.segments);\n// }\n// appendSegments(segments: string[]) {\n// this.segments = this.segments.concat(segments);\n// }\n// toAbsolutePath() {\n// return '/' + this.segments.join('/');\n// }\n// toRelativePath() {\n// return this.segments.join('/');\n// }\n// toString() {\n// const path = this.segments.join('/');\n// return this.isAbsolute ? '/' + path : path;\n// }\n// }\n//# sourceMappingURL=path.js.map","export class PathWithParams {\n path;\n params;\n hash;\n constructor(path) {\n let i = path.lastIndexOf('#');\n if (i > -1) {\n this.hash = path.substring(i);\n path = path.substring(0, i);\n }\n else {\n this.hash = '';\n }\n i = path.indexOf('?');\n if (i > -1) {\n this.path = path.substring(0, i);\n this.params = new URLSearchParams(path.substring(i + 1));\n }\n else {\n this.path = path;\n this.params = new URLSearchParams();\n }\n }\n add(params) {\n for (const [key, value] of Object.entries(params)) {\n this.params.set(key, value);\n }\n return this;\n }\n toString() {\n return this.path + '?' + this.params.toString() + this.hash;\n }\n}\n//# sourceMappingURL=PathWithParams.js.map","import { joinPath } from \"./path\";\nimport { PathWithParams } from \"./PathWithParams\";\nconst BASE_PATH = Symbol('BASE_PATH');\nexport { BASE_PATH };\nexport class LocationChangeEvent {\n name;\n type;\n location;\n state;\n _canceled = false;\n constructor(name, type, location, state) {\n this.name = name;\n this.type = type;\n this.location = location;\n this.state = state;\n }\n get isPageLoad() {\n return this.type === 'initial';\n }\n get isBackForward() {\n return this.type === 'popState';\n }\n get isLinkClick() {\n return this.type === 'linkClick';\n }\n get isNavigation() {\n return this.type === 'navigate';\n }\n get isCancelable() {\n return this.name === 'beforeChange';\n }\n cancel() {\n if (this.name === 'afterChange') {\n throw new Error('Cannot cancel afterChange event');\n }\n this._canceled = true;\n }\n}\nexport class BeforeLocationChangeEvent extends LocationChangeEvent {\n constructor(type, location, state) {\n super('beforeChange', type, location, state);\n }\n}\nexport class AfterLocationChangeEvent extends LocationChangeEvent {\n constructor(type, location, state) {\n super('afterChange', type, location, state);\n }\n}\nfunction getElementHrefAsUrl(elem) {\n if (elem && elem.tagName.toLowerCase() === 'a') {\n const href = elem.href;\n if (href != null) {\n return new URL(href);\n }\n }\n return null;\n}\nexport class HistoryNavigator {\n // params to preserve in the query string when navigating\n stickyParams;\n _popStateListener;\n _linkNavListener;\n _listeners = [];\n constructor() {\n }\n addListener(listener) {\n this._listeners.push(listener);\n }\n fireLocationChange(event) {\n for (const listener of this._listeners) {\n listener(event);\n }\n }\n /**\n * Should be called when the page is first loaded.\n * It will fire a location change event with type `initial` and the current window.location as the location\n */\n firePageLoad() {\n this.fireLocationChange(new AfterLocationChangeEvent('initial', new URL(window.location.href)));\n }\n addStickyParams(path) {\n if (this.stickyParams) {\n return new PathWithParams(path).add(this.stickyParams).toString();\n }\n return path;\n }\n navigate(to, options = {}) {\n if (options.basePath) {\n let basePath = options.basePath;\n if (!basePath.startsWith('/')) {\n basePath = '/' + basePath;\n }\n to = joinPath(basePath, to);\n }\n to = this.addStickyParams(to);\n this._navigate(new URL(to, window.location.href), 'navigate', options);\n }\n _navigate(to, type, options) {\n const beforeEvent = new BeforeLocationChangeEvent(type, to, options.state);\n this.fireLocationChange(beforeEvent);\n if (beforeEvent._canceled) {\n return;\n }\n window.history[options.replace ? 'replaceState' : 'pushState']({\n from: window.location.href,\n data: options.state || undefined\n }, '', to.href);\n this.fireLocationChange(new AfterLocationChangeEvent(type, to, options.state));\n }\n start() {\n if (typeof window === \"undefined\") {\n return;\n }\n const _popStateListener = (ev) => {\n let type = ev.state ? 'popState' : 'linkClick';\n const to = new URL(window.location.href);\n let state = undefined;\n if (ev.state) {\n type = 'popState';\n state = ev.state.data;\n }\n else {\n type = 'linkClick';\n }\n this.fireLocationChange(new AfterLocationChangeEvent(type, to, state));\n };\n const _linkNavListener = (ev) => {\n const url = getElementHrefAsUrl(ev.target);\n if (url && url.origin === window.location.origin) {\n ev.preventDefault();\n const to = new URL(this.addStickyParams(url.href));\n const basePath = ev[BASE_PATH] || ev.target[BASE_PATH];\n if (basePath) {\n to.pathname = joinPath(basePath, to.pathname);\n }\n this._navigate(to, 'linkClick', {});\n }\n };\n this._popStateListener = _popStateListener;\n this._linkNavListener = _linkNavListener;\n window.addEventListener('popstate', _popStateListener);\n document.body.addEventListener('click', this._linkNavListener);\n }\n stop() {\n this._popStateListener && window.removeEventListener('popstate', this._popStateListener);\n this._linkNavListener && document.body.removeEventListener('click', this._linkNavListener);\n }\n}\n//# sourceMappingURL=HistoryNavigator.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useRef } from \"react\";\nimport { BASE_PATH } from \"./HistoryNavigator\";\nexport function FixLinks({ basePath, children }) {\n const ref = useRef(null);\n useEffect(() => {\n if (ref.current) {\n const divElem = ref.current;\n const listener = (ev) => {\n const elem = ev.target;\n if (elem.tagName.toLowerCase() === 'a') {\n ev[BASE_PATH] = basePath;\n }\n };\n divElem.addEventListener('click', listener);\n return () => {\n divElem.removeEventListener('click', listener);\n };\n }\n }, [ref.current]);\n return (_jsx(\"div\", { ref: ref, className: \"h-full w-full\", children: children }));\n}\n//# sourceMappingURL=FixLinks.js.map","import { getPathSegments, toSegments } from \"./path\";\n/**\n * Path matcher which support :param and *wildcard segments.\n * The wildcard segment is only supported as the last segment\n */\nexport class PathMatcher {\n tree = new RootSegmentNode();\n loadMapping(mapping) {\n for (const [key, value] of Object.entries(mapping)) {\n this.addSegments(getPathSegments(key), value);\n }\n }\n addPath(path, value) {\n this.addSegments(getPathSegments(path), value);\n }\n addSegments(segments, value) {\n let node = this.tree;\n for (let i = 0, l = segments.length; i < l; i++) {\n const segment = segments[i];\n if (segment[0] === ':') {\n let childNode = node.wildcard;\n if (!childNode) {\n childNode = new VariableSegmentNode(segment);\n node.wildcard = childNode;\n }\n else if (!(childNode instanceof VariableSegmentNode)) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A wildcard \":\" segment will overwrite an existing wildcard segment at path: ${'/' + segments.slice(0, i).join(\"/\")}`);\n }\n node = childNode;\n }\n else if (segment === '*') {\n if (node.wildcard) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A wildcard \"*\" segment already exists at path: ${'/' + segments.slice(0, i).join(\"/\")}`);\n }\n node.wildcard = new WildcardSegmentNode(segment, value);\n if (i < l - 1) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A wildcard segment must be the last segment`);\n }\n return;\n }\n else {\n let childNode = node.children[segment];\n if (!childNode) {\n childNode = new LiteralSegmentNode(segment);\n node.children[segment] = childNode;\n } // else // a literal segment already exists\n node = childNode;\n }\n }\n if (node.value !== undefined) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A value already exists at path: ${'/' + segments.join(\"/\")}`);\n }\n node.value = value;\n }\n match(path) {\n const segments = toSegments(path);\n if (segments.length === 0) {\n return null;\n }\n const params = {};\n let node = this.tree;\n for (const segment of segments) {\n const match = node.match(segment, params);\n if (match) {\n node = match;\n }\n else {\n return null;\n }\n }\n if (!node.value) { // not a leaf node (partial match)\n if (node instanceof ParentSegmentNode) {\n if (node.wildcard instanceof WildcardSegmentNode) {\n node = node.wildcard.match('', params);\n if (!node.value) {\n throw new Error(\"Wildcard segment node `*` must have a value\");\n }\n }\n }\n if (!node.value)\n return null; // not a leaf node, neither a trailing wildcard (partial match)\n }\n let matchedSegments, remainingSegments;\n if (params._ && params._.length > 0) {\n matchedSegments = segments.slice(0, -params._.length);\n remainingSegments = params._;\n }\n else {\n matchedSegments = segments;\n }\n return { params, matchedSegments, remainingSegments, value: node.value };\n }\n}\nclass ParentSegmentNode {\n name;\n value;\n children = {};\n wildcard;\n constructor(name, value) {\n this.name = name;\n this.value = value;\n }\n match(segment, params) {\n let node = this.children[segment];\n if (node) {\n return node;\n }\n else if (this.wildcard) {\n if (this.wildcard instanceof WildcardSegmentNode) {\n return this.wildcard.match(segment, params);\n }\n else if (this.wildcard instanceof VariableSegmentNode) {\n params[this.wildcard.paramName] = segment;\n return this.wildcard;\n }\n else {\n throw new Error(\"Unknown wildcard segment node type: \" + this.wildcard.constructor.name);\n }\n }\n else {\n return null;\n }\n }\n}\nclass RootSegmentNode extends ParentSegmentNode {\n constructor() {\n super(\"#root\");\n }\n}\nclass LiteralSegmentNode extends ParentSegmentNode {\n constructor(name, value) {\n super(name, value);\n }\n}\nclass VariableSegmentNode extends ParentSegmentNode {\n paramName;\n constructor(name, value) {\n super(name, value);\n this.paramName = name.substring(1);\n }\n}\nclass WildcardSegmentNode {\n name;\n value;\n constructor(name, value) {\n this.name = name;\n this.value = value;\n }\n match(segment, params) {\n if (!params._) {\n params._ = segment ? [segment] : [];\n }\n else {\n segment && params._.push(segment);\n }\n return this;\n }\n}\n//# sourceMappingURL=PathMatcher.js.map","import { createContext, useContext, useEffect } from \"react\";\nimport { HistoryNavigator } from \"./HistoryNavigator\";\nimport { PathMatcher } from \"./PathMatcher\";\nimport { isRootPath, joinPath } from \"./path\";\nexport class BaseRouter {\n // the path to use when navigating to the root of the router\n index;\n matcher = new PathMatcher();\n constructor(routes, index) {\n this.index = index;\n for (const route of routes) {\n this.matcher.addPath(route.path, route);\n }\n }\n match(path) {\n const useIndex = isRootPath(path) && this.index;\n return this.matcher.match(useIndex ? this.index : path);\n }\n}\nexport class Router extends BaseRouter {\n prompt;\n observer;\n navigator = new HistoryNavigator();\n constructor(routes, updateState) {\n super(routes);\n this.navigator.addListener((event) => {\n if (event.isCancelable && this.prompt && !!this.prompt.when) {\n if (!window.confirm(this.prompt.message))\n return;\n }\n if (this.observer) {\n this.observer(event);\n }\n // only process afterChange events\n if (event.name === \"afterChange\") {\n const match = this.match(event.location.pathname);\n if (match && match.value) {\n updateState({\n ...match,\n state: event.state,\n });\n }\n else {\n updateState(null);\n }\n }\n });\n }\n getTopRouter() {\n return this;\n }\n /**\n * Subsequent navigations will preserve the given params in the query string.\n * Use null to clear the sticky params.\n * @param params\n */\n setStickyParams(params) {\n this.navigator.stickyParams = params != null ? params : undefined;\n }\n withObserver(observer) {\n this.observer = observer;\n return this;\n }\n start() {\n this.navigator.start();\n // initialize with the current location\n this.navigator.firePageLoad();\n }\n stop() {\n this.navigator.stop();\n }\n navigate(path, options) {\n this.navigator.navigate(path, options);\n }\n}\nexport class NestedRouter extends BaseRouter {\n parent;\n basePath;\n constructor(parent, basePath, routes) {\n super(routes);\n this.parent = parent;\n this.basePath = basePath;\n }\n getTopRouter() {\n if (this.parent instanceof Router) {\n return this.parent;\n }\n else {\n return this.parent.getTopRouter();\n }\n }\n navigate(path, options) {\n // base path is nested by default in a NestedRouter unless explicitly set to false by caller\n const isBasePathNested = options?.isBasePathNested ?? true;\n let basePath;\n if (isBasePathNested) {\n const childBasePath = options?.basePath;\n // e.g. \"/store\" + \"/objects/123\" => \"/store/objects/123\"\n basePath = childBasePath ? joinPath(this.basePath, childBasePath) : this.basePath;\n }\n else {\n // e.g. \"/store\" + \"/studio\" => \"/studio\"\n basePath = options?.basePath ?? this.basePath;\n }\n this.parent.navigate(path, {\n ...options,\n basePath,\n });\n }\n}\nconst ReactRouterContext = createContext(undefined);\nexport { ReactRouterContext };\nexport function useRouterContext() {\n const ctx = useContext(ReactRouterContext);\n if (!ctx) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n return ctx;\n}\nexport function useNavigate() {\n const { navigate } = useRouterContext();\n return navigate;\n}\nexport function useParams(arg) {\n const { params } = useRouterContext();\n if (arg) {\n return params[arg];\n }\n else {\n return params;\n }\n}\nexport function useLocation() {\n const { location } = useRouterContext();\n return location;\n}\nexport function useNavigationPrompt(prompt) {\n const { router } = useRouterContext();\n useEffect(() => {\n router.getTopRouter().prompt = prompt;\n return () => {\n router.getTopRouter().prompt = undefined;\n };\n }, []);\n useEffect(() => {\n if (prompt.when) {\n const doBlock = prompt.when;\n const listener = function (ev) {\n if (doBlock) {\n ev.preventDefault();\n ev.returnValue = \"\";\n }\n };\n window.addEventListener(\"beforeunload\", listener);\n return () => {\n window.removeEventListener(\"beforeunload\", listener);\n };\n }\n }, [prompt.when]);\n}\n//# sourceMappingURL=Router.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useNavigate, useRouterContext } from \"./Router\";\nexport function Nav({ children, onClick }) {\n const navigate = useNavigate();\n const _onClick = (ev) => {\n const link = ev.target.closest('a');\n if (link && link.href) {\n ev.stopPropagation();\n ev.preventDefault();\n navigate(link.href);\n onClick?.(ev);\n }\n };\n return (_jsx(\"span\", { onClick: _onClick, children: children }));\n}\nexport function NavLink({ children, href, className, topLevelNav }) {\n const { router } = useRouterContext();\n const _onClick = (ev) => {\n ev.stopPropagation();\n ev.preventDefault();\n const actualRouter = topLevelNav ? router.getTopRouter() : router;\n actualRouter.navigate(href);\n };\n return (_jsx(\"a\", { href: href, className: className, onClick: _onClick, children: children }));\n}\n//# sourceMappingURL=Nav.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useState } from \"react\";\nimport { useRouterContext } from \"./Router\";\nexport function RouteComponent({ spinner }) {\n const ctx = useRouterContext();\n const route = ctx.route;\n if (route.Component) {\n const Component = route.Component;\n return _jsx(Component, { ...ctx.params });\n }\n else if (route.LazyComponent) {\n return _jsx(LazyRouteComponent, { route: route, spinner: spinner });\n }\n else {\n throw new Error(`Invalid route for ${route.path}. Either Component or LazyCOmponent must be specified.`);\n }\n}\nfunction LazyRouteComponent({ route, spinner }) {\n const [Component, setComponent] = useState(null);\n useEffect(() => {\n route.LazyComponent().then(module => {\n if (!module.default) {\n throw new Error(`Lazy module for ${route.path} does not have a default export`);\n }\n // we need to wrap the component type in an arrow function\n // otherwise the setState function will execute the function as a state update function\n setComponent(() => module.default);\n });\n }, [route]);\n return Component ? (_jsx(Component, {})) : spinner || null;\n}\n//# sourceMappingURL=RouteComponent.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { FixLinks } from \"./FixLinks\";\nimport { RouteComponent } from \"./RouteComponent\";\nimport { ReactRouterContext, useRouterContext } from \"./Router\";\nimport { joinPath } from \"./path\";\nexport function NestedNavigationContext({ basePath, fixLinks = false, children }) {\n const ctx = useRouterContext();\n const wrapWithFixLinks = fixLinks ?\n (elem) => _jsx(FixLinks, { basePath: ctx.matchedRoutePath, children: elem })\n : (elem) => elem;\n return (_jsx(ReactRouterContext.Provider, { value: {\n ...ctx,\n navigate: (to, options) => {\n const actualBasePath = options?.basePath ? joinPath(basePath, options.basePath) : basePath;\n return ctx.navigate(to, { ...options, basePath: actualBasePath });\n }\n }, children: wrapWithFixLinks(children ? children : _jsx(RouteComponent, {})) }));\n}\n//# sourceMappingURL=NestedNavigationContext.js.map","import { jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nimport { useRouterContext } from \"./Router\";\nexport function Route404Component() {\n const ctx = useRouterContext();\n return _jsxs(\"div\", { children: [\"Route not found for path \", ctx.matchedRoutePath] });\n}\nexport function createRoute404() {\n return {\n params: {},\n matchedSegments: [],\n state: null,\n value: {\n path: 'virtual:404',\n Component: () => _jsx(Route404Component, {})\n }\n };\n}\n//# sourceMappingURL=Route404.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { FixLinks } from \"./FixLinks\";\nimport { createRoute404 } from \"./Route404\";\nimport { RouteComponent } from \"./RouteComponent\";\nimport { NestedRouter, ReactRouterContext, useRouterContext } from \"./Router\";\nexport function NestedRouterProvider({ routes, index, children, fixLinks = false }) {\n const ctx = useRouterContext();\n const [nestedRouteMatch, setNestedRouteMatch] = useState(undefined);\n const nestedRouter = useMemo(() => {\n if (typeof window === 'undefined')\n return null;\n const basePath = ctx.matchedRoutePath;\n const nestedRouter = new NestedRouter(ctx.router, basePath, routes);\n nestedRouter.index = index;\n return nestedRouter;\n }, []);\n useEffect(() => {\n if (nestedRouter) {\n if (ctx.matchedRoutePath !== nestedRouter.basePath) {\n // the change doesn't belong to this nested router\n // it should be handled by the top level router which will change the page or the nested router\n return;\n }\n const route = nestedRouter.match(ctx.remainingPath || '/') || createRoute404();\n setNestedRouteMatch(route);\n }\n }, [nestedRouter, ctx.remainingPath]);\n const wrapWithFixLinks = fixLinks ?\n (elem) => _jsx(FixLinks, { basePath: ctx.matchedRoutePath, children: elem })\n : (elem) => elem;\n return nestedRouteMatch && (_jsx(ReactRouterContext.Provider, { value: {\n ...ctx,\n router: nestedRouter,\n route: nestedRouteMatch.value,\n params: nestedRouteMatch.params,\n matchedRoutePath: '/' + nestedRouteMatch.matchedSegments.join('/'),\n remainingPath: nestedRouteMatch.remainingSegments ? '/' + nestedRouteMatch.remainingSegments.join('/') : undefined,\n navigate: (to, options) => {\n return nestedRouter.navigate(to, options);\n }\n }, children: wrapWithFixLinks(children ? children : _jsx(RouteComponent, {})) }));\n}\n//# sourceMappingURL=NestedRouterProvider.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useSafeLayoutEffect } from \"@vertesia/ui/core\";\n//import { useSafeLayoutEffect } from \"../core\";\nimport { useMemo, useState } from \"react\";\nimport { RouteComponent } from \"./RouteComponent\";\nimport { ReactRouterContext, Router } from \"./Router\";\nimport { createRoute404 } from \"./Route404\";\nexport function RouterProvider({ routes, index, onChange, children }) {\n const [state, setState] = useState(undefined);\n const router = useMemo(() => {\n if (typeof window === 'undefined')\n return null;\n const router = new Router(routes, (match) => {\n if (match === null) {\n match = createRoute404();\n }\n setState({\n location: window.location,\n route: match.value,\n params: match.params,\n state: match.state,\n router: router,\n matchedRoutePath: '/' + match.matchedSegments.join('/'),\n remainingPath: match.remainingSegments ? '/' + match.remainingSegments.join('/') : undefined,\n navigate: (to, options) => {\n return router.navigate(to, options);\n }\n });\n }).withObserver(onChange);\n router.index = index;\n return router;\n }, []);\n useSafeLayoutEffect(() => {\n router && router.start();\n return () => {\n router && router.stop();\n };\n }, []);\n return state && (_jsx(ReactRouterContext.Provider, { value: state, children: children ? children : _jsx(RouteComponent, {}) }));\n}\n//# sourceMappingURL=RouterProvider.js.map"],"names":["isRootPath","path","joinPath","path1","path2","endsWith","startsWith","substring","getPathSegments","s","e","length","split","toSegments","Array","isArray","Error","PathWithParams","params","hash","constructor","i","lastIndexOf","this","indexOf","URLSearchParams","add","key","value","Object","entries","set","toString","BASE_PATH","Symbol","LocationChangeEvent","name","type","location","state","_canceled","isPageLoad","isBackForward","isLinkClick","isNavigation","isCancelable","cancel","BeforeLocationChangeEvent","super","AfterLocationChangeEvent","HistoryNavigator","stickyParams","_popStateListener","_linkNavListener","_listeners","addListener","listener","push","fireLocationChange","event","firePageLoad","URL","window","href","addStickyParams","navigate","to","options","basePath","_navigate","beforeEvent","history","replace","from","data","undefined","start","ev","url","elem","tagName","toLowerCase","getElementHrefAsUrl","target","origin","preventDefault","pathname","addEventListener","document","body","stop","removeEventListener","FixLinks","children","ref","useRef","useEffect","current","divElem","_jsx","className","PathMatcher","tree","RootSegmentNode","loadMapping","mapping","addSegments","addPath","segments","node","l","segment","childNode","wildcard","VariableSegmentNode","join","slice","WildcardSegmentNode","LiteralSegmentNode","match","matchedSegments","remainingSegments","ParentSegmentNode","_","paramName","BaseRouter","index","matcher","routes","route","useIndex","Router","prompt","observer","navigator","updateState","when","confirm","message","getTopRouter","setStickyParams","withObserver","NestedRouter","parent","isBasePathNested","childBasePath","ReactRouterContext","createContext","useRouterContext","ctx","useContext","useNavigate","useParams","arg","useLocation","useNavigationPrompt","router","doBlock","returnValue","Nav","onClick","link","closest","stopPropagation","NavLink","topLevelNav","RouteComponent","spinner","Component","LazyComponent","LazyRouteComponent","setComponent","useState","then","module","default","NestedNavigationContext","fixLinks","wrapWithFixLinks","matchedRoutePath","Provider","actualBasePath","Route404Component","_jsxs","createRoute404","NestedRouterProvider","nestedRouteMatch","setNestedRouteMatch","nestedRouter","useMemo","remainingPath","RouterProvider","onChange","setState","useSafeLayoutEffect"],"mappings":"sNAAO,SAASA,EAAWC,GACvB,MAAgB,MAATA,GAAyB,KAATA,CAC3B,CACO,SAASC,EAASC,EAA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version":3,"file":"vertesia-ui-router.js","sources":["esm/router/path.js","esm/router/PathWithParams.js","esm/router/HistoryNavigator.js","esm/router/FixLinks.js","esm/router/PathMatcher.js","esm/router/Router.js","esm/router/Nav.js","esm/router/RouteComponent.js","esm/router/NestedNavigationContext.js","esm/router/Route404.js","esm/router/NestedRouterProvider.js","esm/router/RouterProvider.js"],"sourcesContent":["export function isRootPath(path) {\n return path === '/' || path === '';\n}\nexport function joinPath(path1, path2) {\n if (path1.endsWith('/') && path2.startsWith('/')) {\n path2 = path1 + path2.substring(1);\n }\n else if (path1.endsWith('/')) {\n path2 = path1 + path2;\n }\n else if (path2.startsWith('/')) {\n path2 = path1 + path2;\n }\n else {\n path2 = path1 + '/' + path2;\n }\n return path2;\n}\nexport function getPathSegments(path) {\n if (path === '' || path === '/') {\n return [];\n }\n let s = 0, e = path.length;\n if (path.startsWith('./')) {\n s = 2;\n }\n else if (path.startsWith('/')) {\n s = 1;\n }\n if (path.endsWith('/')) {\n e = path.length - 1;\n }\n return (s > 0 || e < path.length ? path.substring(s, e) : path).split('/');\n}\nexport function toSegments(path) {\n if (typeof path === 'string') {\n return getPathSegments(path);\n }\n else if (Array.isArray(path)) {\n return path;\n }\n else {\n throw new Error(`Unsupported path object: ${path}`);\n }\n}\n// export class Path {\n// static parse(path: string, abs = false) {\n// if (abs !== undefined) {\n// abs = path.startsWith('/');\n// }\n// return new Path(getPathSegments(path), abs);\n// }\n// constructor(public segments: string[], public isAbsolute = false) {\n// }\n// getParameters() {\n// const out = [];\n// for (const segment of this.segments) {\n// if (segment[0] === ':') {\n// out.push(segment.substring(1));\n// }\n// }\n// if (this.segments[this.segments.length - 1] === '*') {\n// out.push('_');\n// }\n// return out;\n// }\n// resolveParameters(path: string) {\n// const params: PathMatchParams = {};\n// const resolvedSegments = getPathSegments(path);\n// if (resolvedSegments.length < this.segments.length) {\n// return null;\n// }\n// const segments = this.segments;\n// for (let i = 0, l = segments.length; i < l; i++) {\n// const seg = segments[i];\n// if (seg[0] === ':') {\n// params[seg.substring(1)] = resolvedSegments[i];\n// }\n// }\n// if (resolvedSegments.length - this.segments.length) {\n// params._ = resolvedSegments.slice(this.segments.length);\n// }\n// return params;\n// }\n// match(path: string | string[] | Path) {\n// const segments = toSegments(path);\n// if (segments.length < this.segments.length) {\n// return false;\n// }\n// let params: PathMatchParams | undefined;\n// const mySegments = this.segments;\n// for (let i = 0, l = mySegments.length; i < l; i++) {\n// const segment = mySegments[i];\n// if (segment === ':') {\n// if (!params) params = {};\n// params[segment.substring(1)] = segment;\n// } else if (segment !== segments[i]) {\n// if (i === l - 1 && segment === '*') {\n// if (!params) params = {};\n// params._ = segments.slice(i);\n// return params;\n// }\n// return false;\n// }\n// }\n// return params ? params : false;\n// }\n// join(path: Path | string | string[]) {\n// const segments = toSegments(path);\n// return new Path(this.segments.concat(segments), this.isAbsolute);\n// }\n// getRelativePath(path: Path | string | string[], asAbsolute: boolean = false) {\n// const segments = toSegments(path);\n// const extraSegmentsCount = segments.length - this.segments.length;\n// if (extraSegmentsCount <= 0) {\n// return null;\n// }\n// return new Path(segments.slice(this.segments.length), asAbsolute);\n// }\n// prependSegments(segments: string[]) {\n// this.segments = segments.concat(this.segments);\n// }\n// appendSegments(segments: string[]) {\n// this.segments = this.segments.concat(segments);\n// }\n// toAbsolutePath() {\n// return '/' + this.segments.join('/');\n// }\n// toRelativePath() {\n// return this.segments.join('/');\n// }\n// toString() {\n// const path = this.segments.join('/');\n// return this.isAbsolute ? '/' + path : path;\n// }\n// }\n//# sourceMappingURL=path.js.map","export class PathWithParams {\n path;\n params;\n hash;\n constructor(path) {\n let i = path.lastIndexOf('#');\n if (i > -1) {\n this.hash = path.substring(i);\n path = path.substring(0, i);\n }\n else {\n this.hash = '';\n }\n i = path.indexOf('?');\n if (i > -1) {\n this.path = path.substring(0, i);\n this.params = new URLSearchParams(path.substring(i + 1));\n }\n else {\n this.path = path;\n this.params = new URLSearchParams();\n }\n }\n add(params) {\n for (const [key, value] of Object.entries(params)) {\n this.params.set(key, value);\n }\n return this;\n }\n toString() {\n return this.path + '?' + this.params.toString() + this.hash;\n }\n}\n//# sourceMappingURL=PathWithParams.js.map","import { joinPath } from \"./path\";\nimport { PathWithParams } from \"./PathWithParams\";\nconst BASE_PATH = Symbol('BASE_PATH');\nexport { BASE_PATH };\nexport class LocationChangeEvent {\n name;\n type;\n location;\n state;\n _canceled = false;\n constructor(name, type, location, state) {\n this.name = name;\n this.type = type;\n this.location = location;\n this.state = state;\n }\n get isPageLoad() {\n return this.type === 'initial';\n }\n get isBackForward() {\n return this.type === 'popState';\n }\n get isLinkClick() {\n return this.type === 'linkClick';\n }\n get isNavigation() {\n return this.type === 'navigate';\n }\n get isCancelable() {\n return this.name === 'beforeChange';\n }\n cancel() {\n if (this.name === 'afterChange') {\n throw new Error('Cannot cancel afterChange event');\n }\n this._canceled = true;\n }\n}\nexport class BeforeLocationChangeEvent extends LocationChangeEvent {\n constructor(type, location, state) {\n super('beforeChange', type, location, state);\n }\n}\nexport class AfterLocationChangeEvent extends LocationChangeEvent {\n constructor(type, location, state) {\n super('afterChange', type, location, state);\n }\n}\nfunction getElementHrefAsUrl(elem) {\n if (elem && elem.tagName.toLowerCase() === 'a') {\n const href = elem?.href.trim();\n if (typeof href === 'string' && href.length > 0) {\n return new URL(href);\n }\n }\n return null;\n}\nexport class HistoryNavigator {\n // params to preserve in the query string when navigating\n stickyParams;\n _popStateListener;\n _linkNavListener;\n _listeners = [];\n constructor() {\n }\n addListener(listener) {\n this._listeners.push(listener);\n }\n fireLocationChange(event) {\n for (const listener of this._listeners) {\n listener(event);\n }\n }\n /**\n * Should be called when the page is first loaded.\n * It will fire a location change event with type `initial` and the current window.location as the location\n */\n firePageLoad() {\n this.fireLocationChange(new AfterLocationChangeEvent('initial', new URL(window.location.href)));\n }\n addStickyParams(path) {\n if (this.stickyParams) {\n return new PathWithParams(path).add(this.stickyParams).toString();\n }\n return path;\n }\n navigate(to, options = {}) {\n if (options.basePath) {\n let basePath = options.basePath;\n if (!basePath.startsWith('/')) {\n basePath = '/' + basePath;\n }\n to = joinPath(basePath, to);\n }\n to = this.addStickyParams(to);\n this._navigate(new URL(to, window.location.href), 'navigate', options);\n }\n _navigate(to, type, options) {\n const beforeEvent = new BeforeLocationChangeEvent(type, to, options.state);\n this.fireLocationChange(beforeEvent);\n if (beforeEvent._canceled) {\n return;\n }\n window.history[options.replace ? 'replaceState' : 'pushState']({\n from: window.location.href,\n data: options.state || undefined\n }, '', to.href);\n this.fireLocationChange(new AfterLocationChangeEvent(type, to, options.state));\n }\n start() {\n if (typeof window === \"undefined\") {\n return;\n }\n const _popStateListener = (ev) => {\n let type = ev.state ? 'popState' : 'linkClick';\n const to = new URL(window.location.href);\n let state = undefined;\n if (ev.state) {\n type = 'popState';\n state = ev.state.data;\n }\n else {\n type = 'linkClick';\n }\n this.fireLocationChange(new AfterLocationChangeEvent(type, to, state));\n };\n const _linkNavListener = (ev) => {\n const url = getElementHrefAsUrl(ev.target);\n if (url && url.origin === window.location.origin) {\n ev.preventDefault();\n const to = new URL(this.addStickyParams(url.href));\n const basePath = ev[BASE_PATH] || ev.target[BASE_PATH];\n if (basePath) {\n to.pathname = joinPath(basePath, to.pathname);\n }\n this._navigate(to, 'linkClick', {});\n }\n };\n this._popStateListener = _popStateListener;\n this._linkNavListener = _linkNavListener;\n window.addEventListener('popstate', _popStateListener);\n document.body.addEventListener('click', this._linkNavListener);\n }\n stop() {\n this._popStateListener && window.removeEventListener('popstate', this._popStateListener);\n this._linkNavListener && document.body.removeEventListener('click', this._linkNavListener);\n }\n}\n//# sourceMappingURL=HistoryNavigator.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useRef } from \"react\";\nimport { BASE_PATH } from \"./HistoryNavigator\";\nexport function FixLinks({ basePath, children }) {\n const ref = useRef(null);\n useEffect(() => {\n if (ref.current) {\n const divElem = ref.current;\n const listener = (ev) => {\n const elem = ev.target;\n if (elem.tagName.toLowerCase() === 'a') {\n ev[BASE_PATH] = basePath;\n }\n };\n divElem.addEventListener('click', listener);\n return () => {\n divElem.removeEventListener('click', listener);\n };\n }\n }, [ref.current]);\n return (_jsx(\"div\", { ref: ref, className: \"h-full w-full\", children: children }));\n}\n//# sourceMappingURL=FixLinks.js.map","import { getPathSegments, toSegments } from \"./path\";\n/**\n * Path matcher which support :param and *wildcard segments.\n * The wildcard segment is only supported as the last segment\n */\nexport class PathMatcher {\n tree = new RootSegmentNode();\n loadMapping(mapping) {\n for (const [key, value] of Object.entries(mapping)) {\n this.addSegments(getPathSegments(key), value);\n }\n }\n addPath(path, value) {\n this.addSegments(getPathSegments(path), value);\n }\n addSegments(segments, value) {\n let node = this.tree;\n for (let i = 0, l = segments.length; i < l; i++) {\n const segment = segments[i];\n if (segment[0] === ':') {\n let childNode = node.wildcard;\n if (!childNode) {\n childNode = new VariableSegmentNode(segment);\n node.wildcard = childNode;\n }\n else if (!(childNode instanceof VariableSegmentNode)) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A wildcard \":\" segment will overwrite an existing wildcard segment at path: ${'/' + segments.slice(0, i).join(\"/\")}`);\n }\n node = childNode;\n }\n else if (segment === '*') {\n if (node.wildcard) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A wildcard \"*\" segment already exists at path: ${'/' + segments.slice(0, i).join(\"/\")}`);\n }\n node.wildcard = new WildcardSegmentNode(segment, value);\n if (i < l - 1) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A wildcard segment must be the last segment`);\n }\n return;\n }\n else {\n let childNode = node.children[segment];\n if (!childNode) {\n childNode = new LiteralSegmentNode(segment);\n node.children[segment] = childNode;\n } // else // a literal segment already exists\n node = childNode;\n }\n }\n if (node.value !== undefined) {\n throw new Error(`Failed to index path segments: ${segments.join('/')}. A value already exists at path: ${'/' + segments.join(\"/\")}`);\n }\n node.value = value;\n }\n match(path) {\n const segments = toSegments(path);\n if (segments.length === 0) {\n return null;\n }\n const params = {};\n let node = this.tree;\n for (const segment of segments) {\n const match = node.match(segment, params);\n if (match) {\n node = match;\n }\n else {\n return null;\n }\n }\n if (!node.value) { // not a leaf node (partial match)\n if (node instanceof ParentSegmentNode) {\n if (node.wildcard instanceof WildcardSegmentNode) {\n node = node.wildcard.match('', params);\n if (!node.value) {\n throw new Error(\"Wildcard segment node `*` must have a value\");\n }\n }\n }\n if (!node.value)\n return null; // not a leaf node, neither a trailing wildcard (partial match)\n }\n let matchedSegments, remainingSegments;\n if (params._ && params._.length > 0) {\n matchedSegments = segments.slice(0, -params._.length);\n remainingSegments = params._;\n }\n else {\n matchedSegments = segments;\n }\n return { params, matchedSegments, remainingSegments, value: node.value };\n }\n}\nclass ParentSegmentNode {\n name;\n value;\n children = {};\n wildcard;\n constructor(name, value) {\n this.name = name;\n this.value = value;\n }\n match(segment, params) {\n let node = this.children[segment];\n if (node) {\n return node;\n }\n else if (this.wildcard) {\n if (this.wildcard instanceof WildcardSegmentNode) {\n return this.wildcard.match(segment, params);\n }\n else if (this.wildcard instanceof VariableSegmentNode) {\n params[this.wildcard.paramName] = segment;\n return this.wildcard;\n }\n else {\n throw new Error(\"Unknown wildcard segment node type: \" + this.wildcard.constructor.name);\n }\n }\n else {\n return null;\n }\n }\n}\nclass RootSegmentNode extends ParentSegmentNode {\n constructor() {\n super(\"#root\");\n }\n}\nclass LiteralSegmentNode extends ParentSegmentNode {\n constructor(name, value) {\n super(name, value);\n }\n}\nclass VariableSegmentNode extends ParentSegmentNode {\n paramName;\n constructor(name, value) {\n super(name, value);\n this.paramName = name.substring(1);\n }\n}\nclass WildcardSegmentNode {\n name;\n value;\n constructor(name, value) {\n this.name = name;\n this.value = value;\n }\n match(segment, params) {\n if (!params._) {\n params._ = segment ? [segment] : [];\n }\n else {\n segment && params._.push(segment);\n }\n return this;\n }\n}\n//# sourceMappingURL=PathMatcher.js.map","import { createContext, useContext, useEffect } from \"react\";\nimport { HistoryNavigator } from \"./HistoryNavigator\";\nimport { PathMatcher } from \"./PathMatcher\";\nimport { isRootPath, joinPath } from \"./path\";\nexport class BaseRouter {\n // the path to use when navigating to the root of the router\n index;\n matcher = new PathMatcher();\n constructor(routes, index) {\n this.index = index;\n for (const route of routes) {\n this.matcher.addPath(route.path, route);\n }\n }\n match(path) {\n const useIndex = isRootPath(path) && this.index;\n return this.matcher.match(useIndex ? this.index : path);\n }\n}\nexport class Router extends BaseRouter {\n prompt;\n observer;\n navigator = new HistoryNavigator();\n constructor(routes, updateState) {\n super(routes);\n this.navigator.addListener((event) => {\n if (event.isCancelable && this.prompt && !!this.prompt.when) {\n if (!window.confirm(this.prompt.message))\n return;\n }\n if (this.observer) {\n this.observer(event);\n }\n // only process afterChange events\n if (event.name === \"afterChange\") {\n const match = this.match(event.location.pathname);\n if (match && match.value) {\n updateState({\n ...match,\n state: event.state,\n });\n }\n else {\n updateState(null);\n }\n }\n });\n }\n getTopRouter() {\n return this;\n }\n /**\n * Subsequent navigations will preserve the given params in the query string.\n * Use null to clear the sticky params.\n * @param params\n */\n setStickyParams(params) {\n this.navigator.stickyParams = params != null ? params : undefined;\n }\n withObserver(observer) {\n this.observer = observer;\n return this;\n }\n start() {\n this.navigator.start();\n // initialize with the current location\n this.navigator.firePageLoad();\n }\n stop() {\n this.navigator.stop();\n }\n navigate(path, options) {\n this.navigator.navigate(path, options);\n }\n}\nexport class NestedRouter extends BaseRouter {\n parent;\n basePath;\n constructor(parent, basePath, routes) {\n super(routes);\n this.parent = parent;\n this.basePath = basePath;\n }\n getTopRouter() {\n if (this.parent instanceof Router) {\n return this.parent;\n }\n else {\n return this.parent.getTopRouter();\n }\n }\n navigate(path, options) {\n // base path is nested by default in a NestedRouter unless explicitly set to false by caller\n const isBasePathNested = options?.isBasePathNested ?? true;\n let basePath;\n if (isBasePathNested) {\n const childBasePath = options?.basePath;\n // e.g. \"/store\" + \"/objects/123\" => \"/store/objects/123\"\n basePath = childBasePath ? joinPath(this.basePath, childBasePath) : this.basePath;\n }\n else {\n // e.g. \"/store\" + \"/studio\" => \"/studio\"\n basePath = options?.basePath ?? this.basePath;\n }\n this.parent.navigate(path, {\n ...options,\n basePath,\n });\n }\n}\nconst ReactRouterContext = createContext(undefined);\nexport { ReactRouterContext };\nexport function useRouterContext() {\n const ctx = useContext(ReactRouterContext);\n if (!ctx) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n return ctx;\n}\nexport function useNavigate() {\n const { navigate } = useRouterContext();\n return navigate;\n}\nexport function useParams(arg) {\n const { params } = useRouterContext();\n if (arg) {\n return params[arg];\n }\n else {\n return params;\n }\n}\nexport function useLocation() {\n const { location } = useRouterContext();\n return location;\n}\nexport function useNavigationPrompt(prompt) {\n const { router } = useRouterContext();\n useEffect(() => {\n router.getTopRouter().prompt = prompt;\n return () => {\n router.getTopRouter().prompt = undefined;\n };\n }, []);\n useEffect(() => {\n if (prompt.when) {\n const doBlock = prompt.when;\n const listener = function (ev) {\n if (doBlock) {\n ev.preventDefault();\n ev.returnValue = \"\";\n }\n };\n window.addEventListener(\"beforeunload\", listener);\n return () => {\n window.removeEventListener(\"beforeunload\", listener);\n };\n }\n }, [prompt.when]);\n}\n//# sourceMappingURL=Router.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useNavigate, useRouterContext } from \"./Router\";\nexport function Nav({ children, onClick }) {\n const navigate = useNavigate();\n const _onClick = (ev) => {\n const link = ev.target.closest('a');\n if (link && link.href) {\n ev.stopPropagation();\n ev.preventDefault();\n navigate(link.href);\n onClick?.(ev);\n }\n };\n return (_jsx(\"span\", { onClick: _onClick, children: children }));\n}\nexport function NavLink({ children, href, className, topLevelNav }) {\n const { router } = useRouterContext();\n const _onClick = (ev) => {\n ev.stopPropagation();\n ev.preventDefault();\n const actualRouter = topLevelNav ? router.getTopRouter() : router;\n actualRouter.navigate(href);\n };\n return (_jsx(\"a\", { href: href, className: className, onClick: _onClick, children: children }));\n}\n//# sourceMappingURL=Nav.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useState } from \"react\";\nimport { useRouterContext } from \"./Router\";\nexport function RouteComponent({ spinner }) {\n const ctx = useRouterContext();\n const route = ctx.route;\n if (route.Component) {\n const Component = route.Component;\n return _jsx(Component, { ...ctx.params });\n }\n else if (route.LazyComponent) {\n return _jsx(LazyRouteComponent, { route: route, spinner: spinner });\n }\n else {\n throw new Error(`Invalid route for ${route.path}. Either Component or LazyCOmponent must be specified.`);\n }\n}\nfunction LazyRouteComponent({ route, spinner }) {\n const [Component, setComponent] = useState(null);\n useEffect(() => {\n route.LazyComponent().then(module => {\n if (!module.default) {\n throw new Error(`Lazy module for ${route.path} does not have a default export`);\n }\n // we need to wrap the component type in an arrow function\n // otherwise the setState function will execute the function as a state update function\n setComponent(() => module.default);\n });\n }, [route]);\n return Component ? (_jsx(Component, {})) : spinner || null;\n}\n//# sourceMappingURL=RouteComponent.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { FixLinks } from \"./FixLinks\";\nimport { RouteComponent } from \"./RouteComponent\";\nimport { ReactRouterContext, useRouterContext } from \"./Router\";\nimport { joinPath } from \"./path\";\nexport function NestedNavigationContext({ basePath, fixLinks = false, children }) {\n const ctx = useRouterContext();\n const wrapWithFixLinks = fixLinks ?\n (elem) => _jsx(FixLinks, { basePath: ctx.matchedRoutePath, children: elem })\n : (elem) => elem;\n return (_jsx(ReactRouterContext.Provider, { value: {\n ...ctx,\n navigate: (to, options) => {\n const actualBasePath = options?.basePath ? joinPath(basePath, options.basePath) : basePath;\n return ctx.navigate(to, { ...options, basePath: actualBasePath });\n }\n }, children: wrapWithFixLinks(children ? children : _jsx(RouteComponent, {})) }));\n}\n//# sourceMappingURL=NestedNavigationContext.js.map","import { jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nimport { useRouterContext } from \"./Router\";\nexport function Route404Component() {\n const ctx = useRouterContext();\n return _jsxs(\"div\", { children: [\"Route not found for path \", ctx.matchedRoutePath] });\n}\nexport function createRoute404() {\n return {\n params: {},\n matchedSegments: [],\n state: null,\n value: {\n path: 'virtual:404',\n Component: () => _jsx(Route404Component, {})\n }\n };\n}\n//# sourceMappingURL=Route404.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { FixLinks } from \"./FixLinks\";\nimport { createRoute404 } from \"./Route404\";\nimport { RouteComponent } from \"./RouteComponent\";\nimport { NestedRouter, ReactRouterContext, useRouterContext } from \"./Router\";\nexport function NestedRouterProvider({ routes, index, children, fixLinks = false }) {\n const ctx = useRouterContext();\n const [nestedRouteMatch, setNestedRouteMatch] = useState(undefined);\n const nestedRouter = useMemo(() => {\n if (typeof window === 'undefined')\n return null;\n const basePath = ctx.matchedRoutePath;\n const nestedRouter = new NestedRouter(ctx.router, basePath, routes);\n nestedRouter.index = index;\n return nestedRouter;\n }, []);\n useEffect(() => {\n if (nestedRouter) {\n if (ctx.matchedRoutePath !== nestedRouter.basePath) {\n // the change doesn't belong to this nested router\n // it should be handled by the top level router which will change the page or the nested router\n return;\n }\n const route = nestedRouter.match(ctx.remainingPath || '/') || createRoute404();\n setNestedRouteMatch(route);\n }\n }, [nestedRouter, ctx.remainingPath]);\n const wrapWithFixLinks = fixLinks ?\n (elem) => _jsx(FixLinks, { basePath: ctx.matchedRoutePath, children: elem })\n : (elem) => elem;\n return nestedRouteMatch && (_jsx(ReactRouterContext.Provider, { value: {\n ...ctx,\n router: nestedRouter,\n route: nestedRouteMatch.value,\n params: nestedRouteMatch.params,\n matchedRoutePath: '/' + nestedRouteMatch.matchedSegments.join('/'),\n remainingPath: nestedRouteMatch.remainingSegments ? '/' + nestedRouteMatch.remainingSegments.join('/') : undefined,\n navigate: (to, options) => {\n return nestedRouter.navigate(to, options);\n }\n }, children: wrapWithFixLinks(children ? children : _jsx(RouteComponent, {})) }));\n}\n//# sourceMappingURL=NestedRouterProvider.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useSafeLayoutEffect } from \"@vertesia/ui/core\";\n//import { useSafeLayoutEffect } from \"../core\";\nimport { useMemo, useState } from \"react\";\nimport { RouteComponent } from \"./RouteComponent\";\nimport { ReactRouterContext, Router } from \"./Router\";\nimport { createRoute404 } from \"./Route404\";\nexport function RouterProvider({ routes, index, onChange, children }) {\n const [state, setState] = useState(undefined);\n const router = useMemo(() => {\n if (typeof window === 'undefined')\n return null;\n const router = new Router(routes, (match) => {\n if (match === null) {\n match = createRoute404();\n }\n setState({\n location: window.location,\n route: match.value,\n params: match.params,\n state: match.state,\n router: router,\n matchedRoutePath: '/' + match.matchedSegments.join('/'),\n remainingPath: match.remainingSegments ? '/' + match.remainingSegments.join('/') : undefined,\n navigate: (to, options) => {\n return router.navigate(to, options);\n }\n });\n }).withObserver(onChange);\n router.index = index;\n return router;\n }, []);\n useSafeLayoutEffect(() => {\n router && router.start();\n return () => {\n router && router.stop();\n };\n }, []);\n return state && (_jsx(ReactRouterContext.Provider, { value: state, children: children ? children : _jsx(RouteComponent, {}) }));\n}\n//# sourceMappingURL=RouterProvider.js.map"],"names":["isRootPath","path","joinPath","path1","path2","endsWith","startsWith","substring","getPathSegments","s","e","length","split","toSegments","Array","isArray","Error","PathWithParams","params","hash","constructor","i","lastIndexOf","this","indexOf","URLSearchParams","add","key","value","Object","entries","set","toString","BASE_PATH","Symbol","LocationChangeEvent","name","type","location","state","_canceled","isPageLoad","isBackForward","isLinkClick","isNavigation","isCancelable","cancel","BeforeLocationChangeEvent","super","AfterLocationChangeEvent","HistoryNavigator","stickyParams","_popStateListener","_linkNavListener","_listeners","addListener","listener","push","fireLocationChange","event","firePageLoad","URL","window","href","addStickyParams","navigate","to","options","basePath","_navigate","beforeEvent","history","replace","from","data","undefined","start","ev","url","elem","tagName","toLowerCase","trim","getElementHrefAsUrl","target","origin","preventDefault","pathname","addEventListener","document","body","stop","removeEventListener","FixLinks","children","ref","useRef","useEffect","current","divElem","_jsx","className","PathMatcher","tree","RootSegmentNode","loadMapping","mapping","addSegments","addPath","segments","node","l","segment","childNode","wildcard","VariableSegmentNode","join","slice","WildcardSegmentNode","LiteralSegmentNode","match","matchedSegments","remainingSegments","ParentSegmentNode","_","paramName","BaseRouter","index","matcher","routes","route","useIndex","Router","prompt","observer","navigator","updateState","when","confirm","message","getTopRouter","setStickyParams","withObserver","NestedRouter","parent","isBasePathNested","childBasePath","ReactRouterContext","createContext","useRouterContext","ctx","useContext","useNavigate","useParams","arg","useLocation","useNavigationPrompt","router","doBlock","returnValue","Nav","onClick","link","closest","stopPropagation","NavLink","topLevelNav","RouteComponent","spinner","Component","LazyComponent","LazyRouteComponent","setComponent","useState","then","module","default","NestedNavigationContext","fixLinks","wrapWithFixLinks","matchedRoutePath","Provider","actualBasePath","Route404Component","_jsxs","createRoute404","NestedRouterProvider","nestedRouteMatch","setNestedRouteMatch","nestedRouter","useMemo","remainingPath","RouterProvider","onChange","setState","useSafeLayoutEffect"],"mappings":"sNAAO,SAASA,EAAWC,GACvB,MAAgB,MAATA,GAAyB,KAATA,CAC3B,CACO,SAASC,EAASC,EAAOC,GAa5B,OAXIA,EADAD,EAAME,SAAS,MAAQD,EAAME,WAAW,KAChCH,EAAQC,EAAMG,UAAU,GAE3BJ,EAAME,SAAS,MAGfD,EAAME,WAAW,KAFdH,EAAQC,EAMRD,EAAQ,IAAMC,CAG9B,CACO,SAASI,EAAgBP,GAC5B,GAAa,KAATA,GAAwB,MAATA,EACf,MAAO,GAEX,IAAIQ,EAAI,EAAGC,EAAIT,EAAKU,OAUpB,OATIV,EAAKK,WAAW,MAChBG,EAAI,EAECR,EAAKK,WAAW,OACrBG,EAAI,GAEJR,EAAKI,SAAS,OACdK,EAAIT,EAAKU,OAAS,IAEdF,EAAI,GAAKC,EAAIT,EAAKU,OAASV,EAAKM,UAAUE,EAAGC,GAAKT,GAAMW,MAAM,IAC1E,CACO,SAASC,EAAWZ,GACvB,GAAoB,iBAATA,EACP,OAAOO,EAAgBP,GAEtB,GAAIa,MAAMC,QAAQd,GACnB,OAAOA,EAGP,MAAM,IAAIe,MAAM,4BAA4Bf,IAEpD,8FC5CO,MAAM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,oBAAXhI,OACP,OAAO,KACX,MAAM+F,EAAS,IAAIzB,EAAOH,GAAST,IACjB,OAAVA,IACAA,EAAQiE,KAEZS,EAAS,CACL5J,SAAUwB,OAAOxB,SACjB4F,MAAOV,EAAM5F,MACbV,OAAQsG,EAAMtG,OACdqB,MAAOiF,EAAMjF,MACbsH,OAAQA,EACRuB,iBAAkB,IAAM5D,EAAMC,gBAAgBL,KAAK,KACnD2E,cAAevE,EAAME,kBAAoB,IAAMF,EAAME,kBAAkBN,KAAK,UAAOzC,EACnFV,SAAU,CAACC,EAAIC,IACJ0F,EAAO5F,SAASC,EAAIC,QAGpC2E,aAAamD,GAEhB,OADApC,EAAO9B,MAAQA,EACR8B,IACR,IAOH,OANAsC,GAAoB,KAChBtC,GAAUA,EAAOjF,QACV,KACHiF,GAAUA,EAAOlE,UAEtB,IACIpD,GAAU6D,EAAK+C,EAAmBkC,SAAU,CAAEzJ,MAAOW,EAAOuD,SAAUA,GAAsBM,EAAKmE,EAAgB,CAAE,IAC9H"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{Button as n,Modal as o,ModalTitle as a,ModalBody as l,useToast as r,Input as s,Spinner as c,SelectStack as d,VSelectBox as m,useSafeLayoutEffect as u,ErrorBox as h,Center as p,useFetch as f,SelectBox as g,ModalFooter as v,VTabs as x,VTabsBar as y,VTabsPanel as b,VTooltip as N,Avatar as w,ModeToggle as k,MenuList as C,ToastProvider as S,ThemeProvider as j}from"@vertesia/ui/core";import{useState as P,useEffect as z,Fragment as L}from"react";import{useUserSession as T,useUXTracking as I,setFirebaseTenant as _,getFirebaseAuth as A,UserNotFoundError as U,fetchComposableTokenFromFirebaseToken as O,UserSessionProvider as E}from"@vertesia/ui/session";import{Env as q}from"@vertesia/ui/env";import W from"clsx";import{signInWithRedirect as D,OAuthProvider as M,GoogleAuthProvider as R,GithubAuthProvider as F,getAuth as G}from"firebase/auth";import{useLocation as Y}from"@vertesia/ui/router";import{Popover as J}from"@vertesia/ui/widgets";import{getTenantIdFromProject as B}from"@vertesia/common";import{Check as V,CopyIcon as H}from"lucide-react";import{UserPermissionProvider as K}from"@vertesia/ui/features";import{Transition as $}from"@headlessui/react";function Q(){const i=T(),{client:r,account:s}=i,[c,d]=P(!1),[m,u]=P([]);z((()=>{r.account.listInvites().then((e=>{e.length>0&&(console.log("Got invites - showing modal"),u(e),d(!0))}))}),[s?.id]);const h=()=>d(!1),p=m.map((o=>e("div",{className:"flex flex-row w-full justify-between border rounded-sm px-2 py-2 ",children:[e("div",{className:"flex flex-col",children:[t("div",{className:"w-full font-semibold",children:o.data.account.name}),e("div",{className:"text-xs",children:["Role: ",o.data.role]}),e("div",{className:"text-xs",children:["by ",o.data.invitedBy.name]})]}),e("div",{className:"flex flex-col gap-4",children:[t(n,{size:"xs",onClick:()=>(async e=>{await r.account.acceptInvite(e.id),await i.fetchAccounts();const t=m.filter((t=>t.id!==e.id));u(t),0===t.length&&h()})(o),children:"Accept"})," ",t(n,{size:"xs",variant:"secondary",onClick:()=>(async e=>{await r.account.rejectInvite(e.id);const t=m.filter((t=>t.id!==e.id));u(t),0===t.length&&h()})(o),children:"Reject"})]})]},o.id)));return t("div",{children:e(o,{isOpen:c,onClose:h,children:[t(a,{children:"Review Invites"}),e(l,{children:[t("div",{className:"text-sm pb-4",children:"You have received the following invites to join other accounts. Please review and accept or declined them."}),p]})]})})}function X({redirectTo:o}){const[a,l]=P(!1),{trackEvent:d}=I(),[m,u]=P(""),h=r();return e(i,{children:[t(s,{value:m,onChange:u,placeholder:"Enter your enterprise email",type:"email"}),a?t("div",{className:"w-full flex justify-center",children:t(c,{})}):t(n,{variant:"outline",onClick:async()=>{if(!m)return;/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m)?(l(!0),_(m).then((e=>{if(!e)return h({title:"Tenant not found",status:"error",duration:5e3}),void l(!1);localStorage.setItem("tenantName",e.name??"");const t=function(e){switch(q.firebase.providerType){case"oidc":default:return new M("oidc.main");case"google":{let t=e||window.location.pathname||"/";"/"!==t[0]&&(t="/"+t);const i=new R;return i.addScope("profile"),i.addScope("email"),i.setCustomParameters({prompt:"select_account",redirect_uri:window.location.origin+t}),i}case"microsoft":return new M("microsoft.com");case"github":return new M("github.com")}}(o);d("enterprise_signin",{firebaseTenantName:e.name}),q.logger.info("Enterprise single sign-in",{vertesia:{email:m,firebaseTenantName:e.name,firebaseTenantId:e.firebaseTenantId}}),D(A(),t),l(!1)}))):h({title:"Invalid email address",status:"error",duration:5e3})},className:"w-full mt-2 py-4 flex rounded-lg hover:shadow-sm transition duration-150 text-center",children:t("span",{className:"text-sm font-semibold",children:"Continue with Enterprise SSO"})})]})}function Z({}){return e(n,{variant:"outline",onClick:()=>{localStorage.removeItem("tenantName");let e="https://dengenlabs.firebaseapp.com/__/auth/handler"+window.location.pathname;"/"!==e[0]&&(e="/"+e);const t=new F;t.addScope("profile"),t.addScope("email"),D(A(),t)},className:"w-full py-5 flex rounded-lg hover:shadow-sm transition duration-150 text-center mb-2",children:[t("img",{className:"size-6 bg-white rounded-full",src:"https://www.svgrepo.com/show/503359/github.svg",loading:"lazy",alt:"github logo"}),t("span",{className:"text-sm font-semibold",children:"Continue with GitHub"})]})}function ee({redirectTo:i}){return e(n,{variant:"outline",onClick:()=>{localStorage.removeItem("tenantName");let e=i||window.location.pathname||"/";"/"!==e[0]&&(e="/"+e);const t=new R;t.addScope("profile"),t.addScope("email"),t.setCustomParameters({prompt:"select_account",redirect_uri:window.location.origin+e}),D(A(),t)},className:"w-full py-5 flex rounded-lg hover:shadow-sm transition duration-150 text-center mb-2",children:[t("img",{className:"size-6",src:"https://www.svgrepo.com/show/475656/google-color.svg",loading:"lazy",alt:"google logo"}),t("span",{className:"text-sm font-semibold",children:"Continue with Google"})]})}function te({redirectTo:i}){return e(n,{variant:"outline",onClick:()=>{localStorage.removeItem("tenantName");let e=i||window.location.pathname||"/";"/"!==e[0]&&(e="/"+e);const t=new M("microsoft.com");t.addScope("profile"),t.addScope("email"),D(A(),t)},className:"w-full py-5 flex rounded-lg hover:shadow-sm transition duration-150 text-center",children:[t("img",{className:"size-6",src:"https://learn.microsoft.com/en-us/entra/identity-platform/media/howto-add-branding-in-apps/ms-symbollockup_mssymbol_19.svg",loading:"lazy",alt:"microsoft logo"}),t("span",{className:"text-sm font-semibold",children:"Continue with Microsoft"})]})}const ie=[{id:1,label:"1-10 employees"},{id:11,label:"11-100 employees"},{id:101,label:"101-1000 employees"},{id:1001,label:"1001-5000 employees"},{id:5001,label:"5000+ employees"}],ne=[{id:"personal",label:"Personal",description:"For personal use, or for a small team."},{id:"company",label:"Company",description:"For a company or organization."}],oe=[{id:"testing",label:"Just Testing or Evaluating LLMs"},{id:"exploring",label:"Actively Exploring LLMs on a Project"},{id:"using",label:"Already Using LLMs in Production"},{id:"migrating",label:"Migrating to different LLMs"},{id:"other",label:"Other"}];function ae({onSignup:o,goBack:a}){const[l,r]=P(void 0),[c,u]=P(void 0),[h,p]=P(void 0),[f,g]=P(void 0),[v,x]=P(void 0),[y,b]=P(void 0),[N,w]=P(void 0),k="company"===l;z((()=>{const e=G().currentUser;e?b(e):console.error("No user found")}),[y]);return e("div",{className:"flex flex-col space-y-2",children:[e("div",{className:"prose",children:[e("p",{className:"prose text-sm text-muted pt-4",children:["Welcome to Vertesia, ",y?.displayName," (",y?.email,"). Please tell us a little bit about yourself and you'll be on your way. No credit card is required."]}),N&&t("div",{className:"text-destructive",children:N})]}),t(le,{label:"Account Type",children:t(d,{options:ne,selected:ne.find((e=>e.id===l)),onSelect:e=>r(e.id)})}),k&&e(i,{children:[t(le,{label:"Company Size",children:t(m,{className:"w-full border border-accent bg-muted",value:c,options:ie,onChange:u,optionLabel:e=>e?.label,placeholder:"Select Company Size"})}),t(le,{label:"Company Name",children:t(s,{value:h,onChange:p,type:"text",required:!0})}),t(le,{label:"Company Website",children:t(s,{value:f,onChange:g,type:"text"})})]}),t(le,{label:"Project Maturity",children:t(m,{className:"w-full border border-accent bg-muted",options:oe,value:oe.find((e=>e.id===v)),optionLabel:e=>e?.label,placeholder:"Select Project Maturity",onChange:e=>x(e?.id)})}),e("div",{className:"pt-8 flex flex-col",children:[t(n,{variant:"primary",onClick:async()=>{if(!(l?k&&!h?(w("Please enter an organization name"),0):!k||c||(w("Please select a company size"),0):(w("Please select an account type"),0)))return;if(!l)return;const e={accountType:l,companyName:h,companySize:c?.id,companyWebsite:f,maturity:v};window.localStorage.setItem("composableSignupData",JSON.stringify(e));const t=await(G().currentUser?.getIdToken());console.log("Got firebase token",G(),t),t?o(e,t):console.error("No firebase token found")},size:"xl",children:t("span",{className:"text-lg",children:"Sign Up"})}),t(n,{variant:"ghost",size:"xl",className:"mt-4",onClick:a,children:t("span",{className:"",children:"Wrong account, go back"})})]})]})}function le({label:i,children:n}){return e("div",{className:"flex flex-col space-y-2 pt-4",children:[t("div",{className:"text-sm text-muted",children:i}),n]})}function re({allowedPrefix:e,isNested:i=!1,lightLogo:n,darkLogo:o}){const[a,l]=P(!1);return u((()=>{e&&l(window.location.href.startsWith(e))}),[]),a?null:t(se,{isNested:i,lightLogo:n,darkLogo:o})}function se({isNested:i=!1,lightLogo:n,darkLogo:o}){const{isLoading:a,user:l,authError:r}=T();return a||l?null:t("div",{style:{zIndex:999998},className:(i?"absolute":"fixed")+"overflow-y-auto ",children:e("div",{className:W("flex flex-col items-center justify-center py-14 px-4"),children:[t(ce,{authError:r,lightLogo:n,darkLogo:o}),e("div",{className:"flex gap-x-6 mt-10 justify-center text-muted",children:[t("a",{href:"https://vertesiahq.com/privacy",className:"text-sm",children:"Privacy Policy"}),t("a",{href:"https://vertesiahq.com/terms",className:"text-sm",children:"Terms of Service"})]})]})})}function ce({authError:o,darkLogo:a,lightLogo:l}){const[r,s]=P(void 0),[c,d]=P(!1),{signOut:m}=T(),{trackEvent:u}=I();history.replaceState({},"","/");const h=()=>{s(void 0),d(!0)};z((()=>{o instanceof U&&(console.log("User not found, redirecting to signup"),h())}),[o]);return e(i,{children:[l&&t("img",{src:l,alt:"logo",className:"h-15 block dark:hidden"}),a&&t("img",{src:a,alt:"logo",className:"h-15 hidden dark:block"}),r&&e("div",{className:"my-6",children:["Need to make a change?"," ",t(n,{onClick:h,children:" Go back"})]}),t("div",{className:"flex flex-col space-y-2",children:c&&!localStorage.getItem("tenantName")?t(ae,{onSignup:(e,t)=>{console.log("Got Signup data",e),s(e);const i={signupData:e,firebaseToken:t};fetch(q.endpoints.studio+"/auth/signup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then((e=>{console.log("Signup successful",i,e),u("sign_up"),window.location.href="/"}))},goBack:()=>{console.log("Going back, signing out"),s(void 0),d(!1),m()}}):e("div",{className:"flex flex-col",children:[t("div",{className:"my-4",children:t("h2",{className:"text-2xl font-bold text-center",children:"Log in or Sign up"})}),e("div",{className:"max-w-2xl text-center my-2 px-2",children:["First time here? No problem, it's free to try!",t("br",{}),"We'll just ask you a couple of questions next and you'll be on your way."]}),e("div",{className:"flex items-center flex-col",children:[e("div",{className:"py-4 w-70",children:[t(ee,{}),t(Z,{}),t(te,{})]}),e("div",{className:"flex items-center flex-row w-70 text-muted",children:[t("hr",{className:"w-full"}),t("div",{className:"px-2 text-xs",children:"OR"}),t("hr",{className:"w-full"})]}),t("div",{className:"py-4 w-70",children:t(X,{})})]}),o&&t("div",{className:"text-center",children:e("div",{className:"",children:["Sorry, we have not been able to sign you in.",t("br",{}),"Please try again or contact",t("a",{className:"text-info mx-1",href:"mailto:support@vertesiahq.com",children:"support@vertesiahq.com"}),"if it persists.",e("pre",{className:"mt-2",children:["Error: ",o.message]})]})})]})})]})}function de(){const[e,i]=P(),[n,o]=P(),a=function(e){const t=new URLSearchParams(e.search);let i=t.get("redirect_uri");const n=t.get("code");return i&&n?(i=decodeURI(i),i.startsWith("http://127.0.0.1:")||i.startsWith("http://localhost:")?{redirect:i,code:n,profile:t.get("profile")??"default",project:t.get("project")??void 0,account:t.get("account")??void 0}:null):null}(Y()),l=r(),s=async e=>{if(!a)return;if(!e.profile)return void l({title:"Profile is required",description:"Please enter a profile name to save the client authorization",status:"error",duration:2e3});if(!e.account)return void l({title:"Account is required",description:"Please select an account to authorize the client to access the ComposablePrompts servers",status:"error",duration:2e3});if(!e.project)return void l({title:"Project is required",description:"Please select a project to authorize the client to access the ComposablePrompts servers",status:"error",duration:2e3});let t;try{const n=await O(e.account,e.project,86400);n?(t={...e,studio_server_url:q.endpoints.studio,zeno_server_url:q.endpoints.zeno,token:n},await fetch(a.redirect,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i(t)):l({title:"Failed to get composable token",status:"error",duration:5e3})}catch(e){t?(o(e),i(t)):l({title:"Error authorizing client",description:e.message,status:"error",duration:5e3})}},c=a?e?t(ue,{payload:e,error:n}):t(me,{clientInfo:a,onAccept:s}):t(h,{title:"Invalid request",children:"This page should be called by a terminal client to authenticate against the ComposablePrompts servers"});return t("div",{className:"w-full flex flex-col items-center gap-4 mt-24",children:c})}function me({onAccept:n,clientInfo:o}){const{client:a,user:l}=T(),{data:r,error:s}=f((()=>l?a.projects.list():Promise.resolve([])),[l]);if(s)return t(h,{title:"Error loading projects",children:s.message});const d=q.isLocalDev?"Local Dev":q.isDev?"Staging":"Production";return l&&r?e(i,{children:[e("div",{className:"w-1/3",children:[e("div",{className:"mb-4 text-xl font-semibold text-gray-800",children:["Authorizing client on ",d," environment."]}),e("div",{className:"mb-2 text-md text-gray-800",children:[t("div",{children:"A client app wants authorization to access the composable prompt servers in your name."}),e("div",{children:["The client app code is ",t("b",{children:o.code}),". You can check if the code is correct in the terminal."]})]}),e("div",{className:"mb-2 text-sm text-gray-600",children:[t("div",{children:"You must choose the target account and project for the client to access."}),t("div",{children:"Also, enter a profile name that will be used to save the authorization in your client configuration."})]})]}),t(he,{onAccept:n,allProjects:r,data:o})]}):t(c,{size:"lg"})}function ue({payload:i,error:o}){const a=r();return e("div",{children:[o?e("div",{children:[e(h,{title:"Failed to send the authorization token to the cli tool",children:['This can happen due to security checks on Safari. The error is "',o.message,'"']}),t("div",{children:"Don't worry, you can still authenticate the cli tool by pasting the authentication token in the terminal. You can close this page."})]}):t("div",{children:"The client is authenticated. You can close this page."}),t(p,{className:"mt-4",children:t(n,{variant:"secondary",onClick:()=>{i&&(navigator.clipboard.writeText(JSON.stringify(i)),a({title:"Authentication Payload copied",description:o?"You can paste the authentication payload in the terminal to authenticate the client.":"You can close the page now.",status:"success",duration:5e3}))},children:"Copy the Authentication Payload"})})]})}function he({allProjects:i,data:o,onAccept:a}){const{accounts:l,account:r,project:c}=T(),[d,m]=P((()=>({profile:o.profile,account:o.account??r?.id,project:o.project??c?.id}))),u=i.filter((e=>e.account===d.account));return e("div",{className:"w-1/3",children:[e("div",{className:"mb-4 flex flex-col gap-2",children:[t("span",{className:"font-semibold text-gray-600",children:"Profile Name"}),t(s,{type:"text",value:d.profile,onChange:e=>{m({...d,profile:e})}})]}),e("div",{className:"mb-4 flex flex-col gap-2",children:[t("span",{className:"font-semibold text-gray-600",children:"Account"}),t(pe,{value:d.account,onChange:e=>{m({...d,account:e.id,project:void 0})},accounts:l||[]})]}),e("div",{className:"mb-4 flex flex-col gap-2",children:[t("span",{className:"font-semibold text-gray-600",children:"Project"}),t(fe,{value:d.project,onChange:e=>{m({...d,project:e.id})},projects:u})]}),t("div",{className:"pt-2",children:t(n,{size:"xl",onClick:()=>a(d),children:"Authorize Client"})})]})}function pe({value:e,accounts:i,onChange:n}){return t(g,{options:i,value:i?.find((t=>t.id===e)),onChange:e=>{n(e)},by:"id",optionLabel:e=>e.name,placeholder:"Select Account"})}function fe({value:e,projects:i,onChange:n}){return t(g,{by:"id",value:i.find((t=>t.id===e)),options:i,optionLabel:e=>e.name,placeholder:"Select Project",onChange:e=>{n(e)}})}function ge({isOpen:i,onClose:r}){return e(o,{isOpen:i,onClose:r,children:[t(a,{children:"Sign In"}),e(l,{className:"flex justify-center",children:[t(ee,{}),t(Z,{}),t(te,{})]}),t(v,{justify:"end",children:t(n,{variant:"ghost",onClick:r,children:"Cancel"})})]})}function ve({title:i,value:n}){const[o,a]=P(!1);return e("div",{className:"w-full flex justify-between items-center mb-1",children:[e("div",{className:"flex flex-col w-[calc(100%-3rem)]",children:[t("div",{className:"text-sm px-2 dark:text-slate-200",children:i}),t(N,{description:n,size:"xs",placement:"left",children:e("div",{className:"text-xs truncate text-muted w-full text-left px-2",children:[n," "]})})]}),o?t(V,{className:"size-4 cursor-pointer text-success"}):t(H,{className:"size-4 cursor-pointer text-gray-400 dark:text-slate-400",onClick:()=>function(e){navigator.clipboard.writeText(e),a(!0),setTimeout((()=>a(!1)),2e3)}(n)})]})}function xe(){const i=T(),{account:n,project:o,client:a,authToken:l}=i,r=new URL(a.baseUrl).hostname,s=new URL(a.store.baseUrl).hostname,c=o?B(o):"",d=[{name:"user",label:"User",content:e("div",{className:"space-y-1 p-2",children:[t(ve,{title:"Organization ID",value:n?.id??"Unknown"}),t(ve,{title:"Project ID",value:o?.id??"Unknown"}),t(ve,{title:"User ID",value:l?.sub??"Unknown"}),t(ve,{title:"Organization Roles",value:l?.account_roles?.join(",")??"Unknown"}),t(ve,{title:"Project Roles",value:l?.project_roles?.join(",")??"Unknown"})]})},{name:"environment",label:"Environment",content:e("div",{className:"space-y-1 p-2",children:[t(ve,{title:"Tenant ID",value:c}),t(ve,{title:"Environment",value:q.type}),t(ve,{title:"Server",value:r}),t(ve,{title:"Store",value:s}),t(ve,{title:"App Version",value:q.version})]})}];return t("div",{className:"w-full",children:e(x,{defaultValue:"user",tabs:d,fullWidth:!0,children:[t(y,{}),t(b,{})]})})}function ye({}){const{user:o,isLoading:a}=T(),[l,r]=P(!1);return a?t(c,{}):o?t("div",{className:"px-3",children:t(be,{asMenuTrigger:!0})}):e(i,{children:[t(n,{onClick:()=>r(!0),children:"Sign In"}),t(ge,{isOpen:l,onClose:()=>r(!1)})]})}function be({className:i,asMenuTrigger:n=!1}){const o=T(),{user:a}=o;return o&&a?e(J,{strategy:"fixed",placement:"bottom-start",zIndex:100,children:[t(J.Trigger,{click:!0,children:t("div",{className:W(i,"flex items-center justify-start",n&&"cursor-pointer"),children:t(w,{size:"sm",color:"bg-amber-500",shape:"circle",name:a?.name})})}),t(J.Content,{className:"w-[280px] mx-2 my-1",children:t("div",{className:"bg-white dark:bg-slate-900 shadow-lg rounded-md ring-1 ring-gray-200 dark:ring-slate-700",children:e("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:[e("div",{className:"py-2 pl-2",children:[t("p",{className:"px-4 dark:text-white mb-1",children:a?.name??"Unknown"}),t("p",{className:"px-4 text-xs text-gray-500",children:a?.email??""})]}),t("div",{className:"w-full p-1",children:t(xe,{})}),t("div",{className:"py-2 pl-2",children:t(k,{})}),t("div",{className:"py-2",children:t(C,{children:t(C.Item,{className:"px-2",onClick:()=>o.logout(),children:"Sign out"})})})]})})})]}):null}function Ne(e){return!!e&&(e.endsWith("@vertesiahq.com")||e.endsWith("@becomposable.com")||e.endsWith("@composableprompts.com"))}function we({}){const{isLoading:e}=T(),[i,n]=P(!0);return z((()=>{e||n(!1)}),[e]),t($,{appear:!0,show:i,as:L,unmount:!0,leave:"transition ease-in duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:t("div",{style:{zIndex:999999},className:"fixed inset-x-0 inset-y-0",children:t("div",{className:"flex w-full h-full items-center justify-center",children:t("div",{className:"animate-[spin_4s_linear_infinite]",children:t("img",{src:"/icon.svg",className:"w-10 h-auto animate-pulse rounded-full"})})})})})}function ke({children:i,lightLogo:n,darkLogo:o}){return t(S,{children:t(E,{children:e(j,{defaultTheme:"system",storageKey:"vite-ui-theme",children:[t(we,{}),t(re,{allowedPrefix:"/shared/",lightLogo:n,darkLogo:o}),t(K,{children:i})]})})})}export{Q as InviteAcceptModal,re as SigninScreen,de as TerminalLogin,ye as UserSessionMenu,ke as VertesiaShell,Ne as isVertesiaEmail};
2
+ //# sourceMappingURL=vertesia-ui-shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertesia-ui-shell.js","sources":["esm/shell/login/InviteAcceptModal.js","esm/shell/login/EnterpriseSigninButton.js","esm/shell/login/GitHubSignInButton.js","esm/shell/login/GoogleSignInButton.js","esm/shell/login/MicrosoftSigninButton.js","esm/shell/login/SignupForm.js","esm/shell/login/SigninScreen.js","esm/shell/login/TerminalLogin.js","esm/shell/login/SignInModal.js","esm/shell/login/UserInfo.js","esm/shell/login/UserSessionMenu.js","esm/shell/utils.js","esm/shell/SplashScreen.js","esm/shell/VertesiaShell.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button, Modal, ModalBody, ModalTitle } from \"@vertesia/ui/core\";\nimport { useEffect, useState } from \"react\";\nimport { useUserSession } from \"@vertesia/ui/session\";\nexport function InviteAcceptModal() {\n const session = useUserSession();\n const { client, account } = session;\n const [showModal, setShowModal] = useState(false);\n const [invites, setInvites] = useState([]);\n useEffect(() => {\n client.account.listInvites().then(invites => {\n if (invites.length > 0) {\n console.log(\"Got invites - showing modal\");\n setInvites(invites);\n /*toast({\n status: 'info',\n title: 'You have pending invites',\n description: 'Click the button on the top right to review them.'\n })*/\n setShowModal(true);\n }\n });\n }, [account?.id]);\n const closeModal = () => setShowModal(false);\n const accept = async (invite) => {\n await client.account.acceptInvite(invite.id);\n await session.fetchAccounts();\n const remainingInvites = invites.filter(i => i.id !== invite.id);\n setInvites(remainingInvites);\n if (remainingInvites.length === 0) {\n closeModal();\n }\n };\n const reject = async (invite) => {\n await client.account.rejectInvite(invite.id);\n const remainingInvites = invites.filter(i => i.id !== invite.id);\n setInvites(remainingInvites);\n if (remainingInvites.length === 0) {\n closeModal();\n }\n };\n const inviteList = invites.map(invite => (_jsxs(\"div\", { className: \"flex flex-row w-full justify-between border rounded-sm px-2 py-2 \", children: [_jsxs(\"div\", { className: \"flex flex-col\", children: [_jsx(\"div\", { className: \"w-full font-semibold\", children: invite.data.account.name }), _jsxs(\"div\", { className: \"text-xs\", children: [\"Role: \", invite.data.role] }), _jsxs(\"div\", { className: \"text-xs\", children: [\"by \", invite.data.invitedBy.name] })] }), _jsxs(\"div\", { className: \"flex flex-col gap-4\", children: [_jsx(Button, { size: 'xs', onClick: () => accept(invite), children: \"Accept\" }), \" \", _jsx(Button, { size: 'xs', variant: \"secondary\", onClick: () => reject(invite), children: \"Reject\" })] })] }, invite.id)));\n return (_jsx(\"div\", { children: _jsxs(Modal, { isOpen: showModal, onClose: closeModal, children: [_jsx(ModalTitle, { children: \"Review Invites\" }), _jsxs(ModalBody, { children: [_jsx(\"div\", { className: \"text-sm pb-4\", children: \"You have received the following invites to join other accounts. Please review and accept or declined them.\" }), inviteList] })] }) }));\n}\n//# sourceMappingURL=InviteAcceptModal.js.map","import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button, Input, Spinner, useToast } from \"@vertesia/ui/core\";\nimport { Env } from \"@vertesia/ui/env\";\nimport { getFirebaseAuth, setFirebaseTenant, useUXTracking } from \"@vertesia/ui/session\";\nimport { GoogleAuthProvider, OAuthProvider, signInWithRedirect } from \"firebase/auth\";\nimport { useState } from \"react\";\nfunction getProvider(redirectTo) {\n const providerType = Env.firebase.providerType;\n switch (providerType) {\n case \"oidc\":\n return new OAuthProvider(\"oidc.main\");\n case \"google\": {\n let redirectPath = redirectTo || window.location.pathname || '/';\n if (redirectPath[0] !== '/') {\n redirectPath = '/' + redirectPath;\n }\n const provider = new GoogleAuthProvider();\n provider.addScope('profile');\n provider.addScope('email');\n provider.setCustomParameters({\n prompt: 'select_account',\n redirect_uri: window.location.origin + redirectPath\n });\n return provider;\n }\n case \"microsoft\":\n return new OAuthProvider(\"microsoft.com\");\n case \"github\":\n return new OAuthProvider(\"github.com\");\n default:\n return new OAuthProvider(\"oidc.main\");\n }\n}\nexport default function EnterpriseSigninButton({ redirectTo }) {\n const [isLoading, setIsLoading] = useState(false);\n const { trackEvent } = useUXTracking();\n const [email, setEmail] = useState(\"\");\n const toast = useToast();\n const signIn = async () => {\n if (!email)\n return;\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!emailRegex.test(email)) {\n toast({\n title: \"Invalid email address\",\n status: \"error\",\n duration: 5000,\n });\n return;\n }\n // Env.firebase.tenantEmail = email;\n setIsLoading(true);\n setFirebaseTenant(email).then((data) => {\n if (!data) {\n toast({\n title: \"Tenant not found\",\n status: \"error\",\n duration: 5000,\n });\n setIsLoading(false);\n return;\n }\n localStorage.setItem(\"tenantName\", data.name ?? \"\");\n const provider = getProvider(redirectTo);\n trackEvent(\"enterprise_signin\", {\n firebaseTenantName: data.name,\n });\n Env.logger.info('Enterprise single sign-in', {\n vertesia: {\n email: email,\n firebaseTenantName: data.name,\n firebaseTenantId: data.firebaseTenantId,\n },\n });\n signInWithRedirect(getFirebaseAuth(), provider);\n setIsLoading(false);\n });\n };\n return (_jsxs(_Fragment, { children: [_jsx(Input, { value: email, onChange: setEmail, placeholder: \"Enter your enterprise email\", type: \"email\" }), isLoading ? (_jsx(\"div\", { className: \"w-full flex justify-center\", children: _jsx(Spinner, {}) })) : (_jsx(Button, { variant: \"outline\", onClick: signIn, className: \"w-full mt-2 py-4 flex rounded-lg hover:shadow-sm transition duration-150 text-center\", children: _jsx(\"span\", { className: \"text-sm font-semibold\", children: \"Continue with Enterprise SSO\" }) }))] }));\n}\n//# sourceMappingURL=EnterpriseSigninButton.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { GithubAuthProvider, signInWithRedirect } from \"firebase/auth\";\nimport { getFirebaseAuth } from \"@vertesia/ui/session\";\nimport { Button } from \"@vertesia/ui/core\";\nexport default function GitHubSignInButton({}) {\n const signIn = () => {\n localStorage.removeItem(\"tenantName\");\n //with github can only have one allowed redirect\n const baseUrl = \"https://dengenlabs.firebaseapp.com/__/auth/handler\";\n let redirectPath = baseUrl + window.location.pathname;\n if (redirectPath[0] !== \"/\") {\n redirectPath = \"/\" + redirectPath;\n }\n const provider = new GithubAuthProvider();\n provider.addScope(\"profile\");\n provider.addScope(\"email\");\n /*provider.setCustomParameters({\n redirect_uri: redirectPath,\n });*/\n signInWithRedirect(getFirebaseAuth(), provider);\n };\n return (_jsxs(Button, { variant: \"outline\", onClick: signIn, className: \"w-full py-5 flex rounded-lg hover:shadow-sm transition duration-150 text-center mb-2\", children: [_jsx(\"img\", { className: \"size-6 bg-white rounded-full\", src: \"https://www.svgrepo.com/show/503359/github.svg\", loading: \"lazy\", alt: \"github logo\" }), _jsx(\"span\", { className: \"text-sm font-semibold\", children: \"Continue with GitHub\" })] }));\n}\n//# sourceMappingURL=GitHubSignInButton.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { GoogleAuthProvider, signInWithRedirect } from \"firebase/auth\";\nimport { getFirebaseAuth } from \"@vertesia/ui/session\";\nimport { Button } from \"@vertesia/ui/core\";\nexport default function GoogleSignInButton({ redirectTo }) {\n const signIn = () => {\n localStorage.removeItem(\"tenantName\");\n let redirectPath = redirectTo || window.location.pathname || '/';\n if (redirectPath[0] !== '/') {\n redirectPath = '/' + redirectPath;\n }\n const provider = new GoogleAuthProvider();\n provider.addScope('profile');\n provider.addScope('email');\n // always ask to select the google account\n //console.log('redirectPath', window.location.origin + redirectPath)\n provider.setCustomParameters({\n prompt: 'select_account',\n redirect_uri: window.location.origin + redirectPath\n });\n signInWithRedirect(getFirebaseAuth(), provider);\n };\n return (_jsxs(Button, { variant: \"outline\", onClick: signIn, className: \"w-full py-5 flex rounded-lg hover:shadow-sm transition duration-150 text-center mb-2\", children: [_jsx(\"img\", { className: \"size-6\", src: \"https://www.svgrepo.com/show/475656/google-color.svg\", loading: \"lazy\", alt: \"google logo\" }), _jsx(\"span\", { className: \"text-sm font-semibold\", children: \"Continue with Google\" })] }));\n}\n//# sourceMappingURL=GoogleSignInButton.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { OAuthProvider, signInWithRedirect } from \"firebase/auth\";\nimport { getFirebaseAuth } from \"@vertesia/ui/session\";\nimport { Button } from \"@vertesia/ui/core\";\nexport default function MicrosoftSignInButton({ redirectTo }) {\n const signIn = () => {\n localStorage.removeItem(\"tenantName\");\n let redirectPath = redirectTo || window.location.pathname || '/';\n if (redirectPath[0] !== '/') {\n redirectPath = '/' + redirectPath;\n }\n const provider = new OAuthProvider('microsoft.com');\n provider.addScope('profile');\n provider.addScope('email');\n signInWithRedirect(getFirebaseAuth(), provider);\n };\n return (_jsxs(Button, { variant: \"outline\", onClick: signIn, className: \"w-full py-5 flex rounded-lg hover:shadow-sm transition duration-150 text-center\", children: [_jsx(\"img\", { className: \"size-6\", src: \"https://learn.microsoft.com/en-us/entra/identity-platform/media/howto-add-branding-in-apps/ms-symbollockup_mssymbol_19.svg\", loading: \"lazy\", alt: \"microsoft logo\" }), _jsx(\"span\", { className: \"text-sm font-semibold\", children: \"Continue with Microsoft\" })] }));\n}\n//# sourceMappingURL=MicrosoftSigninButton.js.map","import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { Button, Input, VSelectBox, SelectStack } from \"@vertesia/ui/core\";\nimport { getAuth } from \"firebase/auth\";\nimport { useEffect, useState } from \"react\";\nconst companySizeOptions = [\n { id: 1, label: \"1-10 employees\" },\n { id: 11, label: \"11-100 employees\" },\n { id: 101, label: \"101-1000 employees\" },\n { id: 1001, label: \"1001-5000 employees\" },\n { id: 5001, label: \"5000+ employees\" },\n];\nconst accountTypeOptions = [\n {\n id: \"personal\",\n label: \"Personal\",\n description: \"For personal use, or for a small team.\",\n },\n {\n id: \"company\",\n label: \"Company\",\n description: \"For a company or organization.\",\n },\n];\nconst projectMaturityOptions = [\n { id: \"testing\", label: \"Just Testing or Evaluating LLMs\" },\n { id: \"exploring\", label: \"Actively Exploring LLMs on a Project\" },\n { id: \"using\", label: \"Already Using LLMs in Production\" },\n { id: \"migrating\", label: \"Migrating to different LLMs\" },\n { id: \"other\", label: \"Other\" },\n];\nexport default function SignupForm({ onSignup, goBack }) {\n const [accountType, setAccountType] = useState(undefined);\n const [companySize, setCompanySize] = useState(undefined);\n const [companyName, setCompanyName] = useState(undefined);\n const [companyWebsite, setCompanyWebsite] = useState(undefined);\n const [projectMaturity, setProjectMaturity] = useState(undefined);\n const [fbUser, setFbUser] = useState(undefined);\n const [error, setError] = useState(undefined);\n const isCompany = accountType === \"company\";\n useEffect(() => {\n const user = getAuth().currentUser;\n if (!user) {\n console.error('No user found');\n return;\n }\n setFbUser(user);\n }, [fbUser]);\n const isValid = () => {\n if (!accountType) {\n setError(\"Please select an account type\");\n return false;\n }\n if (isCompany && !companyName) {\n setError(\"Please enter an organization name\");\n return false;\n }\n if (isCompany && !companySize) {\n setError(\"Please select a company size\");\n return false;\n }\n return true;\n };\n const onSubmit = async () => {\n if (!isValid())\n return;\n if (!accountType)\n return;\n const signupData = {\n accountType: accountType,\n companyName: companyName,\n companySize: companySize?.id,\n companyWebsite: companyWebsite,\n maturity: projectMaturity,\n };\n window.localStorage.setItem(\"composableSignupData\", JSON.stringify(signupData));\n const fbToken = await getAuth().currentUser?.getIdToken();\n console.log('Got firebase token', getAuth(), fbToken);\n if (!fbToken) {\n console.error('No firebase token found');\n return;\n }\n onSignup(signupData, fbToken);\n };\n return (_jsxs(\"div\", { className: \"flex flex-col space-y-2\", children: [_jsxs(\"div\", { className: \"prose\", children: [_jsxs(\"p\", { className: \"prose text-sm text-muted pt-4\", children: [\"Welcome to Vertesia, \", fbUser?.displayName, \" (\", fbUser?.email, \"). Please tell us a little bit about yourself and you'll be on your way. No credit card is required.\"] }), error &&\n _jsx(\"div\", { className: \"text-destructive\", children: error })] }), _jsx(FormItem, { label: \"Account Type\", children: _jsx(SelectStack, { options: accountTypeOptions, selected: accountTypeOptions.find((option) => option.id === accountType), onSelect: (option) => setAccountType(option.id) }) }), isCompany &&\n _jsxs(_Fragment, { children: [_jsx(FormItem, { label: \"Company Size\", children: _jsx(VSelectBox, { className: \"w-full border border-accent bg-muted\", value: companySize, options: companySizeOptions, onChange: setCompanySize, optionLabel: (option) => option?.label, placeholder: 'Select Company Size' }) }), _jsx(FormItem, { label: \"Company Name\", children: _jsx(Input, { value: companyName, onChange: setCompanyName, type: \"text\", required: true }) }), _jsx(FormItem, { label: \"Company Website\", children: _jsx(Input, { value: companyWebsite, onChange: setCompanyWebsite, type: \"text\" }) })] }), _jsx(FormItem, { label: \"Project Maturity\", children: _jsx(VSelectBox, { className: \"w-full border border-accent bg-muted\", options: projectMaturityOptions, value: projectMaturityOptions.find((option) => option.id === projectMaturity), optionLabel: (option) => option?.label, placeholder: 'Select Project Maturity', onChange: (option) => setProjectMaturity(option?.id) }) }), _jsxs(\"div\", { className: \"pt-8 flex flex-col\", children: [_jsx(Button, { variant: \"primary\", onClick: onSubmit, size: \"xl\", children: _jsx(\"span\", { className: \"text-lg\", children: \"Sign Up\" }) }), _jsx(Button, { variant: \"ghost\", size: \"xl\", className: \"mt-4\", onClick: goBack, children: _jsx(\"span\", { className: \"\", children: \"Wrong account, go back\" }) })] })] }));\n}\nfunction FormItem({ label, children }) {\n return (_jsxs(\"div\", { className: \"flex flex-col space-y-2 pt-4\", children: [_jsx(\"div\", { className: \"text-sm text-muted\", children: label }), children] }));\n}\n//# sourceMappingURL=SignupForm.js.map","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { Button, useSafeLayoutEffect } from \"@vertesia/ui/core\";\nimport { Env } from \"@vertesia/ui/env\";\nimport { UserNotFoundError, useUserSession, useUXTracking } from \"@vertesia/ui/session\";\nimport clsx from \"clsx\";\nimport { useEffect, useState } from \"react\";\nimport EnterpriseSigninButton from \"./EnterpriseSigninButton\";\nimport GitHubSignInButton from \"./GitHubSignInButton\";\nimport GoogleSignInButton from \"./GoogleSignInButton\";\nimport MicrosoftSignInButton from \"./MicrosoftSigninButton\";\nimport SignupForm from \"./SignupForm\";\nexport function SigninScreen({ allowedPrefix, isNested = false, lightLogo, darkLogo }) {\n const [allow, setAllow] = useState(false);\n useSafeLayoutEffect(() => {\n allowedPrefix && setAllow(window.location.href.startsWith(allowedPrefix));\n }, []);\n return allow ? null : _jsx(SigninScreenImpl, { isNested: isNested, lightLogo: lightLogo, darkLogo: darkLogo });\n}\nfunction SigninScreenImpl({ isNested = false, lightLogo, darkLogo }) {\n const { isLoading, user, authError } = useUserSession();\n return !isLoading && !user ? (_jsx(\"div\", { style: { zIndex: 999998 }, className: (isNested ? \"absolute\" : \"fixed\") + \"overflow-y-auto \", children: _jsxs(\"div\", { className: clsx(\"flex flex-col items-center justify-center py-14 px-4\"), children: [_jsx(StandardSigninPanel, { authError: authError, lightLogo: lightLogo, darkLogo: darkLogo }), _jsxs(\"div\", { className: \"flex gap-x-6 mt-10 justify-center text-muted\", children: [_jsx(\"a\", { href: \"https://vertesiahq.com/privacy\", className: \"text-sm\", children: \"Privacy Policy\" }), _jsx(\"a\", { href: \"https://vertesiahq.com/terms\", className: \"text-sm\", children: \"Terms of Service\" })] })] }) })) : null;\n}\nfunction StandardSigninPanel({ authError, darkLogo, lightLogo }) {\n const [signupData, setSignupData] = useState(undefined);\n const [collectSignupData, setCollectSignupData] = useState(false);\n const { signOut } = useUserSession();\n const { trackEvent } = useUXTracking();\n history.replaceState({}, '', '/');\n const goBack = () => {\n console.log(\"Going back, signing out\");\n setSignupData(undefined);\n setCollectSignupData(false);\n signOut();\n };\n const goToSignup = () => {\n setSignupData(undefined);\n setCollectSignupData(true);\n };\n useEffect(() => {\n if (authError instanceof UserNotFoundError) {\n console.log(\"User not found, redirecting to signup\");\n goToSignup();\n }\n }, [authError]);\n const onSignup = (data, fbToken) => {\n console.log(\"Got Signup data\", data);\n setSignupData(data);\n const payload = {\n signupData: data,\n firebaseToken: fbToken,\n };\n fetch(Env.endpoints.studio + \"/auth/signup\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n }).then((res) => {\n console.log(\"Signup successful\", payload, res);\n trackEvent(\"sign_up\");\n window.location.href = \"/\";\n });\n };\n return (_jsxs(_Fragment, { children: [lightLogo && _jsx(\"img\", { src: lightLogo, alt: 'logo', className: 'h-15 block dark:hidden' }), darkLogo && _jsx(\"img\", { src: darkLogo, alt: 'logo', className: 'h-15 hidden dark:block' }), signupData && (_jsxs(\"div\", { className: \"my-6\", children: [\"Need to make a change?\", \" \", _jsx(Button, { onClick: goToSignup, children: \" Go back\" })] })), _jsx(\"div\", { className: \"flex flex-col space-y-2\", children: collectSignupData && !localStorage.getItem('tenantName') ? (_jsx(SignupForm, { onSignup: onSignup, goBack: goBack })) : (_jsxs(\"div\", { className: \"flex flex-col\", children: [_jsx(\"div\", { className: \"my-4\", children: _jsx(\"h2\", { className: \"text-2xl font-bold text-center\", children: \"Log in or Sign up\" }) }), _jsxs(\"div\", { className: \"max-w-2xl text-center my-2 px-2\", children: [\"First time here? No problem, it's free to try!\", _jsx(\"br\", {}), \"We'll just ask you a couple of questions next and you'll be on your way.\"] }), _jsxs(\"div\", { className: \"flex items-center flex-col\", children: [_jsxs(\"div\", { className: \"py-4 w-70\", children: [_jsx(GoogleSignInButton, {}), _jsx(GitHubSignInButton, {}), _jsx(MicrosoftSignInButton, {})] }), _jsxs(\"div\", { className: \"flex items-center flex-row w-70 text-muted\", children: [_jsx(\"hr\", { className: \"w-full\" }), _jsx(\"div\", { className: \"px-2 text-xs\", children: \"OR\" }), _jsx(\"hr\", { className: \"w-full\" })] }), _jsx(\"div\", { className: \"py-4 w-70\", children: _jsx(EnterpriseSigninButton, {}) })] }), authError && (_jsx(\"div\", { className: \"text-center\", children: _jsxs(\"div\", { className: \"\", children: [\"Sorry, we have not been able to sign you in.\", _jsx(\"br\", {}), \"Please try again or contact\", _jsx(\"a\", { className: 'text-info mx-1', href: \"mailto:support@vertesiahq.com\", children: \"support@vertesiahq.com\" }), \"if it persists.\", _jsxs(\"pre\", { className: \"mt-2\", children: [\"Error: \", authError.message] })] }) }))] })) })] }));\n}\n//# sourceMappingURL=SigninScreen.js.map","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { useState } from 'react';\nimport { Button, Center, ErrorBox, Input, SelectBox, Spinner, useFetch, useToast } from '@vertesia/ui/core';\nimport { Env } from \"@vertesia/ui/env\";\nimport { useLocation } from \"@vertesia/ui/router\";\nimport { fetchComposableTokenFromFirebaseToken, useUserSession } from '@vertesia/ui/session';\nfunction getClientInfo(location) {\n const params = new URLSearchParams(location.search);\n let redirect = params.get('redirect_uri');\n const code = params.get('code');\n if (!redirect || !code) {\n return null;\n }\n redirect = decodeURI(redirect);\n if (!redirect.startsWith('http://127.0.0.1:') && !redirect.startsWith('http://localhost:')) {\n return null;\n }\n const profile = params.get('profile') ?? \"default\";\n const project = params.get('project') ?? undefined;\n const account = params.get('account') ?? undefined;\n return { redirect, code, profile, project, account };\n}\nexport function TerminalLogin() {\n const [payload, setPayload] = useState();\n const [error, setError] = useState();\n const location = useLocation();\n const clientInfo = getClientInfo(location);\n const toast = useToast();\n const onAccept = async (data) => {\n if (!clientInfo)\n return;\n if (!data.profile) {\n toast({\n title: 'Profile is required',\n description: 'Please enter a profile name to save the client authorization',\n status: 'error',\n duration: 2000\n });\n return;\n }\n if (!data.account) {\n toast({\n title: 'Account is required',\n description: 'Please select an account to authorize the client to access the ComposablePrompts servers',\n status: 'error',\n duration: 2000\n });\n return;\n }\n if (!data.project) {\n toast({\n title: 'Project is required',\n description: 'Please select a project to authorize the client to access the ComposablePrompts servers',\n status: 'error',\n duration: 2000\n });\n return;\n }\n // expire in 1 day\n let payload;\n try {\n const token = await fetchComposableTokenFromFirebaseToken(data.account, data.project, 24 * 3600);\n if (token) {\n payload = {\n ...data,\n studio_server_url: Env.endpoints.studio,\n zeno_server_url: Env.endpoints.zeno,\n token,\n };\n await fetch(clientInfo.redirect, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(payload)\n });\n setPayload(payload);\n }\n else {\n toast({\n title: 'Failed to get composable token',\n status: 'error',\n duration: 5000\n });\n }\n }\n catch (err) {\n if (payload) {\n setError(err);\n setPayload(payload);\n }\n else {\n toast({\n title: 'Error authorizing client',\n description: err.message,\n status: 'error',\n duration: 5000\n });\n }\n }\n };\n const getPageContent = () => {\n if (!clientInfo) {\n return _jsx(ErrorBox, { title: 'Invalid request', children: \"This page should be called by a terminal client to authenticate against the ComposablePrompts servers\" });\n }\n return payload\n ? _jsx(AuthDoneScreen, { payload: payload, error: error })\n : _jsx(AuthAcceptScreen, { clientInfo: clientInfo, onAccept: onAccept });\n };\n const page = getPageContent();\n return (_jsx(\"div\", { className: \"w-full flex flex-col items-center gap-4 mt-24\", children: page }));\n}\nfunction AuthAcceptScreen({ onAccept, clientInfo }) {\n const { client, user } = useUserSession();\n const { data: allProjects, error } = useFetch(() => user ? client.projects.list() : Promise.resolve([]), [user]);\n if (error) {\n return _jsx(ErrorBox, { title: 'Error loading projects', children: error.message });\n }\n const getEnvironmentName = () => {\n if (Env.isLocalDev) {\n return \"Local Dev\";\n }\n else if (Env.isDev) {\n return \"Staging\";\n }\n return \"Production\";\n };\n const envName = getEnvironmentName();\n return user && allProjects ? (_jsxs(_Fragment, { children: [_jsxs(\"div\", { className: 'w-1/3', children: [_jsxs(\"div\", { className: \"mb-4 text-xl font-semibold text-gray-800\", children: [\"Authorizing client on \", envName, \" environment.\"] }), _jsxs(\"div\", { className: 'mb-2 text-md text-gray-800', children: [_jsx(\"div\", { children: \"A client app wants authorization to access the composable prompt servers in your name.\" }), _jsxs(\"div\", { children: [\"The client app code is \", _jsx(\"b\", { children: clientInfo.code }), \". You can check if the code is correct in the terminal.\"] })] }), _jsxs(\"div\", { className: 'mb-2 text-sm text-gray-600', children: [_jsx(\"div\", { children: \"You must choose the target account and project for the client to access.\" }), _jsx(\"div\", { children: \"Also, enter a profile name that will be used to save the authorization in your client configuration.\" })] })] }), _jsx(ProfileForm, { onAccept: onAccept, allProjects: allProjects, data: clientInfo })] })) : _jsx(Spinner, { size: 'lg' });\n}\nfunction AuthDoneScreen({ payload, error }) {\n const toast = useToast();\n const onCopy = () => {\n if (payload) {\n navigator.clipboard.writeText(JSON.stringify(payload));\n toast({\n title: 'Authentication Payload copied',\n description: error ? 'You can paste the authentication payload in the terminal to authenticate the client.' : 'You can close the page now.',\n status: 'success',\n duration: 5000\n });\n }\n };\n return (_jsxs(\"div\", { children: [error ?\n _jsxs(\"div\", { children: [_jsxs(ErrorBox, { title: 'Failed to send the authorization token to the cli tool', children: [\"This can happen due to security checks on Safari. The error is \\\"\", error.message, \"\\\"\"] }), _jsx(\"div\", { children: \"Don't worry, you can still authenticate the cli tool by pasting the authentication token in the terminal. You can close this page.\" })] })\n : _jsx(\"div\", { children: \"The client is authenticated. You can close this page.\" }), _jsx(Center, { className: \"mt-4\", children: _jsx(Button, { variant: 'secondary', onClick: onCopy, children: \"Copy the Authentication Payload\" }) })] }));\n}\nfunction ProfileForm({ allProjects, data, onAccept }) {\n const { accounts, account, project } = useUserSession();\n const [currentData, setCurrentData] = useState(() => ({\n profile: data.profile,\n account: data.account ?? account?.id,\n project: data.project ?? project?.id,\n }));\n const onChangeProfile = (value) => {\n setCurrentData({ ...currentData, profile: value });\n };\n const onChangeAccount = (value) => {\n setCurrentData({ ...currentData, account: value.id, project: undefined });\n };\n const onChangeProject = (value) => {\n setCurrentData({ ...currentData, project: value.id });\n };\n const projects = allProjects.filter(p => p.account === currentData.account);\n return (_jsxs(\"div\", { className: 'w-1/3', children: [_jsxs(\"div\", { className: \"mb-4 flex flex-col gap-2\", children: [_jsx(\"span\", { className: \"font-semibold text-gray-600\", children: \"Profile Name\" }), _jsx(Input, { type: 'text', value: currentData.profile, onChange: onChangeProfile })] }), _jsxs(\"div\", { className: \"mb-4 flex flex-col gap-2\", children: [_jsx(\"span\", { className: \"font-semibold text-gray-600\", children: \"Account\" }), _jsx(SelectAccount, { value: currentData.account, onChange: onChangeAccount, accounts: accounts || [] })] }), _jsxs(\"div\", { className: \"mb-4 flex flex-col gap-2\", children: [_jsx(\"span\", { className: \"font-semibold text-gray-600\", children: \"Project\" }), _jsx(SelectProject, { value: currentData.project, onChange: onChangeProject, projects: projects })] }), _jsx(\"div\", { className: \"pt-2\", children: _jsx(Button, { size: 'xl', onClick: () => onAccept(currentData), children: \"Authorize Client\" }) })] }));\n}\nfunction SelectAccount({ value, accounts, onChange }) {\n const _onChange = (value) => {\n onChange(value);\n };\n return _jsx(SelectBox, { options: accounts, value: accounts?.find(a => a.id === value), onChange: _onChange, by: \"id\", optionLabel: (option) => option.name, placeholder: 'Select Account' });\n}\nfunction SelectProject({ value, projects, onChange }) {\n const _onChange = (value) => {\n onChange(value);\n };\n return (_jsx(SelectBox, { by: \"id\", value: projects.find(p => p.id === value), options: projects, optionLabel: (option) => option.name, placeholder: 'Select Project', onChange: _onChange }));\n}\n//# sourceMappingURL=TerminalLogin.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button, Modal, ModalBody, ModalFooter, ModalTitle } from \"@vertesia/ui/core\";\nimport GitHubSignInButton from \"./GitHubSignInButton\";\nimport GoogleSignInButton from \"./GoogleSignInButton\";\nimport MicrosoftSignInButton from \"./MicrosoftSigninButton\";\nexport default function SignInModal({ isOpen, onClose }) {\n return (_jsxs(Modal, { isOpen: isOpen, onClose: onClose, children: [_jsx(ModalTitle, { children: \"Sign In\" }), _jsxs(ModalBody, { className: \"flex justify-center\", children: [_jsx(GoogleSignInButton, {}), _jsx(GitHubSignInButton, {}), _jsx(MicrosoftSignInButton, {})] }), _jsx(ModalFooter, { justify: \"end\", children: _jsx(Button, { variant: \"ghost\", onClick: onClose, children: \"Cancel\" }) })] }));\n}\n//# sourceMappingURL=SignInModal.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { getTenantIdFromProject } from \"@vertesia/common\";\nimport { VTabs, VTabsBar, VTabsPanel, VTooltip } from \"@vertesia/ui/core\";\nimport { Env } from \"@vertesia/ui/env\";\nimport { useUserSession } from \"@vertesia/ui/session\";\nimport { Check, CopyIcon } from \"lucide-react\";\nimport { useState } from \"react\";\nexport function InfoItems({ title, value }) {\n function copyToClipboard(value) {\n navigator.clipboard.writeText(value);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n }\n const [isCopied, setIsCopied] = useState(false);\n return (_jsxs(\"div\", { className: \"w-full flex justify-between items-center mb-1\", children: [_jsxs(\"div\", { className: \"flex flex-col w-[calc(100%-3rem)]\", children: [_jsx(\"div\", { className: 'text-sm px-2 dark:text-slate-200', children: title }), _jsx(VTooltip, { description: value, size: \"xs\", placement: \"left\", children: _jsxs(\"div\", { className: 'text-xs truncate text-muted w-full text-left px-2', children: [value, \" \"] }) })] }), isCopied ?\n _jsx(Check, { className: \"size-4 cursor-pointer text-success\" })\n :\n _jsx(CopyIcon, { className: \"size-4 cursor-pointer text-gray-400 dark:text-slate-400\", onClick: () => copyToClipboard(value) })] }));\n}\nexport default function InfoList() {\n const session = useUserSession();\n const { account, project, client, authToken } = session;\n const server = new URL(client.baseUrl).hostname;\n const store = new URL(client.store.baseUrl).hostname;\n const tenantId = project ? getTenantIdFromProject(project) : '';\n const tabs = [\n {\n name: 'user',\n label: 'User',\n content: _jsxs(\"div\", { className: \"space-y-1 p-2\", children: [_jsx(InfoItems, { title: \"Organization ID\", value: account?.id ?? 'Unknown' }), _jsx(InfoItems, { title: \"Project ID\", value: project?.id ?? 'Unknown' }), _jsx(InfoItems, { title: \"User ID\", value: authToken?.sub ?? 'Unknown' }), _jsx(InfoItems, { title: \"Organization Roles\", value: authToken?.account_roles?.join(',') ?? 'Unknown' }), _jsx(InfoItems, { title: \"Project Roles\", value: authToken?.project_roles?.join(',') ?? 'Unknown' })] })\n },\n {\n name: 'environment',\n label: 'Environment',\n content: _jsxs(\"div\", { className: \"space-y-1 p-2\", children: [_jsx(InfoItems, { title: \"Tenant ID\", value: tenantId }), _jsx(InfoItems, { title: \"Environment\", value: Env.type }), _jsx(InfoItems, { title: \"Server\", value: server }), _jsx(InfoItems, { title: \"Store\", value: store }), _jsx(InfoItems, { title: \"App Version\", value: Env.version })] })\n }\n ];\n return (_jsx(\"div\", { className: \"w-full\", children: _jsxs(VTabs, { defaultValue: \"user\", tabs: tabs, fullWidth: true, children: [_jsx(VTabsBar, {}), _jsx(VTabsPanel, {})] }) }));\n}\n//# sourceMappingURL=UserInfo.js.map","import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Avatar, Button, MenuList, ModeToggle, Spinner } from \"@vertesia/ui/core\";\nimport { useUserSession } from \"@vertesia/ui/session\";\nimport { Popover } from \"@vertesia/ui/widgets\";\nimport clsx from \"clsx\";\nimport { useState } from \"react\";\nimport SignInModal from \"./SignInModal\";\nimport InfoList from \"./UserInfo\";\nexport function UserSessionMenu({}) {\n const { user, isLoading } = useUserSession();\n const [showModal, setShowModal] = useState(false);\n if (isLoading) {\n return _jsx(Spinner, {});\n }\n else if (!user) {\n return _jsxs(_Fragment, { children: [_jsx(Button, { onClick: () => setShowModal(true), children: \"Sign In\" }), _jsx(SignInModal, { isOpen: showModal, onClose: () => setShowModal(false) })] });\n }\n else {\n return (_jsx(\"div\", { className: \"px-3\", children: _jsx(UserSessionPopup, { asMenuTrigger: true }) }));\n }\n}\nfunction UserSessionPopup({ className, asMenuTrigger = false }) {\n const session = useUserSession();\n const { user } = session;\n if (!session || !user)\n return null;\n return (_jsxs(Popover, { strategy: 'fixed', placement: 'bottom-start', zIndex: 100, children: [_jsx(Popover.Trigger, { click: true, children: _jsx(\"div\", { className: clsx(className, \"flex items-center justify-start\", asMenuTrigger && \"cursor-pointer\"), children: _jsx(Avatar, { size: 'sm', color: 'bg-amber-500', shape: 'circle', \n /*src={picture} */\n name: user?.name }) }) }), _jsx(Popover.Content, { className: \"w-[280px] mx-2 my-1\", children: _jsx(\"div\", { className: \"bg-white dark:bg-slate-900 shadow-lg rounded-md ring-1 ring-gray-200 dark:ring-slate-700\", children: _jsxs(\"div\", { className: 'divide-y divide-gray-200 dark:divide-slate-700', children: [_jsxs(\"div\", { className: 'py-2 pl-2', children: [_jsx(\"p\", { className: \"px-4 dark:text-white mb-1\", children: user?.name ?? 'Unknown' }), _jsx(\"p\", { className: \"px-4 text-xs text-gray-500\", children: user?.email ?? '' })] }), _jsx(\"div\", { className: \"w-full p-1\", children: _jsx(InfoList, {}) }), _jsx(\"div\", { className: 'py-2 pl-2', children: _jsx(ModeToggle, {}) }), _jsx(\"div\", { className: 'py-2', children: _jsx(MenuList, { children: _jsx(MenuList.Item, { className: 'px-2', onClick: () => session.logout(), children: \"Sign out\" }) }) })] }) }) })] }));\n}\n//# sourceMappingURL=UserSessionMenu.js.map","export function isVertesiaEmail(email) {\n return email ? (email.endsWith('@vertesiahq.com') ||\n email.endsWith('@becomposable.com') ||\n email.endsWith('@composableprompts.com')) : false;\n}\n//# sourceMappingURL=utils.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { Transition } from \"@headlessui/react\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useUserSession } from \"@vertesia/ui/session\";\nexport function SplashScreen({}) {\n const { isLoading } = useUserSession();\n const [show, setShow] = useState(true);\n useEffect(() => {\n if (!isLoading) {\n setShow(false);\n }\n // setTimeout(() => {\n // setShow(false)\n // }, 2000)\n }, [isLoading]);\n // 300 500 700 1000\n return (_jsx(Transition, { appear: true, show: show, as: Fragment, unmount: true, leave: \"transition ease-in duration-500\", leaveFrom: \"opacity-100\", leaveTo: \"opacity-0\", children: _jsx(\"div\", { style: { zIndex: 999999 }, className: 'fixed inset-x-0 inset-y-0', children: _jsx(\"div\", { className: \"flex w-full h-full items-center justify-center\", children: _jsx(\"div\", { className: \"animate-[spin_4s_linear_infinite]\", children: _jsx(\"img\", { src: '/icon.svg', className: 'w-10 h-auto animate-pulse rounded-full' }) }) }) }) }));\n}\n//# sourceMappingURL=SplashScreen.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { ThemeProvider, ToastProvider } from \"@vertesia/ui/core\";\nimport { UserPermissionProvider } from \"@vertesia/ui/features\";\nimport { UserSessionProvider } from \"@vertesia/ui/session\";\nimport { SplashScreen } from \"./SplashScreen\";\nimport { SigninScreen } from \"./login/SigninScreen\";\nexport function VertesiaShell({ children, lightLogo, darkLogo }) {\n return (_jsx(ToastProvider, { children: _jsx(UserSessionProvider, { children: _jsxs(ThemeProvider, { defaultTheme: \"system\", storageKey: \"vite-ui-theme\", children: [_jsx(SplashScreen, {}), _jsx(SigninScreen, { allowedPrefix: \"/shared/\", lightLogo: lightLogo, darkLogo: darkLogo }), _jsx(UserPermissionProvider, { children: children })] }) }) }));\n}\n//# sourceMappingURL=VertesiaShell.js.map"],"names":["InviteAcceptModal","session","useUserSession","client","account","showModal","setShowModal","useState","invites","setInvites","useEffect","listInvites","then","length","console","log","id","closeModal","inviteList","map","invite","_jsxs","className","children","_jsx","data","name","role","invitedBy","Button","size","onClick","async","acceptInvite","fetchAccounts","remainingInvites","filter","i","accept","variant","rejectInvite","reject","Modal","isOpen","onClose","ModalTitle","ModalBody","EnterpriseSigninButton","redirectTo","isLoading","setIsLoading","trackEvent","useUXTracking","email","setEmail","toast","useToast","_Fragment","Input","value","onChange","placeholder","type","Spinner","test","setFirebaseTenant","title","status","duration","localStorage","setItem","provider","Env","firebase","providerType","OAuthProvider","redirectPath","window","location","pathname","GoogleAuthProvider","addScope","setCustomParameters","prompt","redirect_uri","origin","getProvider","firebaseTenantName","logger","info","vertesia","firebaseTenantId","signInWithRedirect","getFirebaseAuth","GitHubSignInButton","removeItem","GithubAuthProvider","src","loading","alt","GoogleSignInButton","MicrosoftSignInButton","companySizeOptions","label","accountTypeOptions","description","projectMaturityOptions","SignupForm","onSignup","goBack","accountType","setAccountType","undefined","companySize","setCompanySize","companyName","setCompanyName","companyWebsite","setCompanyWebsite","projectMaturity","setProjectMaturity","fbUser","setFbUser","error","setError","isCompany","user","getAuth","currentUser","displayName","FormItem","SelectStack","options","selected","find","option","onSelect","VSelectBox","optionLabel","required","signupData","maturity","JSON","stringify","fbToken","getIdToken","SigninScreen","allowedPrefix","isNested","lightLogo","darkLogo","allow","setAllow","useSafeLayoutEffect","href","startsWith","SigninScreenImpl","authError","style","zIndex","clsx","StandardSigninPanel","setSignupData","collectSignupData","setCollectSignupData","signOut","history","replaceState","goToSignup","UserNotFoundError","getItem","payload","firebaseToken","fetch","endpoints","studio","method","headers","body","res","message","TerminalLogin","setPayload","clientInfo","params","URLSearchParams","search","redirect","get","code","decodeURI","profile","project","getClientInfo","useLocation","onAccept","token","fetchComposableTokenFromFirebaseToken","studio_server_url","zeno_server_url","zeno","err","page","AuthDoneScreen","AuthAcceptScreen","ErrorBox","allProjects","useFetch","projects","list","Promise","resolve","envName","isLocalDev","isDev","ProfileForm","Center","navigator","clipboard","writeText","accounts","currentData","setCurrentData","p","SelectAccount","SelectProject","SelectBox","a","by","SignInModal","ModalFooter","justify","InfoItems","isCopied","setIsCopied","VTooltip","placement","Check","CopyIcon","setTimeout","copyToClipboard","InfoList","authToken","server","URL","baseUrl","hostname","store","tenantId","getTenantIdFromProject","tabs","content","sub","account_roles","join","project_roles","version","VTabs","defaultValue","fullWidth","VTabsBar","VTabsPanel","UserSessionMenu","UserSessionPopup","asMenuTrigger","Popover","strategy","Trigger","click","Avatar","color","shape","Content","ModeToggle","MenuList","Item","logout","isVertesiaEmail","endsWith","SplashScreen","show","setShow","Transition","appear","as","Fragment","unmount","leave","leaveFrom","leaveTo","VertesiaShell","ToastProvider","UserSessionProvider","ThemeProvider","defaultTheme","storageKey","UserPermissionProvider"],"mappings":"4sCAIO,SAASA,IACZ,MAAMC,EAAUC,KACVC,OAAEA,EAAMC,QAAEA,GAAYH,GACrBI,EAAWC,GAAgBC,GAAS,IACpCC,EAASC,GAAcF,EAAS,IACvCG,GAAU,KACNP,EAAOC,QAAQO,cAAcC,MAAKJ,IAC1BA,EAAQK,OAAS,IACjBC,QAAQC,IAAI,+BACZN,EAAWD,GAMXF,GAAa,SAGtB,C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