import {
  InventoryItemGeneralSection
} from "./chunk-MLNUGLGT.mjs";
import {
  TextCell,
  TextHeader
} from "./chunk-DRHDNSJA.mjs";
import {
  PlaceholderCell
} from "./chunk-P3UUX2T6.mjs";
import "./chunk-LQTHYS2Z.mjs";
import {
  _DataTable,
  useDataTable
} from "./chunk-7TWTWTDT.mjs";
import "./chunk-HQKGZADC.mjs";
import "./chunk-EMIHDNB7.mjs";
import "./chunk-XRM7PIRS.mjs";
import {
  getFormattedCountry
} from "./chunk-B6ZOPCPA.mjs";
import "./chunk-YOYOJU5D.mjs";
import {
  SectionRow
} from "./chunk-LFLGEXIG.mjs";
import {
  TwoColumnPage
} from "./chunk-GIZFNLKK.mjs";
import {
  DataTable
} from "./chunk-327JQRJK.mjs";
import {
  useQueryParams
} from "./chunk-C76H5USB.mjs";
import {
  useDate
} from "./chunk-3BQAAPDR.mjs";
import {
  Thumbnail
} from "./chunk-MNXC6Q4F.mjs";
import "./chunk-DG7J63J2.mjs";
import "./chunk-PJU3RODH.mjs";
import {
  useExtension
} from "./chunk-C5P5PL3E.mjs";
import {
  TwoColumnPageSkeleton
} from "./chunk-LPEUYMRK.mjs";
import {
  ActionMenu
} from "./chunk-OZPB6JBL.mjs";
import "./chunk-OC7BQLYI.mjs";
import "./chunk-S4DMV3ZT.mjs";
import "./chunk-QJ63TWAK.mjs";
import "./chunk-OW2UL5FI.mjs";
import "./chunk-5DUV4AET.mjs";
import "./chunk-FAB3VINY.mjs";
import "./chunk-Q7YBE4IP.mjs";
import "./chunk-HI6URQ7H.mjs";
import "./chunk-6CLQKVAU.mjs";
import "./chunk-KI7TOXBR.mjs";
import "./chunk-QBIQEVTU.mjs";
import "./chunk-WAXMT4IY.mjs";
import "./chunk-DYDGGABK.mjs";
import "./chunk-LGNTHZ5Y.mjs";
import "./chunk-CN7JXSGW.mjs";
import "./chunk-AO2USOOE.mjs";
import "./chunk-KWWLGCSY.mjs";
import "./chunk-5AFMB7XQ.mjs";
import "./chunk-5U6AZEO7.mjs";
import "./chunk-A63RZVX6.mjs";
import "./chunk-HBXV7ENS.mjs";
import "./chunk-ZBMENGLV.mjs";
import {
  useDeleteReservationItem,
  useReservationItems
} from "./chunk-LGLPAUIO.mjs";
import {
  useStockLocations
} from "./chunk-CDORR33H.mjs";
import "./chunk-DE44HCDH.mjs";
import "./chunk-MUOBXNL6.mjs";
import "./chunk-BEQ5XTWH.mjs";
import "./chunk-HP2JH45P.mjs";
import "./chunk-VCSSQVPD.mjs";
import "./chunk-SQDIZZDW.mjs";
import {
  inventoryItemLevelsQueryKeys,
  inventoryItemsQueryKeys,
  useInventoryItem,
  useInventoryItemLevels
} from "./chunk-LA2ILUXH.mjs";
import "./chunk-7AXHHXCX.mjs";
import {
  queryClient
} from "./chunk-FXYH54JP.mjs";
import "./chunk-774WSTCC.mjs";
import {
  sdk
} from "./chunk-NFEK63OE.mjs";
import "./chunk-QZ7TP4HQ.mjs";

// src/routes/inventory/inventory-detail/constants.ts
var INVENTORY_DETAIL_FIELDS = "*variants,*variants.product,*variants.options";

// src/routes/inventory/inventory-detail/breadcrumb.tsx
import { jsx } from "react/jsx-runtime";
var InventoryDetailBreadcrumb = (props) => {
  const { id } = props.params || {};
  const { inventory_item } = useInventoryItem(
    id,
    {
      fields: INVENTORY_DETAIL_FIELDS
    },
    {
      initialData: props.data,
      enabled: Boolean(id)
    }
  );
  if (!inventory_item) {
    return null;
  }
  return /* @__PURE__ */ jsx("span", { children: inventory_item.title ?? inventory_item.sku ?? id });
};

