@iblai/iblai-js 2.22.0 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3836,7 +3836,9 @@ var datasetsTabAddResourceModal$3 = {
3836
3836
  title: "Add Resources",
3837
3837
  description: "Add knowledge to help your agent provide more relevant insights. Others with edit access can reuse these sources for more topics.",
3838
3838
  googleDrivePickerError: "Google Drive Picker Error",
3839
- forceClosePicker: "Force Close Picker"
3839
+ forceClosePicker: "Force Close Picker",
3840
+ notConfigured: "Not configured for this tenant",
3841
+ scrollRegionAriaLabel: "Resource types"
3840
3842
  };
3841
3843
  var datasetsTabDatasetItem$3 = {
3842
3844
  scheduleRetrain: "Schedule retrain",
@@ -5754,7 +5756,11 @@ var resourceModalGithubFileUploadModal$3 = {
5754
5756
  errorAddingDocument: "Error adding training document",
5755
5757
  githubRepoUrlPlaceholder: "Github Repo URL",
5756
5758
  selectBranchPlaceholder: "Select Branch",
5757
- submit: "Submit"
5759
+ submit: "Submit",
5760
+ description: "Add a GitHub repository and pick a branch to train your agent on.",
5761
+ scrollRegionAriaLabel: "Repository details",
5762
+ repoUrlLabel: "Repository URL",
5763
+ branchLabel: "Branch"
5758
5764
  };
5759
5765
  var resourceModalLocalFileUploadModal$3 = {
5760
5766
  fileNotFound: "File not found",
@@ -5768,7 +5774,9 @@ var resourceModalLocalFileUploadModal$3 = {
5768
5774
  descriptionOptional: "Description (optional)",
5769
5775
  descriptionPlaceholder: "Add a description for this image...",
5770
5776
  submitting: "Submitting",
5771
- submit: "Submit"
5777
+ submit: "Submit",
5778
+ description: "Upload a file to train your agent on its contents.",
5779
+ scrollRegionAriaLabel: "File upload"
5772
5780
  };
5773
5781
  var resourceModalUrlUploadModal$3 = {
5774
5782
  urlPlaceholder: "URL",
@@ -5777,11 +5785,15 @@ var resourceModalUrlUploadModal$3 = {
5777
5785
  invalidYoutubeUrl: "Invalid YouTube URL",
5778
5786
  invalidBlackboardUrl: "Invalid Blackboard URL",
5779
5787
  invalidUrl: "Invalid URL",
5780
- submit: "Submit"
5788
+ submit: "Submit",
5789
+ description: "Add a link to train your agent on its content.",
5790
+ scrollRegionAriaLabel: "Link details",
5791
+ urlLabel: "URL"
5781
5792
  };
5782
5793
  var resourceModalWebsiteCrawlModal$3 = {
5783
- title: "Web Crawler Configuration",
5784
5794
  description: "Configure your web crawler settings and URL patterns",
5795
+ infoBox: "Crawl a website and train your agent on its pages. Set how deep to follow links, how many pages to fetch, and which URLs to include.",
5796
+ scrollRegionAriaLabel: "Web crawler settings",
5785
5797
  formAriaLabel: "Web crawler configuration form",
5786
5798
  urlRequired: "URL is required",
5787
5799
  invalidUrl: "Invalid URL",
@@ -5796,6 +5808,9 @@ var resourceModalWebsiteCrawlModal$3 = {
5796
5808
  selectPatternTypeAriaLabel: "Select pattern type",
5797
5809
  globPattern: "Glob Pattern",
5798
5810
  regularExpression: "Regular Expression",
5811
+ userAgentLabel: "User-Agent (optional)",
5812
+ userAgentPlaceholder: "Iblai-bot/1.0 (+https://ibl.ai/bot)",
5813
+ userAgentHelpText: "Optional. Overrides the default crawler User-Agent for every request. Leave blank to use the default.",
5799
5814
  crawlerMatchPatternsLabel: "Crawler Match Patterns",
5800
5815
  globPlaceholder: "https://example.com/",
5801
5816
  regexPlaceholder: "(http|https)://www.example.com/(.*)",
@@ -11325,7 +11340,9 @@ var datasetsTabAddResourceModal$2 = {
11325
11340
  title: "Ajouter des ressources",
11326
11341
  description: "Ajoutez des connaissances pour aider votre agent à fournir des informations plus pertinentes. Les autres utilisateurs avec accès en modification peuvent réutiliser ces sources pour d'autres sujets.",
11327
11342
  googleDrivePickerError: "Erreur du sélecteur Google Drive",
11328
- forceClosePicker: "Forcer la fermeture du sélecteur"
11343
+ forceClosePicker: "Forcer la fermeture du sélecteur",
11344
+ notConfigured: "Non configuré pour ce locataire",
11345
+ scrollRegionAriaLabel: "Types de ressources"
11329
11346
  };
11330
11347
  var datasetsTabDatasetItem$2 = {
11331
11348
  scheduleRetrain: "Planifier le réentraînement",
@@ -13243,7 +13260,11 @@ var resourceModalGithubFileUploadModal$2 = {
13243
13260
  errorAddingDocument: "Erreur lors de l'ajout du document d'entraînement",
13244
13261
  githubRepoUrlPlaceholder: "URL du dépôt GitHub",
13245
13262
  selectBranchPlaceholder: "Sélectionner une branche",
13246
- submit: "Soumettre"
13263
+ submit: "Soumettre",
13264
+ description: "Ajoutez un dépôt GitHub et choisissez une branche pour entraîner votre agent.",
13265
+ scrollRegionAriaLabel: "Détails du dépôt",
13266
+ repoUrlLabel: "URL du dépôt",
13267
+ branchLabel: "Branche"
13247
13268
  };
13248
13269
  var resourceModalLocalFileUploadModal$2 = {
13249
13270
  fileNotFound: "Fichier introuvable",
@@ -13257,7 +13278,9 @@ var resourceModalLocalFileUploadModal$2 = {
13257
13278
  descriptionOptional: "Description (facultative)",
13258
13279
  descriptionPlaceholder: "Ajoutez une description pour cette image...",
13259
13280
  submitting: "Envoi en cours",
13260
- submit: "Soumettre"
13281
+ submit: "Soumettre",
13282
+ description: "Importez un fichier pour entraîner votre agent sur son contenu.",
13283
+ scrollRegionAriaLabel: "Import de fichier"
13261
13284
  };
13262
13285
  var resourceModalUrlUploadModal$2 = {
13263
13286
  urlPlaceholder: "URL",
@@ -13266,11 +13289,15 @@ var resourceModalUrlUploadModal$2 = {
13266
13289
  invalidYoutubeUrl: "URL YouTube invalide",
13267
13290
  invalidBlackboardUrl: "URL Blackboard invalide",
13268
13291
  invalidUrl: "URL invalide",
13269
- submit: "Soumettre"
13292
+ submit: "Soumettre",
13293
+ description: "Ajoutez un lien pour entraîner votre agent sur son contenu.",
13294
+ scrollRegionAriaLabel: "Détails du lien",
13295
+ urlLabel: "URL"
13270
13296
  };
13271
13297
  var resourceModalWebsiteCrawlModal$2 = {
13272
- title: "Configuration du robot d'exploration web",
13273
13298
  description: "Configurez les paramètres et les modèles d'URL de votre robot d'exploration web",
13299
+ infoBox: "Explorez un site web et entraînez votre agent sur ses pages. Définissez la profondeur des liens, le nombre de pages à récupérer et les URL à inclure.",
13300
+ scrollRegionAriaLabel: "Paramètres du robot d'exploration",
13274
13301
  formAriaLabel: "Formulaire de configuration du robot d'exploration web",
13275
13302
  urlRequired: "L'URL est requise",
13276
13303
  invalidUrl: "URL invalide",
@@ -13285,6 +13312,9 @@ var resourceModalWebsiteCrawlModal$2 = {
13285
13312
  selectPatternTypeAriaLabel: "Sélectionner le type de modèle",
13286
13313
  globPattern: "Modèle Glob",
13287
13314
  regularExpression: "Expression régulière",
13315
+ userAgentLabel: "User-Agent (facultatif)",
13316
+ userAgentPlaceholder: "Iblai-bot/1.0 (+https://ibl.ai/bot)",
13317
+ userAgentHelpText: "Facultatif. Remplace le User-Agent par défaut du robot d'exploration pour chaque requête. Laissez vide pour utiliser celui par défaut.",
13288
13318
  crawlerMatchPatternsLabel: "Modèles de correspondance du robot",
13289
13319
  globPlaceholder: "https://example.com/",
13290
13320
  regexPlaceholder: "(http|https)://www.example.com/(.*)",
@@ -18648,7 +18678,9 @@ var datasetsTabAddResourceModal$1 = {
18648
18678
  title: "Agregar recursos",
18649
18679
  description: "Agregue conocimiento para ayudar a su agente a proporcionar información más relevante. Otros usuarios con acceso de edición pueden reutilizar estas fuentes para más temas.",
18650
18680
  googleDrivePickerError: "Error del selector de Google Drive",
18651
- forceClosePicker: "Forzar cierre del selector"
18681
+ forceClosePicker: "Forzar cierre del selector",
18682
+ notConfigured: "No configurado para este inquilino",
18683
+ scrollRegionAriaLabel: "Tipos de recursos"
18652
18684
  };
18653
18685
  var datasetsTabDatasetItem$1 = {
18654
18686
  scheduleRetrain: "Programar reentrenamiento",
@@ -20566,7 +20598,11 @@ var resourceModalGithubFileUploadModal$1 = {
20566
20598
  errorAddingDocument: "Error al agregar el documento de entrenamiento",
20567
20599
  githubRepoUrlPlaceholder: "URL del repositorio de GitHub",
20568
20600
  selectBranchPlaceholder: "Seleccionar rama",
20569
- submit: "Enviar"
20601
+ submit: "Enviar",
20602
+ description: "Agrega un repositorio de GitHub y elige una rama para entrenar a tu agente.",
20603
+ scrollRegionAriaLabel: "Detalles del repositorio",
20604
+ repoUrlLabel: "URL del repositorio",
20605
+ branchLabel: "Rama"
20570
20606
  };
20571
20607
  var resourceModalLocalFileUploadModal$1 = {
20572
20608
  fileNotFound: "Archivo no encontrado",
@@ -20580,7 +20616,9 @@ var resourceModalLocalFileUploadModal$1 = {
20580
20616
  descriptionOptional: "Descripción (opcional)",
20581
20617
  descriptionPlaceholder: "Añade una descripción para esta imagen...",
20582
20618
  submitting: "Enviando",
20583
- submit: "Enviar"
20619
+ submit: "Enviar",
20620
+ description: "Sube un archivo para entrenar a tu agente con su contenido.",
20621
+ scrollRegionAriaLabel: "Carga de archivo"
20584
20622
  };
20585
20623
  var resourceModalUrlUploadModal$1 = {
20586
20624
  urlPlaceholder: "URL",
@@ -20589,11 +20627,15 @@ var resourceModalUrlUploadModal$1 = {
20589
20627
  invalidYoutubeUrl: "URL de YouTube no válida",
20590
20628
  invalidBlackboardUrl: "URL de Blackboard no válida",
20591
20629
  invalidUrl: "URL no válida",
20592
- submit: "Enviar"
20630
+ submit: "Enviar",
20631
+ description: "Agrega un enlace para entrenar a tu agente con su contenido.",
20632
+ scrollRegionAriaLabel: "Detalles del enlace",
20633
+ urlLabel: "URL"
20593
20634
  };
20594
20635
  var resourceModalWebsiteCrawlModal$1 = {
20595
- title: "Configuración del rastreador web",
20596
20636
  description: "Configure los ajustes de su rastreador web y los patrones de URL",
20637
+ infoBox: "Rastrea un sitio web y entrena a tu agente con sus páginas. Define la profundidad de los enlaces, cuántas páginas obtener y qué URL incluir.",
20638
+ scrollRegionAriaLabel: "Configuración del rastreador web",
20597
20639
  formAriaLabel: "Formulario de configuración del rastreador web",
20598
20640
  urlRequired: "La URL es obligatoria",
20599
20641
  invalidUrl: "URL no válida",
@@ -20608,6 +20650,9 @@ var resourceModalWebsiteCrawlModal$1 = {
20608
20650
  selectPatternTypeAriaLabel: "Seleccionar tipo de patrón",
20609
20651
  globPattern: "Patrón Glob",
20610
20652
  regularExpression: "Expresión regular",
20653
+ userAgentLabel: "User-Agent (opcional)",
20654
+ userAgentPlaceholder: "Iblai-bot/1.0 (+https://ibl.ai/bot)",
20655
+ userAgentHelpText: "Opcional. Sustituye el User-Agent predeterminado del rastreador en cada solicitud. Déjalo en blanco para usar el predeterminado.",
20611
20656
  crawlerMatchPatternsLabel: "Patrones de coincidencia del rastreador",
20612
20657
  globPlaceholder: "https://example.com/",
20613
20658
  regexPlaceholder: "(http|https)://www.example.com/(.*)",
@@ -25971,7 +26016,9 @@ var datasetsTabAddResourceModal = {
25971
26016
  title: "添加资源",
25972
26017
  description: "添加知识以帮助您的代理提供更相关的见解。其他具有编辑权限的用户可以为更多主题重复使用这些来源。",
25973
26018
  googleDrivePickerError: "Google Drive 选择器错误",
25974
- forceClosePicker: "强制关闭选择器"
26019
+ forceClosePicker: "强制关闭选择器",
26020
+ notConfigured: "未为此租户配置",
26021
+ scrollRegionAriaLabel: "资源类型"
25975
26022
  };
25976
26023
  var datasetsTabDatasetItem = {
25977
26024
  scheduleRetrain: "安排重新训练",
@@ -27889,7 +27936,11 @@ var resourceModalGithubFileUploadModal = {
27889
27936
  errorAddingDocument: "添加训练文档时出错",
27890
27937
  githubRepoUrlPlaceholder: "GitHub 仓库 URL",
27891
27938
  selectBranchPlaceholder: "选择分支",
27892
- submit: "提交"
27939
+ submit: "提交",
27940
+ description: "添加 GitHub 仓库并选择分支来训练您的智能体。",
27941
+ scrollRegionAriaLabel: "仓库详情",
27942
+ repoUrlLabel: "仓库 URL",
27943
+ branchLabel: "分支"
27893
27944
  };
27894
27945
  var resourceModalLocalFileUploadModal = {
27895
27946
  fileNotFound: "未找到文件",
@@ -27903,7 +27954,9 @@ var resourceModalLocalFileUploadModal = {
27903
27954
  descriptionOptional: "描述(可选)",
27904
27955
  descriptionPlaceholder: "为此图片添加描述...",
27905
27956
  submitting: "提交中",
27906
- submit: "提交"
27957
+ submit: "提交",
27958
+ description: "上传文件,用其内容训练您的智能体。",
27959
+ scrollRegionAriaLabel: "文件上传"
27907
27960
  };
27908
27961
  var resourceModalUrlUploadModal = {
27909
27962
  urlPlaceholder: "URL",
@@ -27912,11 +27965,15 @@ var resourceModalUrlUploadModal = {
27912
27965
  invalidYoutubeUrl: "无效的 YouTube URL",
27913
27966
  invalidBlackboardUrl: "无效的 Blackboard URL",
27914
27967
  invalidUrl: "无效的 URL",
27915
- submit: "提交"
27968
+ submit: "提交",
27969
+ description: "添加链接,用其内容训练您的智能体。",
27970
+ scrollRegionAriaLabel: "链接详情",
27971
+ urlLabel: "URL"
27916
27972
  };
27917
27973
  var resourceModalWebsiteCrawlModal = {
27918
- title: "网络爬虫配置",
27919
27974
  description: "配置您的网络爬虫设置和 URL 模式",
27975
+ infoBox: "抓取网站并用其页面训练您的智能体。设置链接跟踪深度、抓取页面数量以及要包含的网址。",
27976
+ scrollRegionAriaLabel: "网络爬虫设置",
27920
27977
  formAriaLabel: "网络爬虫配置表单",
27921
27978
  urlRequired: "URL 为必填项",
27922
27979
  invalidUrl: "无效的 URL",
@@ -27931,6 +27988,9 @@ var resourceModalWebsiteCrawlModal = {
27931
27988
  selectPatternTypeAriaLabel: "选择模式类型",
27932
27989
  globPattern: "Glob 模式",
27933
27990
  regularExpression: "正则表达式",
27991
+ userAgentLabel: "User-Agent(可选)",
27992
+ userAgentPlaceholder: "Iblai-bot/1.0 (+https://ibl.ai/bot)",
27993
+ userAgentHelpText: "可选。为每个请求覆盖默认的抓取工具 User-Agent。留空则使用默认值。",
27934
27994
  crawlerMatchPatternsLabel: "爬虫匹配模式",
27935
27995
  globPlaceholder: "https://example.com/",
27936
27996
  regexPlaceholder: "(http|https)://www.example.com/(.*)",
@@ -244213,7 +244273,7 @@ const ProjectFilesModal$1 = lazy(() => Promise.resolve().then(function () { retu
244213
244273
  const AddMentorToProjectModal$1 = lazy(() => Promise.resolve().then(function () { return addMentorToProjectModal; }).then((mod) => ({
244214
244274
  default: mod.AddMentorToProjectModal,
244215
244275
  })));
244216
- function ProjectLandingPage({ project, sessionId, onSubmit, onScreenSharingClick, isScreenSharingModalOpen, onPhoneCallClick, stopGenerating, tenantKey, username, enableSafetyDisclaimer, enableWebBrowsing, isStreaming, updateSessionTools, setSessionTools, activeTools, screenSharing, deepResearch, studyMode, imageGeneration, codeInterpreter, promptsIsEnabled, isPreviewMode, setMessage, mentorId, mentorUniqueId, projectId, googleSlidesIsEnabled, googleDocumentIsEnabled, artifactsEnabled, userIsStudent, isPublicRoute, navigateToProject, showExploreMentors = false, }) {
244276
+ function ProjectLandingPage({ project, sessionId, onSubmit, onScreenSharingClick, isScreenSharingModalOpen, onPhoneCallClick, stopGenerating, tenantKey, username, enableSafetyDisclaimer, enableWebBrowsing, isStreaming, updateSessionTools, setSessionTools, activeTools, screenSharing, deepResearch, studyMode, imageGeneration, codeInterpreter, promptsIsEnabled, isPreviewMode, setMessage, mentorId, mentorUniqueId, projectId, googleSlidesIsEnabled, googleDocumentIsEnabled, artifactsEnabled, userIsStudent, isPublicRoute, navigateToProject, showExploreMentors = false, disabledResourceTypes, maxUploadSizeMb, dropboxExtensions, }) {
244217
244277
  var _a;
244218
244278
  const [isInstructionsModalOpen, setIsInstructionsModalOpen] = useState(false);
244219
244279
  const [isFilesModalOpen, setIsFilesModalOpen] = useState(false);
@@ -244226,7 +244286,7 @@ function ProjectLandingPage({ project, sessionId, onSubmit, onScreenSharingClick
244226
244286
  name: mentor.name,
244227
244287
  avatar: mentor.profile_image,
244228
244288
  description: mentor.description,
244229
- })), onAddMentorClick: () => setIsAddMentorModalOpen(true), showTitle: true, tenantKey: tenantKey, mentorId: mentorId, projectId: projectId, username: username, navigateToProject: navigateToProject }))] })] })] }), isInstructionsModalOpen && (jsx(Suspense, { fallback: null, children: jsx(ProjectInstructionsModal$1, { isOpen: isInstructionsModalOpen, onClose: () => setIsInstructionsModalOpen(false), tenantKey: tenantKey, projectId: projectId, username: username }) })), isFilesModalOpen && (jsx(Suspense, { fallback: null, children: jsx(ProjectFilesModal$1, { isOpen: isFilesModalOpen, onClose: () => setIsFilesModalOpen(false), tenantKey: tenantKey, mentorId: mentorId, username: username }) })), isAddMentorModalOpen && (jsx(Suspense, { fallback: null, children: jsx(AddMentorToProjectModal$1, { isOpen: isAddMentorModalOpen, onClose: () => setIsAddMentorModalOpen(false), projectName: project.name, tenantKey: tenantKey, projectId: projectId, username: username, isPublicRoute: isPublicRoute }) }))] }));
244289
+ })), onAddMentorClick: () => setIsAddMentorModalOpen(true), showTitle: true, tenantKey: tenantKey, mentorId: mentorId, projectId: projectId, username: username, navigateToProject: navigateToProject }))] })] })] }), isInstructionsModalOpen && (jsx(Suspense, { fallback: null, children: jsx(ProjectInstructionsModal$1, { isOpen: isInstructionsModalOpen, onClose: () => setIsInstructionsModalOpen(false), tenantKey: tenantKey, projectId: projectId, username: username }) })), isFilesModalOpen && (jsx(Suspense, { fallback: null, children: jsx(ProjectFilesModal$1, { isOpen: isFilesModalOpen, onClose: () => setIsFilesModalOpen(false), tenantKey: tenantKey, mentorId: mentorId, username: username, disabledResourceTypes: disabledResourceTypes, maxUploadSizeMb: maxUploadSizeMb, dropboxExtensions: dropboxExtensions }) })), isAddMentorModalOpen && (jsx(Suspense, { fallback: null, children: jsx(AddMentorToProjectModal$1, { isOpen: isAddMentorModalOpen, onClose: () => setIsAddMentorModalOpen(false), projectName: project.name, tenantKey: tenantKey, projectId: projectId, username: username, isPublicRoute: isPublicRoute }) }))] }));
244230
244290
  }
