@blocklet/pages-kit 0.2.285 → 0.2.287

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 (209) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/assistant.js +26 -0
  2. package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +127 -0
  3. package/lib/cjs/builtin/async/ai-runtime/api/message.js +33 -0
  4. package/lib/cjs/builtin/async/ai-runtime/api/request.js +47 -0
  5. package/lib/cjs/builtin/async/ai-runtime/api/session.js +121 -0
  6. package/lib/cjs/builtin/async/ai-runtime/api/subscription.js +32 -0
  7. package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +63 -0
  8. package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading.js +60 -0
  9. package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +40 -0
  10. package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +51 -0
  11. package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +156 -0
  12. package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +43 -0
  13. package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +30 -0
  14. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
  15. package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +109 -0
  16. package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +102 -0
  17. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +193 -0
  18. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  19. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  20. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  21. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  22. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  23. package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +105 -0
  24. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +21 -0
  25. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +35 -0
  26. package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +12 -0
  27. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +48 -0
  28. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +66 -0
  29. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +43 -0
  30. package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +44 -0
  31. package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +76 -0
  32. package/lib/cjs/builtin/async/ai-runtime/components/layout/index.js +15 -0
  33. package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
  34. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
  35. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
  36. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +134 -0
  37. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +48 -0
  38. package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
  39. package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
  40. package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
  41. package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
  42. package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
  43. package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
  44. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +94 -0
  45. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +48 -0
  46. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +21 -0
  47. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +67 -0
  48. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +15 -0
  49. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +103 -0
  50. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
  51. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
  52. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
  53. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
  54. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +62 -0
  55. package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  56. package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
  57. package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
  58. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +37 -0
  59. package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
  60. package/lib/cjs/builtin/async/ai-runtime/index.js +75 -0
  61. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +147 -0
  62. package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +59 -0
  63. package/lib/cjs/builtin/async/ai-runtime/state/index.js +423 -0
  64. package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
  65. package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
  66. package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
  67. package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
  68. package/lib/cjs/utils/builtin.js +1 -0
  69. package/lib/cjs/utils/inject-global-components.js +2 -0
  70. package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
  71. package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
  72. package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
  73. package/lib/esm/builtin/async/ai-runtime/api/request.js +43 -0
  74. package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
  75. package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
  76. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
  77. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +56 -0
  78. package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
  79. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +48 -0
  80. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
  81. package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
  82. package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
  83. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +10 -0
  84. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
  85. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
  86. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
  87. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  88. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  89. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  90. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  91. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  92. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +99 -0
  93. package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
  94. package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
  95. package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
  96. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +42 -0
  97. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
  98. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +37 -0
  99. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
  100. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +73 -0
  101. package/lib/esm/builtin/async/ai-runtime/components/layout/index.js +12 -0
  102. package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +8 -0
  103. package/lib/esm/builtin/async/ai-runtime/components/message/MessageActions.js +35 -0
  104. package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +24 -0
  105. package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +105 -0
  106. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +42 -0
  107. package/lib/esm/builtin/async/ai-runtime/components/message/ReferenceLinks.js +8 -0
  108. package/lib/esm/builtin/async/ai-runtime/components/parameters/LanguageField.js +53 -0
  109. package/lib/esm/builtin/async/ai-runtime/components/parameters/NumberField.js +19 -0
  110. package/lib/esm/builtin/async/ai-runtime/components/parameters/SelectField.js +22 -0
  111. package/lib/esm/builtin/async/ai-runtime/components/parameters/StringField.js +19 -0
  112. package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +31 -0
  113. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +88 -0
  114. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +22 -0
  115. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +15 -0
  116. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +61 -0
  117. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +9 -0
  118. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +97 -0
  119. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
  120. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
  121. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
  122. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
  123. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
  124. package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  125. package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
  126. package/lib/esm/builtin/async/ai-runtime/hooks/header.js +25 -0
  127. package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +31 -0
  128. package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
  129. package/lib/esm/builtin/async/ai-runtime/index.js +66 -0
  130. package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
  131. package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
  132. package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
  133. package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
  134. package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
  135. package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
  136. package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
  137. package/lib/esm/utils/builtin.js +1 -0
  138. package/lib/esm/utils/inject-global-components.js +2 -0
  139. package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
  140. package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
  141. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
  142. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
  143. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
  144. package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
  145. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
  146. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +33 -0
  147. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
  148. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +2 -0
  149. package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
  150. package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
  151. package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
  152. package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
  153. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
  154. package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
  155. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
  156. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
  157. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
  158. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
  159. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
  160. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
  161. package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
  162. package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
  163. package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
  164. package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
  165. package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
  166. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
  167. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +8 -0
  168. package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
  169. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +4 -0
  170. package/lib/types/builtin/async/ai-runtime/components/layout/index.d.ts +7 -0
  171. package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
  172. package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
  173. package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
  174. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +10 -0
  175. package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
  176. package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
  177. package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
  178. package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
  179. package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
  180. package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
  181. package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
  182. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +4 -0
  183. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +4 -0
  184. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.d.ts +4 -0
  185. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +6 -0
  186. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +4 -0
  187. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +5 -0
  188. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +5 -0
  189. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +5 -0
  190. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +5 -0
  191. package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +4 -0
  192. package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +9 -0
  193. package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
  194. package/lib/types/builtin/async/ai-runtime/constants.d.ts +2 -0
  195. package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
  196. package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
  197. package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
  198. package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
  199. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
  200. package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
  201. package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
  202. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
  203. package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
  204. package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
  205. package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
  206. package/lib/types/builtin/session.d.ts +11 -1
  207. package/lib/types/utils/builtin.d.ts +1 -0
  208. package/package.json +13 -8
  209. package/tsconfig.json +5 -1