// src/routes/inventory/inventory-detail/inventory-detail.tsx
import { useLoaderData, useParams } from "react-router-dom";

// src/routes/inventory/inventory-detail/components/inventory-item-attributes/attributes-section.tsx
import { Container, Heading } from "@medusajs/ui";
import { PencilSquare } from "@medusajs/icons";
import { useTranslation } from "react-i18next";
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
var InventoryItemAttributeSection = ({
  inventoryItem
}) => {
  const { t } = useTranslation();
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx2(Heading, { level: "h2", children: t("products.attributes") }),
      /* @__PURE__ */ jsx2(
        ActionMenu,
        {
          groups: [
            {
              actions: [
                {
                  label: t("actions.edit"),
                  to: "attributes",
                  icon: /* @__PURE__ */ jsx2(PencilSquare, {})
                }
              ]
            }
          ]
        }
      )
    ] }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.height"), value: inventoryItem.height }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.width"), value: inventoryItem.width }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.length"), value: inventoryItem.length }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.weight"), value: inventoryItem.weight }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.midCode"), value: inventoryItem.mid_code }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.material"), value: inventoryItem.material }),
    /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.hsCode"), value: inventoryItem.hs_code }),
    /* @__PURE__ */ jsx2(
      SectionRow,
      {
        title: t("fields.countryOfOrigin"),
        value: getFormattedCountry(inventoryItem.origin_country)
      }
    )
  ] });
};

// src/routes/inventory/inventory-detail/components/inventory-item-location-levels.tsx
import { Button, Container as Container2, Heading as Heading2 } from "@medusajs/ui";
import { useTranslation as useTranslation3 } from "react-i18next";
import { Link } from "react-router-dom";

