import { BehaviorSubject, Observable } from 'rxjs'; import { BasketEntry, Recipe } from '../_models'; import { EventTrace } from '../_types/event-trace'; import { AnalyticsService } from './analytics.service'; import { BasketsSynchronizerService } from './baskets-synchronizing'; import { BasketsService } from './baskets.service'; import { LoadLitDrawerService } from './load-lit-drawer.service'; import { PriceService } from './price.service'; import { RecipesService } from './recipes.service'; import * as i0 from "@angular/core"; export interface RecipeInBasketPreview { id: string; title: string; picture: string; guests: number; nbrProducts: number; totalPrice: number; 'price-per-serve': number; } export interface RecipesWithEntries { recipe: Recipe; entries: BasketEntry[]; } export interface BasketPreviewState { isOpen: boolean; activeTabIndex?: number; } export declare class BasketUtilsService { private basketsService; private recipesService; private priceService; private basketSynchroService; private analyticsService; private loadLitDrawerService; private readonly removeRecipeJobs$; constructor(basketsService: BasketsService, recipesService: RecipesService, priceService: PriceService, basketSynchroService: BasketsSynchronizerService, analyticsService: AnalyticsService, loadLitDrawerService: LoadLitDrawerService); recipesWithEntries: RecipesWithEntries[]; basketPreviewState$: BehaviorSubject; /** * Builds a preview of recipes in the basket, including their total price and total number of products per recipe. * This method fetches matching recipes and basket entries, computes the pricing and product count, and formats * the data for presentation. * @returns An Observable emitting an array of RecipeInBasketPreview objects, each representing a preview * of a recipe in the basket. */ buildPreview(): Observable; openBasket(analyticsPath?: string, selectedTab?: number): void; removeRecipe(recipeId: string, analyticsPath: string): Observable; private removeRecipeInternal; removeProduct(basketEntry: BasketEntry, eventTrace: EventTrace): void; updateProduct(basketEntry: BasketEntry, quantity: number, eventTrace: EventTrace): void; private buildRemoveProducts; private buildRemoveActions; private fetchDataToRemoveRecipe; private removeRecipeFromBasket; /** * Formats the given recipes and their associated basket entries into a structured preview suitable for display. * This internal method sorts recipes by their IDs, calculates the total price and product count for each recipe, * and formats the output as RecipeInBasketPreview objects. * @param builtRecipes An array of objects, each combining a Recipe with its associated BasketEntry items. * @returns An Observable emitting an array of RecipeInBasketPreview objects, formatted and ready for display. */ private formatPreview; /** * Matches each recipe with its corresponding basket entries based on the recipe IDs. * This method fetches all relevant recipes and basket entries, then correlates each recipe with the entries * that belong to it, preparing the data for further processing and preview generation. * @returns An Observable emitting an array of objects, each containing a Recipe and its associated BasketEntry items. */ private matchRecipesWithBasketEntries; static ɵfac: i0.ɵɵFactoryDef; static ɵprov: i0.ɵɵInjectableDef; } //# sourceMappingURL=basket-utils.service.d.ts.map