import { isJsx, isObject } from "../utils/assertion.js";
import "../utils/index.js";
import { useStyleConfig } from "../core/theme.js";
import "../core/index.js";
import list_default from "../list/list.js";
import "../list/index.js";
import avatar_default from "../avatar/avatar.js";
import "../avatar/index.js";
import Popover from "../popover/popover.js";
import "../popover/index.js";
import { useHeaderContext } from "./context.js";
import headerAccountUserInfo_default from "./headerAccountUserInfo.js";
import { Fragment } from "react";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/header/headerAccount.tsx
/** Disables popper's dynamic re-positioning */
/** Displays user account information and helpful links, like settings or logout. */
function HeaderAccount(props) {
	const { contentProps, sections, triggerProps, userInfo, ...rest } = props;
	const { isMobile } = useHeaderContext();
	const styles = useStyleConfig("Header", useHeaderContext()).account;
	const name = isObject(userInfo) ? userInfo.displayName : "";
	const variant = styles?.trigger?.variant ?? "solidDarkBlue";
	return /* @__PURE__ */ jsxs(Popover, {
		isLazy: false,
		offset: [isMobile ? 64 : 39, 16],
		placement: "bottom-end",
		...rest,
		children: [/* @__PURE__ */ jsx(Popover.Trigger, {
			as: avatar_default,
			className: "vui-headerAccountTrigger",
			isInteractive: true,
			ml: 1,
			name,
			role: "button",
			size: "lg",
			title: "Account",
			variant,
			...styles.trigger,
			...triggerProps
		}), /* @__PURE__ */ jsxs(Popover.Content, {
			borderRadius: 0,
			className: "vui-headerAccountContent",
			column: true,
			...styles.content,
			w: isMobile ? 280 : 320,
			...contentProps,
			children: [isJsx(userInfo) ? userInfo : userInfo && /* @__PURE__ */ jsx(headerAccountUserInfo_default, { ...userInfo }), isJsx(sections) ? sections : sections && /* @__PURE__ */ jsx(list_default, {
				className: "vui-headerAccountList",
				mb: 2,
				children: sections.map(({ heading, links }, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
					/* @__PURE__ */ jsx(list_default.Divider, {}),
					heading && /* @__PURE__ */ jsx(list_default.Heading, { text: heading }),
					links?.map(({ icon, url, ...rest$1 }, index$1) => /* @__PURE__ */ jsx(list_default.Item, {
						iconLeft: icon,
						linkProps: { href: url },
						...rest$1
					}, index$1))
				] }, index))
			})]
		})]
	});
}
HeaderAccount.displayName = "HeaderAccount";
var headerAccount_default = HeaderAccount;

//#endregion
export { HeaderAccount, headerAccount_default as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=headerAccount.js.map