import {
  SectionRow
} from "./chunk-3XPXUIK3.js";
import {
  ActionMenu
} from "./chunk-BDGZ4EQO.js";

// src/pages/inventory/inventory-detail/components/inventory-item-general-section.tsx
import { Container, Heading } from "@medusajs/ui";
import { PencilSquare } from "@medusajs/icons";
import { useTranslation } from "react-i18next";
import { jsx, jsxs } from "react/jsx-runtime";
var InventoryItemGeneralSection = ({
  inventoryItem
}) => {
  const { t } = useTranslation();
  const getQuantityFormat = (quantity) => {
    if (quantity !== void 0 && !isNaN(quantity)) {
      return t("inventory.quantityAcrossLocations", {
        quantity,
        locations: inventoryItem.location_levels?.length
      });
    }
    return "-";
  };
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", "data-testid": "inventory-item-general-section", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", "data-testid": "inventory-item-general-header", children: [
      /* @__PURE__ */ jsxs(Heading, { "data-testid": "inventory-item-general-title", children: [
        inventoryItem.title ?? inventoryItem.sku,
        " ",
        t("fields.details")
      ] }),
      /* @__PURE__ */ jsx(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  icon: /* @__PURE__ */ jsx(PencilSquare, {}),
                  label: t("actions.edit"),
                  to: "edit"
                }
              ]
            }
          ],
          "data-testid": "inventory-item-general-action-menu"
        }
      )
    ] }),
    /* @__PURE__ */ jsx(SectionRow, { title: t("fields.sku"), value: inventoryItem.sku ?? "-", "data-testid": "inventory-item-sku-row" }),
    /* @__PURE__ */ jsx(
      SectionRow,
      {
        title: t("fields.inStock"),
        value: getQuantityFormat(inventoryItem.stocked_quantity),
        "data-testid": "inventory-item-in-stock-row"
      }
    ),
    /* @__PURE__ */ jsx(
      SectionRow,
      {
        title: t("inventory.reserved"),
        value: getQuantityFormat(inventoryItem.reserved_quantity),
        "data-testid": "inventory-item-reserved-row"
      }
    ),
    /* @__PURE__ */ jsx(
      SectionRow,
      {
        title: t("inventory.available"),
        value: getQuantityFormat(
          inventoryItem.stocked_quantity - inventoryItem.reserved_quantity
        ),
        "data-testid": "inventory-item-available-row"
      }
    )
  ] });
};

export {
  InventoryItemGeneralSection
};
