private function buildDiscountLineItems(PromotionEntity $promotion, Cart $cart, SalesChannelContext $context): array
    {
        /** @var PromotionDiscountCollection|null $collection */
        $collection = $promotion->getDiscounts();

        if (!$collection instanceof PromotionDiscountCollection) {
            return [];
        }

        $lineItems = [];

        /** @var PromotionDiscountEntity $discount */
        foreach ($collection->getElements() as $discount) {
            // skip if already added! we do not update existing items!
            // depending on our recalculation mode, all promotion items have been removed anyway by now.
            // in recalculation mode, we only add NEW items...and not edit existing ones!
            if ($cart->has($discount->getId())) {
                continue;
            }

            $itemIDs = [];

            // check what type of discount we have.
            // with this, we know how we have to apply our discount.
            // either add discount line items with filter rules
            // or reduce shipping costs, and so on...
            switch ($discount->getScope()) {
                case PromotionDiscountEntity::SCOPE_CART:
                    $itemIDs = $this->itemCollector->getAllLineItemIDs($cart);
                    break;
            }

            // add a new discount line item for this discount
            // if we have at least one valid item that will be discounted.
            if (count($itemIDs) > 0) {
                /* @var LineItem $discountItem */
                $discountItem = $this->itemBuilder->buildDiscountLineItem(
                    $promotion,
                    $discount,
                    $context->getContext()->getCurrencyPrecision()
                );

                $lineItems[] = $discountItem;
            }
        }

        return $lineItems;
    }