// src/lib/inventory-preview.ts
var getOfferRestockPreview = (item, quantity) => {
  if (!item || quantity <= 0) {
    return [];
  }
  const links = item.offer?.inventory_item_link ?? [];
  if (!links.length) {
    return [];
  }
  return links.map((link) => {
    const inventoryItemId = link.inventory_item?.id ?? link.inventory_item_id ?? null;
    if (!inventoryItemId) {
      return null;
    }
    const required = link.required_quantity ?? 1;
    if (required <= 0) {
      return null;
    }
    const label = link.inventory_item?.title || link.inventory_item?.sku || inventoryItemId;
    return {
      inventoryItemId,
      inventoryItemLabel: label,
      delta: quantity * required
    };
  }).filter((row) => row !== null);
};

export {
  getOfferRestockPreview
};
