import { handleUrlClick } from "../utils/urlHelper.js";
import { formatUrlDisplay } from "../utils/urlFormatter.js";
import React from "react";
import { Space, Typography } from "antd";
import { LinkOutlined } from "@ant-design/icons";
//#region src/components/pisellUrl/components/ReadOnlyView.tsx
/**
* PisellUrl 只读态视图组件
* 
* 职责：
* - 渲染只读态 URL 链接展示
* - 支持点击新窗口打开链接（安全性保障）
* - 支持协议/路径隐藏
* - 支持链接图标
* 
* @param props 组件 Props
*/
const ReadOnlyView = (props) => {
	const { value = "", enableLinkClick = true, openInNewWindow = true, showLinkIcon = true, showProtocol = false, showWww = false, showPathname = true, displayFormat = "full", customFormat, defaultProtocol = "https://", fontSize = 16, fontWeight = 500, color = "#101828", linkColor = "#7F56DA", onLinkClick } = props;
	const displayUrl = formatUrlDisplay(value, {
		showProtocol,
		showWww,
		showPathname,
		displayFormat,
		customFormat
	});
	const handleClick = () => {
		if (enableLinkClick && value) {
			onLinkClick === null || onLinkClick === void 0 || onLinkClick(value);
			handleUrlClick(value, openInNewWindow, defaultProtocol);
		}
	};
	const canClick = enableLinkClick && !!value;
	return /* @__PURE__ */ React.createElement("div", { className: "pisell-url-read" }, /* @__PURE__ */ React.createElement(Space, { size: "small" }, showLinkIcon && /* @__PURE__ */ React.createElement(LinkOutlined, { style: { color: linkColor } }), canClick ? /* @__PURE__ */ React.createElement(Typography.Link, {
		onClick: handleClick,
		style: {
			fontSize,
			fontWeight,
			color: linkColor
		},
		"aria-label": props["aria-label"],
		"aria-describedby": props["aria-describedby"]
	}, displayUrl) : /* @__PURE__ */ React.createElement(Typography.Text, {
		style: {
			fontSize,
			fontWeight,
			color
		},
		"aria-label": props["aria-label"],
		"aria-describedby": props["aria-describedby"]
	}, displayUrl)));
};
//#endregion
export { ReadOnlyView as default };
