const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./PisellBaseCard.less");
//#region src/components/pisellBaseCard/PisellBaseCard.tsx
/**
* 合并默认样式与状态样式
*/
function mergeStateStyle(base, hover, active, disabled, isHover, isActive, isDisabled) {
	let s = require_objectSpread2._objectSpread2({}, base);
	if (isDisabled && disabled) {
		Object.assign(s, disabled);
		return s;
	}
	if (isActive && active) Object.assign(s, active);
	if (isHover && hover) Object.assign(s, hover);
	return s;
}
/**
* PisellBaseCard 基础卡片容器
* 提供可定制的容器用于承载子内容，支持默认/悬停/按下/禁用四态样式，可点击时支持焦点与键盘触发
*/
function PisellBaseCard({ children, className, style, hoverStyle, activeStyle, disabledStyle, clickable = true, disabled = false, onClick }) {
	const [isHover, setIsHover] = (0, react.useState)(false);
	const [isActive, setIsActive] = (0, react.useState)(false);
	const mergedStyle = mergeStateStyle(style, hoverStyle, activeStyle, disabledStyle, isHover, isActive, disabled);
	const handleClick = (0, react.useCallback)((e) => {
		if (!clickable || disabled) return;
		onClick === null || onClick === void 0 || onClick(e);
	}, [
		clickable,
		disabled,
		onClick
	]);
	const handleKeyDown = (0, react.useCallback)((e) => {
		if (!clickable || disabled) return;
		if (e.key === "Enter" || e.key === " ") {
			e.preventDefault();
			e.target.click();
		}
	}, [clickable, disabled]);
	const handlePointerEnter = (0, react.useCallback)(() => {
		if (!disabled) setIsHover(true);
	}, [disabled]);
	const handlePointerLeave = (0, react.useCallback)(() => {
		setIsHover(false);
		setIsActive(false);
	}, []);
	const handlePointerDown = (0, react.useCallback)(() => {
		if (clickable && !disabled) setIsActive(true);
	}, [clickable, disabled]);
	const handlePointerUp = (0, react.useCallback)(() => {
		setIsActive(false);
	}, []);
	const canInteract = clickable && !disabled;
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-base-card-root", className),
		style: mergedStyle,
		"data-clickable": clickable,
		"data-disabled": disabled,
		role: canInteract ? "button" : void 0,
		"aria-disabled": disabled ? true : void 0,
		tabIndex: canInteract ? 0 : void 0,
		onClick: handleClick,
		onKeyDown: handleKeyDown,
		onPointerEnter: handlePointerEnter,
		onPointerLeave: handlePointerLeave,
		onPointerDown: handlePointerDown,
		onPointerUp: handlePointerUp
	}, children);
}
//#endregion
exports.PisellBaseCard = PisellBaseCard;
