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 classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
//#region src/plus/saasDevice/appPeripheral/components/PhysicalDeviceSelectModal.tsx
const renderDeviceInfo = (device) => /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement("strong", null, device.name || device.uuid), /* @__PURE__ */ react.default.createElement("span", null, [
	device.connect_type,
	device.ip,
	device.port,
	device.mac
].filter(Boolean).join(" · ") || device.uuid));
const PhysicalDeviceSelectModal = ({ state, variant, submitting, getText, onClose, onSelect }) => {
	if (!state) return null;
	const isPhone = variant === "phone";
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		open: true,
		title: getText("pisell2.saas.app-peripheral.select-physical"),
		headerDivider: false,
		footerDivider: false,
		okVisible: false,
		cancelText: getText("pisell2.saas.app-peripheral.cancel"),
		cancelButtonProps: {
			block: true,
			size: "large",
			type: "default",
			disabled: submitting,
			onClick: onClose
		},
		width: 560,
		platform: isPhone ? "h5" : void 0,
		mobileModalHeight: isPhone ? "auto" : void 0,
		className: (0, classnames.default)("saas-app-peripheral-physical-modal", { "saas-app-peripheral-physical-modal--phone": isPhone }),
		destroyOnClose: true,
		maskClosable: !submitting,
		onCancel: () => {
			if (submitting) return;
			onClose();
		}
	}, /* @__PURE__ */ react.default.createElement(antd.List, {
		className: "saas-app-peripheral-physical-modal__list",
		dataSource: state.devices,
		renderItem: (device) => /* @__PURE__ */ react.default.createElement(antd.List.Item, null, /* @__PURE__ */ react.default.createElement("div", {
			role: "button",
			tabIndex: submitting ? -1 : 0,
			"aria-disabled": submitting,
			className: (0, classnames.default)("saas-app-peripheral-physical-modal__option", { "is-disabled": submitting }),
			onClick: () => {
				if (submitting) return;
				onSelect(device);
			},
			onKeyDown: (event) => {
				if (submitting) return;
				if (event.key === "Enter" || event.key === " ") {
					event.preventDefault();
					onSelect(device);
				}
			}
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: "ApiOutlined" }), renderDeviceInfo(device)))
	}));
};
//#endregion
exports.default = PhysicalDeviceSelectModal;
