require("../../../_virtual/_rolldown/runtime.js");
const require_load = require("../../../utils/load.js");
let react = require("react");
//#region src/components/eftposPay/tyro/hooks.tsx
/**
* @title: 获取 Tyro 资源
* @description:
* @param {Eftpos} type 类型
* @param {string} url 链接
* @return {*}
* @Author: hongbing.wang
* @Date: 2024-08-19 18:36
*/
const useTyro = (params) => {
	const ref = (0, react.useRef)();
	const [load, setLoad] = (0, react.useState)(false);
	const url = (0, react.useMemo)(() => {
		return params && params.url && params.version ? `${params.url}/${params.version}` : "https://iclientsimulator.test.tyro.com/iclient-v1.js";
	}, [params]);
	(0, react.useEffect)(() => {
		require_load.default(url, document.head).then(() => {
			var _window;
			return (_window = window) === null || _window === void 0 ? void 0 : _window.TYRO;
		}).then((res) => {
			setLoad(true);
			ref.current = res;
		}, () => {
			setLoad(true);
		});
	}, [url]);
	return [ref, load];
};
//#endregion
exports.useTyro = useTyro;