244231
244291
 
244232
244292
  function MinimumMentorAlert({ open, onOpenChange }) {
@@ -244499,8 +244559,9 @@ const TrainOrDeleteModal$1 = dynamic(() => Promise.resolve().then(function () {
244499
244559
  */
244500
244560
  function isCrawlableDocType(documentType) {
244501
244561
  const docType = documentType === null || documentType === void 0 ? void 0 : documentType.toLowerCase();
244502
- // Uploaded documents (local files like PDF, DOCX, etc.)
244503
- const uploadedFileTypes = ['file'];
244562
+ // Uploaded documents: generic local files ('file') plus the local resource
244563
+ // types that send their own fileType as the document type.
244564
+ const uploadedFileTypes = ['file', 'image', 'audio', 'video', 'zip'];
244504
244565
  if (uploadedFileTypes.some((type) => docType === null || docType === void 0 ? void 0 : docType.includes(type))) {
244505
244566
  return false;
244506
244567
  }
@@ -244511,6 +244572,12 @@ function isCrawlableDocType(documentType) {
244511
244572
  }
244512
244573
  return true;
244513
244574
  }
244575
+ /**
244576
+ * The crawler User-Agent override only applies to web crawler documents.
244577
+ */
244578
+ function isWebCrawlerDocType(documentType) {
244579
+ return !!(documentType === null || documentType === void 0 ? void 0 : documentType.toLowerCase().includes('webcrawler'));
244580
+ }
244514
244581
  function DatasetItem({ dataset, onSelect, isSelected, labels }) {
244515
244582
  var _a, _b, _c, _d, _e;
244516
244583
  const t = useT();
@@ -244587,7 +244654,7 @@ function DatasetItem({ dataset, onSelect, isSelected, labels }) {
244587
244654
  }
244588
244655
  }, className: "text-gray-500 hover:text-gray-700", disabled: isEditTrainingDocumentLoading || disabled, children: dataset.access === 'private' ? (jsxs(Fragment$1, { children: [jsx(EyeOff, { className: "h-4 w-4" }), jsx("span", { className: "sr-only", children: t('datasetsTabDatasetItem.makePublic') })] })) : (jsxs(Fragment$1, { children: [jsx(Eye, { className: "h-4 w-4" }), jsx("span", { className: "sr-only", children: t('datasetsTabDatasetItem.makePrivate') })] })) })) }) }), jsx(TableCell, { className: "p-3 whitespace-nowrap", children: jsx(WithFormPermissions, { name: "is_trained",
244589
244656
  // @ts-ignore
244590
- permissions: (_e = dataset === null || dataset === void 0 ? void 0 : dataset.permissions) === null || _e === void 0 ? void 0 : _e.field, children: ({ disabled }) => (jsx(TrainingStatusSwitch, { is_trained: dataset.is_trained, url: dataset.url, disabled: disabled, training_status: dataset.training_status, handleEditTrainingDocument: handleEditTrainingDocument, onUntrainSuccess: () => setIsDeleteDatasetModalOpen(true), onTrainRequest: () => setIsTrainOrDeleteModalOpen(true) })) }) })] }, dataset.id), isDeleteDatasetModalOpen && (jsx(DeleteDatasetModal$1, { isOpen: isDeleteDatasetModalOpen, onClose: () => setIsDeleteDatasetModalOpen(false), dataset: dataset, labels: labels })), isRetrainScheduleModalOpen && (jsx(RetrainScheduleModal$1, { isOpen: isRetrainScheduleModalOpen, onClose: () => setIsRetrainScheduleModalOpen(false), dataset: dataset, labels: labels })), isTrainOrDeleteModalOpen && (jsx(TrainOrDeleteModal$1, { isOpen: isTrainOrDeleteModalOpen, onClose: () => setIsTrainOrDeleteModalOpen(false), onTrain: handleTrainDataset, onDelete: handleDeleteFromTrainModal, showUserAgentField: isCrawlableDocType(dataset.document_type), isLoading: isEditTrainingDocumentLoading, labels: labels }))] }));
244657
+ permissions: (_e = dataset === null || dataset === void 0 ? void 0 : dataset.permissions) === null || _e === void 0 ? void 0 : _e.field, children: ({ disabled }) => (jsx(TrainingStatusSwitch, { is_trained: dataset.is_trained, url: dataset.url, disabled: disabled, training_status: dataset.training_status, handleEditTrainingDocument: handleEditTrainingDocument, onUntrainSuccess: () => setIsDeleteDatasetModalOpen(true), onTrainRequest: () => setIsTrainOrDeleteModalOpen(true) })) }) })] }, dataset.id), isDeleteDatasetModalOpen && (jsx(DeleteDatasetModal$1, { isOpen: isDeleteDatasetModalOpen, onClose: () => setIsDeleteDatasetModalOpen(false), dataset: dataset, labels: labels })), isRetrainScheduleModalOpen && (jsx(RetrainScheduleModal$1, { isOpen: isRetrainScheduleModalOpen, onClose: () => setIsRetrainScheduleModalOpen(false), dataset: dataset, labels: labels })), isTrainOrDeleteModalOpen && (jsx(TrainOrDeleteModal$1, { isOpen: isTrainOrDeleteModalOpen, onClose: () => setIsTrainOrDeleteModalOpen(false), onTrain: handleTrainDataset, onDelete: handleDeleteFromTrainModal, showUserAgentField: isWebCrawlerDocType(dataset.document_type), isLoading: isEditTrainingDocumentLoading, labels: labels }))] }));
244591
244658
  }
