function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _instanceof(left, right) {
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { LoadingOutlined } from "@ant-design/icons";
import { Download as DownloadIcon, ArrowLeft as LeftIcon, Locate, SquareArrowOutUpRight as ShareIcon } from "@sofa-design/icons";
import { Alert, Button, ConfigProvider, Image, Segmented, Spin, Typography } from "antd";
import classNames from "clsx";
import React, { useContext, useEffect, useRef, useState } from "react";
import { ActionIconBox } from "../../Components/ActionIconBox";
import { I18nContext } from "../../I18n";
import { MarkdownEditor } from "../../MarkdownEditor";
import { HtmlPreview } from "../HtmlPreview";
import { formatFileSize, formatLastModified } from "../utils";
import { getLanguageFromFilename, wrapContentInCodeBlock } from "../utils/codeLanguageUtils";
import { fileTypeProcessor } from "./FileTypeProcessor";
import { useFileStyle } from "./style";
import { getFileTypeIcon } from "./utils";
var HTML_MIME_TYPE = 'text/html';
var HTML_EXTENSIONS = [
    '.html',
    '.htm'
];
var EDITOR_PADDING = '0 12px';
var isHtmlFile = function isHtmlFile(fileName, mimeType) {
    var name = (fileName === null || fileName === void 0 ? void 0 : fileName.toLowerCase()) || '';
    var byExtension = HTML_EXTENSIONS.some(function(ext) {
        return name.endsWith(ext);
    });
    var byMimeType = mimeType === HTML_MIME_TYPE;
    return byExtension || byMimeType;
};
var getContentStatus = function getContentStatus(state) {
    if ('error' in state) return 'error';
    return state.status === 'loading' ? 'loading' : 'done';
};
var buildMarkdownContent = function buildMarkdownContent(raw, category, fileName) {
    if (category === 'code') {
        var language = getLanguageFromFilename(fileName);
        return wrapContentInCodeBlock(raw, language);
    }
    return raw;
};
// 占位符组件
var PlaceholderContent = function PlaceholderContent(param) {
    var children = param.children, showFileInfo = param.showFileInfo, file = param.file, onDownload = param.onDownload, locale = param.locale, prefixCls = param.prefixCls, hashId = param.hashId;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var finalPrefixCls = prefixCls || getPrefixCls('workspace-preview');
    return /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(finalPrefixCls, "-placeholder"), hashId)
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(finalPrefixCls, "-placeholder-content"), hashId)
    }, children, showFileInfo && file && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.fileName']) || '文件名：', file.name), file.size && /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.fileSize']) || '文件大小：', file.size), onDownload && /*#__PURE__*/ React.createElement("button", {
        type: "button",
        className: classNames("".concat(finalPrefixCls, "-download-button"), hashId),
        onClick: onDownload,
        "aria-label": (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载文件'
    }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.clickToDownload']) || '点击下载'))));
};
/**
 * 文件预览组件
 */ export var PreviewComponent = function PreviewComponent(param) {
    var file = param.file, customContent = param.customContent, customHeader = param.customHeader, customActions = param.customActions, onBack = param.onBack, onDownload = param.onDownload, onShare = param.onShare, onLocate = param.onLocate, markdownEditorProps = param.markdownEditorProps, headerFileOverride = param.headerFileOverride;
    var _ref, _ref1;
    var locale = useContext(I18nContext).locale;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var filePrefixCls = getPrefixCls('workspace-file');
    var _useFileStyle = useFileStyle(filePrefixCls), wrapSSR = _useFileStyle.wrapSSR, hashId = _useFileStyle.hashId;
    var prefixCls = "".concat(filePrefixCls, "-preview");
    var editorRef = useRef();
    var _useState = _sliced_to_array(useState(null), 2), processResult = _useState[0], setProcessResult = _useState[1];
    var _useState1 = _sliced_to_array(useState({
        status: 'idle',
        mdContent: '',
        rawContent: ''
    }), 2), contentState = _useState1[0], setContentState = _useState1[1];
    var _useState2 = _sliced_to_array(useState('preview'), 2), htmlViewMode = _useState2[0], setHtmlViewMode = _useState2[1];
    var canDownload = file.canDownload !== false;
    var handleDownload = function handleDownload() {
        if (!canDownload) return;
        onDownload === null || onDownload === void 0 ? void 0 : onDownload(file);
    };
    var handleShare = function handleShare(e) {
        onShare === null || onShare === void 0 ? void 0 : onShare(file, {
            anchorEl: e.currentTarget,
            origin: 'preview'
        });
    };
    var handleLocate = function handleLocate() {
        onLocate === null || onLocate === void 0 ? void 0 : onLocate(file);
    };
    useEffect(function() {
        if (customContent) return;
        try {
            var result = fileTypeProcessor.processFile(file);
            setProcessResult(result);
        } catch (err) {
            setContentState({
                status: 'error',
                error: _instanceof(err, Error) ? err.message : (locale === null || locale === void 0 ? void 0 : locale['workspace.file.processFailed']) || '文件处理失败'
            });
        }
    }, [
        file,
        customContent
    ]);
    useEffect(function() {
        if (customContent || !processResult) return;
        var typeInference = processResult.typeInference, dataSource = processResult.dataSource;
        var isTextOrCode = typeInference.category === 'text' || typeInference.category === 'code';
        // 非文本/代码类型时重置状态
        if (!isTextOrCode) {
            setContentState({
                status: 'idle',
                mdContent: '',
                rawContent: ''
            });
            return;
        }
        var setReadyContent = function setReadyContent(raw) {
            setContentState({
                status: 'ready',
                mdContent: buildMarkdownContent(raw, typeInference.category, file.name),
                rawContent: raw
            });
        };
        if (dataSource.content) {
            setReadyContent(dataSource.content);
            return;
        }
        if (dataSource.previewUrl) {
            setContentState({
                status: 'loading',
                mdContent: '',
                rawContent: ''
            });
            fetch(dataSource.previewUrl).then(function(response) {
                if (!response.ok) {
                    throw new Error("HTTP ".concat(response.status, ": ").concat(response.statusText));
                }
                return response.text();
            }).then(setReadyContent).catch(function(err) {
                var errorMessage = _instanceof(err, Error) ? err.message : (locale === null || locale === void 0 ? void 0 : locale['common.loadTextFailed']) || '加载文本内容失败';
                setContentState({
                    status: 'error',
                    error: errorMessage
                });
                console.error('加载文本内容失败:', err);
            });
        } else {
            // 无数据源时重置状态，避免显示旧内容
            setContentState({
                status: 'idle',
                mdContent: '',
                rawContent: ''
            });
        }
    }, [
        processResult,
        file.name,
        customContent,
        locale
    ]);
    useEffect(function() {
        var _editorRef_current;
        if (customContent) return;
        if (((_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.store) && contentState.status === 'ready' && contentState.mdContent) {
            editorRef.current.store.setMDContent(contentState.mdContent);
        }
    }, [
        contentState,
        customContent
    ]);
    useEffect(function() {
        return function() {
            if (processResult) {
                fileTypeProcessor.cleanupResult(processResult);
            }
        };
    }, [
        processResult
    ]);
    useEffect(function() {
        setHtmlViewMode('preview');
    }, [
        file.name
    ]);
    var isCurrentFileHtml = isHtmlFile(file.name, processResult === null || processResult === void 0 ? void 0 : processResult.dataSource.mimeType);
    var renderPreviewContent = function renderPreviewContent() {
        if (file.loading) {
            return /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-content-loading"), hashId)
            }, /*#__PURE__*/ React.createElement("span", {
                className: classNames("".concat(prefixCls, "-content-loading-tip"), hashId)
            }, /*#__PURE__*/ React.createElement(LoadingOutlined, null), (locale === null || locale === void 0 ? void 0 : locale['workspace.file.generating']) || '正在生成'), /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-content-loading-inner"), hashId)
            }, (file === null || file === void 0 ? void 0 : file.content) || '...'));
        }
        if (customContent) {
            return /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-custom-content"), hashId)
            }, customContent);
        }
        if (!processResult) {
            return /*#__PURE__*/ React.createElement(PlaceholderContent, {
                prefixCls: prefixCls,
                hashId: hashId
            }, /*#__PURE__*/ React.createElement(Spin, {
                size: "large",
                tip: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.processing']) || '正在处理文件...'
            }, /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-spin-anchor"), hashId),
                style: {
                    minHeight: 64,
                    width: '100%'
                },
                "aria-hidden": true
            })));
        }
        if (contentState.status === 'error') {
            return /*#__PURE__*/ React.createElement(PlaceholderContent, {
                prefixCls: prefixCls,
                hashId: hashId
            }, /*#__PURE__*/ React.createElement(Alert, {
                message: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.processFailed']) || '文件处理失败',
                description: contentState.error,
                type: "error",
                showIcon: true
            }));
        }
        var typeInference = processResult.typeInference, dataSource = processResult.dataSource, canPreview = processResult.canPreview, previewMode = processResult.previewMode;
        if (!canPreview || previewMode === 'none') {
            return /*#__PURE__*/ React.createElement(PlaceholderContent, {
                prefixCls: prefixCls,
                hashId: hashId
            }, /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-unsupported"), hashId)
            }, /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(filePrefixCls, "-item"), "".concat(prefixCls, "-unsupported-item"), hashId)
            }, /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(filePrefixCls, "-item-icon"), hashId)
            }, getFileTypeIcon(fileTypeProcessor.inferFileType(file).fileType, file.icon, file.name)), /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(filePrefixCls, "-item-info"), hashId),
                style: {
                    textAlign: 'left'
                }
            }, /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(filePrefixCls, "-item-name"), hashId)
            }, /*#__PURE__*/ React.createElement(Typography.Text, {
                ellipsis: {
                    tooltip: file.name
                },
                style: {
                    font: 'var(--font-text-h6-base)',
                    color: 'var(--color-gray-text-default)'
                }
            }, file.name)), (fileTypeProcessor.inferFileType(file).displayType || file.size || file.lastModified) && /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(filePrefixCls, "-item-details"), hashId)
            }, /*#__PURE__*/ React.createElement(Typography.Text, {
                type: "secondary",
                ellipsis: true
            }, fileTypeProcessor.inferFileType(file).displayType && /*#__PURE__*/ React.createElement("span", {
                className: classNames("".concat(filePrefixCls, "-item-type"), hashId)
            }, fileTypeProcessor.inferFileType(file).displayType), file.size && /*#__PURE__*/ React.createElement(React.Fragment, null, fileTypeProcessor.inferFileType(file).displayType && /*#__PURE__*/ React.createElement("span", {
                className: classNames("".concat(filePrefixCls, "-item-separator"), hashId)
            }, "|"), /*#__PURE__*/ React.createElement("span", {
                className: classNames("".concat(filePrefixCls, "-item-size"), hashId)
            }, formatFileSize(file.size))), file.lastModified && /*#__PURE__*/ React.createElement(React.Fragment, null, (fileTypeProcessor.inferFileType(file).displayType || file.size) && /*#__PURE__*/ React.createElement("span", {
                className: classNames("".concat(filePrefixCls, "-item-separator"), hashId)
            }, "|"), /*#__PURE__*/ React.createElement("span", {
                className: classNames("".concat(filePrefixCls, "-item-time"), hashId)
            }, formatLastModified(file.lastModified))))))), canDownload && onDownload ? /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-unsupported-text"), hashId)
            }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unsupportedPreview']) || '此文件无法预览，请下载查看。'), /*#__PURE__*/ React.createElement(Button, {
                color: "default",
                variant: "solid",
                icon: /*#__PURE__*/ React.createElement(DownloadIcon, null),
                onClick: handleDownload,
                "aria-label": (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载'
            }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.downloadButton']) || '下载')) : /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-unsupported-text"), hashId)
            }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unsupportedPreviewNoDownload']) || '此文件无法预览。')));
        }
        var renderTextOrCode = function renderTextOrCode() {
            if (isCurrentFileHtml) {
                var htmlStatus = getContentStatus(contentState);
                return /*#__PURE__*/ React.createElement("div", {
                    className: classNames("".concat(prefixCls, "-text"), hashId)
                }, /*#__PURE__*/ React.createElement(HtmlPreview, {
                    html: contentState.rawContent || '',
                    status: htmlStatus,
                    viewMode: htmlViewMode,
                    onViewModeChange: setHtmlViewMode,
                    iframeProps: {
                        sandbox: 'allow-scripts'
                    },
                    showSegmented: false
                }));
            }
            if (contentState.status === 'loading') {
                return /*#__PURE__*/ React.createElement(PlaceholderContent, {
                    prefixCls: prefixCls,
                    hashId: hashId
                }, /*#__PURE__*/ React.createElement(Spin, {
                    size: "large",
                    tip: (locale === null || locale === void 0 ? void 0 : locale['workspace.loadingFileContent']) || '正在加载文件内容...'
                }, /*#__PURE__*/ React.createElement("div", {
                    className: classNames("".concat(prefixCls, "-spin-anchor"), hashId),
                    style: {
                        minHeight: 64,
                        width: '100%'
                    },
                    "aria-hidden": true
                })));
            }
            return /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(prefixCls, "-text"), hashId)
            }, /*#__PURE__*/ React.createElement(MarkdownEditor, _object_spread({
                editorRef: editorRef,
                initValue: "",
                readonly: true,
                contentStyle: {
                    padding: EDITOR_PADDING
                }
            }, markdownEditorProps)));
        };
        var getPreviewErrorMessage = function getPreviewErrorMessage(category) {
            var messages = {
                image: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.cannotGetImagePreview']) || '无法获取图片预览',
                video: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.cannotGetVideoPreview']) || '无法获取视频预览',
                audio: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.cannotGetAudioPreview']) || '无法获取音频预览',
                pdf: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.cannotGetPdfPreview']) || '无法获取PDF预览'
            };
            return messages[category] || "无法获取".concat(category, "预览");
        };
        var renderMediaPreview = function renderMediaPreview(category) {
            if (!dataSource.previewUrl) {
                return /*#__PURE__*/ React.createElement(PlaceholderContent, {
                    locale: locale,
                    prefixCls: prefixCls,
                    hashId: hashId
                }, /*#__PURE__*/ React.createElement("p", null, getPreviewErrorMessage(category)));
            }
            var mediaElements = {
                image: /*#__PURE__*/ React.createElement("div", {
                    className: classNames("".concat(prefixCls, "-image"), hashId)
                }, /*#__PURE__*/ React.createElement(Image, {
                    src: dataSource.previewUrl,
                    alt: file.name
                })),
                video: /*#__PURE__*/ React.createElement("video", {
                    className: classNames("".concat(prefixCls, "-video"), hashId),
                    src: dataSource.previewUrl,
                    controls: true,
                    controlsList: "nodownload",
                    preload: "metadata"
                }, /*#__PURE__*/ React.createElement("track", {
                    kind: "captions"
                }), (locale === null || locale === void 0 ? void 0 : locale['workspace.file.videoNotSupported']) || '您的浏览器不支持视频播放'),
                audio: /*#__PURE__*/ React.createElement("audio", {
                    className: classNames("".concat(prefixCls, "-audio"), hashId),
                    src: dataSource.previewUrl,
                    controls: true,
                    controlsList: "nodownload",
                    preload: "metadata"
                }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.audioNotSupported']) || '您的浏览器不支持音频播放'),
                pdf: /*#__PURE__*/ React.createElement("embed", {
                    className: classNames("".concat(prefixCls, "-pdf"), hashId),
                    src: dataSource.previewUrl,
                    type: "application/pdf",
                    width: "100%",
                    height: "100%"
                })
            };
            return mediaElements[category];
        };
        switch(typeInference.category){
            case 'text':
            case 'code':
                return renderTextOrCode();
            case 'image':
            case 'video':
            case 'audio':
            case 'pdf':
                return renderMediaPreview(typeInference.category);
            default:
                return /*#__PURE__*/ React.createElement(PlaceholderContent, {
                    file: file,
                    showFileInfo: true,
                    onDownload: canDownload && onDownload ? handleDownload : undefined,
                    locale: locale,
                    prefixCls: prefixCls,
                    hashId: hashId
                }, /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unknownFileType']) || '未知的文件类型'), /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.fileType']) || '文件类型：', typeInference.fileType));
        }
    };
    return wrapSSR(/*#__PURE__*/ React.createElement("div", {
        className: classNames(prefixCls, hashId)
    }, customHeader ? /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-header"), hashId)
    }, customHeader) : /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-header"), hashId)
    }, onBack && /*#__PURE__*/ React.createElement("button", {
        type: "button",
        className: classNames("".concat(prefixCls, "-back-button"), hashId),
        onClick: onBack,
        "aria-label": (locale === null || locale === void 0 ? void 0 : locale['workspace.file.backToFileList']) || '返回文件列表'
    }, /*#__PURE__*/ React.createElement(LeftIcon, {
        className: classNames("".concat(prefixCls, "-back-icon"), hashId)
    })), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-file-info"), hashId)
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-file-title"), hashId)
    }, function() {
        var headerFile = headerFileOverride ? _object_spread({}, file, headerFileOverride) : file;
        var fileType = fileTypeProcessor.inferFileType(file).fileType;
        return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("span", {
            className: classNames("".concat(prefixCls, "-file-icon"), hashId)
        }, getFileTypeIcon(fileType, headerFile.icon, headerFile.name)), /*#__PURE__*/ React.createElement("span", {
            className: classNames("".concat(prefixCls, "-file-name"), hashId)
        }, headerFile.name));
    }()), ((_ref = headerFileOverride === null || headerFileOverride === void 0 ? void 0 : headerFileOverride.lastModified) !== null && _ref !== void 0 ? _ref : file.lastModified) && /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-generate-time"), hashId)
    }, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.generationTime']) || '生成时间：', formatLastModified((_ref1 = headerFileOverride === null || headerFileOverride === void 0 ? void 0 : headerFileOverride.lastModified) !== null && _ref1 !== void 0 ? _ref1 : file.lastModified))), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-actions"), hashId)
    }, !customContent && isCurrentFileHtml && /*#__PURE__*/ React.createElement(Segmented, {
        size: "small",
        options: [
            {
                label: (locale === null || locale === void 0 ? void 0 : locale['htmlPreview.preview']) || '预览',
                value: 'preview'
            },
            {
                label: (locale === null || locale === void 0 ? void 0 : locale['htmlPreview.code']) || '代码',
                value: 'code'
            }
        ],
        value: htmlViewMode,
        onChange: function onChange(val) {
            return setHtmlViewMode(val);
        }
    }), customActions && /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-custom-actions"), hashId)
    }, customActions), onLocate && file.canLocate === true && /*#__PURE__*/ React.createElement(ActionIconBox, {
        title: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.location']) || '定位',
        onClick: handleLocate,
        tooltipProps: {
            mouseEnterDelay: 0.3
        },
        className: classNames("".concat(prefixCls, "-item-action-btn"), hashId)
    }, /*#__PURE__*/ React.createElement(Locate, null)), onShare && file.canShare === true && /*#__PURE__*/ React.createElement(ActionIconBox, {
        title: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.share']) || '分享',
        onClick: handleShare,
        tooltipProps: {
            mouseEnterDelay: 0.3
        },
        className: classNames("".concat(prefixCls, "-item-action-btn"), hashId)
    }, /*#__PURE__*/ React.createElement(ShareIcon, null)), canDownload && onDownload && /*#__PURE__*/ React.createElement(ActionIconBox, {
        title: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载',
        onClick: handleDownload,
        tooltipProps: {
            mouseEnterDelay: 0.3
        },
        className: classNames("".concat(prefixCls, "-item-action-btn"), hashId)
    }, /*#__PURE__*/ React.createElement(DownloadIcon, null)))), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-content"), hashId)
    }, renderPreviewContent())));
};
