"use client";
import { cn } from "./index3.js";
import { PanelExpansionContext, PanelLayoutContext } from "./index473.js";
import * as React from "react";
import { jsx } from "react/jsx-runtime";
//#region src/components/templates/AppShell/AppShellPanel.tsx
var APPSHELL_PANEL_TYPE = "AppShell.Panel";
/**
* Generic content slot for AppShell. Max 2 panels visible at a time.
*
* Sizing priority: expanded > width/flex > default (flex: 1)
*
* Reads PanelLayoutContext to self-manage visibility and mobile sizing,
* eliminating the need for cloneElement style injection from Root.
*/
function AppShellPanel({ width, flex, expanded = false, onExpandedChange, label, className, style, children, ...props }) {
	const layout = React.useContext(PanelLayoutContext);
	const expansionValue = React.useMemo(() => ({
		expanded,
		onExpandedChange
	}), [expanded, onExpandedChange]);
	const computedStyle = React.useMemo(() => {
		if (!layout.visible && !layout.isMobile) return {
			...style,
			opacity: 0,
			width: "0px",
			flex: "0",
			overflow: "hidden",
			pointerEvents: "none"
		};
		if (layout.isMobile) return {
			...style,
			flex: "1"
		};
		const sizeStyles = {};
		if (expanded) sizeStyles.flex = "1";
		else if (width !== void 0) {
			sizeStyles.width = typeof width === "number" ? `${width}px` : width;
			sizeStyles.maxWidth = "100%";
		} else if (flex !== void 0) sizeStyles.flex = String(flex);
		else sizeStyles.flex = "1";
		return {
			...sizeStyles,
			...style
		};
	}, [
		layout.visible,
		layout.isMobile,
		expanded,
		width,
		flex,
		style
	]);
	const isHidden = !layout.visible && !layout.isMobile;
	return /* @__PURE__ */ jsx(PanelExpansionContext.Provider, {
		value: expansionValue,
		children: /* @__PURE__ */ jsx("div", {
			"data-slot": "app-shell-panel",
			"data-expanded": expanded || void 0,
			"aria-hidden": isHidden || void 0,
			inert: isHidden || void 0,
			...layout.panelId ? {
				role: "tabpanel",
				id: layout.panelId,
				"aria-labelledby": layout.tabId
			} : {},
			className: cn("flex h-full min-w-0 flex-col", isHidden && "overflow-clip", width !== void 0 && !expanded && !isHidden && !layout.isMobile && "shrink-0", layout.isMobile && "animate-[delight-fade-in_150ms_ease-out_both]", layout.isMobile && "motion-reduce:animate-none", "transition-[flex,width,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]", "motion-reduce:transition-none", className),
			style: computedStyle,
			...props,
			children
		})
	});
}
AppShellPanel.displayName = "AppShell.Panel";
AppShellPanel.__appShellType = APPSHELL_PANEL_TYPE;
//#endregion
export { APPSHELL_PANEL_TYPE, AppShellPanel };

//# sourceMappingURL=index476.js.map