244592
244659
  function TrainingStatusSwitch({ is_trained, url, training_status, disabled, handleEditTrainingDocument, onUntrainSuccess, onTrainRequest, }) {
244593
244660
  const t = useT();
@@ -244854,6 +244921,15 @@ const resourceTypes = [
244854
244921
  accept: 'text/plain',
244855
244922
  icon: (jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("rect", { width: "24", height: "24", rx: "4", fill: "url(#paint0_linear_text)" }), jsx("path", { d: "M7 7H17V9H13V17H11V9H7V7Z", fill: "white" }), jsx("defs", { children: jsxs("linearGradient", { id: "paint0_linear_text", x1: "0", y1: "0", x2: "24", y2: "24", gradientUnits: "userSpaceOnUse", children: [jsx("stop", { stopColor: "#4F46E5" }), jsx("stop", { offset: "1", stopColor: "#06B6D4" })] }) })] })),
244856
244923
  },
244924
+ {
244925
+ id: 'markdown',
244926
+ name: 'Markdown',
244927
+ bgColor: 'bg-blue-100',
244928
+ isActive: true,
244929
+ type: 'local',
244930
+ accept: 'text/markdown,.md,.markdown',
244931
+ icon: (jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: [jsx("rect", { width: "24", height: "24", rx: "4", fill: "#1F2937" }), jsx("path", { d: "M4 16V8h2l2 3 2-3h2v8H9.5v-4.6L8 13.7l-1.5-2.3V16H4Zm11.5 0L13 13h1.75V8h1.5v5H18l-2.5 3Z", fill: "white" })] })),
244932
+ },
244857
244933
  {
244858
244934
  id: 'audio',
244859
244935
  name: 'Audio',
@@ -244915,6 +244991,26 @@ const resourceTypes = [
244915
244991
  },
244916
244992
  ];
244917
244993
 
