import { n as __exportAll } from "./chunk-B-1-B7_t.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 CardRenderer_default } from "./CardRenderer-BVyy_sI2.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, ref, renderList, toDisplayString, unref, useModel, watch, withCtx } from "vue";
//#region src/components/compositions/cards/TabListCard.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = {
	key: 0,
	class: "mb-3 flex flex-col gap-0.5"
};
var _hoisted_2 = {
	key: 0,
	class: "text-base font-semibold"
};
var _hoisted_3 = {
	key: 1,
	class: "text-sm text-muted-foreground"
};
var _hoisted_4 = { class: "flex-1" };
var _hoisted_5 = {
	key: 2,
	class: "text-sm text-muted-foreground italic",
	"data-testid": "tab-list-empty"
};
var TabListCard_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "TabListCard",
	props: /* @__PURE__ */ mergeModels({
		title: {},
		subtitle: {},
		showCard: { type: Boolean },
		tabs: { default: () => [] },
		item: { default: () => ({}) },
		defaultTab: {},
		style: { default: "default" },
		navOnTop: {
			type: Boolean,
			default: false
		},
		hideNav: {
			type: Boolean,
			default: false
		}
	}, {
		"modelValue": {},
		"modelModifiers": {}
	}),
	emits: ["update:modelValue"],
	setup(__props) {
		/**
		* Props-driven `tab-list` composition — renders the shadcn-vue Tabs
		* primitive where each panel is a nested DisplayCard rendered via
		* `CardRenderer`. Each tab is a fully-resolved DisplayCard (not an ID
		* lookup).
		*
		* Self-contained — directly mountable in any Vue app:
		*
		*   <TabListCard
		*     v-model="activeTab"
		*     :tabs="[generalCard, advancedCard]"
		*     :item="dataModel"
		*   />
		*
		* The tab label comes from the child card's `title`, falling back to
		* the card's `id`. The first child is the default active tab.
		*/
		const props = __props;
		const activeTab = useModel(__props, "modelValue");
		const tabList = computed(() => props.tabs ?? []);
		const tabIds = computed(() => tabList.value.map((t) => t.id));
		function labelFor(card) {
			if (card.title) return card.title;
			return card.id;
		}
		const internalActive = ref(activeTab.value ?? props.defaultTab ?? tabIds.value[0] ?? "");
		watch(() => activeTab.value, (next) => {
			if (next !== void 0 && next !== internalActive.value) internalActive.value = next;
		});
		watch(() => tabIds.value, (next) => {
			if (!next.includes(internalActive.value)) {
				internalActive.value = next[0] ?? "";
				if (activeTab.value !== internalActive.value) activeTab.value = internalActive.value;
			}
		});
		function onTabChange(value) {
			const id = String(value);
			internalActive.value = id;
			activeTab.value = id;
		}
		const navOnTopComputed = computed(() => props.style === "horizontal" || props.navOnTop === true);
		const wrapperClass = computed(() => ["gxp-tab-list", navOnTopComputed.value ? "flex flex-col gap-3" : "flex flex-row gap-3"]);
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock(Fragment, null, [__props.title || __props.subtitle ? (openBlock(), createElementBlock("header", _hoisted_1, [__props.title ? (openBlock(), createElementBlock("h3", _hoisted_2, toDisplayString(__props.title), 1)) : createCommentVNode("", true), __props.subtitle ? (openBlock(), createElementBlock("p", _hoisted_3, toDisplayString(__props.subtitle), 1)) : createCommentVNode("", true)])) : createCommentVNode("", true), tabList.value.length > 0 ? (openBlock(), createBlock(unref(Tabs_default), {
				key: 1,
				"model-value": internalActive.value,
				"default-value": __props.defaultTab ?? tabIds.value[0],
				class: normalizeClass(wrapperClass.value),
				orientation: navOnTopComputed.value ? "horizontal" : "vertical",
				"onUpdate:modelValue": onTabChange
			}, {
				default: withCtx(() => [!__props.hideNav ? (openBlock(), createBlock(unref(TabsList_default), {
					key: 0,
					class: normalizeClass(["inline-flex items-center rounded-md bg-muted p-1", navOnTopComputed.value ? "flex-row" : "flex-col h-auto"])
				}, {
					default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(tabList.value, (tab) => {
						return openBlock(), createBlock(unref(TabsTrigger_default), {
							key: tab.id,
							value: tab.id,
							"data-tab-id": tab.id,
							class: "rounded-sm px-3 py-1.5 text-sm font-medium data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm"
						}, {
							default: withCtx(() => [createTextVNode(toDisplayString(labelFor(tab)), 1)]),
							_: 2
						}, 1032, ["value", "data-tab-id"]);
					}), 128))]),
					_: 1
				}, 8, ["class"])) : createCommentVNode("", true), createElementVNode("div", _hoisted_4, [(openBlock(true), createElementBlock(Fragment, null, renderList(tabList.value, (tab) => {
					return openBlock(), createBlock(unref(TabsContent_default), {
						key: tab.id,
						value: tab.id,
						"data-tab-panel-id": tab.id
					}, {
						default: withCtx(() => [createVNode(CardRenderer_default, {
							card: tab,
							item: __props.item
						}, null, 8, ["card", "item"])]),
						_: 2
					}, 1032, ["value", "data-tab-panel-id"]);
				}), 128))])]),
				_: 1
			}, 8, [
				"model-value",
				"default-value",
				"class",
				"orientation"
			])) : (openBlock(), createElementBlock("p", _hoisted_5, " No tabs to display. "))], 64);
		};
	}
});
//#endregion
//#region src/components/compositions/cards/TabListCard.vue
var TabListCard_exports = /* @__PURE__ */ __exportAll({ default: () => TabListCard_default });
var TabListCard_default = TabListCard_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { TabListCard_exports as n, TabListCard_default as t };

//# sourceMappingURL=TabListCard-CdWNXO_e.js.map