// src/routes/inventory/inventory-detail/components/location-levels-table/use-location-list-table-columns.tsx
import { PencilSquare as PencilSquare2, Trash } from "@medusajs/icons";
import { useMemo } from "react";
import { createDataTableColumnHelper, toast, usePrompt } from "@medusajs/ui";
import { useTranslation as useTranslation2 } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { jsx as jsx3 } from "react/jsx-runtime";
var columnHelper = createDataTableColumnHelper();
var useLocationListTableColumns = () => {
  const { t } = useTranslation2();
  const navigate = useNavigate();
  const prompt = usePrompt();
  const handleDelete = async (level) => {
    const res = await prompt({
      title: t("general.areYouSure"),
      description: t("inventory.deleteWarning"),
      confirmText: t("actions.delete"),
      cancelText: t("actions.cancel")
    });
    if (!res) {
      return;
    }
    try {
      await sdk.admin.inventoryItem.deleteLevel(
        level.inventory_item_id,
        level.location_id
      );
      toast.success(t("inventory.levelDeleted"));
      queryClient.invalidateQueries({
        queryKey: inventoryItemsQueryKeys.lists()
      });
      queryClient.invalidateQueries({
        queryKey: inventoryItemLevelsQueryKeys.list({
          inventoryItemId: level.inventory_item_id
        })
      });
      queryClient.invalidateQueries({
        queryKey: inventoryItemsQueryKeys.detail(level.inventory_item_id)
      });
      queryClient.invalidateQueries({
        queryKey: inventoryItemLevelsQueryKeys.detail(level.inventory_item_id)
      });
    } catch (e) {
      toast.error(e instanceof Error ? e.message : t("errorBoundary.defaultTitle"));
    }
  };
  return useMemo(
    () => [
      columnHelper.accessor("stock_locations.0.name", {
        header: t("fields.location"),
        cell: ({ getValue }) => {
          const locationName = getValue();
          if (!locationName) {
            return /* @__PURE__ */ jsx3(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx3("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx3("span", { className: "truncate", children: locationName.toString() }) });
        }
      }),
      columnHelper.accessor("reserved_quantity", {
        header: t("inventory.reserved"),
        cell: ({ getValue }) => {
          const quantity = getValue();
          if (Number.isNaN(quantity)) {
            return /* @__PURE__ */ jsx3(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx3("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx3("span", { className: "truncate", children: quantity }) });
        },
        enableSorting: true
      }),
      columnHelper.accessor("stocked_quantity", {
        header: t("fields.inStock"),
        cell: ({ getValue }) => {
          const stockedQuantity = getValue();
          if (Number.isNaN(stockedQuantity)) {
            return /* @__PURE__ */ jsx3(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx3("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx3("span", { className: "truncate", children: stockedQuantity }) });
        },
        enableSorting: true
      }),
      columnHelper.accessor("available_quantity", {
        header: t("inventory.available"),
        cell: ({ getValue }) => {
          const availableQuantity = getValue();
          if (Number.isNaN(availableQuantity)) {
            return /* @__PURE__ */ jsx3(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx3("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx3("span", { className: "truncate", children: availableQuantity }) });
        }
      }),
      columnHelper.action({
        actions: (ctx) => {
          const level = ctx.row.original;
          return [
            [
              {
                icon: /* @__PURE__ */ jsx3(PencilSquare2, {}),
                label: t("actions.edit"),
                onClick: () => {
                  navigate(`locations/${level.location_id}`);
                }
              }
            ],
            [
              {
                icon: /* @__PURE__ */ jsx3(Trash, {}),
                label: t("actions.delete"),
                onClick: () => handleDelete(level),
                disabled: level.reserved_quantity > 0 || level.stocked_quantity > 0
              }
            ]
          ];
        }
      })
    ],
    [t]
  );
};

// src/routes/inventory/inventory-detail/components/location-levels-table/use-location-list-table-query.tsx
var useLocationLevelTableQuery = ({
  pageSize = 20,
  prefix
}) => {
  const queryObject = useQueryParams(
    [
      "order",
      "offset",
      "location_id",
      "stocked_quantity",
      "reserved_quantity",
      "incoming_quantity"
    ],
    prefix
  );
  const { offset, ...rest } = queryObject;
  const searchParams = {
    limit: pageSize,
    offset: offset ? Number(offset) : 0,
    ...rest
  };
  return searchParams;
};

// src/routes/inventory/inventory-detail/components/location-levels-table/location-list-table.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
var PAGE_SIZE = 20;
var PREFIX = "invlvl";
var ItemLocationListTable = ({
  inventory_item_id
}) => {
  const searchParams = useLocationLevelTableQuery({
    pageSize: PAGE_SIZE,
    prefix: PREFIX
  });
  const {
    inventory_levels,
    count,
    isPending: isLoading,
    isError,
    error
  } = useInventoryItemLevels(inventory_item_id, {
    ...searchParams,
    fields: "+stock_locations.id,+stock_locations.name"
  });
  const columns = useLocationListTableColumns();
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx4(
    DataTable,
    {
      data: inventory_levels ?? [],
      columns,
      rowCount: count,
      pageSize: PAGE_SIZE,
      getRowId: (row) => row.id,
      isLoading,
      prefix: PREFIX,
      layout: "fill",
      enableSearch: false
    }
  );
};

// src/routes/inventory/inventory-detail/components/inventory-item-location-levels.tsx
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
var InventoryItemLocationLevelsSection = ({
  inventoryItem
}) => {
  const { t } = useTranslation3();
  return /* @__PURE__ */ jsxs2(Container2, { className: "divide-y p-0", children: [
    /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx5(Heading2, { level: "h2", children: t("inventory.locationLevels") }),
      /* @__PURE__ */ jsx5(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx5(Link, { to: "locations", children: t("inventory.manageLocations") }) })
    ] }),
    /* @__PURE__ */ jsx5(ItemLocationListTable, { inventory_item_id: inventoryItem.id })
  ] });
};

// src/routes/inventory/inventory-detail/components/inventory-item-reservations.tsx
import { Button as Button2, Container as Container3, Heading as Heading3 } from "@medusajs/ui";
import { useTranslation as useTranslation7 } from "react-i18next";
import { Link as Link2 } from "react-router-dom";

// src/routes/inventory/inventory-detail/components/reservations-table/reservation-list-table.tsx
import { useMemo as useMemo3 } from "react";

// src/routes/inventory/inventory-detail/components/reservations-table/use-reservation-list-table-columns.tsx
import { createColumnHelper } from "@tanstack/react-table";
import { useMemo as useMemo2 } from "react";
import { useTranslation as useTranslation6 } from "react-i18next";

// src/components/table/table-cells/common/created-at-cell/created-at-cell.tsx
import { Tooltip } from "@medusajs/ui";
import { useTranslation as useTranslation4 } from "react-i18next";
import { jsx as jsx6 } from "react/jsx-runtime";
var CreatedAtCell = ({ date }) => {
  const { getFullDate } = useDate();
  if (!date) {
    return /* @__PURE__ */ jsx6(PlaceholderCell, {});
  }
  return /* @__PURE__ */ jsx6("div", { className: "flex h-full w-full items-center overflow-hidden", children: /* @__PURE__ */ jsx6(
    Tooltip,
    {
      className: "z-10",
      content: /* @__PURE__ */ jsx6("span", { className: "text-pretty", children: `${getFullDate({
        date,
        includeTime: true
      })}` }),
      children: /* @__PURE__ */ jsx6("span", { className: "truncate", children: getFullDate({ date, includeTime: true }) })
    }
  ) });
};

// src/routes/inventory/inventory-detail/components/reservations-table/reservation-actions.tsx
import { PencilSquare as PencilSquare3, Trash as Trash2 } from "@medusajs/icons";
import { toast as toast2, usePrompt as usePrompt2 } from "@medusajs/ui";
import { useTranslation as useTranslation5 } from "react-i18next";
import { jsx as jsx7 } from "react/jsx-runtime";
var ReservationActions = ({
  reservation
}) => {
  const { t } = useTranslation5();
  const prompt = usePrompt2();
  const { mutateAsync } = useDeleteReservationItem(reservation.id);
  const handleDelete = async () => {
    const res = await prompt({
      title: t("general.areYouSure"),
      description: t("inventory.deleteWarning"),
      confirmText: t("actions.delete"),
      cancelText: t("actions.cancel")
    });
    if (!res) {
      return;
    }
    await mutateAsync(void 0, {
      onSuccess: () => {
        toast2.success(t("inventory.reservation.deleteSuccessToast"));
      },
      onError: (e) => {
        toast2.error(e.message);
      }
    });
  };
  return /* @__PURE__ */ jsx7(
    ActionMenu,
    {
      groups: [
        {
          actions: [
            {
              icon: /* @__PURE__ */ jsx7(PencilSquare3, {}),
              label: t("actions.edit"),
              to: `/reservations/${reservation.id}/edit`
            }
          ]
        },
        {
          actions: [
            {
              icon: /* @__PURE__ */ jsx7(Trash2, {}),
              label: t("actions.delete"),
              onClick: handleDelete
            }
          ]
        }
      ]
    }
  );
};

// src/routes/inventory/inventory-detail/components/reservations-table/use-reservation-list-table-columns.tsx
import { jsx as jsx8 } from "react/jsx-runtime";
var columnHelper2 = createColumnHelper();
var useReservationTableColumn = ({ sku }) => {
  const { t } = useTranslation6();
  return useMemo2(
    () => [
      columnHelper2.display({
        id: "sku",
        header: () => /* @__PURE__ */ jsx8(TextHeader, { text: t("fields.sku") }),
        cell: () => {
          return /* @__PURE__ */ jsx8(TextCell, { text: sku });
        }
      }),
      columnHelper2.accessor("line_item.order_id", {
        header: () => /* @__PURE__ */ jsx8(TextHeader, { text: t("inventory.reservation.orderID") }),
        cell: ({ getValue }) => {
          const orderId = getValue();
          if (!orderId) {
            return /* @__PURE__ */ jsx8(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx8(TextCell, { text: orderId });
        }
      }),
      columnHelper2.accessor("description", {
        header: () => /* @__PURE__ */ jsx8(TextHeader, { text: t("fields.description") }),
        cell: ({ getValue }) => {
          const description = getValue();
          if (!description) {
            return /* @__PURE__ */ jsx8(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx8(TextCell, { text: description });
        }
      }),
      columnHelper2.accessor("location.name", {
        header: () => /* @__PURE__ */ jsx8(TextHeader, { text: t("inventory.reservation.location") }),
        cell: ({ getValue }) => {
          const location = getValue();
          if (!location) {
            return /* @__PURE__ */ jsx8(PlaceholderCell, {});
          }
          return /* @__PURE__ */ jsx8(TextCell, { text: location });
        }
      }),
      columnHelper2.accessor("created_at", {
        header: () => /* @__PURE__ */ jsx8(TextHeader, { text: t("fields.createdAt") }),
        cell: ({ getValue }) => /* @__PURE__ */ jsx8(CreatedAtCell, { date: getValue() })
      }),
      columnHelper2.accessor("quantity", {
        header: () => /* @__PURE__ */ jsx8(TextHeader, { text: t("fields.quantity"), align: "right" }),
        cell: ({ getValue }) => {
          return /* @__PURE__ */ jsx8(TextCell, { text: getValue(), align: "right" });
        }
      }),
      columnHelper2.display({
        id: "actions",
        cell: ({ row }) => /* @__PURE__ */ jsx8(ReservationActions, { reservation: row.original })
      })
    ],
    [t]
  );
};

// src/routes/inventory/inventory-detail/components/reservations-table/use-reservation-list-table-query.tsx
var useReservationsTableQuery = ({
  pageSize = 20,
  prefix
}) => {
  const raw = useQueryParams(
    [
      "id",
      "location_id",
      "inventory_item_id",
      "quantity",
      "line_item_id",
      "description",
      "created_by"
    ],
    prefix
  );
  const { quantity, ...params } = raw;
  const searchParams = {
    limit: pageSize,
    quantity: quantity ? JSON.parse(quantity) : void 0,
    ...params
  };
  return {
    searchParams,
    raw
  };
};

// src/routes/inventory/inventory-detail/components/reservations-table/reservation-list-table.tsx
import { jsx as jsx9 } from "react/jsx-runtime";
var PAGE_SIZE2 = 20;
var ReservationItemTable = ({
  inventoryItem
}) => {
  const { searchParams, raw } = useReservationsTableQuery({
    pageSize: PAGE_SIZE2
  });
  const { reservations, count, isPending, isError, error } = useReservationItems({
    ...searchParams,
    inventory_item_id: [inventoryItem.id]
  });
  const { stock_locations } = useStockLocations({
    id: (reservations || []).map((r) => r.location_id)
  });
  const data = useMemo3(() => {
    const locationMap = new Map((stock_locations || []).map((l) => [l.id, l]));
    return (reservations || []).map((r) => ({
      ...r,
      location: locationMap.get(r.location_id)
    }));
  }, [reservations, stock_locations]);
  const columns = useReservationTableColumn({ sku: inventoryItem.sku });
  const { table } = useDataTable({
    data: data ?? [],
    columns,
    count,
    enablePagination: true,
    getRowId: (row) => row.id,
    pageSize: PAGE_SIZE2
  });
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsx9(
    _DataTable,
    {
      table,
      columns,
      pageSize: PAGE_SIZE2,
      count,
      isLoading: isPending,
      pagination: true,
      queryObject: raw
    }
  );
};

// src/routes/inventory/inventory-detail/components/inventory-item-reservations.tsx
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
var InventoryItemReservationsSection = ({
  inventoryItem
}) => {
  const { t } = useTranslation7();
  return /* @__PURE__ */ jsxs3(Container3, { className: "divide-y p-0", children: [
    /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between px-6 py-4", children: [
      /* @__PURE__ */ jsx10(Heading3, { level: "h2", children: t("reservations.domain") }),
      /* @__PURE__ */ jsx10(Button2, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx10(Link2, { to: `/reservations/create?item_id=${inventoryItem.id}`, children: t("actions.create") }) })
    ] }),
    /* @__PURE__ */ jsx10(ReservationItemTable, { inventoryItem })
  ] });
};

// src/routes/inventory/inventory-detail/components/inventory-item-variants/variants-section.tsx
import { TriangleRightMini } from "@medusajs/icons";
import { Container as Container4, Heading as Heading4 } from "@medusajs/ui";
import { useTranslation as useTranslation8 } from "react-i18next";
import { Link as Link3 } from "react-router-dom";
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
var InventoryItemVariantsSection = ({
  variants
}) => {
  const { t } = useTranslation8();
  if (!variants?.length) {
    return null;
  }
  return /* @__PURE__ */ jsxs4(Container4, { className: "p-0", children: [
    /* @__PURE__ */ jsx11("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx11(Heading4, { level: "h2", children: t("inventory.associatedVariants") }) }),
    /* @__PURE__ */ jsx11("div", { className: "txt-small flex flex-col gap-2 px-2 pb-2", children: variants.map((variant) => {
      const link = variant.product ? `/products/${variant.product.id}/variants/${variant.id}` : null;
      const Inner = /* @__PURE__ */ jsx11("div", { className: "shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2 transition-colors", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ jsx11("div", { className: "shadow-elevation-card-rest rounded-md", children: /* @__PURE__ */ jsx11(Thumbnail, { src: variant.product?.thumbnail }) }),
        /* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-col", children: [
          /* @__PURE__ */ jsx11("span", { className: "text-ui-fg-base font-medium", children: variant.title }),
          /* @__PURE__ */ jsx11("span", { className: "text-ui-fg-subtle", children: variant.options.map((o) => o.value).join(" \u22C5 ") })
        ] }),
        /* @__PURE__ */ jsx11("div", { className: "flex size-7 items-center justify-center", children: /* @__PURE__ */ jsx11(TriangleRightMini, { className: "text-ui-fg-muted rtl:rotate-180" }) })
      ] }) });
      if (!link) {
        return /* @__PURE__ */ jsx11("div", { children: Inner }, variant.id);
      }
      return /* @__PURE__ */ jsx11(
        Link3,
        {
          to: link,
          className: "focus-within:shadow-borders-interactive-with-focus [&:hover>div]:bg-ui-bg-component-hover rounded-md outline-none",
          children: Inner
        },
        variant.id
      );
    }) })
  ] });
};

// src/routes/inventory/inventory-detail/inventory-detail.tsx
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
var InventoryDetail = () => {
  const { id } = useParams();
  const initialData = useLoaderData();
  const {
    inventory_item,
    isPending: isLoading,
    isError,
    error
  } = useInventoryItem(
    id,
    {
      fields: INVENTORY_DETAIL_FIELDS
    },
    {
      initialData
    }
  );
  const { getWidgets } = useExtension();
  if (isLoading || !inventory_item) {
    return /* @__PURE__ */ jsx12(
      TwoColumnPageSkeleton,
      {
        showJSON: true,
        mainSections: 3,
        sidebarSections: 2,
        showMetadata: true
      }
    );
  }
  if (isError) {
    throw error;
  }
  return /* @__PURE__ */ jsxs5(
    TwoColumnPage,
    {
      widgets: {
        after: getWidgets("inventory_item.details.after"),
        before: getWidgets("inventory_item.details.before"),
        sideAfter: getWidgets("inventory_item.details.side.after"),
        sideBefore: getWidgets("inventory_item.details.side.before")
      },
      data: inventory_item,
      showJSON: true,
      showMetadata: true,
      children: [
        /* @__PURE__ */ jsxs5(TwoColumnPage.Main, { children: [
          /* @__PURE__ */ jsx12(InventoryItemGeneralSection, { inventoryItem: inventory_item }),
          /* @__PURE__ */ jsx12(InventoryItemLocationLevelsSection, { inventoryItem: inventory_item }),
          /* @__PURE__ */ jsx12(InventoryItemReservationsSection, { inventoryItem: inventory_item })
        ] }),
        /* @__PURE__ */ jsxs5(TwoColumnPage.Sidebar, { children: [
          /* @__PURE__ */ jsx12(
            InventoryItemVariantsSection,
            {
              variants: inventory_item.variants
            }
          ),
          /* @__PURE__ */ jsx12(InventoryItemAttributeSection, { inventoryItem: inventory_item })
        ] })
      ]
    }
  );
};

// src/routes/inventory/inventory-detail/loader.ts
var inventoryDetailQueryParams = {
  fields: INVENTORY_DETAIL_FIELDS
};
var inventoryDetailQuery = (id) => ({
  queryKey: inventoryItemsQueryKeys.detail(id, inventoryDetailQueryParams),
  queryFn: async () => sdk.admin.inventoryItem.retrieve(id, inventoryDetailQueryParams)
});
var inventoryItemLoader = async ({ params }) => {
  const id = params.id;
  const query = inventoryDetailQuery(id);
  return queryClient.ensureQueryData(query);
};
export {
  InventoryDetailBreadcrumb as Breadcrumb,
  InventoryDetail as Component,
  inventoryItemLoader as loader
};