244994
+ /**
244995
+ * Shared chrome for the Add Resources picker and every per-type resource
244996
+ * dialog, mirroring the Datasets tab: a fixed header (title + description bar
244997
+ * with a divider), a body that scrolls on its own (`ResourceDialogBody`), and
244998
+ * an optional fixed footer (`ResourceDialogFooter`).
244999
+ */
245000
+ function ResourceDialogContent({ title, description, className, children, }) {
245001
+ return (jsxs(DialogContent, { className: cn('flex max-h-[80vh] w-full max-w-lg flex-col gap-0 overflow-hidden p-0', className), children: [jsxs(DialogHeader, { className: "flex-shrink-0 space-y-1 border-b border-gray-200 bg-white px-4 pt-4 pr-10 pb-3 text-left", children: [jsx(DialogTitle, { className: "text-muted-foreground text-base", children: title }), jsx(DialogDescription, { className: "text-xs text-gray-600", children: description })] }), children] }));
245002
+ }
245003
+ /** The only scrolling part of a resource dialog; focusable so keyboard users can scroll it. */
245004
+ function ResourceDialogBody({ label, children }) {
245005
+ return (jsx("div", { className: "min-h-0 flex-1 space-y-4 overflow-x-hidden overflow-y-auto p-4", tabIndex: 0, role: "region", "aria-label": label, children: children }));
245006
+ }
245007
+ /** Actions pinned below the scroll region so they stay visible. */
245008
+ function ResourceDialogFooter({ children }) {
245009
+ return (jsx("div", { className: "flex flex-shrink-0 justify-end border-t border-gray-200 bg-white px-4 py-3", children: children }));
245010
+ }
245011
+ /** Submit button styling shared by every resource dialog footer. */
245012
+ const RESOURCE_SUBMIT_BUTTON_CLASS = 'bg-gradient-to-r from-[#2563EB] to-[#93C5FD] text-sm text-white hover:text-white hover:opacity-90';
245013
+
244918
245014
  /**
244919
245015
  * Spend-cap blocks (HTTP 429) carry the machine code in `error`/`error_code`
244920
245016
  * and a friendly, learner-safe sentence in `message`. Detection keys on
@@ -245009,7 +245105,7 @@ function GithubFileUploadModal() {
245009
245105
  const { branches, error, isLoading } = useGithubRepoDetails(debouncedGithubUrl, tenantKey);
245010
245106
  const isLoadingDisabled = !githubUrl || isLoading || isAddTrainingDocumentLoading;
245011
245107
  const isDisabled = isLoadingDisabled || !branch;
245012
- return (jsxs("div", { className: "flex flex-col space-y-4", children: [jsx(Input, { type: "url", placeholder: t('resourceModalGithubFileUploadModal.githubRepoUrlPlaceholder'), value: githubUrl, onChange: (e) => setGithubUrl(e.target.value), autoComplete: "url", disabled: isAddTrainingDocumentLoading }), jsx("p", { className: "text-xs font-light text-red-500", children: error }), jsxs(Select$1, { value: branch, onValueChange: (value) => setBranch(value), disabled: isLoadingDisabled, children: [jsx(SelectTrigger, { className: "w-full rounded-md border p-2", children: jsx(SelectValue, { placeholder: t('resourceModalGithubFileUploadModal.selectBranchPlaceholder') }) }), jsx(SelectContent, { children: branches.map((b) => (jsx(SelectItem, { value: b, children: b }, b))) })] }), jsx("div", { className: "flex justify-end", children: jsx(Button$1, { onClick: handleSubmit, disabled: isDisabled, className: `${githubUrl ? 'bg-gradient-to-r from-blue-600 to-blue-400 text-white' : 'bg-gray-100 text-gray-500'} hover:opacity-90`, children: t('resourceModalGithubFileUploadModal.submit') }) })] }));
245108
+ return (jsxs(Fragment$1, { children: [jsxs(ResourceDialogBody, { label: t('resourceModalGithubFileUploadModal.scrollRegionAriaLabel'), children: [jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: "github-repo-url", children: t('resourceModalGithubFileUploadModal.repoUrlLabel') }), jsx(Input, { id: "github-repo-url", type: "url", placeholder: t('resourceModalGithubFileUploadModal.githubRepoUrlPlaceholder'), value: githubUrl, onChange: (e) => setGithubUrl(e.target.value), autoComplete: "url", disabled: isAddTrainingDocumentLoading, "aria-describedby": error ? 'github-repo-url-error' : undefined, "aria-invalid": !!error }), error ? (jsx("p", { id: "github-repo-url-error", className: "text-destructive -mt-1 text-xs", role: "alert", children: error })) : null] }), jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: "github-branch", children: t('resourceModalGithubFileUploadModal.branchLabel') }), jsxs(Select$1, { value: branch, onValueChange: (value) => setBranch(value), disabled: isLoadingDisabled, children: [jsx(SelectTrigger, { id: "github-branch", className: "w-full", children: jsx(SelectValue, { placeholder: t('resourceModalGithubFileUploadModal.selectBranchPlaceholder') }) }), jsx(SelectContent, { children: branches.map((b) => (jsx(SelectItem, { value: b, children: b }, b))) })] })] })] }), jsx(ResourceDialogFooter, { children: jsx(Button$1, { onClick: handleSubmit, disabled: isDisabled, className: RESOURCE_SUBMIT_BUTTON_CLASS, children: t('resourceModalGithubFileUploadModal.submit') }) })] }));
245013
245109
  }
245014
245110
 
245015
245111
  /**
@@ -245129,18 +245225,18 @@ function LocalFileUploadModal({ resource, maxFileSizeMB = DEFAULT_MAX_FILE_SIZE_
245129
245225
  handleUploadFile();
245130
245226
  }
245131
245227
  };
245132
- return (jsxs("div", { className: "flex flex-col items-center", children: [jsxs("div", { className: `w-full max-w-sm border-2 border-dashed ${isDraggingFile
245133
- ? 'border-blue-400 bg-blue-50/50 backdrop-blur-sm'
245134
- : 'border-gray-300 bg-gray-50'} flex flex-col items-center justify-center rounded-lg p-8 transition-all duration-200 ${!isDraggingFile && 'hover:bg-gray-100'}`, onDragOver: handleDragOver, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDrop: handleDrop, children: [jsx("div", { className: "mb-4 rounded-full bg-blue-100 p-3", children: jsx(Upload, { className: "h-8 w-8 text-blue-600" }) }), jsx("h3", { className: "mb-1 text-lg font-medium text-gray-700", children: t('resourceModalLocalFileUploadModal.dragAndDrop') }), jsx("p", { className: "mb-4 text-sm text-gray-500", children: t('resourceModalLocalFileUploadModal.or') }), jsxs("label", { htmlFor: "file-upload", className: "cursor-pointer", children: [jsx("div", { className: "rounded-md bg-gradient-to-r from-blue-600 to-blue-400 px-4 py-2 font-medium text-white transition-colors hover:opacity-90", children: t('resourceModalLocalFileUploadModal.browseFiles') }), jsx("input", { id: "file-upload", type: "file", accept: resource.accept, className: "hidden", ref: fileInputRef, onChange: handleFileChange })] }), jsx("p", { className: "mt-4 text-xs text-gray-500", children: t('resourceModalLocalFileUploadModal.maximumFileSize', {
245135
- value: maxFileSize.value,
245136
- unit: maxFileSize.unit,
245137
- }) }), file && (jsxs(Fragment$1, { children: [jsx("div", { className: "mt-4 flex w-full items-center rounded-md border border-gray-200 bg-white p-3", children: jsxs("div", { className: "flex w-full items-center", children: [jsx("div", { className: "mr-3 flex-shrink-0 rounded-md bg-blue-100 p-2", children: jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { d: "M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2Z", fill: "#4285F4" }), jsx("path", { d: "M14 2V8H20L14 2Z", fill: "#A1C2FA" })] }) }), jsxs("div", { className: "isolate z-50 min-w-0 flex-1 overflow-hidden", children: [jsx("p", { className: "truncate text-sm font-medium", children: file.name }), jsxs("p", { className: "text-xs text-gray-500", children: [convertFromBytes(file.size).value, " ", convertFromBytes(file.size).unit] })] }), jsx("button", { onClick: () => {
245138
- setFile(null);
245139
- setDescription('');
245140
- if (fileInputRef.current) {
245141
- fileInputRef.current.value = '';
245142
- }
245143
- }, className: "ml-2 flex-shrink-0 rounded-full p-1 transition-colors hover:bg-gray-100", children: jsx(X$1, { className: "h-4 w-4 text-gray-500" }) })] }) }), isImageFile(file) && (jsxs("div", { className: "mt-3 w-full", children: [jsx("label", { htmlFor: "image-description", className: "mb-1 block text-sm font-medium text-gray-700", children: t('resourceModalLocalFileUploadModal.descriptionOptional') }), jsx(Textarea, { id: "image-description", value: description, onChange: (e) => setDescription(e.target.value), placeholder: t('resourceModalLocalFileUploadModal.descriptionPlaceholder'), className: "resize-none", rows: 3 })] }))] }))] }), jsx("div", { className: "mt-4 flex w-full justify-end", children: jsx(Button$1, { onClick: handleSubmit, disabled: !file || isDisabled, className: `${file ? 'bg-gradient-to-r from-blue-600 to-blue-400 text-white' : 'bg-gray-100 text-gray-500'} hover:opacity-90`, children: isAddTrainingDocumentLoading ? (jsxs(Fragment$1, { children: [jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" }), ' ', t('resourceModalLocalFileUploadModal.submitting')] })) : (jsx(Fragment$1, { children: t('resourceModalLocalFileUploadModal.submit') })) }) })] }));
245228
+ return (jsxs(Fragment$1, { children: [jsx(ResourceDialogBody, { label: t('resourceModalLocalFileUploadModal.scrollRegionAriaLabel'), children: jsxs("div", { className: `w-full border-2 border-dashed ${isDraggingFile
245229
+ ? 'border-blue-400 bg-blue-50/50 backdrop-blur-sm'
245230
+ : 'border-gray-300 bg-gray-50'} flex flex-col items-center justify-center rounded-lg p-8 transition-all duration-200 ${!isDraggingFile && 'hover:bg-gray-100'}`, onDragOver: handleDragOver, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDrop: handleDrop, children: [jsx("div", { className: "mb-4 rounded-full bg-blue-100 p-3", children: jsx(Upload, { className: "h-8 w-8 text-blue-600" }) }), jsx("h3", { className: "mb-1 text-lg font-medium text-gray-700", children: t('resourceModalLocalFileUploadModal.dragAndDrop') }), jsx("p", { className: "mb-4 text-sm text-gray-500", children: t('resourceModalLocalFileUploadModal.or') }), jsxs("label", { htmlFor: "file-upload", className: "cursor-pointer", children: [jsx("div", { className: "rounded-md bg-gradient-to-r from-blue-600 to-blue-400 px-4 py-2 font-medium text-white transition-colors hover:opacity-90", children: t('resourceModalLocalFileUploadModal.browseFiles') }), jsx("input", { id: "file-upload", type: "file", accept: resource.accept, className: "hidden", ref: fileInputRef, onChange: handleFileChange })] }), jsx("p", { className: "mt-4 text-xs text-gray-500", children: t('resourceModalLocalFileUploadModal.maximumFileSize', {
245231
+ value: maxFileSize.value,
245232
+ unit: maxFileSize.unit,
245233
+ }) }), file && (jsxs(Fragment$1, { children: [jsx("div", { className: "mt-4 flex w-full items-center rounded-md border border-gray-200 bg-white p-3", children: jsxs("div", { className: "flex w-full items-center", children: [jsx("div", { className: "mr-3 flex-shrink-0 rounded-md bg-blue-100 p-2", children: jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { d: "M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2Z", fill: "#4285F4" }), jsx("path", { d: "M14 2V8H20L14 2Z", fill: "#A1C2FA" })] }) }), jsxs("div", { className: "isolate z-50 min-w-0 flex-1 overflow-hidden", children: [jsx("p", { className: "truncate text-sm font-medium", children: file.name }), jsxs("p", { className: "text-xs text-gray-500", children: [convertFromBytes(file.size).value, " ", convertFromBytes(file.size).unit] })] }), jsx("button", { onClick: () => {
245234
+ setFile(null);
245235
+ setDescription('');
245236
+ if (fileInputRef.current) {
245237
+ fileInputRef.current.value = '';
245238
+ }
245239
+ }, className: "ml-2 flex-shrink-0 rounded-full p-1 transition-colors hover:bg-gray-100", children: jsx(X$1, { className: "h-4 w-4 text-gray-500" }) })] }) }), isImageFile(file) && (jsxs("div", { className: "mt-3 grid w-full gap-2", children: [jsx(Label$2, { htmlFor: "image-description", children: t('resourceModalLocalFileUploadModal.descriptionOptional') }), jsx(Textarea, { id: "image-description", value: description, onChange: (e) => setDescription(e.target.value), placeholder: t('resourceModalLocalFileUploadModal.descriptionPlaceholder'), className: "resize-none", rows: 3 })] }))] }))] }) }), jsx(ResourceDialogFooter, { children: jsx(Button$1, { onClick: handleSubmit, disabled: !file || isDisabled, className: RESOURCE_SUBMIT_BUTTON_CLASS, children: isAddTrainingDocumentLoading ? (jsxs(Fragment$1, { children: [jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" }), ' ', t('resourceModalLocalFileUploadModal.submitting')] })) : (jsx(Fragment$1, { children: t('resourceModalLocalFileUploadModal.submit') })) }) })] }));
245144
245240
  }
245145
245241
 
245146
245242
  function UrlUploadModal({ resource }) {
@@ -245209,9 +245305,7 @@ function UrlUploadModal({ resource }) {
245209
245305
  handleSubmitUrl();
245210
245306
  }
245211
245307
  };
245212
- return (jsxs("div", { className: "flex flex-col space-y-4", children: [jsx(Input, { type: "url", placeholder: t('resourceModalUrlUploadModal.urlPlaceholder'), value: url, onChange: handleUrlChange, autoComplete: "url" }), jsx("div", { className: "flex justify-end", children: jsx(Button$1, { onClick: handleSubmit, disabled: !url || isDisabled, className: cn('cursor-pointer hover:opacity-90', url
245213
- ? 'bg-gradient-to-r from-blue-600 to-blue-400 text-white'
245214
- : 'bg-gray-100 text-gray-500'), children: t('resourceModalUrlUploadModal.submit') }) })] }));
245308
+ return (jsxs(Fragment$1, { children: [jsx(ResourceDialogBody, { label: t('resourceModalUrlUploadModal.scrollRegionAriaLabel'), children: jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: "resource-url", children: t('resourceModalUrlUploadModal.urlLabel') }), jsx(Input, { id: "resource-url", type: "url", placeholder: t('resourceModalUrlUploadModal.urlPlaceholder'), value: url, onChange: handleUrlChange, autoComplete: "url" })] }) }), jsx(ResourceDialogFooter, { children: jsx(Button$1, { onClick: handleSubmit, disabled: !url || isDisabled, className: RESOURCE_SUBMIT_BUTTON_CLASS, children: t('resourceModalUrlUploadModal.submit') }) })] }));
245215
245309
  }
245216
245310
 
245217
245311
  function useWebsiteCrawlerResource(resource) {
@@ -245236,9 +245330,11 @@ function useWebsiteCrawlerResource(resource) {
245236
245330
  crawler_match_patterns: [],
245237
245331
  crawler_pattern_type: 'glob',
245238
245332
  temp_crawler_match_patterns: '',
245333
+ crawler_user_agent: '',
245239
245334
  },
245240
245335
  onSubmit: async ({ value }) => {
245241
245336
  try {
245337
+ const crawlerUserAgent = value.crawler_user_agent.trim();
245242
245338
  await addTrainingDocument({
245243
245339
  org: tenantKey,
245244
245340
  formData: {
@@ -245250,6 +245346,11 @@ function useWebsiteCrawlerResource(resource) {
245250
245346
  crawler_match_patterns: crawlerMatchPatterns,
245251
245347
  //@ts-expect-error crawler_pattern_type may not be on the typed args but is accepted by the API
245252
245348
  crawler_pattern_type: value.crawler_pattern_type,
245349
+ // Per-document User-Agent override; sent only when set so the
245350
+ // backend default applies otherwise.
245351
+ ...(crawlerUserAgent
245352
+ ? { crawler_extra_headers: { 'User-Agent': crawlerUserAgent } }
245353
+ : {}),
245253
245354
  },
245254
245355
  userId: username !== null && username !== void 0 ? username : '',
245255
245356
  }).unwrap();
@@ -245276,30 +245377,30 @@ function useWebsiteCrawlerResource(resource) {
245276
245377
  function WebsiteCrawlModal({ resource }) {
245277
245378
  const t = useT();
245278
245379
  const { form, handleCheckUrlIsValid, crawlerMatchPatterns, setCrawlerMatchPatterns } = useWebsiteCrawlerResource(resource);
245279
- return (jsxs(Card$1, { className: "mx-auto w-full max-w-2xl", role: "dialog", "aria-labelledby": "crawler-title", "aria-describedby": "crawler-description", children: [jsxs(CardHeader, { children: [jsx(CardTitle, { id: "crawler-title", className: "text-md font-semibold text-gray-600", children: t('resourceModalWebsiteCrawlModal.title') }), jsx("p", { id: "crawler-description", className: "text-muted-foreground text-sm", children: t('resourceModalWebsiteCrawlModal.description') })] }), jsx(CardContent, { children: jsx("form", { className: "space-y-4", onSubmit: (e) => {
245280
- e.preventDefault();
245281
- e.stopPropagation();
245282
- form.handleSubmit();
245283
- }, "aria-label": t('resourceModalWebsiteCrawlModal.formAriaLabel'), children: jsxs(Fragment$1, { children: [jsx(form.Field, { name: "url", validators: {
245380
+ return (jsxs("form", { className: "flex min-h-0 flex-1 flex-col", onSubmit: (e) => {
245381
+ e.preventDefault();
245382
+ e.stopPropagation();
245383
+ form.handleSubmit();
245384
+ }, "aria-label": t('resourceModalWebsiteCrawlModal.formAriaLabel'), children: [jsxs(ResourceDialogBody, { label: t('resourceModalWebsiteCrawlModal.scrollRegionAriaLabel'), children: [jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600", children: t('resourceModalWebsiteCrawlModal.infoBox') }), jsxs(Fragment$1, { children: [jsx(form.Field, { name: "url", validators: {
245284
245385
  onChange: ({ value }) => (!value && t('resourceModalWebsiteCrawlModal.urlRequired')) ||
245285
245386
  (!handleCheckUrlIsValid(value) && t('resourceModalWebsiteCrawlModal.invalidUrl')),
245286
245387
  }, children: (field) => {
245287
245388
  var _a, _b, _c;
245288
- return (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.urlLabel') }), jsx(Input, { id: field.name, type: "url", value: field.state.value, onChange: (e) => field.handleChange(e.target.value), placeholder: t('resourceModalWebsiteCrawlModal.urlPlaceholder'), "aria-describedby": ((_a = field.state.meta.errors) === null || _a === void 0 ? void 0 : _a.length) ? `${field.name}-error` : undefined, "aria-invalid": !!((_b = field.state.meta.errors) === null || _b === void 0 ? void 0 : _b.length), "aria-required": "true" }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: `${field.name}-error`, className: "text-destructive mb-2 text-sm", role: "alert", children: field.state.meta.errors })) : null] }));
245389
+ return (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.urlLabel') }), jsx(Input, { id: field.name, type: "url", value: field.state.value, onChange: (e) => field.handleChange(e.target.value), placeholder: t('resourceModalWebsiteCrawlModal.urlPlaceholder'), "aria-describedby": ((_a = field.state.meta.errors) === null || _a === void 0 ? void 0 : _a.length) ? `${field.name}-error` : undefined, "aria-invalid": !!((_b = field.state.meta.errors) === null || _b === void 0 ? void 0 : _b.length), "aria-required": "true" }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: `${field.name}-error`, className: "text-destructive -mt-1 text-xs", role: "alert", children: field.state.meta.errors })) : null] }));
245289
245390
  } }), jsxs("div", { className: "grid grid-cols-2 gap-4", children: [jsx(form.Field, { name: "crawler_max_depth", validators: {
245290
245391
  onChange: ({ value }) => (!value && t('resourceModalWebsiteCrawlModal.fieldRequired')) ||
245291
245392
  (value < 1 && t('resourceModalWebsiteCrawlModal.mustBeGreaterThanZero')) ||
245292
245393
  (value > 10000 && t('resourceModalWebsiteCrawlModal.mustBeLessThan10000')),
245293
245394
  }, children: (field) => {
245294
245395
  var _a, _b, _c;
245295
- return (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.maxCrawlDepthLabel') }), jsx(Input, { id: field.name, type: "number", min: "1", max: "10000", value: field.state.value, onChange: (e) => field.handleChange(Number.parseInt(e.target.value)), "aria-describedby": ((_a = field.state.meta.errors) === null || _a === void 0 ? void 0 : _a.length) ? `${field.name}-error` : undefined, "aria-invalid": !!((_b = field.state.meta.errors) === null || _b === void 0 ? void 0 : _b.length), "aria-required": "true" }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: `${field.name}-error`, className: "text-destructive mb-2 text-sm", role: "alert", children: field.state.meta.errors })) : null] }));
245396
+ return (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.maxCrawlDepthLabel') }), jsx(Input, { id: field.name, type: "number", min: "1", max: "10000", value: field.state.value, onChange: (e) => field.handleChange(Number.parseInt(e.target.value)), "aria-describedby": ((_a = field.state.meta.errors) === null || _a === void 0 ? void 0 : _a.length) ? `${field.name}-error` : undefined, "aria-invalid": !!((_b = field.state.meta.errors) === null || _b === void 0 ? void 0 : _b.length), "aria-required": "true" }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: `${field.name}-error`, className: "text-destructive -mt-1 text-xs", role: "alert", children: field.state.meta.errors })) : null] }));
245296
245397
  } }), jsx(form.Field, { name: "crawler_max_pages_limit", validators: {
245297
245398
  onChange: ({ value }) => (!value && t('resourceModalWebsiteCrawlModal.fieldRequired')) ||
245298
245399
  (value < 1 && t('resourceModalWebsiteCrawlModal.mustBeGreaterThanZero')),
245299
245400
  }, children: (field) => {
245300
245401
  var _a, _b, _c;
245301
- return (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.maxPagesLimitLabel') }), jsx(Input, { id: field.name, type: "number", min: "1", value: field.state.value, onChange: (e) => field.handleChange(Number.parseInt(e.target.value)), "aria-describedby": ((_a = field.state.meta.errors) === null || _a === void 0 ? void 0 : _a.length) ? `${field.name}-error` : undefined, "aria-invalid": !!((_b = field.state.meta.errors) === null || _b === void 0 ? void 0 : _b.length), "aria-required": "true" }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: `${field.name}-error`, className: "text-destructive mb-2 text-sm", role: "alert", children: field.state.meta.errors })) : null] }));
245302
- } })] }), jsx(form.Field, { name: "crawler_pattern_type", children: (field) => (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: "pattern-type", children: t('resourceModalWebsiteCrawlModal.patternTypeLabel') }), jsxs(Select$1, { value: field.state.value, onValueChange: (value) => field.handleChange(value), children: [jsx(SelectTrigger, { id: "pattern-type", "aria-label": t('resourceModalWebsiteCrawlModal.selectPatternTypeAriaLabel'), children: jsx(SelectValue, {}) }), jsxs(SelectContent, { children: [jsx(SelectItem, { value: "glob", children: t('resourceModalWebsiteCrawlModal.globPattern') }), jsx(SelectItem, { value: "regex", children: t('resourceModalWebsiteCrawlModal.regularExpression') })] })] })] })) }), jsx(form.Subscribe, { selector: (state) => [
245402
+ return (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.maxPagesLimitLabel') }), jsx(Input, { id: field.name, type: "number", min: "1", value: field.state.value, onChange: (e) => field.handleChange(Number.parseInt(e.target.value)), "aria-describedby": ((_a = field.state.meta.errors) === null || _a === void 0 ? void 0 : _a.length) ? `${field.name}-error` : undefined, "aria-invalid": !!((_b = field.state.meta.errors) === null || _b === void 0 ? void 0 : _b.length), "aria-required": "true" }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: `${field.name}-error`, className: "text-destructive -mt-1 text-xs", role: "alert", children: field.state.meta.errors })) : null] }));
245403
+ } })] }), jsx(form.Field, { name: "crawler_pattern_type", children: (field) => (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: "pattern-type", children: t('resourceModalWebsiteCrawlModal.patternTypeLabel') }), jsxs(Select$1, { value: field.state.value, onValueChange: (value) => field.handleChange(value), children: [jsx(SelectTrigger, { id: "pattern-type", "aria-label": t('resourceModalWebsiteCrawlModal.selectPatternTypeAriaLabel'), children: jsx(SelectValue, {}) }), jsxs(SelectContent, { children: [jsx(SelectItem, { value: "glob", children: t('resourceModalWebsiteCrawlModal.globPattern') }), jsx(SelectItem, { value: "regex", children: t('resourceModalWebsiteCrawlModal.regularExpression') })] })] })] })) }), jsx(form.Field, { name: "crawler_user_agent", children: (field) => (jsxs("div", { className: "grid gap-2", children: [jsx(Label$2, { htmlFor: field.name, children: t('resourceModalWebsiteCrawlModal.userAgentLabel') }), jsx(Input, { id: field.name, type: "text", value: field.state.value, onChange: (e) => field.handleChange(e.target.value), placeholder: t('resourceModalWebsiteCrawlModal.userAgentPlaceholder'), "aria-describedby": "user-agent-help" }), jsx("p", { id: "user-agent-help", className: "text-muted-foreground -mt-1 text-xs", children: t('resourceModalWebsiteCrawlModal.userAgentHelpText') })] })) }), jsx(form.Subscribe, { selector: (state) => [
245303
245404
  state.values.temp_crawler_match_patterns,
245304
245405
  state.values.crawler_pattern_type,
245305
245406
  ], children: ([tempCrawlerMatchPatterns, crawlerPatternType]) => (jsx(form.Field, { name: "temp_crawler_match_patterns", validators: {
@@ -245330,14 +245431,24 @@ function WebsiteCrawlModal({ resource }) {
245330
245431
  ]);
245331
245432
  field.handleChange('');
245332
245433
  }
245333
- }, disabled: !String(tempCrawlerMatchPatterns).trim(), size: "sm", "aria-label": t('resourceModalWebsiteCrawlModal.addPatternAriaLabel'), children: jsx(Plus, { className: "h-4 w-4" }) })] }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: "pattern-error", className: "text-destructive mb-2 text-sm", role: "alert", children: field.state.meta.errors })) : null, jsx("p", { id: "pattern-help", className: "text-muted-foreground text-sm", children: t('resourceModalWebsiteCrawlModal.patternHelpText') }), jsx("div", { className: "bg-muted/50 flex min-h-[2rem] flex-wrap gap-2 rounded-md border p-2", role: "list", "aria-label": t('resourceModalWebsiteCrawlModal.addedPatternsAriaLabel'), children: crawlerMatchPatterns.length === 0 ? (jsx("span", { className: "text-muted-foreground text-sm", children: t('resourceModalWebsiteCrawlModal.noPatternsAdded') })) : (crawlerMatchPatterns.map((pattern, index) => (jsxs(Badge, { variant: "secondary", className: "flex items-center gap-1", children: [jsx("span", { className: "text-xs", children: pattern }), jsx("button", { type: "button", onClick: () => setCrawlerMatchPatterns(crawlerMatchPatterns.filter((p) => p !== pattern)), className: "hover:bg-destructive/20 ml-1 rounded-full p-0.5", "aria-label": t('resourceModalWebsiteCrawlModal.removePatternAriaLabel', { pattern }), children: jsx(X$1, { className: "h-3 w-3" }) })] }, index)))) })] })] }));
245334
- } })) }), jsx(form.Subscribe, { selector: (state) => [state.isSubmitting], children: ([isSubmitting]) => (jsxs("div", { className: "flex gap-3 pt-4", children: [jsx(Button$1, { type: "submit", className: "w-full bg-gradient-to-r from-[#2563EB] to-[#93C5FD] text-sm text-white hover:text-white hover:opacity-90", disabled: isSubmitting, "aria-describedby": isSubmitting ? 'submitting-status' : undefined, children: isSubmitting
245335
- ? t('resourceModalWebsiteCrawlModal.submitting')
245336
- : t('resourceModalWebsiteCrawlModal.submit') }), isSubmitting && (jsx("div", { id: "submitting-status", className: "sr-only", role: "status", "aria-live": "polite", children: t('resourceModalWebsiteCrawlModal.formBeingSubmitted') }))] })) })] }) }) })] }));
245337
- }
245338
-
245339
- function ResourceModal({ resource, isOpen, onClose }) {
245340
- return (jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: jsxs(DialogContent, { className: "w-full max-w-md", children: [jsx(DialogHeader, { children: jsx(DialogTitle, { className: "text-muted-foreground text-base", children: resource.name }) }), resource.type === 'github' && jsx(GithubFileUploadModal, {}), resource.type === 'local' && jsx(LocalFileUploadModal, { resource: resource }), resource.type === 'webcrawler' && jsx(WebsiteCrawlModal, { resource: resource }), resource.type === 'url' && jsx(UrlUploadModal, { resource: resource })] }) }));
245434
+ }, disabled: !String(tempCrawlerMatchPatterns).trim(), size: "sm", "aria-label": t('resourceModalWebsiteCrawlModal.addPatternAriaLabel'), children: jsx(Plus, { className: "h-4 w-4" }) })] }), ((_c = field.state.meta.errors) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("p", { id: "pattern-error", className: "text-destructive -mt-1 text-xs", role: "alert", children: field.state.meta.errors })) : null, jsx("p", { id: "pattern-help", className: "text-muted-foreground -mt-1 text-xs", children: t('resourceModalWebsiteCrawlModal.patternHelpText') }), jsx("div", { className: "bg-muted/50 flex min-h-[2rem] flex-wrap gap-2 rounded-md border p-2", role: "list", "aria-label": t('resourceModalWebsiteCrawlModal.addedPatternsAriaLabel'), children: crawlerMatchPatterns.length === 0 ? (jsx("span", { className: "text-muted-foreground text-xs", children: t('resourceModalWebsiteCrawlModal.noPatternsAdded') })) : (crawlerMatchPatterns.map((pattern, index) => (jsxs(Badge, { variant: "secondary", className: "flex items-center gap-1", children: [jsx("span", { className: "text-xs", children: pattern }), jsx("button", { type: "button", onClick: () => setCrawlerMatchPatterns(crawlerMatchPatterns.filter((p) => p !== pattern)), className: "hover:bg-destructive/20 ml-1 rounded-full p-0.5", "aria-label": t('resourceModalWebsiteCrawlModal.removePatternAriaLabel', { pattern }), children: jsx(X$1, { className: "h-3 w-3" }) })] }, index)))) })] })] }));
245435
+ } })) })] })] }), jsx(form.Subscribe, { selector: (state) => [state.isSubmitting], children: ([isSubmitting]) => (jsxs(ResourceDialogFooter, { children: [jsx(Button$1, { type: "submit", className: RESOURCE_SUBMIT_BUTTON_CLASS, disabled: isSubmitting, "aria-describedby": isSubmitting ? 'submitting-status' : undefined, children: isSubmitting
245436
+ ? t('resourceModalWebsiteCrawlModal.submitting')
245437
+ : t('resourceModalWebsiteCrawlModal.submit') }), isSubmitting && (jsx("div", { id: "submitting-status", className: "sr-only", role: "status", "aria-live": "polite", children: t('resourceModalWebsiteCrawlModal.formBeingSubmitted') }))] })) })] }));
245438
+ }
245439
+
245440
+ // `link` types open a cloud picker instead of this dialog; it maps to the
245441
+ // generic Add Resources copy only to keep the record total.
245442
+ const DESCRIPTION_KEYS = {
245443
+ github: 'resourceModalGithubFileUploadModal.description',
245444
+ local: 'resourceModalLocalFileUploadModal.description',
245445
+ url: 'resourceModalUrlUploadModal.description',
245446
+ webcrawler: 'resourceModalWebsiteCrawlModal.description',
245447
+ link: 'datasetsTabAddResourceModal.description',
245448
+ };
245449
+ function ResourceModal({ resource, isOpen, onClose, maxFileSizeMB }) {
245450
+ const t = useT();
245451
+ return (jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: jsxs(ResourceDialogContent, { title: resource.name, description: t(DESCRIPTION_KEYS[resource.type]), children: [resource.type === 'github' && jsx(GithubFileUploadModal, {}), resource.type === 'local' && (jsx(LocalFileUploadModal, { resource: resource, maxFileSizeMB: maxFileSizeMB })), resource.type === 'webcrawler' && jsx(WebsiteCrawlModal, { resource: resource }), resource.type === 'url' && jsx(UrlUploadModal, { resource: resource })] }) }));
245341
245452
  }
245342
245453
 
245343
245454
  var bundle = {exports: {}};
@@ -245350,6 +245461,8 @@ var bundle = {exports: {}};
245350
245461
  var bundleExports = bundle.exports;
245351
245462
  var GoogleDrivePicker = /*@__PURE__*/getDefaultExportFromCjs(bundleExports);
