const require_index = require("../../../locales/index.js");
//#region src/components/PisellTabbar/utils/index.ts
/**
* 默认的特殊项配置
*/
const defaultItems = {
	all: {
		id: 0,
		shop_id: 9,
		parent_id: 0,
		name: require_index.getText("pisell-tabbar-all"),
		slug: "All",
		icon: ""
	},
	search: {
		id: -1,
		shop_id: 9,
		parent_id: 0,
		name: require_index.getText("table-filter-find"),
		text: require_index.getText("table-filter-find"),
		slug: "Search",
		key: "search",
		icon: "",
		customClick: true
	},
	expand: {
		id: -2,
		shop_id: 9,
		parent_id: 0,
		key: "expand",
		icon: "pisell2-expand-01",
		name: "Expand",
		slug: "expand",
		customClick: true
	}
};
/**
* 向数据源添加特殊项（如 all、search、expand 按钮）
* 
* @param dataSource - 原始数据源
* @param keys - 要添加的特殊项 key 数组
* @returns 添加了特殊项的新数据源
* 
* @example
* ```tsx
* const newData = addDataSourceItemsByKey(categoryData, ['expand', 'all']);
* // 返回: [expandItem, allItem, ...categoryData]
* ```
*/
const addDataSourceItemsByKey = (dataSource, keys) => {
	return [...keys.map((key) => defaultItems[key]), ...dataSource];
};
/**
* 获取默认激活的 key 数组
* 
* @param dataSource - 数据源
* @param rowKey - 用作唯一标识的字段名
* @returns 默认激活的 key 数组（多层级）
* 
* @description
* 默认选中第一项，如果第一项有子级，同时选中第一个子级
* 
* @example
* ```tsx
* const defaultKeys = getDefaultActiveKey(categoryData, 'id');
* // 返回: [1, 0] (第一层级的第一项ID，第二层级的第一项ID)
* ```
*/
const getDefaultActiveKey = (dataSource, rowKey) => {
	const _activeKey = [];
	if (dataSource.length) {
		var _dataSource$0$childre;
		_activeKey.push(dataSource[0][rowKey]);
		if ((_dataSource$0$childre = dataSource[0].children) === null || _dataSource$0$childre === void 0 ? void 0 : _dataSource$0$childre.length) _activeKey.push(0);
	}
	return _activeKey;
};
//#endregion
exports.addDataSourceItemsByKey = addDataSourceItemsByKey;
exports.getDefaultActiveKey = getDefaultActiveKey;
