const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/plus/webPosLogin/components/UserFooter/index.tsx
/** 默认用户头像 */
const DEFAULT_USER_AVATAR = "https://pisell2-dev.s3.cn-north-1.amazonaws.com.cn/static/default-avatar.png";
/** 默认店铺图标 */
const DEFAULT_STORE_ICON = "https://pisell2-dev.s3.cn-north-1.amazonaws.com.cn/static/default-store-icon.png";
/**
* 获取店铺显示名称
* @param store 店铺数据
* @param locale 语言
*/
const getStoreName = (store, locale = "en") => {
	var _store$tenant;
	if (!store) return "";
	const name = store === null || store === void 0 || (_store$tenant = store.tenant) === null || _store$tenant === void 0 ? void 0 : _store$tenant.name;
	if (!name) return "";
	return name[locale] || name.original || "";
};
/**
* UserFooter 底部用户信息组件
* @description 展示当前用户和店铺信息，支持切换账号和切换店铺
*/
const UserFooter = (0, react.memo)((props) => {
	var _selectedStore$tenant;
	const { userInfo, selectedStore, step = "store", locale = "en", onChangeAccount, onChangeStore, isShowChangeStore = false } = props;
	/** 用户头像 */
	const userAvatar = (userInfo === null || userInfo === void 0 ? void 0 : userInfo.avatar) || DEFAULT_USER_AVATAR;
	/** 用户名称 */
	const userName = (userInfo === null || userInfo === void 0 ? void 0 : userInfo.name) || "";
	/** 店铺图标 */
	const storeIcon = (selectedStore === null || selectedStore === void 0 || (_selectedStore$tenant = selectedStore.tenant) === null || _selectedStore$tenant === void 0 ? void 0 : _selectedStore$tenant.logo) || DEFAULT_STORE_ICON;
	/** 店铺名称 */
	const storeName = (0, react.useMemo)(() => getStoreName(selectedStore, locale), [selectedStore, locale]);
	/** 是否显示店铺信息（设备选择步骤显示） */
	const showStoreInfo = (step === "device" || step === "channel") && selectedStore && isShowChangeStore;
	if (!userInfo) return null;
	return /* @__PURE__ */ react.default.createElement("div", { className: "user-footer" }, /* @__PURE__ */ react.default.createElement("div", { className: "user-footer__user" }, /* @__PURE__ */ react.default.createElement("div", { className: "user-footer__avatar" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Image, {
		src: userAvatar,
		alt: userName,
		preview: false,
		width: 44,
		height: 44,
		fallbackType: "avatar"
	})), /* @__PURE__ */ react.default.createElement("div", { className: "user-footer__info" }, /* @__PURE__ */ react.default.createElement("span", { className: "user-footer__name" }, userName), /* @__PURE__ */ react.default.createElement("a", {
		className: "user-footer__action",
		onClick: onChangeAccount
	}, _pisell_utils.locales.getText("webpos-login-change-account")))), showStoreInfo && /* @__PURE__ */ react.default.createElement("div", { className: "user-footer__store" }, /* @__PURE__ */ react.default.createElement("div", { className: "user-footer__avatar" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Image, {
		src: storeIcon,
		alt: storeName,
		preview: false,
		width: 44,
		height: 44,
		fallbackType: "avatar"
	})), /* @__PURE__ */ react.default.createElement("div", { className: "user-footer__info" }, /* @__PURE__ */ react.default.createElement("span", {
		className: "user-footer__name",
		title: storeName
	}, storeName), /* @__PURE__ */ react.default.createElement("a", {
		className: "user-footer__action",
		onClick: onChangeStore
	}, _pisell_utils.locales.getText("webpos-login-change-store")))));
});
UserFooter.displayName = "UserFooter";
//#endregion
exports.default = UserFooter;
