//#region src/plus/pisellReservation/floorMap/floorMapBoundRecordIds.ts
/** 无绑定图元时固定引用，避免 `extraRequestParams` 每次 render 新对象触发 booking 请求死循环 */
const EMPTY_BOUND_FORM_RECORD_IDS = [];
function parseRecordIdToPositiveInt(recordId) {
	const t = recordId.trim();
	if (!t || t === "0") return null;
	const n = Number(t);
	if (Number.isFinite(n) && n > 0) return Math.trunc(n);
	if (/^\d+$/.test(t)) return Math.trunc(Number(t));
	return null;
}
/**
* @param sceneElements 当前平面图配置中的图元列表
* @param gridDataSourceKey 与 RecordBoard / 图元 binding 一致的数据源 key（默认 tables）
*/
function sceneElementsToBoundFormRecordIds(sceneElements, gridDataSourceKey) {
	if (!Array.isArray(sceneElements) || sceneElements.length === 0) return EMPTY_BOUND_FORM_RECORD_IDS;
	const seen = /* @__PURE__ */ new Set();
	const out = [];
	for (const el of sceneElements) {
		var _db$recordId;
		const db = el === null || el === void 0 ? void 0 : el.dataBinding;
		if (!db || db.dataSourceKey !== gridDataSourceKey) continue;
		const n = parseRecordIdToPositiveInt(String((_db$recordId = db.recordId) !== null && _db$recordId !== void 0 ? _db$recordId : ""));
		if (n != null && !seen.has(n)) {
			seen.add(n);
			out.push(n);
		}
	}
	return out;
}
//#endregion
exports.sceneElementsToBoundFormRecordIds = sceneElementsToBoundFormRecordIds;