@@ -0,0 +1,48 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ import { CircularProgress, ListItemButton } from '@mui/material';
23
+ import { useState } from 'react';
24
+ import { useLocaleContext } from '../../../locale';
25
+ export default function LoadingListItemButton(_a) {
26
+ var props = __rest(_a, []);
27
+ const { t } = useLocaleContext();
28
+ const [clicked, setClicked] = useState(false);
29
+ const [loading, setLoading] = useState(false);
30
+ const handleClick = (e) => __awaiter(this, void 0, void 0, function* () {
31
+ var _b;
32
+ if (loading)
33
+ return;
34
+ if (!clicked) {
35
+ setClicked(true);
36
+ return;
37
+ }
38
+ try {
39
+ setLoading(true);
40
+ yield ((_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props, e));
41
+ }
42
+ finally {
43
+ setClicked(false);
44
+ setLoading(false);
45
+ }
46
+ });
47
+ return (_jsxs(ListItemButton, Object.assign({}, props, { onClick: handleClick, sx: Object.assign(Object.assign({}, props.sx), { minWidth: 120, display: 'flex', justifyContent: 'space-between', gap: 1 }), children: [clicked ? t('confirmDelete') : t('delete'), loading && _jsx(CircularProgress, { size: 14 })] })));
48
+ }
@@ -0,0 +1,129 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Icon } from '@iconify/react';
14
+ import { Box, Stack, styled } from '@mui/material';
15
+ import React from 'react';
16
+ import { useLocaleContext } from '../../../locale';
17
+ import MarkdownAsync from '../../react-markdown';
18
+ import ReactSyntaxHighlighterAsync from '../../react-syntax-highlighter';
19
+ import { ActionButton } from './ActionButton';
20
+ const ReactSyntaxHighlighter = React.lazy(() => ReactSyntaxHighlighterAsync().then((m) => ({ default: m.Prism })));
21
+ const Markdown = React.lazy(() => Promise.all([
22
+ MarkdownAsync(),
23
+ // @ts-ignore
24
+ import('https://esm.sh/remark-gfm@4?bundle'),
25
+ ]).then(([{ default: Markdown }, remark]) => ({
26
+ default: (props) => _jsx(Markdown, Object.assign({}, props, { remarkPlugins: [remark.default] })),
27
+ })));
28
+ const MarkdownRenderer = styled((props) => (_jsx(Markdown, Object.assign({}, props, { components: {
29
+ pre: MarkdownPre,
30
+ code: (_a) => {
31
+ var { node, inline, className, children } = _a, props = __rest(_a, ["node", "inline", "className", "children"]);
32
+ if (!children)
33
+ return null;
34
+ const match = /language-(\w+)/.exec(className || '');
35
+ return !inline ? (_jsx(Box, Object.assign({ component: ReactSyntaxHighlighter, language: match === null || match === void 0 ? void 0 : match[1] }, props, { sx: { borderRadius: 1 }, children: String(children).replace(/\n$/, '') }))) : (_jsx(Box, Object.assign({ component: "code", className: className }, props, { children: children })));
36
+ },
37
+ table: ({ className, children }) => {
38
+ return (_jsx(Box, { sx: { overflow: 'auto', my: 1 }, children: _jsx("table", { className: className, children: children }) }));
39
+ },
40
+ } })))) `
41
+ width: 100%;
42
+ overflow: hidden;
43
+ word-break: break-word;
44
+
45
+ > * {
46
+ &:first-child /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
47
+ margin-top: 0;
48
+ }
49
+ &:last-child /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
50
+ margin-bottom: 0;
51
+ }
52
+ }
53
+
54
+ pre {
55
+ overflow: auto;
56
+ }
57
+
58
+ li {
59
+ margin: 0;
60
+ padding: 0;
61
+ }
62
+
63
+ li p {
64
+ display: inline-block;
65
+ vertical-align: top;
66
+ margin: 0;
67
+ padding: 0;
68
+ }
69
+
70
+ table {
71
+ border-collapse: collapse;
72
+ white-space: nowrap;
73
+
74
+ th,
75
+ td {
76
+ border: 1px solid grey;
77
+ padding: 4px 8px;
78
+ }
79
+ }
80
+
81
+ a {
82
+ color: ${({ theme }) => theme.palette.primary.main};
83
+
84
+ :hover {
85
+ text-decoration: underline;
86
+ }
87
+ }
88
+
89
+ &.writing > *:last-child {
90
+ &:after {
91
+ content: '';
92
+ display: inline-block;
93
+ vertical-align: middle;
94
+ height: 1.2em;
95
+ margin-top: -0.2em;
96
+ margin-left: 0.1em;
97
+ border-right: 0.2em solid orange;
98
+ border-radius: 10px;
99
+ animation: blink-caret 0.75s step-end infinite;
100
+
101
+ @keyframes blink-caret {
102
+ from,
103
+ to {
104
+ border-color: transparent;
105
+ }
106
+ 50% {
107
+ border-color: ${({ theme }) => theme.palette.secondary.main};
108
+ }
109
+ }
110
+ }
111
+ }
112
+ `;
113
+ export default MarkdownRenderer;
114
+ function MarkdownPre({ children }) {
115
+ const { t } = useLocaleContext();
116
+ const childrenProps = children === null || children === void 0 ? void 0 : children.props;
117
+ if (!(childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.children))
118
+ return null;
119
+ const match = /language-(\w+)/.exec(childrenProps.className || '');
120
+ const language = match === null || match === void 0 ? void 0 : match[1];
121
+ return (_jsxs(Box, { component: "div", sx: {
122
+ fontSize: 14,
123
+ borderRadius: 1,
124
+ bgcolor: 'rgb(245, 242, 240)',
125
+ '> pre': { mt: '0 !important' },
126
+ }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", p: 0.5, pl: 1.5, borderBottom: 1, borderColor: "grey.200", children: [_jsx(Box, { children: language }), _jsx(Box, { flex: 1 }), _jsx(ActionButton, { autoReset: true, tip: t('copyToClipboard'), tipSucceed: t('copied'), title: _jsx(Icon, { icon: "tabler:copy" }), titleSucceed: _jsx(Icon, { icon: "tabler:copy-check" }), sx: { minWidth: 32, minHeight: 32, p: 0, fontSize: 18 }, onClick: () => {
127
+ window.navigator.clipboard.writeText(childrenProps.children);
128
+ } })] }), children] }));
129
+ }
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { MoreHoriz as MoreHorizIcon } from '@mui/icons-material';
3
+ import { Box, IconButton, Menu } from '@mui/material';
4
+ import { useState } from 'react';
5
+ export default function MenuButton({ sx, menus, children }) {
6
+ const [anchorEl, setAnchorEl] = useState(null);
7
+ const open = Boolean(anchorEl);
8
+ const handleClick = (event) => {
9
+ setAnchorEl(event.currentTarget);
10
+ };
11
+ const handleClose = () => {
12
+ setAnchorEl(null);
13
+ };
14
+ return (_jsxs(Box, { sx: sx, children: [_jsx(IconButton, { onClick: handleClick, children: children || _jsx(MoreHorizIcon, {}) }), _jsx(Menu, { disableScrollLock: true, MenuListProps: {
15
+ sx: {
16
+ p: 0.5,
17
+ '.MuiMenuItem-root': {
18
+ minWidth: 120,
19
+ fontSize: 14,
20
+ lineHeight: 1.5,
21
+ fontWeight: 'medium',
22
+ borderRadius: 0.5,
23
+ },
24
+ },
25
+ }, slotProps: {
26
+ paper: {
27
+ sx: {
28
+ border: 1,
29
+ borderColor: 'divider',
30
+ boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
31
+ },
32
+ },
33
+ }, anchorEl: anchorEl, anchorOrigin: {
34
+ vertical: 'bottom',
35
+ horizontal: 'right',
36
+ }, transformOrigin: {
37
+ vertical: 'top',
38
+ horizontal: 'right',
39
+ }, open: open, onClick: handleClose, onClose: handleClose, children: typeof menus === 'function' ? menus() : menus })] }));
40
+ }
@@ -0,0 +1,27 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Box, Link, Stack, Typography } from '@mui/material';
14
+ import { useLocaleContext } from '../../../locale';
15
+ import { useSubscribeLink } from '../hooks/subscribe';
16
+ export default function PoweredBy(_a) {
17
+ var { assistantId } = _a, props = __rest(_a, ["assistantId"]);
18
+ const { t } = useLocaleContext();
19
+ const { subscribeLink } = useSubscribeLink({ assistantId });
20
+ return (_jsxs(Stack, Object.assign({ py: 0.5 }, props, { children: [subscribeLink && (_jsxs(Box, { className: "ai-chat-require-subscribe-footer", sx: {
21
+ px: 2,
22
+ fontSize: 12,
23
+ lineHeight: '20px',
24
+ textAlign: 'center',
25
+ color: 'rgba(75, 85, 99, 1)',
26
+ }, children: [t('requireNewSubscriptionFooter'), _jsx(Link, { href: subscribeLink, sx: { ml: 0.5 }, children: t('subscribeNow') })] })), _jsx(Stack, { className: "ai-chat-powered-by", direction: "row", justifyContent: "center", children: _jsxs(Typography, { variant: "caption", sx: { display: 'inline-flex', alignItems: 'center', a: { display: 'inline-flex', alignItems: 'center' } }, children: [_jsxs(Typography, { component: "span", fontSize: 12, color: "text.poweredBy", children: [t('poweredBy'), ' '] }), "\u00A0", _jsxs(Link, { href: "https://www.arcblock.io", target: "_blank", color: "text.poweredBy", children: [_jsx(Box, { component: "img", src: "https://www.arcblock.io/.well-known/service/blocklet/logo", sx: { height: 16, verticalAlign: 'middle', mr: 0.5, borderRadius: 0.5 } }), "ArcBlock"] }), "\u00A0\u00B7\u00A0", _jsxs(Link, { href: "https://www.aigne.io", target: "_blank", color: "text.poweredBy", children: [_jsx(Box, { component: "img", src: "https://www.aigne.io/.well-known/service/blocklet/logo", sx: { height: 16, verticalAlign: 'middle', mr: 0.5, borderRadius: 0.5 } }), "AIGNE"] })] }) })] })));
27
+ }
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { LocaleProvider, useLocaleContext } from '../../../locale';
4
+ import { translations } from '../locales';
5
+ import GlobalLoading from './GlobalLoading';
6
+ import ThemeProvider from './ThemeProvider';
7
+ export default function RuntimeProvider({ children }) {
8
+ const { locale } = useLocaleContext();
9
+ return (_jsx(LocaleProvider, { translations: translations, locale: locale, fallbackLocale: "en", children: _jsx(ThemeProvider, { children: _jsxs(React.Suspense, { children: [_jsx(GlobalLoading, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), children] }) }) }));
10
+ }
@@ -0,0 +1,101 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { Box } from '@mui/material';
23
+ import { useEffect, useMemo, useState } from 'react';
24
+ import ScrollToBottomAsync from '../../react-scroll-to-bottom';
25
+ const scrollToBottomModuleLoader = {};
26
+ function loadScrollToBottomModule() {
27
+ var _a;
28
+ (_a = scrollToBottomModuleLoader.promise) !== null && _a !== void 0 ? _a : (scrollToBottomModuleLoader.promise = ScrollToBottomAsync()
29
+ .then((mod) => {
30
+ scrollToBottomModuleLoader.mod = mod;
31
+ return mod;
32
+ })
33
+ .catch((error) => {
34
+ scrollToBottomModuleLoader.error = error;
35
+ throw error;
36
+ }));
37
+ return scrollToBottomModuleLoader;
38
+ }
39
+ export function useScrollToBottomModule() {
40
+ const loader = loadScrollToBottomModule();
41
+ const [mod, setMod] = useState(loader.mod);
42
+ const [error, setError] = useState(loader.error);
43
+ useEffect(() => {
44
+ (() => __awaiter(this, void 0, void 0, function* () {
45
+ try {
46
+ yield loader.promise;
47
+ if (loader.mod)
48
+ setMod(loader.mod);
49
+ else if (loader.error)
50
+ setError(loader.error);
51
+ }
52
+ catch (error) {
53
+ setError(error);
54
+ }
55
+ }))();
56
+ }, []);
57
+ if (mod)
58
+ return mod;
59
+ if (error)
60
+ throw error;
61
+ throw loader.promise;
62
+ }
63
+ export default function ScrollView(_a) {
64
+ var { children, initialScrollBehavior } = _a, props = __rest(_a, ["children", "initialScrollBehavior"]);
65
+ const { Composer } = useScrollToBottomModule();
66
+ return (_jsx(Composer, { initialScrollBehavior: initialScrollBehavior, children: _jsx(ScrollViewWithinWindow, Object.assign({}, props, { children: children })) }));
67
+ }
68
+ function ScrollViewWithinWindow(_a) {
69
+ var { children, scroller, component } = _a, props = __rest(_a, ["children", "scroller", "component"]);
70
+ const { setTarget } = useScrollToBottomModule().useInternalContext();
71
+ const ele = useFakeScrollElementOfWindow();
72
+ useEffect(() => {
73
+ if (scroller === 'window') {
74
+ setTarget(ele);
75
+ }
76
+ }, [scroller]);
77
+ if (!component)
78
+ return children;
79
+ return (_jsx(Box, Object.assign({ component: component }, props, { ref: !scroller ? setTarget : undefined, children: children })));
80
+ }
81
+ function useFakeScrollElementOfWindow() {
82
+ return useMemo(() => {
83
+ const e = document.scrollingElement;
84
+ return new Proxy(e, {
85
+ get: (_, p) => {
86
+ if (p === 'offsetHeight')
87
+ return window.innerHeight;
88
+ if (['addEventListener', 'removeEventListener'].includes(p))
89
+ return window[p].bind(window);
90
+ const v = e[p];
91
+ if (v instanceof Function)
92
+ return v.bind(e);
93
+ return v;
94
+ },
95
+ set: (_, p, v) => {
96
+ e[p] = v;
97
+ return true;
98
+ },
99
+ });
100
+ }, []);
101
+ }
@@ -0,0 +1,93 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Icon } from '@iconify/react';
14
+ import { Box, MenuItem, useTheme } from '@mui/material';
15
+ import { useCallback } from 'react';
16
+ import { FacebookIcon, FacebookShareButton, LinkedinIcon, LinkedinShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, WeiboIcon, WeiboShareButton, XIcon, TwitterShareButton as XShareButton, } from 'react-share';
17
+ import { LocaleProvider, useLocaleContext } from '../../../locale';
18
+ import { translations } from '../locales';
19
+ import { mergeSx } from '../utils';
20
+ import MenuButton from './MenuButton';
21
+ const getFormattedUrl = (url) => {
22
+ // remove page & sessionId query params
23
+ const urlObj = new URL(url);
24
+ urlObj.searchParams.delete('page');
25
+ urlObj.searchParams.delete('sessionId');
26
+ return urlObj.toString();
27
+ };
28
+ export default function SocialShare(props) {
29
+ const { type = 'menu' } = props, restProps = __rest(props, ["type"]);
30
+ const { locale } = useLocaleContext();
31
+ const renderContent = useCallback(() => {
32
+ // @ts-ignore
33
+ if (type === 'buttons') {
34
+ return _jsx(SocialShareButtons, Object.assign({}, restProps));
35
+ }
36
+ return _jsx(SocialShareMenu, Object.assign({}, restProps));
37
+ }, [type, restProps]);
38
+ return (_jsx(LocaleProvider, { translations: translations, locale: locale, fallbackLocale: "en", children: renderContent() }));
39
+ }
40
+ export function SocialShareMenu(_a) {
41
+ var { url = getFormattedUrl(window.location.href), content } = _a, restProps = __rest(_a, ["url", "content"]);
42
+ const theme = useTheme();
43
+ const { t } = useLocaleContext();
44
+ const itemIconSx = {
45
+ width: 22,
46
+ height: 22,
47
+ border: 1,
48
+ borderColor: theme.palette.text.secondary,
49
+ borderRadius: 0.75,
50
+ display: 'flex',
51
+ alignItems: 'center',
52
+ justifyContent: 'center',
53
+ };
54
+ const buttonSx = {
55
+ display: 'flex',
56
+ alignItems: 'center',
57
+ gap: 1.5,
58
+ minWidth: 120,
59
+ lineHeight: '1!important',
60
+ };
61
+ const iconProps = {
62
+ bgStyle: { fill: '#fff' },
63
+ iconFillColor: theme.palette.text.secondary,
64
+ style: {
65
+ borderRadius: '6px',
66
+ },
67
+ };
68
+ const renderShareIcon = () => {
69
+ // eslint-disable-next-line react/no-unstable-nested-components
70
+ return _jsx(Box, Object.assign({ component: () => _jsx(Icon, { icon: "tabler:share" }) }, restProps));
71
+ };
72
+ return (_jsx(MenuButton, { menus: [
73
+ _jsx(MenuItem, { children: _jsxs(Box, { component: XShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: XIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToX') })] }) }, "shareOnX"),
74
+ _jsx(MenuItem, { children: _jsxs(Box, { component: TelegramShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: TelegramIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToTelegram') })] }) }, "shareOnTelegram"),
75
+ _jsx(MenuItem, { children: _jsxs(Box, { component: RedditShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: RedditIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToReddit') })] }) }, "shareOnReddit"),
76
+ _jsx(MenuItem, { children: _jsxs(Box, { component: WeiboShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: WeiboIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToWeibo') })] }) }, "shareOnWeibo"),
77
+ _jsx(MenuItem, { children: _jsxs(Box, { component: FacebookShareButton, url: url, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: FacebookIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToFacebook') })] }) }, "shareOnFacebook"),
78
+ _jsx(MenuItem, { children: _jsxs(Box, { component: LinkedinShareButton, url: url, summary: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: LinkedinIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToLinkedin') })] }) }, "shareOnLinkedin"),
79
+ _jsx(MenuItem, { children: _jsxs(Box, { component: "div", sx: buttonSx, onClick: () => {
80
+ window.navigator.clipboard.writeText(url);
81
+ }, children: [_jsx(Box, { sx: itemIconSx, round: true, children: _jsx(Icon, Object.assign({ icon: "tabler:link" }, iconProps)) }), _jsx("span", { children: t('socialShare.copyLink') })] }) }, "copyToClipboard"),
82
+ ], children: renderShareIcon() }));
83
+ }
84
+ export function SocialShareButtons(_a) {
85
+ var { url = getFormattedUrl(window.location.href), content, sx, itemSx, onClick, bgFill, iconFill } = _a, rest = __rest(_a, ["url", "content", "sx", "itemSx", "onClick", "bgFill", "iconFill"]);
86
+ const mergedSx = mergeSx({ display: 'flex', alignItems: 'center', gap: 0.5, lineHeight: 1 }, sx);
87
+ const mergedItemSx = mergeSx({ width: { xs: 24, sm: 28 }, height: { xs: 24, sm: 28 }, borderRadius: 1 }, itemSx);
88
+ const iconProps = {
89
+ bgStyle: { fill: bgFill || '#bbb' },
90
+ iconFillColor: iconFill || '#fff',
91
+ };
92
+ return (_jsxs(Box, Object.assign({ sx: mergedSx }, rest, { children: [_jsx(XShareButton, { url: url, title: content, children: _jsx(Box, Object.assign({ component: XIcon, sx: mergedItemSx }, iconProps)) }), _jsx(TelegramShareButton, { url: url, title: content, children: _jsx(Box, Object.assign({ component: TelegramIcon, sx: mergedItemSx }, iconProps)) }), _jsx(RedditShareButton, { url: url, title: content, children: _jsx(Box, Object.assign({ component: RedditIcon, sx: mergedItemSx }, iconProps)) }), _jsx(WeiboShareButton, { url: url, title: content, children: _jsx(Box, Object.assign({ component: WeiboIcon, sx: mergedItemSx }, iconProps)) }), _jsx(FacebookShareButton, { url: url, children: _jsx(Box, Object.assign({ component: FacebookIcon, sx: mergedItemSx }, iconProps)) }), _jsx(LinkedinShareButton, { url: url, summary: content, children: _jsx(Box, Object.assign({ component: LinkedinIcon, sx: mergedItemSx }, iconProps)) })] })));
93
+ }
@@ -0,0 +1,190 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { ArrowDropDownRounded } from '@mui/icons-material';
14
+ import { GlobalStyles, ThemeProvider as MuiThemeProvider, alpha, createTheme, useTheme, } from '@mui/material';
15
+ import { useMemo } from 'react';
16
+ export default function ThemeProvider({ children, template, transparentHeaderBg, }) {
17
+ const theme = useTheme();
18
+ const colors = {
19
+ default: {
20
+ color: undefined,
21
+ bg: '#ffffff',
22
+ // primary: '#333843',
23
+ primary: '#3B82F6',
24
+ },
25
+ blue: {
26
+ color: 'white',
27
+ bg: 'linear-gradient(180deg, #0D60FF 0%, #E2EDFE 100%)',
28
+ primary: '#0D60FF',
29
+ },
30
+ red: {
31
+ color: 'white',
32
+ bg: 'linear-gradient(180deg, #F65F84 0%, #817DE6 100%), linear-gradient(180deg, #9300FF 0%, #D900FF 100%)',
33
+ primary: '#F65F84',
34
+ },
35
+ green: {
36
+ color: 'white',
37
+ bg: 'linear-gradient(180deg, #149E8C 0%, #35E77D 100%)',
38
+ primary: '#149E8C',
39
+ },
40
+ };
41
+ const color = colors[template] || colors.default;
42
+ const newTheme = useMemo(() => {
43
+ const themeOptions = {
44
+ components: {
45
+ MuiSelect: {
46
+ defaultProps: { IconComponent: ArrowDropDownRounded },
47
+ },
48
+ MuiTextField: {
49
+ variants: [
50
+ {
51
+ props: {},
52
+ style: ({ theme }) => theme.unstable_sx({
53
+ '.MuiInputBase-root': {
54
+ fieldset: { borderColor: 'rgba(229, 231, 235, 1)' },
55
+ '&:hover': {
56
+ fieldset: {
57
+ border: 'none',
58
+ boxShadow: `0px 0px 0px 4px ${alpha(theme.palette.primary.main, 0.2)}, 0px 0px 0px 1px ${theme.palette.primary.main}`,
59
+ },
60
+ },
61
+ '&.Mui-focused fieldset': {
62
+ border: 'none',
63
+ boxShadow: `0px 0px 0px 4px ${alpha(theme.palette.primary.main, 0.2)}, 0px 0px 0px 1px ${theme.palette.primary.main}`,
64
+ },
65
+ },
66
+ }),
67
+ },
68
+ {
69
+ props: { select: true },
70
+ style: (_a) => {
71
+ var { theme } = _a, p = __rest(_a, ["theme"]);
72
+ const { placeholder } = p;
73
+ return theme.unstable_sx({
74
+ '& .MuiSelect-select .notranslate::after': placeholder
75
+ ? {
76
+ content: `"${placeholder}"`,
77
+ opacity: 0.42,
78
+ }
79
+ : {},
80
+ '& .MuiFormLabel-root:not(.MuiInputLabel-shrink) + .MuiInputBase-root > .MuiSelect-select .notranslate::after': {
81
+ opacity: 0,
82
+ },
83
+ });
84
+ },
85
+ },
86
+ ],
87
+ },
88
+ MuiListItemButton: {
89
+ variants: [
90
+ {
91
+ props: {},
92
+ style: ({ theme }) => theme.unstable_sx({
93
+ fontSize: 13,
94
+ color: '#010714',
95
+ }),
96
+ },
97
+ ],
98
+ },
99
+ MuiDialog: {
100
+ variants: [
101
+ {
102
+ props: {},
103
+ style: ({ theme }) => theme.unstable_sx({
104
+ '.MuiDialogTitle-root': {
105
+ px: 2.5,
106
+ py: 2,
107
+ },
108
+ '.MuiDialogContent-root': {
109
+ px: 2.5,
110
+ py: 2,
111
+ },
112
+ '.MuiDialogActions-root': {
113
+ px: 2.5,
114
+ py: 2,
115
+ },
116
+ }),
117
+ },
118
+ ],
119
+ },
120
+ },
121
+ };
122
+ const paletteTheme = createTheme({
123
+ palette: {
124
+ primary: {
125
+ main: color.primary,
126
+ },
127
+ secondary: {
128
+ main: '#010714',
129
+ },
130
+ text: {
131
+ secondary: '#98A3B1',
132
+ // @ts-ignore
133
+ poweredBy: 'rgba(209, 213, 219, 1)',
134
+ },
135
+ // @ts-ignore custom `black` color
136
+ black: {
137
+ main: '#010714',
138
+ },
139
+ },
140
+ });
141
+ return createTheme(theme, themeOptions, {
142
+ palette: {
143
+ primary: paletteTheme.palette.primary,
144
+ secondary: paletteTheme.palette.secondary,
145
+ text: paletteTheme.palette.text,
146
+ // @ts-ignore
147
+ black: paletteTheme.palette.black,
148
+ background: {
149
+ default: color.bg,
150
+ },
151
+ },
152
+ shape: {
153
+ borderRadius: 8,
154
+ },
155
+ shadows: [
156
+ 'none',
157
+ '0px 0px 0px 1px rgba(2, 7, 19, 0.08), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 2px 4px 0px rgba(2, 7, 19, 0.04)',
158
+ '0px 0px 0px 1px rgba(2, 7, 19, 0.08), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 2px 8px 0px rgba(2, 7, 19, 0.10)',
159
+ ...paletteTheme.shadows.slice(3),
160
+ ],
161
+ });
162
+ }, [theme]);
163
+ return (_jsxs(MuiThemeProvider, { theme: newTheme, children: [_jsx(GlobalStyles, { styles: {
164
+ '.page-header': transparentHeaderBg
165
+ ? {
166
+ backgroundColor: 'transparent !important',
167
+ color: color.color,
168
+ button: {
169
+ color: color.color,
170
+ },
171
+ }
172
+ : {
173
+ // with border bottom
174
+ borderBottom: '1px solid rgba(229, 231, 235, 1)',
175
+ },
176
+ body: {
177
+ background: 'transparent !important',
178
+ '&:before': {
179
+ content: '""',
180
+ position: 'fixed',
181
+ left: 0,
182
+ top: 0,
183
+ right: 0,
184
+ bottom: 0,
185
+ background: color.bg,
186
+ zIndex: -1,
187
+ },
188
+ },
189
+ } }), children] }));
190
+ }