@e-llm-studio/instant-learning 1.3.14 → 1.3.15-alpha.2

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 (201) hide show
  1. package/dist/ComponentRegistry.js +4 -0
  2. package/dist/ComponentRegistry.js.map +1 -1
  3. package/dist/ILMarketplaceWrapper.js +29 -4
  4. package/dist/ILMarketplaceWrapper.js.map +1 -1
  5. package/dist/cjs/ComponentRegistry.js +4 -0
  6. package/dist/cjs/ComponentRegistry.js.map +1 -1
  7. package/dist/cjs/ILMarketplaceWrapper.js +29 -4
  8. package/dist/cjs/ILMarketplaceWrapper.js.map +1 -1
  9. package/dist/cjs/features/IL-OTJ/ILOTJ.js +5 -1
  10. package/dist/cjs/features/IL-OTJ/ILOTJ.js.map +1 -1
  11. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +21 -7
  12. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js.map +1 -1
  13. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +16 -9
  14. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js.map +1 -1
  15. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +188 -30
  16. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
  17. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
  18. package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js +31 -15
  19. package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
  20. package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
  21. package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
  22. package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
  23. package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
  24. package/dist/cjs/features/IL-OTJ/_components/hooks/useVariantEditSession.js +21 -7
  25. package/dist/cjs/features/IL-OTJ/_components/hooks/useVariantEditSession.js.map +1 -1
  26. package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js +19 -0
  27. package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
  28. package/dist/cjs/features/IL-OTJ/helpers/utils.js +45 -1
  29. package/dist/cjs/features/IL-OTJ/helpers/utils.js.map +1 -1
  30. package/dist/cjs/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js +26 -0
  31. package/dist/cjs/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js.map +1 -1
  32. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js +27 -2
  33. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
  34. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js +6 -5
  35. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
  36. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +5 -2
  37. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
  38. package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.js +1 -0
  39. package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.js.map +1 -1
  40. package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.module.css.js +2 -2
  41. package/dist/cjs/features/IL-marketplace/components/LearningManagementWrapper.js +4 -1
  42. package/dist/cjs/features/IL-marketplace/components/LearningManagementWrapper.js.map +1 -1
  43. package/dist/cjs/features/IL-marketplace/services/IL-marketplace.api.js +6 -1
  44. package/dist/cjs/features/IL-marketplace/services/IL-marketplace.api.js.map +1 -1
  45. package/dist/cjs/features/LearningManagement/LearningManagement.js +27 -0
  46. package/dist/cjs/features/LearningManagement/LearningManagement.js.map +1 -1
  47. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +4 -2
  48. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js.map +1 -1
  49. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +11 -1
  50. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js.map +1 -1
  51. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +24 -1
  52. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
  53. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js +134 -33
  54. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
  55. package/dist/cjs/features/LearningManagement/store/useEnvStore.js +2 -0
  56. package/dist/cjs/features/LearningManagement/store/useEnvStore.js.map +1 -1
  57. package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js.map +1 -1
  58. package/dist/cjs/index.js +1 -0
  59. package/dist/cjs/index.js.map +1 -1
  60. package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +7 -1
  61. package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js.map +1 -1
  62. package/dist/cjs/schema-driven/BPARenderer.js +59 -3
  63. package/dist/cjs/schema-driven/BPARenderer.js.map +1 -1
  64. package/dist/cjs/schema-driven/components/FileUploadField.js +815 -0
  65. package/dist/cjs/schema-driven/components/FileUploadField.js.map +1 -0
  66. package/dist/cjs/schema-driven/components/FileUploadField.module.css.js +12 -0
  67. package/dist/cjs/schema-driven/components/FileUploadField.module.css.js.map +1 -0
  68. package/dist/cjs/schema-driven/components/PromptTextEditorField.js +85 -23
  69. package/dist/cjs/schema-driven/components/PromptTextEditorField.js.map +1 -1
  70. package/dist/cjs/schema-driven/components/VariantListField.js +133 -11
  71. package/dist/cjs/schema-driven/components/VariantListField.js.map +1 -1
  72. package/dist/cjs/schema-driven/types.js.map +1 -1
  73. package/dist/cjs/schema-driven/utils/PayloadUtils.js +2 -23
  74. package/dist/cjs/schema-driven/utils/PayloadUtils.js.map +1 -1
  75. package/dist/cjs/schema-driven/utils/fileUploadService.js +461 -0
  76. package/dist/cjs/schema-driven/utils/fileUploadService.js.map +1 -0
  77. package/dist/features/IL-OTJ/ILOTJ.js +5 -1
  78. package/dist/features/IL-OTJ/ILOTJ.js.map +1 -1
  79. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +21 -7
  80. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js.map +1 -1
  81. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +16 -9
  82. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js.map +1 -1
  83. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +189 -31
  84. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
  85. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
  86. package/dist/features/IL-OTJ/_components/CriticalGaps.js +31 -15
  87. package/dist/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
  88. package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
  89. package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
  90. package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
  91. package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
  92. package/dist/features/IL-OTJ/_components/hooks/useVariantEditSession.js +21 -8
  93. package/dist/features/IL-OTJ/_components/hooks/useVariantEditSession.js.map +1 -1
  94. package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js +14 -0
  95. package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
  96. package/dist/features/IL-OTJ/helpers/utils.js +45 -2
  97. package/dist/features/IL-OTJ/helpers/utils.js.map +1 -1
  98. package/dist/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js +26 -0
  99. package/dist/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js.map +1 -1
  100. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js +27 -2
  101. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
  102. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js +6 -5
  103. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
  104. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +5 -2
  105. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
  106. package/dist/features/IL-marketplace/components/GuidelineLibraryCard.js +1 -0
  107. package/dist/features/IL-marketplace/components/GuidelineLibraryCard.js.map +1 -1
  108. package/dist/features/IL-marketplace/components/GuidelineLibraryCard.module.css.js +2 -2
  109. package/dist/features/IL-marketplace/components/LearningManagementWrapper.js +4 -1
  110. package/dist/features/IL-marketplace/components/LearningManagementWrapper.js.map +1 -1
  111. package/dist/features/IL-marketplace/services/IL-marketplace.api.js +6 -1
  112. package/dist/features/IL-marketplace/services/IL-marketplace.api.js.map +1 -1
  113. package/dist/features/LearningManagement/LearningManagement.js +27 -0
  114. package/dist/features/LearningManagement/LearningManagement.js.map +1 -1
  115. package/dist/features/LearningManagement/LearningTemplateLayout.js +4 -2
  116. package/dist/features/LearningManagement/LearningTemplateLayout.js.map +1 -1
  117. package/dist/features/LearningManagement/RuleContent/RuleContent.js +11 -1
  118. package/dist/features/LearningManagement/RuleContent/RuleContent.js.map +1 -1
  119. package/dist/features/LearningManagement/components/InstantLearningModal.js +25 -2
  120. package/dist/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
  121. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js +136 -35
  122. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
  123. package/dist/features/LearningManagement/store/useEnvStore.js +2 -0
  124. package/dist/features/LearningManagement/store/useEnvStore.js.map +1 -1
  125. package/dist/features/LearningManagement/store/useLMSConfigStore.js.map +1 -1
  126. package/dist/index.js +1 -1
  127. package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +8 -2
  128. package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js.map +1 -1
  129. package/dist/schema-driven/BPARenderer.js +60 -4
  130. package/dist/schema-driven/BPARenderer.js.map +1 -1
  131. package/dist/schema-driven/components/FileUploadField.js +811 -0
  132. package/dist/schema-driven/components/FileUploadField.js.map +1 -0
  133. package/dist/schema-driven/components/FileUploadField.module.css.js +8 -0
  134. package/dist/schema-driven/components/FileUploadField.module.css.js.map +1 -0
  135. package/dist/schema-driven/components/PromptTextEditorField.js +85 -23
  136. package/dist/schema-driven/components/PromptTextEditorField.js.map +1 -1
  137. package/dist/schema-driven/components/VariantListField.js +134 -12
  138. package/dist/schema-driven/components/VariantListField.js.map +1 -1
  139. package/dist/schema-driven/types.js.map +1 -1
  140. package/dist/schema-driven/utils/PayloadUtils.js +3 -23
  141. package/dist/schema-driven/utils/PayloadUtils.js.map +1 -1
  142. package/dist/schema-driven/utils/fileUploadService.js +443 -0
  143. package/dist/schema-driven/utils/fileUploadService.js.map +1 -0
  144. package/dist/types/src/ComponentRegistry.d.ts.map +1 -1
  145. package/dist/types/src/ILMarketplaceMockTest.d.ts.map +1 -1
  146. package/dist/types/src/ILMarketplaceWrapper.d.ts +8 -1
  147. package/dist/types/src/ILMarketplaceWrapper.d.ts.map +1 -1
  148. package/dist/types/src/features/IL-OTJ/ILOTJ.d.ts +3 -0
  149. package/dist/types/src/features/IL-OTJ/ILOTJ.d.ts.map +1 -1
  150. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts.map +1 -1
  151. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts.map +1 -1
  152. package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts +4 -0
  153. package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts.map +1 -1
  154. package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts +2 -1
  155. package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts.map +1 -1
  156. package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts +2 -1
  157. package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts.map +1 -1
  158. package/dist/types/src/features/IL-OTJ/_components/MessageRendering/MessageRendering.d.ts.map +1 -1
  159. package/dist/types/src/features/IL-OTJ/_components/hooks/useVariantEditSession.d.ts +3 -3
  160. package/dist/types/src/features/IL-OTJ/_components/hooks/useVariantEditSession.d.ts.map +1 -1
  161. package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts +7 -0
  162. package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts.map +1 -0
  163. package/dist/types/src/features/IL-OTJ/helpers/utils.d.ts +12 -2
  164. package/dist/types/src/features/IL-OTJ/helpers/utils.d.ts.map +1 -1
  165. package/dist/types/src/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.d.ts.map +1 -1
  166. package/dist/types/src/features/IL-marketplace/PromoteFlow/PromoteFlow.d.ts.map +1 -1
  167. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.api.d.ts.map +1 -1
  168. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts +4 -0
  169. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts.map +1 -1
  170. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.utils.d.ts.map +1 -1
  171. package/dist/types/src/features/IL-marketplace/components/GuidelineLibraryCard.d.ts.map +1 -1
  172. package/dist/types/src/features/IL-marketplace/components/LearningManagementWrapper.d.ts +3 -1
  173. package/dist/types/src/features/IL-marketplace/components/LearningManagementWrapper.d.ts.map +1 -1
  174. package/dist/types/src/features/IL-marketplace/services/IL-marketplace.api.d.ts.map +1 -1
  175. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts +6 -1
  176. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  177. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts +4 -0
  178. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts.map +1 -1
  179. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts +4 -0
  180. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
  181. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts +4 -0
  182. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  183. package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts +4 -0
  184. package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts.map +1 -1
  185. package/dist/types/src/features/LearningManagement/store/useEnvStore.d.ts +2 -0
  186. package/dist/types/src/features/LearningManagement/store/useEnvStore.d.ts.map +1 -1
  187. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +2 -0
  188. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -1
  189. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts.map +1 -1
  190. package/dist/types/src/schema-driven/BPARenderer.d.ts.map +1 -1
  191. package/dist/types/src/schema-driven/components/FileUploadField.d.ts +81 -0
  192. package/dist/types/src/schema-driven/components/FileUploadField.d.ts.map +1 -0
  193. package/dist/types/src/schema-driven/components/PromptTextEditorField.d.ts.map +1 -1
  194. package/dist/types/src/schema-driven/components/VariantListField.d.ts.map +1 -1
  195. package/dist/types/src/schema-driven/demoSchema.d.ts.map +1 -1
  196. package/dist/types/src/schema-driven/types.d.ts +5 -0
  197. package/dist/types/src/schema-driven/types.d.ts.map +1 -1
  198. package/dist/types/src/schema-driven/utils/PayloadUtils.d.ts.map +1 -1
  199. package/dist/types/src/schema-driven/utils/fileUploadService.d.ts +196 -0
  200. package/dist/types/src/schema-driven/utils/fileUploadService.d.ts.map +1 -0
  201. package/package.json +4 -4
