require("../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../utils/index.js");
const require_bookingTicket = require("./bookingTicket.js");
const require_useActiveExecute = require("./useActiveExecute.js");
let react = require("react");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/components/ticketBooking/hooks/pisellos/useScanCustomer.ts
const useScanCustomer = () => {
	const bookingTicket = require_bookingTicket.useBookingTicket();
	const scanRef = (0, react.useRef)(null);
	const Toast = (0, _pisell_materials.useToast)();
	const { executeIfActive } = require_useActiveExecute.useActiveExecute();
	const handleScanCustomer = (callback) => {
		console.log("handleScanCustomer>>>>>>>", callback);
		scanRef.current = bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.scanCustomerListener(executeIfActive((data) => {
			console.log("scanCustomerListener>>>>>>>", data);
			if (data.status === "failed") {
				Toast.fail(_pisell_utils.locales.getText("pisell2.text.scan-global-failed"));
				return;
			}
			callback(require_index.formatScanCustomer(data));
		}));
	};
	return {
		openScan: handleScanCustomer,
		closeScan: () => {
			var _scanRef$current, _scanRef$current$remo;
			(_scanRef$current = scanRef.current) === null || _scanRef$current === void 0 || (_scanRef$current$remo = _scanRef$current.remove) === null || _scanRef$current$remo === void 0 || _scanRef$current$remo.call(_scanRef$current);
		}
	};
};
//#endregion
exports.default = useScanCustomer;
