"use client" import type { ReactNode } from "react" import Link from "next/link" import { Globe, Lock, Star, Users } from "lucide-react" import { EditorAccountButton } from "@/components/drive/editor-account-button" import { OfficeEditorInlineTitle } from "@/components/drive/office-editor-inline-title" import { ShareDialog } from "@/components/drive/share-dialog" import { CollabPresenceAvatars } from "@/components/drive/richtext/collab-presence-avatars" import { DocsLogoIcon } from "@/components/drive/richtext/docs-logo-icon" import { DocsMenubar } from "@/components/drive/richtext/docs-menubar" import type { DocsEditMenuActions, DocsEditMenuState } from "@/components/drive/richtext/docs-edit-menu" import type { DocsFileMenuActions } from "@/components/drive/richtext/docs-file-menu" import { DocsMoveButton } from "@/components/drive/richtext/docs-move-button" import { Button } from "@/components/ui/button" import type { DriveShare, DriveFileInfo } from "@/lib/api/types" import type { CollabPresenceUser } from "@/lib/drive/use-collab-presence" import { resolveShareButtonIcon, type ShareButtonIcon, } from "@/lib/drive/drive-share-button-state" import type { PageFormatId } from "@/lib/drive/page-formats" import type { RichTextSaveStatus } from "@/lib/drive/richtext-types" import { cn } from "@/lib/utils" function ShareButtonIcon({ kind }: { kind: ShareButtonIcon }) { if (kind === "globe") return if (kind === "users") return return } function saveStatusLabel(status: RichTextSaveStatus): string { switch (status) { case "saving": return "Enregistrement…" case "saved": return "Enregistré dans UltiDrive" case "error": return "Erreur d'enregistrement" default: return "" } } export function DocsChrome({ title, onRename, renameDisabled, backHref, backLabel, showBack = true, shares = [], onShareClick, showShare = false, showAccount = false, saveStatus = "idle", presenceUsers = [], pageFormatId, onPageFormatChange, zoom, onZoomChange, trailing, moveFile, onFileMoved, fileMenuActions, fileMenuDialogs, fileMenuDisabled, editMenuActions, editMenuState, editMenuDisabled, renameSignal, }: { title: string onRename?: (next: string) => Promise renameDisabled?: boolean backHref?: string backLabel?: string showBack?: boolean shares?: DriveShare[] onShareClick?: () => void showShare?: boolean showAccount?: boolean saveStatus?: RichTextSaveStatus presenceUsers?: CollabPresenceUser[] pageFormatId: PageFormatId onPageFormatChange: (id: PageFormatId) => void zoom: number onZoomChange: (zoom: number) => void trailing?: ReactNode /** Propriétaire uniquement — affiche le bouton déplacer. */ moveFile?: DriveFileInfo onFileMoved?: (newPath: string) => void fileMenuActions?: DocsFileMenuActions fileMenuDialogs?: ReactNode fileMenuDisabled?: boolean editMenuActions?: DocsEditMenuActions editMenuState?: DocsEditMenuState editMenuDisabled?: boolean renameSignal?: number }) { const shareIcon = resolveShareButtonIcon(shares) const statusText = saveStatusLabel(saveStatus) const iconHref = showBack !== false && backHref ? backHref : "/drive" const iconLabel = showBack !== false && backHref ? (backLabel ?? "Retour au Drive") : "Ouvrir le Drive" return ( <> {onRename ? ( ) : ( {title} )} {moveFile && onFileMoved ? ( ) : null} {statusText ? ( {statusText} ) : null} {trailing} {presenceUsers.length > 0 ? ( ) : null} {showShare ? ( Partager ) : null} {showAccount ? : null} {showShare ? : null} {fileMenuDialogs} > ) }