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("./index.less");
//#region src/components/floatingDock/index.tsx
const DEFAULT_BOTTOM = 24;
const DEFAULT_HIDDEN_RATIO = .5;
const DEFAULT_BOUNDARY_PADDING = 8;
const DEFAULT_AUTO_DOCK_DELAY = 5e3;
/**
* 固定右下角的半隐藏浮动容器，点击后展开，无操作后自动收起。
*/
const FloatingDock = (props) => {
	const { children, className, style, initialBottom = DEFAULT_BOTTOM, hiddenRatio = DEFAULT_HIDDEN_RATIO, boundaryPadding = DEFAULT_BOUNDARY_PADDING, autoDockDelay = DEFAULT_AUTO_DOCK_DELAY } = props;
	const autoDockTimerRef = (0, react.useRef)(null);
	const [expanded, setExpanded] = (0, react.useState)(false);
	const clearAutoDockTimer = (0, react.useCallback)(() => {
		if (autoDockTimerRef.current) {
			clearTimeout(autoDockTimerRef.current);
			autoDockTimerRef.current = null;
		}
	}, []);
	const scheduleAutoDock = (0, react.useCallback)(() => {
		clearAutoDockTimer();
		autoDockTimerRef.current = setTimeout(() => {
			setExpanded(false);
		}, autoDockDelay);
	}, [autoDockDelay, clearAutoDockTimer]);
	(0, react.useEffect)(() => clearAutoDockTimer, [clearAutoDockTimer]);
	const handleClickCapture = (0, react.useCallback)(() => {
		if (expanded) {
			scheduleAutoDock();
			return;
		}
		setExpanded(true);
		scheduleAutoDock();
	}, [expanded, scheduleAutoDock]);
	const handlePointerEnter = (0, react.useCallback)(() => {
		if (expanded) scheduleAutoDock();
	}, [expanded, scheduleAutoDock]);
	const finalStyle = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, style), {}, {
		right: expanded ? boundaryPadding : 0,
		bottom: initialBottom,
		transform: expanded ? "translateX(0)" : `translateX(${hiddenRatio * 100}%)`
	});
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-floating-dock", className, { "pisell-floating-dock-expanded": expanded }),
		style: finalStyle,
		onPointerEnter: handlePointerEnter,
		onClickCapture: handleClickCapture
	}, children);
};
//#endregion
exports.default = FloatingDock;
