@blocklet/pages-kit 0.2.286 → 0.2.288

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 (214) 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 +55 -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 +24 -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 +49 -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 +22 -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 +104 -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 +89 -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 +57 -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 +81 -0
  32. package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
  33. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
  34. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
  35. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +129 -0
  36. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +47 -0
  37. package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
  38. package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
  39. package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
  40. package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
  41. package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
  42. package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
  43. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +111 -0
  44. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +60 -0
  45. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +52 -0
  46. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +28 -0
  47. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +120 -0
  48. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
  49. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
  50. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
  51. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
  52. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +65 -0
  53. package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  54. package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
  55. package/lib/cjs/builtin/async/ai-runtime/error.js +10 -0
  56. package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
  57. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +38 -0
  58. package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
  59. package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +32 -0
  60. package/lib/cjs/builtin/async/ai-runtime/index.js +81 -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/loading.js +39 -0
  65. package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
  66. package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
  67. package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
  68. package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
  69. package/lib/cjs/utils/builtin.js +1 -0
  70. package/lib/cjs/utils/inject-global-components.js +2 -0
  71. package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
  72. package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
  73. package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
  74. package/lib/esm/builtin/async/ai-runtime/api/request.js +51 -0
  75. package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
  76. package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
  77. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
  78. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +21 -0
  79. package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
  80. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +46 -0
  81. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
  82. package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
  83. package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
  84. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
  85. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
  86. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
  87. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
  88. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  89. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  90. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  91. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  92. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  93. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +98 -0
  94. package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
  95. package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
  96. package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
  97. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +60 -0
  98. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
  99. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +50 -0
  100. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
  101. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +75 -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 +100 -0
  106. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +41 -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 +103 -0
  114. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +34 -0
  115. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +46 -0
  116. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +22 -0
  117. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +114 -0
  118. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
  119. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
  120. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
  121. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
  122. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
  123. package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  124. package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
  125. package/lib/esm/builtin/async/ai-runtime/error.js +6 -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 +32 -0
  128. package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
  129. package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +29 -0
  130. package/lib/esm/builtin/async/ai-runtime/index.js +72 -0
  131. package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
  132. package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
  133. package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
  134. package/lib/esm/builtin/async/ai-runtime/state/loading.js +36 -0
  135. package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
  136. package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
  137. package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
  138. package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
  139. package/lib/esm/utils/builtin.js +1 -0
  140. package/lib/esm/utils/inject-global-components.js +2 -0
  141. package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
  142. package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
  143. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
  144. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
  145. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
  146. package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
  147. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
  148. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +2 -0
  149. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
  150. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +5 -0
  151. package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
  152. package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
  153. package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
  154. package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
  155. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
  156. package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
  157. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
  158. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
  159. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
  160. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
  161. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
  162. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
  163. package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
  164. package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
  165. package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
  166. package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
  167. package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
  168. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
  169. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +11 -0
  170. package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
  171. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +6 -0
  172. package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
  173. package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
  174. package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
  175. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +8 -0
  176. package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
  177. package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
  178. package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
  179. package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
  180. package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
  181. package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
  182. package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
  183. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +10 -0
  184. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +5 -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 +5 -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 +8 -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/error.d.ts +4 -0
  196. package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
  197. package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
  198. package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
  199. package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +1 -0
  200. package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
  201. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
  202. package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
  203. package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
  204. package/lib/types/builtin/async/ai-runtime/state/loading.d.ts +10 -0
  205. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
  206. package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
  207. package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
  208. package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
  209. package/lib/types/builtin/page/header.d.ts +1 -6
  210. package/lib/types/builtin/session.d.ts +11 -1
  211. package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -116
  212. package/lib/types/utils/builtin.d.ts +1 -0
  213. package/package.json +14 -9
  214. package/tsconfig.json +5 -1
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const jsx_runtime_1 = require("react/jsx-runtime");
27
+ const react_1 = require("@iconify/react");
28
+ const material_1 = require("@mui/material");
29
+ const react_2 = require("react");
30
+ const locale_1 = require("../../../../locale");
31
+ const session_1 = require("../../state/session");
32
+ const LoadingListItemButton_1 = __importDefault(require("../LoadingListItemButton"));
33
+ function SettingButton(_a) {
34
+ var { sessionId, form } = _a, props = __rest(_a, ["sessionId", "form"]);
35
+ const { t } = (0, locale_1.useLocaleContext)();
36
+ const [, state] = (0, session_1.useSessionState)({ sessionId, required: true });
37
+ const [openSetting, setOpenSetting] = (0, react_2.useState)(false);
38
+ const settingOptions = [
39
+ // {
40
+ // key: 'parametersSetting',
41
+ // label: t('parametersSetting'),
42
+ // onClick: () => parametersDialogOpen(),
43
+ // icon: 'tabler:adjustments-horizontal',
44
+ // sx: {
45
+ // color: 'rgba(3, 7, 18, 1)',
46
+ // },
47
+ // },
48
+ {
49
+ key: 'clearSession',
50
+ label: t('clearSession'),
51
+ onClick: () => __awaiter(this, void 0, void 0, function* () {
52
+ form.setFocus('question');
53
+ yield state.clearSession({
54
+ sessionId,
55
+ });
56
+ }),
57
+ icon: 'tabler:eraser',
58
+ sx: {
59
+ color: 'rgba(225, 29, 72, 1)',
60
+ },
61
+ },
62
+ ];
63
+ return [
64
+ (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ id: "setting-button", onClick: () => setOpenSetting(!openSetting) }, props, { sx: Object.assign({ minWidth: 40, minHeight: 40, p: 0, mr: 1, alignSelf: 'flex-end' }, props.sx), children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "tabler:menu-2", sx: { fontSize: 24, color: 'black.main' } }) }), "setting-button"),
65
+ (0, jsx_runtime_1.jsx)(material_1.Popper, { anchorEl: document.getElementById('setting-button'), open: openSetting, placement: "top-start", sx: { zIndex: (theme) => theme.zIndex.modal + 1 }, children: (0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: (e) => {
66
+ e.preventDefault();
67
+ e.stopPropagation();
68
+ setOpenSetting(false);
69
+ }, children: (0, jsx_runtime_1.jsx)(material_1.Paper, { sx: {
70
+ py: 0.5,
71
+ boxShadow: '0px 8px 16px 0px rgba(2, 7, 19, 0.08), 0px 0px 0px 1px rgba(2, 7, 19, 0.08)',
72
+ }, children: settingOptions.map((option) => {
73
+ const { key, label, onClick, icon, sx } = option;
74
+ return ((0, jsx_runtime_1.jsxs)(LoadingListItemButton_1.default, { onClick: () => __awaiter(this, void 0, void 0, function* () {
75
+ yield onClick();
76
+ setOpenSetting(false);
77
+ }), sx: Object.assign({ fontSize: 13, lineHeight: '22px', py: 0.75, px: 1.5, fontWeight: 400 }, sx), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: icon, sx: { fontSize: 16, mr: 1 } }), label] }, key));
78
+ }) }) }) }, "setting-popper"),
79
+ ];
80
+ }
81
+ exports.default = SettingButton;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const jsx_runtime_1 = require("react/jsx-runtime");
27
+ const react_1 = require("react");
28
+ function Lottie({ src }) {
29
+ (0, react_1.useEffect)(() => {
30
+ Promise.resolve().then(() => __importStar(require('@lottiefiles/lottie-player')));
31
+ }, []);
32
+ return (0, jsx_runtime_1.jsx)("lottie-player", { autoplay: true, loop: true, mode: "normal", src: src }, src);
33
+ }
34
+ exports.default = Lottie;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const material_1 = require("@mui/material");
16
+ const locale_1 = require("../../../../locale");
17
+ const ActionButton_1 = require("../ActionButton");
18
+ function MessageActions(_a) {
19
+ var { content } = _a, props = __rest(_a, ["content"]);
20
+ const { t } = (0, locale_1.useLocaleContext)();
21
+ const commonActionButtonsSx = {
22
+ border: '0px !important',
23
+ minWidth: '32px',
24
+ color: 'rgba(75, 85, 99, 1)',
25
+ '.MuiButton-startIcon': {
26
+ marginRight: '0px !important',
27
+ },
28
+ };
29
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "row", gap: 1 }, props, { children: (0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { autoReset: true, size: "small", variant: "outlined",
30
+ // @ts-ignore
31
+ color: "black", tip: t('copyToClipboard'),
32
+ // title={t('copy')}
33
+ // titleSucceed={t('copied')}
34
+ icon: "tabler:copy", iconSucceed: "tabler:copy-check-filled", sx: Object.assign({}, commonActionButtonsSx), onClick: () => {
35
+ window.navigator.clipboard.writeText(content);
36
+ } }) })));
37
+ }
38
+ exports.default = MessageActions;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const material_1 = require("@mui/material");
8
+ const locale_1 = require("../../../../locale");
9
+ const subscribe_1 = require("../../hooks/subscribe");
10
+ const MarkdownRenderer_1 = __importDefault(require("../MarkdownRenderer"));
11
+ function MessageErrorView({ assistantId, assistant, error, }) {
12
+ var _a, _b, _c;
13
+ const { t } = (0, locale_1.useLocaleContext)();
14
+ const { subscribeLink } = (0, subscribe_1.useSubscribeLink)({ assistantId });
15
+ if (error.type === 'InvalidSubscriptionError') {
16
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-chat-message-error", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
17
+ bgcolor: 'grey.100',
18
+ p: 1.5,
19
+ borderRadius: 1,
20
+ }, children: (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: t('requireNewSubscription', {
21
+ price: (_b = (_a = assistant.release) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.price,
22
+ }) }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 1, children: subscribeLink ? ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", href: subscribeLink, children: t('subscribeNow') })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
23
+ bgcolor: 'grey.100',
24
+ p: 1.5,
25
+ borderRadius: 1,
26
+ }, children: t('thanksForSubscription') })) })] }));
27
+ }
28
+ return ((0, jsx_runtime_1.jsx)(material_1.Alert, { className: "ai-chat-message-error", severity: "error", children: (error.type === 'ReachMaxRoundLimitError' && ((_c = assistant === null || assistant === void 0 ? void 0 : assistant.release) === null || _c === void 0 ? void 0 : _c.reachMaxRoundLimitTip)) || error.message }));
29
+ }
30
+ exports.default = MessageErrorView;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const jsx_runtime_1 = require("react/jsx-runtime");
30
+ const image_preview_1 = __importDefault(require("@blocklet/ai-kit/components/image-preview"));
31
+ const material_1 = require("@mui/material");
32
+ const dayjs_1 = __importDefault(require("dayjs"));
33
+ const react_1 = __importStar(require("react"));
34
+ const ux_1 = require("../../../../arcblock/ux");
35
+ const session_1 = require("../../../../session");
36
+ const common_1 = require("../common");
37
+ const MarkdownRenderer_1 = __importDefault(require("../MarkdownRenderer"));
38
+ const MessageActions_1 = __importDefault(require("./MessageActions"));
39
+ const MessageErrorView_1 = __importDefault(require("./MessageErrorView"));
40
+ function MessageItemView({ assistantId, assistant, message, hideAvatar, }) {
41
+ var _a, _b;
42
+ const showUserMessage = ((_a = assistant.release) === null || _a === void 0 ? void 0 : _a.template) !== 'form' && !!((_b = message.parameters) === null || _b === void 0 ? void 0 : _b.question);
43
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-item", gap: 2.5, overflow: "hidden", sx: {
44
+ '.message-question': Object.assign(Object.assign({}, commonMessageSx), { borderTopRightRadius: '2px', backgroundColor: 'rgba(239, 246, 255, 1)' }),
45
+ '.message-response': Object.assign(Object.assign({}, commonMessageSx), { borderTopLeftRadius: '2px', backgroundColor: 'rgba(229, 231, 235, 1)' }),
46
+ '.ai-chat-message-ai:hover': {
47
+ '.message-actions': {
48
+ opacity: 1,
49
+ },
50
+ },
51
+ }, children: [showUserMessage && (0, jsx_runtime_1.jsx)(UserMessage, { message: message }), (0, jsx_runtime_1.jsx)(AgentMessage, { assistantId: assistantId, assistant: assistant, message: message, hideAvatar: hideAvatar })] }));
52
+ }
53
+ exports.default = MessageItemView;
54
+ const commonMessageSx = {
55
+ position: 'relative',
56
+ borderRadius: 1,
57
+ py: 1,
58
+ px: 2,
59
+ mt: 0.5,
60
+ // without logo width
61
+ maxWidth: 'calc(100% - 40px)',
62
+ '.message-actions': {
63
+ position: 'absolute',
64
+ top: 0,
65
+ right: -40,
66
+ background: 'white',
67
+ border: 1,
68
+ borderRadius: 1,
69
+ borderColor: 'grey.300',
70
+ opacity: 0,
71
+ transition: 'opacity 0.2s',
72
+ },
73
+ };
74
+ function UserMessage({ message }) {
75
+ var _a, _b, _c, _d;
76
+ const { session: authSession } = (0, session_1.useSessionContext)();
77
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-user", direction: "row", gap: 1.5, sx: {
78
+ display: 'flex',
79
+ flexDirection: 'row-reverse',
80
+ textAlign: 'right',
81
+ justifyContent: 'flex-end',
82
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { flex: 1, overflow: "hidden", sx: {
83
+ display: 'flex',
84
+ flexDirection: 'column',
85
+ alignItems: 'flex-end',
86
+ }, children: [(0, jsx_runtime_1.jsxs)(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, (0, jsx_runtime_1.jsx)(MessageTime, { time: message.createdAt })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
87
+ }
88
+ function AgentMessage({ assistantId, assistant, message, hideAvatar, }) {
89
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
90
+ const showMainMessage = !!(((_a = message.result) === null || _a === void 0 ? void 0 : _a.content) || ((_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.length));
91
+ const isMessageLoading = (message.loading || !message.result) && !message.error;
92
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, did: (_d = globalThis.blocklet) === null || _d === void 0 ? void 0 : _d.appId, variant: "circle", shape: "circle", src: (_e = assistant.release) === null || _e === void 0 ? void 0 : _e.logo }) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, overflow: "hidden", children: [!hideAvatar && ((0, jsx_runtime_1.jsxs)(MessageUserName, { children: [((_f = assistant.release) === null || _f === void 0 ? void 0 : _f.title) || assistant.name, (0, jsx_runtime_1.jsx)(MessageTime, { time: message.createdAt })] })), (0, jsx_runtime_1.jsxs)(react_1.default.Suspense, { children: [showMainMessage ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 1, className: "message-response", children: [(_h = (_g = message.result) === null || _g === void 0 ? void 0 : _g.messages) === null || _h === void 0 ? void 0 : _h.map((childMsg, index) => {
93
+ var _a, _b, _c, _d, _e, _f, _g;
94
+ return ((_a = childMsg.result) === null || _a === void 0 ? void 0 : _a.content) ? ((0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { className: isMessageLoading &&
95
+ !((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) &&
96
+ !((_d = (_c = message.result) === null || _c === void 0 ? void 0 : _c.images) === null || _d === void 0 ? void 0 : _d.length) &&
97
+ message.result.messages.length - 1 === index
98
+ ? 'writing'
99
+ : '', sx: childMsg.respondAs === 'systemMessage' ? { color: 'text.secondary' } : {}, children: (_e = childMsg.result) === null || _e === void 0 ? void 0 : _e.content }, childMsg.taskId)) : ((_g = (_f = childMsg.result) === null || _f === void 0 ? void 0 : _f.images) === null || _g === void 0 ? void 0 : _g.length) ? ((0, jsx_runtime_1.jsx)(image_preview_1.default, { itemWidth: 100, spacing: 1, dataSource: childMsg.result.images.map((i) => ({ src: i.url })) }, childMsg.taskId)) : null;
100
+ }), ((_j = message.result) === null || _j === void 0 ? void 0 : _j.content) && ((0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { className: isMessageLoading ? 'writing' : '', children: message.result.content })), !isMessageLoading && ((_k = message.result) === null || _k === void 0 ? void 0 : _k.content) && ((0, jsx_runtime_1.jsx)(MessageActions_1.default, { className: "message-actions", content: message.result.content }))] })) : (isMessageLoading && ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", height: 24 + 8 + 8,
101
+ // only response with loading
102
+ className: "message-response" }))), !!((_m = (_l = message.result) === null || _l === void 0 ? void 0 : _l.objects) === null || _m === void 0 ? void 0 : _m.length) &&
103
+ ((_p = (_o = message.result) === null || _o === void 0 ? void 0 : _o.objects) === null || _p === void 0 ? void 0 : _p.map((object) => ((0, jsx_runtime_1.jsx)(common_1.MessageMetadataRenderer, { object: object.data }, object.taskId)))), message.error && (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { assistantId: assistantId, assistant: assistant, error: message.error })] })] })] }));
104
+ }
105
+ function MessageUserName({ children }) {
106
+ return ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "div", noWrap: true, sx: {
107
+ fontSize: 14,
108
+ lineHeight: '24px',
109
+ fontWeight: 500,
110
+ display: 'flex',
111
+ alignItems: 'center',
112
+ gap: 1,
113
+ }, children: children }));
114
+ }
115
+ function MessageTime({ time }) {
116
+ const t = (0, react_1.useMemo)(() => {
117
+ const date = (0, dayjs_1.default)(time);
118
+ if (!date.isValid())
119
+ return undefined;
120
+ return date.isSame((0, dayjs_1.default)(), 'date') ? date.format('HH:mm') : date.format('YYYY-MM-DD HH:mm');
121
+ }, [time]);
122
+ if (!t)
123
+ return null;
124
+ return ((0, jsx_runtime_1.jsx)(material_1.Typography, { sx: {
125
+ fontSize: 12,
126
+ lineHeight: '24px',
127
+ color: 'text.secondary',
128
+ }, children: t }, "user-time"));
129
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const jsx_runtime_1 = require("react/jsx-runtime");
18
+ const material_1 = require("@mui/material");
19
+ const react_1 = require("react");
20
+ const assistant_1 = require("../../state/assistant");
21
+ const session_1 = require("../../state/session");
22
+ const MessageItemView_1 = __importDefault(require("./MessageItemView"));
23
+ function MessageListView(_a) {
24
+ var { assistantId, sessionId } = _a, props = __rest(_a, ["assistantId", "sessionId"]);
25
+ const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
26
+ const [session, { messages = [] }] = (0, session_1.useSessionState)({ sessionId, required: true });
27
+ const opener = (0, react_1.useMemo)(() => {
28
+ var _a;
29
+ const { openerMessage } = (_a = assistant.release) !== null && _a !== void 0 ? _a : {};
30
+ if (openerMessage) {
31
+ return {
32
+ taskId: '',
33
+ sessionId: session.id,
34
+ createdAt: session.createdAt,
35
+ updatedAt: session.createdAt,
36
+ result: { content: openerMessage },
37
+ };
38
+ }
39
+ return undefined;
40
+ }, [assistant.release]);
41
+ if (!session)
42
+ return null;
43
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2.5 }, props, { children: [opener && (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { assistantId: assistantId, assistant: assistant, message: opener }), messages.map((message) => {
44
+ return ((0, jsx_runtime_1.jsx)(MessageItemView_1.default, { assistantId: assistantId, assistant: assistant, message: message }, message.taskId));
45
+ })] })));
46
+ }
47
+ exports.default = MessageListView;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const material_1 = require("@mui/material");
5
+ function ReferenceLinks({ links }) {
6
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { wordBreak: 'break-word' }, children: links === null || links === void 0 ? void 0 : links.map((item) => (0, jsx_runtime_1.jsx)(ReferenceLinkItemView, { link: item }, item.url)) }));
7
+ }
8
+ exports.default = ReferenceLinks;
9
+ function ReferenceLinkItemView({ link, }) {
10
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: link.url, children: link.title || link.url }) }));
11
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const material_1 = require("@mui/material");
16
+ const react_1 = require("react");
17
+ const locale_1 = require("../../../../locale");
18
+ const LanguageField = (0, react_1.forwardRef)((_a, ref) => {
19
+ var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
20
+ const { locale } = (0, locale_1.useLocaleContext)();
21
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ ref: ref, select: true, onChange: (e) => onChange(e.target.value) }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { readOnly }), children: languages.map((option) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: option.en, children: locale === 'zh' ? option.cn : option.en }, option.en))) })));
22
+ });
23
+ exports.default = LanguageField;
24
+ const languages = [
25
+ { en: 'English', cn: '英语' },
26
+ { en: 'Simplified Chinese', cn: '中文-简体' },
27
+ { en: 'Traditional Chinese', cn: '中文-繁体' },
28
+ { en: 'Spanish', cn: '西班牙语' },
29
+ { en: 'French', cn: '法语' },
30
+ { en: 'German', cn: '德语' },
31
+ { en: 'Italian', cn: '意大利语' },
32
+ { en: 'Portuguese', cn: '葡萄牙语' },
33
+ { en: 'Japanese', cn: '日语' },
34
+ { en: 'Korean', cn: '韩语' },
35
+ { en: 'Russian', cn: '俄语' },
36
+ { en: 'Polish', cn: '波兰语' },
37
+ { en: 'Arabic', cn: '阿拉伯语' },
38
+ { en: 'Dutch', cn: '荷兰语' },
39
+ { en: 'Swedish', cn: '瑞典语' },
40
+ { en: 'Finnish', cn: '芬兰语' },
41
+ { en: 'Czech', cn: '捷克语' },
42
+ { en: 'Danish', cn: '丹麦语' },
43
+ { en: 'Greek', cn: '希腊语' },
44
+ { en: 'Romanian', cn: '罗马尼亚语' },
45
+ { en: 'Hungarian', cn: '匈牙利语' },
46
+ { en: 'Bulgarian', cn: '保加利亚语' },
47
+ { en: 'Slovak', cn: '斯洛伐克语' },
48
+ { en: 'Norwegian', cn: '挪威语' },
49
+ { en: 'Hebrew', cn: '希伯来语' },
50
+ { en: 'Turkish', cn: '土耳其语' },
51
+ { en: 'Thai', cn: '泰语' },
52
+ { en: 'Indonesian', cn: '印尼语' },
53
+ { en: 'Vietnamese', cn: '越南语' },
54
+ { en: 'Hindi', cn: '印地语' },
55
+ ];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const material_1 = require("@mui/material");
16
+ const react_1 = require("react");
17
+ const NumberField = (0, react_1.forwardRef)((_a, ref) => {
18
+ var { readOnly, parameter } = _a, props = __rest(_a, ["readOnly", "parameter"]);
19
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ ref: ref }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { readOnly, inputProps: Object.assign({ type: 'number', inputMode: 'numeric', pattern: '[0-9]*', min: parameter === null || parameter === void 0 ? void 0 : parameter.min, max: parameter === null || parameter === void 0 ? void 0 : parameter.max }, props.inputProps) }), onChange: (e) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, Number(e.target.value)); } })));
20
+ });
21
+ exports.default = NumberField;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const material_1 = require("@mui/material");
16
+ const react_1 = require("react");
17
+ const SelectField = (0, react_1.forwardRef)((_a, ref) => {
18
+ var _b, _c, _d, _e;
19
+ var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
20
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ ref: ref, select: true, onChange: (e) => onChange(e.target.value) }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { readOnly }), SelectProps: Object.assign(Object.assign({}, props.SelectProps), { MenuProps: Object.assign(Object.assign({}, (_b = props.SelectProps) === null || _b === void 0 ? void 0 : _b.MenuProps), { sx: Object.assign(Object.assign({}, (_d = (_c = props.SelectProps) === null || _c === void 0 ? void 0 : _c.MenuProps) === null || _d === void 0 ? void 0 : _d.sx), { '.MuiMenuItem-root': {
21
+ whiteSpace: 'pre-wrap',
22
+ } }) }) }), children: (_e = parameter === null || parameter === void 0 ? void 0 : parameter.options) === null || _e === void 0 ? void 0 : _e.map((option) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: option.value, children: option.label }, option.id))) })));
23
+ });
24
+ exports.default = SelectField;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const jsx_runtime_1 = require("react/jsx-runtime");
15
+ const material_1 = require("@mui/material");
16
+ const react_1 = require("react");
17
+ const StringField = (0, react_1.forwardRef)((_a, ref) => {
18
+ var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
19
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ ref: ref, multiline: parameter === null || parameter === void 0 ? void 0 : parameter.multiline, minRows: (parameter === null || parameter === void 0 ? void 0 : parameter.multiline) ? 2 : undefined, onChange: (e) => onChange(e.target.value) }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { inputProps: Object.assign(Object.assign({}, props.inputProps), { maxLength: parameter === null || parameter === void 0 ? void 0 : parameter.maxLength }), readOnly }) })));
20
+ });
21
+ exports.default = StringField;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const jsx_runtime_1 = require("react/jsx-runtime");
18
+ const LanguageField_1 = __importDefault(require("./LanguageField"));
19
+ const NumberField_1 = __importDefault(require("./NumberField"));
20
+ const SelectField_1 = __importDefault(require("./SelectField"));
21
+ const StringField_1 = __importDefault(require("./StringField"));
22
+ function ParameterField(_a) {
23
+ var { parameter } = _a, props = __rest(_a, ["parameter"]);
24
+ if (parameter.type === 'source')
25
+ return null;
26
+ if (parameter.key === 'datasetId') {
27
+ return null;
28
+ }
29
+ const Field = {
30
+ number: NumberField_1.default,
31
+ string: StringField_1.default,
32
+ select: SelectField_1.default,
33
+ language: LanguageField_1.default,
34
+ }[parameter.type || 'string'] || StringField_1.default;
35
+ return ((0, jsx_runtime_1.jsx)(Field, Object.assign({ label: parameter === null || parameter === void 0 ? void 0 : parameter.label, helperText: parameter === null || parameter === void 0 ? void 0 : parameter.helper, placeholder: parameter === null || parameter === void 0 ? void 0 : parameter.placeholder }, { parameter }, { size: "small" }, props)));
36
+ }
37
+ exports.default = ParameterField;