import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import React, { useState } from "react";
import { Button, Typography } from "antd";
//#region src/components/pisellLongText/components/ReadOnlyView.tsx
const { Paragraph } = Typography;
/**
* PisellLongText 只读态视图组件
* 
* 负责渲染只读态的多行文本展示，支持展开/折叠功能
* 
* 功能：
* - 多行文本展示
* - 根据 maxLines 截断内容
* - 展开/收起按钮（超出行数时显示）
* - 字数统计（可选）
* - 保留换行和空格（whiteSpace: 'pre-wrap'）
* 
* @param props 组件 Props
*/
const ReadOnlyView = (props) => {
	const [isExpanded, setIsExpanded] = useState(false);
	const { value, maxLines = 3, enableExpand = true, expandText = "展开", collapseText = "收起", expandButtonPosition = "bottom", showWordCount = false, fontSize = 16, fontWeight = 500, color = "#101828", lineHeight = 1.5, className, style } = props;
	const content = value || "";
	const lines = content.split("\n");
	const needExpand = lines.length > maxLines;
	const displayContent = !isExpanded && needExpand ? lines.slice(0, maxLines).join("\n") + "..." : content;
	const textStyle = _objectSpread2({
		fontSize,
		fontWeight,
		color,
		lineHeight,
		whiteSpace: "pre-wrap",
		margin: 0
	}, style);
	const handleToggleExpand = () => {
		var _props$onExpand;
		const newExpanded = !isExpanded;
		setIsExpanded(newExpanded);
		(_props$onExpand = props.onExpand) === null || _props$onExpand === void 0 || _props$onExpand.call(props, newExpanded);
	};
	return /* @__PURE__ */ React.createElement("div", { className: `pisell-long-text-read ${className || ""}` }, /* @__PURE__ */ React.createElement(Paragraph, { style: textStyle }, displayContent), enableExpand && needExpand && /* @__PURE__ */ React.createElement(Button, {
		type: "link",
		size: "small",
		onClick: handleToggleExpand,
		className: "pisell-long-text-expand-btn"
	}, isExpanded ? collapseText : expandText), showWordCount && /* @__PURE__ */ React.createElement("div", { className: "pisell-long-text-word-count" }, content.length, " 字"));
};
//#endregion
export { ReadOnlyView as default };
