import { n as cn } from "./utils-DXzSsU1e.js";
import { o as CardContent_default, r as CardHeader_default, s as Card_default } from "./card-X74FuL7B.js";
import { a as TabsContent_default, i as TabsList_default, o as Tabs_default, r as TabsTrigger_default } from "./tabs-CNh54xN1.js";
import { t as ElementRenderer_default } from "./ElementRenderer-DV1pZRd4.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, ref, renderList, toDisplayString, unref, withCtx } from "vue";
//#region src/components/compositions/elements/card/TabCard.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "text-base font-semibold" };
var _hoisted_2 = {
	key: 0,
	class: "py-3 text-sm text-muted-foreground"
};
var _hoisted_3 = {
	key: 0,
	class: "py-3 text-sm text-muted-foreground"
};
//#endregion
//#region src/components/compositions/elements/card/TabCard.vue
var TabCard_default = /* @__PURE__ */ defineComponent({
	__name: "TabCard",
	props: {
		label: {},
		title: {},
		showCard: {
			type: Boolean,
			default: true
		},
		gutterY: { default: "1rem" },
		gutterX: { default: "0" },
		tabs: { default: () => [] },
		activeTab: { default: 0 },
		item: { default: () => ({}) },
		classList: {}
	},
	setup(__props) {
		/**
		* `card.tab` element composition.
		*
		* Renders a tabbed container. Each tab in `tabs` owns an optional
		* `nestedElements` array of resolved child elements. In the FormBuilder
		* each tab's `elementList` IDs are resolved before being forwarded here.
		*/
		const props = __props;
		const resolvedTabs = computed(() => (props.tabs ?? []).map((tab) => ({
			...tab,
			children: (tab.nestedElements ?? []).filter((e) => typeof e === "object" && e !== null && typeof e.type === "string")
		})));
		const currentTab = ref(computed(() => resolvedTabs.value[props.activeTab ?? 0]?.id ?? resolvedTabs.value[0]?.id ?? "").value);
		const bodyStyle = computed(() => ({
			rowGap: props.gutterY,
			columnGap: props.gutterX
		}));
		const heading = computed(() => props.title ?? props.label);
		return (_ctx, _cache) => {
			return props.showCard !== false ? (openBlock(), createBlock(unref(Card_default), {
				key: 0,
				class: normalizeClass(unref(cn)(props.classList))
			}, {
				default: withCtx(() => [heading.value ? (openBlock(), createBlock(unref(CardHeader_default), { key: 0 }, {
					default: withCtx(() => [createElementVNode("span", _hoisted_1, toDisplayString(heading.value), 1)]),
					_: 1
				})) : createCommentVNode("", true), createVNode(unref(CardContent_default), null, {
					default: withCtx(() => [createVNode(unref(Tabs_default), {
						modelValue: currentTab.value,
						"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentTab.value = $event)
					}, {
						default: withCtx(() => [resolvedTabs.value.length ? (openBlock(), createBlock(unref(TabsList_default), { key: 0 }, {
							default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(resolvedTabs.value, (tab) => {
								return openBlock(), createBlock(unref(TabsTrigger_default), {
									key: tab.id,
									value: tab.id
								}, {
									default: withCtx(() => [createTextVNode(toDisplayString(tab.label), 1)]),
									_: 2
								}, 1032, ["value"]);
							}), 128))]),
							_: 1
						})) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(resolvedTabs.value, (tab) => {
							return openBlock(), createBlock(unref(TabsContent_default), {
								key: tab.id,
								value: tab.id,
								class: "flex flex-col pt-3",
								style: normalizeStyle(bodyStyle.value)
							}, {
								default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(tab.children, (child) => {
									return openBlock(), createBlock(ElementRenderer_default, {
										key: child.id,
										element: child,
										item: props.item
									}, null, 8, ["element", "item"]);
								}), 128)), !tab.children.length ? (openBlock(), createElementBlock("p", _hoisted_2, " No elements configured for this tab. ")) : createCommentVNode("", true)]),
								_: 2
							}, 1032, ["value", "style"]);
						}), 128))]),
						_: 1
					}, 8, ["modelValue"]), !resolvedTabs.value.length ? (openBlock(), createElementBlock("p", _hoisted_3, " No tabs configured. ")) : createCommentVNode("", true)]),
					_: 1
				})]),
				_: 1
			}, 8, ["class"])) : (openBlock(), createElementBlock("div", {
				key: 1,
				class: normalizeClass(unref(cn)(props.classList))
			}, [createVNode(unref(Tabs_default), {
				modelValue: currentTab.value,
				"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentTab.value = $event)
			}, {
				default: withCtx(() => [resolvedTabs.value.length ? (openBlock(), createBlock(unref(TabsList_default), { key: 0 }, {
					default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(resolvedTabs.value, (tab) => {
						return openBlock(), createBlock(unref(TabsTrigger_default), {
							key: tab.id,
							value: tab.id
						}, {
							default: withCtx(() => [createTextVNode(toDisplayString(tab.label), 1)]),
							_: 2
						}, 1032, ["value"]);
					}), 128))]),
					_: 1
				})) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(resolvedTabs.value, (tab) => {
					return openBlock(), createBlock(unref(TabsContent_default), {
						key: tab.id,
						value: tab.id,
						class: "flex flex-col pt-3",
						style: normalizeStyle(bodyStyle.value)
					}, {
						default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(tab.children, (child) => {
							return openBlock(), createBlock(ElementRenderer_default, {
								key: child.id,
								element: child,
								item: props.item
							}, null, 8, ["element", "item"]);
						}), 128))]),
						_: 2
					}, 1032, ["value", "style"]);
				}), 128))]),
				_: 1
			}, 8, ["modelValue"])], 2));
		};
	}
});
//#endregion
export { TabCard_default as default };

//# sourceMappingURL=TabCard-DzGqbFcq.js.map