declare interface Animation_2 { enabled?: boolean; duration?: number; type?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; } declare interface BrowseConfig { referer?: string; referrer?: string; url?: string; title?: string; [key: string]: string | number | undefined; } declare interface BubbleConfig { show?: boolean; icon?: string; title?: string; subtitle?: string; messages?: BubbleMessageItem[]; autoRotate?: boolean; rotateInterval?: number; switchMode?: BubbleSwitchMode; } declare interface BubbleMessageItem { icon?: string; title?: string; subtitle?: string; } declare type BubbleSwitchMode = 'fade' | 'slide-up' | 'ticker'; declare interface ButtonConfig { show?: boolean; icon?: string; text?: string; width?: number; height?: number; action?: 'chat' | 'thread' | 'webrtc' | 'call' | 'ticket'; previewImageUrl?: string; previewImageAlt?: string; onClick?: () => void; } export declare interface BytedeskConfig { isDebug?: boolean; forceRefresh?: boolean; mode?: 'floating' | 'inline'; container?: string | HTMLElement; inlineConfig?: { autoShow?: boolean; showBubble?: boolean; mode?: 'container' | 'fixed-right'; width?: number; zIndex?: number; offsetTop?: number; offsetBottom?: number; }; apiUrl?: string; htmlUrl?: string; embedUrl?: string; chatPath?: string; threadPath?: string; webrtcPath?: string; callPath?: string; ticketPath?: string; placement?: 'bottom-left' | 'bottom-right'; marginBottom?: number; marginSide?: number; autoPopup?: boolean; autoPopupDelay?: number; draggable?: boolean; locale?: string; /** * 是否在 ChatHeader 显示“切换显示模式”按钮(弹窗 <-> 嵌入页面右侧)。 * 默认 false(不显示)。设为 true 可显示该按钮。 * 仅在嵌入宿主(window.parent !== window)时生效。 */ showToggleViewModeButton?: boolean; inviteConfig?: InviteConfig; tabsConfig?: TabsConfig; bubbleConfig?: BubbleConfig; buttonConfig?: ButtonConfig; buttonsConfig?: ButtonConfig[]; feedbackConfig?: FeedbackConfig; chatConfig?: ChatConfig; browseConfig?: BrowseConfig; animation?: Animation_2; window?: WindowConfig; minimizedBarConfig?: MinimizedBarConfig; theme?: Theme; onInit?: () => void; onShowChat?: () => void; onHideChat?: () => void; onMessage?: (message: string, type: string) => void; onMessageBubbleClick?: (event: MessageBubbleClickEvent) => void; onConfigChange?: (config: BytedeskConfig) => void; onVisitorInfo?: (uid: string, visitorUid: string) => void; /** * 切换显示模式回调(弹窗 <-> 嵌入页面右侧)。 * 当 iframe 内 ChatHeader 点击切换按钮时触发。 * 若宿主(如 React/Vue 适配器)提供了该回调,SDK 将把切换交由宿主处理 *(例如通过 remount 实例切换);未提供时 SDK 内部自行重建 UI。 * nextMode: 'floating' | 'inline' */ onToggleViewMode?: (nextMode: 'floating' | 'inline') => void; } declare class BytedeskWeb { private config; private originalBodyPaddingRight; private resizeHandler; private resizeDebounceTimer; private resizeObserver; private unreadBadgeMode; private unreadBadgeCount; private bubble; private bubbleContainer; private minimizedBar; private buttonElements; private buttonPreviewElement; private buttonPreviewHideTimer; private window; private embedNavBar; private isEmbedMode; private embedCurrentUrl; private inviteDialog; private contextMenu; private hideTimeout; private isVisible; private isDragging; private isMinimizedBarDragging; private dragDidMove; private windowState; private loopCount; private loopTimer; private isDestroyed; private isWindowDragging; private windowDragState; private initVisitorPromise; private getUnreadMessageCountPromise; private clearUnreadMessagesPromise; private feedbackTooltip; private feedbackDialog; private selectedText; private selectionDebounceTimer; private isTooltipVisible; private lastSelectionText; private lastMouseEvent; private lastSelectionRect; private bubbleMessages; private bubbleMessageIndex; private bubbleMessageTimer; private bubbleMessageTransitionTimer; private bubbleMessageViewportElement; private bubbleMessageContentElement; private bubblePendingMessageElement; private bubbleTickerTrackElement; private bubbleTickerStyleElement; private bubbleIconElement; private bubbleTitleElement; private bubbleSubtitleElement; constructor(config: BytedeskConfig); private setupApiUrl; private mergeConfig; private isInlineMode; private isInlineFixedRightMode; private getInlineFixedRightWidth; private getInlineFixedRightTopOffset; private getInlineFixedRightBottomOffset; private applyInlineFixedRightBodySpacing; private restoreInlineFixedRightBodySpacing; private isFloatingMode; private resolveContainer; private getWindowParent; private isElementAttached; private detachElement; private clearResizeSubscriptions; private refreshFloatingUi; private getMinimizedBarLabel; private createMinimizedBarIcon; private createMinimizedBarLabelElement; private hideDefaultFloatingUi; private restoreDefaultFloatingUi; private removeMinimizedBar; private showMinimizedBar; private restoreMinimizedWindow; private updateChatWindowLayout; private refreshChatIframeUrl; setTheme(themeConfig: Partial>): void; setConfig(nextConfig: Partial, options?: SetConfigOptions): void; private getPrimaryActionFromConfig; private syncChatPathByAction; private getDefaultConfig; private getDefaultTabsConfig; private getEffectiveButtonConfigs; private hasVisibleButtons; private isMultiButtonLayout; private applyConfiguredButtonVisibility; private hideBubbleMessageElement; private triggerButtonAction; private hideButtonPreview; private cancelButtonPreviewHide; private scheduleHideButtonPreview; private showButtonPreview; private createButtonElement; init(): Promise; _initVisitor(): Promise; private _browseVisitor; private getBrowserInfo; private getOSInfo; private getDeviceInfo; _getUnreadMessageCount(): Promise; getUnreadMessageCount(): Promise; initVisitor(): Promise; browseVisitor(): Promise; clearBrowseFailedLimit(): void; clearVisitorInfo(): void; forceInitVisitor(): Promise; private removeUnreadBadgeElement; private renderUnreadBadge; setUnreadMessageCount(count: number): number; showUnreadDot(): void; clearUnreadBadge(): void; clearUnreadMessages(): Promise; private getBubbleMessages; private getBubbleSwitchMode; private buildBubbleMessageContentNode; private buildBubbleTickerItemNode; private destroyBubbleTicker; private setBubbleTickerRunning; private initBubbleTicker; private renderBubbleMessage; private syncBubbleViewportHeight; private cleanupPendingBubbleMessage; private stopBubbleMessageTransition; private transitionBubbleMessage; private stopBubbleMessageRotation; private startBubbleMessageRotation; private createBubble; private createChatWindow; private createEmbedNavBar; private createEmbedNavButton; private updateEmbedUrlDisplay; private showEmbedNavBar; /** * 确保嵌入导航栏存在并适配窗口布局。 * - 新窗口:createChatWindow 已创建,直接复用 * - 旧窗口(无导航栏):动态注入导航栏并调整布局 */ private ensureEmbedNavBar; private hideEmbedNavBar; private getEnabledEmbeddedTabs; private getDefaultEmbeddedTab; private generateChatUrl; private normalizePath; private getChatPageBaseUrl; private getChatPathByTab; private setupMessageListener; private handleLocalStorageData; sendMessageToIframe(message: any): void; resetAnonymousVisitor(): void; showChat(config?: Partial): void; hideChat(options?: { preserveFloatingUiHidden?: boolean; }): void; showThread(config?: Partial): void; showWebrtc(config?: Partial): void; showCall(config?: Partial): void; showTicket(config?: Partial): void; /** * 嵌入式显示外部网页(如帮助文档、产品页面等) * @param url - 要嵌入显示的外部网页完整 URL * @param title - 导航栏自定义标题,未传时兜底显示网址 */ showEmbed(url: string, title?: string): void; /** * 处理 iframe 内 ChatHeader 的切换显示模式请求。 * 优先交给宿主回调(如 React/Vue 适配器通过 remount 切换,保证与宿主渲染状态一致); * 宿主未提供回调时(如纯 JS 嵌入),由 SDK 内部重建 UI。 */ private handleToggleViewModeRequest; /** * 切换显示模式:floating(弹窗) <-> inline(嵌入页面右侧) * 由 iframe 内 ChatHeader 按钮通过 postMessage 触发,也可由宿主直接调用。 * 切换后会以“当前对话可见”为目标重建 UI: * - floating -> inline:销毁浮窗 UI,在内联容器重建并展示聊天窗口 * - inline -> floating:销毁内联窗口,重建浮窗 UI 并直接打开聊天窗口 * * 注意:此方法始终走 SDK 内部重建。若宿主需要接管切换(例如 React 适配器 * 通过 key remount 切换),请在 config 中提供 onToggleViewMode 回调, * iframe 按钮触发的请求会优先调用该回调。 */ toggleViewMode(): void; /** * 切换到弹窗(floating)模式 */ switchToFloatingMode(): void; /** * 切换到内联嵌入(inline)模式 */ switchToInlineMode(): void; /** * 应用指定显示模式(floating/inline),供宿主适配器在接管切换时调用。 * 与 toggleViewMode 不同,此方法接收显式 nextMode,而非自动取反当前模式。 */ applyViewMode(nextMode: "floating" | "inline"): void; private rebuildForViewMode; private minimizeWindow; private toggleMaximize; private handleWindowDragStart; private handleWindowDragMove; private handleWindowDragEnd; private setupResizeListener; destroy(): void; private createInviteDialog; showInviteDialog(): void; hideInviteDialog(): void; handleInviteLoop(): void; showButton(): void; hideButton(): void; showBubble(): void; hideBubble(): void; private createContextMenu; private showContextMenu; private hideContextMenu; private togglePlacement; /** * 初始化文档反馈功能 */ private initFeedbackFeature; /** * 设置文本选择监听器 */ private setupTextSelectionListener; /** * 带防抖的文本选择处理 */ private handleTextSelectionWithDebounce; /** * 处理文本选择 */ private handleTextSelection; /** * 创建反馈提示框(含"问AI"和"文档反馈"两个按钮) */ private createFeedbackTooltip; /** * 显示反馈提示框 */ private showFeedbackTooltip; /** * 隐藏反馈提示框 */ private hideFeedbackTooltip; /** * 创建反馈对话框 */ private createFeedbackDialog; /** * 显示反馈对话框 */ private showFeedbackDialog; /** * 隐藏反馈对话框 */ private hideFeedbackDialog; /** * 生成页面截图并上传到服务器 * @returns 返回上传后的截图URL,如果失败则返回null */ private generateAndUploadScreenshot; /** * 生成截图预览(不上传到服务器) */ private generateScreenshotPreview; /** * 计算选中文本附近的截图区域 */ private calculateScreenshotArea; /** * 动态加载 html2canvas */ private loadHtml2Canvas; /** * 从CDN加载html2canvas */ private loadHtml2CanvasFromCDN; /** * 提交反馈 */ private submitFeedback; /** * 提交反馈到服务器 */ private submitFeedbackToServer; /** * 显示反馈成功消息 */ private showFeedbackSuccess; /** * 公共方法:显示反馈对话框 */ showDocumentFeedback(selectedText?: string): void; /** * 公共方法:显示聊天窗口并自动发送选中的文本 * @param text - 要自动发送的文本内容 */ showChatAndSendText(text: string): void; /** * 公共方法:重新初始化反馈功能 */ reinitFeedbackFeature(): void; /** * 公共方法:强制初始化反馈功能(用于调试) */ forceInitFeedbackFeature(): { success: boolean; methods: { showDocumentFeedback: boolean; testTextSelection: boolean; }; elements: { tooltip: boolean; dialog: boolean; tooltipDOM: boolean; dialogDOM: boolean; }; }; /** * 公共方法:测试文本选择功能 */ testTextSelection(text?: string): void; /** * 公共方法:获取调试信息 */ getDebugInfo(): { config: BytedeskConfig; feedbackConfig: FeedbackConfig | undefined; feedbackTooltip: boolean; feedbackDialog: boolean; selectedText: string; methods: { showDocumentFeedback: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; testTextSelection: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; forceInitFeedbackFeature: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; }; }; /** * 公共方法:销毁反馈功能 */ private destroyFeedbackFeature; } export default BytedeskWeb; declare interface ChatConfig { org: string; t: string; sid: string; title?: string; uid?: string; visitorUid?: string; nickname?: string; avatar?: string; mobile?: string; email?: string; note?: string; channel?: string; goodsInfo?: string; orderInfo?: string; extra?: string; vipLevel?: string; debug?: boolean; draft?: boolean; settingsUid?: string; loadHistory?: boolean; threadDetail?: string | boolean; visitorProfile?: string | boolean; [key: string]: string | number | boolean | undefined; } export declare interface FeedbackConfig { enabled?: boolean; trigger?: 'selection' | 'button' | 'both'; showOnSelection?: boolean; selectionText?: string; askAiText?: string; buttonText?: string; dialogTitle?: string; placeholder?: string; submitText?: string; cancelText?: string; successMessage?: string; categoryNames?: string[]; requiredTypes?: boolean; typesSectionTitle?: string; typesDescription?: string; submitScreenshot?: boolean; onSubmit?: (feedback: FeedbackData) => void; onCancel?: () => void; onAskAi?: (selectedText: string) => void; } export declare interface FeedbackData { selectedText: string; images?: string[]; content: string; categoryNames?: string; url: string; title: string; userAgent: string; visitorUid?: string; orgUid?: string; } declare interface InviteConfig { show?: boolean; text?: string; icon?: string; delay?: number; loop?: boolean; loopDelay?: number; loopCount?: number; acceptText?: string; rejectText?: string; onAccept?: () => void; onReject?: () => void; onClose?: () => void; onOpen?: () => void; } declare interface MessageBubbleClickEvent { uid?: string; type?: string; content?: unknown; navigateToPath?: string | null; extra?: unknown; position?: string; status?: string; } declare interface MinimizedBarConfig { text?: string; } declare interface SetConfigOptions { replaceChatConfig?: boolean; replaceTabsConfig?: boolean; } declare interface TabsConfig { messages?: boolean; thread?: boolean; help?: boolean; } declare interface Theme { mode?: 'light' | 'dark' | 'system'; textColor?: string; backgroundColor?: string; } declare interface WindowConfig { width?: number; height?: number; } export { }