require("../../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../../components/addServiceVariant/utils.js");
const require_utils$1 = require("../../../booking/info2/cartClientCard/utils.js");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/components/ticketBooking/hooks/pisellos/useScanGlobalHandle.ts
const useScanGlobalHandle = () => {
	const Toast = (0, _pisell_materials.useToast)();
	const walletHandle = (data) => {
		const handleSetClient = require_utils$1.getHandleSetClient();
		if (!data.data) {
			Toast.fail(_pisell_utils.locales.getText("pisell2.text.scan-global-failed"));
			return;
		}
		if (handleSetClient && data.data) handleSetClient(data.data);
	};
	const walletPassHandle = (data) => {
		const handleSetClient = require_utils$1.getHandleSetClient();
		if (!data.data) {
			Toast.fail(_pisell_utils.locales.getText("pisell2.text.scan-global-failed"));
			return;
		}
		if (handleSetClient && data.data) handleSetClient(data.data, { fullData: data });
	};
	const productHandle = (data) => {
		var _data$data, _data$data2;
		const handleSetService = require_utils.getHandleSetService();
		if (!((_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.list)) {
			Toast.fail(_pisell_utils.locales.getText("pisell2.text.scan-global-failed"));
			return;
		}
		if (handleSetService && (data === null || data === void 0 || (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.list)) handleSetService(data.data.list, data.scanCode);
	};
	const handleScan = (data) => {
		if (data.searchType === "wallet") walletHandle(data);
		else if (data.searchType === "walletPass") walletPassHandle(data);
		else if (data.searchType === "product" || data.searchType === "local_product") productHandle(data);
	};
	return handleScan;
};
//#endregion
exports.default = useScanGlobalHandle;
