const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_edgeRouting = require("../utils/edgeRouting.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./NodePortMarkers.less");
//#region src/components/pisellFloorMapLayout/components/NodePortMarkers.tsx
/**
* NodePortMarkers - 选中图元时显示四向锚点，用于拉线
*/
/** 端口圆点的视觉直径（px），与 NodePortMarkers.less 中 base width/height 保持一致 */
const MARKER_VISUAL_SIZE = 10;
const PREFIX = "pisell-floor-map-layout";
const MARKER_ANCHORS = [
	"top",
	"right",
	"bottom",
	"left"
];
function NodePortMarkers(props) {
	const { rect, contentOffsetX = 0, contentOffsetY = 0, previewOnly = false, onAnchorPointerDown, highlightAnchors = [], className, viewportScale = 1 } = props;
	const safeScale = Math.max(viewportScale, .01);
	const markerSize = MARKER_VISUAL_SIZE / safeScale;
	const markerHalf = markerSize / 2;
	const markerOutset = 16 / safeScale;
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)(`${PREFIX}-port-markers`, className),
		style: {
			position: "absolute",
			left: contentOffsetX + rect.left,
			top: contentOffsetY + rect.top,
			width: rect.width,
			height: rect.height,
			pointerEvents: "none",
			zIndex: 5
		}
	}, MARKER_ANCHORS.map((anchor) => {
		const pt = require_edgeRouting.getPortMarkerDisplayPoint({
			left: 0,
			top: 0,
			width: rect.width,
			height: rect.height
		}, anchor, markerOutset);
		const highlighted = highlightAnchors.includes(anchor);
		const Tag = previewOnly ? "span" : "button";
		return /* @__PURE__ */ react.default.createElement(Tag, {
			key: anchor,
			type: previewOnly ? void 0 : "button",
			className: (0, classnames.default)(`${PREFIX}-port-marker`, {
				[`${PREFIX}-port-marker--highlight`]: highlighted,
				[`${PREFIX}-port-marker--preview`]: previewOnly
			}),
			style: {
				left: pt.x,
				top: pt.y,
				width: markerSize,
				height: markerSize,
				marginLeft: -markerHalf,
				marginTop: -markerHalf,
				pointerEvents: previewOnly ? "none" : "auto"
			},
			"aria-label": anchor,
			onPointerDown: previewOnly || !onAnchorPointerDown ? void 0 : (ev) => {
				ev.stopPropagation();
				ev.preventDefault();
				onAnchorPointerDown(anchor, ev);
			}
		});
	}));
}
//#endregion
exports.NodePortMarkers = NodePortMarkers;