245352
245463
 
245464
+ /** Least-privilege scope: only files the user picks/creates via the picker. */
245465
+ const GOOGLE_DRIVE_SCOPES = ['https://www.googleapis.com/auth/drive.file'];
245353
245466
  const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
245354
245467
  const [authToken, setAuthToken] = React__default.useState(null);
245355
245468
  const [driveFiles, setDriveFiles] = React__default.useState([]);
@@ -245424,10 +245537,7 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
245424
245537
  refresh_token: 'test-refresh token',
245425
245538
  client_id: credentials.client_id,
245426
245539
  token: authToken === null || authToken === void 0 ? void 0 : authToken.access_token,
245427
- scopes: [
245428
- 'https://www.googleapis.com/auth/drive.metadata.readonly',
245429
- 'https://www.googleapis.com/auth/drive.readonly',
245430
- ],
245540
+ scopes: GOOGLE_DRIVE_SCOPES,
245431
245541
  token_type: authToken === null || authToken === void 0 ? void 0 : authToken.token_type,
245432
245542
  expiry_date: new Date(Date.now() + ((authToken === null || authToken === void 0 ? void 0 : authToken.expires_in) || 0) * 1000).toISOString(),
245433
245543
  },
@@ -245521,10 +245631,7 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
245521
245631
  openPicker({
245522
245632
  clientId: credentials.client_id,
245523
245633
  developerKey: credentials.developer_key,
245524
- customScopes: [
245525
- 'https://www.googleapis.com/auth/drive.metadata.readonly',
245526
- 'https://www.googleapis.com/auth/drive.readonly',
245527
- ],
245634
+ customScopes: GOOGLE_DRIVE_SCOPES,
245528
245635
  // @ts-expect-error - token accepts null to force fresh auth per google-drive-picker API
245529
245636
  token: null, // Always start with null token to force fresh auth
245530
245637
  showUploadView: true,
@@ -245612,6 +245719,8 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
245612
245719
  forceClosePickerModal,
245613
245720
  pickerError,
245614
245721
  resetPickerState,
245722
+ credentialsLoaded: credentialLoaded,
245723
+ isConfigured: Boolean(credentials.client_id),
245615
245724
  };
245616
245725
  };
