import { validateI18nRequired } from "../../model/types.js";
import React from "react";
import { Form } from "antd";
import { BaseTranslation, Icon, Select as Select$1 } from "@pisell/materials";
//#region src/plus/saasDevice/devicePlanning/components/shared/DeviceBasicInfoForm.tsx
const DeviceBasicInfoForm = ({ form, selectedModel, profiles = [], profileRequired, showProfile, workAreas, workAreaId, currentWorkAreaId, getText, translation, onWorkAreaChange, onValuesChange, showSelectedModel = true }) => {
	var _selectedModel$type;
	return /* @__PURE__ */ React.createElement("div", {
		className: "add-device-modal__body",
		style: { minHeight: "auto" }
	}, showSelectedModel && selectedModel ? /* @__PURE__ */ React.createElement("div", { className: "add-device-modal__selected-model" }, /* @__PURE__ */ React.createElement(Icon, { type: ((_selectedModel$type = selectedModel.type) === null || _selectedModel$type === void 0 ? void 0 : _selectedModel$type.icon) || "DesktopOutlined" }), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "add-device-modal__model-name" }, translation(selectedModel.name) || ""), /* @__PURE__ */ React.createElement("div", { className: "add-device-modal__model-desc" }, translation(selectedModel.description) || ""))) : null, /* @__PURE__ */ React.createElement(Form, {
		form,
		layout: "vertical",
		preserve: false,
		onValuesChange
	}, /* @__PURE__ */ React.createElement(Form.Item, {
		name: "name",
		label: getText("pisell2.saas.device-planning.add.device-name"),
		required: true,
		rules: [{ validator: validateI18nRequired(getText("pisell2.saas.device-planning.add.device-name-required")) }]
	}, /* @__PURE__ */ React.createElement(BaseTranslation, { renderMode: "edit" })), workAreas ? /* @__PURE__ */ React.createElement(Form.Item, {
		label: getText("pisell2.saas.device-planning.edit.work-area"),
		required: true
	}, /* @__PURE__ */ React.createElement(Select$1, {
		value: workAreaId,
		options: workAreas.map((area) => ({
			label: `${translation(area.name) || area.id}${area.id === currentWorkAreaId ? ` (${getText("pisell2.saas.device-planning.connect.current")})` : ""}`,
			value: area.id
		})),
		onChange: (value) => onWorkAreaChange === null || onWorkAreaChange === void 0 ? void 0 : onWorkAreaChange(value)
	})) : null, showProfile && profileRequired ? /* @__PURE__ */ React.createElement(Form.Item, {
		name: "profile_id",
		label: getText("pisell2.saas.device-planning.add.device-profile"),
		required: true,
		rules: [{
			required: true,
			message: getText("pisell2.saas.device-planning.add.device-profile-required")
		}],
		help: profiles.length === 0 ? getText("pisell2.saas.device-planning.add.create-profile-first") : void 0
	}, /* @__PURE__ */ React.createElement(Select$1, {
		disabled: profiles.length === 0,
		options: profiles.map((profile) => ({
			label: translation(profile.name) || String(profile.id),
			value: profile.id
		}))
	})) : null));
};
//#endregion
export { DeviceBasicInfoForm as default };
