const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_index = require("../../../utils/index.js");
//#region src/plus/saasDevice/devicePlanning/serve.ts
const CONFIG = { isPisell2: true };
const getWorkAreas = function() {
	var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
		const response = yield require_index.request.getRequest().get("/tenant/device/workarea", { relation_count: [
			"smartDevices",
			"dumbDevices",
			"integratedDevices"
		] }, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || [];
	});
	return function getWorkAreas() {
		return _ref.apply(this, arguments);
	};
}();
const createWorkArea = function() {
	var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (payload) {
		const response = yield require_index.request.getRequest().post("/tenant/device/workarea", payload, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function createWorkArea(_x) {
		return _ref2.apply(this, arguments);
	};
}();
const updateWorkArea = function() {
	var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (id, payload) {
		const response = yield require_index.request.getRequest().put(`/tenant/device/workarea/${id}`, payload, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function updateWorkArea(_x2, _x3) {
		return _ref3.apply(this, arguments);
	};
}();
const sortWorkAreas = (ids) => require_index.request.getRequest().post("/tenant/device/workarea/sort", { ids }, CONFIG);
const deleteWorkArea = (id) => require_index.request.getRequest().remove(`/tenant/device/workarea/${id}`, {}, CONFIG);
const getWorkAreaDetail = function() {
	var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (params) {
		return require_index.request.getRequest().get(`/tenant/device/workarea`, params, CONFIG);
	});
	return function getWorkAreaDetail(_x4) {
		return _ref4.apply(this, arguments);
	};
}();
const getDevices = function() {
	var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (params) {
		const response = yield require_index.request.getRequest().get("/tenant/device", {
			with: params.with || [
				"type",
				"model",
				"workarea"
			],
			workarea_id: params.workarea_id,
			type_kind: params.type_kind,
			profile_id: params.profile_id
		}, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || [];
	});
	return function getDevices(_x5) {
		return _ref5.apply(this, arguments);
	};
}();
const getDeviceDetail = function() {
	var _ref6 = require_asyncToGenerator._asyncToGenerator(function* (id) {
		const response = yield require_index.request.getRequest().get(`/tenant/device/${id}`, { with: [
			"type",
			"model",
			"model.activeProfiles",
			"profile"
		] }, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function getDeviceDetail(_x6) {
		return _ref6.apply(this, arguments);
	};
}();
const createDeviceConnection = function() {
	var _ref7 = require_asyncToGenerator._asyncToGenerator(function* (payload) {
		const response = yield require_index.request.getRequest().post("/tenant/device/connection", payload, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function createDeviceConnection(_x7) {
		return _ref7.apply(this, arguments);
	};
}();
const getDeviceConnections = function() {
	var _ref8 = require_asyncToGenerator._asyncToGenerator(function* (params) {
		const response = yield require_index.request.getRequest().get("/tenant/device/connection", {
			with: params.with || [
				"targetDevice.type",
				"sourceDevice.type",
				"profiles"
			],
			type: params.type,
			source_device_id: params.source_device_id,
			target_device_id: params.target_device_id
		}, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || [];
	});
	return function getDeviceConnections(_x8) {
		return _ref8.apply(this, arguments);
	};
}();
const getDeviceConnectionDetail = function() {
	var _ref9 = require_asyncToGenerator._asyncToGenerator(function* (id) {
		const response = yield require_index.request.getRequest().get(`/tenant/device/connection/${id}`, { with: [
			"targetDevice.type",
			"sourceDevice.type",
			"profiles"
		] }, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function getDeviceConnectionDetail(_x9) {
		return _ref9.apply(this, arguments);
	};
}();
const updateDeviceConnection = function() {
	var _ref10 = require_asyncToGenerator._asyncToGenerator(function* (id, payload) {
		const response = yield require_index.request.getRequest().put(`/tenant/device/connection/${id}`, payload, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function updateDeviceConnection(_x10, _x11) {
		return _ref10.apply(this, arguments);
	};
}();
const deleteDeviceConnection = (id) => require_index.request.getRequest().remove(`/tenant/device/connection/${id}`, {}, CONFIG);
const getDeviceTypes = function() {
	var _ref11 = require_asyncToGenerator._asyncToGenerator(function* (params) {
		const response = yield require_index.request.getRequest().get("/tenant/device/type/all", {
			with: params.with || [
				"activeModels",
				"activeModels.activeProfiles",
				"activeModels.brand"
			],
			kind: params.kind
		}, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || [];
	});
	return function getDeviceTypes(_x12) {
		return _ref11.apply(this, arguments);
	};
}();
const getDeviceBrands = function() {
	var _ref12 = require_asyncToGenerator._asyncToGenerator(function* () {
		const response = yield require_index.request.getRequest().get("/api/device_brand:list", {
			page: 1,
			pageSize: 20,
			filter: { $and: [{ $and: { deleted_at: { $is: null } } }] }
		}, {
			isNocobase: true,
			headers: { "x-data-source": "pisell2" }
		});
		return (response === null || response === void 0 ? void 0 : response.data) || [];
	});
	return function getDeviceBrands() {
		return _ref12.apply(this, arguments);
	};
}();
const createDevice = function() {
	var _ref13 = require_asyncToGenerator._asyncToGenerator(function* (payload) {
		const response = yield require_index.request.getRequest().post("/tenant/device", payload, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function createDevice(_x13) {
		return _ref13.apply(this, arguments);
	};
}();
const sortDevices = (ids) => require_index.request.getRequest().post("/tenant/device/sort", { ids }, CONFIG);
const updateDevice = function() {
	var _ref14 = require_asyncToGenerator._asyncToGenerator(function* (id, payload) {
		const response = yield require_index.request.getRequest().put(`/tenant/device/${id}`, payload, CONFIG);
		return (response === null || response === void 0 ? void 0 : response.data) || null;
	});
	return function updateDevice(_x14, _x15) {
		return _ref14.apply(this, arguments);
	};
}();
const deleteDevice = (id) => require_index.request.getRequest().remove(`/tenant/device/${id}`, {}, CONFIG);
//#endregion
exports.createDevice = createDevice;
exports.createDeviceConnection = createDeviceConnection;
exports.createWorkArea = createWorkArea;
exports.deleteDevice = deleteDevice;
exports.deleteDeviceConnection = deleteDeviceConnection;
exports.deleteWorkArea = deleteWorkArea;
exports.getDeviceBrands = getDeviceBrands;
exports.getDeviceConnectionDetail = getDeviceConnectionDetail;
exports.getDeviceConnections = getDeviceConnections;
exports.getDeviceDetail = getDeviceDetail;
exports.getDeviceTypes = getDeviceTypes;
exports.getDevices = getDevices;
exports.getWorkAreaDetail = getWorkAreaDetail;
exports.getWorkAreas = getWorkAreas;
exports.sortDevices = sortDevices;
exports.sortWorkAreas = sortWorkAreas;
exports.updateDevice = updateDevice;
exports.updateDeviceConnection = updateDeviceConnection;
exports.updateWorkArea = updateWorkArea;
