import type { AuthenticationChatOption, LoadPreviousSessionChatOption } from './types'; export function createPage({ instanceId, webhookUrl, showWelcomeScreen, loadPreviousSession, i18n: { en }, initialMessages, authentication, allowFileUploads, allowedFilesMimeTypes, }: { instanceId: string; webhookUrl?: string; showWelcomeScreen?: boolean; loadPreviousSession?: LoadPreviousSessionChatOption; i18n: { en: Record; }; initialMessages: string[]; mode: 'test' | 'production'; authentication: AuthenticationChatOption; allowFileUploads?: boolean; allowedFilesMimeTypes?: string; }) { const validAuthenticationOptions: AuthenticationChatOption[] = [ 'none', 'basicAuth', 'n8nUserAuth', ]; const validLoadPreviousSessionOptions: LoadPreviousSessionChatOption[] = [ 'manually', 'memory', 'notSupported', ]; const sanitizedAuthentication = validAuthenticationOptions.includes(authentication) ? authentication : 'none'; const sanitizedShowWelcomeScreen = !!showWelcomeScreen; const sanitizedAllowFileUploads = !!allowFileUploads; const sanitizedAllowedFilesMimeTypes = allowedFilesMimeTypes?.toString() ?? ''; const sanitizedLoadPreviousSession = validLoadPreviousSessionOptions.includes( loadPreviousSession as LoadPreviousSessionChatOption, ) ? loadPreviousSession : 'notSupported'; return ` Chat `; }