| 
					
				 | 
			
			
				@@ -4,21 +4,25 @@ import React, { useEffect, useState } from 'react' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { ChevronRightIcon } from '@heroicons/react/20/solid' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import Link from 'next/link' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { Trans, useTranslation } from 'react-i18next' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { useContextSelector } from 'use-context-selector' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import s from './style.module.css' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import Modal from '@/app/components/base/modal' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import Button from '@/app/components/base/button' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import AppIcon from '@/app/components/base/app-icon' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import Switch from '@/app/components/base/switch' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { SimpleSelect } from '@/app/components/base/select' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import type { AppDetailResponse } from '@/models/app' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import type { AppIconType, Language } from '@/types/app' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import type { AppIconType, AppSSO, Language } from '@/types/app' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { useToastContext } from '@/app/components/base/toast' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { languages } from '@/i18n/language' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import TooltipPlus from '@/app/components/base/tooltip-plus' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import AppContext from '@/context/app-context' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import type { AppIconSelection } from '@/app/components/base/app-icon-picker' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import AppIconPicker from '@/app/components/base/app-icon-picker' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 export type ISettingsModalProps = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   isChat: boolean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  appInfo: AppDetailResponse 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  appInfo: AppDetailResponse & Partial<AppSSO> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   isShow: boolean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   defaultValue?: string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   onClose: () => void 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -39,6 +43,7 @@ export type ConfigParams = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   icon: string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   icon_background?: string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   show_workflow_steps: boolean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  enable_sso?: boolean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const prefixSettings = 'appOverview.overview.appInfo.settings' 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -50,6 +55,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   onClose, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   onSave, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const { notify } = useToastContext() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const [isShowMore, setIsShowMore] = useState(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -76,6 +82,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     privacyPolicy: privacy_policy, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     customDisclaimer: custom_disclaimer, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     show_workflow_steps, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    enable_sso: appInfo.enable_sso, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const [language, setLanguage] = useState(default_language) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const [saveLoading, setSaveLoading] = useState(false) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -98,6 +105,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       privacyPolicy: privacy_policy, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       customDisclaimer: custom_disclaimer, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       show_workflow_steps, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      enable_sso: appInfo.enable_sso, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     setLanguage(default_language) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     setAppIcon(icon_type === 'image' 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -149,6 +157,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       show_workflow_steps: inputInfo.show_workflow_steps, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      enable_sso: inputInfo.enable_sso, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     await onSave?.(params) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     setSaveLoading(false) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -219,9 +228,19 @@ const SettingsModal: FC<ISettingsModalProps> = ({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           <input className={`w-full mt-2 rounded-lg h-10 box-border px-3 ${s.projectName} bg-gray-100`} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             value={inputInfo.chatColorTheme ?? ''} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             onChange={onChange('chatColorTheme')} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            placeholder= 'E.g #A020F0' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            placeholder='E.g #A020F0' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {systemFeatures.enable_web_sso_switch_component && <div className='w-full mt-8'> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          <p className='system-xs-medium text-gray-500'>{t(`${prefixSettings}.sso.label`)}</p> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          <div className='flex justify-between items-center'> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <div className='font-medium system-sm-semibold flex-grow text-gray-900'>{t(`${prefixSettings}.sso.title`)}</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <TooltipPlus disabled={systemFeatures.sso_enforced_for_web} popupContent={<div className='w-[180px]'>{t(`${prefixSettings}.sso.tooltip`)}</div>}> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              <Switch disabled={!systemFeatures.sso_enforced_for_web} defaultValue={systemFeatures.sso_enforced_for_web && inputInfo.enable_sso} onChange={v => setInputInfo({ ...inputInfo, enable_sso: v })}></Switch> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </TooltipPlus> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          </div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          <p className='body-xs-regular text-gray-500'>{t(`${prefixSettings}.sso.description`)}</p> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </div>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         {!isShowMore && <div className='w-full cursor-pointer mt-8' onClick={() => setIsShowMore(true)}> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           <div className='flex justify-between'> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             <div className={`font-medium ${s.settingTitle} flex-grow text-gray-900`}>{t(`${prefixSettings}.more.entry`)}</div> 
			 |