245617
245726
 
@@ -245682,6 +245791,7 @@ function ieOnEnd (script, cb) {
245682
245791
 
245683
245792
  var loadScript = /*@__PURE__*/getDefaultExportFromCjs(loadScript$1);
245684
245793
 
245794
+ /** Default file types offered by the Dropbox chooser. Hosts override via `extensions`. */
245685
245795
  const DROPBOX_EXTENSIONS = [
245686
245796
  '.pdf',
245687
245797
  '.doc',
@@ -245693,6 +245803,12 @@ const DROPBOX_EXTENSIONS = [
245693
245803
  '.xlsx',
245694
245804
  '.ppt',
245695
245805
  '.pptx',
245806
+ '.png',
245807
+ '.jpeg',
245808
+ '.jpg',
245809
+ '.mp3',
245810
+ '.wav',
245811
+ '.m4a',
245696
245812
  ];
245697
245813
  const DROPBOX_SDK_URL = 'https://www.dropbox.com/static/api/2/dropins.js';
245698
245814
  const SCRIPT_ID = 'dropboxjs';
@@ -245701,6 +245817,7 @@ const useDropboxPicker = ({ tenantKey, mentorId, cancel = () => { }, linkType =
245701
245817
  const [dropboxReady, setDropboxReady] = useState(false);
245702
245818
  const [openChooser, setOpenChooser] = useState(false);
245703
245819
  const [appKey, setAppKey] = useState(null);
245820
+ const [credentialsLoaded, setCredentialsLoaded] = useState(false);
245704
245821
  // Use RTK Query hooks
245705
245822
  const [getCredentials] = useLazyGetCredentialsQuery();
245706
245823
  const [addTrainingDocument] = useAddTrainingDocumentMutation();
@@ -245723,6 +245840,7 @@ const useDropboxPicker = ({ tenantKey, mentorId, cancel = () => { }, linkType =
245723
245840
  catch (error) {
245724
245841
  console.error(JSON.stringify({ tenant: tenantKey, error }));
245725
245842
  }
245843
+ setCredentialsLoaded(true);
245726
245844
  }
245727
245845
  };
245728
245846
  handleFetchAppKey();
@@ -245820,6 +245938,8 @@ const useDropboxPicker = ({ tenantKey, mentorId, cancel = () => { }, linkType =
245820
245938
  openChooser: onChoose,
245821
245939
  dropboxReady,
245822
245940
  appKey,
245941
+ credentialsLoaded,
245942
+ isConfigured: Boolean(appKey),
245823
245943
  };
245824
245944
  };
245825
245945
 
@@ -245829,6 +245949,7 @@ const useOneDrivePicker = ({ tenantKey, mentorId }) => {
245829
245949
  const [onedriveAppId, setOnedriveAppId] = useState(null);
245830
245950
  const [fullDomain, setFullDomain] = useState(null);
245831
245951
  const [isSDKLoaded, setIsSDKLoaded] = useState(false);
245952
+ const [credentialsLoaded, setCredentialsLoaded] = useState(false);
245832
245953
  // Use RTK Query hooks
245833
245954
  const [getCredentials] = useLazyGetCredentialsQuery();
245834
245955
  const [addTrainingDocument] = useAddTrainingDocumentMutation();
@@ -245943,6 +246064,7 @@ const useOneDrivePicker = ({ tenantKey, mentorId }) => {
245943
246064
  catch (error) {
245944
246065
  console.error(JSON.stringify({ tenant: tenantKey, error }));
245945
246066
  }
246067
+ setCredentialsLoaded(true);
245946
246068
  }
245947
246069
  };
245948
246070
  handleFetchAppId();
@@ -246035,46 +246157,81 @@ const useOneDrivePicker = ({ tenantKey, mentorId }) => {
246035
246157
  pickOneDriveFile,
246036
246158
  onedriveAppId,
246037
246159
  isSDKLoaded,
246160
+ credentialsLoaded,
246161
+ isConfigured: Boolean(onedriveAppId),
246038
246162
  };
246039
246163
  };
246040
246164
 
246041
- function AddResourceModal({ isOpen, onClose, disabledDatasets = [], }) {
246165
+ function AddResourceModal({ isOpen, onClose, disabledDatasets = [], maxFileSizeMB, dropboxExtensions, }) {
246042
246166
  const t = useT();
246043
246167
  const { tenantKey, mentorId } = useAgentSettings();
246044
246168
  const [selectedResource, setSelectedResource] = React__default.useState(null);
246045
- const { openChooser } = useDropboxPicker({
246169
+ const dropbox = useDropboxPicker({
246046
246170
  autoShow: false,
246047
246171
  tenantKey,
246048
246172
  mentorId,
246049
- });
246050
- const { handlePickerOpen, loadGoogleApiScript, isPickerLoaded, forceClosePickerModal, pickerError, } = useGoogleDrivePicker({ tenantKey, mentorId });
246051
- const { pickOneDriveFile } = useOneDrivePicker({ tenantKey, mentorId });
246052
- return (jsxs(Fragment$1, { children: [jsx(Script, { src: "https://apis.google.com/js/api.js", onLoad: loadGoogleApiScript, strategy: "lazyOnload" }), jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [jsx(DialogHeader, { className: "flex flex-row items-center justify-between", children: jsx(DialogTitle, { children: t('datasetsTabAddResourceModal.title') }) }), jsx("div", { className: "pt-4", children: jsxs("div", { children: [jsx("p", { className: "mb-6 text-gray-600", children: t('datasetsTabAddResourceModal.description') }), pickerError && (jsx("div", { className: "mb-4 rounded-lg border border-red-200 bg-red-50 p-4", children: jsxs("div", { className: "flex items-center justify-between", children: [jsxs("div", { children: [jsx("h4", { className: "text-sm font-medium text-red-800", children: t('datasetsTabAddResourceModal.googleDrivePickerError') }), jsx("p", { className: "mt-1 text-sm text-red-600", children: pickerError })] }), jsx("button", { onClick: forceClosePickerModal, className: "ml-4 rounded bg-red-100 px-3 py-1 text-sm font-medium text-red-800 hover:bg-red-200", children: t('datasetsTabAddResourceModal.forceClosePicker') })] }) })), jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: resourceTypes.map((resource) => (jsxs("button", { className: cn('flex items-center rounded-lg border p-4 transition-colors duration-200 hover:bg-gray-50', resource.isActive && !disabledDatasets.includes(resource.id.toLowerCase())
246053
- ? 'cursor-pointer'
246054
- : 'cursor-not-allowed opacity-50'), onClick: () => {
246055
- if (resource.type !== 'link') {
246056
- setSelectedResource(resource);
246057
- return;
246058
- }
246059
- if (resource.name === 'Google Drive') {
246060
- if (isPickerLoaded) {
246061
- handlePickerOpen();
246062
- }
246063
- else {
246064
- // Show loading state or toast
246065
- console.log('Google Picker is still loading...');
246066
- }
246067
- return;
246068
- }
246069
- if (resource.name === 'Dropbox') {
246070
- openChooser();
246071
- return;
246173
+ extensions: dropboxExtensions,
246174
+ });
246175
+ const { handlePickerOpen, loadGoogleApiScript, isPickerLoaded, forceClosePickerModal, pickerError, credentialsLoaded: googleCredentialsLoaded, isConfigured: googleIsConfigured, } = useGoogleDrivePicker({ tenantKey, mentorId });
246176
+ const oneDrive = useOneDrivePicker({ tenantKey, mentorId });
246177
+ // A cloud provider only works once the tenant has OAuth credentials for it
246178
+ // (GET .../integration-credential/?name=<provider>). Without them the SDK is
246179
+ // handed an empty client id and the click does nothing at all — no popup, no
246180
+ // error — which reads as a broken button. Disable and say why instead.
246181
+ // `loaded` gates on the lookup having finished so the buttons are not
246182
+ // disabled during the in-flight fetch.
246183
+ const cloudProviders = {
246184
+ 'google-drive': {
246185
+ loaded: googleCredentialsLoaded,
246186
+ configured: googleIsConfigured,
246187
+ },
246188
+ onedrive: {
246189
+ loaded: oneDrive.credentialsLoaded,
246190
+ configured: oneDrive.isConfigured,
246191
+ },
246192
+ dropbox: {
246193
+ loaded: dropbox.credentialsLoaded,
246194
+ configured: dropbox.isConfigured,
246195
+ },
246196
+ };
246197
+ return (jsxs(Fragment$1, { children: [jsx(Script, { src: "https://apis.google.com/js/api.js", onLoad: loadGoogleApiScript, strategy: "lazyOnload" }), jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: jsx(ResourceDialogContent, { title: t('datasetsTabAddResourceModal.title'), description: t('datasetsTabAddResourceModal.description'), className: "sm:max-w-[800px]", children: jsxs(ResourceDialogBody, { label: t('datasetsTabAddResourceModal.scrollRegionAriaLabel'), children: [pickerError && (jsx("div", { className: "rounded-lg border border-red-200 bg-red-50 p-4", children: jsxs("div", { className: "flex items-center justify-between", children: [jsxs("div", { children: [jsx("h4", { className: "text-sm font-medium text-red-800", children: t('datasetsTabAddResourceModal.googleDrivePickerError') }), jsx("p", { className: "mt-1 text-sm text-red-600", children: pickerError })] }), jsx("button", { onClick: forceClosePickerModal, className: "ml-4 rounded bg-red-100 px-3 py-1 text-sm font-medium text-red-800 hover:bg-red-200", children: t('datasetsTabAddResourceModal.forceClosePicker') })] }) })), jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: resourceTypes.map((resource) => {
246198
+ const cloudProvider = cloudProviders[resource.id];
246199
+ const notConfigured = cloudProvider
246200
+ ? cloudProvider.loaded && !cloudProvider.configured
246201
+ : false;
246202
+ const isDisabled = !resource.isActive ||
246203
+ disabledDatasets.includes(resource.id.toLowerCase()) ||
246204
+ notConfigured;
246205
+ return (jsxs("button", { title: notConfigured ? t('datasetsTabAddResourceModal.notConfigured') : undefined, className: cn('flex items-center rounded-lg border p-4 transition-colors duration-200 hover:bg-gray-50', !isDisabled ? 'cursor-pointer' : 'cursor-not-allowed opacity-50'), onClick: () => {
246206
+ if (resource.type !== 'link') {
246207
+ setSelectedResource(resource);
246208
+ return;
246209
+ }
246210
+ if (resource.name === 'Google Drive') {
246211
+ if (isPickerLoaded) {
246212
+ handlePickerOpen();
246072
246213
  }
246073
- if (resource.name === 'Microsoft OneDrive') {
246074
- pickOneDriveFile();
246075
- return;
246214
+ else {
246215
+ // Show loading state or toast
246216
+ console.log('Google Picker is still loading...');
246076
246217
  }
246077
- }, disabled: !resource.isActive || disabledDatasets.includes(resource.id.toLowerCase()), children: [jsx("div", { className: "mr-3 flex h-10 w-10 items-center justify-center rounded-md bg-blue-100", children: resource.icon }), jsx("span", { className: "text-gray-700", children: resource.name })] }, resource.id))) })] }) })] }) }), selectedResource && (jsx(ResourceModal, { resource: selectedResource, isOpen: !!selectedResource, onClose: () => setSelectedResource(null) }))] }));
246218
+ return;
246219
+ }
246220
+ if (resource.name === 'Dropbox') {
246221
+ dropbox.openChooser();
246222
+ return;
246223
+ }
246224
+ if (resource.name === 'Microsoft OneDrive') {
246225
+ oneDrive.pickOneDriveFile();
246226
+ return;
246227
+ }
246228
+ }, disabled: isDisabled, children: [jsx("div", { className: "mr-3 flex h-10 w-10 items-center justify-center rounded-md bg-blue-100", children: resource.icon }), jsxs("span", { className: "flex flex-col items-start text-left", children: [jsx("span", { className: "text-gray-700", children: resource.name }), notConfigured && (
246229
+ // aria-hidden: the same text is already the button's
246230
+ // `title`, so exposing it here too would append it to
246231
+ // the accessible name ("Dropbox Not configured for
246232
+ // this tenant") and break name-based lookups.
246233
+ jsx("span", { "aria-hidden": "true", className: "text-xs text-gray-500", children: t('datasetsTabAddResourceModal.notConfigured') }))] })] }, resource.id));
246234
+ }) })] }) }) }), selectedResource && (jsx(ResourceModal, { resource: selectedResource, isOpen: !!selectedResource, onClose: () => setSelectedResource(null), maxFileSizeMB: maxFileSizeMB }))] }));
246078
246235
  }
