const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_hooks = require("./hooks.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region src/components/eftpos/log.tsx
function Log({ device, type, tyroUrl, tyroVersion }) {
	const [TyroRef, load] = require_hooks.useTyro({
		url: tyroUrl,
		version: tyroVersion
	});
	const iClientRef = (0, react.useRef)();
	const [src, setSrc] = (0, react.useState)("");
	(0, react.useEffect)(() => {
		if (load && TyroRef.current) {
			const IClient = TyroRef.current.IClient;
			const { apiKey, posProductData } = device.config;
			iClientRef.current = new IClient(apiKey, posProductData);
			getTerminalInfo(() => {
				setSrc((tyroUrl || "https://iclientsimulator.test.tyro.com") + "/logs.html");
			});
		}
	}, [load]);
	/**
	* @title: 获取设备信息
	* @description: 获取设备信息
	* @param {function} cb
	* @Author: hongbing.wang
	* @Date: 2024-08-19 11:32
	*/
	const getTerminalInfo = (cb) => {
		const iClient = iClientRef.current;
		if (!iClient) return;
		const { integrationKey, tid, mid } = device;
		iClient.terminalInfo(({ status, message, terminalInfo }) => {
			if (status === "success") cb(status, message, terminalInfo);
		}, {
			mid,
			tid,
			integrationKey
		});
	};
	(0, react.useEffect)(() => {
		console.log(device);
	}, [device]);
	return /* @__PURE__ */ react.default.createElement("div", { style: {
		flex: 1,
		height: "100%"
	} }, src ? /* @__PURE__ */ react.default.createElement("iframe", {
		src,
		style: {
			width: "100%",
			height: "100%",
			border: "none"
		}
	}) : null);
}
//#endregion
exports.default = Log;
