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;
}
import { CloseCircleFill, CornerLeftUp, QuoteBefore } from "@sofa-design/icons";
import { ConfigProvider } from "antd";
import classNames from "clsx";
import React, { useContext } from "react";
import { useStyle } from "./style";
/**
 * Quote 组件 - 引用组件
 *
 * 该组件用于显示代码引用或文档引用，支持显示文件名、行号范围、引用描述等信息。
 * 提供悬停显示详细内容的功能，支持关闭按钮和点击交互。
 *
 * @component
 * @description 引用组件，用于显示代码或文档引用信息
 * @param {QuoteProps} props - 组件属性
 * @param {string} [props.fileName] - 文件名
 * @param {string} [props.lineRange] - 行号范围（可选）
 * @param {string} props.quoteDescriptionription - 引用描述
 * @param {string} [props.popupDetail] - 详细内容（悬停显示）
 * @param {boolean} [props.closable=false] - 是否显示关闭按钮
 * @param {() => void} [props.onClose] - 关闭回调
 * @param {string} [props.className] - 自定义CSS类名
 * @param {React.CSSProperties} [props.style] - 自定义样式
 * @param {(fileName: string, lineRange?: string) => void} [props.onFileClick] - 点击文件名回调
 *
 * @example
 * ```tsx
 * <Quote
 *   fileName="example.js"
 *   lineRange="10-15"
 *   quoteDescriptionription="函数定义"
 *   popupDetail="function example() { return 'hello'; }"
 *   closable={true}
 *   onClose={() => console.log('关闭引用')}
 *   onFileClick={(fileName, lineRange) => {
 *     console.log('点击文件:', fileName, '行号:', lineRange);
 *   }}
 * />
 * ```
 *
 * @returns {React.ReactElement} 渲染的引用组件
 *
 * @remarks
 * - 支持文件名和行号范围显示
 * - 提供悬停显示详细内容功能
 * - 支持关闭按钮和点击交互
 * - 提供自定义样式和类名
 * - 集成图标和动画效果
 * - 支持响应式布局
 */ export var Quote = function Quote(param) {
    var fileName = param.fileName, lineRange = param.lineRange, quoteDescription = param.quoteDescription, popupDetail = param.popupDetail, _param_popupDirection = param.popupDirection, popupDirection = _param_popupDirection === void 0 ? 'left' : _param_popupDirection, _param_closable = param.closable, closable = _param_closable === void 0 ? false : _param_closable, onClose = param.onClose, className = param.className, style = param.style, onFileClick = param.onFileClick;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var prefixCls = getPrefixCls('agentic-quote');
    var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    // 处理文件名点击
    var handleFileClick = function handleFileClick() {
        if (onFileClick && fileName) {
            onFileClick(fileName, lineRange);
        }
    };
    // 样式类名
    var containerCls = classNames("".concat(prefixCls, "-container"), hashId, className);
    var quoteDescriptionCls = classNames("".concat(prefixCls, "-quoteDescription"), hashId);
    var closeCls = classNames("".concat(prefixCls, "-close-button"), hashId);
    var quoteIconCls = classNames("".concat(prefixCls, "-quote-icon"), hashId);
    // 弹出层样式类名
    var popupCls = classNames("".concat(prefixCls, "-popup"), hashId);
    var popupHeaderCls = classNames("".concat(prefixCls, "-popup-header"), hashId);
    var popupTitleCls = classNames("".concat(prefixCls, "-popup-title"), hashId);
    var popupRangeCls = classNames("".concat(prefixCls, "-popup-range"), hashId);
    var popupContentCls = classNames("".concat(prefixCls, "-popup-content"), hashId);
    return wrapSSR(/*#__PURE__*/ React.createElement("div", {
        className: containerCls,
        style: style,
        "data-testid": "quote-container"
    }, /*#__PURE__*/ React.createElement("div", {
        className: quoteIconCls,
        "data-testid": "quote-icon"
    }, /*#__PURE__*/ React.createElement(QuoteBefore, null)), /*#__PURE__*/ React.createElement("span", {
        className: quoteDescriptionCls,
        "data-testid": "quote-description"
    }, quoteDescription), closable && onClose && /*#__PURE__*/ React.createElement("div", {
        onClick: onClose,
        className: closeCls,
        "data-testid": "quote-close-button"
    }, /*#__PURE__*/ React.createElement(CloseCircleFill, null)), popupDetail && /*#__PURE__*/ React.createElement("div", {
        className: popupCls,
        "data-testid": "quote-popup",
        style: _define_property({}, popupDirection, 0)
    }, (fileName || lineRange) && /*#__PURE__*/ React.createElement("div", {
        className: popupHeaderCls,
        onClick: handleFileClick,
        "data-testid": "quote-popup-header"
    }, /*#__PURE__*/ React.createElement("div", {
        style: {
            fontSize: 14,
            display: 'flex',
            alignItems: 'center'
        },
        "data-testid": "quote-popup-icon"
    }, /*#__PURE__*/ React.createElement(CornerLeftUp, null)), fileName && /*#__PURE__*/ React.createElement("span", {
        className: popupTitleCls,
        "data-testid": "quote-popup-title"
    }, fileName), lineRange && /*#__PURE__*/ React.createElement("span", {
        className: popupRangeCls,
        "data-testid": "quote-popup-range"
    }, "(", lineRange, ")")), /*#__PURE__*/ React.createElement("div", {
        className: popupContentCls,
        "data-testid": "quote-popup-content"
    }, popupDetail))));
};
export default Quote;
