import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import { request } from "../../../utils/index.js";
//#region src/plus/pisellReservation/serve/formResourcePage.ts
/**
* GET /shop/form/resource/page — 资源分页列表（见 api/api.md）
*/
function buildQuery(params) {
	var _params$num, _params$ids;
	const q = { num: (_params$num = params.num) !== null && _params$num !== void 0 ? _params$num : 999 };
	/** 不传 skip 时请求里不包含该 query，走后端默认 */
	if (params.skip !== void 0) q.skip = params.skip;
	if ((_params$ids = params.ids) === null || _params$ids === void 0 ? void 0 : _params$ids.length) q["ids"] = params.ids;
	return q;
}
/**
* 拉取资源分页列表；解析 `status` + `data.list` / `data.count`。
*/
function getFormResourcePage() {
	return _getFormResourcePage.apply(this, arguments);
}
function _getFormResourcePage() {
	_getFormResourcePage = _asyncToGenerator(function* (params = {}) {
		var _res$data;
		const res = yield request.getRequest().get(`/shop/form/resource/page`, buildQuery(params), {
			fullResult: true,
			isShopApi: true,
			osServer: true
		});
		const body = (_res$data = res === null || res === void 0 ? void 0 : res.data) !== null && _res$data !== void 0 ? _res$data : res;
		const payload = body && typeof body === "object" && "data" in body ? body.data : body;
		const rawList = payload === null || payload === void 0 ? void 0 : payload.list;
		const list = Array.isArray(rawList) ? rawList : [];
		return {
			list,
			count: typeof (payload === null || payload === void 0 ? void 0 : payload.count) === "number" && Number.isFinite(payload.count) ? payload.count : list.length,
			skip: payload === null || payload === void 0 ? void 0 : payload.skip,
			size: payload === null || payload === void 0 ? void 0 : payload.size
		};
	});
	return _getFormResourcePage.apply(this, arguments);
}
//#endregion
export { getFormResourcePage };
