import { getLocale } from "../../../utils/locales.js";
import React from "react";
import { locales } from "@pisell/utils";
import "./LegalTerms.less";
//#region src/pro/Login2.0/components/LegalTerms.tsx
const LegalTerms = ({ config }) => {
	var _config$terms;
	if (!(config === null || config === void 0 ? void 0 : config.enabled) || !(config === null || config === void 0 || (_config$terms = config.terms) === null || _config$terms === void 0 ? void 0 : _config$terms.length)) return null;
	const getTextByMode = () => {
		if ((config.mode || "register") === "login") return locales.getText("pisell-legal-terms-login-text");
		else return locales.getText("pisell-legal-terms-register-text");
	};
	const renderTerms = () => {
		var _config$terms2;
		return (_config$terms2 = config.terms) === null || _config$terms2 === void 0 ? void 0 : _config$terms2.map((term, index) => {
			let termName = "";
			if (typeof term.name === "string") termName = term.name;
			else if (typeof term.name === "object") {
				const locale = getLocale() || "zh-CN";
				termName = term.name[locale] || term.name.original || "";
			}
			return /* @__PURE__ */ React.createElement(React.Fragment, { key: index }, index > 0 && /* @__PURE__ */ React.createElement("span", { className: "legal-terms-separator" }, locales.getText("pisell-legal-terms-and")), /* @__PURE__ */ React.createElement("a", {
				href: term.url,
				target: "_blank",
				rel: "noopener noreferrer",
				className: "legal-terms-link"
			}, termName));
		});
	};
	return /* @__PURE__ */ React.createElement("div", { className: "legal-terms" }, /* @__PURE__ */ React.createElement("span", { className: "legal-terms-text" }, getTextByMode()), renderTerms());
};
//#endregion
export { LegalTerms as default };
