const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../../locales/index.js");
const require_index$1 = require("../../../pisellCamera/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
//#region src/components/dataSourceComponents/fields/Upload/CameraPopover.tsx
const CameraPopover = (props) => {
	const [open, setOpen] = (0, react.useState)(false);
	const cameraRef = (0, react.useRef)(null);
	const handleOpenChange = (newOpen) => {
		setOpen(newOpen);
	};
	const onClick = (e, type) => {
		e.stopPropagation();
		e.preventDefault();
		if (type === "upload") {
			console.log("本地文件");
			props.onLocalFileClick();
		} else {
			var _cameraRef$current;
			console.log("拍照");
			(_cameraRef$current = cameraRef.current) === null || _cameraRef$current === void 0 || _cameraRef$current.open();
		}
		handleOpenChange(false);
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-upload-camera-popover" }, /* @__PURE__ */ react.default.createElement(antd.Popover, {
		open,
		onOpenChange: handleOpenChange,
		trigger: "click",
		arrow: false,
		content: /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-upload-camera-popover-content" }, /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode-upload-camera-popover-content-item",
			onClick: (e) => onClick(e, "upload")
		}, require_index.getText("pisell-upload-camera-local-files")), /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode-upload-camera-popover-content-item",
			onClick: (e) => onClick(e, "photo")
		}, require_index.getText("pisell-upload-camera-capture"))),
		destroyTooltipOnHide: true
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-lowcode-upload-camera-wrapper",
		onClick: (e) => {
			e.stopPropagation();
			e.preventDefault();
			handleOpenChange(true);
		}
	})), /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		ref: cameraRef,
		onChange: props.onCameraChange
	}));
};
//#endregion
exports.default = CameraPopover;
