import { getText } from "../../../../locales/index.js";
import PisellCamera from "../../../pisellCamera/index.js";
import React, { useRef, useState } from "react";
import { Popover } from "antd";
//#region src/components/dataSourceComponents/fields/Upload/CameraPopover.tsx
const CameraPopover = (props) => {
	const [open, setOpen] = useState(false);
	const cameraRef = 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.createElement("div", { className: "pisell-lowcode-upload-camera-popover" }, /* @__PURE__ */ React.createElement(Popover, {
		open,
		onOpenChange: handleOpenChange,
		trigger: "click",
		arrow: false,
		content: /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-upload-camera-popover-content" }, /* @__PURE__ */ React.createElement("div", {
			className: "pisell-lowcode-upload-camera-popover-content-item",
			onClick: (e) => onClick(e, "upload")
		}, getText("pisell-upload-camera-local-files")), /* @__PURE__ */ React.createElement("div", {
			className: "pisell-lowcode-upload-camera-popover-content-item",
			onClick: (e) => onClick(e, "photo")
		}, getText("pisell-upload-camera-capture"))),
		destroyTooltipOnHide: true
	}, /* @__PURE__ */ React.createElement("div", {
		className: "pisell-lowcode-upload-camera-wrapper",
		onClick: (e) => {
			e.stopPropagation();
			e.preventDefault();
			handleOpenChange(true);
		}
	})), /* @__PURE__ */ React.createElement(PisellCamera, {
		ref: cameraRef,
		onChange: props.onCameraChange
	}));
};
//#endregion
export { CameraPopover as default };
