const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_PisellBasicGrid = require("../PisellBasicGrid/PisellBasicGrid.js");
const require_index = require("../PisellScrollView/index.js");
const require_useTabsState = require("./hooks/useTabsState.js");
const require_getRowKey = require("./utils/getRowKey.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./PisellSuperTabs.less");
//#region src/components/PisellSuperTabs/PisellSuperTabs.tsx
/**
* PisellSuperTabs 组件
* @description 通用导航框架封装的全能型 Tab 组件
* @template T - 数据源项的类型
*/
const PisellSuperTabs = (props, ref) => {
	const { className, style, dataSource = [], rowKey = "key", value, id, defaultValue, onChange, renderItem, gridProps = {}, scrollViewProps = {}, children, slotLeft, slotRight, slotTop, slotBottom, tabItemClassName, tabItemStyle, slotLeftClassName, slotRightClassName, slotTopClassName, slotBottomClassName, slotLeftStyle, slotRightStyle, slotTopStyle, slotBottomStyle, isControlled = true, __designMode } = props;
	const containerRef = (0, react.useRef)(null);
	const { activeKey, handleTabChange } = require_useTabsState.useTabsState({
		value,
		defaultValue,
		onChange,
		isControlled: isControlled !== null && isControlled !== void 0 ? isControlled : false
	});
	const scrollItemByRowKey = (key) => {
		const item = document.querySelector(`.pisell-super-tabs-item-${id}-${key}`);
		console.log(`.pisell-super-tabs-item-${id}-${key}`);
		if (item) item.scrollIntoView({ behavior: "smooth" });
	};
	(0, react.useImperativeHandle)(ref, () => {
		if (__designMode) return containerRef.current;
		return { scrollItemByRowKey };
	});
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-super-tabs", className),
		style,
		id,
		ref: containerRef
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-super-tabs-slot-top-" + id, slotTopClassName),
		style: slotTopStyle
	}, slotTop), /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-super-tabs-slot-left-" + id, slotLeftClassName),
		style: slotLeftStyle
	}, slotLeft), /* @__PURE__ */ react.default.createElement(require_index.default, scrollViewProps, /* @__PURE__ */ react.default.createElement(require_PisellBasicGrid.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, gridProps), {}, {
		dataSource,
		rowKey,
		renderItem: (item, index) => {
			const key = require_getRowKey.getRowKey(item, index, rowKey);
			const active = key === String(activeKey);
			let content;
			if (renderItem) if (typeof renderItem === "function") content = renderItem({
				dataSource: item,
				index,
				onClick: () => {
					if (item.customClick) return;
					handleTabChange(key, item);
				},
				tabsState: {
					activeKey,
					handleTabChange
				},
				tabsProps: props,
				active: { value: active }
			});
			else content = renderItem;
			else content = item["label"];
			return /* @__PURE__ */ react.default.createElement("div", {
				key,
				className: (0, classnames.default)("pisell-super-tabs-item", `pisell-super-tabs-item-${id}-${key}`, { "pisell-super-tabs-item--active": active }, tabItemClassName),
				style: tabItemStyle
			}, content);
		}
	}))), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-super-tabs-content" }, children), /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-super-tabs-slot-right-" + id, slotRightClassName),
		style: slotRightStyle
	}, slotRight), /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-super-tabs-slot-bottom-" + id, slotBottomClassName),
		style: slotBottomStyle
	}, slotBottom));
};
PisellSuperTabs.displayName = "PisellSuperTabs";
var PisellSuperTabs_default = (0, react.forwardRef)(PisellSuperTabs);
//#endregion
exports.default = PisellSuperTabs_default;