@@ -0,0 +1,811 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
3
+ import { AlertCircle, X, Upload, FileText, Loader2, Check, Pencil } from 'lucide-react';
4
+ import { SectionWrapper } from '../../features/IL-OTJ/_components/molecules/Sections/SectionWrapper.js';
5
+ import { InputDataReasoningCard } from '../../features/IL-OTJ/_components/InputDataReasoningCard.js';
6
+ import { ButtonCognitiveIcon } from '../../features/IL-OTJ/_components/_svg/ButtonCognitiveIcon.js';
7
+ import { useDynamicFormStore } from '../store/useDynamicFormStore.js';
8
+ import useEnvStore from '../../features/LearningManagement/store/useEnvStore.js';
9
+ import { useConfigStore } from '../../features/LearningManagement/store/useConfigStore.js';
10
+ import { useLearningTemplateStore } from '../../features/LearningManagement/store/useLearningTemplateStore.js';
11
+ import useAuthStore from '../../features/LearningManagement/store/useAuthStore.js';
12
+ import { parseMaxFileSizeBytes, formatFileSize, normalizeAcceptString, getGCSSignedUrl, isFileAccepted, isImageFile, uploadFilesBatch, getFileExtension } from '../utils/fileUploadService.js';
13
+ import { getOptionalGuidelineRuntimeConfig } from '../../features/IL-marketplace/services/guideline.runtime.config.js';
14
+ import styles from './FileUploadField.module.css.js';
15
+
16
+ function FileUploadField(props) {
17
+ var _a, _b, _c, _d, _e, _f, _g;
18
+ const {
19
+ id,
20
+ schema,
21
+ title = (schema == null ? void 0 : schema.title) || "Supporting documents",
22
+ subtitle = (schema == null ? void 0 : schema.subtitle) || "Upload any supporting documents, such as user journey files, technical or integration documentation, or PDFs",
23
+ value,
24
+ onChange,
25
+ readOnly = false,
26
+ required = (schema == null ? void 0 : schema.is_required) || false,
27
+ citation,
28
+ isMirage,
29
+ tierKey,
30
+ variantIndex,
31
+ state,
32
+ uiState,
33
+ enableInlineEdit = false,
34
+ hideEditControls,
35
+ parentEditing,
36
+ activeEditId,
37
+ setActiveEditId,
38
+ isAiStreaming: propAiStreaming,
39
+ accept: propAccept,
40
+ uploadType: propUploadType,
41
+ maxUploads: propMaxUploads,
42
+ maxSize: propMaxSize,
43
+ bordered: propBordered,
44
+ collapsible: propCollapsible,
45
+ defaultOpen: propDefaultOpen,
46
+ openSections: propOpenSections,
47
+ setOpenSections: propSetOpenSections
48
+ } = props;
49
+ const isBordered = propBordered !== void 0 ? !!propBordered : (schema == null ? void 0 : schema.bordered) !== void 0 ? !!schema.bordered : true;
50
+ const isCollapsible = propCollapsible !== void 0 ? !!propCollapsible : (schema == null ? void 0 : schema.collapsible) !== void 0 ? !!schema.collapsible : true;
51
+ const resolvedDefaultOpen = propDefaultOpen !== void 0 ? !!propDefaultOpen : (schema == null ? void 0 : schema.default_open) !== void 0 ? !!schema.default_open : (schema == null ? void 0 : schema.defaultOpen) !== void 0 ? !!schema.defaultOpen : true;
52
+ const rawUploadType = (propUploadType || (schema == null ? void 0 : schema.upload_type) || "multiple").toString().trim().toLowerCase();
53
+ const isSingleUpload = rawUploadType === "single";
54
+ const rawMaxUploads = propMaxUploads != null ? propMaxUploads : schema == null ? void 0 : schema.max_uploads;
55
+ const effectiveMaxUploads = useMemo(() => {
56
+ if (isSingleUpload) return 1;
57
+ if (rawMaxUploads !== void 0 && rawMaxUploads !== null && rawMaxUploads !== "") {
58
+ const parsed = Number(rawMaxUploads);
59
+ if (!isNaN(parsed) && parsed > 0) return parsed;
60
+ }
61
+ return Infinity;
62
+ }, [isSingleUpload, rawMaxUploads]);
63
+ const rawMaxSize = propMaxSize != null ? propMaxSize : schema == null ? void 0 : schema.max_size;
64
+ const effectiveMaxFileSizeBytes = useMemo(
65
+ () => parseMaxFileSizeBytes(rawMaxSize),
66
+ [rawMaxSize]
67
+ );
68
+ const maxFileSizeLabel = effectiveMaxFileSizeBytes ? formatFileSize(effectiveMaxFileSizeBytes) : null;
69
+ const rawAccept = propAccept || props.acceptedFormats || props.acceptedFileTypes || props.allowedExtensions || (schema == null ? void 0 : schema.accept) || (schema == null ? void 0 : schema.accepted_formats) || (schema == null ? void 0 : schema.accepted_file_types) || (schema == null ? void 0 : schema.allowed_extensions);
70
+ const normalizedAccept = useMemo(() => normalizeAcceptString(rawAccept), [rawAccept]);
71
+ const acceptedFormatsLabel = useMemo(
72
+ () => normalizedAccept == null ? void 0 : normalizedAccept.split(",").map((format) => format.trim()).join(", "),
73
+ [normalizedAccept]
74
+ );
75
+ const [isReasoningOpen, setIsReasoningOpen] = useState(false);
76
+ const [isDragging, setIsDragging] = useState(false);
77
+ const [isUploading, setIsUploading] = useState(false);
78
+ const [duplicateWarning, setDuplicateWarning] = useState(null);
79
+ const [formatWarning, setFormatWarning] = useState(null);
80
+ const [sizeWarning, setSizeWarning] = useState(null);
81
+ const [limitWarning, setLimitWarning] = useState(null);
82
+ const fileInputRef = useRef(null);
83
+ const { getGlobalField, getVariantField, clearAllMirages, getGlobalMirage, getVariantMirage } = useDynamicFormStore();
84
+ const dataKey = (schema == null ? void 0 : schema.data_key) || id;
85
+ const cleanKey = dataKey.replace("global.", "");
86
+ const isGlobal = dataKey.startsWith("global.") || variantIndex === void 0;
87
+ useEffect(() => {
88
+ if (!isMirage) return;
89
+ const currentMirage = isGlobal ? getGlobalMirage(cleanKey) : getVariantMirage(tierKey != null ? tierKey : "", variantIndex != null ? variantIndex : 0, cleanKey);
90
+ const currentStoreValue = isGlobal ? getGlobalField(cleanKey) : getVariantField(tierKey != null ? tierKey : "", variantIndex != null ? variantIndex : 0, cleanKey);
91
+ if (currentStoreValue !== void 0 && currentStoreValue !== currentMirage && currentStoreValue !== "") {
92
+ clearAllMirages();
93
+ }
94
+ }, [value, isMirage, isGlobal, cleanKey, tierKey, variantIndex, getGlobalMirage, getVariantMirage, getGlobalField, getVariantField, clearAllMirages]);
95
+ const envProjectId = useEnvStore((s) => s.projectId);
96
+ const configProjectId = useConfigStore(
97
+ (s) => {
98
+ var _a2, _b2;
99
+ return ((_a2 = s.configuration) == null ? void 0 : _a2.PROJECT_ID) || ((_b2 = s.configuration) == null ? void 0 : _b2.projectId);
100
+ }
101
+ );
102
+ const resolvedProjectId = props.projectId || (schema == null ? void 0 : schema.project_id) || envProjectId || configProjectId || (uiState == null ? void 0 : uiState.projectId) || (state == null ? void 0 : state.projectId) || (typeof window !== "undefined" ? window.__PROJECT_ID__ : void 0) || (typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.REACT_APP_PROJECT_ID : void 0) || null;
103
+ const runtimeConfig = getOptionalGuidelineRuntimeConfig();
104
+ const templateToken = useLearningTemplateStore((s) => s.token);
105
+ const authUser = useAuthStore((s) => s.user);
106
+ const runtimeToken = (_c = (_b = runtimeConfig == null ? void 0 : runtimeConfig.getHostContext) == null ? void 0 : _b.call(runtimeConfig)) == null ? void 0 : _c.authToken;
107
+ const resolvedToken = templateToken || (authUser == null ? void 0 : authUser.accessToken) || runtimeToken || "";
108
+ const resolvedUserName = props.artifactUserName || ((authUser == null ? void 0 : authUser.firstname) ? `${authUser.firstname} ${authUser.lastname || ""}`.trim() : null) || (authUser == null ? void 0 : authUser.email) || ((_e = (_d = runtimeConfig == null ? void 0 : runtimeConfig.getHostContext) == null ? void 0 : _d.call(runtimeConfig)) == null ? void 0 : _e.userName) || null;
109
+ const resolvedUserEmail = props.artifactUserEmail || (authUser == null ? void 0 : authUser.email) || ((_g = (_f = runtimeConfig == null ? void 0 : runtimeConfig.getHostContext) == null ? void 0 : _f.call(runtimeConfig)) == null ? void 0 : _g.userEmail) || null;
110
+ const filesList = useMemo(() => {
111
+ if (!value) return [];
112
+ if (Array.isArray(value)) {
113
+ return value.map((item, index) => {
114
+ var _a2;
115
+ if (typeof item === "string") {
116
+ return {
117
+ id: `file-${index}-${item}`,
118
+ name: item.split("/").pop() || item,
119
+ filename: item.split("/").pop() || item,
120
+ url: item,
121
+ signedUrl: item.startsWith("http") ? item : void 0,
122
+ status: "success"
123
+ };
124
+ }
125
+ return {
126
+ id: item.id || `file-${index}`,
127
+ name: item.name || item.filename || "Uploaded Document",
128
+ filename: item.filename || item.name,
129
+ url: item.url,
130
+ signedUrl: item.signedUrl || item.signed_url || (((_a2 = item.url) == null ? void 0 : _a2.startsWith("http")) ? item.url : void 0),
131
+ previewUrl: item.previewUrl,
132
+ size: item.size,
133
+ type: item.type,
134
+ status: item.status || "success",
135
+ progress: item.progress,
136
+ error: item.error
137
+ };
138
+ });
139
+ }
140
+ if (typeof value === "string") {
141
+ try {
142
+ const parsed = JSON.parse(value);
143
+ if (Array.isArray(parsed)) {
144
+ return parsed.map((item, index) => {
145
+ var _a2;
146
+ if (typeof item === "string") {
147
+ return {
148
+ id: `file-${index}-${item}`,
149
+ name: item.split("/").pop() || item,
150
+ filename: item.split("/").pop() || item,
151
+ url: item,
152
+ signedUrl: item.startsWith("http") ? item : void 0,
153
+ status: "success"
154
+ };
155
+ }
156
+ return {
157
+ id: item.id || `file-${index}`,
158
+ name: item.name || item.filename || "Uploaded Document",
159
+ filename: item.filename || item.name,
160
+ url: item.url,
161
+ signedUrl: item.signedUrl || item.signed_url || (((_a2 = item.url) == null ? void 0 : _a2.startsWith("http")) ? item.url : void 0),
162
+ previewUrl: item.previewUrl,
163
+ size: item.size,
164
+ type: item.type,
165
+ status: item.status || "success",
166
+ progress: item.progress,
167
+ error: item.error
168
+ };
169
+ });
170
+ }
171
+ } catch (e) {
172
+ return [
173
+ {
174
+ id: "file-0",
175
+ name: value.split("/").pop() || value,
176
+ filename: value.split("/").pop() || value,
177
+ url: value,
178
+ signedUrl: value.startsWith("http") ? value : void 0,
179
+ status: "success"
180
+ }
181
+ ];
182
+ }
183
+ }
184
+ return [];
185
+ }, [value]);
186
+ const [signedUrlMap, setSignedUrlMap] = useState({});
187
+ useEffect(() => {
188
+ const filesNeedingSignedUrl = filesList.filter((f) => {
189
+ const path = f.url;
190
+ if (!path) return false;
191
+ if (f.signedUrl) return false;
192
+ if (signedUrlMap[path]) return false;
193
+ return true;
194
+ });
195
+ if (filesNeedingSignedUrl.length === 0) return;
196
+ let isMounted = true;
197
+ void Promise.all(
198
+ filesNeedingSignedUrl.map(async (file) => {
199
+ const path = file.url;
200
+ try {
201
+ const fetchedUrl = await getGCSSignedUrl(path, {
202
+ token: resolvedToken
203
+ });
204
+ return { path, url: fetchedUrl };
205
+ } catch (e) {
206
+ return { path, url: null };
207
+ }
208
+ })
209
+ ).then((results) => {
210
+ if (!isMounted) return;
211
+ setSignedUrlMap((prev) => {
212
+ const next = { ...prev };
213
+ let hasNew = false;
214
+ results.forEach(({ path, url }) => {
215
+ if (url && next[path] !== url) {
216
+ next[path] = url;
217
+ hasNew = true;
218
+ }
219
+ });
220
+ return hasNew ? next : prev;
221
+ });
222
+ });
223
+ return () => {
224
+ isMounted = false;
225
+ };
226
+ }, [filesList, resolvedToken, signedUrlMap]);
227
+ const isStreaming = propAiStreaming || (uiState == null ? void 0 : uiState.isAiStreaming) || false;
228
+ const isParentControlled = hideEditControls !== void 0 ? !!hideEditControls : false;
229
+ const isEditing = !readOnly && !isStreaming && (isParentControlled ? !!parentEditing : enableInlineEdit ? activeEditId === id : true);
230
+ const isEditingRef = useRef(isEditing);
231
+ useEffect(() => {
232
+ isEditingRef.current = isEditing;
233
+ }, [isEditing]);
234
+ const isUploadLimitReached = filesList.length >= effectiveMaxUploads;
235
+ const canUploadMore = isEditing && !isUploadLimitReached;
236
+ const helperTextContent = useMemo(() => {
237
+ const parts = [];
238
+ if (acceptedFormatsLabel) {
239
+ parts.push(acceptedFormatsLabel);
240
+ } else {
241
+ parts.push("All file formats accepted");
242
+ }
243
+ if (isFinite(effectiveMaxUploads)) {
244
+ parts.push(`Up to ${effectiveMaxUploads} ${effectiveMaxUploads === 1 ? "file" : "files"}`);
245
+ }
246
+ if (maxFileSizeLabel) {
247
+ parts.push(`Maximum file size: ${maxFileSizeLabel} per file`);
248
+ } else {
249
+ parts.push("No file size limit");
250
+ }
251
+ return parts.join(" \u2022 ");
252
+ }, [effectiveMaxUploads, acceptedFormatsLabel, maxFileSizeLabel]);
253
+ const handleUploadFiles = useCallback(
254
+ async (rawFiles) => {
255
+ if (!isEditing || !onChange) return;
256
+ const fileArray = Array.from(rawFiles);
257
+ if (fileArray.length === 0) return;
258
+ setDuplicateWarning(null);
259
+ setFormatWarning(null);
260
+ setSizeWarning(null);
261
+ setLimitWarning(null);
262
+ const remainingSlots = isFinite(effectiveMaxUploads) ? Math.max(0, effectiveMaxUploads - filesList.length) : Infinity;
263
+ if (remainingSlots <= 0) {
264
+ setLimitWarning(
265
+ isSingleUpload ? "Only 1 file can be uploaded. Delete the current file to upload a new one." : `Maximum upload limit of ${effectiveMaxUploads} ${effectiveMaxUploads === 1 ? "file" : "files"} reached.`
266
+ );
267
+ if (fileInputRef.current) {
268
+ fileInputRef.current.value = "";
269
+ }
270
+ return;
271
+ }
272
+ let filesToProcess = fileArray;
273
+ if (isSingleUpload && fileArray.length > 1) {
274
+ setLimitWarning("Single upload mode: only the first file was selected.");
275
+ filesToProcess = [fileArray[0]];
276
+ } else if (fileArray.length > remainingSlots) {
277
+ setLimitWarning(
278
+ `Maximum ${effectiveMaxUploads} files allowed. Only the first ${remainingSlots} ${remainingSlots === 1 ? "file was" : "files were"} accepted.`
279
+ );
280
+ filesToProcess = fileArray.slice(0, remainingSlots);
281
+ }
282
+ const validFiles = [];
283
+ const invalidFiles = [];
284
+ const oversizedFiles = [];
285
+ for (const file of filesToProcess) {
286
+ if (!isFileAccepted(file, normalizedAccept)) {
287
+ invalidFiles.push(file);
288
+ } else if (effectiveMaxFileSizeBytes !== null && file.size > effectiveMaxFileSizeBytes) {
289
+ oversizedFiles.push(file);
290
+ } else {
291
+ validFiles.push(file);
292
+ }
293
+ }
294
+ if (invalidFiles.length > 0) {
295
+ const invalidNames = invalidFiles.map((f) => f.name).join(", ");
296
+ const message = invalidFiles.length === 1 ? `File "${invalidNames}" is not an accepted format. Accepted formats: ${normalizedAccept}` : `Files "${invalidNames}" are not accepted formats. Accepted formats: ${normalizedAccept}`;
297
+ setFormatWarning(message);
298
+ }
299
+ if (oversizedFiles.length > 0 && maxFileSizeLabel) {
300
+ const oversizedNames = oversizedFiles.map((file) => file.name).join(", ");
301
+ const message = oversizedFiles.length === 1 ? `File "${oversizedNames}" exceeds the ${maxFileSizeLabel} per-file size limit.` : `Files "${oversizedNames}" exceed the ${maxFileSizeLabel} per-file size limit.`;
302
+ setSizeWarning(message);
303
+ }
304
+ if (validFiles.length === 0) {
305
+ if (fileInputRef.current) {
306
+ fileInputRef.current.value = "";
307
+ }
308
+ return;
309
+ }
310
+ setIsUploading(true);
311
+ const optimisticItems = validFiles.map((file, i) => {
312
+ const isImg = isImageFile(file.name, file.type);
313
+ let previewBlobUrl = void 0;
314
+ try {
315
+ if (isImg && typeof URL !== "undefined" && typeof URL.createObjectURL === "function") {
316
+ previewBlobUrl = URL.createObjectURL(file);
317
+ }
318
+ } catch (e) {
319
+ }
320
+ return {
321
+ id: `upload-${Date.now()}-${i}-${file.name}`,
322
+ name: file.name,
323
+ filename: file.name,
324
+ size: file.size,
325
+ type: file.type,
326
+ status: "uploading",
327
+ progress: 0,
328
+ previewUrl: previewBlobUrl
329
+ };
330
+ });
331
+ let currentList = [...filesList, ...optimisticItems];
332
+ onChange(currentList);
333
+ try {
334
+ const result = await uploadFilesBatch({
335
+ projectId: resolvedProjectId || "",
336
+ files: validFiles,
337
+ token: resolvedToken,
338
+ artifactUserName: resolvedUserName,
339
+ artifactUserEmail: resolvedUserEmail,
340
+ onProgress: (_totalPct, fileProgressMap) => {
341
+ if (!isEditingRef.current || !fileProgressMap) return;
342
+ currentList = currentList.map((item) => {
343
+ if (item.status === "uploading" && fileProgressMap[item.name || item.filename || ""] !== void 0) {
344
+ const fileBytes = item.size || 1;
345
+ const loaded = fileProgressMap[item.name || item.filename || ""];
346
+ const pct = Math.min(99, Math.round(loaded / fileBytes * 100));
347
+ return { ...item, progress: pct };
348
+ }
349
+ return item;
350
+ });
351
+ onChange(currentList);
352
+ }
353
+ });
354
+ if (!isEditingRef.current) return;
355
+ if (result.duplicates.length > 0) {
356
+ const dupNames = result.duplicates.join(", ");
357
+ const message = result.duplicates.length === 1 ? `File "${dupNames}" already exists.` : `Files "${dupNames}" already exist.`;
358
+ setDuplicateWarning(message);
359
+ }
360
+ const updatedList = [];
361
+ for (const item of currentList) {
362
+ const optimisticMatch = optimisticItems.find((opt) => opt.id === item.id);
363
+ if (!optimisticMatch) {
364
+ updatedList.push(item);
365
+ continue;
366
+ }
367
+ const fileName = item.name || item.filename || "";
368
+ if (result.duplicates.includes(fileName)) {
369
+ continue;
370
+ }
371
+ const uploadedSuccess = result.uploaded.find(
372
+ (u) => u.name === fileName || u.filename === fileName
373
+ );
374
+ if (uploadedSuccess) {
375
+ if (uploadedSuccess.url && uploadedSuccess.signedUrl) {
376
+ setSignedUrlMap((prev) => ({
377
+ ...prev,
378
+ [uploadedSuccess.url]: uploadedSuccess.signedUrl
379
+ }));
380
+ }
381
+ updatedList.push({
382
+ ...uploadedSuccess,
383
+ id: item.id,
384
+ previewUrl: uploadedSuccess.previewUrl || item.previewUrl
385
+ });
386
+ continue;
387
+ }
388
+ const fileSpecificError = result.errors.find((err) => err.includes(fileName));
389
+ const generalError = result.errors.length > 0 ? result.errors[0] : null;
390
+ updatedList.push({
391
+ ...item,
392
+ status: "error",
393
+ error: fileSpecificError || generalError || "Failed to upload"
394
+ });
395
+ }
396
+ if (!isEditingRef.current) return;
397
+ onChange(updatedList);
398
+ } catch (err) {
399
+ if (!isEditingRef.current) return;
400
+ console.error("[FileUploadField] Upload process error:", err);
401
+ const errorList = currentList.map((item) => {
402
+ const optimisticMatch = optimisticItems.find((opt) => opt.id === item.id);
403
+ if (optimisticMatch) {
404
+ return {
405
+ ...item,
406
+ status: "error",
407
+ error: (err == null ? void 0 : err.message) || "Upload failed"
408
+ };
409
+ }
410
+ return item;
411
+ });
412
+ onChange(errorList);
413
+ } finally {
414
+ setIsUploading(false);
415
+ if (fileInputRef.current) {
416
+ fileInputRef.current.value = "";
417
+ }
418
+ }
419
+ },
420
+ [
421
+ isEditing,
422
+ onChange,
423
+ filesList,
424
+ resolvedProjectId,
425
+ resolvedToken,
426
+ resolvedUserName,
427
+ resolvedUserEmail,
428
+ normalizedAccept,
429
+ effectiveMaxUploads,
430
+ effectiveMaxFileSizeBytes,
431
+ maxFileSizeLabel,
432
+ isSingleUpload
433
+ ]
434
+ );
435
+ const handleDragOver = (e) => {
436
+ e.preventDefault();
437
+ e.stopPropagation();
438
+ if (isEditing && !isDragging) {
439
+ setIsDragging(true);
440
+ }
441
+ };
442
+ const handleDragLeave = (e) => {
443
+ e.preventDefault();
444
+ e.stopPropagation();
445
+ if (isDragging) {
446
+ setIsDragging(false);
447
+ }
448
+ };
449
+ const handleDrop = (e) => {
450
+ var _a2;
451
+ e.preventDefault();
452
+ e.stopPropagation();
453
+ setIsDragging(false);
454
+ if (!isEditing) return;
455
+ if (((_a2 = e.dataTransfer) == null ? void 0 : _a2.files) && e.dataTransfer.files.length > 0) {
456
+ void handleUploadFiles(e.dataTransfer.files);
457
+ }
458
+ };
459
+ const handleNativeFileChange = (e) => {
460
+ if (!isEditing) return;
461
+ if (e.target.files && e.target.files.length > 0) {
462
+ void handleUploadFiles(e.target.files);
463
+ }
464
+ };
465
+ const handleBrowseClick = (e) => {
466
+ var _a2;
467
+ e.stopPropagation();
468
+ if (!isEditing) return;
469
+ (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
470
+ };
471
+ const handleDropzoneClick = () => {
472
+ var _a2;
473
+ if (!isEditing) return;
474
+ (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
475
+ };
476
+ const handleRemoveFile = (targetId, e) => {
477
+ e.stopPropagation();
478
+ if (!isEditing || !onChange) return;
479
+ setDuplicateWarning(null);
480
+ setFormatWarning(null);
481
+ setSizeWarning(null);
482
+ setLimitWarning(null);
483
+ if (fileInputRef.current) {
484
+ fileInputRef.current.value = "";
485
+ }
486
+ const nextList = filesList.filter((item) => item.id !== targetId);
487
+ onChange(nextList);
488
+ };
489
+ const inlineSnapshotRef = useRef(null);
490
+ const handleInlineStart = () => {
491
+ setDuplicateWarning(null);
492
+ setFormatWarning(null);
493
+ setSizeWarning(null);
494
+ setLimitWarning(null);
495
+ inlineSnapshotRef.current = JSON.parse(JSON.stringify(filesList));
496
+ setActiveEditId == null ? void 0 : setActiveEditId(id);
497
+ };
498
+ const handleInlineCancel = () => {
499
+ if (inlineSnapshotRef.current !== null && onChange) {
500
+ onChange(inlineSnapshotRef.current);
501
+ }
502
+ inlineSnapshotRef.current = null;
503
+ setDuplicateWarning(null);
504
+ setFormatWarning(null);
505
+ setSizeWarning(null);
506
+ setLimitWarning(null);
507
+ setActiveEditId == null ? void 0 : setActiveEditId(null);
508
+ };
509
+ const handleInlineDone = () => {
510
+ inlineSnapshotRef.current = null;
511
+ setActiveEditId == null ? void 0 : setActiveEditId(null);
512
+ };
513
+ const inlineEditActions = enableInlineEdit && !isParentControlled && !readOnly ? isEditing ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px" }, children: [
514
+ /* @__PURE__ */ jsxs(
515
+ "button",
516
+ {
517
+ type: "button",
518
+ title: "Apply changes",
519
+ onClick: handleInlineDone,
520
+ style: {
521
+ display: "flex",
522
+ alignItems: "center",
523
+ gap: "4px",
524
+ padding: "4px 8px",
525
+ borderRadius: "6px",
526
+ border: "1px solid var(--il-primary, #2563EB)",
527
+ backgroundColor: "var(--il-primary, #2563EB)",
528
+ color: "#ffffff",
529
+ fontSize: "12px",
530
+ fontWeight: 500,
531
+ cursor: "pointer"
532
+ },
533
+ children: [
534
+ /* @__PURE__ */ jsx(Check, { size: 14 }),
535
+ " Done"
536
+ ]
537
+ }
538
+ ),
539
+ /* @__PURE__ */ jsxs(
540
+ "button",
541
+ {
542
+ type: "button",
543
+ title: "Cancel changes",
544
+ onClick: handleInlineCancel,
545
+ style: {
546
+ display: "flex",
547
+ alignItems: "center",
548
+ gap: "4px",
549
+ padding: "4px 8px",
550
+ borderRadius: "6px",
551
+ border: "1px solid var(--il-border, #CBD5E1)",
552
+ backgroundColor: "var(--il-surface, #ffffff)",
553
+ color: "var(--il-muted, #64748B)",
554
+ fontSize: "12px",
555
+ fontWeight: 500,
556
+ cursor: "pointer"
557
+ },
558
+ children: [
559
+ /* @__PURE__ */ jsx(X, { size: 14 }),
560
+ " Cancel"
561
+ ]
562
+ }
563
+ )
564
+ ] }) : /* @__PURE__ */ jsxs(
565
+ "button",
566
+ {
567
+ type: "button",
568
+ title: "Edit",
569
+ onClick: handleInlineStart,
570
+ disabled: isStreaming,
571
+ style: {
572
+ display: "flex",
573
+ alignItems: "center",
574
+ gap: "4px",
575
+ padding: "4px 8px",
576
+ borderRadius: "6px",
577
+ border: "1px solid var(--il-border, #CBD5E1)",
578
+ backgroundColor: "var(--il-surface, #ffffff)",
579
+ color: "var(--il-muted, #64748B)",
580
+ fontSize: "12px",
581
+ fontWeight: 500,
582
+ cursor: isStreaming ? "not-allowed" : "pointer",
583
+ opacity: isStreaming ? 0.5 : 1
584
+ },
585
+ children: [
586
+ /* @__PURE__ */ jsx(Pencil, { size: 14 }),
587
+ " Edit"
588
+ ]
589
+ }
590
+ ) : null;
591
+ const headerActions = citation || inlineEditActions ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
592
+ inlineEditActions,
593
+ citation && /* @__PURE__ */ jsx(
594
+ "button",
595
+ {
596
+ type: "button",
597
+ onClick: () => setIsReasoningOpen((prev) => !prev),
598
+ style: {
599
+ background: "none",
600
+ border: "none",
601
+ padding: "4px",
602
+ cursor: "pointer",
603
+ display: "flex",
604
+ alignItems: "center",
605
+ justifyContent: "center"
606
+ },
607
+ title: "Why this value?",
608
+ "aria-label": "Toggle cognitive reasoning",
609
+ children: /* @__PURE__ */ jsx(ButtonCognitiveIcon, {})
610
+ }
611
+ )
612
+ ] }) : null;
613
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
614
+ /* @__PURE__ */ jsx(
615
+ SectionWrapper,
616
+ {
617
+ id,
618
+ required,
619
+ title,
620
+ subtitle,
621
+ collapsible: isCollapsible,
622
+ defaultOpen: resolvedDefaultOpen,
623
+ bordered: isBordered,
624
+ openSections: propOpenSections,
625
+ setOpenSections: propSetOpenSections,
626
+ readOnly: !isEditing,
627
+ headerActions,
628
+ children: /* @__PURE__ */ jsxs("div", { className: styles.container, children: [
629
+ /* @__PURE__ */ jsx(
630
+ "input",
631
+ {
632
+ ref: fileInputRef,
633
+ type: "file",
634
+ multiple: !isSingleUpload && effectiveMaxUploads > 1,
635
+ disabled: !canUploadMore,
636
+ accept: normalizedAccept,
637
+ style: { display: "none" },
638
+ onChange: handleNativeFileChange
639
+ }
640
+ ),
641
+ (duplicateWarning || formatWarning || sizeWarning || limitWarning) && /* @__PURE__ */ jsxs("div", { className: styles.warningBanner, role: "alert", children: [
642
+ /* @__PURE__ */ jsxs("div", { className: styles.warningContent, children: [
643
+ /* @__PURE__ */ jsx(AlertCircle, { size: 16, color: "#D97706", style: { flexShrink: 0 } }),
644
+ /* @__PURE__ */ jsx("span", { className: styles.warningText, children: [duplicateWarning, formatWarning, sizeWarning, limitWarning].filter(Boolean).join(" ") })
645
+ ] }),
646
+ /* @__PURE__ */ jsx(
647
+ "button",
648
+ {
649
+ type: "button",
650
+ onClick: () => {
651
+ setDuplicateWarning(null);
652
+ setFormatWarning(null);
653
+ setSizeWarning(null);
654
+ setLimitWarning(null);
655
+ },
656
+ className: styles.warningCloseBtn,
657
+ title: "Dismiss notification",
658
+ "aria-label": "Dismiss notification",
659
+ children: /* @__PURE__ */ jsx(X, { size: 14 })
660
+ }
661
+ )
662
+ ] }),
663
+ canUploadMore ? /* @__PURE__ */ jsxs(
664
+ "div",
665
+ {
666
+ className: `${styles.dropzone} ${isDragging ? styles.dropzoneActive : ""}`,
667
+ onClick: handleDropzoneClick,
668
+ onDragOver: handleDragOver,
669
+ onDragEnter: handleDragOver,
670
+ onDragLeave: handleDragLeave,
671
+ onDrop: handleDrop,
672
+ role: "button",
673
+ tabIndex: 0,
674
+ "aria-label": "Upload files dropzone",
675
+ children: [
676
+ /* @__PURE__ */ jsx("div", { className: styles.uploadIconWrapper, children: /* @__PURE__ */ jsx(Upload, { size: 24, strokeWidth: 2 }) }),
677
+ /* @__PURE__ */ jsx("p", { className: styles.promptText, children: isSingleUpload ? /* @__PURE__ */ jsxs(Fragment, { children: [
678
+ "Drag and drop a file here, or",
679
+ " ",
680
+ /* @__PURE__ */ jsx("span", { className: styles.browseLink, onClick: handleBrowseClick, children: "browse" })
681
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
682
+ "Drag and drop files here, or",
683
+ " ",
684
+ /* @__PURE__ */ jsx("span", { className: styles.browseLink, onClick: handleBrowseClick, children: "browse" })
685
+ ] }) }),
686
+ /* @__PURE__ */ jsx("p", { className: styles.helperText, children: helperTextContent })
687
+ ]
688
+ }
689
+ ) : filesList.length === 0 ? /* @__PURE__ */ jsxs(
690
+ "div",
691
+ {
692
+ className: `${styles.dropzone} ${styles.dropzoneDisabled}`,
693
+ role: "region",
694
+ "aria-label": "Upload files disabled",
695
+ children: [
696
+ /* @__PURE__ */ jsx("div", { className: styles.uploadIconWrapper, style: { color: "var(--il-muted, #94a3b8)" }, children: /* @__PURE__ */ jsx(Upload, { size: 24, strokeWidth: 2 }) }),
697
+ /* @__PURE__ */ jsx("p", { className: styles.promptText, style: { color: "var(--il-muted, #64748B)" }, children: "No documents uploaded" }),
698
+ /* @__PURE__ */ jsxs("p", { className: styles.helperText, children: [
699
+ helperTextContent,
700
+ " \u2022 Edit this section to upload documents"
701
+ ] })
702
+ ]
703
+ }
704
+ ) : null,
705
+ filesList.length > 0 && /* @__PURE__ */ jsx("div", { className: styles.fileList, children: filesList.map((file) => {
706
+ var _a2, _b2;
707
+ const extension = getFileExtension(file.name || file.filename);
708
+ const isItemUploading = file.status === "uploading";
709
+ const hasError = file.status === "error";
710
+ const isImg = isImageFile(file.name || file.filename, file.type);
711
+ const fileGcsUrl = file.url || "";
712
+ const effectiveSignedUrl = file.signedUrl || (fileGcsUrl ? signedUrlMap[fileGcsUrl] : void 0);
713
+ const effectiveLink = effectiveSignedUrl || (fileGcsUrl.startsWith("http") ? fileGcsUrl : void 0);
714
+ const effectiveImageSrc = effectiveSignedUrl || file.previewUrl || (fileGcsUrl.startsWith("http") ? fileGcsUrl : void 0);
715
+ return /* @__PURE__ */ jsxs(
716
+ "div",
717
+ {
718
+ className: `${styles.fileCard} ${hasError ? styles.fileCardError : ""}`,
719
+ children: [
720
+ /* @__PURE__ */ jsxs("div", { className: styles.fileInfoLeft, children: [
721
+ hasError ? /* @__PURE__ */ jsx("div", { className: styles.fileIcon, children: /* @__PURE__ */ jsx(AlertCircle, { size: 22, color: "#EF4444" }) }) : isImg ? effectiveImageSrc ? /* @__PURE__ */ jsx(
722
+ "a",
723
+ {
724
+ href: effectiveLink || effectiveImageSrc,
725
+ target: "_blank",
726
+ rel: "noopener noreferrer",
727
+ className: styles.imagePreviewSquare,
728
+ onClick: (e) => {
729
+ if (!effectiveLink && !effectiveImageSrc) {
730
+ e.preventDefault();
731
+ }
732
+ e.stopPropagation();
733
+ },
734
+ title: `Preview ${file.name}`,
735
+ children: /* @__PURE__ */ jsx(
736
+ "img",
737
+ {
738
+ src: effectiveImageSrc,
739
+ alt: file.name,
740
+ className: styles.imageThumbnail
741
+ }
742
+ )
743
+ }
744
+ ) : /* @__PURE__ */ jsx("div", { className: styles.imagePreviewSquare, children: /* @__PURE__ */ jsx(FileText, { size: 26, strokeWidth: 1.8, color: "#7C3AED" }) }) : /* @__PURE__ */ jsx("div", { className: styles.fileIcon, children: /* @__PURE__ */ jsx(FileText, { size: 22, strokeWidth: 1.8 }) }),
745
+ /* @__PURE__ */ jsxs("div", { className: styles.fileMeta, children: [
746
+ effectiveLink && !hasError && !isItemUploading ? /* @__PURE__ */ jsx(
747
+ "a",
748
+ {
749
+ href: effectiveLink,
750
+ target: "_blank",
751
+ rel: "noopener noreferrer",
752
+ className: styles.fileName,
753
+ title: file.name,
754
+ onClick: (e) => e.stopPropagation(),
755
+ children: file.name
756
+ }
757
+ ) : /* @__PURE__ */ jsx("span", { className: styles.fileName, title: file.name, children: file.name }),
758
+ hasError ? /* @__PURE__ */ jsx("span", { className: styles.fileErrorText, children: file.error || "Failed to upload" }) : isItemUploading ? /* @__PURE__ */ jsxs("div", { className: styles.progressContainer, children: [
759
+ /* @__PURE__ */ jsxs("span", { className: styles.progressLabel, children: [
760
+ "Uploading... ",
761
+ (_a2 = file.progress) != null ? _a2 : 0,
762
+ "%"
763
+ ] }),
764
+ /* @__PURE__ */ jsx("div", { className: styles.progressBarWrapper, children: /* @__PURE__ */ jsx(
765
+ "div",
766
+ {
767
+ className: styles.progressBarFill,
768
+ style: { width: `${Math.max((_b2 = file.progress) != null ? _b2 : 15, 10)}%` }
769
+ }
770
+ ) })
771
+ ] }) : /* @__PURE__ */ jsxs("span", { className: styles.fileType, children: [
772
+ extension,
773
+ file.size ? ` \u2022 ${formatFileSize(file.size)}` : ""
774
+ ] })
775
+ ] })
776
+ ] }),
777
+ /* @__PURE__ */ jsx("div", { className: styles.fileActionsRight, children: isItemUploading ? /* @__PURE__ */ jsx(Loader2, { size: 18, className: styles.loadingSpinner }) : isEditing ? /* @__PURE__ */ jsx(
778
+ "button",
779
+ {
780
+ type: "button",
781
+ className: styles.removeButton,
782
+ title: "Remove file",
783
+ "aria-label": `Remove ${file.name}`,
784
+ onClick: (e) => handleRemoveFile(file.id, e),
785
+ children: /* @__PURE__ */ jsx(X, { size: 18 })
786
+ }
787
+ ) : null })
788
+ ]
789
+ },
790
+ file.id
791
+ );
792
+ }) }),
793
+ !canUploadMore && filesList.length > 0 && /* @__PURE__ */ jsx("p", { className: styles.helperText, children: helperTextContent })
794
+ ] })
795
+ }
796
+ ),
797
+ citation && /* @__PURE__ */ jsx(
798
+ InputDataReasoningCard,
799
+ {
800
+ isVisible: isReasoningOpen,
801
+ citation,
802
+ citations: state == null ? void 0 : state.citations,
803
+ fieldName: title,
804
+ fieldValue: value
805
+ }
806
+ )
807
+ ] });
808
+ }
809
+
810
+ export { FileUploadField as default };
811
+ //# sourceMappingURL=FileUploadField.js.map