import { n as __exportAll, r as __toESM } from "./chunk-B-1-B7_t.js";
import { computed, createCommentVNode, createElementBlock, defineComponent, normalizeClass, onMounted, openBlock, ref, toDisplayString, useTemplateRef, watch } from "vue";
//#region src/components/compositions/elements/display/BarcodeDisplay.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["aria-label"];
var _hoisted_2 = {
	key: 0,
	class: "mt-1 text-xs text-destructive",
	"data-testid": "barcode-error"
};
var BarcodeDisplay_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "BarcodeDisplay",
	props: {
		value: {},
		format: { default: "CODE128" },
		classList: {}
	},
	setup(__props) {
		/**
		* Props-driven barcode display.
		*
		* Generates a barcode SVG from `value` using the `jsbarcode` library,
		* lazy-imported on mount. Default format is CODE128; supply alternates
		* (EAN13, UPC, ...) via the `format` prop.
		*/
		const props = __props;
		const content = computed(() => {
			if (props.value === void 0 || props.value === null) return "";
			return String(props.value);
		});
		const rootClass = computed(() => {
			const cl = props.classList;
			if (!cl) return "";
			return Array.isArray(cl) ? cl.join(" ") : cl;
		});
		const svgRef = useTemplateRef("svgRef");
		const error = ref("");
		async function renderBarcode() {
			if (!svgRef.value || !content.value) return;
			try {
				const JsBarcode = (await import("./JsBarcode-DMGiaXa_.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).default;
				JsBarcode(svgRef.value, content.value, {
					format: props.format,
					displayValue: true,
					margin: 4
				});
				error.value = "";
			} catch (e) {
				error.value = e instanceof Error ? e.message : "Failed to render barcode";
			}
		}
		onMounted(() => {
			renderBarcode();
		});
		watch(() => [content.value, props.format], () => {
			renderBarcode();
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", {
				class: normalizeClass(["inline-block", rootClass.value]),
				"data-testid": "barcode-display"
			}, [(openBlock(), createElementBlock("svg", {
				ref_key: "svgRef",
				ref: svgRef,
				role: "img",
				"aria-label": `Barcode: ${content.value}`
			}, null, 8, _hoisted_1)), error.value ? (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(error.value), 1)) : createCommentVNode("", true)], 2);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/display/BarcodeDisplay.vue
var BarcodeDisplay_exports = /* @__PURE__ */ __exportAll({ default: () => BarcodeDisplay_default });
var BarcodeDisplay_default = BarcodeDisplay_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { BarcodeDisplay_exports as n, BarcodeDisplay_default as t };

//# sourceMappingURL=BarcodeDisplay-BUEUIyOk.js.map