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AAE,MAAOrR,GACPjE,GAAW,oCAAqCqD,OAAOY,GACzD,EAGFsR,EAAAA,EAAAA,GAAWR,GAAaF,QACtBb,EAAAA,GAAAA,KAACI,EAAAA,EAAc,CAACC,OAAQ1U,GAAWkU,UACjCG,EAAAA,GAAAA,KAACM,EAAAA,EAAa,CAACC,SAAU,GAAG7U,GAAAA,cAAoBmU,UAC9CG,EAAAA,GAAAA,KAACwB,EAAAA,EAAsB,CACrBlO,WAAYA,EACZmO,aAAa,GAAE5B,UAEfG,EAAAA,GAAAA,KAACQ,GAAG,IAAKU,UAIhB,C","sources":["webpack://oribasketprovider/../../src/index.ts","webpack://oribasketprovider/../../../src/constants/index.ts","webpack://oribasketprovider/../../../src/types/RequestUrl.ts","webpack://oribasketprovider/../../../src/utils/convertToCamelCase.ts","webpack://oribasketprovider/../../../src/types/HttpHeader.ts","webpack://oribasketprovider/../../../src/types/ContentType.ts","webpack://oribasketprovider/../../../src/utils/getHttpRequestSettings.ts","webpack://oribasketprovider/../../../src/utils/addBasketOffer.ts","webpack://oribasketprovider/../../src/constants-generated.ts","webpack://oribasketprovider/../../src/logger.ts","webpack://oribasketprovider/../../../src/utils/addToBasket.ts","webpack://oribasketprovider/../../../src/api/deleteOfferItem.ts","webpack://oribasketprovider/../../../src/handlers/deleteOfferItemHandler.ts","webpack://oribasketprovider/../../../src/constants/requestOptions.ts","webpack://oribasketprovider/../../../src/handlers/updateOfferItemHandler.ts","webpack://oribasketprovider/../../../src/constants/shoppingContextActions.ts","webpack://oribasketprovider/../../../src/handlers/acceptNotificationHandler.ts","webpack://oribasketprovider/../../../src/handlers/addBackorderDemandHandler.ts","webpack://oribasketprovider/../../../src/handlers/addBasketOfferHandler.ts","webpack://oribasketprovider/../../../src/handlers/addCatalogueOfferHandler.ts","webpack://oribasketprovider/../../../src/handlers/addCustomerOrderHandler.ts","webpack://oribasketprovider/../../../src/handlers/addFreeShippingOfferHandler.ts","webpack://oribasketprovider/../../../src/handlers/addPersonalNutritionItemsHandler.ts","webpack://oribasketprovider/../../../src/api/addPersonalNutritionItems.ts","webpack://oribasketprovider/../../../src/handlers/addToBasketHandler.ts","webpack://oribasketprovider/../../../src/utils/getBuyingUrlAndMethod.ts","webpack://oribasketprovider/../../../src/handlers/addVoucherHandler.ts","webpack://oribasketprovider/../../../src/handlers/cancelBackorderDemandHandler.ts","webpack://oribasketprovider/../../../src/handlers/cancelSubscriptionHandler.ts","webpack://oribasketprovider/../../../src/handlers/clearBasketHandler.ts","webpack://oribasketprovider/../../../src/handlers/delaySubscriptionHandler.ts","webpack://oribasketprovider/../../../src/handlers/checkLoyaltyDialogResultAndAddToBasketHandler.ts","webpack://oribasketprovider/../../../src/handlers/removeBasketItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/removeCustomerOrderHandler.ts","webpack://oribasketprovider/../../../src/handlers/removeVoucherHandler.ts","webpack://oribasketprovider/../../../src/handlers/replaceShoppingBagItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/replaceSubscriptionHandler.ts","webpack://oribasketprovider/../../../src/api/replaceSubscription.ts","webpack://oribasketprovider/../../../src/handlers/requestShoppingContextHandler.ts","webpack://oribasketprovider/../../../src/handlers/resetShippingSelectionHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateBasketItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateCustomerOrderItemHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateDeliveryHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateDeliveryChannelHandler.ts","webpack://oribasketprovider/../../../src/handlers/updateDonationHandler.ts","webpack://oribasketprovider/../../../src/api/updateOfferItem.ts","webpack://oribasketprovider/../../../src/handlers/updateOfferItemsHandler.ts","webpack://oribasketprovider/../../../src/handlers/updatePaymentProviderHandler.ts","webpack://oribasketprovider/../../../src/types/ClientAppConfig.ts","webpack://oribasketprovider/../../../src/contexts/ConfigurationContext.ts","webpack://oribasketprovider/../../../src/types/StorageType.ts","webpack://oribasketprovider/../../../src/utils/dispatchBasketUpdatedEvent.ts","webpack://oribasketprovider/../../../src/utils/logReceivedEvent.ts","webpack://oribasketprovider/../../../src/utils/cookies.ts","webpack://oribasketprovider/../../../src/utils/getUserCheck.ts","webpack://oribasketprovider/../../../src/utils/hashes.ts","webpack://oribasketprovider/../../../src/utils/isValidStorageTimestamp.ts","webpack://oribasketprovider/../../../src/utils/storageImplIndexedDb.ts","webpack://oribasketprovider/../../../src/utils/storageImplLocal.ts","webpack://oribasketprovider/../../../src/utils/clearCachePages.ts","webpack://oribasketprovider/../../../src/hooks/useBasketProviderData.ts","webpack://oribasketprovider/../../../src/utils/getUseIndexedDbFeatureToggle.ts","webpack://oribasketprovider/../../../src/utils/storage.ts","webpack://oribasketprovider/../../../src/components/BasketProvider.ts","webpack://oribasketprovider/../../../src/containers/ApiProvider.tsx","webpack://oribasketprovider/../../../src/containers/BasketProviderController.tsx","webpack://oribasketprovider/./src/App.tsx","webpack://oribasketprovider/./src/logger.ts","webpack://oribasketprovider/./src/appRender.tsx"],"sourcesContent":["import type { Data } from './Data';\n\nexport { Results as LastAddedItemMethod } from '@ori-events/loyalty-dialog-result';\n\nexport type {\n BasketOffer,\n BasketOfferBenefit,\n BasketOfferConcept,\n BasketOfferConceptBenefit,\n BasketOfferItem,\n BasketOfferProduct,\n BasketOfferPurchase,\n} from './BasketOffer';\nexport { BasketOfferTypes } from './BasketOffer';\n\nexport type { GodModeOutput, GodModeOutputItem } from './GodModeOutput';\n\nexport type { LastAddedItem } from './LastAddedItem';\n\nexport type { Referral } from './Referral';\n\nexport type {\n ShoppingBag,\n ShoppingBagBalance,\n ShoppingBagDiscount,\n ShoppingBagSubscriptions,\n ShoppingBagSubscriptionsPackages,\n ShoppingBagVipLoyalty,\n} from './ShoppingBag';\n\nexport type {\n DiscountMessage,\n OriginalProduct,\n Replacement,\n ReplacementItem,\n ShoppingBagItem,\n ShoppingBagItemProductFlag,\n} from './ShoppingBagItem';\n\nexport type { ShoppingBagOffer } from './ShoppingBagOffer';\n\nexport type { ShoppingMessage, ProgressBarItems } from './ShoppingMessage';\n\nexport type { ShoppingNotification } from './ShoppingNotification';\nexport { ShoppingNotificationType } from './ShoppingNotification';\n\nexport type {\n EndConsumerOrderItem,\n PendingEndConsumerOrder,\n ShippingOffer,\n SliderModel,\n UnitDataCollection,\n UnitDataCollectionBeautyConsultant,\n UnitDataCollectionCommon,\n UnitDataCollectionDelivery,\n UnitDataCollectionDonationUnit,\n UnitDataCollectionEndConsumerPendingOrder,\n UnitDataCollectionOffer,\n UnitDataCollectionPreOrderTargetUnit,\n UnitDataCollectionSectionUnit,\n UnitDataCollectionSpecialOffer,\n UnitDataCollectionVouchers,\n UnitDataCollectionWellnessSelling,\n UnitDataOffer,\n UnitDataOfferItem,\n} from './UnitDataCollection';\n\nexport const Test = 'TEST';\nexport const Name = 'basket-updated';\ntype EventName = typeof Name;\n\nexport const BasketUpdatedEvent: EventName = Name;\nexport type { Data };\n\nexport interface Event extends CustomEvent {\n type: EventName;\n}\n\nexport default Event;\n\ndeclare global {\n interface WindowEventMap {\n [Name]: Event;\n }\n}\n","export * from '../constants-generated';\n\n/** Storage key under which the shopping context data gets stored. */\nexport const CONTEXT_KEY = 'shoppingContext';\n\n/** Local storage data will be cleaned on next reload when older than this timeout (currently 5 minutes in ms). */\nexport const DATA_CACHE_TIMEOUT = 300000;\n\n/** In some situations, we mark the local cache to be cleaned after page reload with this flag. */\nexport const SCHEDULED_CLEANUP_KEY = `basket-provider cache cleanup`;\n\n/** User cookie helps identifying the current shopping session. */\nexport const USER_COOKIE_NAME = 'ShoppingKey';\n\n/** GUID of the UseIndexedDb feature toggle. */\nexport const USE_INDEXED_DB_FT_GUID = '121C4156-31A6-4259-BCEC-954302CA7659';\n\n/**\n * Experimental delay before the shopping-context-loaded event gets triggered.\n * This is here to fix problems in automated UI tests, if possible.\n */\nexport const POST_INIT_EVENT_DELAY = 200;\n","export enum RequestUrl {\n AcceptNotification = '/system/ajax/Message/AcceptFailMessage',\n AddBackorderDemand = '/system/ajax/ShoppingBag/AddBackorderDemand',\n AddBasketOffer = '/system/ajax/Offer/ApplyBasketOffer',\n AddCatalogueOffer = '/system/ajax/Offer/ApplyCatalogueOffer',\n AddCustomerOrder = '/system/ajax/EndConsumerOrder/ApproveOrders',\n AddFreeShippingOffer = '/system/ajax/Delivery/AddFreeShippingItem',\n AddToBasketCheckLoyalty = '/system/ajax/ShoppingBag/AddToShoppingBagItemAndCheckLoyalty',\n AddToBasketForMoney = '/system/ajax/ShoppingBag/AddOrUpdateShoppingBagItem',\n AddToBasketForPoints = '/system/ajax/Offer/AddOfferItem',\n AddToBasketForPointsRewardShop = '/system/ajax/Offer/RedeemLoyaltyPoints',\n AddVoucher = '/system/ajax/ShoppingBag/AddVoucher',\n CancelBackorderDemand = '/system/ajax/ShoppingBag/CancelBackorderDemand',\n CancelSubscription = '/system/ajax/ShoppingBag/CancelSubscription',\n ClearBasket = '/system/ajax/ShoppingBag/RemoveAllShoppingBagItems',\n DelaySubscription = '/system/ajax/ShoppingBag/DelaySubscription',\n GetShoppingContext = '/system/ajax/ShoppingBag/GetShoppingContext',\n PurchaseBasketOffer = '/system/ajax/Offer/PurchaseBasketOffer',\n RemoveBasketItem = '/system/ajax/ShoppingBag/RemoveShoppingBagItem',\n RemoveCustomerOrder = '/system/ajax/EndConsumerOrder/UnapproveOrder',\n RemoveVoucher = '/system/ajax/ShoppingBag/RemoveVoucher',\n ReplaceShoppingBagItem = '/system/ajax/ShoppingBag/ReplaceShoppingBagItem',\n ResetFreeShippingSelection = '/system/ajax/Delivery/ResetFreeShippingSelection',\n UpdateBasketItem = '/system/ajax/ShoppingBag/UpdateShoppingBagItem',\n UpdateCustomerOrderItem = '/system/ajax/EndConsumerOrder/UpdateEndConsumerOrderItem',\n UpdateDeliveryAddress = '/system/ajax/DeliverySelection/UpdateDeliveryAddress',\n UpdateDeliveryChannel = '/system/ajax/DeliverySelection/UpdateDeliveryChannel',\n UpdateDonation = '/system/ajax/Donation/UpdateDonation',\n UpdateOfferItem = '/system/ajax/Offer/UpdateOfferItem',\n UpdateOfferItems = '/system/ajax/Offer/UpdateOfferItems',\n UpdatePaymentProvider = '/system/ajax/Payment/UpdatePaymentProvider',\n}\n","import camelCase from 'lodash.camelcase';\n\ntype CamelCaseObjectDeepType = (object?: unknown) => T;\n\nexport const convertToCamelCase: CamelCaseObjectDeepType = (object?: unknown) => {\n if (Array.isArray(object)) {\n return object.map(convertToCamelCase) as unknown as T;\n }\n\n if (typeof object === 'object' && object !== null && object.constructor === Object) {\n return Object.fromEntries(\n Object.entries(object).map(([key, value]) => [camelCase(key), convertToCamelCase(value)]),\n ) as unknown as T;\n }\n\n return object as T;\n};\n","// TODO -- Move to checkout-utils\nexport enum HttpHeader {\n ContentType = 'Content-Type',\n Placement = 'x-placement',\n}\n","// TODO -- Move to checkout-utils\nexport enum ContentType {\n Json = 'application/json',\n}\n","import type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { ContentType, HttpHeader } from '../types';\n\nexport const getHttpRequestSettings: (data?: T, method?: HttpMethod) => RequestInit = (\n data,\n method = HttpMethod.Get,\n) => {\n const headers: HeadersInit = {\n [HttpHeader.ContentType]: ContentType.Json,\n };\n let body: BodyInit | undefined;\n if (data) {\n const { placement, ...finalData } = data;\n if (placement) {\n headers[HttpHeader.Placement] = placement;\n }\n const bodyValue = JSON.stringify(finalData);\n body = bodyValue === '{}' ? undefined : bodyValue;\n }\n\n return {\n credentials: 'same-origin',\n headers,\n method,\n ...(method === HttpMethod.Post && Boolean(body) && { body }),\n };\n};\n","import type { BasketOfferItem } from '@ori-events/add-basket-offer';\nimport * as AddBasketOfferFailed from '@ori-events/add-basket-offer-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport type { RequestUrl } from '../types';\nimport { convertToCamelCase } from './convertToCamelCase';\nimport { getHttpRequestSettings } from './getHttpRequestSettings';\n\ntype AddBasketOfferApplyParams = PositionData & {\n offerId: number;\n};\n\ntype AddBasketOfferPurchaseParams = PositionData & {\n choiceId: number;\n items: BasketOfferItem[];\n};\n\nexport async function addBasketOffer(\n url: RequestUrl.AddBasketOffer | RequestUrl.PurchaseBasketOffer,\n params: AddBasketOfferApplyParams | AddBasketOfferPurchaseParams,\n) {\n const response = await fetch(url, getHttpRequestSettings(params, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddBasketOfferFailed.isAddBasketOfferErrorResponse(data)) {\n const event = new CustomEvent(AddBasketOfferFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n return data;\n}\n","/* istanbul ignore file */\n//\n// DO NOT EDIT!\n// This file was autogenerated by Eddie.\n// Changes may cause incorrect behavior and will be lost when the file is regenerated.\n//\n// Run `npx eddie update workspace` to regenerate.\n//\n\nexport const APP_NAME = 'basket-provider-lib';\nexport const PACKAGE_NAME = '@ori/basket-provider-lib';\nexport const TEAM_NAME = 'Checkout';\n\nexport const EMOTION_CACHE_KEY = `${APP_NAME}-emotion-cache-key`;\n\nexport const APP_ROOT_ELEMENT_ID = `${APP_NAME}-root`;\n","import { getDebugLogger, getWarningLogger } from '@ori/checkout-utils';\nimport { Logger } from '@ori/logger';\n\nimport { APP_NAME, PACKAGE_NAME, TEAM_NAME } from './constants';\n\nexport const mainLogger = new Logger(PACKAGE_NAME, { teamName: TEAM_NAME });\n\nexport const logDebug = getDebugLogger(APP_NAME);\nexport const logWarning = getWarningLogger(APP_NAME);\n","import type * as AddToBasket from '@ori-events/add-to-basket';\nimport * as AddToBasketFailed from '@ori-events/add-to-basket-failed';\nimport * as ShowLoyaltyDialog from '@ori-events/show-loyalty-dialog';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { logWarning } from '../logger';\nimport { convertToCamelCase } from './convertToCamelCase';\nimport { getHttpRequestSettings } from './getHttpRequestSettings';\n\nexport type AddToBasketParams = AddToBasket.Data &\n PositionData & {\n choiceId?: number | null;\n catalogueItemId?: string;\n };\n\nexport const MISSING_PLACEMENT_MESSAGE = `Missing 'placement' property in add-to-basket action data will impact reporting, please contact your SE.`;\n\nexport async function addToBasket(url: string, params: AddToBasketParams, buyingMethod: AddToBasket.Method) {\n const { itemCode, placement, quantity } = params;\n if (!placement) {\n logWarning(MISSING_PLACEMENT_MESSAGE);\n }\n const response = await fetch(url, getHttpRequestSettings(params, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddToBasketFailed.isAddToBasketErrorResponse(data)) {\n const event = new CustomEvent(AddToBasketFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n if (AddToBasketFailed.isAddToBasketLoyaltyResponse(data)) {\n const event = new CustomEvent(ShowLoyaltyDialog.Name, {\n detail: {\n ...data,\n itemCode,\n placement,\n quantity,\n },\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n return {\n ...data,\n lastAddedItem: {\n itemCode,\n method: buyingMethod,\n quantity,\n },\n };\n}\n","import {\n deleteShoppingSessionOfferChoice,\n type DeleteShoppingSessionOfferChoiceHeaders,\n} from '@ori/global-api-client-react';\n\nimport type { HandlerSettings } from '../types';\n\ntype DeleteOfferItemHandlerSettings = Pick;\n\nexport type DeleteOfferItemParams = DeleteOfferItemHandlerSettings & {\n itemCode: string;\n offerId: number;\n tenant: string;\n};\n\nexport async function deleteOfferItem({ client, itemCode, offerId, sessionId, tenant }: DeleteOfferItemParams) {\n // TODO -- Is this needed when there is the tenant prop of ApiProvider applied on some upper level?\n const headers: DeleteShoppingSessionOfferChoiceHeaders = {\n 'x-tenant-context': tenant,\n };\n\n return deleteShoppingSessionOfferChoice(client, sessionId, offerId, itemCode, headers);\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as DeleteOfferItem from '@ori-events/delete-offer-item';\nimport { isDeleteOfferItemErrorResponse, Name as ErrorEventName } from '@ori-events/delete-offer-item-failed';\nimport type { Data as ErrorData } from '@ori-events/delete-offer-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { deleteOfferItem } from '../api';\nimport { mainLogger } from '../logger';\nimport { RequestUrl, type HandlerSettings } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & DeleteOfferItem.Data;\n\nconst dispatchErrorEvent = (detail: ErrorData) => {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail,\n });\n window.dispatchEvent(errorEvent);\n};\n\nexport async function deleteOfferItemHandler(\n { detail: { choiceId, itemCode } }: CustomEvent,\n { client, sessionId, tenant }: HandlerSettings,\n) {\n // STEP 1 - Update through API\n try {\n await deleteOfferItem({\n client,\n itemCode,\n offerId: choiceId,\n sessionId,\n tenant,\n });\n } catch (error: unknown) {\n mainLogger.error(error as Error, { message: 'Error while deleting offer item in delete-offer-item event.' });\n dispatchErrorEvent({\n isSuccess: false,\n localizedMessage: '',\n message: 'Deletion of offer item failed via API call',\n });\n\n return false;\n }\n\n // STEP 2 - Update shopping context via Online endpoint\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isDeleteOfferItemErrorResponse(data)) {\n dispatchErrorEvent(data);\n\n return false;\n }\n\n return data;\n}\n","// TODO -- common header names & values to checkout-utils\nexport const putRequestOptions = {\n // eslint-disable-next-line @typescript-eslint/naming-convention -- predefined HTTP header name\n headers: { 'Content-Type': 'application/json' },\n method: 'PUT',\n};\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as UpdateOfferItem from '@ori-events/update-offer-item';\nimport { isUpdateOfferItemFailedResponse, Name as ErrorEventName } from '@ori-events/update-offer-item-failed';\nimport type { Data as ErrorData } from '@ori-events/update-offer-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { updateOfferItem } from '../api';\nimport { mainLogger } from '../logger';\nimport { RequestUrl, type HandlerSettings } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateOfferItem.Data;\n\nconst dispatchErrorEvent = (detail: ErrorData) => {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail,\n });\n window.dispatchEvent(errorEvent);\n};\n\nexport async function updateOfferItemHandler(\n { detail: { choiceId, itemCode, quantity } }: CustomEvent,\n { client, sessionId, tenant }: HandlerSettings,\n) {\n // STEP 1 - Update through API\n try {\n await updateOfferItem({\n client,\n itemCode,\n offerId: choiceId,\n quantity,\n sessionId,\n tenant,\n });\n } catch (error: unknown) {\n mainLogger.error(error as Error, { message: 'Error while updating offer item in update-offer-item event.' });\n dispatchErrorEvent({\n isSuccess: false,\n localizedMessage: '',\n message: 'Updating of offer item failed via API call',\n });\n\n return false;\n }\n\n // STEP 2 - Update shopping context via Online endpoint\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateOfferItemFailedResponse(data)) {\n dispatchErrorEvent(data);\n\n return false;\n }\n\n return data;\n}\n","import * as AcceptNotification from '@ori-events/accept-notification';\nimport * as AcceptNotificationFailed from '@ori-events/accept-notification-failed';\nimport * as AddBackorderDemand from '@ori-events/add-backorder-demand';\nimport * as AddBackorderDemandFailed from '@ori-events/add-backorder-demand-failed';\nimport * as AddBasketOffer from '@ori-events/add-basket-offer';\nimport * as AddBasketOfferFailed from '@ori-events/add-basket-offer-failed';\nimport * as AddCatalogueOffer from '@ori-events/add-catalogue-offer';\nimport * as AddCatalogueOfferFailed from '@ori-events/add-catalogue-offer-failed';\nimport * as AddCustomerOrder from '@ori-events/add-customer-order';\nimport * as AddCustomerOrderFailed from '@ori-events/add-customer-order-failed';\nimport * as AddFreeShippingOffer from '@ori-events/add-free-shipping-offer';\nimport * as AddFreeShippingOfferFailed from '@ori-events/add-free-shipping-offer-failed';\nimport * as AddPersonalNutritionItems from '@ori-events/add-personal-nutrition-items';\nimport * as AddPersonalNutritionItemsFailed from '@ori-events/add-personal-nutrition-items-failed';\nimport * as AddToBasket from '@ori-events/add-to-basket';\nimport * as AddToBasketFailed from '@ori-events/add-to-basket-failed';\nimport * as AddVoucher from '@ori-events/add-voucher';\nimport * as AddVoucherFailed from '@ori-events/add-voucher-failed';\nimport * as CancelBackorderDemand from '@ori-events/cancel-backorder-demand';\nimport * as CancelSubscription from '@ori-events/cancel-subscription';\nimport * as CancelSubscriptionFailed from '@ori-events/cancel-subscription-failed';\nimport * as ClearBasket from '@ori-events/clear-basket';\nimport * as DelaySubscription from '@ori-events/delay-subscription';\nimport * as DelaySubscriptionFailed from '@ori-events/delay-subscription-failed';\nimport * as DeleteOfferItem from '@ori-events/delete-offer-item';\nimport * as DeleteOfferItemFailed from '@ori-events/delete-offer-item-failed';\nimport * as LoyaltyDialogResult from '@ori-events/loyalty-dialog-result';\nimport * as RemoveBasketItem from '@ori-events/remove-basket-item';\nimport * as RemoveBasketItemFailed from '@ori-events/remove-basket-item-failed';\nimport * as RemoveCustomerOrder from '@ori-events/remove-customer-order';\nimport * as RemoveCustomerOrderFailed from '@ori-events/remove-customer-order-failed';\nimport * as RemoveVoucher from '@ori-events/remove-voucher';\nimport * as RemoveVoucherFailed from '@ori-events/remove-voucher-failed';\nimport * as ReplaceShoppingBagItem from '@ori-events/replace-shopping-bag-item';\nimport * as ReplaceShoppingBagItemFailed from '@ori-events/replace-shopping-bag-item-failed';\nimport * as ReplaceSubscription from '@ori-events/replace-subscription';\nimport * as ReplaceSubscriptionFailed from '@ori-events/replace-subscription-failed';\nimport * as RequestShoppingContext from '@ori-events/request-shopping-context';\nimport * as ResetShippingSelection from '@ori-events/reset-shipping-selection';\nimport * as ShoppingContextLoaded from '@ori-events/shopping-context-loaded';\nimport * as UpdateBasketItem from '@ori-events/update-basket-item';\nimport * as UpdateBasketItemFailed from '@ori-events/update-basket-item-failed';\nimport * as UpdateCustomerOrderItem from '@ori-events/update-customer-order-item';\nimport * as UpdateCustomerOrderItemFailed from '@ori-events/update-customer-order-item-failed';\nimport * as UpdateDelivery from '@ori-events/update-delivery';\nimport * as UpdateDeliveryChannel from '@ori-events/update-delivery-channel';\nimport * as UpdateDeliveryChannelFailed from '@ori-events/update-delivery-channel-failed';\nimport * as UpdateDeliveryFailed from '@ori-events/update-delivery-failed';\nimport * as UpdateDonation from '@ori-events/update-donation';\nimport * as UpdateDonationFailed from '@ori-events/update-donation-failed';\nimport * as UpdateOfferItem from '@ori-events/update-offer-item';\nimport * as UpdateOfferItemFailed from '@ori-events/update-offer-item-failed';\nimport * as UpdateOfferItems from '@ori-events/update-offer-items';\nimport * as UpdatePaymentProvider from '@ori-events/update-payment-provider';\nimport * as UpdatePaymentProviderFailed from '@ori-events/update-payment-provider-failed';\n\nimport {\n acceptNotificationHandler,\n addBackorderDemandHandler,\n addBasketOfferHandler,\n addCatalogueOfferHandler,\n addCustomerOrderHandler,\n addFreeShippingOfferHandler,\n addPersonalNutritionItemsHandler,\n addToBasketHandler,\n addVoucherHandler,\n cancelBackorderDemandHandler,\n cancelSubscriptionHandler,\n checkLoyaltyDialogResultAndAddToBasketHandler,\n clearBasketHandler,\n delaySubscriptionHandler,\n deleteOfferItemHandler,\n removeBasketItemHandler,\n removeCustomerOrderHandler,\n removeVoucherHandler,\n replaceShoppingBagItemHandler,\n replaceSubscriptionHandler,\n requestShoppingContextHandler,\n resetShippingSelectionHandler,\n updateBasketItemHandler,\n updateCustomerOrderItemHandler,\n updateDeliveryHandler,\n updateDeliveryChannelHandler,\n updateDonationHandler,\n updateOfferItemHandler,\n updateOfferItemsHandler,\n updatePaymentProviderHandler,\n} from '../handlers';\nimport type { ShoppingContextActionInfo, TriggerActionEventName } from '../types';\n\n/**\n * Configuration of shopping context actions. Mapping of triggering events to response\n * success & failed events and event handlers for the responses.\n */\nexport const shoppingContextActions = new Map([\n [AcceptNotification.Name, { failedEvent: AcceptNotificationFailed.Name, handler: acceptNotificationHandler }],\n [AddBackorderDemand.Name, { failedEvent: AddBackorderDemandFailed.Name, handler: addBackorderDemandHandler }],\n [AddBasketOffer.Name, { failedEvent: AddBasketOfferFailed.Name, handler: addBasketOfferHandler }],\n [AddCatalogueOffer.Name, { failedEvent: AddCatalogueOfferFailed.Name, handler: addCatalogueOfferHandler }],\n [AddCustomerOrder.Name, { failedEvent: AddCustomerOrderFailed.Name, handler: addCustomerOrderHandler }],\n [AddFreeShippingOffer.Name, { failedEvent: AddFreeShippingOfferFailed.Name, handler: addFreeShippingOfferHandler }],\n [\n AddPersonalNutritionItems.Name,\n { failedEvent: AddPersonalNutritionItemsFailed.Name, handler: addPersonalNutritionItemsHandler },\n ],\n [AddToBasket.Name, { failedEvent: AddToBasketFailed.Name, handler: addToBasketHandler }],\n [AddVoucher.Name, { failedEvent: AddVoucherFailed.Name, handler: addVoucherHandler }],\n // TODO -- no failed event available so far for CancelBackorderDemand\n [CancelBackorderDemand.Name, { handler: cancelBackorderDemandHandler }],\n [CancelSubscription.Name, { failedEvent: CancelSubscriptionFailed.Name, handler: cancelSubscriptionHandler }],\n // TODO -- no failed event available so far for ClearBasket\n [ClearBasket.Name, { handler: clearBasketHandler }],\n [DelaySubscription.Name, { failedEvent: DelaySubscriptionFailed.Name, handler: delaySubscriptionHandler }],\n [DeleteOfferItem.Name, { failedEvent: DeleteOfferItemFailed.Name, handler: deleteOfferItemHandler }],\n // TODO -- solve better the possible cases for LoyaltyDialogResult - maybe add-to-basket-failed,\n // and don't set up the loading state when just closed dialog (so exception to check for this case)\n [LoyaltyDialogResult.Name, { handler: checkLoyaltyDialogResultAndAddToBasketHandler }],\n [RemoveBasketItem.Name, { failedEvent: RemoveBasketItemFailed.Name, handler: removeBasketItemHandler }],\n [RemoveCustomerOrder.Name, { failedEvent: RemoveCustomerOrderFailed.Name, handler: removeCustomerOrderHandler }],\n [RemoveVoucher.Name, { failedEvent: RemoveVoucherFailed.Name, handler: removeVoucherHandler }],\n [\n ReplaceShoppingBagItem.Name,\n { failedEvent: ReplaceShoppingBagItemFailed.Name, handler: replaceShoppingBagItemHandler },\n ],\n [ReplaceSubscription.Name, { failedEvent: ReplaceSubscriptionFailed.Name, handler: replaceSubscriptionHandler }],\n [RequestShoppingContext.Name, { successEvent: ShoppingContextLoaded.Name, handler: requestShoppingContextHandler }],\n // TODO -- no failed event available so far for ResetShippingSelection\n [ResetShippingSelection.Name, { handler: resetShippingSelectionHandler }],\n [UpdateBasketItem.Name, { failedEvent: UpdateBasketItemFailed.Name, handler: updateBasketItemHandler }],\n [\n UpdateCustomerOrderItem.Name,\n { failedEvent: UpdateCustomerOrderItemFailed.Name, handler: updateCustomerOrderItemHandler },\n ],\n [UpdateDelivery.Name, { failedEvent: UpdateDeliveryFailed.Name, handler: updateDeliveryHandler }],\n [\n UpdateDeliveryChannel.Name,\n { failedEvent: UpdateDeliveryChannelFailed.Name, handler: updateDeliveryChannelHandler },\n ],\n [UpdateDonation.Name, { failedEvent: UpdateDonationFailed.Name, handler: updateDonationHandler }],\n [UpdateOfferItem.Name, { failedEvent: UpdateOfferItemFailed.Name, handler: updateOfferItemHandler }],\n // TODO -- no failed event available so far for UpdateOfferItems\n [UpdateOfferItems.Name, { handler: updateOfferItemsHandler }],\n [\n UpdatePaymentProvider.Name,\n { failedEvent: UpdatePaymentProviderFailed.Name, handler: updatePaymentProviderHandler },\n ],\n]);\n","import type * as AcceptNotification from '@ori-events/accept-notification';\nimport type { Data as ErrorData, AcceptNotificationResponse } from '@ori-events/accept-notification-failed';\nimport { isAcceptNotificationErrorResponse, Name as ErrorEventName } from '@ori-events/accept-notification-failed';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase } from '../utils';\n\nexport async function acceptNotificationHandler({ detail: { reasonId } }: CustomEvent) {\n const response = await fetch(`${RequestUrl.AcceptNotification}?reasonId=${reasonId}`);\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isAcceptNotificationErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as AddBackorderDemand from '@ori-events/add-backorder-demand';\nimport type { AddBackorderDemandResponse, Data as ErrorData } from '@ori-events/add-backorder-demand-failed';\nimport { isAddBackorderDemandErrorResponse, Name as ErrorEventName } from '@ori-events/add-backorder-demand-failed';\nimport type * as BasketUpdated from '@ori-events/basket-updated';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddBackorderDemand.Data & PositionData;\n\nexport async function addBackorderDemandHandler({ detail: { lineNumber, placement, quantity } }: CustomEvent) {\n if (typeof quantity === 'number' && quantity > 0) {\n const responseWithQuantity = await fetch(\n `${RequestUrl.UpdateBasketItem}?lineNumber=${lineNumber}&quantity=${quantity}`,\n getHttpRequestSettings({ placement }),\n );\n const dataWithQuantity = convertToCamelCase(\n (await responseWithQuantity.json()) as object,\n );\n\n if (isAddBackorderDemandErrorResponse(dataWithQuantity)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: dataWithQuantity,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n }\n\n const response = await fetch(`${RequestUrl.AddBackorderDemand}?lineNumber=${lineNumber}`, getHttpRequestSettings());\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isAddBackorderDemandErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as AddBasketOffer from '@ori-events/add-basket-offer';\nimport { isAddBasketOfferPurchaseEvent } from '@ori-events/add-basket-offer';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { addBasketOffer } from '../utils';\n\ntype Data = AddBasketOffer.Data & PositionData;\ntype PurchaseData = AddBasketOffer.AddBasketOfferPurchaseData & PositionData;\n\nexport async function addBasketOfferHandler(event: CustomEvent) {\n if (isAddBasketOfferPurchaseEvent(event)) {\n const {\n detail: { items, offerId: choiceId, placement },\n } = event as CustomEvent;\n\n return addBasketOffer(RequestUrl.PurchaseBasketOffer, {\n choiceId,\n items,\n placement,\n });\n }\n\n const {\n detail: { offerId, placement },\n } = event as CustomEvent;\n\n return addBasketOffer(RequestUrl.AddBasketOffer, {\n offerId,\n placement,\n });\n}\n","import type * as AddCatalogueOffer from '@ori-events/add-catalogue-offer';\nimport * as AddCatalogueOfferFailed from '@ori-events/add-catalogue-offer-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddCatalogueOffer.Data & PositionData;\n\nexport const dispatchAddCatalogueOfferFailedEvent = (detail: AddCatalogueOfferFailed.Data) => {\n const event = new CustomEvent(AddCatalogueOfferFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function addCatalogueOfferHandler({ detail: { offerId, placement } }: CustomEvent) {\n const request = await fetch(\n RequestUrl.AddCatalogueOffer,\n getHttpRequestSettings({ offerId, placement }, HttpMethod.Post),\n );\n\n const response = convertToCamelCase(\n (await request.json()) as object,\n );\n if (AddCatalogueOfferFailed.isAddCatalogueOfferErrorResponse(response)) {\n dispatchAddCatalogueOfferFailedEvent(response);\n\n return false;\n }\n\n return response;\n}\n","import type * as AddCustomerOrder from '@ori-events/add-customer-order';\nimport * as AddCustomerOrderFailed from '@ori-events/add-customer-order-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddCustomerOrder.Data & PositionData;\n\nexport async function addCustomerOrderHandler({ detail: { orderIds, placement } }: CustomEvent) {\n const url = new URL(RequestUrl.AddCustomerOrder, window.location.href);\n orderIds.forEach((id) => url.searchParams.append('orderIds', String(id)));\n\n const response = await fetch(url.toString(), getHttpRequestSettings({ placement }));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddCustomerOrderFailed.isAddCustomerOrderErrorResponse(data)) {\n const errorEvent = new CustomEvent(AddCustomerOrderFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return {\n ...data,\n lastAddedCustomerOrderIds: orderIds,\n };\n}\n","import type * as AddFreeShippingOffer from '@ori-events/add-free-shipping-offer';\nimport * as AddFreeShippingOfferFailed from '@ori-events/add-free-shipping-offer-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddFreeShippingOffer.Data & PositionData;\n\nexport const dispatchAddFreeShippingOfferFailedEvent = (detail: AddFreeShippingOfferFailed.Data) => {\n const event = new CustomEvent(AddFreeShippingOfferFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function addFreeShippingOfferHandler({ detail: { itemCode, placement } }: CustomEvent) {\n const request = await fetch(\n RequestUrl.AddFreeShippingOffer,\n getHttpRequestSettings({ itemCode, placement }, HttpMethod.Post),\n );\n\n const response = convertToCamelCase(\n (await request.json()) as object,\n );\n if (AddFreeShippingOfferFailed.isAddFreeShippingOfferErrorResponse(response)) {\n dispatchAddFreeShippingOfferFailedEvent(response);\n\n return false;\n }\n\n return response;\n}\n","import type * as AddPersonalNutritionItems from '@ori-events/add-personal-nutrition-items';\nimport * as AddPersonalNutritionItemsFailed from '@ori-events/add-personal-nutrition-items-failed';\nimport type * as BasketUpdated from '@ori-events/basket-updated';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\nimport { type GlobalShoppingPersonalNutritionComponentsDto } from '@ori/global-api-client-react';\n\nimport { addPersonalNutritionItems } from '../api';\nimport { mainLogger } from '../logger';\nimport { RequestUrl } from '../types';\nimport type { HandlerSettings } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & AddPersonalNutritionItems.Data;\n\nexport async function addPersonalNutritionItemsHandler(\n { detail: { items } }: CustomEvent,\n { client, sessionId, tenant }: HandlerSettings,\n) {\n const globalShoppingPersonalNutritionComponentsDto: GlobalShoppingPersonalNutritionComponentsDto = {\n collection: items,\n };\n\n try {\n await addPersonalNutritionItems({\n client,\n globalShoppingPersonalNutritionComponentsDto,\n sessionId,\n tenant,\n });\n } catch (error: unknown) {\n mainLogger.error(error as Error, {\n message: 'Error while adding personal nutrition items in addPersonalNutritionItems event',\n });\n\n const errorEvent = new CustomEvent(AddPersonalNutritionItemsFailed.Name, {\n detail: {\n isSuccess: false,\n localizedMessage: String(error),\n message: String(error),\n },\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n // STEP 2 - Update shopping context via Online endpoint\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n const rawData = convertToCamelCase((await response.json()) as object);\n\n if (AddPersonalNutritionItemsFailed.isAddPersonalNutritionItemsErrorResponse(rawData)) {\n const errorEvent = new CustomEvent(AddPersonalNutritionItemsFailed.Name, {\n detail: rawData,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n const data = {\n ...rawData,\n isPersonalNutritionAddedAsLast: true,\n };\n\n return data;\n}\n","import {\n type GlobalShoppingPersonalNutritionComponentsDto,\n type UpdateShoppingSessionPersonalNutritionHeaders,\n updateShoppingSessionPersonalNutrition,\n} from '@ori/global-api-client-react';\n\nimport type { HandlerSettings } from '../types';\n\ntype AddPersonalNutritionItemsHandlerSettings = Pick;\n\nexport type AddPersonalNutritionItemsParams = AddPersonalNutritionItemsHandlerSettings & {\n globalShoppingPersonalNutritionComponentsDto: GlobalShoppingPersonalNutritionComponentsDto;\n sessionId: string;\n tenant: string;\n};\n\nexport async function addPersonalNutritionItems({\n client,\n globalShoppingPersonalNutritionComponentsDto,\n sessionId,\n tenant,\n}: AddPersonalNutritionItemsParams) {\n // TODO -- Is this needed when there is the tenant prop of ApiProvider applied on some upper level?\n const headers: UpdateShoppingSessionPersonalNutritionHeaders = {\n 'x-tenant-context': tenant,\n };\n\n return updateShoppingSessionPersonalNutrition(\n client,\n sessionId,\n globalShoppingPersonalNutritionComponentsDto,\n headers,\n );\n}\n","import type * as AddToBasket from '@ori-events/add-to-basket';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { addToBasket, getBuyingUrlAndMethod } from '../utils';\n\ntype Data = AddToBasket.Data & PositionData;\n\nexport async function addToBasketHandler({\n detail: { itemCode, quantity, originalItemCode, replacementType, method: addToBasketMethod, placement },\n}: CustomEvent) {\n const { url, method } = getBuyingUrlAndMethod(addToBasketMethod);\n\n return addToBasket(\n url,\n {\n itemCode,\n quantity,\n originalItemCode,\n replacementType,\n placement,\n },\n method,\n );\n}\n","import * as AddToBasket from '@ori-events/add-to-basket';\n\nimport { RequestUrl } from '../types';\n\ninterface BuyingUrlAndMethod {\n url: string;\n method: AddToBasket.Method;\n}\n\nexport function getBuyingUrlAndMethod(method?: AddToBasket.Method): BuyingUrlAndMethod {\n switch (method) {\n case AddToBasket.Method.BUY_FOR_MONEY:\n return {\n url: RequestUrl.AddToBasketForMoney,\n method: AddToBasket.Method.BUY_FOR_MONEY,\n };\n case AddToBasket.Method.BUY_FOR_POINTS:\n return {\n url: RequestUrl.AddToBasketForPointsRewardShop,\n method: AddToBasket.Method.BUY_FOR_POINTS,\n };\n default:\n return {\n url: RequestUrl.AddToBasketCheckLoyalty,\n method: AddToBasket.Method.BUY_FOR_MONEY,\n };\n }\n}\n","import type * as AddVoucher from '@ori-events/add-voucher';\nimport * as AddVoucherFailed from '@ori-events/add-voucher-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = AddVoucher.Data & PositionData;\n\nconst dispatchAddVoucherFailed = (detail: AddVoucherFailed.Data) => {\n const event = new CustomEvent(AddVoucherFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function addVoucherHandler({ detail: { placement, voucherCode } }: CustomEvent) {\n const fetchUrl = `${RequestUrl.AddVoucher}?voucherCode=${voucherCode}`;\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (AddVoucherFailed.isAddVoucherErrorResponse(data)) {\n dispatchAddVoucherFailed(data);\n\n return false;\n }\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as CancelBackorderDemand from '@ori-events/cancel-backorder-demand';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = CancelBackorderDemand.Data & PositionData;\n\nexport async function cancelBackorderDemandHandler({ detail: { lineNumber, placement } }: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.CancelBackorderDemand}?lineNumber=${lineNumber}`,\n getHttpRequestSettings({ placement }),\n );\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as CancelSubscription from '@ori-events/cancel-subscription';\nimport * as CancelSubscriptionFailed from '@ori-events/cancel-subscription-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = CancelSubscription.Data & PositionData;\n\nexport const dispatchCancelSubscriptionFailedEvent = (detail: CancelSubscriptionFailed.Data) => {\n const event = new CustomEvent(CancelSubscriptionFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function cancelSubscriptionHandler({\n detail: { consumerId, packageId, placement, subscriptionId },\n}: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.CancelSubscription}?consumerId=${consumerId}&subscriptionId=${subscriptionId}&packageId=${packageId}`,\n getHttpRequestSettings({ placement }),\n );\n\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (CancelSubscriptionFailed.isCancelSubscriptionErrorResponse(data)) {\n dispatchCancelSubscriptionFailedEvent(data);\n\n return false;\n }\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\nexport async function clearBasketHandler() {\n const response = await fetch(RequestUrl.ClearBasket, getHttpRequestSettings());\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as DelaySubscription from '@ori-events/delay-subscription';\nimport * as DelaySubscriptionFailed from '@ori-events/delay-subscription-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = DelaySubscription.Data & PositionData;\n\nexport const dispatchDelaySubscriptionFailedEvent = (detail: DelaySubscriptionFailed.Data) => {\n const event = new CustomEvent(DelaySubscriptionFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function delaySubscriptionHandler({\n detail: { cycle, placement, step, subscriptionId },\n}: CustomEvent) {\n const response = await fetch(\n RequestUrl.DelaySubscription,\n getHttpRequestSettings({ cycle, placement, step, subscriptionId }, HttpMethod.Post),\n );\n const data = convertToCamelCase((await response.json()) as object);\n\n if (DelaySubscriptionFailed.isDelaySubscriptionErrorResponse(data)) {\n dispatchDelaySubscriptionFailedEvent(data);\n\n return false;\n }\n\n return data;\n}\n","import * as AddToBasket from '@ori-events/add-to-basket';\nimport * as LoyaltyDialogResult from '@ori-events/loyalty-dialog-result';\n\nimport { RequestUrl } from '../types';\nimport { addToBasket } from '../utils';\n\nexport async function checkLoyaltyDialogResultAndAddToBasketHandler({ detail }: CustomEvent) {\n const { result } = detail;\n\n if (LoyaltyDialogResult.isLoyaltyCloseResult(result)) {\n return false;\n }\n\n if (LoyaltyDialogResult.isLoyaltyBuyForPointsResult(result)) {\n const { catalogueItemId, choiceId, itemCode, quantity, placement } = detail;\n\n return addToBasket(\n RequestUrl.AddToBasketForPoints,\n {\n itemCode,\n quantity,\n choiceId,\n catalogueItemId,\n placement,\n },\n AddToBasket.Method.BUY_FOR_POINTS,\n );\n }\n\n if (LoyaltyDialogResult.isLoyaltyBuyForMoneyResult(result)) {\n const { itemCode, quantity, originalItemCode, replacementType, placement } = detail;\n\n return addToBasket(\n RequestUrl.AddToBasketForMoney,\n {\n itemCode,\n quantity,\n originalItemCode,\n replacementType,\n placement,\n },\n AddToBasket.Method.BUY_FOR_MONEY,\n );\n }\n\n return false;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as RemoveBasketItem from '@ori-events/remove-basket-item';\nimport * as RemoveBasketItemFailed from '@ori-events/remove-basket-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & RemoveBasketItem.Data;\n\nexport async function removeBasketItemHandler({ detail: { lineNumber, placement } }: CustomEvent) {\n const response = await fetch(\n RequestUrl.RemoveBasketItem,\n getHttpRequestSettings({ lineNumber, placement }, HttpMethod.Post),\n );\n\n const data = convertToCamelCase((await response.json()) as object);\n\n if (RemoveBasketItemFailed.isRemoveBasketItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(RemoveBasketItemFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as RemoveCustomerOrder from '@ori-events/remove-customer-order';\nimport * as RemoveCustomerOrderFailed from '@ori-events/remove-customer-order-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & RemoveCustomerOrder.Data;\n\nexport async function removeCustomerOrderHandler({ detail: { endConsumerOrderId, placement } }: CustomEvent) {\n const fetchUrl = `${RequestUrl.RemoveCustomerOrder}?endConsumerOrderId=${endConsumerOrderId}`;\n\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (RemoveCustomerOrderFailed.isRemoveCustomerOrderErrorResponse(data)) {\n const errorEvent = new CustomEvent(RemoveCustomerOrderFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as RemoveVoucher from '@ori-events/remove-voucher';\nimport * as RemoveVoucherFailed from '@ori-events/remove-voucher-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & RemoveVoucher.Data;\n\nconst dispatchRemoveVoucherFailed = (detail: RemoveVoucherFailed.Data) => {\n const event = new CustomEvent(RemoveVoucherFailed.Name, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport async function removeVoucherHandler({ detail: { placement, voucherCode } }: CustomEvent) {\n const fetchUrl = `${RequestUrl.RemoveVoucher}?voucherCode=${voucherCode}`;\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (RemoveVoucherFailed.isRemoveVoucherErrorResponse(data)) {\n dispatchRemoveVoucherFailed(data);\n\n return false;\n }\n\n return data;\n}\n","import type * as ReplaceShoppingBagItem from '@ori-events/replace-shopping-bag-item';\nimport * as ReplaceShoppingBagItemFailed from '@ori-events/replace-shopping-bag-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & ReplaceShoppingBagItem.Data;\n\nexport async function replaceShoppingBagItemHandler({\n detail: { itemCode, lineNumber, placement },\n}: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.ReplaceShoppingBagItem}?lineNumber=${lineNumber}&itemCode=${itemCode}`,\n getHttpRequestSettings({ placement }),\n );\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (ReplaceShoppingBagItemFailed.isReplaceShoppingBagItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(ReplaceShoppingBagItemFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as ReplaceSubscription from '@ori-events/replace-subscription';\nimport * as ReplaceSubscriptionFailed from '@ori-events/replace-subscription-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\nimport { type GlobalCustomersSubscriptionItemDto } from '@ori/global-api-client-react';\n\nimport { replaceSubscription } from '../api';\nimport { mainLogger } from '../logger';\nimport { RequestUrl } from '../types';\nimport type { HandlerSettings } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & ReplaceSubscription.Data;\ntype Response = ReplaceSubscriptionFailed.ReplaceSubscriptionResponse;\n\nexport async function replaceSubscriptionHandler(\n { detail: { droppingId, itemCode, subscriptionId } }: CustomEvent,\n { client, customerId, tenant }: HandlerSettings,\n) {\n // STEP 1 - Update through API\n const subscriptionItemId = 0;\n const item = {\n droppingId,\n isReplacementAllowed: true,\n itemCode,\n quantity: 1,\n subscriptionItemId,\n // TODO -- This was optional / not used before, that's why the cast for now.\n // The ReplaceSubscription event data contains currently only the props destructured above.\n // To change it (if requested), we need cross-team collaboration with Presentation.\n // discountedPrice: 0,\n // discountPercent: 0,\n // totalBp: 0,\n // price: 0,\n // isDropped: false,\n };\n const globalCustomersSubscriptionItemDto = item as GlobalCustomersSubscriptionItemDto;\n\n try {\n await replaceSubscription({\n client,\n customerId,\n globalCustomersSubscriptionItemDto,\n subscriptionId,\n subscriptionItemId,\n tenant,\n });\n } catch (error: unknown) {\n mainLogger.error(error as Error, { message: 'Error while replacing subscription in replaceSubscription event.' });\n\n return false;\n }\n\n // STEP 2 - Update shopping context via Online endpoint\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n\n if (ReplaceSubscriptionFailed.isReplaceSubscriptionErrorResponse(data)) {\n const errorEvent = new CustomEvent(ReplaceSubscriptionFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import {\n type GlobalCustomersSubscriptionItemDto,\n updateCustomerSubscriptionSubscriptionItem,\n type UpdateCustomerSubscriptionSubscriptionItemHeaders,\n} from '@ori/global-api-client-react';\n\nimport type { HandlerSettings } from '../types';\n\ntype ReplaceSubscriptionHandlerSettings = Pick;\n\nexport type ReplaceSubscriptionParams = ReplaceSubscriptionHandlerSettings & {\n globalCustomersSubscriptionItemDto: GlobalCustomersSubscriptionItemDto;\n subscriptionId: number;\n subscriptionItemId: number;\n tenant: string;\n};\n\nexport async function replaceSubscription({\n client,\n customerId,\n globalCustomersSubscriptionItemDto,\n subscriptionId,\n subscriptionItemId,\n tenant,\n}: ReplaceSubscriptionParams) {\n // TODO -- Is this needed when there is the tenant prop of ApiProvider applied on some upper level?\n const headers: UpdateCustomerSubscriptionSubscriptionItemHeaders = {\n 'x-tenant-context': tenant,\n };\n\n return updateCustomerSubscriptionSubscriptionItem(\n client,\n customerId,\n subscriptionId,\n subscriptionItemId,\n globalCustomersSubscriptionItemDto,\n headers,\n );\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport * as ShoppingContextLoaded from '@ori-events/shopping-context-loaded';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\nexport async function requestShoppingContextHandler() {\n const response = await fetch(RequestUrl.GetShoppingContext, getHttpRequestSettings(undefined, HttpMethod.Post));\n const data = convertToCamelCase((await response.json()) as object);\n const event = new CustomEvent(ShoppingContextLoaded.Name, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return data;\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\nexport async function resetShippingSelectionHandler() {\n const response = await fetch(RequestUrl.ResetFreeShippingSelection, getHttpRequestSettings());\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as UpdateBasketItem from '@ori-events/update-basket-item';\nimport type { Data as ErrorData, UpdateBasketItemResponse } from '@ori-events/update-basket-item-failed';\nimport { isUpdateBasketItemErrorResponse, Name as ErrorEventName } from '@ori-events/update-basket-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateBasketItem.Data;\n\nexport async function updateBasketItemHandler({ detail: { lineNumber, placement, quantity } }: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.UpdateBasketItem}?lineNumber=${lineNumber}&quantity=${quantity}`,\n getHttpRequestSettings({ placement }),\n );\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateBasketItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as UpdateCustomerOrderItem from '@ori-events/update-customer-order-item';\nimport * as UpdateCustomerOrderItemFailed from '@ori-events/update-customer-order-item-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateCustomerOrderItem.Data;\n\nexport async function updateCustomerOrderItemHandler({\n detail: { endConsumerOrderId, itemCode, placement, requestedQuantity },\n}: CustomEvent) {\n const fetchUrl =\n `${RequestUrl.UpdateCustomerOrderItem}` +\n `?endConsumerOrderId=${endConsumerOrderId}` +\n `&itemCode=${itemCode}` +\n `&requestedQuantity=${requestedQuantity}`;\n\n const response = await fetch(fetchUrl, getHttpRequestSettings({ placement }));\n const data = convertToCamelCase(\n (await response.json()) as object,\n );\n\n if (UpdateCustomerOrderItemFailed.isUpdateCustomerOrderItemErrorResponse(data)) {\n const errorEvent = new CustomEvent(UpdateCustomerOrderItemFailed.Name, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as UpdateDelivery from '@ori-events/update-delivery';\nimport type { Data as ErrorData, UpdateDeliveryResponse } from '@ori-events/update-delivery-failed';\nimport { isUpdateDeliveryErrorResponse, Name as ErrorEventName } from '@ori-events/update-delivery-failed';\n\nimport { putRequestOptions } from '../constants/requestOptions';\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase } from '../utils';\n\ntype Data = UpdateDelivery.Data;\n\nexport async function updateDeliveryHandler({\n detail: { deliveryAddressId, deliveryChannelId, registrationId },\n}: CustomEvent) {\n // if needed, start with delivery channel ID update\n if (typeof deliveryChannelId !== 'undefined') {\n const channelRequestOptions = {\n ...putRequestOptions,\n body: JSON.stringify({ deliveryChannelId }),\n };\n const channelResponse = await fetch(RequestUrl.UpdateDeliveryChannel, channelRequestOptions);\n const channelResponseData = convertToCamelCase((await channelResponse.json()) as object);\n\n if (isUpdateDeliveryErrorResponse(channelResponseData)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: channelResponseData,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n }\n\n // delivery address ID update\n const addressParams: {\n addressId: number;\n registrationId?: string;\n } = {\n addressId: deliveryAddressId,\n };\n if (registrationId) {\n addressParams.registrationId = registrationId;\n }\n const addressRequestOptions = {\n ...putRequestOptions,\n body: JSON.stringify(addressParams),\n };\n const addressResponse = await fetch(RequestUrl.UpdateDeliveryAddress, addressRequestOptions);\n const addressResponseData = convertToCamelCase((await addressResponse.json()) as object);\n\n if (isUpdateDeliveryErrorResponse(addressResponseData)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: addressResponseData,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return addressResponseData;\n}\n","import type * as UpdateDeliveryChannel from '@ori-events/update-delivery-channel';\nimport type { Data as ErrorData, UpdateDeliveryChannelResponse } from '@ori-events/update-delivery-channel-failed';\nimport {\n isUpdateDeliveryChannelErrorResponse,\n Name as ErrorEventName,\n} from '@ori-events/update-delivery-channel-failed';\n\nimport { putRequestOptions } from '../constants/requestOptions';\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase } from '../utils';\n\ntype Data = UpdateDeliveryChannel.Data;\n\nexport async function updateDeliveryChannelHandler({ detail: { deliveryChannelId } }: CustomEvent) {\n const requestOptions = {\n ...putRequestOptions,\n body: JSON.stringify({ deliveryChannelId }),\n };\n const response = await fetch(RequestUrl.UpdateDeliveryChannel, requestOptions);\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateDeliveryChannelErrorResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import type * as UpdateDonation from '@ori-events/update-donation';\nimport type { Data as ErrorData, UpdateDonationResponse } from '@ori-events/update-donation-failed';\nimport { isUpdateDonationFailedResponse, Name as ErrorEventName } from '@ori-events/update-donation-failed';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateDonation.Data;\n\nexport async function updateDonationHandler({ detail: { choiceId, checked } }: CustomEvent) {\n const response = await fetch(\n RequestUrl.UpdateDonation,\n getHttpRequestSettings({ choiceId, checked }, HttpMethod.Post),\n );\n\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdateDonationFailedResponse(data)) {\n const event = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(event);\n\n return false;\n }\n\n return data;\n}\n","import {\n type GlobalShoppingOfferChoiceDtoBody,\n updateShoppingSessionOfferChoice,\n type UpdateShoppingSessionOfferChoiceHeaders,\n} from '@ori/global-api-client-react';\n\nimport type { HandlerSettings } from '../types';\nimport { deleteOfferItem } from './deleteOfferItem';\n\ntype UpdateOfferItemHandlerSettings = Pick;\n\nexport type UpdateOfferItemParams = UpdateOfferItemHandlerSettings & {\n itemCode: string;\n offerId: number;\n quantity: number;\n tenant: string;\n};\n\nexport async function updateOfferItem(params: UpdateOfferItemParams) {\n const { client, itemCode, offerId, quantity, sessionId, tenant } = params;\n\n if (quantity === 0) {\n return deleteOfferItem(params);\n }\n\n const globalShoppingOfferChoiceDtoBody = {\n itemCode,\n quantity,\n } as GlobalShoppingOfferChoiceDtoBody;\n\n // TODO -- Is this needed when there is the tenant prop of ApiProvider applied on some upper level?\n const headers: UpdateShoppingSessionOfferChoiceHeaders = {\n 'x-tenant-context': tenant,\n };\n\n return updateShoppingSessionOfferChoice(\n client,\n sessionId,\n offerId,\n itemCode,\n globalShoppingOfferChoiceDtoBody,\n headers,\n );\n}\n","import type * as BasketUpdated from '@ori-events/basket-updated';\nimport type * as UpdateOfferItems from '@ori-events/update-offer-items';\nimport type { PositionData } from '@ori/analytics-data';\nimport { HttpMethod } from '@ori/checkout-utils';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdateOfferItems.Data;\n\nexport async function updateOfferItemsHandler({ detail: { choiceId, items, placement } }: CustomEvent) {\n const response = await fetch(\n RequestUrl.UpdateOfferItems,\n getHttpRequestSettings({ choiceId, items, placement }, HttpMethod.Post),\n );\n\n return convertToCamelCase((await response.json()) as object);\n}\n","import type * as UpdatePaymentProvider from '@ori-events/update-payment-provider';\nimport type { Data as ErrorData, UpdatePaymentProviderResponse } from '@ori-events/update-payment-provider-failed';\nimport {\n isUpdatePaymentProviderFailedResponse,\n Name as ErrorEventName,\n} from '@ori-events/update-payment-provider-failed';\nimport type { PositionData } from '@ori/analytics-data';\n\nimport { RequestUrl } from '../types';\nimport { convertToCamelCase, getHttpRequestSettings } from '../utils';\n\ntype Data = PositionData & UpdatePaymentProvider.Data;\n\nexport async function updatePaymentProviderHandler({ detail: { paymentProviderId, placement } }: CustomEvent) {\n const response = await fetch(\n `${RequestUrl.UpdatePaymentProvider}?paymentProviderId=${paymentProviderId}`,\n getHttpRequestSettings({ placement }),\n );\n const data = convertToCamelCase((await response.json()) as object);\n\n if (isUpdatePaymentProviderFailedResponse(data)) {\n const errorEvent = new CustomEvent(ErrorEventName, {\n detail: data,\n });\n window.dispatchEvent(errorEvent);\n\n return false;\n }\n\n return data;\n}\n","import { NOT_LOGGED_IN_USER_ID } from '@ori/auth';\nimport type { PickClientAppDataConfigProps } from '@ori/client-app-config';\n\n// This can be extended by specific types for your Online properties\nexport type ClientAppConfig = PickClientAppDataConfigProps<\n 'currentLanguage' | 'customerId' | 'globalApiUrl' | 'identityUrl' | 'staticApiUrl' | 'tenant'\n>;\n\nexport const DEFAULT_CONFIG: ClientAppConfig = {\n currentLanguage: 'en-GB',\n customerId: NOT_LOGGED_IN_USER_ID,\n globalApiUrl: '',\n identityUrl: '',\n staticApiUrl: '',\n tenant: 'uk',\n};\n","import { useContext, createContext } from 'react';\n\nimport type { ClientAppConfig } from '../types';\nimport { DEFAULT_CONFIG } from '../types';\n\nexport const configurationContext = createContext(DEFAULT_CONFIG);\n\nexport const ConfigurationProvider = configurationContext.Provider;\n\nexport const useConfiguration = () => useContext(configurationContext);\n","export enum StorageType {\n IndexedDb = 'IndexedDb',\n LocalStorage = 'LocalStorage',\n}\n","import * as BasketUpdated from '@ori-events/basket-updated';\n\nimport type { UpdateEventType } from '../types';\n\nexport const dispatchBasketUpdatedEvent = (\n detail: BasketUpdated.Data,\n eventType: UpdateEventType = BasketUpdated.Name,\n) => {\n const event = new CustomEvent(eventType, {\n detail,\n });\n window.dispatchEvent(event);\n};\n\nexport default dispatchBasketUpdatedEvent;\n","import { logDebug } from '../logger';\n\nexport const logReceivedEvent = (event: T) => logDebug(`Received ${event.type} event:\\n\\t`, event);\n","export const getCookie = (cookieName: string) => {\n const match = document.cookie.match(new RegExp(`${cookieName}=([^;]+)`));\n\n return match ? match[1] : undefined;\n};\n","import { USER_COOKIE_NAME } from '../constants';\nimport { getCookie } from './cookies';\nimport { adler32 } from './hashes';\n\n/**\n * Returns user check hash data based on user cookie.\n * The cookie should always be set at least in Online session.\n * The 'unknown' value is just a fallback for testing.\n */\nexport const getUserCheck = () => adler32((getCookie(USER_COOKIE_NAME) ?? '').trim() || 'unknown');\n","export const adler32 = (data: string) => {\n const MOD_ADLER = 65521;\n const BITS_MOVED = 16;\n const { length } = data;\n\n let a = 1;\n let b = 0;\n\n for (let i = 0; i < length; i++) {\n // eslint-disable-next-line unicorn/prefer-code-point -- x\n a += data.charCodeAt(i);\n b += a;\n }\n\n a %= MOD_ADLER;\n b %= MOD_ADLER;\n\n // eslint-disable-next-line no-bitwise -- x\n return (b << BITS_MOVED) | a;\n};\n","import { DATA_CACHE_TIMEOUT } from '../constants';\n\n/**\n * Checks a timestamp flag stored with the data in storage for not being older\n * than the specified time amount. If true, the stored data can be re-used.\n * If false, the data is stale and has to be reloaded.\n */\nexport const isValidStorageTimestamp = (timestamp: number) => Date.now() - timestamp <= DATA_CACHE_TIMEOUT;\n","import { type IDBPDatabase, openDB } from 'idb';\n\nimport { logDebug, logWarning, mainLogger } from '../logger';\nimport type { GetStorageItemMethod, RemoveStorageItemMethod, SetStorageItemMethod, StoredValue } from '../types';\nimport { getUserCheck } from './getUserCheck';\nimport { isValidStorageTimestamp } from './isValidStorageTimestamp';\n\nconst childLogger = mainLogger.createChild('IndexedDb storage');\n\n/** Returns true if the IndexedDb storage is available. */\nexport function isStorageAvailable() {\n const isAvailable = Boolean(typeof window === 'object' && window.indexedDB);\n if (!isAvailable) {\n logWarning('Storage is not available.');\n }\n\n return isAvailable;\n}\n\n/**\n * Shopping context store name. Store is basically equivalent of DB table.\n * This is currently also being used for database name.\n */\nconst SHOPPING_CONTEXT = 'shoppingContext';\n\n/**\n * This is used for versioning of the DB structure.\n * When there are changes requiring different code and/or data updates,\n * the number should be incremented and optional upgrade routines for the DB structure\n * defined in the openDB() method, upgrade() subroutine below.\n */\nconst CURRENT_VERSION = 1;\n\n/** IndexedDb access / open request object. */\nlet db: Promise | undefined;\n\nexport async function getDb() {\n if (!db) {\n db = openDB(SHOPPING_CONTEXT, CURRENT_VERSION, {\n upgrade(database) {\n // create the shopping context store if missing\n if (!database.objectStoreNames.contains(SHOPPING_CONTEXT)) {\n database.createObjectStore(SHOPPING_CONTEXT);\n }\n },\n });\n }\n\n return db;\n}\n\n/** Returns a value identified by the key stored in IndexedDb storage. */\nexport const getStorageItem: GetStorageItemMethod = async (key: string) => {\n try {\n const database = await getDb();\n const data = (await database.get(SHOPPING_CONTEXT, key)) as StoredValue | undefined;\n\n if (!data) {\n logDebug(`Item with key '${key}' wasn't found in storage.`);\n\n return undefined;\n }\n\n const { savedTimestamp, value, userCheck } = data;\n if (!isValidStorageTimestamp(savedTimestamp)) {\n await database.delete(SHOPPING_CONTEXT, key);\n logDebug(`Stored item with key '${key}' has expired and was deleted.`);\n\n return undefined;\n }\n\n if (userCheck !== getUserCheck()) {\n await database.delete(SHOPPING_CONTEXT, key);\n logDebug(`Item with key '${key}' was stored for different user and was deleted.`);\n\n return undefined;\n }\n\n logDebug(`Item with key ${key} was found in storage.\\n\\t`, data);\n\n return value;\n } catch (error) {\n childLogger.error(error as Error, { action: `getStorageItem - storing item with ${key}` });\n\n return undefined;\n }\n};\n\n/** Stores a value under the specified key in IndexedDb storage. */\nexport const setStorageItem: SetStorageItemMethod = async (key: string, value: T) => {\n try {\n const data: StoredValue = {\n savedTimestamp: Date.now(),\n value,\n userCheck: getUserCheck(),\n };\n\n const database = await getDb();\n await database.put(SHOPPING_CONTEXT, data, key);\n logDebug(`Stored item with key '${key}', value:\\n\\t`, data);\n\n return true;\n } catch (error) {\n childLogger.error(error as Error, { action: `setStorageItem - storing item with ${key}` });\n\n return false;\n }\n};\n\n/** Removes a value identified by the specified key from IndexedDb storage. */\nexport const removeStorageItem: RemoveStorageItemMethod = async (key: string) => {\n try {\n const database = await getDb();\n await database.delete(SHOPPING_CONTEXT, key);\n logDebug(`Stored item with key '${key}' was removed.`);\n\n return true;\n } catch (error) {\n childLogger.error(error as Error, { action: `removeStorageItem - removing item with ${key}` });\n\n return false;\n }\n};\n","/*\nBoth sessionStorage or localStorage could be used here.\nThe sessionStorage doesn't support triggering syncing events on other browser tabs\n(not utilized anyway ATM to have same functionality scope for all implemented storages).\nThe sessionStorage should clean up stored data after the browser tab gets closed.\nBut the browser's restore-session-on-reopen functionality may clash with this.\nBoth storage types have no connection with server-side session,\nso, if working with server session data, manual cleanups / refreshing\nhas to be solved anyway.\n*/\nimport { logDebug, logWarning, mainLogger } from '../logger';\nimport type { GetStorageItemMethod, RemoveStorageItemMethod, SetStorageItemMethod, StoredValue } from '../types';\nimport { getUserCheck } from './getUserCheck';\nimport { isValidStorageTimestamp } from './isValidStorageTimestamp';\n\nconst childLogger = mainLogger.createChild('local storage');\n\nexport const getStorage = () => typeof window === 'object' && window.localStorage;\n\n/** Returns true if the local storage is available. */\nexport function isStorageAvailable() {\n const isAvailable = Boolean(getStorage());\n if (!isAvailable) {\n logWarning('Storage is not available.');\n }\n\n return isAvailable;\n}\n\n// TODO -- don't we have some util for this already in some NPM?\nfunction parseValue(serializedData: string) {\n let parsedValue: StoredValue | undefined;\n try {\n parsedValue = JSON.parse(serializedData) as StoredValue;\n } catch (error) {\n childLogger.error(error as Error, { action: 'Error parsing serialized data.' });\n }\n\n return parsedValue;\n}\n\n/** Returns a value identified by the key stored in localStorage. */\nexport const getStorageItem: GetStorageItemMethod = async (key: string) =>\n new Promise((resolve) => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n resolve(undefined);\n\n return;\n }\n\n const data = storage.getItem(key);\n if (!data) {\n logDebug(`Item with key '${key}' wasn't found in storage.`);\n resolve(undefined);\n\n return;\n }\n\n const parsedData = parseValue(data);\n if (!parsedData) {\n const error = new Error(`Error getting stored item with key '${key}'.`);\n childLogger.error(error, { action: 'getStorageItem' });\n resolve(undefined);\n\n return;\n }\n\n const { savedTimestamp, value, userCheck } = parsedData;\n if (!isValidStorageTimestamp(savedTimestamp)) {\n storage.removeItem(key);\n logDebug(`Stored item with key '${key}' has expired and was deleted.`);\n resolve(undefined);\n\n return;\n }\n\n if (userCheck !== getUserCheck()) {\n storage.removeItem(key);\n logDebug(`Item with key '${key}' was stored for different user and was deleted.`);\n resolve(undefined);\n\n return;\n }\n\n logDebug(`Item with key ${key} was found in storage.\\n\\t`, parsedData);\n resolve(value);\n });\n\n/** Stores a value under the specified key in localStorage. */\nexport const setStorageItem: SetStorageItemMethod = async (key: string, value: T) =>\n new Promise((resolve) => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n resolve(false);\n\n return;\n }\n\n const data: StoredValue = {\n savedTimestamp: Date.now(),\n value,\n userCheck: getUserCheck(),\n };\n\n try {\n storage.setItem(key, JSON.stringify(data));\n logDebug(`Stored item with key '${key}', value:\\n\\t`, data);\n resolve(true);\n } catch (error) {\n childLogger.error(error as Error, { action: `setStorageItem - storing item with ${key}:` });\n resolve(false);\n }\n });\n\n/** Removes a value identified by the specified key from localStorage. */\nexport const removeStorageItem: RemoveStorageItemMethod = async (key: string) =>\n new Promise((resolve) => {\n const storage = getStorage();\n if (typeof storage !== 'object') {\n resolve(false);\n\n return;\n }\n\n try {\n storage.removeItem(key);\n logDebug(`Stored item with key '${key}' was removed.`);\n resolve(true);\n } catch (error) {\n childLogger.error(error as Error, { action: `removeStorageItem - removing item with ${key}:` });\n resolve(false);\n }\n });\n","import { logDebug } from '../logger';\n\nconst pagePathPatterns = ['/shopping/basket'];\n\nexport const isPageMarkedForCacheCleanup = () => {\n const isCleanupPage = pagePathPatterns.some((item) => window.location.pathname.includes(item));\n if (isCleanupPage) {\n logDebug('Cache cleanup is always requested for current page.');\n }\n\n return isCleanupPage;\n};\n","import * as BasketUpdated from '@ori-events/basket-updated';\nimport * as PlaceOrderRequested from '@ori-events/place-order-requested';\nimport * as RequestClearShoppingCache from '@ori-events/request-clear-shopping-cache';\nimport * as RequestShoppingContext from '@ori-events/request-shopping-context';\nimport * as ShoppingContextLoaded from '@ori-events/shopping-context-loaded';\nimport { useToken } from '@ori/auth';\nimport { useApiClient } from '@ori/global-api-client-react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { CONTEXT_KEY, POST_INIT_EVENT_DELAY } from '../constants';\nimport { shoppingContextActions } from '../constants/shoppingContextActions';\nimport { useConfiguration } from '../contexts';\nimport { logDebug } from '../logger';\nimport type {\n ContextUpdateEventHandler,\n GetStorageItemMethod,\n HandlerSettings,\n IsStorageAvailableMethod,\n RemoveStorageItemMethod,\n SetStorageItemMethod,\n SuccessEventName,\n} from '../types';\nimport { StorageType } from '../types';\nimport {\n dispatchBasketUpdatedEvent,\n getStorageMethods,\n getUseIndexedDbFeatureToggle,\n isPageMarkedForCacheCleanup,\n isScheduledCacheCleanup,\n logReceivedEvent,\n removeScheduledCacheCleanup,\n} from '../utils';\n\nlet isReadyPromiseResolve: (value: PromiseLike | boolean) => void;\n\n/**\n * Promise indicating that shopping bag provider handlers are connected\n * and other components can start communicating with the provider via events.\n */\nexport const isReady = new Promise((resolve) => {\n isReadyPromiseResolve = resolve;\n});\n\n// Publish the promise to window scope for other components.\nif (typeof window !== 'undefined') {\n window.isBasketProviderReady = isReady;\n}\n\ntype EventListenerInfo = {\n eventName: string;\n eventListener: EventListener;\n};\n\ntype EventListenerFactoryMethod = (\n handler: ContextUpdateEventHandler,\n currentSettings: HandlerSettings,\n) => EventListener;\n\n/** Creates event listeners for the actions defined in shoppingContextActions list. */\nfunction getEventListeners(\n currentSettings: HandlerSettings,\n createEventListener: EventListenerFactoryMethod,\n createRequestShoppingContextEventListener: EventListenerFactoryMethod,\n) {\n const result: EventListenerInfo[] = [];\n for (const [triggerActionEventName, { handler }] of shoppingContextActions.entries()) {\n const eventListenerFactory =\n triggerActionEventName === RequestShoppingContext.Name\n ? createRequestShoppingContextEventListener\n : createEventListener;\n result.push({\n eventName: triggerActionEventName,\n eventListener: eventListenerFactory(handler, currentSettings),\n });\n }\n\n return result;\n}\n\nlet isStorageAvailable: IsStorageAvailableMethod | undefined;\nlet getStorageItem: GetStorageItemMethod | undefined;\nlet setStorageItem: SetStorageItemMethod | undefined;\nlet removeStorageItem: RemoveStorageItemMethod | undefined;\n\nexport const useBasketProviderData = () => {\n const globalApiClient = useApiClient();\n const { currentLanguage, tenant, staticApiUrl } = useConfiguration();\n const { customerId } = useToken();\n\n const getCachedContext = useCallback(async () => getStorageItem?.(CONTEXT_KEY), []);\n const setCachedContext = useCallback(async (value: BasketUpdated.Data) => setStorageItem?.(CONTEXT_KEY, value), []);\n const clearCachedContext = useCallback(async () => removeStorageItem?.(CONTEXT_KEY), []);\n\n // Indication that startup shopping context data initialization was done.\n const [isInitialShoppingContextApplied, setIsInitialShoppingContextApplied] = useState(false);\n\n // Indication that shopping context was requested during startup.\n const wasShoppingContextRequestedDuringInit = useRef(false);\n\n // Indication that startup loading of shopping context is already in progress.\n // Rather than triggering new requests, we wait for the 1st one to return data.\n // This is valid mostly for startup, as multiple apps can be asking for shopping\n // context via the request-shopping-context event in parallel. For later updates,\n // this is not a problem as the updates are triggered by user actions.\n const isRequestingShoppingContext = useRef(false);\n\n // Current shopping context / shopping session data. This is also being synchronized\n // with the cache on startup & after each update action.\n const [shoppingContext, setShoppingContext] = useState();\n\n const shoppingSessionId = useRef('');\n\n /**\n * Sets current shopping context data state while optionally setting also the cache\n * and/or triggering a requested success response event.\n */\n const updateContext = useCallback(\n async (data: BasketUpdated.Data, eventTypeToBeTriggered?: SuccessEventName, shouldStoreData = true) => {\n shoppingSessionId.current = data.sessionId ?? '';\n setShoppingContext(data);\n if (shouldStoreData && isStorageAvailable?.()) {\n await setCachedContext(data);\n logDebug('Stored context was updated with new data:\\n\\t', data);\n } else {\n logDebug('Current context state was updated with new data:\\n\\t', data);\n }\n if (eventTypeToBeTriggered) {\n logDebug(`Triggering ${eventTypeToBeTriggered} event ...`);\n dispatchBasketUpdatedEvent(data, eventTypeToBeTriggered);\n }\n },\n [setCachedContext],\n );\n\n /** Tries to read last cache and, if found, sets it back into current shopping context state. */\n const getStoredContext = useCallback(async () => {\n const data = await getCachedContext();\n if (!data) {\n return;\n }\n await updateContext(data, undefined, false);\n logDebug('Restored context data from storage.');\n }, [getCachedContext, updateContext]);\n\n /** Clears current shopping context data and stored cache. */\n const clearContext = useCallback(async () => {\n logDebug('Clearing stored shopping context data ...');\n await clearCachedContext();\n setShoppingContext(undefined);\n }, [clearCachedContext]);\n\n /** Clears shopping context data based on received event. */\n const clearContextOnEvent = useCallback(\n async (event: Event) => {\n logReceivedEvent(event);\n await clearContext();\n },\n [clearContext],\n );\n\n /** Generic event listener for most update actions. */\n const createEventListener = useCallback(\n (handler: ContextUpdateEventHandler, currentSettings: HandlerSettings) => {\n const result = (async (event: T) => {\n logReceivedEvent(event);\n const data = await handler(event, currentSettings);\n if (data === false) {\n logDebug('Shopping context update failed.');\n } else {\n await updateContext(data, BasketUpdated.Name);\n }\n }) as EventListener;\n\n return result;\n },\n [updateContext],\n );\n\n /**\n * Specific event listener for request-shopping-context action.\n * Getting the shopping context data from storage and/or the isRequestingShoppingContext\n * state is involved in this case. If in cache, the data is returned w/o creating\n * another request to server. If the loading already started before, it waits for\n * the original request to return the data.\n */\n const createRequestShoppingContextEventListener = useCallback(\n (handler: ContextUpdateEventHandler, currentSettings: HandlerSettings) => {\n const result = (async (event: T) => {\n logReceivedEvent(event);\n\n if (shoppingContext) {\n const triggerResponse = () => {\n logDebug(`Context data was loaded before. Triggering ${ShoppingContextLoaded.Name} event ...`);\n dispatchBasketUpdatedEvent(shoppingContext, ShoppingContextLoaded.Name);\n };\n\n // postpone a bit to have same events order as when really fetching the data\n setTimeout(() => triggerResponse());\n\n return;\n }\n\n if (!isInitialShoppingContextApplied) {\n // In case the initial storage & shopping context check wasn't done yet,\n // just schedule for later with this flag.\n logDebug('Shopping context was requested during initialization.');\n wasShoppingContextRequestedDuringInit.current = true;\n\n return;\n }\n\n if (isRequestingShoppingContext.current) {\n logDebug('Shopping context request was already called before. Waiting for response ...');\n\n return;\n }\n\n isRequestingShoppingContext.current = true;\n logDebug('Loading shopping context ...');\n const data = await handler(event, currentSettings);\n if (data === false) {\n logDebug('Shopping context load failed.');\n } else {\n logDebug('Shopping context was loaded.');\n await updateContext(data, ShoppingContextLoaded.Name);\n }\n isRequestingShoppingContext.current = false;\n }) as EventListener;\n\n return result;\n },\n [isInitialShoppingContextApplied, isRequestingShoppingContext, shoppingContext, updateContext],\n );\n\n // init event listeners\n useEffect(() => {\n const eventListeners = getEventListeners(\n { client: globalApiClient, customerId, sessionId: shoppingSessionId.current, tenant },\n createEventListener,\n createRequestShoppingContextEventListener,\n );\n eventListeners.push(\n // This is now called when the user requests creating a new order.\n // That means that the cache should be cleared. But we don't know yet\n // if the create order action succeeds. Getting exact order creation\n // result / success might be problematic, as there are page redirects\n // involved, and after page reload, it is too late for clearing caches.\n // So current solution calls the PlaceOrderRequested event before\n // calling the request on server, so that there is enough time to\n // do this cache cleanup here before the redirects happen.\n // ATM, the redirect is being done in legacy module & this logic might\n // change after rewriting to React.\n {\n eventName: PlaceOrderRequested.Name,\n eventListener: (event) => void clearContextOnEvent(event),\n },\n\n // This is now called for other cases when clearing context data is needed.\n {\n eventName: RequestClearShoppingCache.Name,\n eventListener: (event) => void clearContextOnEvent(event),\n },\n );\n\n eventListeners.forEach(({ eventName, eventListener }) => {\n window.addEventListener(eventName, eventListener);\n });\n logDebug('Event listeners are connected.');\n\n // Resolve the ready promise to notify consuming components.\n isReadyPromiseResolve(true);\n\n return () => {\n eventListeners.forEach(({ eventName, eventListener }) => {\n window.removeEventListener(eventName, eventListener);\n });\n eventListeners.length = 0;\n logDebug('Old event listeners were disconnected.');\n };\n }, [\n clearContextOnEvent,\n createEventListener,\n createRequestShoppingContextEventListener,\n customerId,\n globalApiClient,\n tenant,\n ]);\n\n // setup initial state of shopping context data\n const applyInitialShoppingContext = useCallback(async () => {\n const useIndexedDbStorage = await getUseIndexedDbFeatureToggle({ currentLanguage, staticApiUrl, tenant });\n const storageType = useIndexedDbStorage ? StorageType.IndexedDb : StorageType.LocalStorage;\n const methods = getStorageMethods(storageType);\n isStorageAvailable = methods.isStorageAvailable;\n getStorageItem = methods.getStorageItem;\n removeStorageItem = methods.removeStorageItem;\n setStorageItem = methods.setStorageItem;\n logDebug(`Resolved storage methods for ${storageType}.`);\n\n logDebug('Checking initial shopping context state ...');\n if (isStorageAvailable()) {\n logDebug(`Using ${storageType} for caching shopping context data.`);\n if (isPageMarkedForCacheCleanup() || isScheduledCacheCleanup()) {\n removeScheduledCacheCleanup();\n await clearContext();\n } else {\n await getStoredContext();\n }\n }\n setIsInitialShoppingContextApplied(true);\n logDebug('Initial shopping context check was done.');\n }, [clearContext, currentLanguage, getStoredContext, staticApiUrl, tenant]);\n\n // mangling with the initial state of cached data\n // & optional request-shopping-context events received during init\n useEffect(() => {\n if (!isInitialShoppingContextApplied) {\n void applyInitialShoppingContext();\n } else if (wasShoppingContextRequestedDuringInit.current) {\n // In case there were some request-shopping-context events during init,\n // re-trigger an event here to go through proper handler.\n wasShoppingContextRequestedDuringInit.current = false;\n setTimeout(() => {\n logDebug('Re-triggering request-shopping-context event ...');\n dispatchEvent(new CustomEvent(RequestShoppingContext.Name));\n }, POST_INIT_EVENT_DELAY);\n }\n }, [applyInitialShoppingContext, isInitialShoppingContextApplied]);\n\n const contextValue = useMemo(\n () => ({\n isRequestingShoppingContext,\n isReady,\n shoppingContext,\n }),\n [isRequestingShoppingContext, shoppingContext],\n );\n\n return contextValue;\n};\n","import { ApiClient, getTenantFeatureToggle } from '@ori/static-api-client-react';\n\nimport { USE_INDEXED_DB_FT_GUID } from '../constants';\nimport { logDebug, mainLogger } from '../logger';\nimport type { ClientAppConfig } from '../types';\n\nexport async function getUseIndexedDbFeatureToggle({\n currentLanguage,\n staticApiUrl,\n tenant,\n}: Pick) {\n logDebug('Getting useIndexedDbStorage feature toggle ...');\n let result = false;\n try {\n const staticApiClient = new ApiClient({ baseUrl: staticApiUrl, language: currentLanguage, tenant });\n const {\n data: { isEnabled },\n } = await getTenantFeatureToggle(staticApiClient, tenant, USE_INDEXED_DB_FT_GUID);\n logDebug('FT value loaded:', isEnabled);\n result = isEnabled;\n } catch (error) {\n mainLogger.error(error as Error, { message: 'Error while loading UseIndexedDb feature toggle.' });\n }\n\n return result;\n}\n","import { SCHEDULED_CLEANUP_KEY } from '../constants';\nimport { logDebug } from '../logger';\nimport type { StorageMethods } from '../types';\nimport { StorageType } from '../types';\nimport {\n isStorageAvailable as isIndexedDbStorageAvailable,\n getStorageItem as getIndexedDbStorageItem,\n setStorageItem as setIndexedDbStorageItem,\n removeStorageItem as removeIndexedDbStorageItem,\n} from './storageImplIndexedDb';\nimport {\n isStorageAvailable as isLocalStorageAvailable,\n getStorageItem as getLocalStorageItem,\n setStorageItem as setLocalStorageItem,\n removeStorageItem as removeLocalStorageItem,\n} from './storageImplLocal';\n\n/** Storage methods \"factory\". Returns a set of methods for accessing the given type of storage. */\nexport function getStorageMethods(storageType: StorageType): StorageMethods {\n // TODO -- There could also be the fallback from IndexedDb to localStorage if the former wasn't available.\n // TODO -- The particular storage implementations could be lazy loaded, but the code is quite small.\n switch (storageType) {\n case StorageType.IndexedDb:\n return {\n isStorageAvailable: isIndexedDbStorageAvailable,\n getStorageItem: getIndexedDbStorageItem,\n setStorageItem: setIndexedDbStorageItem,\n removeStorageItem: removeIndexedDbStorageItem,\n };\n default:\n // localStorage\n return {\n isStorageAvailable: isLocalStorageAvailable,\n getStorageItem: getLocalStorageItem,\n setStorageItem: setLocalStorageItem,\n removeStorageItem: removeLocalStorageItem,\n };\n }\n}\n\n/**\n * Checks for scheduled cache cleanup flag presence in storage.\n * This is small data and optionally being also set in legacy Online,\n * so always using localStorage in current implementation.\n */\nexport function isScheduledCacheCleanup(): boolean {\n if (!isLocalStorageAvailable()) {\n return false;\n }\n\n const result = localStorage.getItem(SCHEDULED_CLEANUP_KEY);\n if (result) {\n logDebug('Cache cleanup was scheduled with last page reload.');\n }\n\n return result === null ? false : Boolean(result);\n}\n\n/** Removes scheduled cache cleanup flag from storage. */\nexport function removeScheduledCacheCleanup() {\n if (!isLocalStorageAvailable()) {\n return false;\n }\n localStorage.removeItem(SCHEDULED_CLEANUP_KEY);\n\n return true;\n}\n","import type { FC } from 'react';\n\nimport { useBasketProviderData } from '../hooks';\n\nexport const BasketProvider: FC = () => {\n useBasketProviderData();\n\n return null;\n};\n","import { useToken } from '@ori/auth';\nimport { useServiceUrls } from '@ori/configuration-manager';\nimport { ApiClientProvider } from '@ori/global-api-client-react';\nimport type { ReactElement } from 'react';\n\nimport { useConfiguration } from '../contexts';\n\ninterface ApiProviderProps {\n children: ReactElement;\n}\n\nexport const ApiProvider = ({ children }: ApiProviderProps) => {\n const { tenant } = useConfiguration();\n const { globalApiUrl } = useServiceUrls(['globalApi']);\n const { token } = useToken();\n\n return (\n \n {children}\n \n );\n};\n","import { LoggerProvider, ErrorBoundary } from '@ori/logger';\nimport type { FC } from 'react';\n\nimport { BasketProvider } from '../components';\nimport { APP_NAME } from '../constants';\nimport { ConfigurationProvider } from '../contexts';\nimport { mainLogger } from '../logger';\nimport type { ClientAppConfig } from '../types';\nimport { ApiProvider } from './ApiProvider';\n\nexport const BasketProviderController: FC = (configuration) => (\n \n \n \n \n \n \n \n \n \n);\n","import { BasketProviderController } from '@ori/basket-provider-lib';\nimport { ServiceUrlsProvider } from '@ori/configuration-manager';\n\nimport type { ClientAppConfig } from './types';\n\nexport const App = (configuration: ClientAppConfig) => {\n const { globalApiUrl, identityUrl, staticApiUrl } = configuration;\n\n return (\n \n \n \n );\n};\n","import { getDebugLogger, getWarningLogger } from '@ori/checkout-utils';\nimport { Logger } from '@ori/logger';\n\nimport { APP_NAME, PACKAGE_NAME, TEAM_NAME } from './constants';\n\nexport const mainLogger = new Logger(PACKAGE_NAME, { teamName: TEAM_NAME });\n\nexport const logDebug = getDebugLogger(APP_NAME);\nexport const logWarning = getWarningLogger(APP_NAME);\n","/* istanbul ignore file */\nimport { UniversalTokenProvider, doDevelopmentLogin } from '@ori/auth';\nimport { parseClientAppConfig } from '@ori/client-app-config';\nimport { ApplicationInsights, getClientApplicationInsightsConfig, LoggerProvider, ErrorBoundary } from '@ori/logger';\nimport { createRoot } from 'react-dom/client';\n\nimport { App } from './App';\nimport { APP_NAME } from './constants';\nimport { logDebug, logWarning, mainLogger } from './logger';\nimport type { ClientAppConfig } from './types';\n\n/**\n * React app renderer that is used when app is used as a standalone app\n */\nexport const render = async (configElement: HTMLElement, rootElement: HTMLElement) => {\n const { innerText: config = '' } = configElement;\n const clientAppConfig = parseClientAppConfig(config, [\n 'currentLanguage',\n 'customerId',\n 'globalApiUrl',\n 'identityUrl',\n 'tenant',\n ]);\n logDebug('parsed configuration', clientAppConfig);\n const { customerId, identityUrl, tenant } = clientAppConfig;\n\n if (!identityUrl) {\n throw new Error('Missing Identity URL!');\n }\n\n // Get token for local development\n if (process.env.NODE_ENV !== 'production') {\n // when using Requestly we do not want to load token\n if (process.env.REACT_APP_USE_REQUESTLY === '1') {\n logDebug('USING REQUESTLY');\n } else {\n await doDevelopmentLogin({ identityUrl, tenant });\n }\n }\n\n // Initialize Application Insights in production\n if (process.env.NODE_ENV === 'production') {\n try {\n ApplicationInsights.initialize(getClientApplicationInsightsConfig());\n } catch (error: unknown) {\n logWarning('Error while setting up AI logger:', String(error));\n }\n }\n\n createRoot(rootElement).render(\n \n \n \n \n \n \n ,\n );\n};\n"],"names":["Name","CONTEXT_KEY","SCHEDULED_CLEANUP_KEY","isErrorResponse","response","isSuccess","isAddBackorderDemandErrorResponse","isAddBasketOfferErrorResponse","Method","isAddToBasketErrorResponse","isAddToBasketLoyaltyResponse","Boolean","loyaltyPoints","LoyaltyDialogResults","Results","BUY_FOR_MONEY","BUY_FOR_POINTS","isUpdateDeliveryErrorResponse","RequestUrl","convertToCamelCase","object","Array","isArray","map","constructor","Object","fromEntries","entries","key","value","camelCase","HttpHeader","ContentType","getHttpRequestSettings","data","method","HttpMethod","Get","headers","Json","body","placement","finalData","Placement","bodyValue","JSON","stringify","undefined","credentials","Post","async","addBasketOffer","url","params","fetch","json","AddBasketOfferFailed","event","CustomEvent","detail","window","dispatchEvent","APP_NAME","mainLogger","Logger","teamName","logDebug","getDebugLogger","logWarning","getWarningLogger","MISSING_PLACEMENT_MESSAGE","addToBasket","buyingMethod","itemCode","quantity","AddToBasketFailed","ShowLoyaltyDialog","lastAddedItem","deleteOfferItem","client","offerId","sessionId","tenant","deleteShoppingSessionOfferChoice","dispatchErrorEvent","errorEvent","ErrorEventName","putRequestOptions","shoppingContextActions","Map","AcceptNotification","failedEvent","AcceptNotificationFailed","handler","reasonId","isAcceptNotificationErrorResponse","AddBackorderDemand","AddBackorderDemandFailed","lineNumber","responseWithQuantity","UpdateBasketItem","dataWithQuantity","AddBasketOffer","items","isAddBasketOfferPurchaseEvent","choiceId","PurchaseBasketOffer","AddCatalogueOffer","AddCatalogueOfferFailed","request","dispatchAddCatalogueOfferFailedEvent","AddCustomerOrder","AddCustomerOrderFailed","orderIds","URL","location","href","forEach","id","searchParams","append","String","toString","lastAddedCustomerOrderIds","AddFreeShippingOffer","AddFreeShippingOfferFailed","dispatchAddFreeShippingOfferFailedEvent","AddPersonalNutritionItems","AddPersonalNutritionItemsFailed","globalShoppingPersonalNutritionComponentsDto","collection","updateShoppingSessionPersonalNutrition","addPersonalNutritionItems","error","message","localizedMessage","GetShoppingContext","rawData","isPersonalNutritionAddedAsLast","AddToBasket","originalItemCode","replacementType","addToBasketMethod","AddToBasketForMoney","AddToBasketForPointsRewardShop","AddToBasketCheckLoyalty","getBuyingUrlAndMethod","AddVoucher","AddVoucherFailed","voucherCode","fetchUrl","dispatchAddVoucherFailed","CancelBackorderDemand","CancelSubscription","CancelSubscriptionFailed","consumerId","packageId","subscriptionId","dispatchCancelSubscriptionFailedEvent","ClearBasket","DelaySubscription","DelaySubscriptionFailed","cycle","step","dispatchDelaySubscriptionFailedEvent","DeleteOfferItem","DeleteOfferItemFailed","isDeleteOfferItemErrorResponse","LoyaltyDialogResult","result","CLOSE","catalogueItemId","AddToBasketForPoints","RemoveBasketItem","RemoveBasketItemFailed","RemoveCustomerOrder","RemoveCustomerOrderFailed","endConsumerOrderId","RemoveVoucher","RemoveVoucherFailed","dispatchRemoveVoucherFailed","ReplaceShoppingBagItem","ReplaceShoppingBagItemFailed","ReplaceSubscription","ReplaceSubscriptionFailed","droppingId","customerId","globalCustomersSubscriptionItemDto","isReplacementAllowed","subscriptionItemId","updateCustomerSubscriptionSubscriptionItem","replaceSubscription","RequestShoppingContext","successEvent","ShoppingContextLoaded","ResetShippingSelection","ResetFreeShippingSelection","UpdateBasketItemFailed","isUpdateBasketItemErrorResponse","UpdateCustomerOrderItem","UpdateCustomerOrderItemFailed","requestedQuantity","UpdateDelivery","UpdateDeliveryFailed","deliveryAddressId","deliveryChannelId","registrationId","channelRequestOptions","channelResponse","UpdateDeliveryChannel","channelResponseData","addressParams","addressId","addressRequestOptions","addressResponse","UpdateDeliveryAddress","addressResponseData","UpdateDeliveryChannelFailed","requestOptions","isUpdateDeliveryChannelErrorResponse","UpdateDonation","UpdateDonationFailed","checked","isUpdateDonationFailedResponse","UpdateOfferItem","UpdateOfferItemFailed","globalShoppingOfferChoiceDtoBody","updateShoppingSessionOfferChoice","updateOfferItem","isUpdateOfferItemFailedResponse","UpdateOfferItems","UpdatePaymentProvider","UpdatePaymentProviderFailed","paymentProviderId","isUpdatePaymentProviderFailedResponse","DEFAULT_CONFIG","currentLanguage","NOT_LOGGED_IN_USER_ID","globalApiUrl","identityUrl","staticApiUrl","configurationContext","createContext","ConfigurationProvider","Provider","useConfiguration","useContext","StorageType","dispatchBasketUpdatedEvent","eventType","BasketUpdated","logReceivedEvent","type","getUserCheck","length","a","b","i","charCodeAt","adler32","cookieName","match","document","cookie","RegExp","getCookie","trim","isValidStorageTimestamp","timestamp","Date","now","childLogger","createChild","isStorageAvailable","isAvailable","indexedDB","SHOPPING_CONTEXT","db","getDb","openDB","upgrade","database","objectStoreNames","contains","createObjectStore","getStorageItem","get","savedTimestamp","userCheck","delete","action","setStorageItem","put","removeStorageItem","getStorage","localStorage","Promise","resolve","storage","getItem","parsedData","serializedData","parsedValue","parse","parseValue","Error","removeItem","setItem","pagePathPatterns","isReadyPromiseResolve","isReady","isBasketProviderReady","useBasketProviderData","globalApiClient","useApiClient","useToken","getCachedContext","useCallback","setCachedContext","clearCachedContext","isInitialShoppingContextApplied","setIsInitialShoppingContextApplied","useState","wasShoppingContextRequestedDuringInit","useRef","isRequestingShoppingContext","shoppingContext","setShoppingContext","shoppingSessionId","updateContext","eventTypeToBeTriggered","shouldStoreData","current","getStoredContext","clearContext","clearContextOnEvent","createEventListener","currentSettings","createRequestShoppingContextEventListener","triggerResponse","setTimeout","useEffect","eventListeners","triggerActionEventName","eventListenerFactory","push","eventName","eventListener","getEventListeners","PlaceOrderRequested","RequestClearShoppingCache","addEventListener","removeEventListener","applyInitialShoppingContext","useIndexedDbStorage","staticApiClient","ApiClient","baseUrl","language","isEnabled","getTenantFeatureToggle","getUseIndexedDbFeatureToggle","storageType","IndexedDb","LocalStorage","methods","isIndexedDbStorageAvailable","getIndexedDbStorageItem","setIndexedDbStorageItem","removeIndexedDbStorageItem","isLocalStorageAvailable","getLocalStorageItem","setLocalStorageItem","removeLocalStorageItem","getStorageMethods","isPageMarkedForCacheCleanup","isCleanupPage","some","item","pathname","includes","isScheduledCacheCleanup","useMemo","BasketProvider","ApiProvider","children","useServiceUrls","token","_jsx","ApiClientProvider","BasketProviderController","configuration","LoggerProvider","logger","ErrorBoundary","areaName","App","ServiceUrlsProvider","serviceUrls","PACKAGE_NAME","TEAM_NAME","render","configElement","rootElement","innerText","config","clientAppConfig","parseClientAppConfig","ApplicationInsights","initialize","getClientApplicationInsightsConfig","createRoot","UniversalTokenProvider","initialToken"],"sourceRoot":""}