const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
//#region src/components/pisellFloorMapLayout/utils/mergeCanvasesForTabs.ts
/**
* 为画布 Tab 合并展示用字段：
* - `tabBadge` 若在配置中已给出则原样使用（含 0）；
* - 否则用当前 `sceneElements` 中属于该画布的数量，且仅在大于 0 时展示角标。
*/
function mergeCanvasesForTabs(config) {
	var _config$sceneElements;
	const elements = (_config$sceneElements = config.sceneElements) !== null && _config$sceneElements !== void 0 ? _config$sceneElements : [];
	return config.canvases.map((c) => {
		const autoCount = elements.filter((e) => e.canvasId === c.id).length;
		let tabBadge;
		if (c.tabBadge !== void 0 && c.tabBadge !== null) tabBadge = c.tabBadge;
		else if (autoCount > 0) tabBadge = autoCount;
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, c), {}, { tabBadge });
	});
}
//#endregion
exports.mergeCanvasesForTabs = mergeCanvasesForTabs;
