import { filterUndefined } from "../utils/object.js";
import { cs } from "../utils/styles.js";
import { useStyleConfig } from "../core/theme.js";
import styled from "../core/styled.js";
import vui from "../core/vui.js";
import List from "../list/list.js";
import { AccordionProvider } from "./context.js";
import AccordionItem from "./accordionItem.js";
import AccordionItemHorizontal from "./accordionItemHorizontal.js";
import { useMemo } from "react";
import { jsx } from "react/jsx-runtime";

//#region src/accordion/accordion.tsx
const AccordionBase = styled.divBox`
  display: flex;
  min-width: 0;
  transition-duration: normal;
`;
/** Allows to show and hide sections of related content on a page. */
const Accordion = vui((props, ref) => {
	const { children, className, items, orientation = "vertical", iconPosition = "end", size, variant, ...rest } = props;
	const styles = useStyleConfig("Accordion", props);
	const context = useMemo(() => filterUndefined({
		size,
		variant
	}), [size, variant]);
	const aliasedProps = filterUndefined({});
	const isVertical = orientation === "vertical";
	return /* @__PURE__ */ jsx(AccordionProvider, {
		value: context,
		children: /* @__PURE__ */ jsx(AccordionBase, {
			borderLeft: isVertical ? void 0 : `1px solid transparent
        `,
			borderTop: isVertical ? `1px solid transparent` : void 0,
			className: cs("vui-accordion", className),
			ref,
			w: "100%",
			...styles.container,
			...aliasedProps,
			...rest,
			children: isVertical ? /* @__PURE__ */ jsx(List, {
				w: "100%",
				children: items ? items?.map?.((item, key) => /* @__PURE__ */ jsx(AccordionItem, {
					iconPosition,
					...item
				}, key)) : children
			}) : items ? items?.map?.((item, key) => /* @__PURE__ */ jsx(AccordionItemHorizontal, { ...item }, key)) : children
		})
	});
});
Accordion.Item = AccordionItem;
Accordion.ItemHorizontal = AccordionItemHorizontal;
Accordion.displayName = "Accordion";

//#endregion
export { AccordionBase, Accordion as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=accordion.js.map