import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { n as Toggle_default } from "./toggle-BHqEMGeO.js";
import { t as FieldFrame_default } from "./field-frame-DhCOWcMP.js";
import { computed, createBlock, createVNode, defineComponent, mergeModels, openBlock, resolveDynamicComponent, unref, useModel, withCtx } from "vue";
import * as LucideIcons from "@lucide/vue";
import { ToggleLeft, ToggleRight } from "@lucide/vue";
//#region src/components/compositions/elements/boolean/IconToggleBoolean.vue?vue&type=script&setup=true&lang.ts
var IconToggleBoolean_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "IconToggleBoolean",
	props: /* @__PURE__ */ mergeModels({
		modelValue: { type: Boolean },
		id: {},
		name: {},
		label: {},
		hideLabel: { type: Boolean },
		required: { type: Boolean },
		readonly: { type: Boolean },
		disabled: { type: Boolean },
		helpText: {},
		errors: { default: () => [] },
		trueIcon: {},
		falseIcon: {}
	}, {
		"modelValue": {
			type: Boolean,
			default: false
		},
		"modelModifiers": {}
	}),
	emits: ["update:modelValue"],
	setup(__props) {
		/**
		* Props-driven icon-toggle composition. Renders a Toggle primitive that
		* shows `trueIcon` when pressed and `falseIcon` when not. Icons are
		* looked up from `@lucide/vue` by name; missing icons fall back to
		* `ToggleRight` / `ToggleLeft`.
		*
		*   <IconToggleBoolean
		*     v-model="darkMode"
		*     label="Dark mode"
		*     true-icon="moon"
		*     false-icon="sun"
		*   />
		*/
		const props = __props;
		const model = useModel(__props, "modelValue");
		const iconLibrary = LucideIcons;
		function resolveIcon(name, fallback) {
			if (!name) return fallback;
			return iconLibrary[name.split(/[-_\s]/).filter(Boolean).map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("")] ?? iconLibrary[name] ?? fallback;
		}
		const trueIconComponent = computed(() => resolveIcon(props.trueIcon, ToggleRight));
		const falseIconComponent = computed(() => resolveIcon(props.falseIcon, ToggleLeft));
		const activeIcon = computed(() => model.value ? trueIconComponent.value : falseIconComponent.value);
		function onUpdate(pressed) {
			model.value = pressed;
		}
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(FieldFrame_default), {
				label: __props.label,
				required: __props.required,
				"hide-label": __props.hideLabel,
				for: __props.id,
				"help-text": __props.helpText,
				errors: __props.errors
			}, {
				default: withCtx(() => [createVNode(unref(Toggle_default), {
					id: __props.id,
					name: __props.name,
					disabled: __props.disabled || __props.readonly,
					required: __props.required,
					pressed: model.value,
					variant: "outline",
					"data-element-name": __props.name ?? void 0,
					"aria-label": __props.label,
					"onUpdate:pressed": onUpdate
				}, {
					default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(activeIcon.value), { class: "h-4 w-4" }))]),
					_: 1
				}, 8, [
					"id",
					"name",
					"disabled",
					"required",
					"pressed",
					"data-element-name",
					"aria-label"
				])]),
				_: 1
			}, 8, [
				"label",
				"required",
				"hide-label",
				"for",
				"help-text",
				"errors"
			]);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/boolean/IconToggleBoolean.vue
var IconToggleBoolean_exports = /* @__PURE__ */ __exportAll({ default: () => IconToggleBoolean_default });
var IconToggleBoolean_default = IconToggleBoolean_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { IconToggleBoolean_exports as n, IconToggleBoolean_default as t };

//# sourceMappingURL=IconToggleBoolean-DnByTK30.js.map