246079
246236
 
246080
246237
  // DatasetItemList requires a full labels object; without it the empty-state
@@ -246086,7 +246243,7 @@ const PROJECT_FILES_DATASET_LABELS = resolveDatasetsTabLabels({
246086
246243
  function ProjectFilesModal(props) {
246087
246244
  return (jsx(AgentSettingsProvider, { tenantKey: props.tenantKey, mentorId: props.mentorId, username: props.username, enableRBAC: false, children: jsx(ProjectFilesModalInner, { ...props }) }));
246088
246245
  }
246089
- function ProjectFilesModalInner({ isOpen, onClose }) {
246246
+ function ProjectFilesModalInner({ isOpen, onClose, disabledResourceTypes, maxUploadSizeMb, dropboxExtensions, }) {
246090
246247
  var _a;
246091
246248
  const t = useT();
246092
246249
  const [showAddResourceModal, setShowAddResourceModal] = React__default.useState(false);
@@ -246101,7 +246258,7 @@ function ProjectFilesModalInner({ isOpen, onClose }) {
246101
246258
  // @ts-expect-error - Type mismatch between RetrieverDocumentEmbedding[] and Dataset[], id property type difference
246102
246259
  , {
246103
246260
  // @ts-expect-error - Type mismatch between RetrieverDocumentEmbedding[] and Dataset[], id property type difference
246104
- datasets: (_a = datasets === null || datasets === void 0 ? void 0 : datasets.results) !== null && _a !== void 0 ? _a : [], labels: PROJECT_FILES_DATASET_LABELS })] })) }) }) }), jsx(IblPagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: handlePageChange, disabled: isDatasetsFetching || isDatasetsLoading }), jsx(AddResourceModal, { isOpen: showAddResourceModal, onClose: () => closeAddResourceModal(), keepParentOpen: true }), isModalOpen && FreeTrialDialog && (jsx(FreeTrialDialog, { isOpen: isModalOpen, onClose: closeModal }))] }) })] }) }) }));
246261
+ datasets: (_a = datasets === null || datasets === void 0 ? void 0 : datasets.results) !== null && _a !== void 0 ? _a : [], labels: PROJECT_FILES_DATASET_LABELS })] })) }) }) }), jsx(IblPagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: handlePageChange, disabled: isDatasetsFetching || isDatasetsLoading }), jsx(AddResourceModal, { isOpen: showAddResourceModal, onClose: () => closeAddResourceModal(), keepParentOpen: true, disabledDatasets: disabledResourceTypes, maxFileSizeMB: maxUploadSizeMb, dropboxExtensions: dropboxExtensions }), isModalOpen && FreeTrialDialog && (jsx(FreeTrialDialog, { isOpen: isModalOpen, onClose: closeModal }))] }) })] }) }) }));
246105
246262
  }
246106
246263
 
246107
246264
  var projectFilesModal = /*#__PURE__*/Object.freeze({