const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
let _ant_design_icons = require("@ant-design/icons");
require("./index.less");
//#region src/plus/saasDevice/deviceProfile/components/DeleteProfileModal/index.tsx
const DeleteProfileModal = ({ open, loading, submitting, profileName, linkedDevices, translation, getText, onClose, onConfirm }) => {
	const hasLinked = linkedDevices.length > 0;
	const renderConfirmBody = () => {
		const [before, after] = getText("pisell2.saas.device-profile.delete.confirm.content").split("{ProfileName}");
		return /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__body" }, /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__confirm-text" }, before, /* @__PURE__ */ react.default.createElement("strong", null, profileName), after));
	};
	const renderLinkedBody = () => {
		const [before, after] = getText("pisell2.saas.device-profile.delete.linked.content").replace("{ProfileName}", "__PROFILE__").replace("{N}", String(linkedDevices.length)).split("__PROFILE__");
		return /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__body" }, /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__warning" }, /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__warning-title" }, /* @__PURE__ */ react.default.createElement(_ant_design_icons.ExclamationCircleFilled, { className: "delete-profile-modal__warning-icon" }), getText("pisell2.saas.device-profile.delete.linked.title")), /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__warning-content" }, before, /* @__PURE__ */ react.default.createElement("strong", null, profileName), after)), /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__devices-label" }, getText("pisell2.saas.device-profile.delete.linked.devicesLabel")), /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__devices-list" }, linkedDevices.map((d) => {
			var _d$workarea, _d$workarea2;
			return /* @__PURE__ */ react.default.createElement("div", {
				key: d.id,
				className: "delete-profile-modal__device-row"
			}, /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__device-name" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: "DesktopOutlined" }), /* @__PURE__ */ react.default.createElement("span", null, translation(d.name))), d.workarea ? /* @__PURE__ */ react.default.createElement(antd.Tag, { key: d === null || d === void 0 || (_d$workarea = d.workarea) === null || _d$workarea === void 0 ? void 0 : _d$workarea.id }, translation((_d$workarea2 = d.workarea) === null || _d$workarea2 === void 0 ? void 0 : _d$workarea2.name)) : null);
		})));
	};
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		open,
		onCancel: onClose,
		headerDivider: false,
		footerDivider: false,
		title: getText("pisell2.saas.device-profile.delete.title"),
		okVisible: !hasLinked,
		cancelButtonProps: { disabled: submitting },
		okButtonProps: {
			danger: true,
			loading: submitting,
			onClick: onConfirm
		},
		cancelText: getText(hasLinked ? "pisell2.saas.device-profile.delete.button.close" : "pisell2.saas.device-profile.delete.button.cancel"),
		okText: getText("pisell2.saas.device-profile.delete.button.delete"),
		closable: true,
		width: 520,
		destroyOnClose: true,
		maskClosable: false,
		className: "delete-profile-modal"
	}, /* @__PURE__ */ react.default.createElement("div", null, loading ? /* @__PURE__ */ react.default.createElement("div", { className: "delete-profile-modal__loading" }, /* @__PURE__ */ react.default.createElement(antd.Spin, null)) : hasLinked ? renderLinkedBody() : renderConfirmBody()));
};
//#endregion
exports.default = DeleteProfileModal;
