/*! ratio-ui · design system for knowledge sharing · https://github.com/losol/ratio-ui · (c) 2026 Losol AS · MPL-2.0 */
import "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/commerce/CartLineItem/CartLineItem.tsx
/**
* CartLineItem - Display a single cart line item with optional quantity controls
*
* @example
* ```tsx
* import { CartLineItem } from '@eventuras/ratio-ui/commerce/CartLineItem';
* import { formatPrice } from '@eventuras/core/currency';
* import { NumberField } from '@eventuras/ratio-ui/forms';
*
* <CartLineItem
*   item={lineItem}
*   locale="nb"
*   formatPrice={formatPrice}
*   showQuantityControls
*   onQuantityChange={(id, qty) => updateCart(id, qty)}
*   onRemove={(id) => removeFromCart(id)}
*   QuantityField={NumberField}
* />
* ```
*/
var CartLineItem = ({ item, locale, formatPrice, showQuantityControls = false, onQuantityChange, onRemove, testIdPrefix = "cart-item", QuantityField }) => {
	return /* @__PURE__ */ jsxs("div", {
		className: "flex items-start gap-4",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "flex-1 min-w-0",
			children: [
				/* @__PURE__ */ jsx("p", {
					className: "text-sm font-medium text-(--text) truncate",
					children: item.title
				}),
				/* @__PURE__ */ jsxs("p", {
					className: "mt-1 text-xs text-(--text-subtle)",
					children: [
						item.quantity,
						" x ",
						formatPrice(item.pricePerUnitIncVat, item.currency, locale),
						" ",
						"(inkl mva ",
						formatPrice(item.vatAmount, item.currency, locale),
						")"
					]
				}),
				showQuantityControls && QuantityField && onQuantityChange && /* @__PURE__ */ jsx("div", {
					className: "mt-2",
					children: /* @__PURE__ */ jsx(QuantityField, {
						value: item.quantity,
						minValue: 0,
						onChange: (nextQuantity) => {
							if (nextQuantity === 0 && onRemove) {
								onRemove(item.productId);
								return;
							}
							onQuantityChange(item.productId, nextQuantity);
						},
						decrementAriaLabel: "Reduser antall",
						incrementAriaLabel: "Øk antall",
						"aria-label": "Antall",
						testId: `${testIdPrefix}-quantity-${item.productId}`
					})
				})
			]
		}), /* @__PURE__ */ jsxs("div", {
			className: "flex flex-col items-end justify-between",
			children: [showQuantityControls && onRemove && /* @__PURE__ */ jsx("button", {
				type: "button",
				onClick: () => onRemove(item.productId),
				className: "text-sm text-error-text hover:opacity-80",
				children: "Fjern"
			}), /* @__PURE__ */ jsxs("div", {
				className: "text-right",
				children: [/* @__PURE__ */ jsx("p", {
					className: "text-sm font-semibold text-(--text) whitespace-nowrap",
					children: formatPrice(item.lineTotalIncVat, item.currency, locale)
				}), /* @__PURE__ */ jsx("p", {
					className: "text-xs text-(--text-subtle)",
					children: "inkl. mva"
				})]
			})]
		})]
	});
};
//#endregion
export { CartLineItem };

//# sourceMappingURL=CartLineItem.js.map